예제 #1
0
 public virtual void CaseStart(Start node)
 {
     DefaultCase(node);
 }
예제 #2
0
 public virtual void OutStart(Start node)
 {
     DefaultOut(node);
 }
예제 #3
0
 public override void CaseStart(Start node)
 {
     InStart(node);
     node.GetEOF().Apply(this);
     node.GetPDocument().Apply(this);
     OutStart(node);
 }
예제 #4
0
 public virtual void InStart(Start node)
 {
     DefaultIn(node);
 }
예제 #5
0
        public Start Parse()
        {
            Push(0, null);

            IList ign = null;
            while(true)
            {
            while(Index(lexer.Peek()) == -1)
            {
                if(ign == null)
                {
                    ign = new TypedList(NodeCast.Instance);
                }

                ign.Add(lexer.Next());
            }

            if(ign != null)
            {
                ignoredTokens.SetIn(lexer.Peek(), ign);
                ign = null;
            }

            last_pos = lexer.Peek().Pos;
            last_line = lexer.Peek().Line;
            last_token = lexer.Peek();

            int index = Index(lexer.Peek());
            action[0] = actionTable[State()][0][1];
            action[1] = actionTable[State()][0][2];

            int low = 1;
            int high = actionTable[State()].Length - 1;

            while(low <= high)
            {
                int middle = (low + high) / 2;

                if(index < actionTable[State()][middle][0])
                {
                    high = middle - 1;
                }
                else if(index > actionTable[State()][middle][0])
                {
                    low = middle + 1;
                }
                else
                {
                    action[0] = actionTable[State()][middle][1];
                    action[1] = actionTable[State()][middle][2];
                    break;
                }
            }

            switch(action[0])
            {
                case SHIFT:
            {
            ArrayList list = new ArrayList();
            list.Add(lexer.Next());
                        Push(action[1], list);
                        last_shift = action[1];
                    }
            break;
                case REDUCE:
                    switch(action[1])
                    {
                    case 0:
            {
              ArrayList list = New0();
              Push(GoTo(0), list);
            }
            break;
                    case 1:
            {
              ArrayList list = New1();
              Push(GoTo(0), list);
            }
            break;
                    case 2:
            {
              ArrayList list = New2();
              Push(GoTo(0), list);
            }
            break;
                    case 3:
            {
              ArrayList list = New3();
              Push(GoTo(0), list);
            }
            break;
                    case 4:
            {
              ArrayList list = New4();
              Push(GoTo(0), list);
            }
            break;
                    case 5:
            {
              ArrayList list = New5();
              Push(GoTo(0), list);
            }
            break;
                    case 6:
            {
              ArrayList list = New6();
              Push(GoTo(0), list);
            }
            break;
                    case 7:
            {
              ArrayList list = New7();
              Push(GoTo(0), list);
            }
            break;
                    case 8:
            {
              ArrayList list = New8();
              Push(GoTo(0), list);
            }
            break;
                    case 9:
            {
              ArrayList list = New9();
              Push(GoTo(0), list);
            }
            break;
                    case 10:
            {
              ArrayList list = New10();
              Push(GoTo(0), list);
            }
            break;
                    case 11:
            {
              ArrayList list = New11();
              Push(GoTo(0), list);
            }
            break;
                    case 12:
            {
              ArrayList list = New12();
              Push(GoTo(0), list);
            }
            break;
                    case 13:
            {
              ArrayList list = New13();
              Push(GoTo(0), list);
            }
            break;
                    case 14:
            {
              ArrayList list = New14();
              Push(GoTo(0), list);
            }
            break;
                    case 15:
            {
              ArrayList list = New15();
              Push(GoTo(0), list);
            }
            break;
                    case 16:
            {
              ArrayList list = New16();
              Push(GoTo(0), list);
            }
            break;
                    case 17:
            {
              ArrayList list = New17();
              Push(GoTo(0), list);
            }
            break;
                    case 18:
            {
              ArrayList list = New18();
              Push(GoTo(0), list);
            }
            break;
                    case 19:
            {
              ArrayList list = New19();
              Push(GoTo(0), list);
            }
            break;
                    case 20:
            {
              ArrayList list = New20();
              Push(GoTo(0), list);
            }
            break;
                    case 21:
            {
              ArrayList list = New21();
              Push(GoTo(0), list);
            }
            break;
                    case 22:
            {
              ArrayList list = New22();
              Push(GoTo(0), list);
            }
            break;
                    case 23:
            {
              ArrayList list = New23();
              Push(GoTo(0), list);
            }
            break;
                    case 24:
            {
              ArrayList list = New24();
              Push(GoTo(0), list);
            }
            break;
                    case 25:
            {
              ArrayList list = New25();
              Push(GoTo(0), list);
            }
            break;
                    case 26:
            {
              ArrayList list = New26();
              Push(GoTo(0), list);
            }
            break;
                    case 27:
            {
              ArrayList list = New27();
              Push(GoTo(0), list);
            }
            break;
                    case 28:
            {
              ArrayList list = New28();
              Push(GoTo(0), list);
            }
            break;
                    case 29:
            {
              ArrayList list = New29();
              Push(GoTo(0), list);
            }
            break;
                    case 30:
            {
              ArrayList list = New30();
              Push(GoTo(0), list);
            }
            break;
                    case 31:
            {
              ArrayList list = New31();
              Push(GoTo(0), list);
            }
            break;
                    case 32:
            {
              ArrayList list = New32();
              Push(GoTo(0), list);
            }
            break;
                    case 33:
            {
              ArrayList list = New33();
              Push(GoTo(0), list);
            }
            break;
                    case 34:
            {
              ArrayList list = New34();
              Push(GoTo(0), list);
            }
            break;
                    case 35:
            {
              ArrayList list = New35();
              Push(GoTo(0), list);
            }
            break;
                    case 36:
            {
              ArrayList list = New36();
              Push(GoTo(0), list);
            }
            break;
                    case 37:
            {
              ArrayList list = New37();
              Push(GoTo(0), list);
            }
            break;
                    case 38:
            {
              ArrayList list = New38();
              Push(GoTo(0), list);
            }
            break;
                    case 39:
            {
              ArrayList list = New39();
              Push(GoTo(0), list);
            }
            break;
                    case 40:
            {
              ArrayList list = New40();
              Push(GoTo(0), list);
            }
            break;
                    case 41:
            {
              ArrayList list = New41();
              Push(GoTo(0), list);
            }
            break;
                    case 42:
            {
              ArrayList list = New42();
              Push(GoTo(0), list);
            }
            break;
                    case 43:
            {
              ArrayList list = New43();
              Push(GoTo(0), list);
            }
            break;
                    case 44:
            {
              ArrayList list = New44();
              Push(GoTo(0), list);
            }
            break;
                    case 45:
            {
              ArrayList list = New45();
              Push(GoTo(0), list);
            }
            break;
                    case 46:
            {
              ArrayList list = New46();
              Push(GoTo(0), list);
            }
            break;
                    case 47:
            {
              ArrayList list = New47();
              Push(GoTo(0), list);
            }
            break;
                    case 48:
            {
              ArrayList list = New48();
              Push(GoTo(1), list);
            }
            break;
                    case 49:
            {
              ArrayList list = New49();
              Push(GoTo(2), list);
            }
            break;
                    case 50:
            {
              ArrayList list = New50();
              Push(GoTo(2), list);
            }
            break;
                    case 51:
            {
              ArrayList list = New51();
              Push(GoTo(3), list);
            }
            break;
                    case 52:
            {
              ArrayList list = New52();
              Push(GoTo(3), list);
            }
            break;
                    case 53:
            {
              ArrayList list = New53();
              Push(GoTo(3), list);
            }
            break;
                    case 54:
            {
              ArrayList list = New54();
              Push(GoTo(4), list);
            }
            break;
                    case 55:
            {
              ArrayList list = New55();
              Push(GoTo(4), list);
            }
            break;
                    case 56:
            {
              ArrayList list = New56();
              Push(GoTo(5), list);
            }
            break;
                    case 57:
            {
              ArrayList list = New57();
              Push(GoTo(5), list);
            }
            break;
                    case 58:
            {
              ArrayList list = New58();
              Push(GoTo(5), list);
            }
            break;
                    case 59:
            {
              ArrayList list = New59();
              Push(GoTo(6), list);
            }
            break;
                    case 60:
            {
              ArrayList list = New60();
              Push(GoTo(6), list);
            }
            break;
                    case 61:
            {
              ArrayList list = New61();
              Push(GoTo(7), list);
            }
            break;
                    case 62:
            {
              ArrayList list = New62();
              Push(GoTo(8), list);
            }
            break;
                    case 63:
            {
              ArrayList list = New63();
              Push(GoTo(8), list);
            }
            break;
                    case 64:
            {
              ArrayList list = New64();
              Push(GoTo(8), list);
            }
            break;
                    case 65:
            {
              ArrayList list = New65();
              Push(GoTo(8), list);
            }
            break;
                    case 66:
            {
              ArrayList list = New66();
              Push(GoTo(8), list);
            }
            break;
                    case 67:
            {
              ArrayList list = New67();
              Push(GoTo(8), list);
            }
            break;
                    case 68:
            {
              ArrayList list = New68();
              Push(GoTo(8), list);
            }
            break;
                    case 69:
            {
              ArrayList list = New69();
              Push(GoTo(8), list);
            }
            break;
                    case 70:
            {
              ArrayList list = New70();
              Push(GoTo(9), list);
            }
            break;
                    case 71:
            {
              ArrayList list = New71();
              Push(GoTo(9), list);
            }
            break;
                    case 72:
            {
              ArrayList list = New72();
              Push(GoTo(10), list);
            }
            break;
                    case 73:
            {
              ArrayList list = New73();
              Push(GoTo(11), list);
            }
            break;
                    case 74:
            {
              ArrayList list = New74();
              Push(GoTo(12), list);
            }
            break;
                    case 75:
            {
              ArrayList list = New75();
              Push(GoTo(12), list);
            }
            break;
                    case 76:
            {
              ArrayList list = New76();
              Push(GoTo(12), list);
            }
            break;
                    case 77:
            {
              ArrayList list = New77();
              Push(GoTo(12), list);
            }
            break;
                    case 78:
            {
              ArrayList list = New78();
              Push(GoTo(12), list);
            }
            break;
                    case 79:
            {
              ArrayList list = New79();
              Push(GoTo(12), list);
            }
            break;
                    case 80:
            {
              ArrayList list = New80();
              Push(GoTo(13), list);
            }
            break;
                    case 81:
            {
              ArrayList list = New81();
              Push(GoTo(13), list);
            }
            break;
                    case 82:
            {
              ArrayList list = New82();
              Push(GoTo(14), list);
            }
            break;
                    case 83:
            {
              ArrayList list = New83();
              Push(GoTo(14), list);
            }
            break;
                    case 84:
            {
              ArrayList list = New84();
              Push(GoTo(15), list);
            }
            break;
                    case 85:
            {
              ArrayList list = New85();
              Push(GoTo(15), list);
            }
            break;
                    case 86:
            {
              ArrayList list = New86();
              Push(GoTo(16), list);
            }
            break;
                    case 87:
            {
              ArrayList list = New87();
              Push(GoTo(16), list);
            }
            break;
                    case 88:
            {
              ArrayList list = New88();
              Push(GoTo(17), list);
            }
            break;
                    case 89:
            {
              ArrayList list = New89();
              Push(GoTo(18), list);
            }
            break;
                    case 90:
            {
              ArrayList list = New90();
              Push(GoTo(19), list);
            }
            break;
                    case 91:
            {
              ArrayList list = New91();
              Push(GoTo(19), list);
            }
            break;
                    case 92:
            {
              ArrayList list = New92();
              Push(GoTo(19), list);
            }
            break;
                    case 93:
            {
              ArrayList list = New93();
              Push(GoTo(19), list);
            }
            break;
                    case 94:
            {
              ArrayList list = New94();
              Push(GoTo(19), list);
            }
            break;
                    case 95:
            {
              ArrayList list = New95();
              Push(GoTo(19), list);
            }
            break;
                    case 96:
            {
              ArrayList list = New96();
              Push(GoTo(19), list);
            }
            break;
                    case 97:
            {
              ArrayList list = New97();
              Push(GoTo(19), list);
            }
            break;
                    case 98:
            {
              ArrayList list = New98();
              Push(GoTo(19), list);
            }
            break;
                    case 99:
            {
              ArrayList list = New99();
              Push(GoTo(20), list);
            }
            break;
                    case 100:
            {
              ArrayList list = New100();
              Push(GoTo(21), list);
            }
            break;
                    case 101:
            {
              ArrayList list = New101();
              Push(GoTo(22), list);
            }
            break;
                    case 102:
            {
              ArrayList list = New102();
              Push(GoTo(22), list);
            }
            break;
                    case 103:
            {
              ArrayList list = New103();
              Push(GoTo(23), list);
            }
            break;
                    case 104:
            {
              ArrayList list = New104();
              Push(GoTo(23), list);
            }
            break;
                    case 105:
            {
              ArrayList list = New105();
              Push(GoTo(24), list);
            }
            break;
                    case 106:
            {
              ArrayList list = New106();
              Push(GoTo(24), list);
            }
            break;
                    case 107:
            {
              ArrayList list = New107();
              Push(GoTo(25), list);
            }
            break;
                    case 108:
            {
              ArrayList list = New108();
              Push(GoTo(25), list);
            }
            break;
                    case 109:
            {
              ArrayList list = New109();
              Push(GoTo(25), list);
            }
            break;
                    case 110:
            {
              ArrayList list = New110();
              Push(GoTo(25), list);
            }
            break;
                    case 111:
            {
              ArrayList list = New111();
              Push(GoTo(26), list);
            }
            break;
                    case 112:
            {
              ArrayList list = New112();
              Push(GoTo(26), list);
            }
            break;
                    case 113:
            {
              ArrayList list = New113();
              Push(GoTo(27), list);
            }
            break;
                    case 114:
            {
              ArrayList list = New114();
              Push(GoTo(28), list);
            }
            break;
                    case 115:
            {
              ArrayList list = New115();
              Push(GoTo(28), list);
            }
            break;
                    case 116:
            {
              ArrayList list = New116();
              Push(GoTo(29), list);
            }
            break;
                    case 117:
            {
              ArrayList list = New117();
              Push(GoTo(30), list);
            }
            break;
                    case 118:
            {
              ArrayList list = New118();
              Push(GoTo(31), list);
            }
            break;
                    case 119:
            {
              ArrayList list = New119();
              Push(GoTo(31), list);
            }
            break;
                    case 120:
            {
              ArrayList list = New120();
              Push(GoTo(31), list);
            }
            break;
                    case 121:
            {
              ArrayList list = New121();
              Push(GoTo(32), list);
            }
            break;
                    case 122:
            {
              ArrayList list = New122();
              Push(GoTo(33), list);
            }
            break;
                    case 123:
            {
              ArrayList list = New123();
              Push(GoTo(33), list);
            }
            break;
                    case 124:
            {
              ArrayList list = New124();
              Push(GoTo(34), list);
            }
            break;
                    case 125:
            {
              ArrayList list = New125();
              Push(GoTo(34), list);
            }
            break;
                    case 126:
            {
              ArrayList list = New126();
              Push(GoTo(35), list);
            }
            break;
                    case 127:
            {
              ArrayList list = New127();
              Push(GoTo(35), list);
            }
            break;
                    case 128:
            {
              ArrayList list = New128();
              Push(GoTo(35), list);
            }
            break;
                    case 129:
            {
              ArrayList list = New129();
              Push(GoTo(35), list);
            }
            break;
                    case 130:
            {
              ArrayList list = New130();
              Push(GoTo(35), list);
            }
            break;
                    case 131:
            {
              ArrayList list = New131();
              Push(GoTo(36), list);
            }
            break;
                    case 132:
            {
              ArrayList list = New132();
              Push(GoTo(36), list);
            }
            break;
                    case 133:
            {
              ArrayList list = New133();
              Push(GoTo(37), list);
            }
            break;
                    case 134:
            {
              ArrayList list = New134();
              Push(GoTo(37), list);
            }
            break;
                    case 135:
            {
              ArrayList list = New135();
              Push(GoTo(37), list);
            }
            break;
                    case 136:
            {
              ArrayList list = New136();
              Push(GoTo(37), list);
            }
            break;
                    case 137:
            {
              ArrayList list = New137();
              Push(GoTo(38), list);
            }
            break;
                    case 138:
            {
              ArrayList list = New138();
              Push(GoTo(39), list);
            }
            break;
                    case 139:
            {
              ArrayList list = New139();
              Push(GoTo(39), list);
            }
            break;
                    case 140:
            {
              ArrayList list = New140();
              Push(GoTo(39), list);
            }
            break;
                    case 141:
            {
              ArrayList list = New141();
              Push(GoTo(39), list);
            }
            break;
                    case 142:
            {
              ArrayList list = New142();
              Push(GoTo(39), list);
            }
            break;
                    case 143:
            {
              ArrayList list = New143();
              Push(GoTo(39), list);
            }
            break;
                    case 144:
            {
              ArrayList list = New144();
              Push(GoTo(40), list);
            }
            break;
                    case 145:
            {
              ArrayList list = New145();
              Push(GoTo(41), list);
            }
            break;
                    case 146:
            {
              ArrayList list = New146();
              Push(GoTo(41), list);
            }
            break;
                    case 147:
            {
              ArrayList list = New147();
              Push(GoTo(42), list);
            }
            break;
                    case 148:
            {
              ArrayList list = New148();
              Push(GoTo(42), list);
            }
            break;
                    case 149:
            {
              ArrayList list = New149();
              Push(GoTo(43), list);
            }
            break;
                    case 150:
            {
              ArrayList list = New150();
              Push(GoTo(43), list);
            }
            break;
                    }
                    break;
                case ACCEPT:
                    {
                        EOF node2 = (EOF) lexer.Next();
                        PDocument node1 = (PDocument) ((ArrayList)Pop())[0];
                        Start node = new Start(node1, node2);
                        return node;
                    }
                case ERROR:
                    throw new ParserException(last_token,
                        "[" + last_line + "," + last_pos + "] " +
                        errorMessages[errors[action[1]]]);
            }
            }
        }