From 653db60651d95d725fb83d1752b9e796d6f29e65 Mon Sep 17 00:00:00 2001 From: Aleksey Chichenkov Date: Wed, 30 Jan 2019 16:53:12 +0300 Subject: [PATCH] fix replasing --- main.js | 7 +++++-- test.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index e5faca8..7a96193 100644 --- a/main.js +++ b/main.js @@ -18,6 +18,7 @@ exec("re2c -i " + inp, function(err, stdout, stderr) { }); var post_process_lexer = function (_string) { + var output = args["o"] || "lexer.js"; // replace start and end fbrackets _string = _string.replace(/START\n\{/gm, ""); @@ -25,7 +26,10 @@ var post_process_lexer = function (_string) { _string = _string.replace(/^.*(_r2c_var_.*;|unsigned int yyaccept = 0;)\n/gm, ""); // replace var yych; _string = _string.replace(/(yych = \*this._yy_cursor);\n/gm, "\tcase 1:\n yych = this._string[this._yy_cursor];\n"); // insert "case 1:" before; - _string = _string.replace(/\*(.*?);/gm, "this._string[$1];"); // замена разыменовываний + + _string = _string.replace(/\*\((.*?)\);/gm, "this._string[($1)];"); // замена разыменовываний + _string = _string.replace(/\*(.* ?);/gm, "this._string[$1];"); // замена разыменовываний + _string = _string.replace(/^yy(\d*?):/gm, "case $1:"); // replace goto marker onto case _string = _string.replace(/\) goto yy(\d*?);/gm, ") { id = $1; break; }"); // replace goto inside if _string = _string.replace(/goto yy(\d*?);/gm, "id = $1; break;"); // replace goto outside if @@ -55,7 +59,6 @@ var post_process_lexer = function (_string) { } } - var output = args["o"] || "lexer.js"; _string = process_metatags(_string); diff --git a/test.js b/test.js index b04cb0e..c61c373 100644 --- a/test.js +++ b/test.js @@ -4,7 +4,7 @@ var fs = require("fs"); var exec = require('child_process').exec; -exec("node main.js -o=lexer_test.js -t=node", function(err, stdout, stderr) { +exec("node main.js -o=lexer_test.js -t=node -logs", function(err, stdout, stderr) { err && console.log("ERROR: ", err); err && process.exit(1);