Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Accessing the Abstract Syntax Tree of imported files
Accessing the Abstract Syntax Tree of imported files [message #1740274] Thu, 11 August 2016 07:08 Go to next message
Paul Rosset is currently offline Paul RossetFriend
Messages: 4
Registered: August 2016
Junior Member
First of all I'm sorry if i posted this twice because I am not shure if my topic was received yesterday.

The goal of my Xtext project is to describe a memory mapping between an fpga and a processor. I have an import directive that lets me describe stuctures that will be used in more than one sample.
Import:
   'Import' importedNamespace = QualifiedNameWithWildcard
;
  
QualifiedNameWithWildcard:
   QualifiedName '.*'?
;

The code works when describing the structures but when generating content for one file I cannot access the content of my imported source files. I do need the Information of the parsed file to be able to get the size of structures.

Is there method to invoke the parsing of an imported file when passing the include directive?
Re: Accessing the Abstract Syntax Tree of imported files [message #1740390 is a reply to message #1740274] Fri, 12 August 2016 13:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
no there is not. the name you import even does not need to exist.

that is the semantics of you imports? do you use it to make names accessible under their simple name?
or do you use it for "include" semantics only


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Accessing the Abstract Syntax Tree of imported files [message #1740521 is a reply to message #1740390] Mon, 15 August 2016 11:34 Go to previous messageGo to next message
Paul Rosset is currently offline Paul RossetFriend
Messages: 4
Registered: August 2016
Junior Member
I want to generate the following structure

//File Fpga.mod
MemArea Fpga
{

Import FrequencyGenrator.*
//File FrequencyGenerator.mod <--- Defines the Module FrequencyGenerator as a 30 Byte Structure
Import ADConverter.*
//File ADConverter.mod  <--- Defines the Module ADC Converter as a 16 Byte Structure

	Version 12
	Description "Configuration Memory Layout for the fpga"

	Module FrequencyGenerator channel1
	Module FrequencyGenerator channel2
        Module ADConverter input
} 


The file FrequencyGenerator.mod has the description of the FrequencyGenerator module.
In order to place the FrequencyGenerator modules in the memory of the FPGA I do need the size of it while processing Fpga.mod. CurrentIy do not have this information because i do not have the Tree for the imported files while parsing Fpga.mod.

[Updated on: Mon, 15 August 2016 12:14]

Report message to a moderator

Re: Accessing the Abstract Syntax Tree of imported files [message #1740523 is a reply to message #1740521] Mon, 15 August 2016 11:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i still dont get the semantoc of the imports.

if you have a FrequencyGenerator and a ADConverter you can simply follow these references cant you? when iterating over the modules?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Accessing the Abstract Syntax Tree of imported files [message #1740532 is a reply to message #1740523] Mon, 15 August 2016 12:57 Go to previous message
Paul Rosset is currently offline Paul RossetFriend
Messages: 4
Registered: August 2016
Junior Member
Thank you for your response did not see that the iterator provides an instance of Module.

I extracted my modules with a filter from the packageDeclaration:
for (module : pck.elements.filter(Module))
{
    generateModule(moduleIt)
}


I fixed my problem by calling generateModule when parsing the MemArea.
Previous Topic:Evaluate the XBlockExpression to value?
Next Topic:Xtext from ecore
Goto Forum:
  


Current Time: Fri Apr 19 02:10:39 GMT 2024

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

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

Back to the top