📄 parser.cs
字号:
}
#line 1338 "VBNET.ATG"
parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParamModifier.In));
while (la.kind == 12) {
lexer.NextToken();
if (la.kind == 55) {
lexer.NextToken();
}
Identifier();
#line 1342 "VBNET.ATG"
operandName = t.val;
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 1343 "VBNET.ATG"
out operandType);
}
#line 1344 "VBNET.ATG"
parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParamModifier.In));
}
Expect(25);
#line 1347 "VBNET.ATG"
Point endPos = t.EndLocation;
if (la.kind == 48) {
lexer.NextToken();
while (la.kind == 27) {
AttributeSection(
#line 1348 "VBNET.ATG"
out section);
#line 1348 "VBNET.ATG"
returnTypeAttributes.Add(section);
}
TypeName(
#line 1348 "VBNET.ATG"
out returnType);
#line 1348 "VBNET.ATG"
endPos = t.EndLocation;
Expect(1);
}
Block(
#line 1349 "VBNET.ATG"
out stmt);
Expect(88);
Expect(187);
Expect(1);
#line 1351 "VBNET.ATG"
OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier,
attributes,
parameters,
returnType,
operatorType
);
operatorDeclaration.ConversionType = opConversionType;
operatorDeclaration.ReturnTypeAttributes = returnTypeAttributes;
operatorDeclaration.Body = (BlockStatement)stmt;
operatorDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
operatorDeclaration.EndLocation = endPos;
operatorDeclaration.Body.StartLocation = startPos;
operatorDeclaration.Body.EndLocation = t.Location;
compilationUnit.AddChild(operatorDeclaration);
break;
}
default: SynErr(226); break;
}
}
void EnumMemberDecl(
#line 921 "VBNET.ATG"
out FieldDeclaration f) {
#line 923 "VBNET.ATG"
Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>();
AttributeSection section = null;
VariableDeclaration varDecl = null;
while (la.kind == 27) {
AttributeSection(
#line 927 "VBNET.ATG"
out section);
#line 927 "VBNET.ATG"
attributes.Add(section);
}
Identifier();
#line 930 "VBNET.ATG"
f = new FieldDeclaration(attributes);
varDecl = new VariableDeclaration(t.val);
f.Fields.Add(varDecl);
f.StartLocation = t.Location;
if (la.kind == 11) {
lexer.NextToken();
Expr(
#line 935 "VBNET.ATG"
out expr);
#line 935 "VBNET.ATG"
varDecl.Initializer = expr;
}
Expect(1);
}
void InterfaceMemberDecl() {
#line 838 "VBNET.ATG"
TypeReference type =null;
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
List<TemplateDefinition> templates = new List<TemplateDefinition>();
AttributeSection section, returnTypeAttributeSection = null;
Modifiers mod = new Modifiers();
List<AttributeSection> attributes = new List<AttributeSection>();
string name;
if (StartOf(16)) {
while (la.kind == 27) {
AttributeSection(
#line 846 "VBNET.ATG"
out section);
#line 846 "VBNET.ATG"
attributes.Add(section);
}
while (StartOf(7)) {
MemberModifier(
#line 849 "VBNET.ATG"
mod);
}
if (la.kind == 93) {
lexer.NextToken();
#line 852 "VBNET.ATG"
mod.Check(Modifier.VBInterfaceEvents);
Identifier();
#line 853 "VBNET.ATG"
name = t.val;
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 854 "VBNET.ATG"
p);
}
Expect(25);
}
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 855 "VBNET.ATG"
out type);
}
Expect(1);
#line 858 "VBNET.ATG"
EventDeclaration ed = new EventDeclaration(type, mod.Modifier, p, attributes, name, null);
compilationUnit.AddChild(ed);
ed.EndLocation = t.EndLocation;
} else if (la.kind == 167) {
lexer.NextToken();
#line 864 "VBNET.ATG"
mod.Check(Modifier.VBInterfaceMethods);
Identifier();
#line 865 "VBNET.ATG"
name = t.val;
TypeParameterList(
#line 866 "VBNET.ATG"
templates);
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 867 "VBNET.ATG"
p);
}
Expect(25);
}
Expect(1);
#line 870 "VBNET.ATG"
MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, null, p, attributes);
md.TypeReference = new TypeReference("", "System.Void");
md.EndLocation = t.EndLocation;
md.Templates = templates;
compilationUnit.AddChild(md);
} else if (la.kind == 100) {
lexer.NextToken();
#line 878 "VBNET.ATG"
mod.Check(Modifier.VBInterfaceMethods);
Identifier();
#line 879 "VBNET.ATG"
name = t.val;
TypeParameterList(
#line 880 "VBNET.ATG"
templates);
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 881 "VBNET.ATG"
p);
}
Expect(25);
}
if (la.kind == 48) {
lexer.NextToken();
while (la.kind == 27) {
AttributeSection(
#line 882 "VBNET.ATG"
out returnTypeAttributeSection);
}
TypeName(
#line 882 "VBNET.ATG"
out type);
}
#line 884 "VBNET.ATG"
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.EndLocation = t.EndLocation;
md.Templates = templates;
compilationUnit.AddChild(md);
Expect(1);
} else if (la.kind == 146) {
lexer.NextToken();
#line 899 "VBNET.ATG"
mod.Check(Modifier.VBInterfaceProperties);
Identifier();
#line 900 "VBNET.ATG"
name = t.val;
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 901 "VBNET.ATG"
p);
}
Expect(25);
}
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 902 "VBNET.ATG"
out type);
}
#line 904 "VBNET.ATG"
if(type == null) {
type = new TypeReference("System.Object");
}
Expect(1);
#line 910 "VBNET.ATG"
PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
pd.Parameters = p;
pd.EndLocation = t.EndLocation;
compilationUnit.AddChild(pd);
} else SynErr(227);
} else if (StartOf(17)) {
NonModuleDeclaration(
#line 917 "VBNET.ATG"
mod, attributes);
} else SynErr(228);
}
void Expr(
#line 1729 "VBNET.ATG"
out Expression expr) {
DisjunctionExpr(
#line 1731 "VBNET.ATG"
out expr);
}
void ImplementsClause(
#line 1700 "VBNET.ATG"
out List<InterfaceImplementation> baseInterfaces) {
#line 1702 "VBNET.ATG"
baseInterfaces = new List<InterfaceImplementation>();
TypeReference type = null;
string memberName = null;
Expect(107);
NonArrayTypeName(
#line 1707 "VBNET.ATG"
out type, false);
#line 1708 "VBNET.ATG"
if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type);
#line 1709 "VBNET.ATG"
baseInterfaces.Add(new InterfaceImplementation(type, memberName));
while (la.kind == 12) {
lexer.NextToken();
NonArrayTypeName(
#line 1711 "VBNET.ATG"
out type, false);
#line 1712 "VBNET.ATG"
if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type);
#line 1713 "VBNET.ATG"
baseInterfaces.Add(new InterfaceImplementation(type, memberName));
}
}
void HandlesClause(
#line 1658 "VBNET.ATG"
out List<string> handlesClause) {
#line 1660 "VBNET.ATG"
handlesClause = new List<string>();
string name;
Expect(105);
EventMemberSpecifier(
#line 1663 "VBNET.ATG"
out name);
#line 1663 "VBNET.ATG"
handlesClause.Add(name);
while (la.kind == 12) {
lexer.NextToken();
EventMemberSpecifier(
#line 1664 "VBNET.ATG"
out name);
#line 1664 "VBNET.ATG"
handlesClause.Add(name);
}
}
void Block(
#line 2343 "VBNET.ATG"
out Statement stmt) {
#line 2346 "VBNET.ATG"
BlockStatement blockStmt = new BlockStatement();
blockStmt.StartLocation = t.Location;
compilationUnit.BlockStart(blockStmt);
while (StartOf(18) ||
#line 2351 "VBNET.ATG"
IsEndStmtAhead()) {
if (
#line 2351 "VBNET.ATG"
IsEndStmtAhead()) {
Expect(88);
EndOfStmt();
#line 2351 "VBNET.ATG"
compilationUnit.AddChild(new EndStatement());
} else {
Statement();
EndOfStmt();
}
}
#line 2356 "VBNET.ATG"
stmt = blockStmt;
blockStmt.EndLocation = t.EndLocation;
compilationUnit.BlockEnd();
}
void Charset(
#line 1650 "VBNET.ATG"
out CharsetModifier charsetModifier) {
#line 1651 "VBNET.ATG"
charsetModifier = CharsetModifier.None;
if (la.kind == 100 || la.kind == 167) {
} else if (la.kind == 47) {
lexer.NextToken();
#line 1652 "VBNET.ATG"
charsetModifier = CharsetModifier.ANSI;
} else if (la.kind == 50) {
lexer.NextToken();
#line 1653 "VBNET.ATG"
charsetModifier = CharsetModifier.Auto;
} else if (la.kind == 176) {
lexer.NextToken();
#line 1654 "VBNET.ATG"
charsetModifier = CharsetModifier.Unicode;
} else SynErr(229);
}
void VariableDeclarator(
#line 1538 "VBNET.ATG"
List<VariableDeclaration> fieldDeclaration) {
#line 1540 "VBNET.ATG"
Expression expr = null;
TypeReference type = null;
ArrayList rank = null;
List<Expression> dimension = null;
Identifier();
#line 1545 "VBNET.ATG"
string name = t.val;
if (
#line 1546 "VBNET.ATG"
IsSize() && !IsDims()) {
ArrayInitializationModifier(
#line 1546 "VBNET.ATG"
out dimension);
}
if (
#line 1547 "VBNET.ATG"
IsDims()) {
ArrayNameModifier(
#line 1547 "VBNET.ATG"
out rank);
}
if (
#line 1549 "VBNET.ATG"
IsObjectCreation()) {
Expect(48);
ObjectCreateExpression(
#line 1549 "VBNET.ATG"
out expr);
#line 1551 "VBNET.ATG"
if (expr is ObjectCreateExpression) {
type = ((ObjectCreateExpression)expr).CreateType;
} else {
type = ((ArrayCreateExpression)expr).CreateType;
}
} else if (StartOf(19)) {
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 1558 "VBNET.ATG"
out type);
}
#line 1560 "VBNET.ATG"
if (type != null && dimension != null) {
if(type.RankSpecifier != null) {
Error("array rank only allowed one time");
} else {
for (int i = 0; i < dimension.Count; i++)
dimension[i] = Expression.AddInteger(dimension[i], 1);
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 (type != null && rank != null) {
if(type.RankSpecifier != null) {
Error("array rank only allowed one time");
} else {
type.RankSpecifier = (int[])rank.ToArray(typeof(int));
}
}
if (la.kind == 11) {
lexer.NextToken();
VariableInitializer(
#line 1582 "VBNET.ATG"
out expr);
}
} else SynErr(230);
#line 1584 "VBNET.ATG"
fieldDeclaration.Add(new VariableDeclaration(name, expr, type));
}
void ConstantDeclarator(
#line 1521 "VBNET.ATG"
List<VariableDeclaration> constantDeclaration) {
#line 1523 "VBNET.ATG"
Expression expr = null;
TypeReference type = null;
string name = String.Empty;
Identifier();
#line 1527 "VBNET.ATG"
name = t.val;
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 1528 "VBNET.ATG"
out type);
}
Expect(11);
Expr(
#line 1529 "VBNET.ATG"
out expr);
#line 1531 "VBNET.ATG"
VariableDeclaration f = new VariableDeclaration(name, expr);
f.TypeReference = type;
constantDeclaration.Add(f);
}
void AccessorDecls(
#line 1463 "VBNET.ATG"
out PropertyGetRegion getBlock, out PropertySetRegion setBlock) {
#line 1465 "VBNET.ATG"
List<AttributeSection> attributes = new List<AttributeSection>();
AttributeSection section;
getBlock = null;
setBlock = null;
while (la.kind == 27) {
AttributeSection(
#line 1470 "VBNET.ATG"
out section);
#line 1470 "VBNET.ATG"
attributes.Add(section);
}
if (la.kind == 101) {
GetAccessorDecl(
#line 1472 "VBNET.ATG"
out getBlock, attributes);
if (la.kind == 27 || la.kind == 156) {
#line 1474 "VBNET.ATG"
attributes = new List<AttributeSection>();
while (la.kind == 27) {
AttributeSection(
#line 1475 "VBNET.ATG"
out section);
#line 1475 "VBNET.ATG"
attributes.Add(section);
}
SetAccessorDecl(
#line 1476 "VBNET.ATG"
out setBlock, attributes);
}
} else if (la.kind == 156) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -