5 <title>CodeMirror: Scheme mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="scheme.js"></script>
9 <style>.CodeMirror {background: #f8f8f8;}</style>
10 <link rel="stylesheet" href="../../doc/docs.css">
13 <h1>CodeMirror: Scheme mode</h1>
14 <form><textarea id="code" name="code">
15 ; See if the input starts with a given symbol.
16 (define (match-symbol input pattern)
17 (cond ((null? (remain input)) #f)
18 ((eqv? (car (remain input)) pattern) (r-cdr input))
21 ; Allow the input to start with one of a list of patterns.
22 (define (match-or input pattern)
23 (cond ((null? pattern) #f)
24 ((match-pattern input (car pattern)))
25 (else (match-or input (cdr pattern)))))
27 ; Allow a sequence of patterns.
28 (define (match-seq input pattern)
31 (let ((match (match-pattern input (car pattern))))
32 (if match (match-seq match (cdr pattern)) #f))))
34 ; Match with the pattern but no problem if it does not match.
35 (define (match-opt input pattern)
36 (let ((match (match-pattern input (car pattern))))
37 (if match match input)))
39 ; Match anything (other than '()), until pattern is found. The rather
40 ; clumsy form of requiring an ending pattern is needed to decide where
41 ; the end of the match is. If none is given, this will match the rest
43 (define (match-any input pattern)
44 (cond ((null? (remain input)) #f)
45 ((null? pattern) (f-cons (remain input) (clear-remain input)))
47 (let ((accum-any (collector)))
48 (define (match-pattern-any input pattern)
49 (cond ((null? (remain input)) #f)
50 (else (accum-any (car (remain input)))
51 (cond ((match-pattern (r-cdr input) pattern))
52 (else (match-pattern-any (r-cdr input) pattern))))))
53 (let ((retval (match-pattern-any input (car pattern))))
55 (f-cons (accum-any) retval)
59 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
62 <p><strong>MIME types defined:</strong> <code>text/x-scheme</code>.</p>