atomy 0.1.1 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +13 -0
- data/LICENSE.md +201 -0
- data/bin/atomy +16 -133
- data/kernel/array.ay +6 -0
- data/kernel/atomy.ay +18 -0
- data/kernel/condition.ay +171 -271
- data/kernel/control-flow.ay +197 -192
- data/kernel/core.ay +120 -0
- data/kernel/data.ay +83 -39
- data/kernel/define.ay +84 -93
- data/kernel/doc.ay +282 -449
- data/kernel/dynamic.ay +25 -29
- data/kernel/file.ay +9 -0
- data/kernel/grammar.ay +267 -0
- data/kernel/hash.ay +17 -0
- data/kernel/interpolation.ay +59 -0
- data/kernel/io.ay +70 -244
- data/kernel/let-macro.ay +24 -0
- data/kernel/let-pattern.ay +24 -0
- data/kernel/loop.ay +80 -0
- data/kernel/mutation.ay +53 -0
- data/kernel/particles.ay +176 -39
- data/kernel/patterns.ay +527 -191
- data/kernel/pretty.ay +311 -277
- data/kernel/quotes.ay +29 -0
- data/kernel/range.ay +4 -0
- data/kernel/regexp.ay +23 -0
- data/kernel/repl.ay +83 -109
- data/kernel/stack-local.ay +21 -0
- data/lib/atomy.rb +37 -0
- data/lib/atomy/bootstrap.rb +256 -0
- data/lib/atomy/code/assign.rb +64 -0
- data/lib/atomy/code/block.rb +98 -0
- data/lib/atomy/code/class_variable.rb +17 -0
- data/lib/atomy/code/constant.rb +21 -0
- data/lib/atomy/code/define.rb +242 -0
- data/lib/atomy/code/define_function.rb +51 -0
- data/lib/atomy/code/define_method.rb +20 -0
- data/lib/atomy/code/false.rb +9 -0
- data/lib/atomy/code/instance_variable.rb +15 -0
- data/lib/atomy/code/integer.rb +13 -0
- data/lib/atomy/code/list.rb +17 -0
- data/lib/atomy/code/nil.rb +9 -0
- data/lib/atomy/code/pattern.rb +23 -0
- data/lib/atomy/code/pattern/and.rb +61 -0
- data/lib/atomy/code/pattern/quasi_quote.rb +185 -0
- data/lib/atomy/code/pattern/splat.rb +29 -0
- data/lib/atomy/code/pattern/wildcard.rb +37 -0
- data/lib/atomy/code/quasi_quote.rb +118 -0
- data/lib/atomy/code/quote.rb +13 -0
- data/lib/atomy/code/self.rb +9 -0
- data/lib/atomy/code/send.rb +110 -0
- data/lib/atomy/code/sequence.rb +23 -0
- data/lib/atomy/code/string_literal.rb +53 -0
- data/lib/atomy/code/symbol.rb +13 -0
- data/lib/atomy/code/true.rb +9 -0
- data/lib/atomy/code/undefined.rb +9 -0
- data/lib/atomy/code/variable.rb +17 -0
- data/lib/atomy/codeloader.rb +218 -0
- data/lib/atomy/compiler.rb +57 -0
- data/lib/atomy/errors.rb +54 -0
- data/lib/atomy/grammar.rb +2278 -0
- data/lib/atomy/locals.rb +75 -0
- data/lib/atomy/message_structure.rb +277 -0
- data/lib/atomy/method.rb +343 -0
- data/lib/atomy/module.rb +144 -0
- data/lib/atomy/node/constructable.rb +169 -0
- data/lib/atomy/node/equality.rb +113 -0
- data/lib/atomy/node/meta.rb +206 -0
- data/lib/atomy/node/pretty.rb +108 -0
- data/lib/atomy/parser.rb +21 -0
- data/lib/atomy/pattern.rb +26 -0
- data/lib/atomy/pattern/and.rb +59 -0
- data/lib/atomy/pattern/attribute.rb +16 -0
- data/lib/atomy/pattern/class_variable.rb +15 -0
- data/lib/atomy/pattern/equality.rb +42 -0
- data/lib/atomy/pattern/instance_variable.rb +15 -0
- data/lib/atomy/pattern/kind_of.rb +20 -0
- data/lib/atomy/pattern/or.rb +48 -0
- data/lib/atomy/pattern/quasi_quote.rb +164 -0
- data/lib/atomy/pattern/splat.rb +15 -0
- data/lib/atomy/pattern/wildcard.rb +18 -0
- data/lib/atomy/rubygems.rb +48 -0
- data/lib/atomy/version.rb +3 -0
- metadata +169 -134
- data/COPYING +0 -30
- data/README.md +0 -1
- data/kernel/block.ay +0 -30
- data/kernel/boot.ay +0 -10
- data/kernel/comparison.ay +0 -61
- data/kernel/concurrency.ay +0 -84
- data/kernel/cosmetics.ay +0 -3
- data/kernel/data-delta.ay +0 -105
- data/kernel/documentation.ay +0 -135
- data/kernel/errors.ay +0 -6
- data/kernel/format.ay +0 -13
- data/kernel/format/data.ay +0 -89
- data/kernel/format/formatter.ay +0 -345
- data/kernel/format/parser.ay +0 -13
- data/kernel/hashes.ay +0 -39
- data/kernel/namespaces.ay +0 -63
- data/kernel/node.ay +0 -48
- data/kernel/operators.ay +0 -28
- data/kernel/precision.ay +0 -148
- data/kernel/therie.ay +0 -204
- data/lib/ast/binary_send.rb +0 -44
- data/lib/ast/block.rb +0 -268
- data/lib/ast/constant.rb +0 -88
- data/lib/ast/internal/assign.rb +0 -19
- data/lib/ast/internal/block_pass.rb +0 -21
- data/lib/ast/internal/catch.rb +0 -247
- data/lib/ast/internal/class.rb +0 -30
- data/lib/ast/internal/class_variable.rb +0 -23
- data/lib/ast/internal/define.rb +0 -174
- data/lib/ast/internal/ensure.rb +0 -135
- data/lib/ast/internal/file.rb +0 -14
- data/lib/ast/internal/global_variable.rb +0 -20
- data/lib/ast/internal/if_then_else.rb +0 -24
- data/lib/ast/internal/instance_variable.rb +0 -17
- data/lib/ast/internal/let_macro.rb +0 -35
- data/lib/ast/internal/macro_quote.rb +0 -23
- data/lib/ast/internal/match.rb +0 -53
- data/lib/ast/internal/module.rb +0 -30
- data/lib/ast/internal/pattern.rb +0 -17
- data/lib/ast/internal/return.rb +0 -29
- data/lib/ast/internal/set.rb +0 -19
- data/lib/ast/internal/singleton_class.rb +0 -18
- data/lib/ast/internal/splat.rb +0 -14
- data/lib/ast/internal/when.rb +0 -24
- data/lib/ast/list.rb +0 -25
- data/lib/ast/macro.rb +0 -37
- data/lib/ast/node.rb +0 -599
- data/lib/ast/operator.rb +0 -21
- data/lib/ast/particle.rb +0 -13
- data/lib/ast/primitive.rb +0 -20
- data/lib/ast/quasi_quote.rb +0 -20
- data/lib/ast/quote.rb +0 -13
- data/lib/ast/send.rb +0 -104
- data/lib/ast/splice.rb +0 -32
- data/lib/ast/string.rb +0 -23
- data/lib/ast/unary.rb +0 -44
- data/lib/ast/unquote.rb +0 -45
- data/lib/ast/variable.rb +0 -64
- data/lib/atomy.kpeg.rb +0 -3995
- data/lib/code_loader.rb +0 -137
- data/lib/compiler/compiler.rb +0 -155
- data/lib/compiler/stages.rb +0 -81
- data/lib/formatter.kpeg.rb +0 -1394
- data/lib/macros.rb +0 -317
- data/lib/method.rb +0 -261
- data/lib/namespace.rb +0 -236
- data/lib/parser.rb +0 -28
- data/lib/patterns.rb +0 -276
- data/lib/patterns/any.rb +0 -21
- data/lib/patterns/attribute.rb +0 -59
- data/lib/patterns/block_pass.rb +0 -54
- data/lib/patterns/constant.rb +0 -33
- data/lib/patterns/default.rb +0 -44
- data/lib/patterns/head_tail.rb +0 -63
- data/lib/patterns/list.rb +0 -77
- data/lib/patterns/match.rb +0 -45
- data/lib/patterns/named.rb +0 -55
- data/lib/patterns/named_class.rb +0 -46
- data/lib/patterns/named_global.rb +0 -46
- data/lib/patterns/named_instance.rb +0 -46
- data/lib/patterns/particle.rb +0 -29
- data/lib/patterns/quasi_quote.rb +0 -184
- data/lib/patterns/quote.rb +0 -33
- data/lib/patterns/singleton_class.rb +0 -31
- data/lib/patterns/splat.rb +0 -57
- data/lib/util.rb +0 -37
data/kernel/format.ay
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
namespace(atomy/format)
|
2
|
-
|
3
|
-
base = File expand-path("../", _FILE)
|
4
|
-
|
5
|
-
import(base + "/format/data")
|
6
|
-
import(base + "/format/formatter")
|
7
|
-
import(base + "/format/parser")
|
8
|
-
|
9
|
-
symbols(parse)
|
10
|
-
|
11
|
-
export-to(atomy):
|
12
|
-
macro-quoter(f) [c]:
|
13
|
-
Atomy::Format::Parser parse(c)
|
data/kernel/format/data.ay
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
namespace(atomy/format)
|
2
|
-
|
3
|
-
macro(ast(root, &nodes)):
|
4
|
-
parent = root || 'Atomy::AST::Node
|
5
|
-
cs = nodes contents map [e]:
|
6
|
-
e match:
|
7
|
-
Atomy::AST::Send -> do:
|
8
|
-
name = Atomy::AST::Constant new(0, e method-name)
|
9
|
-
|
10
|
-
children = []
|
11
|
-
attributes = []
|
12
|
-
|
13
|
-
e arguments each [a]:
|
14
|
-
a match:
|
15
|
-
`[@~name] ->
|
16
|
-
attributes << `[#~name]
|
17
|
-
|
18
|
-
`@~name ->
|
19
|
-
attributes << `#~name
|
20
|
-
|
21
|
-
_ ->
|
22
|
-
children << a
|
23
|
-
|
24
|
-
`(class(~name < ~parent):
|
25
|
-
children(~*children)
|
26
|
-
attributes(~*attributes)
|
27
|
-
generate)
|
28
|
-
|
29
|
-
_ ->
|
30
|
-
`(class(~e < ~parent):
|
31
|
-
generate)
|
32
|
-
|
33
|
-
when(root):
|
34
|
-
cs unshift(`(class(~root < Atomy::AST::Node) {}))
|
35
|
-
|
36
|
-
`(do: ~*cs)
|
37
|
-
|
38
|
-
module(Atomy::Format):
|
39
|
-
ast(Segment):
|
40
|
-
Chunk([#flags], @text)
|
41
|
-
String([#flags])
|
42
|
-
Decimal([#flags])
|
43
|
-
Hex([#flags])
|
44
|
-
Octal([#flags])
|
45
|
-
Binary([#flags])
|
46
|
-
Radix([#flags])
|
47
|
-
Float([#flags])
|
48
|
-
Exponent([#flags])
|
49
|
-
General([#flags])
|
50
|
-
Character([#flags])
|
51
|
-
Any([#flags])
|
52
|
-
Pluralize(#singular, [#flags], #plural?)
|
53
|
-
Lowercase(#content, [#flags])
|
54
|
-
Capitalize(#content, [#flags])
|
55
|
-
Uppercase(#content, [#flags])
|
56
|
-
Justify([#segments], [#flags])
|
57
|
-
Skip([#flags])
|
58
|
-
Indirection([#flags])
|
59
|
-
Iterate(#content, [#flags])
|
60
|
-
Break([#flags])
|
61
|
-
Conditional([#branches], [#flags], #default?)
|
62
|
-
|
63
|
-
ast(Flag):
|
64
|
-
Number(@value)
|
65
|
-
Symbol(@character)
|
66
|
-
ZeroPad
|
67
|
-
Precision(@value)
|
68
|
-
|
69
|
-
ast:
|
70
|
-
Formatter([#segments])
|
71
|
-
|
72
|
-
Segment symbol?(m) :=
|
73
|
-
@flags any? [f]:
|
74
|
-
f match:
|
75
|
-
Symbol -> f character == m
|
76
|
-
_ -> false
|
77
|
-
|
78
|
-
Segment precision := do:
|
79
|
-
@flags each [f]:
|
80
|
-
when(f is-a?(Precision)):
|
81
|
-
return(f value)
|
82
|
-
|
83
|
-
nil
|
84
|
-
|
85
|
-
Segment zero-pad? :=
|
86
|
-
@flags any? [f]:
|
87
|
-
f match:
|
88
|
-
ZeroPad -> true
|
89
|
-
_ -> false
|
data/kernel/format/formatter.ay
DELETED
@@ -1,345 +0,0 @@
|
|
1
|
-
namespace(atomy/format)
|
2
|
-
|
3
|
-
module(Atomy::Format):
|
4
|
-
class(Formatter):
|
5
|
-
attr-accessor(#position)
|
6
|
-
|
7
|
-
export:
|
8
|
-
initialize(@line, @segments) :=
|
9
|
-
reset!
|
10
|
-
|
11
|
-
bytecode(g) := do:
|
12
|
-
pos(g)
|
13
|
-
construct(g)
|
14
|
-
|
15
|
-
reset! := do:
|
16
|
-
@input = []
|
17
|
-
@output = ""
|
18
|
-
@position = 0
|
19
|
-
@stop? = false
|
20
|
-
@iterating = []
|
21
|
-
|
22
|
-
scan(*@input) := do:
|
23
|
-
@segments each [s]:
|
24
|
-
s match:
|
25
|
-
Break ? symbol?(".") -> do:
|
26
|
-
when(@iterating empty?):
|
27
|
-
@stop? = true
|
28
|
-
break
|
29
|
-
|
30
|
-
Break ->
|
31
|
-
when(next-inputs empty?):
|
32
|
-
break
|
33
|
-
|
34
|
-
_ -> process(s)
|
35
|
-
|
36
|
-
@output
|
37
|
-
|
38
|
-
export-to(atomy):
|
39
|
-
format(*inputs) := do:
|
40
|
-
res = scan(*inputs)
|
41
|
-
reset!
|
42
|
-
res
|
43
|
-
|
44
|
-
-- TODO: use alias-method
|
45
|
-
self [*inputs] := format(*inputs)
|
46
|
-
|
47
|
-
peek-input := @input [@position]
|
48
|
-
|
49
|
-
next-input := do:
|
50
|
-
v = peek-input
|
51
|
-
@position += 1
|
52
|
-
v
|
53
|
-
|
54
|
-
next-inputs := @input [@position .. -1] || []
|
55
|
-
|
56
|
-
process(c: Chunk) :=
|
57
|
-
@output << c text
|
58
|
-
|
59
|
-
process(s: String) :=
|
60
|
-
@output << justified(s, next-input to-s, true)
|
61
|
-
|
62
|
-
process(i: Decimal) :=
|
63
|
-
@output << integer(i, 10)
|
64
|
-
|
65
|
-
process(i: Hex) :=
|
66
|
-
@output << integer(i, 16)
|
67
|
-
|
68
|
-
process(i: Octal) :=
|
69
|
-
@output << integer(i, 8)
|
70
|
-
|
71
|
-
process(i: Binary) :=
|
72
|
-
@output << integer(i, 2)
|
73
|
-
|
74
|
-
process(i: Radix) :=
|
75
|
-
@output << integer(i, i precision)
|
76
|
-
|
77
|
-
process(f: Float) :=
|
78
|
-
@output << float(f, "f")
|
79
|
-
|
80
|
-
process(f: Exponent) :=
|
81
|
-
@output << float(f, "e")
|
82
|
-
|
83
|
-
process(f: General) :=
|
84
|
-
@output << float(f, "g")
|
85
|
-
|
86
|
-
process(c: Character) :=
|
87
|
-
@output << char(c, next-input)
|
88
|
-
|
89
|
-
process(a: Any) :=
|
90
|
-
@output << justified(a, next-input show, true)
|
91
|
-
|
92
|
-
process(p: Pluralize) := do:
|
93
|
-
word = sub-format(p singular)
|
94
|
-
num =
|
95
|
-
if(p symbol?(">"))
|
96
|
-
then: peek-input
|
97
|
-
else: next-input
|
98
|
-
|
99
|
-
condition:
|
100
|
-
num == 1 ->
|
101
|
-
@output << word
|
102
|
-
|
103
|
-
p plural ->
|
104
|
-
@output << sub-format(p plural)
|
105
|
-
|
106
|
-
otherwise ->
|
107
|
-
@output << pluralize(word)
|
108
|
-
|
109
|
-
process(l: Lowercase) :=
|
110
|
-
@output << sub-format(l content) downcase
|
111
|
-
|
112
|
-
process(c: Capitalize) := do:
|
113
|
-
words = sub-format(c content) split(" ")
|
114
|
-
number(c, words size) times [n]:
|
115
|
-
unless(n == 0):
|
116
|
-
@output << " "
|
117
|
-
|
118
|
-
@output << words shift capitalize
|
119
|
-
|
120
|
-
unless(words empty?):
|
121
|
-
@output << " " + words join(" ")
|
122
|
-
|
123
|
-
process(u: Uppercase) :=
|
124
|
-
@output << sub-format(u content) upcase
|
125
|
-
|
126
|
-
process(s: Skip) :=
|
127
|
-
if(s symbol?("<"))
|
128
|
-
then: @position -= number(s)
|
129
|
-
else: @position += number(s)
|
130
|
-
|
131
|
-
process(i: Indirection) :=
|
132
|
-
if(i symbol?("*"))
|
133
|
-
then:
|
134
|
-
@output << sub-format(next-input)
|
135
|
-
else:
|
136
|
-
@output << next-input format(*next-input)
|
137
|
-
|
138
|
-
process(i: Iterate) := do:
|
139
|
-
splat? = i symbol?("*")
|
140
|
-
sub? = i symbol?(".")
|
141
|
-
always-run? = i symbol?("+")
|
142
|
-
iterations = number(i, nil)
|
143
|
-
|
144
|
-
inputs =
|
145
|
-
if(splat?)
|
146
|
-
then: next-inputs
|
147
|
-
else: next-input
|
148
|
-
|
149
|
-
before = [@input, @position]
|
150
|
-
|
151
|
-
when(inputs empty? && always-run? &&
|
152
|
-
iterations != 0):
|
153
|
-
@output << sub-format(i content)
|
154
|
-
return(nil)
|
155
|
-
|
156
|
-
iterations match:
|
157
|
-
nil ->
|
158
|
-
if(sub?)
|
159
|
-
then:
|
160
|
-
@iterating = inputs
|
161
|
-
inputs each [is]:
|
162
|
-
@output << i content format(*is)
|
163
|
-
else:
|
164
|
-
@input = inputs
|
165
|
-
@position = 0
|
166
|
-
iterate(i content)
|
167
|
-
n -> do:
|
168
|
-
@input = inputs
|
169
|
-
@position = 0
|
170
|
-
iterate-max(n, i content)
|
171
|
-
|
172
|
-
if(splat?)
|
173
|
-
then: @position = @input size
|
174
|
-
else: [@input, @position] = before
|
175
|
-
|
176
|
-
process(c: Conditional) :=
|
177
|
-
[c symbol?("?"), c branches] match:
|
178
|
-
[true, t . (f . _)] ->
|
179
|
-
@output << sub-format(if(next-input) then: t; else: f)
|
180
|
-
|
181
|
-
[true, [t]] ->
|
182
|
-
when(next-input):
|
183
|
-
@output << sub-format(t)
|
184
|
-
|
185
|
-
_ -> do:
|
186
|
-
n = next-number(c)
|
187
|
-
if(n >= c branches size)
|
188
|
-
then:
|
189
|
-
when(c default):
|
190
|
-
@output << sub-format(c default)
|
191
|
-
else:
|
192
|
-
@output << sub-format(c branches [n])
|
193
|
-
|
194
|
-
process(j: Justify) :=
|
195
|
-
@output <<
|
196
|
-
justify(j, j segments collect [s]: sub-format(s))
|
197
|
-
|
198
|
-
process(x) := raise("todo formatting: " + x inspect)
|
199
|
-
|
200
|
-
|
201
|
-
pluralize(s) :=
|
202
|
-
condition:
|
203
|
-
s =~ r"o$"(i) ->
|
204
|
-
s + "es"
|
205
|
-
|
206
|
-
s =~ r"[aeiou]$"(i) ->
|
207
|
-
s + "s"
|
208
|
-
|
209
|
-
s =~ r"(?<root>.+[aeiou])y$"(i) ->
|
210
|
-
s + "s"
|
211
|
-
|
212
|
-
s =~ r"(lay-by|stand-by)$"(i) ->
|
213
|
-
s + "s"
|
214
|
-
|
215
|
-
s =~ r"(.+)y$"(i) ->
|
216
|
-
$1 + "es"
|
217
|
-
|
218
|
-
s =~ r"(.+)us$"(i) ->
|
219
|
-
$1 + ""
|
220
|
-
|
221
|
-
s =~ r"(.+)sis$"(i) ->
|
222
|
-
$1 + "es"
|
223
|
-
|
224
|
-
s =~ r"(.+)(ex|ix)$"(i) ->
|
225
|
-
$1 + "ces"
|
226
|
-
|
227
|
-
s =~ r"(.+)(ss|sh|ch|dge)$"(i) ->
|
228
|
-
s + "es"
|
229
|
-
|
230
|
-
otherwise ->
|
231
|
-
s + "s"
|
232
|
-
|
233
|
-
|
234
|
-
iterate(f) :=
|
235
|
-
until(next-inputs empty? || @stop?):
|
236
|
-
@output << sub-format(f)
|
237
|
-
|
238
|
-
iterate-max(max, f) :=
|
239
|
-
max times:
|
240
|
-
when(next-inputs empty? || @stop?):
|
241
|
-
break
|
242
|
-
|
243
|
-
@output << sub-format(f)
|
244
|
-
|
245
|
-
next-number(s) :=
|
246
|
-
number(s, nil) || next-input
|
247
|
-
|
248
|
-
char(c, n: Integer) := justified(c, n chr, true)
|
249
|
-
char(c, s) := justified(c, s to-s [0, 1], true)
|
250
|
-
|
251
|
-
integer(i, base) := justified(i, Integer(next-input) to-s(base))
|
252
|
-
|
253
|
-
float(f, x) := do:
|
254
|
-
format =
|
255
|
-
if(f precision)
|
256
|
-
then: "%." + f precision to-s + x
|
257
|
-
else: "%" + x
|
258
|
-
|
259
|
-
justified(f, sprintf(format, Float(next-input)))
|
260
|
-
|
261
|
-
sub-format(sub) := do:
|
262
|
-
sub position = @position
|
263
|
-
out = sub scan(*@input)
|
264
|
-
@position = sub position
|
265
|
-
sub reset!
|
266
|
-
out
|
267
|
-
|
268
|
-
number(s, default = 1) := do:
|
269
|
-
s flags each [f]:
|
270
|
-
when(f is-a?(Number)):
|
271
|
-
return(f value || next-inputs size)
|
272
|
-
|
273
|
-
default
|
274
|
-
|
275
|
-
justified(j, s, left? = false) :=
|
276
|
-
number(j, nil) match:
|
277
|
-
nil -> s
|
278
|
-
w -> do:
|
279
|
-
padding = if(j zero-pad?) then: "0"; else: " "
|
280
|
-
|
281
|
-
condition:
|
282
|
-
j symbol?("=") || j symbol?("<") && j symbol?(">") ->
|
283
|
-
s center(w, padding)
|
284
|
-
|
285
|
-
left? && !(j symbol?(">")) || j symbol?("<") ->
|
286
|
-
s ljust(w, padding)
|
287
|
-
|
288
|
-
otherwise ->
|
289
|
-
s rjust(w, padding)
|
290
|
-
|
291
|
-
justify(j, [s]) := justified(j, s)
|
292
|
-
justify(j, ss) :=
|
293
|
-
number(j, nil) match:
|
294
|
-
nil -> ss join
|
295
|
-
to -> justify-to(j, to, ss)
|
296
|
-
|
297
|
-
justify-to(_, _, []) := ""
|
298
|
-
justify-to(j, to, all: s . ss) := do:
|
299
|
-
needed = to - all collect(&#size) inject(*#"+")
|
300
|
-
|
301
|
-
spacings =
|
302
|
-
condition:
|
303
|
-
j symbol?("<") && j symbol?(">") || j symbol?("=") ->
|
304
|
-
all size + 1
|
305
|
-
|
306
|
-
j symbol?("<") ->
|
307
|
-
all size
|
308
|
-
|
309
|
-
j symbol?(">") ->
|
310
|
-
all size
|
311
|
-
|
312
|
-
otherwise ->
|
313
|
-
all size - 1
|
314
|
-
|
315
|
-
naive-average = needed / spacings
|
316
|
-
|
317
|
-
average =
|
318
|
-
if(needed - naive-average * spacings >= spacings - 1)
|
319
|
-
then: naive-average + 1
|
320
|
-
else: naive-average
|
321
|
-
|
322
|
-
condition:
|
323
|
-
j symbol?("<") || j symbol?("=") ->
|
324
|
-
[ " " * naive-average
|
325
|
-
s
|
326
|
-
" " * average
|
327
|
-
spaced(j, average, needed - naive-average - average, ss)
|
328
|
-
] join
|
329
|
-
|
330
|
-
otherwise ->
|
331
|
-
[ s
|
332
|
-
" " * naive-average
|
333
|
-
spaced(j, average, needed - naive-average, ss)
|
334
|
-
] join
|
335
|
-
|
336
|
-
spaced(_, _, _, []) := ""
|
337
|
-
spaced(j, _, left, [s]) :=
|
338
|
-
if(j symbol?(">") || j symbol?("="))
|
339
|
-
then: s + " " * left
|
340
|
-
else: " " * left + s
|
341
|
-
spaced(j, average, left, s . ss) :=
|
342
|
-
[ s
|
343
|
-
" " * average
|
344
|
-
spaced(j, average, left - average, ss)
|
345
|
-
] join
|
data/kernel/format/parser.ay
DELETED