NEW
|
local base = require("outputters.base") |
× |
2 |
|
|
NEW
|
local outputter = pl.class(base) |
× |
NEW
|
outputter._name = "ast"
|
× |
NEW
|
outputter.extension = "ast"
|
× |
6 |
|
|
7 |
local outfile |
|
8 |
|
|
NEW
|
function outputter:_ensureInit () |
× |
NEW
|
if not outfile then |
× |
NEW
|
local fname = self:getOutputFilename() |
× |
NEW
|
outfile = fname == "-" and io.stdout or io.open(fname, "w+") |
× |
13 |
end
|
|
14 |
end
|
|
15 |
|
|
NEW
|
function outputter:preProcess (ast) |
× |
NEW
|
self:_ensureInit() |
× |
NEW
|
local prettyprinted = pl.pretty.write(ast, " ") |
× |
NEW
|
outfile:write(prettyprinted) |
× |
20 |
end
|
|
21 |
|
|
NEW
|
function outputter:finish () |
× |
NEW
|
self:runHooks("prefinish")
|
× |
NEW
|
outfile:close() |
× |
25 |
end
|
|
26 |
|
|
NEW
|
return outputter
|
× |