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

class Compile
{
  clearNewLines = 0;
  rewriteFile = 1; //do not append result to the end of file, but rewrite it
  class Pass_1
  {
    print_1 = "public class %(fsmname) extends FSMBase\n";
    print_2 = "{\n";
    indent_1 = 2;
    print_3 = "// variables valid during existence of FSM and helper functions\n";
    print_4 = "%(fsmVariables)\n";
    print_5 = "// FSM States\n";
    class State
    {
        print_1 = "private FSMState _state%(statename) = new FSMState()\n";
        print_2 = "{\n";
        indent_1 = 4;

        print_3 = "public void create()\n";
        print_4 = "{\n";
        indent_2 = 6;
        ifFinal_yes = 1;
        print_final = "_final = true;\n";
        ifFinal_both = 0;
        
        class Links
        {
            print_1 = "addLink(new FSMLink(%(priority), _state%(to))\n";
            print_2 = "{\n";
            indent_1 = 8;
            
            print_3 = "protected void precondition()\n";
            print_4 = "{\n";
            indent_2 = 10;
            print_5 = "%(condPreCondition)\n";
            indent_3 = 8;
            print_6 = "}\n";

            print_7 = "protected boolean condition()\n";
            print_8 = "{\n";
            indent_4 = 10;
            print_9 = "%(condition)\n";
            indent_5 = 8;
            print_10 = "}\n";

            print_11 = "protected void action()\n";
            print_12 = "{\n";
            indent_6 = 10;
            print_13 = "%(action)\n";
            indent_7 = 8;
            print_14 = "}\n";

            indent_8 = 6;
            print_15 = "});\n";
        };

        indent_3 = 4;
        print_5 = "}\n";

        print_6 = "protected void init()\n";
        print_7 = "{\n";
        indent_4 = 6;
        print_8 = "%(stateinit)\n";
        indent_5 = 4;
        print_9 = "}\n";

        print_10 = "protected void precondition()\n";
        print_11 = "{\n";
        indent_6 = 6;
        print_12 = "%(stateprecondition)\n";
        indent_7 = 4;
        print_13 = "}\n";

        indent_8 = 2;
        print_14 = "};\n";
    };
  }
  class Pass_2
  {
    indent_1 = 2;
    print_1 = "// FSM creation\n";
    print_2 = "public %(fsmname)()\n";
    print_3 = "{\n";
    indent_2 = 4;
    class State
    {
        print_1 = "_state%(statename).create();\n";
    };
    print_4 = "\n";
    print_5 = "create(_state%(initStateName));\n";
    indent_3 = 2;
    print_6 = "}\n";
    indent_4 = 0;
    print_7 = "};\n";
  };
};

class Decompile
{
  process = 0;   //0 for not processing Decompile info
};
