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'}
11 local ws
= token(l
.WHITESPACE
, l
.space^
1)
14 local rule1
= token(l
.STRING
,
15 P('.') * (P('B') * P('R')^
-1 + P('I') * P('PR')^
-1) *
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)