[antlr-interest] Antlr v3.0ea8 : @header not taken intoaccountinautomatically generated lexer java code...

Don Caton dcaton at shorelinesoftware.com
Thu May 4 08:59:51 PDT 2006


Jim:

> I would wish to discourage the use of include files that 
> carry code, in favor of solving any issues that people find 
> this to be the only solution for, in a more elegant fashion. 

In general I agree, but the problem is mixed-language programming.

I put any non-trivial code in a header file that's included in the lexer or
parser's generated code.  This allows me to edit the C++ code in the normal
code editor (I use Visual Studio) and retain all the benefits of syntax
highlighting, Intellisense, and all the other stuff you get in a
language-aware code editor.

When I load a .g file into Visual Studio, it has no idea what the syntax is
and I'm basically editing a plain text file, with no assistance from the
editor.

The solution is a language add-in for Visual Studio that understands .g
files, but it would also have to understand any other language that was used
to create actions (e.g. C++, C#, etc.).  While possible, writing a VS
language package is not a trivial task, and even more so when you have to
parse a complex language like C++ that's embedded within the Antlr syntax.

Until (or even if) some other editing mechanism is available, the need to
put C functions in .h files is (IMO) a necessary evil when writing any sort
of non-trivial parsers with Antlr.

Don




More information about the antlr-interest mailing list