lisp-interpreter 0.1.0 → 0.2.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/Gemfile +1 -1
- data/README.md +2 -2
- data/lib/lisp/interpreter/functional.rb +8 -1
- data/lib/lisp/interpreter/list.rb +2 -0
- data/lib/lisp/interpreter/parser.rb +3 -3
- data/lib/lisp/interpreter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdf872d493fc81d79bca68b298c725f4a4ea0976
|
4
|
+
data.tar.gz: '0196ca2dcc427290d7834ebc083e99f944339b8c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a71d36f48baa147d86a7bacd6eca2b422ec4ad985c0c12b41c0003691accb9e95fbfa711d1be3717a8701f381e681fa0698cf071efc7b31f1062a69c2d5266
|
7
|
+
data.tar.gz: e31700583f19cc9b9e494cdd08f636490e38eb988a3003de2e320ca76caeafc25f12ee838f005cc24a8b7e50cbede92884267f05885cfba09f6fef01f507bd8c
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/zaki1993
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/zaki1993/Ruby-Project/lisp-interpreter" }
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in lisp-interpreter.gemspec
|
6
6
|
gemspec
|
data/README.md
CHANGED
@@ -162,7 +162,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
162
162
|
|
163
163
|
## Contributing
|
164
164
|
|
165
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
165
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/zaki1993/Ruby-Project/lisp-interpreter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
166
166
|
|
167
167
|
## License
|
168
168
|
|
@@ -170,4 +170,4 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
170
170
|
|
171
171
|
## Code of Conduct
|
172
172
|
|
173
|
-
Everyone interacting in the Lisp::Interpreter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
173
|
+
Everyone interacting in the Lisp::Interpreter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/zaki1993/Ruby-Project/lisp-interpreter/blob/master/CODE_OF_CONDUCT.md).
|
@@ -53,10 +53,16 @@ module Optimize
|
|
53
53
|
send func, values
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
56
|
+
def call_compose_helper(other)
|
57
57
|
tmp = ['(', *other[1..-1]]
|
58
58
|
idx = find_bracket_idx tmp, 0
|
59
59
|
funcs = find_all_values tmp[1..idx - 1]
|
60
|
+
raise '' if tmp[idx + 1..-1].empty?
|
61
|
+
[funcs, idx, tmp]
|
62
|
+
end
|
63
|
+
|
64
|
+
def call_compose(other)
|
65
|
+
funcs, idx, tmp = call_compose_helper other
|
60
66
|
value, = find_next_value tmp[idx + 1..-1]
|
61
67
|
funcs.reverse.each do |t|
|
62
68
|
value = calc_input_val ['(', t, value.to_s, ')']
|
@@ -267,6 +273,7 @@ module FunctionalScheme
|
|
267
273
|
end
|
268
274
|
|
269
275
|
def define(other)
|
276
|
+
raise 'Incorrect number of arguments' if other.size < 2
|
270
277
|
fetch_define other
|
271
278
|
end
|
272
279
|
end
|
@@ -148,7 +148,9 @@ module SchemeLists
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def map(other)
|
151
|
+
raise 'Incorrect number of arguments' if other.empty?
|
151
152
|
func, other = valid_function other
|
153
|
+
raise 'Incorrect number of arguments' if other.empty?
|
152
154
|
lst = find_all_values other
|
153
155
|
lst = lst.map { |t| find_list_function_value [t] }
|
154
156
|
lst = (equalize_lists lst).transpose
|
@@ -15,13 +15,13 @@ class Parser
|
|
15
15
|
include Environment
|
16
16
|
|
17
17
|
def initialize(env_type = Environment::TEST)
|
18
|
-
@
|
18
|
+
@env_type = env_type
|
19
19
|
@tokenizer = Tokenizer.new
|
20
20
|
end
|
21
21
|
|
22
22
|
def run
|
23
23
|
loop do
|
24
|
-
print 'zakichan> ' if @
|
24
|
+
print 'zakichan> ' if @env_type == Environment::PROD
|
25
25
|
token = ''
|
26
26
|
until (validate_token token).nil? && token != ''
|
27
27
|
crr_input = STDIN.gets.chomp
|
@@ -66,7 +66,7 @@ class Parser
|
|
66
66
|
def print_result(result)
|
67
67
|
to_remove = result.to_s.list? || result.to_s.pair? || result.to_s.quote?
|
68
68
|
result = result.delete('\'') if to_remove
|
69
|
-
puts result if @
|
69
|
+
puts result if @env_type == Environment::PROD
|
70
70
|
result
|
71
71
|
end
|
72
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lisp-interpreter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zaki Petrov
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.6.12
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Lisp interpreter gem
|