📄 vbnet.atg
字号:
ImportClause<out object importClause>
(.
string qualident = null;
string aliasident = null;
importClause = null;
.) =
[ IF (IsAssignment()) Identifier (. aliasident = t.val; .) "=" ]
Qualident<out qualident>
(.
if (qualident != null && qualident.Length > 0) {
if (aliasident != null) {
importClause = new ImportsAliasDeclaration(aliasident, qualident);
} else {
importedNamespaces.Add(qualident);
importClause = new ImportsDeclaration(qualident);
}
}
.)
.
/* 6.4.2 */
NamespaceMemberDecl
(.
Modifiers m = new Modifiers(this);
AttributeSection section;
ArrayList attributes = new ArrayList();
string qualident;
.) =
"Namespace"
(.
Point startPos = t.Location;
.)
Qualident<out qualident>
(.
INode node = new NamespaceDeclaration(qualident);
node.StartLocation = startPos;
compilationUnit.AddChild(node);
compilationUnit.BlockStart(node);
.)
EOL
NamespaceBody
(.
node.EndLocation = t.Location;
compilationUnit.BlockEnd();
.)
|
{ AttributeSection<out section> (. attributes.Add(section); .) }
{ TypeModifier<m> } NonModuleDeclaration<m, attributes>
.
/* 6.4.2 */
NonModuleDeclaration<Modifiers m, ArrayList attributes>
(.
string name = String.Empty;
ArrayList names = null;
.) =
(. m.Check(Modifier.Classes); .)
/* Spec, 7.5 */
"Class"
(. TypeDeclaration newType = new TypeDeclaration();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
newType.Type = Types.Class;
newType.Modifier = m.Modifier;
newType.Attributes = attributes;
.)
Identifier (. newType.Name = t.val; newType.StartLocation = t.EndLocation; .)
EndOfStmt
[ ClassBaseType<out name> (. newType.BaseType = name; .) ]
{ TypeImplementsClause<out names> (. newType.BaseInterfaces = names; .) }
ClassBody<newType>
(.
compilationUnit.BlockEnd();
.)
| "Module"
(.
m.Check(Modifier.Modules);
TypeDeclaration newType = new TypeDeclaration();
newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.StartLocation = t.Location;
newType.Type = Types.Module;
newType.Modifier = m.Modifier;
newType.Attributes = attributes;
.)
Identifier (. newType.Name = t.val; newType.StartLocation = t.EndLocation; .)
EOL
ModuleBody<newType>
(.
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
.)
| "Structure"
(.
m.Check(Modifier.Structures);
TypeDeclaration newType = new TypeDeclaration();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
newType.StartLocation = t.Location;
newType.Type = Types.Structure;
newType.Modifier = m.Modifier;
newType.Attributes = attributes;
ArrayList baseInterfaces = new ArrayList();
.)
Identifier (. newType.Name = t.val; newType.StartLocation = t.EndLocation; .)
EOL { TypeImplementsClause<out baseInterfaces> }
StructureBody<newType>
(.
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
.)
| /* 7.4 */
"Enum"
(.
m.Check(Modifier.Enums);
TypeDeclaration newType = new TypeDeclaration();
newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Enum;
newType.Modifier = m.Modifier;
newType.Attributes = attributes;
.)
Identifier
(. newType.Name = t.val; newType.StartLocation = t.EndLocation; .)
[ "As" PrimitiveTypeName<out name> (. newType.BaseType = name; .) ]
EOL
EnumBody<newType>
(.
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
.)
| /* 7.8 */
"Interface"
(.
m.Check(Modifier.Interfaces);
TypeDeclaration newType = new TypeDeclaration();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
newType.Type = Types.Interface;
newType.Modifier = m.Modifier;
newType.Attributes = attributes;
ArrayList baseInterfaces = new ArrayList();
.)
Identifier (. newType.Name = t.val; newType.StartLocation = t.EndLocation; .)
EndOfStmt { InterfaceBase<out baseInterfaces> (. newType.BaseInterfaces = baseInterfaces; .) }
InterfaceBody<newType>
(.
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
.)
| /* 7.10 */
"Delegate"
(.
m.Check(Modifier.Delegates);
DelegateDeclaration delegateDeclr = new DelegateDeclaration();
ArrayList p = null;
TypeReference type = null;
delegateDeclr.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
delegateDeclr.StartLocation = t.Location;
delegateDeclr.Modifier = m.Modifier;
delegateDeclr.Attributes = attributes;
.)
(
"Sub" Identifier (. delegateDeclr.Name = t.val; .)
[ "(" [ FormalParameterList<out p> ] ")" (. delegateDeclr.Parameters = p; .) ]
|
"Function" Identifier (. delegateDeclr.Name = t.val; .)
[ "(" [ FormalParameterList<out p> ] ")" (. delegateDeclr.Parameters = p; .) ]
[ "As" TypeName<out type> (. delegateDeclr.ReturnType = type; .)]
)
(. delegateDeclr.EndLocation = t.EndLocation; .)
EOL
(.
compilationUnit.AddChild(delegateDeclr);
.)
.
NamespaceBody =
{ NamespaceMemberDecl }
"End" "Namespace"
EOL
.
ClassBody<TypeDeclaration newType>
(. AttributeSection section; .) =
{
(.
ArrayList attributes = new ArrayList();
Modifiers m = new Modifiers(this);
.)
{ AttributeSection<out section> (. attributes.Add(section); .) }
{ MemberModifier<m> }
ClassMemberDecl<m, attributes>
}
"End" "Class" (. newType.EndLocation = t.EndLocation; .)
EOL
.
StructureBody<TypeDeclaration newType>
(. AttributeSection section; .) =
{
(.
ArrayList attributes = new ArrayList();
Modifiers m = new Modifiers(this);
.)
{ 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; .) =
{
(.
ArrayList attributes = new ArrayList();
Modifiers m = new Modifiers(this);
.)
{ 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;
ArrayList p = null;
AttributeSection section;
Modifiers mod = new Modifiers(this);
ArrayList attributes = new ArrayList();
ArrayList parameters = new ArrayList();
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(Modifier.InterfaceEvents); .)
Identifier (. name = t.val; .)
[ "(" [ FormalParameterList<out p> ] ")" ]
[ "As" TypeName<out type> ]
EOL
(.
EventDeclaration ed = new EventDeclaration(type, mod.Modifier, p, attributes, name, null);
ed.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
compilationUnit.AddChild(ed);
ed.EndLocation = t.EndLocation;
.)
|
"Sub"
(.
mod.Check(Modifier.InterfaceMethods);
ArrayList comments = lexer.SpecialTracker.RetreiveComments();
.)
Identifier (. name = t.val; .)
[ "(" [ FormalParameterList<out p> ] ")" ]
EOL
(.
MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, null, p, attributes);
md.Specials["before"] = comments;
md.EndLocation = t.EndLocation;
compilationUnit.AddChild(md);
.)
|
"Function"
(.
mod.Check(Modifier.InterfaceMethods);
AttributeSection attributeSection = null;
.)
Identifier (. name = t.val; .)
[ "(" [ FormalParameterList<out p> ] ")" ]
[ "As" [AttributeSection<out attributeSection> ] TypeName<out type> ]
(.
if(type == null) {
type = new TypeReference("System.Object");
}
type.Attributes = attributeSection;
MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, type, p, attributes);
md.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
md.EndLocation = t.EndLocation;
compilationUnit.AddChild(md);
.)
EOL
|
"Property"
(.
mod.Check(Modifier.InterfaceProperties);
ArrayList comments = lexer.SpecialTracker.RetreiveComments();
.)
Identifier (. name = t.val; .)
[ "(" [ FormalParameterList<out 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.Specials["before"] = comments;
pd.EndLocation = t.EndLocation;
compilationUnit.AddChild(pd);
.)
)
| /* inner type declarations */
NonModuleDeclaration<mod, attributes>
.
/* 7.4.1 */
EnumMemberDecl<out FieldDeclaration f>
(.
Expression expr = null;
ArrayList attributes = new ArrayList();
AttributeSection section = null;
VariableDeclaration varDecl = null;
.) =
{ AttributeSection<out section> (. attributes.Add(section); .) }
Identifier
(.
f = new FieldDeclaration(attributes);
varDecl = new VariableDeclaration(t.val);
varDecl.Specials["before"] = lexer.SpecialTracker.RetreiveComments();
f.Fields.Add(varDecl);
f.StartLocation = t.Location;
.)
[ "=" Expr<out expr> (. varDecl.Initializer = expr; .) ]
EOL
.
ClassMemberDecl<Modifiers m, ArrayList attributes> =
StructureMemberDecl<m, attributes>
.
ClassBaseType<out string name>
(.
TypeReference type;
name = String.Empty;
.) =
"Inherits"
TypeName<out type> (. name = type.Type; .)
EndOfStmt
.
/* 7.6.1 */
StructureMemberDecl<Modifiers m, ArrayList attributes>
(.
TypeReference type = null;
ArrayList p = null;
Statement stmt = null;
ArrayList variableDeclarators = new ArrayList();
.)=
NonModuleDeclaration<m, attributes>
| /* 9.2.1 */
"Sub"
(.
Point startPos = t.Location;
ArrayList comments = lexer.SpecialTracker.RetreiveComments();
.)
(
(.
string name = String.Empty;
MethodDeclaration methodDeclaration;
HandlesClause handlesClause = null;
ImplementsClause implementsClause = null;
.)
Identifier
(.
name = t.val;
m.Check(Modifier.Methods);
.)
[ "(" [ FormalParameterList<out p> ] ")" ]
[
(
ImplementsClause<out implementsClause>
|
HandlesClause<out handlesClause>
)
]
(. Point endLocation = t.EndLocation; .)
EOL
(
/* abstract methods without a body */
IF(IsMustOverride(m))
(.
methodDeclaration = new MethodDeclaration(name, m.Modifier, null, p, attributes);
methodDeclaration.Specials["before"] = comments;
methodDeclaration.StartLocation = startPos;
methodDeclaration.EndLocation = endLocation;
methodDeclaration.HandlesClause = handlesClause;
methodDeclaration.ImplementsClause = implementsClause;
compilationUnit.AddChild(methodDeclaration);
.)
|
(.
methodDeclaration = new MethodDeclaration(name, m.Modifier, null, p, attributes);
methodDeclaration.Specials["before"] = comments;
methodDeclaration.StartLocation = startPos;
methodDeclaration.EndLocation = endLocation;
methodDeclaration.HandlesClause = handlesClause;
methodDeclaration.ImplementsClause = implementsClause;
compilationUnit.AddChild(methodDeclaration);
compilationUnit.BlockStart(methodDeclaration);
.)
Block<out stmt>
(.
compilationUnit.BlockEnd();
methodDeclaration.Body = (BlockStatement)stmt;
.)
"End" "Sub" (. methodDeclaration.Body.EndLocation = t.EndLocation; .) EOL
)
/* 9.3 */
| "New" [ "(" [ FormalParameterList<out p> ] ")" ]
(. m.Check(Modifier.Constructors); .)
(. Point constructorEndLocation = t.EndLocation; .)
EOL
Block<out stmt>
"End" "Sub" (. Point endLocation = t.EndLocation; .) EOL
(.
ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes);
cd.StartLocation = startPos;
cd.Specials["before"] = comments;
cd.EndLocation = constructorEndLocation;
cd.Body = (BlockStatement)stmt;
cd.Body.EndLocation = endLocation;
compilationUnit.AddChild(cd);
.)
)
|
/* 9.2.1 */
"Function"
(.
m.Check(Modifier.Methods);
string name = String.Empty;
Point startPos = t.Location;
MethodDeclaration methodDeclaration;
HandlesClause handlesClause = null;
ImplementsClause implementsClause = null;
AttributeSection attributeSection = null;
.)
Identifier (. name = t.val; .)
[ "(" [ FormalParameterList<out p> ] ")" ]
["As" [AttributeSection<out attributeSection>] TypeName<out type> ]
(.
if(type == null) {
type = new TypeReference("System.Object");
}
type.Attributes = attributeSection;
.)
[
(
ImplementsClause<out implementsClause>
|
HandlesClause<out handlesClause>
)
]
EOL
(
/* abstract methods without a body */
IF(IsMustOverride(m))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -