📄 cs.atg
字号:
.)
ident (. newType.Name = t.val; .)
[ StructInterfaces<out names> (. newType.BaseTypes = names; .) ] (. newType.StartLocation = t.EndLocation; .)
StructBody
[ ";" ] (. newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
.)
| /*--- interface declaration: */
"interface" (. TypeDeclaration newType = new TypeDeclaration();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Interface;
newType.Attributes = attributes;
newType.Modifier = m.Modifier;.)
ident (. newType.Name = t.val; .)
[ InterfaceBase<out names> (. newType.BaseTypes = names; .) ] (. newType.StartLocation = t.EndLocation; .)
InterfaceBody
[ ";" ] (. newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
.)
| /*--- enumeration declaration: */
"enum" (. TypeDeclaration newType = new TypeDeclaration();
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.Type = Types.Enum;
newType.Attributes = attributes;
newType.Modifier = m.Modifier;.)
ident (. newType.Name = t.val; .)
[ ":" IntegralType<out name> (. newType.BaseTypes = new StringCollection();
newType.BaseTypes.Add(name);
.)
] (. newType.StartLocation = t.EndLocation;
.)
EnumBody
[ ";" ] (. newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
.)
| /*--- delegate declaration: */
"delegate" (. DelegateDeclaration delegateDeclr = new DelegateDeclaration();
delegateDeclr.StartLocation = t.Location;
delegateDeclr.Modifier = m.Modifier;
delegateDeclr.Attributes = attributes;
.)
( IF (NotVoidPointer()) "void" (. delegateDeclr.ReturnType = new TypeReference("void", 0, null); .)
| Type<out type> (. delegateDeclr.ReturnType = type; .)
)
ident (. delegateDeclr.Name = t.val; .)
"(" [ FormalParameterList<out p> (. delegateDeclr.Parameters = p; .)
] ")"
";" (. delegateDeclr.EndLocation = t.Location;
compilationUnit.AddChild(delegateDeclr);
.)
)
.
Qualident<out string qualident>
=
ident (. StringBuilder qualidentBuilder = new StringBuilder(t.val); .)
{ IF (DotAndIdent()) "." ident (. qualidentBuilder.Append('.');
qualidentBuilder.Append(t.val);
.)
} (. qualident = qualidentBuilder.ToString(); .)
.
ClassBase<out StringCollection names>
(.
string qualident;
names = new StringCollection();
.)
=
":" ClassType<out qualident> (. names.Add(qualident); .)
{ "," Qualident<out qualident> (. names.Add(qualident); .) }
.
ClassBody
(. AttributeSection section; .)
=
"{"
{ (.ArrayList attributes = new ArrayList();
Modifiers m = new Modifiers(this);
.)
{ AttributeSection<out section> (. attributes.Add(section); .) }
{ MemberModifier<m> }
ClassMemberDecl<m, attributes>
}
"}"
.
StructInterfaces<out StringCollection names>
(.
string qualident;
names = new StringCollection();
.)
=
":" Qualident<out qualident> (. names.Add(qualident); .)
{ "," Qualident<out qualident> (. names.Add(qualident); .) }
.
StructBody
(. AttributeSection section; .)
=
"{"
{ (.ArrayList attributes = new ArrayList();
Modifiers m = new Modifiers(this);
.)
{ AttributeSection<out section> (. attributes.Add(section); .) }
{ MemberModifier<m> }
StructMemberDecl<m, attributes>
}
"}"
.
InterfaceBase<out StringCollection names>
(.
string qualident;
names = new StringCollection();
.)
=
":" Qualident<out qualident> (. names.Add(qualident); .)
{ "," Qualident<out qualident> (. names.Add(qualident); .) }
.
InterfaceBody
= "{" { InterfaceMemberDecl } "}" .
EnumBody (. FieldDeclaration f; .)
=
"{" [ EnumMemberDecl<out f> (. compilationUnit.AddChild(f); .)
{ IF (NotFinalComma()) "," EnumMemberDecl<out f> (. compilationUnit.AddChild(f); .)
}
[","] ] "}"
.
Type<out TypeReference type>
(.
string name = "";
int pointer = 0;
.)
=
( ClassType<out name>
| SimpleType<out name>
| "void" "*" (. pointer = 1; name = "void"; .)
) (. ArrayList r = new ArrayList(); .)
{ IF (IsPointerOrDims()) (. int i = 1; .)
( "*" (. ++pointer; .)
| "[" { "," (. ++i; .) } "]" (. r.Add(i); .)
)
} (. int[] rank = new int[r.Count]; r.CopyTo(rank);
type = new TypeReference(name, pointer, rank);
.)
.
NonArrayType<out TypeReference type>
(.
string name = "";
int pointer = 0;
.)
=
( ClassType<out name>
| SimpleType<out name>
| "void" "*" (. pointer = 1; name = "void"; .)
)
{ IF (IsPointer())
( "*" (. ++pointer; .)
)
} (.
type = new TypeReference(name, pointer, null);
.)
.
SimpleType<out string name>
(. name = String.Empty; .)
=
IntegralType<out name>
| "float" (. name = t.val; .)
| "double" (. name = t.val; .)
| "decimal" (. name = t.val; .)
| "bool" (. name = t.val; .)
.
FormalParameterList<out ArrayList parameter>
(.
parameter = new ArrayList();
ParameterDeclarationExpression p;
AttributeSection section;
ArrayList attributes = new ArrayList();
.)
=
{ AttributeSection<out section> (.attributes.Add(section); .) }
(
FixedParameter<out p> (. bool paramsFound = false;
p.Attributes = attributes;
parameter.Add(p);
.)
{
"," (. attributes = new ArrayList(); if (paramsFound) Error("params array must be at end of parameter list"); .)
{ AttributeSection<out section> (.attributes.Add(section); .) }
(
FixedParameter<out p> (. p.Attributes = attributes; parameter.Add(p); .)
| ParameterArray<out p> (. paramsFound = true; p.Attributes = attributes; parameter.Add(p); .)
)
}
| ParameterArray<out p> (. p.Attributes = attributes; parameter.Add(p); .)
)
.
FixedParameter<out ParameterDeclarationExpression p>
(.
TypeReference type;
ParamModifiers mod = ParamModifiers.In;
.)
=
[
"ref" (. mod = ParamModifiers.Ref; .)
| "out" (. mod = ParamModifiers.Out; .)
]
Type<out type> ident (. p = new ParameterDeclarationExpression(type, t.val, mod); .)
.
ParameterArray<out ParameterDeclarationExpression p>
(. TypeReference type; .)
=
"params" Type<out type> ident (. p = new ParameterDeclarationExpression(type, t.val, ParamModifiers.Params); .)
.
TypeModifier<Modifiers m>
=
"new" (. m.Add(Modifier.New); .)
| "public" (. m.Add(Modifier.Public); .)
| "protected" (. m.Add(Modifier.Protected); .)
| "internal" (. m.Add(Modifier.Internal); .)
| "private" (. m.Add(Modifier.Private); .)
| "unsafe" (. m.Add(Modifier.Unsafe); .)
| "abstract" (. m.Add(Modifier.Abstract); .)
| "sealed" (. m.Add(Modifier.Sealed); .)
.
ClassType<out string name> (. string qualident; name = "";.)
=
Qualident<out qualident> (. name = qualident; .)
| "object" (. name = "object"; .)
| "string" (. name = "string"; .)
.
IntegralType<out string name> (. name = ""; .)
=
"sbyte" (. name = "sbyte"; .)
| "byte" (. name = "byte"; .)
| "short" (. name = "short"; .)
| "ushort" (. name = "ushort"; .)
| "int" (. name = "int"; .)
| "uint" (. name = "uint"; .)
| "long" (. name = "long"; .)
| "ulong" (. name = "ulong"; .)
| "char" (. name = "char"; .)
.
MemberModifier<Modifiers m>
=
"abstract" (. m.Add(Modifier.Abstract); .)
| "extern" (. m.Add(Modifier.Extern); .)
| "internal" (. m.Add(Modifier.Internal); .)
| "new" (. m.Add(Modifier.New); .)
| "override" (. m.Add(Modifier.Override); .)
| "private" (. m.Add(Modifier.Private); .)
| "protected" (. m.Add(Modifier.Protected); .)
| "public" (. m.Add(Modifier.Public); .)
| "readonly" (. m.Add(Modifier.Readonly); .)
| "sealed" (. m.Add(Modifier.Sealed); .)
| "static" (. m.Add(Modifier.Static); .)
| "unsafe" (. m.Add(Modifier.Unsafe); .)
| "virtual" (. m.Add(Modifier.Virtual); .)
| "volatile" (. m.Add(Modifier.Volatile); .)
.
StructMemberDecl<Modifiers m, ArrayList attributes>
(.
string qualident = null;
TypeReference type;
Expression expr;
ArrayList p = new ArrayList();
Statement stmt = null;
ArrayList variableDeclarators = new ArrayList();
.)
=
/*--- constant declaration: */ (. m.Check(Modifier.Constants); .)
"const" (.Point startPos = t.Location; .)
Type<out type> ident (. FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const);
fd.StartLocation = startPos;
VariableDeclaration f = new VariableDeclaration(t.val);
fd.Fields.Add(f);
.)
"=" Expr<out expr> (. f.Initializer = expr; .)
{ "," ident (. f = new VariableDeclaration(t.val);
fd.Fields.Add(f);
.)
"=" Expr<out expr> (. f.Initializer = expr; .)
} ";" (. fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); .)
/*--- void method (procedure) declaration: */
| IF (NotVoidPointer()) (. m.Check(Modifier.PropertysEventsMethods); .)
"void" (. Point startPos = t.Location; .)
Qualident<out qualident> "("
[ FormalParameterList<out p> ] ")" (. 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);
.)
( Block<out stmt> | ";" ) (. compilationUnit.BlockEnd();
methodDeclaration.Body = (BlockStatement)stmt;
.)
| /*--- event declaration: */ (. m.Check(Modifier.PropertysEventsMethods); .)
"event" (. EventDeclaration eventDecl = new EventDeclaration(m.Modifier, attributes);
eventDecl.StartLocation = t.Location;
compilationUnit.AddChild(eventDecl);
compilationUnit.BlockStart(eventDecl);
EventAddRegion addBlock = null;
EventRemoveRegion removeBlock = null;
.)
Type<out type> (. eventDecl.TypeReference = type; .)
(
IF (IsVarDecl()) VariableDeclarator<variableDeclarators>
{ "," VariableDeclarator<variableDeclarators> } ";" (. eventDecl.VariableDeclarators = variableDeclarators; eventDecl.EndLocation = t.EndLocation; .)
| Qualident<out qualident> (. eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; .)
"{" (. eventDecl.BodyStart = t.Location; .)
EventAccessorDecls<out addBlock, out removeBlock>
"}" (. eventDecl.BodyEnd = t.EndLocation; .)
) (. compilationUnit.BlockEnd();
eventDecl.AddRegion = addBlock;
eventDecl.RemoveRegion = removeBlock;
.)
/*--- constructor or static contructor declaration: */
| IF (IdentAndLPar()) (. m.Check(Modifier.Constructors | Modifier.StaticConstructors); .)
ident (. string name = t.val; Point startPos = t.Location; .) "(" [ (. m.Check(Modifier.Constructors); .)
FormalParameterList<out p>
]
")" (.ConstructorInitializer init = null; .)
[ (. m.Check(Modifier.Constructors); .)
ConstructorInitializer<out init>
] (.
ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -