summaryrefslogtreecommitdiff
path: root/context/data/scite/lexers/scite-context-lexer-mps.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2011-09-15 09:08:00 +0200
committerHans Hagen <pragma@wxs.nl>2011-09-15 09:08:00 +0200
commitcc209e17295e7e78bf1b685cdaeb6037bb938a27 (patch)
treedca9e760a7f46d9b4982357a664b9e0d4208e7c3 /context/data/scite/lexers/scite-context-lexer-mps.lua
parente6e373fe2dfcbf28514a4361d19d2cf503e54230 (diff)
downloadcontext-cc209e17295e7e78bf1b685cdaeb6037bb938a27.tar.gz
beta 2011.09.15 09:08
Diffstat (limited to 'context/data/scite/lexers/scite-context-lexer-mps.lua')
-rw-r--r--context/data/scite/lexers/scite-context-lexer-mps.lua75
1 files changed, 44 insertions, 31 deletions
diff --git a/context/data/scite/lexers/scite-context-lexer-mps.lua b/context/data/scite/lexers/scite-context-lexer-mps.lua
index fa7d88c5d..70324f340 100644
--- a/context/data/scite/lexers/scite-context-lexer-mps.lua
+++ b/context/data/scite/lexers/scite-context-lexer-mps.lua
@@ -8,8 +8,7 @@ local info = {
local lexer = lexer
local global, string, table, lpeg = _G, string, table, lpeg
-local token, style, colors, word_match, no_style = lexer.token, lexer.style, lexer.colors, lexer.word_match, lexer.style_nothing
-local exact_match = lexer.context.exact_match
+local token, style, colors, exact_match, no_style = lexer.token, lexer.style, lexer.colors, lexer.exact_match, lexer.style_nothing
local P, R, S, V, C, Cmt = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Cmt
local type, next, pcall, loadfile = type, next, pcall, loadfile
@@ -34,13 +33,15 @@ do
end
-local whitespace = lexer.WHITESPACE -- triggers states
-local any_char = lexer.any_char
+local whitespace = metafunlexer.WHITESPACE -- triggers states
local space = lexer.space -- S(" \n\r\t\f\v")
+local any = lexer.any
+
local digit = R("09")
local sign = S("+-")
local period = P(".")
+local dquote = P('"')
local cstoken = R("az","AZ") + P("_")
local number = sign^-1 * ( -- at most one
digit^1 * period * digit^0 -- 10.0 10.
@@ -48,19 +49,20 @@ local number = sign^-1 * ( -- at most one
+ digit^1 -- 10
)
-local spacing = token(whitespace, space^1)
-local comment = token('comment', P('%') * (1-S("\n\r"))^0)
-local metafun = token('command', exact_match(metafuncommands))
-local plain = token('plain', exact_match(plaincommands))
-local quoted = token('specials', P('"'))
- * token('default', P(1-P('"'))^1)
- * token('specials', P('"'))
-local primitive = token('primitive', exact_match(primitivecommands))
-local csname = token('user', cstoken^1)
-local specials = token('specials', S("#()[]<>=:\""))
-local number = token('number', number)
-local extras = token('extras', S("`~%^&_-+/\'|\\"))
-local default = token('default', P(1))
+local spacing = token(whitespace, space^1)
+local rest = token('default', any)
+local comment = token('comment', P('%') * (1-S("\n\r"))^0)
+local metafun = token('command', exact_match(metafuncommands))
+local plain = token('plain', exact_match(plaincommands))
+local quoted = token('quote', dquote)
+ * token('string', P(1-dquote)^1)
+ * token('quote', dquote)
+local primitive = token('primitive', exact_match(primitivecommands))
+----- csname = token('user', cstoken^1)
+local identifier = token('default', cstoken^1)
+local number = token('number', number)
+local special = token('special', S("#()[]<>=:\""))
+local extra = token('extra', S("`~%^&_-+/\'|\\"))
_rules = {
{ 'whitespace', spacing },
@@ -68,22 +70,33 @@ _rules = {
{ 'metafun', metafun },
{ 'plain', plain },
{ 'primitive', primitive },
- { 'csname', csname },
+ { 'identifier', identifier },
{ 'number', number },
{ 'quoted', quoted },
- { 'specials', specials },
- { 'extras', extras },
- { 'any_char', any_char },
+ { 'special', special },
+ { 'extra', extra },
+ { 'rest', rest },
}
-_tokenstyles = {
- { "comment", lexer.style_context_comment },
- { "default", lexer.style_context_default },
- { "number" , lexer.style_context_number },
- { "primitive", lexer.style_context_primitive },
- { "plain", lexer.style_context_plain },
- { "command", lexer.style_context_command },
- { "user", lexer.style_context_user },
- { "specials", lexer.style_context_specials },
- { "extras", lexer.style_context_extras },
+_tokenstyles = lexer.context.styleset
+
+_foldsymbols = {
+ _patterns = {
+ "%l+",
+ },
+ ["primitive"] = {
+ ["beginfig"] = 1,
+ ["endfig"] = -1,
+ ["def"] = 1,
+ ["vardef"] = 1,
+ ["primarydef"] = 1,
+ ["secondarydef" ] = 1,
+ ["tertiarydef"] = 1,
+ ["enddef"] = -1,
+ ["if"] = 1,
+ ["fi"] = -1,
+ ["for"] = 1,
+ ["forever"] = 1,
+ ["endfor"] = -1,
+ }
}