Skip to content

Commit dfa81b9

Browse files
author
Ian
committed
[!~] Sync with [2017-10] version.
[~] [code] [~] [rockspec] [~] [readme]
1 parent ce86171 commit dfa81b9

File tree

405 files changed

+4116
-3084
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

405 files changed

+4116
-3084
lines changed

#mechs/generic_file_converter.lua

Lines changed: 0 additions & 70 deletions
This file was deleted.

#mechs/msg_with_time.lua

Lines changed: 0 additions & 11 deletions
This file was deleted.

#mechs/represent_size.lua

Lines changed: 0 additions & 18 deletions
This file was deleted.

get_ast.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
local get_params = request('get_ast.get_params')
2+
local convert = request('!.file.convert')
3+
local get_ast = request('!.lua.code.get_ast')
4+
5+
return
6+
function(args)
7+
local f_in_name, f_out_name = get_params(args)
8+
if not f_in_name then
9+
return
10+
end
11+
convert(
12+
{
13+
f_in_name = f_in_name,
14+
f_out_name = f_out_name,
15+
parse = get_ast,
16+
}
17+
)
18+
end

get_ast/get_params.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--[[
2+
Parse table with command line and return
3+
4+
<f_in_name> <f_out_name>
5+
6+
of fail and return nil.
7+
]]
8+
9+
local usage_text =
10+
[[
11+
Get annotated syntax tree (AST) for Lua 5.3 code.
12+
13+
lua.get_ast <f_in> [<f_out>]
14+
15+
-- Martin, 2017-10-14
16+
]]
17+
18+
local cmdline_processor =
19+
new(request('!.mechs.command_line_processor.interface'))
20+
cmdline_processor.allowed_params =
21+
{
22+
{name = 'f_in_name', type = 'string'},
23+
{name = 'f_out_name', type = 'string'},
24+
}
25+
26+
return
27+
function(args)
28+
assert_table(args)
29+
if not args[1] or (args[1] == '--help') then
30+
print(usage_text)
31+
return
32+
end
33+
34+
local params = cmdline_processor:run(args)
35+
if not params.f_in_name then
36+
print(usage_text)
37+
return
38+
end
39+
40+
local f_in_name, f_out_name
41+
f_in_name = params.f_in_name
42+
f_out_name = params.f_out_name or (f_in_name .. '.ast')
43+
44+
return f_in_name, f_out_name
45+
end

get_formatter_ast.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
local get_params = request('get_formatter_ast.get_params')
2+
local convert = request('!.file.convert')
3+
local get_ast = request('!.lua.code.get_ast')
4+
local formatter_preprocess = request('!.formats.lua.save.formatter.preprocess')
5+
6+
local parse =
7+
function(s)
8+
local result
9+
result = get_ast(s)
10+
result = formatter_preprocess(result, true) --second parameter is <keep_comments>
11+
return result
12+
end
13+
14+
return
15+
function(args)
16+
local f_in_name, f_out_name = get_params(args)
17+
if not f_in_name then
18+
return
19+
end
20+
convert(
21+
{
22+
f_in_name = f_in_name,
23+
f_out_name = f_out_name,
24+
parse = parse,
25+
}
26+
)
27+
end

get_formatter_ast/get_params.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--[[
2+
Parse table with command line and return
3+
4+
<f_in_name> <f_out_name>
5+
6+
or fail and return nil.
7+
]]
8+
9+
local usage_text =
10+
[[
11+
Get transformed annotated syntax tree (AST) for Lua 5.3 code.
12+
13+
lua.get_formatter_ast <f_in> [<f_out>]
14+
15+
-- Martin, 2017-10-14
16+
]]
17+
18+
local cmdline_processor =
19+
new(request('!.mechs.command_line_processor.interface'))
20+
cmdline_processor.allowed_params =
21+
{
22+
{name = 'f_in_name', type = 'string'},
23+
{name = 'f_out_name', type = 'string'},
24+
}
25+
26+
return
27+
function(args)
28+
assert_table(args)
29+
if not args[1] or (args[1] == '--help') then
30+
print(usage_text)
31+
return
32+
end
33+
34+
local params = cmdline_processor:run(args)
35+
if not params.f_in_name then
36+
print(usage_text)
37+
return
38+
end
39+
40+
local f_in_name, f_out_name
41+
f_in_name = params.f_in_name
42+
f_out_name = params.f_out_name or (f_in_name .. '.fast')
43+
44+
return f_in_name, f_out_name
45+
end

0 commit comments

Comments
 (0)