-
Notifications
You must be signed in to change notification settings - Fork 14
/
parsers.py
61 lines (58 loc) · 1.35 KB
/
parsers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
# Updated mapping of file extensions to parsers
PARSERS = {
".py": "python",
".js": "javascript",
".mjs": "javascript", # mjs file extension stands for "module JavaScript."
".go": "go",
".bash": "bash",
".c": "c",
".cc": "cpp",
".cs": "c_sharp",
".cl": "commonlisp",
".cpp": "cpp",
".css": "css",
".dockerfile": "dockerfile",
".dot": "dot",
".el": "elisp",
".ex": "elixir",
".elm": "elm",
".et": "embedded_template",
".erl": "erlang",
".gomod": "gomod",
".hack": "hack",
".hs": "haskell",
".hcl": "hcl",
".html": "html",
".java": "java",
".jsdoc": "jsdoc",
".json": "json",
".jl": "julia",
".kt": "kotlin",
".lua": "lua",
".mk": "make",
# ".md": "markdown", # https://github.com/ikatyang/tree-sitter-markdown/issues/59
".m": "objc",
".ml": "ocaml",
".pl": "perl",
".php": "php",
".ql": "ql",
".r": "r",
".R": "r",
".regex": "regex",
".rst": "rst",
".rb": "ruby",
".rs": "rust",
".scala": "scala",
".sql": "sql",
".sqlite": "sqlite",
".toml": "toml",
".tsq": "tsq",
".tsx": "typescript",
".ts": "typescript",
".yaml": "yaml",
}
def filename_to_lang(filename):
file_extension = os.path.splitext(filename)[1]
lang = PARSERS.get(file_extension)
return lang