// Parse and translate a math factor
 private void Factor()
 {
     if (Cradle.Look == '(')
     {
         Cradle.Match('(');
         Expression();
         Cradle.Match(')');
     }
     else if (Cradle.IsAlpha(Cradle.Look))
         Ident();
     else
         Cradle.EmitLn("MOVE #" + Cradle.GetNum() + ",D0");
 }
 // Parse and translate the first math factor
 private void SignedFactor()
 {
     if (Cradle.Look == '+') Cradle.GetChar();
     if (Cradle.Look == '-')
     {
         Cradle.GetChar();
         if (Cradle.IsDigit(Cradle.Look))
             Cradle.EmitLn("MOVE #-" + Cradle.GetNum() + ",D0");
         else
         {
             Factor();
             Cradle.EmitLn("NEG D0");
         }
     }
     else
         Factor();
 }
Beispiel #3
0
 // Parse and translate a math factor
 private int Factor()
 {
     if (Cradle.Look == '(')
     {
         Cradle.Match('(');
         int value = Expression();
         Cradle.Match(')');
         return(value);
     }
     else if (Cradle.IsAlpha(Cradle.Look))
     {
         return(Table[Cradle.GetName() - 'A']);
     }
     else
     {
         return(Cradle.GetNum());
     }
 }