|
Re: model to text and comments [message #644774 is a reply to message #644374] |
Tue, 14 December 2010 08:32 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Henrik,
I'd usually try to use a custom serializer for any use case that
involves heavy customizing.
The other approaches (adapter + comment associater or unassigned text
serializer) involve heavy customizing and I'm not that sure about the
runtime invariants of these components.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 10.12.10 18:49, schrieb Henrik Lindberg:
> Hi,
> I have a use case where I create a (DSL) model using a model to model
> transformation and I would like to also insert a few comments (in
> selected places). What would be the approach to take for something like
> this?
>
> My DSL does not contain any 'assigned rules' for comments, but the
> comments are not hidden from the grammar.
>
> I imagine (a somewhat heavy) approach would be to first serialize to
> text without comments, then parse the result to get a node model, and
> then perform textual changes.
>
> My other idea is to use a "comment adapter" and pick up any comment text
> while serializing. However since comments would not be found the same
> way when going in the other direction, I am not so fond of this solution.
>
> Some more detail info about the grammar:
>
> In this grammar there are issues with overlapping terminals so basically
> everything that is normally handled with terminals is handled as data
> rules (i.e. strings, comments, etc.). This also means that there are no
> hidden terminals. Instead, all rules typically ends with an
> OptionalWhiteSpace (OWS) rule that is defined to be an optional sequence
> of white space and comments.
>
> A rule may look like this:
> AdditiveExpression returns Expression:
> MultiplicativeExpression ({AdditiveExpression.leftExpr=current}
> opName = AdditiveOperator OWS
> rightExpr = MultiplicativeExpression)*
> ;
>
> This works fine as all rules that consumes a token (that may be followed
> by WS/Comments) also ends by consuming OWS. (And the root rule consumes
> any leading OWS).
>
> Regards
> - henrik
|
|
|
|
Powered by
FUDForum. Page generated in 0.02481 seconds