how2 specify some freetext block [message #1062291] |
Fri, 07 June 2013 01:24  |
Eclipse User |
|
|
|
I want to add a feature for my generator to handle some free text entry.
Similar to multiline comments, but I want to use the complete textblock with my generator.
Lets take the Greetings as a base and allow some greeting card text to be entered without the necessity to escape quotes etc. as we have if we use STRING.
Example of XYZ.mydsl
Hello Paul we have a lovely "new" hotel room found here
lots of beer and wine
fine weather, wish you were here !
|
|
|
|
|
Re: how2 specify some freetext block [message #1062537 is a reply to message #1062510] |
Sat, 08 June 2013 09:33   |
Eclipse User |
|
|
|
On 2013-08-06 9:22, Uli Merkel wrote:
> Hi henrik,
> i'm very confused on your post (because of my missing experience).
>
> On the example i was into someting like all what comes after the name
> (which is the ID after 'Hello') and before the '!'
> Greeting: 'Hello' name=ID (mailtext=whatever_comes_and_is_not_a_token)?
> '!';
>
> OK, lets change the example to have some START and END :
>
> extended example of XYZ.mydsl
>
> Hello Paul @STARTMAIL@we have a lovely "new" hotel room found here
> lots of beer and wine
> fine weather, wish you were here@STOPMAIL@ !
>
>
>
> I'm an absolute newbie on XTEXT, so any sample XTXET snippet would help me
> plus the corresponding XTEND
Basically you write a terminal in a fashion similar to the ML comment
terminal, since you are not (I assume) going to accept an escaped
terminator.
terminal VERBATIM : '%{' -> '}' ;
Hello Paul %{We have a lovely "new" hotel room found here
lots of beer and wine
fine weather, wish you where here}
Naturally, the VERBATIM stops on the first '}'. If you want to be able
to have one in the text, you need to do more (look at the STRING
terminal), or simply make the end token more special:
terminal VERBATIM : '%{' -> '%}' ;
Now you cannot have the sequence '%}' nested in the text.
How well this will work depends on your other terminals.
Suggest you write a very small test grammar where you play with your
grammar / terminals until you have something that works as you want.
Hope that helps.
- henrik
|
|
|
|
Powered by
FUDForum. Page generated in 0.03644 seconds