📄 vbnet.atg
字号:
(.
methodDeclaration = new MethodDeclaration(name, m.Modifier, type, p, attributes);
methodDeclaration.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
methodDeclaration.StartLocation = startPos;
methodDeclaration.EndLocation = t.EndLocation;
methodDeclaration.HandlesClause = handlesClause;
methodDeclaration.ImplementsClause = implementsClause;
compilationUnit.AddChild(methodDeclaration);
.)
|
(.
methodDeclaration = new MethodDeclaration(name, m.Modifier, type, p, attributes);
methodDeclaration.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
methodDeclaration.StartLocation = startPos;
methodDeclaration.EndLocation = t.EndLocation;
methodDeclaration.HandlesClause = handlesClause;
methodDeclaration.ImplementsClause = implementsClause;
compilationUnit.AddChild(methodDeclaration);
compilationUnit.BlockStart(methodDeclaration);
.)
Block<out stmt>
(.
compilationUnit.BlockEnd();
methodDeclaration.Body = (BlockStatement)stmt;
.)
"End" "Function"
(.
methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation;
methodDeclaration.Body.EndLocation = t.EndLocation;
.)
EOL
)
|
/* 9.2.2. */
"Declare"
(.
m.Check(Modifier.ExternalMethods);
Point startPos = t.Location;
CharsetModifier charsetModifer = CharsetModifier.None;
string library = String.Empty;
string alias = null;
string name = String.Empty;
.)
[Charset<out charsetModifer> ]
(
"Sub"
Identifier (. name = t.val; .)
"Lib" LiteralString (. library = t.val; .)
["Alias" LiteralString (. alias = t.val; .)]
[ "(" [ FormalParameterList<out p> ] ")" ]
EOL
(.
DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer);
declareDeclaration.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
declareDeclaration.StartLocation = startPos;
declareDeclaration.EndLocation = t.EndLocation;
compilationUnit.AddChild(declareDeclaration);
.)
|
"Function"
Identifier (. name = t.val; .)
"Lib" LiteralString (. library = t.val; .)
["Alias" LiteralString (. alias = t.val; .)]
[ "(" [ FormalParameterList<out p> ] ")" ]
["As" TypeName<out type> ]
EOL
(.
DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
declareDeclaration.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
declareDeclaration.StartLocation = startPos;
declareDeclaration.EndLocation = t.EndLocation;
compilationUnit.AddChild(declareDeclaration);
.)
)
|
/* 9. 4 */
"Event"
(.
m.Check(Modifier.Events);
Point startPos = t.Location;
EventDeclaration eventDeclaration;
string name = String.Empty;
ImplementsClause implementsClause = null;
.)
Identifier (. name= t.val; .)
(
"As" TypeName<out type>
|
[ "(" [ FormalParameterList<out p> ] ")" ]
)
[ ImplementsClause<out implementsClause> ]
(.
eventDeclaration = new EventDeclaration(type, m.Modifier, p, attributes, name, implementsClause);
eventDeclaration.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
eventDeclaration.StartLocation = startPos;
eventDeclaration.EndLocation = t.EndLocation;
compilationUnit.AddChild(eventDeclaration);
.)
EOL
| /* 9.6 */
(. Point startPos = t.Location; .)
(.
m.Check(Modifier.Fields);
FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
ArrayList comments = lexer.SpecialTracker.RetreiveComments();
fd.StartLocation = startPos;
.)
VariableDeclarator<variableDeclarators>
(.
((INode)variableDeclarators[0]).Specials["before"] = comments;
.)
{ "," VariableDeclarator<variableDeclarators> }
EOL
(.
fd.EndLocation = t.EndLocation;
fd.Fields = variableDeclarators;
compilationUnit.AddChild(fd);
.)
| /* 9.4 */
(. m.Check(Modifier.Fields); .)
"Const" (. m.Add(Modifier.Constant); .)
(.
FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
fd.StartLocation = t.Location;
ArrayList comments = lexer.SpecialTracker.RetreiveComments();
ArrayList constantDeclarators = new ArrayList();
.)
ConstantDeclarator<constantDeclarators>
(.
((INode)constantDeclarators[0]).Specials["before"] = comments;
.)
{ "," ConstantDeclarator<constantDeclarators> }
(.
fd.Fields = constantDeclarators;
fd.EndLocation = t.Location;
.)
EOL
(.
fd.EndLocation = t.EndLocation;
compilationUnit.AddChild(fd);
.)
| /* 9.7 */
"Property"
(.
m.Check(Modifier.Properties);
Point startPos = t.Location;
ImplementsClause implementsClause = null;
.)
Identifier (. string propertyName = t.val; .)
[ "(" [ FormalParameterList<out p> ] ")" ]
[ "As" TypeName<out type> ]
(.
if(type == null) {
type = new TypeReference("System.Object");
}
.)
[ ImplementsClause<out implementsClause> ]
EOL
(
/* abstract properties without a body */
IF(IsMustOverride(m))
(.
PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
pDecl.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
pDecl.StartLocation = startPos;
pDecl.EndLocation = t.Location;
pDecl.TypeReference = type;
pDecl.ImplementsClause = implementsClause;
pDecl.Parameters = p;
compilationUnit.AddChild(pDecl);
.)
|
(.
PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
pDecl.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
pDecl.StartLocation = startPos;
pDecl.EndLocation = t.Location;
pDecl.BodyStart = t.Location;
pDecl.TypeReference = type;
pDecl.ImplementsClause = implementsClause;
pDecl.Parameters = p;
PropertyGetRegion getRegion;
PropertySetRegion setRegion;
.)
AccessorDecls<out getRegion, out setRegion>
"End" "Property"
EOL
(.
pDecl.GetRegion = getRegion;
pDecl.SetRegion = setRegion;
pDecl.BodyEnd = t.EndLocation;
compilationUnit.AddChild(pDecl);
.)
)
.
/* 9.7 */
AccessorDecls<out PropertyGetRegion getBlock, out PropertySetRegion setBlock>
(.
ArrayList attributes = new ArrayList();
AttributeSection section;
getBlock = null;
setBlock = null;
.) =
{ AttributeSection<out section> (. attributes.Add(section); .) }
(
GetAccessorDecl<out getBlock, attributes>
[
(. attributes = new ArrayList(); .)
{ AttributeSection<out section> (. attributes.Add(section); .) }
SetAccessorDecl<out setBlock, attributes>
]
|
SetAccessorDecl<out setBlock, attributes>
[
(. attributes = new ArrayList(); .)
{ AttributeSection<out section> (. attributes.Add(section); .) }
GetAccessorDecl<out getBlock, attributes>
]
)
.
/* 9.7.1 */
GetAccessorDecl<out PropertyGetRegion getBlock, ArrayList attributes>
(. Statement stmt = null; .) =
"Get"
EOL
Block<out stmt>
(.
getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes);
.)
"End" "Get"
EOL
.
/* 9.7.2 */
SetAccessorDecl<out PropertySetRegion setBlock, ArrayList attributes>
(.
Statement stmt = null;
ArrayList p = null;
.) =
"Set"
[ "(" [ FormalParameterList<out p> ] ")" ]
EOL
Block<out stmt>
(.
setBlock = new PropertySetRegion((BlockStatement)stmt, attributes);
setBlock.Parameters = p;
.)
"End" "Set"
EOL
.
/* 9.5 */
ConstantDeclarator<ArrayList constantDeclaration>
(.
Expression expr = null;
TypeReference type = null;
string name = String.Empty;
.) =
Identifier (. name = t.val; .)
["As" TypeName<out type> ]
"=" Expr<out expr>
(.
VariableDeclaration f = new VariableDeclaration(name, expr);
f.Type = type;
constantDeclaration.Add(f);
.)
.
/* 9.6 */
VariableDeclarator<ArrayList fieldDeclaration>
(.
Expression expr = null;
TypeReference type = null;
ObjectCreateExpression oce = null;
ArrayCreateExpression ace = null;
ArrayList rank = null;
ArrayList dimension = null;
.) =
Identifier
(.
VariableDeclaration f = new VariableDeclaration(t.val);
.)
[ IF(IsRank()) ArrayTypeModifiers<out rank> ]
[ IF(IsSize()) ArrayInitializationModifier<out dimension> ]
(
IF(IsObjectCreation()) "As" ObjectCreateExpression<out expr>
(.
if(expr is ArrayCreateExpression) {
ace = expr as ArrayCreateExpression;
f.Initializer = ace.ArrayInitializer;
} else {
oce = expr as ObjectCreateExpression;
f.Initializer = oce;
if(oce.CreateType != null) {
f.Type = oce.CreateType;
}
}
.)
|
[ "As" TypeName<out type> ]
(.
if(type != null) {
type.Dimension = dimension;
}
f.Type = type;
if (type != null && rank != null) {
if(type.RankSpecifier != null) {
Error("array rank only allowed one time");
} else {
type.RankSpecifier = rank;
}
}
.)
[ "=" VariableInitializer<out expr> (. f.Initializer = expr; .) ]
)
(. fieldDeclaration.Add(f); .)
.
/* 6.8 */
ArrayInitializationModifier<out ArrayList arrayModifiers>
(.
arrayModifiers = null;
.) =
"(" InitializationRankList<out arrayModifiers> ")"
.
/* 7.5.4.3 */
InitializationRankList<out ArrayList rank>
(.
rank = null;
Expression expr = null;
.) =
Expr<out expr> (. rank = new ArrayList(); rank.Add(expr); .)
{
"," Expr<out expr> (. 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>
(.
initializer.CreateExpressions.Add(expr);
.)
{
IF (NotFinalComma()) "," VariableInitializer<out expr>
(. 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 HandlesClause handlesClause>
(.
handlesClause = new HandlesClause();
string name;
.) =
"Handles" EventMemberSpecifier<out name> (. handlesClause.EventNames.Add(name); .)
{ "," EventMemberSpecifier<out name> (. handlesClause.EventNames.Add(name); .) }
.
/* 7.8. */
InterfaceBase <out ArrayList bases>
(.
TypeReference type;
bases = new ArrayList();
.) =
"Inherits"
TypeName<out type> (. bases.Add(type); .)
{
","
TypeName<out type> (. bases.Add(type); .)
}
EOL
.
/* 7.2 */
TypeImplementsClause<out ArrayList baseInterfaces>
(.
baseInterfaces = new ArrayList();
TypeReference type = null;
.) =
"Implements" TypeName<out type>
(.
baseInterfaces.Add(type);
.)
{
"," TypeName<out type>
(. baseInterfaces.Add(type); .)
}
EndOfStmt
.
/* 9.1 */
ImplementsClause<out ImplementsClause clause>
(.
clause = new ImplementsClause();
string typename = String.Empty;
string first;
.) =
"Implements" Identifier (. first = t.val; .) "." Qualident<out typename> (. ((ImplementsClause)clause).BaseMembers.Add(first + "." + typename); .)
{ "," Identifier (. first = t.val; .) "." Qualident<out typename> (. ((ImplementsClause)clause).BaseMembers.Add(first + "." + typename); .) }
.
EventMemberSpecifier<out string name>
(. string type; name = String.Empty; .) =
Identifier (. type = t.val; .)
"."
Identifier (. name = type + "." + t.val; .)
| "MyBase" "."
(
Identifier (. name = "MyBase." + t.val; .)
| "Error" (. name = "MyBase.Error"; .)
)
.
Expr<out Expression expr>
(. expr = new Expression(); .) =
ConditionalOrExpr<out expr>
{
/*ConditionalOrExpr<out expr> |*/
(. AssignmentOperatorType op; Expression val; .)
AssignmentOperator<out op> Expr<out val> (. expr = new AssignmentExpression(expr, op, val); .)
}
.
UnaryExpr<out Expression uExpr>
(.
Expression expr;
UnaryOperatorType uop = UnaryOperatorType.None;
bool isUOp = false;
.) =
{ "+" (. uop = UnaryOperatorType.Plus; isUOp = true; .)
| "-" (. uop = UnaryOperatorType.Minus; isUOp = true; .)
/* | "Not" (. uop = UnaryOperatorType.Not; isUOp = true;.) */
| "*" (. uop = UnaryOperatorType.Star; isUOp = true;.)
}
SimpleExpr<out expr>
(.
if (isUOp) {
uExpr = new UnaryOperatorExpression(expr, uop);
} else {
uExpr = 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>
(.
Expression expr;
TypeReference type = null;
string name = String.Empty;
pexpr = null;
.) =
(
(
/* 11.4.1 */
LiteralString (.pexpr = new PrimitiveExpression(t.literalValue, t.val); .)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -