本文整理汇总了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);
}
示例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>());
}
示例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);
}
}
示例4: ParseParexpr
private IEnumerable<AstNode> ParseParexpr(CommonTree node)
{
yield return ParseAntlrNode(node.XChildren().ElementAt(0)).Single();
}
示例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());
}
}
示例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());
}
}
}
示例7: ParseExpr
private IEnumerable<AstNode> ParseExpr(CommonTree node)
{
yield return new ExpressionStatement((Expression)ParseAntlrNode(node.XChildren()[0]).Single());
}
示例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());
}
示例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>());
}