|
|
|
@ -16,7 +16,8 @@ if(args["c"] !== undefined) { |
|
|
|
|
|
|
|
|
|
var program_path = config.lemon_bin; |
|
|
|
|
var lemon_flags = config.flags; |
|
|
|
|
var parser_path = config.out_path; |
|
|
|
|
var input_path = config.input_path; |
|
|
|
|
var output_path = config.output_path; |
|
|
|
|
var file_name = config.file_name; |
|
|
|
|
|
|
|
|
|
var fn_y = file_name + ".y"; |
|
|
|
@ -29,17 +30,17 @@ var temp_fn_out = "temp_" + "file_name" + ".out"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var update_parser_y = function () { |
|
|
|
|
var source_parser_y = fs.readFileSync(parser_path + fn_y, "utf8"); |
|
|
|
|
var source_parser_y = fs.readFileSync(input_path + fn_y, "utf8"); |
|
|
|
|
|
|
|
|
|
source_parser_y = source_parser_y.replace(/&&.*?REPLACER\{(.*?)\}&&/gm, function (match, file_path, offset, string) { |
|
|
|
|
return fs.readFileSync(file_path, "utf8"); |
|
|
|
|
return fs.readFileSync("./" + input_path + file_path, "utf8"); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
fs.writeFileSync(parser_path + temp_fn_y, source_parser_y); |
|
|
|
|
fs.writeFileSync(input_path + temp_fn_y, source_parser_y); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var post_process_parser = function () { |
|
|
|
|
var out_js = fs.readFileSync(parser_path + temp_fn_js, "utf8"); |
|
|
|
|
var out_js = fs.readFileSync(input_path + temp_fn_js, "utf8"); |
|
|
|
|
|
|
|
|
|
if (args["t"] !== undefined) { |
|
|
|
|
switch (args["t"]) { |
|
|
|
@ -56,24 +57,28 @@ var post_process_parser = function () { |
|
|
|
|
|
|
|
|
|
out_js = js_beautify(out_js, {indent_size: 4, space_in_empty_paren: true}); |
|
|
|
|
|
|
|
|
|
fs.writeFileSync(parser_path + fn_js, out_js); |
|
|
|
|
if(!fs.existsSync(output_path)){ |
|
|
|
|
fs.mkdirSync(output_path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fs.writeFileSync(output_path + fn_js, out_js); |
|
|
|
|
|
|
|
|
|
var temp_parser_out = fs.readFileSync(parser_path + temp_fn_out, "utf8"); |
|
|
|
|
fs.writeFileSync(parser_path + fn_out, temp_parser_out); |
|
|
|
|
var temp_parser_out = fs.readFileSync(input_path + temp_fn_out, "utf8"); |
|
|
|
|
fs.writeFileSync(output_path + fn_out, temp_parser_out); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var start = function () { |
|
|
|
|
update_parser_y(); |
|
|
|
|
|
|
|
|
|
exec(program_path + " " + parser_path + temp_fn_y + " " + lemon_flags, function(err, stdout, stderr) { |
|
|
|
|
exec(program_path + " " + input_path + temp_fn_y + " " + lemon_flags, function(err, stdout, stderr) { |
|
|
|
|
err && console.log("ERROR: ", err); |
|
|
|
|
err && process.exit(1); |
|
|
|
|
|
|
|
|
|
post_process_parser(); |
|
|
|
|
|
|
|
|
|
fs.unlinkSync(parser_path + temp_fn_y); |
|
|
|
|
fs.unlinkSync(parser_path + temp_fn_js); |
|
|
|
|
fs.unlinkSync(parser_path + temp_fn_out); |
|
|
|
|
fs.unlinkSync(input_path + temp_fn_y); |
|
|
|
|
fs.unlinkSync(input_path + temp_fn_js); |
|
|
|
|
fs.unlinkSync(input_path + temp_fn_out); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|