nydp 0.3.0 → 0.4.0
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 +4 -4
- data/.zeiger.yml +28 -0
- data/lib/lisp/core-000.nydp +1 -1
- data/lib/lisp/core-015-documentation.nydp +6 -9
- data/lib/lisp/core-017-builtin-dox.nydp +33 -0
- data/lib/lisp/core-025-warnings.nydp +15 -0
- data/lib/lisp/core-030-syntax.nydp +38 -2
- data/lib/lisp/core-035-flow-control.nydp +2 -2
- data/lib/lisp/core-037-list-utils.nydp +7 -5
- data/lib/lisp/core-040-utils.nydp +15 -4
- data/lib/lisp/core-043-list-utils.nydp +1 -0
- data/lib/lisp/core-045-dox-utils.nydp +6 -0
- data/lib/lisp/core-050-test-runner.nydp +9 -9
- data/lib/lisp/core-070-prefix-list.nydp +2 -2
- data/lib/lisp/core-090-hook.nydp +24 -0
- data/lib/lisp/core-100-utils.nydp +38 -10
- data/lib/lisp/tests/ampersand-syntax-examples.nydp +26 -0
- data/lib/lisp/tests/boot-tests.nydp +1 -1
- data/lib/lisp/tests/collect-tests.nydp +4 -0
- data/lib/lisp/tests/destructuring-examples.nydp +18 -1
- data/lib/lisp/tests/fill-bucket-examples.nydp +46 -2
- data/lib/lisp/tests/floor-examples.nydp +58 -0
- data/lib/lisp/tests/k-examples.nydp +5 -0
- data/lib/lisp/tests/power-examples.nydp +16 -0
- data/lib/lisp/tests/string-tests.nydp +8 -0
- data/lib/lisp/tests/syntax-tests.nydp +6 -0
- data/lib/lisp/tests/zip-examples.nydp +16 -0
- data/lib/nydp.rb +6 -2
- data/lib/nydp/assignment.rb +1 -2
- data/lib/nydp/builtin/ensuring.rb +1 -2
- data/lib/nydp/builtin/greater_than.rb +2 -2
- data/lib/nydp/builtin/handle_error.rb +1 -2
- data/lib/nydp/builtin/less_than.rb +2 -2
- data/lib/nydp/builtin/math_ceiling.rb +7 -0
- data/lib/nydp/builtin/math_floor.rb +7 -0
- data/lib/nydp/builtin/math_power.rb +7 -0
- data/lib/nydp/builtin/math_round.rb +7 -0
- data/lib/nydp/builtin/parse.rb +2 -2
- data/lib/nydp/builtin/parse_in_string.rb +3 -3
- data/lib/nydp/builtin/pre_compile.rb +0 -1
- data/lib/nydp/compiler.rb +1 -1
- data/lib/nydp/cond.rb +3 -6
- data/lib/nydp/context_symbol.rb +40 -32
- data/lib/nydp/core.rb +8 -2
- data/lib/nydp/function_invocation.rb +3 -5
- data/lib/nydp/image_store.rb +21 -0
- data/lib/nydp/interpreted_function.rb +8 -12
- data/lib/nydp/lexical_context_builder.rb +19 -35
- data/lib/nydp/pair.rb +2 -1
- data/lib/nydp/parser.rb +4 -0
- data/lib/nydp/plugin.rb +15 -8
- data/lib/nydp/runner.rb +3 -3
- data/lib/nydp/symbol.rb +3 -1
- data/lib/nydp/symbol_lookup.rb +2 -2
- data/lib/nydp/truth.rb +2 -2
- data/lib/nydp/version.rb +1 -1
- data/lib/nydp/vm.rb +47 -27
- data/spec/date_spec.rb +2 -2
- data/spec/embedded_spec.rb +16 -16
- data/spec/error_spec.rb +1 -1
- data/spec/nydp_spec.rb +13 -4
- data/spec/parser_spec.rb +63 -16
- data/spec/spec_helper.rb +1 -2
- data/spec/string_atom_spec.rb +2 -2
- data/spec/symbol_spec.rb +2 -2
- data/spec/tokeniser_spec.rb +101 -0
- metadata +16 -2
data/spec/symbol_spec.rb
CHANGED
@@ -47,7 +47,7 @@ describe Nydp::Symbol do
|
|
47
47
|
|
48
48
|
f.invoke vm, pair_list([foo, bar])
|
49
49
|
|
50
|
-
expect(vm.args.pop).to eq
|
50
|
+
expect(vm.args.pop).to eq bar
|
51
51
|
end
|
52
52
|
|
53
53
|
it "works with builtin greater-than when false" do
|
@@ -63,7 +63,7 @@ describe Nydp::Symbol do
|
|
63
63
|
|
64
64
|
f.invoke vm, pair_list([bar, foo])
|
65
65
|
|
66
|
-
expect(vm.args.pop).to eq
|
66
|
+
expect(vm.args.pop).to eq foo
|
67
67
|
end
|
68
68
|
|
69
69
|
it "works with builtin less-than when false" do
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "tokenising" do
|
4
|
+
it "should return another stream of tokens" do
|
5
|
+
tt = []
|
6
|
+
reader = Nydp::StringReader.new "(a b c 1 2 3)"
|
7
|
+
t = Nydp::Tokeniser.new reader
|
8
|
+
tt = []
|
9
|
+
tok = t.next_token
|
10
|
+
while tok
|
11
|
+
tt << tok
|
12
|
+
tok = t.next_token
|
13
|
+
end
|
14
|
+
expect(tt).to eq [[:left_paren, ""],
|
15
|
+
[:symbol, "a"],
|
16
|
+
[:symbol, "b"],
|
17
|
+
[:symbol, "c"],
|
18
|
+
[:number, 1.0],
|
19
|
+
[:number, 2.0],
|
20
|
+
[:number, 3.0],
|
21
|
+
[:right_paren]]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return a stream of tokens, including whitespace before right-paren" do
|
25
|
+
reader = Nydp::StringReader.new "foo )"
|
26
|
+
t = Nydp::Tokeniser.new reader
|
27
|
+
tt = []
|
28
|
+
tok = t.next_token
|
29
|
+
while tok
|
30
|
+
tt << tok
|
31
|
+
tok = t.next_token
|
32
|
+
end
|
33
|
+
expect(tt).to eq [[:symbol , "foo"],
|
34
|
+
[:right_paren]]
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns nothing at all" do
|
38
|
+
s = Nydp::StringReader.new ""
|
39
|
+
tkz = Nydp::Tokeniser.new s
|
40
|
+
expect(tkz.next_token).to be_nil
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns a whitespace token" do
|
44
|
+
s = Nydp::StringReader.new " "
|
45
|
+
tkz = Nydp::Tokeniser.new s
|
46
|
+
expect(tkz.next_token).to be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns a symbol token" do
|
50
|
+
s = Nydp::StringReader.new "hello"
|
51
|
+
tkz = Nydp::Tokeniser.new s
|
52
|
+
expect(tkz.next_token).to eq [:symbol, "hello"]
|
53
|
+
expect(tkz.next_token).to be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns symbol then whitespace" do
|
57
|
+
s = Nydp::StringReader.new "hello "
|
58
|
+
tkz = Nydp::Tokeniser.new s
|
59
|
+
expect(tkz.next_token).to eq [:symbol, "hello"]
|
60
|
+
expect(tkz.next_token).to be_nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns whitespace symbol whitespace symbol whitespace" do
|
64
|
+
s = Nydp::StringReader.new " hello world "
|
65
|
+
tkz = Nydp::Tokeniser.new s
|
66
|
+
expect(tkz.next_token).to eq [:symbol, "hello"]
|
67
|
+
expect(tkz.next_token).to eq [:symbol, "world"]
|
68
|
+
expect(tkz.next_token).to be_nil
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns whitespace left_paren symbol whitespace symbol right_paren whitespace" do
|
72
|
+
s = Nydp::StringReader.new " (hello world) "
|
73
|
+
tkz = Nydp::Tokeniser.new s
|
74
|
+
expect(tkz.next_token).to eq [:left_paren, ""]
|
75
|
+
expect(tkz.next_token).to eq [:symbol, "hello"]
|
76
|
+
expect(tkz.next_token).to eq [:symbol, "world"]
|
77
|
+
expect(tkz.next_token).to eq [:right_paren]
|
78
|
+
expect(tkz.next_token).to be_nil
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns whitespace left_paren with prefix symbol whitespace symbol right_paren whitespace" do
|
82
|
+
s = Nydp::StringReader.new " %w(hello world) "
|
83
|
+
tkz = Nydp::Tokeniser.new s
|
84
|
+
expect(tkz.next_token).to eq [:left_paren, "%w"]
|
85
|
+
expect(tkz.next_token).to eq [:symbol, "hello"]
|
86
|
+
expect(tkz.next_token).to eq [:symbol, "world"]
|
87
|
+
expect(tkz.next_token).to eq [:right_paren]
|
88
|
+
expect(tkz.next_token).to be_nil
|
89
|
+
end
|
90
|
+
|
91
|
+
it "returns a comment" do
|
92
|
+
s = Nydp::StringReader.new "hello
|
93
|
+
; observe!
|
94
|
+
world"
|
95
|
+
tkz = Nydp::Tokeniser.new s
|
96
|
+
expect(tkz.next_token).to eq [:symbol , 'hello']
|
97
|
+
expect(tkz.next_token).to eq [:comment , "observe!" ]
|
98
|
+
expect(tkz.next_token).to eq [:symbol , "world"]
|
99
|
+
expect(tkz.next_token).to be_nil
|
100
|
+
end
|
101
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nydp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conan Dalton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- ".gitattributes"
|
79
79
|
- ".gitignore"
|
80
80
|
- ".rspec"
|
81
|
+
- ".zeiger.yml"
|
81
82
|
- Gemfile
|
82
83
|
- LICENSE.txt
|
83
84
|
- README.md
|
@@ -90,6 +91,7 @@ files:
|
|
90
91
|
- lib/lisp/core-015-documentation.nydp
|
91
92
|
- lib/lisp/core-017-builtin-dox.nydp
|
92
93
|
- lib/lisp/core-020-utils.nydp
|
94
|
+
- lib/lisp/core-025-warnings.nydp
|
93
95
|
- lib/lisp/core-030-syntax.nydp
|
94
96
|
- lib/lisp/core-035-flow-control.nydp
|
95
97
|
- lib/lisp/core-037-list-utils.nydp
|
@@ -108,6 +110,7 @@ files:
|
|
108
110
|
- lib/lisp/tests/add-hook-examples.nydp
|
109
111
|
- lib/lisp/tests/aif-examples.nydp
|
110
112
|
- lib/lisp/tests/all-examples.nydp
|
113
|
+
- lib/lisp/tests/ampersand-syntax-examples.nydp
|
111
114
|
- lib/lisp/tests/any-examples.nydp
|
112
115
|
- lib/lisp/tests/auto-hash-examples.nydp
|
113
116
|
- lib/lisp/tests/best-examples.nydp
|
@@ -131,6 +134,7 @@ files:
|
|
131
134
|
- lib/lisp/tests/explain-mac-examples.nydp
|
132
135
|
- lib/lisp/tests/fill-bucket-examples.nydp
|
133
136
|
- lib/lisp/tests/filter-forms-examples.nydp
|
137
|
+
- lib/lisp/tests/floor-examples.nydp
|
134
138
|
- lib/lisp/tests/foundation-test.nydp
|
135
139
|
- lib/lisp/tests/group-by-examples.nydp
|
136
140
|
- lib/lisp/tests/hash-examples.nydp
|
@@ -138,6 +142,7 @@ files:
|
|
138
142
|
- lib/lisp/tests/intersperse-examples.nydp
|
139
143
|
- lib/lisp/tests/invocation-tests.nydp
|
140
144
|
- lib/lisp/tests/isa-examples.nydp
|
145
|
+
- lib/lisp/tests/k-examples.nydp
|
141
146
|
- lib/lisp/tests/len-examples.nydp
|
142
147
|
- lib/lisp/tests/list-gsub-examples.nydp
|
143
148
|
- lib/lisp/tests/list-match-examples.nydp
|
@@ -147,6 +152,7 @@ files:
|
|
147
152
|
- lib/lisp/tests/orequal-examples.nydp
|
148
153
|
- lib/lisp/tests/parser-tests.nydp
|
149
154
|
- lib/lisp/tests/plus-plus-examples.nydp
|
155
|
+
- lib/lisp/tests/power-examples.nydp
|
150
156
|
- lib/lisp/tests/pre-compile-examples.nydp
|
151
157
|
- lib/lisp/tests/pretty-print-tests.nydp
|
152
158
|
- lib/lisp/tests/push-examples.nydp
|
@@ -163,6 +169,7 @@ files:
|
|
163
169
|
- lib/lisp/tests/tuples-examples.nydp
|
164
170
|
- lib/lisp/tests/type-of-examples.nydp
|
165
171
|
- lib/lisp/tests/unparse-tests.nydp
|
172
|
+
- lib/lisp/tests/zip-examples.nydp
|
166
173
|
- lib/nydp.rb
|
167
174
|
- lib/nydp/assignment.rb
|
168
175
|
- lib/nydp/builtin.rb
|
@@ -183,6 +190,10 @@ files:
|
|
183
190
|
- lib/nydp/builtin/inspect.rb
|
184
191
|
- lib/nydp/builtin/is_equal.rb
|
185
192
|
- lib/nydp/builtin/less_than.rb
|
193
|
+
- lib/nydp/builtin/math_ceiling.rb
|
194
|
+
- lib/nydp/builtin/math_floor.rb
|
195
|
+
- lib/nydp/builtin/math_power.rb
|
196
|
+
- lib/nydp/builtin/math_round.rb
|
186
197
|
- lib/nydp/builtin/minus.rb
|
187
198
|
- lib/nydp/builtin/modulo.rb
|
188
199
|
- lib/nydp/builtin/parse.rb
|
@@ -215,6 +226,7 @@ files:
|
|
215
226
|
- lib/nydp/function_invocation.rb
|
216
227
|
- lib/nydp/hash.rb
|
217
228
|
- lib/nydp/helper.rb
|
229
|
+
- lib/nydp/image_store.rb
|
218
230
|
- lib/nydp/interpreted_function.rb
|
219
231
|
- lib/nydp/lexical_context.rb
|
220
232
|
- lib/nydp/lexical_context_builder.rb
|
@@ -250,6 +262,7 @@ files:
|
|
250
262
|
- spec/symbol_spec.rb
|
251
263
|
- spec/thread_local_spec.rb
|
252
264
|
- spec/time_spec.rb
|
265
|
+
- spec/tokeniser_spec.rb
|
253
266
|
homepage: http://github.com/conanite/nydp
|
254
267
|
licenses:
|
255
268
|
- MIT
|
@@ -291,3 +304,4 @@ test_files:
|
|
291
304
|
- spec/symbol_spec.rb
|
292
305
|
- spec/thread_local_spec.rb
|
293
306
|
- spec/time_spec.rb
|
307
|
+
- spec/tokeniser_spec.rb
|