mirror of https://github.com/golang/go.git
go/scanner, go/token: recognize => (ALIAS) token
For #16339. Change-Id: I0f83e46f13b5c8801aacf48fc8b690049edbbbff Reviewed-on: https://go-review.googlesource.com/30210 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
c1e267cc73
commit
776a90100f
|
|
@ -731,7 +731,7 @@ scanAgain:
|
|||
case '>':
|
||||
tok = s.switch4(token.GTR, token.GEQ, '>', token.SHR, token.SHR_ASSIGN)
|
||||
case '=':
|
||||
tok = s.switch2(token.ASSIGN, token.EQL)
|
||||
tok = s.switch3(token.ASSIGN, token.EQL, '>', token.ALIAS)
|
||||
case '!':
|
||||
tok = s.switch2(token.NOT, token.NEQ)
|
||||
case '&':
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ var tokens = [...]elt{
|
|||
{token.LAND, "&&", operator},
|
||||
{token.LOR, "||", operator},
|
||||
{token.ARROW, "<-", operator},
|
||||
{token.ALIAS, "=>", operator},
|
||||
{token.INC, "++", operator},
|
||||
{token.DEC, "--", operator},
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,10 @@ const (
|
|||
TYPE
|
||||
VAR
|
||||
keyword_end
|
||||
|
||||
// Alias support - must add at end to pass Go 1 compatibility test
|
||||
|
||||
ALIAS // =>
|
||||
)
|
||||
|
||||
var tokens = [...]string{
|
||||
|
|
@ -221,6 +225,8 @@ var tokens = [...]string{
|
|||
SWITCH: "switch",
|
||||
TYPE: "type",
|
||||
VAR: "var",
|
||||
|
||||
ALIAS: "=>",
|
||||
}
|
||||
|
||||
// String returns the string corresponding to the token tok.
|
||||
|
|
@ -300,7 +306,7 @@ func (tok Token) IsLiteral() bool { return literal_beg < tok && tok < literal_en
|
|||
// IsOperator returns true for tokens corresponding to operators and
|
||||
// delimiters; it returns false otherwise.
|
||||
//
|
||||
func (tok Token) IsOperator() bool { return operator_beg < tok && tok < operator_end }
|
||||
func (tok Token) IsOperator() bool { return operator_beg < tok && tok < operator_end || tok == ALIAS }
|
||||
|
||||
// IsKeyword returns true for tokens corresponding to keywords;
|
||||
// it returns false otherwise.
|
||||
|
|
|
|||
Loading…
Reference in New Issue