vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 5a3982645d5314972bcb4947790e6355551ff9df parent 8c7672828fda16fe1ff6875f38c41d4c99b0e40e Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 6 Jan 2021 15:28:16 +0100 lexers/strace: improve comments, field names and syscall results Diffstat:
| M | lua/lexers/strace.lua | | | 14 | ++++++++------ |
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lua/lexers/strace.lua b/lua/lexers/strace.lua @@ -1,9 +1,9 @@ --- Copyright 2017 Marc André Tanner. See LICENSE. +-- Copyright 2017-2021 Marc André Tanner. See LICENSE. -- strace(1) output lexer local l = require('lexer') local token, word_match = l.token, l.word_match -local S = lpeg.S +local S, B = lpeg.S, lpeg.B local M = {_NAME = 'strace'} @@ -13,16 +13,18 @@ local number = token(l.NUMBER, l.float + l.integer) local constant = token(l.CONSTANT, (l.upper + '_') * (l.upper + l.digit + '_')^0) local syscall = token(l.KEYWORD, l.starts_line(l.word)) local operator = token(l.OPERATOR, S('+-/*%<>~!=^&|?~:;,.()[]{}')) -local comment = token(l.COMMENT, l.nested_pair('/*', '*/') + ('(' * (l.alpha + ' ')^1 * ')\n')) -local result = token(l.TYPE, '= ' * l.integer) +local comment = token(l.COMMENT, l.nested_pair('/*', '*/') + (l.delimited_range('()') * l.newline)) +local result = token(l.TYPE, B(' = ') * l.integer) +local identifier = token(l.IDENTIFIER, l.word) M._rules = { {'whitespace', ws}, - {'keyword', syscall}, + {'syscall', syscall}, {'constant', constant}, {'string', string}, {'comment', comment}, - {'type', result}, + {'result', result}, + {'identifier', identifier}, {'number', number}, {'operator', operator}, }