What's wrong with this cross-reference [message #988709] |
Sat, 01 December 2012 13:51  |
Eclipse User |
|
|
|
Hi,
I'm writing a DSL for a state machine. In order to keep the number of events from growing to rapidly my events have parameters. The following example shows how I'd like my DSL to work:
event LocationUpdate {
lon : float
lat : float
}
state s1 {
LocationUpdate: lon = 20 -> s2
}
state s2 {
LocationUpdate -> s1
}
Unfortunately I get the following error: "Description Resource Path Location Type Couldn't resolve reference to ParemeterDefinition 'lon'."
The problem is the cross-reference in the "Condition" rule of my grammar (I think), but I don't know how to fix it. Here is the whole thing:
grammar de.unisiegen.StatesLanguage with org.eclipse.xtext.common.Terminals
generate statesLanguage "http://www.eclipse.org/StatesLanguage"
StatesList :
states += State* &
actions += Action* &
events += Event*
;
State:
('state'|'startstate') name = ID '{'
actions += ActionInvocation* &
transitions += StateTransition+
'}'
;
StateTransition:
EventInvocation '->' state = [State]
;
ActionInvocation:
(percent = Number '%')? action = [Action] val += Value*
;
Action:
'action' name = ID '{'
params+= ParemeterDefinition*
'}'
;
Event:
'event' name = ID '{'
params += ParemeterDefinition*
'}'
;
ParemeterDefinition:
name = ID ':' type = DATATYPE
;
EventInvocation:
eventName = [Event] (':' condition = Condition (logicalOperators+= LOGICALBINARYOPERATOR conditions+= Condition)* )?
;
Condition:
parameter = [ParemeterDefinition]
eqoperator = EQUALITYOPERATOR
val = Value
;
Value:
BOOL | STRING | Number
;
Number:
FLOAT | INT
;
enum DATATYPE:
int|float|string|bool
;
terminal EQUALITYOPERATOR:
"=" | ">" | "<" | ">=" | "<=" | "!="
;
enum LOGICALBINARYOPERATOR:
and | or
;
terminal BOOL:
"true"|"false"
;
terminal FLOAT:
INT'.'INT
;
If you can spot anything else, which seems odd or wrong to you besides the problem I described, feel free to tell me. I've never written a DSL before and take any advice I can get.
Thanks
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07322 seconds