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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +4 -7
- data/Rakefile +5 -1
- data/bin/lasp +5 -5
- data/lib/lasp/corelib.rb +18 -18
- data/lib/lasp/eval.rb +3 -4
- data/lib/lasp/repl.rb +21 -0
- data/lib/lasp/version.rb +1 -1
- metadata +3 -4
- data/bin/lasp-repl +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fca3af94104dd1dc67d77518aaf7453a42b109d
|
4
|
+
data.tar.gz: a2a3d7157ec4383687b5cefe14de7d0f643058e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81b9f85741d98c4395246d241fcbe471ee9524247bb297a2fc9b1519494ac0db0ab0622fac4e47256191f756432ec64de867be555afbf4dbb1aef27f5a173eab
|
7
|
+
data.tar.gz: 54e9ac7f09dbb55fb2bb807df769c4040026cf0d7d2b8a4004182f439cd66c399eaf237344dbd1c68e90d08989b7889c264547dcdea09fdbf7b365269be66dfb
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
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
|
-
|
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
|
141
|
+
# This is basically just a shorthand for `rake install && lasp`
|
145
142
|
rake repl
|
146
143
|
```
|
data/Rakefile
CHANGED
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
|
-
|
7
|
-
|
8
|
-
|
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)
|
data/lib/lasp/corelib.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
module Lasp
|
2
2
|
CORELIB = {
|
3
|
-
:+ => -> (
|
4
|
-
:- => -> (
|
5
|
-
:* => -> (
|
6
|
-
:/ => -> (
|
7
|
-
:< => -> (
|
8
|
-
:> => -> (
|
9
|
-
:"=" => -> (
|
10
|
-
:list => -> (
|
11
|
-
:head => -> (
|
12
|
-
:tail => -> (
|
13
|
-
:cons => -> (
|
14
|
-
:"hash-map" => -> (
|
15
|
-
:get => -> (
|
16
|
-
:assoc => -> (
|
17
|
-
:dissoc => -> (
|
18
|
-
:not => -> (
|
19
|
-
:println => -> (
|
20
|
-
:"." => -> (
|
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
|
data/lib/lasp/eval.rb
CHANGED
@@ -20,18 +20,17 @@ module Lasp
|
|
20
20
|
env[key] = eval(value, env)
|
21
21
|
elsif head == :fn
|
22
22
|
params, func = tail
|
23
|
-
|
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.(
|
30
|
+
head.(*tail)
|
32
31
|
else
|
33
32
|
fn = eval(head, env)
|
34
|
-
fn.(
|
33
|
+
fn.(*tail.map { |form| eval(form, env) })
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
data/lib/lasp/repl.rb
ADDED
@@ -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
|
data/lib/lasp/version.rb
CHANGED
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
|
+
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-
|
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
|
data/bin/lasp-repl
DELETED
@@ -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
|