Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Handling terminals without assigned feature, for code generation
Handling terminals without assigned feature, for code generation [message #1791796] Thu, 05 July 2018 12:31 Go to next message
Habtom Kahsay Gidey is currently offline Habtom Kahsay GideyFriend
Messages: 1
Registered: December 2017
Junior Member
In my DSL expression, I can use brackets (), like 2*( 3 + (1+2)), which I don't have a defined feature in my grammar, but I want to make use of it in my code generator to convert it, for instance, to squared brackets or so. Would there be a possibility to handle this brackets without assigning them to a feature?
Re: Handling terminals without assigned feature, for code generation [message #1792126 is a reply to message #1791796] Thu, 12 July 2018 04:33 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
Hi,

you can do two things:

- in the generator you can test if the binary expression has a lower precedence than the one that it is enclosed by and the generate it with parentesis.
- you can use org.eclipse.xtext.nodemodel.util.NodeModelUtils.findActualNodeFor(EObject) to find the node model and traverse it to see if there where ( )


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 12 July 2018 04:52]

Report message to a moderator

Previous Topic:RPGLE - String Literal Parsing
Next Topic:(xtext) Grammar's problem
Goto Forum:
  


Current Time: Tue Sep 21 17:42:10 GMT 2021

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

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

Back to the top