set basic repo structure
This commit is contained in:
41
grammar/MXParser.g4
Normal file
41
grammar/MXParser.g4
Normal file
@ -0,0 +1,41 @@
|
||||
parser grammar MXParser;
|
||||
|
||||
options { tokenVocab=MXLexer; }
|
||||
|
||||
mxprog
|
||||
: function* EOF
|
||||
;
|
||||
|
||||
function
|
||||
: type ID LPAREN RPAREN block
|
||||
;
|
||||
|
||||
type
|
||||
: INT
|
||||
| VOID
|
||||
;
|
||||
|
||||
block
|
||||
: LBRACE statement* RBRACE
|
||||
;
|
||||
|
||||
statement
|
||||
: expression SEMICOLON
|
||||
| returnStmt
|
||||
| ifStmt
|
||||
;
|
||||
|
||||
expression
|
||||
: INT_LITERAL
|
||||
| ID
|
||||
| expression (PLUS | MINUS | MULTIPLY | DIVIDE) expression
|
||||
| LPAREN expression RPAREN
|
||||
;
|
||||
|
||||
returnStmt
|
||||
: RETURN expression? SEMICOLON
|
||||
;
|
||||
|
||||
ifStmt
|
||||
: IF LPAREN expression RPAREN statement (ELSE statement)?
|
||||
;
|
Reference in New Issue
Block a user