cmd/compile/internal/syntax: allow more than one rune "unread"

Make it possible to "unread" more than one byte before the most
recently read rune. Use a better name than ungetr2 and make it
slightly more efficient.

R=Go1.13

Change-Id: I45d5dfa11e508259a972ca6560d1f78d7a51fe15
Reviewed-on: https://go-review.googlesource.com/c/158957
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Robert Griesemer 2019-01-22 15:20:50 -08:00
parent 701f6a27b5
commit 58365b34bb
2 changed files with 32 additions and 23 deletions

View file

@ -150,7 +150,7 @@ redo:
case '.':
c = s.getr()
if isDigit(c) {
s.ungetr2()
s.unread(1)
s.number('.')
break
}
@ -160,7 +160,7 @@ redo:
s.tok = _DotDotDot
break
}
s.ungetr2()
s.unread(1)
}
s.ungetr()
s.tok = _Dot