nendo 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ ;;; -*- mode: nendo; syntax: scheme -*-
2
+ ;;;
3
+ ;;; record.nnd - util.record for Nendo
4
+ ;;;
5
+ ;;; Copyright (c) 2014-2014 Kiyoka Nishiyama <kiyoka@sumibi.org>
6
+ ;;;
7
+ ;;; Redistribution and use in source and binary forms, with or without
8
+ ;;; modification, are permitted provided that the following conditions
9
+ ;;; are met:
10
+ ;;;
11
+ ;;; 1. Redistributions of source code must retain the above copyright
12
+ ;;; notice, this list of conditions and the following disclaimer.
13
+ ;;;
14
+ ;;; 2. Redistributions in binary form must reproduce the above copyright
15
+ ;;; notice, this list of conditions and the following disclaimer in the
16
+ ;;; documentation and/or other materials provided with the distribution.
17
+ ;;;
18
+ ;;; 3. Neither the name of the authors nor the names of its contributors
19
+ ;;; may be used to endorse or promote products derived from this
20
+ ;;; software without specific prior written permission.
21
+ ;;;
22
+ ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
+ ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
+ ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
+ ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
+ ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
+ ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28
+ ;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29
+ ;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30
+ ;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31
+ ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
+ ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+ ;;;
34
+
35
+ (define (record? type)
36
+ (type.is_a? Record))
37
+
38
+ (define (record-constructor rtd . rest-tags)
39
+ (let ([arg-count (length (car rest-tags))]
40
+ [tags (car rest-tags)])
41
+ (lambda args
42
+ (if (= (length args)
43
+ arg-count)
44
+ (let1 new (make-record-type rtd.typename tags)
45
+ (for-each
46
+ (lambda (tag arg)
47
+ (new.set! tag arg))
48
+ tags
49
+ args)
50
+ new)
51
+ (raise ArgumentError (sprintf "wrong number of arguments to constructor [%s] [%s]" rtd args))))))
52
+
53
+ (define (record-predicate type)
54
+ (lambda (thing)
55
+ (and (record? type)
56
+ (record? thing)
57
+ (eq? type.typename thing.typename))))
58
+
59
+ (define (record-accessor type tag)
60
+ (lambda (thing)
61
+ (if ((record-predicate type) thing)
62
+ (thing.get tag)
63
+ (raise ArgumentError (sprintf "accessor applied to bad value [%s] [%s] [%s]" type tag thing)))))
64
+
65
+ (define (record-modifier type tag)
66
+ (lambda (thing value)
67
+ (if ((record-predicate type) thing)
68
+ (thing.set! tag value)
69
+ (raise ArgumentError (sprintf "modifier applied to bad value [%s] [%s] [%s]" type tag thing)))))
70
+
@@ -0,0 +1,304 @@
1
+ #
2
+ # This file is nendo's compiled library file.
3
+ # generated "nendo -c src" command.
4
+ #
5
+
6
+ trampCall(
7
+ begin #execFunc
8
+ def self._record_QUMARK_METHOD( origname, pred, args ) lispMethodEntry( origname, true ) ; ret = callProcedure( '_record_QUMARK', origname, pred, args ) ; lispMethodExit( origname, true ) ; return ret end
9
+ @global_lisp_binding['_record_QUMARK'] = self.method( :_record_QUMARK_METHOD )
10
+ @_record_QUMARK =
11
+ trampCall(
12
+ Proc.new { |_type|
13
+ trampCall(_type).is_a?(
14
+ trampCall(Record)
15
+ )
16
+ }
17
+ )
18
+ end
19
+ )
20
+ #--------------------
21
+
22
+ trampCall(
23
+ begin #execFunc
24
+ def self._record_MIMARKconstructor_METHOD( origname, pred, args ) lispMethodEntry( origname, true ) ; ret = callProcedure( '_record_MIMARKconstructor', origname, pred, args ) ; lispMethodExit( origname, true ) ; return ret end
25
+ @global_lisp_binding['_record_MIMARKconstructor'] = self.method( :_record_MIMARKconstructor_METHOD )
26
+ @_record_MIMARKconstructor =
27
+ trampCall(
28
+ Proc.new { |_rtd,*__rest__| _rest_MIMARKtags = __rest__[0] ;
29
+ begin #makeLet
30
+ ___lambda = lambda { |_arg_MIMARKcount,_tags|
31
+ Proc.new { |*__rest__| _args = __rest__[0] ;
32
+ if (
33
+ __EQMARK(
34
+ _length(
35
+ trampCall(_args)
36
+ ) ,
37
+ trampCall(_arg_MIMARKcount)
38
+ )
39
+ ) then
40
+ begin #makeLet
41
+ ___lambda = lambda { |_new|
42
+ trampCall( self._for_MIMARKeach_METHOD( 'for-each',
43
+ trampCall(@_for_MIMARKeach) ,
44
+ [
45
+ Proc.new { |_tag,_arg|
46
+ trampCall(_new).set!(
47
+ trampCall(_tag) ,
48
+ trampCall(_arg)
49
+ )
50
+ } ,
51
+ trampCall(_tags) ,
52
+ trampCall(_args)
53
+ ]
54
+ ))
55
+ trampCall(_new)
56
+ } ; ___lambda.call(
57
+ trampCall( self._make_MIMARKrecord_MIMARKtype_METHOD( 'make-record-type',
58
+ trampCall(@_make_MIMARKrecord_MIMARKtype) ,
59
+ [
60
+ trampCall(_rtd).typename ,
61
+ trampCall(_tags)
62
+ ]
63
+ ))
64
+ )
65
+ end
66
+ else
67
+ delayCall( '__PAMARKraise', '%raise',
68
+ trampCall(@__PAMARKraise) ,
69
+ [
70
+ trampCall(ArgumentError) ,
71
+ trampCall( self._sprintf_METHOD( 'sprintf',
72
+ trampCall(@_sprintf) ,
73
+ [
74
+ "wrong number of arguments to constructor [%s] [%s]" ,
75
+ trampCall(_rtd) ,
76
+ trampCall(_args)
77
+ ]
78
+ )) ,
79
+ trampCall( self._sprintf_METHOD( 'sprintf',
80
+ trampCall(@_sprintf) ,
81
+ [
82
+ "%s:%s raised %s" ,
83
+ trampCall( self.__ASMARKFILE_ASMARK_METHOD( '*FILE*',
84
+ trampCall(@__ASMARKFILE_ASMARK) ,
85
+ [
86
+ ]
87
+ )) ,
88
+ trampCall( self.__ASMARKLINE_ASMARK_METHOD( '*LINE*',
89
+ trampCall(@__ASMARKLINE_ASMARK) ,
90
+ [
91
+ ]
92
+ )) ,
93
+ trampCall(ArgumentError)
94
+ ]
95
+ ))
96
+ ]
97
+ )
98
+ end
99
+ }
100
+ } ; ___lambda.call(
101
+ _length(
102
+ _car(
103
+ trampCall(_rest_MIMARKtags)
104
+ )
105
+ ) ,
106
+ _car(
107
+ trampCall(_rest_MIMARKtags)
108
+ )
109
+ )
110
+ end
111
+ }
112
+ )
113
+ end
114
+ )
115
+ #--------------------
116
+
117
+ trampCall(
118
+ begin #execFunc
119
+ def self._record_MIMARKpredicate_METHOD( origname, pred, args ) lispMethodEntry( origname, true ) ; ret = callProcedure( '_record_MIMARKpredicate', origname, pred, args ) ; lispMethodExit( origname, true ) ; return ret end
120
+ @global_lisp_binding['_record_MIMARKpredicate'] = self.method( :_record_MIMARKpredicate_METHOD )
121
+ @_record_MIMARKpredicate =
122
+ trampCall(
123
+ Proc.new { |_type|
124
+ Proc.new { |_thing|
125
+ if (
126
+ _not(
127
+ _eq_QUMARK(
128
+ false ,
129
+ trampCall( self._record_QUMARK_METHOD( 'record?',
130
+ trampCall(@_record_QUMARK) ,
131
+ [
132
+ trampCall(_type)
133
+ ]
134
+ ))
135
+ )
136
+ )
137
+ ) then
138
+ if (
139
+ _not(
140
+ _eq_QUMARK(
141
+ false ,
142
+ trampCall( self._record_QUMARK_METHOD( 'record?',
143
+ trampCall(@_record_QUMARK) ,
144
+ [
145
+ trampCall(_thing)
146
+ ]
147
+ ))
148
+ )
149
+ )
150
+ ) then
151
+ delayCall( '_eq_QUMARK', 'eq?',
152
+ trampCall(@_eq_QUMARK) ,
153
+ [
154
+ trampCall(_type).typename ,
155
+ trampCall(_thing).typename
156
+ ]
157
+ )
158
+ else
159
+ false
160
+ end
161
+ else
162
+ false
163
+ end
164
+ }
165
+ }
166
+ )
167
+ end
168
+ )
169
+ #--------------------
170
+
171
+ trampCall(
172
+ begin #execFunc
173
+ def self._record_MIMARKaccessor_METHOD( origname, pred, args ) lispMethodEntry( origname, true ) ; ret = callProcedure( '_record_MIMARKaccessor', origname, pred, args ) ; lispMethodExit( origname, true ) ; return ret end
174
+ @global_lisp_binding['_record_MIMARKaccessor'] = self.method( :_record_MIMARKaccessor_METHOD )
175
+ @_record_MIMARKaccessor =
176
+ trampCall(
177
+ Proc.new { |_type,_tag|
178
+ Proc.new { |_thing|
179
+ if (
180
+ trampCall( callProcedure( nil, 'anonymouse',
181
+ trampCall( self._record_MIMARKpredicate_METHOD( 'record-predicate',
182
+ trampCall(@_record_MIMARKpredicate) ,
183
+ [
184
+ trampCall(_type)
185
+ ]
186
+ )) ,
187
+ [
188
+ trampCall(_thing)
189
+ ]
190
+ ))
191
+ ) then
192
+ trampCall(_thing).get(
193
+ trampCall(_tag)
194
+ )
195
+ else
196
+ delayCall( '__PAMARKraise', '%raise',
197
+ trampCall(@__PAMARKraise) ,
198
+ [
199
+ trampCall(ArgumentError) ,
200
+ trampCall( self._sprintf_METHOD( 'sprintf',
201
+ trampCall(@_sprintf) ,
202
+ [
203
+ "accessor applied to bad value [%s] [%s] [%s]" ,
204
+ trampCall(_type) ,
205
+ trampCall(_tag) ,
206
+ trampCall(_thing)
207
+ ]
208
+ )) ,
209
+ trampCall( self._sprintf_METHOD( 'sprintf',
210
+ trampCall(@_sprintf) ,
211
+ [
212
+ "%s:%s raised %s" ,
213
+ trampCall( self.__ASMARKFILE_ASMARK_METHOD( '*FILE*',
214
+ trampCall(@__ASMARKFILE_ASMARK) ,
215
+ [
216
+ ]
217
+ )) ,
218
+ trampCall( self.__ASMARKLINE_ASMARK_METHOD( '*LINE*',
219
+ trampCall(@__ASMARKLINE_ASMARK) ,
220
+ [
221
+ ]
222
+ )) ,
223
+ trampCall(ArgumentError)
224
+ ]
225
+ ))
226
+ ]
227
+ )
228
+ end
229
+ }
230
+ }
231
+ )
232
+ end
233
+ )
234
+ #--------------------
235
+
236
+ trampCall(
237
+ begin #execFunc
238
+ def self._record_MIMARKmodifier_METHOD( origname, pred, args ) lispMethodEntry( origname, true ) ; ret = callProcedure( '_record_MIMARKmodifier', origname, pred, args ) ; lispMethodExit( origname, true ) ; return ret end
239
+ @global_lisp_binding['_record_MIMARKmodifier'] = self.method( :_record_MIMARKmodifier_METHOD )
240
+ @_record_MIMARKmodifier =
241
+ trampCall(
242
+ Proc.new { |_type,_tag|
243
+ Proc.new { |_thing,_value|
244
+ if (
245
+ trampCall( callProcedure( nil, 'anonymouse',
246
+ trampCall( self._record_MIMARKpredicate_METHOD( 'record-predicate',
247
+ trampCall(@_record_MIMARKpredicate) ,
248
+ [
249
+ trampCall(_type)
250
+ ]
251
+ )) ,
252
+ [
253
+ trampCall(_thing)
254
+ ]
255
+ ))
256
+ ) then
257
+ trampCall(_thing).set!(
258
+ trampCall(_tag) ,
259
+ trampCall(_value)
260
+ )
261
+ else
262
+ delayCall( '__PAMARKraise', '%raise',
263
+ trampCall(@__PAMARKraise) ,
264
+ [
265
+ trampCall(ArgumentError) ,
266
+ trampCall( self._sprintf_METHOD( 'sprintf',
267
+ trampCall(@_sprintf) ,
268
+ [
269
+ "modifier applied to bad value [%s] [%s] [%s]" ,
270
+ trampCall(_type) ,
271
+ trampCall(_tag) ,
272
+ trampCall(_thing)
273
+ ]
274
+ )) ,
275
+ trampCall( self._sprintf_METHOD( 'sprintf',
276
+ trampCall(@_sprintf) ,
277
+ [
278
+ "%s:%s raised %s" ,
279
+ trampCall( self.__ASMARKFILE_ASMARK_METHOD( '*FILE*',
280
+ trampCall(@__ASMARKFILE_ASMARK) ,
281
+ [
282
+ ]
283
+ )) ,
284
+ trampCall( self.__ASMARKLINE_ASMARK_METHOD( '*LINE*',
285
+ trampCall(@__ASMARKLINE_ASMARK) ,
286
+ [
287
+ ]
288
+ )) ,
289
+ trampCall(ArgumentError)
290
+ ]
291
+ ))
292
+ ]
293
+ )
294
+ end
295
+ }
296
+ }
297
+ )
298
+ end
299
+ )
300
+
301
+
302
+ # -------------------------------------------------------
303
+ # [EOF]
304
+ # -------------------------------------------------------
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nendo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kiyoka Nishiyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Nendo is a programming language written in Ruby.
14
14
  email: kiyoka@sumibi.org
@@ -73,6 +73,8 @@ files:
73
73
  - lib/nendo/srfi-2.nndc
74
74
  - lib/nendo/srfi-26.nnd
75
75
  - lib/nendo/srfi-26.nndc
76
+ - lib/nendo/srfi-9.nnd
77
+ - lib/nendo/srfi-9.nndc
76
78
  - lib/nendo/text/html-lite.nnd
77
79
  - lib/nendo/text/html-lite.nndc
78
80
  - lib/nendo/text/tree.nnd
@@ -83,6 +85,8 @@ files:
83
85
  - lib/nendo/util/list.nndc
84
86
  - lib/nendo/util/match.nnd
85
87
  - lib/nendo/util/match.nndc
88
+ - lib/nendo/util/record.nnd
89
+ - lib/nendo/util/record.nndc
86
90
  homepage: http://github.com/kiyoka/nendo
87
91
  licenses:
88
92
  - New BSD
@@ -105,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
109
  version: '0'
106
110
  requirements: []
107
111
  rubyforge_project:
108
- rubygems_version: 2.2.2
112
+ rubygems_version: 2.4.5
109
113
  signing_key:
110
114
  specification_version: 4
111
115
  summary: Nendo is a dialect of Lisp.