Skip to content

Instantly share code, notes, and snippets.

@mattdeboard
Created September 3, 2014 03:20
Show Gist options
  • Save mattdeboard/123caa1b16fa4e35895c to your computer and use it in GitHub Desktop.
Save mattdeboard/123caa1b16fa4e35895c to your computer and use it in GitHub Desktop.
[1] Root ::= Body?
[2] Body ::= Line ( TERMINATOR Line | TERMINATOR )*
[3] Line ::= Expression
| Statement
[4] Statement
::= Return
| Comment
| STATEMENT
[5] Expression
::= Value
| Invocation
| Code
| Operation
| Assign
| If
| Try
| While
| For
| Switch
| Class
| Throw
[6] Block ::= INDENT OUTDENT
| INDENT Body OUTDENT
[7] Identifier
::= IDENTIFIER
[8] AlphaNumeric
::= NUMBER
| STRING
[9] Literal ::= AlphaNumeric
| JS
| REGEX
| DEBUGGER
| UNDEFINED
| NULL
| BOOL
[10] Assign ::= Assignable '=' Expression
| Assignable '=' TERMINATOR Expression
| Assignable '=' INDENT Expression OUTDENT
[11] AssignObj
::= ObjAssignable
| ObjAssignable ':' Expression
| ObjAssignable ':' INDENT Expression OUTDENT
| Comment
[12] ObjAssignable
::= Identifier
| AlphaNumeric
| ThisProperty
[13] Return ::= RETURN Expression
| RETURN
[14] Comment ::= HERECOMMENT
[15] Code ::= PARAM_START ParamList PARAM_END FuncGlyph Block
| FuncGlyph Block
[16] FuncGlyph
::= '->'
| '=>'
[17] OptComma ::= ','?
[18] ParamList
::= ( Param | ParamList ',' Param | ParamList OptComma TERMINATOR Param | ParamList OptComma INDENT ParamList OptComma OUTDENT )?
[19] Param ::= ParamVar
| ParamVar '...'
| ParamVar '=' Expression
[20] ParamVar ::= Identifier
| ThisProperty
| Array
| Object
[21] Splat ::= Expression '...'
[22] SimpleAssignable
::= Identifier
| Value Accessor
| Invocation Accessor
| ThisProperty
[23] Assignable
::= SimpleAssignable
| Array
| Object
[24] Value ::= Assignable
| Literal
| Parenthetical
| Range
| This
[25] Accessor ::= '.' Identifier
| '?.' Identifier
| '::' Identifier
| '?::' Identifier
| '::'
| INDEX_SOAK* INDEX_START IndexValue INDEX_END
[26] IndexValue
::= Expression
| Slice
[27] Object ::= '{' AssignList OptComma '}'
[28] AssignList
::= ( AssignObj | AssignList ',' AssignObj | AssignList OptComma TERMINATOR AssignObj | AssignList OptComma INDENT AssignList OptComma OUTDENT )?
[29] Class ::= CLASS
| CLASS Block
| CLASS EXTENDS Expression
| CLASS EXTENDS Expression Block
| CLASS SimpleAssignable
| CLASS SimpleAssignable Block
| CLASS SimpleAssignable EXTENDS Expression
| CLASS SimpleAssignable EXTENDS Expression Block
[30] Invocation
::= ( Value OptFuncExist Arguments | SUPER | SUPER Arguments ) ( OptFuncExist Arguments )*
[31] OptFuncExist
::= FUNC_EXIST?
[32] Arguments
::= CALL_START CALL_END
| CALL_START ArgList OptComma CALL_END
[33] This ::= THIS
| '@'
[34] ThisProperty
::= '@' Identifier
[35] Array ::= '[' ']'
| '[' ArgList OptComma ']'
[36] RangeDots
::= '..'
| '...'
[37] Range ::= '[' Expression RangeDots Expression ']'
[38] Slice ::= Expression RangeDots Expression
| Expression RangeDots
| RangeDots Expression
| RangeDots
[39] ArgList ::= Arg
| ArgList ',' Arg
| ArgList OptComma TERMINATOR Arg
| INDENT ArgList OptComma OUTDENT
| ArgList OptComma INDENT ArgList OptComma OUTDENT
[40] Arg ::= Expression
| Splat
[41] SimpleArgs
::= Expression ( ',' Expression )*
[42] Try ::= TRY Block
| TRY Block Catch
| TRY Block FINALLY Block
| TRY Block Catch FINALLY Block
[43] Catch ::= CATCH Identifier Block
| CATCH Object Block
| CATCH Block
[44] Throw ::= THROW Expression
[45] Parenthetical
::= '(' Body ')'
| '(' INDENT Body OUTDENT ')'
[46] WhileSource
::= WHILE Expression
| WHILE Expression WHEN Expression
| UNTIL Expression
| UNTIL Expression WHEN Expression
[47] While ::= WhileSource Block
| Statement WhileSource
| Expression WhileSource
| Loop
[48] Loop ::= LOOP Block
| LOOP Expression
[49] For ::= Statement ForBody
| Expression ForBody
| ForBody Block
[50] ForBody ::= FOR Range
| ForStart ForSource
[51] ForStart ::= FOR ForVariables
| FOR OWN ForVariables
[52] ForValue ::= Identifier
| ThisProperty
| Array
| Object
[53] ForVariables
::= ForValue
| ForValue ',' ForValue
[54] ForSource
::= FORIN Expression
| FOROF Expression
| FORIN Expression WHEN Expression
| FOROF Expression WHEN Expression
| FORIN Expression BY Expression
| FORIN Expression WHEN Expression BY Expression
| FORIN Expression BY Expression WHEN Expression
[55] Switch ::= SWITCH Expression INDENT Whens OUTDENT
| SWITCH Expression INDENT Whens ELSE Block OUTDENT
| SWITCH INDENT Whens OUTDENT
| SWITCH INDENT Whens ELSE Block OUTDENT
[56] Whens ::= When+
[57] When ::= LEADING_WHEN SimpleArgs Block
| LEADING_WHEN SimpleArgs Block TERMINATOR
[58] IfBlock ::= IF Expression Block ( ELSE IF Expression Block )*
[59] If ::= IfBlock
| IfBlock ELSE Block
| Statement POST_IF Expression
| Expression POST_IF Expression
[60] Operation
::= UNARY Expression
| '-' Expression
| '+' Expression
| '--' SimpleAssignable
| '++' SimpleAssignable
| SimpleAssignable '--'
| SimpleAssignable '++'
| Expression '?'
| Expression '+' Expression
| Expression '-' Expression
| Expression MATH Expression
| Expression SHIFT Expression
| Expression COMPARE Expression
| Expression LOGIC Expression
| Expression RELATION Expression
| SimpleAssignable COMPOUND_ASSIGN Expression
| SimpleAssignable COMPOUND_ASSIGN INDENT Expression OUTDENT
| SimpleAssignable COMPOUND_ASSIGN TERMINATOR Expression
| SimpleAssignable EXTENDS Expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment