Skip to content

Commit 22cbca5

Browse files
CIAvashalecthomas
authored andcommitted
Allow skipping group's emitter, via passing nil as emitter
1 parent 4b989ea commit 22cbca5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: regexp.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ func ByGroups(emitters ...Emitter) Emitter {
4343
// panic(errors.Errorf("number of groups %q does not match number of emitters %v", groups, emitters))
4444
} else {
4545
for i, group := range groups[1:] {
46-
iterators = append(iterators, emitters[i].Emit([]string{group}, state))
46+
if emitters[i] != nil {
47+
iterators = append(iterators, emitters[i].Emit([]string{group}, state))
48+
}
4749
}
4850
}
4951
return Concaterator(iterators...)
@@ -109,7 +111,7 @@ func UsingByGroup(sublexerGetFunc func(string) Lexer, sublexerNameGroup, codeGro
109111
if err != nil {
110112
panic(err)
111113
}
112-
} else {
114+
} else if emitters[i] != nil {
113115
iterators[i] = emitters[i].Emit([]string{group}, state)
114116
}
115117
}

0 commit comments

Comments
 (0)