MCPcopy Create free account
hub / github.com/go-git/go-git / tokenizeExpression

Function tokenizeExpression

internal/revision/scanner.go:15–44  ·  view source on GitHub ↗

tokenizeExpression aggregates a series of runes matching check predicate into a single string and provides given tokenType as token type

(ch rune, tokenType token, check runeCategoryValidator, r *bufio.Reader)

Source from the content-addressed store, hash-verified

13// tokenizeExpression aggregates a series of runes matching check predicate into a single
14// string and provides given tokenType as token type
15func tokenizeExpression(ch rune, tokenType token, check runeCategoryValidator, r *bufio.Reader) (token, string, error) {
16 var data []rune
17 data = append(data, ch)
18
19 for {
20 c, _, err := r.ReadRune()
21
22 if c == zeroRune {
23 break
24 }
25
26 if err != nil {
27 return tokenError, "", err
28 }
29
30 if check(c) {
31 data = append(data, c)
32 } else {
33 err := r.UnreadRune()
34
35 if err != nil {
36 return tokenError, "", err
37 }
38
39 return tokenType, string(data), nil
40 }
41 }
42
43 return tokenType, string(data), nil
44}
45
46var zeroRune = rune(0)
47

Callers 1

scanMethod · 0.85

Calls 1

checkFunction · 0.85

Tested by

no test coverage detected