MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / BashShellLexer

Class BashShellLexer

src/packagedcode/bashlex.py:33–66  ·  view source on GitHub ↗

A Pygments shell lexer to lex shell scripts used as package build scripts and package manifests such as autotools, ebuild, PKGBUILD or APKBUILD. This used as an input to further parse and extract metadata.

Source from the content-addressed store, hash-verified

31
32
33class BashShellLexer(RegexLexer):
34 """
35 A Pygments shell lexer to lex shell scripts used as package build scripts
36 and package manifests such as autotools, ebuild, PKGBUILD or APKBUILD.
37 This used as an input to further parse and extract metadata.
38 """
39
40 name = 'Shell'
41 aliases = ['shell']
42 # for info, as this is not used here otherwise
43 filenames = ['*.ebuild', 'PKGBUILD', 'APKBUILD', ]
44 mimetypes = []
45
46 tokens = {
47 'root': [
48 include('basic'),
49 include('data'),
50 ],
51 'basic': [
52 (r'#.*$', Comment),
53 # variable declaration and assignment
54 (r'^(\b\w+)(\+?=)', bygroups(Name.Variable, Equal)),
55 ],
56 'data': [
57 (r'\(', ArrayStart),
58 (r'\)', ArrayEnd),
59 # (?s) is re.DOTALL e.g. across lines
60 (r'(?s)"(\\.|[^"])*"', String.Double),
61 (r"(?s)'(\\.|[^'])*'", String.Single),
62 (r'\n+', LF),
63 (r'\s+', WS),
64 (r'\S+', Text),
65 ],
66 }

Callers 1

get_tokensFunction · 0.90

Calls 1

includeFunction · 0.85

Tested by

no test coverage detected