[antlr-interest] Comments
Loring Craymer
Loring.G.Craymer at jpl.nasa.gov
Mon Feb 21 01:44:58 PST 2005
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Marcel Cerveny
> Sent: Monday, February 21, 2005 1:33 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Comments
>
> Hello there!
>
> I'm a complete newbie to antlr. I need to parse files with reasonably
> simple structure. So far so good.
> However, some issues popped up.
>
> 1. When creating an abstract syntax tree (I'm a lamer and all I know
> is what I read in a few examples/papers on Internet) it seems to me
> that AST can have only the form of a binary tree. Is that right?
No--ANTLR builds child-sibling trees. A node can have any number of
children or siblings.
>
> 2. If AST can be also non-binary tree, Is there any possibility to say
> to AST that I do not care about the order of say leaves (i.e. function
> parameters etc.) For example having function definition "void foo (int
> a, int b, int c);" where the order does not matter?
No, ANTLR constructs trees in the order that it encounters tokens, except
for ! and ^ annotation.
> 3. Is there a nice antlr template for parsing and consequentially
> skipping single- and multi-line comment? If yes or if someone
> experienced can give me hints, I'd really appreciate it.
Take a look at the sample grammars at www.antlr.org. Specifically, the Java
grammar should help.
> Thank you in advance for your answers.
>
> Marcel Cerveny
More information about the antlr-interest
mailing list