add struct definitions as a direct child of program

This commit is contained in:
2020-02-04 19:13:45 +01:00
parent e297a7d2e8
commit 3e8e30e0da

View File

@@ -5,7 +5,15 @@ parse
;
program
: functionDef* expression SCOL
: (functionDef | structDef)* expression SCOL
;
structDef
: STRUCT structName=IDENT OBRK structField+ CBRK
;
structField
: IDENT type_annotation SCOL
;
functionDef
@@ -99,6 +107,7 @@ type
: INTEGER
| BOOLEAN
| FLOAT
| IDENT
;
functionCall
@@ -127,6 +136,7 @@ PRINT: 'print';
IF: 'if';
ELSE: 'else';
FUNC: 'function';
STRUCT: 'struct';
RETURN: 'return';
LET: 'let';
WHILE: 'while';