2017-04-05 14:01:31 +00:00
|
|
|
package slinguist
|
|
|
|
|
2017-04-18 06:57:59 +00:00
|
|
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.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"
|
|
|
|
)
|
|
|
|
|
|
|
|
type languageMatcher func ([]byte) (string, bool)
|
|
|
|
|
2017-05-29 08:05:16 +00:00
|
|
|
var contentMatchers = map[string]languageMatcher{
|
2017-04-05 14:01:31 +00:00
|
|
|
{{ range $index, $disambiguator := . -}}
|
|
|
|
{{ printf "%q" $disambiguator.Extension }}: func(i []byte) (string, bool) {
|
|
|
|
{{ 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 }} {
|
|
|
|
return {{ printf "%q" $language.Language }}, true
|
|
|
|
}
|
|
|
|
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end}}
|
|
|
|
|
|
|
|
return {{ returnLanguage $disambiguator.Languages }}, {{ safeLanguage $disambiguator.Languages }}
|
|
|
|
},
|
|
|
|
{{ end -}}
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
{{ range $index, $heuristic := getAllHeuristics . -}}
|
|
|
|
{{ $heuristic.Name }} = regexp.MustCompile(`{{ $heuristic.Regexp }}`)
|
|
|
|
{{ end -}}
|
|
|
|
)
|