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.
12345678910111213141516171819202122232425262728293031323334package token
// slash handles all tokens starting with '/'.func slash(tokens List, buffer []byte, i Position) (List, Position) { if i+1 < Position(len(buffer)) && buffer[i+1] == '/' { position := i
for i < Position(len(buffer)) && buffer[i] != '\n' { i++ }
tokens = append(tokens, Token{Kind: Comment, Position: position, Length: Length(i - position)}) } else { position := i i++
for i < Position(len(buffer)) && isOperator(buffer[i]) { i++ }
kind := Invalid
switch string(buffer[position:i]) { case "/": kind = Div case "/=": kind = DivAssign }
tokens = append(tokens, Token{Kind: kind, Position: position, Length: Length(i - position)}) }
return tokens, i}