File: rdp.sch

package info (click to toggle)
sdc 1.0.8beta-8
  • links: PTS
  • area: contrib
  • in suites: slink
  • size: 1,400 kB
  • ctags: 874
  • sloc: lisp: 8,120; ansic: 967; makefile: 671; perl: 136; sh: 50
file content (42 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download
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
;;; -*-scheme-*-

;;; token-in? depends on the desired target
;;; better import it (inline)
;{{{ (token-in? x set-token)

(define-inline (token-in? x set-token)
  (let ((max (vector-length set-token)))
    (or
     (eqv? max 0)
     (and
      (if (pair? (token-type set-token))
	  (memq (token-type x) (token-type set-token))
	  (eq? (token-type x) (token-type set-token)))
      (or (< max 2)
	  (and (memq (token-type x) '(DATA OUTPUT PI))
	       (if (pair? (data-token-data set-token))
		   (member (data-token-data x) (data-token-data set-token))
		   (equal? (data-token-data x) (data-token-data set-token))))
	  (if (list? (token-gi set-token))
	      (memq (token-gi x) (token-gi set-token))
	      (eq? (token-gi x) (token-gi set-token))))
      (or (< max 3)
	  (equal? (token-args x) (token-args set-token))))
     )))

;}}}

;{{{ --- Some macros to be used outside ---
;  (how to export those???

;{{{ macro: (rdp-call f)

(define-macro (rdp-call f) `(lambda (c h s) (,f c h s)))

;}}}
;{{{

(define-macro (rdp-reduce c h s) `((car ,c) (cdr ,c) ,h ,s))
(define-macro (rdp-push f stack) `(cons ,f ,stack))

;}}}