logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

meson.lua (5721B)


  1. -- Copyright 2020-2024 Florian Fischer. See LICENSE.
  2. -- Meson file LPeg lexer.
  3. local lexer = lexer
  4. local S = lpeg.S
  5. local lex = lexer.new(..., {fold_by_indentation = true})
  6. -- Keywords.
  7. lex:add_rule('keyword', lex:tag(lexer.KEYWORD, lex:word_match(lexer.KEYWORD)))
  8. -- Functions.
  9. -- https://mesonbuild.com/Reference-manual.html#builtin-objects
  10. -- https://mesonbuild.com/Reference-manual.html#returned-objects
  11. local method = lex:tag(lexer.FUNCTION_METHOD, lex:word_match(lexer.FUNCTION_METHOD))
  12. -- https://mesonbuild.com/Reference-manual.html#functions
  13. local func = lex:tag(lexer.FUNCTION_BUILTIN, lex:word_match(lexer.FUNCTION_BUILTIN))
  14. -- A function call must be followed by an opening parenthesis. The matching of function calls
  15. -- instead of just their names is needed to not falsely highlight function names which can also
  16. -- be keyword arguments. For example 'include_directories' can be a function call itself or a
  17. -- keyword argument of an 'executable' or 'library' function call.
  18. lex:add_rule('function', (method + func) * #(lexer.space^0 * '('))
  19. -- Builtin objects.
  20. -- https://mesonbuild.com/Reference-manual.html#builtin-objects
  21. lex:add_rule('object', lex:tag(lexer.VARIABLE_BUILTIN, lex:word_match(lexer.VARIABLE_BUILTIN)))
  22. -- Constants.
  23. lex:add_rule('constant', lex:tag(lexer.CONSTANT_BUILTIN, lex:word_match(lexer.CONSTANT_BUILTIN)))
  24. -- Identifiers.
  25. lex:add_rule('identifier', lex:tag(lexer.IDENTIFIER, lexer.word))
  26. -- Strings.
  27. local str = lexer.range("'", true)
  28. local multiline_str = lexer.range("'''")
  29. lex:add_rule('string', lex:tag(lexer.STRING, multiline_str + str))
  30. -- Comments.
  31. lex:add_rule('comment', lex:tag(lexer.COMMENT, lexer.to_eol('#', true)))
  32. -- Numbers.
  33. local oct_num = '0o' * lpeg.R('07')
  34. local integer = S('+-')^-1 * (lexer.hex_num + lexer.bin_num + oct_num + lexer.dec_num)
  35. lex:add_rule('number', lex:tag(lexer.NUMBER, integer))
  36. -- Operators.
  37. lex:add_rule('operator', lex:tag(lexer.OPERATOR, S('()[]{}-=+/%:.,?<>')))
  38. -- Word lists
  39. lex:set_word_list(lexer.KEYWORD, {
  40. 'and', 'or', 'not', 'if', 'elif', 'else', 'endif', 'foreach', 'break', 'continue', 'endforeach'
  41. })
  42. lex:set_word_list(lexer.FUNCTION_METHOD, {
  43. -- array --
  44. 'contains', 'get', 'length',
  45. -- boolean --
  46. 'to_int', 'to_string',
  47. -- dictionary --
  48. 'has_key', 'get', 'keys',
  49. -- disabler --
  50. 'found',
  51. -- integer --
  52. 'is_even', 'is_odd',
  53. -- string --
  54. 'contains', 'endswith', 'format', 'join', 'split', 'startswith', 'substring', 'strip', 'to_int',
  55. 'to_lower', 'to_upper', 'underscorify', 'version_compare',
  56. -- meson object --
  57. 'add_dist_script', 'add_install_script', 'add_postconf_script', 'backend', 'build_root',
  58. 'source_root', 'project_build_root', 'project_source_root', 'current_build_dir',
  59. 'current_source_dir', 'get_compiler', 'get_cross_property', 'get_external_property',
  60. 'can_run_host_binaries', 'has_exe_wrapper', 'install_dependency_manifest', 'is_cross_build',
  61. 'is_subproject', 'is_unity', 'override_find_program', 'override_dependency', 'project_version',
  62. 'project_license', 'project_name', 'version',
  63. -- *_machine object --
  64. 'cpu_family', 'cpu', 'system', 'endian',
  65. -- compiler object --
  66. 'alignment', 'cmd_array', 'compiles', 'compute_int', 'find_library', 'first_supported_argument',
  67. 'first_supported_link_argument', 'get_define', 'get_id', 'get_argument_syntax', 'get_linker_id',
  68. 'get_supported_arguments', 'get_supported_link_arguments', 'has_argument', 'has_link_argument',
  69. 'has_function', 'check_header', 'has_header', 'has_header_symbol', 'has_member', 'has_members',
  70. 'has_multi_arguments', 'has_multi_link_arguments', 'has_type', 'links', 'run',
  71. 'symbols_have_underscore_prefix', 'sizeof', 'version', 'has_function_attribute',
  72. 'get_supported_function_attributes',
  73. -- build target object --
  74. 'extract_all_objects', 'extract_objects', 'full_path', 'private_dir_include', 'name',
  75. -- configuration data object --
  76. 'get', 'get_unquoted', 'has', 'keys', 'merge_from', 'set', 'set10', 'set_quoted',
  77. -- custom target object --
  78. 'full_path', 'to_list',
  79. -- dependency object --
  80. 'found', 'name', 'get_pkgconfig_variable', 'get_configtool_variable', 'type_name', 'version',
  81. 'include_type', 'as_system', 'as_link_whole', 'partial_dependency', 'found',
  82. -- external program object --
  83. 'found', 'path', 'full_path',
  84. -- environment object --
  85. 'append', 'prepend', 'set',
  86. -- external library object --
  87. 'found', 'type_name', 'partial_dependency', 'enabled', 'disabled', 'auto',
  88. -- generator object --
  89. 'process',
  90. -- subproject object --
  91. 'found', 'get_variable',
  92. -- run result object --
  93. 'compiled', 'returncode', 'stderr', 'stdout'
  94. })
  95. lex:set_word_list(lexer.FUNCTION_BUILTIN, {
  96. 'add_global_arguments', 'add_global_link_arguments', 'add_languages', 'add_project_arguments',
  97. 'add_project_link_arguments', 'add_test_setup', 'alias_targ', 'assert', 'benchmark',
  98. 'both_libraries', 'build_target', 'configuration_data', 'configure_file', 'custom_target',
  99. 'declare_dependency', 'dependency', 'disabler', 'error', 'environment', 'executable',
  100. 'find_library', 'find_program', 'files', 'generator', 'get_option', 'get_variable', 'import',
  101. 'include_directories', 'install_data', 'install_headers', 'install_man', 'install_subdir',
  102. 'is_disabler', 'is_variable', 'jar', 'join_paths', 'library', 'message', 'warning', 'summary',
  103. 'project', 'run_command', 'run_targ', 'set_variable', 'shared_library', 'shared_module',
  104. 'static_library', 'subdir', 'subdir_done', 'subproject', 'test', 'vcs_tag'
  105. })
  106. lex:set_word_list(lexer.VARIABLE_BUILTIN, {
  107. 'meson', 'build_machine', 'host_machine', 'target_machine'
  108. })
  109. lex:set_word_list(lexer.CONSTANT_BUILTIN, {'false', 'true'})
  110. lexer.property['scintillua.comment'] = '#'
  111. return lex