本文整理汇总了C#中Antlr.Runtime.Tree.CommonTree类的典型用法代码示例。如果您正苦于以下问题:C# CommonTree类的具体用法?C# CommonTree怎么用?C# CommonTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonTree类属于Antlr.Runtime.Tree命名空间,在下文中一共展示了CommonTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAddListToExistChildren
public void TestAddListToExistChildren()
{
// Add child ^(nil 101 102 103) to root ^(5 6)
// should add 101 102 103 to end of 5's child list
CommonTree root = new CommonTree( new CommonToken( 5 ) );
root.AddChild( new CommonTree( new CommonToken( 6 ) ) );
// child tree
CommonTree r0 = new CommonTree( (IToken)null );
CommonTree c0, c1, c2;
r0.AddChild( c0 = new CommonTree( new CommonToken( 101 ) ) );
r0.AddChild( c1 = new CommonTree( new CommonToken( 102 ) ) );
r0.AddChild( c2 = new CommonTree( new CommonToken( 103 ) ) );
root.AddChild( r0 );
assertNull( root.Parent );
assertEquals( -1, root.ChildIndex );
// check children of root all point at root
assertEquals( root, c0.Parent );
assertEquals( 1, c0.ChildIndex );
assertEquals( root, c0.Parent );
assertEquals( 2, c1.ChildIndex );
assertEquals( root, c0.Parent );
assertEquals( 3, c2.ChildIndex );
}
示例2: UserFunction
// method xyt(param1, param2) {
public UserFunction(String name, List<String> parameterNames, CommonTree functionBody, int definedLine)
{
this.parameterNames = parameterNames;
this.functionBody = functionBody;
this.name = name;
this.definedLine = definedLine;
}
示例3: GetSpan
private SnapshotSpan? GetSpan(CommonTree tree)
{
if (tree == null)
return null;
return GetSpan(tree.Token);
}
示例4: BindToAntlrNode
public AstNode BindToAntlrNode(CommonTree node)
{
// horrible, but works for now
if (AntlrNode == null)
AntlrNode = node;
return this;
}
示例5: BlaiseInstrumentTreeWalker
public BlaiseInstrumentTreeWalker(CommonTree tree, CommonTokenStream tokens, BlaiseImportOptions options, string agencyId, string mainLanguage)
{
this.tree = tree;
this.tokens = tokens;
this.options = options;
this.MainLanguage = mainLanguage;
this.AgencyId = agencyId;
Result = new XDocument();
DdiInstance = Ddi.Element(Ddi.DdiInstance);
Ddi.AddNamespaces(DdiInstance);
ResourcePackage = Ddi.Element(Ddi.ResourcePackage);
// Required in DDI 3.1
var purpose = Ddi.Element(Ddi.Purpose);
purpose.Add(Ddi.XmlLang(MainLanguage));
purpose.Add(new XElement(Ddi.Content, "Not Specified"));
ResourcePackage.Add(purpose);
Instrument = Ddi.Element(Ddi.Instrument);
ControlConstructScheme = Ddi.Element(Ddi.ControlConstructScheme);
XElement groupDataCollection = Ddi.Element(Ddi.GroupDataCollection, false);
XElement dataCollection = Ddi.Element(Ddi.DataCollection);
groupDataCollection.Add(dataCollection);
dataCollection.Add(Instrument);
ResourcePackage.Add(groupDataCollection);
ResourcePackage.Add(ControlConstructScheme);
DdiInstance.Add(ResourcePackage);
}
示例6: CommonTree
public CommonTree(CommonTree node)
: base(node)
{
this.token = node.token;
this.startIndex = node.startIndex;
this.stopIndex = node.stopIndex;
}
示例7: Add
private object Add(CommonTree tree)
{
var lhs = LhsOperand(tree);
var rhs = RhsOperand(tree);
return Operator.Add(lhs, rhs);
}
示例8: TestSeek
public void TestSeek()
{
// ^(101 ^(102 103 ^(106 107) ) 104 105)
// stream has 7 real + 6 nav nodes
// Sequence of types: 101 DN 102 DN 103 106 DN 107 UP UP 104 105 UP EOF
ITree r0 = new CommonTree( new CommonToken( 101 ) );
ITree r1 = new CommonTree( new CommonToken( 102 ) );
r0.AddChild( r1 );
r1.AddChild( new CommonTree( new CommonToken( 103 ) ) );
ITree r2 = new CommonTree( new CommonToken( 106 ) );
r2.AddChild( new CommonTree( new CommonToken( 107 ) ) );
r1.AddChild( r2 );
r0.AddChild( new CommonTree( new CommonToken( 104 ) ) );
r0.AddChild( new CommonTree( new CommonToken( 105 ) ) );
ITreeNodeStream stream = newStream( r0 );
stream.Consume(); // consume 101
stream.Consume(); // consume DN
stream.Consume(); // consume 102
stream.Seek( 7 ); // seek to 107
Assert.AreEqual( 107, ( (ITree)stream.LT( 1 ) ).Type );
stream.Consume(); // consume 107
stream.Consume(); // consume UP
stream.Consume(); // consume UP
Assert.AreEqual( 104, ( (ITree)stream.LT( 1 ) ).Type );
}
示例9: generateFile
public void generateFile(CommonTree ast, string fileName)
{
using (XmlWriter writer = XmlWriter.Create(fileName))
{
generate(ast, writer);
}
}
示例10: CountAltsForRule
public int CountAltsForRule( CommonTree t )
{
CommonTree block = (CommonTree)t.GetFirstChildWithType(BLOCK);
if (block == null || block.ChildCount == 0)
return 0;
return block.Children.Count(i => i.Type == ALT);
}
示例11: WalkChildren
protected void WalkChildren(CommonTree ast)
{
if (ast == null || ast.Children == null)
return;
foreach (CommonTree child in ast.Children)
Walk(child);
}
示例12: Extract
public static List<Expression> Extract(CommonTree tree)
{
var list = new List<Expression>();
if (tree.Children == null)
return list;
list.AddRange(tree.Children.Select(arg => new Expression(arg)));
return list;
}
示例13: HandleSignature
protected override void HandleSignature(CommonTree signature, IList<IToken> qualifiers, IList<CommonTree> names, CommonTree extendsSpec, CommonTree body, CommonTree block)
{
if (names == null)
return;
foreach (var name in names)
HandleSignatureOrEnum(signature, name);
}
示例14: CommonTree
public CommonTree(CommonTree node)
: base(node) {
if (node == null)
throw new ArgumentNullException("node");
this.token = node.token;
this.startIndex = node.startIndex;
this.stopIndex = node.stopIndex;
}
示例15: generateDocument
public XmlDocument generateDocument(CommonTree ast)
{
XmlDocument doc = new XmlDocument();
using (XmlWriter writer = doc.CreateNavigator().AppendChild())
{
generate(ast, writer);
}
return doc;
}