本文整理汇总了C#中ParseNode.Complete方法的典型用法代码示例。如果您正苦于以下问题:C# ParseNode.Complete方法的具体用法?C# ParseNode.Complete怎么用?C# ParseNode.Complete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseNode
的用法示例。
在下文中一共展示了ParseNode.Complete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParserState
/// <summary>
/// Constructs a parser state, that manages a pointer to the text.
/// </summary>
/// <param name="text"></param>
public ParserState(string text)
{
this.text = text;
ParseNode root = new ParseNode(null, null, text, 0);
root.Complete(text.Length);
nodes.Push(root);
}
示例2: ParserState
/// <summary>
/// Constructs a parser state, that manages a pointer to the text.
/// </summary>
/// <param name="text"></param>
public ParserState(string text)
{
CreateNodes = true;
_text = text;
var root = new ParseNode(null, null, text, 0);
root.Complete(text.Length);
_nodes.Push(root);
}
示例3: Match
/// <summary>
/// This is the work-horse function. It attempts to match a rule
/// by calling the rule's specialized "InternalMatch()" function.
/// If the match is successful, a node is created and added to the
/// the parser tree managed by ParserState.
/// If the match fails, then no node is created (technically
/// the node was already created, and just gets deleted) and the
/// ParserState index is returned to its original location.
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
public virtual bool Match(ParserState p)
{
int old_index = p.index;
if (p.CreateNodes && !(this is SkipRule))
{
ParseNode node = new ParseNode(this, p.Peek(), p.text, old_index);
p.Push(node);
if (InternalMatch(p))
{
node.Complete(p.index);
p.Pop();
return true;
}
else
{
p.index = old_index;
node = null;
p.Pop();
return false;
}
}
else
{
if (InternalMatch(p))
{
return true;
}
else
{
p.index = old_index;
return false;
}
}
}
示例4: InternalMatch
protected override bool InternalMatch(ParserState p)
{
ParseNode node = new ParseNode(this, p.Peek(), p.text, p.index);
p.Push(node);
if (rules[0].Match(p))
{
node.Complete(p.index);
p.Pop();
return true;
}
else
{
node = null;
p.Pop();
return false;
}
}