Reformatting

This commit is contained in:
Jan Eitzinger 2022-11-09 14:05:27 +01:00
parent 9f9cc0c3ca
commit dffd393c0d

View File

@ -118,23 +118,29 @@ func ParseNodeList(raw string) (NodeList, error) {
exprs := []interface { exprs := []interface {
consume(input string) (next string, ok bool) consume(input string) (next string, ok bool)
}{} }{}
for i := 0; i < len(rawterm); i++ { for i := 0; i < len(rawterm); i++ {
c := rawterm[i] c := rawterm[i]
if isLetter(c) || isDigit(c) { if isLetter(c) || isDigit(c) {
j := i j := i
for j < len(rawterm) && (isLetter(rawterm[j]) || isDigit(rawterm[j]) || isDash(rawterm[j])) { for j < len(rawterm) &&
(isLetter(rawterm[j]) ||
isDigit(rawterm[j]) ||
isDash(rawterm[j])) {
j++ j++
} }
exprs = append(exprs, NLExprString(rawterm[i:j])) exprs = append(exprs, NLExprString(rawterm[i:j]))
i = j - 1 i = j - 1
} else if c == '[' { } else if c == '[' {
end := strings.Index(rawterm[i:], "]") end := strings.Index(rawterm[i:], "]")
if end == -1 { if end == -1 {
return nil, fmt.Errorf("node list: unclosed '['") return nil, fmt.Errorf("node list: unclosed '['")
} }
parts := strings.Split(rawterm[i+1:i+end], ",") parts := strings.Split(rawterm[i+1:i+end], ",")
nles := NLExprIntRanges{} nles := NLExprIntRanges{}
for _, part := range parts { for _, part := range parts {
minus := strings.Index(part, "-") minus := strings.Index(part, "-")
if minus == -1 { if minus == -1 {