1 /* Grammar of a mini procedural programming language */
5 l = 'a'..'z'|'A'..'Z'|'_';
9 str = '"' (Any - '"')* '"';
10 blank = ' ' | '\n' | '\t';
18 {assign:} id '=' e ';' |
19 {print:} 'print' '(' e ')' ';' |
20 {print_str:} 'print' '(' str ')' ';' |
21 {println:} 'println' '(' ')' ';' |
22 {while:} 'while' '(' c ')' stmts |
23 {if:} 'if' '(' c ')' [then:]stmts else? ;
33 {read:} 'read' '(' ')'
37 {mul:} [left:]e '*' [right:]e |
38 {div:} [left:]e '/' [right:]e
40 {add:} [left:]e '+' [right:]e |
41 {sub:} [left:]e '-' [right:]e ;
44 {eq:} [left:]e '=' [right:]e |
45 {ne:} [left:]e '!=' [right:]e |
46 {lt:} [left:]e '<' [right:]e |
47 {le:} [left:]e '<=' [right:]e |
48 {gt:} [left:]e '>' [right:]e |
49 {ge:} [left:]e '>=' [right:]e
53 {and:} [left:]c '&&' [right:]c
55 {or:} [left:]c '||' [right:]c ;