skeem 0.2.01 → 0.2.02

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f5189dc1b13c7998cdf1ee98579ff1f70ae057493897f1e9bc64614ddb08a50
4
- data.tar.gz: c302f6dce9b86a5ef7d5c644afbd164a8957d848ddaf5ab729e8f66a58b5bd55
3
+ metadata.gz: ff26a0c0a06cb583052e17627fd7c620e26dc5c595613f1f6d5716a368c154b7
4
+ data.tar.gz: e7697be919dc2624c449ff001524d426ff914b2e09f8bc69f581599bd3961148
5
5
  SHA512:
6
- metadata.gz: b2e87e734659cff72352271a51ee76be8af918287ba2db9c267993774b03f04e3203aea62d130ee73678d8ad8011d4cca485ce3126116915685c33c6ac9ba326
7
- data.tar.gz: 95a6027ac7ce681dbc4ab9dbe7a3f9ae96c8b19ff37bd61d4932ca869f2f1ab94495759c54d332fbf84772cfa0affb5a1dea610aa1002de48e0d64c61cb81228
6
+ metadata.gz: 3a2ec84eec62e1bd007b480f89a843af69c023259dcfd37ae5808c8f7266f904ac0a6ab6ee8eb4f1877d3fbe16735c39c281c18ca16ee27c09307ae48f677287
7
+ data.tar.gz: e58e2a58401d9b8d6c17c9394029a4e2438917682e767e0541262c98ff4c0011dd8fd6b2fe998c019c96c7ce0a6007d2697d5987271858fba7c80d053242ba41
data/CHANGELOG.md CHANGED
@@ -1,8 +1,11 @@
1
+ ## [0.2.02] - 2019-04-20
2
+ ### Added
3
+ - Skeem now supports 'let*' local binding construct
4
+
1
5
  ## [0.2.01] - 2019-04-19
2
6
  ### Added
3
7
  - Skeem now supports 'let' local binding construct
4
8
 
5
-
6
9
  ## [0.2.00] - 2019-04-14
7
10
  ### Major refactoring
8
11
 
data/README.md CHANGED
@@ -168,6 +168,11 @@ __Syntax:__
168
168
  * (let (<binding_spec\*\>) <body\>)
169
169
 
170
170
 
171
+ #### let*
172
+ __Purpose:__ Define one or more variable local to the block.
173
+ __Syntax:__
174
+ * (let* (<binding_spec\*\>) <body\>)
175
+
171
176
  ### Standard library
172
177
  This section lists the implemented standard procedures
173
178
 
data/lib/skeem/grammar.rb CHANGED
@@ -20,6 +20,7 @@ module Skeem
20
20
 
21
21
  # Keywords...
22
22
  add_terminals('DEFINE', 'IF', 'LAMBDA', 'LET')
23
+ add_terminals('LET*')
23
24
  add_terminals('QUOTE', 'QUASIQUOTE', 'SET!')
24
25
  add_terminals('UNQUOTE', 'UNQUOTE-SPLICING')
25
26
 
@@ -93,6 +94,7 @@ module Skeem
93
94
  rule 'number' => 'REAL'
94
95
  rule('assignment' => 'LPAREN SET! IDENTIFIER expression RPAREN').as 'assignment'
95
96
  rule('derived_expression' => 'LPAREN LET LPAREN binding_spec_star RPAREN body RPAREN').as 'short_let_form'
97
+ rule('derived_expression' => 'LPAREN LET* LPAREN binding_spec_star RPAREN body RPAREN').as 'let_star_form'
96
98
  rule 'derived_expression' => 'quasiquotation'
97
99
  rule('quasiquotation' => 'LPAREN QUASIQUOTE qq_template RPAREN').as 'quasiquotation'
98
100
  rule('quasiquotation' => 'GRAVE_ACCENT qq_template').as 'quasiquotation_short'
@@ -256,6 +256,11 @@ module Skeem
256
256
  def reduce_short_let_form(_production, aRange, _tokens, theChildren)
257
257
  SkmBindingBlock.new(:let, theChildren[3], theChildren[5])
258
258
  end
259
+
260
+ # rule('derived_expression' => 'LPAREN LET* LPAREN binding_spec_star RPAREN body RPAREN').as 'let_star_form'
261
+ def reduce_let_star_form(_production, aRange, _tokens, theChildren)
262
+ SkmBindingBlock.new(:let_star, theChildren[3], theChildren[5])
263
+ end
259
264
 
260
265
  # rule('quasiquotation' => 'LPAREN QUASIQUOTE qq_template RPAREN').as 'quasiquotation'
261
266
  def reduce_quasiquotation(_production, aRange, _tokens, theChildren)
@@ -125,14 +125,19 @@ module Skeem
125
125
  end
126
126
 
127
127
  def evaluate(aRuntime)
128
+ aRuntime.push(SkmFrame.new(aRuntime.environment))
128
129
  if kind == :let
129
- aRuntime.push(SkmFrame.new(aRuntime.environment))
130
130
  locals = bindings.map do |bnd|
131
131
  SkmBinding.new(bnd.variable, bnd.value.evaluate(aRuntime))
132
132
  end
133
133
  locals.each do |bnd|
134
134
  aRuntime.add_binding(bnd.variable.evaluate(aRuntime), bnd.value)
135
135
  end
136
+ elsif kind == :let_star
137
+ bindings.each do |bnd|
138
+ val = bnd.value.evaluate(aRuntime)
139
+ aRuntime.add_binding(bnd.variable.evaluate(aRuntime), val)
140
+ end
136
141
  end
137
142
 
138
143
  result = body[:sequence].evaluate(aRuntime)
@@ -36,6 +36,7 @@ module Skeem
36
36
  IF
37
37
  LAMBDA
38
38
  LET
39
+ LET*
39
40
  QUASIQUOTE
40
41
  QUOTE
41
42
  SET!
data/lib/skeem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Skeem
2
- VERSION = '0.2.01'.freeze
2
+ VERSION = '0.2.02'.freeze
3
3
  end
@@ -305,7 +305,7 @@ SKEEM
305
305
  expect(result.last.last.value).to eq(4)
306
306
  end
307
307
  end # context
308
-
308
+
309
309
  context 'Binding constructs:' do
310
310
  it 'should implement local bindings' do
311
311
  source = <<-SKEEM
@@ -316,7 +316,7 @@ SKEEM
316
316
  result = subject.run(source)
317
317
  expect(result).to eq(6)
318
318
  end
319
-
319
+
320
320
  it 'should implement precedence of local bindings' do
321
321
  source = <<-SKEEM
322
322
  (define x 23)
@@ -328,8 +328,8 @@ SKEEM
328
328
  SKEEM
329
329
  result = subject.run(source)
330
330
  expect(result.last).to eq(66)
331
- end
332
-
331
+ end
332
+
333
333
  it 'should support the nesting of local bindings' do
334
334
  source = <<-SKEEM
335
335
  (let ((x 2) (y 3))
@@ -339,7 +339,18 @@ SKEEM
339
339
  SKEEM
340
340
  result = subject.run(source)
341
341
  expect(result).to eq(35)
342
- end
342
+ end
343
+
344
+ it 'should implement let* expression' do
345
+ source = <<-SKEEM
346
+ (let ((x 2) (y 3))
347
+ (let* ((x 7)
348
+ (z (+ x y)))
349
+ (* z x)))
350
+ SKEEM
351
+ result = subject.run(source)
352
+ expect(result).to eq(70)
353
+ end
343
354
  end # context
344
355
 
345
356
  context 'Quasiquotation:' do
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.2.01
4
+ version: 0.2.02
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-19 00:00:00.000000000 Z
11
+ date: 2019-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley