Commit 776a9010 authored by Robert Griesemer's avatar Robert Griesemer

go/scanner, go/token: recognize => (ALIAS) token

For #16339.

Change-Id: I0f83e46f13b5c8801aacf48fc8b690049edbbbff
Reviewed-on: https://go-review.googlesource.com/30210Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
parent c1e267cc
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment