chushihua
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
2014-08-31: Version 0.1.2
|
||||
* Change the field ref to matchIndex on the type=refernce node (issue #67)
|
||||
|
||||
2014-08-30: Version 0.1.1
|
||||
* Only handled unicode code point escapes if 'u' flag is set (issue #56)
|
||||
* Removed `matchIdx` from the AST
|
||||
* References like /\1/ were broken (issue #57)
|
||||
* Renamed type `ref` to `reference` in the AST
|
||||
* Update regex to match identifier and include script to generate regex
|
||||
|
||||
2014-06-29: Version 0.1.0
|
||||
* first tagged release
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
# RegJSParser
|
||||
|
||||
Parsing the JavaScript's RegExp in JavaScript.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install regjsparser
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var parse = require('regjsparser').parse;
|
||||
|
||||
var parseTree = parse('^a'); // /^a/
|
||||
console.log(parseTree);
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
To run the tests, run the following command:
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
|
||||
To create a new reference file, execute…
|
||||
|
||||
```bash
|
||||
node test/update-fixtures.js
|
||||
```
|
||||
|
||||
…from the repo top directory.
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env node
|
||||
(function() {
|
||||
|
||||
var fs = require('fs');
|
||||
var parse = require('../parser').parse;
|
||||
var jsesc = require('jsesc');
|
||||
var regexes = process.argv.splice(2);
|
||||
var first = regexes[0];
|
||||
var data;
|
||||
var log = console.log;
|
||||
var main = function() {
|
||||
if (/^(?:-h|--help|undefined)$/.test(first)) {
|
||||
log([
|
||||
'\nUsage:\n',
|
||||
'\tregjsparser [regex ...]',
|
||||
'\tregjsparser [-h | --help]',
|
||||
'\nExamples:\n',
|
||||
'\tregjsparser \'^foo.bar$\'',
|
||||
'\tregjsparser \'[a-zA-Z0-9]\''
|
||||
].join('\n'));
|
||||
return process.exit(1);
|
||||
}
|
||||
|
||||
regexes.forEach(function(snippet) {
|
||||
var result;
|
||||
try {
|
||||
result = parse(snippet);
|
||||
log(jsesc(result, {
|
||||
'json': true,
|
||||
'compact': false,
|
||||
'indent': '\t'
|
||||
}));
|
||||
} catch(error) {
|
||||
log(error.message + '\n');
|
||||
log('Error: failed to parse. Make sure the regular expression is valid.');
|
||||
log('If you think this is a bug in regjsparser, please report it:');
|
||||
log('\thttps://github.com/jviereck/regjsparser/issues/new');
|
||||
log('\nStack trace:\n');
|
||||
log(error.stack);
|
||||
return process.exit(1);
|
||||
}
|
||||
});
|
||||
// Return with exit status 0 outside of the `forEach` loop, in case
|
||||
// multiple regular expressions were passed in.
|
||||
return process.exit(0);
|
||||
};
|
||||
|
||||
main();
|
||||
|
||||
}());
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "regjsparser",
|
||||
"version": "0.1.5",
|
||||
"author": "'Julian Viereck' <julian.viereck@gmail.com>",
|
||||
"license": "BSD",
|
||||
"main": "./parser",
|
||||
"bin": "bin/parser",
|
||||
"homepage": "https://github.com/jviereck/regjsparser",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:jviereck/regjsparser.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/index.js"
|
||||
},
|
||||
"files": [
|
||||
"bin/",
|
||||
"LICENSE.BSD",
|
||||
"parser.js",
|
||||
"README.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"jsesc": "~0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"regenerate": "~1.0.1",
|
||||
"unicode-7.0.0": "~0.1.5"
|
||||
}
|
||||
}
|
||||
+962
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user