aboutsummaryrefslogtreecommitdiff
path: root/lexers
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-10-07 07:31:21 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-10-07 07:42:51 +0200
commit4e8e356e94533cc2d47aec804cdc86dbb0fca530 (patch)
tree3e69ac1ad2b4f3e0a3f635d5b2eedb95200e8761 /lexers
parentca0ce4631c2474088f4ee0943d45397460fec3a7 (diff)
downloadvis-4e8e356e94533cc2d47aec804cdc86dbb0fca530.tar.gz
vis-4e8e356e94533cc2d47aec804cdc86dbb0fca530.tar.xz
lexers: sync with scintillua changeset 571 rev 23435f1d82da
This fixes ":set syntax text" and adds a missing file association for the taskpaper lexer. The protobuf and crystal lexers were slightly reformatted, but should contain no functional changes.
Diffstat (limited to 'lexers')
-rw-r--r--lexers/crystal.lua21
-rw-r--r--lexers/lexer.lua5
-rw-r--r--lexers/protobuf.lua5
3 files changed, 15 insertions, 16 deletions
diff --git a/lexers/crystal.lua b/lexers/crystal.lua
index 4af2fef..8766e96 100644
--- a/lexers/crystal.lua
+++ b/lexers/crystal.lua
@@ -48,7 +48,8 @@ end)
-- TODO: regex_str fails with `obj.method /patt/` syntax.
local regex_str = #P('/') * l.last_char_includes('!%^&*([{-=+|:;,?<>~') *
l.delimited_range('/', true, false) * S('iomx')^0
-local string = token(l.STRING, (sq_str + dq_str + heredoc + cmd_str) * S('f')^-1) +
+local string = token(l.STRING, (sq_str + dq_str + heredoc + cmd_str) *
+ S('f')^-1) +
token(l.REGEX, regex_str)
local word_char = l.alnum + S('_!?')
@@ -63,22 +64,20 @@ local number = token(l.NUMBER, l.float * S('ri')^-1 + integer + numeric_literal)
-- Keywords.
local keyword = token(l.KEYWORD, word_match({
- 'alias', 'begin', 'break', 'case', 'class', 'def', 'defined?',
- 'do', 'else', 'elsif', 'end', 'ensure', 'false', 'for', 'if',
- 'in', 'module', 'next', 'nil', 'not', 'redo', 'rescue', 'retry',
- 'return', 'self', 'super', 'then', 'true', 'undef', 'unless',
- 'until', 'when', 'while', 'yield', '__FILE__', '__LINE__'
+ 'alias', 'begin', 'break', 'case', 'class', 'def', 'defined?', 'do', 'else',
+ 'elsif', 'end', 'ensure', 'false', 'for', 'if', 'in', 'module', 'next', 'nil',
+ 'not', 'redo', 'rescue', 'retry', 'return', 'self', 'super', 'then', 'true',
+ 'undef', 'unless', 'until', 'when', 'while', 'yield', '__FILE__', '__LINE__'
}, '?!'))
-- Functions.
local func = token(l.FUNCTION, word_match({
'abort', 'at_exit', 'caller', 'delay', 'exit', 'fork', 'future',
- 'get_stack_top', 'gets', 'lazy', 'loop', 'main', 'p', 'print',
- 'printf', 'puts', 'raise', 'rand', 'read_line', 'require', 'sleep',
- 'spawn', 'sprintf', 'system', 'with_color',
+ 'get_stack_top', 'gets', 'lazy', 'loop', 'main', 'p', 'print', 'printf',
+ 'puts', 'raise', 'rand', 'read_line', 'require', 'sleep', 'spawn', 'sprintf',
+ 'system', 'with_color',
-- Macros
- 'assert_responds_to', 'debugger', 'parallel', 'pp', 'record',
- 'redefine_main'
+ 'assert_responds_to', 'debugger', 'parallel', 'pp', 'record', 'redefine_main'
}, '?!')) * -S('.:|')
-- Identifiers.
diff --git a/lexers/lexer.lua b/lexers/lexer.lua
index bce9c29..5653bb2 100644
--- a/lexers/lexer.lua
+++ b/lexers/lexer.lua
@@ -1032,9 +1032,7 @@ function M.load(name, alt_name)
-- prevent errors from occurring.
if not M.property then
M.property, M.property_int = {}, setmetatable({}, {
- __index = function(t, k)
- return tostring(tonumber(M.property[k]) or 0)
- end,
+ __index = function(t, k) return tonumber(M.property[k]) or 0 end,
__newindex = function() error('read-only property') end
})
end
@@ -1114,6 +1112,7 @@ end
-- @return table of token names and positions.
-- @name lex
function M.lex(lexer, text, init_style)
+ if not lexer._GRAMMAR then return {M.DEFAULT, #text + 1} end
if not lexer._LEXBYLINE then
-- For multilang lexers, build a new grammar whose initial_rule is the
-- current language.
diff --git a/lexers/protobuf.lua b/lexers/protobuf.lua
index fdf0a73..c257e7e 100644
--- a/lexers/protobuf.lua
+++ b/lexers/protobuf.lua
@@ -1,5 +1,6 @@
--- Copyright 2016 David B. Lamkins <david@lamkins.net>
--- Protocol Buffer IDL <https://developers.google.com/protocol-buffers/>
+-- Copyright 2016 David B. Lamkins <david@lamkins.net>. See LICENSE.
+-- Protocol Buffer IDL LPeg lexer.
+-- <https://developers.google.com/protocol-buffers/>
local l = require('lexer')
local token, word_match = l.token, l.word_match