oppen 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/oppen/version.rb +1 -1
- data/lib/wadler/print.rb +71 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4bd96d5a824c1ad4de7d5d1e041365ba41a0ee56acf4ace9b95fcaa94600c6a
|
4
|
+
data.tar.gz: 911d25db3ee42855425bc8dc29bc4f2ff6af231a29b949de684d02ad6f28418d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61dc218e4918ee44bbe66d5926859153d3052547669943512e4d65844959cab13c9e180e1406be1e7c31328e0025533ee632a025d59173abb9264f80df5b6ca6
|
7
|
+
data.tar.gz: e79d9269ab5fd74f4726edf6e834d8f95cece52499d4730040df5e90dd1a365a4691262e780bc2a1efca0209e319d82a082416f727ed1a3ec193a1f353fe7e6d
|
data/lib/oppen/version.rb
CHANGED
data/lib/wadler/print.rb
CHANGED
@@ -35,6 +35,10 @@ module Oppen
|
|
35
35
|
|
36
36
|
# @return [String]
|
37
37
|
def output
|
38
|
+
if !tokens.first.is_a? Token::Begin
|
39
|
+
tokens.unshift Oppen.begin_consistent(offset: 0)
|
40
|
+
tokens << Oppen.end
|
41
|
+
end
|
38
42
|
if !tokens.last.is_a? Oppen::Token::EOF
|
39
43
|
tokens << Oppen.eof
|
40
44
|
end
|
@@ -128,5 +132,72 @@ module Oppen
|
|
128
132
|
def break(line_continuation: '')
|
129
133
|
tokens << Oppen.line_break(line_continuation:, offset: current_indent)
|
130
134
|
end
|
135
|
+
|
136
|
+
# @!group Helpers
|
137
|
+
|
138
|
+
# Set a base indenetaion level to the printer.
|
139
|
+
#
|
140
|
+
# @param indent [Integer]
|
141
|
+
#
|
142
|
+
# @return [Nil]
|
143
|
+
def base_indent(indent = 0)
|
144
|
+
@current_indent = indent if !indent.nil?
|
145
|
+
end
|
146
|
+
|
147
|
+
# Open a consistent group.
|
148
|
+
#
|
149
|
+
# @param indent [Integer]
|
150
|
+
#
|
151
|
+
# @return [Nil]
|
152
|
+
def group_open(indent: 0)
|
153
|
+
tokens << Oppen.begin_consistent(offset: indent)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Close a group.
|
157
|
+
#
|
158
|
+
# @return [Nil]
|
159
|
+
def group_close(_)
|
160
|
+
tokens << Oppen.end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Open a consistent group with indent.
|
164
|
+
#
|
165
|
+
# @param indent [Integer]
|
166
|
+
#
|
167
|
+
# @return [Nil]
|
168
|
+
def indent_open(indent)
|
169
|
+
@current_indent += indent
|
170
|
+
group_open
|
171
|
+
end
|
172
|
+
|
173
|
+
# Close a group with indent.
|
174
|
+
#
|
175
|
+
# @param indent [Integer]
|
176
|
+
#
|
177
|
+
# @return [Nil]
|
178
|
+
def indent_close(group, indent)
|
179
|
+
@current_indent -= indent
|
180
|
+
group_close(group)
|
181
|
+
end
|
182
|
+
|
183
|
+
# Open a nest by indent.
|
184
|
+
#
|
185
|
+
# @param indent [Integer]
|
186
|
+
#
|
187
|
+
# @return [Nil]
|
188
|
+
def nest_open(indent)
|
189
|
+
@current_indent += indent
|
190
|
+
end
|
191
|
+
|
192
|
+
# Close a nest by indent.
|
193
|
+
#
|
194
|
+
# @param indent [Integer]
|
195
|
+
#
|
196
|
+
# @return [Nil]
|
197
|
+
def nest_close(indent)
|
198
|
+
@current_indent -= indent
|
199
|
+
end
|
200
|
+
|
201
|
+
# @!endgroup
|
131
202
|
end
|
132
203
|
end
|