1 -- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE.
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
= 'diff'}
10 -- Text, separators, and file headers.
11 local index
= token(l
.COMMENT
, 'Index: ' * l
.any^
0 * P(-1))
12 local separator
= token(l
.COMMENT
, ('---' + P('*')^
4 + P('=')^
1) * l
.space^
0 *
14 local header
= token('header', (P('*** ') + '--- ' + '+++ ') * l
.any^
1)
17 local location
= token(l
.NUMBER
, ('@@' + l
.digit^
1 + '****') * l
.any^
1)
19 -- Additions, deletions, and changes.
20 local addition
= token('addition', S('>+') * l
.any^
0)
21 local deletion
= token('deletion', S('<-') * l
.any^
0)
22 local change
= token('change', '! ' * l
.any^
0)
26 {'separator', separator
},
28 {'location', location
},
29 {'addition', addition
},
30 {'deletion', deletion
},
32 {'any_line', token('default', l
.any^
1)},
36 header
= l
.STYLE_COMMENT
,
37 addition
= 'fore:green',
38 deletion
= 'fore:red',
39 change
= 'fore:yellow',