aboutsummaryrefslogtreecommitdiff
path: root/examples/typedlua/tlp.lua
blob: 2a4a73667fb8050c7b3306cb80632dd2285fe188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local tlparser = require "tlparser"

local function getcontents(filename)
  file = assert(io.open(filename, "r"))
  contents = file:read("*a")
  file:close()
  return contents
end

if #arg ~= 1 then
  print ("Usage: lua tlp.lua <file>")
  os.exit(1)
end

local filename = arg[1]
local subject = getcontents(filename)
local r, msg = tlparser.parse(subject, filename, false, true)
if not r then print(msg) end

os.exit(0)