📄 vbnet.atg
字号:
(. newType.BodyStartLocation = t.Location; .)
{ TypeImplementsClause<out baseInterfaces> (. newType.BaseTypes.AddRange(baseInterfaces);.) }
StructureBody<newType>
(.
compilationUnit.BlockEnd();
.)
| /* 7.4 */
"Enum"
(.
m.Check(Modifiers.VBEnums);
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
newType.StartLocation = m.GetDeclarationLocation(t.Location);
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = ClassType.Enum;
.)
Identifier (. newType.Name = t.val; .)
[ "As" NonArrayTypeName<out typeRef, false> (. newType.BaseTypes.Add(typeRef); .) ]
EOL
(. newType.BodyStartLocation = t.Location; .)
EnumBody<newType>
(.
compilationUnit.BlockEnd();
.)
| /* 7.8 */
"Interface"
(.
m.Check(Modifiers.VBInterfacs);
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
newType.StartLocation = m.GetDeclarationLocation(t.Location);
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = ClassType.Interface;
.)
Identifier (. newType.Name = t.val; .)
TypeParameterList<newType.Templates>
EndOfStmt
(. newType.BodyStartLocation = t.Location; .)
{ InterfaceBase<out baseInterfaces> (. newType.BaseTypes.AddRange(baseInterfaces); .) }
InterfaceBody<newType>
(.
compilationUnit.BlockEnd();
.)
| /* 7.10 */
"Delegate"
(.
m.Check(Modifiers.VBDelegates);
DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
delegateDeclr.ReturnType = new TypeReference("", "System.Void");
delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
.)
(
"Sub" Identifier (. delegateDeclr.Name = t.val; .)
TypeParameterList<delegateDeclr.Templates>
[ "(" [ FormalParameterList<p> ] ")" (. delegateDeclr.Parameters = p; .) ]
|
"Function" Identifier (. delegateDeclr.Name = t.val; .)
TypeParameterList<delegateDeclr.Templates>
[ "(" [ FormalParameterList<p> ] ")" (. delegateDeclr.Parameters = p; .) ]
[ "As" (. TypeReference type; .) TypeName<out type> (. delegateDeclr.ReturnType = type; .)]
)
(. delegateDeclr.EndLocation = t.EndLocation; .)
EOL
(.
compilationUnit.AddChild(delegateDeclr);
.)
.
NamespaceBody =
{ NamespaceMemberDecl }
"End" "Namespace"
EOL
.
ClassBody<TypeDeclaration newType>
(. AttributeSection section; .) =
{
(.List<AttributeSection> attributes = new List<AttributeSection>();
ModifierList m = new ModifierList();
.)
{ AttributeSection<out section> (. attributes.Add(section); .) }
{ MemberModifier<m> }
ClassMemberDecl<m, attributes>
}
.
StructureBody<TypeDeclaration newType>
(. AttributeSection section; .) =
{
(.List<AttributeSection> attributes = new List<AttributeSection>();
ModifierList m = new ModifierList();
.)
{ AttributeSection<out section> (. attributes.Add(section); .) }
{ MemberModifier<m> }
StructureMemberDecl<m, attributes>
}
"End" "Structure" (. newType.EndLocation = t.EndLocation; .)
EOL
.
/* 7.7.1 */
ModuleBody<TypeDeclaration newType>
(. AttributeSection section; .) =
{
(.List<AttributeSection> attributes = new List<AttributeSection>();
ModifierList m = new ModifierList();
.)
{ AttributeSection<out section> (. attributes.Add(section); .) }
{ MemberModifier<m> }
ClassMemberDecl<m, attributes>
}
"End" "Module" (. newType.EndLocation = t.EndLocation; .)
EOL
.
EnumBody<TypeDeclaration newType>
(. FieldDeclaration f; .) =
{
EnumMemberDecl<out f> (. compilationUnit.AddChild(f); .)
}
"End" "Enum" (. newType.EndLocation = t.EndLocation; .)
EOL
.
InterfaceBody<TypeDeclaration newType> =
{ InterfaceMemberDecl }
"End" "Interface" (. newType.EndLocation = t.EndLocation; .)
EOL
.
/* The information provided in the spec about */
/* interface declarations is wrong */
InterfaceMemberDecl
(.
TypeReference type =null;
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
List<TemplateDefinition> templates = new List<TemplateDefinition>();
AttributeSection section, returnTypeAttributeSection = null;
ModifierList mod = new ModifierList();
List<AttributeSection> attributes = new List<AttributeSection>();
string name;
.) =
{ AttributeSection<out section> (. attributes.Add(section); .) }
/* this is different to c#: not only the Shadows modifier is allowed, */
/* also member modifiers like overloads etc. */
{ MemberModifier<mod> }
(
"Event"
(.
mod.Check(Modifiers.VBInterfaceEvents);
Location startLocation = t.Location;
.)
Identifier (. name = t.val; .)
[ "(" [ FormalParameterList<p> ] ")" ]
[ "As" TypeName<out type> ]
EOL
(.
EventDeclaration ed = new EventDeclaration(type, mod.Modifier, p, attributes, name, null);
compilationUnit.AddChild(ed);
ed.StartLocation = startLocation;
ed.EndLocation = t.EndLocation;
.)
|
"Sub"
(.
Location startLocation = t.Location;
mod.Check(Modifiers.VBInterfaceMethods);
.)
Identifier (. name = t.val; .)
TypeParameterList<templates>
[ "(" [ FormalParameterList<p> ] ")" ]
EOL
(.
MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, null, p, attributes);
md.TypeReference = new TypeReference("", "System.Void");
md.StartLocation = startLocation;
md.EndLocation = t.EndLocation;
md.Templates = templates;
compilationUnit.AddChild(md);
.)
|
"Function"
(.
mod.Check(Modifiers.VBInterfaceMethods);
Location startLocation = t.Location;
.)
Identifier (. name = t.val; .)
TypeParameterList<templates>
[ "(" [ FormalParameterList<p> ] ")" ]
[ "As" { AttributeSection<out returnTypeAttributeSection> } TypeName<out type> ]
(.
if(type == null) {
type = new TypeReference("System.Object");
}
MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, type, p, attributes);
if (returnTypeAttributeSection != null) {
returnTypeAttributeSection.AttributeTarget = "return";
md.Attributes.Add(returnTypeAttributeSection);
}
md.StartLocation = startLocation;
md.EndLocation = t.EndLocation;
md.Templates = templates;
compilationUnit.AddChild(md);
.)
EOL
|
"Property"
(.
Location startLocation = t.Location;
mod.Check(Modifiers.VBInterfaceProperties);
.)
Identifier (. name = t.val; .)
[ "(" [ FormalParameterList<p> ] ")" ]
[ "As" TypeName<out type> ]
(.
if(type == null) {
type = new TypeReference("System.Object");
}
.)
EOL
(.
PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
pd.Parameters = p;
pd.EndLocation = t.EndLocation;
pd.StartLocation = startLocation;
compilationUnit.AddChild(pd);
.)
)
| /* inner type declarations */
NonModuleDeclaration<mod, attributes>
.
/* 7.4.1 */
EnumMemberDecl<out FieldDeclaration f>
(.
Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>();
AttributeSection section = null;
VariableDeclaration varDecl = null;
.) =
{ AttributeSection<out section> (. attributes.Add(section); .) }
Identifier
(.
f = new FieldDeclaration(attributes);
varDecl = new VariableDeclaration(t.val);
f.Fields.Add(varDecl);
f.StartLocation = t.Location;
.)
[ "=" Expr<out expr> (. varDecl.Initializer = expr; .) ]
EOL
.
ClassMemberDecl<ModifierList m, List<AttributeSection> attributes> =
StructureMemberDecl<m, attributes>
.
ClassBaseType<out TypeReference typeRef>
(.
typeRef = null;
.) =
"Inherits"
TypeName<out typeRef>
EndOfStmt
.
/* 7.6.1 */
StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
(.
TypeReference type = null;
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
Statement stmt = null;
List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>();
List<TemplateDefinition> templates = new List<TemplateDefinition>();
.)
=
NonModuleDeclaration<m, attributes>
| /* 9.2.1 */
"Sub"
(.
Location startPos = t.Location;
.)
(
(.
string name = String.Empty;
MethodDeclaration methodDeclaration; List<string> handlesClause = null;
List<InterfaceImplementation> implementsClause = null;
.)
Identifier
(.
name = t.val;
m.Check(Modifiers.VBMethods);
.)
TypeParameterList<templates>
[ "(" [ FormalParameterList<p> ] ")" ]
[
(
ImplementsClause<out implementsClause>
|
HandlesClause<out handlesClause>
)
]
(. Location endLocation = t.EndLocation; .)
EOL
(
/* abstract methods without a body */
IF(IsMustOverride(m))
(.
methodDeclaration = new MethodDeclaration(name, m.Modifier, null, p, attributes);
methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
methodDeclaration.EndLocation = endLocation;
methodDeclaration.TypeReference = new TypeReference("", "System.Void");
methodDeclaration.Templates = templates;
methodDeclaration.HandlesClause = handlesClause;
methodDeclaration.InterfaceImplementations = implementsClause;
compilationUnit.AddChild(methodDeclaration);
.)
|
(.
methodDeclaration = new MethodDeclaration(name, m.Modifier, null, p, attributes);
methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
methodDeclaration.EndLocation = endLocation;
methodDeclaration.TypeReference = new TypeReference("", "System.Void");
methodDeclaration.Templates = templates;
methodDeclaration.HandlesClause = handlesClause;
methodDeclaration.InterfaceImplementations = implementsClause;
compilationUnit.AddChild(methodDeclaration);
.)
(. if (ParseMethodBodies) { .)
Block<out stmt>
"End" "Sub"
(. } else {
// don't parse method body
lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
}
.)
(. methodDeclaration.Body = (BlockStatement)stmt; .)
(. methodDeclaration.Body.EndLocation = t.EndLocation; .) EOL
)
/* 9.3 */
| "New" [ "(" [ FormalParameterList<p> ] ")" ]
(. m.Check(Modifiers.Constructors); .)
(. Location constructorEndLocation = t.EndLocation; .)
EOL
(. if (ParseMethodBodies) { .)
Block<out stmt>
"End" "Sub"
(. } else {
// don't parse method body
lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
}
.)
(. Location endLocation = t.EndLocation; .) EOL
(.
ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes);
cd.StartLocation = m.GetDeclarationLocation(startPos);
cd.EndLocation = constructorEndLocation;
cd.Body = (BlockStatement)stmt;
cd.Body.EndLocation = endLocation;
compilationUnit.AddChild(cd);
.)
)
|
/* 9.2.1 */
"Function"
(.
m.Check(Modifiers.VBMethods);
string name = String.Empty;
Location startPos = t.Location;
MethodDeclaration methodDeclaration;List<string> handlesClause = null;
List<InterfaceImplementation> implementsClause = null;
AttributeSection returnTypeAttributeSection = null;
.)
Identifier (. name = t.val; .)
TypeParameterList<templates>
[ "(" [ FormalParameterList<p> ] ")" ]
["As" { AttributeSection<out returnTypeAttributeSection> } TypeName<out type> ]
(.
if(type == null) {
type = new TypeReference("System.Object");
}
.)
[
(
ImplementsClause<out implementsClause>
|
HandlesClause<out handlesClause>
)
]
EOL
(
/* abstract methods without a body */
IF(IsMustOverride(m))
(.
methodDeclaration = new MethodDeclaration(name, m.Modifier, type, p, attributes);
methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
methodDeclaration.EndLocation = t.EndLocation;
methodDeclaration.HandlesClause = handlesClause;
methodDeclaration.Templates = templates;
methodDeclaration.InterfaceImplementations = implementsClause;
if (returnTypeAttributeSection != null) {
returnTypeAttributeSection.AttributeTarget = "return";
methodDeclaration.Attributes.Add(returnTypeAttributeSection);
}
compilationUnit.AddChild(methodDeclaration);
.)
|
(.
methodDeclaration = new MethodDeclaration(name, m.Modifier, type, p, attributes);
methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
methodDeclaration.EndLocation = t.EndLocation;
methodDeclaration.Templates = templates;
methodDeclaration.HandlesClause = handlesClause;
methodDeclaration.InterfaceImplementations = implementsClause;
if (returnTypeAttributeSection != null) {
returnTypeAttributeSection.AttributeTarget = "return";
methodDeclaration.Attributes.Add(returnTypeAttributeSection);
}
compilationUnit.AddChild(methodDeclaration);
if (ParseMethodBodies) { .)
Block<out stmt>
"End" "Function"
(. } else {
// don't parse method body
lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement();
}
methodDeclaration.Body = (BlockStatement)stmt;
methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation;
methodDeclaration.Body.EndLocation = t.EndLocation;
.)
EOL
)
|
/* 9.2.2. */
"Declare"
(.
m.Check(Modifiers.VBExternalMethods);
Location startPos = t.Location;
CharsetModifier charsetModifer = CharsetModifier.None;
string library = String.Empty;
string alias = null;
string name = String.Empty;
.)
[Charset<out charsetModifer> ]
(
"Sub"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -