本文整理汇总了Golang中github.com/hailiang/gombi/parse.Node.ChildCount方法的典型用法代码示例。如果您正苦于以下问题:Golang Node.ChildCount方法的具体用法?Golang Node.ChildCount怎么用?Golang Node.ChildCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/hailiang/gombi/parse.Node
的用法示例。
在下文中一共展示了Node.ChildCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: parseLiteralValue
func (p *parser) parseLiteralValue(n *parse.Node) (exprs []ast.Expr) {
if n.ChildCount() == 3 {
eachListItem(element, n.Child(1), func(item *parse.Node) {
exprs = append(exprs, p.parseElement(item))
})
}
return
}
示例2: eachInlineListItem
func eachInlineListItem(n *parse.Node, visit func(*parse.Node)) {
visit(n.Child(0))
if n.ChildCount() > 1 {
n.Child(1).EachItem(func(item *parse.Node) {
visit(item.Child(1))
})
}
return
}
示例3: parseSignature
func (p *parser) parseSignature(n *parse.Node, scope *ast.Scope) *ast.FuncType {
funcType := ast.FuncType{
Params: p.parseParams(n.Child(0), scope),
}
if n.ChildCount() > 1 {
funcType.Results = p.parseResults(n.Child(1), scope)
}
return &funcType
}
示例4: parseReturnStmt
func (p *parser) parseReturnStmt(n *parse.Node) ast.Stmt {
ret := ast.ReturnStmt{
Return: token.Pos(n.Child(0).Pos()),
}
if n.ChildCount() > 1 {
ret.Results = p.parseExprList(n.Child(1))
}
return &ret
}
示例5: parseInterfaceType
func (p *parser) parseInterfaceType(n *parse.Node) ast.Expr {
keywordPos := token.Pos(n.Child(0).Pos())
n = n.Child(1)
specs := ast.FieldList{
Opening: token.Pos(n.Child(0).Pos()),
Closing: token.Pos(n.LastChild().Pos()),
}
if n.ChildCount() > 2 {
eachListItem(methodSpec, n.Child(1), func(item *parse.Node) {
specs.List = append(specs.List, p.parseMethodSpec(item))
})
}
return &ast.InterfaceType{
Interface: keywordPos,
Methods: &specs,
}
}
示例6: parseExpr
func (p *parser) parseExpr(n *parse.Node) ast.Expr {
if n == nil {
return nil // ??
}
switch n.ChildCount() {
case 1:
return p.parseUnaryExpr(n.Child(0))
case 3:
op := n.Child(1).Child(0).Child(0)
return &ast.BinaryExpr{
X: p.parseExpr(n.Child(0)),
OpPos: token.Pos(op.Pos()),
Op: token.Token(op.ID()),
Y: p.parseUnaryExpr(n.Child(2)),
}
}
return nil
}
示例7: parseImportDecl
func (p *parser) parseImportDecl(n *parse.Node) (decl *ast.GenDecl, specs []*ast.ImportSpec) {
decl = &ast.GenDecl{
TokPos: token.Pos(n.Child(0).Pos()),
Tok: token.IMPORT,
}
n = n.Child(1)
if n.Is(importSpec) {
spec := p.parseImportSpec(n)
specs = append(specs, spec)
decl.Specs = append(decl.Specs, spec)
return
}
decl.Lparen = token.Pos(n.Child(0).Pos())
decl.Rparen = token.Pos(n.LastChild().Pos())
if n.ChildCount() == 3 {
eachListItem(importSpec, n.Child(1), func(item *parse.Node) {
spec := p.parseImportSpec(item)
specs = append(specs, spec)
decl.Specs = append(decl.Specs, spec)
})
}
return
}