本文整理汇总了C#中ParseTree.ExtendFields方法的典型用法代码示例。如果您正苦于以下问题:C# ParseTree.ExtendFields方法的具体用法?C# ParseTree.ExtendFields怎么用?C# ParseTree.ExtendFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseTree
的用法示例。
在下文中一共展示了ParseTree.ExtendFields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
ParseTree bodyTree = body.Parse(lexer, state);
if (bodyTree == ParseTree.No)
return ParseTree.No;
ParseTree labelledTree = new ParseTree();
labelledTree = labelledTree.ExtendFields(bodyTree);
labelledTree.Fields[label] = bodyTree.Value;
return labelledTree;
}
示例2: ExtendingFields
public void ExtendingFields()
{
ParseTree a = new ParseTree();
a.Fields["a"] = "A";
a.Fields["b"] = "B";
a.Fields["c"] = "C";
Assert.IsTrue(a.Fields.ContainsKey("a"));
Assert.IsTrue(a.Fields.ContainsKey("b"));
Assert.IsTrue(a.Fields.ContainsKey("c"));
ParseTree b = new ParseTree();
b.ExtendFields(a);
b.Fields["d"] = "D";
Assert.IsTrue(b.Fields.ContainsKey("a"));
Assert.IsTrue(b.Fields.ContainsKey("b"));
Assert.IsTrue(b.Fields.ContainsKey("c"));
Assert.IsTrue(b.Fields.ContainsKey("d"));
}
示例3: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
state.RuntimeState.Runtime.ParseTrace.Enter(this, lexer.CurrentSource(), "token");
int start = lexer.Position;
ParseTree bodyTree = body.Parse(lexer, state);
if (bodyTree == ParseTree.No)
{
state.RuntimeState.Runtime.ParseTrace.No(this, lexer.SourceFrom(start));
return ParseTree.No;
}
state.RuntimeState.Runtime.ParseTrace.Yes(this, lexer.SourceFrom(start));
ParseTree tokenTree = new ParseTree(
lexer.Text.Substring(start, lexer.Position - start));
tokenTree = tokenTree.ExtendFields(bodyTree);
return tokenTree;
}