program = { statement } ; statement = function | return | loop | while | for | break | continue | if | expression_statement ; function = "function" , identifier , "(" , { identifier , "," , } ")" , block return = "return" , expression , ";" ; loop = "loop" , block ; while = "while" , "(" , expression , ")" , block ; for = "for" , "(" , [ expression ] , ";" , [ expression ] , ";" , [ expression ] , ")" , block break = "break" , ";" ; continue = "continue" , ";" ; if = "if" , "(" , expression , ")" , block [ , "else" , ( if | block ) ] ; block = "{" , { statement } , "}" ; expression_statement = expression , ";" ; expression = assignment | declaration ; declaration = "var" , identifier , "=" , expression ; assignment = ( identifier , "=" , assignment ) | logical_or; logical_or = logical_and { , "||" , logical_and } ; logical_and = equality { , "&&" , equality } ; equality = comparison { , ( "==" | "!=" ) , comparison } ; comparison = term { , ( ">" | "<" | ">=" | "<=" ) , term } ; term = factor { , ( "+" | "-" ) , factor } ; factor = unary { , ( "*" | "/" ) , unary } ; unary = ( ( "!" | "-" ) , unary ) | subscript ; subscript = primary , { "[" , expression , "]" , } primary = identifier | array | member | call | number | string | group ; array = "[" , { expression , "," ? } , "]" ; member = identifier , "." , { ( identifier | call ) , "." ? } ; call = ( identifier , "(" , { expression, "," ? } , ")" ) ; group = "(" , expression , ")" ; identifier = alphabetic , { alphabetic | digit } ; string = '"' , { character - '"' } , '"' ; number = digit , { digit } , [ "." , digit , { digit } ] ;