How to start [message #1386074] |
Fri, 13 June 2014 10:45 |
Félix SILINOU KAMDEM Messages: 96 Registered: April 2013 |
Member |
|
|
Hello everyone, I have create this grammar:
/*** Alternatives ****/
Alternative 1:
for {e1, e2, e3} select :
R1 or R2 or R3;
Alternative 2:
for {e6, e7, e8} select :
R6 or R7 or R8;
/*** Decision appears when the user make a choice from [b][i]alternative i[/i][/b], [b][i]alternative i[/i][/b] will be automatically delete from the file ****/
Decision 1 select R7 for {e6, e7, e8} :
consequences : decision 1.0 select R2 for {e1, e2, e3} and exclude R7 for {e6,e7,e8}
/*** Tell if the rule has to be excluded or Apply when the decision is validate. Automatically, Decision will be delete from the file ****/
Exclude rule R10 for {e9};
Apply rule R12 for {e10,e11};
What I want to do is this :
1 - I have a file which contains only some Alternatives.
2 - An user has a possibility to make a choise from an Alternative
3 - Decision appears when the user make a choice from Alternative i, Alternative i will be automatically delete from the file
4 - Tell if the rule has to be exclude or Apply when the Decision is validate. Automatically, the Decision will be delete from the file
The problem is that, I don't know howI can do that.
Thank you in advance for your help.
[Updated on: Fri, 13 June 2014 10:46] Report message to a moderator
|
|
|
|
|
Re: How to start [message #1386678 is a reply to message #1386616] |
Thu, 19 June 2014 12:14 |
Gary Worsham Messages: 176 Registered: September 2013 |
Senior Member |
|
|
Of course I used the main Xtext pages: http://www.eclipse.org/Xtext/
Lars Vogel has some good tutorials; this one is about EMF rather than Xtext explicitly. http://www.vogella.com/tutorials/EclipseEMF/article.html
I looked at your example, not sure I really understand it. I can tell you what I did and see if it helps you understand at least MY application of Xtext and Xtend.
My existing problem was that I was writing (still am) a DSP CAD program using Java Swing. I am using a library that some other guy wrote, which models the instruction set of the DSP chip, but does so in Java so that you can do object-oriented things with code blocks. This is exactly the approach that I used in my CAD program.
I got tired of hand translating existing DSP code to Java, so the first thing I used Xtext/Xtend for was to generate the proper Java code and methods (specific to my program) from a slightly annotated DSP code file. Suddenly, tasks that had taken hours took minutes, with much less debugging involved.
Then I saw that a lot of the coding I was doing in Java to determine information about the DSP model I was building with code blocks also had repetitive patterns. These patterns were conceptually simple but tedious to code in Java. So I abstracted those Java code patterns into a more concise syntax. Again, a great increase in development speed and great decrease in bugs.
Finally, I developed a bunch of Swing "control panels" for each block, with sliders, checkboxes, and radio buttons, to control some of the internal variables of these blocks. Again, after doing it for awhile I started to see patterns repeating and again realized that the concepts were way easier than the code required to implement those concepts. So I am currently adding syntax to my grammar, and expanding my code generators so that I can create vast amounts of instantly functional Java Swing code with just a few statements within my annotated DSP source.
This relies heavily on the "Template" code generation approach you can do with Xtext and Xtend. I didn't accomplish anything that I couldn't have accomplished with Java itself. I saw a way to multiply my productivity by reducing repetitive coding patterns to a much simpler representation. That is the only approach I've used with these tools and it works quite well.
Your example shows alternatives and talks about interaction with the user. So I presume that you have a program written in some language and you are trying to come up with a more compact and repeatable way to represent this. If that's true, it would help to see some of that code applied to a simple example of the type you're trying to solve.
Xtext analyzes your source code according to rules you created and builds a model from this, using all the information you supplied. The Xtend code generator walks through this model (multiple times, if needed) and based on the extracted model details, spits out "Template" code. Nothing in Xtend itself guarantees that this code works properly. It's simply quoted with insertions/substitutions based on the model. The logic of the problem you're solving is contained in this quoted template code, along with the structure contained in the code generator (which you also have to write). The translation from a more compact representation is what Xtext/Xtend offer me. My program still has large sections written in Java that are not going to get replaced with Xtend - there's no benefit to doing this.
Part of my point of view on this is a result of challenges I have designing things up front. I'm not a professional software developer and so I usually do things the hard way for awhile (such a writing Java Swing code directly) before I can see a pattern emerging which could be simplified somehow.
I hope this helps a little!
[Updated on: Thu, 19 June 2014 13:04] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03301 seconds