[antlr-interest] This learning curve is getting me down (error messages using examples) NEWBIE NEEDS HELP

Norman Dunbar Norman at dunbar-it.co.uk
Wed Oct 19 00:39:14 PDT 2011


Morning Andy,

> After getting quite excited reading through the first few chapters of Language Implementation Patterns",
Possibly, just possibly, not the best book to start with. Ask me how I know!

 > ...

> How normal are these sorts of startup problems? Are the examples generally not working in this way?
I'd say pretty normal. I suspect you, like me, are not a computer 
science student (or graduate) and so, "compiler" writing is for fun. So 
we are on the back foot from the start.

Equally, as with any half decent system, regardless of what it is, 
documentation is occasionally out of date, or plain wrong, of whatever. 
It's a chore to find something that is decent, current and works. :-)

I had a very similar problem when I started using DocBook for document 
production. I spend ages trying and failing to find anything good enough 
to use for an absolute beginner.

Talking of which, is CSharp a good place to start as a beginner? 
Probably not. Start simple - try building the calculator example from 
the ALTLR website (and in the book as I remember).

When you get that working, try adding on the divide ability (I seem to 
remember that it was a three function calculator - add, subtract, 
multiply but no divide!).

Then build a small "language" to do something equally as simple, and 
then you can build on it. It's the old saying "walk before you run".

 > And how much will it help to get the Definitive Guide To ANTLR?
A lot! This is the book I think you should have started with. I got mine 
from the Book Depository (via Amazon.co.uk) and I'm working my way 
through it for the first time, before I start doing anything.

Also, are you using ANTLRworks? I would if I was you! You can see how 
your grammer will work, or not!

> Will ANTLRworks flag problems like this, which are presumably specific to the C#/.NET platform?
I imagine it will, yes.

> And while I'm at it, once I'm done with this, will I easily be able to get ANTLR to put line and column numbers from my source files into the nodes in ASTs that I build? That's important to me.
I seem to remember reading in the Definitive Guide, that this is 
possible. From the footnote on page 44:

You can put anything you want into the token structure. ANTLR’s default 
CommonToken objects include start/stop indexes into the character 
buffer, the line number, and the token’s character position within that
line, among other things.


Good luck.

-- 
Norman Dunbar
Dunbar IT Consultants Ltd

Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL

Company Number: 05132767


More information about the antlr-interest mailing list