The input to be parsed by the grammar:
An example grammar using the above annotations is:
root : statement SEQ OPT . statement : ident "=" expr ";" [ass] | "if" expr "then" statement SEQ OPT "else" statement SEQ OPT "fi" [ifthenelse] | "while" expr "do" statement SEQ OPT "od" [while] | "print" expr ";" [print] | "function" ident "(" ident LIST OPT ")" "{" statement SEQ OPT "}" [fndef] | expr ";" . primary_expr : ident "(" expr LIST OPT ")" [fncall] | ident | int | char | string | "(" expr ")" . unary_expr : "!" primary_expr [not] | "-" primary_expr [min] | primary_expr . l_expr1 : l_expr1 "*" unary_expr [times] | l_expr1 "/" unary_expr [div] | l_expr1 "%" unary_expr [mod] | unary_expr . l_expr2 : l_expr2 "+" l_expr1 [add] | l_expr2 "-" l_expr1 [sub] | l_expr1 . l_expr3 : l_expr3 "<=" l_expr2 [le] | l_expr3 ">=" l_expr2 [ge] | l_expr3 "<" l_expr2 [lt] | l_expr3 ">" l_expr2 [gt] | l_expr3 "==" l_expr2 [eq] | l_expr3 "!=" l_expr2 [ne] | l_expr2 . l_expr4 : l_expr4 "&&" l_expr3 [land] | l_expr3 . l_expr5 : l_expr5 "||" l_expr4 [lor] | l_expr4 . expr : l_expr5 "?" l_expr5 ":" expr [ifthenelse] | l_expr5 .
function gcd(x, y) { while y != 0 do c = x % y; x = y; y = c; od x; } a = 345; b = 555; print gcd(a, b);