// Parse and translate an expression private void Expression() { if (Cradle.IsAddop(Cradle.Look)) Cradle.EmitLn("CLR D0"); else Term(); while (Cradle.IsAddop(Cradle.Look)) { Cradle.EmitLn("MOVE D0,-(SP)"); switch (Cradle.Look) { case '+': Add(); break; case '-': Subtract(); break; } } }
// Parse and translate an expression private int Expression() { int Value = (Cradle.IsAddop(Cradle.Look)) ? 0 : Term(); while (Cradle.IsAddop(Cradle.Look)) { switch (Cradle.Look) { case '+': Cradle.Match('+'); Value += Term(); break; case '-': Cradle.Match('-'); Value -= Term(); break; } } return(Value); }