本文整理汇总了C#中ForStatement.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# ForStatement.AddChild方法的具体用法?C# ForStatement.AddChild怎么用?C# ForStatement.AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ForStatement
的用法示例。
在下文中一共展示了ForStatement.AddChild方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
public override object Visit(For forStatement)
{
var result = new ForStatement();
var location = LocationsBag.GetLocations(forStatement);
result.AddChild(new CSharpTokenNode(Convert(forStatement.loc), ForStatement.ForKeywordRole), ForStatement.ForKeywordRole);
if (location != null)
result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
AddStatementOrList(result, forStatement.Initializer, ForStatement.InitializerRole);
if (location != null && location.Count > 1)
result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.Semicolon), Roles.Semicolon);
if (forStatement.Condition != null)
result.AddChild((Expression)forStatement.Condition.Accept(this), Roles.Condition);
if (location != null && location.Count >= 3)
result.AddChild(new CSharpTokenNode(Convert(location [2]), Roles.Semicolon), Roles.Semicolon);
AddStatementOrList(result, forStatement.Iterator, ForStatement.IteratorRole);
if (location != null && location.Count >= 4)
result.AddChild(new CSharpTokenNode(Convert(location [3]), Roles.RPar), Roles.RPar);
if (forStatement.Statement != null)
result.AddChild((Statement)forStatement.Statement.Accept(this), Roles.EmbeddedStatement);
return result;
}
示例2: Visit
public override object Visit (For forStatement)
{
var result = new ForStatement ();
var location = LocationsBag.GetLocations (forStatement);
result.AddChild (new CSharpTokenNode (Convert (forStatement.loc), "for".Length), ForStatement.Roles.Keyword);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ForStatement.Roles.LPar);
if (forStatement.InitStatement != null)
result.AddChild ((INode)forStatement.InitStatement.Accept (this), ForStatement.Roles.Initializer);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ForStatement.Roles.Semicolon);
if (forStatement.Test != null)
result.AddChild ((INode)forStatement.Test.Accept (this), ForStatement.Roles.Condition);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), ForStatement.Roles.Semicolon);
if (forStatement.Increment != null)
result.AddChild ((INode)forStatement.Increment.Accept (this), ForStatement.Roles.Iterator);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[3]), 1), ForStatement.Roles.RPar);
result.AddChild ((INode)forStatement.Statement.Accept (this), ForStatement.Roles.EmbeddedStatement);
return result;
}
示例3: AddStatementOrList
void AddStatementOrList(ForStatement forStatement, Mono.CSharp.Statement init, Role<Statement> role)
{
if (init == null)
return;
var stmtList = init as StatementList;
if (stmtList != null) {
foreach (var stmt in stmtList.Statements) {
forStatement.AddChild((Statement)stmt.Accept(this), role);
}
} else if (init is Mono.CSharp.EmptyStatement) {
} else {
forStatement.AddChild((Statement)init.Accept(this), role);
}
}
示例4: AddStatementOrList
void AddStatementOrList (ForStatement forStatement, Statement init, int role)
{
if (init == null)
return;
if (init is StatementList) {
foreach (var stmt in ((StatementList)init).Statements) {
forStatement.AddChild ((AstNode)stmt.Accept (this), role);
}
} else {
forStatement.AddChild ((AstNode)init.Accept (this), role);
}
}
示例5: AddStatementOrList
void AddStatementOrList (ForStatement forStatement, Mono.CSharp.Statement init, Role<Statement> role)
{
if (init == null)
return;
if (init is StatementList) {
foreach (var stmt in ((StatementList)init).Statements) {
forStatement.AddChild ((Statement)stmt.Accept (this), role);
}
} else {
forStatement.AddChild ((Statement)init.Accept (this), role);
}
}
示例6: AddStatementOrList
void AddStatementOrList (ForStatement forStatement, Mono.CSharp.Statement init, Role<Statement> role)
{
if (init == null)
return;
if (init is StatementList) {
foreach (var stmt in ((StatementList)init).Statements) {
Console.WriteLine ("stmt:" + stmt);
forStatement.AddChild ((Statement)stmt.Accept (this), role);
}
} else if (init is Mono.CSharp.EmptyStatement) {
} else {
forStatement.AddChild ((Statement)init.Accept (this), role);
}
}
示例7: forStatement
public ForStatement forStatement()
{
EnterRule_forStatement();
EnterRule("forStatement", 19);
TraceIn("forStatement", 19);
ForStatement st = default(ForStatement);
IToken identifier36 = default(IToken);
ForStruct forList37 = default(ForStruct);
List<Statement> statement38 = default(List<Statement>);
st = new ForStatement();
try { DebugEnterRule(GrammarFileName, "forStatement");
DebugLocation(392, 5);
try
{
// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:397:6: ( FOR identifier EQUAL forList DO statement )
DebugEnterAlt(1);
// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:397:8: FOR identifier EQUAL forList DO statement
{
DebugLocation(397, 8);
Match(input,FOR,Follow._FOR_in_forStatement1336);
DebugLocation(398, 7);
PushFollow(Follow._identifier_in_forStatement1344);
identifier36=identifier();
PopFollow();
DebugLocation(399, 7);
st.SetIdentifier(identifier36);
DebugLocation(402, 7);
Match(input,EQUAL,Follow._EQUAL_in_forStatement1360);
DebugLocation(403, 7);
PushFollow(Follow._forList_in_forStatement1368);
forList37=forList();
PopFollow();
DebugLocation(404, 7);
st.SetForStruct(forList37);
DebugLocation(407, 7);
Match(input,DO,Follow._DO_in_forStatement1384);
DebugLocation(408, 7);
PushFollow(Follow._statement_in_forStatement1392);
statement38=statement();
PopFollow();
DebugLocation(409, 7);
foreach(var child in statement38)
{
st.AddChild(child);
}
}
}
catch (RecognitionException e)
{
throw e;
}
finally
{
TraceOut("forStatement", 19);
LeaveRule("forStatement", 19);
LeaveRule_forStatement();
}
DebugLocation(415, 5);
} finally { DebugExitRule(GrammarFileName, "forStatement"); }
return st;
}