Skip to content

Grammar specification

Rodri Pizarro edited this page Oct 19, 2020 · 6 revisions
PROGRAM:
INSTRUCTION
INSTRUCTION PROGRAM
INSTRUCTION:
EOE
ASSIGNATION EOE
EXECUTION EOE
DEFINITION
FOR_STATEMENT
IF_STATEMENT

EOE: ';'

ASSIGNATION:
DATA_TYPE NAME '=' VALUE
NAME '=' VALUE
NAME '++'
NAME '--'
EXECUTION:
NAME '(' ARRAY ')'
NAME '.' NAME '(' ARRAY ')'
DEFINITION:
DATA_TYPE NAME EOE
DATA_TYPE NAME '(' ARGUMENT_DEFINITION ')' '{' FUNCTION '}'

FOR_STATEMENT: 'for' '(' ASSIGNATION EOE BOOLEAN_OPERATION EOE ASSIGNATION ')' '{' SCOPE '}'

IF_STATEMENT:
'if' '(' BOOLEAN_OPERATION ')' '{' SCOPE '}'
'if' '(' BOOLEAN_OPERATION ')' '{' SCOPE '}' 'else' '{' SCOPE '}'

BREAK: 'break'

DATA_TYPE:
'sample'
'sound'
'number'
'argument'
'group'
'boolean'
'string'

NAME: '([a-z]|[A-Z]|_)([a-z]|[A-Z]|_|[0-9])*'

VALUE:
STRING
NAME
'null'
EXECUTION
'[' ARRAY ']'
'(' ARRAY ')'
BOOLEAN_OPERATION
MATH_OPERATION
ARRAY:
VALUE
VALUE ',' ARRAY
ARGUMENT_DEFINITION:
DATA_TYPE NAME
DATA_TYPE NAME ',' ARGUMENT_DEFINITION
FUNCTION:
FUNCTION_INSTRUCTION
FUNCTION_INSTRUCTION FUNCTION
FUNCTION_INSTRUCTION:
EOE
ASSIGNATION EOE
EXECUTION EOE
DEFINITION
FOR_STATEMENT
IF_STATEMENT
RETURN EOE
BOOLEAN_OPERATION:
BOOLEAN_VALUE
NAME
EXECUTION
VALUE BOOLEAN_OPERATOR VALUE
'(' VALUE BOOLEAN_OPERATOR VALUE ')'
BOOLEAN_VALUE:
'true'
'false'
NUMBER
BOOLEAN_OPERATOR:
'=='
'<'
'>'
'<='
'>='
'!='
'&'
'|'
SCOPE:
SCOPE_INSTRUCTION
SCOPE_INSTRUCTION SCOPE
SCOPE_INSTRUCTION:
EOE
ASSIGNATION EOE
EXECUTION EOE
DEFINITION
FOR_STATEMENT
IF_STATEMENT
RETURN EOE
BREAK EOE

STRING: '"' * '"'

MATH_OPERATION:
NUMBER
NAME
EXECUTION
MATH_OPERATION MATH_OPERATOR MATH_OPERATION
'(' MATH_OPERATION MATH_OPERATOR MATH_OPERATION ')'
MATH_OPERATOR:
'+'
'-'
'/'
'*'

RETURN: 'return' VALUE

NUMBER: '([0-9])*(.([0-9])+)?'

Clone this wiki locally