Пример #1
0
		public static void Assign(this BlockStatement block, Expression left, Expression right)
		{
			if (left == null)
				throw new ArgumentNullException("left");
			if (right == null)
				throw new ArgumentNullException("right");
			AddStatement(block, new AssignmentExpression(left, AssignmentOperatorType.Assign, right));
		}
Пример #2
0
		public LocalLookupVariable(string name, TypeReference typeRef, Location startPos, Location endPos, bool isConst, bool isLoopVariable, Expression initializer, LambdaExpression parentLambdaExpression, bool isQueryContinuation)
		{
			this.Name = name;
			this.TypeRef = typeRef;
			this.StartPos = startPos;
			this.EndPos = endPos;
			this.IsConst = isConst;
			this.IsLoopVariable = isLoopVariable;
			this.Initializer = initializer;
			this.ParentLambdaExpression = parentLambdaExpression;
			this.IsQueryContinuation = isQueryContinuation;
		}
Пример #3
0
		/// <summary>
		/// Returns the existing expression plus the specified integer value.
		/// The old <paramref name="expr"/> object is not modified, but might be a subobject on the new expression
		/// (and thus its parent property is modified).
		/// </summary>
		public static Expression AddInteger(Expression expr, int value)
		{
			PrimitiveExpression pe = expr as PrimitiveExpression;
			if (pe != null && pe.Value is int) {
				int newVal = (int)pe.Value + value;
				return new PrimitiveExpression(newVal, newVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
			}
			BinaryOperatorExpression boe = expr as BinaryOperatorExpression;
			if (boe != null && boe.Op == BinaryOperatorType.Add) {
				// clone boe:
				boe = new BinaryOperatorExpression(boe.Left, boe.Op, boe.Right);
				
				boe.Right = AddInteger(boe.Right, value);
				if (boe.Right is PrimitiveExpression && ((PrimitiveExpression)boe.Right).Value is int) {
					int newVal = (int)((PrimitiveExpression)boe.Right).Value;
					if (newVal == 0) {
						return boe.Left;
					} else if (newVal < 0) {
						((PrimitiveExpression)boe.Right).Value = -newVal;
						boe.Op = BinaryOperatorType.Subtract;
					}
				}
				return boe;
			}
			if (boe != null && boe.Op == BinaryOperatorType.Subtract) {
				pe = boe.Right as PrimitiveExpression;
				if (pe != null && pe.Value is int) {
					int newVal = (int)pe.Value - value;
					if (newVal == 0)
						return boe.Left;
					
					// clone boe:
					boe = new BinaryOperatorExpression(boe.Left, boe.Op, boe.Right);
					
					if (newVal < 0) {
						newVal = -newVal;
						boe.Op = BinaryOperatorType.Add;
					}
					boe.Right = new PrimitiveExpression(newVal, newVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
					return boe;
				}
			}
			BinaryOperatorType opType = BinaryOperatorType.Add;
			if (value < 0) {
				value = -value;
				opType = BinaryOperatorType.Subtract;
			}
			return new BinaryOperatorExpression(expr, opType, new PrimitiveExpression(value, value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)));
		}
Пример #4
0
		public void AddVariable(TypeReference typeRef, string name,
		                        Location startPos, Location endPos, bool isConst,
		                        bool isLoopVariable, Expression initializer,
		                        LambdaExpression parentLambdaExpression,
		                        bool isQueryContinuation)
		{
			if (name == null || name.Length == 0) {
				return;
			}
			List<LocalLookupVariable> list;
			if (!variables.ContainsKey(name)) {
				variables[name] = list = new List<LocalLookupVariable>();
			} else {
				list = (List<LocalLookupVariable>)variables[name];
			}
			list.Add(new LocalLookupVariable(name, typeRef, startPos, endPos, isConst, isLoopVariable, initializer, parentLambdaExpression, isQueryContinuation));
		}
Пример #5
0
		void CheckMemberReferenceExpression(Expression expr, string memberName, string targetObjectIdentifier)
		{
			Assert.IsTrue(expr is MemberReferenceExpression);
			Assert.IsTrue((expr as MemberReferenceExpression).MemberName == memberName &&
			              (expr as MemberReferenceExpression).TargetObject is IdentifierExpression &&
			              ((expr as MemberReferenceExpression).TargetObject as IdentifierExpression).Identifier == targetObjectIdentifier);
		}
Пример #6
0
	void ReDimClause(out Expression expr) {
		SimpleNonInvocationExpression(out expr);
		ReDimClauseInternal(ref expr);
	}
Пример #7
0
	void ExponentiationExpr(out Expression outExpr) {
		Expression expr; Location startLocation = la.Location;
		SimpleExpr(out outExpr);
		while (la.kind == 32) {
			Get();
			SimpleExpr(out expr);
			outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
		}
	}
Пример #8
0
	void MultiplicativeExpr(out Expression outExpr) {
		Expression expr;
		BinaryOperatorType op = BinaryOperatorType.None;
		Location startLocation = la.Location;

		UnaryExpr(out outExpr);
		while (la.kind == 24 || la.kind == 34) {
			if (la.kind == 34) {
				Get();
				op = BinaryOperatorType.Multiply;
			} else {
				Get();
				op = BinaryOperatorType.Divide;
			}
			UnaryExpr(out expr);
			outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };
		}
	}
Пример #9
0
	void ModuloExpr(out Expression outExpr) {
		Expression expr; Location startLocation = la.Location;
		IntegerDivisionExpr(out outExpr);
		while (la.kind == 154) {
			Get();
			IntegerDivisionExpr(out expr);
			outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
		}
	}
Пример #10
0
	void SimpleNonInvocationExpression(out Expression pexpr) {
		Expression expr;
		CollectionInitializerExpression cie;
		TypeReference type = null;
		string name = String.Empty;
		Location startLocation = la.Location;
		pexpr = null;

		if (StartOf(34)) {
			switch (la.kind) {
			case 3: {
				Get();
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; 
				break;
			}
			case 4: {
				Get();
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; 
				break;
			}
			case 7: {
				Get();
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; 
				break;
			}
			case 6: {
				Get();
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; 
				break;
			}
			case 5: {
				Get();
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; 
				break;
			}
			case 9: {
				Get();
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; 
				break;
			}
			case 8: {
				Get();
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; 
				break;
			}
			case 217: {
				Get();
				pexpr = new PrimitiveExpression(true, "true"); 
				break;
			}
			case 122: {
				Get();
				pexpr = new PrimitiveExpression(false, "false");
				break;
			}
			case 165: {
				Get();
				pexpr = new PrimitiveExpression(null, "null"); 
				break;
			}
			case 37: {
				Get();
				Expr(out expr);
				Expect(38);
				pexpr = new ParenthesizedExpression(expr);
				break;
			}
			case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 98: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: {
				Identifier();
				pexpr = new IdentifierExpression(t.val);
					pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;

				if (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) {
					Expect(37);
					Expect(169);
					TypeArgumentList(((IdentifierExpression)pexpr).TypeArguments);
					Expect(38);
				}
				break;
			}
			case 68: case 71: case 82: case 99: case 100: case 109: case 141: case 151: case 168: case 196: case 201: case 202: case 208: case 221: case 222: case 225: {
				string val = String.Empty;
				if (StartOf(13)) {
					PrimitiveTypeName(out val);
				} else {
					Get();
					val = "System.Object";
				}
				pexpr = new TypeReferenceExpression(new TypeReference(val, true));
				break;
			}
			case 153: {
				Get();
				pexpr = new ThisReferenceExpression();
				break;
			}
			case 158: case 159: {
				Expression retExpr = null;
				if (la.kind == 158) {
					Get();
					retExpr = new BaseReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation };
				} else {
					Get();
					retExpr = new ClassReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation };
				}
				Expect(26);
				IdentifierOrKeyword(out name);
				pexpr = new MemberReferenceExpression(retExpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
				break;
			}
			case 130: {
				Get();
				Expect(26);
				Identifier();
				type = new TypeReference(t.val ?? "");
				type.IsGlobal = true;
				pexpr = new TypeReferenceExpression(type);
				break;
			}
			case 162: {
				ObjectCreateExpression(out expr);
				pexpr = expr;
				break;
			}
			case 35: {
				CollectionInitializer(out cie);
				pexpr = cie;
				break;
			}
			case 94: case 106: case 219: {
				CastType castType = CastType.Cast;
				if (la.kind == 106) {
					Get();
				} else if (la.kind == 94) {
					Get();
					castType = CastType.Conversion;
				} else {
					Get();
					castType = CastType.TryCast;
				}
				Expect(37);
				Expr(out expr);
				Expect(22);
				TypeName(out type);
				Expect(38);
				pexpr = new CastExpression(type, expr, castType);
				break;
			}
			case 76: case 77: case 78: case 79: case 80: case 81: case 83: case 85: case 86: case 90: case 91: case 92: case 93: case 95: case 96: case 97: {
				CastTarget(out type);
				Expect(37);
				Expr(out expr);
				Expect(38);
				pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion);
				break;
			}
			case 57: {
				Get();
				SimpleExpr(out expr);
				pexpr = new AddressOfExpression(expr);
				break;
			}
			case 129: {
				Get();
				Expect(37);
				GetTypeTypeName(out type);
				Expect(38);
				pexpr = new TypeOfExpression(type);
				break;
			}
			case 220: {
				Get();
				SimpleExpr(out expr);
				Expect(144);
				TypeName(out type);
				pexpr = new TypeOfIsExpression(expr, type);
				break;
			}
			case 135: {
				ConditionalExpression(out pexpr);
				break;
			}
			case 10: case 16: case 17: case 18: case 19: {
				XmlLiteralExpression(out pexpr);
				break;
			}
			}
		} else if (StartOf(35)) {
			if (la.kind == 26) {
				Get();
				if (la.kind == 10) {
					Get();
					IdentifierOrKeyword(out name);
					Expect(11);
					pexpr = new XmlMemberAccessExpression(null, XmlAxisType.Element, name, true) { StartLocation = startLocation, EndLocation = t.EndLocation };
				} else if (StartOf(33)) {
					IdentifierOrKeyword(out name);
					pexpr = new MemberReferenceExpression(null, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
				} else SynErr(281);
			} else if (la.kind == 29) {
				Get();
				IdentifierOrKeyword(out name);
				pexpr = new BinaryOperatorExpression(null, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation });
			} else {
				XmlAxisType axisType = XmlAxisType.Element; bool isXmlIdentifier = false;
				if (la.kind == 27) {
					Get();
					axisType = XmlAxisType.Descendents;
				} else {
					Get();
					axisType = XmlAxisType.Attribute;
				}
				if (la.kind == 10) {
					Get();
					isXmlIdentifier = true;
				}
				IdentifierOrKeyword(out name);
				if (la.kind == 11) {
					Get();
				}
				pexpr = new XmlMemberAccessExpression(null, axisType, name, isXmlIdentifier);
			}
		} else SynErr(282);
		if (pexpr != null) {
				pexpr.StartLocation = startLocation;
				pexpr.EndLocation = t.EndLocation;
			}

	}
Пример #11
0
	void SimpleExpr(out Expression pexpr) {
		string name; Location startLocation = la.Location;
		SimpleNonInvocationExpression(out pexpr);
		while (StartOf(32)) {
			if (la.kind == 26) {
				Get();
				if (la.kind == 10) {
					Get();
					IdentifierOrKeyword(out name);
					Expect(11);
					pexpr = new XmlMemberAccessExpression(pexpr, XmlAxisType.Element, name, true);
				} else if (StartOf(33)) {
					IdentifierOrKeyword(out name);
					pexpr = new MemberReferenceExpression(pexpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
				} else SynErr(280);
				if (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) {
					Expect(37);
					Expect(169);
					TypeArgumentList(((MemberReferenceExpression)pexpr).TypeArguments);
					Expect(38);
				}
			} else if (la.kind == 29) {
				Get();
				IdentifierOrKeyword(out name);
				pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation });
			} else if (la.kind == 27 || la.kind == 28) {
				XmlAxisType type = XmlAxisType.Attribute; bool isXmlName = false;
				if (la.kind == 28) {
					Get();
				} else {
					Get();
					type = XmlAxisType.Descendents;
				}
				if (la.kind == 10) {
					Get();
					isXmlName = true;
				}
				IdentifierOrKeyword(out name);
				if (la.kind == 11) {
					Get();
				}
				pexpr = new XmlMemberAccessExpression(pexpr, type, name, isXmlName);
			} else {
				InvocationExpression(ref pexpr);
			}
		}
		if (pexpr != null) {
				pexpr.StartLocation = startLocation;
				pexpr.EndLocation = t.EndLocation;
			}

	}
Пример #12
0
	void DisjunctionExpr(out Expression outExpr) {
		Expression expr;
		BinaryOperatorType op = BinaryOperatorType.None;
		Location startLocation = la.Location;

		ConjunctionExpr(out outExpr);
		while (la.kind == 175 || la.kind == 177 || la.kind == 236) {
			if (la.kind == 175) {
				Get();
				op = BinaryOperatorType.BitwiseOr;
			} else if (la.kind == 177) {
				Get();
				op = BinaryOperatorType.LogicalOr;
			} else {
				Get();
				op = BinaryOperatorType.ExclusiveOr;
			}
			ConjunctionExpr(out expr);
			outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
		}
	}
Пример #13
0
	void LambdaExpr(out Expression expr) {
		LambdaExpression lambda = null;

		if (la.kind == 210) {
			SubLambdaExpression(out lambda);
		} else if (la.kind == 127) {
			FunctionLambdaExpression(out lambda);
		} else SynErr(278);
		expr = lambda;
	}
Пример #14
0
	void QueryExpr(out Expression expr) {
		QueryExpression qexpr = new QueryExpression();
		qexpr.StartLocation = la.Location;
		expr = qexpr;

		FromOrAggregateQueryOperator(qexpr.Clauses);
		while (StartOf(31)) {
			QueryOperator(qexpr.Clauses);
		}
		qexpr.EndLocation = t.EndLocation;

	}
Пример #15
0
	void ObjectCreateExpression(out Expression oce) {
		TypeReference type = null;
		CollectionInitializerExpression initializer = null;
		List<Expression> arguments = null;
		ArrayList dimensions = null;
		oce = null;
		Location startLocation = la.Location;
		bool canBeNormal; bool canBeReDim;

		Expect(162);
		if (StartOf(9)) {
			NonArrayTypeName(out type, false);
			if (la.kind == 37) {
				Get();
				NormalOrReDimArgumentList(out arguments, out canBeNormal, out canBeReDim);
				Expect(38);
				if (la.kind == 35 || (la.kind == Tokens.OpenParenthesis)) {
					if (la.kind == Tokens.OpenParenthesis) {
						ArrayTypeModifiers(out dimensions);
						CollectionInitializer(out initializer);
					} else {
						CollectionInitializer(out initializer);
					}
				}
				if (canBeReDim && !canBeNormal && initializer == null) initializer = new CollectionInitializerExpression();
			}
		}
		if (initializer == null) {
				oce = new ObjectCreateExpression(type, arguments);
			} else {
				if (dimensions == null) dimensions = new ArrayList();
				dimensions.Insert(0, (arguments == null) ? 0 : Math.Max(arguments.Count - 1, 0));
				type.RankSpecifier = (int[])dimensions.ToArray(typeof(int));
				ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer);
				ace.Arguments = arguments;
				oce = ace;
			}

		if (la.kind == 126 || la.kind == 233) {
			if (la.kind == 233) {
				MemberInitializerExpression memberInitializer = null;
					Expression anonymousMember = null;

				Get();
				CollectionInitializerExpression memberInitializers = new CollectionInitializerExpression();
					memberInitializers.StartLocation = la.Location;

				Expect(35);
				if (la.kind == 26 || la.kind == 147) {
					MemberInitializer(out memberInitializer);
					memberInitializers.CreateExpressions.Add(memberInitializer);
				} else if (StartOf(24)) {
					Expr(out anonymousMember);
					memberInitializers.CreateExpressions.Add(anonymousMember);
				} else SynErr(272);
				while (la.kind == 22) {
					Get();
					if (la.kind == 26 || la.kind == 147) {
						MemberInitializer(out memberInitializer);
						memberInitializers.CreateExpressions.Add(memberInitializer);
					} else if (StartOf(24)) {
						Expr(out anonymousMember);
						memberInitializers.CreateExpressions.Add(anonymousMember);
					} else SynErr(273);
				}
				Expect(36);
				memberInitializers.EndLocation = t.Location;
					if(oce is ObjectCreateExpression)
					{
						((ObjectCreateExpression)oce).ObjectInitializer = memberInitializers;
					}

			} else {
				Get();
				CollectionInitializer(out initializer);
				if(oce is ObjectCreateExpression)
						((ObjectCreateExpression)oce).ObjectInitializer = initializer;

			}
		}
		if (oce != null) {
				oce.StartLocation = startLocation;
				oce.EndLocation = t.EndLocation;
			}

	}
Пример #16
0
	void ConcatenationExpr(out Expression outExpr) {
		Expression expr; Location startLocation = la.Location;
		AdditiveExpr(out outExpr);
		while (la.kind == 23) {
			Get();
			AdditiveExpr(out expr);
			outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
		}
	}
Пример #17
0
	void AdditiveExpr(out Expression outExpr) {
		Expression expr;
		BinaryOperatorType op = BinaryOperatorType.None;
		Location startLocation = la.Location;

		ModuloExpr(out outExpr);
		while (la.kind == 30 || la.kind == 31) {
			if (la.kind == 31) {
				Get();
				op = BinaryOperatorType.Add;
			} else {
				Get();
				op = BinaryOperatorType.Subtract;
			}
			ModuloExpr(out expr);
			outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
		}
	}
Пример #18
0
	void InvocationExpression(ref Expression pexpr) {
		List<Expression> parameters = null;
		Expect(37);
		Location start = t.Location;
		ArgumentList(out parameters);
		Expect(38);
		pexpr = new InvocationExpression(pexpr, parameters);

		pexpr.StartLocation = start; pexpr.EndLocation = t.Location;
	}
Пример #19
0
	void IntegerDivisionExpr(out Expression outExpr) {
		Expression expr; Location startLocation = la.Location;
		MultiplicativeExpr(out outExpr);
		while (la.kind == 25) {
			Get();
			MultiplicativeExpr(out expr);
			outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
		}
	}
Пример #20
0
	void ConditionalExpression(out Expression expr) {
		ConditionalExpression conditionalExpression = new ConditionalExpression();
		BinaryOperatorExpression binaryOperatorExpression = new BinaryOperatorExpression();
		conditionalExpression.StartLocation = binaryOperatorExpression.StartLocation = la.Location;

		Expression condition = null;
		Expression trueExpr = null;
		Expression falseExpr = null;

		Expect(135);
		Expect(37);
		Expr(out condition);
		Expect(22);
		Expr(out trueExpr);
		if (la.kind == 22) {
			Get();
			Expr(out falseExpr);
		}
		Expect(38);
		if(falseExpr != null)
			{
				conditionalExpression.Condition = condition;
				conditionalExpression.TrueExpression = trueExpr;
				conditionalExpression.FalseExpression = falseExpr;
				conditionalExpression.EndLocation = t.EndLocation;
				
				expr = conditionalExpression;
			}
			else
			{
				binaryOperatorExpression.Left = condition;
				binaryOperatorExpression.Right = trueExpr;
				binaryOperatorExpression.Op = BinaryOperatorType.NullCoalescing;
				binaryOperatorExpression.EndLocation = t.EndLocation;
				
				expr = binaryOperatorExpression;
			}

	}
Пример #21
0
	void UnaryExpr(out Expression uExpr) {
		Expression expr;
		UnaryOperatorType uop = UnaryOperatorType.None;
		Location startLocation = la.Location;
		bool isUOp = false;

		while (la.kind == 30 || la.kind == 31 || la.kind == 34) {
			if (la.kind == 31) {
				Get();
				uop = UnaryOperatorType.Plus; isUOp = true;
			} else if (la.kind == 30) {
				Get();
				uop = UnaryOperatorType.Minus; isUOp = true;
			} else {
				Get();
				uop = UnaryOperatorType.Dereference;  isUOp = true;
			}
		}
		ExponentiationExpr(out expr);
		if (isUOp) {
				uExpr = new UnaryOperatorExpression(expr, uop) { StartLocation = startLocation, EndLocation = t.EndLocation };
			} else {
				uExpr = expr;
			}

	}
Пример #22
0
	void XmlLiteralExpression(out Expression pexpr) {
		List<XmlExpression> exprs = new List<XmlExpression>();
		XmlExpression currentExpression = null;

		if (StartOf(36)) {
			XmlContentExpression(exprs);
			while (StartOf(36)) {
				XmlContentExpression(exprs);
			}
			if (la.kind == 10) {
				XmlElement(out currentExpression);
				exprs.Add(currentExpression);
				while (StartOf(36)) {
					XmlContentExpression(exprs);
				}
			}
		} else if (la.kind == 10) {
			XmlElement(out currentExpression);
			exprs.Add(currentExpression);
			while (StartOf(36)) {
				XmlContentExpression(exprs);
			}
		} else SynErr(285);
		if (exprs.Count > 1) {
				pexpr = new XmlDocumentExpression() { Expressions = exprs };
			} else {
				pexpr = exprs[0];
			}

	}
Пример #23
0
	void Argument(out Expression argumentexpr) {
		Expression expr;
		argumentexpr = null;
		string name;
		Location startLocation = la.Location;

		if (IsNamedAssign()) {
			Identifier();
			name = t.val; 
			Expect(55);
			Expr(out expr);
			argumentexpr = new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };

		} else if (StartOf(24)) {
			Expr(out argumentexpr);
		} else SynErr(299);
	}
Пример #24
0
	void ConjunctionExpr(out Expression outExpr) {
		Expression expr;
		BinaryOperatorType op = BinaryOperatorType.None;
		Location startLocation = la.Location;

		NotExpr(out outExpr);
		while (la.kind == 60 || la.kind == 61) {
			if (la.kind == 60) {
				Get();
				op = BinaryOperatorType.BitwiseAnd;
			} else {
				Get();
				op = BinaryOperatorType.LogicalAnd;
			}
			NotExpr(out expr);
			outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
		}
	}
Пример #25
0
	void ReDimClauseInternal(ref Expression expr) {
		List<Expression> arguments; bool canBeNormal; bool canBeRedim; string name; Location startLocation = la.Location;
		while (la.kind == 26 || (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)) {
			if (la.kind == 26) {
				Get();
				IdentifierOrKeyword(out name);
				expr = new MemberReferenceExpression(expr, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
			} else {
				InvocationExpression(ref expr);
				expr.StartLocation = startLocation;
					expr.EndLocation = t.EndLocation;

			}
		}
		Expect(37);
		NormalOrReDimArgumentList(out arguments, out canBeNormal, out canBeRedim);
		Expect(38);
		expr = new InvocationExpression(expr, arguments);
			if (canBeRedim == false || canBeNormal && (la.kind == Tokens.Dot || la.kind == Tokens.OpenParenthesis)) {
				if (this.Errors.Count == 0) {
					// don't recurse on parse errors - could result in endless recursion
					ReDimClauseInternal(ref expr);
				}
			}

	}
Пример #26
0
	void NotExpr(out Expression outExpr) {
		UnaryOperatorType uop = UnaryOperatorType.None;
		while (la.kind == 164) {
			Get();
			uop = UnaryOperatorType.Not;
		}
		ComparisonExpr(out outExpr);
		if (uop != UnaryOperatorType.None)
		    outExpr = new UnaryOperatorExpression(outExpr, uop);

	}
Пример #27
0
		public static Expression CheckNull(Expression expression)
		{
			return expression == null ? NullExpression.Instance : expression;
		}
Пример #28
0
	void ComparisonExpr(out Expression outExpr) {
		Expression expr;
		BinaryOperatorType op = BinaryOperatorType.None;
		Location startLocation = la.Location;

		ShiftExpr(out outExpr);
		while (StartOf(40)) {
			switch (la.kind) {
			case 40: {
				Get();
				op = BinaryOperatorType.LessThan;
				break;
			}
			case 39: {
				Get();
				op = BinaryOperatorType.GreaterThan;
				break;
			}
			case 43: {
				Get();
				op = BinaryOperatorType.LessThanOrEqual;
				break;
			}
			case 42: {
				Get();
				op = BinaryOperatorType.GreaterThanOrEqual;
				break;
			}
			case 41: {
				Get();
				op = BinaryOperatorType.InEquality;
				break;
			}
			case 20: {
				Get();
				op = BinaryOperatorType.Equality;
				break;
			}
			case 150: {
				Get();
				op = BinaryOperatorType.Like;
				break;
			}
			case 144: {
				Get();
				op = BinaryOperatorType.ReferenceEquality;
				break;
			}
			case 145: {
				Get();
				op = BinaryOperatorType.ReferenceInequality;
				break;
			}
			}
			if (StartOf(41)) {
				ShiftExpr(out expr);
				outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
			} else if (la.kind == 164) {
				Location startLocation2 = la.Location;
				Get();
				ShiftExpr(out expr);
				outExpr = new BinaryOperatorExpression(outExpr, op, new UnaryOperatorExpression(expr, UnaryOperatorType.Not) { StartLocation = startLocation2, EndLocation = t.EndLocation }) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
			} else SynErr(292);
		}
	}
		Expression CheckPropertyInitializationExpression(Expression e, string name)
		{
			Assert.IsInstanceOf(typeof(MemberInitializerExpression), e);
			Assert.AreEqual(name, ((MemberInitializerExpression)e).Name);
			return ((MemberInitializerExpression)e).Expression;
		}
Пример #30
0
	void ShiftExpr(out Expression outExpr) {
		Expression expr;
		BinaryOperatorType op = BinaryOperatorType.None;
		Location startLocation = la.Location;

		ConcatenationExpr(out outExpr);
		while (la.kind == 44 || la.kind == 45) {
			if (la.kind == 44) {
				Get();
				op = BinaryOperatorType.ShiftLeft;
			} else {
				Get();
				op = BinaryOperatorType.ShiftRight;
			}
			ConcatenationExpr(out expr);
			outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; 
		}
	}