<?ZBNF-www.vishia.de version="1.0" encoding="iso-8859-1" ?>
$xmlns:topics="http://www.vishia.de/2006/Topics".
$xmlns:xhtml="http://www.w3.org/1999/xhtml".
$inputEncodingKeyword="encoding".
$comment=/*...*/.
$endlineComment=//.

StateMachine::=      
{ #include <* \n?includeLine>
}

##some string value definition used for code generation.
##{ <variable> }



{ static <*;?statefnarg>;  ##argument for each state subroutine
}


##This method should be contained in the users cpp file or in an header included:
[
void switchTo(void* <*)?>);
]


class States \{
  inline void variables ( ) \{ { <variable> } \}  ##some string value definition used for code generation.
##  void args ( { <* ,)?statefnarg> } );
  { <state> }
\} ; 
\e.

variable::= char * <$?name>  = <""?value> ;.

stateStructure::={ + <CompositeState> }.


state::=
[ /**<* |\.|*/?shortdescription><* |*/?description> */] 

[public : |] class <$?@stateName>  [| : public | : protected  <*\{?> ]  ##after : some super states for access in C++
\{
{ int statenr_<* ;?stateNr> ;
| int parallel<?stateParallel> ;
##| <$?parallelParentState> * parallelParent[State];
| public : class History \{ \} ; <?hasHistory>
| [/**<* |\.|*/?-shortdescription><* |*/?-description> */]
  [ void entry ( ) \{<action?+entry> \}
  | void exit ( ) \{<action?+exit> \}
  | void trans  <trans?+trans> 
  | void join  <join?+trans> 
  | void inState ( ) \{<action?+instate> \}
| <state>
  ] }
\} ; 
.


##action::= <*\{\}?code>[\{<action>\}].
action::= <*|\}//\.?code>.

trans::= [<#?nrTrans>]( 
[ bool cond = <*\{?condP>
| int time = <*\{?timeP>
| { class <$?joinState> [*] join  ? , } [)]
 
]
<transbody?>.


##Body of a transition method in the primary C++ source.
##
transbody::= \{
  <* |switchTo?code>  ##any C-code till first new for the transition code.
  switchTo (
  {  new  { History<?history> | <$?dstState> ? :: } [ ( )]   ##Note: last of State::State is dstState
  ? , <?fork>    ##Note: if more as one state then it is a fork. Mark it.
  } ) ;
\}.

cond::=<*\{?cond>.


##A join transition.
##
join::= ( {<?joinState> class {<$?name>?::} * ? , } )<transbody?>.