本文整理汇总了C#中ITreeAdaptor类的典型用法代码示例。如果您正苦于以下问题:C# ITreeAdaptor类的具体用法?C# ITreeAdaptor怎么用?C# ITreeAdaptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITreeAdaptor类属于命名空间,在下文中一共展示了ITreeAdaptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TreePatternParser
public TreePatternParser( TreePatternLexer tokenizer, TreeWizard wizard, ITreeAdaptor adaptor )
{
this.tokenizer = tokenizer;
this.wizard = wizard;
this.adaptor = adaptor;
ttype = tokenizer.NextToken(); // kickstart
}
示例2: EqualsCore
protected static bool EqualsCore(object t1, object t2, ITreeAdaptor adaptor)
{
if ((t1 == null) || (t2 == null))
{
return false;
}
if (adaptor.GetType(t1) != adaptor.GetType(t2))
{
return false;
}
if (!adaptor.GetText(t1).Equals(adaptor.GetText(t2)))
{
return false;
}
int childCount = adaptor.GetChildCount(t1);
int num2 = adaptor.GetChildCount(t2);
if (childCount != num2)
{
return false;
}
for (int i = 0; i < childCount; i++)
{
object child = adaptor.GetChild(t1, i);
object obj3 = adaptor.GetChild(t2, i);
if (!EqualsCore(child, obj3, adaptor))
{
return false;
}
}
return true;
}
示例3: InContext
/// <summary>
/// The worker for <see cref="InContext(TreeParser, string)"/>. It's <see langword="static"/> and full of
/// parameters for testing purposes.
/// </summary>
private static bool InContext(
ITreeAdaptor adaptor,
string[] tokenNames,
object t,
string context)
{
if (Regex.IsMatch(context, DotDot))
{
// don't allow "..", must be "..."
throw new ArgumentException("invalid syntax: ..");
}
if (Regex.IsMatch(context, DoubleEtc))
{
// don't allow double "..."
throw new ArgumentException("invalid syntax: ... ...");
}
context = context.Replace("...", " ... "); // ensure spaces around ...
context = context.Trim();
string[] nodes = context.Split(new[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
int ni = nodes.Length - 1;
t = adaptor.GetParent(t);
while (ni >= 0 && t != null)
{
if (nodes[ni].Equals("..."))
{
// walk upwards until we see nodes[ni-1] then continue walking
if (ni == 0)
{
// ... at start is no-op
return true;
}
string goal = nodes[ni - 1];
object ancestor = GetAncestor(adaptor, tokenNames, t, goal);
if (ancestor == null)
return false;
t = ancestor;
ni--;
}
string name = tokenNames[adaptor.GetType(t)];
if (!name.Equals(nodes[ni]))
{
//System.Console.Error.WriteLine("not matched: " + nodes[ni] + " at " + t);
return false;
}
// advance to parent and to previous element in context node list
ni--;
t = adaptor.GetParent(t);
}
if (t == null && ni >= 0)
return false; // at root but more nodes to match
return true;
}
示例4: TreeViewModel
public TreeViewModel(ITreeAdaptor adaptor, object tree)
{
if (adaptor == null)
throw new ArgumentNullException("adaptor");
if (tree == null)
throw new ArgumentNullException("tree");
_adaptor = adaptor;
_tree = tree;
}
示例5: Concatenate_Depth2_Subtree_Name
// Private interface
private static string Concatenate_Depth2_Subtree_Name( ITreeAdaptor tree_adapter, object node )
{
StringBuilder builder = new StringBuilder();
builder.Append( tree_adapter.GetText( node ) );
for ( int i = 0; i < tree_adapter.GetChildCount( node ); i++ )
{
object child_node = tree_adapter.GetChild( node, i );
builder.Append( tree_adapter.GetText( child_node ) );
}
return builder.ToString();
}
示例6: TreeVisualizerViewModel
public TreeVisualizerViewModel(ITreeAdaptor adaptor, object tree, ITokenStream tokenStream, string sourceText)
{
if (adaptor == null)
throw new ArgumentNullException("adaptor");
if (tree == null)
throw new ArgumentNullException("tree");
_adaptor = adaptor;
_tree = tree;
_tokenStream = tokenStream;
_sourceText = sourceText;
object root = adaptor.Nil();
adaptor.AddChild(root, tree);
_treeViewModel = new TreeViewModel(_adaptor, root);
}
示例7: DefineNodes
protected virtual IEnumerable<string> DefineNodes(object tree, ITreeAdaptor adaptor)
{
if (tree != null)
{
int childCount = adaptor.GetChildCount(tree);
if (childCount != 0)
{
yield return this.GetNodeText(adaptor, tree);
for (int i = 0; i < childCount; i++)
{
object child = adaptor.GetChild(tree, i);
yield return this.GetNodeText(adaptor, child);
foreach (string iteratorVariable3 in this.DefineNodes(child, adaptor))
{
yield return iteratorVariable3;
}
}
}
}
}
示例8: DefineEdges
protected virtual IEnumerable<string> DefineEdges(object tree, ITreeAdaptor adaptor)
{
if (tree != null)
{
int childCount = adaptor.GetChildCount(tree);
if (childCount != 0)
{
string iteratorVariable1 = "n" + this.GetNodeNumber(tree);
string text = adaptor.GetText(tree);
for (int i = 0; i < childCount; i++)
{
object child = adaptor.GetChild(tree, i);
string iteratorVariable5 = adaptor.GetText(child);
string iteratorVariable6 = "n" + this.GetNodeNumber(child);
yield return string.Format(" {0} -> {1} // \"{2}\" -> \"{3}\"", new object[] { iteratorVariable1, iteratorVariable6, this.FixString(text), this.FixString(iteratorVariable5) });
foreach (string iteratorVariable7 in this.DefineEdges(child, adaptor))
{
yield return iteratorVariable7;
}
}
}
}
}
示例9: TreeWizard
public TreeWizard( ITreeAdaptor adaptor, IDictionary<string, int> tokenNameToTypeMap )
{
this.adaptor = adaptor;
this.tokenNameToTypeMap = tokenNameToTypeMap;
}
示例10: RewriteRuleNodeStream
/// <summary>Create a stream, but feed off an existing list</summary>
public RewriteRuleNodeStream(
ITreeAdaptor adaptor,
string elementDescription,
IList<object> elements
) : base(adaptor, elementDescription, elements) {
}
示例11: _Equals
protected static bool _Equals( object t1, object t2, ITreeAdaptor adaptor )
{
// make sure both are non-null
if ( t1 == null || t2 == null )
{
return false;
}
// check roots
if ( adaptor.GetType( t1 ) != adaptor.GetType( t2 ) )
{
return false;
}
if ( !adaptor.GetText( t1 ).Equals( adaptor.GetText( t2 ) ) )
{
return false;
}
// check children
int n1 = adaptor.GetChildCount( t1 );
int n2 = adaptor.GetChildCount( t2 );
if ( n1 != n2 )
{
return false;
}
for ( int i = 0; i < n1; i++ )
{
object child1 = adaptor.GetChild( t1, i );
object child2 = adaptor.GetChild( t2, i );
if ( !_Equals( child1, child2, adaptor ) )
{
return false;
}
}
return true;
}
示例12: RewriteRuleElementStream
public RewriteRuleElementStream( ITreeAdaptor adaptor, string elementDescription )
{
this.elementDescription = elementDescription;
this.adaptor = adaptor;
}
示例13: RewriteRuleSubtreeStream
public RewriteRuleSubtreeStream(ITreeAdaptor adaptor, string elementDescription, IList elements) : base(adaptor, elementDescription, elements) { }
示例14: ReadOnlyTreeVisitor
public ReadOnlyTreeVisitor(ITreeAdaptor adaptor)
{
this.adaptor = adaptor;
}
示例15: UnBufferedTreeNodeStream
public UnBufferedTreeNodeStream(ITreeAdaptor adaptor, object tree)
{
this.root = tree;
this.adaptor = adaptor;
Reset();
down = adaptor.Create(Token.DOWN, "DOWN");
up = adaptor.Create(Token.UP, "UP");
eof = adaptor.Create(Token.EOF, "EOF");
}