📄 parser.cs
字号:
out stmt);
} else if (la.kind == 11) {
lexer.NextToken();
#line 813 "cs.ATG"
stmt = null;
} else SynErr(143);
#line 816 "cs.ATG"
List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
parameters.Add(new ParameterDeclarationExpression(type, varName));
OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier,
attributes,
parameters,
operatorType,
isImplicit ? ConversionType.Implicit : ConversionType.Explicit
);
operatorDeclaration.Body = (BlockStatement)stmt;
operatorDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
operatorDeclaration.EndLocation = endPos;
compilationUnit.AddChild(operatorDeclaration);
} else if (StartOf(17)) {
TypeDecl(
#line 832 "cs.ATG"
m, attributes);
} else if (StartOf(9)) {
Type(
#line 834 "cs.ATG"
out type);
#line 834 "cs.ATG"
Location startPos = t.Location;
if (la.kind == 91) {
#line 836 "cs.ATG"
OverloadableOperatorType op;
m.Check(Modifiers.Operators);
if (m.isNone) Error("at least one modifier must be set");
lexer.NextToken();
OverloadableOperator(
#line 840 "cs.ATG"
out op);
#line 840 "cs.ATG"
TypeReference firstType, secondType = null; string secondName = null;
Expect(20);
Type(
#line 841 "cs.ATG"
out firstType);
Expect(1);
#line 841 "cs.ATG"
string firstName = t.val;
if (la.kind == 14) {
lexer.NextToken();
Type(
#line 842 "cs.ATG"
out secondType);
Expect(1);
#line 842 "cs.ATG"
secondName = t.val;
} else if (la.kind == 21) {
} else SynErr(144);
#line 850 "cs.ATG"
Location endPos = t.Location;
Expect(21);
if (la.kind == 16) {
Block(
#line 851 "cs.ATG"
out stmt);
} else if (la.kind == 11) {
lexer.NextToken();
} else SynErr(145);
#line 853 "cs.ATG"
List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
parameters.Add(new ParameterDeclarationExpression(firstType, firstName));
if (secondType != null) {
parameters.Add(new ParameterDeclarationExpression(secondType, secondName));
}
OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier,
attributes,
parameters,
type,
op);
operatorDeclaration.Body = (BlockStatement)stmt;
operatorDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
operatorDeclaration.EndLocation = endPos;
compilationUnit.AddChild(operatorDeclaration);
} else if (
#line 870 "cs.ATG"
IsVarDecl()) {
#line 871 "cs.ATG"
m.Check(Modifiers.Fields);
FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
fd.StartLocation = m.GetDeclarationLocation(startPos);
if (
#line 875 "cs.ATG"
m.Contains(Modifiers.Fixed)) {
VariableDeclarator(
#line 876 "cs.ATG"
variableDeclarators);
Expect(18);
Expr(
#line 878 "cs.ATG"
out expr);
#line 878 "cs.ATG"
if (variableDeclarators.Count > 0)
variableDeclarators[variableDeclarators.Count-1].FixedArrayInitialization = expr;
Expect(19);
while (la.kind == 14) {
lexer.NextToken();
VariableDeclarator(
#line 882 "cs.ATG"
variableDeclarators);
Expect(18);
Expr(
#line 884 "cs.ATG"
out expr);
#line 884 "cs.ATG"
if (variableDeclarators.Count > 0)
variableDeclarators[variableDeclarators.Count-1].FixedArrayInitialization = expr;
Expect(19);
}
} else if (la.kind == 1) {
VariableDeclarator(
#line 889 "cs.ATG"
variableDeclarators);
while (la.kind == 14) {
lexer.NextToken();
VariableDeclarator(
#line 890 "cs.ATG"
variableDeclarators);
}
} else SynErr(146);
Expect(11);
#line 892 "cs.ATG"
fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd);
} else if (la.kind == 110) {
#line 895 "cs.ATG"
m.Check(Modifiers.Indexers);
lexer.NextToken();
Expect(18);
FormalParameterList(
#line 896 "cs.ATG"
p);
Expect(19);
#line 896 "cs.ATG"
Location endLocation = t.EndLocation;
Expect(16);
#line 897 "cs.ATG"
IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes);
indexer.StartLocation = startPos;
indexer.EndLocation = endLocation;
indexer.BodyStart = t.Location;
PropertyGetRegion getRegion;
PropertySetRegion setRegion;
AccessorDecls(
#line 904 "cs.ATG"
out getRegion, out setRegion);
Expect(17);
#line 905 "cs.ATG"
indexer.BodyEnd = t.EndLocation;
indexer.GetRegion = getRegion;
indexer.SetRegion = setRegion;
compilationUnit.AddChild(indexer);
} else if (
#line 910 "cs.ATG"
la.kind == Tokens.Identifier) {
if (
#line 911 "cs.ATG"
IsExplicitInterfaceImplementation()) {
TypeName(
#line 912 "cs.ATG"
out explicitInterface, false);
#line 913 "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 916 "cs.ATG"
qualident = t.val;
} else SynErr(147);
#line 918 "cs.ATG"
Location qualIdentEndLocation = t.EndLocation;
if (la.kind == 16 || la.kind == 20 || la.kind == 23) {
if (la.kind == 20 || la.kind == 23) {
#line 922 "cs.ATG"
m.Check(Modifiers.PropertysEventsMethods);
if (la.kind == 23) {
TypeParameterList(
#line 924 "cs.ATG"
templates);
}
Expect(20);
if (StartOf(10)) {
FormalParameterList(
#line 925 "cs.ATG"
p);
}
Expect(21);
#line 926 "cs.ATG"
MethodDeclaration methodDeclaration = new MethodDeclaration(qualident,
m.Modifier,
type,
p,
attributes);
if (explicitInterface != null)
methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident));
methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
methodDeclaration.EndLocation = t.EndLocation;
methodDeclaration.Templates = templates;
compilationUnit.AddChild(methodDeclaration);
while (
#line 938 "cs.ATG"
IdentIsWhere()) {
TypeParameterConstraintsClause(
#line 938 "cs.ATG"
templates);
}
if (la.kind == 16) {
Block(
#line 939 "cs.ATG"
out stmt);
} else if (la.kind == 11) {
lexer.NextToken();
} else SynErr(148);
#line 939 "cs.ATG"
methodDeclaration.Body = (BlockStatement)stmt;
} else {
lexer.NextToken();
#line 942 "cs.ATG"
PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes);
if (explicitInterface != null)
pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident));
pDecl.StartLocation = m.GetDeclarationLocation(startPos);
pDecl.EndLocation = qualIdentEndLocation;
pDecl.BodyStart = t.Location;
PropertyGetRegion getRegion;
PropertySetRegion setRegion;
AccessorDecls(
#line 951 "cs.ATG"
out getRegion, out setRegion);
Expect(17);
#line 953 "cs.ATG"
pDecl.GetRegion = getRegion;
pDecl.SetRegion = setRegion;
pDecl.BodyEnd = t.EndLocation;
compilationUnit.AddChild(pDecl);
}
} else if (la.kind == 15) {
#line 961 "cs.ATG"
m.Check(Modifiers.Indexers);
lexer.NextToken();
Expect(110);
Expect(18);
FormalParameterList(
#line 962 "cs.ATG"
p);
Expect(19);
#line 963 "cs.ATG"
IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes);
indexer.StartLocation = m.GetDeclarationLocation(startPos);
indexer.EndLocation = t.EndLocation;
if (explicitInterface != null)
indexer.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, "this"));
PropertyGetRegion getRegion;
PropertySetRegion setRegion;
Expect(16);
#line 971 "cs.ATG"
Location bodyStart = t.Location;
AccessorDecls(
#line 972 "cs.ATG"
out getRegion, out setRegion);
Expect(17);
#line 973 "cs.ATG"
indexer.BodyStart = bodyStart;
indexer.BodyEnd = t.EndLocation;
indexer.GetRegion = getRegion;
indexer.SetRegion = setRegion;
compilationUnit.AddChild(indexer);
} else SynErr(149);
} else SynErr(150);
} else SynErr(151);
}
void InterfaceMemberDecl() {
#line 1000 "cs.ATG"
TypeReference type;
AttributeSection section;
Modifiers mod = Modifiers.None;
List<AttributeSection> attributes = new List<AttributeSection>();
List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
string name;
PropertyGetRegion getBlock;
PropertySetRegion setBlock;
Location startLocation = new Location(-1, -1);
List<TemplateDefinition> templates = new List<TemplateDefinition>();
while (la.kind == 18) {
AttributeSection(
#line 1013 "cs.ATG"
out section);
#line 1013 "cs.ATG"
attributes.Add(section);
}
if (la.kind == 88) {
lexer.NextToken();
#line 1014 "cs.ATG"
mod = Modifiers.New; startLocation = t.Location;
}
if (
#line 1017 "cs.ATG"
NotVoidPointer()) {
Expect(122);
#line 1017 "cs.ATG"
if (startLocation.X == -1) startLocation = t.Location;
Expect(1);
#line 1017 "cs.ATG"
name = t.val;
if (la.kind == 23) {
TypeParameterList(
#line 1018 "cs.ATG"
templates);
}
Expect(20);
if (StartOf(10)) {
FormalParameterList(
#line 1019 "cs.ATG"
parameters);
}
Expect(21);
while (
#line 1020 "cs.ATG"
IdentIsWhere()) {
TypeParameterConstraintsClause(
#line 1020 "cs.ATG"
templates);
}
Expect(11);
#line 1022 "cs.ATG"
MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes);
md.StartLocation = startLocation;
md.EndLocation = t.EndLocation;
md.Templates = templates;
compilationUnit.AddChild(md);
} else if (StartOf(18)) {
if (StartOf(9)) {
Type(
#line 1029 "cs.ATG"
out type);
#line 1029 "cs.ATG"
if (startLocation.X == -1) startLocation = t.Location;
if (la.kind == 1) {
lexer.NextToken();
#line 1031 "cs.ATG"
name = t.val; Location qualIdentEndLocation = t.EndLocation;
if (la.kind == 20 || la.kind == 23) {
if (la.kind == 23) {
TypeParameterList(
#line 1035 "cs.ATG"
templates);
}
Expect(20);
if (StartOf(10)) {
FormalParameterList(
#line 1036 "cs.ATG"
parameters);
}
Expect(21);
while (
#line 1038 "cs.ATG"
IdentIsWhere()) {
TypeParameterConstraintsClause(
#line 1038 "cs.ATG"
templates);
}
Expect(11);
#line 1039 "cs.ATG"
MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes);
md.StartLocation = startLocation;
md.EndLocation = t.EndLocation;
md.Templates = templates;
compilationUnit.AddChild(md);
} else if (la.kind == 16) {
#line 1046 "cs.ATG"
PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd);
lexer.NextToken();
#line 1047 "cs.ATG"
Location bodyStart = t.Location;
InterfaceAccessors(
#line 1047 "cs.ATG"
out getBlock, out setBlock);
Expect(17);
#line 1047 "cs.ATG"
pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation;
} else SynErr(152);
} else if (la.kind == 110) {
lexer.NextToken();
Expect(18);
FormalParameterList(
#line 1050 "cs.ATG"
parameters);
Expect(19);
#line 1050 "cs.ATG"
Location bracketEndLocation = t.EndLocation;
#line 1050 "cs.ATG"
IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id);
Expect(16);
#line 1051 "cs.ATG"
Location bodyStart = t.Location;
InterfaceAccessors(
#line 1051 "cs.ATG"
out getBlock, out setBlock);
Expect(17);
#line 1051 "cs.ATG"
id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;
} else SynErr(153);
} else {
lexer.NextToken();
#line 1054 "cs.ATG"
if (startLocation.X == -1) startLocation = t.Location;
Type(
#line 1054 "cs.ATG"
out type);
Expect(1);
#line 1054 "cs.ATG"
EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes, null);
compilationUnit.AddChild(ed);
Expect(11);
#line 1057 "cs.ATG"
ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation;
}
} else SynErr(154);
}
void EnumMemberDecl(
#line 1062 "cs.ATG"
out FieldDeclaration f) {
#line 1064 "cs.ATG"
Expression expr = null;
List<AttributeSection> attributes = new List<AttributeSection>();
AttributeSection section = null;
VariableDeclaration varDecl = null;
while (la.kind == 18) {
AttributeSection(
#line 1070 "cs.ATG"
out section);
#line 1070 "cs.ATG"
attributes.Add(section);
}
Expect(1);
#line 1071 "cs.ATG"
f = new FieldDeclaration(attributes);
varDecl = new VariableDeclaration(t.val);
f.Fields.Add(varDecl);
f.StartLocation = t.Location;
if (la.kind == 3) {
lexer.NextToken();
Expr(
#line 1076 "cs.ATG"
out expr);
#line 1076 "cs.ATG"
varDecl.Initializer = expr;
}
}
void TypeWithRestriction(
#line 523 "cs.ATG"
out TypeReference type, bool allowNullable, bool canBeUnbound) {
#line 525 "cs.ATG"
string name;
int pointer = 0;
type = null;
if (la.kind == 1 || la.kind == 90 || la.kind == 107) {
ClassType(
#line 530 "cs.ATG"
out type, canBeUnbound);
} else if (StartOf(4)) {
SimpleType(
#line 531 "cs.ATG"
out name);
#line 531 "cs.ATG"
type = new TypeReference(name);
} else if (la.kind == 122) {
lexer.NextToken();
Expect(6);
#line 532 "cs.ATG"
pointer = 1; type = new TypeReference("void");
} else SynErr(155);
#line 533 "cs.ATG"
List<int> r = new List<int>();
if (
#line 535 "cs.ATG"
allowNullable && la.kind == Tokens.Question) {
NullableQuestionMark(
#line 535 "cs.ATG"
ref type);
}
while (
#line 537 "cs.ATG"
IsPointerOrDims()) {
#line 537 "cs.ATG"
int i = 0;
if (la.kind == 6) {
lexer.NextToken();
#line 538 "cs.ATG"
++pointer;
} else if (la.kind == 18) {
lexer.NextToken();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -