aboutsummaryrefslogtreecommitdiff
path: root/lua/lexers/props.lua
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2023-08-11 01:27:32 +0200
committerRandy Palamar <randy@rnpnr.xyz>2024-03-27 06:04:21 -0600
commit4c4392d29df777ff702dfe99b4f3c23142976e05 (patch)
tree5355324abe18952f7d19d6cfc5dbeb5d6cb72b84 /lua/lexers/props.lua
parent95bf9f59f8a9a37148bdc0787db378d62c7cd032 (diff)
downloadvis-4c4392d29df777ff702dfe99b4f3c23142976e05.tar.gz
vis-4c4392d29df777ff702dfe99b4f3c23142976e05.tar.xz
update lexers to orbitalquark/scintillua@b789dde
Rather than cherry pick patches from after 6.2 we will just grab everything as is.
Diffstat (limited to 'lua/lexers/props.lua')
-rw-r--r--lua/lexers/props.lua28
1 files changed, 16 insertions, 12 deletions
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