ui: make primary cursor blink even if no lua theme has been loaded
[vis.git] / lexers / man.lua
blob557e11d6a5bf7036960cc7e990048c31acd0d569
1 -- Copyright 2015-2016 David B. Lamkins <david@lamkins.net>. See LICENSE.
2 -- man/roff LPeg lexer.
4 local l = require('lexer')
5 local token, word_match = l.token, l.word_match
6 local P, R, S = lpeg.P, lpeg.R, lpeg.S
8 local M = {_NAME = 'man'}
10 -- Whitespace.
11 local ws = token(l.WHITESPACE, l.space^1)
13 -- Markup.
14 local rule1 = token(l.STRING,
15 P('.') * (P('B') * P('R')^-1 + P('I') * P('PR')^-1) *
16 l.nonnewline^0)
17 local rule2 = token(l.NUMBER, P('.') * S('ST') * P('H') * l.nonnewline^0)
18 local rule3 = token(l.KEYWORD,
19 P('.br') + P('.DS') + P('.RS') + P('.RE') + P('.PD'))
20 local rule4 = token(l.LABEL, P('.') * (S('ST') * P('H') + P('.TP')))
21 local rule5 = token(l.VARIABLE,
22 P('.B') * P('R')^-1 + P('.I') * S('PR')^-1 + P('.PP'))
23 local rule6 = token(l.TYPE, P('\\f') * S('BIPR'))
24 local rule7 = token(l.PREPROCESSOR, l.starts_line('.') * l.alpha^1)
26 M._rules = {
27 {'whitespace', ws},
28 {'rule1', rule1},
29 {'rule2', rule2},
30 {'rule3', rule3},
31 {'rule4', rule4},
32 {'rule5', rule5},
33 {'rule6', rule6},
34 {'rule7', rule7},
37 return M