[antlr-interest] Antlrworks quirky behaviour ?
Pranab Dhar
pdhar at tibco.com
Wed Jun 13 18:02:43 PDT 2007
Hi,
I am noticing a weird behaviour in antlrworks. It is with this
grammar while building the AST.
postfixOp:
'.'
| '@'
;
postfixExpr :
(
primaryExpr -> primaryExpr
)
(
(lc=TOK_LBRACK i=index TOK_RBRACK) ->
^(ARRAY_INDEX[$lc,"ARRAY_INDEX"] $postfixExpr $i)
|
(
p=postfixOp li=labelIdentifier
(
al=argList ->
^(FUNCTION_EXPRESSION[$li.start,"FUNCTION_EXPRESSION"] ^($p $postfixExpr
$li) $al )
| /* NOTHING */ -> ^($p $postfixExpr $li)
)
)
)*
;
When I use the grammar above the AST tree shown in antlrworks does not
show the tree below the FUNCTION_EXPRESSION while the stringTree is
correctly shown as a result of the getTree() api call.
(PROJECTION (ALIAS_CLAUSE (FUNCTION_EXPRESSION (. Datetime now)
ARG_LIST)))
When the grammar is modified to remove the AST rewrite rules and use ^ |
operators the tree is shown correctly in the antlrworks.
The dilemma is which one to believe is correct.
Pranab
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070613/c64161a7/attachment.html
More information about the antlr-interest
mailing list