parjs icon indicating copy to clipboard operation
parjs copied to clipboard

Regexp parser error

Open zim32 opened this issue 5 years ago • 2 comments

Trying all this leads to error

const { regexp } = require('parjs');

let TEST = regexp(new RegExp('a')); let TEST = regexp(/a/); let TEST = regexp('a'); TEST.parse('a');

this.reason = `expecting input matching /${origRegexp.source}/`;
                ^
TypeError: Cannot set property 'reason' of undefined
    at regexp (/home/***/www/node_modules/parjs/internal/parsers/regexp.js:19:17)
    at Object.<anonymous> (/home/***/www/parser.js:14:14)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

zim32 avatar Aug 09 '20 19:08 zim32

This works. Something with typescript export import

const p = require('parjs'); let TEST = p.regexp(/a/);

zim32 avatar Aug 09 '20 19:08 zim32

I believe this is addressed by PR 30. Here's how I worked around it:

import {regexp as buggyRegexp} from "parjs";
let regexp: (origRegexp: RegExp) => Parjser<string[]> = buggyRegexp.bind({});

rapropos avatar Aug 30 '20 22:08 rapropos

Fixed in #30. Thank you!

GregRos avatar Sep 05 '23 22:09 GregRos