aboutsummaryrefslogtreecommitdiff
path: root/lua/lexers/strace.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/strace.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/strace.lua')
-rw-r--r--lua/lexers/strace.lua28
1 files changed, 12 insertions, 16 deletions
diff --git a/lua/lexers/strace.lua b/lua/lexers/strace.lua
index 846c4fc..c2d2df1 100644
--- a/lua/lexers/strace.lua
+++ b/lua/lexers/strace.lua
@@ -1,35 +1,31 @@
--- Copyright 2017-2021 Marc André Tanner. See LICENSE.
+-- Copyright 2017-2024 Marc André Tanner. See LICENSE.
-- strace(1) output lexer
-local lexer = require('lexer')
-local token, word_match = lexer.token, lexer.word_match
+local lexer = lexer
local S, B = lpeg.S, lpeg.B
-local lex = lexer.new('strace', {lex_by_line = true})
-
--- Whitespace
-lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))
+local lex = lexer.new(..., {lex_by_line = true})
-- Syscall
-lex:add_rule('syscall', token(lexer.KEYWORD, lexer.starts_line(lexer.word)))
+lex:add_rule('syscall', lex:tag(lexer.FUNCTION, lexer.starts_line(lexer.word)))
-- Upper case constants
-lex:add_rule('constant', token(lexer.CONSTANT,
- (lexer.upper + '_') * (lexer.upper + lexer.digit + '_')^0))
+lex:add_rule('constant',
+ lex:tag(lexer.CONSTANT, (lexer.upper + '_') * (lexer.upper + lexer.digit + '_')^0))
-- Single and double quoted strings
local sq_str = lexer.range("'", true)
local dq_str = lexer.range('"', true)
-lex:add_rule('string', token(lexer.STRING, sq_str + dq_str))
+lex:add_rule('string', lex:tag(lexer.STRING, sq_str + dq_str))
-- Comments and text in parentheses at the line end
local comment = lexer.range('/*', '*/')
local description = lexer.range('(', ')') * lexer.newline
-lex:add_rule('comment', token(lexer.COMMENT, comment + description))
+lex:add_rule('comment', lex:tag(lexer.COMMENT, comment + description))
-lex:add_rule('result', token(lexer.TYPE, B(' = ') * lexer.integer))
-lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word))
-lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer))
-lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>~!=^&|?~:;,.()[]{}')))
+lex:add_rule('result', lex:tag(lexer.TYPE, B(' = ') * lexer.integer))
+lex:add_rule('identifier', lex:tag(lexer.IDENTIFIER, lexer.word))
+lex:add_rule('number', lex:tag(lexer.NUMBER, lexer.float + lexer.integer))
+lex:add_rule('operator', lex:tag(lexer.OPERATOR, S('+-/*%<>~!=^&|?~:;,.()[]{}')))
return lex