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

Is there a F# target? #22

Open
ChristophSchmidpeter opened this issue Nov 6, 2021 · 2 comments
Open

Is there a F# target? #22

ChristophSchmidpeter opened this issue Nov 6, 2021 · 2 comments

Comments

@ChristophSchmidpeter
Copy link

In th project file there is the option <DOptions>language=CSharp</DOptions>
Setting it to <DOptions>language=FSharp</DOptions>
results in the error:

The "RunAntlrTool" task returned false but did not log an error

Is it possible to set it to F# / to generate F# code with ANTLR? Or is the only option to create a separate C# project in which the code is generated?

@kaby76
Copy link
Owner

kaby76 commented Nov 6, 2021

Sorry, there's no F# target for the standard Antlr4 tool. And, there isn't one either for the Antlr4cs tool and runtime, which is a rewrite of Antlr4 in C# by Sam Harwell.

But, I think you can place the code in a separate csproj and can then interop with F#. I would recommend you pull your .g4's into a directory, and download the Trash trgen dotnet tool (dotnet tool install -g trgen), then in a shell prompt trgen -s name-of-start-rule. It looks in your current directory containing the Antlr grammar, then will create a csproj you can call from F#. You should modify the generated parser driver code for what you need.

@lextm
Copy link
Contributor

lextm commented Sep 9, 2023

You can see how ANTLR generates the skeleton and targets different programming languages from https://github.com/antlr/antlr4/tree/4.13.1/tool/resources/org/antlr/v4/tool/templates/codegen

So if you want F# code to be generated for your ANTLR grammar file(s) you might contribute to the original ANTLR 4 repo the F# related files.

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

3 participants