Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
soong.py79 linesDownload Raw Back to lexers
1"""2    pygments.lexers.soong3    ~~~~~~~~~~~~~~~~~~~~~4 5    Lexers for Soong (Android.bp Blueprint) files.6 7    :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.8    :license: BSD, see LICENSE for details.9"""10 11from pygments.lexer import RegexLexer, bygroups, include12from pygments.token import Comment, Name, Number, Operator, Punctuation, \13        String, Whitespace14 15__all__ = ['SoongLexer']16 17class SoongLexer(RegexLexer):18    name = 'Soong'19    version_added = '2.18'20    url = 'https://source.android.com/docs/setup/reference/androidbp'21    aliases = ['androidbp', 'bp', 'soong']22    filenames = ['Android.bp']23 24    tokens = {25        'root': [26            # A variable assignment27            (r'(\w*)(\s*)(\+?=)(\s*)',28             bygroups(Name.Variable, Whitespace, Operator, Whitespace),29             'assign-rhs'),30 31            # A top-level module32            (r'(\w*)(\s*)(\{)',33             bygroups(Name.Function, Whitespace, Punctuation),34             'in-rule'),35 36            # Everything else37            include('comments'),38            (r'\s+', Whitespace),  # newlines okay39        ],40        'assign-rhs': [41            include('expr'),42            (r'\n', Whitespace, '#pop'),43        ],44        'in-list': [45            include('expr'),46            include('comments'),47            (r'\s+', Whitespace),  # newlines okay in a list48            (r',', Punctuation),49            (r'\]', Punctuation, '#pop'),50        ],51        'in-map': [52            # A map key53            (r'(\w+)(:)(\s*)', bygroups(Name, Punctuation, Whitespace)),54 55            include('expr'),56            include('comments'),57            (r'\s+', Whitespace),  # newlines okay in a map58            (r',', Punctuation),59            (r'\}', Punctuation, '#pop'),60        ],61        'in-rule': [62            # Just re-use map syntax63            include('in-map'),64        ],65        'comments': [66            (r'//.*', Comment.Single),67            (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),68        ],69        'expr': [70            (r'(true|false)\b', Name.Builtin),71            (r'0x[0-9a-fA-F]+', Number.Hex),72            (r'\d+', Number.Integer),73            (r'".*?"', String),74            (r'\{', Punctuation, 'in-map'),75            (r'\[', Punctuation, 'in-list'),76            (r'\w+', Name),77        ],78    }79 
codekingpro/portable-devtools · Team Ai