diff --git a/jsonstring.go b/jsonstring.go index e9aef83..741d275 100644 --- a/jsonstring.go +++ b/jsonstring.go @@ -59,8 +59,8 @@ var jsonReplacer = newByteReplacer(func() ([]byte, []string) { }()) type byteReplacer struct { - m [256]byte newStrings []string + m [256]byte } func newByteReplacer(oldChars []byte, newStrings []string) *byteReplacer { @@ -79,7 +79,7 @@ func newByteReplacer(oldChars []byte, newStrings []string) *byteReplacer { m[c] = byte(i) } return &byteReplacer{ - m: m, + m: m, newStrings: newStrings, } } diff --git a/parser/parser.go b/parser/parser.go index a3901f3..a546471 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -13,14 +13,15 @@ import ( ) type parser struct { - s *scanner - w io.Writer - packageName string + w io.Writer + s *scanner + packageName string + prefix string + forDepth int + switchDepth int + skipOutputDepth int + skipLineComments bool - prefix string - forDepth int - switchDepth int - skipOutputDepth int importsUseEmitted bool packageNameEmitted bool diff --git a/parser/scanner.go b/parser/scanner.go index 3be2d37..396a99d 100644 --- a/parser/scanner.go +++ b/parser/scanner.go @@ -31,9 +31,10 @@ func tokenIDToStr(id int) string { } type token struct { - ID int Value []byte + ID int + line int pos int } @@ -51,25 +52,29 @@ func (t *token) String() string { } type scanner struct { - r *bufio.Reader - t token - c byte err error + r *bufio.Reader + filePath string - line int lineStr []byte - nextTokenID int - - capture bool capturedValue []byte + t token + + line int + + nextTokenID int + collapseSpaceDepth int stripSpaceDepth int - stripToNewLine bool - rewind bool + c byte + + capture bool + stripToNewLine bool + rewind bool } var tailOfLine = regexp.MustCompile(`^[[:blank:]]*(?:\r*\n)?`) diff --git a/parser/scanner_test.go b/parser/scanner_test.go index 0583c32..fa8d47d 100644 --- a/parser/scanner_test.go +++ b/parser/scanner_test.go @@ -323,6 +323,6 @@ func testScannerSuccess(t *testing.T, str string, expectedTokens []tt) { } type tt struct { - ID int Value string + ID int }