no dependencies

This commit is contained in:
Aleksey Chichenkov 2019-01-30 15:43:01 +03:00
parent 93f01c6ebd
commit d7e8646d1d
5 changed files with 1237 additions and 209 deletions

View File

@ -10,12 +10,10 @@
```bash ```bash
git clone -- http://git.macaw.me:3000/chichenkov/re2-js-generator.git git clone -- http://git.macaw.me:3000/chichenkov/re2-js-generator.git
cd re2-js-generator cd re2-js-generator
npm install
``` ```
## One Minute Guide ## One Minute Guide
You can fast use example: You can fast use example:
```bash ```bash
npm install
./build_example.sh ./build_example.sh
cd example/ cd example/
node lexme.js node lexme.js
@ -50,3 +48,8 @@ node test.js
Read re2c manual: http://re2c.org/manual/manual.html Read re2c manual: http://re2c.org/manual/manual.html
Report for bugs: rolahd@yandex.ru Report for bugs: rolahd@yandex.ru
## 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)

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

@ -1,8 +1,8 @@
/** /**
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/23/19. * Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/23/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;
@ -60,7 +60,14 @@ var post_process_lexer = function (_string) {
_string = process_metatags(_string); _string = process_metatags(_string);
if( !(args["no-beautify"] || args["nb"]) ) { if( !(args["no-beautify"] || args["nb"]) ) {
_string = js_beautify(_string, {indent_size: 4, space_in_empty_paren: true}); _string = js_beautify(_string, {
indent_size: 4,
indent_char: ' ',
preserve_newlines: true,
space_after_anon_function: true,
keep_array_indentation: false,
braces_on_own_line: false
});
} }
if(!enable_logs){ if(!enable_logs){

View File

@ -7,207 +7,5 @@
"name": "chichenkov", "name": "chichenkov",
"email": "rolahd@yandex.ru" "email": "rolahd@yandex.ru"
}, },
"dependencies": { "dependencies": {}
"@types/node": {
"integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz",
"version": "10.12.18"
},
"@types/semver": {
"integrity": "sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ==",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-5.5.0.tgz",
"version": "5.5.0"
},
"abbrev": {
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"version": "1.1.1"
},
"args-parser": "^1.1.0",
"balanced-match": {
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"version": "1.0.0"
},
"brace-expansion": {
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
},
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"version": "1.1.11"
},
"commander": {
"integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz",
"version": "2.19.0"
},
"concat-map": {
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"version": "0.0.1"
},
"config-chain": {
"integrity": "sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA==",
"requires": {
"ini": "^1.3.4",
"proto-list": "~1.2.1"
},
"resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.12.tgz",
"version": "1.1.12"
},
"editorconfig": {
"integrity": "sha512-GWjSI19PVJAM9IZRGOS+YKI8LN+/sjkSjNyvxL5ucqP9/IqtYNXBaQ/6c/hkPNYQHyOHra2KoXZI/JVpuqwmcQ==",
"requires": {
"@types/node": "^10.11.7",
"@types/semver": "^5.5.0",
"commander": "^2.19.0",
"lru-cache": "^4.1.3",
"semver": "^5.6.0",
"sigmund": "^1.0.1"
},
"resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.15.2.tgz",
"version": "0.15.2"
},
"fs.realpath": {
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"version": "1.0.0"
},
"glob": {
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
},
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
"version": "7.1.3"
},
"inflight": {
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
"once": "^1.3.0",
"wrappy": "1"
},
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"version": "1.0.6"
},
"inherits": {
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"version": "2.0.3"
},
"ini": {
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"version": "1.3.5"
},
"js-beautify": "^1.8.9",
"lru-cache": {
"integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==",
"requires": {
"pseudomap": "^1.0.2",
"yallist": "^2.1.2"
},
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
"version": "4.1.5"
},
"minimatch": {
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "^1.1.7"
},
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"version": "3.0.4"
},
"minimist": {
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"version": "0.0.8"
},
"mkdirp": {
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
},
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"version": "0.5.1"
},
"nopt": {
"integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=",
"requires": {
"abbrev": "1",
"osenv": "^0.1.4"
},
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz",
"version": "4.0.1"
},
"once": {
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1"
},
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"version": "1.4.0"
},
"os-homedir": {
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"version": "1.0.2"
},
"os-tmpdir": {
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"version": "1.0.2"
},
"osenv": {
"integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==",
"requires": {
"os-homedir": "^1.0.0",
"os-tmpdir": "^1.0.0"
},
"resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz",
"version": "0.1.5"
},
"path-is-absolute": {
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"version": "1.0.1"
},
"proto-list": {
"integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=",
"resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz",
"version": "1.2.4"
},
"pseudomap": {
"integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=",
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
"version": "1.0.2"
},
"semver": {
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"version": "5.6.0"
},
"sigmund": {
"integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=",
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
"version": "1.0.1"
},
"wrappy": {
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"version": "1.0.2"
},
"yallist": {
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
"version": "2.1.2"
}
}
} }