Reputation: 21
I want to define grammar in Xtext for the state machine. My rule is that one state machine must have [1.. * ] transitions, [1..1] initial state, [1..1] final state, and [0.. * ] intermediate states.
StateMachine:
'InitialState' initialstate = InitialState
'FinalState' finalstate = FinalState
'States' '{' states+=State* '}'
'Transitions' '{' transitions+=Transitions ( "," transitions+=Transitions)* '}'
;
This is how I have written the rules but when I generate the ecore model, I notice that the relation of the initial state and final state with the state machine is [0..1] and not [1..1] as I wanted it, and the relation between transition and statemachine is [0.. * ] and not [1..*]. Can you help me find out where I went wrong?
Thank you
Upvotes: 1
Views: 131
Reputation: 6729
Xtext does not put any restrictions on the ecore file based on the concrete syntax. Their constraints would be already validated / guaranteed by the grammar / concrete syntax already.
If you want to have a more constrained ecore, you need to switch from generated to imported metamodel.
Upvotes: 0