Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
meson.py140 linesDownload Raw Back to lexers
1"""2    pygments.lexers.meson3    ~~~~~~~~~~~~~~~~~~~~~4 5    Pygments lexer for the Meson build system6 7    :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.8    :license: BSD, see LICENSE for details.9"""10 11from pygments.lexer import RegexLexer, words, include12from pygments.token import Comment, Name, Number, Punctuation, Operator, \13    Keyword, String, Whitespace14 15__all__ = ['MesonLexer']16 17 18class MesonLexer(RegexLexer):19    """Meson language lexer.20 21    The grammar definition use to transcribe the syntax was retrieved from22    https://mesonbuild.com/Syntax.html#grammar for version 0.58.23    Some of those definitions are improperly transcribed, so the Meson++24    implementation was also checked: https://github.com/dcbaker/meson-plus-plus.25    """26 27    # TODO String interpolation @VARNAME@ inner matches28    # TODO keyword_arg: value inner matches29 30    name = 'Meson'31    url = 'https://mesonbuild.com/'32    aliases = ['meson', 'meson.build']33    filenames = ['meson.build', 'meson_options.txt']34    mimetypes = ['text/x-meson']35    version_added = '2.10'36 37    tokens = {38        'root': [39            (r'#.*?$', Comment),40            (r"'''.*'''", String.Single),41            (r'[1-9][0-9]*', Number.Integer),42            (r'0o[0-7]+', Number.Oct),43            (r'0x[a-fA-F0-9]+', Number.Hex),44            include('string'),45            include('keywords'),46            include('expr'),47            (r'[a-zA-Z_][a-zA-Z_0-9]*', Name),48            (r'\s+', Whitespace),49        ],50        'string': [51            (r"[']{3}([']{0,2}([^\\']|\\(.|\n)))*[']{3}", String),52            (r"'.*?(?<!\\)(\\\\)*?'", String),53        ],54        'keywords': [55            (words((56                'if',57                'elif',58                'else',59                'endif',60                'foreach',61                'endforeach',62                'break',63                'continue',64            ),65                   suffix=r'\b'), Keyword),66        ],67        'expr': [68            (r'(in|and|or|not)\b', Operator.Word),69            (r'(\*=|/=|%=|\+]=|-=|==|!=|\+|-|=)', Operator),70            (r'[\[\]{}:().,?]', Punctuation),71            (words(('true', 'false'), suffix=r'\b'), Keyword.Constant),72            include('builtins'),73            (words((74                'meson',75                'build_machine',76                'host_machine',77                'target_machine',78            ),79                   suffix=r'\b'), Name.Variable.Magic),80        ],81        'builtins': [82            # This list was extracted from the v0.58 reference manual83            (words((84                'add_global_arguments',85                'add_global_link_arguments',86                'add_languages',87                'add_project_arguments',88                'add_project_link_arguments',89                'add_test_setup',90                'assert',91                'benchmark',92                'both_libraries',93                'build_target',94                'configuration_data',95                'configure_file',96                'custom_target',97                'declare_dependency',98                'dependency',99                'disabler',100                'environment',101                'error',102                'executable',103                'files',104                'find_library',105                'find_program',106                'generator',107                'get_option',108                'get_variable',109                'include_directories',110                'install_data',111                'install_headers',112                'install_man',113                'install_subdir',114                'is_disabler',115                'is_variable',116                'jar',117                'join_paths',118                'library',119                'message',120                'project',121                'range',122                'run_command',123                'set_variable',124                'shared_library',125                'shared_module',126                'static_library',127                'subdir',128                'subdir_done',129                'subproject',130                'summary',131                'test',132                'vcs_tag',133                'warning',134            ),135                   prefix=r'(?<!\.)',136                   suffix=r'\b'), Name.Builtin),137            (r'(?<!\.)import\b', Name.Namespace),138        ],139    }140 
codekingpro/portable-devtools · Team Ai