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

How can I pass command line arguments to antlr? #69

Closed
BrentRector opened this issue Jan 22, 2019 · 2 comments
Closed

How can I pass command line arguments to antlr? #69

BrentRector opened this issue Jan 22, 2019 · 2 comments
Labels
feature request A request for a new feature

Comments

@BrentRector
Copy link

For example, my *.g4 file contains UTF-8 characters. Therefore I need to invoke antlr with the -encoding command line option such as:

antlr4 -encoding utf8 grammar.g4

I suspect the vscode extension doesn't pass that command line option as copile-on-save produces errors in VSCode but not when running antlr from the command line. However, I cannot find a configuration setting for the encoding command line option.

Similarly, I need to pass the encoding option when invoking grun as well.

@mike-lischke
Copy link
Owner

No, currently it's not possible to specify command line parameters. This can be added as an addition to the launch task.

@mike-lischke mike-lischke added the feature request A request for a new feature label Jan 22, 2019
@kenjiuno
Copy link

kenjiuno commented Jun 2, 2022

Hi.

Can I pass 2 or more parameters to additionalParameters?

I want to pass -encoding UTF8.

In .vscode/settings.json

{
    "antlr4.generation": {
        "additionalParameters": "-encoding UTF8",
        "mode": "internal",
        "language": "Java",
        "listeners": true,
        "visitors": false
    }
}

However output from generator is:

error(2):  unknown command-line option -encoding UTF8

I have looked up b0f7ebd.

if (options.additionalParameters) {
parameters.push(options.additionalParameters);
}

options.additionalParameters isn't separated.

Perhaps passing -encoding UTF8 will give "-encoding UTF8" in command line args.

%JAVA_HOME%\bin\java -jar H:\DL\antlr-4.10.1-complete.jar "-encoding utf8" Zengin.g4
error(2):  unknown command-line option -encoding utf8

The above error message matches.

I want to pass separated parameters like this:

%JAVA_HOME%\bin\java -jar H:\DL\antlr-4.10.1-complete.jar -encoding utf8 Zengin.g4

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

No branches or pull requests

3 participants