📄 cs.atg
字号:
"~" ident (. DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes);
d.Modifier = m.Modifier;
d.StartLocation = m.GetDeclarationLocation(startPos);
.)
"(" ")" (. d.EndLocation = t.EndLocation; .) ( Block<out stmt> | ";" ) (.
d.Body = (BlockStatement)stmt;
compilationUnit.AddChild(d);
.)
.
InterfaceMemberDecl
(.
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>();
.)
=
{ AttributeSection<out section> (. attributes.Add(section); .)}
[ "new" (. mod = Modifiers.New; startLocation = t.Location; .) ]
(
/*--- interface void method (procedure) declaration: */
IF (NotVoidPointer()) "void" (. if (startLocation.X == -1) startLocation = t.Location; .) ident (. name = t.val; .)
[ TypeParameterList<templates> ]
"(" [ FormalParameterList<parameters> ] ")"
{ IF (IdentIsWhere()) TypeParameterConstraintsClause<templates> }
";"
(. MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes);
md.StartLocation = startLocation;
md.EndLocation = t.EndLocation;
md.Templates = templates;
compilationUnit.AddChild(md);
.)
| (
Type<out type> (. if (startLocation.X == -1) startLocation = t.Location; .)
(
ident (. name = t.val; Location qualIdentEndLocation = t.EndLocation; .)
(
/*--- interface "not void" method (function) declaration: */
/* .NET 2.0 */
[ TypeParameterList<templates> ]
"(" [ FormalParameterList<parameters> ] ")"
/* .NET 2.0 */
{ IF (IdentIsWhere()) TypeParameterConstraintsClause<templates> }
";" (. MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes);
md.StartLocation = startLocation;
md.EndLocation = t.EndLocation;
md.Templates = templates;
compilationUnit.AddChild(md);
.)
/*--- interface property declaration: */
| (. PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); .)
"{" (. Location bodyStart = t.Location;.) InterfaceAccessors<out getBlock, out setBlock> "}" (. pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; .)
)
/*--- interface indexer declaration: */
| "this" "[" FormalParameterList<parameters> "]" (.Location bracketEndLocation = t.EndLocation; .) (. IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); .)
"{" (. Location bodyStart = t.Location;.) InterfaceAccessors<out getBlock, out setBlock> "}" (. id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;.)
)
/*--- interface event declaration: */
| "event" (. if (startLocation.X == -1) startLocation = t.Location; .) Type<out type> ident (. EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes, null);
compilationUnit.AddChild(ed);
.)
";" (. ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; .)
)
)
.
EnumMemberDecl<out FieldDeclaration f>
(.
Expression expr = null;
List<AttributeSection> attributes = new List<AttributeSection>();
AttributeSection section = null;
VariableDeclaration varDecl = null;
.)
=
{ AttributeSection<out section> (. attributes.Add(section); .) }
ident (. f = new FieldDeclaration(attributes);
varDecl = new VariableDeclaration(t.val);
f.Fields.Add(varDecl);
f.StartLocation = t.Location;
.)
[ "=" Expr<out expr> (. varDecl.Initializer = expr; .) ]
.
AccessorDecls<out PropertyGetRegion getBlock, out PropertySetRegion setBlock>
(.
List<AttributeSection> attributes = new List<AttributeSection>();
AttributeSection section;
getBlock = null;
setBlock = null;
ModifierList modifiers = null;
.)
=
{ AttributeSection<out section> (. attributes.Add(section); .) }
[ AccessorModifiers<out modifiers> ]
(
IF (IdentIsGet())
GetAccessorDecl<out getBlock, attributes>
(. if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } .)
[ (. attributes = new List<AttributeSection>(); modifiers = null; .)
{ AttributeSection<out section> (. attributes.Add(section); .) }
[ AccessorModifiers<out modifiers> ]
SetAccessorDecl<out setBlock, attributes>
(. if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } .)
]
| IF (IdentIsSet())
SetAccessorDecl<out setBlock, attributes>
(. if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } .)
[ (. attributes = new List<AttributeSection>(); modifiers = null; .)
{ AttributeSection<out section> (. attributes.Add(section); .) }
[ AccessorModifiers<out modifiers> ]
GetAccessorDecl<out getBlock, attributes>
(. if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } .)
]
| ident (. Error("get or set accessor declaration expected"); .)
)
.
GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attributes>
(. Statement stmt = null; .)
=
ident /* "get" is not a keyword! */
(. if (t.val != "get") Error("get expected"); .)
(. Location startLocation = t.Location; .)
( Block<out stmt> | ";" )
(. getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); .)
(. getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; .)
.
SetAccessorDecl<out PropertySetRegion setBlock, List<AttributeSection> attributes>
(. Statement stmt = null; .)
=
ident /* "set" is not a keyword! */
(. if (t.val != "set") Error("set expected"); .)
(. Location startLocation = t.Location; .)
( Block<out stmt> | ";" )
(. setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); .)
(. setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; .)
.
EventAccessorDecls<out EventAddRegion addBlock, out EventRemoveRegion removeBlock>
(. AttributeSection section;
List<AttributeSection> attributes = new List<AttributeSection>();
Statement stmt;
addBlock = null;
removeBlock = null;
.)
=
{ AttributeSection<out section> (. attributes.Add(section); .) }
(
IF (IdentIsAdd()) (. addBlock = new EventAddRegion(attributes); .)
AddAccessorDecl<out stmt> (. attributes = new List<AttributeSection>(); addBlock.Block = (BlockStatement)stmt; .)
{ AttributeSection<out section> (. attributes.Add(section); .)}
RemoveAccessorDecl<out stmt> (. removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; .)
| IF (IdentIsRemove())
RemoveAccessorDecl <out stmt> (. removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List<AttributeSection>(); .)
{ AttributeSection<out section> (. attributes.Add(section); .) }
AddAccessorDecl<out stmt> (. addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; .)
| ident (. Error("add or remove accessor declaration expected"); .)
)
.
InterfaceAccessors<out PropertyGetRegion getBlock, out PropertySetRegion setBlock>
(.
AttributeSection section;
List<AttributeSection> attributes = new List<AttributeSection>();
getBlock = null; setBlock = null;
PropertyGetSetRegion lastBlock = null;
.)
=
{ AttributeSection<out section> (. attributes.Add(section); .) }
(. Location startLocation = la.Location; .)
(
IF (IdentIsGet()) ident (. getBlock = new PropertyGetRegion(null, attributes); .)
| IF (IdentIsSet()) ident (. setBlock = new PropertySetRegion(null, attributes); .)
| ident (. Error("set or get expected"); .)
)
";"
(. if (getBlock != null) { getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; }
if (setBlock != null) { setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; }
attributes = new List<AttributeSection>(); .)
[
{ AttributeSection<out section> (. attributes.Add(section); .) }
(. startLocation = la.Location; .)
(
IF (IdentIsGet()) ident (. if (getBlock != null) Error("get already declared");
else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; }
.)
| IF (IdentIsSet()) ident (. if (setBlock != null) Error("set already declared");
else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; }
.)
| ident (. Error("set or get expected"); .)
)
";"
(. if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } .)
]
.
VariableDeclarator<List<VariableDeclaration> fieldDeclaration>
(. Expression expr = null; .)
=
ident (. VariableDeclaration f = new VariableDeclaration(t.val); .)
[ "=" VariableInitializer<out expr> (. f.Initializer = expr; .) ] (. fieldDeclaration.Add(f); .)
.
Block<out Statement stmt> /* not BlockStatement because of EmbeddedStatement */
=
"{" (. BlockStatement blockStmt = new BlockStatement();
blockStmt.StartLocation = t.Location;
compilationUnit.BlockStart(blockStmt);
if (!ParseMethodBodies) lexer.SkipCurrentBlock(0);
.)
{ Statement }
"}" (.
stmt = blockStmt;
blockStmt.EndLocation = t.EndLocation;
compilationUnit.BlockEnd();
.)
.
AddAccessorDecl<out Statement stmt>
(.stmt = null;.)
=
/* "add" is not a keyword!? */
ident (. if (t.val != "add") Error("add expected"); .)
Block<out stmt>
.
RemoveAccessorDecl<out Statement stmt>
(.stmt = null;.)
=
/* "remove" is not a keyword!? */
ident (. if (t.val != "remove") Error("remove expected"); .)
Block<out stmt>
.
ConstructorInitializer<out ConstructorInitializer ci>
(. Expression expr; ci = new ConstructorInitializer(); .)
=
":"
(
"base" (. ci.ConstructorInitializerType = ConstructorInitializerType.Base; .)
| "this" (. ci.ConstructorInitializerType = ConstructorInitializerType.This; .)
)
"("
[ Argument<out expr> (. if (expr != null) { ci.Arguments.Add(expr); } .) { "," Argument<out expr> (. if (expr != null) { ci.Arguments.Add(expr); } .) } ]
")"
.
VariableInitializer<out Expression initializerExpression>
(. TypeReference type = null; Expression expr = null; initializerExpression = null; .)
=
Expr<out initializerExpression>
| ArrayInitializer<out initializerExpression>
| "stackalloc" Type<out type> "[" Expr<out expr> "]" (. initializerExpression = new StackAllocExpression(type, expr); .)
.
OverloadableOperator<out OverloadableOperatorType op>
(. op = OverloadableOperatorType.None; .)
=
"+" (. op = OverloadableOperatorType.Add; .)
| "-" (. op = OverloadableOperatorType.Subtract; .)
| "!" (. op = OverloadableOperatorType.Not; .)
| "~" (. op = OverloadableOperatorType.BitNot; .)
| "++" (. op = OverloadableOperatorType.Increment; .)
| "--" (. op = OverloadableOperatorType.Decrement; .)
| "true" (. op = OverloadableOperatorType.IsTrue; .)
| "false" (. op = OverloadableOperatorType.IsFalse; .)
| "*" (. op = OverloadableOperatorType.Multiply; .)
| "/" (. op = OverloadableOperatorType.Divide; .)
| "%" (. op = OverloadableOperatorType.Modulus; .)
| "&" (. op = OverloadableOperatorType.BitwiseAnd; .)
| "|" (. op = OverloadableOperatorType.BitwiseOr; .)
| "^" (. op = OverloadableOperatorType.ExclusiveOr; .)
| "<<" (. op = OverloadableOperatorType.ShiftLeft; .)
| "==" (. op = OverloadableOperatorType.Equality; .)
| "!=" (. op = OverloadableOperatorType.InEquality; .)
| "<" (. op = OverloadableOperatorType.LessThan; .)
| ">=" (. op = OverloadableOperatorType.GreaterThanOrEqual; .)
| "<=" (. op = OverloadableOperatorType.LessThanOrEqual; .)
| ">" (. op = OverloadableOperatorType.GreaterThan; .) [ ">" (. op = OverloadableOperatorType.ShiftRight; .) ]
.
Argument<out Expression argumentexpr>
(.
Expression expr;
FieldDirection fd = FieldDirection.None;
.)
=
[
"ref" (. fd = FieldDirection.Ref; .)
| "out" (. fd = FieldDirection.Out; .)
]
Expr<out expr> (. argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; .)
.
AssignmentOperator<out AssignmentOperatorType op>
(. op = AssignmentOperatorType.None; .)
=
"=" (. op = AssignmentOperatorType.Assign; .)
| "+=" (. op = AssignmentOperatorType.Add; .)
| "-=" (. op = AssignmentOperatorType.Subtract; .)
| "*=" (. op = AssignmentOperatorType.Multiply; .)
| "/=" (. op = AssignmentOperatorType.Divide; .)
| "%=" (. op = AssignmentOperatorType.Modulus; .)
| "&=" (. op = AssignmentOperatorType.BitwiseAnd; .)
| "|=" (. op = AssignmentOperatorType.BitwiseOr; .)
| "^=" (. op = AssignmentOperatorType.ExclusiveOr; .)
| "<<=" (. op = AssignmentOperatorType.ShiftLeft; .)
| IF (la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual)
">" ">=" (. op = AssignmentOperatorType.ShiftRight; .)
.
ArrayInitializer<out Expression outExpr>
(.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -