Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » jsp editor(jsp editor)
jsp editor [message #677532] Wed, 08 June 2011 18:37 Go to next message
spcmdr is currently offline spcmdrFriend
Messages: 15
Registered: January 2011
Junior Member
Hi

I would like to create a jsp like text editor?
Is it possible to do so using xtext?

Is there a grammar rule for free text?
What I mean is that I see how to create grammer rule for html tag.
What rule is available for the text like in <b>the text goes here</b>

Regards
Re: jsp editor [message #677618 is a reply to message #677532] Thu, 09 June 2011 01:01 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
The difficulties with "template" languages (mixing free text and code)
is usually lexer oriented - when in "free text" mode you do not want
keywords etc. to be recognized.

What you need to do is similar to interpreting documentation comments
associated with code. There are posts on that subject in this forum you
can search for.

If you can use special symbols to switch between template and
non-template mode it is not so difficult. I made an implementation in
Eclipse b3 (with the help from Sebastian on writing the lexer rules)
that makes it possible to switch "modes" as well as nest templates.

Regards
- henrik

On 6/8/11 8:37 PM, forums-noreply@eclipse.org wrote:
> Hi
>
> I would like to create a jsp like text editor?
> Is it possible to do so using xtext?
>
> Is there a grammar rule for free text?
> What I mean is that I see how to create grammer rule for html tag.
> What rule is available for the text like in <b>the text goes here</b>
>
> Regards
Re: jsp editor [message #723891 is a reply to message #677618] Fri, 09 September 2011 19:11 Go to previous messageGo to next message
Andrey Mising name is currently offline Andrey Mising nameFriend
Messages: 26
Registered: September 2011
Junior Member
Hi Henrik,

How to define special symbols to switch between template and
non-template mode in Xtext?
Can you please give an example?
Thank you,
Andrey
Re: jsp editor [message #723910 is a reply to message #723891] Fri, 09 September 2011 20:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you can find the b3 grammar here
http://git.eclipse.org/c/b3/b3.git/tree/org.eclipse.b3.beelang/src/org/eclipse/b3/BeeLang.xtext

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: jsp editor [message #723960 is a reply to message #723910] Sat, 10 September 2011 02:10 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 9/9/11 10:36 PM, Christian Dietrich wrote:
> Hi,
>
> you can find the b3 grammar here
> http://git.eclipse.org/c/b3/b3.git/tree/org.eclipse.b3.beelang/src/org/eclipse/b3/BeeLang.xtext
>
>
> ~Christian

In b3, it is possible to write a template within « », and it is possible
to switch to expressions mode within the template to interpolate the
value of the expression. The tricky thing was to express the terminals
for this. (I got help from Sebastian ;).
Since the «» are not used for anything else in the grammar, it was quite
straight forward.

In Geppeto (IDE for Puppet manifests), the template possibilities are
much more complicated to lex due to excessive syntactic sugar coating.
Basically a template is a double quoted string "", and expression
interpolations are $var, or ${expression} (with some additional
variations). In Geppetto, I use an external lexer (primarily to overcome
other lexing issues, but it helps with strings and templates as well).

The geppetto code is found at github cloudsmith/geppetto.

If I were to implement something jsp like and I could not reserve some
characters like «» (or distinct operators like '${' '}$') for templates,
I would strongly recommend using an external lexer to enable more
complex lexing logic to recognize the templates. The same goes for
templates that are base on initial magic marker on a line (like %) to
end of line and the marker char is also an operator, or if the logic
requires understanding of "indents from margin".


Regards
- henrik
Previous Topic:Slow createInjectorAndDoEMFRegistration
Next Topic:New composite update sites are available
Goto Forum:
  


Current Time: Thu Apr 25 07:40:25 GMT 2024

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

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

Back to the top