[antlr-interest] Issues with Tree Grammar
Ney, Richard
Richard.Ney at Aspect.com
Tue Apr 19 18:49:16 PDT 2005
I have an existing tree grammar that I have to modify to handle a slight
modification. Currently as shown in the listed grammer the
groupExpression is based off of the mathExpression.
selectColumn
: #(SELECT_COLUMN (column = groupExpression a = objectAlias))
| #(SELECT_STAR STAR)
;
objectAlias
: a:ALIAS
| /* empty */
;
distinct
: "distinct"
| /* empty */
;
groupExpression
: #("avg" column = mathExpression)
| #("sum" column = mathExpression)
| #("count" dist = distinct (column = fieldName | STAR))
| #("max" column = mathExpression)
| #("min" column = mathExpression)
| column = mathExpression
;
mathExpression
: #(PLUS left = mathExpression right = mathExpression)
| #(MINUS left = mathExpression right = mathExpression)
| #(STAR left = mathExpression right = mathExpression)
| #(DIV left = mathExpression right = mathExpression)
| #(MOD left = mathExpression right = mathExpression)
| result = expression
;
expression
: result = fieldName
| node = unaryExpression
;
Now based on a change in requirements I now need to be able to form a
mathExpression that has the left or right sides as a groupExpression
trees. Can someone recommend a simple way to modify the grammar to add
this support while avoiding the recursive grammar?
Richard Ney
Principal Software Engineer
Aspect Communications
1310 Ridder Park Drive
San Jose, CA 95131-2313
916.797.9602 Home Office
408.325.2464 SJ Office
www.aspect.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050419/58f157b4/attachment-0001.html
More information about the antlr-interest
mailing list