1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-11-23 22:24:39 +02:00

Use a callback to emit tokens.

This is a) faster and b) supports streaming output.
This commit is contained in:
Alec Thomas
2017-06-02 15:15:15 +10:00
parent 6dd81b044b
commit b30de35ff1
7 changed files with 71 additions and 64 deletions

View File

@@ -176,6 +176,6 @@ func (t TokenType) InSubCategory(other TokenType) bool {
return t/100 == other/100
}
func (t TokenType) Emit(groups []string) []Token {
return []Token{Token{Type: t, Value: groups[0]}}
func (t TokenType) Emit(groups []string, out func(Token)) {
out(Token{Type: t, Value: groups[0]})
}