protected bool TryHandleFloatLiteral(string text, out Word result) { bool found = false; try { double val = Double.Parse(text); result = new PushStackItemWord(text, new DoubleItem(val)); found = true; } catch { result = null; found = false; } return(found); }
protected bool TryHandleIntLiteral(string text, out Word result) { bool found = false; try { int val = Int32.Parse(text); result = new PushStackItemWord(text, new IntItem(val)); found = true; } catch { result = null; found = false; } return(found); }
public bool TryFindVariable(string text, out Word result) { bool found = false; if (variables.ContainsKey(text)) { VariableItem variableItem = variables[text]; result = new PushStackItemWord(text, variableItem); found = true; } else { result = null; found = false; } return(found); }
protected bool TryHandleBoolLiteral(string text, out Word result) { if (text == "true") { result = new PushStackItemWord(text, new BoolItem(true)); return(true); } else if (text == "false") { result = new PushStackItemWord(text, new BoolItem(false)); return(true); } else { result = null; return(false); } }
public bool TryFindWord(string name, out Word result) { bool found = false; // Search through moduleStack for (int i = moduleStack.Count - 1; i >= 0; i--) { found = moduleStack[i].TryFindWord(name, out result); if (found) { return(found); } } // Search registered modules Module module; if (registeredModules.TryGetValue(name, out module)) { result = new PushStackItemWord(name, module); return(true); } // Search through usingModules for (int i = usingModules.Count - 1; i >= 0; i--) { found = usingModules[i].TryFindWord(name, out result); if (found) { return(found); } } result = null; return(false); }