add struct definitions as a direct child of program
This commit is contained in:
@@ -5,7 +5,15 @@ parse
|
|||||||
;
|
;
|
||||||
|
|
||||||
program
|
program
|
||||||
: functionDef* expression SCOL
|
: (functionDef | structDef)* expression SCOL
|
||||||
|
;
|
||||||
|
|
||||||
|
structDef
|
||||||
|
: STRUCT structName=IDENT OBRK structField+ CBRK
|
||||||
|
;
|
||||||
|
|
||||||
|
structField
|
||||||
|
: IDENT type_annotation SCOL
|
||||||
;
|
;
|
||||||
|
|
||||||
functionDef
|
functionDef
|
||||||
@@ -99,6 +107,7 @@ type
|
|||||||
: INTEGER
|
: INTEGER
|
||||||
| BOOLEAN
|
| BOOLEAN
|
||||||
| FLOAT
|
| FLOAT
|
||||||
|
| IDENT
|
||||||
;
|
;
|
||||||
|
|
||||||
functionCall
|
functionCall
|
||||||
@@ -127,6 +136,7 @@ PRINT: 'print';
|
|||||||
IF: 'if';
|
IF: 'if';
|
||||||
ELSE: 'else';
|
ELSE: 'else';
|
||||||
FUNC: 'function';
|
FUNC: 'function';
|
||||||
|
STRUCT: 'struct';
|
||||||
RETURN: 'return';
|
RETURN: 'return';
|
||||||
LET: 'let';
|
LET: 'let';
|
||||||
WHILE: 'while';
|
WHILE: 'while';
|
||||||
|
|||||||
Reference in New Issue
Block a user