📄 parser.cs
字号:
declareDeclaration.EndLocation = t.EndLocation;
compilationUnit.AddChild(declareDeclaration);
} else if (la.kind == 100) {
lexer.NextToken();
Identifier();
#line 930 "VBNET.ATG"
name = t.val;
Expect(115);
Expect(3);
#line 931 "VBNET.ATG"
library = t.literalValue as string;
if (la.kind == 44) {
lexer.NextToken();
Expect(3);
#line 932 "VBNET.ATG"
alias = t.literalValue as string;
}
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 933 "VBNET.ATG"
p);
}
Expect(25);
}
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 934 "VBNET.ATG"
out type);
}
Expect(1);
#line 937 "VBNET.ATG"
DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
declareDeclaration.EndLocation = t.EndLocation;
compilationUnit.AddChild(declareDeclaration);
} else SynErr(224);
break;
}
case 93: {
lexer.NextToken();
#line 947 "VBNET.ATG"
m.Check(Modifiers.VBEvents);
Location startPos = t.Location;
EventDeclaration eventDeclaration;
string name = String.Empty;
List<InterfaceImplementation> implementsClause = null;
Identifier();
#line 953 "VBNET.ATG"
name= t.val;
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 955 "VBNET.ATG"
out type);
} else if (la.kind == 1 || la.kind == 24 || la.kind == 107) {
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 957 "VBNET.ATG"
p);
}
Expect(25);
}
} else SynErr(225);
if (la.kind == 107) {
ImplementsClause(
#line 959 "VBNET.ATG"
out implementsClause);
}
#line 961 "VBNET.ATG"
eventDeclaration = new EventDeclaration(type, m.Modifier, p, attributes, name, implementsClause);
eventDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
eventDeclaration.EndLocation = t.EndLocation;
compilationUnit.AddChild(eventDeclaration);
Expect(1);
break;
}
case 2: case 47: case 49: case 50: case 51: case 70: case 95: case 134: case 144: case 169: case 176: case 177: {
#line 968 "VBNET.ATG"
Location startPos = t.Location;
#line 970 "VBNET.ATG"
m.Check(Modifiers.Fields);
FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier);
fd.StartLocation = m.GetDeclarationLocation(startPos);
IdentifierForFieldDeclaration();
#line 974 "VBNET.ATG"
string name = t.val;
VariableDeclaratorPartAfterIdentifier(
#line 975 "VBNET.ATG"
variableDeclarators, name);
while (la.kind == 12) {
lexer.NextToken();
VariableDeclarator(
#line 976 "VBNET.ATG"
variableDeclarators);
}
Expect(1);
#line 979 "VBNET.ATG"
fd.EndLocation = t.EndLocation;
fd.Fields = variableDeclarators;
compilationUnit.AddChild(fd);
break;
}
case 71: {
#line 984 "VBNET.ATG"
m.Check(Modifiers.Fields);
lexer.NextToken();
#line 985 "VBNET.ATG"
m.Add(Modifiers.Const, t.Location);
#line 987 "VBNET.ATG"
FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
fd.StartLocation = m.GetDeclarationLocation(t.Location);
List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>();
ConstantDeclarator(
#line 991 "VBNET.ATG"
constantDeclarators);
while (la.kind == 12) {
lexer.NextToken();
ConstantDeclarator(
#line 992 "VBNET.ATG"
constantDeclarators);
}
#line 994 "VBNET.ATG"
fd.Fields = constantDeclarators;
fd.EndLocation = t.Location;
Expect(1);
#line 999 "VBNET.ATG"
fd.EndLocation = t.EndLocation;
compilationUnit.AddChild(fd);
break;
}
case 146: {
lexer.NextToken();
#line 1005 "VBNET.ATG"
m.Check(Modifiers.VBProperties);
Location startPos = t.Location;
List<InterfaceImplementation> implementsClause = null;
Identifier();
#line 1009 "VBNET.ATG"
string propertyName = t.val;
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 1010 "VBNET.ATG"
p);
}
Expect(25);
}
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 1011 "VBNET.ATG"
out type);
}
#line 1013 "VBNET.ATG"
if(type == null) {
type = new TypeReference("System.Object");
}
if (la.kind == 107) {
ImplementsClause(
#line 1017 "VBNET.ATG"
out implementsClause);
}
Expect(1);
if (
#line 1021 "VBNET.ATG"
IsMustOverride(m)) {
#line 1023 "VBNET.ATG"
PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
pDecl.StartLocation = m.GetDeclarationLocation(startPos);
pDecl.EndLocation = t.Location;
pDecl.TypeReference = type;
pDecl.InterfaceImplementations = implementsClause;
pDecl.Parameters = p;
compilationUnit.AddChild(pDecl);
} else if (StartOf(16)) {
#line 1033 "VBNET.ATG"
PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
pDecl.StartLocation = m.GetDeclarationLocation(startPos);
pDecl.EndLocation = t.Location;
pDecl.BodyStart = t.Location;
pDecl.TypeReference = type;
pDecl.InterfaceImplementations = implementsClause;
pDecl.Parameters = p;
PropertyGetRegion getRegion;
PropertySetRegion setRegion;
AccessorDecls(
#line 1043 "VBNET.ATG"
out getRegion, out setRegion);
Expect(88);
Expect(146);
Expect(1);
#line 1047 "VBNET.ATG"
pDecl.GetRegion = getRegion;
pDecl.SetRegion = setRegion;
pDecl.BodyEnd = t.EndLocation;
compilationUnit.AddChild(pDecl);
} else SynErr(226);
break;
}
case 204: {
lexer.NextToken();
#line 1054 "VBNET.ATG"
Location startPos = t.Location;
Expect(93);
#line 1056 "VBNET.ATG"
m.Check(Modifiers.VBCustomEvents);
EventAddRemoveRegion eventAccessorDeclaration;
EventAddRegion addHandlerAccessorDeclaration = null;
EventRemoveRegion removeHandlerAccessorDeclaration = null;
EventRaiseRegion raiseEventAccessorDeclaration = null;
List<InterfaceImplementation> implementsClause = null;
Identifier();
#line 1063 "VBNET.ATG"
string customEventName = t.val;
Expect(48);
TypeName(
#line 1064 "VBNET.ATG"
out type);
if (la.kind == 107) {
ImplementsClause(
#line 1065 "VBNET.ATG"
out implementsClause);
}
Expect(1);
while (StartOf(17)) {
EventAccessorDeclaration(
#line 1068 "VBNET.ATG"
out eventAccessorDeclaration);
#line 1070 "VBNET.ATG"
if(eventAccessorDeclaration is EventAddRegion)
{
addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration;
}
else if(eventAccessorDeclaration is EventRemoveRegion)
{
removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration;
}
else if(eventAccessorDeclaration is EventRaiseRegion)
{
raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration;
}
}
Expect(88);
Expect(93);
Expect(1);
#line 1086 "VBNET.ATG"
if(addHandlerAccessorDeclaration == null)
{
Error("Need to provide AddHandler accessor.");
}
if(removeHandlerAccessorDeclaration == null)
{
Error("Need to provide RemoveHandler accessor.");
}
if(raiseEventAccessorDeclaration == null)
{
Error("Need to provide RaiseEvent accessor.");
}
EventDeclaration decl = new EventDeclaration(type, customEventName, m.Modifier, attributes, null);
decl.StartLocation = m.GetDeclarationLocation(startPos);
decl.EndLocation = t.EndLocation;
decl.AddRegion = addHandlerAccessorDeclaration;
decl.RemoveRegion = removeHandlerAccessorDeclaration;
decl.RaiseRegion = raiseEventAccessorDeclaration;
compilationUnit.AddChild(decl);
break;
}
case 187: case 201: case 202: {
#line 1109 "VBNET.ATG"
ConversionType opConversionType = ConversionType.None;
if (la.kind == 201 || la.kind == 202) {
if (la.kind == 202) {
lexer.NextToken();
#line 1110 "VBNET.ATG"
opConversionType = ConversionType.Implicit;
} else {
lexer.NextToken();
#line 1111 "VBNET.ATG"
opConversionType = ConversionType.Explicit;
}
}
Expect(187);
#line 1114 "VBNET.ATG"
m.Check(Modifiers.VBOperators);
Location startPos = t.Location;
TypeReference returnType = NullTypeReference.Instance;
TypeReference operandType = NullTypeReference.Instance;
string operandName;
OverloadableOperatorType operatorType;
AttributeSection section;
List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
List<AttributeSection> returnTypeAttributes = new List<AttributeSection>();
OverloadableOperator(
#line 1124 "VBNET.ATG"
out operatorType);
Expect(24);
if (la.kind == 55) {
lexer.NextToken();
}
Identifier();
#line 1125 "VBNET.ATG"
operandName = t.val;
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 1126 "VBNET.ATG"
out operandType);
}
#line 1127 "VBNET.ATG"
parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In));
while (la.kind == 12) {
lexer.NextToken();
if (la.kind == 55) {
lexer.NextToken();
}
Identifier();
#line 1131 "VBNET.ATG"
operandName = t.val;
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 1132 "VBNET.ATG"
out operandType);
}
#line 1133 "VBNET.ATG"
parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In));
}
Expect(25);
#line 1136 "VBNET.ATG"
Location endPos = t.EndLocation;
if (la.kind == 48) {
lexer.NextToken();
while (la.kind == 27) {
AttributeSection(
#line 1137 "VBNET.ATG"
out section);
#line 1137 "VBNET.ATG"
returnTypeAttributes.Add(section);
}
TypeName(
#line 1137 "VBNET.ATG"
out returnType);
#line 1137 "VBNET.ATG"
endPos = t.EndLocation;
Expect(1);
}
Block(
#line 1138 "VBNET.ATG"
out stmt);
Expect(88);
Expect(187);
Expect(1);
#line 1140 "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(227); break;
}
}
void EnumMemberDecl(
#line 694 "VBNET.ATG"
out FieldDeclaration f) {
#line 696 "VBNET.ATG"
Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>();
AttributeSection section = null;
VariableDeclaration varDecl = null;
while (la.kind == 27) {
AttributeSection(
#line 700 "VBNET.ATG"
out section);
#line 700 "VBNET.ATG"
attributes.Add(section);
}
Identifier();
#line 703 "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 708 "VBNET.ATG"
out expr);
#line 708 "VBNET.ATG"
varDecl.Initializer = expr;
}
Expect(1);
}
void InterfaceMemberDecl() {
#line 595 "VBNET.ATG"
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;
if (StartOf(18)) {
while (la.kind == 27) {
AttributeSection(
#line 603 "VBNET.ATG"
out section);
#line 603 "VBNET.ATG"
attributes.Add(section);
}
while (StartOf(8)) {
MemberModifier(
#line 606 "VBNET.ATG"
mod);
}
if (la.kind == 93) {
lexer.NextToken();
#line 610 "VBNET.ATG"
mod.Check(Modifiers.VBInterfaceEvents);
Location startLocation = t.Location;
Identifier();
#line 613 "VBNET.ATG"
name = t.val;
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 614 "VBNET.ATG"
p);
}
Expect(25);
}
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 615 "VBNET.ATG"
out type);
}
Expect(1);
#line 618 "VBNET.ATG"
EventDeclaration ed = new EventDeclaration(type, mod.Modifier, p, attributes, name, null);
compilationUnit.AddChild(ed);
ed.StartLocation = startLocation;
ed.EndLocation = t.EndLocation;
} else if (la.kind == 167) {
lexer.NextToken();
#line 626 "VBNET.ATG"
Location startLocation = t.Location;
mod.Check(Modifiers.VBInterfaceMethods);
Identifier();
#line 629 "VBNET.ATG"
name = t.val;
TypeParameterList(
#line 630 "VBNET.ATG"
templates);
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 631 "VBNET.ATG"
p);
}
Expect(25);
}
Expect(1);
#line 634 "VBNET.ATG"
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);
} else if (la.kind == 100) {
lexer.NextToken();
#line 644 "VBNET.ATG"
mod.Check(Modifiers.VBInterfaceMethods);
Location startLocation = t.Location;
Identifier();
#line 647 "VBNET.ATG"
name = t.val;
TypeParameterList(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -