1 -- man/roff LPeg lexer.
3 local l
= require('lexer')
4 local token
, word_match
= l
.token
, l
.word_match
5 local P
, R
, S
= lpeg
.P
, lpeg
.R
, lpeg
.S
7 local M
= {_NAME
= 'man'}
10 local ws
= token(l
.WHITESPACE
, l
.space^
1)
13 local rule1
= token(l
.STRING
,
14 P('.') * (P('B') * P('R')^
-1 + P('I') * P('PR')^
-1) * l
.nonnewline^
0)
15 local rule2
= token(l
.NUMBER
, P('.') * S('ST') * P('H') * l
.nonnewline^
0)
16 local rule3
= token(l
.KEYWORD
,
17 P('.br') + P('.DS') + P('.RS') + P('.RE') + P('.PD'))
18 local rule4
= token(l
.LABEL
, P('.') * (S('ST') * P('H') + P('.TP')))
19 local rule5
= token(l
.VARIABLE
,
20 P('.B') * P('R')^
-1 + P('.I') * S('PR')^
-1 + P('.PP'))
21 local rule6
= token(l
.TYPE
, P('\\f') * S('BIPR'))
22 local rule7
= token(l
.PREPROCESSOR
, l
.starts_line('.') * l
.alpha^
1)