当前位置: 首页>>代码示例>>C#>>正文


C# CommonTree.XChildren方法代码示例

本文整理汇总了C#中Antlr.Runtime.Tree.CommonTree.XChildren方法的典型用法代码示例。如果您正苦于以下问题:C# CommonTree.XChildren方法的具体用法?C# CommonTree.XChildren怎么用?C# CommonTree.XChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Antlr.Runtime.Tree.CommonTree的用法示例。


在下文中一共展示了CommonTree.XChildren方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseAssignment

        private IEnumerable<AstNode> ParseAssignment(CommonTree node)
        {
            var target = ParseAntlrNode(node.XChildren()[0]).Single();
            if (!(target is VariableExpression))
            {
                throw new SemanticErrorException(ElfCode, node, ElfExceptionType.InvalidAssignmentLhs);
            }

            var expression = (Expression)ParseAntlrNode(node.XChildren()[1]).Single();
            yield return new AssignmentExpression((VariableExpression)target, expression);
        }
开发者ID:xeno-by,项目名称:elf4b,代码行数:11,代码来源:ElfAstBuilder.cs

示例2: ParseRegularInvocation

 private IEnumerable<AstNode> ParseRegularInvocation(CommonTree node)
 {
     CheckIfLoophole(node);
     yield return new InvocationExpression(node.XChildren()[0].Text,
         ParseAntlrNode(node.XChildren()[1].Children).Cast<Expression>());
 }
开发者ID:xeno-by,项目名称:elf4b,代码行数:6,代码来源:ElfAstBuilder.cs

示例3: ParseIf

        private IEnumerable<AstNode> ParseIf(CommonTree node)
        {
            var test = (Expression)ParseAntlrNode(node.XChildren()[0]).Single();
            var then = (Block)ParseAntlrNode(node.XChildren()[1]).Single();

            if (node.XChildren().Count() == 2)
            {
                yield return new IfStatement(test, then);
            }
            else
            {
                var @else = (Block)ParseAntlrNode(node.XChildren()[2]).Single();
                yield return new IfStatement(test, then, @else);
            }
        }
开发者ID:xeno-by,项目名称:elf4b,代码行数:15,代码来源:ElfAstBuilder.cs

示例4: ParseParexpr

 private IEnumerable<AstNode> ParseParexpr(CommonTree node)
 {
     yield return ParseAntlrNode(node.XChildren().ElementAt(0)).Single();
 }
开发者ID:xeno-by,项目名称:elf4b,代码行数:4,代码来源:ElfAstBuilder.cs

示例5: ParseRet

 private IEnumerable<AstNode> ParseRet(CommonTree node)
 {
     if (node.XChildren().Count() == 0)
     {
         yield return new ReturnStatement();
     }
     else
     {
         yield return new ReturnStatement((Expression)ParseAntlrNode(node.XChildren()[0]).Single());
     }
 }
开发者ID:xeno-by,项目名称:elf4b,代码行数:11,代码来源:ElfAstBuilder.cs

示例6: ParseVar

 private IEnumerable<AstNode> ParseVar(CommonTree node)
 {
     foreach(var varDecl in node.XChildren())
     {
         if (varDecl.XChildren().Count() == 0)
         {
             yield return new VarStatement(varDecl.Text);
         }
         else
         {
             yield return new VarStatement(varDecl.XChildren()[0].Text);
             yield return new ExpressionStatement(
                 (AssignmentExpression)ParseAntlrNode(varDecl).Single());
         }
     }
 }
开发者ID:xeno-by,项目名称:elf4b,代码行数:16,代码来源:ElfAstBuilder.cs

示例7: ParseExpr

 private IEnumerable<AstNode> ParseExpr(CommonTree node)
 {
     yield return new ExpressionStatement((Expression)ParseAntlrNode(node.XChildren()[0]).Single());
 }
开发者ID:xeno-by,项目名称:elf4b,代码行数:4,代码来源:ElfAstBuilder.cs

示例8: ParseFunc

        private IEnumerable<AstNode> ParseFunc(CommonTree node)
        {
            var decl = node.XChildren().Single(c => c.Token.Type == ElfParser.DECL);
            var name = decl.XChildren()[0].Text;
            var args = decl.XChildren()[1].XChildren().Select(c => c.Text);
            var bodyBlock = node.XChildren()[1];

            yield return new FuncDef(name, args, (Block)ParseAntlrNode(bodyBlock).Single());
        }
开发者ID:xeno-by,项目名称:elf4b,代码行数:9,代码来源:ElfAstBuilder.cs

示例9: ParseClass

        private IEnumerable<AstNode> ParseClass(CommonTree node)
        {
            var decl = node.XChildren().Single(c => c.Token.Type == ElfParser.DECL);
            var name = decl.XChildren()[0].Text;
            var rtimpl = decl.XChildren()[1].XChildren().ElementAt(0).Text;

            yield return new ClassDef(name, rtimpl, ParseAntlrNode(node.XChildren().Skip(1)).Cast<FuncDef>());
        }
开发者ID:xeno-by,项目名称:elf4b,代码行数:8,代码来源:ElfAstBuilder.cs


注:本文中的Antlr.Runtime.Tree.CommonTree.XChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。