Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to build a correct grammar without conflicting keywords and ID's
How to build a correct grammar without conflicting keywords and ID's [message #1115679] Tue, 24 September 2013 12:27 Go to next message
Joerg Thiemer is currently offline Joerg Thiemer
Messages: 8
Registered: July 2010
Junior Member
Hello,

I'm not so familiar with ANTLR grammar and I have the following problem.

Here's a snipped of my grammar:

Model:
(alias+=Alias | field+=FieldFormat)*
;
Alias:
'alias' alias=ID string=ID
;

FieldFormat: {FieldFormat}
'format' typ=FormatType?
;

FormatType:
('r'|'z'|'l')
;

How can I avoid that

'alias r anytext' causes an error 'extraneous input 'r' expecting RULE_ID
or at
'alias f format' - 'missing RULE_ID at 'format'

Thank you
Joerg
Re: How to build a correct grammar without conflicting keywords and ID's [message #1115683 is a reply to message #1115679] Tue, 24 September 2013 12:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi,

you have to introduce an datatype rule e.g.

XID: ('r'|'z'|'l'|ID);

Alias:
'alias' alias=XID string=XID
;
Re: How to build a correct grammar without conflicting keywords and ID's [message #1116230 is a reply to message #1115683] Wed, 25 September 2013 05:57 Go to previous message
Joerg Thiemer is currently offline Joerg Thiemer
Messages: 8
Registered: July 2010
Junior Member
Thank you, it works...
Previous Topic:Problem with Super Grammar and an Ecore based SubGrammar
Next Topic:Declarative scope provider disabling qualified namespace
Goto Forum:
  


Current Time: Fri Oct 24 15:03:29 GMT 2014

Powered by FUDForum. Page generated in 0.02069 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software