ui: make primary cursor blink even if no lua theme has been loaded
[vis.git] / lexers / dockerfile.lua
blob3f6ca7fa3f8b91790ecd25dd4b221c501fcd0a0f
1 -- Copyright 2016 Alejandro Baez (https://keybase.io/baez). See LICENSE.
2 -- Dockerfile 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 = 'dockerfile'}
10 -- Whitespace
11 local indent = #l.starts_line(S(' \t')) *
12 (token(l.WHITESPACE, ' ') + token('indent_error', '\t'))^1
13 local ws = token(l.WHITESPACE, S(' \t')^1 + l.newline^1)
15 -- Comments.
16 local comment = token(l.COMMENT, '#' * l.nonnewline^0)
18 -- Strings.
19 local sq_str = l.delimited_range("'", false, true)
20 local dq_str = l.delimited_range('"')
21 local string = token(l.STRING, sq_str + dq_str)
23 -- Numbers.
24 local number = token(l.NUMBER, l.float + l.integer)
26 -- Keywords.
27 local keyword = token(l.KEYWORD, word_match{
28 'ADD', 'ARG', 'CMD', 'COPY', 'ENTRYPOINT', 'ENV', 'EXPOSE', 'FROM', 'LABEL',
29 'MAINTAINER', 'ONBUILD', 'RUN', 'STOPSIGNAL', 'USER', 'VOLUME', 'WORKDIR'
32 -- Identifiers.
33 local identifier = token(l.IDENTIFIER, l.word)
35 -- Variable.
36 local variable = token(l.VARIABLE,
37 S('$')^1 * (S('{')^1 * l.word * S('}')^1 + l.word))
39 -- Operators.
40 local operator = token(l.OPERATOR, S('\\[],=:{}'))
42 M._rules = {
43 {'whitespace', ws},
44 {'keyword', keyword},
45 {'variable', variable},
46 {'identifier', identifier},
47 {'string', string},
48 {'comment', comment},
49 {'number', number},
50 {'operator', operator},
53 M._FOLDBYINDENTATION = true
55 return M