Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445package token
// operator handles all tokens that qualify as an operator.func operator(tokens List, buffer []byte, i Position) (List, Position) { position := i kind := Invalid increment := false
for { i++ current := buffer[position:i]
if i >= Position(len(buffer)) { kind, _ = operatorKind(current, 0) break }
next := buffer[i] kind, increment = operatorKind(current, next)
if kind != Invalid { if increment { i++ }
break }
if !increment { break } }
tokens = append(tokens, Token{Kind: kind, Position: position, Length: Length(i - position)}) return tokens, i}
func isOperator(c byte) bool { switch c { case '=', ':', '.', '+', '-', '*', '/', '<', '>', '&', '|', '^', '%', '!': return true default: return false }}