?? parser.cs
字號:
}
#line 664 "cs.ATG"
node.EndLocation = t.EndLocation;
compilationUnit.BlockEnd();
} else if (StartOf(2)) {
while (la.kind == 16) {
AttributeSection(
#line 668 "cs.ATG"
out section);
#line 668 "cs.ATG"
attributes.Add(section);
}
while (StartOf(3)) {
TypeModifier(
#line 669 "cs.ATG"
m);
}
TypeDecl(
#line 670 "cs.ATG"
m, attributes);
} else SynErr(126);
}
void Qualident(
#line 755 "cs.ATG"
out string qualident) {
Expect(1);
#line 757 "cs.ATG"
StringBuilder qualidentBuilder = new StringBuilder(t.val);
while (
#line 758 "cs.ATG"
DotAndIdent()) {
Expect(13);
Expect(1);
#line 758 "cs.ATG"
qualidentBuilder.Append('.');
qualidentBuilder.Append(t.val);
}
#line 761 "cs.ATG"
qualident = qualidentBuilder.ToString();
}
void Attribute(
#line 573 "cs.ATG"
out ICSharpCode.SharpRefactory.Parser.AST.Attribute attribute) {
#line 574 "cs.ATG"
string qualident;
Qualident(
#line 576 "cs.ATG"
out qualident);
#line 576 "cs.ATG"
ArrayList positional = new ArrayList();
ArrayList named = new ArrayList();
string name = qualident;
if (la.kind == 18) {
AttributeArguments(
#line 580 "cs.ATG"
ref positional, ref named);
}
#line 580 "cs.ATG"
attribute = new ICSharpCode.SharpRefactory.Parser.AST.Attribute(name, positional, named);
}
void AttributeArguments(
#line 583 "cs.ATG"
ref ArrayList positional, ref ArrayList named) {
#line 585 "cs.ATG"
bool nameFound = false;
string name = "";
Expression expr;
Expect(18);
if (StartOf(4)) {
if (
#line 593 "cs.ATG"
IsAssignment()) {
#line 593 "cs.ATG"
nameFound = true;
lexer.NextToken();
#line 594 "cs.ATG"
name = t.val;
Expect(3);
}
Expr(
#line 596 "cs.ATG"
out expr);
#line 596 "cs.ATG"
if(name == "") positional.Add(expr);
else { named.Add(new NamedArgument(name, expr)); name = ""; }
while (la.kind == 12) {
lexer.NextToken();
if (
#line 603 "cs.ATG"
IsAssignment()) {
#line 603 "cs.ATG"
nameFound = true;
Expect(1);
#line 604 "cs.ATG"
name = t.val;
Expect(3);
} else if (StartOf(4)) {
#line 606 "cs.ATG"
if (nameFound) Error("no positional argument after named argument");
} else SynErr(127);
Expr(
#line 607 "cs.ATG"
out expr);
#line 607 "cs.ATG"
if(name == "") positional.Add(expr);
else { named.Add(new NamedArgument(name, expr)); name = ""; }
}
}
Expect(19);
}
void Expr(
#line 1722 "cs.ATG"
out Expression expr) {
#line 1723 "cs.ATG"
expr = null; Expression expr1 = null, expr2 = null;
UnaryExpr(
#line 1725 "cs.ATG"
out expr);
if (StartOf(5)) {
ConditionalOrExpr(
#line 1728 "cs.ATG"
ref expr);
if (la.kind == 11) {
lexer.NextToken();
Expr(
#line 1728 "cs.ATG"
out expr1);
Expect(9);
Expr(
#line 1728 "cs.ATG"
out expr2);
#line 1728 "cs.ATG"
expr = new ConditionalExpression(expr, expr1, expr2);
}
} else if (StartOf(6)) {
#line 1730 "cs.ATG"
AssignmentOperatorType op; Expression val;
AssignmentOperator(
#line 1730 "cs.ATG"
out op);
Expr(
#line 1730 "cs.ATG"
out val);
#line 1730 "cs.ATG"
expr = new AssignmentExpression(expr, op, val);
} else SynErr(128);
}
void AttributeSection(
#line 615 "cs.ATG"
out AttributeSection section) {
#line 617 "cs.ATG"
string attributeTarget = "";
ArrayList attributes = new ArrayList();
ICSharpCode.SharpRefactory.Parser.AST.Attribute attribute;
Expect(16);
#line 623 "cs.ATG"
Point startPos = t.Location;
if (
#line 624 "cs.ATG"
IsLocalAttrTarget()) {
if (la.kind == 68) {
lexer.NextToken();
#line 625 "cs.ATG"
attributeTarget = "event";
} else if (la.kind == 100) {
lexer.NextToken();
#line 626 "cs.ATG"
attributeTarget = "return";
} else {
lexer.NextToken();
#line 627 "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 637 "cs.ATG"
out attribute);
#line 637 "cs.ATG"
attributes.Add(attribute);
while (
#line 638 "cs.ATG"
NotFinalComma()) {
Expect(12);
Attribute(
#line 638 "cs.ATG"
out attribute);
#line 638 "cs.ATG"
attributes.Add(attribute);
}
if (la.kind == 12) {
lexer.NextToken();
}
Expect(17);
#line 640 "cs.ATG"
section = new AttributeSection(attributeTarget, attributes);
section.StartLocation = startPos;
section.EndLocation = t.EndLocation;
}
void TypeModifier(
#line 926 "cs.ATG"
Modifiers m) {
switch (la.kind) {
case 88: {
lexer.NextToken();
#line 928 "cs.ATG"
m.Add(Modifier.New);
break;
}
case 97: {
lexer.NextToken();
#line 929 "cs.ATG"
m.Add(Modifier.Public);
break;
}
case 96: {
lexer.NextToken();
#line 930 "cs.ATG"
m.Add(Modifier.Protected);
break;
}
case 83: {
lexer.NextToken();
#line 931 "cs.ATG"
m.Add(Modifier.Internal);
break;
}
case 95: {
lexer.NextToken();
#line 932 "cs.ATG"
m.Add(Modifier.Private);
break;
}
case 118: {
lexer.NextToken();
#line 933 "cs.ATG"
m.Add(Modifier.Unsafe);
break;
}
case 48: {
lexer.NextToken();
#line 934 "cs.ATG"
m.Add(Modifier.Abstract);
break;
}
case 102: {
lexer.NextToken();
#line 935 "cs.ATG"
m.Add(Modifier.Sealed);
break;
}
default: SynErr(129); break;
}
}
void TypeDecl(
#line 673 "cs.ATG"
Modifiers m, ArrayList attributes) {
#line 675 "cs.ATG"
TypeReference type;
StringCollection names;
ArrayList p; string name;
if (la.kind == 58) {
#line 679 "cs.ATG"
m.Check(Modifier.Classes);
lexer.NextToken();
#line 680 "cs.ATG"
TypeDeclaration newType = new TypeDeclaration();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Class;
newType.Modifier = m.Modifier;
newType.Attributes = attributes;
Expect(1);
#line 688 "cs.ATG"
newType.Name = t.val;
if (la.kind == 9) {
ClassBase(
#line 689 "cs.ATG"
out names);
#line 689 "cs.ATG"
newType.BaseTypes = names;
}
#line 689 "cs.ATG"
newType.StartLocation = t.EndLocation;
ClassBody();
if (la.kind == 10) {
lexer.NextToken();
}
#line 691 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else if (StartOf(7)) {
#line 694 "cs.ATG"
m.Check(Modifier.StructsInterfacesEnumsDelegates);
if (la.kind == 108) {
lexer.NextToken();
#line 695 "cs.ATG"
TypeDeclaration newType = new TypeDeclaration();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Struct;
newType.Modifier = m.Modifier;
newType.Attributes = attributes;
Expect(1);
#line 702 "cs.ATG"
newType.Name = t.val;
if (la.kind == 9) {
StructInterfaces(
#line 703 "cs.ATG"
out names);
#line 703 "cs.ATG"
newType.BaseTypes = names;
}
#line 703 "cs.ATG"
newType.StartLocation = t.EndLocation;
StructBody();
if (la.kind == 10) {
lexer.NextToken();
}
#line 705 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else if (la.kind == 82) {
lexer.NextToken();
#line 709 "cs.ATG"
TypeDeclaration newType = new TypeDeclaration();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Interface;
newType.Attributes = attributes;
newType.Modifier = m.Modifier;
Expect(1);
#line 715 "cs.ATG"
newType.Name = t.val;
if (la.kind == 9) {
InterfaceBase(
#line 716 "cs.ATG"
out names);
#line 716 "cs.ATG"
newType.BaseTypes = names;
}
#line 716 "cs.ATG"
newType.StartLocation = t.EndLocation;
InterfaceBody();
if (la.kind == 10) {
lexer.NextToken();
}
#line 718 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else if (la.kind == 67) {
lexer.NextToken();
#line 722 "cs.ATG"
TypeDeclaration newType = new TypeDeclaration();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Enum;
newType.Attributes = attributes;
newType.Modifier = m.Modifier;
Expect(1);
#line 728 "cs.ATG"
newType.Name = t.val;
if (la.kind == 9) {
lexer.NextToken();
IntegralType(
#line 729 "cs.ATG"
out name);
#line 729 "cs.ATG"
newType.BaseTypes = new StringCollection();
newType.BaseTypes.Add(name);
}
#line 732 "cs.ATG"
newType.StartLocation = t.EndLocation;
EnumBody();
if (la.kind == 10) {
lexer.NextToken();
}
#line 734 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else {
lexer.NextToken();
#line 738 "cs.ATG"
DelegateDeclaration delegateDeclr = new DelegateDeclaration();
delegateDeclr.StartLocation = t.Location;
delegateDeclr.Modifier = m.Modifier;
delegateDeclr.Attributes = attributes;
if (
#line 743 "cs.ATG"
NotVoidPointer()) {
Expect(122);
#line 743 "cs.ATG"
delegateDeclr.ReturnType = new TypeReference("void", 0, null);
} else if (StartOf(8)) {
Type(
#line 744 "cs.ATG"
out type);
#line 744 "cs.ATG"
delegateDeclr.ReturnType = type;
} else SynErr(130);
Expect(1);
#line 746 "cs.ATG"
delegateDeclr.Name = t.val;
Expect(18);
if (StartOf(9)) {
FormalParameterList(
#line 747 "cs.ATG"
out p);
#line 747 "cs.ATG"
delegateDeclr.Parameters = p;
}
Expect(19);
Expect(10);
#line 749 "cs.ATG"
delegateDeclr.EndLocation = t.Location;
compilationUnit.AddChild(delegateDeclr);
}
} else SynErr(131);
}
void ClassBase(
#line 764 "cs.ATG"
out StringCollection names) {
#line 766 "cs.ATG"
string qualident;
names = new StringCollection();
Expect(9);
ClassType(
#line 770 "cs.ATG"
out qualident);
#line 770 "cs.ATG"
names.Add(qualident);
while (la.kind == 12) {
lexer.NextToken();
Qualident(
#line 771 "cs.ATG"
out qualident);
#line 771 "cs.ATG"
names.Add(qualident);
}
}
void ClassBody() {
#line 775 "cs.ATG"
AttributeSection section;
Expect(14);
while (StartOf(10)) {
#line 778 "cs.ATG"
ArrayList attributes = new ArrayList();
Modifiers m = new Modifiers(this);
while (la.kind == 16) {
AttributeSection(
#line 781 "cs.ATG"
out section);
#line 781 "cs.ATG"
attributes.Add(section);
}
while (StartOf(11)) {
MemberModifier(
#line 782 "cs.ATG"
m);
}
ClassMemberDecl(
#line 783 "cs.ATG"
m, attributes);
}
Expect(15);
}
void StructInterfaces(
#line 788 "cs.ATG"
out StringCollection names) {
#line 790 "cs.ATG"
string qualident;
names = new StringCollection();
Expect(9);
Qualident(
#line 794 "cs.ATG"
out qualident);
#line 794 "cs.ATG"
names.Add(qualident);
while (la.kind == 12) {
lexer.NextToken();
Qualident(
#line 795 "cs.ATG"
out qualident);
#line 795 "cs.ATG"
names.Add(qualident);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -