remove dependencies

This commit is contained in:
Aleksey Chichenkov 2019-01-30 18:03:10 +03:00
parent a7873cc203
commit 8f914cc2d9
9 changed files with 3266 additions and 2052 deletions

View File

@ -6,8 +6,6 @@
## Compile lemon-js ## Compile lemon-js
```bash ```bash
gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
npm install
# or
./build.sh ./build.sh
``` ```
@ -90,3 +88,7 @@ Used re2js lexer from: [http://git.macaw.me:3000/chichenkov/re2-js-generator](ht
## Original project ## Original project
See https://github.com/sormy/lemon-js 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)

View File

@ -2,8 +2,6 @@
gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
npm install
cat config.example > config.js cat config.example > config.js
node main.js node main.js

View File

@ -2,6 +2,4 @@
gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
npm install
cat config.template > config.js cat config.template > config.js

View File

@ -1,44 +1,17 @@
/* Generated by re2c 1.0.3 on Wed Jan 30 13:09:24 2019 */ /* Generated by re2c 1.0.3 on Wed Jan 30 16:51:51 2019 */
var types = [ 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"];
"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 = { var errors = {
"-2": "not found close quote or singleQuote", "-2": "end of search",
"-1": "not found any lexemes or errors or anything else", "-1": "not found any lexemes or errors or anything else",
"0": "success", "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 = { this._last_found_lexeme = {
error: -1 error: -1
}; };
@ -53,10 +26,10 @@ var Test_lexer = function(_string) {
this._yy_accept = 0; this._yy_accept = 0;
}; };
Test_lexer.prototype = { Lexer.prototype = {
types: types, types: types,
errors: errors, errors: errors,
_notFoundCloseQuote: function() { _notFoundCloseQuote: function () {
this._error = true; this._error = true;
this._last_found_lexeme = { this._last_found_lexeme = {
error: 2, error: 2,
@ -66,7 +39,7 @@ Test_lexer.prototype = {
console.log(print_f("Not found close quote start: %s", this._yy_cursor)); console.log(print_f("Not found close quote start: %s", this._yy_cursor));
}, },
_unknownSymbol: function() { _unknownSymbol: function () {
this._error = true; this._error = true;
this._last_found_lexeme = { this._last_found_lexeme = {
error: 1, error: 1,
@ -76,7 +49,7 @@ Test_lexer.prototype = {
console.log(print_f("Found unknown symbol on position: %s", this._yy_cursor)); console.log(print_f("Found unknown symbol on position: %s", this._yy_cursor));
}, },
_oidUnexpectedSymbol: function() { _oidUnexpectedSymbol: function () {
this._error = true; this._error = true;
this._last_found_lexeme = { this._last_found_lexeme = {
error: 3, error: 3,
@ -86,7 +59,7 @@ Test_lexer.prototype = {
console.log(print_f("Found unknown symbol in Oid on position: %s", this._yy_cursor)); console.log(print_f("Found unknown symbol in Oid on position: %s", this._yy_cursor));
}, },
_oidNotFoundCloseBracket: function() { _oidNotFoundCloseBracket: function () {
this._error = true; this._error = true;
this._last_found_lexeme = { this._last_found_lexeme = {
error: 4, error: 4,
@ -96,7 +69,7 @@ Test_lexer.prototype = {
console.log(print_f("Not found close bracket for Oid")); 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))); 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 = { this._last_found_lexeme = {
error: 0, error: 0,
@ -106,7 +79,7 @@ Test_lexer.prototype = {
end: this._yy_cursor 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))); 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 = { this._last_found_lexeme = {
error: 0, error: 0,
@ -118,14 +91,14 @@ Test_lexer.prototype = {
rsb: _rsb rsb: _rsb
}; };
}, },
_endOfString: function() { _endOfString: function () {
console.log(print_f("search end\n")); console.log(print_f("search end\n"));
this._end = true; this._end = true;
this._last_found_lexeme = { this._last_found_lexeme = {
error: -2 error: -2
}; };
}, },
_searchString: function() { _searchString: function () {
var _quote = this._string[this._yy_cursor - 1]; var _quote = this._string[this._yy_cursor - 1];
var found_back_slash = false; var found_back_slash = false;
while (this._yy_cursor < this._string.length) { while (this._yy_cursor < this._string.length) {
@ -164,14 +137,14 @@ Test_lexer.prototype = {
this._notFoundCloseQuote(); this._notFoundCloseQuote();
}, },
_searchOid: function() { _searchOid: function () {
var lsb, rsb; var lsb, rsb;
var state = 0; var state = 0;
while (this._yy_cursor < this._string.length) { while (this._yy_cursor < this._string.length) {
switch (state) { switch (state) {
case 0: case 0:
this._yy_char = this._string[this._yy_cursor]; this._yy_char = this._string[this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case " ": case " ":
state = 0; state = 0;
@ -191,7 +164,7 @@ Test_lexer.prototype = {
break; break;
case 1: case 1:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case " ": case " ":
state = 1; state = 1;
@ -218,7 +191,7 @@ Test_lexer.prototype = {
break; break;
case 2: case 2:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case " ": case " ":
case "0": case "0":
@ -246,7 +219,7 @@ Test_lexer.prototype = {
break; break;
case 3: case 3:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case " ": case " ":
case "0": case "0":
@ -282,22 +255,22 @@ Test_lexer.prototype = {
this._oidNotFoundCloseBracket(); this._oidNotFoundCloseBracket();
}, },
_set_next: function() { _set_next: function () {
this._yy_accept = 0; this._yy_accept = 0;
this._state = 1; this._state = 1;
this._yy_lex_start = this._yy_cursor; this._yy_lex_start = this._yy_cursor;
this._yy_marker = this._yy_cursor; this._yy_marker = this._yy_cursor;
}, },
next: function() { next: function () {
if (this._end || this._error) return null; if (this._end || this._error) return null;
this.search(); this.search();
return this.token(); return this.token();
}, },
token: function() { token: function () {
return this._last_found_lexeme; return this._last_found_lexeme;
}, },
search: function() { search: function () {
if (this._end) return false; if (this._end) return false;
while (true) { while (true) {
@ -306,7 +279,7 @@ Test_lexer.prototype = {
case 1: case 1:
this._yy_char = this._string[this._yy_cursor]; this._yy_char = this._string[this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case undefined: case undefined:
this._state = 2; this._state = 2;
@ -463,7 +436,8 @@ Test_lexer.prototype = {
++this._yy_cursor; ++this._yy_cursor;
case 5: case 5:
{ {
this._unknownSymbol();this._set_next(); this._unknownSymbol();
this._set_next();
return; return;
} }
case 6: case 6:
@ -473,7 +447,7 @@ Test_lexer.prototype = {
} }
case 8: case 8:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '=': case '=':
this._state = 50; this._state = 50;
@ -516,7 +490,7 @@ Test_lexer.prototype = {
case 19: case 19:
this._yy_accept = 0; this._yy_accept = 0;
this._yy_char = this._string[(this._yy_marker = ++this._yy_cursor)]; this._yy_char = this._string[(this._yy_marker = ++this._yy_cursor)];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '.': case '.':
this._state = 52; this._state = 52;
@ -541,7 +515,7 @@ Test_lexer.prototype = {
break; break;
case 20: case 20:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -563,7 +537,8 @@ Test_lexer.prototype = {
break; break;
case 21: case 21:
{ {
this._foundLexeme("DOT");this._set_next(); this._foundLexeme("DOT");
this._set_next();
return; return;
} }
case 22: case 22:
@ -575,7 +550,7 @@ Test_lexer.prototype = {
case 24: case 24:
this._yy_accept = 1; this._yy_accept = 1;
this._yy_char = this._string[(this._yy_marker = ++this._yy_cursor)]; this._yy_char = this._string[(this._yy_marker = ++this._yy_cursor)];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '.': case '.':
this._state = 52; this._state = 52;
@ -600,7 +575,8 @@ Test_lexer.prototype = {
break; break;
case 26: case 26:
{ {
this._foundLexeme("INTEGER_LITERAL");this._set_next(); this._foundLexeme("INTEGER_LITERAL");
this._set_next();
return; return;
} }
case 27: case 27:
@ -611,7 +587,7 @@ Test_lexer.prototype = {
} }
case 29: case 29:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '=': case '=':
this._state = 57; this._state = 57;
@ -624,12 +600,13 @@ Test_lexer.prototype = {
break; break;
case 30: case 30:
{ {
this._foundLexeme("LT");this._set_next(); this._foundLexeme("LT");
this._set_next();
return; return;
} }
case 31: case 31:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '=': case '=':
this._state = 59; this._state = 59;
@ -642,7 +619,7 @@ Test_lexer.prototype = {
break; break;
case 32: case 32:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '=': case '=':
this._state = 61; this._state = 61;
@ -655,12 +632,13 @@ Test_lexer.prototype = {
break; break;
case 33: case 33:
{ {
this._foundLexeme("GT");this._set_next(); this._foundLexeme("GT");
this._set_next();
return; return;
} }
case 34: case 34:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'N': case 'N':
case 'n': case 'n':
@ -677,13 +655,14 @@ Test_lexer.prototype = {
break; break;
case 35: case 35:
{ {
this._foundLexeme("ID");this._set_next(); this._foundLexeme("ID");
this._set_next();
return; return;
} }
case 36: case 36:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
case 37: case 37:
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -758,7 +737,7 @@ Test_lexer.prototype = {
break; break;
case 38: case 38:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'A': case 'A':
case 'a': case 'a':
@ -772,7 +751,7 @@ Test_lexer.prototype = {
break; break;
case 39: case 39:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'I': case 'I':
case 'i': case 'i':
@ -786,7 +765,7 @@ Test_lexer.prototype = {
break; break;
case 40: case 40:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'L': case 'L':
case 'l': case 'l':
@ -804,7 +783,7 @@ Test_lexer.prototype = {
break; break;
case 41: case 41:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'R': case 'R':
case 'r': case 'r':
@ -821,7 +800,7 @@ Test_lexer.prototype = {
break; break;
case 42: case 42:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'R': case 'R':
case 'r': case 'r':
@ -850,7 +829,7 @@ Test_lexer.prototype = {
} }
case 47: case 47:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'N': case 'N':
case 'n': case 'n':
@ -864,7 +843,7 @@ Test_lexer.prototype = {
break; break;
case 48: case 48:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'R': case 'R':
case 'r': case 'r':
@ -878,7 +857,7 @@ Test_lexer.prototype = {
break; break;
case 49: case 49:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'R': case 'R':
case 'r': case 'r':
@ -898,7 +877,7 @@ Test_lexer.prototype = {
} }
case 52: case 52:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -934,7 +913,7 @@ Test_lexer.prototype = {
case 54: case 54:
this._yy_accept = 2; this._yy_accept = 2;
this._yy_char = this._string[(this._yy_marker = ++this._yy_cursor)]; this._yy_char = this._string[(this._yy_marker = ++this._yy_cursor)];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -959,7 +938,8 @@ Test_lexer.prototype = {
break; break;
case 56: case 56:
{ {
this._foundLexeme("FLOAT_LITERAL");this._set_next(); this._foundLexeme("FLOAT_LITERAL");
this._set_next();
return; return;
} }
case 57: case 57:
@ -982,7 +962,7 @@ Test_lexer.prototype = {
} }
case 63: case 63:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'D': case 'D':
case 'd': case 'd':
@ -996,7 +976,7 @@ Test_lexer.prototype = {
break; break;
case 64: case 64:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'd': case 'd':
this._state = 77; this._state = 77;
@ -1009,7 +989,7 @@ Test_lexer.prototype = {
break; break;
case 65: case 65:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'L': case 'L':
case 'l': case 'l':
@ -1023,7 +1003,7 @@ Test_lexer.prototype = {
break; break;
case 66: case 66:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'K': case 'K':
case 'k': case 'k':
@ -1037,7 +1017,7 @@ Test_lexer.prototype = {
break; break;
case 67: case 67:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'I': case 'I':
case 'i': case 'i':
@ -1051,7 +1031,7 @@ Test_lexer.prototype = {
break; break;
case 68: case 68:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'T': case 'T':
case 't': case 't':
@ -1065,7 +1045,7 @@ Test_lexer.prototype = {
break; break;
case 69: case 69:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1140,12 +1120,13 @@ Test_lexer.prototype = {
break; break;
case 70: case 70:
{ {
this._foundLexeme("OR");this._set_next(); this._foundLexeme("OR");
this._set_next();
return; return;
} }
case 71: case 71:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'd': case 'd':
this._state = 83; this._state = 83;
@ -1158,7 +1139,7 @@ Test_lexer.prototype = {
break; break;
case 72: case 72:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'U': case 'U':
case 'u': case 'u':
@ -1172,7 +1153,7 @@ Test_lexer.prototype = {
break; break;
case 73: case 73:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'm': case 'm':
this._state = 86; this._state = 86;
@ -1185,7 +1166,7 @@ Test_lexer.prototype = {
break; break;
case 74: case 74:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '-': case '-':
this._state = 87; this._state = 87;
@ -1210,7 +1191,7 @@ Test_lexer.prototype = {
break; break;
case 75: case 75:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1285,12 +1266,13 @@ Test_lexer.prototype = {
break; break;
case 76: case 76:
{ {
this._foundLexeme("AND");this._set_next(); this._foundLexeme("AND");
this._set_next();
return; return;
} }
case 77: case 77:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'r': case 'r':
this._state = 90; this._state = 90;
@ -1303,7 +1285,7 @@ Test_lexer.prototype = {
break; break;
case 78: case 78:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'S': case 'S':
case 's': case 's':
@ -1317,7 +1299,7 @@ Test_lexer.prototype = {
break; break;
case 79: case 79:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'E': case 'E':
case 'e': case 'e':
@ -1331,7 +1313,7 @@ Test_lexer.prototype = {
break; break;
case 80: case 80:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'K': case 'K':
case 'k': case 'k':
@ -1345,7 +1327,7 @@ Test_lexer.prototype = {
break; break;
case 81: case 81:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1420,12 +1402,13 @@ Test_lexer.prototype = {
break; break;
case 82: case 82:
{ {
this._foundLexeme("NOT");this._set_next(); this._foundLexeme("NOT");
this._set_next();
return; return;
} }
case 83: case 83:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1505,7 +1488,7 @@ Test_lexer.prototype = {
} }
case 85: case 85:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'E': case 'E':
case 'e': case 'e':
@ -1519,7 +1502,7 @@ Test_lexer.prototype = {
break; break;
case 86: case 86:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'e': case 'e':
this._state = 96; this._state = 96;
@ -1532,7 +1515,7 @@ Test_lexer.prototype = {
break; break;
case 87: case 87:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1554,7 +1537,7 @@ Test_lexer.prototype = {
break; break;
case 88: case 88:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1576,7 +1559,7 @@ Test_lexer.prototype = {
break; break;
case 90: case 90:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'e': case 'e':
this._state = 98; this._state = 98;
@ -1589,7 +1572,7 @@ Test_lexer.prototype = {
break; break;
case 91: case 91:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1664,12 +1647,13 @@ Test_lexer.prototype = {
break; break;
case 92: case 92:
{ {
this._foundLexeme("LIKE");this._set_next(); this._foundLexeme("LIKE");
this._set_next();
return; return;
} }
case 93: case 93:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'E': case 'E':
case 'e': case 'e':
@ -1683,7 +1667,7 @@ Test_lexer.prototype = {
break; break;
case 94: case 94:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1758,12 +1742,13 @@ Test_lexer.prototype = {
break; break;
case 95: case 95:
{ {
this._foundLexeme("BOOL_LITERAL");this._set_next(); this._foundLexeme("BOOL_LITERAL");
this._set_next();
return; return;
} }
case 96: case 96:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1840,12 +1825,13 @@ Test_lexer.prototype = {
break; break;
case 97: case 97:
{ {
this._foundLexeme("TIME");this._set_next(); this._foundLexeme("TIME");
this._set_next();
return; return;
} }
case 98: case 98:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 's': case 's':
this._state = 102; this._state = 102;
@ -1858,7 +1844,7 @@ Test_lexer.prototype = {
break; break;
case 99: case 99:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -1933,12 +1919,13 @@ Test_lexer.prototype = {
break; break;
case 100: case 100:
{ {
this._foundLexeme("NLIKE");this._set_next(); this._foundLexeme("NLIKE");
this._set_next();
return; return;
} }
case 101: case 101:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'i': case 'i':
this._state = 103; this._state = 103;
@ -1951,7 +1938,7 @@ Test_lexer.prototype = {
break; break;
case 102: case 102:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 's': case 's':
this._state = 104; this._state = 104;
@ -1964,7 +1951,7 @@ Test_lexer.prototype = {
break; break;
case 103: case 103:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'f': case 'f':
this._state = 106; this._state = 106;
@ -1977,7 +1964,7 @@ Test_lexer.prototype = {
break; break;
case 104: case 104:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -2052,12 +2039,13 @@ Test_lexer.prototype = {
break; break;
case 105: case 105:
{ {
this._foundLexeme("ADDRESS");this._set_next(); this._foundLexeme("ADDRESS");
this._set_next();
return; return;
} }
case 106: case 106:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case 'f': case 'f':
this._state = 107; this._state = 107;
@ -2070,7 +2058,7 @@ Test_lexer.prototype = {
break; break;
case 107: case 107:
this._yy_char = this._string[++this._yy_cursor]; this._yy_char = this._string[++this._yy_cursor];
(function() { (function () {
switch (this._yy_char) { switch (this._yy_char) {
case '0': case '0':
case '1': case '1':
@ -2145,7 +2133,8 @@ Test_lexer.prototype = {
break; break;
case 108: case 108:
{ {
this._foundLexeme("TIMEDIFF");this._set_next(); this._foundLexeme("TIMEDIFF");
this._set_next();
return; return;
} }
@ -2169,7 +2158,7 @@ Test_lexer.prototype = {
var print_f = function() { var print_f = function () {
var r_str = ""; var r_str = "";
var next = arguments[0]; var next = arguments[0];
@ -2206,4 +2195,7 @@ var print_f = function() {
return r_str; return r_str;
}; };
module.exports = Test_lexer
(new Lexer("[")).search();
module.exports = Lexer

41
libs/args-parser.js Normal file
View 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

File diff suppressed because it is too large Load Diff

13
main.js
View File

@ -2,8 +2,8 @@
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/28/19. * Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/28/19.
*/ */
var js_beautify = require("js-beautify"); var js_beautify = require("./libs/js-beautifier");
var args = require("args-parser")(process.argv); var args = require("./libs/args-parser")(process.argv);
var fs = require("fs"); var fs = require("fs");
var exec = require('child_process').exec; 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)){ if(!fs.existsSync(output_path)){
fs.mkdirSync(output_path); fs.mkdirSync(output_path);

View File

@ -7,8 +7,5 @@
"name": "chichenkov", "name": "chichenkov",
"email": "rolahd@yandex.ru" "email": "rolahd@yandex.ru"
}, },
"dependencies": { "dependencies": {}
"args-parser": "^1.1.0",
"js-beautify": "^1.8.9"
}
} }

View File

@ -4,7 +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 args = require("./libs/args-parser")(process.argv);
var cfg_path = "config.js"; var cfg_path = "config.js";
var config; var config;