Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » replace references(replace references)
replace references [message #736891] Fri, 14 October 2011 12:42 Go to next message
samir  is currently offline samir Friend
Messages: 27
Registered: September 2011
Junior Member
hello
if I have a grammar that contains references. For example, this:

A: ID | [B];
B: name = id;

Then when I'm going to call my compiler. I want to pass the file
where the references have been replaced. You can do this. how?
Re: replace references [message #736911 is a reply to message #736891] Fri, 14 October 2011 13:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i dont get your problem. can you elaborate a bit on what you want to do.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: replace references [message #736926 is a reply to message #736911] Fri, 14 October 2011 13:24 Go to previous messageGo to next message
samir  is currently offline samir Friend
Messages: 27
Registered: September 2011
Junior Member
if this was my grammar


Prog : ('Types{'(td += TypeDich';')*'}')?
('Declarations{'(d += Dich';')*'}')? 'Main{'(main = Term)'}';

Dich : name = ID '=' term = Term;
Nrif : nome = [Dich];
Term : Var | Abs | App | Uq | Tapp| Nrif| 'let'var = variable '=' t1 =Term 'in' t2 = Term;
Var : name = variable;
Abs : '\\('param = variable ':' type = T').'body = Term;
App : '('t1 = Term ')' t2= Term;
Uq : '/\\'var = tvar'.'term = Term;
Tapp: => '('term = Term')'type = T;

T : p=tvar ('->'c+=T)* | '('p1=T')' ('->'c1+=T )*|'forall' var=tvar t=T|Trif;
TypeDich : name = ID '=' type = T;
Trif : nome = [TypeDich];

terminal variable : ('a'..'z')+;
terminal tvar : ('A'..'Z')+;


e ho un programma come questo

Types{
Bool = A->B->A;
Id = A->A;
}


Declarations{
True = \(t:B).\(f:B->B).t;
False = \(t:B).\(f:B).f;
Not = ((\(b:B).b) True) False;
Adf = let x = True in Not;
}



Main{
(True)False
}

I want to do is to replace all references to the place of the term reported. before calling the interpreter
For example, in the main I want to replace instead of True WITH \(t:B).\(f:B->B).t.
I'm asking is how can I make?

[Updated on: Fri, 14 October 2011 13:37]

Report message to a moderator

Re: replace references [message #736966 is a reply to message #736926] Fri, 14 October 2011 14:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

Still do not understand the problem. If you have a nrif you can ask it for its nome and get a Dich. This dich you can ask for its term. This Term is the replacement Term for the nrif. Isnt it ?

Regards
Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: replace references [message #736987 is a reply to message #736926] Fri, 14 October 2011 14:43 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
Hi,

when you say "before I am calling the compiler" do you mean the Xbase compiler or are you feeding your file to an external program that reads the textual input? In the other post, you are speaking of an interpreter. What actually do you mean?

If you feed it to an external programm, you could use the codegen framework to generate a file that conforms to your compiler.


Andreas
Re: replace references [message #737016 is a reply to message #736966] Fri, 14 October 2011 15:22 Go to previous messageGo to next message
samir  is currently offline samir Friend
Messages: 27
Registered: September 2011
Junior Member
yes, but I do want to call my Interpreter, and I want these changes are reflected in the editor
Re: replace references [message #737835 is a reply to message #737016] Sat, 15 October 2011 14:14 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

so you want to do a Model 2 Model transformation within your editor? calling IXtextDocument.modify should allow you to do this.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Calling IGenerator from an Handler
Next Topic:Xtend2 array conversion
Goto Forum:
  


Current Time: Tue Apr 23 11:05:53 GMT 2024

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

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

Back to the top