lisp-interpreter 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: 2e3026ff75a77f9f9f3d0b0a6a82021bd3b08f47
4
- data.tar.gz: da8f9e91a5af019a8a6c564b530bf99534318611
3
+ metadata.gz: '04861fa302be02832ee0c9046fd0cef4fcd26b23'
4
+ data.tar.gz: c9321964af29b7aba0e0cb7b9682d68f79795b68
5
5
  SHA512:
6
- metadata.gz: faa24cfec02e0a84a25af4d3580a2d2965ee1c7a6524bbadab0cb5bfc1aebad8430e78c3ec152b922396445c847c95cfdedd74ef26767eec84fa7a4a09e21507
7
- data.tar.gz: 4e7b97e227764fb61e022eeea697c3cec1d119cf59683a44d5ce4ebe4d9c7eeeb36c720da01cbba35542e6cc1e2d472348d3798e4c88e86a4ce3dac04da79f6c
6
+ metadata.gz: c33ff37553a332339d73ec5120cd56922126f481d8d7aaa3ae1bd68b7919ce542e6e6bc60e57231ac43e9078fe4cd265aaedd0f54b25f5575023508519eef63b
7
+ data.tar.gz: 496f3e3511eb5e7c478c49d3e42b24586a49bb90dd001367fcf7813cc3399cda2c8cc123e47eb84f0cce1f77b44791f806f803f5058aebf454fd3a3b9905679b
@@ -122,7 +122,7 @@ module FunctionalSchemeHelper
122
122
  end
123
123
 
124
124
  def find_params_lambda(other)
125
- raise 'Unbound symbol ' + other.to_s if other[0] != '('
125
+ raise 'Invalid syntax' if other[0] != '('
126
126
  idx = find_bracket_idx other, 0
127
127
  [other[1..idx - 1], other[idx + 1..-1]]
128
128
  end
@@ -130,7 +130,7 @@ module FunctionalSchemeHelper
130
130
  def eval_lambda(other)
131
131
  idx = find_bracket_idx other.unshift('('), 0
132
132
  to_eval = other[1..idx - 1]
133
- (proc_lambda to_eval).call(*other[idx + 1..-1])
133
+ (proc_lambda to_eval, true).call(*other[idx + 1..-1])
134
134
  end
135
135
 
136
136
  def proc_lambda_helper(other, params, args)
@@ -139,9 +139,11 @@ module FunctionalSchemeHelper
139
139
  define_func_helper other.dup, params.dup, args
140
140
  end
141
141
 
142
- def proc_lambda(other)
142
+ def proc_lambda(other, is_call = false)
143
143
  params, other = find_params_lambda other
144
144
  other = fetch_inner_scope other
145
+ valid = params.all? { |t| valid_var_name t } || is_call
146
+ raise 'Invalid syntax' unless valid
145
147
  to_return = other[0..1].join == '(compose' && params.empty?
146
148
  return calc_input_val other if to_return
147
149
  proc = proc do |*args|
@@ -1,5 +1,5 @@
1
1
  module Lisp
2
2
  module Interpreter
3
- VERSION = '0.3.2'.freeze
3
+ VERSION = '0.3.3'.freeze
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'lisp/interpreter'
3
2
 
4
3
  RSpec.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lisp-interpreter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaki Petrov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-04 00:00:00.000000000 Z
11
+ date: 2017-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler