96 lines
2.1 KiB
Plaintext
96 lines
2.1 KiB
Plaintext
program -> definition restdefs .
|
|
restdefs -> definition restdefs | .
|
|
|
|
definition -> FUN IDENTIFIER LPAREN parameters RPAREN funcassign .
|
|
funcassign -> ASSIGN statements | .
|
|
|
|
definition -> VAR IDENTIFIER ASSIGN initializers .
|
|
|
|
parameters -> IDENTIFIER restparams | .
|
|
restparams -> COMMA IDENTIFIER restparams | .
|
|
|
|
statements -> statement reststmts .
|
|
reststmts -> COMMA statement reststmts | .
|
|
|
|
statement -> expression exprassign .
|
|
exprassign -> ASSIGN expression | .
|
|
|
|
statement -> IF expression THEN statements elsestmt END .
|
|
elsestmt -> ELSE statements | .
|
|
|
|
statement -> WHILE expression DO statements END .
|
|
|
|
statement -> LET definition reststmtdefs IN statements END .
|
|
reststmtdefs -> definition reststmtdefs | .
|
|
|
|
expression -> conjexpr restdisj .
|
|
restdisj -> OR conjexpr restdisj | .
|
|
|
|
conjexpr -> cmpexpr restconj .
|
|
restconj -> AND cmpexpr restconj | .
|
|
|
|
cmpexpr -> addexpr restcmp .
|
|
restcmp -> EQU addexpr
|
|
| NEQ addexpr
|
|
| LTH addexpr
|
|
| GTH addexpr
|
|
| LEQ addexpr
|
|
| GEQ addexpr
|
|
| .
|
|
|
|
addexpr -> multexpr restadd .
|
|
restadd -> ADD multexpr restadd
|
|
| SUB multexpr restadd | .
|
|
|
|
multexpr -> prefixexpr restmult .
|
|
restmult -> MUL prefixexpr restmult
|
|
| DIV prefixexpr restmult
|
|
| MOD prefixexpr restmult
|
|
| .
|
|
|
|
prefixexpr -> NOT prefixexpr
|
|
| ADD prefixexpr
|
|
| SUB prefixexpr
|
|
| PTR prefixexpr
|
|
| postfixexpr .
|
|
|
|
postfixexpr -> primary postfixop .
|
|
postfixop -> PTR postfixop | .
|
|
|
|
primary -> const | LPAREN expression RPAREN | IDENTIFIER exprargs .
|
|
exprargs -> LPAREN arguments RPAREN | .
|
|
|
|
arguments -> expression restargs | .
|
|
restargs -> COMMA expression restargs | .
|
|
|
|
initializers -> initializer restinits | .
|
|
restinits -> COMMA initializer restinits | .
|
|
|
|
initializer -> INTCONST intconstmult | CHARCONST | STRINGCONST .
|
|
intconstmult -> MUL const | .
|
|
|
|
const -> INTCONST | CHARCONST | STRINGCONST .
|
|
|
|
|
|
--------------------------------------------------------------------
|
|
|
|
//LEFT ASOC.
|
|
exp0 = exp0 op other | other
|
|
|
|
|
|
|
v
|
|
|
|
exp0 = other exp0'
|
|
exp0' = op other exp0' | .
|
|
|
|
|
|
|
|
|
|
//RIGHT ASOC.
|
|
exp0 = other op exp0 | other
|
|
|
|
|
|
|
v
|
|
|
|
exp0 = other exp0'
|
|
exp0' = op exp0 | . |