|
|
|
Re: how2 specify some freetext block [message #1062537 is a reply to message #1062510] |
Sat, 08 June 2013 13:33 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
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.03354 seconds