This commit is contained in:
Aleksey Chichenkov 2019-01-29 12:09:17 +03:00
parent c87b2ccde9
commit 62bf16fdcd
3 changed files with 16 additions and 10 deletions

View File

@ -22,9 +22,9 @@ node test.js --c=<your_config>.js
``` ```
## Also ## Also
You can use this syntax for include your code here. You can use this syntax for include your *.y file.
```bash ```bash
<&&REPLACER{<file_path>}&&> <&&REPLACER{<file_path>}&&>
``` ```
## Special Directives ## Special Directives

21
main.js
View File

@ -31,15 +31,20 @@ var temp_fn_out = "temp_" + "file_name" + ".out";
var update_parser_y = function () { var update_parser_y = function () {
var source_parser_y = fs.readFileSync(parser_path + fn_y, "utf8"); var source_parser_y = fs.readFileSync(parser_path + fn_y, "utf8");
var result = /&&.*?REPLACER\{(.*?)\}&&/gm.exec(source_parser_y); source_parser_y = source_parser_y.replace(/&&.*?REPLACER\{(.*?)\}&&/gm, function (match, file_path, offset, string) {
if(result) { return fs.readFileSync(file_path, "utf8");
var file_path = result[1]; });
var process_code = fs.readFileSync(file_path, "utf8");
source_parser_y = source_parser_y.replace(/&&.*?REPLACER\{(.*?)\}&&/gm, process_code); fs.writeFileSync(parser_path + temp_fn_y, source_parser_y);
// var result = /&&.*?REPLACER\{(.*?)\}&&/gm.exec(source_parser_y);
fs.writeFileSync(parser_path + temp_fn_y, source_parser_y); // if(result) {
} // var file_path = result[1];
// var process_code = fs.readFileSync(file_path, "utf8");
//
// source_parser_y = source_parser_y.replace(/&&.*?REPLACER\{(.*?)\}&&/gm, process_code);
//
// fs.writeFileSync(parser_path + temp_fn_y, source_parser_y);
// }
}; };
var post_process_parser = function () { var post_process_parser = function () {

View File

@ -4,6 +4,7 @@
var fs = require("fs"); var fs = require("fs");
var exec = require('child_process').exec; var exec = require('child_process').exec;
var args = require("args-parser")(process.argv);
var cfg_path = "config.js"; var cfg_path = "config.js";
var config; var config;