From 5291fc8d33e69f9a62b2f9d9550c1cb00cab9317 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 18 Oct 2015 21:50:20 -0400 Subject: scheme: Allow for custom special symbols. The 'make-scheme-highlighter' procedure lets the user override what the set of special symbols and regexps are, useful for adding/removing context-specific symbols. * syntax-highlight/scheme.scm (make-scheme-highlighter): New procedure. (scheme-highlighter): Define in terms of 'make-scheme-highlighter'. --- syntax-highlight/scheme.scm | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'syntax-highlight/scheme.scm') diff --git a/syntax-highlight/scheme.scm b/syntax-highlight/scheme.scm index 78f2150..f4f4ac6 100644 --- a/syntax-highlight/scheme.scm +++ b/syntax-highlight/scheme.scm @@ -26,7 +26,10 @@ #:use-module (srfi srfi-11) #:use-module (srfi srfi-41) #:use-module (syntax-highlight parsers) - #:export (scheme-highlighter)) + #:export (%default-special-symbols + %default-special-regexps + make-scheme-highlighter + scheme-highlighter)) (define char-set:lisp-delimiters (char-set-union char-set:whitespace @@ -110,15 +113,22 @@ language." (define %default-special-regexps '("^define")) -(define scheme-highlighter +(define* (make-scheme-highlighter special-symbols special-regexps) + "Create a syntax highlighting procedure for Scheme that associates +the 'special' tag for symbols appearing in the list SPECIAL-SYMBOLS or +matching a regular expression in SPECIAL-REGEXPS." (parse-many (parse-any parse-whitespace (parse-openers '("(" "[" "{")) (parse-closers '(")" "]" "}")) - (parse-specials %default-special-symbols) - (parse-specials/regexp %default-special-regexps) + (parse-specials special-symbols) + (parse-specials/regexp special-regexps) parse-string-literal parse-comment parse-keyword parse-quoted-symbol parse-symbol))) + +(define scheme-highlighter + (make-scheme-highlighter %default-special-symbols + %default-special-regexps)) -- cgit v1.2.3