pns/grammar.txt
2025-03-21 16:16:45 +01:00

72 lines
1.8 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 .