1
0
mirror of https://github.com/golang/go synced 2024-11-25 06:57:58 -07:00

goyacc: fix handling of / and comments in goyacc

Fixes #618.

R=rsc
CC=golang-dev
https://golang.org/cl/217094
This commit is contained in:
Rob Pike 2010-02-23 16:00:14 +11:00
parent 8ba5c5593f
commit 38202de114

View File

@ -1352,13 +1352,31 @@ loop:
return
case '/':
nc := getrune(finput)
if nc != '/' && nc != '*' {
ungetrune(finput, nc)
break
}
// a comment
putrune(ftable, c)
putrune(ftable, nc)
c = getrune(finput)
for c != EOF {
if c == '\n' {
switch {
case c == '\n':
lineno++
break swt
if nc == '/' { // end of // comment
break swt
}
case c == '*' && nc == '*': // end of /* comment?
nnc := getrune(finput)
if nnc == '/' {
putrune(ftable, '*')
putrune(ftable, '/')
c = getrune(finput)
break swt
}
ungetrune(finput, nnc)
}
putrune(ftable, c)
c = getrune(finput)