formula := space? expression+ expression = string_join | arithmetic | comparison | thing thing = function | brackets | any_reference | string | percentage | number | boolean | prefix | named_reference argument = expression | null function := /[A-Z]+/ `'(' space argument? (space `',' space argument)* space `')' brackets := `'(' space expression+ space `')' string_join := thing (space `"&" space thing)+ arithmetic := thing (space operator space thing)+ comparison := thing space comparator space thing comparator := '>=' | '<=' | '<>' | '>' | '<' | '=' string := `'"' /[^"]*/ `'"' any_reference = table_reference | local_table_reference | quoted_sheet_reference | sheet_reference | sheetless_reference percentage := /[-+]?[0-9]+\.?[0-9]*/ `'%' number := /[-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?/ operator := '+' | '-' | '/' | '*' | '^' table_reference := table_name `'[' (complex_structured_reference | simple_structured_reference) `']' local_table_reference := `'[' (complex_structured_reference | overly_structured_reference | simple_structured_reference) `']' table_name = /[.a-zA-Z0-9]+/ complex_structured_reference = /\[[^\u005d]*\],\[[^\u005d]*\]/ overly_structured_reference = `'[' simple_structured_reference `']' simple_structured_reference = /[^\u005d]*/ named_reference := /[a-zA-Z][\w_.]+/ quoted_sheet_reference := single_quoted_string `'!' (sheetless_reference | named_reference) sheet_reference := /[a-zA-Z0-9][\w_.]+/ `'!' (sheetless_reference | named_reference) single_quoted_string = `"'" /[^']*/ `"'" sheetless_reference = column_range | row_range | area | cell column_range := column `':' column row_range := row `':' row area := reference `':' reference cell := reference row = /\$?\d+/ column = /\$?[A-Z]+/ reference = /\$?[A-Z]+\$?[0-9]+/ boolean = boolean_true | boolean_false boolean_true := `'TRUE' boolean_false := `'FALSE' prefix := /[-+]/ thing space = `/[ \n]*/ null := &','