Dmitry Panov 6 éve
szülő
commit
ef30b0537d
6 módosított fájl, 11 hozzáadás és 15 törlés
  1. 1 1
      parser/lexer.go
  2. 3 3
      parser/parser.go
  3. 0 1
      parser/regexp.go
  4. 2 2
      parser/regexp_test.go
  5. 4 4
      parser/statement.go
  6. 1 4
      parser/testutil_test.go

+ 1 - 1
parser/lexer.go

@@ -631,7 +631,7 @@ func parseStringLiteral(literal string) (string, error) {
 	str := literal
 	buffer := bytes.NewBuffer(make([]byte, 0, 3*len(literal)/2))
 	var surrogate rune
-	S:
+S:
 	for len(str) > 0 {
 		switch chr := str[0]; {
 		// We do not explicitly handle the case of the quote

+ 3 - 3
parser/parser.go

@@ -52,9 +52,9 @@ const (
 )
 
 type _parser struct {
-	str      string
-	length   int
-	base     int
+	str    string
+	length int
+	base   int
 
 	chr       rune // The current character
 	chrOffset int  // The offset of current character

+ 0 - 1
parser/regexp.go

@@ -144,7 +144,6 @@ func (self *_RegExp_parser) scanBracket() {
 		return
 	}
 
-
 	self.pass()
 	for self.chr != -1 {
 		if self.chr == ']' {

+ 2 - 2
parser/regexp_test.go

@@ -90,7 +90,7 @@ func TestRegExp(t *testing.T) {
 
 			test("(%)", "(%)")
 
-			test("(?:[%\\s])", "(?:[%" + WhitespaceChars +"])")
+			test("(?:[%\\s])", "(?:[%"+WhitespaceChars+"])")
 
 			test("[[]", "[[]")
 
@@ -121,7 +121,7 @@ func TestTransformRegExp(t *testing.T) {
 	tt(t, func() {
 		pattern, err := TransformRegExp(`\s+abc\s+`)
 		is(err, nil)
-		is(pattern, `[` + WhitespaceChars + `]+abc[` + WhitespaceChars +`]+`)
+		is(pattern, `[`+WhitespaceChars+`]+abc[`+WhitespaceChars+`]+`)
 		is(regexp.MustCompile(pattern).MatchString("\t abc def"), true)
 	})
 }

+ 4 - 4
parser/statement.go

@@ -1,15 +1,15 @@
 package parser
 
 import (
+	"encoding/base64"
 	"github.com/dop251/goja/ast"
 	"github.com/dop251/goja/file"
 	"github.com/dop251/goja/token"
 	"github.com/go-sourcemap/sourcemap"
-	"encoding/base64"
-	"strings"
-	"os"
 	"io/ioutil"
 	"net/url"
+	"os"
+	"strings"
 )
 
 func (self *_parser) parseBlockStatement() *ast.BlockStatement {
@@ -558,7 +558,7 @@ func (self *_parser) parseProgram() *ast.Program {
 }
 
 func (self *_parser) parseSourceMap() *sourcemap.Consumer {
-	lastLine := self.str[strings.LastIndexByte(self.str, '\n') + 1:]
+	lastLine := self.str[strings.LastIndexByte(self.str, '\n')+1:]
 	if strings.HasPrefix(lastLine, "//# sourceMappingURL") {
 		urlIndex := strings.Index(lastLine, "=")
 		urlStr := lastLine[urlIndex+1:]

+ 1 - 4
parser/testutil_test.go

@@ -2,9 +2,9 @@ package parser
 
 import (
 	"fmt"
+	"path/filepath"
 	"runtime"
 	"testing"
-	"path/filepath"
 )
 
 // Quick and dirty replacement for terst
@@ -20,7 +20,6 @@ func tt(t *testing.T, f func()) {
 	f()
 }
 
-
 func is(a, b interface{}) {
 	as := fmt.Sprintf("%v", a)
 	bs := fmt.Sprintf("%v", b)
@@ -28,5 +27,3 @@ func is(a, b interface{}) {
 		panic(fmt.Errorf("%+v(%T) != %+v(%T)", a, a, b, b))
 	}
 }
-
-