nendo 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/nendo +2 -2
- data/emacs/nendo-mode.el +126 -0
- data/example/KyotoCabinet/kcbench.rb +20 -0
- data/example/KyotoCabinet/kcbench1.nnd +29 -0
- data/example/KyotoCabinet/kcbench2.nnd +30 -0
- data/example/KyotoCabinet/kcbench3.nnd +31 -0
- data/example/export-lisp-functions.rb +20 -0
- data/example/scratch.nnd +8 -17
- data/example/tak_ruby_version.rb +14 -0
- data/lib/debug/syslog.nndc +1 -1
- data/lib/init.nnd +334 -202
- data/lib/init.nndc +5691 -4128
- data/lib/nendo/test.nnd +165 -0
- data/lib/nendo/test.nndc +1635 -0
- data/lib/nendo.rb +248 -37
- data/lib/srfi-1.nnd +15 -24
- data/lib/srfi-1.nndc +1247 -1607
- data/lib/text/html-lite.nnd +1 -1
- data/lib/text/html-lite.nndc +171 -171
- data/lib/text/tree.nndc +2 -2
- data/test/nendo_spec.rb +1281 -981
- data/test/nendo_util.nnd +98 -0
- data/test/srfi-1-test.nnd +28 -0
- data/test/textlib.nnd +24 -0
- metadata +13 -3
data/bin/nendo
CHANGED
@@ -131,12 +131,12 @@ def main
|
|
131
131
|
# compile script file.
|
132
132
|
core.clean_compiled_code( )
|
133
133
|
core.load( fn )
|
134
|
-
core.
|
134
|
+
core.evalStr( sprintf( '(print-compiled-code "%s")', fn ))
|
135
135
|
else
|
136
136
|
# start script file.
|
137
137
|
core.setArgv( userOptions[1..userOptions.length] )
|
138
138
|
core.load( fn )
|
139
|
-
core.
|
139
|
+
core.evalStr( "(if (and (global-defined? 'main) (procedure? main)) (main *argv*) #f)" )
|
140
140
|
end
|
141
141
|
else
|
142
142
|
core.repl
|
data/emacs/nendo-mode.el
CHANGED
@@ -3,6 +3,33 @@
|
|
3
3
|
;;
|
4
4
|
;; Copyright (c) 2010 Kiyoka Nishiyama
|
5
5
|
;;
|
6
|
+
;; Redistribution and use in source and binary forms, with or without
|
7
|
+
;; modification, are permitted provided that the following conditions
|
8
|
+
;; are met:
|
9
|
+
;;
|
10
|
+
;; 1. Redistributions of source code must retain the above copyright
|
11
|
+
;; notice, this list of conditions and the following disclaimer.
|
12
|
+
;;
|
13
|
+
;; 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
;; notice, this list of conditions and the following disclaimer in the
|
15
|
+
;; documentation and/or other materials provided with the distribution.
|
16
|
+
;;
|
17
|
+
;; 3. Neither the name of the authors nor the names of its contributors
|
18
|
+
;; may be used to endorse or promote products derived from this
|
19
|
+
;; software without specific prior written permission.
|
20
|
+
;;
|
21
|
+
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
27
|
+
;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
;;
|
6
33
|
;;
|
7
34
|
;; Please add follows to .emacs
|
8
35
|
;; (setq scheme-program-name "nendo")
|
@@ -82,6 +109,105 @@ Editing commands are similar to those of 'scheme-mode'."
|
|
82
109
|
match init))))
|
83
110
|
|
84
111
|
|
112
|
+
;;
|
113
|
+
;; Indent width settings
|
114
|
+
;; port from gauche-mode.el by OOHASHI Daichi <leque@katch.ne.jp>
|
115
|
+
;;
|
116
|
+
(mapc #'(lambda (s)
|
117
|
+
(put (car s) 'scheme-indent-function (cdr s)))
|
118
|
+
'(
|
119
|
+
(&block . 1)
|
120
|
+
(and-let* . 1)
|
121
|
+
(begin0 . 0)
|
122
|
+
(call-with-builder . 1)
|
123
|
+
(call-with-cgi-script . 1)
|
124
|
+
(call-with-client-socket . 1)
|
125
|
+
(call-with-ftp-connection . 1)
|
126
|
+
(call-with-input-conversion . 1)
|
127
|
+
(call-with-input-file . 1)
|
128
|
+
(call-with-input-process . 1)
|
129
|
+
(call-with-input-string . 1)
|
130
|
+
(call-with-iterator . 1)
|
131
|
+
(call-with-iterators . 1)
|
132
|
+
(call-with-output-conversion . 1)
|
133
|
+
(call-with-output-file . 1)
|
134
|
+
(call-with-output-process . 1)
|
135
|
+
(call-with-output-string . 0)
|
136
|
+
(call-with-process-io . 1)
|
137
|
+
(call-with-string-io . 1)
|
138
|
+
(call-with-temporary-file . 1)
|
139
|
+
(call-with-values . 1)
|
140
|
+
(dolist . 1)
|
141
|
+
(dotimes . 1)
|
142
|
+
(guard . 1)
|
143
|
+
(hash-table-for-each . 1)
|
144
|
+
(if-let1 . 2)
|
145
|
+
(if-match . 2)
|
146
|
+
(let*-values . 1)
|
147
|
+
(let-args . 2)
|
148
|
+
(let-keywords . 2)
|
149
|
+
(let-keywords* . 2)
|
150
|
+
(let-match . 2)
|
151
|
+
(let-optionals* . 2)
|
152
|
+
(let-values . 1)
|
153
|
+
(let1 . 2)
|
154
|
+
(let/cc . 1)
|
155
|
+
(make . 1)
|
156
|
+
(make-parameter . 1)
|
157
|
+
(match . 1)
|
158
|
+
(parameterize . 1)
|
159
|
+
(parse-options . 1)
|
160
|
+
(pre-pose-order . 1)
|
161
|
+
(rlet1 . 2)
|
162
|
+
(receive . 2)
|
163
|
+
(rxmatch-case . 1)
|
164
|
+
(rxmatch-cond . 0)
|
165
|
+
(rxmatch-if . 4)
|
166
|
+
(rxmatch-let . 2)
|
167
|
+
(syntax-rules . 1)
|
168
|
+
(unless . 1)
|
169
|
+
(until . 1)
|
170
|
+
(unwind-protect . 1)
|
171
|
+
(when . 1)
|
172
|
+
(while . 1)
|
173
|
+
(with-builder . 1)
|
174
|
+
(with-error-handler . 1)
|
175
|
+
(with-exception-handler . 1)
|
176
|
+
(with-error-to-port . 1)
|
177
|
+
(with-input-conversion . 1)
|
178
|
+
(with-input-from-port . 1)
|
179
|
+
(with-input-from-file . 1)
|
180
|
+
(with-input-from-process . 1)
|
181
|
+
(with-input-from-string . 1)
|
182
|
+
(with-iterator . 1)
|
183
|
+
(with-locking-mutex . 1)
|
184
|
+
(with-module . 1)
|
185
|
+
(with-output-conversion . 1)
|
186
|
+
(with-output-to-file . 1)
|
187
|
+
(with-output-to-port . 1)
|
188
|
+
(with-output-to-process . 1)
|
189
|
+
(with-port-locking . 1)
|
190
|
+
(with-ports . 3)
|
191
|
+
(with-signal-handlers . 1)
|
192
|
+
(with-string-io . 1)
|
193
|
+
(with-time-counter . 1)
|
194
|
+
;; R6RS
|
195
|
+
(call-with-bytevector-output-port . 0)
|
196
|
+
(call-with-current-continuation . 0)
|
197
|
+
(call-with-port . 1)
|
198
|
+
(call-with-string-output-port . 0)
|
199
|
+
(call/cc . 0)
|
200
|
+
(datum->syntax . 1)
|
201
|
+
(define-condition-type . 2)
|
202
|
+
(define-enumeration . 1)
|
203
|
+
(define-record-type . 1)
|
204
|
+
(dynamic-wind . 0)
|
205
|
+
(identifier-syntax . 0)
|
206
|
+
(library . 1)
|
207
|
+
(letrec* . 1)
|
208
|
+
(with-syntax . 1)
|
209
|
+
))
|
210
|
+
|
85
211
|
|
86
212
|
(provide 'nendo-mode)
|
87
213
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require 'kyotocabinet'
|
5
|
+
include KyotoCabinet
|
6
|
+
|
7
|
+
db = DB::new
|
8
|
+
|
9
|
+
# データベースを開く
|
10
|
+
unless db.open('numbers.kch', DB::OWRITER | DB::OCREATE)
|
11
|
+
printf("open error: %s\n", db.error)
|
12
|
+
end
|
13
|
+
|
14
|
+
# 書きこみ
|
15
|
+
(0..99999).each { |num|
|
16
|
+
db[ num ] = num
|
17
|
+
}
|
18
|
+
|
19
|
+
p db[1000]
|
20
|
+
p db[10000]
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
:; #-*- mode: nendo; syntax: scheme -*-;;
|
3
|
+
:; exec /usr/local/bin/nendo $0 $*
|
4
|
+
|
5
|
+
(require "kyotocabinet")
|
6
|
+
|
7
|
+
(define db (KyotoCabinet::DB.new))
|
8
|
+
|
9
|
+
(define (main argv)
|
10
|
+
(define (_create)
|
11
|
+
(if (not (db.open "numbers.kch" (+ KyotoCabinet::DB::OWRITER KyotoCabinet::DB::OCREATE)))
|
12
|
+
(printf "open error: %s\n" db.error)
|
13
|
+
;; 書きこみ
|
14
|
+
(let loop ((num 0))
|
15
|
+
(when (< num 100000)
|
16
|
+
(hash-table-put! db num num)
|
17
|
+
(loop (+ num 1))))))
|
18
|
+
(_create)
|
19
|
+
(print (hash-table-get db 1000))
|
20
|
+
(print (hash-table-get db 10000)))
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
:; #-*- mode: nendo; syntax: scheme -*-;;
|
3
|
+
:; exec /usr/local/bin/nendo $0 $*
|
4
|
+
|
5
|
+
(require "kyotocabinet")
|
6
|
+
|
7
|
+
(define db (KyotoCabinet::DB.new))
|
8
|
+
|
9
|
+
(define (main argv)
|
10
|
+
(define (_create)
|
11
|
+
(if (not (db.open "numbers.kch" (+ KyotoCabinet::DB::OWRITER KyotoCabinet::DB::OCREATE)))
|
12
|
+
(printf "open error: %s\n" db.error)
|
13
|
+
;; 書きこみ
|
14
|
+
(Range.new 0 99999
|
15
|
+
(&block (num)
|
16
|
+
(db.store num num)))))
|
17
|
+
(_create)
|
18
|
+
(print (hash-table-get db 1000))
|
19
|
+
(print (hash-table-get db 10000)))
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
:; #-*- mode: nendo; syntax: scheme -*-;;
|
3
|
+
:; exec /usr/local/bin/nendo $0 $*
|
4
|
+
|
5
|
+
(require "kyotocabinet")
|
6
|
+
|
7
|
+
(define db (KyotoCabinet::DB.new))
|
8
|
+
|
9
|
+
(define (main argv)
|
10
|
+
(define (_create)
|
11
|
+
(if (not (db.open "numbers.kch" (+ KyotoCabinet::DB::OWRITER KyotoCabinet::DB::OCREATE)))
|
12
|
+
(printf "open error: %s\n" db.error)
|
13
|
+
;; 書きこみ
|
14
|
+
(for-each
|
15
|
+
(lambda (num)
|
16
|
+
(db.store num num))
|
17
|
+
(range 100000))))
|
18
|
+
|
19
|
+
(_create)
|
20
|
+
(print (hash-table-get db 1000))
|
21
|
+
(print (hash-table-get db 10000)))
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
|
3
|
+
require 'nendo'
|
4
|
+
|
5
|
+
def main
|
6
|
+
core = Nendo::Core.new()
|
7
|
+
core.loadInitFile
|
8
|
+
lst = [ "a", "b", "c",
|
9
|
+
[ "d", "e" ].to_list
|
10
|
+
].to_list
|
11
|
+
core.evalStr( '(define (sexpToString sexp) (write-to-string sexp))' )
|
12
|
+
core.evalStr( '(export-to-ruby sexpToString)' )
|
13
|
+
core.evalStr( '(use text.tree)' )
|
14
|
+
core.evalStr( '(define (treeToString sexp) (tree->string sexp))' )
|
15
|
+
core.evalStr( '(export-to-ruby treeToString)' )
|
16
|
+
puts core.sexpToString( lst )
|
17
|
+
puts core.treeToString( lst )
|
18
|
+
end
|
19
|
+
|
20
|
+
main
|
data/example/scratch.nnd
CHANGED
@@ -2,23 +2,14 @@
|
|
2
2
|
;; -----------------
|
3
3
|
(enable-idebug)
|
4
4
|
(disable-idebug)
|
5
|
-
(define debug-print-length
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
(
|
13
|
-
(second lis))
|
5
|
+
(define debug-print-length 2000)
|
6
|
+
|
7
|
+
(%internal-define-to-letrec
|
8
|
+
'(macro (x)
|
9
|
+
(define (foo v) (+ v 1))
|
10
|
+
(define result 10)
|
11
|
+
(define (bar v) (+ v 2))
|
12
|
+
'(1 2 3)))
|
14
13
|
|
15
|
-
(foo '(1 2 3))
|
16
|
-
(foo 1)
|
17
|
-
|
18
|
-
'(1 2 3)
|
19
14
|
(exit)
|
20
15
|
|
21
|
-
;; circular
|
22
|
-
(load-library "srfi-1")
|
23
|
-
(list?
|
24
|
-
(circular-list 1 2))
|
data/lib/debug/syslog.nndc
CHANGED
@@ -19,7 +19,7 @@ trampCall(
|
|
19
19
|
|
20
20
|
trampCall(
|
21
21
|
begin
|
22
|
-
def self._debug_MIMARKprint_MIMARKoutput_MIMARKfunc_METHOD( origname, pred, args ) callProcedure( origname, pred, args ) end
|
22
|
+
def self._debug_MIMARKprint_MIMARKoutput_MIMARKfunc_METHOD( origname, pred, args ) lispMethodEntry( origname, true ) ; ret = callProcedure( origname, pred, args ) ; lispMethodExit( origname, true ) ; return ret end
|
23
23
|
@global_lisp_binding['_debug_MIMARKprint_MIMARKoutput_MIMARKfunc'] = self.method( :_debug_MIMARKprint_MIMARKoutput_MIMARKfunc_METHOD )
|
24
24
|
@_debug_MIMARKprint_MIMARKoutput_MIMARKfunc =
|
25
25
|
trampCall(
|