I think I've identified a couple bugs in the grammar provided by AIP-160:
-3 = x would be parsed as -(3 = x), which (because NOT and MINUS are interchangeable) is equivalent to NOT (3 = x), which evaluates to true when x is -3 but also when x is -2.
Another issue with negative number literals: x = -3 doesn't parse. (From an ANTLR4-generated parser, I get extraneous input '-' expecting {'NOT', 'AND', 'OR', STRING, TEXT, '('}.)
restriction is defined as comparable [comparator arg], which doesn't allow whitespace around comparators. It should be something like comparable [[WS] comparator [WS] arg] (or comparable (WS? comparator WS? arg)? in .g4/ANTLR4 syntax).
This is probably not exhaustive - just what I've found after a few hours of playing with ANTLR4.
Given these bugs, I have to assume this grammar isn't actually what Google is using in prod. Would it be possible to update the grammar file to one that is a bit more battle-tested?
Well, the first two issues were resolved when I updated my TEXT terminal to include the - character. I suppose that's my mistake. But a related request is: could AIP-160 be updated to include a lexis?
I think I've identified a couple bugs in the grammar provided by AIP-160:
-3 = x
would be parsed as-(3 = x)
, which (becauseNOT
andMINUS
are interchangeable) is equivalent toNOT (3 = x)
, which evaluates to true when x is-3
but also when x is-2
.x = -3
doesn't parse. (From an ANTLR4-generated parser, I getextraneous input '-' expecting {'NOT', 'AND', 'OR', STRING, TEXT, '('}
.)comparable [comparator arg]
, which doesn't allow whitespace around comparators. It should be something likecomparable [[WS] comparator [WS] arg]
(orcomparable (WS? comparator WS? arg)?
in .g4/ANTLR4 syntax).This is probably not exhaustive - just what I've found after a few hours of playing with ANTLR4.
Given these bugs, I have to assume this grammar isn't actually what Google is using in prod. Would it be possible to update the grammar file to one that is a bit more battle-tested?