From 37563c749f0a3a3651dbb99cdc13ace0d26e5abe Mon Sep 17 00:00:00 2001 From: Aleksey Chichenkov Date: Mon, 28 Jan 2019 18:36:41 +0300 Subject: [PATCH] oid add to lexer --- lexer.l | 10 +++++++--- main.js | 2 +- test.js | 6 ++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lexer.l b/lexer.l index 705608b..01f43da 100644 --- a/lexer.l +++ b/lexer.l @@ -19,6 +19,7 @@ var types = [ "OR", "NOT", "ADDRESS", + "OID", "TIME", "TIMEDIFF", "INTEGER_LITERAL", @@ -74,9 +75,10 @@ Lexer.prototype = { console.log(print_f("found lex: %s; start: %s; end: %s; result => %s", _lexeme, this._yy_lex_start, this._yy_cursor, this._string.substring(this._yy_lex_start, this._yy_cursor))); this._last_found_lexeme = { error: 0, - lexeme: _lexeme, - start: this._yy_lex_start, - end: this._yy_cursor + lexeme: _lexeme, + value: this._string.substring(this._yy_lex_start, this._yy_cursor), + start: this._yy_lex_start, + end: this._yy_cursor }; }, _endOfString: function(){ @@ -187,6 +189,7 @@ Lexer.prototype = { ADDRESS = "Address"; TIME = "Time"; + OID = "Oid"; TIMEDIFF = "TimeDiff"; BOOL_LITERAL = 'true'|'false'; @@ -227,6 +230,7 @@ Lexer.prototype = { ADDRESS { this._foundLexeme("ADDRESS"); this._set_next(); return; } TIME { this._foundLexeme("TIME"); this._set_next(); return; } TIMEDIFF { this._foundLexeme("TIMEDIFF"); this._set_next(); return; } + OID { this._foundLexeme("OID"); this._set_next(); return; } INTEGER_LITERAL { this._foundLexeme("INTEGER_LITERAL"); this._set_next(); return; } FLOAT_LITERAL { this._foundLexeme("FLOAT_LITERAL"); this._set_next(); return; } diff --git a/main.js b/main.js index ed11cd4..bac34b9 100644 --- a/main.js +++ b/main.js @@ -42,7 +42,7 @@ var post_process_lexer = function (_string) { if(args["t"] !== undefined) { switch (args["t"]) { case "web": - _string = "(function(){\n" + _string + "return Lexer; \n})"; + _string = "(function(){\n" + _string + "return Lexer; \n})()"; break; case "node": _string += "\n module.exports = Lexer"; diff --git a/test.js b/test.js index 4f2422c..258b25d 100644 --- a/test.js +++ b/test.js @@ -8,10 +8,6 @@ exec("node main.js -o=lexer_test.js -t=node", function(err, stdout, stderr) { err && console.log("ERROR: ", err); err && process.exit(1); - var file = fs.readFileSync("lexer_test.js", "utf8"); - file += "\n module.exports = Lexer"; - fs.writeFileSync("lexer_test.js", file); - test(); fs.unlinkSync("lexer_test.js"); @@ -46,6 +42,7 @@ var test = function() { (new Lexer("NLIKE")).search(); (new Lexer("nlike")).search(); (new Lexer("Address")).search(); + (new Lexer("Oid")).search(); (new Lexer("Time")).search(); (new Lexer("TimeDiff")).search(); @@ -59,4 +56,5 @@ var test = function() { (new Lexer(' "111\\\"11\\\"1" "222222" ')).search(); (new Lexer(" '111\\\'11\\\'1' '222222' ")).search(); + console.log("\nSuccess tests\n"); }; \ No newline at end of file