unparser 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/unparser.rb +1 -0
- data/lib/unparser/emitter.rb +3 -9
- data/lib/unparser/emitter/flipflop.rb +29 -0
- data/lib/unparser/emitter/repetition.rb +0 -10
- data/lib/unparser/emitter/send.rb +0 -10
- data/spec/integration/unparser/spike_spec.rb +17 -17
- data/unparser.gemspec +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db2821186d187ad46f917f49cb11af9afc247fd8
|
4
|
+
data.tar.gz: acafc7b50f6b70e7fc8d633fa3c2322c3d9a8657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4ddda74c96cbcf812df1ae84a01f9a48b0f889307c65d9d02c3d0ad0ab87189c171f3aafdb3d44f3d77b60721cddadf5c0977f6a8749e7506b29b81b3bdd0c6
|
7
|
+
data.tar.gz: 7e3b9cf95b9596cbbb7507f01f024be51a0ad3d560a700d2f7732991c82674cf6b5de100f1e64084039d56d01a5b81465caf987a1dd55d34e7068acd8313b89e
|
data/lib/unparser.rb
CHANGED
data/lib/unparser/emitter.rb
CHANGED
@@ -122,19 +122,13 @@ module Unparser
|
|
122
122
|
self
|
123
123
|
end
|
124
124
|
|
125
|
-
#
|
125
|
+
# Dispatch node
|
126
126
|
#
|
127
|
-
# @return [
|
128
|
-
# if if node needs begin
|
129
|
-
#
|
130
|
-
# @return [false]
|
131
|
-
# otherwise
|
127
|
+
# @return [undefined]
|
132
128
|
#
|
133
129
|
# @api private
|
134
130
|
#
|
135
|
-
|
136
|
-
false
|
137
|
-
end
|
131
|
+
abstract_method :dispatch
|
138
132
|
|
139
133
|
# Return node
|
140
134
|
#
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Unparser
|
2
|
+
class Emitter
|
3
|
+
class FlipFlop < self
|
4
|
+
|
5
|
+
MAP = IceNine.deep_freeze(
|
6
|
+
:iflipflop => '..',
|
7
|
+
:eflipflop => '...',
|
8
|
+
).freeze
|
9
|
+
|
10
|
+
handle *MAP.keys
|
11
|
+
|
12
|
+
children :left, :right
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Perform dispatch
|
17
|
+
#
|
18
|
+
# @return [undefined]
|
19
|
+
#
|
20
|
+
# @api private
|
21
|
+
#
|
22
|
+
def dispatch
|
23
|
+
parentheses { visit(left) }
|
24
|
+
write(MAP.fetch(node.type))
|
25
|
+
parentheses { visit(right) }
|
26
|
+
end
|
27
|
+
end # FlipFLop
|
28
|
+
end # Emitter
|
29
|
+
end # Unparser
|
@@ -15,16 +15,6 @@ module Unparser
|
|
15
15
|
|
16
16
|
handle *MAP.keys
|
17
17
|
|
18
|
-
# Test if child should be emitted with explicit begin nodes
|
19
|
-
#
|
20
|
-
# @return [true]
|
21
|
-
#
|
22
|
-
# @api private
|
23
|
-
#
|
24
|
-
def needs_begin?
|
25
|
-
true
|
26
|
-
end
|
27
|
-
|
28
18
|
# Perform dispatch
|
29
19
|
#
|
30
20
|
# @return [undefined]
|
@@ -905,23 +905,23 @@ describe Unparser, 'spike' do
|
|
905
905
|
assert_source '(a ||= 2).bar'
|
906
906
|
end
|
907
907
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
908
|
+
context 'flip flops' do
|
909
|
+
context 'inclusive' do
|
910
|
+
assert_source <<-RUBY
|
911
|
+
if (i == 4)..(i == 4)
|
912
|
+
foo
|
913
|
+
end
|
914
|
+
RUBY
|
915
|
+
end
|
916
|
+
|
917
|
+
context 'exclusive' do
|
918
|
+
assert_source <<-RUBY
|
919
|
+
if (i == 4)...(i == 4)
|
920
|
+
foo
|
921
|
+
end
|
922
|
+
RUBY
|
923
|
+
end
|
924
|
+
end
|
925
925
|
|
926
926
|
context 'case statement' do
|
927
927
|
assert_source <<-RUBY
|
data/unparser.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'unparser'
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.8'
|
6
6
|
|
7
7
|
s.authors = ['Markus Schirp']
|
8
8
|
s.email = 'mbj@schir-dso.com'
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.extra_rdoc_files = %w(README.md)
|
18
18
|
s.executables = [ 'test-unparser' ]
|
19
19
|
|
20
|
-
s.add_dependency('parser', '~> 2.0.0.
|
20
|
+
s.add_dependency('parser', '~> 2.0.0.pre1')
|
21
21
|
s.add_dependency('concord', '~> 0.1.0')
|
22
22
|
s.add_dependency('adamantium', '~> 0.0.7')
|
23
23
|
s.add_dependency('equalizer', '~> 0.0.5')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.0.
|
19
|
+
version: 2.0.0.pre1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.0.
|
26
|
+
version: 2.0.0.pre1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: concord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/unparser/emitter/def.rb
|
125
125
|
- lib/unparser/emitter/defined.rb
|
126
126
|
- lib/unparser/emitter/empty.rb
|
127
|
+
- lib/unparser/emitter/flipflop.rb
|
127
128
|
- lib/unparser/emitter/for.rb
|
128
129
|
- lib/unparser/emitter/hookexe.rb
|
129
130
|
- lib/unparser/emitter/if.rb
|