oid add to lexer
This commit is contained in:
parent
a5991c4e55
commit
37563c749f
10
lexer.l
10
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; }
|
||||
|
2
main.js
2
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";
|
||||
|
6
test.js
6
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");
|
||||
};
|
Loading…
Reference in New Issue
Block a user