nydp 0.4.2 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +44 -0
- data/lib/lisp/core-010-precompile.nydp +13 -16
- data/lib/lisp/core-012-utils.nydp +3 -2
- data/lib/lisp/core-015-documentation.nydp +54 -23
- data/lib/lisp/core-017-builtin-dox.nydp +14 -12
- data/lib/lisp/core-020-utils.nydp +5 -5
- data/lib/lisp/core-030-syntax.nydp +166 -72
- data/lib/lisp/core-035-flow-control.nydp +38 -11
- data/lib/lisp/core-037-list-utils.nydp +12 -0
- data/lib/lisp/core-039-module.nydp +24 -0
- data/lib/lisp/core-040-utils.nydp +32 -12
- data/lib/lisp/core-041-string-utils.nydp +25 -1
- data/lib/lisp/core-042-date-utils.nydp +21 -1
- data/lib/lisp/core-043-list-utils.nydp +96 -64
- data/lib/lisp/core-070-prefix-list.nydp +1 -1
- data/lib/lisp/core-080-pretty-print.nydp +57 -17
- data/lib/lisp/core-090-hook.nydp +35 -1
- data/lib/lisp/core-100-utils.nydp +82 -2
- data/lib/lisp/core-110-hash-utils.nydp +56 -2
- data/lib/lisp/core-120-settings.nydp +16 -5
- data/lib/lisp/core-130-validations.nydp +51 -0
- data/lib/lisp/core-900-benchmarking.nydp +78 -20
- data/lib/lisp/tests/accum-examples.nydp +28 -1
- data/lib/lisp/tests/aif-examples.nydp +8 -3
- data/lib/lisp/tests/andify-examples.nydp +7 -0
- data/lib/lisp/tests/at-syntax-examples.nydp +17 -0
- data/lib/lisp/tests/best-examples.nydp +9 -0
- data/lib/lisp/tests/builtin-tests.nydp +19 -0
- data/lib/lisp/tests/case-examples.nydp +14 -0
- data/lib/lisp/tests/date-examples.nydp +54 -1
- data/lib/lisp/tests/destructuring-examples.nydp +46 -14
- data/lib/lisp/tests/detect-examples.nydp +12 -0
- data/lib/lisp/tests/dp-examples.nydp +24 -0
- data/lib/lisp/tests/each-tests.nydp +5 -0
- data/lib/lisp/tests/empty-examples.nydp +1 -1
- data/lib/lisp/tests/error-tests.nydp +4 -4
- data/lib/lisp/tests/explain-mac-examples.nydp +1 -1
- data/lib/lisp/tests/filter-forms-examples.nydp +15 -0
- data/lib/lisp/tests/hash-examples.nydp +25 -1
- data/lib/lisp/tests/list-grep-examples.nydp +40 -0
- data/lib/lisp/tests/list-tests.nydp +58 -1
- data/lib/lisp/tests/map-hash-examples.nydp +11 -0
- data/lib/lisp/tests/module-examples.nydp +10 -0
- data/lib/lisp/tests/multi-assign-examples.nydp +6 -0
- data/lib/lisp/tests/parser-tests.nydp +25 -0
- data/lib/lisp/tests/pretty-print-tests.nydp +17 -14
- data/lib/lisp/tests/set-difference-examples.nydp +8 -0
- data/lib/lisp/tests/settings-examples.nydp +17 -1
- data/lib/lisp/tests/string-tests.nydp +70 -1
- data/lib/lisp/tests/syntax-tests.nydp +5 -1
- data/lib/lisp/tests/to-integer-examples.nydp +16 -0
- data/lib/lisp/tests/validation-examples.nydp +15 -0
- data/lib/nydp.rb +10 -3
- data/lib/nydp/assignment.rb +10 -3
- data/lib/nydp/builtin.rb +1 -1
- data/lib/nydp/builtin/abs.rb +8 -0
- data/lib/nydp/builtin/date.rb +15 -1
- data/lib/nydp/builtin/error.rb +1 -1
- data/lib/nydp/builtin/hash.rb +24 -1
- data/lib/nydp/builtin/inspect.rb +1 -1
- data/lib/nydp/builtin/plus.rb +10 -2
- data/lib/nydp/builtin/random_string.rb +2 -2
- data/lib/nydp/builtin/{car.rb → regexp.rb} +2 -2
- data/lib/nydp/builtin/ruby_wrap.rb +72 -0
- data/lib/nydp/builtin/string_match.rb +2 -2
- data/lib/nydp/builtin/string_pad_left.rb +7 -0
- data/lib/nydp/builtin/string_pad_right.rb +7 -0
- data/lib/nydp/builtin/string_replace.rb +3 -3
- data/lib/nydp/builtin/string_split.rb +4 -3
- data/lib/nydp/builtin/to_integer.rb +23 -0
- data/lib/nydp/builtin/to_string.rb +2 -9
- data/lib/nydp/builtin/type_of.rb +9 -6
- data/lib/nydp/closure.rb +0 -3
- data/lib/nydp/cond.rb +23 -1
- data/lib/nydp/context_symbol.rb +14 -6
- data/lib/nydp/core.rb +36 -28
- data/lib/nydp/core_ext.rb +21 -5
- data/lib/nydp/date.rb +26 -18
- data/lib/nydp/function_invocation.rb +34 -26
- data/lib/nydp/helper.rb +35 -3
- data/lib/nydp/interpreted_function.rb +68 -40
- data/lib/nydp/literal.rb +1 -1
- data/lib/nydp/pair.rb +22 -5
- data/lib/nydp/parser.rb +11 -7
- data/lib/nydp/string_atom.rb +3 -4
- data/lib/nydp/symbol_lookup.rb +7 -7
- data/lib/nydp/tokeniser.rb +2 -2
- data/lib/nydp/truth.rb +10 -10
- data/lib/nydp/version.rb +1 -1
- data/lib/nydp/vm.rb +7 -0
- data/nydp.gemspec +2 -4
- data/spec/date_spec.rb +93 -0
- data/spec/embedded_spec.rb +12 -12
- data/spec/foreign_hash_spec.rb +14 -2
- data/spec/hash_non_hash_behaviour_spec.rb +7 -7
- data/spec/hash_spec.rb +24 -2
- data/spec/nydp_spec.rb +14 -2
- data/spec/pair_spec.rb +3 -1
- data/spec/parser_spec.rb +31 -20
- data/spec/rand_spec.rb +3 -3
- data/spec/spec_helper.rb +10 -1
- metadata +24 -37
- data/lib/nydp/builtin/cdr.rb +0 -7
- data/lib/nydp/builtin/cons.rb +0 -9
data/lib/nydp/helper.rb
CHANGED
@@ -1,7 +1,39 @@
|
|
1
1
|
module Nydp
|
2
2
|
module AutoWrap
|
3
|
-
|
4
|
-
|
3
|
+
# include this and be sure to either override #_nydp_ok? or #_nydp_whitelist
|
4
|
+
# #_nydp_whitelist should return a list of accessor (zero-arg) methods which are safe for nydp to invoke
|
5
|
+
# #_nydp_procify should return a list of methods that can be exposed to script code.
|
6
|
+
#
|
7
|
+
# class Blub
|
8
|
+
# _nydp_procs << :blubme
|
9
|
+
# def blubme where, when
|
10
|
+
# puts "blubme #{where}, #{when}"
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# in nydp, if blub is an instance of Blub:
|
15
|
+
#
|
16
|
+
# (blub.blubme "here" "now")
|
17
|
+
#
|
18
|
+
# prints
|
19
|
+
#
|
20
|
+
# blubme here, now
|
21
|
+
#
|
22
|
+
def _nydp_wrapper ; self ; end
|
23
|
+
def _nydp_ok? method ; _nydp_whitelist.include? method ; end
|
24
|
+
def _nydp_procify? method ; _nydp_procs.include? method ; end # override to allow returning Method instances for given method name
|
25
|
+
def _nydp_get key ; _nydp_safe_send(key.to_s.as_method_name) ; end
|
26
|
+
def to_ruby ; self ; end
|
27
|
+
def _nydp_safe_send meth, *args
|
28
|
+
return send meth, *args if _nydp_ok?(meth)
|
29
|
+
return method(meth) if _nydp_procify?(meth)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Struct < ::Struct
|
34
|
+
include AutoWrap
|
35
|
+
def _nydp_whitelist ; members ; end
|
36
|
+
def _nydp_procs ; [] ; end
|
5
37
|
end
|
6
38
|
|
7
39
|
module Converter
|
@@ -51,7 +83,7 @@ module Nydp
|
|
51
83
|
|
52
84
|
def literal? expr
|
53
85
|
case expr
|
54
|
-
when String, Float, Integer,
|
86
|
+
when String, Float, Integer, Integer, Nydp::Symbol, Nydp::Truth, Nydp::Nil
|
55
87
|
true
|
56
88
|
else
|
57
89
|
false
|
@@ -5,8 +5,8 @@ require 'nydp/closure'
|
|
5
5
|
module Nydp
|
6
6
|
class PopArg
|
7
7
|
def self.execute vm ; vm.args.pop ; end
|
8
|
-
def self.to_s ; ""
|
9
|
-
def self.inspect ; "#pop_arg"
|
8
|
+
def self.to_s ; "" ; end
|
9
|
+
def self.inspect ; "#pop_arg" ; end
|
10
10
|
end
|
11
11
|
|
12
12
|
class InterpretedFunction
|
@@ -16,42 +16,22 @@ module Nydp
|
|
16
16
|
|
17
17
|
attr_accessor :arg_names, :body, :context_builder
|
18
18
|
|
19
|
-
def
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def invoke_2 vm, parent_context, arg
|
24
|
-
vm.push_instructions self.body, set_args_1(parent_context, arg)
|
25
|
-
end
|
26
|
-
|
27
|
-
def invoke_3 vm, parent_context, arg_0, arg_1
|
28
|
-
vm.push_instructions self.body, set_args_2(parent_context, arg_0, arg_1)
|
29
|
-
end
|
30
|
-
|
31
|
-
def invoke_4 vm, parent_context, arg_0, arg_1, arg_2
|
32
|
-
vm.push_instructions self.body, set_args_3(parent_context, arg_0, arg_1, arg_2)
|
33
|
-
end
|
34
|
-
|
35
|
-
def invoke vm, parent_context, arg_values
|
36
|
-
vm.push_instructions self.body, set_args(parent_context, arg_values)
|
37
|
-
end
|
38
|
-
|
39
|
-
def setup_context context, names, values
|
40
|
-
if pair? names
|
41
|
-
context.set names.car, values.car
|
42
|
-
setup_context context, names.cdr, values.cdr
|
43
|
-
elsif NIL != names
|
44
|
-
context.set names, values
|
45
|
-
end
|
19
|
+
def lexical_reach n
|
20
|
+
body.map { |b| b.lexical_reach(n - 1) }.max
|
46
21
|
end
|
47
22
|
|
48
23
|
def self.build arg_list, body, bindings
|
49
24
|
my_params = { }
|
50
25
|
index_parameters arg_list, my_params
|
51
|
-
|
26
|
+
body = compile_body body, cons(my_params, bindings), []
|
27
|
+
reach = body.map { |b| b.lexical_reach(-1) }.max
|
28
|
+
|
29
|
+
ifn_klass = reach >= 0 ? InterpretedFunctionWithClosure : InterpretedFunctionWithoutClosure
|
30
|
+
ifn = ifn_klass.new
|
52
31
|
ifn.arg_names = arg_list
|
32
|
+
ifn.body = body
|
33
|
+
|
53
34
|
ifn.extend Nydp::LexicalContextBuilder.select arg_list
|
54
|
-
ifn.body = compile_body body, cons(my_params, bindings), []
|
55
35
|
ifn
|
56
36
|
end
|
57
37
|
|
@@ -62,6 +42,11 @@ module Nydp
|
|
62
42
|
if Nydp::NIL.is? rest
|
63
43
|
return Pair.from_list(instructions)
|
64
44
|
else
|
45
|
+
# PopArg is necessary because each expression pushes an arg onto the arg stack.
|
46
|
+
# we only need to keep the arg pushed by the last expression in a function
|
47
|
+
# so we need the following line in order to remove unwanted args from the stack.
|
48
|
+
# Each expression at some executes vm.push_arg(thing)
|
49
|
+
# TODO find a more intelligent way to do this, eg change the meaning of vm or of push_arg in the expression vm.push_arg(thing)
|
65
50
|
instructions << PopArg
|
66
51
|
compile_body rest, bindings, instructions
|
67
52
|
end
|
@@ -76,19 +61,62 @@ module Nydp
|
|
76
61
|
end
|
77
62
|
end
|
78
63
|
|
79
|
-
def execute vm
|
80
|
-
# TODO do not create a new Closure if this function does not refer to it
|
81
|
-
# - including top-level function definitions
|
82
|
-
# - and any other function that does not refer to any lexically-bound outer variable
|
83
|
-
# - for example (fn (x) (* x x)) in (map λx(* x x) things) does not need a closure, because
|
84
|
-
# the function does not refer to any lexical variable outside itself.
|
85
|
-
vm.push_arg Closure.new(self, vm.current_context)
|
86
|
-
end
|
87
|
-
|
88
64
|
def nydp_type ; "fn" ; end
|
89
65
|
def inspect ; to_s ; end
|
90
66
|
def to_s
|
91
67
|
"(fn #{arg_names.inspect} #{body.map { |b| b.inspect}.join(' ')})"
|
92
68
|
end
|
93
69
|
end
|
70
|
+
|
71
|
+
class InterpretedFunctionWithClosure < InterpretedFunction
|
72
|
+
def invoke_1 vm, ctx
|
73
|
+
vm.push_instructions self.body, set_args_0(ctx)
|
74
|
+
end
|
75
|
+
|
76
|
+
def invoke_2 vm, ctx, arg
|
77
|
+
vm.push_instructions self.body, set_args_1(ctx, arg)
|
78
|
+
end
|
79
|
+
|
80
|
+
def invoke_3 vm, ctx, arg_0, arg_1
|
81
|
+
vm.push_instructions self.body, set_args_2(ctx, arg_0, arg_1)
|
82
|
+
end
|
83
|
+
|
84
|
+
def invoke_4 vm, ctx, arg_0, arg_1, arg_2
|
85
|
+
vm.push_instructions self.body, set_args_3(ctx, arg_0, arg_1, arg_2)
|
86
|
+
end
|
87
|
+
|
88
|
+
def invoke vm, ctx, arg_values
|
89
|
+
vm.push_instructions self.body, set_args(ctx, arg_values)
|
90
|
+
end
|
91
|
+
|
92
|
+
def execute vm
|
93
|
+
vm.push_arg Closure.new(self, vm.current_context)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class InterpretedFunctionWithoutClosure < InterpretedFunction
|
98
|
+
def invoke_1 vm
|
99
|
+
vm.push_instructions self.body, set_args_0(vm.current_context)
|
100
|
+
end
|
101
|
+
|
102
|
+
def invoke_2 vm, arg
|
103
|
+
vm.push_instructions self.body, set_args_1(vm.current_context, arg)
|
104
|
+
end
|
105
|
+
|
106
|
+
def invoke_3 vm, arg_0, arg_1
|
107
|
+
vm.push_instructions self.body, set_args_2(vm.current_context, arg_0, arg_1)
|
108
|
+
end
|
109
|
+
|
110
|
+
def invoke_4 vm, arg_0, arg_1, arg_2
|
111
|
+
vm.push_instructions self.body, set_args_3(vm.current_context, arg_0, arg_1, arg_2)
|
112
|
+
end
|
113
|
+
|
114
|
+
def invoke vm, arg_values
|
115
|
+
vm.push_instructions self.body, set_args(vm.current_context, arg_values)
|
116
|
+
end
|
117
|
+
|
118
|
+
def execute vm
|
119
|
+
vm.push_arg self
|
120
|
+
end
|
121
|
+
end
|
94
122
|
end
|
data/lib/nydp/literal.rb
CHANGED
data/lib/nydp/pair.rb
CHANGED
@@ -16,7 +16,8 @@ class Nydp::Pair
|
|
16
16
|
def cddr ; cdr.cdr ; end
|
17
17
|
def car= thing ; @car = thing ; @_hash = nil ; end
|
18
18
|
def cdr= thing ; @cdr = thing ; @_hash = nil ; end
|
19
|
-
def hash ; @_hash ||= (car.hash + cdr.hash) ; end
|
19
|
+
# def hash ; @_hash ||= (car.hash + cdr.hash) ; end
|
20
|
+
def hash ; (car.hash + cdr.hash) ; end # can't cache hash of symbol, breaks when unmarshalling
|
20
21
|
def eql? other ; self == other ; end
|
21
22
|
def copy ; cons(car, cdr.copy) ; end
|
22
23
|
def + other ; copy.append other ; end
|
@@ -24,12 +25,28 @@ class Nydp::Pair
|
|
24
25
|
def inspect ; "(#{inspect_rest})" ; end
|
25
26
|
def & other ; self.class.from_list((Set.new(self) & other).to_a) ; end
|
26
27
|
def | other ; self.class.from_list((Set.new(self) | other).to_a) ; end
|
28
|
+
def - other ; self.class.from_list((Set.new(self) - other).to_a) ; end
|
27
29
|
def proper? ; Nydp::NIL.is?(cdr) || (cdr.is_a?(Nydp::Pair) && cdr.proper?) ; end
|
28
30
|
|
31
|
+
def index_of x
|
32
|
+
if x == car
|
33
|
+
0
|
34
|
+
elsif pair?(cdr)
|
35
|
+
1 + cdr.index_of(x)
|
36
|
+
else
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
29
41
|
# returns Array of elements after calling #n2r on each element
|
30
|
-
def to_ruby list=[]
|
31
|
-
list << n2r(car)
|
32
|
-
cdr.is_a?(Nydp::Pair)
|
42
|
+
def to_ruby list=[], pair=self
|
43
|
+
list << n2r(pair.car)
|
44
|
+
while(pair.cdr.is_a?(Nydp::Pair))
|
45
|
+
pair = pair.cdr
|
46
|
+
list << n2r(pair.car)
|
47
|
+
end
|
48
|
+
|
49
|
+
list
|
33
50
|
end
|
34
51
|
|
35
52
|
# returns Array of elements as they are
|
@@ -50,7 +67,7 @@ class Nydp::Pair
|
|
50
67
|
if n >= list.size
|
51
68
|
last
|
52
69
|
else
|
53
|
-
new list[n], from_list(list, last, n+1)
|
70
|
+
Nydp::Pair.new list[n], from_list(list, last, n+1)
|
54
71
|
end
|
55
72
|
end
|
56
73
|
|
data/lib/nydp/parser.rb
CHANGED
@@ -34,8 +34,7 @@ module Nydp
|
|
34
34
|
when /^(.*),@$/
|
35
35
|
prefix_list $1, Pair.from_list([sym(:"unquote-splicing"), list])
|
36
36
|
else
|
37
|
-
|
38
|
-
Pair.from_list([sym(:"prefix-list"), pfx, list])
|
37
|
+
Pair.from_list([sym(:"prefix-list"), prefix, list])
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
@@ -45,15 +44,16 @@ module Nydp
|
|
45
44
|
|
46
45
|
SYMBOL_OPERATORS =
|
47
46
|
[
|
48
|
-
[ /%/, "percent-syntax" ],
|
49
47
|
[ /\!/, "bang-syntax" ],
|
50
48
|
[ /::/, "colon-colon-syntax"],
|
51
49
|
[ /:/, "colon-syntax" ],
|
52
50
|
[ /&/, "ampersand-syntax" ],
|
51
|
+
[ /%/, "percent-syntax" ],
|
53
52
|
[ /\./, "dot-syntax" ],
|
54
53
|
[ /\$/, "dollar-syntax" ],
|
55
54
|
[ /->/, "arrow-syntax" ],
|
56
55
|
[ /[=][>]/, "rocket-syntax" ],
|
56
|
+
[ /@/, "at-syntax" ],
|
57
57
|
]
|
58
58
|
|
59
59
|
def parse_symbol txt
|
@@ -73,6 +73,8 @@ module Nydp
|
|
73
73
|
Pair.from_list [sym(:unquote), parse_symbol($1)]
|
74
74
|
when /^\.$/
|
75
75
|
sym txt
|
76
|
+
when /^@$/
|
77
|
+
sym txt
|
76
78
|
else
|
77
79
|
SYMBOL_OPERATORS.each do |rgx, name|
|
78
80
|
syms = txt.split(rgx, -1)
|
@@ -108,7 +110,7 @@ module Nydp
|
|
108
110
|
when :symbol
|
109
111
|
parse_symbol token.last
|
110
112
|
when :comment
|
111
|
-
Pair.from_list [sym(:comment),
|
113
|
+
Pair.from_list [sym(:comment), token.last]
|
112
114
|
else
|
113
115
|
token.last
|
114
116
|
end
|
@@ -129,14 +131,16 @@ module Nydp
|
|
129
131
|
fragments = [sym(:"string-pieces")]
|
130
132
|
string_token = token_stream.next_string_fragment(open_delimiter, close_delimiter, INTERPOLATION_SIGN, INTERPOLATION_ESCAPES)
|
131
133
|
raise "unterminated string" if string_token.nil?
|
132
|
-
fragments <<
|
134
|
+
fragments << string_token.string if string_token.string != ""
|
133
135
|
while !(string_token.is_a? StringFragmentCloseToken)
|
134
136
|
fragments << expression(token_stream)
|
135
137
|
string_token = token_stream.next_string_fragment('', close_delimiter, INTERPOLATION_SIGN, INTERPOLATION_ESCAPES)
|
136
|
-
fragments <<
|
138
|
+
fragments << string_token.string if string_token.string != ""
|
137
139
|
end
|
138
140
|
|
139
|
-
if fragments.size ==
|
141
|
+
if fragments.size == 1
|
142
|
+
return ""
|
143
|
+
elsif fragments.size == 2
|
140
144
|
return fragments[1]
|
141
145
|
else
|
142
146
|
return Pair.from_list fragments
|
data/lib/nydp/string_atom.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
module Nydp
|
2
2
|
class StringAtom
|
3
|
-
attr_accessor :string
|
4
|
-
|
5
|
-
|
6
|
-
end
|
3
|
+
attr_accessor :string
|
4
|
+
|
5
|
+
def initialize string ; @string = string ; end
|
7
6
|
|
8
7
|
def nydp_type ; :string ; end
|
9
8
|
def to_s ; string ; end
|
data/lib/nydp/symbol_lookup.rb
CHANGED
@@ -11,17 +11,17 @@ module Nydp
|
|
11
11
|
bindings
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.build name,
|
15
|
-
|
16
|
-
depth
|
17
|
-
while NIL !=
|
18
|
-
here =
|
14
|
+
def self.build name, original_bindings
|
15
|
+
effective_bindings = skip_empty original_bindings
|
16
|
+
depth = 0
|
17
|
+
while NIL != effective_bindings
|
18
|
+
here = effective_bindings.car
|
19
19
|
if here.key? name
|
20
20
|
binding_index = here[name]
|
21
|
-
return ContextSymbol.build(depth, name, binding_index)
|
21
|
+
return ContextSymbol.build(depth, name, binding_index, original_bindings.index_of(here))
|
22
22
|
else
|
23
23
|
depth += 1
|
24
|
-
|
24
|
+
effective_bindings = skip_empty effective_bindings.cdr
|
25
25
|
end
|
26
26
|
end
|
27
27
|
name
|
data/lib/nydp/tokeniser.rb
CHANGED
@@ -3,7 +3,7 @@ require "strscan"
|
|
3
3
|
module Nydp
|
4
4
|
class Tokeniser
|
5
5
|
BACKSLASH = /\\/.freeze
|
6
|
-
COMMENT =
|
6
|
+
COMMENT = /;;?.*$/.freeze
|
7
7
|
QUOTE = /"/.freeze
|
8
8
|
PIPE = /\|/.freeze
|
9
9
|
LIST_PFX = /[^\s()]*\(/.freeze
|
@@ -89,7 +89,7 @@ module Nydp
|
|
89
89
|
@finished = true
|
90
90
|
return nil
|
91
91
|
elsif comment = s.scan(COMMENT)
|
92
|
-
tok = [:comment, comment
|
92
|
+
tok = [:comment, comment.gsub(/^;;?\s*/, '').strip]
|
93
93
|
elsif open_str = s.scan(QUOTE)
|
94
94
|
tok = [:string_open_delim, open_str]
|
95
95
|
elsif open_sym = s.scan(PIPE)
|
data/lib/nydp/truth.rb
CHANGED
@@ -3,14 +3,14 @@ require 'singleton'
|
|
3
3
|
module Nydp
|
4
4
|
class Truth
|
5
5
|
include Singleton
|
6
|
-
def init_with *; Nydp::T
|
7
|
-
def to_s ; 't'
|
8
|
-
def inspect ; 't
|
9
|
-
def assign *_ ; self
|
10
|
-
def nydp_type ; :truth
|
11
|
-
def to_ruby ; true
|
12
|
-
def _nydp_get a ; Nydp::T
|
13
|
-
def _nydp_set a, v ; Nydp::T
|
6
|
+
def init_with *; Nydp::T ; end
|
7
|
+
def to_s ; 't' ; end
|
8
|
+
def inspect ; 't' ; end
|
9
|
+
def assign *_ ; self ; end
|
10
|
+
def nydp_type ; :truth ; end
|
11
|
+
def to_ruby ; true ; end
|
12
|
+
def _nydp_get a ; Nydp::T ; end
|
13
|
+
def _nydp_set a, v ; Nydp::T ; end
|
14
14
|
end
|
15
15
|
|
16
16
|
class Nil
|
@@ -19,8 +19,8 @@ module Nydp
|
|
19
19
|
def car ; self ; end
|
20
20
|
def cdr ; self ; end
|
21
21
|
def size ; 0 ; end
|
22
|
-
def is? other ; self
|
23
|
-
def isnt? other ; self
|
22
|
+
def is? other ; self.equal? other ; end
|
23
|
+
def isnt? other ; !self.equal? other ; end
|
24
24
|
def to_s ; "" ; end
|
25
25
|
def + other ; other ; end
|
26
26
|
def copy ; self ; end
|
data/lib/nydp/version.rb
CHANGED
data/lib/nydp/vm.rb
CHANGED
@@ -116,6 +116,13 @@ module Nydp
|
|
116
116
|
end
|
117
117
|
msg << "\n"
|
118
118
|
msg << "\n"
|
119
|
+
msg << "\nargs stack"
|
120
|
+
msg << "\n================="
|
121
|
+
args.each_with_index do |args, ix|
|
122
|
+
msg << "\args##{ix} :\n#{args}"
|
123
|
+
end
|
124
|
+
msg << "\n"
|
125
|
+
msg << "\n"
|
119
126
|
msg
|
120
127
|
end
|
121
128
|
end
|
data/nydp.gemspec
CHANGED
@@ -18,8 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency 'rspec', '~> 3.1'
|
24
|
-
spec.add_development_dependency 'rspec_numbering_formatter'
|
21
|
+
spec.add_development_dependency "rake", "~> 12"
|
22
|
+
spec.add_development_dependency 'rspec' #, '~> 3.1'
|
25
23
|
end
|