Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » First use is a declaration(Variable declared when first used)
First use is a declaration [message #1770259] Wed, 09 August 2017 12:56 Go to next message
KRZYSZTOF BRILLA is currently offline KRZYSZTOF BRILLAFriend
Messages: 1
Registered: August 2017
Junior Member
Hello,
I'm trying to figure out way to write rule that allows me to use either Reference or declare new variable when not used before;

a:=a+b // here both a & b are declared, and a is referred
b:=a+c // here only c is declared but b and a are referred

Could You give me an example please, I looked on the forum and in Bettni&Lorenzo book but did not found an answer?
Re: First use is a declaration [message #1770897 is a reply to message #1770259] Fri, 18 August 2017 13:48 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 752
Registered: July 2009
Location: Hamburg
Senior Member
What I have done in the past: In the grammar use cross-references only and write an IDerivedStateComputer that creates the declarations in the derived state:
Iterate over all cross-references to variables, get the link text using NodeModelUtils, collect all these names in a set to remove duplicates, create a Variable EObject for each name.


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:Problem faced with Xtext when running in headless application
Next Topic:Some proposals in content assisting are hidden
Goto Forum:
  


Current Time: Mon Jan 22 20:35:39 GMT 2018

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

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