📄 parser.cs
字号:
TypeWithRestriction(
#line 520 "cs.ATG"
out type, true, false);
}
void FormalParameterList(
#line 581 "cs.ATG"
List<ParameterDeclarationExpression> parameter) {
#line 584 "cs.ATG"
ParameterDeclarationExpression p;
AttributeSection section;
List<AttributeSection> attributes = new List<AttributeSection>();
while (la.kind == 18) {
AttributeSection(
#line 589 "cs.ATG"
out section);
#line 589 "cs.ATG"
attributes.Add(section);
}
if (StartOf(14)) {
FixedParameter(
#line 591 "cs.ATG"
out p);
#line 591 "cs.ATG"
bool paramsFound = false;
p.Attributes = attributes;
parameter.Add(p);
while (la.kind == 14) {
lexer.NextToken();
#line 596 "cs.ATG"
attributes = new List<AttributeSection>(); if (paramsFound) Error("params array must be at end of parameter list");
while (la.kind == 18) {
AttributeSection(
#line 597 "cs.ATG"
out section);
#line 597 "cs.ATG"
attributes.Add(section);
}
if (StartOf(14)) {
FixedParameter(
#line 599 "cs.ATG"
out p);
#line 599 "cs.ATG"
p.Attributes = attributes; parameter.Add(p);
} else if (la.kind == 94) {
ParameterArray(
#line 600 "cs.ATG"
out p);
#line 600 "cs.ATG"
paramsFound = true; p.Attributes = attributes; parameter.Add(p);
} else SynErr(134);
}
} else if (la.kind == 94) {
ParameterArray(
#line 603 "cs.ATG"
out p);
#line 603 "cs.ATG"
p.Attributes = attributes; parameter.Add(p);
} else SynErr(135);
}
void ClassType(
#line 651 "cs.ATG"
out TypeReference typeRef, bool canBeUnbound) {
#line 652 "cs.ATG"
TypeReference r; typeRef = null;
if (la.kind == 1) {
TypeName(
#line 654 "cs.ATG"
out r, canBeUnbound);
#line 654 "cs.ATG"
typeRef = r;
} else if (la.kind == 90) {
lexer.NextToken();
#line 655 "cs.ATG"
typeRef = new TypeReference("object");
} else if (la.kind == 107) {
lexer.NextToken();
#line 656 "cs.ATG"
typeRef = new TypeReference("string");
} else SynErr(136);
}
void TypeName(
#line 1969 "cs.ATG"
out TypeReference typeRef, bool canBeUnbound) {
#line 1970 "cs.ATG"
List<TypeReference> typeArguments = null;
string alias = null;
string qualident;
if (
#line 1975 "cs.ATG"
la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) {
lexer.NextToken();
#line 1976 "cs.ATG"
alias = t.val;
Expect(10);
}
Qualident(
#line 1979 "cs.ATG"
out qualident);
if (la.kind == 23) {
TypeArgumentList(
#line 1980 "cs.ATG"
out typeArguments, canBeUnbound);
}
#line 1982 "cs.ATG"
if (alias == null) {
typeRef = new TypeReference(qualident, typeArguments);
} else if (alias == "global") {
typeRef = new TypeReference(qualident, typeArguments);
typeRef.IsGlobal = true;
} else {
typeRef = new TypeReference(alias + "." + qualident, typeArguments);
}
while (
#line 1991 "cs.ATG"
DotAndIdent()) {
Expect(15);
#line 1992 "cs.ATG"
typeArguments = null;
Qualident(
#line 1993 "cs.ATG"
out qualident);
if (la.kind == 23) {
TypeArgumentList(
#line 1994 "cs.ATG"
out typeArguments, canBeUnbound);
}
#line 1995 "cs.ATG"
typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments);
}
}
void MemberModifiers(
#line 672 "cs.ATG"
ModifierList m) {
while (StartOf(15) ||
#line 690 "cs.ATG"
la.kind == Tokens.Identifier && la.val == "partial") {
if (la.kind == 48) {
lexer.NextToken();
#line 675 "cs.ATG"
m.Add(Modifiers.Abstract, t.Location);
} else if (la.kind == 70) {
lexer.NextToken();
#line 676 "cs.ATG"
m.Add(Modifiers.Extern, t.Location);
} else if (la.kind == 83) {
lexer.NextToken();
#line 677 "cs.ATG"
m.Add(Modifiers.Internal, t.Location);
} else if (la.kind == 88) {
lexer.NextToken();
#line 678 "cs.ATG"
m.Add(Modifiers.New, t.Location);
} else if (la.kind == 93) {
lexer.NextToken();
#line 679 "cs.ATG"
m.Add(Modifiers.Override, t.Location);
} else if (la.kind == 95) {
lexer.NextToken();
#line 680 "cs.ATG"
m.Add(Modifiers.Private, t.Location);
} else if (la.kind == 96) {
lexer.NextToken();
#line 681 "cs.ATG"
m.Add(Modifiers.Protected, t.Location);
} else if (la.kind == 97) {
lexer.NextToken();
#line 682 "cs.ATG"
m.Add(Modifiers.Public, t.Location);
} else if (la.kind == 98) {
lexer.NextToken();
#line 683 "cs.ATG"
m.Add(Modifiers.ReadOnly, t.Location);
} else if (la.kind == 102) {
lexer.NextToken();
#line 684 "cs.ATG"
m.Add(Modifiers.Sealed, t.Location);
} else if (la.kind == 106) {
lexer.NextToken();
#line 685 "cs.ATG"
m.Add(Modifiers.Static, t.Location);
} else if (la.kind == 73) {
lexer.NextToken();
#line 686 "cs.ATG"
m.Add(Modifiers.Fixed, t.Location);
} else if (la.kind == 118) {
lexer.NextToken();
#line 687 "cs.ATG"
m.Add(Modifiers.Unsafe, t.Location);
} else if (la.kind == 121) {
lexer.NextToken();
#line 688 "cs.ATG"
m.Add(Modifiers.Virtual, t.Location);
} else if (la.kind == 123) {
lexer.NextToken();
#line 689 "cs.ATG"
m.Add(Modifiers.Volatile, t.Location);
} else {
Expect(1);
#line 691 "cs.ATG"
m.Add(Modifiers.Partial, t.Location);
}
}
}
void ClassMemberDecl(
#line 983 "cs.ATG"
ModifierList m, List<AttributeSection> attributes) {
#line 984 "cs.ATG"
Statement stmt = null;
if (StartOf(16)) {
StructMemberDecl(
#line 986 "cs.ATG"
m, attributes);
} else if (la.kind == 27) {
#line 987 "cs.ATG"
m.Check(Modifiers.Destructors); Location startPos = t.Location;
lexer.NextToken();
Expect(1);
#line 988 "cs.ATG"
DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes);
d.Modifier = m.Modifier;
d.StartLocation = m.GetDeclarationLocation(startPos);
Expect(20);
Expect(21);
#line 992 "cs.ATG"
d.EndLocation = t.EndLocation;
if (la.kind == 16) {
Block(
#line 992 "cs.ATG"
out stmt);
} else if (la.kind == 11) {
lexer.NextToken();
} else SynErr(137);
#line 993 "cs.ATG"
d.Body = (BlockStatement)stmt;
compilationUnit.AddChild(d);
} else SynErr(138);
}
void StructMemberDecl(
#line 696 "cs.ATG"
ModifierList m, List<AttributeSection> attributes) {
#line 698 "cs.ATG"
string qualident = null;
TypeReference type;
Expression expr;
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
Statement stmt = null;
List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>();
List<TemplateDefinition> templates = new List<TemplateDefinition>();
TypeReference explicitInterface = null;
if (la.kind == 59) {
#line 708 "cs.ATG"
m.Check(Modifiers.Constants);
lexer.NextToken();
#line 709 "cs.ATG"
Location startPos = t.Location;
Type(
#line 710 "cs.ATG"
out type);
Expect(1);
#line 710 "cs.ATG"
FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifiers.Const);
fd.StartLocation = m.GetDeclarationLocation(startPos);
VariableDeclaration f = new VariableDeclaration(t.val);
fd.Fields.Add(f);
Expect(3);
Expr(
#line 715 "cs.ATG"
out expr);
#line 715 "cs.ATG"
f.Initializer = expr;
while (la.kind == 14) {
lexer.NextToken();
Expect(1);
#line 716 "cs.ATG"
f = new VariableDeclaration(t.val);
fd.Fields.Add(f);
Expect(3);
Expr(
#line 719 "cs.ATG"
out expr);
#line 719 "cs.ATG"
f.Initializer = expr;
}
Expect(11);
#line 720 "cs.ATG"
fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd);
} else if (
#line 724 "cs.ATG"
NotVoidPointer()) {
#line 724 "cs.ATG"
m.Check(Modifiers.PropertysEventsMethods);
Expect(122);
#line 725 "cs.ATG"
Location startPos = t.Location;
if (
#line 726 "cs.ATG"
IsExplicitInterfaceImplementation()) {
TypeName(
#line 727 "cs.ATG"
out explicitInterface, false);
#line 728 "cs.ATG"
if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) {
qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
}
} else if (la.kind == 1) {
lexer.NextToken();
#line 731 "cs.ATG"
qualident = t.val;
} else SynErr(139);
if (la.kind == 23) {
TypeParameterList(
#line 734 "cs.ATG"
templates);
}
Expect(20);
if (StartOf(10)) {
FormalParameterList(
#line 737 "cs.ATG"
p);
}
Expect(21);
#line 738 "cs.ATG"
MethodDeclaration methodDeclaration = new MethodDeclaration(qualident,
m.Modifier,
new TypeReference("void"),
p,
attributes);
methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
methodDeclaration.EndLocation = t.EndLocation;
methodDeclaration.Templates = templates;
if (explicitInterface != null)
methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident));
compilationUnit.AddChild(methodDeclaration);
compilationUnit.BlockStart(methodDeclaration);
while (
#line 753 "cs.ATG"
IdentIsWhere()) {
TypeParameterConstraintsClause(
#line 753 "cs.ATG"
templates);
}
if (la.kind == 16) {
Block(
#line 755 "cs.ATG"
out stmt);
} else if (la.kind == 11) {
lexer.NextToken();
} else SynErr(140);
#line 755 "cs.ATG"
compilationUnit.BlockEnd();
methodDeclaration.Body = (BlockStatement)stmt;
} else if (la.kind == 68) {
#line 759 "cs.ATG"
m.Check(Modifiers.PropertysEventsMethods);
lexer.NextToken();
#line 760 "cs.ATG"
EventDeclaration eventDecl = new EventDeclaration(null, null, m.Modifier, attributes, null);
eventDecl.StartLocation = t.Location;
compilationUnit.AddChild(eventDecl);
compilationUnit.BlockStart(eventDecl);
EventAddRegion addBlock = null;
EventRemoveRegion removeBlock = null;
Type(
#line 767 "cs.ATG"
out type);
#line 767 "cs.ATG"
eventDecl.TypeReference = type;
if (
#line 768 "cs.ATG"
IsExplicitInterfaceImplementation()) {
TypeName(
#line 769 "cs.ATG"
out explicitInterface, false);
#line 770 "cs.ATG"
qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
#line 771 "cs.ATG"
eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident));
} else if (la.kind == 1) {
lexer.NextToken();
#line 773 "cs.ATG"
qualident = t.val;
} else SynErr(141);
#line 775 "cs.ATG"
eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation;
if (la.kind == 3) {
lexer.NextToken();
Expr(
#line 776 "cs.ATG"
out expr);
#line 776 "cs.ATG"
eventDecl.Initializer = expr;
}
if (la.kind == 16) {
lexer.NextToken();
#line 777 "cs.ATG"
eventDecl.BodyStart = t.Location;
EventAccessorDecls(
#line 778 "cs.ATG"
out addBlock, out removeBlock);
Expect(17);
#line 779 "cs.ATG"
eventDecl.BodyEnd = t.EndLocation;
}
if (la.kind == 11) {
lexer.NextToken();
}
#line 782 "cs.ATG"
compilationUnit.BlockEnd();
eventDecl.AddRegion = addBlock;
eventDecl.RemoveRegion = removeBlock;
} else if (
#line 788 "cs.ATG"
IdentAndLPar()) {
#line 788 "cs.ATG"
m.Check(Modifiers.Constructors | Modifiers.StaticConstructors);
Expect(1);
#line 789 "cs.ATG"
string name = t.val; Location startPos = t.Location;
Expect(20);
if (StartOf(10)) {
#line 789 "cs.ATG"
m.Check(Modifiers.Constructors);
FormalParameterList(
#line 790 "cs.ATG"
p);
}
Expect(21);
#line 792 "cs.ATG"
ConstructorInitializer init = null;
if (la.kind == 9) {
#line 793 "cs.ATG"
m.Check(Modifiers.Constructors);
ConstructorInitializer(
#line 794 "cs.ATG"
out init);
}
#line 796 "cs.ATG"
ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes);
cd.StartLocation = startPos;
cd.EndLocation = t.EndLocation;
if (la.kind == 16) {
Block(
#line 801 "cs.ATG"
out stmt);
} else if (la.kind == 11) {
lexer.NextToken();
} else SynErr(142);
#line 801 "cs.ATG"
cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd);
} else if (la.kind == 69 || la.kind == 79) {
#line 804 "cs.ATG"
m.Check(Modifiers.Operators);
if (m.isNone) Error("at least one modifier must be set");
bool isImplicit = true;
Location startPos = Location.Empty;
if (la.kind == 79) {
lexer.NextToken();
#line 809 "cs.ATG"
startPos = t.Location;
} else {
lexer.NextToken();
#line 809 "cs.ATG"
isImplicit = false; startPos = t.Location;
}
Expect(91);
Type(
#line 810 "cs.ATG"
out type);
#line 810 "cs.ATG"
TypeReference operatorType = type;
Expect(20);
Type(
#line 811 "cs.ATG"
out type);
Expect(1);
#line 811 "cs.ATG"
string varName = t.val;
Expect(21);
#line 812 "cs.ATG"
Location endPos = t.Location;
if (la.kind == 16) {
Block(
#line 813 "cs.ATG"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -