When I define ANTLR SQL99 grammar, I encountered the problem that SQL grammar has rules that are mutually left-recursive.
For example, the boolean value expression is cyclic as following:
boolean value expression
-> boolean term
-> boolean factor
-> boolean test
-> boolean primary
-> predicate
-> comparison predicate
-> row value expression
-> row value special case
-> value expression
-> boolean value expression
So, I think that I define the value expression as the root,
value expression
-> boolean value expression
-> boolean term
-> boolean factor
-> boolean test
-> boolean primary
-> predicate
-> comparison predicate
-> row value expression
-> row value special case
-> (value expression is omitted)
and the place that boolean value expression is referenced by the other element of grammar is rewritten by the value expression.
Similarly, the row value expression is rewritten by the value expression, but I encountered a problem again.
The row value expression is refered by both comparison predicate and between predicate.
But I don't know the priority of the comparison and between predicates.
For instance, the following expression
A = B BETWEEN C AND D
is
(A = B) BETWEEN C AND D
or
A = (B BETWEEN C AND D)
?
First, I will define priority of the predicates in order of the grammar definition.
No comments:
Post a Comment