[antlr-interest] Regular Expressions (2)

Daniela da Cruz danieladacruz at gmail.com
Wed Jul 4 16:26:52 PDT 2012


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
>


More information about the antlr-interest mailing list