diff options
| author | orbitalquark <70453897+orbitalquark@users.noreply.github.com> | 2024-09-18 14:30:49 -0400 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-01-04 12:29:07 -0700 |
| commit | c1f4d3f68787fa2ae964c468d28a84df37319b28 (patch) | |
| tree | dcd62bd74f8f9fd786cba6a0c248fb388d5244a8 /lua/lexers/crystal.lua | |
| parent | cc18cea14d1f836abcebb84a96f5029431474255 (diff) | |
| download | vis-c1f4d3f68787fa2ae964c468d28a84df37319b28.tar.gz vis-c1f4d3f68787fa2ae964c468d28a84df37319b28.tar.xz | |
lexers: switch to tabs for indentation
Diffstat (limited to 'lua/lexers/crystal.lua')
| -rw-r--r-- | lua/lexers/crystal.lua | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lua/lexers/crystal.lua b/lua/lexers/crystal.lua index da6cc08..79468e5 100644 --- a/lua/lexers/crystal.lua +++ b/lua/lexers/crystal.lua @@ -13,19 +13,19 @@ lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) -- Keywords. lex:add_rule('keyword', token(lexer.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. lex:add_rule('function', token(lexer.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', - -- Macros. - 'assert_responds_to', 'debugger', 'parallel', 'pp', 'record', 'redefine_main' + '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', + -- Macros. + 'assert_responds_to', 'debugger', 'parallel', 'pp', 'record', 'redefine_main' }) * -S('.:|')) -- Identifiers. @@ -41,11 +41,11 @@ local cmd_str = lexer.range('`') local sq_str = lexer.range("'") local dq_str = lexer.range('"') local heredoc = '<<' * P(function(input, index) - local _, e, indented, _, delimiter = input:find('^(%-?)(["`]?)([%a_][%w_]*)%2[\n\r\f;]+', index) - if not delimiter then return end - local end_heredoc = (#indented > 0 and '[\n\r\f]+ *' or '[\n\r\f]+') - _, e = input:find(end_heredoc .. delimiter, e) - return e and e + 1 or #input + 1 + local _, e, indented, _, delimiter = input:find('^(%-?)(["`]?)([%a_][%w_]*)%2[\n\r\f;]+', index) + if not delimiter then return end + local end_heredoc = (#indented > 0 and '[\n\r\f]+ *' or '[\n\r\f]+') + _, e = input:find(end_heredoc .. delimiter, e) + return e and e + 1 or #input + 1 end) local string = token(lexer.STRING, (sq_str + dq_str + heredoc + cmd_str) * S('f')^-1) -- TODO: regex_str fails with `obj.method /patt/` syntax. @@ -59,14 +59,14 @@ lex:add_rule('number', token(lexer.NUMBER, lexer.number_('_') * S('ri')^-1 + num -- Variables. local global_var = '$' * - (word + S('!@L+`\'=~/\\,.;<>_*"$?:') + lexer.digit + '-' * S('0FadiIKlpvw')) + (word + S('!@L+`\'=~/\\,.;<>_*"$?:') + lexer.digit + '-' * S('0FadiIKlpvw')) local class_var = '@@' * word local inst_var = '@' * word lex:add_rule('variable', token(lexer.VARIABLE, global_var + class_var + inst_var)) -- Symbols. lex:add_rule('symbol', token('symbol', ':' * P(function(input, index) - if input:sub(index - 2, index - 2) ~= ':' then return true end + if input:sub(index - 2, index - 2) ~= ':' then return true end end) * (word_char^1 + sq_str + dq_str))) lex:add_style('symbol', lexer.styles.constant) @@ -75,8 +75,8 @@ lex:add_rule('operator', token(lexer.OPERATOR, S('!%^&*()[]{}-=+/|:;.,?<>~'))) -- Fold points. local function disambiguate(text, pos, line, s) - return line:sub(1, s - 1):match('^%s*$') and not text:sub(1, pos - 1):match('\\[ \t]*\r?\n$') and - 1 or 0 + return line:sub(1, s - 1):match('^%s*$') and not text:sub(1, pos - 1):match('\\[ \t]*\r?\n$') and + 1 or 0 end lex:add_fold_point(lexer.KEYWORD, 'begin', 'end') lex:add_fold_point(lexer.KEYWORD, 'case', 'end') |
