lasp 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 834e32aec6fd535ecec0d68c7297cb3184ced218
4
- data.tar.gz: ccc67e45c0aeb24b368a51a6bcea67d09af86db9
3
+ metadata.gz: 9fca3af94104dd1dc67d77518aaf7453a42b109d
4
+ data.tar.gz: a2a3d7157ec4383687b5cefe14de7d0f643058e5
5
5
  SHA512:
6
- metadata.gz: ca7f8e586069ed34fa69c03c9c3b16a789b25b695e342d7e2124e5c1b6a9c7b5a23d12cfa4fa329b8668bcb24597ff1e4c8626a39888622369db3e20addab53e
7
- data.tar.gz: 32229cfbb3e1c039249adcedacd75a8e50b3ad3ef0c71f3b0e522d8d5816a5d48429ddd9fa540157d7923b77a195bd46fe921d8b2d8f8086110896e2d1286675
6
+ metadata.gz: 81b9f85741d98c4395246d241fcbe471ee9524247bb297a2fc9b1519494ac0db0ab0622fac4e47256191f756432ec64de867be555afbf4dbb1aef27f5a173eab
7
+ data.tar.gz: 54e9ac7f09dbb55fb2bb807df769c4040026cf0d7d2b8a4004182f439cd66c399eaf237344dbd1c68e90d08989b7889c264547dcdea09fdbf7b365269be66dfb
@@ -1,5 +1,11 @@
1
1
  # Läsp changelog
2
2
 
3
+ ## v0.5.0
4
+
5
+ - Merge `lasp-repl` command into `lasp`, it starts when not provided with a filename.
6
+ - Don't send env to functions implemented as Ruby procs, it was never used.
7
+ - Specs as default rake task.
8
+
3
9
  ## v0.4.0
4
10
 
5
11
  Implicit do-blocks around files. You can now do this...:
data/README.md CHANGED
@@ -17,11 +17,11 @@ sudo gem install lasp
17
17
 
18
18
  ## Running
19
19
 
20
- After installing there are two commands available to you:
20
+ After installing you can invoke `lasp` for a REPL or provide a lasp-file to execute.
21
21
 
22
22
  ```bash
23
23
  # An interactive prompt that lets you play with the language
24
- lasp-repl
24
+ lasp
25
25
 
26
26
  # Run lasp-files
27
27
  lasp path/to/program.lasp
@@ -132,15 +132,12 @@ Implemented in Läsp itself.
132
132
  ### Run the specs
133
133
 
134
134
  ```bash
135
- rspec
136
-
137
- # or more verbose
138
- rspec --format=documentation
135
+ rake
139
136
  ```
140
137
 
141
138
  ### Dev REPL
142
139
 
143
140
  ```bash
144
- # This is basically just a shorthand for `rake install && lasp-repl`
141
+ # This is basically just a shorthand for `rake install && lasp`
145
142
  rake repl
146
143
  ```
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
6
+
3
7
  desc "Install and laund the Läsp REPL"
4
8
  task :repl => [:install] do
5
- sh "lasp-repl"
9
+ sh "lasp"
6
10
  end
data/bin/lasp CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "lasp"
4
+ require "lasp/repl"
4
5
  Lasp::load_stdlib!
5
6
 
6
- unless ARGV.first
7
- puts "You have to supply a path"
8
- exit!
7
+ if ARGV.first
8
+ Lasp::execute_file(ARGV.first)
9
+ else
10
+ Lasp::repl
9
11
  end
10
-
11
- Lasp::execute_file(ARGV.first)
@@ -1,22 +1,22 @@
1
1
  module Lasp
2
2
  CORELIB = {
3
- :+ => -> (_, *args) { args.reduce(:+) },
4
- :- => -> (_, *args) { args.reduce(:-) },
5
- :* => -> (_, *args) { args.reduce(:*) },
6
- :/ => -> (_, *args) { args.reduce(:/) },
7
- :< => -> (_, *args) { args.sort == args },
8
- :> => -> (_, *args) { args.sort.reverse == args },
9
- :"=" => -> (_, *args) { args.uniq.count == 1 },
10
- :list => -> (_, *args) { args },
11
- :head => -> (_, list) { list.first },
12
- :tail => -> (_, list) { list.drop(1) },
13
- :cons => -> (_, item, list) { [item] + list },
14
- :"hash-map" => -> (_, *args) { Hash[*args] },
15
- :get => -> (_, key, a) { a[key] },
16
- :assoc => -> (_, a, key, val) { a.dup.tap { |a| a[key]=val } },
17
- :dissoc => -> (_, a, key) { a.dup.tap { |a| a.delete(key) } },
18
- :not => -> (_, arg) { !arg },
19
- :println => -> (_, output) { puts output },
20
- :"." => -> (_, obj, m, *args) { obj.send(m, *args) },
3
+ :+ => -> (*args) { args.reduce(:+) },
4
+ :- => -> (*args) { args.reduce(:-) },
5
+ :* => -> (*args) { args.reduce(:*) },
6
+ :/ => -> (*args) { args.reduce(:/) },
7
+ :< => -> (*args) { args.sort == args },
8
+ :> => -> (*args) { args.sort.reverse == args },
9
+ :"=" => -> (*args) { args.uniq.count == 1 },
10
+ :list => -> (*args) { args },
11
+ :head => -> (list) { list.first },
12
+ :tail => -> (list) { list.drop(1) },
13
+ :cons => -> (item, list) { [item] + list },
14
+ :"hash-map" => -> (*args) { Hash[*args] },
15
+ :get => -> (key, a) { a[key] },
16
+ :assoc => -> (a, key, val) { a.dup.tap { |a| a[key]=val } },
17
+ :dissoc => -> (a, key) { a.dup.tap { |a| a.delete(key) } },
18
+ :not => -> (arg) { !arg },
19
+ :println => -> (output) { puts output },
20
+ :"." => -> (obj, m, *args) { obj.send(m, *args) },
21
21
  }
22
22
  end
@@ -20,18 +20,17 @@ module Lasp
20
20
  env[key] = eval(value, env)
21
21
  elsif head == :fn
22
22
  params, func = tail
23
- # Use env from context to properly scope closures
24
- -> (_, *args) { eval(func, env.merge(Hash[params.zip(args)])) }
23
+ -> (*args) { eval(func, env.merge(Hash[params.zip(args)])) }
25
24
  elsif head == :do
26
25
  tail.map { |form| eval(form, env) }.last
27
26
  elsif head == :if
28
27
  conditional, true_form, false_form = tail
29
28
  eval(conditional, env) ? eval(true_form, env) : eval(false_form, env)
30
29
  elsif Proc === head
31
- head.(env, *tail)
30
+ head.(*tail)
32
31
  else
33
32
  fn = eval(head, env)
34
- fn.(env, *tail.map { |form| eval(form, env) })
33
+ fn.(*tail.map { |form| eval(form, env) })
35
34
  end
36
35
  end
37
36
  end
@@ -0,0 +1,21 @@
1
+ require "lasp"
2
+ require "readline"
3
+
4
+ module Lasp
5
+ module_function
6
+
7
+ def repl
8
+ trap("SIGINT") { puts "\n\nBye!"; exit }
9
+
10
+ puts "((( Läsp v#{Lasp::VERSION} REPL (ctrl+c to exit) )))\n\n"
11
+ loop do
12
+ begin
13
+ input = Readline.readline("lasp> ", true)
14
+ result = Lasp::execute(input)
15
+ puts " => #{result.inspect}"
16
+ rescue
17
+ puts " *> #{$!}"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Lasp
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lasp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Börjesson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-09 00:00:00.000000000 Z
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -43,7 +43,6 @@ email:
43
43
  - lagginglion@gmail.com
44
44
  executables:
45
45
  - lasp
46
- - lasp-repl
47
46
  extensions: []
48
47
  extra_rdoc_files: []
49
48
  files:
@@ -55,13 +54,13 @@ files:
55
54
  - README.md
56
55
  - Rakefile
57
56
  - bin/lasp
58
- - bin/lasp-repl
59
57
  - lasp.gemspec
60
58
  - lib/lasp.rb
61
59
  - lib/lasp/corelib.rb
62
60
  - lib/lasp/env.rb
63
61
  - lib/lasp/eval.rb
64
62
  - lib/lasp/parser.rb
63
+ - lib/lasp/repl.rb
65
64
  - lib/lasp/stdlib.lasp
66
65
  - lib/lasp/version.rb
67
66
  homepage: https://github.com/alcesleo/lasp
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "lasp"
4
- require "readline"
5
-
6
- Lasp::load_stdlib!
7
-
8
- trap("SIGINT") { puts "\n\nBye!"; exit }
9
-
10
- puts "((( Läsp v#{Lasp::VERSION} REPL (ctrl+c to exit) )))\n\n"
11
- loop do
12
- begin
13
- input = Readline.readline("lasp> ", true)
14
- result = Lasp::execute(input)
15
- puts " => #{result.inspect}"
16
- rescue
17
- puts " *> #{$!}"
18
- end
19
- end