add file trace to parser, refactor, fix inner type
This commit is contained in:
parent
bcf0978b68
commit
c8660a6471
10 changed files with 131 additions and 51 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue