-
Notifications
You must be signed in to change notification settings - Fork 256
Open
Description
test.lua :
#!/usr/bin/env lua
local pretty = require("pl.pretty")
local lexer = require("pl.lexer")
-- 1234
--- 5678
--[=[
local function get_1212121212(file_path)
end
]=]
function parse(lua_code)
local lexical, f = lexer.lua(lua_code) --, {space=true, comments=false})
local items = {}
for t, v in lexical do
local line = lexer.lineno(lexical)
table.insert(items, {t, v, line})
end
return items
end
local function get_luafunctions(file_path)
local lines = io.lines(file_path)
local file = assert(io.open(file_path))
local lua_lexical = parse(file)
pretty.dump(lua_lexical)
end
local file = arg[1]
get_luafunctions(file)
execute on lua5.1.4, ./test.lua test.lua
--[=[
local function get_1212121212(file_path)
end
]=]
at line 7:10 lexer result:
{
"keyword",
"local",
8
},
{
"keyword",
"function",
8
},
{
"iden",
"get_1212121212",
8
},
{
"(",
"(",
8
},
{
"iden",
"file_path",
8
},
{
")",
")",
8
},
{
"keyword",
"end",
9
},
{
[=[]]=],
[=[]]=],
10
},
{
"=",
"=",
10
},
{
[=[]]=],
[=[]]=],
10
},
Metadata
Metadata
Assignees
Labels
No labels