Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Reads a program file (without executing it)
- and returns a table with meta tags.
- ]]
- function parse(filename)
- local file = fs.open(filename, "r")
- local line = ""
- local result = {}
- local hasMatched = false
- while true do
- line = file.readLine()
- if line == nil then break end
- local metadata, key, prm, value = line:match("(%-%-%s-@(%w+)%s-%[?(%w-)]?:%s(.+))")
- if metadata ~= nil then
- hasMatched = true
- result[#result + 1] = { [key] = value, param = prm }
- elseif (metadata == nil and hasMatched) and line ~= nil and line ~= "" then
- break
- end
- end
- file.close()
- return result
- end
Advertisement
Add Comment
Please, Sign In to add comment