For #16339.
Change-Id: I0f83e46f13b5c8801aacf48fc8b690049edbbbff
Reviewed-on: https://go-review.googlesource.com/30210
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
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 '&':
{token.LAND, "&&", operator},
{token.LOR, "||", operator},
{token.ARROW, "<-", operator},
+ {token.ALIAS, "=>", operator},
{token.INC, "++", operator},
{token.DEC, "--", operator},
TYPE
VAR
keyword_end
+
+ // Alias support - must add at end to pass Go 1 compatibility test
+
+ ALIAS // =>
)
var tokens = [...]string{
SWITCH: "switch",
TYPE: "type",
VAR: "var",
+
+ ALIAS: "=>",
}
// String returns the string corresponding to the token tok.
// 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.