tartrazine/internal/code-generator/assets/content.go.tmpl

39 lines
1.1 KiB
Cheetah
Raw Normal View History

2017-06-13 11:56:07 +00:00
package enry
2017-04-05 14:01:31 +00:00
2017-06-08 07:27:27 +00:00
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
2017-04-05 14:01:31 +00:00
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: {{ getCommit }}
import (
"regexp"
)
2017-05-31 10:07:46 +00:00
type languageMatcher func ([]byte) []string
2017-04-05 14:01:31 +00:00
2017-05-29 08:05:16 +00:00
var contentMatchers = map[string]languageMatcher{
2017-04-05 14:01:31 +00:00
{{ range $index, $disambiguator := . -}}
2017-05-31 10:07:46 +00:00
{{ printf "%q" $disambiguator.Extension }}: func(i []byte) []string {
2017-04-05 14:01:31 +00:00
{{ range $i, $language := $disambiguator.Languages -}}
{{- if not (avoidLanguage $language) }}
{{- if gt (len $language.Heuristics) 0 }}
{{- if gt $i 0 }} else {{ end -}}
if {{- range $j, $heuristic := $language.Heuristics }} {{ $heuristic.Name }}.Match(i)
{{- if lt $j (len $language.LogicRelations) }} {{index $language.LogicRelations $j}} {{- end -}} {{ end }} {
2017-05-31 10:07:46 +00:00
return []string{ {{- printf "%q" $language.Language -}} }
2017-04-05 14:01:31 +00:00
}
{{- end -}}
{{- end -}}
{{- end}}
2017-05-31 10:07:46 +00:00
return {{ returnLanguages $disambiguator.Languages | returnStringSlice }}
2017-04-05 14:01:31 +00:00
},
{{ end -}}
}
var (
{{ range $index, $heuristic := getAllHeuristics . -}}
{{ $heuristic.Name }} = regexp.MustCompile(`{{ $heuristic.Regexp }}`)
{{ end -}}
)