Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here are the instructions for creating a syntax diagram.</p> <p>The content of <a href="https://github.com/jashkenas/coffee-script/blob/master/src/grammar.coffee" rel="noreferrer">grammar.coffee</a> is executable code, which must be run for getting the actual Jison grammar. I used the <a href="http://jashkenas.github.com/coffee-script/" rel="noreferrer">Try CoffeeScript</a> page to compile it, after having replaced the Jison call by a Javascript alert. Then ran the resulting Javascript to obtain the grammar, which looks like this:</p> <pre><code>{ "tokens":" TERMINATOR TERMINATOR TERMINATOR STATEMENT INDENT OUTDENT INDENT OUTDENT IDENTIFIER NUMBER STRING JS REGEX BOOL = = INDENT OUTDENT : : INDENT OUTDENT RETURN RETURN HERECOMMENT PARAM_START PARAM_END -&gt; =&gt; , , ... = ... . ?. :: :: INDEX_START INDEX_END INDEX_SOAK { } , TERMINATOR INDENT OUTDENT CLASS CLASS CLASS EXTENDS CLASS EXTENDS CLASS CLASS CLASS EXTENDS CLASS EXTENDS SUPER SUPER FUNC_EXIST CALL_START CALL_END CALL_START CALL_END THIS @ @ [ ] [ ] .. ... [ ] , TERMINATOR INDENT OUTDENT INDENT OUTDENT , TRY TRY TRY FINALLY TRY FINALLY CATCH THROW ( ) ( INDENT OUTDENT ) WHILE WHILE WHEN UNTIL UNTIL WHEN LOOP LOOP FOR FOR FOR OWN , FORIN FOROF FORIN WHEN FOROF WHEN FORIN BY FORIN WHEN BY FORIN BY WHEN SWITCH INDENT OUTDENT SWITCH INDENT ELSE OUTDENT SWITCH INDENT OUTDENT SWITCH INDENT ELSE OUTDENT LEADING_WHEN LEADING_WHEN TERMINATOR IF ELSE IF ELSE POST_IF POST_IF UNARY - + -- ++ -- ++ ? + - MATH SHIFT COMPARE LOGIC RELATION COMPOUND_ASSIGN COMPOUND_ASSIGN INDENT OUTDENT EXTENDS", "bnf": { "Root": [ ["","return $$ = new yy.Block;",null], ["Body","return $$ = $1;",null], ["Block TERMINATOR","return $$ = $1;",null] ], "Body": [ ["Line","$$ = yy.Block.wrap([$1]);",null], ["Body TERMINATOR Line","$$ = $1.push($3);",null], ["Body TERMINATOR","$$ = $1;",null] ], "Line": [ ["Expression","$$ = $1;",null], ["Statement","$$ = $1;",null] ], ... </code></pre> <p>The above can be fed to the <a href="http://bottlecaps.de/convert/" rel="noreferrer">Jison-to-W3C grammar converter</a>, resulting in a grammar like this:</p> <pre><code>Root ::= ( Body | Block TERMINATOR )? Body ::= Line ( TERMINATOR Line | TERMINATOR )* Line ::= Expression | Statement ... </code></pre> <p>From here we can have the <a href="http://bottlecaps.de/rr/ui" rel="noreferrer">Railroad Diagram Generator</a> create a syntax diagram:</p> <p><img src="https://i.stack.imgur.com/bnXkR.png" alt="CoffeeScript Syntax Diagram"></p> <p>. . .</p> <p>Note that the converter only evaluates the "bnf" part of the grammar, so it does not take the token definitions into account. This could be improved by doing some manual postprocessing of the W3C-style grammar.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload