|
|
|
Re: get source postion of tokens [message #793428 is a reply to message #793183] |
Wed, 08 February 2012 05:42 |
Bodo Koch Messages: 8 Registered: February 2012 |
Junior Member |
|
|
Hi,
Let say a tiny scripting language can deal with some kind of objects. To refer to object members one can specify the grammar like:
ObjectRef: objId=ID ('.' objRef+=ID)*;
If the user writes sentences like:
he/she will get a syntax error in the eclipse/xtext IDE.
If the user writes a syntactically correct sentence like
but z is not a member of object a one will try to catch that error by the validation phase and issue an error.
BUT if also the static semantic is correct like
but a or b is not instantiated one will get an null pointer exception during execution time of this script. In a normal eclipse/java IDE (if the program runs in this context) one will get an error message in the control window and can jump direct to the erroneous statement. I do not expect this comfort in exclipse/xtext because this compiled script will not run in that context, but I want to inform the user at what source code position this error occurs.
During the validation one can access the abstract syntax tree members with the methods or.getObjId() and or.getObjRef(), if or is of class ObjectRef. How one can get the source position info out of this elements?
Thanks, and hopefully this explanation helps
Bodo
[Updated on: Wed, 08 February 2012 05:46] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04625 seconds