public string Interpret(Context context) { var list = new List<string>(); foreach (var value in context.Values) { var isDigit = Char.IsDigit(value); if (isDigit) { int figure; Int32.TryParse(value.ToString(), out figure); var figureExpression = new FigureExpression(figure); list.Add(figureExpression.Interpret(context)); } else { var operandExpression = new OperandExpression(value); list.Add(operandExpression.Interpret(context)); } } context.Output = string.Join(" ", list); return context.Output; }
public string Interpret(Context context) { if (_values.ContainsKey(_value)) { return _values[_value]; } return "Not available"; }
static void Main(string[] args) { var interpreter = new StringExpression(); var input = Console.ReadLine(); var context = new Context(input); interpreter.Interpret(context); Console.WriteLine(context.Output); Console.ReadKey(); }
public override void Interpret(Context context) { Console.WriteLine("Called Terminal.Interpret()"); }
public abstract void Interpret(Context context);
public string Interpret(Context context) { return _values[_value]; }