forked from cisco/ChezScheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpand-lang.ss
122 lines (109 loc) · 3.48 KB
/
expand-lang.ss
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
;;; expand-lang.ss
;;; Copyright 1984-2016 Cisco Systems, Inc.
;;;
;;; Licensed under the Apache License, Version 2.0 (the "License");
;;; you may not use this file except in compliance with the License.
;;; You may obtain a copy of the License at
;;;
;;; http://www.apache.org/licenses/LICENSE-2.0
;;;
;;; Unless required by applicable law or agreed to in writing, software
;;; distributed under the License is distributed on an "AS IS" BASIS,
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;; See the License for the specific language governing permissions and
;;; limitations under the License.
(define-record-type libreq
(fields
(immutable path)
(immutable version)
(immutable uid))
(nongenerative #{libreq fnuxvkuvs8x0xbc68h3hm6-0})
(sealed #t))
(define-record-type recompile-info
(fields
(immutable import-req*)
(immutable include-req*))
(nongenerative #{recompile-info fnuxvkuvs8x0xbc68h3hm6-1})
(sealed #t))
(define-record-type library-info
(nongenerative #{library-info e10vy7tci6bqz6pmnxgvlq-2})
(fields
(immutable path)
(immutable version)
(immutable uid)))
(define-record-type library/ct-info
(parent library-info)
(fields
; NB: include-req* should go away with new recompile support that uses recompile-info
(immutable include-req*)
(immutable import-req*)
(immutable visit-visit-req*)
(immutable visit-req*)
(immutable clo*))
(nongenerative #{library/ct-info fgf0koeh2zn6ajlujfyoyf-3})
(sealed #t))
(define-record-type library/rt-info
(parent library-info)
(fields
(immutable invoke-req*))
(nongenerative #{library/rt-info ff86rtm7efmvxcvrmh7t0b-2})
(sealed #t))
(define-record-type program-info
(fields (immutable uid) (immutable invoke-req*))
(nongenerative #{program-info fgc8ptwnu9i5gfqz3s85mr-0})
(sealed #t))
(define (revisit-stuff? x) (and (pair? x) (eqv? (car x) (constant revisit-tag))))
(define (revisit-stuff-inner x) (cdr x))
(define (visit-stuff? x) (and (pair? x) (eqv? (car x) (constant visit-tag))))
(define (visit-stuff-inner x) (cdr x))
(module (Lexpand Lexpand?)
(define library-path?
(lambda (x)
(and (list? x) (andmap symbol? x))))
(define library-version?
(lambda (x)
(and (list? x)
(andmap (lambda (x) (and (integer? x) (exact? x) (>= x 0))) x))))
(define maybe-optimization-loc? (lambda (x) (or (not x) (box? x)))) ; should be a record
(define maybe-label? (lambda (x) (or (not x) (gensym? x))))
(define-language Lexpand
(nongenerative-id #{Lexpand fgy7v2wrvj0so4ro8kvhqo-1})
(terminals
(maybe-label (dl))
(gensym (uid))
(library-path (path))
(library-version (version))
(maybe-optimization-loc (db))
(prelex (dv))
(libreq (import-req visit-req visit-visit-req invoke-req))
(string (include-req))
(Lsrc (lsrc body init visit-code import-code de)) => unparse-Lsrc
(recompile-info (rcinfo))
(library/ct-info (linfo/ct))
(library/rt-info (linfo/rt))
(program-info (pinfo)))
(Outer (outer)
rcinfo
(group outer1 outer2)
(visit-only inner)
(revisit-only inner)
inner)
(Inner (inner)
linfo/ct
ctlib
linfo/rt
rtlib
pinfo
prog
lsrc)
(ctLibrary (ctlib)
(library/ct uid import-code visit-code))
(rtLibrary (rtlib)
(library/rt uid
(dl* ...)
(db* ...)
(dv* ...)
(de* ...)
body))
(Program (prog)
(program uid body))))