Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Newbie: grammar, identifying STRING vs ID
Newbie: grammar, identifying STRING vs ID [message #756484] Sun, 13 November 2011 22:40 Go to next message
Tony BenBrahim is currently offline Tony BenBrahimFriend
Messages: 2
Registered: November 2011
Junior Member
Given the following fragment in the grammar, 'with' 'display' display+=(ID|STRING)+
the model that is generated has display as EList<String>.

This causes a problem in the following usage:
references employess with display last_name ", " first_name

where in Xtend, I cannot figure out which is a string, which should be output single quoted, and an identifier, which should be output as is (The double quotes are gone in the list, just have the string comma followed by space).

Thanks in advance, have just been using Xtext/Xtend for a few hours, and already generating java and pl/sql artifacts, great toolkit, going to get rid of a lot of boring work. Razz
Re: Newbie: grammar, identifying STRING vs ID [message #756486 is a reply to message #756484] Sun, 13 November 2011 23:46 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
As the type of both ID and STRING is a java String, the information in
the grammar is erased.

A simple way is to introduce additional Literal intermediaries.

StringLiteral : LiteralID | LiteralSTRING ;

LiteralID : value = ID;
LiteralSTRING : value = STRING;


and use it

Rule : display += StringLiteral+

- henrik


On 11/13/11 11:40 PM, Tony BenBrahim wrote:
> Given the following fragment in the grammar, 'with' 'display'
> display+=(ID|STRING)+ the model that is generated has display as
> EList<String>.
>
> This causes a problem in the following usage:
> references employess with display last_name ", " first_name
>
> where in Xtend, I cannot figure out which is a string, which should be
> output single quoted, and an identifier, which should be output as is
> (The double quotes are gone in the list, just have the string comma
> followed by space).
>
> Thanks in advance, have just been using Xtext/Xtend for a few hours, and
> already generating java and pl/sql artifacts, great toolkit, going to
> get rid of a lot of boring work. :p
Re: Newbie: grammar, identifying STRING vs ID [message #756505 is a reply to message #756486] Mon, 14 November 2011 06:04 Go to previous message
Tony BenBrahim is currently offline Tony BenBrahimFriend
Messages: 2
Registered: November 2011
Junior Member
Thanks, worked great
Previous Topic:Passing Arguments
Next Topic:Entities extend other entities
Goto Forum:
  


Current Time: Wed Mar 03 07:07:42 GMT 2021

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

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

Back to the top