add return statement to the grammar
This commit is contained in:
@@ -24,6 +24,7 @@ statement
|
||||
: print
|
||||
| if_statement
|
||||
| variable_assignment
|
||||
| return_statement
|
||||
;
|
||||
|
||||
print
|
||||
@@ -38,6 +39,10 @@ variable_assignment
|
||||
: IDENT EQUAL expression SCOL
|
||||
;
|
||||
|
||||
return_statement
|
||||
: RETURN expression SCOL
|
||||
;
|
||||
|
||||
expression
|
||||
: atom MULT atom #multiplicationExpression
|
||||
| atom op=(ADD | SUB) atom #additiveExpression
|
||||
@@ -64,6 +69,7 @@ PRINT: 'print';
|
||||
IF: 'if';
|
||||
ELSE: 'else';
|
||||
FUNC: 'function';
|
||||
RETURN: 'return';
|
||||
|
||||
SCOL: ';';
|
||||
OBRK: '{';
|
||||
|
||||
Reference in New Issue
Block a user