File: highlight.scheme.fold

package info (click to toggle)
kf6-syntax-highlighting 6.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 47,568 kB
  • sloc: xml: 197,750; cpp: 12,850; python: 3,023; sh: 955; perl: 546; ruby: 488; pascal: 393; javascript: 161; php: 150; jsp: 132; lisp: 131; haskell: 124; ada: 119; ansic: 107; makefile: 96; f90: 94; ml: 85; cobol: 81; yacc: 71; csh: 62; erlang: 54; sql: 51; java: 47; objc: 37; awk: 31; asm: 30; tcl: 29; fortran: 18; cs: 10
file content (298 lines) | stat: -rw-r--r-- 9,065 bytes parent folder | download | duplicates (4)
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
; This is a test file to test kates scheme highlighting
; This is a comment

; Brackets colors
((((((((((((( )))))))))))))

;; Another comment, usually used.
<beginfold id='1'>;BEGIN region marker</beginfold id='1'>
;; a vektor
#(1 2 3 4 5)
['a 'b 'c]
<endfold id='1'>;END region marker</endfold id='1'>
;; this represents integer 28 (FIXME: does not work perfectly atm!)
28 028 #e28 #i28       ;; Normal, normal, exact, inexact
#b11100 #o34 #d28 #x1c ;; Bin, oct, dec, hex
#oe34 #eo34            ;; combined.
#o#e34 #e#o34          ;; combined.
;; inf
#i+inf.0 3+inf.0

;; symbols
&symbol-42
symbol-42;comment

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

"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."

"hexadecimal char \x1aF;."

;; Kawa string templates
&{Hello &[name]!} 'no-string
&{This has a {braced} section.} 'no-string
&{&#27; &#x1B; &amp; &lt; &gt; &quot; &apos;} 'no-string
; Multiline string literals
(string-capitalize &{one two three
uno dos tres
})
(write (string-capitalize &{
     &|one two three
     &|uno dos tres
}) out)
&{abc&- <beginfold id='2'>#|</beginfold id='2'>comment<endfold id='2'>|#</endfold id='2'>
  def} 'no-string
&{<beginfold id='2'>&#|</beginfold id='2'>line 1<endfold id='2'>|#</endfold id='2'>one two
  <beginfold id='2'>&#|</beginfold id='2'>line 2<endfold id='2'>|#</endfold id='2'> three
  <beginfold id='2'>&#|</beginfold id='2'>line 3<endfold id='2'>|#</endfold id='2'>uno dos tres
} 'no-string
; Embedded expressions
&{Hello &[(string-capitalize name)]!} 'no-string
&{Hello &(string-capitalize name)!} 'no-string
; formatting
&{&~{&[arr]&~^_&~}} 'no-string
&{&~{&~a[arr]&~^_&~}} 'no-string

;; Kawa XML literals
#<p>The result is <b>final</b>!</p> 'no-xml
#<em>The result is &{result}.</em> 'no-xml
#<p>This is <(if be-bold 'strong 'em)>important</>!</p> 'no-xml
#<p>This is <{(if be-bold 'strong 'em)}>important</>!</p> 'no-xml
#<p>Special characters <![CDATA[< > & ' "]]> here.</p> 'no-xml
#<p>Special characters &lt; &gt; &amp; &quot; &apos; here.</p> 'no-xml
#<gnu:b xmlns:gnu="http://gnu.org/"/> 'no-xml
#<chapter><?dbhtml filename="intro.html" ?>
<title>Introduction</title>
...
</chapter> 'no-xml


;; Kawa Regular expression
#/a\.c/
#/a/i
#/a/im


(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)

<beginfold id='2'>#|</beginfold id='2'> R6RS / SRFI-30 block comment
supports <beginfold id='2'>#|</beginfold id='2'> nested block <endfold id='2'>|#</endfold id='2'> comments <endfold id='2'>|#</endfold id='2'>
'now-no-comment-anymore

<beginfold id='2'>#!</beginfold id='2'>
 guile block-comment.
<endfold id='2'>!#</endfold id='2'>

;; now, a bit hairy:
<beginfold id='2'>#!</beginfold id='2'> comment !#
still comment!!!
<endfold id='2'>!#</endfold id='2'>
'now-no-comment-anymore

;; more precise:
<beginfold id='2'>#!</beginfold id='2'> comment !#
still comment
!# still comment!
<endfold id='2'>!#</endfold id='2'>
'now-no-comment-anymore

;; Datum comment
#;<beginfold id='2'>(</beginfold id='2'>1 2 3<endfold id='2'>)</endfold id='2'> 'now-no-comment-anymore
#;1 'now-no-comment-anymore
#;#o12 'now-no-comment-anymore
#;"bla bla\"" 'now-no-comment-anymore
#;<beginfold id='2'>[</beginfold id='2'>1 2 3<endfold id='2'>]</endfold id='2'> 'now-no-comment-anymore
#;<beginfold id='2'>[</beginfold id='2'>1 [2 (3 (4))]<endfold id='2'>]</endfold id='2'> 'now-no-comment-anymore
#;<beginfold id='2'>(</beginfold id='2'>1 (2 [3 [4]])<endfold id='2'>)</endfold id='2'> 'now-no-comment-anymore
#;#/reg/im 'now-no-comment-anymore
#;#<p>The result is <b>final</b>!</p> 'now-no-comment-anymore
#;#<em>The result is &{result}.</em> 'now-no-comment-anymore
#;#<p>This is <(if be-bold 'strong 'em)>important</>!</p> 'now-no-comment-anymore
#;#<p>This is <{(if be-bold 'strong 'em)}>important</>!</p> 'now-no-comment-anymore
#;#<p>Specal characters <![CDATA[< > & ' "]]> here.</p> 'now-no-comment-anymore
#;#<p>Specal characters &lt; &gt; &amp; &quot; &apos; here.</p> 'now-no-comment-anymore
#;#<gnu:b xmlns:gnu="http://gnu.org/"/> 'now-no-comment-anymore
#;#<chapter><?dbhtml filename="intro.html" ?>
<title>Introduction</title>
...
</chapter> 'now-no-comment-anymore
#;#&{Hello &[name]!} 'now-no-comment-anymore
#;&{This has a {braced} section.} 'now-no-comment-anymore
#;&{&#27;&#x1B; &amp; &lt; &gt; &quot; &apos;} 'now-no-comment-anymore
#;<beginfold id='2'>(</beginfold id='2'>string-capitalize &{one two three
uno dos tres
}<endfold id='2'>)</endfold id='2'> 'now-no-comment-anymore
#;<beginfold id='2'>(</beginfold id='2'>write (string-capitalize &{
     &|one two three
     &|uno dos tres
}) out<endfold id='2'>)</endfold id='2'> 'now-no-comment-anymore
#;&{abc&-
  def} 'now-no-comment-anymore
#;&{&#|line 1|#one two
  &#|line 2|# three
  &#|line 3|#uno dos tres
} 'now-no-comment-anymore
#;&{Hello &[(string-capitalize name)]!} 'now-no-comment-anymore
#;&{Hello &(string-capitalize name)!} 'now-no-comment-anymore
#;&{&~{&[arr]&~^_&~}} 'now-no-comment-anymore
#;&{&~{&~a[arr]&~^_&~}} 'now-no-comment-anymore
#;<beginfold id='2'>(</beginfold id='2'>
1
2
3<endfold id='2'>)</endfold id='2'> 'now-no-comment-anymore

; identifier with hex-escape
H\x65;llo; commment
H\x65;\x6c;lo; commment

(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'.