AddyScript Grammar
Here is the complete grammar for the AddyScript programming language, represented using railroad diagrams and Extended Backus-Naur Form (EBNF) notation.
Axiom
Program:
Non-terminal symbols
StatementWithLabels:
Label:
Statement:
Statement ::= ImportDirective
| ClassDefinition
| FunctionDecl
| ExternalFunctionDecl
| ConstantDecl
| VariableDecl
| Block
| IfElse
| SwitchBlock
| ForLoop
| ForEachLoop
| WhileLoop
| DoLoop
| Continue
| Break
| Goto
| Yield
| Return
| Throw
| TryCatchFinally
| AssignmentWithLet
| Expression ';'
ImportDirective:
QualifiedName:
ClassDefinition:
ClassDefinition ::= Attributes? MODIFIER? 'class' IDENTIFIER ( ':' IDENTIFIER )? '{' ClassMember* '}'
Attributes:
Attribute:
ClassMember:
MemberPrefix:
MemberSpec:
ConstructorSpec:
ParameterList:
Parameter:
Literal:
Literal ::= 'null'
| BOOLEAN
| INTEGER
| BIG_INTEGER
| FLOAT
| BIG_DECIMAL
| COMPLEX
| DATE
| STRING
| BLOB
FieldSpec:
PropertySpec:
PropertySpec ::= 'property' ( IDENTIFIER | '[]' ) (
( '=>' Expression )? ';'
|
'{' SCOPE? (
'read' ( MethodBody SCOPE? 'write' )?
|
'write' ( MethodBody SCOPE? 'read' )?
) MethodBody '}'
)
MethodBody:
MethodSpec:
OperatorSpec:
OverloadableOperator:
OverloadableOperator ::= '+'
| '-'
| '++'
| '--'
| '~'
| '*'
| '/'
| '%'
| '#### '
| '&'
| '|'
| '^'
| '<<'
| '>>'
| '=='
| '!='
| '<'
| '>'
| '<='
| '>='
| 'startswith'
| 'endswith'
| 'contains'
| 'matches'
EventSpec:
FunctionDecl:
FunctionBody:
ExternalFunctionDecl:
VariableSetterList:
VariableSetter:
ConstantDecl:
VariableDecl:
Block:
IfElse:
SwitchBlock:
SwitchBlock ::= 'switch' '(' Expression ')' '{' ( CaseLabel ':' StatementWithLabels* )* ( 'default' ':' StatementWithLabels* )? '}'
CaseLabel:
ForLoop:
ForLoop ::= 'for' '(' ( VariableDecl | ExpressionList )? ';' Expression? ';' ExpressionList? ')' Statement
ExpressionList:
ForEachLoop:
WhileLoop:
DoLoop:
Continue:
Break:
Goto:
Yield:
Return:
Throw:
TryCatchFinally:
TryCatchFinally ::= 'try' ( '(' Expression ')' )? Block ( 'catch' '(' IDENTIFIER ')' Block )? ( 'finally' Block )?
AssignmentWithLet:
Reference:
Reference ::= VariableRef
| ItemRef
| SliceRef
| PropertyRef
| StaticPropertyRef
| ParentPropertyRef
| ParentIndexerRef
| TupleInitializer
| SetInitializer
Expression:
Note: Expression is an axiom to the expressions sublanguage (which is recognized by the ExpressionParser).
Assignment:
AssignmentOperator:
AssignmentOperator ::= '='
| '+='
| '-='
| '*='
| '/='
| '%='
| '#### ='
| '&='
| '|='
| '^='
| '<<='
| '>>='
| '??='
TernaryExpression:
Condition:
LogicalOperator:
Relation:
RelationalOperator:
RelationalOperator ::= '=='
| '!='
| '<'
| '>'
| '<='
| '>='
| '==='
| '!=='
| 'startswith'
| 'endswith'
| 'contains'
| 'matches'
| 'not'? 'in'
Term:
Factor:
Exponentiation:
PostfixUnaryExpression:
PrefixUnaryExpression:
Composite:
Composite ::= Atom ( '[' ( Expression | Expression? '..' Expression? ) ']' | '.' IDENTIFIER ArgumentList? | ArgumentList | ( 'switch' '{' MatchCaseList | 'with' '{' VariableSetterList ) '}' )*
ArgumentList:
Arguments:
Argument:
NamedArgList:
NamedArg:
MatchCaseList:
MatchCase:
Pattern:
Pattern ::= '_'
| 'null'
| ( '>' | '<' | '>=' | '<=' )? ValuePattern
| 'matches' STRING
| TYPE_NAME ( '(' IDENTIFIER ( ',' IDENTIFIER )* ')' | ObjectPattern )?
| ObjectPattern
| NegativePattern
| LogicalPattern
| GroupingPattern
| MUTABLE_STRING
ValuePattern:
ObjectPattern:
NegativePattern:
LogicalPattern:
GroupingPattern:
MatchCaseExpression:
Atom:
Atom ::= Literal
| MUTABLE_STRING
| 'this'
| AtomStartingWithSuper
| AtomStartingWithTypeOf
| AtomStartingWithTypeName
| AtomStartingWithId
| AtomStartingWithNew
| AtomStartingWithLParen
| AtomStartingWithLBrace
| ListInitializer
| Lambda
| InlineFunction
AtomStartingWithSuper:
AtomStartingWithTypeOf:
AtomStartingWithTypeName:
AtomStartingWithId:
AtomStartingWithNew:
ObjectInitializer:
ConstructorCall:
ConstructorCall ::= 'new' QualifiedName ( ArgumentList ( '{' VariableSetterList? '}' )? | '{' VariableSetterList? '}' )
AtomStartingWithLParen:
Conversion:
TupleInitializer:
ParenthesizedExpression:
AtomStartingWithLBrace:
SetInitializer:
MapInitializer:
MapItemInitializerList:
MapItemInitializer:
ListInitializer:
Lambda:
InlineFunction:
Terminal symbols
LETTER:
LETTER_EXTENDED:
DIGIT:
HEXDIGIT:
IDENTIFIER:
STANDARD_IDENTIFIER:
SPECIAL_IDENTIFIER:
ESCAPE_SEQ:
ESCAPE_SEQ ::= '\a'
| '\b'
| '\f'
| '\n'
| '\r'
| '\t'
| '\v'
| ( '\x' | '\u' HEXDIGIT HEXDIGIT ) HEXDIGIT HEXDIGIT
BOOLEAN:
INTEGER:
DECIMAL_INTEGER:
HEX_INTEGER:
BIG_INTEGER:
REAL:
REAL ::= ( DECIMAL_INTEGER? '.' )? DECIMAL_INTEGER ( ( 'e' | 'E' ) ( '+' | '-' )? DECIMAL_INTEGER )?
FLOAT:
BIG_DECIMAL:
COMPLEX:
DATE:
MUTABLE_STRING:
STRING:
BLOB:
SINGLE_QUOTED:
DOUBLE_QUOTED:
TYPE_NAME:
TYPE_NAME ::= 'void'
| 'bool'
| 'int'
| 'long'
| 'rational'
| 'float'
| 'decimal'
| 'complex'
| 'date'
| 'duration'
| 'string'
| 'list'
| 'map'
| 'set'
| 'queue'
| 'stack'
| 'object'
| 'resource'
| 'closure'
MODIFIER:
SCOPE:
generated by RR - Railroad Diagram Generator