Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Newbie: grammar, identifying STRING vs ID
Newbie: grammar, identifying STRING vs ID [message #756484] Sun, 13 November 2011 17:40 Go to next message
Eclipse UserFriend
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 18:46 Go to previous messageGo to next message
Eclipse UserFriend
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 01:04 Go to previous message
Eclipse UserFriend
Thanks, worked great
Previous Topic:Passing Arguments
Next Topic:Entities extend other entities
Goto Forum:
  


Current Time: Sun Jul 06 04:39:25 EDT 2025

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

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

Back to the top