Check this list of tutorials. I blew my mind when a little parser I wrote worked first time. It is much simpler than it first looks. The easiest way to learn is to study the *.jj example grammar descriptions and to google for example source code for javacc code for grammars similar to what you want to tackle.
download JavaCC 4.0 free. Last revised: 2007-04-20 The download zip includes documentation, Jjtree and a number of simple *.jj example grammar descriptions. Just unzip everything with embedded folder names into a Program Files directory. It does not have an explicit installer. You will want to tweak javacc-4.0\bin\javacc.bat, (the script that compiles your grammar descriptor into Java source code) and put a copy somewhere on the path.
You write little methods that describe the various phrases of your grammar. They are a mixture of Java code and JavaCC grammatical BNF. JavaCC then merges them and converts the whole thing into pure Java source code, with methods that will recognise the various phrases. When you compile that, you can parse text. In addition there are commands to describe the tokens of your language tokens — the basic units/words.
![]() |
recommend book⇒Generating Parsers with JavaCC | |
| paperback | ||
|---|---|---|
| ISBN13: | 978-0-9762214-3-2 | |
| ISBN10: | 0-9762214-3-8 | |
| publisher: | Centennial Books | |
| published: | 2007 | |
| by: | Tom Copeland | |
| You can also order direct from the author. Also covers JJTree, JTB and JJDoc. It explains how to write Unicode parsers to handle a much richer character set than in traditional in languages. It covers integration with Eclipse, but not IntelliJ. The documentation for JavaCC is scattered over the web. This book helps you find it all. | ||
![]() |
and suggestions to improve this page to Roedy Green : | ||
| Canadian Mind Products | |||
| mindprod.com IP:[65.110.21.43] | |||
| Your face IP:[38.103.63.61] | The information on this page is for non-military use only. | ||
| You are visitor number 12,814. | Military use includes use by defence contractors. | ||
| You can get a fresh copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) | ||
| http://mindprod.com/jgloss/javacc.html | J:\mindprod\jgloss\javacc.html | ||