Newbie: grammar, identifying STRING vs ID [message #756484] |
Sun, 13 November 2011 22:40 |
Tony BenBrahim 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.
|
|
|
Re: Newbie: grammar, identifying STRING vs ID [message #756486 is a reply to message #756484] |
Sun, 13 November 2011 23:46 |
Henrik Lindberg 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.05630 seconds