« Return to Thread: parsing conflict

parsing conflict

by eugenio_ :: Rate this Message:

Reply to Author | View in Thread

Hello,
I have a conflict problem and I don't know how to manage.

The grammar is like this:

void a() : {}
{
   <TOKEN1> (b()|c())
}

void b() : {}
{
  identifier() <COLON> attribute1()
}

void c() : {}
{
  identifier() <COMMA> attribute2()
}

void identifier() : {}
{
  t = <IDENTIFIER> { jjtThis.setName(t.image); }
}

TOKEN :
{
   < IDENTIFIER : <LETTER> (<LETTER>|<DIGIT>)* >
   .......
}

I get a conflict error because of <IDENTIFIER> in the rule a(). Now I moved the identifier() in the rule a() but I would like to maintain rules as they are here. It seems that each part of the IDENTIFIER is a token and not all the IDENTIFIER is a token. In Antlr things are different. Is it possible to specify a token (using MORE for example) in order to have an IDENTIFIER as a single token and don't have the choice conflict?

Thank you very much for the attention

 « Return to Thread: parsing conflict