This is very well discussed in the book ANTLR - Definitive Reference.

Basically mostly people will construct a tree out of the grammar. The
library identifies the common usage and provides a solution for it.

Gokul.

On Fri, Jul 29, 2011 at 6:19 PM, Colin Yates <[email protected]> wrote:

> Hi all,
>
> I understand that the ANTLR grammar can produce an intermediate form tree
> which is then parsed or you can provide code snippets to build up your own
> internal representation.
>
> I have always used the second, for example:
>
> departmentDefinition returns[DepartmentDefinition value]
>
>        @init {$value = new DepartmentDefinition(); }
>
>        : DEPARTMENT singleReferenceDataDefinition {
> $value.setDepartmentDefinition($singleReferenceDataDefinition.value);
> } departmentStatements[$value]+
>
>
>
>
> This seems a much more natural approach, and I have implemented a handful
> of
> pretty complex grammars this way, but I get the sense that trees are the
> preferred approach.
>
> My question is why - what benefit do they get you?
>
> The reason I want to know is I am about to embark on a library for editing
> documents defined by an ANTLR grammar with syntax highlighting etc. (see my
> next email :)) and I want to make sure I am not sending myself up an alley
> :)
>
> Col
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to