Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » re-generate captured text
re-generate captured text [message #953437] Mon, 22 October 2012 08:40 Go to next message
Bruce L. is currently offline Bruce L.Friend
Messages: 81
Registered: June 2011
Member
Hi, is there a way to generate back from an object of the parse tree the text that was consumed by the parser to instantiate such object?

Example:
Grammar:
...
Func: "f" "("arg=ArgSpec")";

ArgSpec : ...
...


Document
f( 5*PI )


Given the ArgSpec instance (which is possibly a complex type with properties etc) I would like to simply generate the string "5*PI", without manual processing all the fields of the ArgSpec instance

I hope it's clear
Thank you
B
Re: re-generate captured text [message #953446 is a reply to message #953437] Mon, 22 October 2012 08:52 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13605
Registered: July 2009
Senior Member
Hi,

if i get you write you have a parsed eobject in your hand and want to access the text that was parsed.
you get access to the node model through the NodeModelUtil class.

~Christian


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
Re: re-generate captured text [message #953519 is a reply to message #953446] Mon, 22 October 2012 10:07 Go to previous message
Bruce L. is currently offline Bruce L.Friend
Messages: 81
Registered: June 2011
Member
Thank you!

So far, I found these

NodeModelUtils::getTokenText(NodeModelUtils::findActualNodeFor( <my eobject> ))


NodeModelUtils::findActualNodeFor(<my eobject>).getText()


which seem to work

thanks again
B
Previous Topic:formatter that keeps original line breaks
Next Topic:Autoindent code
Goto Forum:
  


Current Time: Wed Sep 23 11:08:50 GMT 2020

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

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

Back to the top