Skip to main content



      Home
Home » Modeling » TMF (Xtext) » DSL design advice(Xtext 2.0)
DSL design advice [message #723560] Thu, 08 September 2011 15:54 Go to next message
Eclipse UserFriend
Hello, I need a HTML section inside one of my objects. For example,

Model:
	"Name: " name=ID
	"Description: {" description=Description
	"}"
;

Description:
	"<html>"
		 //more HTML code
	"</html>"
;



I have thought of this problems:

- The HTML tags and attributes would introduce many keywords to may language and I don't want to use the escape character everywhere in my code.
- The HTML grammar is case-insensitive. I have tried the ignoreCase option, but I don't want all my DSL to be case-insensitive, only de HTML grammar.

What would you recommend me?

Thanks!

Re: DSL design advice [message #723588 is a reply to message #723560] Thu, 08 September 2011 17:57 Go to previous message
Eclipse UserFriend
Solution depends on the rest of your grammar / terminals.

The easiest is to have a terminal that eats everything from '<html>' to
'</html>' If you do not allow the '<' and 'html' and '>' to be separated
with whitespace something like this:

terminal HTML : '<html>' -> '</html>' ;

You have to give this terminal the highest precedence as you do not want
comments and strings inside the html to be lexed as such.

There are more options that require a bit more work.
- henrik

On 9/8/11 9:54 PM, Rafael Angarita wrote:
> Hello, I need a HTML section inside one of my objects. For example,
>
>
> Model:
> "Name: " name=ID
> "Description: {" description=Description
> "}"
> ;
>
> Description:
> "<html>"
> //more HTML code
> "</html>"
> ;
>
>
>
> I have thought of this problems:
>
> - The HTML tags and attributes would introduce many keywords to may
> language and I don't want to use the escape character everywhere in my
> code.
> - The HTML grammar is case-insensitive. I have tried the ignoreCase
> option, but I don't want all my DSL to be case-insensitive, only de HTML
> grammar.
>
> What would you recommend me?
>
> Thanks!
>
>
Previous Topic:method return type validation question
Next Topic:Drag and Drop in xText?
Goto Forum:
  


Current Time: Mon Jul 07 09:30:11 EDT 2025

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

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

Back to the top