mirror of
https://github.com/rocky-linux/peridot.git
synced 2024-12-26 04:00:55 +00:00
39 lines
565 B
Go
39 lines
565 B
Go
package ini
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
var (
|
|
equalOp = []rune("=")
|
|
equalColonOp = []rune(":")
|
|
)
|
|
|
|
func isOp(b []rune) bool {
|
|
if len(b) == 0 {
|
|
return false
|
|
}
|
|
|
|
switch b[0] {
|
|
case '=':
|
|
return true
|
|
case ':':
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func newOpToken(b []rune) (Token, int, error) {
|
|
tok := Token{}
|
|
|
|
switch b[0] {
|
|
case '=':
|
|
tok = newToken(TokenOp, equalOp, NoneType)
|
|
case ':':
|
|
tok = newToken(TokenOp, equalColonOp, NoneType)
|
|
default:
|
|
return tok, 0, NewParseError(fmt.Sprintf("unexpected op type, %v", b[0]))
|
|
}
|
|
return tok, 1, nil
|
|
}
|