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

Feature Request: includePaths option for nearleyc #604

Open
hikerpig opened this issue Feb 9, 2022 · 0 comments
Open

Feature Request: includePaths option for nearleyc #604

hikerpig opened this issue Feb 9, 2022 · 0 comments

Comments

@hikerpig
Copy link

hikerpig commented Feb 9, 2022

Some background

I'm developing a text-to-diagram library, using nearley to generate parsers for different types of diagrams - which have quite different syntaxes so I tend to write separate parser for each one of them. I use @include to include common syntaxes.

Also this library is based on a plugin structure, developers can write their own diagrams, I think maybe I can publish the common syntaxes files and they can include them from node_modules.

But as far as I know, one can't include another .ne file without knowing the exact relative path of it. But writing something like @include "../../node_modules/@pintora/diagrams/lib/syntaxes/config.ne" is not so elegant, IMO.

Feature request

Here in Compile.js, I see there is either directory of current .ne file or process.cwd() for resolving include paths.

        if (!productionRule.builtin) {
            path = require('path').resolve(
                opts.args[0] ? require('path').dirname(opts.args[0]) : process.cwd(),
                productionRule.include
            );

Can we add an option --include-paths to nearleyc CLI for syntax file lookup ?

If this is not a feature that, for some reason, is deliberately not implemented. I will be happy to add it.

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

1 participant