mirror of
https://github.com/golang/go
synced 2024-11-21 19:54:41 -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:
parent
8ba5c5593f
commit
38202de114
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user