|Re: [ report &amp;quot;&amp;quot; [message #789766 is a reply to message #789654]
||Fri, 03 February 2012 11:27
| Henrik Lindberg
Registered: July 2009
On 2012-03-02 9:31, Sebastian Burg wrote:|
> I just didnt have the time to boil it down, as i am happy to have a
> running system right now to show the client.
> The problem is, the grammar is really deterministic at the given point.
> The first word is a terminal word. So i dont see how it should refer to
> another path in the grammar.
> ASSERT ex=ID AT fo=bar | ASSUME ex=ID value=SomeString;
> terminal ASSERT: 'assert';
> terminal ASSUME: 'assume';
> terminal AT: '@';
> as it is now, if there i enter assume, sometimes i get assert xyz @.
Not surprising, nothing is produced that makes the *result* differ, the
fact that an 'assert' or an 'assume' was seen is lost and you get an
instance of 'expression'. You are not showing the grammar for "fo=bar"
so impossible to tell you exactly what is going on.
You need something in the created object that keeps the information. You
can use a boolean flag, assign the keyword, or use two different classes
(this is what typically used).
// using boolean flag
expression: isAssert ?= 'assert' 'at' ... ;
// assigning the keyword
expression : type = ASSERT AT ... | type = ASSUME ... ;
// using classes
expression: AssertExpression | AssumeExpression ;
AssertExpression : 'assert' '@' ... ;
AssumeExpression : 'assign' ... ;
Another thing to possibly change is using the Xtext keyword support as
using terminals for keywords is usually not a very good idea.
expression: 'assert' '@' fo = bar | 'assume' ex= .... ;
expression: ASSERT AT ...
Doing so, they will be recognized as keywords.
> Could it be a cache problem?
> I tried new example to file with a bug, but yet havent been able to
> reproduce the problem. As i said, didnt have the time yet. I will try
> today after the presentation.
The problem is in your grammar.
Hope that helps.
Powered by FUDForum
. Page generated in 0.03986 seconds