class Attributes
{
  names[] = {"privateVariables"};
};

class Compile
{
  clearNewLines = 0;
//  indenting = -1;  //no indenting
  rewriteFile = 1; //do not append result to the end of file, but rewriteIt
  class Pass_Main_Body
  {
    print_1 = "private [""_state"", ""_finalStateArray""];\n";
    print_prVar = "%(privateVariables)\n";
    print_2 = "_state=%qt(initStateName);\n";
    print_3 = "_finalStateArray = [";
    class FinalStates
    {
      iffirst_yes = 1;
      print_1 = "%qt(finalStateName)";
      iffirst_no = -1;
      print_2 = ", %qt(finalStateName)";
      iffirst_all = 0;
    }
    print_4 = "];\n";
    //MAIN WHILE
    print_mw = "while {!(_state in _finalStateArray)} do\n";
    print_5 = "{\n";
    indent_6 = 2;
    //STATE SWITCH
    print_ssw = "switch (_state) do\n";
    print_7 = "{\n";
    iffinal_no = -1;
    class State
    {
      print_case = "case (%qt(stateName)):\n";
      print_01 = "{\n";
      indent_1 = 4;
      print_2 = "%(stateinit)\n";
      print_3 = "switch(true) do\n";
      print_4 = "{\n";
      indent_5 = 6;
      class Links
      {
        print_1 = "case (call {%(condition)}):\n";
        print_2 = "{\n";
        indent_3 = 8;
        print_4 = "%(action)\n";
        print_5 = "_state = %qt(to);\n";
        indent_6 = 6;
        print_7 = "};\n";
      };
      indent_5 = 4;
      print_6 = "};\n";
      indent_7 = 2;
      print_8 = "};\n";
    };
    iffinal_all = 0;
    print_10 = "};\n";
    print_19 = "sleep 0.1;\n"; //in order not to allow the FSM in the script to run all the time
    indent_20 = 0;
    print_21 = "};\n";
  };
  class Pass_Final_State
  {
    //STATE SWITCH
    print_ssw = "switch (_state) do\n";
    print_1 = "{\n";
    iffinal_yes = 1;
    indent_1 = 2;
    class State
    {
      print_case = "case (%qt(stateName)):\n";
      print_01 = "{\n";
      indent_2 = 4;
      print_2 = "%(stateinit)\n";
      indent_5 = 2;
      print_6 = "};\n";
    };
    iffinal_all = 0;
    indent_7 = 0;
    print_10 = "};\n";
  };
};

class Decompile
{
  process = 1;   //0 for not processing Decompile info
  FSMLeft  = "/*";
  FSMRight = "*/";
  class FSMPrefix
  {
    default = "";
  };
  class FSMPrefix2
  {
    default = "";
    head = "*/";
    condition = "\n";
    stateinit = "\n";
    action = "\n";
    privateVariables = "\n";
  };
  class FSMSufix
  {
    default = "";
    compile = "\n";
    condition = "\n";
    stateinit = "\n";
    action = "\n";
    state = "\n";
    head = "\n/*\n";
    link = "\n";
    privateVariables = "\n";
  };
  class FSMSufix2
  {
    default = "";
    compile = "";
    state = "\n";
    head = "\n";
    link = "\n";
  };
};
