public MethodCallExpression(Expression instance, string methodName, params object[] args)
     : base(args)
 {
     _instance = instance;
     _methodName = methodName;
     LookupMethod(instance.Type, methodName);
 }
 public MethodCallExpression(LocalBuilder instance, string methodName, params object[] args)
     : base(args)
 {
     _instance = new Variable(instance);
     _methodName = methodName;
     LookupMethod(instance.LocalType, methodName);
 }
 public LogicalBinOpExpression(Expression left, Expression right, LogicalBinOp op)
 {
     _op = op;
     _children.Add(left);
     _children.Add(right);
 }
 public virtual void Visit(Expression 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);}
 }
 void RelationalTerm(out Expression exp)
 {
     Expression right = null, left = null; RelationalBinOp op = RelationalBinOp.Equal;
     ArithmeticExpression(out left);
     exp = left;
     if (StartOf(3)) {
     switch (la.kind) {
     case 30: {
         Get();
         op = RelationalBinOp.Equal;
         break;
     }
     case 31: {
         Get();
         op = RelationalBinOp.NotEqual;
         break;
     }
     case 32: {
         Get();
         op = RelationalBinOp.GreaterThan;
         break;
     }
     case 33: {
         Get();
         op = RelationalBinOp.GreaterThanOrEqual;
         break;
     }
     case 34: {
         Get();
         op = RelationalBinOp.LessThan;
         break;
     }
     case 35: {
         Get();
         op = RelationalBinOp.LessThanOrEqual;
         break;
     }
     }
     ArithmeticExpression(out right);
     exp = new RelationalBinOpExpression(exp, right, op); CopyPos(exp, ((RelationalBinOpExpression)exp).Left,t);
     }
 }
 public UnaryMinus(Expression exp) {
     _exp = exp;
     _children.Add(exp);
 }
 void PlusMinusTerm(out Expression aexp)
 {
     ArithmeticBinOp op; Expression right = null, left = null;
     UnaryMinusTerm(out left);
     aexp = left;
     while (la.kind == 10 || la.kind == 22 || la.kind == 23) {
     if (la.kind == 10) {
         Get();
         op = ArithmeticBinOp.Multiply;
     } else if (la.kind == 22) {
         Get();
         op = ArithmeticBinOp.Divide;
     } else {
         Get();
         op = ArithmeticBinOp.Modulo;
     }
     UnaryMinusTerm(out right);
     aexp = new ArithmeticBinOpExpression(aexp, right, op); CopyPos(((ArithmeticBinOpExpression)aexp).Left,aexp,t);
     }
 }
 void InOrReadParam(out Expression exp)
 {
     exp = null;
     if (la.kind == 1) {
     Get();
     exp = new PLRString(t.val); SetPos(exp, t);
     } else if (la.kind == 3) {
     Get();
     exp = new VariableBinding(t.val.Replace("!", "")); SetPos(exp, t);
     } else if (StartOf(2)) {
     Expression(out exp);
     } else SynErr(33);
 }
 void AndTerm(out Expression exp)
 {
     Expression right = null, left = null;
     RelationalTerm(out left);
     exp = left;
     while (la.kind == 29) {
     Get();
     RelationalTerm(out right);
     exp = new LogicalBinOpExpression(exp, right, LogicalBinOp.Xor); CopyPos(exp, ((LogicalBinOpExpression)exp).Left,t);
     }
 }
 public BranchProcess(Expression exp, Process ifBranch, Process elseBranch)
 {
     _children.Add(exp);
     _children.Add(ifBranch);
     _children.Add(elseBranch);
 }
 public UnaryMinus(Expression exp)
 {
     _exp = exp;
     _children.Add(exp);
 }
 public RelationalBinOpExpression(Expression left, Expression right, RelationalBinOp op)
 {
     _op = op;
     _children.Add(left);
     _children.Add(right);
 }
 public void Add(Expression exp)
 {
     _children.Add(exp);
 }
 void CallParam(out Expression exp)
 {
     Expression aexp = null; exp = null;
     if (StartOf(2)) {
     ArithmeticExpression(out aexp);
     exp = aexp;
     } else if (la.kind == 8) {
     Get();
     exp = new PLRString(t.val.Substring(1, t.val.Length-2)); SetPos(exp, t);
     } else SynErr(46);
 }
 void Expression(out Expression aexp)
 {
     ArithmeticBinOp op; Expression right = null, left = null;
     PlusMinusTerm(out left);
     aexp = left;
     while (la.kind == 11 || la.kind == 21) {
     if (la.kind == 11) {
         Get();
         op = ArithmeticBinOp.Plus;
     } else {
         Get();
         op = ArithmeticBinOp.Minus;
     }
     PlusMinusTerm(out right);
     aexp = new ArithmeticBinOpExpression(aexp, right, op); CopyPos(((ArithmeticBinOpExpression)aexp).Left,aexp,t);
     }
 }
 void MethodCall(out Expression exp, bool popReturn)
 {
     Expect(6);
     List<object> list = new List<object>(); MethodCallExpression mexp = null; exp = null; string methodName = t.val.Replace(":","");  Token start = t;
     Expect(10);
     if (StartOf(1)) {
     CallParam(out exp);
     list.Add(exp);
     while (la.kind == 11) {
         Get();
         CallParam(out exp);
         list.Add(exp);
     }
     }
     Expect(12);
     mexp = new MethodCallExpression(methodName, list.ToArray()); mexp.PopReturnValue = popReturn; exp = mexp; SetPos(exp, start, t);
 }
 void OutParam(out Expression exp)
 {
     exp = null;
     if (la.kind == 1) {
     Get();
     exp = new PLRString(t.val);
     } else if (StartOf(2)) {
     Expression(out exp);
     } else SynErr(32);
 }
 void OrTerm(out Expression exp)
 {
     Expression right = null, left = null;
     AndTerm(out left);
     exp = left;
     while (la.kind == 28) {
     Get();
     AndTerm(out right);
     exp = new LogicalBinOpExpression(exp, right, LogicalBinOp.And); CopyPos(exp, ((LogicalBinOpExpression)exp).Left,t);
     }
 }
 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 ArithmeticBinOpExpression(Expression left, Expression right, ArithmeticBinOp op)
 {
     _op = op;
     _children.Add(left);
     _children.Add(right);
 }