remove dependencies
This commit is contained in:
parent
a7873cc203
commit
8f914cc2d9
@ -6,8 +6,6 @@
|
||||
## Compile lemon-js
|
||||
```bash
|
||||
gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
|
||||
npm install
|
||||
# or
|
||||
./build.sh
|
||||
```
|
||||
|
||||
@ -90,3 +88,7 @@ Used re2js lexer from: [http://git.macaw.me:3000/chichenkov/re2-js-generator](ht
|
||||
|
||||
## Original project
|
||||
See https://github.com/sormy/lemon-js
|
||||
|
||||
## Links
|
||||
- Used js-beautify-node from: [https://github.com/rwaldron/js-beautify-node](https://github.com/rwaldron/js-beautify-node)
|
||||
- Used args-parser from: [https://www.npmjs.com/package/args-parser](https://www.npmjs.com/package/args-parser)
|
@ -2,8 +2,6 @@
|
||||
|
||||
gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
|
||||
|
||||
npm install
|
||||
|
||||
cat config.example > config.js
|
||||
|
||||
node main.js
|
2
build.sh
2
build.sh
@ -2,6 +2,4 @@
|
||||
|
||||
gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
|
||||
|
||||
npm install
|
||||
|
||||
cat config.template > config.js
|
@ -1,44 +1,17 @@
|
||||
/* Generated by re2c 1.0.3 on Wed Jan 30 13:09:24 2019 */
|
||||
var types = [
|
||||
"SLASH",
|
||||
"LSB",
|
||||
"RSB",
|
||||
"LCB",
|
||||
"RCB",
|
||||
"COLON",
|
||||
"COMMA",
|
||||
"DOT",
|
||||
"REM",
|
||||
"GT",
|
||||
"GTE",
|
||||
"LT",
|
||||
"LTE",
|
||||
"EQ",
|
||||
"NEQ",
|
||||
"LIKE",
|
||||
"NLIKE",
|
||||
"AND",
|
||||
"OR",
|
||||
"NOT",
|
||||
"ADDRESS",
|
||||
"OID",
|
||||
"OID_LITERAL",
|
||||
"TIME",
|
||||
"TIMEDIFF",
|
||||
"INTEGER_LITERAL",
|
||||
"FLOAT_LITERAL",
|
||||
"BOOL_LITERAL",
|
||||
"ID"
|
||||
];
|
||||
/* Generated by re2c 1.0.3 on Wed Jan 30 16:51:51 2019 */
|
||||
var types = ["SLASH", "LSB", "RSB", "LCB", "RCB", "COLON", "COMMA", "DOT", "REM", "GT", "GTE", "LT", "LTE", "EQ", "NEQ", "LIKE", "NLIKE", "AND", "OR", "NOT", "ADDRESS", "OID", "OID_LITERAL", "TIME", "TIMEDIFF", "INTEGER_LITERAL", "FLOAT_LITERAL", "BOOL_LITERAL", "ID"];
|
||||
|
||||
var errors = {
|
||||
"-2": "not found close quote or singleQuote",
|
||||
"-2": "end of search",
|
||||
"-1": "not found any lexemes or errors or anything else",
|
||||
"0": "success",
|
||||
"1": "found unknown symbol"
|
||||
"1": "found unknown symbol",
|
||||
"2": "not found close quote or singleQuote",
|
||||
"3": "Unexpected symbol in oid structure",
|
||||
"4": "Not found close bracket for Oid",
|
||||
};
|
||||
|
||||
var Test_lexer = function(_string) {
|
||||
var Lexer = function (_string) {
|
||||
this._last_found_lexeme = {
|
||||
error: -1
|
||||
};
|
||||
@ -53,10 +26,10 @@ var Test_lexer = function(_string) {
|
||||
this._yy_accept = 0;
|
||||
};
|
||||
|
||||
Test_lexer.prototype = {
|
||||
Lexer.prototype = {
|
||||
types: types,
|
||||
errors: errors,
|
||||
_notFoundCloseQuote: function() {
|
||||
_notFoundCloseQuote: function () {
|
||||
this._error = true;
|
||||
this._last_found_lexeme = {
|
||||
error: 2,
|
||||
@ -66,7 +39,7 @@ Test_lexer.prototype = {
|
||||
|
||||
console.log(print_f("Not found close quote start: %s", this._yy_cursor));
|
||||
},
|
||||
_unknownSymbol: function() {
|
||||
_unknownSymbol: function () {
|
||||
this._error = true;
|
||||
this._last_found_lexeme = {
|
||||
error: 1,
|
||||
@ -76,7 +49,7 @@ Test_lexer.prototype = {
|
||||
|
||||
console.log(print_f("Found unknown symbol on position: %s", this._yy_cursor));
|
||||
},
|
||||
_oidUnexpectedSymbol: function() {
|
||||
_oidUnexpectedSymbol: function () {
|
||||
this._error = true;
|
||||
this._last_found_lexeme = {
|
||||
error: 3,
|
||||
@ -86,7 +59,7 @@ Test_lexer.prototype = {
|
||||
|
||||
console.log(print_f("Found unknown symbol in Oid on position: %s", this._yy_cursor));
|
||||
},
|
||||
_oidNotFoundCloseBracket: function() {
|
||||
_oidNotFoundCloseBracket: function () {
|
||||
this._error = true;
|
||||
this._last_found_lexeme = {
|
||||
error: 4,
|
||||
@ -96,7 +69,7 @@ Test_lexer.prototype = {
|
||||
|
||||
console.log(print_f("Not found close bracket for Oid"));
|
||||
},
|
||||
_foundLexeme: function(_lexeme) {
|
||||
_foundLexeme: function (_lexeme) {
|
||||
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,
|
||||
@ -106,7 +79,7 @@ Test_lexer.prototype = {
|
||||
end: this._yy_cursor
|
||||
};
|
||||
},
|
||||
_foundOidLexeme: function(_lexeme, _lsb, _rsb) {
|
||||
_foundOidLexeme: function (_lexeme, _lsb, _rsb) {
|
||||
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,
|
||||
@ -118,14 +91,14 @@ Test_lexer.prototype = {
|
||||
rsb: _rsb
|
||||
};
|
||||
},
|
||||
_endOfString: function() {
|
||||
_endOfString: function () {
|
||||
console.log(print_f("search end\n"));
|
||||
this._end = true;
|
||||
this._last_found_lexeme = {
|
||||
error: -2
|
||||
};
|
||||
},
|
||||
_searchString: function() {
|
||||
_searchString: function () {
|
||||
var _quote = this._string[this._yy_cursor - 1];
|
||||
var found_back_slash = false;
|
||||
while (this._yy_cursor < this._string.length) {
|
||||
@ -164,14 +137,14 @@ Test_lexer.prototype = {
|
||||
|
||||
this._notFoundCloseQuote();
|
||||
},
|
||||
_searchOid: function() {
|
||||
_searchOid: function () {
|
||||
var lsb, rsb;
|
||||
var state = 0;
|
||||
while (this._yy_cursor < this._string.length) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
this._yy_char = this._string[this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case " ":
|
||||
state = 0;
|
||||
@ -191,7 +164,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 1:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case " ":
|
||||
state = 1;
|
||||
@ -218,7 +191,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 2:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case " ":
|
||||
case "0":
|
||||
@ -246,7 +219,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 3:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case " ":
|
||||
case "0":
|
||||
@ -282,22 +255,22 @@ Test_lexer.prototype = {
|
||||
|
||||
this._oidNotFoundCloseBracket();
|
||||
},
|
||||
_set_next: function() {
|
||||
_set_next: function () {
|
||||
this._yy_accept = 0;
|
||||
this._state = 1;
|
||||
this._yy_lex_start = this._yy_cursor;
|
||||
this._yy_marker = this._yy_cursor;
|
||||
},
|
||||
next: function() {
|
||||
next: function () {
|
||||
if (this._end || this._error) return null;
|
||||
|
||||
this.search();
|
||||
return this.token();
|
||||
},
|
||||
token: function() {
|
||||
token: function () {
|
||||
return this._last_found_lexeme;
|
||||
},
|
||||
search: function() {
|
||||
search: function () {
|
||||
if (this._end) return false;
|
||||
|
||||
while (true) {
|
||||
@ -306,7 +279,7 @@ Test_lexer.prototype = {
|
||||
|
||||
case 1:
|
||||
this._yy_char = this._string[this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case undefined:
|
||||
this._state = 2;
|
||||
@ -463,7 +436,8 @@ Test_lexer.prototype = {
|
||||
++this._yy_cursor;
|
||||
case 5:
|
||||
{
|
||||
this._unknownSymbol();this._set_next();
|
||||
this._unknownSymbol();
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 6:
|
||||
@ -473,7 +447,7 @@ Test_lexer.prototype = {
|
||||
}
|
||||
case 8:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '=':
|
||||
this._state = 50;
|
||||
@ -516,7 +490,7 @@ Test_lexer.prototype = {
|
||||
case 19:
|
||||
this._yy_accept = 0;
|
||||
this._yy_char = this._string[(this._yy_marker = ++this._yy_cursor)];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '.':
|
||||
this._state = 52;
|
||||
@ -541,7 +515,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 20:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -563,7 +537,8 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 21:
|
||||
{
|
||||
this._foundLexeme("DOT");this._set_next();
|
||||
this._foundLexeme("DOT");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 22:
|
||||
@ -575,7 +550,7 @@ Test_lexer.prototype = {
|
||||
case 24:
|
||||
this._yy_accept = 1;
|
||||
this._yy_char = this._string[(this._yy_marker = ++this._yy_cursor)];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '.':
|
||||
this._state = 52;
|
||||
@ -600,7 +575,8 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 26:
|
||||
{
|
||||
this._foundLexeme("INTEGER_LITERAL");this._set_next();
|
||||
this._foundLexeme("INTEGER_LITERAL");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 27:
|
||||
@ -611,7 +587,7 @@ Test_lexer.prototype = {
|
||||
}
|
||||
case 29:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '=':
|
||||
this._state = 57;
|
||||
@ -624,12 +600,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 30:
|
||||
{
|
||||
this._foundLexeme("LT");this._set_next();
|
||||
this._foundLexeme("LT");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 31:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '=':
|
||||
this._state = 59;
|
||||
@ -642,7 +619,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 32:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '=':
|
||||
this._state = 61;
|
||||
@ -655,12 +632,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 33:
|
||||
{
|
||||
this._foundLexeme("GT");this._set_next();
|
||||
this._foundLexeme("GT");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 34:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'N':
|
||||
case 'n':
|
||||
@ -677,13 +655,14 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 35:
|
||||
{
|
||||
this._foundLexeme("ID");this._set_next();
|
||||
this._foundLexeme("ID");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 36:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
case 37:
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -758,7 +737,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 38:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'A':
|
||||
case 'a':
|
||||
@ -772,7 +751,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 39:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'I':
|
||||
case 'i':
|
||||
@ -786,7 +765,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 40:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'L':
|
||||
case 'l':
|
||||
@ -804,7 +783,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 41:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'R':
|
||||
case 'r':
|
||||
@ -821,7 +800,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 42:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'R':
|
||||
case 'r':
|
||||
@ -850,7 +829,7 @@ Test_lexer.prototype = {
|
||||
}
|
||||
case 47:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'N':
|
||||
case 'n':
|
||||
@ -864,7 +843,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 48:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'R':
|
||||
case 'r':
|
||||
@ -878,7 +857,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 49:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'R':
|
||||
case 'r':
|
||||
@ -898,7 +877,7 @@ Test_lexer.prototype = {
|
||||
}
|
||||
case 52:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -934,7 +913,7 @@ Test_lexer.prototype = {
|
||||
case 54:
|
||||
this._yy_accept = 2;
|
||||
this._yy_char = this._string[(this._yy_marker = ++this._yy_cursor)];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -959,7 +938,8 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 56:
|
||||
{
|
||||
this._foundLexeme("FLOAT_LITERAL");this._set_next();
|
||||
this._foundLexeme("FLOAT_LITERAL");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 57:
|
||||
@ -982,7 +962,7 @@ Test_lexer.prototype = {
|
||||
}
|
||||
case 63:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'D':
|
||||
case 'd':
|
||||
@ -996,7 +976,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 64:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'd':
|
||||
this._state = 77;
|
||||
@ -1009,7 +989,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 65:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'L':
|
||||
case 'l':
|
||||
@ -1023,7 +1003,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 66:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'K':
|
||||
case 'k':
|
||||
@ -1037,7 +1017,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 67:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'I':
|
||||
case 'i':
|
||||
@ -1051,7 +1031,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 68:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'T':
|
||||
case 't':
|
||||
@ -1065,7 +1045,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 69:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1140,12 +1120,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 70:
|
||||
{
|
||||
this._foundLexeme("OR");this._set_next();
|
||||
this._foundLexeme("OR");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 71:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'd':
|
||||
this._state = 83;
|
||||
@ -1158,7 +1139,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 72:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'U':
|
||||
case 'u':
|
||||
@ -1172,7 +1153,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 73:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'm':
|
||||
this._state = 86;
|
||||
@ -1185,7 +1166,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 74:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '-':
|
||||
this._state = 87;
|
||||
@ -1210,7 +1191,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 75:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1285,12 +1266,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 76:
|
||||
{
|
||||
this._foundLexeme("AND");this._set_next();
|
||||
this._foundLexeme("AND");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 77:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'r':
|
||||
this._state = 90;
|
||||
@ -1303,7 +1285,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 78:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'S':
|
||||
case 's':
|
||||
@ -1317,7 +1299,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 79:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'E':
|
||||
case 'e':
|
||||
@ -1331,7 +1313,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 80:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'K':
|
||||
case 'k':
|
||||
@ -1345,7 +1327,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 81:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1420,12 +1402,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 82:
|
||||
{
|
||||
this._foundLexeme("NOT");this._set_next();
|
||||
this._foundLexeme("NOT");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 83:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1505,7 +1488,7 @@ Test_lexer.prototype = {
|
||||
}
|
||||
case 85:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'E':
|
||||
case 'e':
|
||||
@ -1519,7 +1502,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 86:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'e':
|
||||
this._state = 96;
|
||||
@ -1532,7 +1515,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 87:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1554,7 +1537,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 88:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1576,7 +1559,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 90:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'e':
|
||||
this._state = 98;
|
||||
@ -1589,7 +1572,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 91:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1664,12 +1647,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 92:
|
||||
{
|
||||
this._foundLexeme("LIKE");this._set_next();
|
||||
this._foundLexeme("LIKE");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 93:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'E':
|
||||
case 'e':
|
||||
@ -1683,7 +1667,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 94:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1758,12 +1742,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 95:
|
||||
{
|
||||
this._foundLexeme("BOOL_LITERAL");this._set_next();
|
||||
this._foundLexeme("BOOL_LITERAL");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 96:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1840,12 +1825,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 97:
|
||||
{
|
||||
this._foundLexeme("TIME");this._set_next();
|
||||
this._foundLexeme("TIME");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 98:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 's':
|
||||
this._state = 102;
|
||||
@ -1858,7 +1844,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 99:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -1933,12 +1919,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 100:
|
||||
{
|
||||
this._foundLexeme("NLIKE");this._set_next();
|
||||
this._foundLexeme("NLIKE");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 101:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'i':
|
||||
this._state = 103;
|
||||
@ -1951,7 +1938,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 102:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 's':
|
||||
this._state = 104;
|
||||
@ -1964,7 +1951,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 103:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'f':
|
||||
this._state = 106;
|
||||
@ -1977,7 +1964,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 104:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -2052,12 +2039,13 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 105:
|
||||
{
|
||||
this._foundLexeme("ADDRESS");this._set_next();
|
||||
this._foundLexeme("ADDRESS");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
case 106:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case 'f':
|
||||
this._state = 107;
|
||||
@ -2070,7 +2058,7 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 107:
|
||||
this._yy_char = this._string[++this._yy_cursor];
|
||||
(function() {
|
||||
(function () {
|
||||
switch (this._yy_char) {
|
||||
case '0':
|
||||
case '1':
|
||||
@ -2145,7 +2133,8 @@ Test_lexer.prototype = {
|
||||
break;
|
||||
case 108:
|
||||
{
|
||||
this._foundLexeme("TIMEDIFF");this._set_next();
|
||||
this._foundLexeme("TIMEDIFF");
|
||||
this._set_next();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2169,7 +2158,7 @@ Test_lexer.prototype = {
|
||||
|
||||
|
||||
|
||||
var print_f = function() {
|
||||
var print_f = function () {
|
||||
var r_str = "";
|
||||
var next = arguments[0];
|
||||
|
||||
@ -2206,4 +2195,7 @@ var print_f = function() {
|
||||
|
||||
return r_str;
|
||||
};
|
||||
module.exports = Test_lexer
|
||||
|
||||
|
||||
(new Lexer("[")).search();
|
||||
module.exports = Lexer
|
41
libs/args-parser.js
Normal file
41
libs/args-parser.js
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/30/19.
|
||||
*/
|
||||
|
||||
function Parse (argv) {
|
||||
// Removing node/bin and called script name
|
||||
argv = argv.slice(2);
|
||||
|
||||
// Returned object
|
||||
var args = {};
|
||||
|
||||
var argName, argValue;
|
||||
|
||||
// For each argument
|
||||
argv.forEach(function (arg, index) {
|
||||
// Seperate argument, for a key/value return
|
||||
arg = arg.split('=');
|
||||
|
||||
// Retrieve the argument name
|
||||
argName = arg[0];
|
||||
|
||||
// Remove "--" or "-"
|
||||
if (argName.indexOf('-') === 0) {
|
||||
argName = argName.slice(argName.slice(0, 2).lastIndexOf('-') + 1);
|
||||
}
|
||||
|
||||
// Associate defined value or initialize it to "true" state
|
||||
argValue = (arg.length === 2)
|
||||
? parseFloat(arg[1]).toString() === arg[1] // check if argument is valid number
|
||||
? +arg[1]
|
||||
: arg[1]
|
||||
: true;
|
||||
|
||||
// Finally add the argument to the args set
|
||||
args[argName] = argValue;
|
||||
});
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
module.exports = Parse;
|
1179
libs/js-beautifier.js
Normal file
1179
libs/js-beautifier.js
Normal file
File diff suppressed because it is too large
Load Diff
13
main.js
13
main.js
@ -2,8 +2,8 @@
|
||||
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/28/19.
|
||||
*/
|
||||
|
||||
var js_beautify = require("js-beautify");
|
||||
var args = require("args-parser")(process.argv);
|
||||
var js_beautify = require("./libs/js-beautifier");
|
||||
var args = require("./libs/args-parser")(process.argv);
|
||||
var fs = require("fs");
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
@ -55,7 +55,14 @@ var post_process_parser = function () {
|
||||
}
|
||||
}
|
||||
|
||||
out_js = js_beautify(out_js, {indent_size: 4, space_in_empty_paren: true});
|
||||
out_js = js_beautify(out_js, {
|
||||
indent_size: 4,
|
||||
indent_char: ' ',
|
||||
preserve_newlines: true,
|
||||
space_after_anon_function: true,
|
||||
keep_array_indentation: false,
|
||||
braces_on_own_line: false
|
||||
});
|
||||
|
||||
if(!fs.existsSync(output_path)){
|
||||
fs.mkdirSync(output_path);
|
||||
|
@ -7,8 +7,5 @@
|
||||
"name": "chichenkov",
|
||||
"email": "rolahd@yandex.ru"
|
||||
},
|
||||
"dependencies": {
|
||||
"args-parser": "^1.1.0",
|
||||
"js-beautify": "^1.8.9"
|
||||
}
|
||||
"dependencies": {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user