📄 vbnet.atg
字号:
| 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>
"." Identifier (. pexpr = new FieldReferenceOrInvocationExpression(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 FieldReferenceOrInvocationExpression(retExpr, name); .)
| ObjectCreateExpression<out expr> (. pexpr = expr; .)
| /* 11.11 */ ( "DirectCast" | "CType" ) "(" Expr<out expr> "," TypeName<out type> ")" (. pexpr = new CastExpression(type, expr); .)
| /* 11.11 */ CastTarget<out type> "(" Expr<out expr> ")" (. pexpr = new CastExpression(type, expr, true); .)
| /* 11.4.5 */ "AddressOf" Expr<out expr> (. pexpr = new AddressOfExpression(expr); .)
| /* 11.5.1 */ "GetType" "(" TypeName<out type> ")" (. pexpr = new GetTypeExpression(type); .)
| /* 11.5.2 */ "TypeOf" SimpleExpr<out expr> "Is" TypeName<out type> (. pexpr = new TypeOfExpression(expr, type); .)
)
{
"." IdentifierOrKeyword<out name> (. pexpr = new FieldReferenceOrInvocationExpression(pexpr, name); .)
| "(" (. ArrayList parameters = new ArrayList(); .)
[
(. expr = null; .) [ Argument<out expr>] (. parameters.Add(expr); .)
{
"," (. expr = null; .)
[ Argument<out expr> ] (. parameters.Add(expr); .)
}
]
")" (. pexpr = new InvocationExpression(pexpr, parameters); .)
}
|
/* this form only occurs in with statements*/
"." IdentifierOrKeyword<out name> (. pexpr = new FieldReferenceOrInvocationExpression(pexpr, name);.)
{
"." IdentifierOrKeyword<out name> (. pexpr = new FieldReferenceOrInvocationExpression(pexpr, name); .)
| "(" (. ArrayList parameters = new ArrayList(); .)
[
(. expr = null; .) [ Argument<out expr>] (. parameters.Add(expr); .)
{
"," (. expr = null; .)
[ Argument<out expr> ] (. parameters.Add(expr); .)
}
]
")" (. pexpr = new InvocationExpression(pexpr, parameters); .)
}
)
.
/* 11.11 */
CastTarget<out TypeReference type>
(.
type = null;
.) =
"CBool" (. type = new TypeReference("System.Boolean"); .)
| "CByte" (. type = new TypeReference("System.Byte"); .)
| "CChar" (. type = new TypeReference("System.Char"); .)
| "CDate" (. type = new TypeReference("System.DateTime"); .)
| "CDec" (. type = new TypeReference("System.Decimal"); .)
| "CDbl" (. type = new TypeReference("System.Double"); .)
| "CInt" (. type = new TypeReference("System.Int32"); .)
| "CLng" (. type = new TypeReference("System.Int64"); .)
| "CObj" (. type = new TypeReference("System.Object"); .)
| "CShort" (. type = new TypeReference("System.Int16"); .)
| "CSng" (. type = new TypeReference("System.Single"); .)
| "CStr" (. type = new TypeReference("System.String"); .)
.
ConditionalOrExpr<out Expression outExpr>
(. Expression expr; .) =
ConditionalAndExpr<out outExpr> { "OrElse" ConditionalAndExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BooleanOr, expr); .) }
.
ConditionalAndExpr<out Expression outExpr>
(. Expression expr; .) =
InclusiveOrExpr<out outExpr> { "AndAlso" InclusiveOrExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BooleanAnd, expr); .) }
.
InclusiveOrExpr<out Expression outExpr>
(. Expression expr; .) =
ExclusiveOrExpr<out outExpr> { "Xor" ExclusiveOrExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); .) }
.
ExclusiveOrExpr<out Expression outExpr>
(. Expression expr; .) =
AndExpr<out outExpr> { "Or" AndExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); .) }
.
AndExpr<out Expression outExpr>
(. Expression expr; .) =
NotExpr<out outExpr> { "And" NotExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); .) }
.
NotExpr<out Expression outExpr>
(. UnaryOperatorType uop = UnaryOperatorType.None; .) =
{ "Not" (. uop = UnaryOperatorType.Not; .) }
EqualityExpr<out outExpr>
(. if (uop != UnaryOperatorType.None)
outExpr = new UnaryOperatorExpression(outExpr, uop);
.)
.
EqualityExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
.) =
RelationalExpr<out outExpr>
{
(
"<>" (. op = BinaryOperatorType.InEquality; .)
| "=" (. op = BinaryOperatorType.Equality; .)
| "Like" (. op = BinaryOperatorType.Like; .)
)
RelationalExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
}
.
RelationalExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
.) =
ShiftExpr<out outExpr>
{
(
"<" (. op = BinaryOperatorType.LessThan; .)
| ">" (. op = BinaryOperatorType.GreaterThan; .)
| "<=" (. op = BinaryOperatorType.LessThanOrEqual; .)
| ">=" (. op = BinaryOperatorType.GreaterThanOrEqual; .)
)
ShiftExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
|
/* 11.5.3 */
"Is" (. op = BinaryOperatorType.IS; .)
Expr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
}
.
ShiftExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
.) =
AdditiveExpr<out outExpr>
{
(
"<<" (. op = BinaryOperatorType.ShiftLeft; .)
| ">>" (. op = BinaryOperatorType.ShiftRight; .)
)
AdditiveExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
}
.
AdditiveExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
.) =
MultiplicativeExpr<out outExpr>
{
(
"+" (. op = BinaryOperatorType.Add; .)
| "-" (. op = BinaryOperatorType.Subtract; .)
| "&" (. op = BinaryOperatorType.Concat; .)
)
MultiplicativeExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
}
.
MultiplicativeExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
.) =
UnaryExpr<out outExpr>
{
(
"*" (. op = BinaryOperatorType.Multiply; .)
| "/" (. op = BinaryOperatorType.Divide; .)
| "\\" (. op = BinaryOperatorType.DivideInteger; .)
| "Mod" (. op = BinaryOperatorType.Modulus; .)
| "^" (. op = BinaryOperatorType.Power; .)
)
UnaryExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
}
.
ObjectCreateExpression<out Expression oce>
(.
TypeReference type = null;
Expression initializer = null;
ArrayList arguments = null;
oce = null;
.) =
"New" ArrayTypeName<out type>
["("
[ ArgumentList<out arguments> ]
")"
]
[
ArrayInitializer<out initializer>
]
(.
if(initializer == null) {
oce = new ObjectCreateExpression(type, arguments);
} else {
ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer as ArrayInitializerExpression);
ace.Parameters = arguments;
oce = ace;
}
.)
.
/* 9.3.2 */
ArgumentList<out ArrayList arguments>
(.
arguments = new ArrayList();
Expression expr = null;
.) =
[
Argument<out expr> (. arguments.Add(expr); .)
{
","
Argument<out expr> (. arguments.Add(expr); .)
}
]
.
/* Spec, 11.8 */
Argument<out Expression argumentexpr>
(.
Expression expr;
argumentexpr = null;
string name;
.) =
IF(IsNamedAssign()) Identifier (. name = t.val; .) ":" "=" Expr<out expr>
(.
argumentexpr = new NamedArgumentExpression(name, expr);
.)
|
Expr<out argumentexpr>
.
/* 7.1. */
TypeName<out TypeReference typeref>
(.
ArrayList rank = null;
.) =
NonArrayTypeName<out typeref>
ArrayTypeModifiers<out rank>
(.
typeref = new TypeReference(typeref == null ? "UNKNOWN" : typeref.Type, rank);
.)
.
ArrayTypeName<out TypeReference typeref>
(.
ArrayList rank = null;
.) =
NonArrayTypeName<out typeref>
ArrayInitializationModifiers<out rank>
(.
typeref = new TypeReference(typeref == null ? "UNKNOWN" : typeref.Type, rank);
.)
.
/* 7.1 */
NonArrayTypeName<out TypeReference typeref>
(.
string name;
typeref = null;
.) =
Qualident<out name> (. typeref = new TypeReference(name); .)
| "Object" (. typeref = new TypeReference("System.Object"); .)
| PrimitiveTypeName<out name> (. typeref = new TypeReference(name); .)
.
ArrayInitializationModifiers<out ArrayList arrayModifiers>
(.
arrayModifiers = new ArrayList();
ArrayList dim = new ArrayList();
.) =
{
IF (IsDims()) "("
[ InitializationRankList <out dim>]
(.
arrayModifiers.Add(dim);
.)
")"
}
(.
if(arrayModifiers.Count == 0) {
arrayModifiers = null;
}
.)
.
/* 7.9 */
ArrayTypeModifiers<out ArrayList arrayModifiers>
(.
arrayModifiers = new ArrayList();
int i = 0;
.) =
{ IF (IsRank())
"("
[ RankList <out i>]
(.
arrayModifiers.Add(i);
.)
")"
}
(.
if(arrayModifiers.Count == 0) {
arrayModifiers = null;
}
.)
.
/* 7.9 */
RankList<out int i>
(. i = 0; .) =
{ "," (. ++i; .) }
.
GlobalAttributeSection =
(. Point startPos = t.Location; .)
"<" ("Assembly" | "Module")
(.
string attributeTarget = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture);
ArrayList attributes = new ArrayList();
ICSharpCode.SharpRefactory.Parser.AST.VB.Attribute attribute;
.)
":" Attribute<out attribute>
(.
attributes.Add(attribute);
attribute.AttributeTarget = attributeTarget;
.)
{
IF (NotFinalComma())
","
(. attributeTarget = ""; .)
[
("Assembly" | "Module")
(.
attributeTarget = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture);
.)
":"
]
Attribute<out attribute>
(.
attribute.AttributeTarget = attributeTarget;
attributes.Add(attribute);
.)
}
[ "," ]
">"
EndOfStmt
(.
AttributeSection section = new AttributeSection(attributeTarget, attributes);
section.StartLocation = startPos;
section.EndLocation = t.EndLocation;
compilationUnit.AddChild(section);
.)
.
/* Spec, 5. */
Attribute<out ICSharpCode.SharpRefactory.Parser.AST.VB.Attribute attribute>
(. string qualident; .) =
Qualident<out qualident>
(.
ArrayList positional = new ArrayList();
ArrayList named = new ArrayList();
string name = qualident;
.)
[ AttributeArguments<ref positional, ref named> ]
(.
attribute = new ICSharpCode.SharpRefactory.Parser.AST.VB.Attribute(name, positional, named);
.)
.
/* Spec, 5.2.2 */
AttributeArguments<ref ArrayList positional, ref ArrayList named>
(.
bool nameFound = false;
string name = "";
Expression expr;
.) =
"("
[
IF (IsNotClosingParenthesis()) (
[
IF (IsNamedAssign()) (. nameFound = true; .)
IdentifierOrKeyword<out name>
[":"] "="
] Expr<out expr>
(.
if(name == "") positional.Add(expr);
else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; }
.)
{
","
(
IF (IsNamedAssign()) (. nameFound = true; .)
IdentifierOrKeyword<out name>
[ ":" ] "="
| (. if (nameFound) Error("no positional argument after named argument"); .)
) Expr<out expr> (. if(name == "") positional.Add(expr);
else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; }
.)
}
)
]
")"
.
/* Spec, 5. */
AttributeSection<out AttributeSection section>
(.
string attributeTarget = "";
ArrayList attributes = new ArrayList();
ICSharpCode.SharpRefactory.Parser.AST.VB.Attribute attribute;
.) =
"<" (. Point startPos = t.Location; .)
[ IF (IsLocalAttrTarget())
( "Event" (. attributeTarget = "event";.)
| "Return" (. attributeTarget = "return";.)
| Identifier
(.
string val = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture);
if (val != "field" || val != "method" ||
val != "module" || val != "param" ||
val != "property" || val != "type")
Error("attribute target specifier (event, return, field," +
"method, module, param, property, or type) expected");
attributeTarget = t.val;
.)
) ":"
]
Attribute<out attribute> (. attributes.Add(attribute); .)
{ IF (NotFinalComma()) "," Attribute<out attribute> (. attributes.Add(attribute); .) }
[ "," ]
">"
(.
section = new AttributeSection(attributeTarget, attributes);
section.StartLocation = startPos;
section.EndLocation = t.EndLocation;
.)
.
/* 9.2.5 */
FormalParameterList<out ArrayList parameter>
(.
parameter = new ArrayList();
ParameterDeclarationExpression p;
AttributeSection section;
ArrayList attributes = new ArrayList();
.) =
{ AttributeSection<out section> (.attributes.Add(section); .) }
(
FormalParameter<out p>
(.
bool paramsFound = false;
p.Attributes = attributes;
parameter.Add(p);
.)
{
"," (. attributes = new ArrayList(); if (paramsFound) Error("params array must be at end of parameter list"); .)
{ AttributeSection<out section> (.attributes.Add(section); .) }
(
FormalParameter <out p> (. p.Attributes = attributes; parameter.Add(p); .)
)
}
)
.
/* 9.2.5 */
FormalParameter<out ParameterDeclarationExpression p>
(.
TypeReference type = null;
ParamModifiers mod = new ParamModifiers(this);
Expression expr = null;
p = null;
ArrayList arrayModifiers = null;
.) =
{ ParameterModifier<mod> }
Identifier (. string parameterName = t.val; .)
[ IF(IsRank()) ArrayTypeModifiers<out arrayModifiers> ]
[ "As" TypeName<out type> ]
(.
if(type != null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -