mirror of
https://github.com/golang/go.git
synced 2025-05-30 19:52:53 +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:
|
case token.CONST, token.TYPE, token.VAR:
|
||||||
s = &ast.DeclStmt{Decl: p.parseDecl()}
|
s = &ast.DeclStmt{Decl: p.parseDecl()}
|
||||||
case
|
case
|
||||||
// tokens that may start a top-level expression
|
// tokens that may start an expression
|
||||||
token.IDENT, token.INT, token.FLOAT, token.CHAR, token.STRING, token.FUNC, token.LPAREN, // operand
|
token.IDENT, token.INT, token.FLOAT, token.IMAG, token.CHAR, token.STRING, token.FUNC, token.LPAREN, // operands
|
||||||
token.LBRACK, token.STRUCT, // composite type
|
token.LBRACK, token.STRUCT, // composite types
|
||||||
token.MUL, token.AND, token.ARROW, token.ADD, token.SUB, token.XOR: // unary operators
|
token.ADD, token.SUB, token.MUL, token.AND, token.XOR, token.ARROW, token.NOT: // unary operators
|
||||||
s, _ = p.parseSimpleStmt(labelOk)
|
s, _ = p.parseSimpleStmt(labelOk)
|
||||||
// because of the required look-ahead, labeled statements are
|
// because of the required look-ahead, labeled statements are
|
||||||
// parsed by parseSimpleStmt - don't expect a semicolon after
|
// parsed by parseSimpleStmt - don't expect a semicolon after
|
||||||
|
Loading…
x
Reference in New Issue
Block a user