Repository navigation
Expand file tree
/
Copy pathreformat_lua
More file actions
executable file
·4445 lines (4440 loc) · 121 KB
/
Copy pathreformat_lua
File metadata and controls
executable file
·4445 lines (4440 loc) · 121 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/local/bin/lua
package.preload['reformat'] =
function(...)
require('workshop.base')
local usage_text =
[[
Reformat Lua 5.5 code.
Usage: f_in f_out
┬ ┬ ┬
│ │ │
└── [options] ─┘
<options>:
--indent=<str> Use given string as indent chunk.
--right-margin=<int> Right margin.
-- Martin, 2026-11
]]
local input_file_name
local output_file_name
local indent_chunk
local right_margin
do
local parse_command_line =
request('!.mechs.parse_command_line')
local default_indent_chunk = ' '
local default_right_margin = 72
local args = parse_command_line(_G.arg)
input_file_name = args[1]
output_file_name = args[2]
indent_chunk = args['indent'] or default_indent_chunk
right_margin =
tonumber(args['right-margin']) or default_right_margin
if
not (
input_file_name and
output_file_name and
indent_chunk and
right_margin
)
then
print(usage_text)
return
end
end
local file_to_str = request('!.convert.file_to_str')
local str_format = string.format
local reformat = request('!.lua.reformat_code')
local file_from_str = request('!.convert.file_from_str')
print('( Lua code reformatter')
local input_code_str = file_to_str(input_file_name)
print(str_format(' Read code from "%s".', input_file_name))
local options =
{ indent_chunk = indent_chunk, right_margin = right_margin }
file_from_str(
output_file_name, reformat(input_code_str, options)
)
print(str_format(' Wrote code to "%s".', output_file_name))
print(')')
end
package.preload['workshop.base'] =
function(...)
local split_name
local base_prefix
local request
local stack_init
local stack_add
local stack_remove
do
local str_match = string.match
local str_find = string.find
local str_sub = string.sub
local tbl_pack = table.pack
local tbl_unpack = table.unpack
local require = require
local empty = ''
local stack_get
do
local names
local depth
stack_init =
function()
names = { }
depth = 1
end
stack_get =
function()
return names[depth]
end
stack_add =
function(prefix, name)
depth = depth + 1
names[depth] = { prefix = prefix, name = name }
end
stack_remove =
function()
depth = depth - 1
end
end
local get_caller_prefix =
function()
local name_rec = stack_get()
if not name_rec then
return empty
end
return name_rec.prefix
end
do
local prefix_name_capture = '^(.+%.)([^%.]+)$'
split_name =
function(qualified_name)
local prefix, name =
str_match(qualified_name, prefix_name_capture)
if not prefix then
prefix = empty
if str_find(qualified_name, '%.') then
name = empty
else
name = qualified_name
end
end
return prefix, name
end
end
local apply_rel_prefix
do
local uplevel_capture = '(.+%.)[^%.]-%.$'
apply_rel_prefix =
function(base_prefix, rel_prefix)
while (str_sub(rel_prefix, 1, 2) == '^.') do
if (base_prefix == empty) then
error("Link is outside of caller's prefix.")
end
base_prefix =
str_match(base_prefix, uplevel_capture) or empty
rel_prefix = str_sub(rel_prefix, 3)
end
return base_prefix .. rel_prefix
end
end
local get_require_name =
function(qualified_name)
local caller_prefix
local is_absolute_name =
(str_sub(qualified_name, 1, 2) == '!.')
if is_absolute_name then
qualified_name = str_sub(qualified_name, 3)
caller_prefix = base_prefix
else
caller_prefix = get_caller_prefix()
end
local prefix, name = split_name(qualified_name)
prefix = apply_rel_prefix(caller_prefix, prefix)
return prefix .. name
end
request =
function(qualified_name)
local require_name = get_require_name(qualified_name)
stack_add(split_name(require_name))
local results = tbl_pack(require(require_name))
stack_remove()
return tbl_unpack(results)
end
end
do
local our_require_name = (...)
base_prefix = split_name(our_require_name)
_G['request'] = request
stack_init()
stack_add(empty, our_require_name)
request('!.system.install_is_functions')()
request('!.system.install_assert_functions')()
_G['new'] = request('!.table.new')
stack_remove()
end
end
package.preload['workshop.concepts.indent'] =
function(...)
local get_indent_level =
function(me)
return me[2]:get_value()
end
local set_indent_level =
function(me, level)
me[2]:set_value(level)
end
local to_string
do
local str_rep = string.rep
to_string =
function(me)
return str_rep(me[1], me[2]:get_value())
end
end
local inc =
function(me)
set_indent_level(me, get_indent_level(me) + 1)
end
local dec =
function(me)
set_indent_level(me, get_indent_level(me) - 1)
end
local interface
local create
do
local range_point_class = request('!.concepts.range_point')
local attach_methods = request('!.table.attach_methods')
create =
function(indent_chunk, min_indent, max_indent)
local range_point =
range_point_class.create(min_indent, max_indent)
local me = { indent_chunk, range_point }
attach_methods(me, interface)
return me
end
end
interface =
{
create = create,
get_indent_level = get_indent_level,
set_indent_level = set_indent_level,
to_string = to_string,
inc = inc,
dec = dec,
}
return interface
end
package.preload['workshop.concepts.range_point'] =
function(...)
local get_min_value =
function(me)
return me[1]
end
local get_max_value =
function(me)
return me[2]
end
local get_value
local set_value
do
local constrain = request('!.number.constrain')
get_value =
function(me)
return constrain(me[3], me[1], me[2])
end
set_value =
function(me, value)
me[3] = constrain(value, me[1], me[2])
end
end
local interface
local create
do
local attach_methods = request('!.table.attach_methods')
create =
function(min_value, max_value)
local me = { min_value, max_value, min_value }
attach_methods(me, interface)
return me
end
end
interface =
{
create = create,
get_min_value = get_min_value,
get_max_value = get_max_value,
get_value = get_value,
set_value = set_value,
}
return interface
end
package.preload['workshop.concepts.shell_command'] =
function(...)
local to_string
do
local quote = request('!.concepts.shell.quote')
local add_to_list = request('!.concepts.list.add_item')
local glue_words = request('!.concepts.words.to_string')
to_string =
function(me)
local words = { }
for _, token in ipairs(me) do
add_to_list(words, quote(token))
end
return glue_words(words)
end
end
local execute
do
local execute_shell_command =
request('!.concepts.shell.execute')
execute =
function(me)
return execute_shell_command(to_string(me))
end
end
local interface
local create
do
local attach_methods = request('!.table.attach_methods')
create =
function(me)
assert_table(me)
for _, token in ipairs(me) do
assert_string(token)
end
attach_methods(me, interface)
return me
end
end
interface =
{ create = create, to_string = to_string, execute = execute }
return interface
end
package.preload['workshop.concepts.text_block'] =
function(...)
local newline = request('!.concepts.ascii.chars').newline
local flush
do
local rtrim = request('!.string.trim_tail')
local str_rep = string.rep
flush =
function(me)
me[5]:write(rtrim(me[1]))
me[5]:write(str_rep(newline, me[2]))
me[1] = ''
me[2] = 0
end
end
local add_to_textline
do
local utf8_len = utf8.len
local str_len = string.len
local max = math.max
add_to_textline =
function(me, str)
if (str == '') then
return
end
if (me[1] == '') then
me[1] = me[3]:to_string()
end
me[1] = me[1] .. str
local len = utf8_len(me[1]) or str_len(me[1])
me[4] = max(me[4], len)
end
end
local add_to_curline =
function(me, str)
if (str == '') then
return
end
if (me[2] > 0) then
flush(me)
end
add_to_textline(me, str)
end
local newline =
function(me)
me[2] = me[2] + 1
end
local on_clean_line =
function(me)
return (me[1] == '') or (me[2] > 0)
end
local request_clean_line =
function(me)
if not on_clean_line(me) then
newline(me)
end
end
local request_empty_line =
function(me)
request_clean_line(me)
if (me[2] == 1) then
newline(me)
end
end
local inc_indent =
function(me)
me[3]:inc()
end
local dec_indent =
function(me)
me[3]:dec()
end
local get_text =
function(me)
flush(me)
return me[5]:get_string()
end
local get_width =
function(me)
return me[4]
end
local string_output_class =
request('!.concepts.streams.output.string')
local seed
do
local utf8_len = utf8.len
seed =
function(me)
local another_me =
{
[1] = me[1],
[2] = me[2],
[3] = new(me[3]),
[4] = 0,
[5] = string_output_class.create(),
}
setmetatable(another_me, getmetatable(me))
return another_me
end
end
local graft
do
local max = math.max
graft =
function(me, another_me)
me[1] = another_me[1]
me[2] = another_me[2]
me[4] = max(me[4], another_me[4])
me[5]:write(another_me[5]:get_string())
end
end
local interface
local create
do
local indent = request('!.concepts.indent')
local min_indent = 0
local max_indent = 100
local attach_methods = request('!.table.attach_methods')
create =
function(indent_chunk)
assert_string(indent_chunk)
local me =
{
[1] = '',
[2] = 0,
[3] =
indent.create(indent_chunk, min_indent, max_indent),
[4] = 0,
[5] = string_output_class.create(),
}
attach_methods(me, interface)
return me
end
end
interface =
{
create = create,
add_to_textline = add_to_textline,
add_to_curline = add_to_curline,
newline = newline,
on_clean_line = on_clean_line,
request_clean_line = request_clean_line,
request_empty_line = request_empty_line,
inc_indent = inc_indent,
dec_indent = dec_indent,
get_text = get_text,
get_width = get_width,
seed = seed,
graft = graft,
}
return interface
end
package.preload['workshop.concepts.ascii.chars'] =
function(...)
local codes = request('codes')
local str_char = string.char
chars = { }
for name, code in pairs(codes) do
chars[name] = str_char(code)
end
return chars
end
package.preload['workshop.concepts.ascii.codes'] =
function(...)
return
{
bell = 7,
backspace = 8,
tab = 9,
newline = 10,
vertical_tab = 11,
form_feed = 12,
carriage_return = 13,
space = 32,
delete = 127,
plus = 43,
minus = 45,
asterisk = 42,
slash = 47,
less_than = 60,
equals = 61,
greater_than = 62,
dot = 46,
comma = 44,
colon = 58,
semicolon = 59,
single_quote = 39,
double_quote = 34,
backtick = 96,
backslash = 92,
number_sign = 35,
question_mark = 63,
bang = 33,
percent = 37,
ampersand = 38,
dollar_sign = 36,
at_sign = 64,
caret = 94,
underscore = 95,
pipe = 124,
tilde = 126,
opening_paren = 40,
closing_paren = 41,
opening_bracket = 91,
closing_bracket = 93,
opening_brace = 123,
closing_brace = 125,
}
end
package.preload['workshop.concepts.list.add_item'] =
function(...)
local tbl_insert = table.insert
return
function(OurList, item)
tbl_insert(OurList, item)
end
end
package.preload['workshop.concepts.list.add_list'] =
function(...)
local tbl_move = table.move
return
function(OurList, AnotherList)
assert(OurList ~= AnotherList)
tbl_move(
AnotherList, 1, #AnotherList, #OurList + 1, OurList
)
end
end
package.preload['workshop.concepts.list.select_seg'] =
function(...)
local is_natural = request('!.number.is_natural')
local tbl_move = table.move
return
function(list, start_idx, len)
assert(is_natural(start_idx))
assert(is_natural(len))
local stop_idx = start_idx + len - 1
local result = { }
tbl_move(list, start_idx, stop_idx, 1, result)
return result
end
end
package.preload['workshop.concepts.list.to_string'] =
function(...)
local tbl_concat = table.concat
return
function(List, separator_str)
assert_table(List)
separator_str = separator_str or ''
assert_string(separator_str)
return tbl_concat(List, separator_str)
end
end
package.preload['workshop.concepts.lua.keywords'] =
function(...)
return
{
'nil',
'true',
'false',
'not',
'and',
'or',
'local',
'global',
'do',
'end',
'goto',
'if',
'then',
'elseif',
'else',
'while',
'repeat',
'until',
'for',
'in',
'break',
'function',
'return',
}
end
package.preload['workshop.concepts.lua.keywords_map'] =
function(...)
local keywords = request('keywords')
local map_values = request('!.table.map_values')
return map_values(keywords)
end
package.preload['workshop.concepts.lua.number_type_names'] =
function(...)
return { 'integer', 'float' }
end
package.preload['workshop.concepts.lua.run_formatter'] =
function(...)
local formatter_class = request('formatter.interface')
return
function(ast, options)
local formatter = formatter_class.create(options)
formatter:process_node(ast)
return formatter[1]:get_text()
end
end
package.preload['workshop.concepts.lua.syntax'] =
function(...)
local link = request('!.mechs.processor.link')
local optimize = request('!.mechs.processor.optimize')
local expression = request('syntax.expression')
local statements = request('syntax.statements')
local producers, consumers = { }, { }
link(expression, producers, consumers)
link(statements, producers, consumers)
assert(not next(consumers))
optimize(statements)
return statements
end
package.preload['workshop.concepts.lua.tokens_accessor'] =
function(...)
local is_name =
function(me)
return me:match_type('name')
end
local is_string =
function(me)
return me:match_type('string')
end
local is_number =
function(me)
return me:match_type('number')
end
local interface
local create
do
local typed_strings_class =
request('!.concepts.streams.seekable.input.typed_strings')
local merge = request('!.table.merge')
local attach_methods = request('!.table.attach_methods')
create =
function(tokens)
local me = typed_strings_class.create(tokens)
local base_interface = getmetatable(me).__index
merge(interface, base_interface)
attach_methods(me, interface)
return me
end
end
interface =
{
create = create,
is_name = is_name,
is_string = is_string,
is_number = is_number,
}
return interface
end
package.preload['workshop.concepts.lua.tokens_syntax'] =
function(...)
local delim = request('tokens_syntax.delim')
local string = request('tokens_syntax.string')
local number = request('tokens_syntax.number')
local name = request('tokens_syntax.name')
local syntel = request('tokens_syntax.syntel')
local handy = request('!.mechs.processor.handy')
local opt_rep = handy.opt_rep
local cho = handy.cho
return
{
delim,
opt_rep(
cho(
{ name = 'string', string },
{ name = 'number', number },
{ name = 'name', name },
{ name = 'syntel', syntel }
),
delim
),
}
end
package.preload['workshop.concepts.lua.transform_ast'] =
function(...)
local align_nodes = request('ast_transformer.align_nodes')
local restruc_nodes = request('ast_transformer.restruc_nodes')
local handlers = request('ast_transformer.handlers.interface')
return
function(syntax_tree)
for subnode_index in ipairs(syntax_tree) do
align_nodes(syntax_tree, subnode_index)
end
restruc_nodes(syntax_tree, handlers)
return syntax_tree
end
end
package.preload['workshop.concepts.lua.type_names'] =
function(...)
return
{
'nil',
'boolean',
'number',
'string',
'function',
'thread',
'userdata',
'table',
}
end
package.preload['workshop.concepts.lua.ast_transformer.align_nodes'] =
function(...)
local align_nodes
align_nodes =
function(parent, index)
local node = parent[index]
if not is_table(node) then
return
end
for subnode_index in ipairs(node) do
align_nodes(node, subnode_index)
end
if (#node == 1) and is_string(node[1]) then
node.value = node[1]
node[1] = nil
end
if (node.type == 'assign_or_call') then
if (node[1].type == 'function_call') then
node = node[1]
else
node.type = 'assignment'
end
elseif (node.type == 'var_or_call') then
if (node[#node].type == 'func_args') then
node.type = 'function_call'
else
node.type = 'var_ref'
end
elseif (node.type == 'local_statement') then
if (node[1].type == 'named_function') then
node[1].type = 'local_named_function'
else
node[1].type = 'local_assignment'
end
node = node[1]
end
parent[index] = node
end
return align_nodes
end
package.preload[
'workshop.concepts.lua.ast_transformer.restruc_nodes'
] =
function(...)
return
function(node, handlers)
local restruc_nodes
restruc_nodes =
function(node)
for _, subnode in ipairs(node) do
restruc_nodes(subnode)
end
local handler = handlers[node.type]
if handler then
handler(node)
end
end
restruc_nodes(node)
end
end
package.preload[
'workshop.concepts.lua.ast_transformer.handlers.assignment'
] =
function(...)
local add_to_list = request('!.concepts.list.add_item')
local replace = request('!.table.replace')
return
function(node)
local dest_list = { type = 'ref_list' }
for i = 1, (#node - 1) do
add_to_list(dest_list, node[i])
end
local result =
{ type = 'assignment', dest_list, node[#node] }
replace(node, result)
end
end
package.preload[
'workshop.concepts.lua.ast_transformer.handlers.expression'
] =
function(...)
local replace = request('!.table.replace')
local add_to_list = request('!.concepts.list.add_item')
return
function(node)
local result = { }
local i = 1
local num_items = #node
local term = { }
local un_ops = { }
while (i <= num_items) and (node[i].type == 'un_op') do
add_to_list(un_ops, node[i].value)
i = i + 1
end
term[1] = un_ops
term[2] = node[i]
node[i] = nil
i = i + 1
if (i < num_items) and (node[i].type == 'bin_op') then
term[3] = node[i].value
i = i + 1
end
add_to_list(result, term)
if (i == num_items) then
local last_node = node[i]
if (last_node.type == 'expression') then
for _, last_node_item in ipairs(last_node) do
add_to_list(result, last_node_item)
end
end
end
result.type = node.type
replace(node, result)
end
end
package.preload[
'workshop.concepts.lua.ast_transformer.handlers.function_call'
] =
function(...)
local add_to_list = request('!.concepts.list.add_item')
local replace = request('!.table.replace')
return
function(node)
local result
local name_part
local seek_pos = 0
while true do
if (seek_pos < #node) then
name_part = { result }
seek_pos = seek_pos + 1
else
break
end
name_part.type = 'name_parts'
while (node[seek_pos].type ~= 'func_args') do
add_to_list(name_part, node[seek_pos])
seek_pos = seek_pos + 1
end
result =
{ type = 'function_call', name_part, node[seek_pos] }
end
replace(node, result)
end
end
package.preload[
'workshop.concepts.lua.ast_transformer.handlers.interface'
] =
function(...)
return
{
['assignment'] = request('assignment'),
['expression'] = request('expression'),
['function_call'] = request('function_call'),
['var_ref'] = request('var_ref'),
}
end
package.preload[
'workshop.concepts.lua.ast_transformer.handlers.var_ref'
] =
function(...)
local add_to_list = request('!.concepts.list.add_item')
local replace = request('!.table.replace')
return
function(node)
local result
local name_parts
local seek_pos = 0
while true do
if (seek_pos < #node) then
name_parts = { result }
seek_pos = seek_pos + 1
else
break
end
while
(seek_pos <= #node) and
(node[seek_pos].type ~= 'func_args')
do
add_to_list(name_parts, node[seek_pos])
seek_pos = seek_pos + 1
end
name_parts.type = 'name_parts'
local args = node[seek_pos]
result = { name_parts, args }
if args then
result.type = 'function_call'
else
result.type = 'var_ref'
end
end
replace(node, result)
end
end
package.preload['workshop.concepts.lua.formatter.interface'] =
function(...)
local interface
local create
do
local default_right_margin = 72
local default_indent_chunk = ' '
local text_block = request('!.concepts.text_block')
local state_keeper_class = request('state_keeper')
local attach_methods = request('!.table.attach_methods')
create =
function(options)
local options = options or { }
local printer
do
local indent_chunk =
options.indent_chunk or default_indent_chunk
printer = text_block.create(indent_chunk)
end
local right_margin =
options.right_margin or default_right_margin
local state_keeper = state_keeper_class.create()
local me = { printer, right_margin, state_keeper }
attach_methods(me, interface)
return me
end
end
interface =
{
create = create,
handlers = request('handlers.interface'),
process_list = request('process_list'),
process_node = request('process_node'),
process_block_oneline = request('process_block_oneline'),
process_block_multiline = request('process_block_multiline'),
process_block = request('process_block'),
represent = request('represent'),
variate = request('variate'),
process_list_variative = request('process_list_variative'),
}
return interface
end
package.preload['workshop.concepts.lua.formatter.process_block'] =
function(...)
return
function(me, node, handler)
local result
me[1]:inc_indent()
if handler then
result = handler(me, node)
else
result = me:process_node(node)
end
me[1]:dec_indent()
return result
end
end
package.preload[
'workshop.concepts.lua.formatter.process_block_multiline'
] =
function(...)
return
function(me, prefix, node, postfix, opt_handler)
local printer = me[1]
if prefix then
printer:add_to_curline(prefix)
end
printer:request_clean_line()
local result = me:process_block(node, opt_handler)
printer:request_clean_line()
if postfix then
printer:add_to_curline(postfix)
end
return result
end
end
package.preload[
'workshop.concepts.lua.formatter.process_block_oneline'
] =
function(...)
return
function(me, prefix, node, postfix, opt_handler)
local printer = me[1]
if prefix then