Coder Social home page Coder Social logo

dogescript / dogescript Goto Github PK

View Code? Open in Web Editor NEW
1.3K 1.3K 93.0 2.38 MB

wow so syntax very doge much future

Home Page: http://dogescript.io

License: MIT License

JavaScript 87.58% Dogescript 10.90% HTML 1.15% Dockerfile 0.22% Shell 0.12% Procfile 0.02%

dogescript's Introduction

dogescript

dogescript

NPM version Build Status Dependency Status devDependency Status

This is an implementation of the best new compile-to-JS language, dogescript. Wow.

And yes, I am very aware I went about a very, er, non-conventional, way of parsing a language, and is probably riddled with bugs and edge-cases. However, this is dogescript, so anything goes!

    wow
         such dogescript
     very compiled
                  next-generation
       npm wow

Installation

npm install -g dogescript

Usage

Command Line

dogescript without a file launches a REPL.

dogescript location/to/dogescript.djs pipes the result to stdout. Use a command like dogescript dogescript.djs > compiled.js to save to a file.

Options:

  • --beautify - Runs the code through a beautifier.
  • --true-doge - Implements "true doge" mode, which splits lines by 3 spaces, instead of by newlines. This stays behind a flag until the spacing it exports is identical to non-true-doge mode. Deprecated in 2.4.0, to be removed in 3.0.0
  • --run - Runs the dogescript code

Javascript

dogescript(file, beauty, trueDoge)

  • file - A string of Dogescript.
  • beauty - A boolean, set to true if you want the output to be ran through a beautifier.
  • trueDoge - A boolean, set to true if you want to enable true-doge mode. Deprecated in 2.4.0, to be removed in 3.0.0

REPL Commands

  • .plz-load [path_to_doge]: loads dogescript code in the given file and adds it to the REPL environment. For this example, iota is a function that produces a series from 0 to n, ie: iota 5 => [0,1,2,3,4], and is defined in repl-test/iota.djs.
  • .plz-exit: exits the REPL environment and terminates the process. An alternative to .exit.

iota.djs

such iota much n
  very series is Array dose apply with null {length:n}&
  dose map with Number.call Number
wow series

Loaded and execute

DOGE> .plz-load repl-test/iota.djs
DOGE> undefined
DOGE> plz iota with 5
[ 0, 1, 2, 3, 4 ]
DOGE>

Language documentation

Projects using dogescript

Utilities

Syntax highlighting

Build plugins

Contributors

Dogescript was originally created by Zach Bruggeman, and is now maintained by the @dogescript/core team. Thank you to every contributor who's helped along the way!

$ git log --format='%aN' | sort -u
Alistair Mersereau
Bart van der Schoor
Bartvds
Ben Atkin
Cassidy Bridges
Chad Engler
Chris Wheatley
Christina Liu
Daniel Lockhart
Elan Shanker
Erik Erwitt
Jacob Groundwater
Jan Monterrubio (AnEmortalKid)
Joe Dailey
Johann Philipp Strathausen
Joseph Dailey
Mario Nachbaur
Nicholas Scheurich
Patrick Piemonte
Peter Carnesciali
Ray Toal
Zach Bruggeman
achesak
alehander42
alistair.mersereau
dogejs
jasdev
noformnocontent

Community

Join us at dogescript.slack.com. Since it is slack, you'll need an invite to the channel. Visit this site to get invited. The invite site is built with slack-invite-automation and is deployed to heroku. Since we are on the free tier, dyno's take a bit to load so give it at least 30 seconds to load the first time.

dogescript's People

Contributors

alehander92 avatar alistairyves avatar anemortalkid avatar bartvds avatar benatkin avatar dependabot[bot] avatar dogejs avatar eerwitt avatar englercj avatar es128 avatar groundwater avatar joedailey avatar joeratt avatar marionauta avatar ngscheurich avatar pcarn avatar pholey avatar remixz avatar rtoal avatar strathausen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dogescript's Issues

Anonymous function assignment

Hey I can't seem to do this:

var foo = function() {
};

I would have thought something like this would have worked:

very foo is much
wow

Add test suite

Since the language is evolving again it could be time to add a test suite where we can add cases to make sure the compiler follows the spec and we don't create regressions.

If you agree this is a good idea then I offer to set something up using for example grunt, mocha and chai.

It'd be something dynamic to make it is easy to add new cases (eg: file based) (been there, done that).

And of course we then link it to Travis-CI (free for OSS) so Github can test on Pull Requests and Merges.

throw / try / catch / finally

There must be a good doge version of these right? Doge love ball games!

Like:

ready
    throw new Error with 'much error'
catch err
    plz console.loge err
retrieve
    plz fix

new Thing()

such doge
very convenient

am I doing it wrong or does doge not know this?

regex is new RegExp with "doge", "g"

=>

regex = new RegExp("doge", "g")

such difficulty

Add licence

It would really help me as I want to create a fork with some simple keyword replacement to create "santascript" for a christmas-themed app thing we're doing at work! If it's not something you're personally bothered with MIT would be perfect!

Future of Dogescript

Hi all! I just wanted to talk about a potential future of Dogescript.

Dogescript has matured a lot since it started, and just recently has seen a surge in activity thanks to awesome community materials being made, and the creation of DSON. There's been some exciting work started as well by @pholey, who is working on rewriting Dogescript to use a lexer written in... Dogescript! ๐Ÿ˜„ It's early on still, but it could be really cool. I've been thinking about the future of Dogescript, and here is my proposal:

Dogescript 2.4.0

I'd like to do a 2.4.0 release, which would still be written in the current crazy JS that it is. This release would be an opportunity to create a nice stable base for Dogescript 3.0.0 (see next section). I'd like to add some features that would be helpful for @pholey in writing a parser with Dogescript. Maybe the current language is good enough, but I'm sure there could be something. As well, I'd like to fix some of the bugs and edge cases, just so there can be less hacks. If there any features you'd like to see in Dogescript, please comment them here. When 2.4.0 is released, any feature development for Dogescript will be frozen.

Dogescript 3.0.0

3.0! This release could be characterized by two things: a parser rewrite, and native DSON support. I say could, as either of these may be too much of a long shot. I think they could happen though. (@pholey not to put any pressure on you!) For a parser rewrite, Dogescript 3.0.0 would be compiled with the stabilized 2.4.0. For DSON support, it would likely integrate DSON.djs, and import it as a global variable, similar to JSON. This is all pretty loose though, so any feedback is welcome.

Community

The Dogescript community is, while small, still pretty awesome. One thing I'd like to do is add some more contributors to this repo. If you've written something cool in Dogescript, written documentation, etc., please leave a comment here, or get in touch with me ([email protected]). I wouldn't really be asking you to do anything specifically, but it would be just helping out with the repo. (merging PRs that you think are good, developing features, collecting resources, creating new resources, etc) I've done my best to do this myself, but I'm not always around to do so. If there's more of us, maybe we can catch even more cool stuff!

As well, I'm wondering if there should be more of a hub for Dogescript. The current site is very... bland, so it might be nice if there was a proper website. Maybe a blog? (GH-36) This does make Dogescript seem bigger than it actually is, but from what I can tell, there's actually a decent amount of Dogescript projects, just no place to collect them.

As always, if you have any feedback, questions, or whatever, leave them here!

functions as variable for other functions

such problem

if I have a function with a return value:

such test much number
    very result is number * number
wow result

I can't call it direcly like

plz console.loge with plz test with 5

nor

plz console.loge with (plz test with 5)

more natural dogespeak possible?

I tried writing a little Mocha spec in dogescript 1.0.0:

plz describe with 'suchFunction' much
  plz it with 'does thing' much done
    plz suchFunction with done
  wow
wow

Now lambdas are in, it's possible to write reasonably nice specs, but I think it'd look much code if it were possible to move the with keyword around. Take a look at this:

plz describe 'suchFunction' with much
  plz it 'does thing' with much done
    plz suchFunction with done
  wow
wow

Would permitting the above syntax introduce too much ambiguity in the parser?

Cannot install v2.1.0

I cannot install v2.1.0 from npm, the url to the install archive is 404.

npm http GET https://registry.npmjs.org/dogescript
npm http 200 https://registry.npmjs.org/dogescript
npm http GET https://registry.npmjs.org/dogescript/-/dogescript-2.1.0.tgz
npm http 404 https://registry.npmjs.org/dogescript/-/dogescript-2.1.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/dogescript/-/dogescript-2.1.0.tgz
npm ERR! Error: 404 Not Found
...
npm ERR! not ok code 0

Could be npm is messed-up, it happens a lot these days.

Support Dogescript syntax highlighting on the web

Since Dogescript is getting famous we might as well support it's syntax highlighting on the web. ๐Ÿ•

This issue is a brainstorm until someone actually does the job.
I'm up for it but I could take a week or two.

I will do it on GeSHi but since there are several highlighting systems around, someone could tackle a different one.


Pygments is the default highlighter on Jekyll websites and fairly used on Wordpress plugins.
It is made in Python but is unfortunately hosted on Bitbucket as a Mercurial repository. I have no experience in neither of these tools so... yeah.
They do have a guide on implementing custom Lexers and we could always inherit the Javascript highlight.


GeSHi is a PHP highlighter, greatly used on Wordpress plugins, Wikipedia's official one (MediaWiki) and phpBB.
It used to be on Sourceforge but has moved to GitHub.
It is very easy to add a new language, just assign variables like this. I couldn't figure out how to actually include them, since the official page tells to email the owner while the GitHub repos have pull requests waiting for a few months.


Our beloved Dogescript Live page uses CodeMirror, a neat in-browser editor. It does a fairly strange job of reinventing the wheel - implementing it's own language modes.
It's written in Javascript, uses Git on GitHub.
If anybody wants to have a Dogescript syntax on our live page, they have a guide and the Javascript mode is a great place to start.


highlight.js is an alternative for GitHub Pages/Jekyll.
It's very easy to add languages to it - simply create a Javascript object with the keywords. Here's a simple example of someone adding the Jade language on their GitHub.
One thing that I didn't liked, though, is that there are pull requests from last year still waiting to be merged. I hope it doesn't happen with Dogescript since our language is TEH BEST!!!11!!one!!11

so commas in strings

Commas are inserted into string literals used as function arguments. For example:

plz console.log with "such bug\nso annoy"

Produces:

console.log("such, bug\nso, annoy");

String literals shouldn't be altered in any way by the compilation process. (Unless a feature such as interpolation is added.)

Add browserified dist files

Pre-bundle browser versions, as per #91

/dist/dogescript.js
/dist/dogescript.min.js

Should probably be a npm 'build' script:

npm run build

Once both this and #91 lands we can add dogescript to bower and http://cdnjs.com/

such restrict syntax

How might we do something like this, (from Meteor):

Template.shibes.helpers({
   doge: function(type) {
       return "is a " + type + " shibe";
   },
   cate: "is not a shibe";
});

Unable to return a value with wow&

Example code shows that to return a variable from a function, you use wow [variable name]. To end an anonymous function that is an argument, you need to use wow&.

However, this doesn't work when trying to return from a function passed as an argument:

plz angular.module with 'MyApp.Directives'&
.plz directive with 'myDirective' much $rootScope
wow& {restrict: 'A', replace: 'true', templateUrl: 'my_directive.html'}

This generates the following JavaScript:

angular.module('MyApp.Directives')
    .directive('myDirective', function($rootScope) {})

The expected output should be:

angular.module('MyApp.Directives')
    .directive('myDirective', function($rootScope) {
        return {
            restrict: 'A',
            replace: true,
            templateUrl: 'my_directive.html'
        };
});

This is preventing us from transitioning our Angular.js application to DogeScript.

DSON + Dogescript

I've just started writing a DSON (http://dogeon.org) parser in Dogescript, because I'm a little bit insane. https://github.com/remixz/DSON.djs.

I like the idea of having better object support in Dogescript, though the current DSON spec interferes a lot of the Dogescript keywords, so it'd have to be modified a bit. I'm wondering if anyone had thoughts on whether or not DSON should be part of Dogescript?

doge return

here's the script

plz numbers.map with soNumbers

such soNumbers much num
    return num + 1
wow

can we have doge return things? perhaps something like

such soNumbers much num
wow num + 1

โ“

cc/ @maxogden

such squat

I got http://twitter.com/dogescript because I saw it was unregistered and thought someone even worse about using names than me might get it. What should I do with it? Ideas so far:

  • Hand it over to @remixz
  • Hand it over to @doge_js
  • Try to maintain it myself
  • ?

doge regexp

following up #4

very regex is new RegExp with keyword, "g"
=> var regex = new RegExp(keyword,, "g");

very regex is new RegExp with 'doge','g'
=> var regex = new RegExp('doge', ,'g');

notice the space & , in between things passed in

๐Ÿฉ

such no loops

wow
            very linear
    so recursion only

  much simple

         do want

Change "loge" to something else

console.loge, and loge are not very doge like!

I'd suggest arf or woof

Also, another suggestion i have is migrating to something similar to CoffeeScript or LiveScript; where code may be easier to maintain.

doge operators

๐Ÿ˜ข

want

very dogePoem is catzPoem.replace with 'catz', 'doge'

for

var dogePoem = catzPoem.replace('catz', 'doge')

require -> so

maybe have require() be so, e.g.

so request
so underscore
so lodash

I guess this have to be a node-only feature

chained method support

i'm trying to rewrite this in dogescript: http://bl.ocks.org/mbostock/7280327

ran into a snag, though, for:

var canvas = d3.select("body").append("canvas")
    .attr("width", width)
    .attr("height", height);

here's the closest I could get with dogescript:

very canvas is plz d3.select with 'body'
  .plz append with 'canvas'
  .plz attr with 'width' width
  .plz attr with 'height' height

if you remove the semicolon it would work. there are probably other solutions too

Chaining issue with lambdas - and incorrect HTTP server example

The chaining syntax doesn't seem to work on lambdas. wow& translates to a literal wow & instead of a } followed by the next call.

This leads to a problem with the HTTP server example, and one that is partially my fault. When providing the example in #11 I forgot to check whether it was actually the correct implementation of Node's "hello world". Which it isn't.

There needs to be a call to .listen() on the return value from .createServer(), which would look like this in JS:

http.createServer(function(req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('so hello\nmuch world');
}).listen(8000);

There's no such listen() call in the example given. In addition, I don't seem to be able to add one. I imagine it'd look like this in dogescript:

so http
plz http.createServer with much req res
   plz req.writeHead with 200 {'Content-Type': 'text/plain'}
   plz req.end with 'so hello\nmuch world'
wow&
.plz listen with 8000

As noted above, wow& doesn't work as chaining syntax, so the example still won't work in the form given above.

is conflict

is is currently being used in dogescript for both assignment and as a comparator. It works, but aside from the potential for confusion and bugs, another side effect of this is the way it's implemented causes all the operators to be very restricted in their usage.

For example, index more 1, which should compile to index += 1, doesn't work.

I suggest the assignment form of is be renamed to as (which is already somewhat implemented), and the operators be made universally available. This will facilitate the addition of also for , and a global removal of the.

An alternative would be renaming the comparator is to same.

Doge-like indentation

Guys, splendid!

However, don't you feel that it would be more doge-spirit, if there's a true doge indentation mode, kinda like the ascii art:

code          more code
         wow an indented code just because dogz
  many yea
             python lol

It can be used within a true-doge block of code, or something

Added script tag capability

I hacked a simple implementation that can parse script tags with 'text/dogescript' type... because.. I don't know.. ๐Ÿ˜„

Can be both inline and external script:

<script type="text/dogescript" src="doge.djs">
<script type="text/dogescript">
plz console.loge with 'wow script'
</script>

I pushed it here: https://github.com/dogescript/dogescript/tree/inline

But I'm not sure how to finalise this, some issues:

  1. For now I put it in index.js so it can be browserified, is that right?
  2. Currently we don't have pre-build browserified dists in the repo yet (like dist/dogescript.js and dist/dogescript.min.js)
  3. Browserify will diligently include jsbeautify but I'm not sure if it is needed (not that big a deal really).

Deprecate "true doge" mode

True doge mode was never implemented fully, and has been behind a flag for a while. While the idea of it was kind of cool, I don't think it's very practical.

Deprecating in 2.4.0, removing in 3.0.0.

Compiler

djs file compile to js file! :)

wow. such ideas

much punctuation
so yuck
wow

"from" for object properties
prop from obj -> obj.prop

"bone from" for class properties/methods
method bone from klass -> klass.prototype.method

"number" or "levl" (or something like that) for array and object lookups
ary number 1 -> ary[0] // -1 from ints, doge count from 1
ary levl i -> ary[i]
obj levl prop -> obj[prop]

"pack" for array definition
ary is pack -> ary = []
pack 1 two 'three' -> [1, two, 'three']

"pares" for object definition
obj is pares -> obj = {}
pares one 1 two 2 three 3 -> {'one': 1, 'two': 2, 'three': 3}

"the" allowed anywhere and parsed out
the name from cat from the alley is 'dogefood' -> alley.cat.name = 'dogefood'

I'd be happy to implement any/all of these. Just let me know which ones you like and if you think of any better terms/spellings.

no lambda not wow

Right now, dogescript has no anonymous functions (or, if it does, they aren't in the example and I couldn't find them anywhere). All functions used therefore have to be named and defined separately from use, which means the Node.js "hello world!" example must be written something like this:

so http

such handler much req res
   plz req.writeHead with 200 {"Content-Type": 'text/plain'}
   plz req.end with "so hello\nmuch world"
wow

plz http.createServer with handler

I suggest making much the keyword for all functions, used either as part of such functionname much arg arg or simply as an expression much arg arg which denotes the start of a function. This would lead to an implementation of "Hello world!" like this:

so http

plz http.createServer with much req res
   plz req.writeHead with 200 {"Content-Type": 'text/plain'}
   plz req.end with "so hello\nmuch world"
wow

This to me still scans as reasonable dogespeak and works fine for the most common callback pattern (a single callback as the last argument to the function).

The only problem I see with this proposal is that argumentless lambdas look a little odd:

plz soHigherOrderFunction with much
   plz veryInnerFunction
wow

Thoughts?

Spec improvements

I'm currently toying with writing a JS to doge converter, and there are some parts of the spec that have fallen down a little.

Obviously everyone wants dogescript to be taken seriously, we all want much enterprise and very develop, so I think some parts of the spec should be changed.

semicolons: converting from JS to doge results in a whole lot of 'next's'.

parentheses: How should the be handled? leave as is, or maybe a more readable string similar to 'many'.

Also it would be nice if dogescript preferred arbitrary spacing between statements, eg:

such doge much woof
                                         console.loge with woof
              wow

Rewrite of dogescript?

Instead of writing and submitting a pull request, i decided to ask first:

I have experience with writing lexers and parsers, and i was planning on writing an actual parser for dogescript (then a parser of dogescript in dogescript), though this would require basically rewriting the whole parser. I wanted to inquire whether or not this would be acceptable as i know many people have spent a fair amount of time on this project, and most of their work would be rewritten

I will continue to work on my own fork regardless (i enjoy writing languages), however i would love it if the official dogescript had a really nice parser.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.