2

I'm happily developing a language in ANTLR 4.4 / ANTLR4CS, and I'd like to start integrating my language into an IDE. The natural place for me feels like integrating it into Visual Studio. It occurs to me that someone might have figured out a general way to plug an ANTLR lexer into the Visual Studio syntax highlighting system, or ANTLR parsers into an MSBuild task such that errors appear in the Visual Studio error list.

Is there any kind of starting point, base package, plugin system, or similar which lets you integrate an ANTLR4CS language with Visual Studio's language support mechanisms?

Alternatively, has anyone had any success building, say, a Sublime Text build system / language def automatically from their grammar?

Steve Cooper
  • 20,542
  • 15
  • 71
  • 88
  • 1
    I did this by reparsing the whole file every time, doing it on a line-by line basis was too much of a PITA for my needs (and our DSL files are small so it works fine). As for the error output, what do you do with your input once it's parsed, and which VS interfaces do you implement? – Lucas Trzesniewski Nov 29 '14 at 00:59
  • Thanks, Lucas. I expect my files will be small enough to use the same shortcut. As to the error output,i just wanted to stitch the syntax errors raised by the parser into the error window. I haven't written any VS code yet because it seems like a lot to learn for the moment. – Steve Cooper Nov 30 '14 at 08:57
  • OK. I don't know if it'll be suitable for your needs, but you can implement a [single file generator](http://msdn.microsoft.com/en-us/library/bb166817.aspx) from a VS extension. The `Generate` method takes a [`IVsGeneratorProgress`](http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsgeneratorprogress.aspx) parameter which lets you report errors easily. – Lucas Trzesniewski Nov 30 '14 at 12:34
  • That looks like a really useful lead! Want to rewrite as an answer and I can give you the points. – Steve Cooper Nov 30 '14 at 23:30

1 Answers1

1

@Lucas Trzesniewski wrote:

I did this by reparsing the whole file every time, doing it on a line-by line basis was too much of a PITA for my needs (and our DSL files are small so it works fine).

I don't know if it'll be suitable for your needs, but you can implement a single file generator from a VS extension. The Generate method takes a IVsGeneratorProgress parameter which lets you report errors easily.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • ([Answered in a comment and converted to a community wiki answer](http://meta.stackoverflow.com/questions/251597/question-with-no-answers-but-issue-solved-in-the-comments)) – Brian Tompsett - 汤莱恩 May 22 '15 at 13:46