提交 d7286819 编写于 作者: chai2010's avatar chai2010

type 指令支持冒号分隔符

上级 650cd479
......@@ -798,11 +798,12 @@ type (
// A TypeSpec node represents a type declaration (TypeSpec production).
TypeSpec struct {
Doc *CommentGroup // associated documentation; or nil
Name *Ident // type name
Assign token.Pos // position of '=', if any
Type Expr // *Ident, *ParenExpr, *SelectorExpr, *StarExpr, or any of the *XxxTypes
Comment *CommentGroup // line comments; or nil
Doc *CommentGroup // associated documentation; or nil
Name *Ident // type name
ColonPos token.Pos // position of ":" operator (token.NoPos if there is no ":")
Assign token.Pos // position of '=', if any
Type Expr // *Ident, *ParenExpr, *SelectorExpr, *StarExpr, or any of the *XxxTypes
Comment *CommentGroup // line comments; or nil
}
)
......
......@@ -2297,7 +2297,10 @@ func (p *parser) parseTypeSpec(doc *ast.CommentGroup, _ token.Token, _ int) ast.
// (Global identifiers are resolved in a separate phase after parsing.)
spec := &ast.TypeSpec{Doc: doc, Name: ident}
p.declare(spec, nil, p.topScope, ast.Typ, ident)
if p.tok == token.ASSIGN {
if p.tok == token.COLON {
spec.ColonPos = p.pos
p.next()
} else if p.tok == token.ASSIGN {
spec.Assign = p.pos
p.next()
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册