mirror of
https://github.com/golang/go.git
synced 2025-05-29 19:35:42 +00:00
go/parser: imaginary constants and ! may start an expression
Complete list of tokens that can start a top-level expression. R=rsc CC=golang-dev https://golang.org/cl/5671074
This commit is contained in:
parent
3908467b1f
commit
f43d2b7fa8
@ -1861,10 +1861,10 @@ func (p *parser) parseStmt() (s ast.Stmt) {
|
||||
case token.CONST, token.TYPE, token.VAR:
|
||||
s = &ast.DeclStmt{Decl: p.parseDecl()}
|
||||
case
|
||||
// tokens that may start a top-level expression
|
||||
token.IDENT, token.INT, token.FLOAT, token.CHAR, token.STRING, token.FUNC, token.LPAREN, // operand
|
||||
token.LBRACK, token.STRUCT, // composite type
|
||||
token.MUL, token.AND, token.ARROW, token.ADD, token.SUB, token.XOR: // unary operators
|
||||
// tokens that may start an expression
|
||||
token.IDENT, token.INT, token.FLOAT, token.IMAG, token.CHAR, token.STRING, token.FUNC, token.LPAREN, // operands
|
||||
token.LBRACK, token.STRUCT, // composite types
|
||||
token.ADD, token.SUB, token.MUL, token.AND, token.XOR, token.ARROW, token.NOT: // unary operators
|
||||
s, _ = p.parseSimpleStmt(labelOk)
|
||||
// because of the required look-ahead, labeled statements are
|
||||
// parsed by parseSimpleStmt - don't expect a semicolon after
|
||||
|
Loading…
x
Reference in New Issue
Block a user