From 3751586e1fbf044fa798737e9c59a0235c5aaee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 25 Feb 2017 20:48:51 +0100 Subject: lexers: sync with scintillua changeset 594 rev 6e29a8d2a783 Stuff which was left out / our local changes include: - lexer.lua: different loading mechanism and style handling - ansi_c.lua: for now we keep the separate token definitions with references to the respective standards. This should highlight file names after #include directives. It will also treat simple, non-nested occurrences of #if 0 ... #endif as a comment. - pkgbuild.lua: the arch specific fields have been kept - all scintilla $(style variables) have been replaced --- lua/lexers/ansi_c.lua | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'lua/lexers/ansi_c.lua') diff --git a/lua/lexers/ansi_c.lua b/lua/lexers/ansi_c.lua index 4f82ab9..f35d4ea 100644 --- a/lua/lexers/ansi_c.lua +++ b/lua/lexers/ansi_c.lua @@ -12,7 +12,10 @@ local ws = token(l.WHITESPACE, l.space^1) -- Comments. local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 +local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 + + l.starts_line('#if') * S(' \t')^0 * '0' * l.space * + (l.any - l.starts_line('#endif'))^0 * + (l.starts_line('#endif'))^-1 local comment = token(l.COMMENT, line_comment + block_comment) -- Strings. @@ -25,11 +28,14 @@ local number = token(l.NUMBER, l.float + l.integer) -- Preprocessor. local preproc_word = word_match{ - 'define', 'elif', 'else', 'endif', 'error', 'if', 'ifdef', 'ifndef', - 'include', 'line', 'pragma', 'undef', 'warning', + 'define', 'elif', 'else', 'endif', 'error', 'if', 'ifdef', 'ifndef', 'line', + 'pragma', 'undef', 'warning' } -local preproc = token(l.PREPROCESSOR, - l.starts_line('#') * S('\t ')^0 * preproc_word) +local preproc = #l.starts_line('#') * + (token(l.PREPROCESSOR, '#' * S('\t ')^0 * preproc_word) + + token(l.PREPROCESSOR, '#' * S('\t ')^0 * 'include') * + (token(l.WHITESPACE, S('\t ')^1) * + token(l.STRING, l.delimited_range('<>', true, true)))^-1) -- Keywords. local storage_class = word_match{ @@ -110,10 +116,13 @@ M._rules = { } M._foldsymbols = { - _patterns = {'%l+', '[{}]', '/%*', '%*/', '//'}, + _patterns = {'#?%l+', '[{}]', '/%*', '%*/', '//'}, [l.PREPROCESSOR] = {['if'] = 1, ifdef = 1, ifndef = 1, endif = -1}, [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} + [l.COMMENT] = { + ['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//'), + ['#if'] = 1, ['#endif'] = -1 + } } return M -- cgit v1.2.3