ui: fall back to xterm-256color if term initialization fails
[vis.git] / lexers / gettext.lua
blobd63ef41c77b8f5419e62fc9c5bede2897f242626
1 -- Copyright 2006-2015 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