diff options
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 |
