diff options
author | mitchell <unknown> | 2018-03-11 23:04:41 -0400 |
---|---|---|
committer | mitchell <unknown> | 2018-03-11 23:04:41 -0400 |
commit | 519b7328b66c4c84f03893a31e4be5ba6b1395f2 (patch) | |
tree | 2055cd79006357e94c185f341d0df17b9a8769eb /lexlua/desktop.lua | |
parent | c0373e036e965a70045971e2abc582cb4bf12a4e (diff) | |
download | scintilla-mirror-519b7328b66c4c84f03893a31e4be5ba6b1395f2.tar.gz |
Added optional Lua lexer support.
This support is disabled by default and must be enabled via compile-time option.
Diffstat (limited to 'lexlua/desktop.lua')
-rw-r--r-- | lexlua/desktop.lua | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lexlua/desktop.lua b/lexlua/desktop.lua new file mode 100644 index 000000000..1c78e3278 --- /dev/null +++ b/lexlua/desktop.lua @@ -0,0 +1,56 @@ +-- Copyright 2006-2018 Mitchell mitchell.att.foicica.com. See License.txt. +-- Desktop Entry LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('desktop') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keys. +lex:add_rule('key', token('key', word_match[[ + Type Version Name GenericName NoDisplay Comment Icon Hidden OnlyShowIn + NotShowIn TryExec Exec Exec Path Terminal MimeType Categories StartupNotify + StartupWMClass URL +]])) +lex:add_style('key', lexer.STYLE_KEYWORD) + +-- Values. +lex:add_rule('value', token('value', word_match[[true false]])) +lex:add_style('value', lexer.STYLE_CONSTANT) + +-- Identifiers. +lex:add_rule('identifier', lexer.token(lexer.IDENTIFIER, + lexer.alpha * (lexer.alnum + S('_-'))^0)) + +-- Group headers. +lex:add_rule('header', + lexer.starts_line(token('header', + lexer.delimited_range('[]', false, true)))) +lex:add_style('header', lexer.STYLE_LABEL) + +-- Locales. +lex:add_rule('locale', token('locale', + lexer.delimited_range('[]', false, true))) +lex:add_style('locale', lexer.STYLE_CLASS) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"'))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, (lexer.float + lexer.integer))) + +-- Field codes. +lex:add_rule('code', lexer.token('code', P('%') * S('fFuUdDnNickvm'))) +lex:add_style('code', lexer.STYLE_VARIABLE) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('='))) + +return lex |