📄 parser.cs
字号:
void StructBody() {
#line 799 "cs.ATG"
AttributeSection section;
Expect(14);
while (StartOf(12)) {
#line 802 "cs.ATG"
ArrayList attributes = new ArrayList();
Modifiers m = new Modifiers(this);
while (la.kind == 16) {
AttributeSection(
#line 805 "cs.ATG"
out section);
#line 805 "cs.ATG"
attributes.Add(section);
}
while (StartOf(11)) {
MemberModifier(
#line 806 "cs.ATG"
m);
}
StructMemberDecl(
#line 807 "cs.ATG"
m, attributes);
}
Expect(15);
}
void InterfaceBase(
#line 812 "cs.ATG"
out StringCollection names) {
#line 814 "cs.ATG"
string qualident;
names = new StringCollection();
Expect(9);
Qualident(
#line 818 "cs.ATG"
out qualident);
#line 818 "cs.ATG"
names.Add(qualident);
while (la.kind == 12) {
lexer.NextToken();
Qualident(
#line 819 "cs.ATG"
out qualident);
#line 819 "cs.ATG"
names.Add(qualident);
}
}
void InterfaceBody() {
Expect(14);
while (StartOf(13)) {
InterfaceMemberDecl();
}
Expect(15);
}
void IntegralType(
#line 945 "cs.ATG"
out string name) {
#line 945 "cs.ATG"
name = "";
switch (la.kind) {
case 101: {
lexer.NextToken();
#line 947 "cs.ATG"
name = "sbyte";
break;
}
case 53: {
lexer.NextToken();
#line 948 "cs.ATG"
name = "byte";
break;
}
case 103: {
lexer.NextToken();
#line 949 "cs.ATG"
name = "short";
break;
}
case 119: {
lexer.NextToken();
#line 950 "cs.ATG"
name = "ushort";
break;
}
case 81: {
lexer.NextToken();
#line 951 "cs.ATG"
name = "int";
break;
}
case 115: {
lexer.NextToken();
#line 952 "cs.ATG"
name = "uint";
break;
}
case 86: {
lexer.NextToken();
#line 953 "cs.ATG"
name = "long";
break;
}
case 116: {
lexer.NextToken();
#line 954 "cs.ATG"
name = "ulong";
break;
}
case 56: {
lexer.NextToken();
#line 955 "cs.ATG"
name = "char";
break;
}
default: SynErr(132); break;
}
}
void EnumBody() {
#line 825 "cs.ATG"
FieldDeclaration f;
Expect(14);
if (la.kind == 1 || la.kind == 16) {
EnumMemberDecl(
#line 827 "cs.ATG"
out f);
#line 827 "cs.ATG"
compilationUnit.AddChild(f);
while (
#line 828 "cs.ATG"
NotFinalComma()) {
Expect(12);
EnumMemberDecl(
#line 828 "cs.ATG"
out f);
#line 828 "cs.ATG"
compilationUnit.AddChild(f);
}
if (la.kind == 12) {
lexer.NextToken();
}
}
Expect(15);
}
void Type(
#line 833 "cs.ATG"
out TypeReference type) {
#line 835 "cs.ATG"
string name = "";
int pointer = 0;
if (la.kind == 1 || la.kind == 90 || la.kind == 107) {
ClassType(
#line 839 "cs.ATG"
out name);
} else if (StartOf(14)) {
SimpleType(
#line 840 "cs.ATG"
out name);
} else if (la.kind == 122) {
lexer.NextToken();
Expect(6);
#line 841 "cs.ATG"
pointer = 1; name = "void";
} else SynErr(133);
#line 842 "cs.ATG"
ArrayList r = new ArrayList();
while (
#line 843 "cs.ATG"
IsPointerOrDims()) {
#line 843 "cs.ATG"
int i = 1;
if (la.kind == 6) {
lexer.NextToken();
#line 844 "cs.ATG"
++pointer;
} else if (la.kind == 16) {
lexer.NextToken();
while (la.kind == 12) {
lexer.NextToken();
#line 845 "cs.ATG"
++i;
}
Expect(17);
#line 845 "cs.ATG"
r.Add(i);
} else SynErr(134);
}
#line 847 "cs.ATG"
int[] rank = new int[r.Count]; r.CopyTo(rank);
type = new TypeReference(name, pointer, rank);
}
void FormalParameterList(
#line 881 "cs.ATG"
out ArrayList parameter) {
#line 883 "cs.ATG"
parameter = new ArrayList();
ParameterDeclarationExpression p;
AttributeSection section;
ArrayList attributes = new ArrayList();
while (la.kind == 16) {
AttributeSection(
#line 889 "cs.ATG"
out section);
#line 889 "cs.ATG"
attributes.Add(section);
}
if (StartOf(15)) {
FixedParameter(
#line 891 "cs.ATG"
out p);
#line 891 "cs.ATG"
bool paramsFound = false;
p.Attributes = attributes;
parameter.Add(p);
while (la.kind == 12) {
lexer.NextToken();
#line 896 "cs.ATG"
attributes = new ArrayList(); if (paramsFound) Error("params array must be at end of parameter list");
while (la.kind == 16) {
AttributeSection(
#line 897 "cs.ATG"
out section);
#line 897 "cs.ATG"
attributes.Add(section);
}
if (StartOf(15)) {
FixedParameter(
#line 899 "cs.ATG"
out p);
#line 899 "cs.ATG"
p.Attributes = attributes; parameter.Add(p);
} else if (la.kind == 94) {
ParameterArray(
#line 900 "cs.ATG"
out p);
#line 900 "cs.ATG"
paramsFound = true; p.Attributes = attributes; parameter.Add(p);
} else SynErr(135);
}
} else if (la.kind == 94) {
ParameterArray(
#line 903 "cs.ATG"
out p);
#line 903 "cs.ATG"
p.Attributes = attributes; parameter.Add(p);
} else SynErr(136);
}
void ClassType(
#line 938 "cs.ATG"
out string name) {
#line 938 "cs.ATG"
string qualident; name = "";
if (la.kind == 1) {
Qualident(
#line 940 "cs.ATG"
out qualident);
#line 940 "cs.ATG"
name = qualident;
} else if (la.kind == 90) {
lexer.NextToken();
#line 941 "cs.ATG"
name = "object";
} else if (la.kind == 107) {
lexer.NextToken();
#line 942 "cs.ATG"
name = "string";
} else SynErr(137);
}
void MemberModifier(
#line 958 "cs.ATG"
Modifiers m) {
switch (la.kind) {
case 48: {
lexer.NextToken();
#line 960 "cs.ATG"
m.Add(Modifier.Abstract);
break;
}
case 70: {
lexer.NextToken();
#line 961 "cs.ATG"
m.Add(Modifier.Extern);
break;
}
case 83: {
lexer.NextToken();
#line 962 "cs.ATG"
m.Add(Modifier.Internal);
break;
}
case 88: {
lexer.NextToken();
#line 963 "cs.ATG"
m.Add(Modifier.New);
break;
}
case 93: {
lexer.NextToken();
#line 964 "cs.ATG"
m.Add(Modifier.Override);
break;
}
case 95: {
lexer.NextToken();
#line 965 "cs.ATG"
m.Add(Modifier.Private);
break;
}
case 96: {
lexer.NextToken();
#line 966 "cs.ATG"
m.Add(Modifier.Protected);
break;
}
case 97: {
lexer.NextToken();
#line 967 "cs.ATG"
m.Add(Modifier.Public);
break;
}
case 98: {
lexer.NextToken();
#line 968 "cs.ATG"
m.Add(Modifier.Readonly);
break;
}
case 102: {
lexer.NextToken();
#line 969 "cs.ATG"
m.Add(Modifier.Sealed);
break;
}
case 106: {
lexer.NextToken();
#line 970 "cs.ATG"
m.Add(Modifier.Static);
break;
}
case 118: {
lexer.NextToken();
#line 971 "cs.ATG"
m.Add(Modifier.Unsafe);
break;
}
case 121: {
lexer.NextToken();
#line 972 "cs.ATG"
m.Add(Modifier.Virtual);
break;
}
case 123: {
lexer.NextToken();
#line 973 "cs.ATG"
m.Add(Modifier.Volatile);
break;
}
default: SynErr(138); break;
}
}
void ClassMemberDecl(
#line 1185 "cs.ATG"
Modifiers m, ArrayList attributes) {
#line 1186 "cs.ATG"
Statement stmt = null;
if (StartOf(16)) {
StructMemberDecl(
#line 1188 "cs.ATG"
m, attributes);
} else if (la.kind == 25) {
#line 1189 "cs.ATG"
m.Check(Modifier.Destructors); Point startPos = t.Location;
lexer.NextToken();
Expect(1);
#line 1190 "cs.ATG"
DestructorDeclaration d = new DestructorDeclaration(t.val, attributes);
d.Modifier = m.Modifier;
d.StartLocation = startPos;
Expect(18);
Expect(19);
if (la.kind == 14) {
Block(
#line 1194 "cs.ATG"
out stmt);
} else if (la.kind == 10) {
lexer.NextToken();
} else SynErr(139);
#line 1194 "cs.ATG"
d.EndLocation = t.EndLocation;
d.Body = (BlockStatement)stmt;
compilationUnit.AddChild(d);
} else SynErr(140);
}
void StructMemberDecl(
#line 976 "cs.ATG"
Modifiers m, ArrayList attributes) {
#line 978 "cs.ATG"
string qualident = null;
TypeReference type;
Expression expr;
ArrayList p = new ArrayList();
Statement stmt = null;
ArrayList variableDeclarators = new ArrayList();
if (la.kind == 59) {
#line 986 "cs.ATG"
m.Check(Modifier.Constants);
lexer.NextToken();
#line 987 "cs.ATG"
Point startPos = t.Location;
Type(
#line 988 "cs.ATG"
out type);
Expect(1);
#line 988 "cs.ATG"
FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const);
fd.StartLocation = startPos;
VariableDeclaration f = new VariableDeclaration(t.val);
fd.Fields.Add(f);
Expect(3);
Expr(
#line 993 "cs.ATG"
out expr);
#line 993 "cs.ATG"
f.Initializer = expr;
while (la.kind == 12) {
lexer.NextToken();
Expect(1);
#line 994 "cs.ATG"
f = new VariableDeclaration(t.val);
fd.Fields.Add(f);
Expect(3);
Expr(
#line 997 "cs.ATG"
out expr);
#line 997 "cs.ATG"
f.Initializer = expr;
}
Expect(10);
#line 998 "cs.ATG"
fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd);
} else if (
#line 1001 "cs.ATG"
NotVoidPointer()) {
#line 1001 "cs.ATG"
m.Check(Modifier.PropertysEventsMethods);
Expect(122);
#line 1002 "cs.ATG"
Point startPos = t.Location;
Qualident(
#line 1003 "cs.ATG"
out qualident);
Expect(18);
if (StartOf(9)) {
FormalParameterList(
#line 1004 "cs.ATG"
out p);
}
Expect(19);
#line 1004 "cs.ATG"
MethodDeclaration methodDeclaration = new MethodDeclaration(qualident,
m.Modifier,
new TypeReference("void"),
p,
attributes);
methodDeclaration.StartLocation = startPos;
methodDeclaration.EndLocation = t.EndLocation;
compilationUnit.AddChild(methodDeclaration);
compilationUnit.BlockStart(methodDeclaration);
if (la.kind == 14) {
Block(
#line 1014 "cs.ATG"
out stmt);
} else if (la.kind == 10) {
lexer.NextToken();
} else SynErr(141);
#line 1014 "cs.ATG"
compilationUnit.BlockEnd();
methodDeclaration.Body = (BlockStatement)stmt;
} else if (la.kind == 68) {
#line 1018 "cs.ATG"
m.Check(Modifier.PropertysEventsMethods);
lexer.NextToken();
#line 1019 "cs.ATG"
EventDeclaration eventDecl = new EventDeclaration(m.Modifier, attributes);
eventDecl.StartLocation = t.Location;
compilationUnit.AddChild(eventDecl);
compilationUnit.BlockStart(eventDecl);
EventAddRegion addBlock = null;
EventRemoveRegion removeBlock = null;
Type(
#line 1026 "cs.ATG"
out type);
#line 1026 "cs.ATG"
eventDecl.TypeReference = type;
if (
#line 1028 "cs.ATG"
IsVarDecl()) {
VariableDeclarator(
#line 1028 "cs.ATG"
variableDeclarators);
while (la.kind == 12) {
lexer.NextToken();
VariableDeclarator(
#line 1029 "cs.ATG"
variableDeclarators);
}
Expect(10);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -