本文整理汇总了C#中ProgrammingLanguageNr1.AST.getChildren方法的典型用法代码示例。如果您正苦于以下问题:C# AST.getChildren方法的具体用法?C# AST.getChildren怎么用?C# AST.getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgrammingLanguageNr1.AST
的用法示例。
在下文中一共展示了AST.getChildren方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLeafNodes
private void GetLeafNodes(AST pCurrentNode, List<AST> pList)
{
List<AST> tmpList = pCurrentNode.getChildren();
if (tmpList == null || tmpList.Count <= 0)
{
pList.Add(pCurrentNode);
}
else
{
foreach (AST child in tmpList)
{
GetLeafNodes(child, pList);
}
}
}
示例2: BuildRow
private string BuildRow(AST pLeaf, AST pRoot)
{
currentNode = pLeaf;
StringBuilder resultString = new StringBuilder();
if (currentNode == _root)
{
PrependString(resultString, GetNodeString(currentNode) );
}
else if (currentNode.getChildren().Count <= 0) {
#if CANT_HANDLE_FANCY_CHARS
PrependString(resultString, "-------- " + GetNodeString(currentNode) );
#else
PrependString(resultString, "──────── " + GetNodeString(currentNode) );
#endif
}
else
#if CANT_HANDLE_FANCY_CHARS
PrependString(resultString, "-------- " + GetNodeString(currentNode) );
#else
PrependString(resultString, "──────┬─ " + GetNodeString(currentNode) );
#endif
if (currentNodeIsLastChild)
{
#if CANT_HANDLE_FANCY_CHARS
PrependString(resultString, " |");
#else
PrependString(resultString, " └");
#endif
}
else
{
#if CANT_HANDLE_FANCY_CHARS
PrependString(resultString, " |");
#else
PrependString(resultString, " ├");
#endif
}
currentNode = currentParentNode;
while (currentParentNode != null)
{
if (currentNodeIsLastChild)
{
PrependString(resultString, " ");
}
else
{
#if CANT_HANDLE_FANCY_CHARS
PrependString(resultString, " |");
#else
PrependString(resultString, " │");
#endif
}
currentNode = currentParentNode;
}
return resultString.ToString();
}
示例3: IsLastChild
private bool IsLastChild(AST pNode, AST pParent)
{
if (pParent == null)
return true;
if (pParent.getChildren().IndexOf(pNode) == pParent.getChildren().Count - 1)
return true;
return false;
}
示例4: addChildren
private void addChildren(List<AST> list, AST ast)
{
List<AST> children = ast.getChildren();
if (children != null)
{
foreach (AST child in children)
{
addToList(list, child);
}
}
}
示例5: BuildNodeList
private void BuildNodeList(AST pCurrentList, List<AST> pList)
{
pList.Add(pCurrentList);
foreach(AST a in pCurrentList.getChildren())
{
BuildNodeList(a, pList);
}
}
示例6: ifThenElse
private void ifThenElse(AST tree)
{
// Push scope
AST_IfNode ifNode = (AST_IfNode)(tree);
Assert.IsNotNull(ifNode);
m_currentScope = (Scope)ifNode.getScope();
Assert.IsNotNull(m_currentScope);
// Evaluate conditional
ReturnValue conditionalExpression = execute(tree.getChild(0));
if (conditionalExpression.FloatValue != 0) {
Assert.IsNotNull(tree.getChild(1));
execute(tree.getChild(1));
}
else {
if (tree.getChildren().Count == 3) {
Assert.IsNotNull(tree.getChild(2));
execute(tree.getChild(2));
}
}
// Pop scope
m_currentScope = (Scope)ifNode.getScope().getEnclosingScope();
Assert.IsNotNull(m_currentScope);
}
示例7: returnStatement
private void returnStatement(AST tree)
{
ReturnValue returnValue = new ReturnValue();
if (tree.getChildren().Count > 0)
{
returnValue = execute(tree.getChild(0));
}
if(returnValue != null) {
#if WRITE_DEBUG_INFO
Console.Write("Return value was: ");
printReturnValue(returnValue);
#endif
throw returnValue;
}
}
示例8: functionCall
private ReturnValue functionCall(AST tree)
{
ReturnValue returnValue = null;
if (m_externalFunctionCreator.externalFunctions.ContainsKey(tree.getTokenString()))
{
ExternalFunctionCreator.OnFunctionCall functionCall = m_externalFunctionCreator.externalFunctions[tree.getTokenString()];
if (functionCall != null)
{
ReturnValue[] parameters = new ReturnValue[tree.getChildren().Count];
int i = 0;
foreach (AST parameter in tree.getChildren())
{
parameters[i] = execute(parameter);
i++;
}
returnValue = functionCall(parameters);
}
else
{
throw new Error("Can't find external function " + tree.getTokenString(), Error.ErrorType.UNDEFINED, tree.getToken().LineNr, tree.getToken().LinePosition);
}
}
else
{
// Call user defined function
string functionName = tree.getTokenString();
AST functionTree = getFunctionTreeNode(functionName);
Assert.IsNotNull(functionTree);
// Create list of parameter values
List<ReturnValue> parameterValues = new List<ReturnValue>();
List<AST> functionCallChildNodes = tree.getChildren();
if (functionCallChildNodes != null)
{
foreach(AST parameter in tree.getChildren())
{
ReturnValue val = execute(parameter);
parameterValues.Add(val);
}
}
returnValue = function(functionTree, parameterValues);
}
return returnValue;
}
示例9: executeAllChildNodes
private void executeAllChildNodes(AST tree)
{
if(tree.getChildren() == null) { return; }
foreach (AST childTree in tree.getChildren()) {
execute(childTree);
}
}
示例10: evaluateScopeDeclarationsInAllChildren
private void evaluateScopeDeclarationsInAllChildren(AST tree)
{
foreach (AST subtree in tree.getChildren())
{
evaluateScopeDeclarations(subtree);
}
}
示例11: evaluateScopeDeclarations
private void evaluateScopeDeclarations(AST tree)
{
Debug.Assert(tree != null);
if (tree.getTokenType() == Token.TokenType.FUNC_DECLARATION)
{
evaluateFunctionScope(tree);
}
else if (tree.getTokenType() == Token.TokenType.IF) {
evaluateIfScope(tree);
}
else if (tree.getTokenType() == Token.TokenType.LOOP) {
evaluateLoopScope(tree);
}
else if (tree.getTokenType() == Token.TokenType.LOOP_BLOCK) {
evaluateLoopBlockScope(tree);
}
else if (tree.getChildren() != null)
{
evaluateScopeDeclarationsInAllChildren(tree);
}
}
示例12: evaluateReferencesInAllChildren
private void evaluateReferencesInAllChildren(AST tree)
{
if (tree.getChildren() != null)
{
// Go through all other subtrees
foreach (AST subtree in tree.getChildren())
{
evaluateReferences(subtree);
}
}
}