[antlr-interest] Newbie questions
Vaclav Barta
vbar at comp.cz
Wed Aug 8 02:42:22 PDT 2007
Adnan Siddiqi wrote:
> confusion for me that how to extract data after successful parsing?
Well, there's a couple of ways...
> Let me explain you further that I have to create a SQL QUERY like
> language for a web portal where different 'custom objects' would be
> add/retrieved by using SQL like language. for example:
>
> "Select objModule from Module Respositoary where @type='entertainment' "
>
> now lets suppose i successfully generate grammer and parse as well by
> using ANTLR generated code. Now How do I pick required 'objModule' of
> type ='entertainment'? can ANTLR allows to make custom functions
> which should be parsed after successful parsing? if not then should I
Yes, that's one way - they're called actions, can be specified as part
of your grammar and can contain any Java code you need at that point.
> pick values from SYMBOL TABLE?
There's another way, where you just generate AST (abstract syntax tree)
and work on it outside the grammar (i.e. by writing _another_ so called
tree parser), but I really wouldn't recommend that - that way didn't
exist in 1998 (other than as a gleam in some computer scientist's eye
:-) ), so you haven't seen it before, and I fail to see the advantages
of complicating my parsing that way - but of course, perhaps it's just
because I don't understand...
Bye
Vasek
P.S.: If you're doing something like SQL, there's an SQL grammar (for
the previous version of ANTLR) at
http://www.antlr.org/grammar/1062280680642/MS_SQL_SELECT.html , which I
found quite useful.
More information about the antlr-interest
mailing list