Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Semantic modification via IUnitOfWork brakes grammar(Semantic modification via IUnitOfWork brakes grammar)
Semantic modification via IUnitOfWork brakes grammar [message #1052193] Mon, 29 April 2013 19:22 Go to next message
Pawel Pogorzelski is currently offline Pawel PogorzelskiFriend
Messages: 40
Registered: July 2009
Member
I have a grammar that defines hidden tokens as SPACE, TAB and SL_COMMENT. That means neither CR nor LF are hidden:

grammar acl.Acl hidden(WS, SL_COMMENT)
...
terminal WS:
	(' ' | '\t')+;
terminal NL:
	('\r'? '\n');


Then I have RuleSection:

RuleSection:
	header=RuleHeader
	rules+=Rule*;
Rule:
	(group=GroupReference | user=User) ASSIGNMENT value=WORD? NL*;


As you can see they are each in new line. Then, if I use IUnitOfWork these rules are not respected (inserted rule is before next section's header, in the same line). How do I perform semantic modification is cases like this?

Thanks,
Pawel
Re: Semantic modification via IUnitOfWork brakes grammar [message #1052251 is a reply to message #1052193] Mon, 29 April 2013 21:24 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Since NL is optional (NL*) the serializer is not forced to output
anything and hence you do not get a NL.

When doing semantic changes, there is typically no existing nodes
containing the NL, so the formatter when formatting the added model
elements has no clue a NL is needed. (If there is a node model, then an
existing NL should be preserved if the formatting rules allow this).

I can think of a couple of ways to fix this:
- Make the serializer output a NL by default if there is no node model
- Make the serializer pick up information in an adapter and output what
is in the adapter (a more general solution).
- Assign the NL to a boolean - i.e. (endsWithNL ?= NL+)? (sets boolean
to true if there is a NL). Simply set it if you want one, and the
serializer should understand the need to output a NL when the endsWithNL
feature is true.

Hope that helps
- henrik

On 2013-29-04 21:22, Pawel Pogorzelski wrote:
> I have a grammar that defines hidden tokens as SPACE, TAB and
> SL_COMMENT. That means neither CR nor LF are hidden:
>
> grammar acl.Acl hidden(WS, SL_COMMENT)
> ...
> terminal WS:
> (' ' | '\t')+;
> terminal NL:
> ('\r'? '\n');
>
> Then I have RuleSection:
>
>
> RuleSection:
> header=RuleHeader
> rules+=Rule*;
> Rule:
> (group=GroupReference | user=User) ASSIGNMENT value=WORD? NL*;
>
>
> As you can see they are each in new line. Then, if I use IUnitOfWork
> these rules are not respected (inserted rule is before next section's
> header, in the same line). How do I perform semantic modification is
> cases like this?
>
> Thanks,
> Pawel
Re: Semantic modification via IUnitOfWork brakes grammar [message #1052815 is a reply to message #1052193] Tue, 30 April 2013 15:18 Go to previous message
Pawel Pogorzelski is currently offline Pawel PogorzelskiFriend
Messages: 40
Registered: July 2009
Member
Thanks Henrik, that help a lot. Indeed, the title is not precise as the output is not broken in the grammar sense. But your pointers are very valuable.
Previous Topic:My generated .java file wont run while in the eclipse application
Next Topic:How to wait for model changes after IDocument.replace()?
Goto Forum:
  


Current Time: Sat Apr 20 00:23:34 GMT 2024

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

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

Back to the top