Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » how2 specify some freetext block(allow some comments to be catched with XTEXT)
how2 specify some freetext block [message #1062291] Fri, 07 June 2013 05:24 Go to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
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 #1062440 is a reply to message #1062291] Fri, 07 June 2013 17:18 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2013-07-06 16:10, Uli Merkel wrote:
> 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 !

It is a lexical issue. How does the lexer know when to enter/exit the
free text mode?

A common way of doing this is referred to as HEREDOC. Look at how that
works in Ruby for an example.

In Xtext you need to write an external lexer and learn to jump through
hoops to do the same.

It is much easier if there is a distinct and unique character
combination that stops the free text mode.

You may still need an external lexer if you cannot solve this with
something string-like.

Regards
- henrik
Re: how2 specify some freetext block [message #1062510 is a reply to message #1062440] Sat, 08 June 2013 07:22 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
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
Re: how2 specify some freetext block [message #1062537 is a reply to message #1062510] Sat, 08 June 2013 13:33 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
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
Re: how2 specify some freetext block [message #1062857 is a reply to message #1062537] Tue, 11 June 2013 06:28 Go to previous message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Hi henrik,

thanks a lot for pointing me to this syntax as a starting point.
As you recommended, I will experiment and have a deeper look in the terminal specification.

Kind regards, Uli
Previous Topic:How do I share Xtext projects with others?
Next Topic:Xtext Problem View Not getting updated
Goto Forum:
  


Current Time: Mon Sep 23 16:54:24 GMT 2024

Powered by FUDForum. Page generated in 0.03354 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top