add file trace to parser, refactor, fix inner type

This commit is contained in:
Neemek 2025-09-30 14:09:05 +02:00
parent bcf0978b68
commit c8660a6471
Signed by: neemek
GPG key ID: 84FFE4D7D40AB25E
10 changed files with 131 additions and 51 deletions

View file

@ -164,7 +164,7 @@ func (t TokenType) String() string {
return "hexadecimal"
}
return "UNDEFINED TOKENTYPE STRING CONVERSION"
panic("UNDEFINED TOKENTYPE STRING CONVERSION")
}
type Lexer struct {
@ -320,9 +320,9 @@ func (l *Lexer) NextToken() (Token, error) {
return l.makeToken(TokenString), nil
default:
if unicode.IsLetter(c) || c == '_' {
if l.isAlpha(c) {
// assemble variable
for l.isAlpha(l.peek()) {
for l.isAlphaNumeric(l.peek()) {
l.advance()
}
@ -435,7 +435,11 @@ func (l *Lexer) accept(c rune) bool {
}
func (l *Lexer) isAlpha(c rune) bool {
return unicode.IsLetter(c) || unicode.IsDigit(c) || c == '_'
return unicode.IsLetter(c) || c == '_'
}
func (l *Lexer) isAlphaNumeric(c rune) bool {
return l.isAlpha(c) || unicode.IsDigit(c)
}
func (l *Lexer) advance() {