program = { statement } ;
statement = if | while | ( expression , ";" ) ;
while = "while" , expression , block ;
if = "if" , expression , block ;
block = "{" , { statement } , "}" ;
expression = assignment | declaration ;
declaration = "var" , identifier , "=" , expression ;
assignment = { identifier , "=" , } logical_or ;
logical_or = logical_and { , "||" , logical_and } ;
logical_and = equality { , "&&" , equality } ;
equality = comparison { , ( "==" | "!=" ) , comparison } ;
comparison = term { , ( ">" | "<" | ">=" | "<=" ) , term } ;
(* implemented *)
term = factor { , ( "+" | "-" ) , factor } ;
factor = primary { , ( "*" | "/" ) , primary } ;
primary = identifier | number | string | group ;
group = "(" , expression , ")" ;
identifier = alphabetic , { alphabetic | digit } ;
string = '"' , { character - '"' } , '"' ;
number = digit , { digit } , [ "." , digit , { digit } ] ;