1"""
2 pygments.lexers.srcinfo
3 ~~~~~~~~~~~~~~~~~~~~~~~
4
5 Lexers for .SRCINFO files used by Arch Linux Packages.
6
7 The description of the format can be found in the wiki:
8 https://wiki.archlinux.org/title/.SRCINFO
9
10 :copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS.
11 :license: BSD, see LICENSE for details.
12"""
13
14from pygments.lexer import RegexLexer, words
15from pygments.token import Text, Comment, Keyword, Name, Operator, Whitespace
16
17__all__ = ['SrcinfoLexer']
18
19keywords = (
20 'pkgbase', 'pkgname',
21 'pkgver', 'pkgrel', 'epoch',
22 'pkgdesc', 'url', 'install', 'changelog',
23 'arch', 'groups', 'license', 'noextract', 'options', 'backup',
24 'validpgpkeys',
25)
26
27architecture_dependent_keywords = (
28 'source', 'depends', 'checkdepends', 'makedepends', 'optdepends',
29 'provides', 'conflicts', 'replaces',
30 'md5sums', 'sha1sums', 'sha224sums', 'sha256sums', 'sha384sums',
31 'sha512sums',
32)
33
34
35class SrcinfoLexer(RegexLexer):
36 """Lexer for .SRCINFO files used by Arch Linux Packages.
37 """
38
39 name = 'Srcinfo'
40 aliases = ['srcinfo']
41 filenames = ['.SRCINFO']
42 url = 'https://wiki.archlinux.org/title/.SRCINFO'
43 version_added = '2.11'
44
45 tokens = {
46 'root': [
47 (r'\s+', Whitespace),
48 (r'#.*', Comment.Single),
49 (words(keywords), Keyword, 'assignment'),
50 (words(architecture_dependent_keywords, suffix=r'_\w+'),
51 Keyword, 'assignment'),
52 (r'\w+', Name.Variable, 'assignment'),
53 ],
54 'assignment': [
55 (r' +', Whitespace),
56 (r'=', Operator, 'value'),
57 ],
58 'value': [
59 (r' +', Whitespace),
60 (r'.*', Text, '#pop:2'),
61 ],
62 }