[ ] = 0, or more times
" " = terminal symbol
| program -> | [ declaration ] "main" statement |
| declaration -> | "global" identifier ";" |
| "semaphore" identifier ";" | |
| "process" process-name "(" formalparameter ")" statement | |
| function-name "(" formalparameter ")" statement | |
| statement -> | stmt |
| "{" [stmt] "}" | |
| stmt -> | id "=" expression ";" |
| "*" id "=" expression ";" | |
| "if" expression statement | |
| "if" expression statement "else" statement | |
| "while" expression statement | |
| "return" expression ";" | |
| function-name "(" actualparameter ")" ";" | |
| process-name "(" actualparameter ")" ";" | |
| ";" | |
| expression -> | term |
| unaryop term | |
| expression binaryop expression | |
| term -> | number |
| id | |
| "(" expression ")" | |
| function-name "(" actualparameter ")" | |
| id -> | variable |
| array-name "[" index "]" | |
| identifier -> | null |
| id [ "," id ] | |
| formalparameter -> | null |
| variable [ "," variable ] | |
| actualparameter -> | null |
| expression [ "," expression ] |
unaryop is { -, !, *, & }
binaryop is { +, -, *, /, &&, ||, <, <=, ==, !=, >=, > }
precedency of operators (from highest)
| ( ) | do an expression inside ( ) first |
| - ! * & | unary op - minus, ! logic not, * deref, & address |
| * / && | multiply, divide, logical and |
| + - || | add, subtract, logical or |
| < <= == != >= > | relational operators |
built-in function and special forms