From 4c4392d29df777ff702dfe99b4f3c23142976e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Fri, 11 Aug 2023 01:27:32 +0200 Subject: update lexers to orbitalquark/scintillua@b789dde Rather than cherry pick patches from after 6.2 we will just grab everything as is. --- lua/lexers/props.lua | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'lua/lexers/props.lua') diff --git a/lua/lexers/props.lua b/lua/lexers/props.lua index a7b6723..b926f96 100644 --- a/lua/lexers/props.lua +++ b/lua/lexers/props.lua @@ -1,32 +1,36 @@ --- Copyright 2006-2022 Mitchell. See LICENSE. +-- Copyright 2006-2024 Mitchell. See LICENSE. -- Props LPeg lexer. -local lexer = require('lexer') -local token, word_match = lexer.token, lexer.word_match +local lexer = lexer local P, S = lpeg.P, lpeg.S -local lex = lexer.new('props', {lex_by_line = true}) +local lex = lexer.new(..., {lex_by_line = true}) --- Whitespace. -lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) +-- Identifiers. +lex:add_rule('identifier', + lex:tag(lexer.IDENTIFIER, (lexer.alpha + S('.-_')) * (lexer.alnum + S('.-_')^0))) -- Colors. local xdigit = lexer.xdigit -lex:add_rule('color', token('color', '#' * xdigit * xdigit * xdigit * xdigit * xdigit * xdigit)) -lex:add_style('color', lexer.styles.number) +lex:add_rule('color', + lex:tag(lexer.NUMBER, '#' * xdigit * xdigit * xdigit * xdigit * xdigit * xdigit)) -- Comments. -lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('#'))) +lex:add_rule('comment', lex:tag(lexer.COMMENT, lexer.to_eol('#'))) -- Equals. -lex:add_rule('equals', token(lexer.OPERATOR, '=')) +lex:add_rule('equals', lex:tag(lexer.OPERATOR, '=')) -- Strings. local sq_str = lexer.range("'") local dq_str = lexer.range('"') -lex:add_rule('string', token(lexer.STRING, sq_str + dq_str)) +lex:add_rule('string', lex:tag(lexer.STRING, sq_str + dq_str)) -- Variables. -lex:add_rule('variable', token(lexer.VARIABLE, '$' * lexer.range('(', ')', true))) +lex:add_rule('variable', + lex:tag(lexer.OPERATOR, '$(') * lex:tag(lexer.VARIABLE, (lexer.nonnewline - lexer.space - ')')^0) * + lex:tag(lexer.OPERATOR, ')')) + +lexer.property['scintillua.comment'] = '#' return lex -- cgit v1.2.3