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:
Manuel Carmona 2017-04-18 08:57:59 +02:00
parent 2644a7c8da
commit c6d74bca66
30 changed files with 659 additions and 508 deletions

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -1,17 +1,17 @@
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
// Extracted from github/linguist commit: {{ getCommit }}
type Type int
const (
TypeUnknown Type = iota
TypeData
TypeProgramming
TypeMarkup
TypeProse
Unknown Type = iota
Data
Programming
Markup
Prose
)
func GetLanguageType(language string) (langType Type) {

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -12,10 +12,8 @@ import (
type languageInfo struct {
Type string `yaml:"type,omitempty"`
Aliases []string `yaml:"aliases,omitempty,flow"`
Extensions []string `yaml:"extensions,omitempty,flow"`
Interpreters []string `yaml:"interpreters,omitempty,flow"`
Group string `yaml:"group,omitempty"`
}
// Languages reads from buf and builds languages.go file from languagesTmplPath.

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -1,17 +1,17 @@
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
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
type Type int
const (
TypeUnknown Type = iota
TypeData
TypeProgramming
TypeMarkup
TypeProse
Unknown Type = iota
Data
Programming
Markup
Prose
)
func GetLanguageType(language string) (langType Type) {
@ -20,8 +20,8 @@ func GetLanguageType(language string) (langType Type) {
}
var languagesType = map[string]Type{
"Scaml": TypeMarkup,
"Scheme": TypeProgramming,
"Scilab": TypeProgramming,
"Self": TypeProgramming,
"Scaml": Markup,
"Scheme": Programming,
"Scilab": Programming,
"Self": Programming,
}

View File

@ -1,17 +1,17 @@
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
// Extracted from github/linguist commit: {{ getCommit }}
type Type int
const (
TypeUnknown Type = iota
TypeData
TypeProgramming
TypeMarkup
TypeProse
Unknown Type = iota
Data
Programming
Markup
Prose
)
func GetLanguageType(language string) (langType Type) {

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: {{ getCommit }}

View File

@ -9,10 +9,10 @@ import (
)
var typeToTypeConst = map[string]string{
"data": "TypeData",
"programming": "TypeProgramming",
"markup": "TypeMarkup",
"prose": "TypeProse",
"data": "Data",
"programming": "Programming",
"markup": "Markup",
"prose": "Prose",
}
// Types reads from buf and builds type.go file from typeTmplPath.

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9

93
shebang.go Normal file
View 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
View 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
View File

@ -1,17 +1,17 @@
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
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
type Type int
const (
TypeUnknown Type = iota
TypeData
TypeProgramming
TypeMarkup
TypeProse
Unknown Type = iota
Data
Programming
Markup
Prose
)
func GetLanguageType(language string) (langType Type) {
@ -20,448 +20,448 @@ func GetLanguageType(language string) (langType Type) {
}
var languagesType = map[string]Type{
"1C Enterprise": TypeProgramming,
"ABAP": TypeProgramming,
"ABNF": TypeData,
"AGS Script": TypeProgramming,
"AMPL": TypeProgramming,
"ANTLR": TypeProgramming,
"API Blueprint": TypeMarkup,
"APL": TypeProgramming,
"ASN.1": TypeData,
"ASP": TypeProgramming,
"ATS": TypeProgramming,
"ActionScript": TypeProgramming,
"Ada": TypeProgramming,
"Agda": TypeProgramming,
"Alloy": TypeProgramming,
"Alpine Abuild": TypeProgramming,
"Ant Build System": TypeData,
"ApacheConf": TypeMarkup,
"Apex": TypeProgramming,
"Apollo Guidance Computer": TypeProgramming,
"AppleScript": TypeProgramming,
"Arc": TypeProgramming,
"Arduino": TypeProgramming,
"AsciiDoc": TypeProse,
"AspectJ": TypeProgramming,
"Assembly": TypeProgramming,
"Augeas": TypeProgramming,
"AutoHotkey": TypeProgramming,
"AutoIt": TypeProgramming,
"Awk": TypeProgramming,
"Batchfile": TypeProgramming,
"Befunge": TypeProgramming,
"Bison": TypeProgramming,
"BitBake": TypeProgramming,
"Blade": TypeMarkup,
"BlitzBasic": TypeProgramming,
"BlitzMax": TypeProgramming,
"Bluespec": TypeProgramming,
"Boo": TypeProgramming,
"Brainfuck": TypeProgramming,
"Brightscript": TypeProgramming,
"Bro": TypeProgramming,
"C": TypeProgramming,
"C#": TypeProgramming,
"C++": TypeProgramming,
"C-ObjDump": TypeData,
"C2hs Haskell": TypeProgramming,
"CLIPS": TypeProgramming,
"CMake": TypeProgramming,
"COBOL": TypeProgramming,
"COLLADA": TypeData,
"CSON": TypeData,
"CSS": TypeMarkup,
"CSV": TypeData,
"Cap'n Proto": TypeProgramming,
"CartoCSS": TypeProgramming,
"Ceylon": TypeProgramming,
"Chapel": TypeProgramming,
"Charity": TypeProgramming,
"ChucK": TypeProgramming,
"Cirru": TypeProgramming,
"Clarion": TypeProgramming,
"Clean": TypeProgramming,
"Click": TypeProgramming,
"Clojure": TypeProgramming,
"CoffeeScript": TypeProgramming,
"ColdFusion": TypeProgramming,
"ColdFusion CFC": TypeProgramming,
"Common Lisp": TypeProgramming,
"Component Pascal": TypeProgramming,
"Cool": TypeProgramming,
"Coq": TypeProgramming,
"Cpp-ObjDump": TypeData,
"Creole": TypeProse,
"Crystal": TypeProgramming,
"Csound": TypeProgramming,
"Csound Document": TypeProgramming,
"Csound Score": TypeProgramming,
"Cuda": TypeProgramming,
"Cycript": TypeProgramming,
"Cython": TypeProgramming,
"D": TypeProgramming,
"D-ObjDump": TypeData,
"DIGITAL Command Language": TypeProgramming,
"DM": TypeProgramming,
"DNS Zone": TypeData,
"DTrace": TypeProgramming,
"Darcs Patch": TypeData,
"Dart": TypeProgramming,
"Diff": TypeData,
"Dockerfile": TypeData,
"Dogescript": TypeProgramming,
"Dylan": TypeProgramming,
"E": TypeProgramming,
"EBNF": TypeData,
"ECL": TypeProgramming,
"ECLiPSe": TypeProgramming,
"EJS": TypeMarkup,
"EQ": TypeProgramming,
"Eagle": TypeMarkup,
"Ecere Projects": TypeData,
"Eiffel": TypeProgramming,
"Elixir": TypeProgramming,
"Elm": TypeProgramming,
"Emacs Lisp": TypeProgramming,
"EmberScript": TypeProgramming,
"Erlang": TypeProgramming,
"F#": TypeProgramming,
"FLUX": TypeProgramming,
"Factor": TypeProgramming,
"Fancy": TypeProgramming,
"Fantom": TypeProgramming,
"Filebench WML": TypeProgramming,
"Filterscript": TypeProgramming,
"Formatted": TypeData,
"Forth": TypeProgramming,
"Fortran": TypeProgramming,
"FreeMarker": TypeProgramming,
"Frege": TypeProgramming,
"G-code": TypeData,
"GAMS": TypeProgramming,
"GAP": TypeProgramming,
"GCC Machine Description": TypeProgramming,
"GDB": TypeProgramming,
"GDScript": TypeProgramming,
"GLSL": TypeProgramming,
"GN": TypeData,
"Game Maker Language": TypeProgramming,
"Genie": TypeProgramming,
"Genshi": TypeProgramming,
"Gentoo Ebuild": TypeProgramming,
"Gentoo Eclass": TypeProgramming,
"Gettext Catalog": TypeProse,
"Gherkin": TypeProgramming,
"Glyph": TypeProgramming,
"Gnuplot": TypeProgramming,
"Go": TypeProgramming,
"Golo": TypeProgramming,
"Gosu": TypeProgramming,
"Grace": TypeProgramming,
"Gradle": TypeData,
"Grammatical Framework": TypeProgramming,
"Graph Modeling Language": TypeData,
"GraphQL": TypeData,
"Graphviz (DOT)": TypeData,
"Groovy": TypeProgramming,
"Groovy Server Pages": TypeProgramming,
"HCL": TypeProgramming,
"HLSL": TypeProgramming,
"HTML": TypeMarkup,
"HTML+Django": TypeMarkup,
"HTML+ECR": TypeMarkup,
"HTML+EEX": TypeMarkup,
"HTML+ERB": TypeMarkup,
"HTML+PHP": TypeMarkup,
"HTTP": TypeData,
"Hack": TypeProgramming,
"Haml": TypeMarkup,
"Handlebars": TypeMarkup,
"Harbour": TypeProgramming,
"Haskell": TypeProgramming,
"Haxe": TypeProgramming,
"Hy": TypeProgramming,
"HyPhy": TypeProgramming,
"IDL": TypeProgramming,
"IGOR Pro": TypeProgramming,
"INI": TypeData,
"IRC log": TypeData,
"Idris": TypeProgramming,
"Inform 7": TypeProgramming,
"Inno Setup": TypeProgramming,
"Io": TypeProgramming,
"Ioke": TypeProgramming,
"Isabelle": TypeProgramming,
"Isabelle ROOT": TypeProgramming,
"J": TypeProgramming,
"JFlex": TypeProgramming,
"JSON": TypeData,
"JSON5": TypeData,
"JSONLD": TypeData,
"JSONiq": TypeProgramming,
"JSX": TypeProgramming,
"Jasmin": TypeProgramming,
"Java": TypeProgramming,
"Java Server Pages": TypeProgramming,
"JavaScript": TypeProgramming,
"Jison": TypeProgramming,
"Jison Lex": TypeProgramming,
"Julia": TypeProgramming,
"Jupyter Notebook": TypeMarkup,
"KRL": TypeProgramming,
"KiCad": TypeProgramming,
"Kit": TypeMarkup,
"Kotlin": TypeProgramming,
"LFE": TypeProgramming,
"LLVM": TypeProgramming,
"LOLCODE": TypeProgramming,
"LSL": TypeProgramming,
"LabVIEW": TypeProgramming,
"Lasso": TypeProgramming,
"Latte": TypeMarkup,
"Lean": TypeProgramming,
"Less": TypeMarkup,
"Lex": TypeProgramming,
"LilyPond": TypeProgramming,
"Limbo": TypeProgramming,
"Linker Script": TypeData,
"Linux Kernel Module": TypeData,
"Liquid": TypeMarkup,
"Literate Agda": TypeProgramming,
"Literate CoffeeScript": TypeProgramming,
"Literate Haskell": TypeProgramming,
"LiveScript": TypeProgramming,
"Logos": TypeProgramming,
"Logtalk": TypeProgramming,
"LookML": TypeProgramming,
"LoomScript": TypeProgramming,
"Lua": TypeProgramming,
"M": TypeProgramming,
"M4": TypeProgramming,
"M4Sugar": TypeProgramming,
"MAXScript": TypeProgramming,
"MQL4": TypeProgramming,
"MQL5": TypeProgramming,
"MTML": TypeMarkup,
"MUF": TypeProgramming,
"Makefile": TypeProgramming,
"Mako": TypeProgramming,
"Markdown": TypeProse,
"Marko": TypeMarkup,
"Mask": TypeMarkup,
"Mathematica": TypeProgramming,
"Matlab": TypeProgramming,
"Maven POM": TypeData,
"Max": TypeProgramming,
"MediaWiki": TypeProse,
"Mercury": TypeProgramming,
"Meson": TypeProgramming,
"Metal": TypeProgramming,
"MiniD": TypeProgramming,
"Mirah": TypeProgramming,
"Modelica": TypeProgramming,
"Modula-2": TypeProgramming,
"Module Management System": TypeProgramming,
"Monkey": TypeProgramming,
"Moocode": TypeProgramming,
"MoonScript": TypeProgramming,
"Myghty": TypeProgramming,
"NCL": TypeProgramming,
"NL": TypeData,
"NSIS": TypeProgramming,
"Nemerle": TypeProgramming,
"NetLinx": TypeProgramming,
"NetLinx+ERB": TypeProgramming,
"NetLogo": TypeProgramming,
"NewLisp": TypeProgramming,
"Nginx": TypeMarkup,
"Nim": TypeProgramming,
"Ninja": TypeData,
"Nit": TypeProgramming,
"Nix": TypeProgramming,
"Nu": TypeProgramming,
"NumPy": TypeProgramming,
"OCaml": TypeProgramming,
"ObjDump": TypeData,
"Objective-C": TypeProgramming,
"Objective-C++": TypeProgramming,
"Objective-J": TypeProgramming,
"Omgrofl": TypeProgramming,
"Opa": TypeProgramming,
"Opal": TypeProgramming,
"OpenCL": TypeProgramming,
"OpenEdge ABL": TypeProgramming,
"OpenRC runscript": TypeProgramming,
"OpenSCAD": TypeProgramming,
"OpenType Feature File": TypeData,
"Org": TypeProse,
"Ox": TypeProgramming,
"Oxygene": TypeProgramming,
"Oz": TypeProgramming,
"P4": TypeProgramming,
"PAWN": TypeProgramming,
"PHP": TypeProgramming,
"PLSQL": TypeProgramming,
"PLpgSQL": TypeProgramming,
"POV-Ray SDL": TypeProgramming,
"Pan": TypeProgramming,
"Papyrus": TypeProgramming,
"Parrot": TypeProgramming,
"Parrot Assembly": TypeProgramming,
"Parrot Internal Representation": TypeProgramming,
"Pascal": TypeProgramming,
"Perl": TypeProgramming,
"Perl6": TypeProgramming,
"Pic": TypeMarkup,
"Pickle": TypeData,
"PicoLisp": TypeProgramming,
"PigLatin": TypeProgramming,
"Pike": TypeProgramming,
"Pod": TypeProse,
"PogoScript": TypeProgramming,
"Pony": TypeProgramming,
"PostScript": TypeMarkup,
"PowerBuilder": TypeProgramming,
"PowerShell": TypeProgramming,
"Processing": TypeProgramming,
"Prolog": TypeProgramming,
"Propeller Spin": TypeProgramming,
"Protocol Buffer": TypeMarkup,
"Public Key": TypeData,
"Pug": TypeMarkup,
"Puppet": TypeProgramming,
"Pure Data": TypeProgramming,
"PureBasic": TypeProgramming,
"PureScript": TypeProgramming,
"Python": TypeProgramming,
"Python console": TypeProgramming,
"Python traceback": TypeData,
"QML": TypeProgramming,
"QMake": TypeProgramming,
"R": TypeProgramming,
"RAML": TypeMarkup,
"RDoc": TypeProse,
"REALbasic": TypeProgramming,
"REXX": TypeProgramming,
"RHTML": TypeMarkup,
"RMarkdown": TypeProse,
"RPM Spec": TypeData,
"RUNOFF": TypeMarkup,
"Racket": TypeProgramming,
"Ragel": TypeProgramming,
"Rascal": TypeProgramming,
"Raw token data": TypeData,
"Reason": TypeProgramming,
"Rebol": TypeProgramming,
"Red": TypeProgramming,
"Redcode": TypeProgramming,
"Regular Expression": TypeData,
"Ren'Py": TypeProgramming,
"RenderScript": TypeProgramming,
"RobotFramework": TypeProgramming,
"Roff": TypeMarkup,
"Rouge": TypeProgramming,
"Ruby": TypeProgramming,
"Rust": TypeProgramming,
"SAS": TypeProgramming,
"SCSS": TypeMarkup,
"SMT": TypeProgramming,
"SPARQL": TypeData,
"SQF": TypeProgramming,
"SQL": TypeData,
"SQLPL": TypeProgramming,
"SRecode Template": TypeMarkup,
"STON": TypeData,
"SVG": TypeData,
"Sage": TypeProgramming,
"SaltStack": TypeProgramming,
"Sass": TypeMarkup,
"Scala": TypeProgramming,
"Scaml": TypeMarkup,
"Scheme": TypeProgramming,
"Scilab": TypeProgramming,
"Self": TypeProgramming,
"Shell": TypeProgramming,
"ShellSession": TypeProgramming,
"Shen": TypeProgramming,
"Slash": TypeProgramming,
"Slim": TypeMarkup,
"Smali": TypeProgramming,
"Smalltalk": TypeProgramming,
"Smarty": TypeProgramming,
"SourcePawn": TypeProgramming,
"Spline Font Database": TypeData,
"Squirrel": TypeProgramming,
"Stan": TypeProgramming,
"Standard ML": TypeProgramming,
"Stata": TypeProgramming,
"Stylus": TypeMarkup,
"SubRip Text": TypeData,
"Sublime Text Config": TypeData,
"SuperCollider": TypeProgramming,
"Swift": TypeProgramming,
"SystemVerilog": TypeProgramming,
"TI Program": TypeProgramming,
"TLA": TypeProgramming,
"TOML": TypeData,
"TXL": TypeProgramming,
"Tcl": TypeProgramming,
"Tcsh": TypeProgramming,
"TeX": TypeMarkup,
"Tea": TypeMarkup,
"Terra": TypeProgramming,
"Text": TypeProse,
"Textile": TypeProse,
"Thrift": TypeProgramming,
"Turing": TypeProgramming,
"Turtle": TypeData,
"Twig": TypeMarkup,
"TypeScript": TypeProgramming,
"Unified Parallel C": TypeProgramming,
"Unity3D Asset": TypeData,
"Unix Assembly": TypeProgramming,
"Uno": TypeProgramming,
"UnrealScript": TypeProgramming,
"UrWeb": TypeProgramming,
"VCL": TypeProgramming,
"VHDL": TypeProgramming,
"Vala": TypeProgramming,
"Verilog": TypeProgramming,
"Vim script": TypeProgramming,
"Visual Basic": TypeProgramming,
"Volt": TypeProgramming,
"Vue": TypeMarkup,
"Wavefront Material": TypeData,
"Wavefront Object": TypeData,
"Web Ontology Language": TypeMarkup,
"WebIDL": TypeProgramming,
"World of Warcraft Addon Data": TypeData,
"X10": TypeProgramming,
"XC": TypeProgramming,
"XCompose": TypeData,
"XML": TypeData,
"XPages": TypeProgramming,
"XProc": TypeProgramming,
"XQuery": TypeProgramming,
"XS": TypeProgramming,
"XSLT": TypeProgramming,
"Xojo": TypeProgramming,
"Xtend": TypeProgramming,
"YAML": TypeData,
"YANG": TypeData,
"Yacc": TypeProgramming,
"Zephir": TypeProgramming,
"Zimpl": TypeProgramming,
"desktop": TypeData,
"eC": TypeProgramming,
"edn": TypeData,
"fish": TypeProgramming,
"mupad": TypeProgramming,
"nesC": TypeProgramming,
"ooc": TypeProgramming,
"reStructuredText": TypeProse,
"wisp": TypeProgramming,
"xBase": TypeProgramming,
"1C Enterprise": Programming,
"ABAP": Programming,
"ABNF": Data,
"AGS Script": Programming,
"AMPL": Programming,
"ANTLR": Programming,
"API Blueprint": Markup,
"APL": Programming,
"ASN.1": Data,
"ASP": Programming,
"ATS": Programming,
"ActionScript": Programming,
"Ada": Programming,
"Agda": Programming,
"Alloy": Programming,
"Alpine Abuild": Programming,
"Ant Build System": Data,
"ApacheConf": Markup,
"Apex": Programming,
"Apollo Guidance Computer": Programming,
"AppleScript": Programming,
"Arc": Programming,
"Arduino": Programming,
"AsciiDoc": Prose,
"AspectJ": Programming,
"Assembly": Programming,
"Augeas": Programming,
"AutoHotkey": Programming,
"AutoIt": Programming,
"Awk": Programming,
"Batchfile": Programming,
"Befunge": Programming,
"Bison": Programming,
"BitBake": Programming,
"Blade": Markup,
"BlitzBasic": Programming,
"BlitzMax": Programming,
"Bluespec": Programming,
"Boo": Programming,
"Brainfuck": Programming,
"Brightscript": Programming,
"Bro": Programming,
"C": Programming,
"C#": Programming,
"C++": Programming,
"C-ObjDump": Data,
"C2hs Haskell": Programming,
"CLIPS": Programming,
"CMake": Programming,
"COBOL": Programming,
"COLLADA": Data,
"CSON": Data,
"CSS": Markup,
"CSV": Data,
"Cap'n Proto": Programming,
"CartoCSS": Programming,
"Ceylon": Programming,
"Chapel": Programming,
"Charity": Programming,
"ChucK": Programming,
"Cirru": Programming,
"Clarion": Programming,
"Clean": Programming,
"Click": Programming,
"Clojure": Programming,
"CoffeeScript": Programming,
"ColdFusion": Programming,
"ColdFusion CFC": Programming,
"Common Lisp": Programming,
"Component Pascal": Programming,
"Cool": Programming,
"Coq": Programming,
"Cpp-ObjDump": Data,
"Creole": Prose,
"Crystal": Programming,
"Csound": Programming,
"Csound Document": Programming,
"Csound Score": Programming,
"Cuda": Programming,
"Cycript": Programming,
"Cython": Programming,
"D": Programming,
"D-ObjDump": Data,
"DIGITAL Command Language": Programming,
"DM": Programming,
"DNS Zone": Data,
"DTrace": Programming,
"Darcs Patch": Data,
"Dart": Programming,
"Diff": Data,
"Dockerfile": Data,
"Dogescript": Programming,
"Dylan": Programming,
"E": Programming,
"EBNF": Data,
"ECL": Programming,
"ECLiPSe": Programming,
"EJS": Markup,
"EQ": Programming,
"Eagle": Markup,
"Ecere Projects": Data,
"Eiffel": Programming,
"Elixir": Programming,
"Elm": Programming,
"Emacs Lisp": Programming,
"EmberScript": Programming,
"Erlang": Programming,
"F#": Programming,
"FLUX": Programming,
"Factor": Programming,
"Fancy": Programming,
"Fantom": Programming,
"Filebench WML": Programming,
"Filterscript": Programming,
"Formatted": Data,
"Forth": Programming,
"Fortran": Programming,
"FreeMarker": Programming,
"Frege": Programming,
"G-code": Data,
"GAMS": Programming,
"GAP": Programming,
"GCC Machine Description": Programming,
"GDB": Programming,
"GDScript": Programming,
"GLSL": Programming,
"GN": Data,
"Game Maker Language": Programming,
"Genie": Programming,
"Genshi": Programming,
"Gentoo Ebuild": Programming,
"Gentoo Eclass": Programming,
"Gettext Catalog": Prose,
"Gherkin": Programming,
"Glyph": Programming,
"Gnuplot": Programming,
"Go": Programming,
"Golo": Programming,
"Gosu": Programming,
"Grace": Programming,
"Gradle": Data,
"Grammatical Framework": Programming,
"Graph Modeling Language": Data,
"GraphQL": Data,
"Graphviz (DOT)": Data,
"Groovy": Programming,
"Groovy Server Pages": Programming,
"HCL": Programming,
"HLSL": Programming,
"HTML": Markup,
"HTML+Django": Markup,
"HTML+ECR": Markup,
"HTML+EEX": Markup,
"HTML+ERB": Markup,
"HTML+PHP": Markup,
"HTTP": Data,
"Hack": Programming,
"Haml": Markup,
"Handlebars": Markup,
"Harbour": Programming,
"Haskell": Programming,
"Haxe": Programming,
"Hy": Programming,
"HyPhy": Programming,
"IDL": Programming,
"IGOR Pro": Programming,
"INI": Data,
"IRC log": Data,
"Idris": Programming,
"Inform 7": Programming,
"Inno Setup": Programming,
"Io": Programming,
"Ioke": Programming,
"Isabelle": Programming,
"Isabelle ROOT": Programming,
"J": Programming,
"JFlex": Programming,
"JSON": Data,
"JSON5": Data,
"JSONLD": Data,
"JSONiq": Programming,
"JSX": Programming,
"Jasmin": Programming,
"Java": Programming,
"Java Server Pages": Programming,
"JavaScript": Programming,
"Jison": Programming,
"Jison Lex": Programming,
"Julia": Programming,
"Jupyter Notebook": Markup,
"KRL": Programming,
"KiCad": Programming,
"Kit": Markup,
"Kotlin": Programming,
"LFE": Programming,
"LLVM": Programming,
"LOLCODE": Programming,
"LSL": Programming,
"LabVIEW": Programming,
"Lasso": Programming,
"Latte": Markup,
"Lean": Programming,
"Less": Markup,
"Lex": Programming,
"LilyPond": Programming,
"Limbo": Programming,
"Linker Script": Data,
"Linux Kernel Module": Data,
"Liquid": Markup,
"Literate Agda": Programming,
"Literate CoffeeScript": Programming,
"Literate Haskell": Programming,
"LiveScript": Programming,
"Logos": Programming,
"Logtalk": Programming,
"LookML": Programming,
"LoomScript": Programming,
"Lua": Programming,
"M": Programming,
"M4": Programming,
"M4Sugar": Programming,
"MAXScript": Programming,
"MQL4": Programming,
"MQL5": Programming,
"MTML": Markup,
"MUF": Programming,
"Makefile": Programming,
"Mako": Programming,
"Markdown": Prose,
"Marko": Markup,
"Mask": Markup,
"Mathematica": Programming,
"Matlab": Programming,
"Maven POM": Data,
"Max": Programming,
"MediaWiki": Prose,
"Mercury": Programming,
"Meson": Programming,
"Metal": Programming,
"MiniD": Programming,
"Mirah": Programming,
"Modelica": Programming,
"Modula-2": Programming,
"Module Management System": Programming,
"Monkey": Programming,
"Moocode": Programming,
"MoonScript": Programming,
"Myghty": Programming,
"NCL": Programming,
"NL": Data,
"NSIS": Programming,
"Nemerle": Programming,
"NetLinx": Programming,
"NetLinx+ERB": Programming,
"NetLogo": Programming,
"NewLisp": Programming,
"Nginx": Markup,
"Nim": Programming,
"Ninja": Data,
"Nit": Programming,
"Nix": Programming,
"Nu": Programming,
"NumPy": Programming,
"OCaml": Programming,
"ObjDump": Data,
"Objective-C": Programming,
"Objective-C++": Programming,
"Objective-J": Programming,
"Omgrofl": Programming,
"Opa": Programming,
"Opal": Programming,
"OpenCL": Programming,
"OpenEdge ABL": Programming,
"OpenRC runscript": Programming,
"OpenSCAD": Programming,
"OpenType Feature File": Data,
"Org": Prose,
"Ox": Programming,
"Oxygene": Programming,
"Oz": Programming,
"P4": Programming,
"PAWN": Programming,
"PHP": Programming,
"PLSQL": Programming,
"PLpgSQL": Programming,
"POV-Ray SDL": Programming,
"Pan": Programming,
"Papyrus": Programming,
"Parrot": Programming,
"Parrot Assembly": Programming,
"Parrot Internal Representation": Programming,
"Pascal": Programming,
"Perl": Programming,
"Perl6": Programming,
"Pic": Markup,
"Pickle": Data,
"PicoLisp": Programming,
"PigLatin": Programming,
"Pike": Programming,
"Pod": Prose,
"PogoScript": Programming,
"Pony": Programming,
"PostScript": Markup,
"PowerBuilder": Programming,
"PowerShell": Programming,
"Processing": Programming,
"Prolog": Programming,
"Propeller Spin": Programming,
"Protocol Buffer": Markup,
"Public Key": Data,
"Pug": Markup,
"Puppet": Programming,
"Pure Data": Programming,
"PureBasic": Programming,
"PureScript": Programming,
"Python": Programming,
"Python console": Programming,
"Python traceback": Data,
"QML": Programming,
"QMake": Programming,
"R": Programming,
"RAML": Markup,
"RDoc": Prose,
"REALbasic": Programming,
"REXX": Programming,
"RHTML": Markup,
"RMarkdown": Prose,
"RPM Spec": Data,
"RUNOFF": Markup,
"Racket": Programming,
"Ragel": Programming,
"Rascal": Programming,
"Raw token data": Data,
"Reason": Programming,
"Rebol": Programming,
"Red": Programming,
"Redcode": Programming,
"Regular Expression": Data,
"Ren'Py": Programming,
"RenderScript": Programming,
"RobotFramework": Programming,
"Roff": Markup,
"Rouge": Programming,
"Ruby": Programming,
"Rust": Programming,
"SAS": Programming,
"SCSS": Markup,
"SMT": Programming,
"SPARQL": Data,
"SQF": Programming,
"SQL": Data,
"SQLPL": Programming,
"SRecode Template": Markup,
"STON": Data,
"SVG": Data,
"Sage": Programming,
"SaltStack": Programming,
"Sass": Markup,
"Scala": Programming,
"Scaml": Markup,
"Scheme": Programming,
"Scilab": Programming,
"Self": Programming,
"Shell": Programming,
"ShellSession": Programming,
"Shen": Programming,
"Slash": Programming,
"Slim": Markup,
"Smali": Programming,
"Smalltalk": Programming,
"Smarty": Programming,
"SourcePawn": Programming,
"Spline Font Database": Data,
"Squirrel": Programming,
"Stan": Programming,
"Standard ML": Programming,
"Stata": Programming,
"Stylus": Markup,
"SubRip Text": Data,
"Sublime Text Config": Data,
"SuperCollider": Programming,
"Swift": Programming,
"SystemVerilog": Programming,
"TI Program": Programming,
"TLA": Programming,
"TOML": Data,
"TXL": Programming,
"Tcl": Programming,
"Tcsh": Programming,
"TeX": Markup,
"Tea": Markup,
"Terra": Programming,
"Text": Prose,
"Textile": Prose,
"Thrift": Programming,
"Turing": Programming,
"Turtle": Data,
"Twig": Markup,
"TypeScript": Programming,
"Unified Parallel C": Programming,
"Unity3D Asset": Data,
"Unix Assembly": Programming,
"Uno": Programming,
"UnrealScript": Programming,
"UrWeb": Programming,
"VCL": Programming,
"VHDL": Programming,
"Vala": Programming,
"Verilog": Programming,
"Vim script": Programming,
"Visual Basic": Programming,
"Volt": Programming,
"Vue": Markup,
"Wavefront Material": Data,
"Wavefront Object": Data,
"Web Ontology Language": Markup,
"WebIDL": Programming,
"World of Warcraft Addon Data": Data,
"X10": Programming,
"XC": Programming,
"XCompose": Data,
"XML": Data,
"XPages": Programming,
"XProc": Programming,
"XQuery": Programming,
"XS": Programming,
"XSLT": Programming,
"Xojo": Programming,
"Xtend": Programming,
"YAML": Data,
"YANG": Data,
"Yacc": Programming,
"Zephir": Programming,
"Zimpl": Programming,
"desktop": Data,
"eC": Programming,
"edn": Data,
"fish": Programming,
"mupad": Programming,
"nesC": Programming,
"ooc": Programming,
"reStructuredText": Prose,
"wisp": Programming,
"xBase": Programming,
}

View File

@ -4,29 +4,29 @@ import . "gopkg.in/check.v1"
func (s *TSuite) TestGetLanguageType(c *C) {
langType := GetLanguageType("BestLanguageEver")
c.Assert(langType, Equals, TypeUnknown)
c.Assert(langType, Equals, Unknown)
langType = GetLanguageType("JSON")
c.Assert(langType, Equals, TypeData)
c.Assert(langType, Equals, Data)
langType = GetLanguageType("COLLADA")
c.Assert(langType, Equals, TypeData)
c.Assert(langType, Equals, Data)
langType = GetLanguageType("Go")
c.Assert(langType, Equals, TypeProgramming)
c.Assert(langType, Equals, Programming)
langType = GetLanguageType("Brainfuck")
c.Assert(langType, Equals, TypeProgramming)
c.Assert(langType, Equals, Programming)
langType = GetLanguageType("HTML")
c.Assert(langType, Equals, TypeMarkup)
c.Assert(langType, Equals, Markup)
langType = GetLanguageType("Sass")
c.Assert(langType, Equals, TypeMarkup)
c.Assert(langType, Equals, Markup)
langType = GetLanguageType("AsciiDoc")
c.Assert(langType, Equals, TypeProse)
c.Assert(langType, Equals, Prose)
langType = GetLanguageType("Textile")
c.Assert(langType, Equals, TypeProse)
c.Assert(langType, Equals, Prose)
}

View File

@ -1,6 +1,6 @@
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
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9