Newbie: grammar, identifying STRING vs ID [message #756484] |
Sun, 13 November 2011 17:40  |
Eclipse User |
|
|
|
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 18:46   |
Eclipse User |
|
|
|
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.04584 seconds