⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbnet.atg

📁 根据cs源码解析为codedom
💻 ATG
📖 第 1 页 / 共 5 页
字号:
				type = new TypeReference("");
			}
			if (dimension != null) {
				if(type.RankSpecifier != null) {
					Error("array rank only allowed one time");
				} else {
					if (rank == null) {
						type.RankSpecifier = new int[] { dimension.Count - 1 };
					} else {
						rank.Insert(0, dimension.Count - 1);
						type.RankSpecifier = (int[])rank.ToArray(typeof(int));
					}
					expr = new ArrayCreateExpression(type, dimension);
				}
			} else if (rank != null) {
				if(type.RankSpecifier != null) {
					Error("array rank only allowed one time");
				} else {
					type.RankSpecifier = (int[])rank.ToArray(typeof(int));
				}
			}
		.)
		[ "=" VariableInitializer<out expr> ]
	)
	(. fieldDeclaration.Add(new VariableDeclaration(name, expr, type)); .)
.

/* 6.8 */
ArrayInitializationModifier<out List<Expression> arrayModifiers>
(.
	arrayModifiers = null;
.) =
	"(" InitializationRankList<out arrayModifiers> ")"
.

/* 7.5.4.3 */
InitializationRankList<out List<Expression> rank>
(.
	rank = new List<Expression>();
	Expression expr = null;
.) =
	Expr<out expr>
	[	"To" (. EnsureIsZero(expr); .)
		Expr<out expr>
	]
	(. if (expr != null) { rank.Add(expr); } .)
	{	","
		Expr<out expr>
		[	"To" (. EnsureIsZero(expr); .)
			Expr<out expr>
		]
		(. if (expr != null) { rank.Add(expr); } .)
	}
.

/* 9.6.3 */
VariableInitializer<out Expression initializerExpression>
	(.
		initializerExpression = null;
	.) =
	Expr<out initializerExpression>
	| ArrayInitializer<out initializerExpression>
	.

/* 9.6.3.4 */
ArrayInitializer<out Expression outExpr>
	(.
		Expression expr = null;
		ArrayInitializerExpression initializer = new ArrayInitializerExpression();
	.) =
	"{"
	[
		VariableInitializer<out expr>
		(.
			if (expr != null) { initializer.CreateExpressions.Add(expr); }
		.)
		{
			IF (NotFinalComma()) "," VariableInitializer<out expr>
			(. if (expr != null) { initializer.CreateExpressions.Add(expr); } .)
		}
	]
	"}" (. outExpr = initializer; .)
	.

Charset<out CharsetModifier charsetModifier>
	(. charsetModifier = CharsetModifier.None; .) =
	| "Ansi"		(. charsetModifier = CharsetModifier.Ansi; .)
	| "Auto"		(. charsetModifier = CharsetModifier.Auto; .)
	| "Unicode"		(. charsetModifier = CharsetModifier.Unicode; .)
	.

/* 9.2.6 */
HandlesClause<out List<string> handlesClause>
	(.
		handlesClause = new List<string>();
		string name;
	.) =
	"Handles" EventMemberSpecifier<out name>	(. handlesClause.Add(name); .)
	{ "," EventMemberSpecifier<out name>		(. handlesClause.Add(name); .) }
	.

/* 7.8. */
InterfaceBase <out List<TypeReference> bases>
	(.
		TypeReference type;
		bases = new List<TypeReference>();
	.) =
	"Inherits"
	TypeName<out type> (. bases.Add(type); .)
	{
		","
		TypeName<out type> (. bases.Add(type); .)
	}
	EOL
	.

/* 7.2 */
TypeImplementsClause<out List<TypeReference> baseInterfaces>
	(.
		baseInterfaces = new List<TypeReference>();
		TypeReference type = null;
	.) =
	"Implements" TypeName<out type>
	(.
		baseInterfaces.Add(type);
	.)
	{
		"," TypeName<out type>
		(. baseInterfaces.Add(type); .)
	}
	EndOfStmt
	.

/* 9.1 */
ImplementsClause<out List<InterfaceImplementation> baseInterfaces>
	(.
		baseInterfaces = new List<InterfaceImplementation>();
		TypeReference type = null;
		string memberName = null;
	.) =
	"Implements"
	NonArrayTypeName<out type, false>
	(. if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); .)
	(. baseInterfaces.Add(new InterfaceImplementation(type, memberName)); .)
	{ ","
		NonArrayTypeName<out type, false>
		(. if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); .)
		(. baseInterfaces.Add(new InterfaceImplementation(type, memberName)); .)
	}
.

EventMemberSpecifier<out string name>
(. string eventName; .)
=
	( Identifier | "MyBase" | "Me" )
	(. name = t.val; .)
	"."
	IdentifierOrKeyword<out eventName>
	(. name = name + "." + eventName; .)
.

Expr<out Expression expr>
=
	DisjunctionExpr<out expr>
.

AssignmentOperator<out AssignmentOperatorType op>
	(. op = AssignmentOperatorType.None; .) =
	"="		(. op = AssignmentOperatorType.Assign; .)
	| "&="	(. op = AssignmentOperatorType.ConcatString; .)
	| "+="	(. op = AssignmentOperatorType.Add; .)
	| "-="	(. op = AssignmentOperatorType.Subtract; .)
	| "*="	(. op = AssignmentOperatorType.Multiply; .)
	| "/="	(. op = AssignmentOperatorType.Divide; .)
	| "\\="	(. op = AssignmentOperatorType.DivideInteger; .)
	| "^="	(. op = AssignmentOperatorType.Power; .)
	| "<<="	(. op = AssignmentOperatorType.ShiftLeft; .)
	| ">>="	(. op = AssignmentOperatorType.ShiftRight; .)
	.

/* 11.4 */
SimpleExpr<out Expression pexpr>
=
	SimpleNonInvocationExpression<out pexpr>
	{		(. string name; .)
		"." IdentifierOrKeyword<out name> (. pexpr = new FieldReferenceExpression(pexpr, name); .)
	|	InvocationExpression<ref pexpr>
	}
.

SimpleNonInvocationExpression<out Expression pexpr>
(.
	Expression expr;
	TypeReference type = null;
	string name = String.Empty;
	pexpr = null;
.) =
	(
		(
			/* 11.4.1 */ 
			LiteralString							(.pexpr = new PrimitiveExpression(t.literalValue, t.val);  .)
		|	LiteralCharacter						(.pexpr = new PrimitiveExpression(t.literalValue, t.val);  .)
		|	LiteralSingle							(.pexpr = new PrimitiveExpression(t.literalValue, t.val);  .)
		|	LiteralDouble							(.pexpr = new PrimitiveExpression(t.literalValue, t.val);  .)
		|	LiteralInteger						(.pexpr = new PrimitiveExpression(t.literalValue, t.val);  .)
		|	LiteralDate							(.pexpr = new PrimitiveExpression(t.literalValue, t.val);  .)
		|	LiteralDecimal						(.pexpr = new PrimitiveExpression(t.literalValue, t.val);  .)
			/* True, False and Nothing are handled as literals in the spec */
		|	"True"											(.pexpr = new PrimitiveExpression(true, "true");  .)
		|	"False"											(.pexpr = new PrimitiveExpression(false, "false"); .)
		|	"Nothing"											(.pexpr = new PrimitiveExpression(null, "null");  .)
		|	/* 11.4.2 */ "(" Expr<out expr> ")" 				(. pexpr = new ParenthesizedExpression(expr); .)
		|	/* 11.4.4 */ Identifier					(. pexpr = new IdentifierExpression(t.val); .)
		|	(. string val = String.Empty; .)
			( PrimitiveTypeName<out val> | "Object" (. val = "Object"; .) )
			"." (. t.val = ""; .) Identifier (. pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); .)
		|	"Me"							(. pexpr = new ThisReferenceExpression(); .)
		|	(. Expression retExpr = null; .)
			( "MyBase"										(. retExpr = new BaseReferenceExpression(); .)
			| "MyClass"										(. retExpr = new ClassReferenceExpression(); .)
			)
			"." IdentifierOrKeyword<out name>				(. pexpr = new FieldReferenceExpression(retExpr, name); .)
		|	"Global" "."
			Identifier (. type = new TypeReference(t.val ?? ""); .)
			/* fallback to "" is required if the token wasn't an identifier (->parser error but no exception) */
			(. type.IsGlobal = true; .)
			(. pexpr = new TypeReferenceExpression(type); .)
		|	ObjectCreateExpression<out expr>					(. pexpr = expr; .)
		|	/* 11.11 : Casts */
			(. CastType castType = CastType.Cast; .)
			( "DirectCast"
			| "CType"   (. castType = CastType.Conversion; .)
			| "TryCast" (. castType = CastType.TryCast; .)
			)
			"(" Expr<out expr> "," TypeName<out type> ")"
			(. pexpr = new CastExpression(type, expr, castType); .)
		|	/* 11.11 */ CastTarget<out type> "(" Expr<out expr> ")"	(. pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion); .)
		|	/* 11.4.5 */ "AddressOf" Expr<out expr>			(. pexpr = new AddressOfExpression(expr); .)
		|	/* 11.5.1 */ "GetType" "(" GetTypeTypeName<out type> ")"	(. pexpr = new TypeOfExpression(type); .)
		|	/* 11.5.2 */ "TypeOf" SimpleExpr<out expr> "Is" TypeName<out type> (. pexpr = new TypeOfIsExpression(expr, type); .)
		)
	|
		/* this form only occurs in WithStatements*/
		"." IdentifierOrKeyword<out name> (. pexpr = new FieldReferenceExpression(null, name);.)
	)
.

InvocationExpression<ref Expression pexpr>
(. List<TypeReference> typeParameters = new List<TypeReference>();
   List<Expression> parameters = null;
   TypeReference type; .)
=
	"(" (. Location start = t.Location; .)
	(	"Of"
		TypeName<out type> (. if (type != null) typeParameters.Add(type); .)
		{
			","
			TypeName<out type> (. if (type != null) typeParameters.Add(type); .)
		}
		")"
		(
			"." Identifier
			(. pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeParameters), t.val); .)
		|	"("
			ArgumentList<out parameters>
			")"
			(. pexpr = new InvocationExpression(pexpr, parameters, typeParameters); .)
		)
	|	ArgumentList<out parameters>
		")"
		(. pexpr = new InvocationExpression(pexpr, parameters, typeParameters); .)
	)
	(. pexpr.StartLocation = start; pexpr.EndLocation = t.Location; .)
.

/* 11.11 */

CastTarget<out TypeReference type>
	(.
		type = null;
	.) =
	"CBool"		(. type = new TypeReference("System.Boolean"); .)
	| "CByte"	(. type = new TypeReference("System.Byte"); .)
	| "CSByte"	(. type = new TypeReference("System.SByte"); .)
	| "CChar"	(. type = new TypeReference("System.Char"); .)
	| "CDate"	(. type = new TypeReference("System.DateTime"); .)
	| "CDec"	(. type = new TypeReference("System.Decimal"); .)
	| "CDbl"	(. type = new TypeReference("System.Double"); .)
	| "CShort"	(. type = new TypeReference("System.Int16"); .)
	| "CInt"	(. type = new TypeReference("System.Int32"); .)
	| "CLng"	(. type = new TypeReference("System.Int64"); .)
	| "CUShort"	(. type = new TypeReference("System.UInt16"); .)
	| "CUInt"	(. type = new TypeReference("System.UInt32"); .)
	| "CULng"	(. type = new TypeReference("System.UInt64"); .)
	| "CObj"	(. type = new TypeReference("System.Object"); .)
	| "CSng"	(. type = new TypeReference("System.Single"); .)
	| "CStr"	(. type = new TypeReference("System.String"); .)
	.

DisjunctionExpr<out Expression outExpr>
(.
	Expression expr;
	BinaryOperatorType op = BinaryOperatorType.None;
.) =
	ConjunctionExpr<out outExpr>
	{
		(
			  "Or"     (. op = BinaryOperatorType.BitwiseOr; .)
			| "OrElse" (. op = BinaryOperatorType.LogicalOr; .)
			| "Xor"    (. op = BinaryOperatorType.ExclusiveOr; .)
		)
		ConjunctionExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr);  .)
	}
.

ConjunctionExpr<out Expression outExpr>
(.
	Expression expr;
	BinaryOperatorType op = BinaryOperatorType.None;
.) =
	NotExpr<out outExpr>
	{
		(
			  "And"     (. op = BinaryOperatorType.BitwiseAnd; .)
			| "AndAlso" (. op = BinaryOperatorType.LogicalAnd; .)
		)
		NotExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr);  .)
	}
.

NotExpr<out Expression outExpr> 
	(. UnaryOperatorType uop = UnaryOperatorType.None; .) =
	{	"Not" (. uop = UnaryOperatorType.Not; .) }
	ComparisonExpr<out outExpr>
                (. if (uop != UnaryOperatorType.None)
	                   outExpr = new UnaryOperatorExpression(outExpr, uop);
                .)
	.

ComparisonExpr<out Expression outExpr>
(.
	Expression expr;
	BinaryOperatorType op = BinaryOperatorType.None;
.) =
	ShiftExpr<out outExpr>
	{
		(
			"<"    (. op = BinaryOperatorType.LessThan; .)
			| ">"  (. op = BinaryOperatorType.GreaterThan; .)
			| "<=" (. op = BinaryOperatorType.LessThanOrEqual; .)
			| ">=" (. op = BinaryOperatorType.GreaterThanOrEqual; .)
			| "<>"		(. op = BinaryOperatorType.InEquality; .)
			| "=" 		(. op = BinaryOperatorType.Equality; .)
			| "Like"	(. op = BinaryOperatorType.Like; .)
			| "Is"	(. op = BinaryOperatorType.ReferenceEquality; .)
			| "IsNot" (. op = BinaryOperatorType.ReferenceInequality; .)
		)
		(
			ShiftExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr);  .)
		|
			"Not"
			ShiftExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, new UnaryOperatorExpression(expr, UnaryOperatorType.Not));  .)
		)
	}
.

ShiftExpr<out Expression outExpr>
	(.
		Expression expr;
		BinaryOperatorType op = BinaryOperatorType.None;
	.) =
	ConcatenationExpr<out outExpr> 
	{
		(
			"<<"   (. op = BinaryOperatorType.ShiftLeft; .)
			| ">>" (. op = BinaryOperatorType.ShiftRight; .)
		)
		ConcatenationExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr);  .) 
	}
	.

ConcatenationExpr<out Expression outExpr>
(. Expression expr; .)
=
	AdditiveExpr<out outExpr> { "&" AdditiveExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr);  .) }
.

AdditiveExpr<out Expression outExpr>
(.
	Expression expr;
	BinaryOperatorType op = BinaryOperatorType.None;
.) =
	ModuloExpr<out outExpr>
	{
		(
			  "+"   (. op = BinaryOperatorType.Add; .)
			| "-" (. op = BinaryOperatorType.Subtract; .)
		)
		ModuloExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr);  .)
	}
.

ModuloExpr<out Expression outExpr>
(. Expression expr; .)
=
	IntegerDivisionExpr<out outExpr> { "Mod" IntegerDivisionExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr);  .) }
.

IntegerDivisionExpr<out Expression outExpr>
(. Expression expr; .)
=
	MultiplicativeExpr<out outExpr> { "\\" MultiplicativeExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr);  .) }
.

MultiplicativeExpr<out Expression outExpr>
(.
	Expression expr;
	BinaryOperatorType op = BinaryOperatorType.None;
.) =
	UnaryExpr<out outExpr>
	{
		(
			"*"   (. op = BinaryOperatorType.Multiply; .)
			| "/" (. op = BinaryOperatorType.Divide; .)
		) 
		UnaryExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .) 
	}
.

UnaryExpr<out Expression uExpr> 
(.
	Expression expr;
	UnaryOperatorType uop = UnaryOperatorType.None;
	bool isUOp = false;
.) =
	{ 	"+" 		(. uop = UnaryOperatorType.Plus; isUOp = true; .)
		| "-" 		(. uop = UnaryOperatorType.Minus; isUOp = true; .)
		| "*" 		(. uop = UnaryOperatorType.Star;  isUOp = true;.)
	}
	ExponentiationExpr<out expr>
	(.
		if (isUOp) {
			uExpr = new UnaryOperatorExpression(expr, uop);
		} else {
			uExpr = expr;
		}
	.)
.

ExponentiationExpr<out Expression outExpr>
(. Expression expr; .)
=
	SimpleExpr<out outExpr> { "^" SimpleExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr);  .) }
.
	
ObjectCreateExpression<out Expression oce>
(.
	TypeReference type = null;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -