class Attributes
{
  names[] = {"globalPrefix", "fsmFunctionDeclaration", "fsmFunctionPrefix", "fsmFunctionSufix", "setFinal"};
};

class Compile
{
  clearNewLines = 0;
  class Pass_1
  {
    print_0 = "\n/////////////////////////////////////////////////////////////////////////////////\n//Global FSM functions and variables\n";
    print_head = "\n// FSM: %(fsmname)\n//\n";
    print_1 = "//{{AFX\n";
    print_2 = "%(globalPrefix)\n";
    print_3 = "//}}AFX\n\n";

  };
  class Pass_2
  {
    nodecompile = 1;
    print_0 = "\n/////////////////////////////////////////////////////////////////////////////////\n//enumerate States of %(fsmname)\n//\n";
    print_1 = "//{{AFX\n";
    print_2 = "#ifndef DECL_ENUM_%(fsmname)State\n#define DECL_ENUM_%(fsmname)State\nDECL_ENUM(%(fsmname)State)\n#endif\n";
    print_2Beg = "DEFINE_ENUM_BEG(%(fsmname)State)\n";
    indent_1=2;
    ifstart_yes = 1;
    class State_start
    {
      print_1 = "%(fsmname)%(statename),\n";
    };
    ifstart_no = -1;
    class State_notStart
    {
      print_1 = "%(fsmname)%(statename),\n";
    };
    ifstart_both = 0;
    indent_2 = 0;
    print_2END = "DEFINE_ENUM_END(%(fsmname)State)\n";
//    print_4 = "%(fsmname)State _state;\n";
    print_5 = "//}}AFX\n";
  };
  class Pass_3
  {
    print_0 = "\n/////////////////////////////////////////////////////////////////////////////////\n//Main FSM function for %(fsmname)\n//\n";
    print_1 = "//{{AFX\n";
    print_2 = "%(fsmFunctionDeclaration){\n";
     indent_1 = 2;
     print_2a = "%(fsmFunctionPrefix)";
     print_3 = "switch (_state)\n{\n";
      indent_2 = 4;
      class State
      {
        print_1 = "case %(fsmName)%(stateName):\n";
        print_2 = "{\n";
        indent_1 = 6;
        ifStart1 = 1;
        print_start = "//this is start state\n";
        ifStart2 = 0;
        print_init = "%(stateInit)";
        print_3 = "%(statePreCondition)";
        class Links
        {
          print_1 = "%(condPreCondition)";
          print_2 = "if (\n";
          indent_2 = 8;
          print_3 = "%(condition)";
          indent_3 = 6;
          print_3a = ")\n{\n";
          indent_4 = 8;
          print_4 = "%(action)";
          print_5 = "_state=%(fsmname)%(to);\n";
          print_br = "break;\n";
          indent_6 =6;
          print_7= "}\n";
        };
        ifFinal_1 = 1;
        print_fin1 = "//this is final state\n";
        print_fin2 = "%(setFinal)\n";
        ifFinal_2 = 0;
        indent_2 = 4;
        print_5 = "}\n";
        print_6 = "break;\n";
      };
      indent = 2;
     print_19 = "}\n";
     print_18 = "%(fsmFunctionSufix)";
     indent_20 = 0;
     print_50 = "}\n";
     print_end = "//}}AFX\n";
  };
};

class Decompile
{
  process = 1;   //0 for not processing Decompile info
  FSMLeft  = "/*";
  FSMRight = "*/";
  class FSMPrefix
  {
    default = "";
    action = "//}}AFX\n";
    condition = "//}}AFX\n";
    fsmFunctionDeclaration = "//}}AFX\n";
    fsmFunctionPrefix = "//}}AFX\n";
    fsmFunctionSufix = "//}}AFX\n";
    setFinal = "//}}AFX\n";
    stateprecondition = "//}}AFX\n";
    condprecondition = "//}}AFX\n";
    stateinit = "//}}AFX\n";
    globalprefix = "//}}AFX\n";
    link = "\n";
  };
  class FSMPrefix2
  {
    default = "";
    head = "*/";
    condition = "\n";
    condprecondition = "\n";
    action = "\n";
    fsmFunctionDeclaration = "\n";
    fsmFunctionPrefix = "\n";
    fsmFunctionSufix = "\n";
    setFinal = "\n";
    stateinit = "\n";
    stateprecondition = "\n";
    globalprefix = "\n";
  };
  class FSMSufix
  {
    default = "";
    compile = "\n";
    state = "\n";
    head = "//{{AFX\n/*\n";
    link = "\n";
    condition = "\n";
    condprecondition = "\n";
    action = "\n";
    fsmFunctionDeclaration = "\n";
    fsmFunctionPrefix = "\n";
    fsmFunctionSufix = "\n";
    setFinal = "\n";
    stateinit = "\n";
    stateprecondition = "\n";
    globalprefix = "\n";
  };
  class FSMSufix2
  {
    default = "";
    compile = "";
    state = "\n";
    head = "//}}AFX\n";
    link = "\n";
    action = "//{{AFX\n";
    condition = "//{{AFX\n";
    fsmFunctionDeclaration = "//{{AFX\n";
    fsmFunctionPrefix = "//{{AFX\n";
    fsmFunctionSufix = "//{{AFX\n";
    setFinal = "//{{AFX\n";
    condprecondition = "//{{AFX\n";
    stateinit = "//{{AFX\n";
    stateprecondition = "//{{AFX\n";
    globalprefix = "//{{AFX\n";
  };
};
