| 776 |
lars |
1 |
<!doctype html>
|
|
|
2 |
<title>CodeMirror: Scheme mode</title>
|
|
|
3 |
<meta charset="utf-8" />
|
|
|
4 |
<link rel=stylesheet href="../../doc/docs.css">
|
|
|
5 |
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
|
6 |
<script src="../../lib/codemirror.js"></script>
|
|
|
7 |
<script src="scheme.js"></script>
|
|
|
8 |
<style>
|
|
|
9 |
.CodeMirror {
|
|
|
10 |
background: #f8f8f8;
|
|
|
11 |
}
|
|
|
12 |
</style>
|
|
|
13 |
<div id=nav>
|
|
|
14 |
<a href="http://codemirror.net">
|
|
|
15 |
<h1>CodeMirror</h1>
|
|
|
16 |
<img id=logo src="../../doc/logo.png">
|
|
|
17 |
</a>
|
|
|
18 |
<ul>
|
|
|
19 |
<li>
|
|
|
20 |
<a href="../../index.html">Home</a>
|
|
|
21 |
<li>
|
|
|
22 |
<a href="../../doc/manual.html">Manual</a>
|
|
|
23 |
<li>
|
|
|
24 |
<a href="https://github.com/codemirror/codemirror">Code</a>
|
|
|
25 |
</ul>
|
|
|
26 |
<ul>
|
|
|
27 |
<li>
|
|
|
28 |
<a href="../index.html">Language modes</a>
|
|
|
29 |
<li>
|
|
|
30 |
<a class=active href="#">Scheme</a>
|
|
|
31 |
</ul>
|
|
|
32 |
</div>
|
|
|
33 |
<article>
|
|
|
34 |
<h2>Scheme mode</h2>
|
|
|
35 |
<form>
|
|
|
36 |
<textarea id="code" name="code"> ; See if the input starts with a given symbol. (define (match-symbol input pattern) (cond ((null? (remain input)) #f) ((eqv? (car (remain input)) pattern) (r-cdr input)) (else #f))) ; Allow the input to start with one of a list of patterns. (define
|
|
|
37 |
(match-or input pattern) (cond ((null? pattern) #f) ((match-pattern input (car pattern))) (else (match-or input (cdr pattern))))) ; Allow a sequence of patterns. (define (match-seq input pattern) (if (null? pattern) input (let ((match (match-pattern
|
|
|
38 |
input (car pattern)))) (if match (match-seq match (cdr pattern)) #f)))) ; Match with the pattern but no problem if it does not match. (define (match-opt input pattern) (let ((match (match-pattern input (car pattern)))) (if match match input)))
|
|
|
39 |
; Match anything (other than '()), until pattern is found. The rather ; clumsy form of requiring an ending pattern is needed to decide where ; the end of the match is. If none is given, this will match the rest ; of the sentence. (define (match-any
|
|
|
40 |
input pattern) (cond ((null? (remain input)) #f) ((null? pattern) (f-cons (remain input) (clear-remain input))) (else (let ((accum-any (collector))) (define (match-pattern-any input pattern) (cond ((null? (remain input)) #f) (else (accum-any
|
|
|
41 |
(car (remain input))) (cond ((match-pattern (r-cdr input) pattern)) (else (match-pattern-any (r-cdr input) pattern)))))) (let ((retval (match-pattern-any input (car pattern)))) (if retval (f-cons (accum-any) retval) #f)))))) </textarea>
|
|
|
42 |
</form>
|
|
|
43 |
<script>
|
|
|
44 |
var editor = CodeMirror.fromTextArea(document.getElementById("code"),
|
|
|
45 |
{});
|
|
|
46 |
</script>
|
|
|
47 |
<p>
|
|
|
48 |
<strong>MIME types defined:</strong> <code>text/x-scheme</code>.</p>
|
|
|
49 |
</article>
|