Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Help with simple grammar
icon5.gif  Help with simple grammar [message #985956] Fri, 16 November 2012 20:58 Go to next message
Andrew A is currently offline Andrew AFriend
Messages: 9
Registered: June 2012
Junior Member
I have a grammar:
Model: statements+=Statement*;
	
Statement: Var | Macro | WS;

Var: '{' '#' value=ID '}' ;
	
Macro: '#macro' '{' value=ID'}';


This parsed succesfull
#macro{x}
{#v}


but this not:
#macro{x}
{#m}

and this is not:
#macro{x}
{#mac}


It seems to be that parser expects #macro (where #m or #mac)

I don't understand why. Could you help me, please?
Re: Help with simple grammar [message #985965 is a reply to message #985956] Fri, 16 November 2012 21:11 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 6543
Registered: July 2009
Senior Member
Hi,

the problem is: keywords are terminals. and the lexer that reads terminals eats as much as it can

=>

Var: '{' '#' value=ID '}' ;

Macro: '#''macro' '{' value=ID'}';
Re: Help with simple grammar [message #986097 is a reply to message #985956] Sun, 18 November 2012 19:22 Go to previous message
Martin Baker is currently offline Martin BakerFriend
Messages: 31
Registered: July 2009
Member
I keep getting caught out with this type of issue. To help me think it through I created Example1 and Example2 on this page.

Martin
Previous Topic:Selection for a type system
Next Topic:terminal ID with prefix!
Goto Forum:
  


Current Time: Thu Dec 18 15:39:00 GMT 2014

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

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