[antlr-interest] Antlr syntax reference

Sam Kuper sam.kuper at uclmail.net
Tue Jun 24 11:39:52 PDT 2008


Dear Benjamin,

2008/6/24 Benjamin Niemann <pink at odahoda.de>:

> EOF is the only predefined token here. There are a few others, but
> they only appear when working with tree parsers.
> They all have in common that they do not match any of the input characters.


Thank you; however, \n is not defined in my grammar, so presumably it is
defined in Antlr somewhere.


> Since you are using Python, an easy way to see which tokens your lexer
> match is to use
>
> python DCPLexer.py <input.txt
>
> or
>
> python DCPLexer.py
> [enter input, then hit CTLR-D]
>
>  (under UNIX, Windows might be slightly differently) and it will just
> dump a list of matched tokens.


I'm running this under Windows. I'm afraid I didn't get any output from
either of those commands.


> The only special thing about \n is that it is always used to track the
> line/column information which is attached to the tokens. But there's
> no magic or special handing when it comes to matching tokens.


It would be good to know more about this. I haven't found anything very
helpful on the Antlr site or wiki yet.

And regarding the exhaustive guide: As far as I can tell the wiki
> should contain everything in a 'reference guide' style, i.e. all
> information regarding syntax, symbols etc. is in there. But for a
> deeper guide to the semantics, you should probably have a look at the
> book.


Thanks for the suggestions; I've already consulted both. I will continue
looking, but since searches (I have the book in PDF) haven't turned up
anything much, I think I've probably covered the existing bases. This kind
of surprises me, because it means everyone using Antlr either just "gets"
the syntax (I don't; though I "get" some of it), or they are essentially
reverse-engineering undocumented parts of the syntax and learning as they go
(which is a lot more effort than just consulting a spec sheet; I would have
thought Terence Parr was against this sort of effort).

I'd be grateful for further suggestions if you have any. Many thanks,

Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080624/bd4bba25/attachment.html 


More information about the antlr-interest mailing list