1
0
mirror of https://github.com/robertkrimen/otto synced 2025-09-28 18:45:22 +08:00

Fix not skipping /* & // after encountering them

This commit is contained in:
Robert Krimen 2012-10-20 13:45:58 -07:00
parent d291bdadca
commit cd4f36ce98
3 changed files with 28 additions and 3 deletions

View File

@ -13,7 +13,6 @@ TEST := -v .
TEST := -v --run Synopsis
TEST := -v --run _eval
TEST := -v --run Broken
TEST := -v --run ParseSuccess
TEST := -v --run OttoError
TEST := -v --run API
TEST := -v --run IsValidRegExp
@ -21,11 +20,13 @@ TEST := -v --run SwitchBreak
TEST := -v --run Unicode
TEST := -v --run _issue
TEST := -v --run String_fromCharCode
TEST := -v --run ParseFailure
TEST := -v --run Lexer\|Parse
TEST := -v --run Lexer
TEST := -v --run String_
TEST := -v --run RegExp
TEST := -v --run ParseSuccess
TEST := -v --run Parse
TEST := -v --run ParseFailure
TEST := .
test: test-i

View File

@ -159,12 +159,16 @@ func (self *_lexer) ScanSkip() int {
chr := self.peek()
switch {
case chr == '/':
read, _, _, _ := self.read(3)
read, _, found, width := self.read(2)
switch read[1] {
case '/':
self.tail += found
self.tailOffset += width
self.ScanLineComment()
lineCount += 1
case '*':
self.tail += found
self.tailOffset += width
lineCount += self.ScanBlockComment()
default:
goto RETURN

View File

@ -653,6 +653,12 @@ func TestParseSuccess(t *testing.T) {
---
{ @ xyzzy { <throw> { <new> TypeError "Nothing happens." } } }
`)
test(`
/abc/.source
---
{ @ { . { /abc/ } source } }
`)
}
func TestParseFailure(t *testing.T) {
@ -1393,6 +1399,20 @@ Label '_' has already been declared
---
Unexpected token ( 2:-:-
`)
test(`
/*/
---
Unexpected token ILLEGAL
0:0:0
`)
test(`
/*/.source
---
Unexpected token ILLEGAL
0:0:0
`)
}
func TestParseComment(t *testing.T) {