summaryrefslogtreecommitdiff
path: root/context/data/scite/lexers/scite-context-lexer-tex.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2012-02-08 23:00:23 +0200
committerMarius <mariausol@gmail.com>2012-02-08 23:00:23 +0200
commit7b47df8cbaae8690f14d306c633b2b2db053f66a (patch)
treea4cb6a0ebb8ac21a14558c258949d3c7da33dd25 /context/data/scite/lexers/scite-context-lexer-tex.lua
parent5fce2a5267a603c8caf76880cdfb839d77ec64f0 (diff)
downloadcontext-7b47df8cbaae8690f14d306c633b2b2db053f66a.tar.gz
beta 2012.02.08 21:04
Diffstat (limited to 'context/data/scite/lexers/scite-context-lexer-tex.lua')
-rw-r--r--context/data/scite/lexers/scite-context-lexer-tex.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/context/data/scite/lexers/scite-context-lexer-tex.lua b/context/data/scite/lexers/scite-context-lexer-tex.lua
index f0929625c..812dfbb05 100644
--- a/context/data/scite/lexers/scite-context-lexer-tex.lua
+++ b/context/data/scite/lexers/scite-context-lexer-tex.lua
@@ -25,13 +25,16 @@ local info = {
-- local interface = lexer.get_property("keywordclass.macros.context.en","")
-- it seems that whitespace triggers the lexer when embedding happens, but this
- -- is quite fragile due to duplicate styles
+ -- is quite fragile due to duplicate styles .. lexer.WHITESPACE is a number
+ -- (initially)
-- this lexer does not care about other macro packages (one can of course add a fake
-- interface but it's not on the agenda)
]]--
+if not lexer._CONTEXTEXTENSIONS then dofile(_LEXERHOME .. "/scite-context-lexer.lua") end
+
local lexer = lexer
local global, string, table, lpeg = _G, string, table, lpeg
local token, exact_match = lexer.token, lexer.exact_match
@@ -39,12 +42,14 @@ local P, R, S, V, C, Cmt, Cp, Cc, Ct = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, l
local type, next = type, next
local find, match, lower = string.find, string.match, string.lower
-module(...)
+-- module(...)
-local contextlexer = _M
+local contextlexer = { _NAME = "context" }
local cldlexer = lexer.load('scite-context-lexer-cld')
local mpslexer = lexer.load('scite-context-lexer-mps')
+-- local cldlexer = lexer.load('scite-context-lexer-lua') -- test
+
local commands = { en = { } }
local primitives = { }
local helpers = { }
@@ -184,7 +189,7 @@ end)
local commentline = P('%') * (1-S("\n\r"))^0
local endline = S("\n\r")^1
-local whitespace = contextlexer.WHITESPACE -- triggers states
+local whitespace = lexer.WHITESPACE
local space = lexer.space -- S(" \n\r\t\f\v")
local any = lexer.any
@@ -427,7 +432,7 @@ lexer.embed_lexer(contextlexer, mpslexer, startmetafuncode, stopmetafuncode)
-- Watch the text grabber, after all, we're talking mostly of text (beware,
-- no punctuation here as it can be special. We might go for utf here.
-_rules = {
+contextlexer._rules = {
{ "whitespace", spacing },
{ "preamble", preamble },
{ "word", word },
@@ -450,14 +455,14 @@ _rules = {
{ "rest", rest },
}
-_tokenstyles = context.styleset
+contextlexer._tokenstyles = context.styleset
local folds = {
["\\start"] = 1, ["\\stop" ] = -1,
["\\begin"] = 1, ["\\end" ] = -1,
}
-_foldsymbols = {
+contextlexer._foldsymbols = {
_patterns = {
"\\start", "\\stop", -- regular environments
"\\begin", "\\end", -- (moveable) blocks
@@ -468,3 +473,5 @@ _foldsymbols = {
["user"] = folds, -- csname
["grouping"] = folds,
}
+
+return contextlexer