本文整理汇总了C#中Antlr.Runtime.Tree.CommonTree类的典型用法代码示例。如果您正苦于以下问题:C# CommonTree类的具体用法?C# CommonTree怎么用?C# CommonTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonTree类属于Antlr.Runtime.Tree命名空间,在下文中一共展示了CommonTree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
}
开发者ID:bszafko,项目名称:antlrcs,代码行数:26,代码来源:TestTrees.cs
示例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;
}
开发者ID:brianex,项目名称:osu-sgl,代码行数:8,代码来源:UserFunction.cs
示例3: GetSpan
private SnapshotSpan? GetSpan(CommonTree tree)
{
if (tree == null)
return null;
return GetSpan(tree.Token);
}
开发者ID:sebandraos,项目名称:LangSvcV2,代码行数:7,代码来源:AlloyExpressionWalker.g3.cs
示例4: BindToAntlrNode
public AstNode BindToAntlrNode(CommonTree node)
{
// horrible, but works for now
if (AntlrNode == null)
AntlrNode = node;
return this;
}
开发者ID:xeno-by,项目名称:elf4b,代码行数:7,代码来源:AstNode.cs
示例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);
}
开发者ID:Colectica,项目名称:MetadataConverters,代码行数:32,代码来源:BlaiseInstrumentTreeWalker.cs
示例6: CommonTree
public CommonTree(CommonTree node)
: base(node)
{
this.token = node.token;
this.startIndex = node.startIndex;
this.stopIndex = node.stopIndex;
}
开发者ID:sebasjm,项目名称:antlr,代码行数:7,代码来源:CommonTree.cs
示例7: Add
private object Add(CommonTree tree)
{
var lhs = LhsOperand(tree);
var rhs = RhsOperand(tree);
return Operator.Add(lhs, rhs);
}
开发者ID:cstrahan,项目名称:chunky,代码行数:7,代码来源:ChunkyInterpreter.cs
示例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 );
}
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:26,代码来源:TestBufferedTreeNodeStream.cs
示例9: generateFile
public void generateFile(CommonTree ast, string fileName)
{
using (XmlWriter writer = XmlWriter.Create(fileName))
{
generate(ast, writer);
}
}
开发者ID:perfoon,项目名称:JavaScript-analyser,代码行数:7,代码来源:XmlTranslatorActivity.cs
示例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);
}
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:8,代码来源:DefineGrammarItemsWalkerHelper.cs
示例11: WalkChildren
protected void WalkChildren(CommonTree ast)
{
if (ast == null || ast.Children == null)
return;
foreach (CommonTree child in ast.Children)
Walk(child);
}
开发者ID:rhencke,项目名称:HiDPISteam,代码行数:8,代码来源:TreeWalker.cs
示例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;
}
开发者ID:jeffpanici75,项目名称:FastTemplate,代码行数:8,代码来源:FnArgs.cs
示例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);
}
开发者ID:sebandraos,项目名称:LangSvcV2,代码行数:8,代码来源:AlloyEditorNavigationSourceWalker.cs
示例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;
}
开发者ID:EightPillars,项目名称:PathwayEditor,代码行数:9,代码来源:CommonTree.cs
示例15: generateDocument
public XmlDocument generateDocument(CommonTree ast)
{
XmlDocument doc = new XmlDocument();
using (XmlWriter writer = doc.CreateNavigator().AppendChild())
{
generate(ast, writer);
}
return doc;
}
开发者ID:perfoon,项目名称:JavaScript-analyser,代码行数:9,代码来源:XmlTranslatorActivity.cs
示例16: DebugTreeGrammar
// Expected tree for function: ^(FUNC ID ( INT | ID ) expr)
/** Set up a local evaluator for a nested function call. The evaluator gets the definition
* tree of the function; the set of all defined functions (to find locally called ones); a
* pointer to the global variable memory; and the value of the function parameter to be
* added to the local memory.
*/
private DebugTreeGrammar(CommonTree function,
List<CommonTree> functionDefinitions,
IDictionary<string, BigInteger> globalMemory,
BigInteger paramValue)
: this(new CommonTreeNodeStream(function.GetChild(2)), functionDefinitions)
{
this.globalMemory = globalMemory;
localMemory[function.GetChild(1).Text] = paramValue;
}
开发者ID:jjchaverra,项目名称:antlr3,代码行数:15,代码来源:DebugTreeGrammarHelper.cs
示例17: VisitProgram
//Даний метод розпочинає обхід AST з кореня
public string VisitProgram(CommonTree tree)
{
//Початок обходу дітей кореневого вузла
foreach (CommonTree node in tree.Children.OfType<CommonTree>())
{
switch (node.Type)
{
case Y11Parser.BECOMES:
this.VisitAssign(node);//Якщо операція присвоєння
break;
case Y11Parser.GET:
this.VisitInput(node);//Якщо операція вводу
break;
case Y11Parser.PUT:
this.VisitOutput(node);//Якщо операція виводу
break;
case Y11Parser.VAR:
this.VisitInit(node);//Якщо оголошення змінних
break;
case Y11Parser.REP:
this.VisitCycle(node);//Якщо початок циклу
break;
default:
break;
}
}
program.AppendFormat(".assembly {0} ", AName);
program.AppendLine("{}");
program.AppendLine(".assembly extern mscorlib {}");
program.AppendLine(".method static void main()");
program.AppendLine("{");
program.AppendLine(".entrypoint");
program.AppendLine(".maxstack 100");
if (this.Variables.Count > 0)
{
string variableString = "int32 " + this.Variables.First();
foreach (string name in this.Variables.Skip(1))
{
variableString += ", int32 " + name;
}
program.AppendFormat(".locals init ({0}) \n", variableString);
}
program.Append(this.methodBody.ToString());
program.AppendLine("call string [mscorlib]System.Console::ReadLine()");
program.AppendLine("ret");
program.AppendLine("}");
return program.ToString();
}
开发者ID:BIZMONT,项目名称:Y11.IDE,代码行数:58,代码来源:AST.cs
示例18: Walk
void Walk(CommonTree tree)
{
if (tree.IsFunction()) {
AddMethod(tree);
}
if (tree.HasChildren()) {
WalkChildren(tree.Children);
}
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:10,代码来源:JavaScriptAstWalker.cs
示例19: getLastTreePosition
private static int getLastTreePosition(CommonTree tree)
{
IList children = tree.Children;
if (children == null)
{
return ((CommonToken)tree.Token).StopIndex + 1;
}
return getLastTreePosition((CommonTree)children[children.Count - 1]);
}
开发者ID:zpLin,项目名称:flashdevelop,代码行数:10,代码来源:AntlrUtilities.cs
示例20: getFirstTreeToken
private static IToken getFirstTreeToken(CommonTree tree)
{
IList children = tree.Children;
if (children == null)
{
return tree.Token;
}
return getFirstTreeToken((CommonTree)children[0]);
}
开发者ID:zpLin,项目名称:flashdevelop,代码行数:10,代码来源:AntlrUtilities.cs
注:本文中的Antlr.Runtime.Tree.CommonTree类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论