mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
28ed2b0cd9
commit
32db3f2756
7 changed files with 147 additions and 42 deletions
|
|
@ -229,7 +229,7 @@ redo:
|
|||
goto assignop
|
||||
}
|
||||
if c == '-' {
|
||||
s.tok = _Arrow
|
||||
s.tok = _Larrow
|
||||
break
|
||||
}
|
||||
s.ungetr()
|
||||
|
|
@ -253,11 +253,16 @@ redo:
|
|||
s.tok = _Operator
|
||||
|
||||
case '=':
|
||||
if s.getr() == '=' {
|
||||
c = s.getr()
|
||||
if c == '=' {
|
||||
s.op, s.prec = Eql, precCmp
|
||||
s.tok = _Operator
|
||||
break
|
||||
}
|
||||
if c == '>' {
|
||||
s.tok = _Rarrow
|
||||
break
|
||||
}
|
||||
s.ungetr()
|
||||
s.tok = _Assign
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue