Files
db_in_45_steps_go/0301/sql_parser.go
T
2026-07-29 22:54:42 +02:00

51 lines
919 B
Go

package db0301
type Parser struct {
buf string
pos int
}
func NewParser(s string) Parser {
return Parser{buf: s, pos: 0}
}
func isSpace(ch byte) bool {
switch ch {
case '\t', '\n', '\v', '\f', '\r', ' ':
return true
}
return false
}
func isAlpha(ch byte) bool {
return 'a' <= (ch|32) && (ch|32) <= 'z'
}
func isDigit(ch byte) bool {
return '0' <= ch && ch <= '9'
}
func isNameStart(ch byte) bool {
return isAlpha(ch) || ch == '_'
}
func isNameContinue(ch byte) bool {
return isAlpha(ch) || isDigit(ch) || ch == '_'
}
func isSeparator(ch byte) bool {
return ch < 128 && !isNameContinue(ch)
}
func (p *Parser) skipSpaces() {
for p.pos < len(p.buf) && isSpace(p.buf[p.pos]) {
p.pos += 1
}
}
func (p *Parser) tryKeyword(kw string) bool
func (p *Parser) tryName() (string, bool)
func (p *Parser) isEnd() bool {
p.skipSpaces()
return p.pos >= len(p.buf)
}
// QzBQWVJJOUhU https://trialofcode.org/