aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-02-25 20:48:51 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-02-25 21:14:28 +0100
commit3751586e1fbf044fa798737e9c59a0235c5aaee7 (patch)
tree417e30516500092e4002d3a6c2dacdd6b3050d90
parentb44f174cccd4cd2b1b975f2767335ce636ee273b (diff)
downloadvis-3751586e1fbf044fa798737e9c59a0235c5aaee7.tar.gz
vis-3751586e1fbf044fa798737e9c59a0235c5aaee7.tar.xz
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
-rw-r--r--lua/lexers/LICENSE2
-rw-r--r--lua/lexers/ansi_c.lua23
-rw-r--r--lua/lexers/chuck.lua27
-rw-r--r--lua/lexers/context.lua2
-rw-r--r--lua/lexers/cpp.lua9
-rw-r--r--lua/lexers/dart.lua2
-rw-r--r--lua/lexers/dockerfile.lua2
-rw-r--r--lua/lexers/dot.lua2
-rw-r--r--lua/lexers/html.lua17
-rw-r--r--lua/lexers/inform.lua1
-rw-r--r--lua/lexers/json.lua2
-rw-r--r--lua/lexers/less.lua2
-rw-r--r--lua/lexers/lexer.lua14
-rw-r--r--lua/lexers/lilypond.lua2
-rw-r--r--lua/lexers/litcoffee.lua2
-rw-r--r--lua/lexers/matlab.lua2
-rw-r--r--lua/lexers/moonscript.lua2
-rw-r--r--lua/lexers/nsis.lua2
-rw-r--r--lua/lexers/pico8.lua2
-rw-r--r--lua/lexers/protobuf.lua2
-rw-r--r--lua/lexers/rc.lua1
-rw-r--r--lua/lexers/sass.lua2
-rw-r--r--lua/lexers/scala.lua2
-rw-r--r--lua/lexers/sml.lua3
-rw-r--r--lua/lexers/taskpaper.lua2
-rw-r--r--lua/lexers/vcard.lua2
26 files changed, 71 insertions, 60 deletions
diff --git a/lua/lexers/LICENSE b/lua/lexers/LICENSE
index 627e560..833f2be 100644
--- a/lua/lexers/LICENSE
+++ b/lua/lexers/LICENSE
@@ -1,6 +1,6 @@
The MIT License
-Copyright (c) 2007-2016 Mitchell
+Copyright (c) 2007-2017 Mitchell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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
diff --git a/lua/lexers/chuck.lua b/lua/lexers/chuck.lua
index 3efe704..0a2aa30 100644
--- a/lua/lexers/chuck.lua
+++ b/lua/lexers/chuck.lua
@@ -1,28 +1,5 @@
---------------------------------------------------------------------------------
--- The MIT License
---
--- Copyright (c) 2010 Martin Morawetz
---
--- Permission is hereby granted, free of charge, to any person obtaining a copy
--- of this software and associated documentation files (the "Software"), to deal
--- in the Software without restriction, including without limitation the rights
--- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
--- copies of the Software, and to permit persons to whom the Software is
--- furnished to do so, subject to the following conditions:
---
--- The above copyright notice and this permission notice shall be included in
--- all copies or substantial portions of the Software.
---
--- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
--- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
--- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
--- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
--- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
--- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
--- THE SOFTWARE.
---------------------------------------------------------------------------------
-
--- Based on lexer code from Mitchell mitchell.att.foicica.com.
+-- Copyright 2010-2017 Martin Morawetz. See LICENSE.
+-- ChucK LPeg lexer.
local l = require('lexer')
local token, word_match = l.token, l.word_match
diff --git a/lua/lexers/context.lua b/lua/lexers/context.lua
index 30ec1b0..8c3a2bb 100644
--- a/lua/lexers/context.lua
+++ b/lua/lexers/context.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 Robert Gieseke. See LICENSE.
+-- Copyright 2006-2017 Robert Gieseke. See LICENSE.
-- ConTeXt LPeg lexer.
local l = require('lexer')
diff --git a/lua/lexers/cpp.lua b/lua/lexers/cpp.lua
index 6ee1ffb..ec3daad 100644
--- a/lua/lexers/cpp.lua
+++ b/lua/lexers/cpp.lua
@@ -26,10 +26,13 @@ local number = token(l.NUMBER, l.float + l.integer)
-- Preprocessor.
local preproc_word = word_match{
'define', 'elif', 'else', 'endif', 'error', 'if', 'ifdef', 'ifndef', 'import',
- 'include', 'line', 'pragma', 'undef', 'using', 'warning'
+ 'line', 'pragma', 'undef', 'using', '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 keyword = token(l.KEYWORD, word_match{
diff --git a/lua/lexers/dart.lua b/lua/lexers/dart.lua
index c237128..b5964e2 100644
--- a/lua/lexers/dart.lua
+++ b/lua/lexers/dart.lua
@@ -1,5 +1,5 @@
+-- Copyright 2013-2017 Brian Schott (@Hackerpilot on Github). See LICENSE.
-- Dart LPeg lexer.
--- Written by Brian Schott (@Hackerpilot on Github).
local l = require('lexer')
local token, word_match = l.token, l.word_match
diff --git a/lua/lexers/dockerfile.lua b/lua/lexers/dockerfile.lua
index cf65f0e..3880021 100644
--- a/lua/lexers/dockerfile.lua
+++ b/lua/lexers/dockerfile.lua
@@ -1,4 +1,4 @@
--- Copyright 2017 Alejandro Baez (https://keybase.io/baez). See LICENSE.
+-- Copyright 2016-2017 Alejandro Baez (https://keybase.io/baez). See LICENSE.
-- Dockerfile LPeg lexer.
local l = require('lexer')
diff --git a/lua/lexers/dot.lua b/lua/lexers/dot.lua
index 5ff845b..aa09fa7 100644
--- a/lua/lexers/dot.lua
+++ b/lua/lexers/dot.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 Brian "Sir Alaran" Schott. See LICENSE.
+-- Copyright 2006-2017 Brian "Sir Alaran" Schott. See LICENSE.
-- Dot LPeg lexer.
-- Based off of lexer code by Mitchell.
diff --git a/lua/lexers/html.lua b/lua/lexers/html.lua
index 732dfa5..7d29881 100644
--- a/lua/lexers/html.lua
+++ b/lua/lexers/html.lua
@@ -112,6 +112,13 @@ M._tokenstyles = {
doctype = l.STYLE_COMMENT
}
+M._foldsymbols = {
+ _patterns = {'</?', '/>', '<!%-%-', '%-%->'},
+ element = {['<'] = 1, ['/>'] = -1, ['</'] = -1},
+ unknown_element = {['<'] = 1, ['/>'] = -1, ['</'] = -1},
+ [l.COMMENT] = {['<!--'] = 1, ['-->'] = -1}
+}
+
-- Tags that start embedded languages.
M.embed_start_tag = element *
(ws^1 * attribute * ws^0 * equals * ws^0 * string)^0 *
@@ -142,6 +149,9 @@ local js_start_rule = #(P('<') * script_element *
end))) * M.embed_start_tag -- <script type="text/javascript">
local js_end_rule = #('</' * script_element * ws^0 * '>') *
M.embed_end_tag -- </script>
+local js_line_comment = '//' * (l.nonnewline_esc - js_end_rule)^0
+local js_block_comment = '/*' * (l.any - '*/' - js_end_rule)^0 * P('*/')^-1
+js._RULES['comment'] = token(l.COMMENT, js_line_comment + js_block_comment)
l.embed_lexer(M, js, js_start_rule, js_end_rule)
-- Embedded CoffeeScript.
@@ -156,11 +166,4 @@ local cs_end_rule = #('</' * script_element * ws^0 * '>') *
M.embed_end_tag -- </script>
l.embed_lexer(M, cs, cs_start_rule, cs_end_rule)
-M._foldsymbols = {
- _patterns = {'</?', '/>', '<!%-%-', '%-%->'},
- element = {['<'] = 1, ['/>'] = -1, ['</'] = -1},
- unknown_element = {['<'] = 1, ['/>'] = -1, ['</'] = -1},
- [l.COMMENT] = {['<!--'] = 1, ['-->'] = -1}
-}
-
return M
diff --git a/lua/lexers/inform.lua b/lua/lexers/inform.lua
index 94049fa..c2e63e9 100644
--- a/lua/lexers/inform.lua
+++ b/lua/lexers/inform.lua
@@ -1,3 +1,4 @@
+-- Copyright 2010-2017 Jeff Stone. See LICENSE.
-- Inform LPeg lexer for Scintillua.
-- JMS 2010-04-25.
diff --git a/lua/lexers/json.lua b/lua/lexers/json.lua
index 6dcebec..6e7025d 100644
--- a/lua/lexers/json.lua
+++ b/lua/lexers/json.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 Brian "Sir Alaran" Schott. See LICENSE.
+-- Copyright 2006-2017 Brian "Sir Alaran" Schott. See LICENSE.
-- JSON LPeg lexer.
-- Based off of lexer code by Mitchell.
diff --git a/lua/lexers/less.lua b/lua/lexers/less.lua
index 2ca3c38..2f56cdd 100644
--- a/lua/lexers/less.lua
+++ b/lua/lexers/less.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 Robert Gieseke. See LICENSE.
+-- Copyright 2006-2017 Robert Gieseke. See LICENSE.
-- Less CSS LPeg lexer.
-- http://lesscss.org
diff --git a/lua/lexers/lexer.lua b/lua/lexers/lexer.lua
index d159f70..e7d749f 100644
--- a/lua/lexers/lexer.lua
+++ b/lua/lexers/lexer.lua
@@ -1510,6 +1510,20 @@ function M.embed_lexer(parent, child, start_rule, end_rule)
tokenstyles[token] = style
end
end
+ -- Add child fold symbols.
+ if not parent._foldsymbols then parent._foldsymbols = {} end
+ if child._foldsymbols then
+ for token, symbols in pairs(child._foldsymbols) do
+ if not parent._foldsymbols[token] then parent._foldsymbols[token] = {} end
+ for k, v in pairs(symbols) do
+ if type(k) == 'number' then
+ parent._foldsymbols[token][#parent._foldsymbols[token] + 1] = v
+ elseif not parent._foldsymbols[token][k] then
+ parent._foldsymbols[token][k] = v
+ end
+ end
+ end
+ end
child._lexer = parent -- use parent's tokens if child is embedding itself
parent_lexer = parent -- use parent's tokens if the calling lexer is a proxy
end
diff --git a/lua/lexers/lilypond.lua b/lua/lexers/lilypond.lua
index f5af771..f7bdf79 100644
--- a/lua/lexers/lilypond.lua
+++ b/lua/lexers/lilypond.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 Robert Gieseke. See LICENSE.
+-- Copyright 2006-2017 Robert Gieseke. See LICENSE.
-- Lilypond LPeg lexer.
-- TODO Embed Scheme; Notes?, Numbers?
diff --git a/lua/lexers/litcoffee.lua b/lua/lexers/litcoffee.lua
index f31a2d1..48d1a2e 100644
--- a/lua/lexers/litcoffee.lua
+++ b/lua/lexers/litcoffee.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 Robert Gieseke. See LICENSE.
+-- Copyright 2006-2017 Robert Gieseke. See LICENSE.
-- Literate CoffeeScript LPeg lexer.
-- http://coffeescript.org/#literate
diff --git a/lua/lexers/matlab.lua b/lua/lexers/matlab.lua
index 5385a41..caef80d 100644
--- a/lua/lexers/matlab.lua
+++ b/lua/lexers/matlab.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 Martin Morawetz. See LICENSE.
+-- Copyright 2006-2017 Martin Morawetz. See LICENSE.
-- Matlab LPeg lexer.
-- Based off of lexer code by Mitchell.
diff --git a/lua/lexers/moonscript.lua b/lua/lexers/moonscript.lua
index 1b5b006..50638ed 100644
--- a/lua/lexers/moonscript.lua
+++ b/lua/lexers/moonscript.lua
@@ -1,4 +1,4 @@
--- Copyright 2017 Alejandro Baez (https://keybase.io/baez). See LICENSE.
+-- Copyright 2016-2017 Alejandro Baez (https://keybase.io/baez). See LICENSE.
-- Moonscript LPeg lexer.
local l = require('lexer')
diff --git a/lua/lexers/nsis.lua b/lua/lexers/nsis.lua
index 184858a..e690b59 100644
--- a/lua/lexers/nsis.lua
+++ b/lua/lexers/nsis.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 Robert Gieseke. See LICENSE.
+-- Copyright 2006-2017 Robert Gieseke. See LICENSE.
-- NSIS LPeg lexer
-- Based on NSIS 2.46 docs: http://nsis.sourceforge.net/Docs/.
diff --git a/lua/lexers/pico8.lua b/lua/lexers/pico8.lua
index 03f4a45..d6df3e2 100644
--- a/lua/lexers/pico8.lua
+++ b/lua/lexers/pico8.lua
@@ -1,4 +1,4 @@
--- Copyright 2017 Alejandro Baez (https://keybase.io/baez). See LICENSE.
+-- Copyright 2016-2017 Alejandro Baez (https://keybase.io/baez). See LICENSE.
-- PICO-8 Lexer.
-- http://www.lexaloffle.com/pico-8.php
diff --git a/lua/lexers/protobuf.lua b/lua/lexers/protobuf.lua
index 252a31e..41cba2a 100644
--- a/lua/lexers/protobuf.lua
+++ b/lua/lexers/protobuf.lua
@@ -1,4 +1,4 @@
--- Copyright 2017 David B. Lamkins <david@lamkins.net>. See LICENSE.
+-- Copyright 2016-2017 David B. Lamkins <david@lamkins.net>. See LICENSE.
-- Protocol Buffer IDL LPeg lexer.
-- <https://developers.google.com/protocol-buffers/>
diff --git a/lua/lexers/rc.lua b/lua/lexers/rc.lua
index 5ea0339..fcf9ef0 100644
--- a/lua/lexers/rc.lua
+++ b/lua/lexers/rc.lua
@@ -1,3 +1,4 @@
+-- Copyright 2017 Michael Forney. See LICENSE.
-- rc LPeg lexer.
local l = require('lexer')
diff --git a/lua/lexers/sass.lua b/lua/lexers/sass.lua
index 002df27..1e1b4eb 100644
--- a/lua/lexers/sass.lua
+++ b/lua/lexers/sass.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 Robert Gieseke. See LICENSE.
+-- Copyright 2006-2017 Robert Gieseke. See LICENSE.
-- Sass CSS preprocessor LPeg lexer.
-- http://sass-lang.com
diff --git a/lua/lexers/scala.lua b/lua/lexers/scala.lua
index d455996..96fe344 100644
--- a/lua/lexers/scala.lua
+++ b/lua/lexers/scala.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2013 JMS. See LICENSE.
+-- Copyright 2006-2017 JMS. See LICENSE.
-- Scala LPeg Lexer.
local l = require('lexer')
diff --git a/lua/lexers/sml.lua b/lua/lexers/sml.lua
index 40c0540..e734afd 100644
--- a/lua/lexers/sml.lua
+++ b/lua/lexers/sml.lua
@@ -1,3 +1,6 @@
+-- Copyright 2017 Murray Calavera. See LICENSE.
+-- Standard ML LPeg lexer.
+
local l = require('lexer')
local token = l.token
diff --git a/lua/lexers/taskpaper.lua b/lua/lexers/taskpaper.lua
index 5e87888..3fb2632 100644
--- a/lua/lexers/taskpaper.lua
+++ b/lua/lexers/taskpaper.lua
@@ -1,4 +1,4 @@
--- Copyright (c) 2017 Larry Hynes. See LICENSE.
+-- Copyright (c) 2016-2017 Larry Hynes. See LICENSE.
-- Taskpaper LPeg lexer
local l = require('lexer')
diff --git a/lua/lexers/vcard.lua b/lua/lexers/vcard.lua
index 2057451..f19473e 100644
--- a/lua/lexers/vcard.lua
+++ b/lua/lexers/vcard.lua
@@ -1,4 +1,4 @@
--- Copyright (c) 2015 Piotr Orzechowski [drzewo.org]. See LICENSE.
+-- Copyright (c) 2015-2017 Piotr Orzechowski [drzewo.org]. See LICENSE.
-- vCard 2.1, 3.0 and 4.0 LPeg lexer.
local l = require('lexer')