コード例 #1
0
 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);}
 }
コード例 #2
0
 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);}
 }
コード例 #3
0
 public virtual void Visit(Variable node)
 {
 }
コード例 #4
0
 void Action(out Action act)
 {
     act = null; Expression exp = null;Variable v = null;
     if (la.kind == 3) {
     Get();
     InAction inAct = new InAction(t.val);
     if (la.kind == 10) {
         Get();
         Expect(3);
         v = new Variable(t.val); SetPos(v, t); inAct.AddVariable(v);
         while (la.kind == 11) {
             Get();
             Expect(3);
             v = new Variable(t.val); SetPos(v, t); inAct.AddVariable(v);
         }
         Expect(12);
     }
     act = inAct;
     } else if (la.kind == 5) {
     Get();
     OutAction outAct = new OutAction(t.val);
     if (la.kind == 10) {
         Get();
         ArithmeticExpression(out exp);
         outAct.AddExpression(exp);
         while (la.kind == 11) {
             Get();
             ArithmeticExpression(out exp);
             outAct.AddExpression(exp);
         }
         Expect(12);
     }
     act = outAct;
     } else if (la.kind == 6) {
     MethodCall(out exp, true);
     act = new Call((MethodCallExpression)exp);
     } else SynErr(43);
 }
コード例 #5
0
 public override void Visit(Variable var)
 {
     if (!Variables.Contains(var)) {
         Variables.Add(var);
     }
 }
コード例 #6
0
 public void AddVariable(Variable var)
 {
     _children.Add(var);
 }
コード例 #7
0
 public override void Visit(Variable node)
 {
     PopChildren();
     Return(SurroundWithParens(node.Name, node.ParenCount));
 }
コード例 #8
0
 public virtual string Format(Variable v)
 {
     return SurroundWithParens(v.Name, v.ParenCount);
 }