[antlr-interest] Integrating Antlr-3.0b5 with VS2005 C# projects
kroepke at classdump.org
Fri Jan 5 17:51:43 PST 2007
On 5. Jan 2007, at 17:03 , Benoit Miller wrote:
> In order to have VS2005/MSBuild detect errors (and enable double-
> clicking on error messages from the IDE), I made a simple VS-like
> message formatter, vstudio.stg:
> group vstudio;
> location(file, line, column) ::= "<file>(<line>,<column>):"
> message(id, text) ::= "<id>: <text>"
> report(location, message, type) ::= "<location> <type> <message>"
> wantsSingleLineMessage() ::= "false"
> Until an official format file makes it in 3.0b6, add vstudio.stg to
> your antlr-3.0b5.jar file in org/antlr/tool/templates/messages/
> formats, next to the existing antlr.stg and gnu.stg.
Yeah, it works for people :)
I'd be more than happy to include this, if it works for people.
Jim, haven't you been working on VS support, too? If you don't
object, I'll commit, ok?
> It's not perfect because sometimes antlr gives an empty location
> field, or non-translated locations, such as this example:
> SimpleCalc.g(39,7): error 100: syntax error: antlr: SimpleCalc.g:
> 39:7: unexpected token: foo
This is due to the fact that some of the error messages come from the
parsers for ANTLR itself, which are written in ANTLR v2. The error
messages (and thus their formatting) will be better once v3 is built
with v3. It just wasn't justifiable to invest a lot of work into
this, if it will go away some time in the future anyway...
> Also, antlr can generate output files even though the grammar has
> errors in it, so further dependency checks fail and the grammar
> won't be recompiled until changed. I think no output should be
> produced on errors... (otherwise, perhaps the error should have
> been a warning? :))
I agree. If there's an error it shouldn't generate stuff. I thought
there were some sets of messages that inhibit code generation, should
be in ErrorManager.java. Do you have a list, so we could add tests
and fix those cases?
A different thing that came up a while ago was that org.antlr.Tool
doesn't give a proper return value when exiting with an error. This
breaks the "stop build on fail" feature of Xcode, at least (I've been
bitten by that in my Xcode support). It also has implications when
embedding org.antlr.Tool in Java IDEs, since we can't just exit.
How does Visual Studio deal with this (exit codes from tools, I mean)?
> In any case, this may be obvious to some, but I wasted an evening
> figuring this out so I thought I'd contribute. Perhaps it can go on
> the wiki, as I could not find this kind of info anywhere.
Thanks very much! Every bit of work helps and I think it's great when
people start using this stuff and find it at least a bit sensible!
(And I know Ter loves that - more than anyone else :))
Again, thanks for the work Benoit!
More information about the antlr-interest