// An Ident node represents an identifier.
Ident struct {
token.Position; // identifier position
- Lit []byte; // identifier string (e.g. foobar)
+ Value string; // identifier string (e.g. foobar)
};
// An Ellipsis node stands for the "..." type in a
// An IntLit node represents an integer literal.
IntLit struct {
token.Position; // int literal position
- Lit []byte; // literal string; e.g. 42 or 0x7f
+ Value []byte; // literal string; e.g. 42 or 0x7f
};
// A FloatLit node represents a floating-point literal.
FloatLit struct {
token.Position; // float literal position
- Lit []byte; // literal string; e.g. 3.14 or 1e-9
+ Value []byte; // literal string; e.g. 3.14 or 1e-9
};
// A CharLit node represents a character literal.
CharLit struct {
token.Position; // char literal position
- Lit []byte; // literal string, including quotes; e.g. 'a' or '\x7f'
+ Value []byte; // literal string, including quotes; e.g. 'a' or '\x7f'
};
// A StringLit node represents a string literal.
StringLit struct {
token.Position; // string literal position
- Lit []byte; // literal string, including quotes; e.g. "foo" or `\m\n\o`
+ Value []byte; // literal string, including quotes; e.g. "foo" or `\m\n\o`
};
// A StringList node represents a sequence of adjacent string literals.
};
// A UnaryExpr node represents a unary expression.
- // Unary "*" expressions are represented via DerefExpr nodes.
+ // Unary "*" expressions are represented via StarExpr nodes.
//
UnaryExpr struct {
token.Position; // position of Op
func (p *parser) parseIdent() *ast.Ident {
if p.tok == token.IDENT {
- x := &ast.Ident{p.pos, p.lit};
+ x := &ast.Ident{p.pos, string(p.lit)};
p.next();
return x;
}
p.expect(token.IDENT); // use expect() error handling
- return &ast.Ident{p.pos, [0]byte{}};
+ return &ast.Ident{p.pos, ""};
}
if !is_ident {
pos := list.At(i).(ast.Expr).Pos();
p.error_expected(pos, "identifier");
- idents[i] = &ast.Ident{pos, []byte{}};
+ idents[i] = &ast.Ident{pos, ""};
}
idents[i] = ident;
}
var typ ast.Expr;
if p.tok == token.TYPE {
// special case for type switch
- typ = &ast.Ident{p.pos, p.lit};
+ typ = &ast.Ident{p.pos, "type"};
p.next();
} else {
typ = p.parseType();
var ident *ast.Ident;
if p.tok == token.PERIOD {
- ident = &ast.Ident{p.pos, []byte{'.'}};
+ ident = &ast.Ident{p.pos, "."};
p.next();
} else if p.tok == token.IDENT {
ident = p.parseIdent();