line = linenumber , stmt , {":" , stmt} ; linenumber = digits ; stmt = if_stmt //TODO | "DEFUN" , [ident] , "(" , [ident , {" , " , ident}] , ")" , "=" , stmt | "ON" , if_equation , ident , if_equation , {"," , if_equation} | "(" , stmt , ")" | function_call ; if_stmt = "IF" , if_equation , "THEN" , stmt , ["ELSE" , stmt] ; //TODO function_call = if_stmt //TODO | equation ; | ident , "(" , [stmt , {argsep , stmt} , [argsep]] , ")" | ident , stmt , {argsep , stmt} , [argsep] equation = lit | "(" , equation , ")" | function_call , op , function_call | op_uni , function_call ; if_equation = if_equation , op - ("=") , if_equation | op_uni , if_equation | lit | "(" , if_equation , ")" ; (* don't bother looking at these, because you already know the stuff *) function = lit ; argsep = ","|";" ; ident = alph , [digits] ; lit = alph , [digits] | num | string ; (* example: "MyVar_2" *) op = "^" | "*" | "/" | "MOD" | "+" | "-" | "<<" | ">>" | "<" | ">" | "<=" | "=<" | ">=" | "=>" | "==" | "<>" | "><" | "BAND" | "BXOR" | "BOR" | "AND" | "OR" | "TO" | "STEP" | "!" | "~" | "#" | "=" ; op_uni = "-" | "+" ; alph = letter | letter , alph ; digits = digit | digit , digits ; hexdigits = hexdigit | hexdigit , hexdigits ; bindigits = bindigit | bindigit , bindigits ; num = digits | digits , "." , [digits] | "." , digits | ("0x"|"0X") , hexdigits | ("0b"|"0B") , bindigits ; (* sorry, no e-notation! *) visible = ? ASCII 0x20 to 0x7E ? ; string = '"' , (visible | visible , stringlit) , '"' ; letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "_" ; digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; hexdigit = "A" | "B" | "C" | "D" | "E" | "F" | "a" | "b" | "c" | "d" | "e" | "f" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; bindigit = "0" | "1" ; (* all possible token states: lit num op bool qot paren sep *) IF (type: function, value: IF) 1. cond 2. true [3. false] DEFUN (type: function, value: DEFUN) 1. funcname 1. arg0 [2. arg1] [3. argN...] 2. stmt ON (type: function, value: ON) 1. varname 2. functionname 3. arg0 [4. arg1] [5. argN...] FUNCTION_CALL (type: function, value: PRINT or something) 1. arg0 2. arg1 [3. argN...]