Commit 38202de1 authored by Rob Pike's avatar Rob Pike

goyacc: fix handling of / and comments in goyacc

Fixes #618.

R=rsc
CC=golang-dev
https://golang.org/cl/217094
parent 8ba5c559
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment