heist 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.
Files changed (76) hide show
  1. data/History.txt +12 -0
  2. data/{README.txt → README.rdoc} +131 -148
  3. data/bin/heist +35 -10
  4. data/lib/heist.rb +3 -3
  5. data/lib/heist/builtin/compiled_library.rb +1 -0
  6. data/lib/heist/builtin/lib/character.scm +74 -0
  7. data/lib/heist/builtin/lib/list.scm +149 -0
  8. data/lib/heist/builtin/lib/logic.scm +17 -0
  9. data/lib/heist/builtin/lib/numeric.scm +184 -0
  10. data/lib/heist/builtin/lib/string.scm +117 -0
  11. data/lib/heist/builtin/lib/util.scm +18 -0
  12. data/lib/heist/builtin/lib/vector.scm +27 -0
  13. data/lib/{builtin → heist/builtin}/primitives.rb +0 -0
  14. data/lib/{builtin → heist/builtin}/syntax.scm +52 -52
  15. data/lib/{parser → heist/parser}/nodes.rb +0 -0
  16. data/lib/{parser → heist/parser}/ruby.rb +0 -0
  17. data/lib/{parser → heist/parser}/scheme.rb +0 -0
  18. data/lib/{parser → heist/parser}/scheme.tt +0 -0
  19. data/lib/{repl.rb → heist/repl.rb} +0 -0
  20. data/lib/{runtime → heist/runtime}/binding.rb +5 -0
  21. data/lib/{runtime → heist/runtime}/callable/continuation.rb +6 -1
  22. data/lib/{runtime → heist/runtime}/callable/function.rb +0 -0
  23. data/lib/{runtime → heist/runtime}/callable/macro.rb +1 -1
  24. data/lib/{runtime → heist/runtime}/callable/macro/expansion.rb +0 -0
  25. data/lib/{runtime → heist/runtime}/callable/macro/matches.rb +0 -0
  26. data/lib/{runtime → heist/runtime}/callable/macro/tree.rb +0 -0
  27. data/lib/{runtime → heist/runtime}/callable/syntax.rb +0 -0
  28. data/lib/{runtime → heist/runtime}/data/character.rb +0 -0
  29. data/lib/{runtime → heist/runtime}/data/cons.rb +0 -0
  30. data/lib/{runtime → heist/runtime}/data/expression.rb +0 -0
  31. data/lib/{runtime → heist/runtime}/data/identifier.rb +0 -0
  32. data/lib/heist/runtime/data/value.rb +14 -0
  33. data/lib/{runtime → heist/runtime}/data/vector.rb +0 -0
  34. data/lib/{runtime → heist/runtime}/frame.rb +3 -0
  35. data/lib/{runtime → heist/runtime}/runtime.rb +2 -2
  36. data/lib/{runtime → heist/runtime}/scope.rb +0 -0
  37. data/lib/{runtime → heist/runtime}/stack.rb +0 -0
  38. data/lib/{runtime → heist/runtime}/stackless.rb +0 -0
  39. data/lib/{stdlib → heist/stdlib}/benchmark.scm +0 -0
  40. data/lib/{stdlib → heist/stdlib}/birdhouse.scm +0 -0
  41. data/lib/{trie.rb → heist/trie.rb} +0 -0
  42. data/spec/heist_spec.rb +88 -0
  43. data/{test → spec}/helpers/lib.scm +0 -0
  44. data/{test → spec}/helpers/macro-helpers.scm +0 -0
  45. data/{test → spec}/helpers/vars.scm +0 -0
  46. data/{test → spec}/plt-macros.txt +0 -0
  47. data/{test → spec}/scheme_tests/arithmetic.scm +0 -0
  48. data/{test → spec}/scheme_tests/benchmarks.scm +0 -0
  49. data/{test → spec}/scheme_tests/booleans.scm +0 -0
  50. data/{test → spec}/scheme_tests/closures.scm +0 -0
  51. data/{test → spec}/scheme_tests/conditionals.scm +0 -0
  52. data/{test → spec}/scheme_tests/continuations.scm +14 -1
  53. data/{test → spec}/scheme_tests/define_functions.scm +0 -0
  54. data/{test → spec}/scheme_tests/define_values.scm +0 -0
  55. data/{test → spec}/scheme_tests/delay.scm +0 -0
  56. data/{test → spec}/scheme_tests/equivalence.scm +0 -0
  57. data/{test → spec}/scheme_tests/file_loading.scm +0 -0
  58. data/{test → spec}/scheme_tests/functional.scm +3 -0
  59. data/{test → spec}/scheme_tests/hygienic.scm +0 -0
  60. data/{test → spec}/scheme_tests/let.scm +0 -0
  61. data/{test → spec}/scheme_tests/lists.scm +0 -0
  62. data/{test → spec}/scheme_tests/macros.scm +0 -0
  63. data/{test → spec}/scheme_tests/numbers.scm +0 -0
  64. data/{test → spec}/scheme_tests/protection.scm +0 -0
  65. data/spec/scheme_tests/quoting.scm +14 -0
  66. data/{test → spec}/scheme_tests/strings.scm +0 -0
  67. data/{test → spec}/scheme_tests/unhygienic.scm +0 -0
  68. data/{test → spec}/scheme_tests/vectors.scm +0 -0
  69. data/spec/spec_helper.rb +4 -0
  70. metadata +98 -113
  71. data/Manifest.txt +0 -64
  72. data/Rakefile +0 -43
  73. data/lib/bin_spec.rb +0 -25
  74. data/lib/builtin/library.rb +0 -1
  75. data/lib/builtin/library.scm +0 -605
  76. data/test/test_heist.rb +0 -148
@@ -19,7 +19,7 @@ module Heist
19
19
  class Runtime
20
20
 
21
21
  %w[ data/expression data/identifier data/character
22
- data/cons data/vector
22
+ data/cons data/vector data/value
23
23
  callable/function callable/syntax callable/macro callable/continuation
24
24
  frame stack stackless
25
25
  scope binding
@@ -33,7 +33,7 @@ module Heist
33
33
 
34
34
  attr_accessor :stack, :top_level, :user_scope
35
35
 
36
- BUILTIN_LIBRARIES = %w[primitives syntax library]
36
+ BUILTIN_LIBRARIES = %w[primitives syntax compiled_library]
37
37
 
38
38
  # A +Runtime+ is initialized using a set of options. The available
39
39
  # options include the following, all of which are +false+ unless
File without changes
File without changes
File without changes
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe Heist do
4
+ let(:options) { {} }
5
+
6
+ before do
7
+ @runtime = Heist::Runtime.new(options)
8
+
9
+ @runtime.define 'assert' do |value|
10
+ value.should be_true
11
+ end
12
+ @runtime.define 'assert-equal' do |expected, actual|
13
+ actual.should == expected
14
+ end
15
+ @runtime.syntax 'assert-raise' do |scope, cells|
16
+ exception = Heist.const_get(cells.car.to_s)
17
+ lambda { scope.eval(cells.cdr.car) }.should raise_error(exception)
18
+ end
19
+ end
20
+
21
+ dir = File.expand_path('../scheme_tests', __FILE__)
22
+
23
+ shared_examples_for "Scheme interpreter" do
24
+
25
+ tests = Dir.entries(dir).grep(/\.scm$/) -
26
+ %w[continuations.scm hygienic.scm unhygienic.scm]
27
+
28
+ tests.each do |test|
29
+ it("runs #{test}") { @runtime.run File.join(dir, test) }
30
+ end
31
+ end
32
+
33
+ shared_examples_for "interpreter with continuations" do
34
+ it "runs continuations.scm" do
35
+ @runtime.run File.join(dir, "continuations.scm")
36
+ end
37
+ end
38
+
39
+ shared_examples_for "interpreter with hygienic macros" do
40
+ it "runs hygienic.scm" do
41
+ @runtime.run File.join(dir, "hygienic.scm")
42
+ end
43
+ end
44
+
45
+ shared_examples_for "interpreter with unhygienic macros" do
46
+ it "runs unhygienic.scm" do
47
+ @runtime.run File.join(dir, "unhygienic.scm")
48
+ end
49
+ end
50
+
51
+ describe "with default options" do
52
+ it_should_behave_like "Scheme interpreter"
53
+ it_should_behave_like "interpreter with hygienic macros"
54
+ end
55
+
56
+ describe "with unhygienic macros" do
57
+ let(:options) { {:unhygienic => true} }
58
+ it_should_behave_like "Scheme interpreter"
59
+ it_should_behave_like "interpreter with unhygienic macros"
60
+
61
+ describe "with continuations" do
62
+ let(:options) { {:unhygienic => true, :continuations => true} }
63
+ it_should_behave_like "Scheme interpreter"
64
+ it_should_behave_like "interpreter with unhygienic macros"
65
+ it_should_behave_like "interpreter with continuations"
66
+ end
67
+
68
+ describe "with laziness" do
69
+ let(:options) { {:unhygienic => true, :lazy => true} }
70
+ it_should_behave_like "Scheme interpreter"
71
+ it_should_behave_like "interpreter with unhygienic macros"
72
+ end
73
+ end
74
+
75
+ describe "with continuations" do
76
+ let(:options) { {:continuations => true} }
77
+ it_should_behave_like "Scheme interpreter"
78
+ it_should_behave_like "interpreter with hygienic macros"
79
+ it_should_behave_like "interpreter with continuations"
80
+ end
81
+
82
+ describe "with laziness" do
83
+ let(:options) { {:lazy => true} }
84
+ it_should_behave_like "Scheme interpreter"
85
+ it_should_behave_like "interpreter with hygienic macros"
86
+ end
87
+ end
88
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -15,7 +15,7 @@
15
15
  ; calling a stored continuation aborts the current stack
16
16
  (define called #f)
17
17
  (begin
18
- (r 5)
18
+ (r (+ 2 3))
19
19
  (set! called #t))
20
20
  (assert (not called))
21
21
 
@@ -36,6 +36,19 @@
36
36
  (r 3)
37
37
  (assert-equal 6 value)
38
38
 
39
+ ; continuations can be called using (apply)
40
+ (apply r '(7))
41
+ (assert-equal 10 value)
42
+
43
+ ; symbols can be passed back to a (set!) call
44
+ (set! value (call/cc
45
+ (lambda (k)
46
+ (set! r k)
47
+ 'foo)))
48
+ (assert-equal 'foo value)
49
+ (r 'bar)
50
+ (assert-equal 'bar value)
51
+
39
52
  ; expressions after the call/cc are re-evaluated
40
53
  (set! y 2)
41
54
  (set! value (+ 1 (call/cc
File without changes
@@ -2,3 +2,6 @@
2
2
  (assert-equal '(1 4 9 16) (map (lambda (x) (* x x)) '(1 2 3 4)))
3
3
  (assert-equal '(5 7 9) (map + '(1 2 3) '(4 5 6)))
4
4
 
5
+ (assert-equal '(1 (2 (3 ()))) (fold-right list '() (list 1 2 3)))
6
+ (assert-equal '(((() 1) 2) 3) (fold-left list '() (list 1 2 3)))
7
+
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ (assert-equal 7 (+ 3 4))
2
+ (assert-equal (list '+ 3 4) '(+ 3 4))
3
+ (assert-equal 7 (+ '3 4))
4
+ (assert-equal (cons 1 8) '(1 . 8))
5
+ (assert-equal (cons 1 8) `(1 . 8))
6
+ (assert-equal (list '+ (list '- 7 9) 4) '(+ (- 7 9) 4))
7
+ (assert-equal (list 7 9 6) `(7 ,(+ 4 5) 6))
8
+ (assert-equal (list 3 7 6 2 6 9) `(3 7 6 ,@((lambda () '(2 6))) 9))
9
+ (assert-equal (list 1 2 10) `(1 2 ,(+ 4 6)))
10
+ (assert-equal (list 3 2 9 8) `(,(/ 9 3) 2 ,@(list 9 8)))
11
+ (assert-equal (list 1 2 4 9 8 5) `(,@(list 1 2) 4 ,@(list 9 8) 5))
12
+ (assert-equal (cons 9 (cons 8 (cons 5 7))) `(,@(list 9 8) 5 . 7))
13
+ (assert-equal (cons 9 (cons 8 24)) `(,@(list 9 8) . ,(* 4 6)))
14
+ (assert-equal (list 'quote (list)) ''())
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require File.expand_path('../../lib/heist', __FILE__)
4
+
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ prerelease:
5
+ version: 0.3.3
5
6
  platform: ruby
6
7
  authors:
7
8
  - James Coglan
@@ -9,162 +10,146 @@ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2010-01-16 00:00:00 +00:00
13
- default_executable:
13
+ date: 2011-10-24 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: oyster
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: treetop
23
+ version: "0.9"
27
24
  type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
34
- version:
25
+ version_requirements: *id001
35
26
  - !ruby/object:Gem::Dependency
36
- name: rubyforge
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
27
+ name: treetop
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
40
31
  requirements:
41
32
  - - ">="
42
33
  - !ruby/object:Gem::Version
43
- version: 2.0.3
44
- version:
34
+ version: "1.2"
35
+ type: :runtime
36
+ version_requirements: *id002
45
37
  - !ruby/object:Gem::Dependency
46
- name: gemcutter
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
50
42
  requirements:
51
43
  - - ">="
52
44
  - !ruby/object:Gem::Version
53
- version: 0.3.0
54
- version:
55
- - !ruby/object:Gem::Dependency
56
- name: hoe
45
+ version: "0"
57
46
  type: :development
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: 2.5.0
64
- version:
65
- description: ""
66
- email:
67
- - jcoglan@googlemail.com
47
+ version_requirements: *id003
48
+ description:
49
+ email: jcoglan@gmail.com
68
50
  executables:
69
51
  - heist
70
52
  extensions: []
71
53
 
72
54
  extra_rdoc_files:
73
- - History.txt
74
- - Manifest.txt
75
- - README.txt
55
+ - README.rdoc
76
56
  files:
77
57
  - History.txt
78
- - Manifest.txt
79
- - Rakefile
80
- - README.txt
58
+ - README.rdoc
81
59
  - bin/heist
82
- - lib/bin_spec.rb
60
+ - lib/heist/trie.rb
61
+ - lib/heist/parser/scheme.tt
62
+ - lib/heist/parser/scheme.rb
63
+ - lib/heist/parser/ruby.rb
64
+ - lib/heist/parser/nodes.rb
65
+ - lib/heist/runtime/scope.rb
66
+ - lib/heist/runtime/binding.rb
67
+ - lib/heist/runtime/data/cons.rb
68
+ - lib/heist/runtime/data/character.rb
69
+ - lib/heist/runtime/data/value.rb
70
+ - lib/heist/runtime/data/expression.rb
71
+ - lib/heist/runtime/data/vector.rb
72
+ - lib/heist/runtime/data/identifier.rb
73
+ - lib/heist/runtime/stackless.rb
74
+ - lib/heist/runtime/callable/syntax.rb
75
+ - lib/heist/runtime/callable/continuation.rb
76
+ - lib/heist/runtime/callable/macro/tree.rb
77
+ - lib/heist/runtime/callable/macro/expansion.rb
78
+ - lib/heist/runtime/callable/macro/matches.rb
79
+ - lib/heist/runtime/callable/function.rb
80
+ - lib/heist/runtime/callable/macro.rb
81
+ - lib/heist/runtime/frame.rb
82
+ - lib/heist/runtime/stack.rb
83
+ - lib/heist/runtime/runtime.rb
84
+ - lib/heist/stdlib/birdhouse.scm
85
+ - lib/heist/stdlib/benchmark.scm
86
+ - lib/heist/builtin/syntax.scm
87
+ - lib/heist/builtin/primitives.rb
88
+ - lib/heist/builtin/lib/character.scm
89
+ - lib/heist/builtin/lib/list.scm
90
+ - lib/heist/builtin/lib/string.scm
91
+ - lib/heist/builtin/lib/util.scm
92
+ - lib/heist/builtin/lib/logic.scm
93
+ - lib/heist/builtin/lib/vector.scm
94
+ - lib/heist/builtin/lib/numeric.scm
95
+ - lib/heist/builtin/compiled_library.rb
96
+ - lib/heist/repl.rb
83
97
  - lib/heist.rb
84
- - lib/repl.rb
85
- - lib/trie.rb
86
- - lib/builtin/library.scm
87
- - lib/builtin/library.rb
88
- - lib/builtin/primitives.rb
89
- - lib/builtin/syntax.scm
90
- - lib/parser/nodes.rb
91
- - lib/parser/ruby.rb
92
- - lib/parser/scheme.rb
93
- - lib/parser/scheme.tt
94
- - lib/runtime/callable/continuation.rb
95
- - lib/runtime/callable/function.rb
96
- - lib/runtime/callable/syntax.rb
97
- - lib/runtime/callable/macro.rb
98
- - lib/runtime/callable/macro/matches.rb
99
- - lib/runtime/callable/macro/tree.rb
100
- - lib/runtime/callable/macro/expansion.rb
101
- - lib/runtime/data/character.rb
102
- - lib/runtime/data/cons.rb
103
- - lib/runtime/data/expression.rb
104
- - lib/runtime/data/identifier.rb
105
- - lib/runtime/data/vector.rb
106
- - lib/runtime/binding.rb
107
- - lib/runtime/frame.rb
108
- - lib/runtime/runtime.rb
109
- - lib/runtime/scope.rb
110
- - lib/runtime/stack.rb
111
- - lib/runtime/stackless.rb
112
- - lib/stdlib/benchmark.scm
113
- - lib/stdlib/birdhouse.scm
114
- - test/helpers/lib.scm
115
- - test/helpers/macro-helpers.scm
116
- - test/helpers/vars.scm
117
- - test/scheme_tests/arithmetic.scm
118
- - test/scheme_tests/benchmarks.scm
119
- - test/scheme_tests/booleans.scm
120
- - test/scheme_tests/closures.scm
121
- - test/scheme_tests/conditionals.scm
122
- - test/scheme_tests/continuations.scm
123
- - test/scheme_tests/define_functions.scm
124
- - test/scheme_tests/define_values.scm
125
- - test/scheme_tests/delay.scm
126
- - test/scheme_tests/equivalence.scm
127
- - test/scheme_tests/file_loading.scm
128
- - test/scheme_tests/functional.scm
129
- - test/scheme_tests/hygienic.scm
130
- - test/scheme_tests/let.scm
131
- - test/scheme_tests/lists.scm
132
- - test/scheme_tests/macros.scm
133
- - test/scheme_tests/numbers.scm
134
- - test/scheme_tests/protection.scm
135
- - test/scheme_tests/strings.scm
136
- - test/scheme_tests/unhygienic.scm
137
- - test/scheme_tests/vectors.scm
138
- - test/plt-macros.txt
139
- - test/test_heist.rb
140
- has_rdoc: true
98
+ - spec/scheme_tests/arithmetic.scm
99
+ - spec/scheme_tests/conditionals.scm
100
+ - spec/scheme_tests/quoting.scm
101
+ - spec/scheme_tests/strings.scm
102
+ - spec/scheme_tests/file_loading.scm
103
+ - spec/scheme_tests/delay.scm
104
+ - spec/scheme_tests/equivalence.scm
105
+ - spec/scheme_tests/unhygienic.scm
106
+ - spec/scheme_tests/macros.scm
107
+ - spec/scheme_tests/booleans.scm
108
+ - spec/scheme_tests/benchmarks.scm
109
+ - spec/scheme_tests/closures.scm
110
+ - spec/scheme_tests/lists.scm
111
+ - spec/scheme_tests/hygienic.scm
112
+ - spec/scheme_tests/define_functions.scm
113
+ - spec/scheme_tests/functional.scm
114
+ - spec/scheme_tests/define_values.scm
115
+ - spec/scheme_tests/vectors.scm
116
+ - spec/scheme_tests/numbers.scm
117
+ - spec/scheme_tests/let.scm
118
+ - spec/scheme_tests/protection.scm
119
+ - spec/scheme_tests/continuations.scm
120
+ - spec/heist_spec.rb
121
+ - spec/plt-macros.txt
122
+ - spec/spec_helper.rb
123
+ - spec/helpers/macro-helpers.scm
124
+ - spec/helpers/vars.scm
125
+ - spec/helpers/lib.scm
141
126
  homepage: http://github.com/jcoglan/heist
142
127
  licenses: []
143
128
 
144
129
  post_install_message:
145
130
  rdoc_options:
146
131
  - --main
147
- - README.txt
132
+ - README.rdoc
148
133
  require_paths:
149
134
  - lib
150
135
  required_ruby_version: !ruby/object:Gem::Requirement
136
+ none: false
151
137
  requirements:
152
138
  - - ">="
153
139
  - !ruby/object:Gem::Version
154
140
  version: "0"
155
- version:
156
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
157
143
  requirements:
158
144
  - - ">="
159
145
  - !ruby/object:Gem::Version
160
146
  version: "0"
161
- version:
162
147
  requirements: []
163
148
 
164
- rubyforge_project: heist
165
- rubygems_version: 1.3.5
149
+ rubyforge_project:
150
+ rubygems_version: 1.8.5
166
151
  signing_key:
167
152
  specification_version: 3
168
- summary: ""
169
- test_files:
170
- - test/test_heist.rb
153
+ summary: Scheme in as little Ruby as possible
154
+ test_files: []
155
+