nendo 0.6.6 → 0.6.7
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.
- checksums.yaml +6 -14
- data/Rakefile +2 -3
- data/VERSION.yml +1 -1
- data/lib/nendo/init.nnd +7 -3
- data/lib/nendo/init.nndc +62 -28
- data/lib/nendo/nendo/experimental.nndc +6 -6
- data/lib/nendo/ruby/builtin_functions.rb +13 -3
- data/lib/nendo/ruby/core.rb +1 -1
- data/lib/nendo/ruby/evaluator.rb +64 -24
- data/lib/nendo/ruby/out_of_module.rb +2 -5
- data/lib/nendo/ruby/reader.rb +1 -2
- data/lib/nendo/ruby/types.rb +24 -0
- data/lib/nendo/srfi-2.nndc +1 -1
- data/lib/nendo/srfi-26.nndc +3 -3
- data/lib/nendo/text/html-lite.nndc +1 -1
- data/lib/nendo/util/combinations.nndc +4 -4
- data/lib/nendo/util/list.nndc +1 -1
- data/lib/nendo/util/match.nndc +33 -33
- data/test/nendo_spec.rb +1 -2158
- data/test/nendo_spec_2.rb +2128 -0
- data/test/nendo_spec_3.rb +105 -0
- metadata +10 -92
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
YzA4YzA1N2NmMjI4YWQwNDkyYjNlYTJhZWJjMzFiOTBjYzY4NmI4YTJlY2U2
|
10
|
-
ODkyMjdhYzJhZGQ0ZjZjM2M2NmUxOGI3NjdkOGJiZGJmOWE3NjUwYTM0NTUz
|
11
|
-
YzBlZGZkNDM1NDFlOWNlZWFhZjgzOGZjYjRjOTMxYjQyNzUyNzI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NjM3ODhmZGYyMzMyNzUwOWVjZTU4OTY1ZmQ0YmU4MDFiYmRhOWYxMTA1YzAw
|
14
|
-
ZmRkODRmMzc0MWQwNTBkN2IxY2RjODQ1NzMwNTMxZGUwNGQwYWE5YjBiODM4
|
15
|
-
M2FiYTZjZTM1OGQ3MWZhMDBkMzllODJiYWMyMjYyMjMwMmViZDU=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8bcb8ea5cb0874720bb6b4b39a5651e7848580d9
|
4
|
+
data.tar.gz: 900a2e9af0b6987a36a8d17773140a4b01e890d4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 609a4d62c959aa142a0ace769aeaf9b3776808aa5ad0b3398cafad7ed1c426c3ecebf8e7604891d50b519a11f3d21be1920e52402d2ebe57052a35c2e9d91c60
|
7
|
+
data.tar.gz: 259f4e4141cd781bf8b3b0433d01a70f786f563b8f85c03b046796b6d87628f5d38cc40f5cba762072404b2957ff1ea5cff399b7c7154d480c0f8a67b83dc6ef
|
data/Rakefile
CHANGED
@@ -40,9 +40,6 @@ begin
|
|
40
40
|
'benchmark/*.rb',
|
41
41
|
'benchmark/*.nnd'].to_a
|
42
42
|
gemspec.rdoc_options += [ '-x', 'match.nndc' ]
|
43
|
-
gemspec.add_development_dependency "rspec"
|
44
|
-
gemspec.add_development_dependency "rake"
|
45
|
-
gemspec.add_dependency "json"
|
46
43
|
end
|
47
44
|
rescue LoadError
|
48
45
|
puts 'Jeweler2 not available. If you want to build a gemfile, please install with "sudo gem install jeweler2"'
|
@@ -58,6 +55,8 @@ end
|
|
58
55
|
|
59
56
|
task :test1 do
|
60
57
|
sh "ruby -I ./lib `which rspec` -b ./test/nendo_spec.rb "
|
58
|
+
sh "ruby -I ./lib `which rspec` -b ./test/nendo_spec_2.rb "
|
59
|
+
sh "ruby -I ./lib `which rspec` -b ./test/nendo_spec_3.rb "
|
61
60
|
sh "ruby -I ./lib `which rspec` -b ./test/syntax_spec.rb "
|
62
61
|
sh "ruby -I ./lib `which rspec` -b ./test/testframework_spec.rb "
|
63
62
|
sh "ruby -I ./lib ./bin/nendo ./test/srfi-1-test.nnd"
|
data/VERSION.yml
CHANGED
data/lib/nendo/init.nnd
CHANGED
@@ -1324,9 +1324,13 @@
|
|
1324
1324
|
(map
|
1325
1325
|
(lambda (orig)
|
1326
1326
|
(string->symbol (+ "/nendo/core/" (symbol->string orig))))
|
1327
|
-
reserved-orig))]
|
1328
|
-
|
1329
|
-
|
1327
|
+
reserved-orig))]
|
1328
|
+
[cast-sym (if (eq? sym.class ParsedSymbol)
|
1329
|
+
(intern sym)
|
1330
|
+
sym)]
|
1331
|
+
)
|
1332
|
+
(memq cast-sym reserved)))
|
1333
|
+
|
1330
1334
|
(define (setup-let-args args)
|
1331
1335
|
(map
|
1332
1336
|
(lambda (arg)
|
data/lib/nendo/init.nndc
CHANGED
@@ -7885,7 +7885,7 @@ trampCall(
|
|
7885
7885
|
))
|
7886
7886
|
end
|
7887
7887
|
rescue => __e
|
7888
|
-
__e.set_backtrace( ["
|
7888
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
7889
7889
|
raise __e
|
7890
7890
|
end
|
7891
7891
|
end
|
@@ -9456,7 +9456,7 @@ trampCall(
|
|
9456
9456
|
))
|
9457
9457
|
end
|
9458
9458
|
rescue => __e
|
9459
|
-
__e.set_backtrace( ["
|
9459
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
9460
9460
|
raise __e
|
9461
9461
|
end
|
9462
9462
|
else
|
@@ -9569,7 +9569,7 @@ trampCall(
|
|
9569
9569
|
))
|
9570
9570
|
end
|
9571
9571
|
rescue => __e
|
9572
|
-
__e.set_backtrace( ["
|
9572
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
9573
9573
|
raise __e
|
9574
9574
|
end
|
9575
9575
|
else
|
@@ -9640,7 +9640,7 @@ trampCall(
|
|
9640
9640
|
))
|
9641
9641
|
end
|
9642
9642
|
rescue => __e
|
9643
|
-
__e.set_backtrace( ["
|
9643
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
9644
9644
|
raise __e
|
9645
9645
|
end
|
9646
9646
|
end
|
@@ -10167,7 +10167,7 @@ trampCall(
|
|
10167
10167
|
begin raise RuntimeError,
|
10168
10168
|
"with-open requires 2 or 3 arguments."
|
10169
10169
|
rescue => __e
|
10170
|
-
__e.set_backtrace( ["./lib/nendo/init.nnd:
|
10170
|
+
__e.set_backtrace( ["./lib/nendo/init.nnd:887"] + __e.backtrace )
|
10171
10171
|
raise __e
|
10172
10172
|
end
|
10173
10173
|
end
|
@@ -10990,7 +10990,7 @@ trampCall(
|
|
10990
10990
|
))
|
10991
10991
|
end
|
10992
10992
|
rescue => __e
|
10993
|
-
__e.set_backtrace( ["
|
10993
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
10994
10994
|
raise __e
|
10995
10995
|
end
|
10996
10996
|
else
|
@@ -13053,7 +13053,7 @@ trampCall(
|
|
13053
13053
|
))
|
13054
13054
|
end
|
13055
13055
|
rescue => __e
|
13056
|
-
__e.set_backtrace( ["
|
13056
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
13057
13057
|
raise __e
|
13058
13058
|
end
|
13059
13059
|
end
|
@@ -13449,7 +13449,7 @@ trampCall(
|
|
13449
13449
|
))
|
13450
13450
|
end
|
13451
13451
|
rescue => __e
|
13452
|
-
__e.set_backtrace( ["
|
13452
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
13453
13453
|
raise __e
|
13454
13454
|
end
|
13455
13455
|
end
|
@@ -13925,7 +13925,7 @@ trampCall(
|
|
13925
13925
|
))
|
13926
13926
|
end
|
13927
13927
|
rescue => __e
|
13928
|
-
__e.set_backtrace( ["
|
13928
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
13929
13929
|
raise __e
|
13930
13930
|
end
|
13931
13931
|
begin
|
@@ -14118,19 +14118,53 @@ trampCall(
|
|
14118
14118
|
begin
|
14119
14119
|
___lambda = lambda { |_reserved|
|
14120
14120
|
begin
|
14121
|
-
|
14122
|
-
|
14123
|
-
|
14124
|
-
|
14125
|
-
|
14126
|
-
|
14127
|
-
|
14128
|
-
|
14121
|
+
___lambda = lambda { |_cast_MIMARKsym|
|
14122
|
+
begin
|
14123
|
+
delayCall( '_memq', 'memq',
|
14124
|
+
begin
|
14125
|
+
trampCall(@_memq)
|
14126
|
+
end ,
|
14127
|
+
[
|
14128
|
+
begin
|
14129
|
+
trampCall(_cast_MIMARKsym)
|
14130
|
+
end ,
|
14131
|
+
begin
|
14132
|
+
trampCall(_reserved)
|
14133
|
+
end
|
14134
|
+
]
|
14135
|
+
)
|
14136
|
+
end
|
14137
|
+
} ; ___lambda.call(
|
14138
|
+
if (
|
14129
14139
|
begin
|
14130
|
-
|
14140
|
+
_eq_QUMARK(
|
14141
|
+
begin
|
14142
|
+
trampCall(_sym).class
|
14143
|
+
end ,
|
14144
|
+
begin
|
14145
|
+
trampCall(ParsedSymbol)
|
14146
|
+
end
|
14147
|
+
)
|
14131
14148
|
end
|
14132
|
-
|
14133
|
-
|
14149
|
+
) then
|
14150
|
+
begin
|
14151
|
+
delayCall( '_intern', 'intern',
|
14152
|
+
begin
|
14153
|
+
trampCall(@_intern)
|
14154
|
+
end ,
|
14155
|
+
[
|
14156
|
+
begin
|
14157
|
+
trampCall(_sym)
|
14158
|
+
end
|
14159
|
+
]
|
14160
|
+
)
|
14161
|
+
end
|
14162
|
+
else
|
14163
|
+
begin
|
14164
|
+
trampCall(_sym)
|
14165
|
+
end
|
14166
|
+
end
|
14167
|
+
)
|
14134
14168
|
end
|
14135
14169
|
} ; ___lambda.call(
|
14136
14170
|
begin
|
@@ -16360,7 +16394,7 @@ trampCall(
|
|
16360
16394
|
begin raise RuntimeError,
|
16361
16395
|
"Error: identifier->symbol requires only symbol"
|
16362
16396
|
rescue => __e
|
16363
|
-
__e.set_backtrace( ["./lib/nendo/init.nnd:
|
16397
|
+
__e.set_backtrace( ["./lib/nendo/init.nnd:1470"] + __e.backtrace )
|
16364
16398
|
raise __e
|
16365
16399
|
end
|
16366
16400
|
end
|
@@ -16612,7 +16646,7 @@ trampCall(
|
|
16612
16646
|
end
|
16613
16647
|
)
|
16614
16648
|
rescue => __e
|
16615
|
-
__e.set_backtrace( ["./lib/nendo/init.nnd:
|
16649
|
+
__e.set_backtrace( ["./lib/nendo/init.nnd:1503"] + __e.backtrace )
|
16616
16650
|
raise __e
|
16617
16651
|
end
|
16618
16652
|
end
|
@@ -16700,7 +16734,7 @@ trampCall(
|
|
16700
16734
|
end
|
16701
16735
|
)
|
16702
16736
|
rescue => __e
|
16703
|
-
__e.set_backtrace( ["./lib/nendo/init.nnd:
|
16737
|
+
__e.set_backtrace( ["./lib/nendo/init.nnd:1505"] + __e.backtrace )
|
16704
16738
|
raise __e
|
16705
16739
|
end
|
16706
16740
|
end
|
@@ -16728,7 +16762,7 @@ trampCall(
|
|
16728
16762
|
end
|
16729
16763
|
)
|
16730
16764
|
rescue => __e
|
16731
|
-
__e.set_backtrace( ["./lib/nendo/init.nnd:
|
16765
|
+
__e.set_backtrace( ["./lib/nendo/init.nnd:1507"] + __e.backtrace )
|
16732
16766
|
raise __e
|
16733
16767
|
end
|
16734
16768
|
end
|
@@ -17190,7 +17224,7 @@ trampCall(
|
|
17190
17224
|
end
|
17191
17225
|
)
|
17192
17226
|
rescue => __e
|
17193
|
-
__e.set_backtrace( ["./lib/nendo/init.nnd:
|
17227
|
+
__e.set_backtrace( ["./lib/nendo/init.nnd:1556"] + __e.backtrace )
|
17194
17228
|
raise __e
|
17195
17229
|
end
|
17196
17230
|
end
|
@@ -17270,7 +17304,7 @@ trampCall(
|
|
17270
17304
|
end
|
17271
17305
|
)
|
17272
17306
|
rescue => __e
|
17273
|
-
__e.set_backtrace( ["./lib/nendo/init.nnd:
|
17307
|
+
__e.set_backtrace( ["./lib/nendo/init.nnd:1559"] + __e.backtrace )
|
17274
17308
|
raise __e
|
17275
17309
|
end
|
17276
17310
|
end
|
@@ -19548,7 +19582,7 @@ trampCall(
|
|
19548
19582
|
begin raise RuntimeError,
|
19549
19583
|
"too few ...'s"
|
19550
19584
|
rescue => __e
|
19551
|
-
__e.set_backtrace( ["./lib/nendo/init.nnd:
|
19585
|
+
__e.set_backtrace( ["./lib/nendo/init.nnd:1669"] + __e.backtrace )
|
19552
19586
|
raise __e
|
19553
19587
|
end
|
19554
19588
|
end
|
@@ -19724,7 +19758,7 @@ trampCall(
|
|
19724
19758
|
begin raise RuntimeError,
|
19725
19759
|
"too many ...'s"
|
19726
19760
|
rescue => __e
|
19727
|
-
__e.set_backtrace( ["./lib/nendo/init.nnd:
|
19761
|
+
__e.set_backtrace( ["./lib/nendo/init.nnd:1683"] + __e.backtrace )
|
19728
19762
|
raise __e
|
19729
19763
|
end
|
19730
19764
|
else
|
@@ -1467,7 +1467,7 @@ trampCall(
|
|
1467
1467
|
end
|
1468
1468
|
)
|
1469
1469
|
rescue => __e
|
1470
|
-
__e.set_backtrace( ["
|
1470
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
1471
1471
|
raise __e
|
1472
1472
|
end
|
1473
1473
|
)
|
@@ -2250,7 +2250,7 @@ trampCall(
|
|
2250
2250
|
end
|
2251
2251
|
)
|
2252
2252
|
rescue => __e
|
2253
|
-
__e.set_backtrace( ["
|
2253
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
2254
2254
|
raise __e
|
2255
2255
|
end
|
2256
2256
|
)
|
@@ -2467,7 +2467,7 @@ trampCall(
|
|
2467
2467
|
end
|
2468
2468
|
)
|
2469
2469
|
rescue => __e
|
2470
|
-
__e.set_backtrace( ["
|
2470
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
2471
2471
|
raise __e
|
2472
2472
|
end
|
2473
2473
|
)
|
@@ -2780,7 +2780,7 @@ trampCall(
|
|
2780
2780
|
end
|
2781
2781
|
)
|
2782
2782
|
rescue => __e
|
2783
|
-
__e.set_backtrace( ["
|
2783
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
2784
2784
|
raise __e
|
2785
2785
|
end
|
2786
2786
|
)
|
@@ -3192,7 +3192,7 @@ trampCall(
|
|
3192
3192
|
end
|
3193
3193
|
)
|
3194
3194
|
rescue => __e
|
3195
|
-
__e.set_backtrace( ["
|
3195
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
3196
3196
|
raise __e
|
3197
3197
|
end
|
3198
3198
|
)
|
@@ -3812,7 +3812,7 @@ trampCall(
|
|
3812
3812
|
end
|
3813
3813
|
)
|
3814
3814
|
rescue => __e
|
3815
|
-
__e.set_backtrace( ["
|
3815
|
+
__e.set_backtrace( [":1"] + __e.backtrace )
|
3816
3816
|
raise __e
|
3817
3817
|
end
|
3818
3818
|
)
|
@@ -55,6 +55,8 @@ module Nendo
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def _equal_QUMARK( a, b )
|
58
|
+
a = a.intern if a.class == ParsedSymbol
|
59
|
+
b = b.intern if b.class == ParsedSymbol
|
58
60
|
if a.is_a? String and b.is_a? String
|
59
61
|
a === b
|
60
62
|
elsif a.class != b.class
|
@@ -279,12 +281,20 @@ module Nendo
|
|
279
281
|
def __GTMARK_EQMARK( a,b ) a >= b end
|
280
282
|
def __LTMARK( a,b ) a < b end
|
281
283
|
def __LTMARK_EQMARK( a,b ) a <= b end
|
282
|
-
def _eq_QUMARK( a,b )
|
284
|
+
def _eq_QUMARK( a,b )
|
285
|
+
a = a.intern if a.class == ParsedSymbol
|
286
|
+
b = b.intern if b.class == ParsedSymbol
|
287
|
+
a == b
|
288
|
+
end
|
283
289
|
def _gt_QUMARK( a,b ) a > b end
|
284
290
|
def _ge_QUMARK( a,b ) a >= b end
|
285
291
|
def _lt_QUMARK( a,b ) a < b end
|
286
292
|
def _le_QUMARK( a,b ) a <= b end
|
287
|
-
def _eqv_QUMARK( a,b )
|
293
|
+
def _eqv_QUMARK( a,b )
|
294
|
+
a = a.intern if a.class == ParsedSymbol
|
295
|
+
b = b.intern if b.class == ParsedSymbol
|
296
|
+
a === b
|
297
|
+
end
|
288
298
|
def _car( cell ) cell.car end
|
289
299
|
def _cdr( cell )
|
290
300
|
if cell.cdr.is_a? Nil
|
@@ -301,7 +311,7 @@ module Nendo
|
|
301
311
|
def _newline( ) print "\n" end
|
302
312
|
def _procedure_QUMARK( arg ) ((Proc == arg.class) or (Method == arg.class)) end
|
303
313
|
def _macro_QUMARK( arg ) (LispMacro == arg.class) end
|
304
|
-
def _symbol_QUMARK( arg ) (arg.is_a? Symbol or arg.is_a? SyntacticClosure) end
|
314
|
+
def _symbol_QUMARK( arg ) (arg.is_a? Symbol or arg.is_a? SyntacticClosure or arg.is_a? ParsedSymbol) end
|
305
315
|
def _keyword_QUMARK( arg ) (arg.is_a? LispKeyword) end
|
306
316
|
def _syntax_QUMARK( arg ) (arg.is_a? LispSyntax) end
|
307
317
|
def _core_MIMARKsyntax_QUMARK( arg )
|
data/lib/nendo/ruby/core.rb
CHANGED
data/lib/nendo/ruby/evaluator.rb
CHANGED
@@ -206,7 +206,8 @@ module Nendo
|
|
206
206
|
if SyntacticClosure == name.class
|
207
207
|
"_" + name.to_s
|
208
208
|
else
|
209
|
-
name = name.to_s
|
209
|
+
name = name.to_s if Symbol == name.class
|
210
|
+
name = name.to_s if ParsedSymbol == name.class
|
210
211
|
if 0 == name.length
|
211
212
|
""
|
212
213
|
else
|
@@ -235,7 +236,8 @@ module Nendo
|
|
235
236
|
end
|
236
237
|
|
237
238
|
def toLispSymbol( name )
|
238
|
-
name = name.to_s
|
239
|
+
name = name.to_s if Symbol == name.class
|
240
|
+
name = name.to_s if ParsedSymbol == name.class
|
239
241
|
raise ArgumentError, sprintf( "Error: `%s' is not a lisp symbol", name ) if not ('_' == name[0])
|
240
242
|
name = name[1..-1]
|
241
243
|
@char_table_ruby_to_lisp.each_pair { |key,val|
|
@@ -339,7 +341,9 @@ module Nendo
|
|
339
341
|
end
|
340
342
|
|
341
343
|
def isDefines( sym )
|
342
|
-
|
344
|
+
sym = castParsedSymbol( sym )
|
345
|
+
result = [ :define, :set!, :"define-syntax", @core_syntax_hash[ :define ], @core_syntax_hash[ :set! ], @core_syntax_hash[ :"define-syntax" ] ].include?( sym )
|
346
|
+
return result
|
343
347
|
end
|
344
348
|
|
345
349
|
def embedBacktraceInfo( sourcefile, lineno )
|
@@ -401,6 +405,7 @@ module Nendo
|
|
401
405
|
end
|
402
406
|
|
403
407
|
def execFunc( funcname, args, sourcefile, lineno, locals, sourceInfo, execType )
|
408
|
+
funcname = castParsedSymbol( funcname )
|
404
409
|
if isDefines( funcname )
|
405
410
|
ar = args.cdr.map { |x| x.car }
|
406
411
|
variable_sym = toRubySymbol( args.car.to_s.sub( /^:/, "" ))
|
@@ -661,6 +666,8 @@ module Nendo
|
|
661
666
|
str += "[" + arr.join(",") + "]"
|
662
667
|
when Symbol
|
663
668
|
str += sprintf( ":\"%s\"", sexp.to_s )
|
669
|
+
when ParsedSymbol
|
670
|
+
str += sprintf( ":\"%s\"", sexp.to_s )
|
664
671
|
when String, LispString
|
665
672
|
str += sprintf( "\"%s\"", LispString.escape( sexp ))
|
666
673
|
when LispKeyword
|
@@ -732,15 +739,29 @@ module Nendo
|
|
732
739
|
# (let ((c 3))
|
733
740
|
# (print (+ a b c))))
|
734
741
|
# => locals must be [["_a" "_b"]["_c"]] value.
|
735
|
-
def translate(
|
742
|
+
def translate( sexpArg, locals, sourceInfo = nil )
|
743
|
+
sexp = castParsedSymbol( sexpArg )
|
736
744
|
case sexp
|
737
745
|
when Cell
|
738
746
|
inv = @core_syntax_hash.invert
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
747
|
+
# if sexp.car.to_s.match( /begin/ ) and sexp.car.to_s.match( /core/ )
|
748
|
+
# p inv
|
749
|
+
# p inv.keys
|
750
|
+
# p sexp.car.class
|
751
|
+
# p castParsedSymbol( sexp.car ).intern, inv.has_key?( castParsedSymbol( sexp.car ).intern )
|
752
|
+
# p inv[ castParsedSymbol( sexp.car ).intern ]
|
753
|
+
# end
|
754
|
+
if ParsedSymbol == sexp.car.class or Symbol == sexp.car.class
|
755
|
+
car = if inv.has_key?( castParsedSymbol( sexp.car ).intern )
|
756
|
+
inv[ castParsedSymbol( sexp.car ).intern ]
|
757
|
+
else
|
758
|
+
castParsedSymbol( sexp.car )
|
759
|
+
end
|
760
|
+
else
|
761
|
+
car = sexp.car
|
762
|
+
end
|
763
|
+
car = castParsedSymbol( car )
|
764
|
+
|
744
765
|
if :quote == car
|
745
766
|
genQuote( sexp.second )
|
746
767
|
elsif :"syntax-quote" == car
|
@@ -792,11 +813,15 @@ module Nendo
|
|
792
813
|
when Array
|
793
814
|
raise RuntimeError, "Error: can't eval unquoted vector."
|
794
815
|
else
|
795
|
-
case
|
816
|
+
case sexpArg
|
796
817
|
when Symbol
|
797
818
|
sym = sexp.to_s
|
798
819
|
sym = toRubySymbol( sym )
|
799
820
|
lispSymbolReference( sym, locals, nil, sexp.sourcefile, sexp.lineno )
|
821
|
+
when ParsedSymbol
|
822
|
+
sym = sexp.to_s
|
823
|
+
sym = toRubySymbol( sym )
|
824
|
+
lispSymbolReference( sym, locals, nil, sexpArg.sourcefile, sexpArg.lineno )
|
800
825
|
when Fixnum
|
801
826
|
sexp.to_s
|
802
827
|
when String, LispString
|
@@ -955,15 +980,16 @@ module Nendo
|
|
955
980
|
#
|
956
981
|
#
|
957
982
|
def __macroexpandEngine( sexp, syntaxArray, lexicalVars )
|
983
|
+
sexp == castParsedSymbol( sexp )
|
958
984
|
case sexp
|
959
985
|
when Cell
|
960
|
-
car = sexp.car
|
986
|
+
car = castParsedSymbol( sexp.car )
|
961
987
|
if :quote == car or :"syntax-quote" == car or @core_syntax_hash[ :quote ] == car or @core_syntax_hash[ :"syntax-quote" ] == car
|
962
988
|
sexp
|
963
989
|
elsif :"%let" == car or :letrec == car or @core_syntax_hash[ :"%let" ] == car or @core_syntax_hash[ :letrec ] == car
|
964
990
|
# catch lexical identifiers of `let' and `letrec'.
|
965
991
|
arr = sexp.second.map { |x|
|
966
|
-
[ x.car.car, macroexpandEngine( x.car.cdr, syntaxArray, lexicalVars ) ]
|
992
|
+
[ castParsedSymbol( x.car.car ), macroexpandEngine( x.car.cdr, syntaxArray, lexicalVars ) ]
|
967
993
|
}
|
968
994
|
lst = arr.map {|x| Cell.new( x[0], x[1] ) }.to_list
|
969
995
|
ret = Cell.new( car,
|
@@ -974,30 +1000,30 @@ module Nendo
|
|
974
1000
|
sexp.second.each {|x|
|
975
1001
|
if not x.car.second.is_a? Cell
|
976
1002
|
raise SyntaxError, "Error: let-syntax get only '((name (syntax-rules ...)))' form but got: " + write_to_string( x )
|
977
|
-
elsif not ( x.car.second.first == :"syntax-rules" or x.car.second.first == :"%syntax-rules")
|
1003
|
+
elsif not ( castParsedSymbol( x.car.second.first ) == :"syntax-rules" or castParsedSymbol( x.car.second.first ) == :"%syntax-rules")
|
978
1004
|
raise SyntaxError, "Error: let-syntax get only '((name (syntax-rules ...)))' form but got: " + write_to_string( x )
|
979
1005
|
end
|
980
1006
|
}
|
981
1007
|
arr_tmp = sexp.second.map { |x|
|
982
|
-
[ x.car.first, __expandSyntaxRules( x.car.second, syntaxArray, lexicalVars ) ]
|
1008
|
+
[ castParsedSymbol( x.car.first ), castParsedSymbol( __expandSyntaxRules( x.car.second, syntaxArray, lexicalVars )) ]
|
983
1009
|
}
|
984
1010
|
arr = arr_tmp.map {|x|
|
985
|
-
[ x[0], __evalSyntaxRules( x[1], lexicalVars ), x[1], lexicalVars ]
|
1011
|
+
[ castParsedSymbol( x[0] ), castParsedSymbol( __evalSyntaxRules( x[1], lexicalVars )), castParsedSymbol( x[1] ), castParsedSymbol( lexicalVars ) ]
|
986
1012
|
}
|
987
1013
|
|
988
1014
|
# trial (expand recursively)
|
989
1015
|
arr_tmp = arr.map { |x|
|
990
|
-
[ x[0], __expandSyntaxRules( x[2], syntaxArray + arr, lexicalVars ) ]
|
1016
|
+
[ castParsedSymbol( x[0] ), castParsedSymbol( __expandSyntaxRules( x[2], syntaxArray + arr, lexicalVars )) ]
|
991
1017
|
}
|
992
1018
|
arr = arr_tmp.map {|x|
|
993
|
-
[ x[0], __evalSyntaxRules( x[1], lexicalVars ), x[1], lexicalVars ]
|
1019
|
+
[ castParsedSymbol( x[0] ), castParsedSymbol( __evalSyntaxRules( x[1], lexicalVars )), castParsedSymbol( x[1] ), castParsedSymbol( lexicalVars ) ]
|
994
1020
|
}
|
995
1021
|
|
996
1022
|
# keywords = ((let-syntax-keyword ( let-syntax-body ))
|
997
1023
|
# (let-syntax-keyword ( let-syntax-body ))
|
998
1024
|
# ..)
|
999
1025
|
newKeywords = arr.map { |e|
|
1000
|
-
[ e[0], [ :"%syntax-rules", e[1]].to_list ].to_list
|
1026
|
+
[ castParsedSymbol(e[0]), [ :"%syntax-rules", e[1]].to_list ].to_list
|
1001
1027
|
}.to_list
|
1002
1028
|
|
1003
1029
|
ret = Cell.new( :"let-syntax",
|
@@ -1005,6 +1031,7 @@ module Nendo
|
|
1005
1031
|
|
1006
1032
|
ret
|
1007
1033
|
else
|
1034
|
+
car = castParsedSymbol( car )
|
1008
1035
|
sym = toRubySymbol( car.to_s )
|
1009
1036
|
newSexp = sexp
|
1010
1037
|
if isRubyInterface( sym )
|
@@ -1020,17 +1047,21 @@ module Nendo
|
|
1020
1047
|
# (syntaxName (syntaxName arg1 arg2 ...) () (global-variables))
|
1021
1048
|
eval( sprintf( "@__syntax = @%s", sym ), @binding )
|
1022
1049
|
newSexp = trampCall( callProcedure( nil, sym, @__syntax, [ sexp, Cell.new(), _global_MIMARKvariables( ) ] ))
|
1023
|
-
elsif _symbol_QUMARK( car ) and syntaxArray.map {|arr|
|
1050
|
+
elsif _symbol_QUMARK( car ) and syntaxArray.map {|arr|
|
1051
|
+
arr[0].intern
|
1052
|
+
}.include?( car.intern )
|
1024
1053
|
# lexical macro expandeding
|
1025
|
-
symbol_and_syntaxObj = syntaxArray.reverse.find {|arr|
|
1026
|
-
|
1054
|
+
symbol_and_syntaxObj = syntaxArray.reverse.find {|arr|
|
1055
|
+
car == castParsedSymbol( arr[0] )
|
1056
|
+
}
|
1057
|
+
keys = syntaxArray.reverse.map { |arr| castParsedSymbol( arr[0] ) }
|
1027
1058
|
if not symbol_and_syntaxObj
|
1028
1059
|
raise "can't find valid syntaxObject"
|
1029
1060
|
end
|
1030
|
-
vars = symbol_and_syntaxObj[3].map { |arr| arr[0] }
|
1061
|
+
vars = symbol_and_syntaxObj[3].map { |arr| castParsedSymbol( arr[0] ) }
|
1031
1062
|
lexvars = @syntaxHash[ symbol_and_syntaxObj[1] ][0]
|
1032
1063
|
lispSyntax = @syntaxHash[ symbol_and_syntaxObj[1] ][1]
|
1033
|
-
newSexp = trampCall( callProcedure( nil, symbol_and_syntaxObj[0], lispSyntax, [
|
1064
|
+
newSexp = trampCall( callProcedure( nil, castParsedSymbol( symbol_and_syntaxObj[0] ), lispSyntax, [
|
1034
1065
|
sexp,
|
1035
1066
|
Cell.new(),
|
1036
1067
|
(_global_MIMARKvariables( ).to_arr + keys + vars).to_list ] ))
|
@@ -1054,6 +1085,14 @@ module Nendo
|
|
1054
1085
|
end
|
1055
1086
|
end
|
1056
1087
|
|
1088
|
+
def castParsedSymbol( arg )
|
1089
|
+
if arg.class == ParsedSymbol
|
1090
|
+
arg.intern
|
1091
|
+
else
|
1092
|
+
arg
|
1093
|
+
end
|
1094
|
+
end
|
1095
|
+
|
1057
1096
|
def macroexpandPhase( sexp )
|
1058
1097
|
macroexpandInit( 100000 )
|
1059
1098
|
_strip_MIMARKlet_MIMARKsyntax_MIMARKkeyword(
|
@@ -1263,7 +1302,7 @@ module Nendo
|
|
1263
1302
|
|
1264
1303
|
def _make_MIMARKsyntactic_MIMARKclosure( mac_env, use_env, identifier )
|
1265
1304
|
if _pair_QUMARK( identifier )
|
1266
|
-
if :"syntax-quote" == identifier.car
|
1305
|
+
if :"syntax-quote" == castParsedSymbol( identifier.car )
|
1267
1306
|
identifier
|
1268
1307
|
else
|
1269
1308
|
raise TypeError, "make-syntactic-closure requires symbol or (syntax-quote sexp) only. but got: " + write_to_string( identifier )
|
@@ -1294,6 +1333,7 @@ module Nendo
|
|
1294
1333
|
sexp
|
1295
1334
|
else
|
1296
1335
|
car = sexp.car
|
1336
|
+
car = castParsedSymbol( car )
|
1297
1337
|
if :"syntax-quote" == car or @core_syntax_hash[ :"syntax-quote" ] == car
|
1298
1338
|
Cell.new( :quote, sexp.cdr )
|
1299
1339
|
else
|
@@ -33,14 +33,11 @@
|
|
33
33
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
34
|
|
35
35
|
class Symbol
|
36
|
-
def setLispToken( token )
|
37
|
-
@token = token
|
38
|
-
end
|
39
36
|
def sourcefile
|
40
|
-
|
37
|
+
""
|
41
38
|
end
|
42
39
|
def lineno
|
43
|
-
|
40
|
+
1
|
44
41
|
end
|
45
42
|
end
|
46
43
|
|
data/lib/nendo/ruby/reader.rb
CHANGED
@@ -374,7 +374,6 @@ module Nendo
|
|
374
374
|
case cur.kind
|
375
375
|
when T_SYMBOL
|
376
376
|
sym = cur.str.intern
|
377
|
-
sym.setLispToken( cur )
|
378
377
|
case sym
|
379
378
|
when :true
|
380
379
|
true
|
@@ -383,7 +382,7 @@ module Nendo
|
|
383
382
|
when :nil
|
384
383
|
nil
|
385
384
|
else
|
386
|
-
sym
|
385
|
+
ParsedSymbol.new( sym, cur.sourcefile, cur.lineno )
|
387
386
|
end
|
388
387
|
when T_NUM
|
389
388
|
if cur.str.match( /[.]/ ) # floating point
|