private void ASNUM() { DataNeeds(1); var val = DATA.Pop(); DATA.Push(SYMTAB.CreateSymbol(SymbolType.DOUBLE, double.Parse(val.Value.ToString()))); }
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; } }
public void DEF() { var defname = DATA.Pop().Value .ToString(); var defvalue = DATA.Pop().Value; SYMTAB.UpdateEntry(defname, SymbolType.STRING, defvalue); }
private void CHR() { DataNeeds(1); Check(0, SymbolType.DOUBLE); var chr = DATA.Pop(); DATA.Push(SYMTAB.CreateSymbol(SymbolType.STRING, (char)((int)chr.Value))); }
public void SWAP() { DataNeeds(2); var swap1 = DATA.Pop(); var swap2 = DATA.Pop(); DATA.Push(swap1); DATA.Push(swap2); return; }
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; }
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}"); } }
private void BANGSIGN() { DataNeeds(2); Check(0, SymbolType.STRING); SYMTAB.UpdateEntry(DATA.Pop().Value.ToString(), DATA.Pop()); }
private void DOT() { DataNeeds(1); Console.Write($"{DATA.Pop().Value}"); }
public void DROP() { DataNeeds(1); DATA.Pop(); return; }
private void END() { DataNeeds(1); var chr = DATA.Pop(); }