shen-ruby 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +5 -0
  3. data/README.md +8 -12
  4. data/Rakefile +4 -9
  5. data/bin/shen_test_suite.rb +0 -1
  6. data/bin/srrepl +2 -4
  7. data/lib/shen_ruby/shen.rb +98 -0
  8. data/lib/shen_ruby/version.rb +1 -1
  9. data/shen-ruby.gemspec +3 -3
  10. data/shen/README.txt +9 -13
  11. data/shen/release/BSD +24 -0
  12. data/shen/release/klambda/core.kl +157 -0
  13. data/shen/release/klambda/declarations.kl +109 -0
  14. data/shen/release/klambda/load.kl +59 -0
  15. data/shen/release/klambda/macros.kl +91 -0
  16. data/shen/release/klambda/prolog.kl +228 -0
  17. data/shen/release/klambda/reader.kl +198 -0
  18. data/shen/release/klambda/sequent.kl +142 -0
  19. data/shen/release/klambda/sys.kl +253 -0
  20. data/shen/release/klambda/t-star.kl +123 -0
  21. data/shen/release/klambda/toplevel.kl +110 -0
  22. data/shen/release/klambda/track.kl +79 -0
  23. data/shen/release/{k_lambda → klambda}/types.kl +41 -63
  24. data/shen/release/klambda/writer.kl +81 -0
  25. data/shen/release/klambda/yacc.kl +87 -0
  26. data/shen/release/license.pdf +0 -0
  27. data/shen/release/test_programs/Chap13/problems.txt +26 -26
  28. data/shen/release/test_programs/README.shen +52 -52
  29. data/shen/release/test_programs/TinyLispFunctions.txt +15 -15
  30. data/shen/release/test_programs/TinyTypes.shen +55 -55
  31. data/shen/release/test_programs/binary.shen +24 -24
  32. data/shen/release/test_programs/bubble_version_1.shen +28 -28
  33. data/shen/release/test_programs/bubble_version_2.shen +22 -22
  34. data/shen/release/test_programs/calculator.shen +21 -21
  35. data/shen/release/test_programs/cartprod.shen +23 -23
  36. data/shen/release/test_programs/change.shen +25 -25
  37. data/shen/release/test_programs/classes-defaults.shen +94 -94
  38. data/shen/release/test_programs/classes-inheritance.shen +100 -100
  39. data/shen/release/test_programs/classes-typed.shen +74 -74
  40. data/shen/release/test_programs/classes-untyped.shen +46 -46
  41. data/shen/release/test_programs/depth_.shen +14 -14
  42. data/shen/release/test_programs/einstein.shen +34 -34
  43. data/shen/release/test_programs/fruit_machine.shen +46 -46
  44. data/shen/release/test_programs/interpreter.shen +217 -217
  45. data/shen/release/test_programs/metaprog.shen +85 -85
  46. data/shen/release/test_programs/minim.shen +192 -192
  47. data/shen/release/test_programs/mutual.shen +11 -11
  48. data/shen/release/test_programs/n_queens.shen +45 -45
  49. data/shen/release/test_programs/newton_version_1.shen +33 -33
  50. data/shen/release/test_programs/newton_version_2.shen +24 -24
  51. data/shen/release/test_programs/parse.prl +14 -14
  52. data/shen/release/test_programs/parser.shen +51 -51
  53. data/shen/release/test_programs/powerset.shen +10 -10
  54. data/shen/release/test_programs/prime.shen +10 -10
  55. data/shen/release/test_programs/prolog.shen +78 -78
  56. data/shen/release/test_programs/proof_assistant.shen +80 -80
  57. data/shen/release/test_programs/proplog_version_1.shen +25 -25
  58. data/shen/release/test_programs/proplog_version_2.shen +27 -27
  59. data/shen/release/test_programs/qmachine.shen +66 -66
  60. data/shen/release/test_programs/red-black.shen +54 -54
  61. data/shen/release/test_programs/search.shen +55 -55
  62. data/shen/release/test_programs/semantic_net.shen +44 -44
  63. data/shen/release/test_programs/spreadsheet.shen +34 -34
  64. data/shen/release/test_programs/stack.shen +27 -27
  65. data/shen/release/test_programs/streams.shen +20 -20
  66. data/shen/release/test_programs/strings.shen +57 -57
  67. data/shen/release/test_programs/structures-typed.shen +71 -71
  68. data/shen/release/test_programs/structures-untyped.shen +41 -41
  69. data/shen/release/test_programs/tests.shen +232 -232
  70. data/shen/release/test_programs/types.shen +11 -11
  71. data/shen/release/test_programs/whist.shen +239 -239
  72. data/shen/release/test_programs/yacc.shen +132 -132
  73. metadata +21 -35
  74. data/shen/lib/shen_ruby/shen.rb +0 -160
  75. data/shen/license.txt +0 -34
  76. data/shen/release/benchmarks/N_queens.shen +0 -45
  77. data/shen/release/benchmarks/README.shen +0 -14
  78. data/shen/release/benchmarks/benchmarks.shen +0 -52
  79. data/shen/release/benchmarks/bigprog +0 -2173
  80. data/shen/release/benchmarks/einstein.shen +0 -33
  81. data/shen/release/benchmarks/heatwave.gif +0 -0
  82. data/shen/release/benchmarks/interpreter.shen +0 -219
  83. data/shen/release/benchmarks/jnk.shen +0 -194
  84. data/shen/release/benchmarks/picture.jpg +0 -0
  85. data/shen/release/benchmarks/plato.jpg +0 -0
  86. data/shen/release/benchmarks/powerset.shen +0 -10
  87. data/shen/release/benchmarks/prime.shen +0 -10
  88. data/shen/release/benchmarks/short.shen +0 -129
  89. data/shen/release/benchmarks/text.txt +0 -68
  90. data/shen/release/k_lambda/core.kl +0 -181
  91. data/shen/release/k_lambda/declarations.kl +0 -131
  92. data/shen/release/k_lambda/load.kl +0 -84
  93. data/shen/release/k_lambda/macros.kl +0 -112
  94. data/shen/release/k_lambda/prolog.kl +0 -252
  95. data/shen/release/k_lambda/reader.kl +0 -222
  96. data/shen/release/k_lambda/sequent.kl +0 -166
  97. data/shen/release/k_lambda/sys.kl +0 -271
  98. data/shen/release/k_lambda/t-star.kl +0 -139
  99. data/shen/release/k_lambda/toplevel.kl +0 -135
  100. data/shen/release/k_lambda/track.kl +0 -103
  101. data/shen/release/k_lambda/writer.kl +0 -105
  102. data/shen/release/k_lambda/yacc.kl +0 -113
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef53ec1dece12e1268ad947755b50ac7f0dde4b7
4
- data.tar.gz: 1f72b4134912bb154027f240c1ef3fa5f65472ae
3
+ metadata.gz: c897025e3db275868a66f65e39372e41c57e1d44
4
+ data.tar.gz: 9c2ea4c35912d387d5ff47752506869ac5683a26
5
5
  SHA512:
6
- metadata.gz: 5eef86bddefaf28ffa148243ab05c2818bd9fd52365cc7653c5b17d0b7fc5e46acc0e84ce7112bb5333c54584ce4b164db0ac0d42366183e496c4850198d6f3f
7
- data.tar.gz: 86e6189fed2c9860123fdf61728bb1b6e0f58a151911f696fad067a5ec16bdf5773ecc84bdb42ca3a6baa6a6cb5168d34426c16297392ca31a562e584488d2bb
6
+ metadata.gz: ecf05de649b240426c5a5686fe754d1cf2ae358e7e05416f6b90d9843964f48416b568158bc71d6db9ca67b05ee519b4e3b55b8fbb6b15b887c916cb22161b9d
7
+ data.tar.gz: b5b9ad3469a0093011533d3ba4af73fda621de93762584185ca418379d8e8cef8c9245e8028ee75910fc20ad2e8c6bb35f57ad4d22abf56edd5b6662812147d3
data/HISTORY.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # ShenRuby Release History
2
2
 
3
+ ## 0.13.0 - February 3, 2013
4
+ ### Features
5
+ - Upgrade to Shen 17
6
+ - Shen is now BSD-licenesed, making ShenRuby BSD/MIT licenesed
7
+
3
8
  ## 0.12.1 - February 1, 2015
4
9
  ### Breaking Changes
5
10
  - The arity of block arguments to Ruby methods no longer needs to be specified. Now all block arguments are denoted by a `&` followed by the function to pass as the block. Any usages of the old syntax, e.g. `&2`, must be updated to `&`.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # ShenRuby
2
2
  ShenRuby is a Ruby port of the [Shen](http://shenlanguage.org/) programming language. Shen is a modern, functional Lisp that supports pattern matching, currying, and optional static type checking.
3
3
 
4
- ShenRuby supports Shen version 16, which was released in September, 2014.
4
+ ShenRuby supports Shen version 17, which was released in February, 2015.
5
5
 
6
6
  The ShenRuby project has two primary goals. The first is to be a low barrier-to-entry means for Rubyists to explore Shen. To someone with a working installation of Ruby 1.9.3 or greater, a Shen REPL is only a gem install away.
7
7
 
@@ -14,7 +14,7 @@ ShenRuby 0.1.0 began to satisfy the first goal by providing a Shen REPL accessib
14
14
  ## Installation
15
15
  NOTE: ShenRuby requires Ruby 1.9 language features. It is tested with Ruby 2.0.0, 2.1.5, and 2.2.0. It has been lightly tested with JRuby 1.7.17. It is functional with Ruby 1.9.3, however its fixed stack size prevents it from passing the Shen Test Suite (see [Setting Stack Size](setting-stack-size) below).
16
16
 
17
- ShenRuby 0.12.1 is the current release. To install it as a gem, use the following command:
17
+ ShenRuby 0.13.0 is the current release. To install it as a gem, use the following command:
18
18
 
19
19
  gem install shen-ruby
20
20
 
@@ -22,14 +22,12 @@ ShenRuby 0.12.1 is the current release. To install it as a gem, use the followin
22
22
 
23
23
  Once the gem has been installed, the Shen REPL can be launched via the `srrepl` (short for ShenRuby REPL) command. For example:
24
24
 
25
- % srrepl
26
- Loading.... Completed in 2.62 seconds.
25
+ Loading.... Completed in 2.60 seconds.
27
26
 
28
- Shen 2010, copyright (C) 2010 Mark Tarver
29
- released under the Shen license
30
- www.shenlanguage.org, version 16
27
+ Shen, copyright (C) 2010-2015 Mark Tarver
28
+ www.shenlanguage.org, Shen 17
31
29
  running under Ruby, implementation: ruby 2.2.0
32
- port 0.12.1 ported by Greg Spurrier
30
+ port 0.13.0 ported by Greg Spurrier
33
31
 
34
32
 
35
33
  (0-)
@@ -222,8 +220,6 @@ The following people are gratefully acknowledged for their contributions to Shen
222
220
  - Bruno Deferrari
223
221
 
224
222
  ## License
225
- Shen and ShenRuby are released under the Shen License. A copy of the Shen License may be found in [shen/license.txt](https://github.com/gregspurrier/shen-ruby/blob/master/shen/license.txt). A detailed description of the license, along with questions and answers, may be found at http://shenlanguage.org/license.html. In particular, please note that any forks or derivatives of ShenRuby must maintain conformance with the Official Shen Specification.
223
+ The implementation of Shen, which is found in the [shen](https://github.com/gregspurrier/shen-ruby/tree/master/shen) directory, is Copyright (c) 2010-2015 Mark Tarver and released under the BSD license. A copy of the license may be found in [shen/release/BSD](https://github.com/gregspurrier/shen-ruby/tree/master/shen/release/BSD).
226
224
 
227
- The implementation of Shen, which is found in the [shen/release](https://github.com/gregspurrier/shen-ruby/tree/master/shen) directory, is Copyright (c) 2010-2014 Mark Tarver and may only be used in accordance with the Shen License.
228
-
229
- The remainder of the code for ShenRuby is Copyright(c) 2012-2015 Greg Spurrier. It may be used outside of the context of ShenRuby under the terms of the MIT License. A copy of the MIT License may be found in [MIT_LICENSE.txt](https://github.com/gregspurrier/shen-ruby/blob/master/MIT_LICENSE.txt).
225
+ The remainder of ShenRuby is Copyright(c) 2012-2015 Greg Spurrier and released under the MIT license. A copy of the license may be found in [MIT_LICENSE.txt](https://github.com/gregspurrier/shen-ruby/blob/master/MIT_LICENSE.txt).
data/Rakefile CHANGED
@@ -14,10 +14,10 @@ SHEN_ZIP = File.join(IMPORT_DIR, 'Shen.zip')
14
14
  namespace :shen do
15
15
  namespace :import do
16
16
  task :release => [:remove_old_release, :import_dirs, :cleanup]
17
- task :import_dirs => [:k_lambda, :test_programs, :benchmarks]
17
+ task :import_dirs => [:k_lambda, :test_programs]
18
18
 
19
19
  task :remove_old_release do
20
- rm_rf IMPORT_DIR
20
+ #rm_rf IMPORT_DIR
21
21
  rm_rf RELEASE_DIR
22
22
  end
23
23
 
@@ -33,7 +33,7 @@ namespace :shen do
33
33
  end
34
34
 
35
35
  task :unzip => SHEN_ZIP do
36
- sh "(cd #{IMPORT_DIR}; unzip Shen.zip)"
36
+ #sh "(cd #{IMPORT_DIR}; unzip Shen.zip)"
37
37
  end
38
38
 
39
39
  def dst_path(src_root, src_path, dst_root)
@@ -68,17 +68,12 @@ namespace :shen do
68
68
  end
69
69
 
70
70
  task :k_lambda => [:unzip, RELEASE_DIR] do
71
- import_dir('K Lambda')
71
+ import_dir('KLambda')
72
72
  end
73
73
 
74
74
  task :test_programs => [:unzip, RELEASE_DIR] do
75
75
  import_dir('Test Programs')
76
76
  fix_load_paths(File.join(RELEASE_DIR, 'test_programs/tests.shen'))
77
77
  end
78
-
79
- task :benchmarks => [:unzip, RELEASE_DIR] do
80
- import_dir('Benchmarks')
81
- fix_load_paths(File.join(RELEASE_DIR, 'benchmarks/benchmarks.shen'))
82
- end
83
78
  end
84
79
  end
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH << File.expand_path('../../lib', __FILE__)
3
- $LOAD_PATH << File.expand_path('../../shen/lib', __FILE__)
4
3
  require 'shen_ruby'
5
4
 
6
5
  shen = ShenRuby::Shen.new
data/bin/srrepl CHANGED
@@ -1,9 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  root = File.expand_path('../..', __FILE__)
3
- %w(lib shen/lib).each do |path|
4
- full_path = File.join(root, path)
5
- $LOAD_PATH << full_path unless $LOAD_PATH.include? full_path
6
- end
3
+ lib_path = File.join(root, 'lib')
4
+ $LOAD_PATH << lib_path unless $LOAD_PATH.include? lib_path
7
5
  require 'shen_ruby'
8
6
 
9
7
  # Leave gracefully if someone hits Control-C during loading
@@ -0,0 +1,98 @@
1
+ module ShenRuby
2
+ # Instances of the ShenRuby::Shen class provide a Shen environment
3
+ # running within a Klam environment. This class is essentially a loader
4
+ # Shen's KLambda sources and the ShenRuby extensions.
5
+ class Shen < Klam::Environment
6
+ def initialize
7
+ super
8
+
9
+ # Set the global variables
10
+ set("*language*".to_sym, "Ruby")
11
+ set("*implementation*".to_sym, "#{::RUBY_ENGINE} #{::RUBY_VERSION}")
12
+ set("*release*".to_sym, ::RUBY_VERSION)
13
+ set("*port*".to_sym, ::ShenRuby::VERSION)
14
+ set("*porters*".to_sym, "Greg Spurrier")
15
+ set("*home-directory*".to_sym, ::Dir.pwd)
16
+ set("*stinput*".to_sym, ::STDIN)
17
+ set("*stoutput*".to_sym, ::STDOUT)
18
+
19
+ # Load the K Lambda files
20
+ kl_root = ::File.expand_path('../../../shen/release/klambda', __FILE__)
21
+ %w(toplevel core sys).each do |kl_filename|
22
+ ::ShenRuby::Shen.load_file(self, ::File.join(kl_root, kl_filename + ".kl"))
23
+ end
24
+
25
+ # Overrides
26
+ class << self
27
+ # Give a way to bail out
28
+ def quit
29
+ ::Kernel.exit(0)
30
+ end
31
+
32
+ # Add a way to evaluate strings, intended for use with Ruby interop.
33
+ # Returns the result of the last expression evaluated.
34
+ def eval_string(s)
35
+ forms = __send__(:"read-from-string", s)
36
+ result = nil
37
+ while forms
38
+ result = eval(head(forms))
39
+ forms = tail(forms)
40
+ end
41
+ result
42
+ end
43
+ alias_method :"eval-string", :eval_string
44
+
45
+ # The performance of `element?` is critical
46
+ def element?(x, l)
47
+ while l
48
+ return true if l.hd == x
49
+ l = l.tl
50
+ end
51
+ return false
52
+ rescue => e
53
+ __send(:"shen.sys-error", :element?)
54
+ end
55
+
56
+ def vector(n)
57
+ v = ::Klam::Absvector.new(n + 1, :"shen.fail!")
58
+ v[0] = n
59
+ v
60
+ end
61
+ end
62
+
63
+ # Load the rest of the K Lambda files
64
+ %w(sequent yacc
65
+ reader prolog track load writer
66
+ macros declarations types t-star
67
+ ).each do |kl_filename|
68
+ ::ShenRuby::Shen.load_file(self, ::File.join(kl_root, kl_filename + ".kl"))
69
+ end
70
+
71
+ # Give type signatures to the new functions added above
72
+ declare :quit, cons(:"-->", cons(:unit, nil))
73
+ declare :eval_string, cons(:string, cons(:"-->", cons(:unit, nil)))
74
+ declare :"eval-string", cons(:string, cons(:"-->", cons(:unit, nil)))
75
+
76
+ systemf :"rb-const"
77
+ systemf :"rb-send"
78
+ systemf :"rb-send-block"
79
+
80
+ old_hush = value(:"*hush*")
81
+ set :"*hush*", true
82
+ load ::File.expand_path('../rb.shen', __FILE__)
83
+ load ::File.expand_path('../shen_ruby.shen', __FILE__)
84
+ set :"*hush*", old_hush
85
+ end
86
+
87
+ class << self
88
+ def load_file(env, path)
89
+ ::File.open(path, 'r') do |file|
90
+ reader = ::Klam::Reader.new(file)
91
+ while form = reader.next
92
+ env.__send__(:"eval-kl", form)
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -1,3 +1,3 @@
1
1
  module ShenRuby
2
- VERSION = "0.12.1"
2
+ VERSION = "0.13.0"
3
3
  end
data/shen-ruby.gemspec CHANGED
@@ -7,12 +7,12 @@ Gem::Specification.new do |s|
7
7
  s.name = "shen-ruby"
8
8
  s.version = ShenRuby::VERSION
9
9
  s.platform = Gem::Platform::RUBY
10
- s.license = "Shen License"
10
+ s.license = "BSD/MIT"
11
11
  s.authors = ["Greg Spurrier", "Mark Tarver"]
12
12
  s.email = ["greg@sourcematters.org"]
13
13
  s.homepage = "https://github.com/gregspurrier/shen-ruby"
14
14
  s.summary = %q{ShenRuby is a Ruby port of the Shen programming language}
15
- s.description = %q{ShenRuby is a port of the Shen programming language to Ruby. It currently supports Shen version 16.}
15
+ s.description = %q{ShenRuby is a port of the Shen programming language to Ruby. It currently supports Shen version 17.}
16
16
 
17
17
  s.required_ruby_version = ">= 1.9.3"
18
18
 
@@ -25,5 +25,5 @@ Gem::Specification.new do |s|
25
25
  s.files = git_files
26
26
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
27
  s.executables = %w(srrepl)
28
- s.require_paths = ["lib", "shen/lib"]
28
+ s.require_paths = ["lib"]
29
29
  end
data/shen/README.txt CHANGED
@@ -1,17 +1,13 @@
1
- The files found in this directory and its subdirectories are part of
2
- Shen and are subject to the Shen License. A copy of the license may be
3
- found in license.txt in this directory. A detailed explanation of the
4
- license may be found at http://shenlanguage.org/license.html.
1
+ The files found under this directory are extracted directly from the
2
+ Shen source code distribution, the most recent version of which is
3
+ available at http://www.shenlanguage.org/Download/Shen.zip.
4
+
5
+ With the exception of README.txt, all of the files are Copyright (c)
6
+ 2010-2015 Mark Tarver and released under the BSD license. Please see
7
+ release/BSD and release/license.pdf for details.
5
8
 
6
9
  Directory contents:
7
10
 
8
11
  README.txt -- this file
9
- license.txt -- the Shen license
10
- release/ -- files extracted directly from the Shen 14 Source
11
- release. The complete source for the most recent
12
- release of Shen may be downloaded from
13
- http://www.shenlanguage.org/Download/index.htm
14
- lib/ -- Ruby code that creates a full Shen environment running
15
- under ShenRuby's implementation of K Lambda. This code
16
- is considered a derivative work of the original Shen
17
- Source release.
12
+ release/ -- files extracted directly from the Shen Source
13
+ release.
data/shen/release/BSD ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2010-2015, Mark Tarver
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ 3. The name of Mark Tarver may not be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY Mark Tarver ''AS IS'' AND ANY
16
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL Mark Tarver BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,157 @@
1
+ "Copyright (c) 2015, Mark Tarver
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ 3. The name of Mark Tarver may not be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY Mark Tarver ''AS IS'' AND ANY
16
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL Mark Tarver BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
25
+
26
+ (defun shen.shen->kl (V551 V552) (compile shen.<define> (cons V551 V552) (lambda X (shen.shen-syntax-error V551 X))))
27
+
28
+ (defun shen.shen-syntax-error (V553 V554) (simple-error (cn "syntax error in " (shen.app V553 (cn " here:
29
+
30
+ " (shen.app (shen.next-50 50 V554) "
31
+ " shen.a)) shen.a))))
32
+
33
+ (defun shen.<define> (V555) (let YaccParse (let Parse_shen.<name> (shen.<name> V555) (if (not (= (fail) Parse_shen.<name>)) (let Parse_shen.<signature> (shen.<signature> Parse_shen.<name>) (if (not (= (fail) Parse_shen.<signature>)) (let Parse_shen.<rules> (shen.<rules> Parse_shen.<signature>) (if (not (= (fail) Parse_shen.<rules>)) (shen.pair (hd Parse_shen.<rules>) (shen.compile_to_machine_code (shen.hdtl Parse_shen.<name>) (shen.hdtl Parse_shen.<rules>))) (fail))) (fail))) (fail))) (if (= YaccParse (fail)) (let Parse_shen.<name> (shen.<name> V555) (if (not (= (fail) Parse_shen.<name>)) (let Parse_shen.<rules> (shen.<rules> Parse_shen.<name>) (if (not (= (fail) Parse_shen.<rules>)) (shen.pair (hd Parse_shen.<rules>) (shen.compile_to_machine_code (shen.hdtl Parse_shen.<name>) (shen.hdtl Parse_shen.<rules>))) (fail))) (fail))) YaccParse)))
34
+
35
+ (defun shen.<name> (V556) (if (cons? (hd V556)) (let Parse_X (hd (hd V556)) (shen.pair (hd (shen.pair (tl (hd V556)) (shen.hdtl V556))) (if (and (symbol? Parse_X) (not (shen.sysfunc? Parse_X))) Parse_X (simple-error (shen.app Parse_X " is not a legitimate function name.
36
+ " shen.a))))) (fail)))
37
+
38
+ (defun shen.sysfunc? (V557) (element? V557 (get (intern "shen") shen.external-symbols (value *property-vector*))))
39
+
40
+ (defun shen.<signature> (V558) (if (and (cons? (hd V558)) (= { (hd (hd V558)))) (let Parse_shen.<signature-help> (shen.<signature-help> (shen.pair (tl (hd V558)) (shen.hdtl V558))) (if (not (= (fail) Parse_shen.<signature-help>)) (if (and (cons? (hd Parse_shen.<signature-help>)) (= } (hd (hd Parse_shen.<signature-help>)))) (shen.pair (hd (shen.pair (tl (hd Parse_shen.<signature-help>)) (shen.hdtl Parse_shen.<signature-help>))) (shen.demodulate (shen.curry-type (shen.hdtl Parse_shen.<signature-help>)))) (fail)) (fail))) (fail)))
41
+
42
+ (defun shen.curry-type (V559) (cond ((and (cons? V559) (and (cons? (tl V559)) (and (= --> (hd (tl V559))) (and (cons? (tl (tl V559))) (and (cons? (tl (tl (tl V559)))) (= --> (hd (tl (tl (tl V559)))))))))) (shen.curry-type (cons (hd V559) (cons --> (cons (tl (tl V559)) ()))))) ((and (cons? V559) (and (cons? (tl V559)) (and (= * (hd (tl V559))) (and (cons? (tl (tl V559))) (and (cons? (tl (tl (tl V559)))) (= * (hd (tl (tl (tl V559)))))))))) (shen.curry-type (cons (hd V559) (cons * (cons (tl (tl V559)) ()))))) ((cons? V559) (map shen.curry-type V559)) (true V559)))
43
+
44
+ (defun shen.<signature-help> (V560) (let YaccParse (if (cons? (hd V560)) (let Parse_X (hd (hd V560)) (let Parse_shen.<signature-help> (shen.<signature-help> (shen.pair (tl (hd V560)) (shen.hdtl V560))) (if (not (= (fail) Parse_shen.<signature-help>)) (if (not (element? Parse_X (cons { (cons } ())))) (shen.pair (hd Parse_shen.<signature-help>) (cons Parse_X (shen.hdtl Parse_shen.<signature-help>))) (fail)) (fail)))) (fail)) (if (= YaccParse (fail)) (let Parse_<e> (<e> V560) (if (not (= (fail) Parse_<e>)) (shen.pair (hd Parse_<e>) ()) (fail))) YaccParse)))
45
+
46
+ (defun shen.<rules> (V561) (let YaccParse (let Parse_shen.<rule> (shen.<rule> V561) (if (not (= (fail) Parse_shen.<rule>)) (let Parse_shen.<rules> (shen.<rules> Parse_shen.<rule>) (if (not (= (fail) Parse_shen.<rules>)) (shen.pair (hd Parse_shen.<rules>) (cons (shen.linearise (shen.hdtl Parse_shen.<rule>)) (shen.hdtl Parse_shen.<rules>))) (fail))) (fail))) (if (= YaccParse (fail)) (let Parse_shen.<rule> (shen.<rule> V561) (if (not (= (fail) Parse_shen.<rule>)) (shen.pair (hd Parse_shen.<rule>) (cons (shen.linearise (shen.hdtl Parse_shen.<rule>)) ())) (fail))) YaccParse)))
47
+
48
+ (defun shen.<rule> (V562) (let YaccParse (let Parse_shen.<patterns> (shen.<patterns> V562) (if (not (= (fail) Parse_shen.<patterns>)) (if (and (cons? (hd Parse_shen.<patterns>)) (= -> (hd (hd Parse_shen.<patterns>)))) (let Parse_shen.<action> (shen.<action> (shen.pair (tl (hd Parse_shen.<patterns>)) (shen.hdtl Parse_shen.<patterns>))) (if (not (= (fail) Parse_shen.<action>)) (if (and (cons? (hd Parse_shen.<action>)) (= where (hd (hd Parse_shen.<action>)))) (let Parse_shen.<guard> (shen.<guard> (shen.pair (tl (hd Parse_shen.<action>)) (shen.hdtl Parse_shen.<action>))) (if (not (= (fail) Parse_shen.<guard>)) (shen.pair (hd Parse_shen.<guard>) (cons (shen.hdtl Parse_shen.<patterns>) (cons (cons where (cons (shen.hdtl Parse_shen.<guard>) (cons (shen.hdtl Parse_shen.<action>) ()))) ()))) (fail))) (fail)) (fail))) (fail)) (fail))) (if (= YaccParse (fail)) (let YaccParse (let Parse_shen.<patterns> (shen.<patterns> V562) (if (not (= (fail) Parse_shen.<patterns>)) (if (and (cons? (hd Parse_shen.<patterns>)) (= -> (hd (hd Parse_shen.<patterns>)))) (let Parse_shen.<action> (shen.<action> (shen.pair (tl (hd Parse_shen.<patterns>)) (shen.hdtl Parse_shen.<patterns>))) (if (not (= (fail) Parse_shen.<action>)) (shen.pair (hd Parse_shen.<action>) (cons (shen.hdtl Parse_shen.<patterns>) (cons (shen.hdtl Parse_shen.<action>) ()))) (fail))) (fail)) (fail))) (if (= YaccParse (fail)) (let YaccParse (let Parse_shen.<patterns> (shen.<patterns> V562) (if (not (= (fail) Parse_shen.<patterns>)) (if (and (cons? (hd Parse_shen.<patterns>)) (= <- (hd (hd Parse_shen.<patterns>)))) (let Parse_shen.<action> (shen.<action> (shen.pair (tl (hd Parse_shen.<patterns>)) (shen.hdtl Parse_shen.<patterns>))) (if (not (= (fail) Parse_shen.<action>)) (if (and (cons? (hd Parse_shen.<action>)) (= where (hd (hd Parse_shen.<action>)))) (let Parse_shen.<guard> (shen.<guard> (shen.pair (tl (hd Parse_shen.<action>)) (shen.hdtl Parse_shen.<action>))) (if (not (= (fail) Parse_shen.<guard>)) (shen.pair (hd Parse_shen.<guard>) (cons (shen.hdtl Parse_shen.<patterns>) (cons (cons where (cons (shen.hdtl Parse_shen.<guard>) (cons (cons shen.choicepoint! (cons (shen.hdtl Parse_shen.<action>) ())) ()))) ()))) (fail))) (fail)) (fail))) (fail)) (fail))) (if (= YaccParse (fail)) (let Parse_shen.<patterns> (shen.<patterns> V562) (if (not (= (fail) Parse_shen.<patterns>)) (if (and (cons? (hd Parse_shen.<patterns>)) (= <- (hd (hd Parse_shen.<patterns>)))) (let Parse_shen.<action> (shen.<action> (shen.pair (tl (hd Parse_shen.<patterns>)) (shen.hdtl Parse_shen.<patterns>))) (if (not (= (fail) Parse_shen.<action>)) (shen.pair (hd Parse_shen.<action>) (cons (shen.hdtl Parse_shen.<patterns>) (cons (cons shen.choicepoint! (cons (shen.hdtl Parse_shen.<action>) ())) ()))) (fail))) (fail)) (fail))) YaccParse)) YaccParse)) YaccParse)))
49
+
50
+ (defun shen.fail_if (V563 V564) (if (V563 V564) (fail) V564))
51
+
52
+ (defun shen.succeeds? (V569) (cond ((= V569 (fail)) false) (true true)))
53
+
54
+ (defun shen.<patterns> (V570) (let YaccParse (let Parse_shen.<pattern> (shen.<pattern> V570) (if (not (= (fail) Parse_shen.<pattern>)) (let Parse_shen.<patterns> (shen.<patterns> Parse_shen.<pattern>) (if (not (= (fail) Parse_shen.<patterns>)) (shen.pair (hd Parse_shen.<patterns>) (cons (shen.hdtl Parse_shen.<pattern>) (shen.hdtl Parse_shen.<patterns>))) (fail))) (fail))) (if (= YaccParse (fail)) (let Parse_<e> (<e> V570) (if (not (= (fail) Parse_<e>)) (shen.pair (hd Parse_<e>) ()) (fail))) YaccParse)))
55
+
56
+ (defun shen.<pattern> (V576) (let YaccParse (if (and (cons? (hd V576)) (cons? (hd (hd V576)))) (if (and (cons? (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (= @p (hd (hd (shen.pair (hd (hd V576)) (hd (tl V576))))))) (let Parse_shen.<pattern1> (shen.<pattern1> (shen.pair (tl (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (shen.hdtl (shen.pair (hd (hd V576)) (hd (tl V576)))))) (if (not (= (fail) Parse_shen.<pattern1>)) (let Parse_shen.<pattern2> (shen.<pattern2> Parse_shen.<pattern1>) (if (not (= (fail) Parse_shen.<pattern2>)) (shen.pair (hd (shen.pair (tl (hd V576)) (hd (tl V576)))) (cons @p (cons (shen.hdtl Parse_shen.<pattern1>) (cons (shen.hdtl Parse_shen.<pattern2>) ())))) (fail))) (fail))) (fail)) (fail)) (if (= YaccParse (fail)) (let YaccParse (if (and (cons? (hd V576)) (cons? (hd (hd V576)))) (if (and (cons? (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (= cons (hd (hd (shen.pair (hd (hd V576)) (hd (tl V576))))))) (let Parse_shen.<pattern1> (shen.<pattern1> (shen.pair (tl (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (shen.hdtl (shen.pair (hd (hd V576)) (hd (tl V576)))))) (if (not (= (fail) Parse_shen.<pattern1>)) (let Parse_shen.<pattern2> (shen.<pattern2> Parse_shen.<pattern1>) (if (not (= (fail) Parse_shen.<pattern2>)) (shen.pair (hd (shen.pair (tl (hd V576)) (hd (tl V576)))) (cons cons (cons (shen.hdtl Parse_shen.<pattern1>) (cons (shen.hdtl Parse_shen.<pattern2>) ())))) (fail))) (fail))) (fail)) (fail)) (if (= YaccParse (fail)) (let YaccParse (if (and (cons? (hd V576)) (cons? (hd (hd V576)))) (if (and (cons? (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (= @v (hd (hd (shen.pair (hd (hd V576)) (hd (tl V576))))))) (let Parse_shen.<pattern1> (shen.<pattern1> (shen.pair (tl (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (shen.hdtl (shen.pair (hd (hd V576)) (hd (tl V576)))))) (if (not (= (fail) Parse_shen.<pattern1>)) (let Parse_shen.<pattern2> (shen.<pattern2> Parse_shen.<pattern1>) (if (not (= (fail) Parse_shen.<pattern2>)) (shen.pair (hd (shen.pair (tl (hd V576)) (hd (tl V576)))) (cons @v (cons (shen.hdtl Parse_shen.<pattern1>) (cons (shen.hdtl Parse_shen.<pattern2>) ())))) (fail))) (fail))) (fail)) (fail)) (if (= YaccParse (fail)) (let YaccParse (if (and (cons? (hd V576)) (cons? (hd (hd V576)))) (if (and (cons? (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (= @s (hd (hd (shen.pair (hd (hd V576)) (hd (tl V576))))))) (let Parse_shen.<pattern1> (shen.<pattern1> (shen.pair (tl (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (shen.hdtl (shen.pair (hd (hd V576)) (hd (tl V576)))))) (if (not (= (fail) Parse_shen.<pattern1>)) (let Parse_shen.<pattern2> (shen.<pattern2> Parse_shen.<pattern1>) (if (not (= (fail) Parse_shen.<pattern2>)) (shen.pair (hd (shen.pair (tl (hd V576)) (hd (tl V576)))) (cons @s (cons (shen.hdtl Parse_shen.<pattern1>) (cons (shen.hdtl Parse_shen.<pattern2>) ())))) (fail))) (fail))) (fail)) (fail)) (if (= YaccParse (fail)) (let YaccParse (if (and (cons? (hd V576)) (cons? (hd (hd V576)))) (if (and (cons? (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (= vector (hd (hd (shen.pair (hd (hd V576)) (hd (tl V576))))))) (if (and (cons? (hd (shen.pair (tl (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (shen.hdtl (shen.pair (hd (hd V576)) (hd (tl V576))))))) (= 0 (hd (hd (shen.pair (tl (hd (shen.pair (hd (hd V576)) (hd (tl V576))))) (shen.hdtl (shen.pair (hd (hd V576)) (hd (tl V576))))))))) (shen.pair (hd (shen.pair (tl (hd V576)) (hd (tl V576)))) (cons vector (cons 0 ()))) (fail)) (fail)) (fail)) (if (= YaccParse (fail)) (let YaccParse (if (cons? (hd V576)) (let Parse_X (hd (hd V576)) (if (cons? Parse_X) (shen.pair (hd (shen.pair (tl (hd V576)) (shen.hdtl V576))) (shen.constructor-error Parse_X)) (fail))) (fail)) (if (= YaccParse (fail)) (let Parse_shen.<simple_pattern> (shen.<simple_pattern> V576) (if (not (= (fail) Parse_shen.<simple_pattern>)) (shen.pair (hd Parse_shen.<simple_pattern>) (shen.hdtl Parse_shen.<simple_pattern>)) (fail))) YaccParse)) YaccParse)) YaccParse)) YaccParse)) YaccParse)) YaccParse)))
57
+
58
+ (defun shen.constructor-error (V577) (simple-error (shen.app V577 " is not a legitimate constructor
59
+ " shen.a)))
60
+
61
+ (defun shen.<simple_pattern> (V578) (let YaccParse (if (cons? (hd V578)) (let Parse_X (hd (hd V578)) (if (= Parse_X _) (shen.pair (hd (shen.pair (tl (hd V578)) (shen.hdtl V578))) (gensym Parse_Y)) (fail))) (fail)) (if (= YaccParse (fail)) (if (cons? (hd V578)) (let Parse_X (hd (hd V578)) (if (not (element? Parse_X (cons -> (cons <- ())))) (shen.pair (hd (shen.pair (tl (hd V578)) (shen.hdtl V578))) Parse_X) (fail))) (fail)) YaccParse)))
62
+
63
+ (defun shen.<pattern1> (V579) (let Parse_shen.<pattern> (shen.<pattern> V579) (if (not (= (fail) Parse_shen.<pattern>)) (shen.pair (hd Parse_shen.<pattern>) (shen.hdtl Parse_shen.<pattern>)) (fail))))
64
+
65
+ (defun shen.<pattern2> (V580) (let Parse_shen.<pattern> (shen.<pattern> V580) (if (not (= (fail) Parse_shen.<pattern>)) (shen.pair (hd Parse_shen.<pattern>) (shen.hdtl Parse_shen.<pattern>)) (fail))))
66
+
67
+ (defun shen.<action> (V581) (if (cons? (hd V581)) (let Parse_X (hd (hd V581)) (shen.pair (hd (shen.pair (tl (hd V581)) (shen.hdtl V581))) Parse_X)) (fail)))
68
+
69
+ (defun shen.<guard> (V582) (if (cons? (hd V582)) (let Parse_X (hd (hd V582)) (shen.pair (hd (shen.pair (tl (hd V582)) (shen.hdtl V582))) Parse_X)) (fail)))
70
+
71
+ (defun shen.compile_to_machine_code (V583 V584) (let Lambda+ (shen.compile_to_lambda+ V583 V584) (let KL (shen.compile_to_kl V583 Lambda+) (let Record (shen.record-source V583 KL) KL))))
72
+
73
+ (defun shen.record-source (V587 V588) (cond ((value shen.*installing-kl*) shen.skip) (true (put V587 shen.source V588 (value *property-vector*)))))
74
+
75
+ (defun shen.compile_to_lambda+ (V589 V590) (let Arity (shen.aritycheck V589 V590) (let Free (map (lambda Rule (shen.free_variable_check V589 Rule)) V590) (let Variables (shen.parameters Arity) (let Strip (map shen.strip-protect V590) (let Abstractions (map shen.abstract_rule Strip) (let Applications (map (lambda X (shen.application_build Variables X)) Abstractions) (cons Variables (cons Applications ())))))))))
76
+
77
+ (defun shen.free_variable_check (V591 V592) (cond ((and (cons? V592) (and (cons? (tl V592)) (= () (tl (tl V592))))) (let Bound (shen.extract_vars (hd V592)) (let Free (shen.extract_free_vars Bound (hd (tl V592))) (shen.free_variable_warnings V591 Free)))) (true (shen.f_error shen.free_variable_check))))
78
+
79
+ (defun shen.extract_vars (V593) (cond ((variable? V593) (cons V593 ())) ((cons? V593) (union (shen.extract_vars (hd V593)) (shen.extract_vars (tl V593)))) (true ())))
80
+
81
+ (defun shen.extract_free_vars (V603 V604) (cond ((and (cons? V604) (and (cons? (tl V604)) (and (= () (tl (tl V604))) (= (hd V604) protect)))) ()) ((and (variable? V604) (not (element? V604 V603))) (cons V604 ())) ((and (cons? V604) (and (= lambda (hd V604)) (and (cons? (tl V604)) (and (cons? (tl (tl V604))) (= () (tl (tl (tl V604)))))))) (shen.extract_free_vars (cons (hd (tl V604)) V603) (hd (tl (tl V604))))) ((and (cons? V604) (and (= let (hd V604)) (and (cons? (tl V604)) (and (cons? (tl (tl V604))) (and (cons? (tl (tl (tl V604)))) (= () (tl (tl (tl (tl V604)))))))))) (union (shen.extract_free_vars V603 (hd (tl (tl V604)))) (shen.extract_free_vars (cons (hd (tl V604)) V603) (hd (tl (tl (tl V604))))))) ((cons? V604) (union (shen.extract_free_vars V603 (hd V604)) (shen.extract_free_vars V603 (tl V604)))) (true ())))
82
+
83
+ (defun shen.free_variable_warnings (V607 V608) (cond ((= () V608) _) (true (simple-error (cn "error: the following variables are free in " (shen.app V607 (cn ": " (shen.app (shen.list_variables V608) "" shen.a)) shen.a))))))
84
+
85
+ (defun shen.list_variables (V609) (cond ((and (cons? V609) (= () (tl V609))) (cn (str (hd V609)) ".")) ((cons? V609) (cn (str (hd V609)) (cn ", " (shen.list_variables (tl V609))))) (true (shen.f_error shen.list_variables))))
86
+
87
+ (defun shen.strip-protect (V610) (cond ((and (cons? V610) (and (cons? (tl V610)) (and (= () (tl (tl V610))) (= (hd V610) protect)))) (shen.strip-protect (hd (tl V610)))) ((cons? V610) (map shen.strip-protect V610)) (true V610)))
88
+
89
+ (defun shen.linearise (V611) (cond ((and (cons? V611) (and (cons? (tl V611)) (= () (tl (tl V611))))) (shen.linearise_help (shen.flatten (hd V611)) (hd V611) (hd (tl V611)))) (true (shen.f_error shen.linearise))))
90
+
91
+ (defun shen.flatten (V612) (cond ((= () V612) ()) ((cons? V612) (append (shen.flatten (hd V612)) (shen.flatten (tl V612)))) (true (cons V612 ()))))
92
+
93
+ (defun shen.linearise_help (V613 V614 V615) (cond ((= () V613) (cons V614 (cons V615 ()))) ((cons? V613) (if (and (variable? (hd V613)) (element? (hd V613) (tl V613))) (let Var (gensym (hd V613)) (let NewAction (cons where (cons (cons = (cons (hd V613) (cons Var ()))) (cons V615 ()))) (let NewPatts (shen.linearise_X (hd V613) Var V614) (shen.linearise_help (tl V613) NewPatts NewAction)))) (shen.linearise_help (tl V613) V614 V615))) (true (shen.f_error shen.linearise_help))))
94
+
95
+ (defun shen.linearise_X (V625 V626 V627) (cond ((= V627 V625) V626) ((cons? V627) (let L (shen.linearise_X V625 V626 (hd V627)) (if (= L (hd V627)) (cons (hd V627) (shen.linearise_X V625 V626 (tl V627))) (cons L (tl V627))))) (true V627)))
96
+
97
+ (defun shen.aritycheck (V628 V629) (cond ((and (cons? V629) (and (cons? (hd V629)) (and (cons? (tl (hd V629))) (and (= () (tl (tl (hd V629)))) (= () (tl V629)))))) (do (shen.aritycheck-action (hd (tl (hd V629)))) (shen.aritycheck-name V628 (arity V628) (length (hd (hd V629)))))) ((and (cons? V629) (and (cons? (hd V629)) (and (cons? (tl (hd V629))) (and (= () (tl (tl (hd V629)))) (and (cons? (tl V629)) (and (cons? (hd (tl V629))) (and (cons? (tl (hd (tl V629)))) (= () (tl (tl (hd (tl V629)))))))))))) (if (= (length (hd (hd V629))) (length (hd (hd (tl V629))))) (do (shen.aritycheck-action (hd (tl (hd V629)))) (shen.aritycheck V628 (tl V629))) (simple-error (cn "arity error in " (shen.app V628 "
98
+ " shen.a))))) (true (shen.f_error shen.aritycheck))))
99
+
100
+ (defun shen.aritycheck-name (V639 V640 V641) (cond ((= -1 V640) V641) ((= V641 V640) V641) (true (do (shen.prhush (cn "
101
+ warning: changing the arity of " (shen.app V639 " can cause errors.
102
+ " shen.a)) (stoutput)) V641))))
103
+
104
+ (defun shen.aritycheck-action (V646) (cond ((cons? V646) (do (shen.aah (hd V646) (tl V646)) (map shen.aritycheck-action V646))) (true shen.skip)))
105
+
106
+ (defun shen.aah (V647 V648) (let Arity (arity V647) (let Len (length V648) (if (and (> Arity -1) (> Len Arity)) (shen.prhush (cn "warning: " (shen.app V647 (cn " might not like " (shen.app Len (cn " argument" (shen.app (if (> Len 1) "s" "") ".
107
+ " shen.a)) shen.a)) shen.a)) (stoutput)) shen.skip))))
108
+
109
+ (defun shen.abstract_rule (V649) (cond ((and (cons? V649) (and (cons? (tl V649)) (= () (tl (tl V649))))) (shen.abstraction_build (hd V649) (hd (tl V649)))) (true (shen.f_error shen.abstract_rule))))
110
+
111
+ (defun shen.abstraction_build (V650 V651) (cond ((= () V650) V651) ((cons? V650) (cons /. (cons (hd V650) (cons (shen.abstraction_build (tl V650) V651) ())))) (true (shen.f_error shen.abstraction_build))))
112
+
113
+ (defun shen.parameters (V652) (cond ((= 0 V652) ()) (true (cons (gensym V) (shen.parameters (- V652 1))))))
114
+
115
+ (defun shen.application_build (V653 V654) (cond ((= () V653) V654) ((cons? V653) (shen.application_build (tl V653) (cons V654 (cons (hd V653) ())))) (true (shen.f_error shen.application_build))))
116
+
117
+ (defun shen.compile_to_kl (V655 V656) (cond ((and (cons? V656) (and (cons? (tl V656)) (= () (tl (tl V656))))) (let Arity (shen.store-arity V655 (length (hd V656))) (let Reduce (map shen.reduce (hd (tl V656))) (let CondExpression (shen.cond-expression V655 (hd V656) Reduce) (let TypeTable (if (value shen.*optimise*) (shen.typextable (shen.get-type V655) (hd V656)) shen.skip) (let TypedCondExpression (if (value shen.*optimise*) (shen.assign-types (hd V656) TypeTable CondExpression) CondExpression) (let KL (cons defun (cons V655 (cons (hd V656) (cons TypedCondExpression ())))) KL))))))) (true (shen.f_error shen.compile_to_kl))))
118
+
119
+ (defun shen.get-type (V661) (cond ((cons? V661) shen.skip) (true (let FType (assoc V661 (value shen.*signedfuncs*)) (if (empty? FType) shen.skip (tl FType))))))
120
+
121
+ (defun shen.typextable (V670 V671) (cond ((and (cons? V670) (and (cons? (tl V670)) (and (= --> (hd (tl V670))) (and (cons? (tl (tl V670))) (and (= () (tl (tl (tl V670)))) (cons? V671)))))) (if (variable? (hd V670)) (shen.typextable (hd (tl (tl V670))) (tl V671)) (cons (cons (hd V671) (hd V670)) (shen.typextable (hd (tl (tl V670))) (tl V671))))) (true ())))
122
+
123
+ (defun shen.assign-types (V672 V673 V674) (cond ((and (cons? V674) (and (= let (hd V674)) (and (cons? (tl V674)) (and (cons? (tl (tl V674))) (and (cons? (tl (tl (tl V674)))) (= () (tl (tl (tl (tl V674)))))))))) (cons let (cons (hd (tl V674)) (cons (shen.assign-types V672 V673 (hd (tl (tl V674)))) (cons (shen.assign-types (cons (hd (tl V674)) V672) V673 (hd (tl (tl (tl V674))))) ()))))) ((and (cons? V674) (and (= lambda (hd V674)) (and (cons? (tl V674)) (and (cons? (tl (tl V674))) (= () (tl (tl (tl V674)))))))) (cons lambda (cons (hd (tl V674)) (cons (shen.assign-types (cons (hd (tl V674)) V672) V673 (hd (tl (tl V674)))) ())))) ((and (cons? V674) (= cond (hd V674))) (cons cond (map (lambda Y (cons (shen.assign-types V672 V673 (hd Y)) (cons (shen.assign-types V672 V673 (hd (tl Y))) ()))) (tl V674)))) ((cons? V674) (let NewTable (shen.typextable (shen.get-type (hd V674)) (tl V674)) (cons (hd V674) (map (lambda Y (shen.assign-types V672 (append V673 NewTable) Y)) (tl V674))))) (true (let AtomType (assoc V674 V673) (if (cons? AtomType) (cons type (cons V674 (cons (tl AtomType) ()))) (if (element? V674 V672) V674 (shen.atom-type V674)))))))
124
+
125
+ (defun shen.atom-type (V675) (if (string? V675) (cons type (cons V675 (cons string ()))) (if (number? V675) (cons type (cons V675 (cons number ()))) (if (boolean? V675) (cons type (cons V675 (cons boolean ()))) (if (symbol? V675) (cons type (cons V675 (cons symbol ()))) V675)))))
126
+
127
+ (defun shen.store-arity (V678 V679) (cond ((value shen.*installing-kl*) shen.skip) (true (put V678 arity V679 (value *property-vector*)))))
128
+
129
+ (defun shen.reduce (V680) (do (set shen.*teststack* ()) (let Result (shen.reduce_help V680) (cons (cons : (cons shen.tests (reverse (value shen.*teststack*)))) (cons Result ())))))
130
+
131
+ (defun shen.reduce_help (V681) (cond ((and (cons? V681) (and (cons? (hd V681)) (and (= /. (hd (hd V681))) (and (cons? (tl (hd V681))) (and (cons? (hd (tl (hd V681)))) (and (= cons (hd (hd (tl (hd V681))))) (and (cons? (tl (hd (tl (hd V681))))) (and (cons? (tl (tl (hd (tl (hd V681)))))) (and (= () (tl (tl (tl (hd (tl (hd V681))))))) (and (cons? (tl (tl (hd V681)))) (and (= () (tl (tl (tl (hd V681))))) (and (cons? (tl V681)) (= () (tl (tl V681))))))))))))))) (do (shen.add_test (cons cons? (tl V681))) (let Abstraction (cons /. (cons (hd (tl (hd (tl (hd V681))))) (cons (cons /. (cons (hd (tl (tl (hd (tl (hd V681)))))) (cons (shen.ebr (hd (tl V681)) (hd (tl (hd V681))) (hd (tl (tl (hd V681))))) ()))) ()))) (let Application (cons (cons Abstraction (cons (cons hd (tl V681)) ())) (cons (cons tl (tl V681)) ())) (shen.reduce_help Application))))) ((and (cons? V681) (and (cons? (hd V681)) (and (= /. (hd (hd V681))) (and (cons? (tl (hd V681))) (and (cons? (hd (tl (hd V681)))) (and (= @p (hd (hd (tl (hd V681))))) (and (cons? (tl (hd (tl (hd V681))))) (and (cons? (tl (tl (hd (tl (hd V681)))))) (and (= () (tl (tl (tl (hd (tl (hd V681))))))) (and (cons? (tl (tl (hd V681)))) (and (= () (tl (tl (tl (hd V681))))) (and (cons? (tl V681)) (= () (tl (tl V681))))))))))))))) (do (shen.add_test (cons tuple? (tl V681))) (let Abstraction (cons /. (cons (hd (tl (hd (tl (hd V681))))) (cons (cons /. (cons (hd (tl (tl (hd (tl (hd V681)))))) (cons (shen.ebr (hd (tl V681)) (hd (tl (hd V681))) (hd (tl (tl (hd V681))))) ()))) ()))) (let Application (cons (cons Abstraction (cons (cons fst (tl V681)) ())) (cons (cons snd (tl V681)) ())) (shen.reduce_help Application))))) ((and (cons? V681) (and (cons? (hd V681)) (and (= /. (hd (hd V681))) (and (cons? (tl (hd V681))) (and (cons? (hd (tl (hd V681)))) (and (= @v (hd (hd (tl (hd V681))))) (and (cons? (tl (hd (tl (hd V681))))) (and (cons? (tl (tl (hd (tl (hd V681)))))) (and (= () (tl (tl (tl (hd (tl (hd V681))))))) (and (cons? (tl (tl (hd V681)))) (and (= () (tl (tl (tl (hd V681))))) (and (cons? (tl V681)) (= () (tl (tl V681))))))))))))))) (do (shen.add_test (cons shen.+vector? (tl V681))) (let Abstraction (cons /. (cons (hd (tl (hd (tl (hd V681))))) (cons (cons /. (cons (hd (tl (tl (hd (tl (hd V681)))))) (cons (shen.ebr (hd (tl V681)) (hd (tl (hd V681))) (hd (tl (tl (hd V681))))) ()))) ()))) (let Application (cons (cons Abstraction (cons (cons hdv (tl V681)) ())) (cons (cons tlv (tl V681)) ())) (shen.reduce_help Application))))) ((and (cons? V681) (and (cons? (hd V681)) (and (= /. (hd (hd V681))) (and (cons? (tl (hd V681))) (and (cons? (hd (tl (hd V681)))) (and (= @s (hd (hd (tl (hd V681))))) (and (cons? (tl (hd (tl (hd V681))))) (and (cons? (tl (tl (hd (tl (hd V681)))))) (and (= () (tl (tl (tl (hd (tl (hd V681))))))) (and (cons? (tl (tl (hd V681)))) (and (= () (tl (tl (tl (hd V681))))) (and (cons? (tl V681)) (= () (tl (tl V681))))))))))))))) (do (shen.add_test (cons shen.+string? (tl V681))) (let Abstraction (cons /. (cons (hd (tl (hd (tl (hd V681))))) (cons (cons /. (cons (hd (tl (tl (hd (tl (hd V681)))))) (cons (shen.ebr (hd (tl V681)) (hd (tl (hd V681))) (hd (tl (tl (hd V681))))) ()))) ()))) (let Application (cons (cons Abstraction (cons (cons pos (cons (hd (tl V681)) (cons 0 ()))) ())) (cons (cons tlstr (tl V681)) ())) (shen.reduce_help Application))))) ((and (cons? V681) (and (cons? (hd V681)) (and (= /. (hd (hd V681))) (and (cons? (tl (hd V681))) (and (cons? (tl (tl (hd V681)))) (and (= () (tl (tl (tl (hd V681))))) (and (cons? (tl V681)) (and (= () (tl (tl V681))) (not (variable? (hd (tl (hd V681))))))))))))) (do (shen.add_test (cons = (cons (hd (tl (hd V681))) (tl V681)))) (shen.reduce_help (hd (tl (tl (hd V681))))))) ((and (cons? V681) (and (cons? (hd V681)) (and (= /. (hd (hd V681))) (and (cons? (tl (hd V681))) (and (cons? (tl (tl (hd V681)))) (and (= () (tl (tl (tl (hd V681))))) (and (cons? (tl V681)) (= () (tl (tl V681)))))))))) (shen.reduce_help (shen.ebr (hd (tl V681)) (hd (tl (hd V681))) (hd (tl (tl (hd V681))))))) ((and (cons? V681) (and (= where (hd V681)) (and (cons? (tl V681)) (and (cons? (tl (tl V681))) (= () (tl (tl (tl V681)))))))) (do (shen.add_test (hd (tl V681))) (shen.reduce_help (hd (tl (tl V681)))))) ((and (cons? V681) (and (cons? (tl V681)) (= () (tl (tl V681))))) (let Z (shen.reduce_help (hd V681)) (if (= (hd V681) Z) V681 (shen.reduce_help (cons Z (tl V681)))))) (true V681)))
132
+
133
+ (defun shen.+string? (V682) (cond ((= "" V682) false) (true (string? V682))))
134
+
135
+ (defun shen.+vector (V683) (cond ((= V683 (vector 0)) false) (true (vector? V683))))
136
+
137
+ (defun shen.ebr (V694 V695 V696) (cond ((= V696 V695) V694) ((and (cons? V696) (and (= /. (hd V696)) (and (cons? (tl V696)) (and (cons? (tl (tl V696))) (and (= () (tl (tl (tl V696)))) (> (occurrences V695 (hd (tl V696))) 0)))))) V696) ((and (cons? V696) (and (= let (hd V696)) (and (cons? (tl V696)) (and (cons? (tl (tl V696))) (and (cons? (tl (tl (tl V696)))) (and (= () (tl (tl (tl (tl V696))))) (= (hd (tl V696)) V695))))))) (cons let (cons (hd (tl V696)) (cons (shen.ebr V694 (hd (tl V696)) (hd (tl (tl V696)))) (tl (tl (tl V696))))))) ((cons? V696) (cons (shen.ebr V694 V695 (hd V696)) (shen.ebr V694 V695 (tl V696)))) (true V696)))
138
+
139
+ (defun shen.add_test (V697) (set shen.*teststack* (cons V697 (value shen.*teststack*))))
140
+
141
+ (defun shen.cond-expression (V698 V699 V700) (let Err (shen.err-condition V698) (let Cases (shen.case-form V700 Err) (let EncodeChoices (shen.encode-choices Cases V698) (shen.cond-form EncodeChoices)))))
142
+
143
+ (defun shen.cond-form (V703) (cond ((and (cons? V703) (and (cons? (hd V703)) (and (= true (hd (hd V703))) (and (cons? (tl (hd V703))) (= () (tl (tl (hd V703)))))))) (hd (tl (hd V703)))) (true (cons cond V703))))
144
+
145
+ (defun shen.encode-choices (V706 V707) (cond ((= () V706) ()) ((and (cons? V706) (and (cons? (hd V706)) (and (= true (hd (hd V706))) (and (cons? (tl (hd V706))) (and (cons? (hd (tl (hd V706)))) (and (= shen.choicepoint! (hd (hd (tl (hd V706))))) (and (cons? (tl (hd (tl (hd V706))))) (and (= () (tl (tl (hd (tl (hd V706)))))) (and (= () (tl (tl (hd V706)))) (= () (tl V706))))))))))) (cons (cons true (cons (cons let (cons Result (cons (hd (tl (hd (tl (hd V706))))) (cons (cons if (cons (cons = (cons Result (cons (cons fail ()) ()))) (cons (if (value shen.*installing-kl*) (cons shen.sys-error (cons V707 ())) (cons shen.f_error (cons V707 ()))) (cons Result ())))) ())))) ())) ())) ((and (cons? V706) (and (cons? (hd V706)) (and (= true (hd (hd V706))) (and (cons? (tl (hd V706))) (and (cons? (hd (tl (hd V706)))) (and (= shen.choicepoint! (hd (hd (tl (hd V706))))) (and (cons? (tl (hd (tl (hd V706))))) (and (= () (tl (tl (hd (tl (hd V706)))))) (= () (tl (tl (hd V706)))))))))))) (cons (cons true (cons (cons let (cons Result (cons (hd (tl (hd (tl (hd V706))))) (cons (cons if (cons (cons = (cons Result (cons (cons fail ()) ()))) (cons (shen.cond-form (shen.encode-choices (tl V706) V707)) (cons Result ())))) ())))) ())) ())) ((and (cons? V706) (and (cons? (hd V706)) (and (cons? (tl (hd V706))) (and (cons? (hd (tl (hd V706)))) (and (= shen.choicepoint! (hd (hd (tl (hd V706))))) (and (cons? (tl (hd (tl (hd V706))))) (and (= () (tl (tl (hd (tl (hd V706)))))) (= () (tl (tl (hd V706))))))))))) (cons (cons true (cons (cons let (cons Freeze (cons (cons freeze (cons (shen.cond-form (shen.encode-choices (tl V706) V707)) ())) (cons (cons if (cons (hd (hd V706)) (cons (cons let (cons Result (cons (hd (tl (hd (tl (hd V706))))) (cons (cons if (cons (cons = (cons Result (cons (cons fail ()) ()))) (cons (cons thaw (cons Freeze ())) (cons Result ())))) ())))) (cons (cons thaw (cons Freeze ())) ())))) ())))) ())) ())) ((and (cons? V706) (and (cons? (hd V706)) (and (cons? (tl (hd V706))) (= () (tl (tl (hd V706))))))) (cons (hd V706) (shen.encode-choices (tl V706) V707))) (true (shen.f_error shen.encode-choices))))
146
+
147
+ (defun shen.case-form (V712 V713) (cond ((= () V712) (cons V713 ())) ((and (cons? V712) (and (cons? (hd V712)) (and (cons? (hd (hd V712))) (and (= : (hd (hd (hd V712)))) (and (cons? (tl (hd (hd V712)))) (and (= shen.tests (hd (tl (hd (hd V712))))) (and (= () (tl (tl (hd (hd V712))))) (and (cons? (tl (hd V712))) (and (cons? (hd (tl (hd V712)))) (and (= shen.choicepoint! (hd (hd (tl (hd V712))))) (and (cons? (tl (hd (tl (hd V712))))) (and (= () (tl (tl (hd (tl (hd V712)))))) (= () (tl (tl (hd V712)))))))))))))))) (cons (cons true (tl (hd V712))) (shen.case-form (tl V712) V713))) ((and (cons? V712) (and (cons? (hd V712)) (and (cons? (hd (hd V712))) (and (= : (hd (hd (hd V712)))) (and (cons? (tl (hd (hd V712)))) (and (= shen.tests (hd (tl (hd (hd V712))))) (and (= () (tl (tl (hd (hd V712))))) (and (cons? (tl (hd V712))) (= () (tl (tl (hd V712)))))))))))) (cons (cons true (tl (hd V712))) ())) ((and (cons? V712) (and (cons? (hd V712)) (and (cons? (hd (hd V712))) (and (= : (hd (hd (hd V712)))) (and (cons? (tl (hd (hd V712)))) (and (= shen.tests (hd (tl (hd (hd V712))))) (and (cons? (tl (hd V712))) (= () (tl (tl (hd V712))))))))))) (cons (cons (shen.embed-and (tl (tl (hd (hd V712))))) (tl (hd V712))) (shen.case-form (tl V712) V713))) (true (shen.f_error shen.case-form))))
148
+
149
+ (defun shen.embed-and (V714) (cond ((and (cons? V714) (= () (tl V714))) (hd V714)) ((cons? V714) (cons and (cons (hd V714) (cons (shen.embed-and (tl V714)) ())))) (true (shen.f_error shen.embed-and))))
150
+
151
+ (defun shen.err-condition (V715) (cons true (cons (cons shen.f_error (cons V715 ())) ())))
152
+
153
+ (defun shen.sys-error (V716) (simple-error (cn "system function " (shen.app V716 ": unexpected argument
154
+ " shen.a))))
155
+
156
+
157
+