summaryrefslogtreecommitdiffstats
path: root/kate/tests/highlight.scheme
blob: ee081d7911464ffd63ac9239969dc3b39e7cb124 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
; This is a test file to test kates scheme highlighting
; This is a comment

;; Another comment, usually used.
;BEGIN region marker
;; a vektor
#(1 2 3 4 5)
;END region marker
;; this represents integer 28 (FIXME: does not work perfectly atm!)
28 028 #e28 #i28       ;; Normal, normal, exact, inexact
#b11100 #o34 #d28 #x1c ;; Bin, okt, dec, hex
#oe34 #eo34            ;; combined.

;; char.
(#\y #\space) ;; list: `y' space.
(#\  #\\ #\)) ;; list of spaces, backslash and`)'.
#\newline     ;; a newline-char
#\NewLine     ;; another one :)

"Hello, world" ;; a string

"hoho, what do you
want to do  ;; this is NO comment
with that?"

;; R5RS definiert diese beiden.
"Das ist \"in Anführungszeichen\" und mit \\ Backslash."

(let ((x (+ 1 2)) (y "blah")) ;; `let' highlighting.
  (and (number? x)            ;; `and' highlighting.
       (string? y)))

(let* ((x 2) (y (+ x 1))) ;; `let*' too.
  (or (negative? x)       ;; `or' anyways.
      (negative? y)))

(do ((vec (make-vector 5)) ;; `do' you may guess!
     (i 0 (+ i 1)))
    ((= i 5) vec)
  (vector-set! vec i i))

(quasiquote ((+ 1 2) (unquote (+ 1 2))))
;; same as: `((+ 1 2) ,(+ 1 2))

;; see above.
(quasiquote ((+ 1 2) (unquote-splicing (list 1 2 3))))
;; same as: `((+ 1 2) ,@(+ 1 2))

;; not necessary.
(quote ())

(cond ((string? x) (string->symbol x)) ;; `cond' highlighting.
      ((symbol? x) => (lambda (x) x))  ;; `=>' highlighting.
      (else ;; `else' highlighting.
       (error "Blah")))

(case x ;; `case' highlighting.
  ((#t) 'true) ((#f) 'false)
  ((()) 'null)
  ((0) 'zero))

;; highlight `let-syntax' and `syntax-rules' .
(let-syntax ((when (syntax-rules ()
                     ((when test stmt1 stmt2 ...)
                      ;; hl `begin' .
                      (if test (begin stmt1 stmt2 ...))))))
  (let ((if #t)) ;; here`if' is actually no keyword.
    (when if (set! if 'now)) ;; nor here.
    if))

(letrec-syntax ...) ;; hl `letrec-syntax'.

(define-syntax when
  (syntax-rules ()
    ((when test stmt1 stmt2 ...)
     (if test (begin stmt1 stmt2 ...))))))

;; variable definitions.
(define natural-numbers ;; hl `define' and the var name
  ;; endless stream of all natual numbers.
  (letrec ((next-cell    ;; hl `letrec'.
            (lambda (x)  ;; hl `lambda'.
              ;; hl `delay' .
              (cons x (delay (next-cell (+ x 1)))))))
    (next-cell 0)))

;; a procedure with unusual but allowed name.
(define 1+
  (lambda (x)
    (+ x 1)))

;; a predicate
(define between?
  (lambda (x y z)
    (if (and (>= x y) (<= x z))
        #t ;; True
      #f))) ;; False.

;; imperative procedure
(define set-something!
  (lambda (required-argument another-one . all-remaining-args)
    (set-car! another-one (lambda all-args
                            (set-cdr! required-argument
                                      (append all-remaining-args
                                              all-args))))))

(define compose
  (lambda (f g)
    (lambda (x)
      (f (g x)))))

;; syntactical sugar for procedure-definitions.
(define (compose f g)
  (lambda (x)
    (f (g x))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NOW: Guile extensions ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; procedure-generator.
(define ((compose f g) x)
  (f (g x)))

;; scheme doesn't say, which chars may be in variables...
;; At least: Guile accepts umlauts
(define-private (timetr??? sprache) ;; hl `define-private'.
  (list-dialekt? sprache))

(define-public x #t)  ;; hl `define-public'.
(define-module (foo bar)) ;; hl `define-module'.
(define-macro (neither . exprs) ;; hl `define-macro'.
  `(and ,@(map (lambda (x) `(not ,x)) exprs)))

(defmacro neither exprs ;; `defmacro' as well.
  `(and ,@(map (lambda (x) `(not ,x)) exprs)))

;; hl, but I really don't know what this is supposed to do :-)
(define-syntax-macro ...)

;; hl GOOPS-`defines'
(define-method (foo bar (baz <vector>) qux) ...)
(define-class <foo> ...)
(define-generic foo)
(define-accessor bar)

;; Keywords!
(blah #:foo 33 #:bar 44)

;; another convention for symbols:
#{foo}#

#{a
few
lines}#

#{4711}#

;; more chars.
#\nul #\nl #\esc #\bs #\bel #\syn #\ack #\sp ;; etc, utc, itc, oops (this is boring)

#!
 guile block-comment.
!#

;; now, a bit hairy:
#! comment !#
still comment!!!
!#
'now-no-comment-anymore

;; more precise:
#! comment !#
still comment
!# still comment!
!#
'now-no-comment-anymore

(while (> foo 10) ;; Highlight `while'.
  (set! foo (- foo 1))
  (catch #t ;; Highlight `catch'.
    (lambda () (display foo))
    (lambda (key . args)
      (if (eq? key 'system-error)
          (break) ;; Highlight `break'.
        (continue))))) ;; Highlight `continue'.