void UnaryMinusTerm(out Expression aexp)
 {
     bool isMinus = false; Token minusToken = null; aexp = null;
     if (la.kind == 21) {
     Get();
     isMinus = true; minusToken = t;
     }
     if (la.kind == 14) {
     Get();
     Expression(out aexp);
     Expect(15);
     aexp.ParenCount += 1;
     } else if (la.kind == 4) {
     Get();
     aexp = new Number(int.Parse(t.val)); SetPos(aexp, t);
     } else if (la.kind == 2) {
     Get();
     aexp = new Variable(t.val); SetPos(aexp, t);
     } else SynErr(34);
     if (isMinus) {aexp = new UnaryMinus(aexp); SetPos(aexp, minusToken);}
 }
 public override void Visit(UnaryMinus exp)
 {
     if (exp.Expression is Number) {
         exp.Parent.Replace(exp, new Number(-((Number)exp.Expression).Value));
     }
 }
 public virtual void Visit(UnaryMinus node)
 {
 }
 void UnaryMinusTerm(out Expression aexp)
 {
     bool isMinus = false; Token minusToken = null; aexp = null;
     if (la.kind == 36) {
     Get();
     isMinus = true; minusToken = t;
     }
     switch (la.kind) {
     case 10: {
     Get();
     ArithmeticExpression(out aexp);
     Expect(12);
     aexp.ParenCount += 1;
     break;
     }
     case 7: {
     Get();
     aexp = new Number(int.Parse(t.val)); SetPos(aexp, t);
     break;
     }
     case 17: {
     Get();
     aexp = new Number(int.Parse(t.val)); SetPos(aexp, t);
     break;
     }
     case 39: {
     Get();
     aexp = new Bool(true); SetPos(aexp, t);
     break;
     }
     case 40: {
     Get();
     aexp = new Bool(false); SetPos(aexp, t);
     break;
     }
     case 3: {
     Get();
     aexp = new Variable(t.val); SetPos(aexp, t);
     break;
     }
     case 6: {
     MethodCall(out aexp, false);
     break;
     }
     default: SynErr(47); break;
     }
     if (isMinus) {aexp = new UnaryMinus(aexp); SetStartPos(aexp, minusToken); SetEndPos(aexp, t);}
 }
 public override void Visit(UnaryMinus node)
 {
     List<string> children = PopChildren();
     Return(SurroundWithParens("-" + children[0], node.ParenCount));
 }
 public virtual string Format(UnaryMinus um)
 {
     return SurroundWithParens("-" + Format(um.Expression), um.ParenCount);
 }