Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » DSL design advice(Xtext 2.0)
DSL design advice [message #723560] Thu, 08 September 2011 19:54 Go to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
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 21:57 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
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: Thu Sep 19 01:15:39 GMT 2024

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

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

Back to the top