nydp 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +44 -0
  3. data/lib/lisp/core-010-precompile.nydp +13 -16
  4. data/lib/lisp/core-012-utils.nydp +21 -6
  5. data/lib/lisp/core-015-documentation.nydp +58 -24
  6. data/lib/lisp/core-017-builtin-dox.nydp +49 -42
  7. data/lib/lisp/core-020-utils.nydp +5 -5
  8. data/lib/lisp/core-030-syntax.nydp +191 -96
  9. data/lib/lisp/core-035-flow-control.nydp +41 -14
  10. data/lib/lisp/core-037-list-utils.nydp +36 -14
  11. data/lib/lisp/core-039-module.nydp +24 -0
  12. data/lib/lisp/core-040-utils.nydp +51 -23
  13. data/lib/lisp/core-041-string-utils.nydp +37 -9
  14. data/lib/lisp/core-042-date-utils.nydp +21 -1
  15. data/lib/lisp/core-043-list-utils.nydp +99 -73
  16. data/lib/lisp/core-045-dox-utils.nydp +5 -0
  17. data/lib/lisp/core-070-prefix-list.nydp +1 -1
  18. data/lib/lisp/core-080-pretty-print.nydp +57 -17
  19. data/lib/lisp/core-090-hook.nydp +35 -1
  20. data/lib/lisp/core-100-utils.nydp +110 -15
  21. data/lib/lisp/core-110-hash-utils.nydp +61 -0
  22. data/lib/lisp/core-120-settings.nydp +46 -0
  23. data/lib/lisp/core-130-validations.nydp +51 -0
  24. data/lib/lisp/{core-060-benchmarking.nydp → core-900-benchmarking.nydp} +107 -19
  25. data/lib/lisp/tests/accum-examples.nydp +28 -1
  26. data/lib/lisp/tests/aif-examples.nydp +8 -3
  27. data/lib/lisp/tests/andify-examples.nydp +7 -0
  28. data/lib/lisp/tests/at-syntax-examples.nydp +17 -0
  29. data/lib/lisp/tests/best-examples.nydp +9 -0
  30. data/lib/lisp/tests/builtin-tests.nydp +19 -0
  31. data/lib/lisp/tests/case-examples.nydp +14 -0
  32. data/lib/lisp/tests/cdr-set-examples.nydp +6 -0
  33. data/lib/lisp/tests/date-examples.nydp +56 -1
  34. data/lib/lisp/tests/destructuring-examples.nydp +46 -14
  35. data/lib/lisp/tests/detect-examples.nydp +12 -0
  36. data/lib/lisp/tests/dp-examples.nydp +24 -0
  37. data/lib/lisp/tests/each-tests.nydp +5 -0
  38. data/lib/lisp/tests/empty-examples.nydp +1 -1
  39. data/lib/lisp/tests/error-tests.nydp +4 -4
  40. data/lib/lisp/tests/explain-mac-examples.nydp +1 -1
  41. data/lib/lisp/tests/filter-forms-examples.nydp +15 -0
  42. data/lib/lisp/tests/foundation-test.nydp +12 -0
  43. data/lib/lisp/tests/hash-examples.nydp +26 -2
  44. data/lib/lisp/tests/list-grep-examples.nydp +40 -0
  45. data/lib/lisp/tests/list-tests.nydp +58 -1
  46. data/lib/lisp/tests/map-hash-examples.nydp +11 -0
  47. data/lib/lisp/tests/module-examples.nydp +10 -0
  48. data/lib/lisp/tests/multi-assign-examples.nydp +6 -0
  49. data/lib/lisp/tests/parser-tests.nydp +25 -0
  50. data/lib/lisp/tests/pretty-print-tests.nydp +17 -14
  51. data/lib/lisp/tests/set-difference-examples.nydp +8 -0
  52. data/lib/lisp/tests/set-intersection-examples.nydp +16 -0
  53. data/lib/lisp/tests/set-union-examples.nydp +8 -0
  54. data/lib/lisp/tests/settings-examples.nydp +40 -0
  55. data/lib/lisp/tests/sort-examples.nydp +8 -0
  56. data/lib/lisp/tests/string-tests.nydp +65 -1
  57. data/lib/lisp/tests/syntax-tests.nydp +5 -1
  58. data/lib/lisp/tests/to-integer-examples.nydp +16 -0
  59. data/lib/lisp/tests/validation-examples.nydp +15 -0
  60. data/lib/lisp/tests/zap-examples.nydp +12 -0
  61. data/lib/nydp.rb +13 -7
  62. data/lib/nydp/assignment.rb +10 -3
  63. data/lib/nydp/builtin.rb +1 -1
  64. data/lib/nydp/builtin/abs.rb +8 -0
  65. data/lib/nydp/builtin/cdr_set.rb +1 -6
  66. data/lib/nydp/builtin/date.rb +15 -1
  67. data/lib/nydp/builtin/error.rb +1 -1
  68. data/lib/nydp/builtin/handle_error.rb +1 -1
  69. data/lib/nydp/builtin/hash.rb +27 -45
  70. data/lib/nydp/builtin/inspect.rb +1 -1
  71. data/lib/nydp/builtin/plus.rb +10 -2
  72. data/lib/nydp/builtin/random_string.rb +2 -2
  73. data/lib/nydp/builtin/{car.rb → regexp.rb} +2 -2
  74. data/lib/nydp/builtin/ruby_wrap.rb +72 -0
  75. data/lib/nydp/builtin/string_match.rb +2 -2
  76. data/lib/nydp/builtin/string_pad_left.rb +7 -0
  77. data/lib/nydp/builtin/string_pad_right.rb +7 -0
  78. data/lib/nydp/builtin/string_replace.rb +1 -1
  79. data/lib/nydp/builtin/string_split.rb +4 -3
  80. data/lib/nydp/builtin/to_integer.rb +23 -0
  81. data/lib/nydp/builtin/to_string.rb +2 -9
  82. data/lib/nydp/builtin/type_of.rb +9 -6
  83. data/lib/nydp/closure.rb +0 -3
  84. data/lib/nydp/cond.rb +23 -1
  85. data/lib/nydp/context_symbol.rb +14 -6
  86. data/lib/nydp/core.rb +36 -28
  87. data/lib/nydp/core_ext.rb +54 -0
  88. data/lib/nydp/date.rb +37 -31
  89. data/lib/nydp/function_invocation.rb +34 -26
  90. data/lib/nydp/hash.rb +5 -6
  91. data/lib/nydp/helper.rb +41 -25
  92. data/lib/nydp/interpreted_function.rb +68 -40
  93. data/lib/nydp/literal.rb +1 -1
  94. data/lib/nydp/pair.rb +22 -5
  95. data/lib/nydp/parser.rb +11 -7
  96. data/lib/nydp/string_atom.rb +16 -22
  97. data/lib/nydp/symbol.rb +40 -27
  98. data/lib/nydp/symbol_lookup.rb +7 -7
  99. data/lib/nydp/tokeniser.rb +2 -2
  100. data/lib/nydp/truth.rb +17 -10
  101. data/lib/nydp/version.rb +1 -1
  102. data/lib/nydp/vm.rb +7 -2
  103. data/nydp.gemspec +2 -4
  104. data/spec/date_spec.rb +115 -22
  105. data/spec/embedded_spec.rb +12 -12
  106. data/spec/foreign_hash_spec.rb +14 -2
  107. data/spec/hash_non_hash_behaviour_spec.rb +7 -7
  108. data/spec/hash_spec.rb +24 -2
  109. data/spec/nydp_spec.rb +14 -2
  110. data/spec/pair_spec.rb +3 -1
  111. data/spec/parser_spec.rb +31 -20
  112. data/spec/rand_spec.rb +3 -3
  113. data/spec/spec_helper.rb +13 -1
  114. data/spec/symbol_spec.rb +31 -0
  115. data/spec/time_spec.rb +1 -1
  116. metadata +31 -38
  117. data/lib/nydp/builtin/cdr.rb +0 -7
  118. data/lib/nydp/builtin/cons.rb +0 -9
data/spec/symbol_spec.rb CHANGED
@@ -5,6 +5,37 @@ describe Nydp::Symbol do
5
5
  let(:foo) { Nydp::Symbol.mk :FOO, ns }
6
6
  let(:vm) { Nydp::VM.new(ns) }
7
7
 
8
+ describe "#inspect" do
9
+ it "wraps itself in pipe chars if empty" do
10
+ sym = Nydp::Symbol.mk "", ns
11
+ expect(sym.inspect).to eq "||"
12
+ end
13
+ it "wraps itself in pipe chars if nil" do
14
+ sym = Nydp::Symbol.mk nil, ns
15
+ expect(sym.inspect).to eq "||"
16
+ end
17
+ it "wraps itself in pipe chars if it has spaces" do
18
+ sym = Nydp::Symbol.mk "hello world", ns
19
+ expect(sym.inspect).to eq "|hello world|"
20
+ end
21
+ it "wraps itself in pipe chars if it has pipe chars" do
22
+ sym = Nydp::Symbol.mk "hello|world", ns
23
+ expect(sym.inspect).to eq '|hello\|world|'
24
+ end
25
+ it "wraps itself in pipe chars if it contains quote chars" do
26
+ sym = Nydp::Symbol.mk "hello 'world'", ns
27
+ expect(sym.inspect).to eq "|hello 'world'|"
28
+ end
29
+ it "wraps itself in pipe chars if it contains doublequote chars" do
30
+ sym = Nydp::Symbol.mk 'hello "world"', ns
31
+ expect(sym.inspect).to eq '|hello "world"|'
32
+ end
33
+ it "wraps itself in pipe chars if it has other punctuation" do
34
+ sym = Nydp::Symbol.mk 'hello,(world)', ns
35
+ expect(sym.inspect).to eq '|hello,(world)|'
36
+ end
37
+ end
38
+
8
39
  it "returns a ruby symbol in #to_ruby" do
9
40
  sym = Nydp::Symbol.mk :foo, ns
10
41
  expect(sym.to_ruby).to eq :foo
data/spec/time_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe Nydp::Date do
8
8
 
9
9
  it "r2n does not convert ruby Time" do
10
10
  rd = Time.now
11
- nd = Nydp.r2n rd, ns
11
+ nd = Nydp.r2n rd
12
12
 
13
13
  expect(nd).to be_a Time
14
14
  expect(nd).to eq rd
metadata CHANGED
@@ -1,59 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nydp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.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-12-14 00:00:00.000000000 Z
11
+ date: 2021-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.3'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.3'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '10.0'
19
+ version: '12'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '10.0'
26
+ version: '12'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.1'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.1'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec_numbering_formatter
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - ">="
@@ -95,28 +67,36 @@ files:
95
67
  - lib/lisp/core-030-syntax.nydp
96
68
  - lib/lisp/core-035-flow-control.nydp
97
69
  - lib/lisp/core-037-list-utils.nydp
70
+ - lib/lisp/core-039-module.nydp
98
71
  - lib/lisp/core-040-utils.nydp
99
72
  - lib/lisp/core-041-string-utils.nydp
100
73
  - lib/lisp/core-042-date-utils.nydp
101
74
  - lib/lisp/core-043-list-utils.nydp
102
75
  - lib/lisp/core-045-dox-utils.nydp
103
76
  - lib/lisp/core-050-test-runner.nydp
104
- - lib/lisp/core-060-benchmarking.nydp
105
77
  - lib/lisp/core-070-prefix-list.nydp
106
78
  - lib/lisp/core-080-pretty-print.nydp
107
79
  - lib/lisp/core-090-hook.nydp
108
80
  - lib/lisp/core-100-utils.nydp
81
+ - lib/lisp/core-110-hash-utils.nydp
82
+ - lib/lisp/core-120-settings.nydp
83
+ - lib/lisp/core-130-validations.nydp
84
+ - lib/lisp/core-900-benchmarking.nydp
109
85
  - lib/lisp/tests/accum-examples.nydp
110
86
  - lib/lisp/tests/add-hook-examples.nydp
111
87
  - lib/lisp/tests/aif-examples.nydp
112
88
  - lib/lisp/tests/all-examples.nydp
113
89
  - lib/lisp/tests/ampersand-syntax-examples.nydp
90
+ - lib/lisp/tests/andify-examples.nydp
114
91
  - lib/lisp/tests/any-examples.nydp
92
+ - lib/lisp/tests/at-syntax-examples.nydp
115
93
  - lib/lisp/tests/auto-hash-examples.nydp
116
94
  - lib/lisp/tests/best-examples.nydp
117
95
  - lib/lisp/tests/boot-tests.nydp
118
96
  - lib/lisp/tests/builtin-tests.nydp
119
97
  - lib/lisp/tests/car-examples.nydp
98
+ - lib/lisp/tests/case-examples.nydp
99
+ - lib/lisp/tests/cdr-set-examples.nydp
120
100
  - lib/lisp/tests/collect-tests.nydp
121
101
  - lib/lisp/tests/cons-examples.nydp
122
102
  - lib/lisp/tests/curry-tests.nydp
@@ -127,6 +107,7 @@ files:
127
107
  - lib/lisp/tests/detect-examples.nydp
128
108
  - lib/lisp/tests/dot-syntax-examples.nydp
129
109
  - lib/lisp/tests/dox-tests.nydp
110
+ - lib/lisp/tests/dp-examples.nydp
130
111
  - lib/lisp/tests/dynamic-scope-test.nydp
131
112
  - lib/lisp/tests/each-tests.nydp
132
113
  - lib/lisp/tests/empty-examples.nydp
@@ -144,11 +125,15 @@ files:
144
125
  - lib/lisp/tests/isa-examples.nydp
145
126
  - lib/lisp/tests/k-examples.nydp
146
127
  - lib/lisp/tests/len-examples.nydp
128
+ - lib/lisp/tests/list-grep-examples.nydp
147
129
  - lib/lisp/tests/list-gsub-examples.nydp
148
130
  - lib/lisp/tests/list-match-examples.nydp
149
131
  - lib/lisp/tests/list-tests.nydp
132
+ - lib/lisp/tests/map-hash-examples.nydp
150
133
  - lib/lisp/tests/mapreduce-examples.nydp
151
134
  - lib/lisp/tests/mapsum-examples.nydp
135
+ - lib/lisp/tests/module-examples.nydp
136
+ - lib/lisp/tests/multi-assign-examples.nydp
152
137
  - lib/lisp/tests/none-examples.nydp
153
138
  - lib/lisp/tests/orequal-examples.nydp
154
139
  - lib/lisp/tests/parser-tests.nydp
@@ -163,25 +148,28 @@ files:
163
148
  - lib/lisp/tests/returning-examples.nydp
164
149
  - lib/lisp/tests/rfnwith-tests.nydp
165
150
  - lib/lisp/tests/seqf-examples.nydp
151
+ - lib/lisp/tests/set-difference-examples.nydp
166
152
  - lib/lisp/tests/set-intersection-examples.nydp
167
153
  - lib/lisp/tests/set-union-examples.nydp
154
+ - lib/lisp/tests/settings-examples.nydp
168
155
  - lib/lisp/tests/sort-examples.nydp
169
156
  - lib/lisp/tests/string-tests.nydp
170
157
  - lib/lisp/tests/syntax-tests.nydp
171
158
  - lib/lisp/tests/time-examples.nydp
159
+ - lib/lisp/tests/to-integer-examples.nydp
172
160
  - lib/lisp/tests/tuples-examples.nydp
173
161
  - lib/lisp/tests/type-of-examples.nydp
174
162
  - lib/lisp/tests/unparse-tests.nydp
163
+ - lib/lisp/tests/validation-examples.nydp
164
+ - lib/lisp/tests/zap-examples.nydp
175
165
  - lib/lisp/tests/zip-examples.nydp
176
166
  - lib/nydp.rb
177
167
  - lib/nydp/assignment.rb
178
168
  - lib/nydp/builtin.rb
169
+ - lib/nydp/builtin/abs.rb
179
170
  - lib/nydp/builtin/apply.rb
180
- - lib/nydp/builtin/car.rb
181
- - lib/nydp/builtin/cdr.rb
182
171
  - lib/nydp/builtin/cdr_set.rb
183
172
  - lib/nydp/builtin/comment.rb
184
- - lib/nydp/builtin/cons.rb
185
173
  - lib/nydp/builtin/date.rb
186
174
  - lib/nydp/builtin/divide.rb
187
175
  - lib/nydp/builtin/ensuring.rb
@@ -207,18 +195,23 @@ files:
207
195
  - lib/nydp/builtin/quit.rb
208
196
  - lib/nydp/builtin/rand.rb
209
197
  - lib/nydp/builtin/random_string.rb
198
+ - lib/nydp/builtin/regexp.rb
199
+ - lib/nydp/builtin/ruby_wrap.rb
210
200
  - lib/nydp/builtin/script_run.rb
211
201
  - lib/nydp/builtin/set_intersection.rb
212
202
  - lib/nydp/builtin/set_union.rb
213
203
  - lib/nydp/builtin/sort.rb
214
204
  - lib/nydp/builtin/sqrt.rb
215
205
  - lib/nydp/builtin/string_match.rb
206
+ - lib/nydp/builtin/string_pad_left.rb
207
+ - lib/nydp/builtin/string_pad_right.rb
216
208
  - lib/nydp/builtin/string_replace.rb
217
209
  - lib/nydp/builtin/string_split.rb
218
210
  - lib/nydp/builtin/sym.rb
219
211
  - lib/nydp/builtin/thread_locals.rb
220
212
  - lib/nydp/builtin/time.rb
221
213
  - lib/nydp/builtin/times.rb
214
+ - lib/nydp/builtin/to_integer.rb
222
215
  - lib/nydp/builtin/to_string.rb
223
216
  - lib/nydp/builtin/type_of.rb
224
217
  - lib/nydp/builtin/vm_info.rb
@@ -227,6 +220,7 @@ files:
227
220
  - lib/nydp/cond.rb
228
221
  - lib/nydp/context_symbol.rb
229
222
  - lib/nydp/core.rb
223
+ - lib/nydp/core_ext.rb
230
224
  - lib/nydp/date.rb
231
225
  - lib/nydp/error.rb
232
226
  - lib/nydp/function_invocation.rb
@@ -289,8 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
283
  - !ruby/object:Gem::Version
290
284
  version: '0'
291
285
  requirements: []
292
- rubyforge_project:
293
- rubygems_version: 2.2.2
286
+ rubygems_version: 3.0.3
294
287
  signing_key:
295
288
  specification_version: 4
296
289
  summary: A civilised yet somewhat dangerous kind of Lisp for a new generation
@@ -1,7 +0,0 @@
1
- class Nydp::Builtin::Cdr
2
- include Nydp::Builtin::Base, Singleton
3
-
4
- def builtin_invoke vm, args
5
- vm.push_arg args.car.cdr
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- module Nydp::Builtin
2
- class Cons
3
- include Nydp::Builtin::Base, Singleton
4
-
5
- def builtin_invoke vm, args
6
- vm.push_arg Nydp::Pair.new(args.car, args.cdr.car)
7
- end
8
- end
9
- end