need explanation regarding assignments [message #870552] |
Tue, 08 May 2012 16:23 |
Tim Student Messages: 12 Registered: May 2012 |
Junior Member |
|
|
I'm totaly new in Xtext and have a probably simple question.
Here is my code.
Several different types of lines will be present in my language, here you only see two of them (activity_line and command_line).
Model:
lines+=line*
;
line: activity_line |
command_line
;
activity_line: 'activity:' name=ID comment*
;
command_line: 'command:' ID comment*
;
comment: '#' ID*
;
Now the question:
What causes the assignment name=ID in rule activity_line. The generated editor recognizes equivalent the same at the command_line rule, when I only regard the Syntaxhighlighting, spell checking etc.
Can somebody tell me the difference of name=ID and ID?
Can I somehow use the 'name' as some kind of variable, where the explicit ID is stored? I can't understand that...
Thanks so far.
[Updated on: Tue, 08 May 2012 18:26] Report message to a moderator
|
|
|
Re: need explanation regarding assignments [message #870565 is a reply to message #870552] |
Tue, 08 May 2012 18:34 |
|
Hi,
guess some basic reading on parsers will help you. Xtext does not only parse (this would be senseless) but it creates an Object Tree / Abstract Syntax Tree too. This tree can be used in a code Generator or Interpreter.
The tree is actually a Graph that consists of Nodes (EClass). There eclasses have attributes and can contain other Nodes (through a containment reference) and reference other Nodes (Cross References)
doing a Xtext tutorial and doing some basic reading on EMF Ecore will give you more information.
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.03369 seconds