📄 parser.cs
字号:
Expect(14);
while (la.kind == 120) {
UsingDirective();
}
while (StartOf(1)) {
NamespaceMemberDecl();
}
Expect(15);
if (la.kind == 10) {
lexer.NextToken();
}
#line 665 "cs.ATG"
node.EndLocation = t.EndLocation;
compilationUnit.BlockEnd();
} else if (StartOf(2)) {
while (la.kind == 16) {
AttributeSection(
#line 669 "cs.ATG"
out section);
#line 669 "cs.ATG"
attributes.Add(section);
}
while (StartOf(3)) {
TypeModifier(
#line 670 "cs.ATG"
m);
}
TypeDecl(
#line 671 "cs.ATG"
m, attributes);
} else SynErr(126);
}
void Qualident(
#line 748 "cs.ATG"
out string qualident) {
Expect(1);
#line 750 "cs.ATG"
StringBuilder qualidentBuilder = new StringBuilder(t.val);
while (
#line 751 "cs.ATG"
DotAndIdent()) {
Expect(13);
Expect(1);
#line 751 "cs.ATG"
qualidentBuilder.Append('.');
qualidentBuilder.Append(t.val);
}
#line 754 "cs.ATG"
qualident = qualidentBuilder.ToString();
}
void Attribute(
#line 574 "cs.ATG"
out ICSharpCode.CsVbRefactory.Parser.AST.Attribute attribute) {
#line 575 "cs.ATG"
string qualident;
Qualident(
#line 577 "cs.ATG"
out qualident);
#line 577 "cs.ATG"
List<Expression> positional = new List<Expression>();
List<NamedArgument> named = new List<NamedArgument>();
string name = qualident;
if (la.kind == 18) {
AttributeArguments(
#line 581 "cs.ATG"
ref positional, ref named);
}
#line 581 "cs.ATG"
attribute = new ICSharpCode.CsVbRefactory.Parser.AST.Attribute(name, positional, named);
}
void AttributeArguments(
#line 584 "cs.ATG"
ref List<Expression> positional, ref List<NamedArgument> named) {
#line 586 "cs.ATG"
bool nameFound = false;
string name = "";
Expression expr;
Expect(18);
if (StartOf(4)) {
if (
#line 594 "cs.ATG"
IsAssignment()) {
#line 594 "cs.ATG"
nameFound = true;
lexer.NextToken();
#line 595 "cs.ATG"
name = t.val;
Expect(3);
}
Expr(
#line 597 "cs.ATG"
out expr);
#line 597 "cs.ATG"
if(name == "") positional.Add(expr);
else { named.Add(new NamedArgument(name, expr)); name = ""; }
while (la.kind == 12) {
lexer.NextToken();
if (
#line 604 "cs.ATG"
IsAssignment()) {
#line 604 "cs.ATG"
nameFound = true;
Expect(1);
#line 605 "cs.ATG"
name = t.val;
Expect(3);
} else if (StartOf(4)) {
#line 607 "cs.ATG"
if (nameFound) Error("no positional argument after named argument");
} else SynErr(127);
Expr(
#line 608 "cs.ATG"
out expr);
#line 608 "cs.ATG"
if(name == "") positional.Add(expr);
else { named.Add(new NamedArgument(name, expr)); name = ""; }
}
}
Expect(19);
}
void Expr(
#line 1723 "cs.ATG"
out Expression expr) {
#line 1724 "cs.ATG"
expr = null; Expression expr1 = null, expr2 = null;
UnaryExpr(
#line 1726 "cs.ATG"
out expr);
if (StartOf(5)) {
ConditionalOrExpr(
#line 1729 "cs.ATG"
ref expr);
if (la.kind == 11) {
lexer.NextToken();
Expr(
#line 1729 "cs.ATG"
out expr1);
Expect(9);
Expr(
#line 1729 "cs.ATG"
out expr2);
#line 1729 "cs.ATG"
expr = new ConditionalExpression(expr, expr1, expr2);
}
} else if (StartOf(6)) {
#line 1731 "cs.ATG"
AssignmentOperatorType op; Expression val;
AssignmentOperator(
#line 1731 "cs.ATG"
out op);
Expr(
#line 1731 "cs.ATG"
out val);
#line 1731 "cs.ATG"
expr = new AssignmentExpression(expr, op, val);
} else SynErr(128);
}
void AttributeSection(
#line 616 "cs.ATG"
out AttributeSection section) {
#line 618 "cs.ATG"
string attributeTarget = "";
List<ICSharpCode.CsVbRefactory.Parser.AST.Attribute> attributes = new List<ICSharpCode.CsVbRefactory.Parser.AST.Attribute>();
ICSharpCode.CsVbRefactory.Parser.AST.Attribute attribute;
Expect(16);
#line 624 "cs.ATG"
Point startPos = t.Location;
if (
#line 625 "cs.ATG"
IsLocalAttrTarget()) {
if (la.kind == 68) {
lexer.NextToken();
#line 626 "cs.ATG"
attributeTarget = "event";
} else if (la.kind == 100) {
lexer.NextToken();
#line 627 "cs.ATG"
attributeTarget = "return";
} else {
lexer.NextToken();
#line 628 "cs.ATG"
if (t.val != "field" || t.val != "method" ||
t.val != "module" || t.val != "param" ||
t.val != "property" || t.val != "type")
Error("attribute target specifier (event, return, field," +
"method, module, param, property, or type) expected");
attributeTarget = t.val;
}
Expect(9);
}
Attribute(
#line 638 "cs.ATG"
out attribute);
#line 638 "cs.ATG"
attributes.Add(attribute);
while (
#line 639 "cs.ATG"
NotFinalComma()) {
Expect(12);
Attribute(
#line 639 "cs.ATG"
out attribute);
#line 639 "cs.ATG"
attributes.Add(attribute);
}
if (la.kind == 12) {
lexer.NextToken();
}
Expect(17);
#line 641 "cs.ATG"
section = new AttributeSection(attributeTarget, attributes);
section.StartLocation = startPos;
section.EndLocation = t.EndLocation;
}
void TypeModifier(
#line 919 "cs.ATG"
Modifiers m) {
switch (la.kind) {
case 88: {
lexer.NextToken();
#line 921 "cs.ATG"
m.Add(Modifier.New);
break;
}
case 97: {
lexer.NextToken();
#line 922 "cs.ATG"
m.Add(Modifier.Public);
break;
}
case 96: {
lexer.NextToken();
#line 923 "cs.ATG"
m.Add(Modifier.Protected);
break;
}
case 83: {
lexer.NextToken();
#line 924 "cs.ATG"
m.Add(Modifier.Internal);
break;
}
case 95: {
lexer.NextToken();
#line 925 "cs.ATG"
m.Add(Modifier.Private);
break;
}
case 118: {
lexer.NextToken();
#line 926 "cs.ATG"
m.Add(Modifier.Unsafe);
break;
}
case 48: {
lexer.NextToken();
#line 927 "cs.ATG"
m.Add(Modifier.Abstract);
break;
}
case 102: {
lexer.NextToken();
#line 928 "cs.ATG"
m.Add(Modifier.Sealed);
break;
}
default: SynErr(129); break;
}
}
void TypeDecl(
#line 674 "cs.ATG"
Modifiers m, List<AttributeSection> attributes) {
#line 676 "cs.ATG"
TypeReference type;
StringCollection names;
List<ParameterDeclarationExpression> p; string name;
if (la.kind == 58) {
#line 680 "cs.ATG"
m.Check(Modifier.Classes);
lexer.NextToken();
#line 681 "cs.ATG"
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Class;
Expect(1);
#line 687 "cs.ATG"
newType.Name = t.val;
if (la.kind == 9) {
ClassBase(
#line 688 "cs.ATG"
out names);
#line 688 "cs.ATG"
newType.BaseTypes = names;
}
#line 688 "cs.ATG"
newType.StartLocation = t.EndLocation;
ClassBody();
if (la.kind == 10) {
lexer.NextToken();
}
#line 690 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else if (StartOf(7)) {
#line 693 "cs.ATG"
m.Check(Modifier.StructsInterfacesEnumsDelegates);
if (la.kind == 108) {
lexer.NextToken();
#line 694 "cs.ATG"
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Struct;
Expect(1);
#line 699 "cs.ATG"
newType.Name = t.val;
if (la.kind == 9) {
StructInterfaces(
#line 700 "cs.ATG"
out names);
#line 700 "cs.ATG"
newType.BaseTypes = names;
}
#line 700 "cs.ATG"
newType.StartLocation = t.EndLocation;
StructBody();
if (la.kind == 10) {
lexer.NextToken();
}
#line 702 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else if (la.kind == 82) {
lexer.NextToken();
#line 706 "cs.ATG"
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Interface;
Expect(1);
#line 711 "cs.ATG"
newType.Name = t.val;
if (la.kind == 9) {
InterfaceBase(
#line 712 "cs.ATG"
out names);
#line 712 "cs.ATG"
newType.BaseTypes = names;
}
#line 712 "cs.ATG"
newType.StartLocation = t.EndLocation;
InterfaceBody();
if (la.kind == 10) {
lexer.NextToken();
}
#line 714 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else if (la.kind == 67) {
lexer.NextToken();
#line 718 "cs.ATG"
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Enum;
Expect(1);
#line 723 "cs.ATG"
newType.Name = t.val;
if (la.kind == 9) {
lexer.NextToken();
IntegralType(
#line 724 "cs.ATG"
out name);
#line 724 "cs.ATG"
newType.BaseTypes = new StringCollection();
newType.BaseTypes.Add(name);
}
#line 727 "cs.ATG"
newType.StartLocation = t.EndLocation;
EnumBody();
if (la.kind == 10) {
lexer.NextToken();
}
#line 729 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else {
lexer.NextToken();
#line 733 "cs.ATG"
DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
delegateDeclr.StartLocation = t.Location;
if (
#line 736 "cs.ATG"
NotVoidPointer()) {
Expect(122);
#line 736 "cs.ATG"
delegateDeclr.ReturnType = new TypeReference("void", 0, null);
} else if (StartOf(8)) {
Type(
#line 737 "cs.ATG"
out type);
#line 737 "cs.ATG"
delegateDeclr.ReturnType = type;
} else SynErr(130);
Expect(1);
#line 739 "cs.ATG"
delegateDeclr.Name = t.val;
Expect(18);
if (StartOf(9)) {
FormalParameterList(
#line 740 "cs.ATG"
out p);
#line 740 "cs.ATG"
delegateDeclr.Parameters = p;
}
Expect(19);
Expect(10);
#line 742 "cs.ATG"
delegateDeclr.EndLocation = t.Location;
compilationUnit.AddChild(delegateDeclr);
}
} else SynErr(131);
}
void ClassBase(
#line 757 "cs.ATG"
out StringCollection names) {
#line 759 "cs.ATG"
string qualident;
names = new StringCollection();
Expect(9);
ClassType(
#line 763 "cs.ATG"
out qualident);
#line 763 "cs.ATG"
names.Add(qualident);
while (la.kind == 12) {
lexer.NextToken();
Qualident(
#line 764 "cs.ATG"
out qualident);
#line 764 "cs.ATG"
names.Add(qualident);
}
}
void ClassBody() {
#line 768 "cs.ATG"
AttributeSection section;
Expect(14);
while (StartOf(10)) {
#line 771 "cs.ATG"
List<AttributeSection> attributes = new List<AttributeSection>();
Modifiers m = new Modifiers();
while (la.kind == 16) {
AttributeSection(
#line 774 "cs.ATG"
out section);
#line 774 "cs.ATG"
attributes.Add(section);
}
while (StartOf(11)) {
MemberModifier(
#line 775 "cs.ATG"
m);
}
ClassMemberDecl(
#line 776 "cs.ATG"
m, attributes);
}
Expect(15);
}
void StructInterfaces(
#line 781 "cs.ATG"
out StringCollection names) {
#line 783 "cs.ATG"
string qualident;
names = new StringCollection();
Expect(9);
Qualident(
#line 787 "cs.ATG"
out qualident);
#line 787 "cs.ATG"
names.Add(qualident);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -