[antlr-interest] Composite tree grammar

Gavin Lambert antlr at mirality.co.nz
Wed Oct 8 23:41:46 PDT 2008


At 06:02 8/10/2008, Bill Andersen wrote:
 >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.
[...]
 >tree grammar FooAST;
 >options {
 >	tokenVocab=Foo;
 >	output=AST;
 >}
 >start
 >	: ^(ZAP FOO BAR)
 >		-> ^(ZAP BAR FOO)
 >	;

Given that the attached screenshot reports an error on line 10 of 
FooAST.g, and there doesn't appear to be that many lines in the 
file, I suspect some kind of EOL problem.

Especially since you're on MacOS.  Maybe the file is being saved 
with Mac CR-only line endings (or some other strange 
construction), while ANTLR requires either LF-only or CRLF.



More information about the antlr-interest mailing list