Пример #1
0
        protected override void DoAction(int action)
        {
#pragma warning disable 162, 1522
            switch (action)
            {
            case 2: // program -> statementList
            { program = ValueStack[ValueStack.Depth - 1].statementList; }
            break;

            case 3: // statementList -> /* empty */
            {
                if (CurrentSemanticValue.statementList == null)
                {
                    CurrentSemanticValue.statementList = codegen.NewList();
                }
            }
            break;

            case 4: // statementList -> statement
            {
                if (CurrentSemanticValue.statementList == null)
                {
                    CurrentSemanticValue.statementList = codegen.NewList();
                }
                if (ValueStack[ValueStack.Depth - 1].statement != null)
                {
                    CurrentSemanticValue.statementList.InsertFront(ValueStack[ValueStack.Depth - 1].statement);
                }
            }
            break;

            case 5: // statementList -> statementList, statement
            {
                if (ValueStack[ValueStack.Depth - 1].statement != null)
                {
                    ValueStack[ValueStack.Depth - 2].statementList.Add(ValueStack[ValueStack.Depth - 1].statement);
                }
                CurrentSemanticValue.statementList = ValueStack[ValueStack.Depth - 2].statementList;
            }
            break;

            case 6: // statement -> plainInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 7: // statement -> assignInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 8: // statement -> forInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 9: // statement -> ifInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 10: // statement -> caseInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 11: // statement -> rawInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 12: // statement -> unlessInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 13: // statement -> tableInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 14: // statement -> captureInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 15: // statement -> includeInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 16: // statement -> timeoutInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 17: // statement -> cycleInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 18: // statement -> commentInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 19: // statement -> outputInst
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
            break;

            case 20: // expr -> expr, AND, term
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.And, ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 21: // expr -> expr, OR, term
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.Or, ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 22: // expr -> term
            { CurrentSemanticValue.expr = ValueStack[ValueStack.Depth - 1].expr; }
            break;

            case 23: // term -> fact, OP_EQ, fact
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.Equ, ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 24: // term -> fact, OP_NE, fact
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.NotEqu, ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 25: // term -> fact, OP_LT, fact
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.Lt, ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 26: // term -> fact, OP_GT, fact
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.Gt, ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 27: // term -> fact, OP_GE, fact
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.GtEq, ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 28: // term -> fact, OP_LE, fact
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.LtEq, ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 29: // term -> fact
            { CurrentSemanticValue.expr = ValueStack[ValueStack.Depth - 1].expr; }
            break;

            case 30: // fact -> LEFT_PAR, expr, RIGHT_PAR
            { CurrentSemanticValue.expr = ValueStack[ValueStack.Depth - 2].expr; }
            break;

            case 31: // fact -> STRING_LITERAL
            { CurrentSemanticValue.expr = codegen.NewExpression(ValueStack[ValueStack.Depth - 1].String); }
            break;

            case 32: // fact -> BOOL_LITERAL
            { CurrentSemanticValue.expr = codegen.NewExpression(ValueStack[ValueStack.Depth - 1].Bool); }
            break;

            case 33: // fact -> NUM_LITERAL
            { CurrentSemanticValue.expr = codegen.NewExpression(ValueStack[ValueStack.Depth - 1].Double); }
            break;

            case 34: // fact -> NIL_LITERAL
            { CurrentSemanticValue.expr = codegen.NewExpression(); }
            break;

            case 35: // fact -> lookup
            { CurrentSemanticValue.expr = ValueStack[ValueStack.Depth - 1].expr; }
            break;

            case 36: // lookup -> lookup, DOT, IDENTIFIER
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.Lookup, ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].String); }
            break;

            case 37: // lookup -> IDENTIFIER
            { CurrentSemanticValue.expr = codegen.NewExpression(Operation.Lookup, ValueStack[ValueStack.Depth - 1].String); }
            break;

            case 38: // assignInst -> TAG_START, ASSIGN, IDENTIFIER, OP_ASSIGN, expr, TAG_END
            { CurrentSemanticValue.statement = codegen.NewAssignment(ValueStack[ValueStack.Depth - 4].String, ValueStack[ValueStack.Depth - 2].expr); }
            break;

            case 39: // commentInst -> TAG_START, COMMENT, TAG_END
            { CurrentSemanticValue.statement = null; }
            break;

            case 40: // plainInst -> PLAIN
            { CurrentSemanticValue.statement = codegen.Write(ValueStack[ValueStack.Depth - 1].String); }
            break;

            case 41: // rawInst -> TAG_START, RAW, stringList, END_RAW, TAG_END
            { CurrentSemanticValue.statement = codegen.Write(ValueStack[ValueStack.Depth - 3].StringBuilder.ToString()); }
            break;

            case 42: // stringList -> /* empty */
            { CurrentSemanticValue.StringBuilder = new StringBuilder(); }
            break;

            case 43: // stringList -> stringList, PLAIN
            { ValueStack[ValueStack.Depth - 2].StringBuilder.Append(ValueStack[ValueStack.Depth - 1].String); CurrentSemanticValue.StringBuilder = ValueStack[ValueStack.Depth - 2].StringBuilder; }
            break;

            case 44: // forInst -> TAG_START, FOR, IDENTIFIER, IN, lookup, attributes, TAG_END,
                     //            statementList, TAG_START, END_FOR, TAG_END
            { CurrentSemanticValue.statement = codegen.NewForLoop(ValueStack[ValueStack.Depth - 9].String, ValueStack[ValueStack.Depth - 7].expr, ValueStack[ValueStack.Depth - 6].statementList, ValueStack[ValueStack.Depth - 4].statementList); }
            break;

            case 45: // forInst -> TAG_START, FOR, IDENTIFIER, IN, LEFT_PAR, expr, DOT_DOT, expr,
                     //            RIGHT_PAR, attributes, TAG_END, statementList, TAG_START, END_FOR,
                     //            TAG_END
            { CurrentSemanticValue.statement = codegen.NewForLoop(ValueStack[ValueStack.Depth - 13].String, codegen.NewExpression(Operation.Range, ValueStack[ValueStack.Depth - 10].expr, ValueStack[ValueStack.Depth - 8].expr), ValueStack[ValueStack.Depth - 6].statementList, ValueStack[ValueStack.Depth - 4].statementList); }
            break;

            case 46: // Anon@1 -> /* empty */
            { currentStatement.Push(codegen.NewIf(ValueStack[ValueStack.Depth - 4].expr, ValueStack[ValueStack.Depth - 2].statementList)); }
            break;

            case 47: // ifInst -> TAG_START, IF, expr, TAG_END, statementList, TAG_START, Anon@1,
                     //           optionalElse, END_IF, TAG_END
            { CurrentSemanticValue.statement = currentStatement.Pop(); }
            break;

            case 49: // optionalElse -> ELSE, TAG_END, statementList, TAG_START
            { codegen.AddElseClause(currentStatement.Peek(), ValueStack[ValueStack.Depth - 2].statementList); }
            break;

            case 50: // Anon@2 -> /* empty */
            { currentStatement.Push(codegen.NewCase(ValueStack[ValueStack.Depth - 2].expr)); }
            break;

            case 51: // caseInst -> TAG_START, CASE, expr, TAG_END, Anon@2, whenList, TAG_START,
                     //             optionalElse, END_CASE, TAG_END
            { CurrentSemanticValue.statement = currentStatement.Pop(); }
            break;

            case 52: // when -> TAG_START, WHEN, expr, TAG_END, statementList
            { codegen.AddWhenClause(currentStatement.Peek(), ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 1].statementList); }
            break;

            case 55: // Anon@3 -> /* empty */
            { currentStatement.Push(codegen.NewUnless(ValueStack[ValueStack.Depth - 4].expr, ValueStack[ValueStack.Depth - 2].statementList)); }
            break;

            case 56: // unlessInst -> TAG_START, UNLESS, expr, TAG_END, statementList, TAG_START,
                     //               Anon@3, optionalElse, END_UNLESS, TAG_END
            { CurrentSemanticValue.statement = currentStatement.Pop(); }
            break;

            case 57: // tableInst -> TAG_START, TABLE, IDENTIFIER, IN, lookup, attributes, TAG_END,
                     //              statementList, TAG_START, END_TABLE, TAG_END
            { CurrentSemanticValue.statement = codegen.NewTableRow(ValueStack[ValueStack.Depth - 9].String, ValueStack[ValueStack.Depth - 7].expr, ValueStack[ValueStack.Depth - 6].statementList, ValueStack[ValueStack.Depth - 4].statementList); }
            break;

            case 58: // captureInst -> TAG_START, CAPTURE, IDENTIFIER, TAG_END, statementList,
                     //                TAG_START, END_CAPTURE, TAG_END
            {
                CurrentSemanticValue.statement = codegen.NewCapture(ValueStack[ValueStack.Depth - 6].String, ValueStack[ValueStack.Depth - 4].statementList);
            }
            break;

            case 59: // includeInst -> TAG_START, INCLUDE, STRING_LITERAL, optionalWith, TAG_END
            { CurrentSemanticValue.statement = codegen.Include(ValueStack[ValueStack.Depth - 3].String, ValueStack[ValueStack.Depth - 2].expr); }
            break;

            case 60: // optionalWith -> /* empty */
            { CurrentSemanticValue.expr = null; }
            break;

            case 61: // optionalWith -> WITH, expr
            { CurrentSemanticValue.expr = ValueStack[ValueStack.Depth - 1].expr; }
            break;

            case 62: // timeoutInst -> TAG_START, TIMEOUT, NUM_LITERAL, TAG_END
            { CurrentSemanticValue.statement = codegen.NewTimeout(ValueStack[ValueStack.Depth - 2].Double); }
            break;

            case 63: // cycleInst -> TAG_START, CYCLE, cycleGroup, exprList, TAG_END
            { CurrentSemanticValue.statement = codegen.NewCycle(ValueStack[ValueStack.Depth - 3].String, ValueStack[ValueStack.Depth - 2].statementList); }
            break;

            case 64: // cycleGroup -> STRING_LITERAL, COL
            { CurrentSemanticValue.String = ValueStack[ValueStack.Depth - 2].String; }
            break;

            case 65: // cycleGroup -> /* empty */
            { CurrentSemanticValue.String = ""; }
            break;

            case 66: // exprList -> exprList, COMMA, expr
            { CurrentSemanticValue.statementList = ValueStack[ValueStack.Depth - 3].statementList; CurrentSemanticValue.statementList.Add(ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 67: // exprList -> expr
            { CurrentSemanticValue.statementList = codegen.NewList(); CurrentSemanticValue.statementList.Add(ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 68: // attributes -> attributes, attribute
            { CurrentSemanticValue.statementList = ValueStack[ValueStack.Depth - 2].statementList; CurrentSemanticValue.statementList.Add(ValueStack[ValueStack.Depth - 1].statement); }
            break;

            case 69: // attributes -> /* empty */
            { CurrentSemanticValue.statementList = codegen.NewList(); }
            break;

            case 70: // attribute -> IDENTIFIER, COL, expr
            { CurrentSemanticValue.statement = codegen.NewAttribute(ValueStack[ValueStack.Depth - 3].String, ValueStack[ValueStack.Depth - 1].expr); }
            break;

            case 71: // outputInst -> OUTPUT_START, expr, filterList, OUTPUT_END
            { CurrentSemanticValue.statement = codegen.Write(ValueStack[ValueStack.Depth - 3].expr, ValueStack[ValueStack.Depth - 2].statementList); }
            break;

            case 72: // filterList -> filterList, filter
            { CurrentSemanticValue.statementList = ValueStack[ValueStack.Depth - 2].statementList; CurrentSemanticValue.statementList.Add(ValueStack[ValueStack.Depth - 1].statement); }
            break;

            case 73: // filterList -> /* empty */
            { CurrentSemanticValue.statementList = codegen.NewList(); }
            break;

            case 74: // filter -> PIPE, IDENTIFIER, OptionalParams
            { CurrentSemanticValue.statement = codegen.NewFilter(ValueStack[ValueStack.Depth - 2].String, ValueStack[ValueStack.Depth - 1].statementList); }
            break;

            case 75: // OptionalParams -> COL, exprList
            { CurrentSemanticValue.statementList = ValueStack[ValueStack.Depth - 1].statementList; }
            break;

            case 76: // OptionalParams -> /* empty */
            { CurrentSemanticValue.statementList = null; }
            break;
            }
#pragma warning restore 162, 1522
        }