[antlr-interest] how to define a named scope

Jim Idle jimi at temporal-wave.com
Wed Aug 11 09:52:07 PDT 2010


Order is:

parser x;
options
tokens
scope MyScope { int x; }
@lexer
@parser
Parser rules
Lexer rules

In the new grammar for ANTLR 4 I allowed the sections to appear in arbitrary
order as this used to bug me too ;-)

Jim


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of William Tribbey
> Sent: Wednesday, August 11, 2010 9:39 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] how to define a named scope
> 
> Hello Everybody, I am trying to use a named scope. I have searched the
> archives and I find a reference to the same question from last year
(posted
> below) that describes the problem I am having. I have the book and am
> looking at the same page. I feel like I am missing a piece of information
that I
> need to get this to work.
> 
> Cheers / Will T.
> 
> 
> [antlr-interest] Position of 'scope' delcaration*Bill Steer* steerr at
> bellsouth.net
> <https://mail.google.com/a/tribbey.net/mail/?extsrc=mailto&url=mailto%3A
> antlr-interest%2540antlr.org%3FSubject%3DRe%3A%2520%255Bantlr-
> interest%255D%2520Position%2520of%2520%2527scope%2527%2520delcarat
> ion%26In-Reply-To%3D%253C4A099F11.5070001%2540bellsouth.net%253E>
> *Tue May 12 09:08:49 PDT 2009*
> 
> 
>    - Previous message: [antlr-interest] Advice on using Antlr in
> Eclipse<034452.html>
>    - Next message: [antlr-interest] C# grammar for ANTRL3 <034454.html>
>    - *Messages sorted by:* [ date ] <date.html#34453> [ thread
> ]<thread.html#34453>
>     [ subject ] <subject.html#34453> [ author ] <author.html#34453>
> 
> ------------------------------
> 
> The book says, at the bottom of page 143, "Simply define a named scope
> outside any rule."  If I put a named scope just before the first rule, I
get an
> error "unexpected token: scope" when generating code.  Where should the
> 'scope' statement appear in the .g file?
> 
> Thanks.
> 
> Bill
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address



More information about the antlr-interest mailing list