Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Referenced Rule type not recognized from Proposal provider
Referenced Rule type not recognized from Proposal provider [message #1702444] Wed, 22 July 2015 11:45 Go to next message
Nadja Marko is currently offline Nadja MarkoFriend
Messages: 4
Registered: July 2015
Junior Member
I have a problem with my cross references to another grammar. The proposal provider does not recognize the rule of the referenced grammar. It shows proposals that are not appropriate and when I chose the incorrect proposal an error is shown and the Quickfix proposes to change to the appropriate term.

Extract of the grammars:
Grammar 1 (Term Definition Grammar)

Model:
(definitionList+=Definition)*;

Definition:
definition = DefinitionType;

DefinitionType:
SystemDef | StateDef | ParamDef | ...;

StateDef:
'state:' name=ID description=Description;

SystemDef:
'system:' name=ID description=Description;

ParamDef:
{ParamDef} 'parameter:' name=ID description=Description;
...

Grammar 2 (Using the definition grammar)
FunctionDescription:
preconditions=PreconditionList mainRequirement=Function_Main ".";

PreconditionList:
{PreconditionList} (preconditionList+=Precondition )* ;

Precondition:
preconditionType=PreconditionType (time_constraint=Timing_constraint)?;

PreconditionType:
Condition | Event;

Condition:
parameterType=(parameter|time) "is" (not?='not')? (lop=LOP)? value=Value;

Event:
Parameter_event | Actor_event;

Parameter_event:
parameter=(time|parameter) action=("increases above" | "decreases below" | "reaches") value=Numeric_value;

Actor_event:
system=system action=("activates" | "deactivates") entity=entity;


system:
"system:" name=ID | definition=[def::SystemDef|ID];


parameter:
"parameter:" name=ID | definition=[def::ParamDef|ID];
...

Incorrect behaviour:

When using the rule Parameter_event, the proposal provider proposes also 'activates'/'deactivates' from the Actor_event.
Using then 'parameter activates ...' (which should be wrong according to the grammar as ) an error is shown and the quickfix proposes to use a system instead.
This incorrect behaviour also occurs at other locations in the grammar and it seems that the DefinitionType (system, parameter, ...) is not recognized correctly from the proposal provider.

Does anyone have an idea how to solve this?
Re: Referenced Rule type not recognized from Proposal provider [message #1702498 is a reply to message #1702444] Wed, 22 July 2015 17:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

can you share complete reproduceable grammars?

from what you have posted:

never ever use spaces in keywords

then your grammar says:

Event:
Parameter_event | Actor_event;



=> at the same place parameter_event and actor event are allowed

system:
"system:" name=ID | definition=[def::SystemDef|ID];

parameter:
"parameter:" name=ID | definition=[def::ParamDef|ID];


has the precedence

system:
("system:" name=ID) | definition=[def::SystemDef|ID];

parameter:
("parameter:" name=ID )| definition=[def::ParamDef|ID];


=> the parser cannot decide if it is a System or a Parameter at this point

otherwise it would be ambigous.

thus you cannot simply change it to

system:
"system:" (name=ID | definition=[def::SystemDef|ID]);

parameter:
"parameter:" (name=ID | definition=[def::ParamDef|ID]);


so what is the semantic of his construct.





Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referenced Rule type not recognized from Proposal provider [message #1702572 is a reply to message #1702498] Thu, 23 July 2015 10:50 Go to previous messageGo to next message
Nadja Marko is currently offline Nadja MarkoFriend
Messages: 4
Registered: July 2015
Junior Member
Thank you very much for your answer.
I cannot share the complete code from grammar 2, but I can share grammar 1 and I tried to write an extract from grammar 2 that includes all relevant information (attached).

>> you say that the parser cannot decide if it is a System or a Parameter at this point.

As I declare it as a 'parameter' name=ID/ 'system' name=ID in the definition grammar, I thought the parser can recognize it as the right rule type (there I say that it is a 'parameter'/'system'). The problem only occurs when I use terms from the definition grammar.

Attached you can further find examples for the language files and screenshots of the incorrect behaviour.
Re: Referenced Rule type not recognized from Proposal provider [message #1702574 is a reply to message #1702572] Thu, 23 July 2015 11:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
as i said: it is a precedence thing.

if i write parameter: xxxx and do content assist it is correct
if i write system:xxx and do content assist it is correct
if i write xxxx and do content assist it is not since it cannot decide if xxxx is a param oder a system


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referenced Rule type not recognized from Proposal provider [message #1702583 is a reply to message #1702574] Thu, 23 July 2015 12:09 Go to previous messageGo to next message
Nadja Marko is currently offline Nadja MarkoFriend
Messages: 4
Registered: July 2015
Junior Member
Ok, thank you. So that means that I have to change the grammar.?
Re: Referenced Rule type not recognized from Proposal provider [message #1702584 is a reply to message #1702583] Thu, 23 July 2015 12:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
yes and you may even have to Change he Syntax since if you Change the grammar it is ambigous

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referenced Rule type not recognized from Proposal provider [message #1702623 is a reply to message #1702584] Thu, 23 July 2015 14:50 Go to previous message
Nadja Marko is currently offline Nadja MarkoFriend
Messages: 4
Registered: July 2015
Junior Member
Thanks for clarifying this!
Previous Topic:error in xtext editor
Next Topic:[Formatter2] annoying line break
Goto Forum:
  


Current Time: Thu Apr 25 19:33:30 GMT 2024

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

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

Back to the top