7

I can't find any documentation that shows how to get ANTLR support in Visual Studio 2022. It seems like the ANTLR extension developers haven't kept up with the changes made to the Visual Studio API object model: ANTLR VSIX is only compatible with Visual Studio 2019, and ANTLR Language Support won't work with anything newer than Visual Studio 2017.

How can I work with ANTLR grammars and build parsers in .NET 6.0 with Visual Studio 2022?

MikeB
  • 1,452
  • 14
  • 28
  • 3
    I paused work on AntlrVSIX because the implementation of Language Server Protocol in Visual Studio 2019 was terrible, years behind what was available in Visual Studio Code. It required some awkward workarounds in both server and client for semantic highlighting. Even with the workarounds, it didn't work well. The LSP libraries since then apparently has caught up with v3.16, at least on the server-side (I had to write [an entire replacement of their server code API](https://github.com/kaby76/lsp-types) because it was just awful). I'm not sure of the status of the client side. Still evaluating. – kaby76 Apr 28 '22 at 11:49
  • 2
    Also, you do not need a VS extension to work with Antlr. Use [Antlr4Templates](https://github.com/kaby76/Antlr4Templates) to create a simple split or combine grammar C# console program from template, then open in VS2022 and work as normal. Builds using Antlr4 tool are under-the-covers. See [Antlr4BuildTasks](https://github.com/kaby76/Antlr4BuildTasks). There is no plugin in VS2022 to help you edit the grammar yet, but building and debugging with NET6 is not a problem. – kaby76 Apr 28 '22 at 11:54
  • Thanks @kaby76! I guess I have to give up on having any support other than being able to build. I don't know anything about the LSP libraries and don't want to use Visual Studio Code; I'm not even sure what package that version number refers to. It's sad news to hear that you've stopped maintaining Visual Studio support, tho. But having the `Antlr4BuildTasks` installed is a step forward as I was previously manually building my grammar, then checking in the resulting `*.cs` files. Now, at least I can directly add my grammar to my project and `Antlr4BuldTasks` build it automatically. – MikeB Apr 28 '22 at 20:17

0 Answers0