[antlr-interest] intro..& questions

Micheal J open.zone at virgin.net
Tue Jun 7 17:37:25 PDT 2005


> Im Rob, Programmer, 20yrs experience, mainly games, but now 
> moved to <ahem> sensible software (where the companies don't 
> seem to go bankrupt at the rate of 1 a week...)

Oh, the excitement...

[...]

> Q1. How do I get the current line number in a parser rule? 
> 	Im in the middle of the rule, checking the semantics 
> and if there's
> a 	problem I want to throw an exception with a new error 
> format that's
> DevStudio friendly ie 
> 	
> 	"Filename.v(25) : error blah blah blah" type of thing.
> 
> 	I can see there's a line number variable in the lexers 
> inputState, but how do you get at it from the Parser? I know 
> I could make them into singletons (there will only ever be 
> one of each anyway) and get at the lexer that way but it just 
> seems .. well, wrong. I cant see any other way at getting at 
> the lexers inputstate to fetch the line the current token was 
> found on..

IToken instances support a  getLine() [and getColumn()] accessor.

[...]

> Ps how do I get hold of Antlr V3? Sounds like a monster!

See announcement post to the list from the last [coupla] weeks. It has a
link to the v3 EA release. It doesn't include a C# codegen yet but that
should be in a future release.

Micheal
ANTLR/C#



More information about the antlr-interest mailing list