aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/tokens.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2016-09-15 17:40:26 -0700
committerRobert Griesemer <gri@golang.org>2016-09-16 20:58:20 +0000
commit32db3f2756324616b7c856ac9501deccc2491239 (patch)
tree28a6afe4150d7cdcda6f06a8abde0ffeb18de267 /src/cmd/compile/internal/syntax/tokens.go
parent28ed2b0cd9ad6e2015f073931c05c08e8bf7b247 (diff)
downloadgo-32db3f2756324616b7c856ac9501deccc2491239.tar.gz
go-32db3f2756324616b7c856ac9501deccc2491239.zip
cmd/compile/internal/syntax: support for alias declarations
Permits parsing of alias declarations with -newparser const/type/var/func T => p.T but the compiler will reject it with an error. For now this also accepts type T = p.T so we can experiment with a type-alias only scenario. - renamed _Arrow token to _Larrow (<-) - introduced _Rarrow token (=>) - introduced AliasDecl node - extended scanner to accept _Rarrow - extended parser and printer to handle alias declarations Change-Id: I0170d10a87df8255db9186d466b6fd405228c38e Reviewed-on: https://go-review.googlesource.com/29355 Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/syntax/tokens.go')
-rw-r--r--src/cmd/compile/internal/syntax/tokens.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/syntax/tokens.go b/src/cmd/compile/internal/syntax/tokens.go
index bd0118a141..4a02c0ce3b 100644
--- a/src/cmd/compile/internal/syntax/tokens.go
+++ b/src/cmd/compile/internal/syntax/tokens.go
@@ -22,7 +22,8 @@ const (
_IncOp
_Assign
_Define
- _Arrow
+ _Larrow
+ _Rarrow
_Star
// delimitors
@@ -69,6 +70,12 @@ const (
)
const (
+ // for AliasDecl
+ Const = _Const
+ Type = _Type
+ Var = _Var
+ Func = _Func
+
// for BranchStmt
Break = _Break
Continue = _Continue
@@ -94,7 +101,8 @@ var tokstrings = [...]string{
_IncOp: "opop",
_Assign: "=",
_Define: ":=",
- _Arrow: "<-",
+ _Larrow: "<-",
+ _Rarrow: "=>",
_Star: "*",
// delimitors