mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 16:52:18 +01:00
Change Token.Line from int32 to uint32.
This commit is contained in:
1 parent
0cfb27db56
commit
a48bbf6d2e
2 files changed
+7
-4
No files matched your search
+2
-2
@@ -26,10 +26,10 @@ type parser struct {
|
|||||||
src []t.Token
|
src []t.Token
|
||||||
m *t.IDMap
|
m *t.IDMap
|
||||||
filename string
|
filename string
|
||||||
lastLine int32
|
lastLine uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) line() int32 {
|
func (p *parser) line() uint32 {
|
||||||
if len(p.src) != 0 {
|
if len(p.src) != 0 {
|
||||||
return p.src[0].Line
|
return p.src[0].Line
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -63,7 +63,7 @@ func (m *IDMap) ByKey(k Key) string {
|
|||||||
|
|
||||||
type Token struct {
|
type Token struct {
|
||||||
ID ID
|
ID ID
|
||||||
Line int32
|
Line uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func alpha(c byte) bool {
|
func alpha(c byte) bool {
|
||||||
@@ -95,7 +95,7 @@ func hasPrefix(a []byte, s string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Tokenize(src []byte, m *IDMap, filename string) (tokens []Token, retErr error) {
|
func Tokenize(src []byte, m *IDMap, filename string) (tokens []Token, retErr error) {
|
||||||
line := int32(1)
|
line := uint32(1)
|
||||||
loop:
|
loop:
|
||||||
for i := 0; i < len(src); {
|
for i := 0; i < len(src); {
|
||||||
c := src[i]
|
c := src[i]
|
||||||
@@ -105,6 +105,9 @@ loop:
|
|||||||
if len(tokens) > 0 && tokens[len(tokens)-1].ID.IsImplicitSemicolon() {
|
if len(tokens) > 0 && tokens[len(tokens)-1].ID.IsImplicitSemicolon() {
|
||||||
tokens = append(tokens, Token{IDSemicolon, line})
|
tokens = append(tokens, Token{IDSemicolon, line})
|
||||||
}
|
}
|
||||||
|
if line == 1<<32-1 {
|
||||||
|
return nil, fmt.Errorf("token: too many lines in %q", filename)
|
||||||
|
}
|
||||||
line++
|
line++
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
|
|||||||
Reference in new issue
Block a user