summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/goyacc/goyacc.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/cmd/goyacc/goyacc.go b/src/cmd/goyacc/goyacc.go
index 4e4819b40..4d9a515a6 100644
--- a/src/cmd/goyacc/goyacc.go
+++ b/src/cmd/goyacc/goyacc.go
@@ -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)