Skip to content

Commit

Permalink
Merge branch 'regexpp' of https://github.com/RunDevelopment/astexplorer
Browse files Browse the repository at this point in the history
… into RunDevelopment-regexpp
  • Loading branch information
fkling committed May 18, 2020
2 parents f957b2a + 6114e54 commit eca049d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -55,6 +55,7 @@ The AST explorer provides following code parsers:
- [Pug][]
- Regular Expressions:
- [regexp-tree][]
- [regexpp][]
- [regjsparser][]
- Scala
- [Scalameta][]
Expand Down Expand Up @@ -151,6 +152,7 @@ node.
[redot]: https://github.com/redotjs/redot
[remark]: https://github.com/remarkjs/remark
[regexp-tree]: https://github.com/DmitrySoshnikov/regexp-tree
[regexpp]: https://github.com/mysticatea/regexpp
[regjsparser]: https://github.com/jviereck/regjsparser
[php-parser]: https://github.com/glayzzle/php-parser
[pug]: https://github.com/pugjs/pug
Expand All @@ -168,7 +170,7 @@ node.
[Scalameta]: http://scalameta.org/
[solidity-parser-antlr]: https://github.com/federicobond/solidity-parser-antlr
[vue-template-compiler]: https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler
[svelte]: https://github.com/sveltejs/svelte
[svelte]: https://github.com/sveltejs/svelte
[hyntax]: https://github.com/nik-garmash/hyntax

### Contributions
Expand Down
1 change: 1 addition & 0 deletions website/package.json
Expand Up @@ -125,6 +125,7 @@
"redot": "^0.6.0",
"redux": "^4.0.5",
"regexp-tree": "^0.1.5",
"regexpp": "^3.1.0",
"regjsparser": "^0.6.0",
"remark": "^12.0.0",
"scalameta-parsers": "^4.2.1",
Expand Down
51 changes: 51 additions & 0 deletions website/src/parsers/regexp/regexpp.js
@@ -0,0 +1,51 @@
import defaultParserInterface from '../utils/defaultParserInterface';
import pkg from 'regexpp/package.json';

const ID = 'regexpp';

/** @type {import("regexpp").RegExpParser.Options} */
export const defaultOptions = {
strict: false,
ecmaVersion: 2020,
};

export default {
...defaultParserInterface,

id: ID,
displayName: ID,
version: pkg.version,
homepage: pkg.homepage,
locationProps: new Set(['end', 'start']),

loadParser(callback) {
require(['regexpp'], callback);
},

parse(regexpp, code, options) {
if (Object.keys(options).length === 0) {
options = this.getDefaultOptions();
}
return regexpp.parseRegExpLiteral(code, options);
},

nodeToRange(node) {
return [node.start, node.end];
},

opensByDefault(node, key) {
return (
key === 'pattern' ||
key === 'elements' ||
key === 'element' ||
key === 'alternatives'
);
},

getDefaultOptions() {
return defaultOptions;
},

_ignoredProperties: new Set(['parent', 'references', 'resolved']),

};
1 change: 1 addition & 0 deletions website/webpack.config.js
Expand Up @@ -163,6 +163,7 @@ module.exports = Object.assign({
path.join(__dirname, 'node_modules', 'redux', 'es'),
path.join(__dirname, 'node_modules', 'regexp-tree'),
path.join(__dirname, 'node_modules', 'regjsparser'),
path.join(__dirname, 'node_modules', 'regexpp'),
path.join(__dirname, 'node_modules', 'simple-html-tokenizer'),
path.join(__dirname, 'node_modules', 'symbol-observable', 'es'),
path.join(__dirname, 'node_modules', 'typescript-eslint-parser'),
Expand Down
5 changes: 5 additions & 0 deletions website/yarn.lock
Expand Up @@ -8703,6 +8703,11 @@ regexpp@^2.0.1:
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f"
integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==

regexpp@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2"
integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==

regexpu-core@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240"
Expand Down

0 comments on commit eca049d

Please sign in to comment.