[antlr-interest] Antlr v2 conflict

Daniela da Cruz danieladacruz at gmail.com
Wed Jul 25 07:37:47 PDT 2012


Thanks Jim for your reply.

So far I have:

declaration: declaration_specifiers declarator;

declaration_specifiers: (type_qualifier | type_specifier)+

declarator: IDENT

type_specifier: "int" | ... | IDENT

both the type_specifier and declarator can be IDENT => Conflict.

Having such rule "id" as you suggest I would then only have:

type_specifier: id

But even this way I would have the same conflict since both the
type_specifier and declarator have "id". do you agree?

thanks
daniela

On Wed, Jul 25, 2012 at 3:22 PM, Jim Idle <jimi at temporal-wave.com> wrote:

> It sounds like you are treating all keywords as reserved words and so not
> allowing them to be identifiers. You will need to change your rules.
>
> Instead of referencing say ID directly use a parser rule id and add the
> keywords that can be ID in to the rule:
>
> id : ID | KEY1 | KEY2 ....
>
> You can change the token type of the keywords in that rule.  You may need
> to add predicates to avoid ambiguity warnings.
>
> Jim
>
> On Jul 25, 2012, at 4:29 AM, Daniela da Cruz <danieladacruz at gmail.com>
> wrote:
>
> > Hi
> >
> > I am developing a grammar for Objective-C using Antlr v2.7 (unfortunately
> > v3 is not an option).
> >
> > The problem I am facing is that a type name can be a builtin type or a
> > Cocoa type of a type defined using typedefs. This causes a conflict with
> > the name of a variable that is also an Identifier.
> >
> > Any idea of how can I solve this conflict?
> >
> > thanks
> > daniela
> >
> > 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