remove dependencies
This commit is contained in:
parent
a7873cc203
commit
8f914cc2d9
@ -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)
|
@ -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
|
2
build.sh
2
build.sh
@ -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
|
@ -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,7 +26,7 @@ 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 () {
|
||||||
@ -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:
|
||||||
@ -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:
|
||||||
@ -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:
|
||||||
@ -624,7 +600,8 @@ 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:
|
||||||
@ -655,7 +632,8 @@ 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:
|
||||||
@ -677,7 +655,8 @@ 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:
|
||||||
@ -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:
|
||||||
@ -1140,7 +1120,8 @@ 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:
|
||||||
@ -1285,7 +1266,8 @@ 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:
|
||||||
@ -1420,7 +1402,8 @@ 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:
|
||||||
@ -1664,7 +1647,8 @@ 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:
|
||||||
@ -1758,7 +1742,8 @@ 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:
|
||||||
@ -1840,7 +1825,8 @@ 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:
|
||||||
@ -1933,7 +1919,8 @@ 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:
|
||||||
@ -2052,7 +2039,8 @@ 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:
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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
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.
|
* 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);
|
||||||
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
2
test.js
2
test.js
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user