From 16e31ceb717c943584cb75d0e28c21e356a54076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Mon, 24 Mar 2025 10:11:05 -0400 Subject: lua/lexers: update to scintillua 6.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an amalgamation of the following upstream commits: - Overhauled API documentation for lexer.lua. - Fixed Markdown to allow code fence blocks to be indented. - Use GitHub Pages' Primer theme for documentation. Build static pages with Jekyll, like GitHub Pages does. - Migrated systemd lexer. Thanks to Matěj Cepl. - Migrated Lisp lexer and highlight character escapes. Thanks to Matěj Cepl. - Migrated rpmspec lexer and made some improvements. Thanks to Matěj Cepl. - Modernized reST lexer. Thanks to Matěj Cepl. - Markdown lexer should just tag the start of a blockquote. The quote's contents may contain markdown. - Output lexer can highlight CSI color sequences. - Allow lexers to define their own fold functions. - Added custom folder for Markdown headers. - Added `lexer.line_start`, `lexer.line_end` and `lexer.text_range()`. - Fixed Markdown lexer to not lex some continuation lines as code. - Fixed SciTE not using Scintillua's markdown lexer. - Markdown lexer should not highlight secondary paragraphs in list items as code blocks. - Have SciTE recognize CMakeLists.txt. --- lua/lexers/rpmspec.lua | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'lua/lexers/rpmspec.lua') diff --git a/lua/lexers/rpmspec.lua b/lua/lexers/rpmspec.lua index 4eec9c8..7b390e4 100644 --- a/lua/lexers/rpmspec.lua +++ b/lua/lexers/rpmspec.lua @@ -1,32 +1,48 @@ -- Copyright 2022-2025 Matej Cepl mcepl.att.cepl.eu. See LICENSE. -local lexer = require('lexer') -local token, word_match = lexer.token, lexer.word_match -local P, S = lpeg.P, lpeg.S +local lexer = lexer +local P, R, S = lpeg.P, lpeg.R, lpeg.S -local lex = lexer.new('rpmspec') - --- Whitespace. -lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) +local lex = lexer.new(...) -- Comments. -lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('#'))) +lex:add_rule('comment', lex:tag(lexer.COMMENT, lexer.to_eol('#'))) + +-- Numbers (including versions) +lex:add_rule('number', lex:tag(lexer.NUMBER, + lpeg.B(lexer.space) * (lexer.number * (lexer.number + S('.+~'))^0))) + +-- Operators +lex:add_rule('operator', lex:tag(lexer.OPERATOR, S('&<>=|'))) -- Strings. -lex:add_rule('string', token(lexer.STRING, lexer.range('"'))) +lex:add_rule('string', lex:tag(lexer.STRING, lexer.range('"'))) -- Keywords. -lex:add_rule('keyword', token(lexer.KEYWORD, word_match{ +lex:add_rule('keyword', lex:tag(lexer.KEYWORD, (lex:word_match(lexer.KEYWORD) + + (P('Patch') + 'Source') * R('09')^0) * ':')) + +-- Macros +lex:add_rule('command', lex:tag(lexer.FUNCTION, lexer.range(S('%$')^1 * S('{')^0 * + ((lexer.alnum + S('_?'))^0), S('}')^0))) + +-- Constants +lex:add_rule('constant', lex:tag(lexer.CONSTANT, lex:word_match(lexer.CONSTANT))) + +-- Word lists +lex:set_word_list(lexer.CONSTANT, { + 'rhel', 'fedora', 'suse_version', 'sle_version', 'x86_64', 'aarch64', 'ppc64le', 'riscv64', + 's390x' +}) + +lex:set_word_list(lexer.KEYWORD, { 'Prereq', 'Summary', 'Name', 'Version', 'Packager', 'Requires', 'Recommends', 'Suggests', 'Supplements', 'Enhances', 'Icon', 'URL', 'Source', 'Patch', 'Prefix', 'Packager', 'Group', 'License', 'Release', 'BuildRoot', 'Distribution', 'Vendor', 'Provides', 'ExclusiveArch', 'ExcludeArch', 'ExclusiveOS', 'Obsoletes', 'BuildArch', 'BuildArchitectures', 'BuildRequires', 'BuildConflicts', 'BuildPreReq', 'Conflicts', 'AutoRequires', 'AutoReq', 'AutoReqProv', 'AutoProv', 'Epoch' -})) - --- Macros -lex:add_rule('command', token(lexer.FUNCTION, '%' * lexer.word)) +}) lexer.property['scintillua.comment'] = '#' -- cgit v1.2.3