<commit_before>#!/usr/bin/env lua
--- Print a Lua table containing a FusionScript AST.
-- @script fusion-ast
-- @author ChickenNuggers
-- @usage fusion-ast [FILE]
local argparse = require("argparse")
local parser = require("fusion.core.parser")
local serpent = require("serpent")

local argparser = argparse() {
	name = "fusion-ast";
	description = "Print a Lua table containing FusionScript AST";
	epilog = "For more info, see https://fusionscript.info";
}
argparser:argument("file", "File(s) to parse"):args("+")
local files = argparser:parse().file

local function read_file(file)
	local file_handler = assert(io.open(file))
	local line = file_handler:read()
	if line:sub(1, 2) == "#!" then
		print(serpent.block(parser:match(file_handler:read("*a"))))
	else
		print(serpent.block(parser:match(line .. '\n' ..
			file_handler:read("*a"))))
	end
	file_handler:close()
end

if #files > 1 then
	for file in ipairs(files) do
		print(("--- %s ---"):format(file))
		read_file(file)
	end
else
	read_file(files[1])
end
<commit_msg>fusion-ast: Remove annoying comments<commit_after>#!/usr/bin/env lua
--- Print a Lua table containing a FusionScript AST.
-- @script fusion-ast
-- @author ChickenNuggers
-- @usage fusion-ast [FILE]
local argparse = require("argparse")
local parser = require("fusion.core.parser")
local serpent = require("serpent")

local argparser = argparse() {
	name = "fusion-ast";
	description = "Print a Lua table containing FusionScript AST";
	epilog = "For more info, see https://fusionscript.info";
}
argparser:argument("file", "File(s) to parse"):args("+")
local files = argparser:parse().file

local function read_file(file)
	local file_handler = assert(io.open(file))
	local line = file_handler:read()
	if line:sub(1, 2) == "#!" then
		print(serpent.block(parser:match(file_handler:read("*a")),
			{comment = false}))
	else
		print(serpent.block(parser:match(line .. '\n' ..
			file_handler:read("*a")), {comment = false}))
	end
	file_handler:close()
end

if #files > 1 then
	for file in ipairs(files) do
		print(("--- %s ---"):format(file))
		read_file(file)
	end
else
	read_file(files[1])
end

{'fraction_non_alphanumeric': 0.16729678638941398, 'fraction_numerical': 0.003780718336483932, 'mean_word_length': 4.8805555555555555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4691254', 'n_tokens_mistral': 760, 'n_tokens_neox': 724, 'n_words': 187}