blob: 51cb564d4bb6eb96f790efeaad939d1599ffa0cf (
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
|
(define (makefile-fontifier string)
(with-input-from-string string
(lambda ()
(read/rp (regular-grammar ()
((: #\# (+ all))
;; makefile comment
(let ((cmt (the-string)))
(cons (it cmt) (ignore))))
((bol (: (+ (out " \t\n:")) #\:))
;; target
(let ((prompt (the-string)))
(cons (bold prompt) (ignore))))
((bol (: (+ alpha) #\=))
;; variable definitions
(let* ((len (- (the-length) 1))
(var (the-substring 0 len)))
(cons (list (color :fg "#bb0000" (bold var)) "=")
(ignore))))
((+ (out " \t\n:=$"))
;; plain strings
(let ((str (the-string)))
(cons str (ignore))))
((: #\$ #\( (+ (out " )\n")) #\))
;; variable references
(let ((str (the-string))
(var (the-substring 2 (- (the-length) 1))))
(cons (underline str) (ignore))))
((+ (in " \t\n:"))
;; separators
(let ((nl (the-string)))
(cons nl (ignore))))
(else
;; default
(let ((c (the-failure)))
(if (eof-object? c)
'()
(skribe-error 'makefile "Unexpected char" c)))))
(current-input-port)))))
(define makefile
(language :name "Makefile"
:fontifier makefile-fontifier))
(frame :width 100.
(prog (source :language makefile [
SKRIBE=skribe
all: demo.html demo.man
demo.html: demo.skb
$(SKRIBE) demo.skb -o demo.html
demo.man: demo.skb
$(SKRIBE) demo.skb -o demo.man
])))
|