-
Notifications
You must be signed in to change notification settings - Fork 2
Eppabasic BNF
henkkuli edited this page Sep 22, 2014
·
1 revision
This document defines the EppaBasic syntax. In this document, 'words in quotes' represent terminal symbols from the scanner while other words represent non-terminal symbols. Lines starting with # represent comments.
BaseLevelBlock ::= BaseLevelStatement 'newline' BaseLevelBlock
| BaseLevelStatement
Block ::= Statement 'newline' Block
| Statement
BaseLevelStatement ::= Statement
| FunctionDefinition
Statement ::= Comment
| VariableDefinition
| VariableAssignment
| BaseFunctionCall
| ForStatement
| IfStatement
| DoStatement
| ReturnStatement
Comment ::= 'comment'
VariableDefinition ::= 'dim' VariableReference 'as' 'identifier'
| 'dim' VariableReference 'as' 'identifier' 'eq' Expression
| 'dim' VariableReference 'eq' Expression
VariableAssignment ::= VariableReference 'eq' Expression
VariableReference ::= 'identifier'
| 'identifier' 'lbracket' ArgumentList 'rbracket'
BaseFunctionCall ::= FunctionCall
| 'identifier' ArgumentList
FunctionCall ::= 'identifier' 'lparen' ArgumentList 'rparen'
ForStatement ::= 'for' 'identifier' 'eq' Expression 'to' Expression 'newline' Block 'newline' 'next' 'identifier'
| 'for' 'identifier' 'eq' Expression 'to' Expression 'step' Expression 'newline' Block 'newline' 'next' 'identifier'
DoStatement ::= 'do' 'newline' Block 'newline' 'loop'
| 'do' 'while' Expression 'newline' Block 'newline' 'loop'
| 'do' 'until' Expression 'newline' Block 'newline' 'loop'
| 'do' 'newline' Block 'newline' 'loop' 'while' Expression
| 'do' 'newline' Block 'newline' 'loop' 'until' Expression
IfStatement ::= 'if' Expression 'then' Statement
| 'if' Expression 'then' 'newline' Block 'newline' ElseIfStatement 'newline' 'endif'
| 'if' Expression 'then' 'newline' Block 'newline' 'endif'
ElseIfStatement ::= 'elseif' Expression 'then' 'newline' Block 'newline' ElseIfStatement
|
ReturnStatement ::= 'return' Expression
ArgumentList ::= Expression 'comma' ArgumentList
| Expression
Expression ::= Expression1
Expression1 ::= Expression2 'or' Expression1
| Expression2 'and' Expression1
| Expression2 'xor' Expression1
| Expression2
Expression2 ::= Expression3 'eq' Expression2
| Expression3 'neq' Expression2
| Expression3 'lt' Expression2
| Expression3 'lte' Expression2
| Expression3 'gt' Expression2
| Expression3 'gte' Expression2
| Expression3
Expression3 ::= Expression4 'concat' Expression 3
| Expression4
Expression4 ::= Expression5 'plus' Expression4
| Expression5 'minus' Expression4
| Expression5
Expression5 ::= Expression6 'mul' Expression5
| Expression6 'div' Expression5
| Expression6 'idiv' Expression5
| Expression6 'mod Expression5
| Expression6 'pow' Expression5
| Expression6
Expression6 ::= 'lparen' Expression1 'rparen'
| 'minus' Expression6
| 'not' Expression1
| 'number'
| 'string'
| VariableReference
| FunctionCall