summaryrefslogtreecommitdiff
path: root/context/data/scite/context/lexers/scite-context-lexer-bibtex.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2014-05-26 15:15:15 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2014-05-26 15:15:15 +0200
commitde743208c924ec75a8cee9abe1be37ab9ef4c1ec (patch)
treed3e244a2c7d6cdf7e96be21279a7a92d703c4baf /context/data/scite/context/lexers/scite-context-lexer-bibtex.lua
parent1d2f8360f233e00f3bf036ac01458bca1bbaedc0 (diff)
downloadcontext-de743208c924ec75a8cee9abe1be37ab9ef4c1ec.tar.gz
2014-05-26 14:59:00
Diffstat (limited to 'context/data/scite/context/lexers/scite-context-lexer-bibtex.lua')
-rw-r--r--context/data/scite/context/lexers/scite-context-lexer-bibtex.lua25
1 files changed, 22 insertions, 3 deletions
diff --git a/context/data/scite/context/lexers/scite-context-lexer-bibtex.lua b/context/data/scite/context/lexers/scite-context-lexer-bibtex.lua
index 88b070e5e..ebcd7cbc6 100644
--- a/context/data/scite/context/lexers/scite-context-lexer-bibtex.lua
+++ b/context/data/scite/context/lexers/scite-context-lexer-bibtex.lua
@@ -17,7 +17,7 @@ local patterns = context.patterns
local token = lexer.token
local exact_match = lexer.exact_match
-local bibtexlexer = lexer.new("xml","scite-context-lexer-xml")
+local bibtexlexer = lexer.new("bib","scite-context-lexer-bibtex")
local whitespace = bibtexlexer.whitespace
local escape, left, right = P("\\"), P('{'), P('}')
@@ -45,8 +45,11 @@ local spaces = space^1
local equal = P("=")
local keyword = (R("az","AZ","09") + S("@_:-"))^1
-local s_quoted = ((escape*single) + spaces^1 + (1-single))^0
-local d_quoted = ((escape*double) + spaces^1 + (1-double))^0
+----- s_quoted = ((escape*single) + spaces + (1-single))^0
+----- d_quoted = ((escape*double) + spaces + (1-double))^0
+local s_quoted = ((escape*single) + (1-single))^0
+local d_quoted = ((escape*double) + (1-double))^0
+
local balanced = patterns.balanced
local t_spacing = token(whitespace, space^1)
@@ -119,6 +122,22 @@ local t_rest = token("default",anything)
--
-- function OnOpen(filename) editor:Colourise(1,editor.TextLength) end -- or is it 0?
+-- somehow lexing fails on this more complex lexer when we insert something, there is no
+-- backtracking to whitespace when we have no embedded lexer, so we fake one ... this works
+-- to some extend but not in all cases (e.g. editing inside line fails) .. maybe i need to
+-- patch the dll ... (better not)
+
+local dummylexer = lexer.load("scite-context-lexer-dummy","bib-dum")
+
+local dummystart = token("embedded",P("\001")) -- an unlikely to be used character
+local dummystop = token("embedded",P("\002")) -- an unlikely to be used character
+
+lexer.embed_lexer(bibtexlexer,dummylexer,dummystart,dummystop)
+
+-- maybe we need to define each functional block as lexer (some 4) so i'll do that when
+-- this issue is persistent ... maybe consider making a local lexer options (not load,
+-- just lexer.new or so) .. or maybe do the reverse, embed the main one in a dummy child
+
bibtexlexer._rules = {
{ "whitespace", t_spacing },
{ "forget", t_forget },