예제 #1
0
        private void ASNUM()
        {
            DataNeeds(1);
            var val = DATA.Pop();

            DATA.Push(SYMTAB.CreateSymbol(SymbolType.DOUBLE, double.Parse(val.Value.ToString())));
        }
예제 #2
0
        private void ARITHOP()
        {
            Needing(new SymbolType[] { SymbolType.STRING, SymbolType.DOUBLE, SymbolType.DOUBLE });
            var op = DATA.Pop();
            var lh = DATA.Pop();
            var rh = DATA.Pop();

            switch (op.Value.ToString())
            {
            case "+":
                DATA.Push(SYMTAB.CreateSymbol(SymbolType.DOUBLE, (double)lh.Value + (double)rh.Value));
                break;

            case "-":
                DATA.Push(SYMTAB.CreateSymbol(SymbolType.DOUBLE, (double)lh.Value - (double)rh.Value));
                break;

            case "*":
                DATA.Push(SYMTAB.CreateSymbol(SymbolType.DOUBLE, (double)lh.Value * (double)rh.Value));
                break;

            case "/":
                DATA.Push(SYMTAB.CreateSymbol(SymbolType.DOUBLE, (double)lh.Value / (double)rh.Value));
                break;
            }
        }
예제 #3
0
        private void CHR()
        {
            DataNeeds(1);
            Check(0, SymbolType.DOUBLE);
            var chr = DATA.Pop();

            DATA.Push(SYMTAB.CreateSymbol(SymbolType.STRING, (char)((int)chr.Value)));
        }