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


Golang Node.LastChild方法代码示例

本文整理汇总了Golang中github.com/hailiang/gombi/parse.Node.LastChild方法的典型用法代码示例。如果您正苦于以下问题:Golang Node.LastChild方法的具体用法?Golang Node.LastChild怎么用?Golang Node.LastChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/hailiang/gombi/parse.Node的用法示例。


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

示例1: parseBlock

func (p *parser) parseBlock(n *parse.Node, scope *ast.Scope) *ast.BlockStmt {
	block := ast.BlockStmt{
		Lbrace: token.Pos(n.Child(0).Pos()),
		Rbrace: token.Pos(n.LastChild().Pos()),
	}
	eachListItem(stmt, n.Child(1), func(item *parse.Node) {
		block.List = append(block.List, p.parseStmt(item))
	})
	return &block
}
开发者ID:h12w,项目名称:gombi,代码行数:10,代码来源:parser.go

示例2: parseParams

func (p *parser) parseParams(n *parse.Node, scope *ast.Scope) *ast.FieldList {
	fieldList := ast.FieldList{
		Opening: token.Pos(n.Child(0).Pos()),
		Closing: token.Pos(n.LastChild().Pos()),
	}
	if n.Child(1).Is(parameterList) {
		eachListItem(parameterDecl, n.Child(1), func(item *parse.Node) {
			fieldList.List = append(fieldList.List, p.parseParamDecl(item, scope))
		})
	}
	return &fieldList
}
开发者ID:h12w,项目名称:gombi,代码行数:12,代码来源:parser.go

示例3: parseValueSpec

func (p *parser) parseValueSpec(n *parse.Node) *ast.ValueSpec {
	n = n.Child(0)
	spec := ast.ValueSpec{}
	if n.Is(identifierList) {
		spec.Names = p.parseIdentList(n)
	} else {
		spec.Names = p.parseIdentList(n.Child(0))
		if n.Child(1).Is(type_) {
			spec.Type = p.parseType(n.Child(1))
		}
		spec.Values = p.parseExprList(n.LastChild())
	}
	return &spec
}
开发者ID:h12w,项目名称:gombi,代码行数:14,代码来源:parser.go

示例4: 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,
	}
}
开发者ID:h12w,项目名称:gombi,代码行数:17,代码来源:parser.go

示例5: 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
}
开发者ID:h12w,项目名称:gombi,代码行数:23,代码来源:parser.go


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