The reserved keyword are printed in bold. All additional tokens are quoted in 'single quotes'.
Note that some "factoring" of the grammar has occurred, i.e. the introduction of safe_table.
query: table_expr | query ';' query | '@' Identifier ':=' table_expr | '$' Identifier ':=' expr table_expr: safe_table | select fieldlist from fwlist | select all fwlist | select all from fwlist | table_expr order // default left to right ascending | table_expr order Ordering | table_expr order by sortlist | table_expr union table_expr | table_expr intersect table_expr | table_expr diff table_expr | table_expr except table_expr safe_table: '(' table_expr ')' | '@' Identifier sortlist: sort_criterion | sortlist ',' sort_criterion sort_criterion: ':' Identifier // select column by name | ':' Number // select by column number | ':' Identifier Ordering | ':' Number Ordering Ordering: asc // ascending order - default | desc // descending order fieldlist: field | fieldlist ',' field field: expr | Identifier '::' expr // name alias for field-expression fwlist: fw | fw where expr // expr is evaluated in boolean context | fwlist ',' fw | fwlist ',' fw where expr // expr is evaluated in boolean context fw: basic_decl // unnamed declaration | Identifier in basic_decl | basic_decl as Identifier | basic_decl Identifier basic_decl: expr // i.e. a locator or anything that returns a value | safe_table | class Identifier locator: Identifier | object '(' expr ',' expr ')' // create object (class, key) | locator '->' Identifier // follow into object by tag name | locator '->' Number // follow into object by position | locator '[' Identifier ']' // locate in current object by tag name | locator '[' Number ']' // locate in current object by position | locator ':' Identifier // row variable - select column by name | locator ':' Number // row variable - select column by number | locator '.' Method // locator method | '->' Identifier // unnamed iterator - follow by tag name | '->' Number // unnamed iterator - follow by position | '[' Identifier ']' // unnamed iterator - locate by tag name | '[' Number ']' // unnamed iterator - locate by position | ':' Identifier // unnamed row variable - select column by name | ':' Number // unnamed row variable - select column by number | '.' Method // unnamed iterator - locator method | safe_table ':' Identifier // table expression - select column by name | safe_table ':' Number // table expression - select column by number Comparator: '=' | '!=' | '<' | '>' | '<=' | '>=' | like expr: locator | exists locator // boolean true/false whether locator value is non-NULL | exists '(' locator ')' | exists_tag locator // whether the tag of the locator exists (does not fetch value) | exists_tag '(' locator ')' | '$' Identifier // a scalar variable | StringLiteral // test in double-quotes | Number | FloatLiteral | Date | true // i.e. boolean literal | false | expr Comparator expr // returns boolean result | not expr // negates boolean value | expr and expr | expr or expr | expr xor expr | expr '+' expr | expr '-' expr | expr '*' expr | expr '/' expr | expr '%' expr // positive remainder (also 'mod' or 'modulo') | '-' expr // negative value | '(' expr ')' | mod '(' expr ',' expr ')' // positive remainder (also '%' or `modulo') | abs '(' expr ')' // absolute value | DateFunc '(' expr ',' expr ')' | TableFunc safe_table | TableFunc safe_table ':' Number | TableFunc safe_table ':' Identifier Method: name // get Object name as Text-type | class // get class-Object of Object-value | length // get length of Text-value | create_session // timestamp-object when the object was created | create_time // same, but as DateType-result | update_session // timestamp-object when the object was last modified | update_time // same, but as DateType-result | node_session // timestamp-object when the tag, or datafields was last added/modified | node_time // same, but as DateType-result TableFunc: count | min | max | sum | avg | first | last DateFunc: yeardiff | monthdiff | daydiff | hourdiff | mindiff | secdiff Identifier: [A-Za-z][A-Za-z0-9_]* // starts with letter, followed by letters or numbers Number: [0-9]+ FloatLiteral: [0-9]+[eE][+-]?[0-9]+ | [0-9]+'.'[0-9]*[eE][+-]?[0-9]+ | '.'[0-9]+[eE][+-]?[0-9]+ | [0-9]+'.'[0-9]* | '.'[0-9]+ StringLiteral: \"([^"]|\\["\n])*\" // anything enclosed in quotes // quotes within a string can be escaped by backslash Date: now // current date/time as YYYY-MM-DD_HH:MM:SS | today // current date as YYYY-MM-DD | DateLiteral DateLiteral: '`'[12][90][0-9][0-9]'-'[01][0-9]'-'[0-3][0-9]'_'[0-2][0-9]':'[0-5][0-9]':'[0-5][0-9] | '`'[12][90][0-9][0-9]'-'[01][0-9]'-'[0-3][0-9]'_'[0-2][0-9]':'[0-5][0-9] | '`'[12][90][0-9][0-9]'-'[01][0-9]'-'[0-3][0-9]'_'[0-2][0-9] | '`'[12][90][0-9][0-9]'-'[01][0-9]'-'[0-3][0-9] | '`'[12][90][0-9][0-9]'-'[01][0-9] | '`'[12][90][0-9][0-9]