goatee-script.js

Dependency Status

     _______  _______  _______  _______  _______  _______
    |    ___||       ||       ||_     _||    ___||    ___|
    |   | __ |   _   ||   _   |  |   |  |   |___ |   |___
    |   ||  ||  |_|  ||  |_|  |  |   |  |    ___||    ___|
    |   |_| ||       ||   _   |  |   |  |   |___ |   |___
    |_______||_______||__| |__|  |___|  |_______||_______|
                                     . ,
                                     (\\
                                  .--, \\__
                                   `-.     *`-.__
                                     |          ')
                                    / \__.-'-, ~;
                                   /     |   { /
                    ._..,-.-"``~"-'      ;    (
                 .;'                    ;'    ´
            ~;,./                      ;'
               ';                     ;'
                ';                 /;'|
                 |    .;._.,;';\   |  |
                 \   /  /       \  |\ |
                  \ || |         | )| )
                  | || |         | || |
            ~~~~~ | \| \  ~~~~~~ | \| \  ~~~~~~~
            "''"' `##`##' "'"''" `##`##' '"''"'"
            '"'"''"'"''"''"''"'"'''"'"'''"''"'"'
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       _______  _______  ______    ___  _______  _______
      |  _____||     __||    _ |  |   ||    _  ||_     _|
      | |_____ |    |   |   |_||_ |   ||   |_| |  |   |
      |_____  ||    |   |    __  ||   ||    ___|  |   |
       _____| ||    |__ |   |  | ||   ||   |      |   |
      |_______||_______||___|  |_||___||___|      |___|

A goatee is the perfect complement for handlebar mustaches. :-{>~

Objective

GoateeScript provides an unique language that is implemented in, modelled after and compiled to “ordinary” javascript. Sounds complicated ? It isn’t ! Look at the following example:

Javascript:

(function() { var test = 1 + 2 * 3 ; return test })();

Coffeescript:

do -> test = 1 + 2 * 3

Goateescript:

test = 1 + 2 * 3

All three examples are equivalent and return the number 7.

As goatee.js provides attributes to map data into markup, I decided the best way to go would be a language that is compact, readable and (the most important feature) has a scope consisting of a chain of contexts. Still confused ? Believe me, the haze will be lifted, once the framework has reached a state where it is useable. For the time beeing there is a command-line interpreter to prove my concept.

See:

Javascript – the source and destination

The rule of thumb is: a goateescript is a single javascript expression without any declarations or a collection of expressions suiteable to fit into a single line. The last expression’s value is always returned to the invoking context.

Similarities to javascript

Differences to javascript

Installation

$ npm install -g goatee-script.js

Usage

$ goatee-script -h

Usage: goatee-script [statements]... [options]

statements     string passed from the command line to evaluate

Options:
   -r STATEMENT, --run STATEMENT   string passed from the command line to
                                   evaluate
   -h, --help                      display this help message
   -i, --interactive               run an interactive `goatee-script` read-
                                   execute-print-loop (repl)
   -m MODE, --mode MODE            [c]ompile, [e]valuate, [p]rint, [r]ender
                                   or [s]tringify statements, default:  [eval]
   -c, --compress                  compress the abstract syntax tree (ast)
   --nodejs OPTION                 pass one option directly to the 'node'
                                   binary, repeat for muliple options
   -v, --version                   display the version number and exit

If called without options, `goatee-script` will run interactive.

Documentation

Read the annotated sources.

Development

Install dependencies …

Run build …

$ npm run build && npm run test && npm run doc

(not tested yet)

Credits go to …