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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c9b95ccef00a5ebdeae86ae92b12af786f209ae
4
- data.tar.gz: cab5a1dd18399aa00b3afcdd0ea371aee67dfae3
3
+ metadata.gz: db2821186d187ad46f917f49cb11af9afc247fd8
4
+ data.tar.gz: acafc7b50f6b70e7fc8d633fa3c2322c3d9a8657
5
5
  SHA512:
6
- metadata.gz: 369c2c1b754ef3d252464a84b334a0e1f8d1bdae36997c811619b9c1483db73232d8a953e08a5b2894b588bdf7d401ebe4ab667c471b1ce5e57572c4016e5809
7
- data.tar.gz: cfc34c5e7d02ac2e58c60c41dd7f9f59c66a21eace1b1c9d42e3052a930c59067dc6c572bf7980ab4e53d0305940221424263ab8cff8b71901f7e4e572bb1573
6
+ metadata.gz: d4ddda74c96cbcf812df1ae84a01f9a48b0f889307c65d9d02c3d0ad0ab87189c171f3aafdb3d44f3d77b60721cddadf5c0977f6a8749e7506b29b81b3bdd0c6
7
+ data.tar.gz: 7e3b9cf95b9596cbbb7507f01f024be51a0ad3d560a700d2f7732991c82674cf6b5de100f1e64084039d56d01a5b81465caf987a1dd55d34e7068acd8313b89e
data/lib/unparser.rb CHANGED
@@ -88,5 +88,6 @@ require 'unparser/emitter/repetition'
88
88
  require 'unparser/emitter/root'
89
89
  require 'unparser/emitter/match'
90
90
  require 'unparser/emitter/empty'
91
+ require 'unparser/emitter/flipflop'
91
92
  # make it easy for zombie
92
93
  require 'unparser/finalize'
@@ -122,19 +122,13 @@ module Unparser
122
122
  self
123
123
  end
124
124
 
125
- # Test if node needs begin
125
+ # Dispatch node
126
126
  #
127
- # @return [true]
128
- # if if node needs begin
129
- #
130
- # @return [false]
131
- # otherwise
127
+ # @return [undefined]
132
128
  #
133
129
  # @api private
134
130
  #
135
- def needs_begin?
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]
@@ -14,16 +14,6 @@ module Unparser
14
14
 
15
15
  AMBIGOUS = [:irange, :erange].to_set.freeze
16
16
 
17
- # Tell node needs begin
18
- #
19
- # @return [true]
20
- #
21
- # @api private
22
- #
23
- def needs_begin?
24
- true
25
- end
26
-
27
17
  private
28
18
 
29
19
  # Perform dispatch
@@ -905,23 +905,23 @@ describe Unparser, 'spike' do
905
905
  assert_source '(a ||= 2).bar'
906
906
  end
907
907
 
908
- #context 'flip flops' do
909
- # context 'flip2' do
910
- # assert_source <<-RUBY
911
- # if (((i) == (4)))..(((i) == (4)))
912
- # foo
913
- # end
914
- # RUBY
915
- # end
916
-
917
- # context 'flip3' do
918
- # assert_source <<-RUBY
919
- # if (((i) == (4)))...(((i) == (4)))
920
- # foo
921
- # end
922
- # RUBY
923
- # end
924
- #end
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.7'
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.beta10')
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.7
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-02 00:00:00.000000000 Z
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.beta10
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.beta10
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