[antlr-interest] Thank you!
easjolly at ix.netcom.com
Sun Jul 1 13:24:55 PDT 2007
I started using ANTLR because a computer scientist friend was kind enough to
point out to me that the problem I was trying to solve was best solved by
parsing. My previous programming experience was in the area of
computational science, solving differential equations and all that, and at
the time, I had no idea what parsing was.
My friend was right that parsing was the solution.
The problem I'm working on, developing open source software to backtranslate
braille technical material, is actually a neat example of a problem where
parsing is the solution so I'll explain it briefly. BTW, braille is usually
represented electronically by a standard (but necessarily somewhat
arbitrary) transliteration to ASCII characters known as ASCII Braille so
I'll use that in the examples. (The reason the transliteration has to be
arbitrary is that braille cells are symbols, not characters, and have
different meanings in different contexts.)
Since standard six-dot braille only has 64 different cells counting the
space, it is naturally necessary to use multi-cell braille symbols (i.e.
tokens) to represent individual print characters. Also, many braille
systems include some sort of shorthand to compensate for tactile reading's
being a bit slower than visual reading.
So, for example, the print word 'greatness' is translated according to the
American English braille system as 'grt;s' where braille 'grt' is shorthand
for print 'great' and braille ';s' is shorthand for print 'ness'. And,
just to make things more fun, the grammar is context-dependent. For
example, braille '7e7s7' is print '(eggs)' since the braille cell
transliterated as a '7' represents a left paren at the beginning of a word,
the sequence 'gg' in the middle of a word, and a right paren at the end of a
Anyway, once I realized that parsing was what I needed, Google luckily led
me to ANTLR and many of the people on this list were very generous in
helping me when I got stuck. And, of course, ANTLR's predicates and actions
turned out to be essential for dealing with a context-sensitive grammar like
Looking back, most of the problems I had when I started were not at all the
fault of ANTLR's documentation. In the first place, as I've already
indicated, I didn't know anything about parsing technology before I started
reading the ANTLR manual. I can say now that this was not the most
efficient approach to learn about parsing and I don't think it was ever
intended to be so.
The second problem I had was that I was just learning Java. (I had at least
had the sense to realize that Fortran wasn't the right language!) So, while
the ANTLR manual kept emphasizing that the best way to understand what was
going on was to look at the generated code, this wasn't as helpful as it
would have been if I'd initially been able to grok Java the way I could grok
The third problem I had was that the domain-specific language I'm working
with is very poorly documented and I was learning this language along with
To summarize, the ANTLR documentation reasonably assumes that you not only
understand the problem you are trying to solve but also have some
understanding of parsing, considerable facility in your target language, and
know enough about Java technology to use an application written in Java. As
the book's Preface says, its intended audience is primarily the "practicing
software developer" who is building "interpreters and translators for
domain- specific languages."
[As an aside, don't most practicing developers start with a simple case that
works and then make incremental changes so that when they run into a problem
they know the likely cause?]
My biggest problem with the ANTLR documentation has been philosophical.
Unlike Ter, I think better bottom-up, not top-down. I confess I would have
initially been entirely happy with a manual that focused on explaining how
to use ANTLR's lexical analysis to print out a stream of tokens with
absolutely no discussion of what I might want to do next or even why ANTLR
provides an unusually effective way of doing this.
I would like to end by saying that thanks in no small part to Terence and to
many of the rest of you, braille-using students may no longer have to rely
on humans to interpret their braille math homework and exams before their
teachers can grade them. And thanks to the many new capabilities of v3, it
appears that I will be able refactor my application so its grammar and
supporting code is much shorter and can be maintained by someone else.
More information about the antlr-interest