delorean_lang 0.4.1 → 0.4.2
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 +5 -5
- data/delorean.gemspec +1 -0
- data/lib/delorean/base.rb +11 -10
- data/lib/delorean/version.rb +1 -1
- data/spec/dev_spec.rb +16 -22
- data/spec/eval_spec.rb +18 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5e28b88960385dcb51187a4ad4aa9f6449ba7d2ab3bf2d156954136466ba783a
|
4
|
+
data.tar.gz: 04c88ebab877fa9ee7e623246954a3734f3d28400e35316f52da930015b135df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99a1c358f6fb77804cfb434d683721080d3fdfec500f757b50c62e6c6393e32cd082ceac78cf76735b520c4e06282199a178a34cc48a13aa0dd5dce4b84af033
|
7
|
+
data.tar.gz: b4413fd38b79db395ccd53b150e8f667809969235def188142ef55ee7e841ae1e6020d1adf32f5314815be6d08801ef825f90cc2aa571f606594d88483f835b8
|
data/delorean.gemspec
CHANGED
data/lib/delorean/base.rb
CHANGED
@@ -86,22 +86,28 @@ module Delorean
|
|
86
86
|
}
|
87
87
|
|
88
88
|
module BaseModule
|
89
|
+
# _e is used by Marty promise_jobs to pass promise-related
|
90
|
+
# information
|
89
91
|
class NodeCall < Struct.new(:_e, :engine, :node, :params)
|
90
|
-
def
|
92
|
+
def cloned_params
|
91
93
|
# FIXME: evaluate() modifies params! => need to clone it.
|
92
94
|
# This is pretty awful. NOTE: can't sanitize params as Marty
|
93
95
|
# patches NodeCall and modifies params to send _parent_id.
|
94
96
|
# This whole thing needs to be redone.
|
95
|
-
|
97
|
+
@cp ||= params.clone
|
98
|
+
end
|
99
|
+
|
100
|
+
def evaluate(attr)
|
101
|
+
engine.evaluate(node, attr, cloned_params)
|
96
102
|
end
|
97
103
|
|
98
104
|
def /(args)
|
99
105
|
begin
|
100
106
|
case args
|
101
107
|
when Array
|
102
|
-
engine.eval_to_hash(node, args,
|
108
|
+
engine.eval_to_hash(node, args, cloned_params)
|
103
109
|
when String
|
104
|
-
|
110
|
+
self.evaluate(args)
|
105
111
|
else
|
106
112
|
raise "non-array/string arg to /"
|
107
113
|
end
|
@@ -114,8 +120,7 @@ module Delorean
|
|
114
120
|
def %(args)
|
115
121
|
raise "non-array arg to %" unless args.is_a?(Array)
|
116
122
|
|
117
|
-
|
118
|
-
engine.eval_to_hash(node, args, params.clone)
|
123
|
+
engine.eval_to_hash(node, args, cloned_params)
|
119
124
|
end
|
120
125
|
|
121
126
|
# add new arguments, results in a new NodeCall
|
@@ -124,10 +129,6 @@ module Delorean
|
|
124
129
|
|
125
130
|
NodeCall.new(_e, engine, node, params.merge(args))
|
126
131
|
end
|
127
|
-
|
128
|
-
def sanitized_params
|
129
|
-
BaseClass._sanitize_hash(params)
|
130
|
-
end
|
131
132
|
end
|
132
133
|
|
133
134
|
class BaseClass
|
data/lib/delorean/version.rb
CHANGED
data/spec/dev_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe "Delorean" do
|
|
20
20
|
engine.enumerate_nodes.should == SortedSet.new(["A", "X", "XX", "Y"])
|
21
21
|
end
|
22
22
|
|
23
|
-
it "can enumerate
|
23
|
+
it "can enumerate attrs by node" do
|
24
24
|
engine.parse defn("X:",
|
25
25
|
" a = 123",
|
26
26
|
" b = a",
|
@@ -31,29 +31,23 @@ describe "Delorean" do
|
|
31
31
|
" c =?",
|
32
32
|
" d = 456",
|
33
33
|
)
|
34
|
-
|
35
|
-
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"
|
34
|
+
|
35
|
+
exp = {
|
36
|
+
"X" => ["a", "b"],
|
37
|
+
"Y" => ["a", "b"],
|
38
|
+
"Z" => [],
|
39
|
+
"XX" => ["a", "b", "c", "d"],
|
39
40
|
}
|
40
|
-
|
41
|
+
res = engine.enumerate_attrs
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
" c =?",
|
51
|
-
" d = 456",
|
52
|
-
)
|
53
|
-
engine.enumerate_attrs_by_node("X").should == ["a", "b"]
|
54
|
-
engine.enumerate_attrs_by_node("Y").should == ["a", "b"]
|
55
|
-
engine.enumerate_attrs_by_node("Z").should == []
|
56
|
-
engine.enumerate_attrs_by_node("XX").should == ["a", "c", "d", "b"]
|
43
|
+
res.keys.sort.should == exp.keys.sort
|
44
|
+
|
45
|
+
exp.each {
|
46
|
+
|k, v|
|
47
|
+
|
48
|
+
engine.enumerate_attrs_by_node(k).sort.should == v
|
49
|
+
res[k].sort.should == v
|
50
|
+
}
|
57
51
|
end
|
58
52
|
|
59
53
|
it "can enumerate params" do
|
data/spec/eval_spec.rb
CHANGED
@@ -967,7 +967,7 @@ eof
|
|
967
967
|
expect(r[2]).to be_nil
|
968
968
|
end
|
969
969
|
|
970
|
-
|
970
|
+
it "can use nodes as continuations" do
|
971
971
|
|
972
972
|
# FIME: This is actually a trivial exmaple. Ideally we should be
|
973
973
|
# able to pass arguments to the nodes when evaluating ys. If the
|
@@ -987,4 +987,21 @@ eof
|
|
987
987
|
r = engine.evaluate("B", "res")
|
988
988
|
expect(r[1]).to eq r[0]
|
989
989
|
end
|
990
|
+
|
991
|
+
it "can use nodes as continuations -- simple" do
|
992
|
+
engine.parse defn("A:",
|
993
|
+
" x = Dummy.side_effect",
|
994
|
+
" y = x",
|
995
|
+
"B:",
|
996
|
+
" ns = A()",
|
997
|
+
" res = [ns.x, ns.y]",
|
998
|
+
" res2 = ns % ['x', 'y']",
|
999
|
+
)
|
1000
|
+
r = engine.evaluate("B", "res")
|
1001
|
+
expect(r[1]).to eq r[0]
|
1002
|
+
|
1003
|
+
# this one works as expected
|
1004
|
+
r2 = engine.evaluate("B", "res2")
|
1005
|
+
expect(r2.values.uniq.length).to eq 1
|
1006
|
+
end
|
990
1007
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delorean_lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.3.10
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: A "compiler" for the Delorean programming language
|
70
84
|
email:
|
71
85
|
- arman.bostani@pnmac.com
|
@@ -118,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
132
|
version: '0'
|
119
133
|
requirements: []
|
120
134
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.7.7
|
122
136
|
signing_key:
|
123
137
|
specification_version: 4
|
124
138
|
summary: Delorean compiler
|