ui: make primary cursor blink even if no lua theme has been loaded
[vis.git] / lexers / gettext.lua
blob8556d01bbe23fbe8570da8a829f7ee1715f0c2f7
1 -- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE.
2 -- Gettext 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 = 'gettext'}
10 -- Whitespace.
11 local ws = token(l.WHITESPACE, l.space^1)
13 -- Comments.
14 local comment = token(l.COMMENT, '#' * S(': .~') * l.nonnewline^0)
16 -- Strings.
17 local string = token(l.STRING, l.delimited_range('"', true))
19 -- Keywords.
20 local keyword = token(l.KEYWORD, word_match({
21 'msgid', 'msgid_plural', 'msgstr', 'fuzzy', 'c-format', 'no-c-format'
22 }, '-', true))
24 -- Identifiers.
25 local identifier = token(l.IDENTIFIER, l.word)
27 -- Variables.
28 local variable = token(l.VARIABLE, S('%$@') * l.word)
30 M._rules = {
31 {'whitespace', ws},
32 {'comment', comment},
33 {'string', string},
34 {'keyword', keyword},
35 {'identifier', identifier},
36 {'variable', variable},
39 return M