skeem 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 848f771b4fb717e1c491f6afae9a88a9c34e5302
4
- data.tar.gz: 349587e3837e36893a5aaaad4a32986708d24979
3
+ metadata.gz: 4b1748ebcacd81d8e56ece9deb9a8087d28ebb50
4
+ data.tar.gz: b4263783f841a2f3577c5cb885554f01f44c067e
5
5
  SHA512:
6
- metadata.gz: 89778cee179ca6cd65a5f45804471637d31a0db36f094cbedadc8ef72cb46cc3b0c75193e4b458b16091388a2a02db8c13e27444b7642da56ffc899504d451ce
7
- data.tar.gz: cecc4f9aca3391d4abf695b593822988b49145e6bf55e66ed468cb10bda9e4fca5f9ad569c2c9e3de1d6220943437eabbd88067b3a5282abeea3bee2d2764679
6
+ metadata.gz: fda3cea9741f1b2da1016b41b90b7ff627e54d37a3c3ac851b5afe6f85eaab943e2a245e1bbde96796179a464c1bcc6e8384fe03aaed3a4a40efe71110ff9483
7
+ data.tar.gz: 75fec756b836694aa1b2ac8874fbdb503017fb99328ce440ea9c8a45ea95f9a8232c5e16e8e5288aa4a3144c52d4de37ebfb22d1a913e1abd71886ea0c412cd7
@@ -1,3 +1,12 @@
1
+ ## [0.0.22] - 2018-10-23
2
+ ### Added
3
+ - Class `SkmBuilder`added support for list datum.
4
+ - File `primitive_builder.rb` implementation of: standard `and` procedure.
5
+
6
+ ### Fixed
7
+ - File `interpreter_spec.rb` Added test example of list quotation.
8
+
9
+
1
10
  ## [0.0.21] - 2018-10-22
2
11
  ### Added
3
12
  - Added support for alternative `define` syntax.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Skeem
2
- [![Linux Build Status](https://travis-ci.org/famished-tiger/Skeem.svg?branch=master)](https://travis-ci.org/famished-tiger/Skeem)
3
- [![Build status](https://ci.appveyor.com/api/projects/status/qs19wn6o6bpo8lm6?svg=true)](https://ci.appveyor.com/project/famished-tiger/skeem)
2
+ |Linux|Windows|
3
+ |:-:|:-:|
4
+ |[![Linux Build Status](https://travis-ci.org/famished-tiger/Skeem.svg?branch=master)](https://travis-ci.org/famished-tiger/Skeem)|[![Windows Build Status](https://ci.appveyor.com/api/projects/status/qs19wn6o6bpo8lm6?svg=true)](https://ci.appveyor.com/project/famished-tiger/skeem)|
5
+
4
6
  [![Gem Version](https://badge.fury.io/rb/skeem.svg)](https://badge.fury.io/rb/skeem)
5
7
  [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/famished-tiger/Skeem/blob/master/LICENSE.txt)
6
8
 
@@ -170,7 +172,7 @@ This section lists the implemented standard procedures
170
172
  * `symbol?`
171
173
 
172
174
  #### Vector procedures
173
- * `vector?`, `vector`, `vector-length`
175
+ * `vector?`, `vector`, `vector-length`, `vector-set!`
174
176
 
175
177
  #### Input/output procedures
176
178
  * `newline`
@@ -51,7 +51,7 @@ module Skeem
51
51
  rule 'simple_datum' => 'symbol'
52
52
  rule 'compound_datum' => 'list'
53
53
  rule 'compound_datum' => 'vector'
54
- rule 'list' => 'LPAREN datum_star RPAREN'
54
+ rule('list' => 'LPAREN datum_star RPAREN').as 'list'
55
55
  rule 'list' => 'LPAREN datum_plus PERIOD datum RPAREN'
56
56
  rule('vector' => 'VECTOR_BEGIN datum_star RPAREN').as 'vector'
57
57
  rule('datum_plus' => 'datum_plus datum').as 'multiple_datums'
@@ -64,6 +64,7 @@ module Skeem
64
64
 
65
65
  def add_boolean_procedures(aRuntime)
66
66
  create_not(aRuntime)
67
+ create_and(aRuntime)
67
68
  create_object_predicate(aRuntime, 'boolean?')
68
69
  end
69
70
 
@@ -278,6 +279,27 @@ module Skeem
278
279
 
279
280
  define_primitive_proc(aRuntime, 'not', unary, primitive)
280
281
  end
282
+
283
+ def create_and(aRuntime)
284
+ # arglist should be a Ruby Array
285
+ primitive = ->(runtime, arglist) do
286
+ if arglist.empty?
287
+ to_skm(true) # in conformance with 4.2.1
288
+ else
289
+ raw_result = true
290
+ last_result = nil
291
+ arglist.each do |raw_arg|
292
+ argument = raw_arg.evaluate(aRuntime)
293
+ last_result = argument
294
+ raw_result &&= !(argument.boolean? && !argument.value)
295
+ break unless raw_result
296
+ end
297
+ raw_result = last_result if raw_result
298
+ to_skm(raw_result)
299
+ end
300
+ end
301
+ define_primitive_proc(aRuntime, 'and', zero_or_more, primitive)
302
+ end
281
303
 
282
304
  def create_length(aRuntime)
283
305
  primitive = ->(runtime, arg) do
@@ -85,6 +85,11 @@ module Skeem
85
85
  SkmQuotation.new(theChildren[2])
86
86
  end
87
87
 
88
+ # rule('list' => 'LPAREN datum_star RPAREN').as 'list'
89
+ def reduce_list(_production, aRange, _tokens, theChildren)
90
+ SkmList.new(theChildren[1])
91
+ end
92
+
88
93
  # rule('vector' => 'VECTOR_BEGIN datum_star RPAREN').as 'vector'
89
94
  def reduce_vector(_production, aRange, _tokens, theChildren)
90
95
  SkmVector.new(theChildren[1])
@@ -1,3 +1,3 @@
1
1
  module Skeem
2
- VERSION = '0.0.21'.freeze
2
+ VERSION = '0.0.22'.freeze
3
3
  end
@@ -166,7 +166,7 @@ SKEEM
166
166
  end
167
167
  end
168
168
 
169
- it 'should implement the quotation of vector' do
169
+ it 'should implement the quotation of vectors' do
170
170
  source = '(quote #(a b c))'
171
171
  result = subject.run(source)
172
172
  expect(result).to be_kind_of(SkmVector)
@@ -181,6 +181,25 @@ SKEEM
181
181
  end
182
182
  end
183
183
 
184
+ it 'should implement the quotation of lists' do
185
+ source = '(quote (+ 1 2))'
186
+ result = subject.run(source)
187
+ expect(result).to be_kind_of(SkmList)
188
+ predictions = [
189
+ [SkmIdentifier, '+'],
190
+ [SkmInteger, 1],
191
+ [SkmInteger, 2]
192
+ ]
193
+ predictions.each_with_index do |(type, value), index|
194
+ expect(result.members[index]).to be_kind_of(type)
195
+ expect(result.members[index].value).to eq(value)
196
+ end
197
+
198
+ source = "'()"
199
+ result = subject.run(source)
200
+ expect(result).to be_kind_of(SkmList)
201
+ expect(result).to be_empty
202
+ end
184
203
 
185
204
  it 'should implement the lambda function with one arg' do
186
205
  source = <<-SKEEM
@@ -203,6 +203,24 @@ module Skeem
203
203
  end
204
204
  end
205
205
 
206
+ it 'should implement the and procedure' do
207
+ checks = [
208
+ ['(and (= 2 2) (> 2 1))', true],
209
+ ['(and (= 2 2) (< 2 1))', false],
210
+ ['(and)', true]
211
+ ]
212
+ checks.each do |(skeem_expr, expectation)|
213
+ result = subject.run(skeem_expr)
214
+ expect(result.value).to eq(expectation)
215
+ end
216
+
217
+ # If all the expressions evaluate to true values,
218
+ # the values of the last expression are returned.
219
+ source = "(and 1 2 'c '(f g))"
220
+ result = subject.run(source)
221
+ p result
222
+ end
223
+
206
224
  it 'should implement the boolean? procedure' do
207
225
  checks = [
208
226
  ['(boolean? #f)', true],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skeem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-22 00:00:00.000000000 Z
11
+ date: 2018-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley