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