Details / Original BNF*

----------------------------------------------------------------------

Program ::= module Id ; Block Id .
Block ::= DeclList begin StmtList end
DeclList ::= { Decl ; }
Decl ::= ConstDecl | VarDecl | ProcDecl
ConstDecl ::= const ConstDeclItem { , ConstDeclItem }
ConstDeclItem ::= Id : Type = ConstExpr
ConstExpr ::= Id | Integer
VarDecl ::= var VarDeclItem { , VarDeclItem }
VarDeclItem ::= Id : Type
ProcDecl ::= procedure Id ( [ FormalDecl {, FormalDecl }] ) ; Block Id
FormalDecl ::= Id : Type
Type ::= int
StmtList ::= { Stmt ; }
Stmt ::= CallStmt | AssignStmt | OutStmt | IfStmt | WhileStmt
CallStmt ::= Id ( [ Exprs ] )
AssignStmt ::= LValue := Expr
LValue ::= Id
OutStmt ::= output := Expr
IfStmt ::= if Test then StmtList end
WhileStmt ::= while Test do StmtList end
Test ::= odd Sum | Sum Relop Sum
Relop ::= < | <= | = | >= | > | <>
Exprs ::= Expr { , Expr }
Expr ::= Sum
Sum ::= Term { (+ | -) Term }
Term ::= Factor { (* | /) Factor }
Factor ::= - Factor | LValue | Integer | input | ( Expr )

* This includes some syntactic sugar that is not strictly BNF, e.g. braces {} mean "0 or more", and brackets [] mean "optional".