diff options
| author | Sam Nystrom <sam@samnystrom.dev> | 2024-12-27 17:25:54 -0500 |
|---|---|---|
| committer | Sam Nystrom <sam@samnystrom.dev> | 2024-12-27 17:25:54 -0500 |
| commit | bacc2552699376770a8c87cd6d3bc71aeb1f9330 (patch) | |
| tree | f1eff71196359519a3b40d87a41454cbf04b2e1d /.config/vis/lexers/roff.lua | |
| parent | 390b2840178b89d84bedcbd8a392a0c567c3f457 (diff) | |
vis: add config
Diffstat (limited to '.config/vis/lexers/roff.lua')
| -rw-r--r-- | .config/vis/lexers/roff.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/.config/vis/lexers/roff.lua b/.config/vis/lexers/roff.lua new file mode 100644 index 0000000..59657a7 --- /dev/null +++ b/.config/vis/lexers/roff.lua @@ -0,0 +1,32 @@ +-- Copyright 2023 Sam Nystrom <sam@samnystrom.dev> +-- Roff LPeg lexer. + +local l = require('lexer') +local token, word_match = l.token, l.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local M = {_NAME = 'roff'} + +-- Whitespace +local ws = token(l.WHITESPACE, l.space^1) + +-- Comments +local comment = token(l.COMMENT, '\\"' * l.nonnewline^0) + +-- Strings +local string = token(l.STRING, l.delimited_range('"')) + +-- Keywords +local word = (l.alpha + '_') * (l.alnum + S('_.'))^0 +local keyword = token(l.KEYWORD, l.starts_line('.') * l.word) + +M._rules = { + {'whitespace', ws}, + {'keyword', keyword}, + {'string', string}, + {'comment', comment}, +} + +M._LEXBYLINE = true + +return M |
