Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--allowed-start-rules cli option is broken. #53

Closed
cd1m0 opened this issue Nov 10, 2020 · 4 comments
Closed

--allowed-start-rules cli option is broken. #53

cd1m0 opened this issue Nov 10, 2020 · 4 comments

Comments

@cd1m0
Copy link

cd1m0 commented Nov 10, 2020

Trying to use the --allowed-start-rules option results in an exception:

[dimo@bender tmp]$ tspegjs --allowed-start-rules Expression,Term tmp.pegjs 
/home/dimo/tmp/tmp/node_modules/ts-pegjs/src/passes/generate-ts.js:1026
        options.allowedStartRules.map(
                                  ^

TypeError: options.allowedStartRules.map is not a function
    at generateToplevel (/home/dimo/tmp/tmp/node_modules/ts-pegjs/src/passes/generate-ts.js:1026:35)
    at generateTS (/home/dimo/tmp/tmp/node_modules/ts-pegjs/src/passes/generate-ts.js:1534:30)
    at /home/dimo/tmp/tmp/node_modules/pegjs/lib/compiler/index.js:62:50
    at Object.each (/home/dimo/tmp/tmp/node_modules/pegjs/lib/utils/arrays.js:63:7)
    at Object.compile (/home/dimo/tmp/tmp/node_modules/pegjs/lib/compiler/index.js:62:16)
    at Object.generate (/home/dimo/tmp/tmp/node_modules/pegjs/lib/peg.js:50:25)
    at /home/dimo/tmp/tmp/node_modules/ts-pegjs/src/cli.js:82:24
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:63:3)

I believe options.allowedStartRules is a string, while an array is expected.

Perhaps there is a missing split(',') on this line https://github.com/metadevpro/ts-pegjs/blob/master/src/cli.js#L32

@pjmolina
Copy link
Contributor

Thanks @cd1m0 Fixed.

@cd1m0
Copy link
Author

cd1m0 commented Feb 9, 2021

So I don't think this is fixed. In b893042 you added this code:

allowedStartRules = (args[index + 1] | '').split(',');

However I think you meant to say "||" instead of "|". The type of bitwise-or-ing 2 strings is actually a number. So if you run this code you still get an error:

/home/dimo/work/consensys/scribble-clean/node_modules/ts-pegjs/src/cli.js:32
        allowedStartRules = (args[index + 1] | "").split(",");
                                                   ^

TypeError: (args[(index + 1)] | "").split is not a function
    at /home/dimo/work/consensys/scribble-clean/node_modules/ts-pegjs/src/cli.js:32:52
    at Array.map (<anonymous>)
    at Object.<anonymous> (/home/dimo/work/consensys/scribble-clean/node_modules/ts-pegjs/src/cli.js:29:6)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47

cd1m0 added a commit to Consensys/scribble that referenced this issue Feb 9, 2021
 - temporarily switch ts-pegjs to my own repo until metadevpro/ts-pegjs#53 gets fixed
pjmolina added a commit that referenced this issue Feb 9, 2021
@pjmolina
Copy link
Contributor

pjmolina commented Feb 9, 2021

Thanks @cd1m0 for catching the typo. Just fixed in 0.3.1

@cd1m0
Copy link
Author

cd1m0 commented Feb 9, 2021

Thanks for fixing this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants