Greetings,

Let me raise the question again.  Sorry that this is becoming something
of pattern for me.

Adding a dynamically scoped attribute to a lexer rule seems to generate
the error message (shown at the bottom as part of my previous post on
this subject) when generating recognizers.

The grammar is as follows:
---------------------

grammar Junkscript;



NEWLINE 
@init { $channel=HIDDEN; }
        :       '\n'
        ;
        

COMMENT
/*
scope {
        String dynamic;
        }
@init {
        $COMMENT::dynamic = null;
        }
        */
        :       '#' ( options {greedy=false;} : (~ NEWLINE)* ) ;


stmt    :       
        ( . )+
        ;
        


------------------------

The simple grammar works fine, but with the "scope" section (along with
init action) under COMMENT uncommented, Antlr generates the error.

Are dynamically scoped attributes allowed for lexer rules?   If so, what
is the error in the grammar above?

Thanks for any assistance.

Junkman

Junkman wrote:
> Greetings,
> 
> I've added an attribute with dynamic scoping to a lexer rule, and when
> generating code, I'm encountering an "internal error".  Listed below is
> partial call stack reported:
> 
> error(10): internal error: Junkscript.g : java.lang.NullPointerException
>       
> org.antlr.grammar.v2.DefineGrammarItemsWalker.ruleScopeSpec(DefineGrammarItemsWalker.java:1050)
>       at
> org.antlr.grammar.v2.DefineGrammarItemsWalker.rule(DefineGrammarItemsWalker.java:891)
>       at
> org.antlr.grammar.v2.DefineGrammarItemsWalker.rules(DefineGrammarItemsWalker.java:576)
>       at
> org.antlr.grammar.v2.DefineGrammarItemsWalker.grammarSpec(DefineGrammarItemsWalker.java:361)
>       at
> org.antlr.grammar.v2.DefineGrammarItemsWalker.grammar(DefineGrammarItemsWalker.java:193)
>       at org.antlr.tool.Grammar.defineGrammarSymbols(Grammar.java:702)
>       at
> org.antlr.tool.CompositeGrammar.defineGrammarSymbols(CompositeGrammar.java:351)
> ...
> 
> 
> Is dynamic scoping allowed for lexer rule attributes?
> 
> Thanks for any info.
> 
> J
> 
> 
> 
> 
> 


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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to