[antlr-interest] Regular Expressions (2)

Brad Cox bradjcox at gmail.com
Wed Jul 4 16:50:24 PDT 2012


Have you considered switching to antlr3 and have you looked at
http://www.antlr.org/grammar/1212699960054/ObjectiveC2ansi.g?

On Wed, Jul 4, 2012 at 7:26 PM, Daniela da Cruz <danieladacruz at gmail.com>wrote:

> Hi Ale
>
> Thanks for your reply. I have been working a bit more in the grammar and
> have done the following test and it simply stops at '@' character. Any idea
> why?
>
> *class CParser extends Parser;*
> *
> *
> options {    k=1;    defaultErrorHandler = false;}
>
> class_interface : "@interface" IDENTIFIER "@end" ;
>
> *class CLexer extends Lexer;*
>
> options{
> testLiterals=false; // don't automatically test for literals
>  k=2;
> charVocabulary='\u0000'..'\uFFFE';
> }
>
> IDENTIFIER : LETTER (LETTER|'0'..'9')*;
> protected LETTER: 'A'..'Z'  | 'a'..'z'  | '_' ;
>
>
> On Thu, Jul 5, 2012 at 12:22 AM, Ale Strooisma <alestrooisma at gmx.net>
> wrote:
>
> > I guess this would work:
> >
> > AT_PROTECTED : AT "protected";
> > AT_PRIVATE : AT "private";
> > fragment AT : "@";
> >
> > Good luck,
> > Ale
> >
> > On 07/05/2012 12:20 AM, Daniela da Cruz wrote:
> > > Sorry. The previous email was sent before I finish it.
> > >
> > > Hello all
> > >
> > > I am developing an Objective-C 2.0 grammar using the Antlr v2.7.
> > > The problem I'm facing is that there exist some ambiguous reserved
> words.
> > > For instance and using k = 1 in Lexer, there exist
> > >
> > > @protected, @private, @public, @interface, in, inout, ...
> > >
> > > defining these regular expressions like:
> > >
> > > AT_PROTECTED : "@protected" ;
> > > AT_PRIVATE : "@private" ;
> > >
> > > Using this approach, of course, I get a lot of warnings because they
> are
> > > ambiguous.
> > >
> > > How do you suggest to solve them?
> > >
> > > Factorize them and then set the token type accordingly?
> > >
> > > Thanks
> > > daniela
> > >
> > > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > > Unsubscribe:
> > http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> > >
> >
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe:
> > http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> >
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>



-- 
Cell: 703-594-1883
Blog: http://bradjcox.blogspot.com
Web: http://virtualschool.edu
Manassas VA 20111


More information about the antlr-interest mailing list