Grammar for Statechart diagrams

Below we give the grammar for statechart diagrams.

StateD =

"$" stateName "$" typeOfStateD

"* * *"

["1LSV" {stateVariableDecl} "LSV1"]

["1LSS"{substate} "LSS1"]

["1LT" {transition} "LT1"].

stateVariableDecl =

stateVariableName ":" [className] [ "=" initValue].

typeOfStateD =

initialState | regularState | terminalState | merge bar | split bar | orstate | anstate.

substate =

StateD.

transition =

fromNode toNode [event] [guardCondition] { "/" action } {sendClause} ["^" returnValue].

fromNode, toNode =

"$" stateName" $".

event =

eventName "(" [ parameter { "," parameter} ] ")".

guardCondition =

"[" condition_clause "]".

sendClause =
syncIndiactor [result ":="] target "." event
.

syncIndicator =

"$" (procedure_call | flat_flow | asynchronous_flow).

procedure_call =

"1".

flat_flow =

"2".

asynchronous_flow =

"3".

target = className | objectName.

action=

actionName "(" [ argument { "," argument } ] ")".

condition_clause =

ifExpression | ( "(" ifExpression ("or" ifExpression )+ ")") | orExpression.

ifExpression =

"(IF" orExpression "THEN" orExpression "ENDIF)".

orExpression =

andExpression | ( "(" andExpression ("or" andExpression )+ ")").

andExpression =

basicExpression | ( "(" basicExpression ("and" basicExpression ")")+ ).

basicExpression =

"(" identifier ( ( ( "=" | "<" | ">" "<=" | ">=" ) ( string_literal | character_literal | interger_literal | floating_point_literal ) ) | ("=" ( "true" | "false" ) ).

stateName, stateVariable, className, objectName, parameter, resutlt, argument =

identifier.

A StateD is described by its name, its type, a set of state variables, a set of substates, and a set of transitions. A substate is itself a stateD.

A state variable may show the following details :

A transition may show the following details: