summaryrefslogtreecommitdiff
path: root/syntax-highlight
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-10-18 21:50:20 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-10-18 21:52:44 -0400
commit5291fc8d33e69f9a62b2f9d9550c1cb00cab9317 (patch)
tree054d27d8af424e1cd5c03d0d4ad54ca5d7cdda6b /syntax-highlight
parent262d63e1ba57025b26de7166cb64e8d225f14893 (diff)
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'.
Diffstat (limited to 'syntax-highlight')
-rw-r--r--syntax-highlight/scheme.scm18
1 files changed, 14 insertions, 4 deletions
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))