Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
3a50d721
Commit
3a50d721
authored
Nov 04, 2010
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/scanner: line comments may end in EOF
R=rsc CC=golang-dev
https://golang.org/cl/2908041
parent
132e5435
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
10 deletions
+7
-10
scanner.go
src/pkg/go/scanner/scanner.go
+3
-7
scanner_test.go
src/pkg/go/scanner/scanner_test.go
+4
-3
No files found.
src/pkg/go/scanner/scanner.go
View file @
3a50d721
...
...
@@ -183,20 +183,17 @@ func (S *Scanner) scanComment() {
if
S
.
ch
==
'/'
{
//-style comment
for
S
.
ch
>=
0
{
S
.
next
()
if
S
.
ch
==
'\n'
{
// '\n' is not part of the comment for purposes of scanning
// (the comment ends on the same line where it started)
for
S
.
ch
!=
'\n'
&&
S
.
ch
>=
0
{
S
.
next
()
}
if
col
==
1
{
// comment starts at the beginning of the current line
S
.
interpretLineComment
(
S
.
src
[
offs
:
S
.
offset
])
}
return
}
}
}
else
{
/*-style comment */
S
.
next
()
for
S
.
ch
>=
0
{
...
...
@@ -207,7 +204,6 @@ func (S *Scanner) scanComment() {
return
}
}
}
S
.
errorAt
(
pos
,
"comment not terminated"
)
}
...
...
src/pkg/go/scanner/scanner_test.go
View file @
3a50d721
...
...
@@ -395,12 +395,14 @@ var lines = []string{
"var
\n
"
,
"foo$//comment
\n
"
,
"foo$//comment"
,
"foo$/*comment*/
\n
"
,
"foo$/*
\n
*/"
,
"foo$/*comment*/
\n
"
,
"foo$/*
\n
*/ "
,
"foo $// comment
\n
"
,
"foo $// comment"
,
"foo $/*comment*/
\n
"
,
"foo $/*
\n
*/"
,
"foo $/* */ /*
\n
*/ bar$/**/
\n
"
,
...
...
@@ -410,7 +412,8 @@ var lines = []string{
"foo $/*0*/ /*1*/ /*2*/
\n
"
,
"foo $/**/ /*-------------*/ /*----
\n
*/bar $/*
\n
*/baa$
\n
"
,
"foo $/* an EOF terminates a line */"
,
"foo $/* an EOF terminates a line *//*"
,
"foo $/* an EOF terminates a line */ /*"
,
"foo $/* an EOF terminates a line */ //"
,
"package main$
\n\n
func main() {
\n\t
if {
\n\t\t
return /* */ }$
\n
}$
\n
"
,
"package main$"
,
...
...
@@ -626,8 +629,6 @@ var errors = []struct {
{
"`"
,
token
.
STRING
,
0
,
"string not terminated"
},
{
"/**/"
,
token
.
COMMENT
,
0
,
""
},
{
"/*"
,
token
.
COMMENT
,
0
,
"comment not terminated"
},
{
"//
\n
"
,
token
.
COMMENT
,
0
,
""
},
{
"//"
,
token
.
COMMENT
,
0
,
"comment not terminated"
},
{
"077"
,
token
.
INT
,
0
,
""
},
{
"078."
,
token
.
FLOAT
,
0
,
""
},
{
"07801234567."
,
token
.
FLOAT
,
0
,
""
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment