Skip to main content


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 offline Christian DietrichFriend
Messages: 14665
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'}';


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Help with simple grammar [message #986097 is a reply to message #985956] Sun, 18 November 2012 19:22 Go to previous message
Martin Mising name is currently offline Martin Mising nameFriend
Messages: 32
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: Sat Apr 20 02:50:59 GMT 2024

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

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

Back to the top