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

            DATA.Push(SYMTAB.CreateSymbol(SymbolType.DOUBLE, double.Parse(val.Value.ToString())));
        }
Example #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;
            }
        }
Example #3
0
        public void DEF()
        {
            var defname = DATA.Pop().Value
                          .ToString();
            var defvalue = DATA.Pop().Value;

            SYMTAB.UpdateEntry(defname, SymbolType.STRING, defvalue);
        }
Example #4
0
        private void CHR()
        {
            DataNeeds(1);
            Check(0, SymbolType.DOUBLE);
            var chr = DATA.Pop();

            DATA.Push(SYMTAB.CreateSymbol(SymbolType.STRING, (char)((int)chr.Value)));
        }
Example #5
0
        public void SWAP()
        {
            DataNeeds(2);
            var swap1 = DATA.Pop();
            var swap2 = DATA.Pop();

            DATA.Push(swap1);
            DATA.Push(swap2);
            return;
        }
Example #6
0
        public void NOT_ROTE()
        {
            DataNeeds(3);
            var rot1 = DATA.Pop();
            var rot2 = DATA.Pop();
            var rot3 = DATA.Pop();

            DATA.Push(rot1);
            DATA.Push(rot3);
            DATA.Push(rot2);
            return;
        }
Example #7
0
        private void ATSIGN()
        {
            DataNeeds(1);
            Check(0, SymbolType.STRING);
            var varname = DATA.Pop().Value.ToString();

            if (SYMTAB.ExistsEntry(varname))
            {
                var ent = SYMTAB.RetrieveEntry(varname);
                DATA.Push(ent);
            }
            else
            {
                throw new Exception($"No entry in symbol table called {varname}");
            }
        }
Example #8
0
 private void BANGSIGN()
 {
     DataNeeds(2);
     Check(0, SymbolType.STRING);
     SYMTAB.UpdateEntry(DATA.Pop().Value.ToString(), DATA.Pop());
 }
Example #9
0
 private void DOT()
 {
     DataNeeds(1);
     Console.Write($"{DATA.Pop().Value}");
 }
Example #10
0
 public void DROP()
 {
     DataNeeds(1);
     DATA.Pop();
     return;
 }
Example #11
0
 private void END()
 {
     DataNeeds(1);
     var chr = DATA.Pop();
 }