diff options
| -rw-r--r-- | lexers/crystal.lua | 21 | ||||
| -rw-r--r-- | lexers/lexer.lua | 5 | ||||
| -rw-r--r-- | lexers/protobuf.lua | 5 | ||||
| -rw-r--r-- | vis.lua | 1 |
4 files changed, 16 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 @@ -176,6 +176,7 @@ vis.ftdetect.filetypes = { snobol4 = { ext = ".sno|.SNO" }, sql = { ext = ".ddl|.sql" }, systemd = { ext = ".automount|.device|.mount|.path|.scope|.service|.slice|.socket|.swap|.target|.timer" }, + taskpaper = { ext = ".taskpaper" }, tcl = { ext = ".tcl|.tk" }, texinfo = { ext = ".texi" }, toml = { ext = ".toml" }, |
