History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ANTLR-301
Type: Bug Bug
Status: Reopened Reopened
Priority: Major Major
Assignee: Terence Parr
Reporter: Terence Parr
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ANTLR v3

headers not injected into delegates

Created: 18/Jun/08 12:08 PM   Updated: 18/Aug/08 11:41 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 3.1.1


 Description  « Hide
dimitrios Kolovos wwrote:

In the composite-java example that demonstrates the new "import" feature of 3.1 none of the parsers/lexers define @header or @lexer::header and as a result all generated classes do not contain a package declaration. Now, if I add

@header{package demo;}

and

@lexer::header{package demo;}

in Java.g, the JavaLexer and JavaParser contain the "package demo;" declaration but all the other files that are generated from sub-grammars (e.g. Java_JavaAnnotations, Java_JavaDecl) do not contain a package declaration. To add a package declaration to them I need to go in each sub-grammar and add a @header{package demo;}.

Is there a way to get package declarations in files generated by sub-grammars only by setting @header{}/@lexer::header{} in the top-level grammar?

Cheers,
Dimitrios



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Terence Parr - 05/Aug/08 12:23 PM
Made Grammar.defineNamedAction propogate header actions down to all delegates if root grammar; regardless of lexer/parser scope.

Terence Parr - 18/Aug/08 11:41 AM
Lars Hamann says:

When defining @lexer::header{} in a root grammar which is including a parser grammar the following error occurs:
error(143): GOCLBase.g:92:1: unknown or invalid action scope for parser grammar: lexer

Interisting information on top: The error is in the file "GOCL.g" at line 92 which is the root grammar and not in GOCLBase.g. This was confusing me a little bit.