diff --git a/Makefile b/Makefile index dafa0c6..5221f88 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/lexer.go b/lexer.go index 23764fa..70b469e 100644 --- a/lexer.go +++ b/lexer.go @@ -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 diff --git a/parser_test.go b/parser_test.go index 3fd9000..fe39acd 100644 --- a/parser_test.go +++ b/parser_test.go @@ -653,6 +653,12 @@ func TestParseSuccess(t *testing.T) { --- { @ xyzzy { { 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) {