本文整理汇总了C#中IParseTree.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# IParseTree.GetText方法的具体用法?C# IParseTree.GetText怎么用?C# IParseTree.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IParseTree
的用法示例。
在下文中一共展示了IParseTree.GetText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Same
/// <summary>
/// Проверяет два синтаксических дерева на сходство, игнорируя вертикальные "цепочки" и скобки.
/// </summary>
public static bool Same(this IParseTree tree1, IParseTree tree2)
{
tree1 = tree1.Collapse();
tree2 = tree2.Collapse();
if (tree1.ChildCount == 0 || tree2.ChildCount == 0) return tree1.GetText() == tree2.GetText();
if (tree1.ChildCount != tree2.ChildCount) return false;
for (int i = 0; i < tree1.ChildCount; i++)
{
if (!tree1.GetChild(i).Same(tree2.GetChild(i))) return false;
}
return true;
}
示例2: ResolveReferences
private void ResolveReferences(DeclarationFinder finder, VBComponent component, IParseTree tree)
{
var state = _state.GetModuleState(component);
if (_state.Status == ParserState.ResolverError || (state != ParserState.Parsed))
{
return;
}
Debug.WriteLine("Resolving '{0}'... (thread {1})", component.Name, Thread.CurrentThread.ManagedThreadId);
var qualifiedName = new QualifiedModuleName(component);
var resolver = new IdentifierReferenceResolver(qualifiedName, finder);
var listener = new IdentifierReferenceListener(resolver);
if (!string.IsNullOrWhiteSpace(tree.GetText().Trim()))
{
var walker = new ParseTreeWalker();
try
{
walker.Walk(listener, tree);
state = ParserState.Ready;
}
catch (Exception exception)
{
Debug.Print("Exception thrown resolving '{0}' (thread {2}): {1}", component.Name, exception, Thread.CurrentThread.ManagedThreadId);
state = ParserState.ResolverError;
}
}
_state.SetModuleState(component, state);
Debug.Print("'{0}' is {1}. Resolver took {2}ms to complete (thread {3})", component.Name, _state.GetModuleState(component), /*_resolverTimer[component].ElapsedMilliseconds*/0, Thread.CurrentThread.ManagedThreadId);
}
示例3: CompareWrite
private bool CompareWrite(string key, IParseTree value)
{
if (!char.IsLetter(key[0])) return key == value.GetText();
//TODO: Use appropriate array of identifiers/operators
if (_dict.ContainsKey(key)) return _dict[key].Same(value);
_dict.Add(key, value);
return true;
}
示例4: Match
private bool Match(IParseTree tree, IParseTree localTree)
{
tree = tree.Collapse();
localTree = localTree.Collapse();
if (localTree.ChildCount == 0) return CompareWrite(localTree.GetText(), tree);
if (tree.ChildCount != localTree.ChildCount) return false;
for (int i = 0; i < tree.ChildCount; i++)
{
if (!Match(tree.GetChild(i), localTree.GetChild(i))) return false;
}
return true;
}
示例5: LoadNode
// загрузить дерево в TreeView по дереву парсинга
public void LoadNode(TreeNode node, IParseTree tree)
{
string s;
if (node == null)
{// если дерева в TreeView еще нет
{
s = tree.GetType().ToString();
if (s.Contains("+")) s = tree.GetType().ToString().Split('+')[1];
if (s.Contains(".")) s = tree.GetType().ToString().Split('.')[3];
if (s.Contains("Context")) s = "Rule:" + s.Substring(0, s.IndexOf("Context"));
if (s.Contains("Terminal")) s = s.Substring(0, 8);
node = tv.Nodes.Add(s + " # " + tree.GetText());
}
}
else
{
{
s = tree.GetType().ToString();
if (s.Contains("+")) s = tree.GetType().ToString().Split('+')[1];
if (s.Contains(".")) s = tree.GetType().ToString().Split('.')[3];
if (s.Contains("Context")) s = "Rule:" + s.Substring(0, s.IndexOf("Context"));
if (s.Contains("Terminal")) s = s.Substring(0, 8);
node = node.Nodes.Add(s + " # " + tree.GetText());
}
}
// загрузить дочерние ноды
for (int i = 0; i < tree.ChildCount; i++)
{
LoadNode(node, tree.GetChild(i));
}
}