mirror of
https://github.com/arthur-pbty/portfolio2023.git
synced 2026-06-12 08:14:39 +02:00
modified
This commit is contained in:
-21
@@ -1,21 +0,0 @@
|
||||
Copyright (c) Julian Viereck and Contributors, All Rights Reserved.
|
||||
|
||||
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.
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
# 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);
|
||||
|
||||
// Toggle on/off additional features:
|
||||
var parseTree = parse('^a', '', {
|
||||
// SEE: https://github.com/jviereck/regjsparser/pull/78
|
||||
unicodePropertyEscape: true,
|
||||
|
||||
// SEE: https://github.com/jviereck/regjsparser/pull/83
|
||||
namedGroups: true,
|
||||
|
||||
// SEE: https://github.com/jviereck/regjsparser/pull/89
|
||||
lookbehind: true
|
||||
});
|
||||
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.
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"name": "regjsparser",
|
||||
"version": "0.9.1",
|
||||
"author": "'Julian Viereck' <julian.viereck@gmail.com>",
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "./parser",
|
||||
"types": "./parser.d.ts",
|
||||
"bin": "bin/parser",
|
||||
"homepage": "https://github.com/jviereck/regjsparser",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:jviereck/regjsparser.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --ext .js --max-warnings 0 .",
|
||||
"test": "run-p test:* && npm run lint",
|
||||
"test:src": "node test/index.js",
|
||||
"test:types": "tsc test/types.ts --noEmit"
|
||||
},
|
||||
"files": [
|
||||
"bin/",
|
||||
"LICENSE.BSD",
|
||||
"parser.js",
|
||||
"parser.d.ts",
|
||||
"README.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"jsesc": "~0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.8.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"regenerate": "~1.0.1",
|
||||
"typescript": "^4.5.2",
|
||||
"unicode-11.0.0": "^0.7.8"
|
||||
}
|
||||
}
|
||||
-183
@@ -1,183 +0,0 @@
|
||||
type _If<Test, Then, Else> = Test extends true ? Then : Else;
|
||||
|
||||
export type Features = {
|
||||
lookbehind?: boolean;
|
||||
namedGroups?: boolean;
|
||||
unicodePropertyEscape?: boolean;
|
||||
unicodeSet?: boolean;
|
||||
modifiers?: boolean;
|
||||
};
|
||||
|
||||
export type AstNodeType =
|
||||
| "alternative"
|
||||
| "anchor"
|
||||
| "characterClass"
|
||||
| "characterClassEscape"
|
||||
| "characterClassRange"
|
||||
| "disjunction"
|
||||
| "dot"
|
||||
| "group"
|
||||
| "quantifier"
|
||||
| "reference"
|
||||
| "unicodePropertyEscape"
|
||||
| "value";
|
||||
|
||||
export type Base<T extends AstNodeType> = {
|
||||
range: [number, number];
|
||||
raw: string;
|
||||
type: T;
|
||||
};
|
||||
|
||||
export type AstNode<F extends Features = {}> =
|
||||
| Alternative<F>
|
||||
| Anchor
|
||||
| CharacterClass<F>
|
||||
| CharacterClassEscape
|
||||
| CharacterClassRange
|
||||
| Disjunction<F>
|
||||
| Dot
|
||||
| Group<F>
|
||||
| Quantifier<F>
|
||||
| Reference<F>
|
||||
| _If<F["unicodePropertyEscape"], UnicodePropertyEscape, never>
|
||||
| Value;
|
||||
|
||||
export type RootNode<F extends Features = {}> = Exclude<
|
||||
AstNode<F>,
|
||||
CharacterClassRange
|
||||
>;
|
||||
|
||||
export type Anchor = Base<"anchor"> & {
|
||||
kind: "boundary" | "end" | "not-boundary" | "start";
|
||||
};
|
||||
|
||||
export type CharacterClassEscape = Base<"characterClassEscape"> & {
|
||||
value: string;
|
||||
};
|
||||
|
||||
export type Value = Base<"value"> & {
|
||||
codePoint: number;
|
||||
kind:
|
||||
| "controlLetter"
|
||||
| "hexadecimalEscape"
|
||||
| "identifier"
|
||||
| "null"
|
||||
| "octal"
|
||||
| "singleEscape"
|
||||
| "symbol"
|
||||
| "unicodeCodePointEscape"
|
||||
| "unicodeEscape";
|
||||
};
|
||||
|
||||
export type Identifier = Base<"value"> & {
|
||||
value: string;
|
||||
};
|
||||
|
||||
export type Alternative<F extends Features = {}> = Base<"alternative"> & {
|
||||
body: RootNode<F>[];
|
||||
};
|
||||
|
||||
export type CharacterClassRange = Base<"characterClassRange"> & {
|
||||
max: Value;
|
||||
min: Value;
|
||||
};
|
||||
|
||||
export type UnicodePropertyEscape = Base<"unicodePropertyEscape"> & {
|
||||
negative: boolean;
|
||||
value: string;
|
||||
};
|
||||
|
||||
export type CharacterClassBody =
|
||||
| CharacterClassEscape
|
||||
| CharacterClassRange
|
||||
| UnicodePropertyEscape
|
||||
| Value;
|
||||
|
||||
export type CharacterClass<F extends Features = {}> = Base<"characterClass"> & {
|
||||
body: CharacterClassBody[];
|
||||
negative: boolean;
|
||||
kind: "union" | _If<F["unicodeSet"], "intersection" | "subtraction", never>;
|
||||
};
|
||||
|
||||
export type ModifierFlags = {
|
||||
enabling: string,
|
||||
disabling: string
|
||||
}
|
||||
|
||||
export type NonCapturingGroup<F extends Features = {}> = Base<"group"> &
|
||||
(
|
||||
| {
|
||||
behavior:
|
||||
| "lookahead"
|
||||
| "lookbehind"
|
||||
| "negativeLookahead"
|
||||
| "negativeLookbehind";
|
||||
body: RootNode<F>[];
|
||||
}
|
||||
| ({
|
||||
behavior: "ignore";
|
||||
body: RootNode<F>[];
|
||||
} & _If<
|
||||
F["modifiers"],
|
||||
{
|
||||
modifierFlags?: ModifierFlags;
|
||||
},
|
||||
{
|
||||
modifierFlags: undefined;
|
||||
}
|
||||
>)
|
||||
);
|
||||
|
||||
|
||||
export type CapturingGroup<F extends Features = {}> = Base<"group"> & {
|
||||
behavior: "normal";
|
||||
body: RootNode<F>[];
|
||||
} & _If<
|
||||
F["namedGroups"],
|
||||
{
|
||||
name?: Identifier;
|
||||
},
|
||||
{
|
||||
name: undefined;
|
||||
}
|
||||
>;
|
||||
|
||||
export type Group<F extends Features = {}> =
|
||||
| CapturingGroup<F>
|
||||
| NonCapturingGroup<F>;
|
||||
|
||||
export type Quantifier<F extends Features = {}> = Base<"quantifier"> & {
|
||||
body: [RootNode<F>];
|
||||
greedy: boolean;
|
||||
max?: number;
|
||||
min: number;
|
||||
symbol?: '?' | '*' | '+';
|
||||
};
|
||||
|
||||
export type Disjunction<F extends Features = {}> = Base<"disjunction"> & {
|
||||
body: [RootNode<F>, RootNode<F>, ...RootNode<F>[]];
|
||||
};
|
||||
|
||||
export type Dot = Base<"dot">;
|
||||
|
||||
export type NamedReference = Base<"reference"> & {
|
||||
matchIndex: undefined;
|
||||
name: Identifier;
|
||||
};
|
||||
|
||||
export type IndexReference = Base<"reference"> & {
|
||||
matchIndex: number;
|
||||
name: undefined;
|
||||
};
|
||||
|
||||
export type Reference<F extends Features = {}> = _If<
|
||||
F["namedGroups"],
|
||||
NamedReference,
|
||||
IndexReference
|
||||
>;
|
||||
|
||||
export function parse<F extends Features = {}>(
|
||||
str: string,
|
||||
flags: string,
|
||||
features?: F
|
||||
): RootNode<F>;
|
||||
-1634
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user