|
Re: Cross References & Strings [message #639869 is a reply to message #639454] |
Thu, 18 November 2010 08:40 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
1) Try
StringOrId:
STRING | ID;
Prefix:
'prefix' name=StringOrID;
Command:
prefix=[Prefix|StringOrID] ...
By default, cross references are expected to have the Syntax of an ID.
So prefix=[Prefix] is the same as prefix=[Prefix|ID]. If you don't want
that, you have to put the rule for the Syntax after a | in the square
brackets, as sketched above.
2) You don't have to, just use the delegating datatype rule as described
above.
3) If you don't provide a value converter, the plus sign will be part of
the String.
Am 16.11.10 17:11, schrieb PTavares:
> Hi to all!
> I need to devoloped a parser and I come across with xtext a couped weeks
> ago.
> I love it but I have some doubts that I like to been explained.
>
> 1.) If I have something like this:
>
> Prefix:
> 'prefix' name=(STRING|ID);
>
> Command:
> prefix=[Prefix] ':' arg=ID;
>
> Why I only get the cross reference if the "prefix" is ID? And how can I
> resolve it to get with cross reference with a string but unquoted?
>
>
> 2.) If my parser needs to allow something like this:
> The following strings are equivalent:
>
> hello
> "hello"
> 'hello'
> "hel" + "lo"
> 'hel' + "lo"
>
> How can I differentiate a STRING from a ID?
>
> 3.) In relation to the second question, to concatenate strings with a
> plus sign ('+') I add the rule:
>
> CUSTOMSTRING:
> (STRING ('+' STRING)*);
>
> With this new rule did I really need to add a Value converter? For which
> prupose?
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.02622 seconds