Omg Grammar

Below is a formal grammar for Omg. Terminals are shown in bold.
program    -> globlist funlist

globlist   -> e
            | globlist glob vardecl

vardecl    -> type decllist ;

type       -> basictype
            | basictype [ CONST .. CONST ]

basictype   -> num
            |  boo

decllist   -> decl
            | decllist , decl

decl       -> ID
            | ID :=  expr


funlist    -> e
            | funlist fundecl

fundecl    -> ID ( params ) body
            | basictype ID ( params ) body

params     -> e
            | paramlist

paramlist  -> param
            | paramlist , param

param      -> basictype ID
            | basictype @ ID
            | basictype [ ] ID

body       -> { stmtlist }

stmtlist   -> e
            | stmtlist stmt

stmt       -> vardecl
            | assignment
            | funcall ;
            | returnstmt
            | ifstmt
            | whilestmt
            | body


assignment -> variable := expr ;

variable   -> ID
            | ID [ expr ]

funcall   -> ID ( )
            | ID ( exprlist )

returnstmt -> ret ;
            | ret expr ;

ifstmt     -> if expr , stmt
            | if expr , stmt else stmt

whilestmt  -> while expr , stmt


exprlist   -> expr
            | exprlist , expr

expr       -> logterm
            | expr or logterm

logterm    -> logfactor
            | logterm and logfactor

logfactor  -> relexpr
            | not relexpr

relexpr    -> arithexpr
            | arithexpr < arithexpr
            | arithexpr <= arithexpr
            | arithexpr > arithexpr
            | arithexpr >= arithexpr
            | arithexpr = arithexpr
            | arithexpr <> arithexpr

arithexpr  -> term
            | arithexpr + term
            | arithexpr - term

term       -> factor
            | term * factor
            | term / factor
            | term mod factor

factor     -> - factor
            | variable
            | funcall
            | CONST
            | yes
            | no
            | ( expr )