Commits

Olemis Lang committed 918b87b

GViz QL: Grammar: Accept COL_SEQ in PIVOT clause instead of SEQ

Comments (0)

Files changed (1)

trac-dev/gviz/tracgviz/grammar.py

       ('selall',  CLAUSE,     [ _Select, _Wildchar ] ),
       ('where',   CLAUSE,     [ _Where, BOOL_EXPR ] ),
       ('groupby', CLAUSE,     [ _GroupBy, SEQ ] ),
-      ('pivot',   CLAUSE,     [ _Pivot, SEQ ] ),
+      ('pivot',   CLAUSE,     [ _Pivot, COL_SEQ ] ),
       ('orderby', CLAUSE,     [ _OrderBy, ORDER_SEQ ] ),
       ('limit',   CLAUSE,     [ _Limit, _Number ] ),
       ('offset',  CLAUSE,     [ _Offset, _Number ] ),
 # no production processing is needed , they are ready to use 
 
 GVIZ_GRAMMAR_PRODUCTIONS = {(NonTerminal, Any): {_Format: {EndMarker: 'format'},
-        _From: {EndMarker: 'from'},
-        _GroupBy: {EndMarker: 'groupby'},
-        _Label: {EndMarker: 'label'},
-        _Options: {EndMarker: 'options'},
-        _OrderBy: {EndMarker: 'orderby'},
-        _Pivot: {EndMarker: 'pivot'},
-        _Select: {EndMarker: 'select'},
-        _Where: {EndMarker: 'where'},
-        _Mult: {(NonTerminal, Any): {EndMarker: 'mult'}},
-        _Plus: {(NonTerminal, Any): {EndMarker: 'sum'}},
-        _Minus: {(NonTerminal, Any): {EndMarker: 'sub'}},
-        _Div: {(NonTerminal, Any): {EndMarker: 'div'}},
-        _BoolOp: {(NonTerminal, Any): {EndMarker: 'cmp'}},
-        _And: {(NonTerminal, Any): {EndMarker: 'boolexp'}},
-        _Not: {EndMarker: 'not'},
-        _Or: {(NonTerminal, Any): {EndMarker: 'orexp'}},
-        _BoolWordOp: {(NonTerminal, Any): {EndMarker: 'strcmp'}},
-        _Comma: {(NonTerminal, Any): {EndMarker: 'seq'}},
-        (Token.Text.Whitespace, ' '): {(NonTerminal, Any): {EndMarker: 'body'}}},
- _Asc: {(NonTerminal, Any): {EndMarker: 'orderasc'}},
- _Desc: {(NonTerminal, Any): {EndMarker: 'orderdsc'}},
- _Date: {EndMarker: 'date'},
- _Number: {_Limit: {EndMarker: 'limit'},
-        _Offset: {EndMarker: 'offset'},
-        EndMarker: 'number'},
- _Str: {_Var: {EndMarker: 'lblexpr'},
-        EndMarker: 'str'},
- _Const: {EndMarker: 'const'},
- _Wildchar: {_Select: {EndMarker: 'selall'}},
- _Var: {EndMarker: 'var'},
- _CloseP: {(NonTerminal, Any): {_OpenP: {_Builtin: {EndMarker: 'bfunc'},
-                _Function: {EndMarker: 'funcargs'},
-                EndMarker: 'par'}},
-        _OpenP: {_Function: {EndMarker: 'func'}}},
- (Token.Text.Whitespace, '\n'): {(NonTerminal, Any): {EndMarker: 'gvizql'}}}
+                                                  _From: {EndMarker: 'from'},
+                                                  _GroupBy: {EndMarker: 'groupby'},
+                                                  _Label: {EndMarker: 'label'},
+                                                  _Options: {EndMarker: 'options'},
+                                                  _OrderBy: {EndMarker: 'orderby'},
+                                                  _Pivot: {EndMarker: 'pivot'},
+                                                  _Select: {EndMarker: 'select'},
+                                                  _Where: {EndMarker: 'where'},
+                                                  _Mult: {(NonTerminal, Any): {EndMarker: 'mult'}},
+                                                  _Plus: {(NonTerminal, Any): {EndMarker: 'sum'}},
+                                                  _Minus: {(NonTerminal, Any): {EndMarker: 'sub'}},
+                                                  _Div: {(NonTerminal, Any): {EndMarker: 'div'}},
+                                                  _BoolOp: {(NonTerminal, Any): {EndMarker: 'cmp'}},
+                                                  _And: {(NonTerminal, Any): {EndMarker: 'boolexp'}},
+                                                  _Not: {EndMarker: 'not'},
+                                                  _Or: {(NonTerminal, Any): {EndMarker: 'orexp'}},
+                                                  _BoolWordOp: {(NonTerminal, Any): {EndMarker: 'strcmp'}},
+                                                  _Comma: {(NonTerminal, Any): {EndMarker: 'seq'}},
+                                                  (Token.Text.Whitespace, ' '): {(NonTerminal, Any): {EndMarker: 'body'}}},
+                             _Asc: {(NonTerminal, Any): {EndMarker: 'orderasc'}},
+                             _Desc: {(NonTerminal, Any): {EndMarker: 'orderdsc'}},
+                             _Const: {EndMarker: 'const'},
+                             _Date: {EndMarker: 'date'},
+                             _Number: {_Limit: {EndMarker: 'limit'},
+                                       _Offset: {EndMarker: 'offset'},
+                                       EndMarker: 'number'},
+                             _Str: {_Var: {EndMarker: 'lblexpr'},
+                                    EndMarker: 'str'},
+                             _Wildchar: {_Select: {EndMarker: 'selall'}},
+                             _Var: {EndMarker: 'var'},
+                             _CloseP: {(NonTerminal, Any): {_OpenP: {_Builtin: {EndMarker: 'bfunc'},
+                                                                     _Function: {EndMarker: 'funcargs'},
+                                                                     EndMarker: 'par'}},
+                                       _OpenP: {_Function: {EndMarker: 'func'}}},
+                             (Token.Text.Whitespace, '\n'): {(NonTerminal, Any): {EndMarker: 'gvizql'}}}
 
 
-GVIZ_GRAMMAR_PRECEDENCE = {((EndMarker, 'ARITHMETIC_EXPR'), _Date): LessPrecedence,
+GVIZ_GRAMMAR_PRECEDENCE = {((EndMarker, 'ARITHMETIC_EXPR'), _Const): LessPrecedence,
+ ((EndMarker, 'ARITHMETIC_EXPR'), _Date): LessPrecedence,
  ((EndMarker, 'ARITHMETIC_EXPR'), _Number): LessPrecedence,
  ((EndMarker, 'ARITHMETIC_EXPR'), _Str): LessPrecedence,
  ((EndMarker, 'ARITHMETIC_EXPR'), _Builtin): LessPrecedence,
- ((EndMarker, 'ARITHMETIC_EXPR'), _Const): LessPrecedence,
  ((EndMarker, 'ARITHMETIC_EXPR'), _Function): LessPrecedence,
  ((EndMarker, 'ARITHMETIC_EXPR'), _Var): LessPrecedence,
  ((EndMarker, 'ARITHMETIC_EXPR'), _Mult): LessPrecedence,
  ((EndMarker, 'BODY'), _Select): LessPrecedence,
  ((EndMarker, 'BODY'), _Where): LessPrecedence,
  ((EndMarker, 'BODY'), (Token.Text.Whitespace, ' ')): LessPrecedence,
+ ((EndMarker, 'BOOL_EXPR'), _Const): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _Date): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _Number): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _Str): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _Builtin): LessPrecedence,
- ((EndMarker, 'BOOL_EXPR'), _Const): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _Function): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _Var): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _Mult): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _Or): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _BoolWordOp): LessPrecedence,
  ((EndMarker, 'BOOL_EXPR'), _OpenP): LessPrecedence,
+ ((EndMarker, 'BOOL_VALUE'), _Const): LessPrecedence,
  ((EndMarker, 'BOOL_VALUE'), _Date): LessPrecedence,
  ((EndMarker, 'BOOL_VALUE'), _Number): LessPrecedence,
  ((EndMarker, 'BOOL_VALUE'), _Str): LessPrecedence,
  ((EndMarker, 'BOOL_VALUE'), _Builtin): LessPrecedence,
- ((EndMarker, 'BOOL_VALUE'), _Const): LessPrecedence,
  ((EndMarker, 'BOOL_VALUE'), _Function): LessPrecedence,
  ((EndMarker, 'BOOL_VALUE'), _Var): LessPrecedence,
  ((EndMarker, 'BOOL_VALUE'), _Mult): LessPrecedence,
  ((EndMarker, 'COLSEQ'), _Var): LessPrecedence,
  ((EndMarker, 'COLSEQ'), _Comma): LessPrecedence,
  ((EndMarker, 'COLUMN'), _Var): LessPrecedence,
+ ((EndMarker, 'FACTOR'), _Const): LessPrecedence,
  ((EndMarker, 'FACTOR'), _Date): LessPrecedence,
  ((EndMarker, 'FACTOR'), _Number): LessPrecedence,
  ((EndMarker, 'FACTOR'), _Str): LessPrecedence,
  ((EndMarker, 'FACTOR'), _Builtin): LessPrecedence,
- ((EndMarker, 'FACTOR'), _Const): LessPrecedence,
  ((EndMarker, 'FACTOR'), _Function): LessPrecedence,
  ((EndMarker, 'FACTOR'), _Var): LessPrecedence,
  ((EndMarker, 'FACTOR'), _Div): LessPrecedence,
  ((EndMarker, 'LABEL_EXPR'), _Var): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _Asc): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _Desc): LessPrecedence,
+ ((EndMarker, 'ORDER_EXPR'), _Const): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _Date): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _Number): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _Str): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _Builtin): LessPrecedence,
- ((EndMarker, 'ORDER_EXPR'), _Const): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _Function): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _Var): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _Mult): LessPrecedence,
  ((EndMarker, 'ORDER_EXPR'), _OpenP): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Asc): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Desc): LessPrecedence,
+ ((EndMarker, 'ORDER_SEQ'), _Const): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Date): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Number): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Str): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Builtin): LessPrecedence,
- ((EndMarker, 'ORDER_SEQ'), _Const): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Function): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Var): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Mult): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Div): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _OpenP): LessPrecedence,
  ((EndMarker, 'ORDER_SEQ'), _Comma): LessPrecedence,
+ ((EndMarker, 'OR_EXPR'), _Const): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _Date): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _Number): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _Str): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _Builtin): LessPrecedence,
- ((EndMarker, 'OR_EXPR'), _Const): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _Function): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _Var): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _Mult): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _Or): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _BoolWordOp): LessPrecedence,
  ((EndMarker, 'OR_EXPR'), _OpenP): LessPrecedence,
+ ((EndMarker, 'SEQ'), _Const): LessPrecedence,
  ((EndMarker, 'SEQ'), _Date): LessPrecedence,
  ((EndMarker, 'SEQ'), _Number): LessPrecedence,
  ((EndMarker, 'SEQ'), _Str): LessPrecedence,
  ((EndMarker, 'SEQ'), _Builtin): LessPrecedence,
- ((EndMarker, 'SEQ'), _Const): LessPrecedence,
  ((EndMarker, 'SEQ'), _Function): LessPrecedence,
  ((EndMarker, 'SEQ'), _Var): LessPrecedence,
  ((EndMarker, 'SEQ'), _Mult): LessPrecedence,
  ((EndMarker, 'SEQ'), _Div): LessPrecedence,
  ((EndMarker, 'SEQ'), _OpenP): LessPrecedence,
  ((EndMarker, 'SEQ'), _Comma): LessPrecedence,
+ ((EndMarker, 'SIMPLE_EXPR'), _Const): LessPrecedence,
  ((EndMarker, 'SIMPLE_EXPR'), _Date): LessPrecedence,
  ((EndMarker, 'SIMPLE_EXPR'), _Number): LessPrecedence,
  ((EndMarker, 'SIMPLE_EXPR'), _Str): LessPrecedence,
  ((EndMarker, 'SIMPLE_EXPR'), _Builtin): LessPrecedence,
- ((EndMarker, 'SIMPLE_EXPR'), _Const): LessPrecedence,
  ((EndMarker, 'SIMPLE_EXPR'), _Function): LessPrecedence,
  ((EndMarker, 'SIMPLE_EXPR'), _Var): LessPrecedence,
  ((EndMarker, 'SIMPLE_EXPR'), _OpenP): LessPrecedence,
+ ((EndMarker, 'TERM'), _Const): LessPrecedence,
  ((EndMarker, 'TERM'), _Date): LessPrecedence,
  ((EndMarker, 'TERM'), _Number): LessPrecedence,
  ((EndMarker, 'TERM'), _Str): LessPrecedence,
  ((EndMarker, 'TERM'), _Builtin): LessPrecedence,
- ((EndMarker, 'TERM'), _Const): LessPrecedence,
  ((EndMarker, 'TERM'), _Function): LessPrecedence,
  ((EndMarker, 'TERM'), _Var): LessPrecedence,
  ((EndMarker, 'TERM'), _Mult): LessPrecedence,
  ((EndMarker, 'TERM'), _Div): LessPrecedence,
  ((EndMarker, 'TERM'), _OpenP): LessPrecedence,
+ ((EndMarker, 'VALUE'), _Const): LessPrecedence,
  ((EndMarker, 'VALUE'), _Date): LessPrecedence,
  ((EndMarker, 'VALUE'), _Number): LessPrecedence,
  ((EndMarker, 'VALUE'), _Str): LessPrecedence,
  ((EndMarker, 'VALUE'), _Builtin): LessPrecedence,
- ((EndMarker, 'VALUE'), _Const): LessPrecedence,
  ((EndMarker, 'VALUE'), _Function): LessPrecedence,
  ((EndMarker, 'VALUE'), _Var): LessPrecedence,
  (_Asc, (EndMarker, 'BODY')): MorePrecedence,
  (_Desc, _Comma): MorePrecedence,
  (_Desc, (Token.Text.Whitespace, '\n')): MorePrecedence,
  (_Desc, (Token.Text.Whitespace, ' ')): MorePrecedence,
+ (_Const, (EndMarker, 'ARITHMETIC_EXPR')): MorePrecedence,
+ (_Const, (EndMarker, 'BODY')): MorePrecedence,
+ (_Const, (EndMarker, 'BOOL_EXPR')): MorePrecedence,
+ (_Const, (EndMarker, 'BOOL_VALUE')): MorePrecedence,
+ (_Const, (EndMarker, 'CLAUSE')): MorePrecedence,
+ (_Const, (EndMarker, 'FACTOR')): MorePrecedence,
+ (_Const, (EndMarker, 'ORDER_EXPR')): MorePrecedence,
+ (_Const, (EndMarker, 'ORDER_SEQ')): MorePrecedence,
+ (_Const, (EndMarker, 'OR_EXPR')): MorePrecedence,
+ (_Const, (EndMarker, 'SEQ')): MorePrecedence,
+ (_Const, (EndMarker, 'SIMPLE_EXPR')): MorePrecedence,
+ (_Const, (EndMarker, 'TERM')): MorePrecedence,
+ (_Const, (EndMarker, 'VALUE')): MorePrecedence,
+ (_Const, _Asc): MorePrecedence,
+ (_Const, _Desc): MorePrecedence,
+ (_Const, _Mult): MorePrecedence,
+ (_Const, _Plus): MorePrecedence,
+ (_Const, _Minus): MorePrecedence,
+ (_Const, _Div): MorePrecedence,
+ (_Const, _BoolOp): MorePrecedence,
+ (_Const, _And): MorePrecedence,
+ (_Const, _Or): MorePrecedence,
+ (_Const, _BoolWordOp): MorePrecedence,
+ (_Const, _CloseP): MorePrecedence,
+ (_Const, _Comma): MorePrecedence,
+ (_Const, (Token.Text.Whitespace, '\n')): MorePrecedence,
+ (_Const, (Token.Text.Whitespace, ' ')): MorePrecedence,
  (_Format, (EndMarker, 'BODY')): MorePrecedence,
  (_Format, (EndMarker, 'CLAUSE')): MorePrecedence,
  (_Format, _Var): LessPrecedence,
  (_From, (Token.Text.Whitespace, ' ')): MorePrecedence,
  (_GroupBy, (EndMarker, 'BODY')): MorePrecedence,
  (_GroupBy, (EndMarker, 'CLAUSE')): MorePrecedence,
+ (_GroupBy, _Const): LessPrecedence,
  (_GroupBy, _Date): LessPrecedence,
  (_GroupBy, _Number): LessPrecedence,
  (_GroupBy, _Str): LessPrecedence,
  (_GroupBy, _Builtin): LessPrecedence,
- (_GroupBy, _Const): LessPrecedence,
  (_GroupBy, _Function): LessPrecedence,
  (_GroupBy, _Var): LessPrecedence,
  (_GroupBy, _Mult): LessPrecedence,
  (_OrderBy, (EndMarker, 'CLAUSE')): MorePrecedence,
  (_OrderBy, _Asc): LessPrecedence,
  (_OrderBy, _Desc): LessPrecedence,
+ (_OrderBy, _Const): LessPrecedence,
  (_OrderBy, _Date): LessPrecedence,
  (_OrderBy, _Number): LessPrecedence,
  (_OrderBy, _Str): LessPrecedence,
  (_OrderBy, _Builtin): LessPrecedence,
- (_OrderBy, _Const): LessPrecedence,
  (_OrderBy, _Function): LessPrecedence,
  (_OrderBy, _Var): LessPrecedence,
  (_OrderBy, _Mult): LessPrecedence,
  (_OrderBy, (Token.Text.Whitespace, ' ')): MorePrecedence,
  (_Pivot, (EndMarker, 'BODY')): MorePrecedence,
  (_Pivot, (EndMarker, 'CLAUSE')): MorePrecedence,
- (_Pivot, _Date): LessPrecedence,
- (_Pivot, _Number): LessPrecedence,
- (_Pivot, _Str): LessPrecedence,
- (_Pivot, _Builtin): LessPrecedence,
- (_Pivot, _Const): LessPrecedence,
- (_Pivot, _Function): LessPrecedence,
  (_Pivot, _Var): LessPrecedence,
- (_Pivot, _Mult): LessPrecedence,
- (_Pivot, _Plus): LessPrecedence,
- (_Pivot, _Minus): LessPrecedence,
- (_Pivot, _Div): LessPrecedence,
- (_Pivot, _OpenP): LessPrecedence,
  (_Pivot, _Comma): LessPrecedence,
  (_Pivot, (Token.Text.Whitespace, '\n')): MorePrecedence,
  (_Pivot, (Token.Text.Whitespace, ' ')): MorePrecedence,
  (_Select, (EndMarker, 'BODY')): MorePrecedence,
  (_Select, (EndMarker, 'CLAUSE')): MorePrecedence,
+ (_Select, _Const): LessPrecedence,
  (_Select, _Date): LessPrecedence,
  (_Select, _Number): LessPrecedence,
  (_Select, _Str): LessPrecedence,
  (_Select, _Builtin): LessPrecedence,
- (_Select, _Const): LessPrecedence,
  (_Select, _Function): LessPrecedence,
  (_Select, _Wildchar): SamePrecedence,
  (_Select, _Var): LessPrecedence,
  (_Select, (Token.Text.Whitespace, ' ')): MorePrecedence,
  (_Where, (EndMarker, 'BODY')): MorePrecedence,
  (_Where, (EndMarker, 'CLAUSE')): MorePrecedence,
+ (_Where, _Const): LessPrecedence,
  (_Where, _Date): LessPrecedence,
  (_Where, _Number): LessPrecedence,
  (_Where, _Str): LessPrecedence,
  (_Where, _Builtin): LessPrecedence,
- (_Where, _Const): LessPrecedence,
  (_Where, _Function): LessPrecedence,
  (_Where, _Var): LessPrecedence,
  (_Where, _Mult): LessPrecedence,
  (_Str, (Token.Text.Whitespace, '\n')): MorePrecedence,
  (_Str, (Token.Text.Whitespace, ' ')): MorePrecedence,
  (_Builtin, _OpenP): SamePrecedence,
- (_Const, (EndMarker, 'ARITHMETIC_EXPR')): MorePrecedence,
- (_Const, (EndMarker, 'BODY')): MorePrecedence,
- (_Const, (EndMarker, 'BOOL_EXPR')): MorePrecedence,
- (_Const, (EndMarker, 'BOOL_VALUE')): MorePrecedence,
- (_Const, (EndMarker, 'CLAUSE')): MorePrecedence,
- (_Const, (EndMarker, 'FACTOR')): MorePrecedence,
- (_Const, (EndMarker, 'ORDER_EXPR')): MorePrecedence,
- (_Const, (EndMarker, 'ORDER_SEQ')): MorePrecedence,
- (_Const, (EndMarker, 'OR_EXPR')): MorePrecedence,
- (_Const, (EndMarker, 'SEQ')): MorePrecedence,
- (_Const, (EndMarker, 'SIMPLE_EXPR')): MorePrecedence,
- (_Const, (EndMarker, 'TERM')): MorePrecedence,
- (_Const, (EndMarker, 'VALUE')): MorePrecedence,
- (_Const, _Asc): MorePrecedence,
- (_Const, _Desc): MorePrecedence,
- (_Const, _Mult): MorePrecedence,
- (_Const, _Plus): MorePrecedence,
- (_Const, _Minus): MorePrecedence,
- (_Const, _Div): MorePrecedence,
- (_Const, _BoolOp): MorePrecedence,
- (_Const, _And): MorePrecedence,
- (_Const, _Or): MorePrecedence,
- (_Const, _BoolWordOp): MorePrecedence,
- (_Const, _CloseP): MorePrecedence,
- (_Const, _Comma): MorePrecedence,
- (_Const, (Token.Text.Whitespace, '\n')): MorePrecedence,
- (_Const, (Token.Text.Whitespace, ' ')): MorePrecedence,
  (_Function, _OpenP): SamePrecedence,
  (_Wildchar, (EndMarker, 'BODY')): MorePrecedence,
  (_Wildchar, (EndMarker, 'CLAUSE')): MorePrecedence,
  (_Mult, (EndMarker, 'TERM')): MorePrecedence,
  (_Mult, _Asc): MorePrecedence,
  (_Mult, _Desc): MorePrecedence,
+ (_Mult, _Const): LessPrecedence,
  (_Mult, _Date): LessPrecedence,
  (_Mult, _Number): LessPrecedence,
  (_Mult, _Str): LessPrecedence,
  (_Mult, _Builtin): LessPrecedence,
- (_Mult, _Const): LessPrecedence,
  (_Mult, _Function): LessPrecedence,
  (_Mult, _Var): LessPrecedence,
  (_Mult, _Mult): MorePrecedence,
  (_Plus, (EndMarker, 'SEQ')): MorePrecedence,
  (_Plus, _Asc): MorePrecedence,
  (_Plus, _Desc): MorePrecedence,
+ (_Plus, _Const): LessPrecedence,
  (_Plus, _Date): LessPrecedence,
  (_Plus, _Number): LessPrecedence,
  (_Plus, _Str): LessPrecedence,
  (_Plus, _Builtin): LessPrecedence,
- (_Plus, _Const): LessPrecedence,
  (_Plus, _Function): LessPrecedence,
  (_Plus, _Var): LessPrecedence,
  (_Plus, _Mult): LessPrecedence,
  (_Minus, (EndMarker, 'SEQ')): MorePrecedence,
  (_Minus, _Asc): MorePrecedence,
  (_Minus, _Desc): MorePrecedence,
+ (_Minus, _Const): LessPrecedence,
  (_Minus, _Date): LessPrecedence,
  (_Minus, _Number): LessPrecedence,
  (_Minus, _Str): LessPrecedence,
  (_Minus, _Builtin): LessPrecedence,
- (_Minus, _Const): LessPrecedence,
  (_Minus, _Function): LessPrecedence,
  (_Minus, _Var): LessPrecedence,
  (_Minus, _Mult): LessPrecedence,
  (_Div, (EndMarker, 'TERM')): MorePrecedence,
  (_Div, _Asc): MorePrecedence,
  (_Div, _Desc): MorePrecedence,
+ (_Div, _Const): LessPrecedence,
  (_Div, _Date): LessPrecedence,
  (_Div, _Number): LessPrecedence,
  (_Div, _Str): LessPrecedence,
  (_Div, _Builtin): LessPrecedence,
- (_Div, _Const): LessPrecedence,
  (_Div, _Function): LessPrecedence,
  (_Div, _Var): LessPrecedence,
  (_Div, _Mult): MorePrecedence,
  (_BoolOp, (EndMarker, 'BOOL_VALUE')): MorePrecedence,
  (_BoolOp, (EndMarker, 'CLAUSE')): MorePrecedence,
  (_BoolOp, (EndMarker, 'OR_EXPR')): MorePrecedence,
+ (_BoolOp, _Const): LessPrecedence,
  (_BoolOp, _Date): LessPrecedence,
  (_BoolOp, _Number): LessPrecedence,
  (_BoolOp, _Str): LessPrecedence,
  (_BoolOp, _Builtin): LessPrecedence,
- (_BoolOp, _Const): LessPrecedence,
  (_BoolOp, _Function): LessPrecedence,
  (_BoolOp, _Var): LessPrecedence,
  (_BoolOp, _Mult): LessPrecedence,
  (_And, (EndMarker, 'BODY')): MorePrecedence,
  (_And, (EndMarker, 'BOOL_EXPR')): MorePrecedence,
  (_And, (EndMarker, 'CLAUSE')): MorePrecedence,
+ (_And, _Const): LessPrecedence,
  (_And, _Date): LessPrecedence,
  (_And, _Number): LessPrecedence,
  (_And, _Str): LessPrecedence,
  (_And, _Builtin): LessPrecedence,
- (_And, _Const): LessPrecedence,
  (_And, _Function): LessPrecedence,
  (_And, _Var): LessPrecedence,
  (_And, _Mult): LessPrecedence,
  (_Not, (EndMarker, 'BOOL_VALUE')): MorePrecedence,
  (_Not, (EndMarker, 'CLAUSE')): MorePrecedence,
  (_Not, (EndMarker, 'OR_EXPR')): MorePrecedence,
+ (_Not, _Const): LessPrecedence,
  (_Not, _Date): LessPrecedence,
  (_Not, _Number): LessPrecedence,
  (_Not, _Str): LessPrecedence,
  (_Not, _Builtin): LessPrecedence,
- (_Not, _Const): LessPrecedence,
  (_Not, _Function): LessPrecedence,
  (_Not, _Var): LessPrecedence,
  (_Not, _Mult): LessPrecedence,
  (_Or, (EndMarker, 'BOOL_EXPR')): MorePrecedence,
  (_Or, (EndMarker, 'CLAUSE')): MorePrecedence,
  (_Or, (EndMarker, 'OR_EXPR')): MorePrecedence,
+ (_Or, _Const): LessPrecedence,
  (_Or, _Date): LessPrecedence,
  (_Or, _Number): LessPrecedence,
  (_Or, _Str): LessPrecedence,
  (_Or, _Builtin): LessPrecedence,
- (_Or, _Const): LessPrecedence,
  (_Or, _Function): LessPrecedence,
  (_Or, _Var): LessPrecedence,
  (_Or, _Mult): LessPrecedence,
  (_BoolWordOp, (EndMarker, 'BOOL_VALUE')): MorePrecedence,
  (_BoolWordOp, (EndMarker, 'CLAUSE')): MorePrecedence,
  (_BoolWordOp, (EndMarker, 'OR_EXPR')): MorePrecedence,
+ (_BoolWordOp, _Const): LessPrecedence,
  (_BoolWordOp, _Date): LessPrecedence,
  (_BoolWordOp, _Number): LessPrecedence,
  (_BoolWordOp, _Str): LessPrecedence,
  (_BoolWordOp, _Builtin): LessPrecedence,
- (_BoolWordOp, _Const): LessPrecedence,
  (_BoolWordOp, _Function): LessPrecedence,
  (_BoolWordOp, _Var): LessPrecedence,
  (_BoolWordOp, _Mult): LessPrecedence,
  (_BoolWordOp, _CloseP): MorePrecedence,
  (_BoolWordOp, (Token.Text.Whitespace, '\n')): MorePrecedence,
  (_BoolWordOp, (Token.Text.Whitespace, ' ')): MorePrecedence,
+ (_OpenP, _Const): LessPrecedence,
  (_OpenP, _Date): LessPrecedence,
  (_OpenP, _Number): LessPrecedence,
  (_OpenP, _Str): LessPrecedence,
  (_OpenP, _Builtin): LessPrecedence,
- (_OpenP, _Const): LessPrecedence,
  (_OpenP, _Function): LessPrecedence,
  (_OpenP, _Var): LessPrecedence,
  (_OpenP, _Mult): LessPrecedence,
  (_Comma, (EndMarker, 'SEQ')): MorePrecedence,
  (_Comma, _Asc): LessPrecedence,
  (_Comma, _Desc): LessPrecedence,
+ (_Comma, _Const): LessPrecedence,
  (_Comma, _Date): LessPrecedence,
  (_Comma, _Number): LessPrecedence,
  (_Comma, _Str): LessPrecedence,
  (_Comma, _Builtin): LessPrecedence,
- (_Comma, _Const): LessPrecedence,
  (_Comma, _Function): LessPrecedence,
  (_Comma, _Var): LessPrecedence,
  (_Comma, _Mult): LessPrecedence,
  ((Token.Text.Whitespace, ' '), _Where): LessPrecedence,
  ((Token.Text.Whitespace, ' '), (Token.Text.Whitespace, '\n')): MorePrecedence,
  ((Token.Text.Whitespace, ' '), (Token.Text.Whitespace, ' ')): MorePrecedence}
+