-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[~] [code] [~] [rockspec] [~] [readme]
- Loading branch information
Ian
committed
Nov 4, 2017
1 parent
ce86171
commit dfa81b9
Showing
405 changed files
with
4,116 additions
and
3,084 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local get_params = request('get_ast.get_params') | ||
local convert = request('!.file.convert') | ||
local get_ast = request('!.lua.code.get_ast') | ||
|
||
return | ||
function(args) | ||
local f_in_name, f_out_name = get_params(args) | ||
if not f_in_name then | ||
return | ||
end | ||
convert( | ||
{ | ||
f_in_name = f_in_name, | ||
f_out_name = f_out_name, | ||
parse = get_ast, | ||
} | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--[[ | ||
Parse table with command line and return | ||
<f_in_name> <f_out_name> | ||
of fail and return nil. | ||
]] | ||
|
||
local usage_text = | ||
[[ | ||
Get annotated syntax tree (AST) for Lua 5.3 code. | ||
lua.get_ast <f_in> [<f_out>] | ||
-- Martin, 2017-10-14 | ||
]] | ||
|
||
local cmdline_processor = | ||
new(request('!.mechs.command_line_processor.interface')) | ||
cmdline_processor.allowed_params = | ||
{ | ||
{name = 'f_in_name', type = 'string'}, | ||
{name = 'f_out_name', type = 'string'}, | ||
} | ||
|
||
return | ||
function(args) | ||
assert_table(args) | ||
if not args[1] or (args[1] == '--help') then | ||
print(usage_text) | ||
return | ||
end | ||
|
||
local params = cmdline_processor:run(args) | ||
if not params.f_in_name then | ||
print(usage_text) | ||
return | ||
end | ||
|
||
local f_in_name, f_out_name | ||
f_in_name = params.f_in_name | ||
f_out_name = params.f_out_name or (f_in_name .. '.ast') | ||
|
||
return f_in_name, f_out_name | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
local get_params = request('get_formatter_ast.get_params') | ||
local convert = request('!.file.convert') | ||
local get_ast = request('!.lua.code.get_ast') | ||
local formatter_preprocess = request('!.formats.lua.save.formatter.preprocess') | ||
|
||
local parse = | ||
function(s) | ||
local result | ||
result = get_ast(s) | ||
result = formatter_preprocess(result, true) --second parameter is <keep_comments> | ||
return result | ||
end | ||
|
||
return | ||
function(args) | ||
local f_in_name, f_out_name = get_params(args) | ||
if not f_in_name then | ||
return | ||
end | ||
convert( | ||
{ | ||
f_in_name = f_in_name, | ||
f_out_name = f_out_name, | ||
parse = parse, | ||
} | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--[[ | ||
Parse table with command line and return | ||
<f_in_name> <f_out_name> | ||
or fail and return nil. | ||
]] | ||
|
||
local usage_text = | ||
[[ | ||
Get transformed annotated syntax tree (AST) for Lua 5.3 code. | ||
lua.get_formatter_ast <f_in> [<f_out>] | ||
-- Martin, 2017-10-14 | ||
]] | ||
|
||
local cmdline_processor = | ||
new(request('!.mechs.command_line_processor.interface')) | ||
cmdline_processor.allowed_params = | ||
{ | ||
{name = 'f_in_name', type = 'string'}, | ||
{name = 'f_out_name', type = 'string'}, | ||
} | ||
|
||
return | ||
function(args) | ||
assert_table(args) | ||
if not args[1] or (args[1] == '--help') then | ||
print(usage_text) | ||
return | ||
end | ||
|
||
local params = cmdline_processor:run(args) | ||
if not params.f_in_name then | ||
print(usage_text) | ||
return | ||
end | ||
|
||
local f_in_name, f_out_name | ||
f_in_name = params.f_in_name | ||
f_out_name = params.f_out_name or (f_in_name .. '.fast') | ||
|
||
return f_in_name, f_out_name | ||
end |
Oops, something went wrong.