Added token package
All checks were successful
/ test (push) Successful in 15s

This commit is contained in:
Eduard Urbach 2025-06-19 15:58:29 +02:00
parent 38bd387002
commit 1405d2b8b1
Signed by: akyoto
GPG key ID: 49226B848C78F6C8
18 changed files with 1500 additions and 0 deletions

35
src/token/zero.go Normal file
View file

@ -0,0 +1,35 @@
package token
// zero handles all tokens starting with a '0'.
func zero(tokens List, buffer []byte, i Position) (List, Position) {
position := i
i++
if i >= Position(len(buffer)) {
tokens = append(tokens, Token{Kind: Number, Position: position, Length: 1})
return tokens, i
}
filter := isDigit
switch buffer[i] {
case 'x':
i++
filter = isHexDigit
case 'b':
i++
filter = isBinaryDigit
case 'o':
i++
filter = isOctalDigit
}
for i < Position(len(buffer)) && filter(buffer[i]) {
i++
}
tokens = append(tokens, Token{Kind: Number, Position: position, Length: Length(i - position)})
return tokens, i
}