Beispiel #1
0
        public void SetType(int id, SimpleScriptTypes type)
        {
            if (!symbolTable.ContainsKey(id))
            {
                throw new ArgumentException("Undeclared identifier.");
            }
            SymbolTableElement x = symbolTable[id];

            switch (type)
            {
            case SimpleScriptTypes.Integer:
                SymbolTableIntegerElement stie = new SymbolTableIntegerElement(x.Name, 0);
                symbolTable[id] = stie;
                break;

            case  SimpleScriptTypes.Double:
                SymbolTableDoubleElement stde = new SymbolTableDoubleElement(x.Name, 0.0);
                symbolTable[id] = stde;
                break;

            case SimpleScriptTypes.Boolean:
                SymbolTableBoolElement stbe = new SymbolTableBoolElement(x.Name, false);
                symbolTable[id] = stbe;
                break;

            case SimpleScriptTypes.String:
                SymbolTableStringElement stse = new SymbolTableStringElement(x.Name, "");
                symbolTable[id] = stse;
                break;

            case SimpleScriptTypes.PosInfo:
                SymbolTablePosElement stpe = new SymbolTablePosElement(x.Name, new PosInfo(x.Name));
                symbolTable[id] = stpe;
                break;
            }
        }
Beispiel #2
0
        protected override void DoAction(int action)
        {
#pragma warning disable 162, 1522
            switch (action)
            {
            case 2: // program -> BEGIN, EOL, statementList, EOL, POS_, posInfoList, END
#line 120 "SimpleScriptParser.y"
            { program = ValueStack[ValueStack.Depth - 5].statementList; }
#line default
                break;

            case 3: // statementList -> /* empty */
#line 123 "SimpleScriptParser.y"
            { if (CurrentSemanticValue.statementList == null)
              {
                  CurrentSemanticValue.statementList = new StatementList();
              }
            }
#line default
                break;

            case 4: // statementList -> statement
#line 125 "SimpleScriptParser.y"
            { if (CurrentSemanticValue.statementList == null)
              {
                  CurrentSemanticValue.statementList = new StatementList();
              }
              CurrentSemanticValue.statementList.InsertFront(ValueStack[ValueStack.Depth - 1].statement); }
#line default
                break;

            case 5: // statementList -> statementList, EOL, statement
#line 129 "SimpleScriptParser.y"
            { ValueStack[ValueStack.Depth - 3].statementList.Add(ValueStack[ValueStack.Depth - 1].statement); CurrentSemanticValue.statementList = ValueStack[ValueStack.Depth - 3].statementList; }
#line default
                break;

            case 6: // statement -> moveStatement
#line 133 "SimpleScriptParser.y"
            { CurrentSemanticValue.statement = ValueStack[ValueStack.Depth - 1].statement; }
#line default
                break;

            case 7: // moveStatement -> JOINT, POS, moveSpeed, moveFine, SEMI
#line 136 "SimpleScriptParser.y"
            { CurrentSemanticValue.statement = new MoveStatement(MoveTypes.Joint, ValueStack[ValueStack.Depth - 4].String, ValueStack[ValueStack.Depth - 3].moveSpeed); }
#line default
                break;

            case 8: // moveSpeed -> INTEGER_LITERAL, PERCENT
#line 139 "SimpleScriptParser.y"
            { CurrentSemanticValue.moveSpeed = new MoveSpeed(ValueStack[ValueStack.Depth - 2].Integer, "percent"); }
#line default
                break;

            case 9: // moveSpeed -> INTEGER_LITERAL, MM_SEC
#line 140 "SimpleScriptParser.y"
            { CurrentSemanticValue.moveSpeed = new MoveSpeed(ValueStack[ValueStack.Depth - 2].Integer, "mm/sec"); }
#line default
                break;

            case 10: // moveSpeed -> INTEGER_LITERAL, CM_MIN
#line 141 "SimpleScriptParser.y"
            { CurrentSemanticValue.moveSpeed = new MoveSpeed(ValueStack[ValueStack.Depth - 2].Integer, "cm/min"); }
#line default
                break;

            case 11: // moveSpeed -> INTEGER_LITERAL, INCH_MIN
#line 142 "SimpleScriptParser.y"
            { CurrentSemanticValue.moveSpeed = new MoveSpeed(ValueStack[ValueStack.Depth - 2].Integer, "inch/min"); }
#line default
                break;

            case 12: // moveSpeed -> INTEGER_LITERAL, DEG_SEC
#line 143 "SimpleScriptParser.y"
            { CurrentSemanticValue.moveSpeed = new MoveSpeed(ValueStack[ValueStack.Depth - 2].Integer, "deg/sec"); }
#line default
                break;

            case 17: // posInfo -> POS, OP_LEFT_BIG, EOL, GROUP, COLON, EOL, UF, COLON, INTEGER_LITERAL,
                     //            COMMA, UT, COLON, INTEGER_LITERAL, COMMA, EOL, J1, OP_ASSIGN,
                     //            DOUBLE_LITERAL, DEG, COMMA, J2, OP_ASSIGN, DOUBLE_LITERAL, DEG,
                     //            COMMA, J3, OP_ASSIGN, DOUBLE_LITERAL, DEG, COMMA, EOL, J4,
                     //            OP_ASSIGN, DOUBLE_LITERAL, DEG, COMMA, J5, OP_ASSIGN,
                     //            DOUBLE_LITERAL, DEG, COMMA, J6, OP_ASSIGN, DOUBLE_LITERAL, DEG,
                     //            EOL, OP_LEFT_BIG, SEMI
#line 159 "SimpleScriptParser.y"
            { int                   yId   = symTable.Add(ValueStack[ValueStack.Depth - 48].String); symTable.SetType(yId, SimpleScriptTypes.PosInfo);
              SymbolTablePosElement ielem = (SymbolTablePosElement)symTable.Get(yId);
              ielem.Value.Type = 0;
              ielem.Value.J1   = ValueStack[ValueStack.Depth - 31].Double; ielem.Value.J2 = ValueStack[ValueStack.Depth - 26].Double; ielem.Value.J3 = ValueStack[ValueStack.Depth - 21].Double;
              ielem.Value.J4   = ValueStack[ValueStack.Depth - 15].Double; ielem.Value.J5 = ValueStack[ValueStack.Depth - 10].Double; ielem.Value.J6 = ValueStack[ValueStack.Depth - 5].Double; }
#line default
                break;
            }
#pragma warning restore 162, 1522
        }