delorean_lang 0.3.15 → 0.3.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delorean/base.rb +1 -1
- data/lib/delorean/delorean.rb +33 -2
- data/lib/delorean/delorean.treetop +1 -1
- data/lib/delorean/nodes.rb +5 -1
- data/lib/delorean/version.rb +1 -1
- data/spec/eval_spec.rb +13 -0
- data/spec/parse_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9e807e4b0e258dcb0a059957acd6f03b9056b80
|
4
|
+
data.tar.gz: 7b847737484ec32546b6e54d75a553e8ace2129b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbebebdd4c9bfb82345d1c0c9e618652e5b02d7c0e62bd1783460aebe4ee298eb3a4cd8b1e841cd34b1e540703cf94d577cd7607534e3c263177b9d2496708bd
|
7
|
+
data.tar.gz: 3477a50fb9f760f313b0d49ae2f869f924d25bf1837362704d4f14bc4fff5d1b8566f0057493e87096f3f73fade3aa9d8562be472c4ceaf5df26a7a00400a327
|
data/lib/delorean/base.rb
CHANGED
data/lib/delorean/delorean.rb
CHANGED
@@ -2150,6 +2150,12 @@ module Delorean
|
|
2150
2150
|
r0
|
2151
2151
|
end
|
2152
2152
|
|
2153
|
+
module BinaryOp0
|
2154
|
+
def sp
|
2155
|
+
elements[1]
|
2156
|
+
end
|
2157
|
+
end
|
2158
|
+
|
2153
2159
|
def _nt_binary_op
|
2154
2160
|
start_index = index
|
2155
2161
|
if node_cache[:binary_op].has_key?(index)
|
@@ -2338,8 +2344,33 @@ module Delorean
|
|
2338
2344
|
r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
|
2339
2345
|
r0 = r16
|
2340
2346
|
else
|
2341
|
-
|
2342
|
-
|
2347
|
+
i17, s17 = index, []
|
2348
|
+
if (match_len = has_terminal?('in', false, index))
|
2349
|
+
r18 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2350
|
+
@index += match_len
|
2351
|
+
else
|
2352
|
+
terminal_parse_failure('in')
|
2353
|
+
r18 = nil
|
2354
|
+
end
|
2355
|
+
s17 << r18
|
2356
|
+
if r18
|
2357
|
+
r19 = _nt_sp
|
2358
|
+
s17 << r19
|
2359
|
+
end
|
2360
|
+
if s17.last
|
2361
|
+
r17 = instantiate_node(SyntaxNode,input, i17...index, s17)
|
2362
|
+
r17.extend(BinaryOp0)
|
2363
|
+
else
|
2364
|
+
@index = i17
|
2365
|
+
r17 = nil
|
2366
|
+
end
|
2367
|
+
if r17
|
2368
|
+
r17 = SyntaxNode.new(input, (index-1)...index) if r17 == true
|
2369
|
+
r0 = r17
|
2370
|
+
else
|
2371
|
+
@index = i0
|
2372
|
+
r0 = nil
|
2373
|
+
end
|
2343
2374
|
end
|
2344
2375
|
end
|
2345
2376
|
end
|
data/lib/delorean/nodes.rb
CHANGED
@@ -177,7 +177,11 @@ eos
|
|
177
177
|
end
|
178
178
|
|
179
179
|
def rewrite(context)
|
180
|
-
|
180
|
+
if op.text_value.start_with? 'in'
|
181
|
+
"(#{e.rewrite(context)}).member?( #{v.rewrite(context)} )"
|
182
|
+
else
|
183
|
+
v.rewrite(context) + " #{op.text_value} " + e.rewrite(context)
|
184
|
+
end
|
181
185
|
end
|
182
186
|
end
|
183
187
|
|
data/lib/delorean/version.rb
CHANGED
data/spec/eval_spec.rb
CHANGED
@@ -781,6 +781,19 @@ eof
|
|
781
781
|
["A", {"a"=>123, "b"=>579}, {"a"=>123, "b"=>579}, {"b"=>579}]
|
782
782
|
end
|
783
783
|
|
784
|
+
it "should eval in expressions" do
|
785
|
+
engine.parse defn("A:",
|
786
|
+
" a = [1,2,3,33,44]",
|
787
|
+
" s = {22,33,44}",
|
788
|
+
" b = (1 in a) && (2 in {22,44})",
|
789
|
+
" c = (2 in a) && (22 in s)",
|
790
|
+
" d = [i*2 for i in s if i in a]",
|
791
|
+
)
|
792
|
+
|
793
|
+
engine.evaluate_attrs("A", %w{b c d}).should ==
|
794
|
+
[false, true, [66, 88]]
|
795
|
+
end
|
796
|
+
|
784
797
|
it "should eval imports" do
|
785
798
|
engine.parse defn("import AAA",
|
786
799
|
"A:",
|
data/spec/parse_spec.rb
CHANGED
@@ -159,6 +159,14 @@ describe "Delorean" do
|
|
159
159
|
)
|
160
160
|
end
|
161
161
|
|
162
|
+
it "should allow in expressions" do
|
163
|
+
engine.parse defn("A:",
|
164
|
+
" int =? 1",
|
165
|
+
" a = if int>1 then int*2 else int/2",
|
166
|
+
" b = int in [1,2,3]",
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
162
170
|
it "should allow non-recursive code 1" do
|
163
171
|
# this is not a recursion error
|
164
172
|
engine.parse defn("A:",
|
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.3.
|
4
|
+
version: 0.3.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|