mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 13:32:24 +00:00
added shebang functionality
fixed autogenerated comment changed constant types names GetLanguageByShebang doesn't print errors languageInfo struct change to have only necessary fields GetLanguageByShebang has a comment now
This commit is contained in:
parent
2644a7c8da
commit
c6d74bca66
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
type Type int
|
type Type int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TypeUnknown Type = iota
|
Unknown Type = iota
|
||||||
TypeData
|
Data
|
||||||
TypeProgramming
|
Programming
|
||||||
TypeMarkup
|
Markup
|
||||||
TypeProse
|
Prose
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetLanguageType(language string) (langType Type) {
|
func GetLanguageType(language string) (langType Type) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -12,10 +12,8 @@ import (
|
|||||||
|
|
||||||
type languageInfo struct {
|
type languageInfo struct {
|
||||||
Type string `yaml:"type,omitempty"`
|
Type string `yaml:"type,omitempty"`
|
||||||
Aliases []string `yaml:"aliases,omitempty,flow"`
|
|
||||||
Extensions []string `yaml:"extensions,omitempty,flow"`
|
Extensions []string `yaml:"extensions,omitempty,flow"`
|
||||||
Interpreters []string `yaml:"interpreters,omitempty,flow"`
|
Interpreters []string `yaml:"interpreters,omitempty,flow"`
|
||||||
Group string `yaml:"group,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Languages reads from buf and builds languages.go file from languagesTmplPath.
|
// Languages reads from buf and builds languages.go file from languagesTmplPath.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
||||||
|
|
||||||
type Type int
|
type Type int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TypeUnknown Type = iota
|
Unknown Type = iota
|
||||||
TypeData
|
Data
|
||||||
TypeProgramming
|
Programming
|
||||||
TypeMarkup
|
Markup
|
||||||
TypeProse
|
Prose
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetLanguageType(language string) (langType Type) {
|
func GetLanguageType(language string) (langType Type) {
|
||||||
@ -20,8 +20,8 @@ func GetLanguageType(language string) (langType Type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var languagesType = map[string]Type{
|
var languagesType = map[string]Type{
|
||||||
"Scaml": TypeMarkup,
|
"Scaml": Markup,
|
||||||
"Scheme": TypeProgramming,
|
"Scheme": Programming,
|
||||||
"Scilab": TypeProgramming,
|
"Scilab": Programming,
|
||||||
"Self": TypeProgramming,
|
"Self": Programming,
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
type Type int
|
type Type int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TypeUnknown Type = iota
|
Unknown Type = iota
|
||||||
TypeData
|
Data
|
||||||
TypeProgramming
|
Programming
|
||||||
TypeMarkup
|
Markup
|
||||||
TypeProse
|
Prose
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetLanguageType(language string) (langType Type) {
|
func GetLanguageType(language string) (langType Type) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: {{ getCommit }}
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
@ -9,10 +9,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var typeToTypeConst = map[string]string{
|
var typeToTypeConst = map[string]string{
|
||||||
"data": "TypeData",
|
"data": "Data",
|
||||||
"programming": "TypeProgramming",
|
"programming": "Programming",
|
||||||
"markup": "TypeMarkup",
|
"markup": "Markup",
|
||||||
"prose": "TypeProse",
|
"prose": "Prose",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Types reads from buf and builds type.go file from typeTmplPath.
|
// Types reads from buf and builds type.go file from typeTmplPath.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
||||||
|
|
||||||
|
93
shebang.go
Normal file
93
shebang.go
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package slinguist
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"bytes"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
shebangExecHack = regexp.MustCompile(`exec (\w+).+\$0.+\$@`)
|
||||||
|
pythonVersion = regexp.MustCompile(`python\d\.\d+`)
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetLanguageByShebang returns the language of the given content looking for the shebang line,
|
||||||
|
// and safe to indicate the sureness of returned language.
|
||||||
|
func GetLanguageByShebang(content []byte) (lang string, safe bool) {
|
||||||
|
interpreter := getInterpreter(content)
|
||||||
|
lang = OtherLanguage
|
||||||
|
if langs, ok := languagesByInterpreter[interpreter]; ok {
|
||||||
|
lang = langs[0]
|
||||||
|
safe = len(langs) == 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getInterpreter(data []byte) (interpreter string) {
|
||||||
|
line := getFirstLine(data)
|
||||||
|
if !hasShebang(line) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip shebang
|
||||||
|
line = bytes.TrimSpace(line[2:])
|
||||||
|
|
||||||
|
splitted := bytes.Fields(line)
|
||||||
|
if bytes.Contains(splitted[0], []byte("env")) {
|
||||||
|
if len(splitted) > 1 {
|
||||||
|
interpreter = string(splitted[1])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
splittedPath := bytes.Split(splitted[0], []byte{'/'})
|
||||||
|
interpreter = string(splittedPath[len(splittedPath)-1])
|
||||||
|
}
|
||||||
|
|
||||||
|
if interpreter == "sh" {
|
||||||
|
interpreter = lookForMultilineExec(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
if pythonVersion.MatchString(interpreter) {
|
||||||
|
interpreter = interpreter[:strings.Index(interpreter, `.`)]
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getFirstLine(data []byte) []byte {
|
||||||
|
buf := bufio.NewScanner(bytes.NewReader(data))
|
||||||
|
buf.Scan()
|
||||||
|
line := buf.Bytes()
|
||||||
|
if err := buf.Err(); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return line
|
||||||
|
}
|
||||||
|
|
||||||
|
func hasShebang(line []byte) bool {
|
||||||
|
shebang := []byte{'#', '!'}
|
||||||
|
return bytes.HasPrefix(line, shebang)
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookForMultilineExec(data []byte) string {
|
||||||
|
const magicNumOfLines = 5
|
||||||
|
interpreter := "sh"
|
||||||
|
|
||||||
|
buf := bufio.NewScanner(bytes.NewReader(data))
|
||||||
|
for i := 0; i < magicNumOfLines && buf.Scan(); i++ {
|
||||||
|
line := buf.Bytes()
|
||||||
|
if shebangExecHack.Match(line) {
|
||||||
|
interpreter = shebangExecHack.FindStringSubmatch(string(line))[1]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := buf.Err(); err != nil {
|
||||||
|
return interpreter
|
||||||
|
}
|
||||||
|
|
||||||
|
return interpreter
|
||||||
|
}
|
60
shebang_test.go
Normal file
60
shebang_test.go
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package slinguist
|
||||||
|
|
||||||
|
import . "gopkg.in/check.v1"
|
||||||
|
|
||||||
|
const (
|
||||||
|
multilineExecHack = `#!/bin/sh
|
||||||
|
# Next line is comment in Tcl, but not in sh... \
|
||||||
|
exec tclsh "$0" ${1+"$@"}`
|
||||||
|
|
||||||
|
multilineNoExecHack = `#!/bin/sh
|
||||||
|
#<<<#
|
||||||
|
echo "A shell script in a zkl program ($0)"
|
||||||
|
echo "Now run zkl <this file> with Hello World as args"
|
||||||
|
zkl $0 Hello World!
|
||||||
|
exit
|
||||||
|
#<<<#
|
||||||
|
println("The shell script says ",vm.arglist.concat(" "));`
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *TSuite) TestGetLanguageByShebang(c *C) {
|
||||||
|
lang, safe := GetLanguageByShebang([]byte(`#!/unknown/interpreter`))
|
||||||
|
c.Assert(lang, Equals, OtherLanguage)
|
||||||
|
c.Assert(safe, Equals, false)
|
||||||
|
|
||||||
|
lang, safe = GetLanguageByShebang([]byte(`no shebang`))
|
||||||
|
c.Assert(lang, Equals, OtherLanguage)
|
||||||
|
c.Assert(safe, Equals, false)
|
||||||
|
|
||||||
|
lang, safe = GetLanguageByShebang([]byte(`#!/usr/bin/env`))
|
||||||
|
c.Assert(lang, Equals, OtherLanguage)
|
||||||
|
c.Assert(safe, Equals, false)
|
||||||
|
|
||||||
|
lang, safe = GetLanguageByShebang([]byte(`#!/usr/bin/python -tt`))
|
||||||
|
c.Assert(lang, Equals, "Python")
|
||||||
|
c.Assert(safe, Equals, true)
|
||||||
|
|
||||||
|
lang, safe = GetLanguageByShebang([]byte(`#!/usr/bin/env python2.6`))
|
||||||
|
c.Assert(lang, Equals, "Python")
|
||||||
|
c.Assert(safe, Equals, true)
|
||||||
|
|
||||||
|
lang, safe = GetLanguageByShebang([]byte(`#!/usr/bin/env perl`))
|
||||||
|
c.Assert(lang, Equals, "Perl")
|
||||||
|
c.Assert(safe, Equals, true)
|
||||||
|
|
||||||
|
lang, safe = GetLanguageByShebang([]byte(`#! /bin/sh`))
|
||||||
|
c.Assert(lang, Equals, "Shell")
|
||||||
|
c.Assert(safe, Equals, true)
|
||||||
|
|
||||||
|
lang, safe = GetLanguageByShebang([]byte(`#!bash`))
|
||||||
|
c.Assert(lang, Equals, "Shell")
|
||||||
|
c.Assert(safe, Equals, true)
|
||||||
|
|
||||||
|
lang, safe = GetLanguageByShebang([]byte(multilineExecHack))
|
||||||
|
c.Assert(lang, Equals, "Tcl")
|
||||||
|
c.Assert(safe, Equals, true)
|
||||||
|
|
||||||
|
lang, safe = GetLanguageByShebang([]byte(multilineNoExecHack))
|
||||||
|
c.Assert(lang, Equals, "Shell")
|
||||||
|
c.Assert(safe, Equals, true)
|
||||||
|
}
|
900
type.go
900
type.go
@ -1,17 +1,17 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
||||||
|
|
||||||
type Type int
|
type Type int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TypeUnknown Type = iota
|
Unknown Type = iota
|
||||||
TypeData
|
Data
|
||||||
TypeProgramming
|
Programming
|
||||||
TypeMarkup
|
Markup
|
||||||
TypeProse
|
Prose
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetLanguageType(language string) (langType Type) {
|
func GetLanguageType(language string) (langType Type) {
|
||||||
@ -20,448 +20,448 @@ func GetLanguageType(language string) (langType Type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var languagesType = map[string]Type{
|
var languagesType = map[string]Type{
|
||||||
"1C Enterprise": TypeProgramming,
|
"1C Enterprise": Programming,
|
||||||
"ABAP": TypeProgramming,
|
"ABAP": Programming,
|
||||||
"ABNF": TypeData,
|
"ABNF": Data,
|
||||||
"AGS Script": TypeProgramming,
|
"AGS Script": Programming,
|
||||||
"AMPL": TypeProgramming,
|
"AMPL": Programming,
|
||||||
"ANTLR": TypeProgramming,
|
"ANTLR": Programming,
|
||||||
"API Blueprint": TypeMarkup,
|
"API Blueprint": Markup,
|
||||||
"APL": TypeProgramming,
|
"APL": Programming,
|
||||||
"ASN.1": TypeData,
|
"ASN.1": Data,
|
||||||
"ASP": TypeProgramming,
|
"ASP": Programming,
|
||||||
"ATS": TypeProgramming,
|
"ATS": Programming,
|
||||||
"ActionScript": TypeProgramming,
|
"ActionScript": Programming,
|
||||||
"Ada": TypeProgramming,
|
"Ada": Programming,
|
||||||
"Agda": TypeProgramming,
|
"Agda": Programming,
|
||||||
"Alloy": TypeProgramming,
|
"Alloy": Programming,
|
||||||
"Alpine Abuild": TypeProgramming,
|
"Alpine Abuild": Programming,
|
||||||
"Ant Build System": TypeData,
|
"Ant Build System": Data,
|
||||||
"ApacheConf": TypeMarkup,
|
"ApacheConf": Markup,
|
||||||
"Apex": TypeProgramming,
|
"Apex": Programming,
|
||||||
"Apollo Guidance Computer": TypeProgramming,
|
"Apollo Guidance Computer": Programming,
|
||||||
"AppleScript": TypeProgramming,
|
"AppleScript": Programming,
|
||||||
"Arc": TypeProgramming,
|
"Arc": Programming,
|
||||||
"Arduino": TypeProgramming,
|
"Arduino": Programming,
|
||||||
"AsciiDoc": TypeProse,
|
"AsciiDoc": Prose,
|
||||||
"AspectJ": TypeProgramming,
|
"AspectJ": Programming,
|
||||||
"Assembly": TypeProgramming,
|
"Assembly": Programming,
|
||||||
"Augeas": TypeProgramming,
|
"Augeas": Programming,
|
||||||
"AutoHotkey": TypeProgramming,
|
"AutoHotkey": Programming,
|
||||||
"AutoIt": TypeProgramming,
|
"AutoIt": Programming,
|
||||||
"Awk": TypeProgramming,
|
"Awk": Programming,
|
||||||
"Batchfile": TypeProgramming,
|
"Batchfile": Programming,
|
||||||
"Befunge": TypeProgramming,
|
"Befunge": Programming,
|
||||||
"Bison": TypeProgramming,
|
"Bison": Programming,
|
||||||
"BitBake": TypeProgramming,
|
"BitBake": Programming,
|
||||||
"Blade": TypeMarkup,
|
"Blade": Markup,
|
||||||
"BlitzBasic": TypeProgramming,
|
"BlitzBasic": Programming,
|
||||||
"BlitzMax": TypeProgramming,
|
"BlitzMax": Programming,
|
||||||
"Bluespec": TypeProgramming,
|
"Bluespec": Programming,
|
||||||
"Boo": TypeProgramming,
|
"Boo": Programming,
|
||||||
"Brainfuck": TypeProgramming,
|
"Brainfuck": Programming,
|
||||||
"Brightscript": TypeProgramming,
|
"Brightscript": Programming,
|
||||||
"Bro": TypeProgramming,
|
"Bro": Programming,
|
||||||
"C": TypeProgramming,
|
"C": Programming,
|
||||||
"C#": TypeProgramming,
|
"C#": Programming,
|
||||||
"C++": TypeProgramming,
|
"C++": Programming,
|
||||||
"C-ObjDump": TypeData,
|
"C-ObjDump": Data,
|
||||||
"C2hs Haskell": TypeProgramming,
|
"C2hs Haskell": Programming,
|
||||||
"CLIPS": TypeProgramming,
|
"CLIPS": Programming,
|
||||||
"CMake": TypeProgramming,
|
"CMake": Programming,
|
||||||
"COBOL": TypeProgramming,
|
"COBOL": Programming,
|
||||||
"COLLADA": TypeData,
|
"COLLADA": Data,
|
||||||
"CSON": TypeData,
|
"CSON": Data,
|
||||||
"CSS": TypeMarkup,
|
"CSS": Markup,
|
||||||
"CSV": TypeData,
|
"CSV": Data,
|
||||||
"Cap'n Proto": TypeProgramming,
|
"Cap'n Proto": Programming,
|
||||||
"CartoCSS": TypeProgramming,
|
"CartoCSS": Programming,
|
||||||
"Ceylon": TypeProgramming,
|
"Ceylon": Programming,
|
||||||
"Chapel": TypeProgramming,
|
"Chapel": Programming,
|
||||||
"Charity": TypeProgramming,
|
"Charity": Programming,
|
||||||
"ChucK": TypeProgramming,
|
"ChucK": Programming,
|
||||||
"Cirru": TypeProgramming,
|
"Cirru": Programming,
|
||||||
"Clarion": TypeProgramming,
|
"Clarion": Programming,
|
||||||
"Clean": TypeProgramming,
|
"Clean": Programming,
|
||||||
"Click": TypeProgramming,
|
"Click": Programming,
|
||||||
"Clojure": TypeProgramming,
|
"Clojure": Programming,
|
||||||
"CoffeeScript": TypeProgramming,
|
"CoffeeScript": Programming,
|
||||||
"ColdFusion": TypeProgramming,
|
"ColdFusion": Programming,
|
||||||
"ColdFusion CFC": TypeProgramming,
|
"ColdFusion CFC": Programming,
|
||||||
"Common Lisp": TypeProgramming,
|
"Common Lisp": Programming,
|
||||||
"Component Pascal": TypeProgramming,
|
"Component Pascal": Programming,
|
||||||
"Cool": TypeProgramming,
|
"Cool": Programming,
|
||||||
"Coq": TypeProgramming,
|
"Coq": Programming,
|
||||||
"Cpp-ObjDump": TypeData,
|
"Cpp-ObjDump": Data,
|
||||||
"Creole": TypeProse,
|
"Creole": Prose,
|
||||||
"Crystal": TypeProgramming,
|
"Crystal": Programming,
|
||||||
"Csound": TypeProgramming,
|
"Csound": Programming,
|
||||||
"Csound Document": TypeProgramming,
|
"Csound Document": Programming,
|
||||||
"Csound Score": TypeProgramming,
|
"Csound Score": Programming,
|
||||||
"Cuda": TypeProgramming,
|
"Cuda": Programming,
|
||||||
"Cycript": TypeProgramming,
|
"Cycript": Programming,
|
||||||
"Cython": TypeProgramming,
|
"Cython": Programming,
|
||||||
"D": TypeProgramming,
|
"D": Programming,
|
||||||
"D-ObjDump": TypeData,
|
"D-ObjDump": Data,
|
||||||
"DIGITAL Command Language": TypeProgramming,
|
"DIGITAL Command Language": Programming,
|
||||||
"DM": TypeProgramming,
|
"DM": Programming,
|
||||||
"DNS Zone": TypeData,
|
"DNS Zone": Data,
|
||||||
"DTrace": TypeProgramming,
|
"DTrace": Programming,
|
||||||
"Darcs Patch": TypeData,
|
"Darcs Patch": Data,
|
||||||
"Dart": TypeProgramming,
|
"Dart": Programming,
|
||||||
"Diff": TypeData,
|
"Diff": Data,
|
||||||
"Dockerfile": TypeData,
|
"Dockerfile": Data,
|
||||||
"Dogescript": TypeProgramming,
|
"Dogescript": Programming,
|
||||||
"Dylan": TypeProgramming,
|
"Dylan": Programming,
|
||||||
"E": TypeProgramming,
|
"E": Programming,
|
||||||
"EBNF": TypeData,
|
"EBNF": Data,
|
||||||
"ECL": TypeProgramming,
|
"ECL": Programming,
|
||||||
"ECLiPSe": TypeProgramming,
|
"ECLiPSe": Programming,
|
||||||
"EJS": TypeMarkup,
|
"EJS": Markup,
|
||||||
"EQ": TypeProgramming,
|
"EQ": Programming,
|
||||||
"Eagle": TypeMarkup,
|
"Eagle": Markup,
|
||||||
"Ecere Projects": TypeData,
|
"Ecere Projects": Data,
|
||||||
"Eiffel": TypeProgramming,
|
"Eiffel": Programming,
|
||||||
"Elixir": TypeProgramming,
|
"Elixir": Programming,
|
||||||
"Elm": TypeProgramming,
|
"Elm": Programming,
|
||||||
"Emacs Lisp": TypeProgramming,
|
"Emacs Lisp": Programming,
|
||||||
"EmberScript": TypeProgramming,
|
"EmberScript": Programming,
|
||||||
"Erlang": TypeProgramming,
|
"Erlang": Programming,
|
||||||
"F#": TypeProgramming,
|
"F#": Programming,
|
||||||
"FLUX": TypeProgramming,
|
"FLUX": Programming,
|
||||||
"Factor": TypeProgramming,
|
"Factor": Programming,
|
||||||
"Fancy": TypeProgramming,
|
"Fancy": Programming,
|
||||||
"Fantom": TypeProgramming,
|
"Fantom": Programming,
|
||||||
"Filebench WML": TypeProgramming,
|
"Filebench WML": Programming,
|
||||||
"Filterscript": TypeProgramming,
|
"Filterscript": Programming,
|
||||||
"Formatted": TypeData,
|
"Formatted": Data,
|
||||||
"Forth": TypeProgramming,
|
"Forth": Programming,
|
||||||
"Fortran": TypeProgramming,
|
"Fortran": Programming,
|
||||||
"FreeMarker": TypeProgramming,
|
"FreeMarker": Programming,
|
||||||
"Frege": TypeProgramming,
|
"Frege": Programming,
|
||||||
"G-code": TypeData,
|
"G-code": Data,
|
||||||
"GAMS": TypeProgramming,
|
"GAMS": Programming,
|
||||||
"GAP": TypeProgramming,
|
"GAP": Programming,
|
||||||
"GCC Machine Description": TypeProgramming,
|
"GCC Machine Description": Programming,
|
||||||
"GDB": TypeProgramming,
|
"GDB": Programming,
|
||||||
"GDScript": TypeProgramming,
|
"GDScript": Programming,
|
||||||
"GLSL": TypeProgramming,
|
"GLSL": Programming,
|
||||||
"GN": TypeData,
|
"GN": Data,
|
||||||
"Game Maker Language": TypeProgramming,
|
"Game Maker Language": Programming,
|
||||||
"Genie": TypeProgramming,
|
"Genie": Programming,
|
||||||
"Genshi": TypeProgramming,
|
"Genshi": Programming,
|
||||||
"Gentoo Ebuild": TypeProgramming,
|
"Gentoo Ebuild": Programming,
|
||||||
"Gentoo Eclass": TypeProgramming,
|
"Gentoo Eclass": Programming,
|
||||||
"Gettext Catalog": TypeProse,
|
"Gettext Catalog": Prose,
|
||||||
"Gherkin": TypeProgramming,
|
"Gherkin": Programming,
|
||||||
"Glyph": TypeProgramming,
|
"Glyph": Programming,
|
||||||
"Gnuplot": TypeProgramming,
|
"Gnuplot": Programming,
|
||||||
"Go": TypeProgramming,
|
"Go": Programming,
|
||||||
"Golo": TypeProgramming,
|
"Golo": Programming,
|
||||||
"Gosu": TypeProgramming,
|
"Gosu": Programming,
|
||||||
"Grace": TypeProgramming,
|
"Grace": Programming,
|
||||||
"Gradle": TypeData,
|
"Gradle": Data,
|
||||||
"Grammatical Framework": TypeProgramming,
|
"Grammatical Framework": Programming,
|
||||||
"Graph Modeling Language": TypeData,
|
"Graph Modeling Language": Data,
|
||||||
"GraphQL": TypeData,
|
"GraphQL": Data,
|
||||||
"Graphviz (DOT)": TypeData,
|
"Graphviz (DOT)": Data,
|
||||||
"Groovy": TypeProgramming,
|
"Groovy": Programming,
|
||||||
"Groovy Server Pages": TypeProgramming,
|
"Groovy Server Pages": Programming,
|
||||||
"HCL": TypeProgramming,
|
"HCL": Programming,
|
||||||
"HLSL": TypeProgramming,
|
"HLSL": Programming,
|
||||||
"HTML": TypeMarkup,
|
"HTML": Markup,
|
||||||
"HTML+Django": TypeMarkup,
|
"HTML+Django": Markup,
|
||||||
"HTML+ECR": TypeMarkup,
|
"HTML+ECR": Markup,
|
||||||
"HTML+EEX": TypeMarkup,
|
"HTML+EEX": Markup,
|
||||||
"HTML+ERB": TypeMarkup,
|
"HTML+ERB": Markup,
|
||||||
"HTML+PHP": TypeMarkup,
|
"HTML+PHP": Markup,
|
||||||
"HTTP": TypeData,
|
"HTTP": Data,
|
||||||
"Hack": TypeProgramming,
|
"Hack": Programming,
|
||||||
"Haml": TypeMarkup,
|
"Haml": Markup,
|
||||||
"Handlebars": TypeMarkup,
|
"Handlebars": Markup,
|
||||||
"Harbour": TypeProgramming,
|
"Harbour": Programming,
|
||||||
"Haskell": TypeProgramming,
|
"Haskell": Programming,
|
||||||
"Haxe": TypeProgramming,
|
"Haxe": Programming,
|
||||||
"Hy": TypeProgramming,
|
"Hy": Programming,
|
||||||
"HyPhy": TypeProgramming,
|
"HyPhy": Programming,
|
||||||
"IDL": TypeProgramming,
|
"IDL": Programming,
|
||||||
"IGOR Pro": TypeProgramming,
|
"IGOR Pro": Programming,
|
||||||
"INI": TypeData,
|
"INI": Data,
|
||||||
"IRC log": TypeData,
|
"IRC log": Data,
|
||||||
"Idris": TypeProgramming,
|
"Idris": Programming,
|
||||||
"Inform 7": TypeProgramming,
|
"Inform 7": Programming,
|
||||||
"Inno Setup": TypeProgramming,
|
"Inno Setup": Programming,
|
||||||
"Io": TypeProgramming,
|
"Io": Programming,
|
||||||
"Ioke": TypeProgramming,
|
"Ioke": Programming,
|
||||||
"Isabelle": TypeProgramming,
|
"Isabelle": Programming,
|
||||||
"Isabelle ROOT": TypeProgramming,
|
"Isabelle ROOT": Programming,
|
||||||
"J": TypeProgramming,
|
"J": Programming,
|
||||||
"JFlex": TypeProgramming,
|
"JFlex": Programming,
|
||||||
"JSON": TypeData,
|
"JSON": Data,
|
||||||
"JSON5": TypeData,
|
"JSON5": Data,
|
||||||
"JSONLD": TypeData,
|
"JSONLD": Data,
|
||||||
"JSONiq": TypeProgramming,
|
"JSONiq": Programming,
|
||||||
"JSX": TypeProgramming,
|
"JSX": Programming,
|
||||||
"Jasmin": TypeProgramming,
|
"Jasmin": Programming,
|
||||||
"Java": TypeProgramming,
|
"Java": Programming,
|
||||||
"Java Server Pages": TypeProgramming,
|
"Java Server Pages": Programming,
|
||||||
"JavaScript": TypeProgramming,
|
"JavaScript": Programming,
|
||||||
"Jison": TypeProgramming,
|
"Jison": Programming,
|
||||||
"Jison Lex": TypeProgramming,
|
"Jison Lex": Programming,
|
||||||
"Julia": TypeProgramming,
|
"Julia": Programming,
|
||||||
"Jupyter Notebook": TypeMarkup,
|
"Jupyter Notebook": Markup,
|
||||||
"KRL": TypeProgramming,
|
"KRL": Programming,
|
||||||
"KiCad": TypeProgramming,
|
"KiCad": Programming,
|
||||||
"Kit": TypeMarkup,
|
"Kit": Markup,
|
||||||
"Kotlin": TypeProgramming,
|
"Kotlin": Programming,
|
||||||
"LFE": TypeProgramming,
|
"LFE": Programming,
|
||||||
"LLVM": TypeProgramming,
|
"LLVM": Programming,
|
||||||
"LOLCODE": TypeProgramming,
|
"LOLCODE": Programming,
|
||||||
"LSL": TypeProgramming,
|
"LSL": Programming,
|
||||||
"LabVIEW": TypeProgramming,
|
"LabVIEW": Programming,
|
||||||
"Lasso": TypeProgramming,
|
"Lasso": Programming,
|
||||||
"Latte": TypeMarkup,
|
"Latte": Markup,
|
||||||
"Lean": TypeProgramming,
|
"Lean": Programming,
|
||||||
"Less": TypeMarkup,
|
"Less": Markup,
|
||||||
"Lex": TypeProgramming,
|
"Lex": Programming,
|
||||||
"LilyPond": TypeProgramming,
|
"LilyPond": Programming,
|
||||||
"Limbo": TypeProgramming,
|
"Limbo": Programming,
|
||||||
"Linker Script": TypeData,
|
"Linker Script": Data,
|
||||||
"Linux Kernel Module": TypeData,
|
"Linux Kernel Module": Data,
|
||||||
"Liquid": TypeMarkup,
|
"Liquid": Markup,
|
||||||
"Literate Agda": TypeProgramming,
|
"Literate Agda": Programming,
|
||||||
"Literate CoffeeScript": TypeProgramming,
|
"Literate CoffeeScript": Programming,
|
||||||
"Literate Haskell": TypeProgramming,
|
"Literate Haskell": Programming,
|
||||||
"LiveScript": TypeProgramming,
|
"LiveScript": Programming,
|
||||||
"Logos": TypeProgramming,
|
"Logos": Programming,
|
||||||
"Logtalk": TypeProgramming,
|
"Logtalk": Programming,
|
||||||
"LookML": TypeProgramming,
|
"LookML": Programming,
|
||||||
"LoomScript": TypeProgramming,
|
"LoomScript": Programming,
|
||||||
"Lua": TypeProgramming,
|
"Lua": Programming,
|
||||||
"M": TypeProgramming,
|
"M": Programming,
|
||||||
"M4": TypeProgramming,
|
"M4": Programming,
|
||||||
"M4Sugar": TypeProgramming,
|
"M4Sugar": Programming,
|
||||||
"MAXScript": TypeProgramming,
|
"MAXScript": Programming,
|
||||||
"MQL4": TypeProgramming,
|
"MQL4": Programming,
|
||||||
"MQL5": TypeProgramming,
|
"MQL5": Programming,
|
||||||
"MTML": TypeMarkup,
|
"MTML": Markup,
|
||||||
"MUF": TypeProgramming,
|
"MUF": Programming,
|
||||||
"Makefile": TypeProgramming,
|
"Makefile": Programming,
|
||||||
"Mako": TypeProgramming,
|
"Mako": Programming,
|
||||||
"Markdown": TypeProse,
|
"Markdown": Prose,
|
||||||
"Marko": TypeMarkup,
|
"Marko": Markup,
|
||||||
"Mask": TypeMarkup,
|
"Mask": Markup,
|
||||||
"Mathematica": TypeProgramming,
|
"Mathematica": Programming,
|
||||||
"Matlab": TypeProgramming,
|
"Matlab": Programming,
|
||||||
"Maven POM": TypeData,
|
"Maven POM": Data,
|
||||||
"Max": TypeProgramming,
|
"Max": Programming,
|
||||||
"MediaWiki": TypeProse,
|
"MediaWiki": Prose,
|
||||||
"Mercury": TypeProgramming,
|
"Mercury": Programming,
|
||||||
"Meson": TypeProgramming,
|
"Meson": Programming,
|
||||||
"Metal": TypeProgramming,
|
"Metal": Programming,
|
||||||
"MiniD": TypeProgramming,
|
"MiniD": Programming,
|
||||||
"Mirah": TypeProgramming,
|
"Mirah": Programming,
|
||||||
"Modelica": TypeProgramming,
|
"Modelica": Programming,
|
||||||
"Modula-2": TypeProgramming,
|
"Modula-2": Programming,
|
||||||
"Module Management System": TypeProgramming,
|
"Module Management System": Programming,
|
||||||
"Monkey": TypeProgramming,
|
"Monkey": Programming,
|
||||||
"Moocode": TypeProgramming,
|
"Moocode": Programming,
|
||||||
"MoonScript": TypeProgramming,
|
"MoonScript": Programming,
|
||||||
"Myghty": TypeProgramming,
|
"Myghty": Programming,
|
||||||
"NCL": TypeProgramming,
|
"NCL": Programming,
|
||||||
"NL": TypeData,
|
"NL": Data,
|
||||||
"NSIS": TypeProgramming,
|
"NSIS": Programming,
|
||||||
"Nemerle": TypeProgramming,
|
"Nemerle": Programming,
|
||||||
"NetLinx": TypeProgramming,
|
"NetLinx": Programming,
|
||||||
"NetLinx+ERB": TypeProgramming,
|
"NetLinx+ERB": Programming,
|
||||||
"NetLogo": TypeProgramming,
|
"NetLogo": Programming,
|
||||||
"NewLisp": TypeProgramming,
|
"NewLisp": Programming,
|
||||||
"Nginx": TypeMarkup,
|
"Nginx": Markup,
|
||||||
"Nim": TypeProgramming,
|
"Nim": Programming,
|
||||||
"Ninja": TypeData,
|
"Ninja": Data,
|
||||||
"Nit": TypeProgramming,
|
"Nit": Programming,
|
||||||
"Nix": TypeProgramming,
|
"Nix": Programming,
|
||||||
"Nu": TypeProgramming,
|
"Nu": Programming,
|
||||||
"NumPy": TypeProgramming,
|
"NumPy": Programming,
|
||||||
"OCaml": TypeProgramming,
|
"OCaml": Programming,
|
||||||
"ObjDump": TypeData,
|
"ObjDump": Data,
|
||||||
"Objective-C": TypeProgramming,
|
"Objective-C": Programming,
|
||||||
"Objective-C++": TypeProgramming,
|
"Objective-C++": Programming,
|
||||||
"Objective-J": TypeProgramming,
|
"Objective-J": Programming,
|
||||||
"Omgrofl": TypeProgramming,
|
"Omgrofl": Programming,
|
||||||
"Opa": TypeProgramming,
|
"Opa": Programming,
|
||||||
"Opal": TypeProgramming,
|
"Opal": Programming,
|
||||||
"OpenCL": TypeProgramming,
|
"OpenCL": Programming,
|
||||||
"OpenEdge ABL": TypeProgramming,
|
"OpenEdge ABL": Programming,
|
||||||
"OpenRC runscript": TypeProgramming,
|
"OpenRC runscript": Programming,
|
||||||
"OpenSCAD": TypeProgramming,
|
"OpenSCAD": Programming,
|
||||||
"OpenType Feature File": TypeData,
|
"OpenType Feature File": Data,
|
||||||
"Org": TypeProse,
|
"Org": Prose,
|
||||||
"Ox": TypeProgramming,
|
"Ox": Programming,
|
||||||
"Oxygene": TypeProgramming,
|
"Oxygene": Programming,
|
||||||
"Oz": TypeProgramming,
|
"Oz": Programming,
|
||||||
"P4": TypeProgramming,
|
"P4": Programming,
|
||||||
"PAWN": TypeProgramming,
|
"PAWN": Programming,
|
||||||
"PHP": TypeProgramming,
|
"PHP": Programming,
|
||||||
"PLSQL": TypeProgramming,
|
"PLSQL": Programming,
|
||||||
"PLpgSQL": TypeProgramming,
|
"PLpgSQL": Programming,
|
||||||
"POV-Ray SDL": TypeProgramming,
|
"POV-Ray SDL": Programming,
|
||||||
"Pan": TypeProgramming,
|
"Pan": Programming,
|
||||||
"Papyrus": TypeProgramming,
|
"Papyrus": Programming,
|
||||||
"Parrot": TypeProgramming,
|
"Parrot": Programming,
|
||||||
"Parrot Assembly": TypeProgramming,
|
"Parrot Assembly": Programming,
|
||||||
"Parrot Internal Representation": TypeProgramming,
|
"Parrot Internal Representation": Programming,
|
||||||
"Pascal": TypeProgramming,
|
"Pascal": Programming,
|
||||||
"Perl": TypeProgramming,
|
"Perl": Programming,
|
||||||
"Perl6": TypeProgramming,
|
"Perl6": Programming,
|
||||||
"Pic": TypeMarkup,
|
"Pic": Markup,
|
||||||
"Pickle": TypeData,
|
"Pickle": Data,
|
||||||
"PicoLisp": TypeProgramming,
|
"PicoLisp": Programming,
|
||||||
"PigLatin": TypeProgramming,
|
"PigLatin": Programming,
|
||||||
"Pike": TypeProgramming,
|
"Pike": Programming,
|
||||||
"Pod": TypeProse,
|
"Pod": Prose,
|
||||||
"PogoScript": TypeProgramming,
|
"PogoScript": Programming,
|
||||||
"Pony": TypeProgramming,
|
"Pony": Programming,
|
||||||
"PostScript": TypeMarkup,
|
"PostScript": Markup,
|
||||||
"PowerBuilder": TypeProgramming,
|
"PowerBuilder": Programming,
|
||||||
"PowerShell": TypeProgramming,
|
"PowerShell": Programming,
|
||||||
"Processing": TypeProgramming,
|
"Processing": Programming,
|
||||||
"Prolog": TypeProgramming,
|
"Prolog": Programming,
|
||||||
"Propeller Spin": TypeProgramming,
|
"Propeller Spin": Programming,
|
||||||
"Protocol Buffer": TypeMarkup,
|
"Protocol Buffer": Markup,
|
||||||
"Public Key": TypeData,
|
"Public Key": Data,
|
||||||
"Pug": TypeMarkup,
|
"Pug": Markup,
|
||||||
"Puppet": TypeProgramming,
|
"Puppet": Programming,
|
||||||
"Pure Data": TypeProgramming,
|
"Pure Data": Programming,
|
||||||
"PureBasic": TypeProgramming,
|
"PureBasic": Programming,
|
||||||
"PureScript": TypeProgramming,
|
"PureScript": Programming,
|
||||||
"Python": TypeProgramming,
|
"Python": Programming,
|
||||||
"Python console": TypeProgramming,
|
"Python console": Programming,
|
||||||
"Python traceback": TypeData,
|
"Python traceback": Data,
|
||||||
"QML": TypeProgramming,
|
"QML": Programming,
|
||||||
"QMake": TypeProgramming,
|
"QMake": Programming,
|
||||||
"R": TypeProgramming,
|
"R": Programming,
|
||||||
"RAML": TypeMarkup,
|
"RAML": Markup,
|
||||||
"RDoc": TypeProse,
|
"RDoc": Prose,
|
||||||
"REALbasic": TypeProgramming,
|
"REALbasic": Programming,
|
||||||
"REXX": TypeProgramming,
|
"REXX": Programming,
|
||||||
"RHTML": TypeMarkup,
|
"RHTML": Markup,
|
||||||
"RMarkdown": TypeProse,
|
"RMarkdown": Prose,
|
||||||
"RPM Spec": TypeData,
|
"RPM Spec": Data,
|
||||||
"RUNOFF": TypeMarkup,
|
"RUNOFF": Markup,
|
||||||
"Racket": TypeProgramming,
|
"Racket": Programming,
|
||||||
"Ragel": TypeProgramming,
|
"Ragel": Programming,
|
||||||
"Rascal": TypeProgramming,
|
"Rascal": Programming,
|
||||||
"Raw token data": TypeData,
|
"Raw token data": Data,
|
||||||
"Reason": TypeProgramming,
|
"Reason": Programming,
|
||||||
"Rebol": TypeProgramming,
|
"Rebol": Programming,
|
||||||
"Red": TypeProgramming,
|
"Red": Programming,
|
||||||
"Redcode": TypeProgramming,
|
"Redcode": Programming,
|
||||||
"Regular Expression": TypeData,
|
"Regular Expression": Data,
|
||||||
"Ren'Py": TypeProgramming,
|
"Ren'Py": Programming,
|
||||||
"RenderScript": TypeProgramming,
|
"RenderScript": Programming,
|
||||||
"RobotFramework": TypeProgramming,
|
"RobotFramework": Programming,
|
||||||
"Roff": TypeMarkup,
|
"Roff": Markup,
|
||||||
"Rouge": TypeProgramming,
|
"Rouge": Programming,
|
||||||
"Ruby": TypeProgramming,
|
"Ruby": Programming,
|
||||||
"Rust": TypeProgramming,
|
"Rust": Programming,
|
||||||
"SAS": TypeProgramming,
|
"SAS": Programming,
|
||||||
"SCSS": TypeMarkup,
|
"SCSS": Markup,
|
||||||
"SMT": TypeProgramming,
|
"SMT": Programming,
|
||||||
"SPARQL": TypeData,
|
"SPARQL": Data,
|
||||||
"SQF": TypeProgramming,
|
"SQF": Programming,
|
||||||
"SQL": TypeData,
|
"SQL": Data,
|
||||||
"SQLPL": TypeProgramming,
|
"SQLPL": Programming,
|
||||||
"SRecode Template": TypeMarkup,
|
"SRecode Template": Markup,
|
||||||
"STON": TypeData,
|
"STON": Data,
|
||||||
"SVG": TypeData,
|
"SVG": Data,
|
||||||
"Sage": TypeProgramming,
|
"Sage": Programming,
|
||||||
"SaltStack": TypeProgramming,
|
"SaltStack": Programming,
|
||||||
"Sass": TypeMarkup,
|
"Sass": Markup,
|
||||||
"Scala": TypeProgramming,
|
"Scala": Programming,
|
||||||
"Scaml": TypeMarkup,
|
"Scaml": Markup,
|
||||||
"Scheme": TypeProgramming,
|
"Scheme": Programming,
|
||||||
"Scilab": TypeProgramming,
|
"Scilab": Programming,
|
||||||
"Self": TypeProgramming,
|
"Self": Programming,
|
||||||
"Shell": TypeProgramming,
|
"Shell": Programming,
|
||||||
"ShellSession": TypeProgramming,
|
"ShellSession": Programming,
|
||||||
"Shen": TypeProgramming,
|
"Shen": Programming,
|
||||||
"Slash": TypeProgramming,
|
"Slash": Programming,
|
||||||
"Slim": TypeMarkup,
|
"Slim": Markup,
|
||||||
"Smali": TypeProgramming,
|
"Smali": Programming,
|
||||||
"Smalltalk": TypeProgramming,
|
"Smalltalk": Programming,
|
||||||
"Smarty": TypeProgramming,
|
"Smarty": Programming,
|
||||||
"SourcePawn": TypeProgramming,
|
"SourcePawn": Programming,
|
||||||
"Spline Font Database": TypeData,
|
"Spline Font Database": Data,
|
||||||
"Squirrel": TypeProgramming,
|
"Squirrel": Programming,
|
||||||
"Stan": TypeProgramming,
|
"Stan": Programming,
|
||||||
"Standard ML": TypeProgramming,
|
"Standard ML": Programming,
|
||||||
"Stata": TypeProgramming,
|
"Stata": Programming,
|
||||||
"Stylus": TypeMarkup,
|
"Stylus": Markup,
|
||||||
"SubRip Text": TypeData,
|
"SubRip Text": Data,
|
||||||
"Sublime Text Config": TypeData,
|
"Sublime Text Config": Data,
|
||||||
"SuperCollider": TypeProgramming,
|
"SuperCollider": Programming,
|
||||||
"Swift": TypeProgramming,
|
"Swift": Programming,
|
||||||
"SystemVerilog": TypeProgramming,
|
"SystemVerilog": Programming,
|
||||||
"TI Program": TypeProgramming,
|
"TI Program": Programming,
|
||||||
"TLA": TypeProgramming,
|
"TLA": Programming,
|
||||||
"TOML": TypeData,
|
"TOML": Data,
|
||||||
"TXL": TypeProgramming,
|
"TXL": Programming,
|
||||||
"Tcl": TypeProgramming,
|
"Tcl": Programming,
|
||||||
"Tcsh": TypeProgramming,
|
"Tcsh": Programming,
|
||||||
"TeX": TypeMarkup,
|
"TeX": Markup,
|
||||||
"Tea": TypeMarkup,
|
"Tea": Markup,
|
||||||
"Terra": TypeProgramming,
|
"Terra": Programming,
|
||||||
"Text": TypeProse,
|
"Text": Prose,
|
||||||
"Textile": TypeProse,
|
"Textile": Prose,
|
||||||
"Thrift": TypeProgramming,
|
"Thrift": Programming,
|
||||||
"Turing": TypeProgramming,
|
"Turing": Programming,
|
||||||
"Turtle": TypeData,
|
"Turtle": Data,
|
||||||
"Twig": TypeMarkup,
|
"Twig": Markup,
|
||||||
"TypeScript": TypeProgramming,
|
"TypeScript": Programming,
|
||||||
"Unified Parallel C": TypeProgramming,
|
"Unified Parallel C": Programming,
|
||||||
"Unity3D Asset": TypeData,
|
"Unity3D Asset": Data,
|
||||||
"Unix Assembly": TypeProgramming,
|
"Unix Assembly": Programming,
|
||||||
"Uno": TypeProgramming,
|
"Uno": Programming,
|
||||||
"UnrealScript": TypeProgramming,
|
"UnrealScript": Programming,
|
||||||
"UrWeb": TypeProgramming,
|
"UrWeb": Programming,
|
||||||
"VCL": TypeProgramming,
|
"VCL": Programming,
|
||||||
"VHDL": TypeProgramming,
|
"VHDL": Programming,
|
||||||
"Vala": TypeProgramming,
|
"Vala": Programming,
|
||||||
"Verilog": TypeProgramming,
|
"Verilog": Programming,
|
||||||
"Vim script": TypeProgramming,
|
"Vim script": Programming,
|
||||||
"Visual Basic": TypeProgramming,
|
"Visual Basic": Programming,
|
||||||
"Volt": TypeProgramming,
|
"Volt": Programming,
|
||||||
"Vue": TypeMarkup,
|
"Vue": Markup,
|
||||||
"Wavefront Material": TypeData,
|
"Wavefront Material": Data,
|
||||||
"Wavefront Object": TypeData,
|
"Wavefront Object": Data,
|
||||||
"Web Ontology Language": TypeMarkup,
|
"Web Ontology Language": Markup,
|
||||||
"WebIDL": TypeProgramming,
|
"WebIDL": Programming,
|
||||||
"World of Warcraft Addon Data": TypeData,
|
"World of Warcraft Addon Data": Data,
|
||||||
"X10": TypeProgramming,
|
"X10": Programming,
|
||||||
"XC": TypeProgramming,
|
"XC": Programming,
|
||||||
"XCompose": TypeData,
|
"XCompose": Data,
|
||||||
"XML": TypeData,
|
"XML": Data,
|
||||||
"XPages": TypeProgramming,
|
"XPages": Programming,
|
||||||
"XProc": TypeProgramming,
|
"XProc": Programming,
|
||||||
"XQuery": TypeProgramming,
|
"XQuery": Programming,
|
||||||
"XS": TypeProgramming,
|
"XS": Programming,
|
||||||
"XSLT": TypeProgramming,
|
"XSLT": Programming,
|
||||||
"Xojo": TypeProgramming,
|
"Xojo": Programming,
|
||||||
"Xtend": TypeProgramming,
|
"Xtend": Programming,
|
||||||
"YAML": TypeData,
|
"YAML": Data,
|
||||||
"YANG": TypeData,
|
"YANG": Data,
|
||||||
"Yacc": TypeProgramming,
|
"Yacc": Programming,
|
||||||
"Zephir": TypeProgramming,
|
"Zephir": Programming,
|
||||||
"Zimpl": TypeProgramming,
|
"Zimpl": Programming,
|
||||||
"desktop": TypeData,
|
"desktop": Data,
|
||||||
"eC": TypeProgramming,
|
"eC": Programming,
|
||||||
"edn": TypeData,
|
"edn": Data,
|
||||||
"fish": TypeProgramming,
|
"fish": Programming,
|
||||||
"mupad": TypeProgramming,
|
"mupad": Programming,
|
||||||
"nesC": TypeProgramming,
|
"nesC": Programming,
|
||||||
"ooc": TypeProgramming,
|
"ooc": Programming,
|
||||||
"reStructuredText": TypeProse,
|
"reStructuredText": Prose,
|
||||||
"wisp": TypeProgramming,
|
"wisp": Programming,
|
||||||
"xBase": TypeProgramming,
|
"xBase": Programming,
|
||||||
}
|
}
|
||||||
|
18
type_test.go
18
type_test.go
@ -4,29 +4,29 @@ import . "gopkg.in/check.v1"
|
|||||||
|
|
||||||
func (s *TSuite) TestGetLanguageType(c *C) {
|
func (s *TSuite) TestGetLanguageType(c *C) {
|
||||||
langType := GetLanguageType("BestLanguageEver")
|
langType := GetLanguageType("BestLanguageEver")
|
||||||
c.Assert(langType, Equals, TypeUnknown)
|
c.Assert(langType, Equals, Unknown)
|
||||||
|
|
||||||
langType = GetLanguageType("JSON")
|
langType = GetLanguageType("JSON")
|
||||||
c.Assert(langType, Equals, TypeData)
|
c.Assert(langType, Equals, Data)
|
||||||
|
|
||||||
langType = GetLanguageType("COLLADA")
|
langType = GetLanguageType("COLLADA")
|
||||||
c.Assert(langType, Equals, TypeData)
|
c.Assert(langType, Equals, Data)
|
||||||
|
|
||||||
langType = GetLanguageType("Go")
|
langType = GetLanguageType("Go")
|
||||||
c.Assert(langType, Equals, TypeProgramming)
|
c.Assert(langType, Equals, Programming)
|
||||||
|
|
||||||
langType = GetLanguageType("Brainfuck")
|
langType = GetLanguageType("Brainfuck")
|
||||||
c.Assert(langType, Equals, TypeProgramming)
|
c.Assert(langType, Equals, Programming)
|
||||||
|
|
||||||
langType = GetLanguageType("HTML")
|
langType = GetLanguageType("HTML")
|
||||||
c.Assert(langType, Equals, TypeMarkup)
|
c.Assert(langType, Equals, Markup)
|
||||||
|
|
||||||
langType = GetLanguageType("Sass")
|
langType = GetLanguageType("Sass")
|
||||||
c.Assert(langType, Equals, TypeMarkup)
|
c.Assert(langType, Equals, Markup)
|
||||||
|
|
||||||
langType = GetLanguageType("AsciiDoc")
|
langType = GetLanguageType("AsciiDoc")
|
||||||
c.Assert(langType, Equals, TypeProse)
|
c.Assert(langType, Equals, Prose)
|
||||||
|
|
||||||
langType = GetLanguageType("Textile")
|
langType = GetLanguageType("Textile")
|
||||||
c.Assert(langType, Equals, TypeProse)
|
c.Assert(langType, Equals, Prose)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package slinguist
|
package slinguist
|
||||||
|
|
||||||
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user