[antlr-interest] On "Heterogeneous tree nodes"
Juan Ignacio Gelos
juang at evolutio.com.ar
Mon Mar 2 09:34:12 PST 2009
Hello,
I'm trying to map SQL queries to ASTs. My idea for the final AST is to have
tree of objects whose classes represent actual language constructs and
database objects. i.e., for starters I want a TableColumn class for the
nodes representing database columns, for example those specified in the
SELECT clause of the SELECT statement (SELECT col1, col2, col3, ... )
Now, to determine that this token is a column, I need to do so through
"nested" parser rules, eg.
column :
dbObject //<ColumnNode>
-> ^( COLUMN dbObject )
dbObject :
identifier ( DOT identifier ) *
;
identifier :
NonQuotedIdentifier
| QuotedIdentifier
;
I want to map this column token to a class named ColumnNode (as you see in
the commented out token option which does not work because dbObject isn't a
lexer rule.
Of course, dbObject and identifier are rules used elsewhere througout the
grammar.
What's the approach to take? a) Can I get the context of the node in the
TreeAdaptor, b) is there any way to make the <token=...> option to work with
parser rules, c) do I need to rephrase the rules in any way to allow for any
of this?
Thanks in advance for any tips/help with this.
Saluda atte.,
Juan Ignacio Gelos
Evolutio Software
juang at evolutio.com.ar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090302/91dc1170/attachment.html
More information about the antlr-interest
mailing list