update grammar a bit
[jwcc.git] / grammar.txt
CommitLineData
933e60e3
JW
1GLOBAL := ( FUNCTION | VARIABLE )*
2FUNCTION := TYPE MODIFIERS _IDENTIFIER ARGSLIST ( ';' | STMTLIST )
3TYPE := 'int'
4MODIFIERS := '*'*
7e3bbd6a 5ARGSLIST := '(' [ TYPE MODIFIERS _IDENTIFIER ( ',' TYPE MODIFIERS _IDENTIFIER )* ] ')'
933e60e3
JW
6STMTLIST := '{' ( VARIABLE | STATEMENT | STMTLIST )* '}'
7VARIABLE := TYPE MODIFIERS _IDENTIFIER [ = EXPRESSION ] ';'
8STATEMENT := ( ';' | EXPRESSION ';' | WHILE | IF | RETURN )
9WHILE := 'while' '(' EXPRESSION ')' CHUNK
10IF := 'if' '(' EXPRESSION ')' CHUNK
11RETURN := 'return' EXPRESSION ';'
12CHUNK := ( STMTLIST | STATEMENT )
13EXPRESSION := P13EXPR
14P13EXPR := P6EXPR ( '=' P6EXPR )*
15P6EXPR := P5EXPR ( '==' P5EXPR )*
16P5EXPR := P3EXPR ( ( '<' | '>' ) P3EXPR )*
17P3EXPR := P2EXPR ( ( '+' | '-' ) P2EXPR )*
7e3bbd6a
JW
18P2EXPR := SUBEXPR ( ( '*' | '/' ) SUBEXPR )*
19SUBEXPR := ( '(' EXPRESSION ')' | _NUMBER | _IDENTIFIER )
This page took 0.016365 seconds and 4 git commands to generate.