[antlr-interest] Composite tree grammar

Bill Andersen andersen at ontologyworks.com
Wed Oct 8 12:59:57 PDT 2008


Everyone,

Yesterday I described a problem with composite tree grammars  
(below).   Can't tell for sure if it's an ANTLRWorks problem, but even  
doing code gen on the second file (which ought to have no dependencies  
on the third) breaks.  Same grammar error reported as before.

Begin forwarded message:

> From: Bill Andersen <andersen at ontologyworks.com>
> Date: October 7, 2008 1:02:06 PM EDT
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Composite tree grammar
>
> Folks,
>
> I want to use grammar import on tree grammars and did the test below  
> using ANTLRWorks 1.2.  I wrote a simple grammar (Foo) to output an  
> AST, a tree grammar (FooAST) to parse the latter, and another  
> (FooASTImport) that imports FooAST and attempts to override the one  
> rule in FooAST.  Code here.  I get a syntax error (in attached  
> snapshot) but can't see where I'm going wrong.  Any help appreciated.
>
> 	.bill
>
> grammar Foo;
> options {
> 	output=AST;
> }
> tokens {
> 	FOO = 'foo';
> 	BAR = 'bar';
> 	ZAP;
> }
> start
> 	: FOO BAR
> 		-> ^(ZAP FOO BAR)
> 	;
> 	
> -----------------------------------
>
> tree grammar FooAST;
> options {
> 	tokenVocab=Foo;
> 	output=AST;
> }
> start
> 	: ^(ZAP FOO BAR)
> 		-> ^(ZAP BAR FOO)
> 	;
>
> -----------------------------------
>
> tree grammar FooASTImport;
> import FooAST;
>
> options {
> 	tokenVocab=Foo;
> 	output=AST;
> }
>
> start
> 	: ^(ZAP FOO BAR)
> 		-> ^(ZAP FOO BAR)
> 	;
>
>
>
>
> Bill Andersen
> Ontology Works, Inc. (www.ontologyworks.com)
> 3600 O'Donnell Street, Suite 600
> Baltimore, MD 21224
> Office: +1.410.675.1201
> Cell: +1.443.858.6444
> Fax: +1.410.675.1204
>
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

Bill Andersen
Ontology Works, Inc. (www.ontologyworks.com)
3600 O'Donnell Street, Suite 600
Baltimore, MD 21224
Office: +1.410.675.1201
Cell: +1.443.858.6444
Fax: +1.410.675.1204




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081008/772406ff/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedGraphic.png
Type: image/png
Size: 20289 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20081008/772406ff/attachment.png 


More information about the antlr-interest mailing list