From: <Saved by Windows Internet Explorer 8>
Subject: The JavaCC FAQ
Date: Mon, 14 Sep 2009 09:28:50 -0500
MIME-Version: 1.0
Content-Type: multipart/related;
	type="text/html";
	boundary="----=_NextPart_000_0000_01CA351D.C4D99D00"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579

This is a multi-part message in MIME format.

------=_NextPart_000_0000_01CA351D.C4D99D00
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.idevelopment.info/data/Programming/java/JavaCC/The_JavaCC_FAQ.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" =
"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=3D(0055) --><HTML><HEAD><TITLE>The JavaCC =
FAQ</TITLE>
<META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 8.00.6001.18812">
<STYLE type=3Dtext/css>TD DIV.comp {
	MARGIN-TOP: -0.6ex; MARGIN-BOTTOM: -1ex
}
TD DIV.comb {
	MARGIN-TOP: -0.6ex; MARGIN-BOTTOM: -0.6ex
}
TD DIV.hrcomp {
	LINE-HEIGHT: 0.9; MARGIN-TOP: -0.8ex; MARGIN-BOTTOM: -1ex
}
TD DIV.norm {
	LINE-HEIGHT: normal
}
SPAN.roman {
	FONT-STYLE: normal; FONT-FAMILY: serif; FONT-WEIGHT: normal
}
SPAN.overacc2 {
	POSITION: relative; TOP: -1.2ex; LEFT: 0.8em
}
SPAN.overacc1 {
	POSITION: relative; TOP: -1.2ex; LEFT: 0.6em
}
</STYLE>
</HEAD>
<BODY>
<H1 align=3Dcenter>The JavaCC FAQ </H1>
<H3 align=3Dcenter>Maintained by Theodore S. Norvell<BR>Computer and =
Electrical=20
Engineering<BR>Memorial University of Newfoundland<BR>Email: theo at =
engr.mun.ca=20
</H3>
<H3 align=3Dcenter>Typeset on Jul 2, 2002 . </H3>
<H1>Contents </H1><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_chAp1">1&nbsp;=20
General Information on JavaCC and =
Parsing</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.1">1.1&nbsp;=20
What is JavaCC?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.2">1.2&nbsp;=20
Could you explain that in more detail?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A =

href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.3">1.3&nbsp;=20
What does JavaCC not do?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.4">1.4&nbsp;=20
What can JavaCC be used for?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.5">1.5&nbsp;=20
Is there a newsgroup or mailing list?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.6">1.6&nbsp;=20
Should I&nbsp;send my question to the newsgroup or mailing=20
list?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.7">1.7&nbsp;=20
Who wrote JavaCC and who maintains it?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A =

href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.8">1.8&nbsp;=20
Is the source code for JavaCC publicly=20
available?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.9">1.9&nbsp;=20
Where can I get JavaCC?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.10">1.10&nbsp;=20
What legal restrictions are there on =
JavaCC?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.11">1.11&nbsp;=20
Are there books or tutorials on =
JavaCC?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc1.12">1.12&nbsp;=20
Are there books or tutorials on parsing theory?</A><BR><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_chAp2">2&nbsp;=20
General Issues</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc2.1">2.1&nbsp;=20
Is there any documentation?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc2.2">2.2&nbsp;=20
What files does JavaCC produce?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc2.3">2.3&nbsp;=20
I changed option <I>x</I>; why am I having=20
trouble?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc2.4">2.4&nbsp;=20
How do I&nbsp;put the generated classes in a package?</A><BR><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_chAp3">3&nbsp;=20
The Token Manager</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.1">3.1&nbsp;=20
What is a token manager?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.2">3.2&nbsp;=20
How do I read from a string instead of a =
file?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.3">3.3&nbsp;=20
What if more than one regular expression matches a prefix of the =
remaining=20
input?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.4">3.4&nbsp;=20
What if no regular expression matches a prefix of the remaining=20
input?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.5">3.5&nbsp;=20
How do I match any character?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.6">3.6&nbsp;=20
How do I match exactly <I>n</I> repetitions of a regular=20
expression?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.7">3.7&nbsp;=20
What are <FONT face=3Dhelvetica><B>TOKEN</B></FONT>, <FONT=20
face=3Dhelvetica><B>SKIP</B></FONT>, and <FONT=20
face=3Dhelvetica><B>SPECIAL_TOKEN</B></FONT>? =
</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.8">3.8&nbsp;=20
What are lexical states all about?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.9">3.9&nbsp;=20
Can the parser force a switch to a new lexical=20
state?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.10">3.10&nbsp;=20
Is there a way to make SwitchTo safer?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A =

href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.11">3.11&nbsp;=20
What is <FONT =
face=3Dhelvetica>MORE</FONT>?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.12">3.12&nbsp;=20
Why do the example Java and C++ parsers report an error when the last =
line of a=20
file is a single line comment?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.13">3.13&nbsp;=20
What is a lexical action?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.14">3.14&nbsp;=20
What is a common token action?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.15">3.15&nbsp;=20
How do I throw a ParseException instead of a=20
TokenMgrError?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc3.16">3.16&nbsp;=20
Why are line and column numbers not recorded?</A><BR><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_chAp4">4&nbsp;=20
The Parser and Lookahead</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.1">4.1&nbsp;=20
Where should I draw the line between lexical analysis and=20
parsing?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.2">4.2&nbsp;=20
What is recursive descent parsing?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.3">4.3&nbsp;=20
What is left-recursion and why can't I use =
it?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.4">4.4&nbsp;=20
What is ``lookahead''?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.5">4.5&nbsp;=20
I get a message saying ``Warning: Choice Conflict ... ''; what should I=20
do?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.6">4.6&nbsp;=20
I&nbsp;added a LOOKAHEAD specification and the warning went away; does =
that mean=20
I&nbsp;fixed the problem?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.7">4.7&nbsp;=20
Are semantic actions executed during syntactic=20
lookahead?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.8">4.8&nbsp;=20
Are nested syntactic lookahead specifications evaluated during syntactic =

lookahead?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.9">4.9&nbsp;=20
Are parameters passed during syntactic=20
lookahead?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.10">4.10&nbsp;=20
Are semantic actions executed during syntactic=20
lookahead?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.11">4.11&nbsp;=20
Is semantic lookahead evaluated during syntactic=20
lookahead?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.12">4.12&nbsp;=20
Can local&nbsp;variables (including parameters) be used in semantic=20
lookahead?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.13">4.13&nbsp;=20
How does JavaCC differ from standard LL(1)=20
parsing?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.14">4.14&nbsp;=20
How do I communicate from the parser to the token=20
manager?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.15">4.15&nbsp;=20
How do I communicate from the token manager to the=20
parser?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.16">4.16&nbsp;=20
What does it mean to put a regular expression within a=20
BNF&nbsp;production?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.17">4.17&nbsp;=20
When should regular expressions be put directly into a=20
BNF&nbsp;production?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.18">4.18&nbsp;=20
How do I parse a sequence without allowing=20
duplications?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.19">4.19&nbsp;=20
How do I&nbsp;deal with keywords that aren't=20
reserved?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc4.20">4.20&nbsp;=20
There's an error in the input, so why doesn't my parser throw a=20
ParseException?</A><BR><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_chAp5">5&nbsp;=20
Semantic Actions</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc5.1">5.1&nbsp;=20
I've written/found a parser, but it doesn't do=20
anything?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc5.2">5.2&nbsp;=20
How do I capture and traverse a sequence of tokens?</A><BR><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_chAp6">6&nbsp;=20
JJTree and JTB</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc6.1">6.1&nbsp;=20
What are JJTree and JTB?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc6.2">6.2&nbsp;=20
Where can I&nbsp;find JJTree?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc6.3">6.3&nbsp;=20
Where can I find JTB?</A><BR><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_chAp7">7&nbsp;=20
Applications of JavaCC</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc7.1">7.1&nbsp;=20
Where can I find a parser for =
<I>x</I>?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc7.2">7.2&nbsp;=20
How do I parse arithmetic expressions?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A =

href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc7.3">7.3&nbsp;=20
I'm writing a programming language interpreter; how do I deal with=20
loops?</A><BR><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_chAp8">8&nbsp;=20
Comparing JavaCC with other tools</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc8.1">8.1&nbsp;=20
Since <I>LL</I>(1) <FONT face=3Dsymbol>=CC</FONT> <I>LALR</I>(1), =
wouldn't a tool=20
based on LALR&nbsp;parsing be better?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc8.2">8.2&nbsp;=20
How does JavaCC compare with Lex and =
Flex?</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tth_sEc8.3">8.3&nbsp;=20
How does JavaCC compare with other Yacc and Bison?</A><BR>
<P><B>Acknowledgments</B>: Your maintainer would like to thank the =
following for=20
help with the FAQ:&nbsp;Ken Beesley, Tom Davies, Brian Goetz, Tony =
LaPaso, Eric=20
Nickell, Phil Robare, David Rosenstrauch, and Michael Welle.=20
<P><BR><BR>The latest copy of this FAQ can be found at <A=20
href=3D"http://www.engr.mun.ca/~theo/JavaCC-FAQ/">The JavaCC FAQ</A>.=20
<P>In citing or linking to this FAQ, please use the following URI:=20
<P><BR clear=3Dall></P>
<TABLE border=3D0 width=3D"100%">
  <TBODY>
  <TR>
    <TD>
      <TABLE align=3Dcenter>
        <TBODY>
        <TR>
          <TD noWrap=20
            =
align=3Dmiddle><I>http</I>://<I>www</I>.<I>engr</I>.<I>mun</I>.<I>ca</I>/=
~<I>theo</I>/<I>JavaCC</I><FONT=20
            =
face=3Dsymbol>-</FONT><I>FAQ</I></TD></TR></TBODY></TABLE></TD></TR></TBO=
DY></TABLE>
<P>
<H1><A name=3Dtth_chAp1>Chapter 1 </A><BR>General Information on JavaCC =
and=20
Parsing</H1>
<P>
<CENTER><EM>"DRAGONS&nbsp;DREAD</EM>=20
<P><EM>GO&nbsp;BACK TO&nbsp;BED!!"</EM>=20
<P>Sheree Fitch, <EM>Sleeping Dragons All Around.=20
<P><BR><BR></EM></CENTER>
<H2><A name=3Dtth_sEc1.1>1.1</A>&nbsp;&nbsp;What is JavaCC?</H2>
<P>JavaCC stands for "the Java Compiler Compiler"; it is a parser =
generator and=20
lexical analyzer generator. JavaCC will read a description of a language =
and=20
generate code, written in Java, that will read and analyze that =
language. JavaCC=20
is particularly useful when the input language has a complex structure =
that=20
makes hand-crafting an input module a difficult job.=20
<P>This technology originated to make programming language =
implementation easier=20
-hence the term "compiler compiler"- but make no mistake that JavaCC is =
of use=20
only to programming language implementors.=20
<P>
<H2><A name=3Dtth_sEc1.2>1.2</A>&nbsp;&nbsp;Could you explain that in =
more=20
detail?</H2>
<P>
<P>Figures 1.1 and 1.2&nbsp;show the relationship between a JavaCC =
generated=20
lexical analyzer (called a "token manager"&nbsp;in JavaCC parlance) and =
a JavaCC=20
generated parser. The figures show the C&nbsp;as the input language. But =
JavaCC=20
can handle any language -and not only programming languages- if you can =
describe=20
the rules of the language to JavaCC.=20
<P>The token manager reads in a sequence of characters and produces a =
sequence=20
of objects called "tokens". The rules used to break the sequence of =
characters=20
into a sequence of tokens obviously depend on the language; they are =
supplied by=20
the programmer as a collection of "regular expressions".=20
<P>The parser consumes the sequence of tokens, analyses its structure, =
and=20
produces ... . Well what the parser produces is up to you; JavaCC is =
completely=20
flexible in this regard<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFtNtAAB"=20
name=3DtthFrefAAB><SUP>1</SUP></A>. The figure shows an "abstract syntax =
tree",=20
but you might want to produce, say, a number (if you are writing a =
calculator),=20
a file of assembly language (if you were writing a one-pass compiler), a =

modified sequence of characters (if you were writing a text processing=20
application), and so on. The programmer supplies a collection of =
"Extended=20
BNF&nbsp;production rules"; JavaCC uses these productions to generate =
the parser=20
as a Java&nbsp;class. These production rules can be annotated with =
snippets of=20
Java code, which is how the programmer tells the parser what to produce. =

<P></P>
<TABLE>
  <TBODY>
  <TR>
    <TD><IMG alt=3D"picture of token manager" align=3Dleft=20
      =
src=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/token-ma=
nager.png"></TD></TD>
  <TR>
    <TD>Figure 1.1 The token manager converts a sequence of characters =
to a=20
      sequence of Token objects.</TD></TR></TBODY></TABLE>
<P></P>
<TABLE>
  <TBODY>
  <TR>
    <TD><IMG alt=3D"picture of a parser" align=3Dleft=20
      =
src=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/parser.p=
ng"></TD></TD>
  <TR>
    <TD>Figure 1.2 The parser analyzes the sequence of=20
tokens.</TD></TR></TBODY></TABLE>
<P>
<H2><A name=3Dtth_sEc1.3>1.3</A>&nbsp;&nbsp;What does JavaCC not =
do?</H2>
<P>JavaCC does not automate the building of trees (or any other specific =
parser=20
output), although there are at least two tree building tools JJTree and =
JTB (see=20
Chapter <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#jjtree-and-jtb">6</A>.)=20
&nbsp;based on JavaCC, and building trees "by hand"with a JavaCC based =
parser is=20
easy.=20
<P>JavaCC&nbsp;does not build symbol-tables, although if you want a =
symbol table=20
for a language, then a JavaCC based parser may provide a good framework. =

<P>JavaCC does not generate output languages. However once you have a =
tree, it=20
is easy to generate string output from it.=20
<P>
<H2><A name=3Dtth_sEc1.4>1.4</A>&nbsp;&nbsp;What can JavaCC be used =
for?</H2>
<P>JavaCC has been used to create parsers for: RTF, Visual Basic, =
Python,=20
Rational Rose mdl files, XML, XML DTDs, HTML, C, C++, Java, JavaScript, =
Oberon,=20
SQL, VHDL, VRML, ASN1, email headers, and lots of proprietary languages. =
It also=20
get used for configuration file readers, calculators, and on and on.=20
<P>
<H2><A name=3Dtth_sEc1.5>1.5</A>&nbsp;&nbsp;Is there a newsgroup or =
mailing=20
list?</H2>
<P>comp.compilers.tools.javacc is a usenet newsgroup for discussing the =
JavaCC=20
and related technologies, like JJTree and JTB.=20
<P>There is also a mail-list. To subscribe send a message to=20
javacc-interest-request@mack.eng.sun.com containing, in its body, the =
single=20
word "subscribe".=20
<P>Eventually the mailing list and comp.compilers.tools.javacc will be=20
gatewayed.=20
<P>
<H2><A name=3Dtth_sEc1.6>1.6</A>&nbsp;&nbsp;Should I&nbsp;send my =
question to the=20
newsgroup or mailing list?</H2>
<P>Yes, but only if your question relates in some way to JavaCC, JJTree, =
or JTB.=20

<P>The newsgroup and mailing list are not suitable fora for discussing =
the Java=20
programming language or javac, which is Sun's Java compiler, or any =
other topic=20
that does not relate directly to the Java Compiler Compiler.=20
<P>Questions on parsing theory or parser generation in general might be =
better=20
addressed to comp.compilers.=20
<P>Questions directly answered in the FAQ need not be asked again in the =

newgroup or mailing list.=20
<P>
<H2><A name=3Dtth_sEc1.7>1.7</A>&nbsp;&nbsp;Who wrote JavaCC and who =
maintains=20
it?</H2>
<P>JavaCC was created by Sreeni Viswanadha and Sriram Sankar when they =
worked=20
for Sun. They then formed their own company, Metamata, which is now a =
wholly=20
owned subsidiary of WebGain. Through all these changes, they've kept =
improving=20
JavaCC. Because of this history, JavaCC is owned by Sun Microsystems and =
is=20
distributed by WebGain.=20
<P>
<H2><A name=3Dtth_sEc1.8>1.8</A>&nbsp;&nbsp;Is the source code for =
JavaCC publicly=20
available?</H2>
<P>Currently (June 2002) the answer is no. However in a letter to the =
JavaCC=20
mailing list on 22 March 2002, Michael Van De Vanter of Sun indicated =
that Sun=20
plans to make JavaCC&nbsp;open source.=20
<P>
<H2><A name=3Dtth_sEc1.9>1.9</A>&nbsp;&nbsp;Where can I get JavaCC?<A=20
name=3Dwhere-is-javacc></A></H2>
<P>JavaCC is available from <A=20
href=3D"http://www.webgain.com/products/java_cc/">WebGain</A>&nbsp;as a =
free=20
download. The precise URL may change.=20
<P>
<H2><A name=3Dtth_sEc1.10>1.10</A>&nbsp;&nbsp;What legal restrictions =
are there on=20
JavaCC?</H2>
<P>There are essentially no restrictions on the use of JavaCC. In =
particular you=20
may use the Java files that JavaCC produces in any way, including =
incorporating=20
them into a product that you sell. However, you are not allowed to =
redistribute=20
JavaCC itself; it is free, but it is not shareware. Furthermore various =
.jj=20
files that are distributed with JavaCC or that you may find on the net, =
may have=20
restrictions on their use - read the copyright notices carefully.=20
<P>
<H2><A name=3Dtth_sEc1.11>1.11</A>&nbsp;&nbsp;Are there books or =
tutorials on=20
JavaCC?</H2>
<P>At the moment there are no books on JavaCC.=20
<P>There are some tutorial examples in the JavaCC&nbsp;documentation.=20
<P>A couple of articles have been published in JavaWorld. See <A=20
href=3D"http://www.javaworld.com/javaworld/jw-12-1996/jw-12-jack.html">ar=
ticle by=20
Chuck McManis</A> and <A=20
href=3D"http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-cooltools.h=
tml">article=20
by Oliver Enseling</A>.=20
<P>Your maintainer is currently writing tutorial on JavaCC, which may =
become a=20
book one day.=20
<P>
<H2><A name=3Dtth_sEc1.12>1.12</A>&nbsp;&nbsp;Are there books or =
tutorials on=20
parsing theory?</H2>
<P>Yes many. Most text-books on compiler technology contain more than =
enough=20
background on parsing theory. Here are some suggestions=20
<P>
<UL>
  <LI>Alfred V. Aho, Ravi Sethi and Jeffrey D. Ullman, <EM>Compilers:=20
  Principles, Techniques, and Tools</EM>, Addison-Wesley, 1985.=20
  <P></P>
  <LI>Charles N. Fischer and Richard J. Leblanc, Jr., <EM>Crafting a =
Compiler=20
  With C</EM>, Addison-Wesley, 1991.=20
  <P></P></LI></UL>
<P>
<H1><A name=3Dtth_chAp2>Chapter 2 </A><BR>General Issues</H1>
<P>
<H2><A name=3Dtth_sEc2.1>2.1</A>&nbsp;&nbsp;Is there any =
documentation?<A=20
name=3Djavacc-doc></A></H2>
<P>Yes. <A=20
href=3D"http://www.webgain.com/products/java_cc/documentation.html">Follo=
w this=20
link</A>.=20
<P>The on-line documentation is currently a bit out of date. <EM>You =
should also=20
read the release notes that come with the JavaCC download.</EM>=20
<P>The documentation is rather terse and is much easier to read if you =
already=20
know a bit about parsing theory. Nevertheless, the documentation is an=20
indispensable resource that is in no way superceded by this FAQ.=20
<P>It used to be possible to download the documentation in a big ZIP =
file. At=20
the moment your maintainer does not know where the documentation can be=20
downloaded from, but you can certainly view it on-line.=20
<P>
<H2><A name=3Dtth_sEc2.2>2.2</A>&nbsp;&nbsp;What files does JavaCC =
produce?<A=20
name=3Dwhat-files></A></H2>
<P>JavaCC is a program generator. Based on its input (a .jj file) =
version 2.1=20
(or later)&nbsp;will produce the following Java source files:=20
<P>
<UL>
  <LI>Boiler-plate files=20
  <P>
  <UL>
    <LI><TT>SimpleCharStream.java</TT> - represent the stream of input=20
    characters.=20
    <P></P>
    <LI><TT>Token.java</TT> - represents a single input token=20
    <P></P>
    <LI><TT>TokenMgrError.java</TT> - an error thrown from the token =
manager.=20
    <P></P>
    <LI><TT>ParseException.java</TT> - an exception indicating that the =
input=20
    did not conform to the parser's grammar.=20
    <P></P></LI></UL>
  <P></P>
  <LI>Custom files (<EM>XXX</EM> is whatever name you choose).=20
  <P>
  <UL>
    <LI><EM>XXX</EM><TT>.java</TT> - the parser class=20
    <P></P>
    <LI><EM>XXX</EM><TT>TokenManager.java</TT> - the token manager =
class.=20
    <P></P>
    <LI><EM>XXX</EM><TT>Constants.java</TT> - an interface associating =
token=20
    classes with symbolic names.=20
    <P></P></LI></UL>
  <P></P></LI></UL>
<P>If you use the option <FONT =
face=3Dhelvetica>JAVA_UNICODE_ESCAPE</FONT> then=20
<TT>SimpleCharStream.java</TT> will note be produced, but rather=20
<TT>JavaCharStream.java</TT>. &nbsp;(Prior to version 2.1, one of four =
possible=20
files was generated: <TT>ASCII_CharStream.java</TT>=20
<TT>ASCII_UCodeESC_CharStream.java</TT>, <TT>UCode_CharStream.java</TT>, =
or=20
<TT>UCode_UCodeESC_CharStream.java</TT>).=20
<P>If you use the option <FONT face=3Dhelvetica>USER_CHAR_STREAM</FONT>, =
then=20
<TT>CharStream.java</TT> (an interface) will be produced instead of the =
class=20
<TT>SimpleCharStream.java</TT>. Similarly the option <FONT=20
face=3Dhelvetica>USER_TOKEN_MANAGER</FONT> will cause the generation of =
an=20
interface <TT>TokenManager.java</TT>, rather than a concrete token =
manager.=20
<P>The boiler plate files will only be produced if they don't already =
exist.=20
There are two important consequences:&nbsp;First, you should delete them =
prior=20
to running JavaCC, if you make any changes that might require changes to =
these=20
files. (See Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#option-changed">2.3</A>,=20
"I changed option <I>x</I>; why am I having trouble?" .) Second, if you =
really=20
want to, you can modify these files and be sure that JavaCC won't =
overwrite=20
them.=20
<P>Modifying any generated files should be used only as a last resort, =
since=20
someday you will likely want to regenerate them and then you'll have to=20
re-modify them. Some people have written scripts (in, say, Perl) to do =
the=20
modifications for them.=20
<P>The custom files are produced every time you run JavaCC.=20
<P>
<H2><A name=3Dtth_sEc2.3>2.3</A>&nbsp;&nbsp;I changed option <I>x</I>; =
why am I=20
having trouble?<A name=3Doption-changed></A></H2>
<P>Try deleting <B>all</B> files generated by JavaCC (see Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#what-files">2.2</A>,=20
`` What files does JavaCC produce?'' ) and then rerunning JavaCC. This =
issue=20
usually comes up when the <FONT face=3Dhelvetica>STATIC</FONT> option is =
changed;=20
JavaCC needs to generate new files, but it will not generate =
boiler-plate files=20
unless they aren't there already.=20
<P>
<H2><A name=3Dtth_sEc2.4>2.4</A>&nbsp;&nbsp;How do I&nbsp;put the =
generated=20
classes in a package?</H2>
<P>Put a <FONT face=3Dhelvetica>package</FONT> declaration right after =
the <FONT=20
face=3Dhelvetica>PARSER_BEGIN(</FONT><EM>XXX</EM><FONT =
face=3Dhelvetica>)</FONT>=20
declaration in the .jj file.=20
<P>
<H1><A name=3Dtth_chAp3>Chapter 3 </A><BR>The Token Manager</H1>
<P>
<H2><A name=3Dtth_sEc3.1>3.1</A>&nbsp;&nbsp;What is a token =
manager?</H2>
<P>In conventional compiling terms, a token manager is a lexical =
analyzer. If=20
that is Greek to you, here is an explanation. The token manager analyzes =
the=20
input stream of characters breaking it up into chunks called tokens and=20
assigning each token a "token kind". For example suppose the input is a=20
C&nbsp;file=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><TT>int main() {</TT>=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD><TT>/*a short program */</TT>=20
        <DT><B></B>
        <DD><TT>return 0 ; }</TT> =
</DD></DL></TD></TR></TBODY></TABLE></FONT>
<P>Then the token manager might break this into chunks as follows:=20
<P>
<CENTER>"<TT>int</TT>", "&nbsp;", "<TT>main</TT>", "<TT>(</TT>", =
"<TT>)</TT>",=20
"&nbsp;", "<TT>{</TT>", "\n",=20
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", "<TT>/*a short =
program=20
*/</TT>", ... </CENTER>
<P>White space and comments are typically discarded, so the chunks are =
then=20
<P>
<CENTER>"<TT>int</TT>", "<TT>main</TT>", "<TT>(</TT>", "<TT>)</TT>",=20
"<TT>{</TT>", "<TT>return</TT>", "<TT>0</TT>", "<TT>;</TT>", =
"<TT>}</TT>"=20
<P></CENTER>Each chunk of text is classified as one of a finite set of =
"token=20
kinds".<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFtNtAAC"=20
name=3DtthFrefAAC><SUP>2</SUP></A> For example the chunks above could be =

classified as, respectively,=20
<P>
<CENTER><FONT face=3Dhelvetica>KWINT</FONT>,<FONT face=3Dhelvetica> =
ID</FONT>,<FONT=20
face=3Dhelvetica> LPAR</FONT>,<FONT face=3Dhelvetica> RPAR</FONT>,<FONT=20
face=3Dhelvetica> LBRACE</FONT>,<FONT face=3Dhelvetica> =
KWRETURN</FONT>,<FONT=20
face=3Dhelvetica> OCTALCONST</FONT>,<FONT face=3Dhelvetica> =
SEMICOLON</FONT>,<FONT=20
face=3Dhelvetica>&nbsp;RBRACE</FONT> </CENTER>
<P>Each chunk of text is represented by an object of class Token, each =
with the=20
following attributes:=20
<P>
<UL>
  <LI><FONT face=3Dhelvetica>.kind</FONT> the token kind encoded as an =
int,=20
  <P></P>
  <LI><FONT face=3Dhelvetica>.image</FONT> the chunk of input text as a =
string,=20
  <P></P></LI></UL>
<P>and a few others.=20
<P>This sequence of Token objects is produced based on regular =
expressions=20
appearing in the .jj file.=20
<P>The sequence is usually sent on to a parser object for further =
processing.=20
<P>
<H2><A name=3Dtth_sEc3.2>3.2</A>&nbsp;&nbsp;How do I read from a string =
instead of=20
a file?</H2>
<P>Here is one way=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>java.io.StringReader sr =3D <B>new</B> java.io.StringReader( str =
);=20
      <P>java.io.Reader r =3D <B>new</B> java.io.BufferedReader( sr );=20
      <P>XXX parser =3D <B>new</B> XXX( r ); =
</P></TD></TR></TBODY></TABLE></FONT>
<P>
<H2><A name=3Dtth_sEc3.3>3.3</A>&nbsp;&nbsp;What if more than one =
regular=20
expression matches a prefix of the remaining input?<A=20
name=3Dmore-than-one></A></H2>
<P>First a definition: If a sequence <I>x</I> can be constructed by =
catenating=20
two other sequences <I>y</I> and <I>z</I>, i.e., <I>x</I>=3D<I>yz</I>, =
then=20
<I>y</I> is called a "prefix"&nbsp;of <I>x</I>.=20
<P>There are three golden rules for picking which regular expression to =
use to=20
identify the next token:=20
<P>
<OL type=3D1>
  <LI>The regular expression must describe a prefix of the remaining =
input=20
  stream.=20
  <P></P>
  <LI>If more than one regular expression describes a prefix, then the =
regular=20
  expression that describes the longest possible prefix of the input =
stream is=20
  used. (This is called the "maximal munch rule".)=20
  <P></P>
  <LI>If more than one regular expression describes the longest possible =
prefix,=20
  then the regular expression that comes first in the .jj file is used.=20
  <P></P></LI></OL>
<P>For example, suppose you are parsing Java, C, or C++. The following =
three=20
regular expression productions might appear in the .jj file=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>TOKEN</B> :&nbsp;{&nbsp; &lt; PLUS : "+" &gt; }=20
      <P><B>TOKEN</B> :&nbsp;{&nbsp; &lt; ASSIGN : "=3D" &gt; }=20
      <P><B>TOKEN</B>&nbsp;:&nbsp;{ &lt; PLASSIGN : "+=3D"&nbsp; &gt; }=20
  </P></TD></TR></TBODY></TABLE></FONT>
<P>Suppose the remaining input stream starts with=20
<P>
<CENTER>"<TT>+=3D1; </TT>..."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. =
</CENTER>
<P>Rule 1 rules out the second production. Rule 2 says that the third =
production=20
is preferred over the first. The order of the productions has no effect =
on this=20
example.=20
<P>Sticking with Java, C, or C++, suppose you have regular expression=20
productions=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>TOKEN</B> :&nbsp;{&nbsp; &lt; KWINT :&nbsp;"int" &gt; }=20
      <P><B>TOKEN</B> :&nbsp;{&nbsp; &lt; IDENT : ["a"-"z","A"-"Z", "_"] =

      (["a"-"z","A"-"Z","0"-"9","_"])* &gt; } =
</P></TD></TR></TBODY></TABLE></FONT>
<P>Suppose the remaining input steams starts with=20
<P>
<CENTER>"<TT>integer i; </TT>..."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, =
</CENTER>
<P>then the second production would be preferred by the maximal munch =
rule (rule=20
2). But if the remaining input stream starts with=20
<P>
<CENTER>"<TT>int i; </TT>..."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, =
</CENTER>
<P>then the maximal munch rule is no help, since both rules match a =
prefix of=20
length 3. In this case the <FONT face=3Dhelvetica>KWINT</FONT> =
production is=20
preferred (by rule 3) because it comes first in the .jj file.=20
<P>
<H2><A name=3Dtth_sEc3.4>3.4</A>&nbsp;&nbsp;What if no regular =
expression matches=20
a prefix of the remaining input?</H2>
<P>Then a TokenMgrError is thrown.=20
<P>
<H2><A name=3Dtth_sEc3.5>3.5</A>&nbsp;&nbsp;How do I match any =
character?</H2>
<P>Use ~[] .=20
<P>
<H2><A name=3Dtth_sEc3.6>3.6</A>&nbsp;&nbsp;How do I match exactly =
<I>n</I>=20
repetitions of a regular expression?</H2>
<P>If <I>X</I> is the regular expression, write <BR clear=3Dall></P>
<TABLE border=3D0 width=3D"100%">
  <TBODY>
  <TR>
    <TD>
      <TABLE align=3Dcenter>
        <TBODY>
        <TR>
          <TD noWrap=20
  =
align=3Dmiddle>(<I>X</I>){<I>n</I>}</TD></TR></TBODY></TABLE></TD></TR></=
TBODY></TABLE>You=20
can also give a lower and upper bound on the number of repetitions: <BR=20
clear=3Dall>
<TABLE border=3D0 width=3D"100%">
  <TBODY>
  <TR>
    <TD>
      <TABLE align=3Dcenter>
        <TBODY>
        <TR>
          <TD noWrap=20
      =
align=3Dmiddle>(<I>X</I>){<I>l</I>,<I>u</I>}</TD></TR></TBODY></TABLE></T=
D></TR></TBODY></TABLE>
<P>
<H2><A name=3Dtth_sEc3.7>3.7</A>&nbsp;&nbsp;What are <FONT=20
face=3Dhelvetica><B>TOKEN</B></FONT>, <FONT =
face=3Dhelvetica><B>SKIP</B></FONT>, and=20
<FONT face=3Dhelvetica><B>SPECIAL_TOKEN</B></FONT>? <A=20
name=3Dtoken-skip-special></A></H2>
<P>Regular expression productions are classified as one of four kinds:=20
<P>
<UL>
  <LI><FONT face=3Dhelvetica><B>TOKEN</B></FONT> means that when the =
production is=20
  applied, a <FONT face=3Dhelvetica>Token</FONT> object should be =
created and=20
  passed to the parser.=20
  <P></P>
  <LI><FONT face=3Dhelvetica><B>SKIP</B></FONT> means that when the =
production is=20
  applied, no <FONT face=3Dhelvetica>Token</FONT> object should be =
constructed.=20
  <P></P>
  <LI><FONT face=3Dhelvetica><B>SPECIAL_TOKEN</B></FONT> means that when =
the=20
  production is applied a <FONT face=3Dhelvetica>Token</FONT> object =
should be=20
  created but it should not be passed to the parser. Each of these =
"special=20
  tokens"&nbsp;can be accessed from the next <FONT =
face=3Dhelvetica>Token</FONT>=20
  produced&nbsp;(whether special or not), via its <FONT=20
  face=3Dhelvetica>specialToken</FONT> field.=20
  <P></P>
  <LI><FONT face=3Dhelvetica><B>MORE</B></FONT> is discussed in Question =
<A=20
  =
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#more">3.11</A>,=20
  "What is <FONT face=3Dhelvetica><B>MORE</B>?</FONT>" .=20
  <P></P></LI></UL>
<P>
<H2><A name=3Dtth_sEc3.8>3.8</A>&nbsp;&nbsp;What are lexical states all =
about?<A=20
name=3Dstates></A></H2>
<P>Lexical states allow you to bring different sets of regular =
expression=20
productions in-to and out-of effect.=20
<P>Suppose you wanted to write a JavaDoc processor. Most of Java is =
tokenized=20
according to regular ordinary Java rules. But between a =
"<TT>/**</TT>"&nbsp;and=20
the next "<TT>*/</TT>"&nbsp;a different set of rules applies in which =
keywords=20
like "<TT>@param</TT>"&nbsp;must be recognized and where newlines are=20
significant. To solve this problem, we could use two lexical states. One =
for=20
regular Java tokenizing and one for tokenizing within JavaDoc comments. =
We might=20
use the following productions:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><EM>// When a /** is seen in the DEFAULT&nbsp;state, switch to =
the=20
      IN_JAVADOC_COMMENT&nbsp;state</EM>=20
      <P><B>TOKEN</B> : {=20
      <P>
      <DL compact>
        <DD>&lt; STARTDOC&nbsp;:&nbsp;"/**" &gt; =
&nbsp;:&nbsp;IN_JAVADOC_COMMENT=20
        } </DD></DL>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P><EM>// When @param is seen in the =
IN_JAVADOC_COMMENT&nbsp;state, it is=20
      a token.</EM>=20
      <P><EM>// Stay in the same state.</EM>=20
      <P>&lt; IN_JAVADOC_COMMENT &gt; <B>TOKEN</B> : {=20
      <P>
      <DL compact>
        <DD>&lt; PARAM&nbsp;:&nbsp;"@param" &gt; } </DD></DL>
      <P>...=20
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P><EM>// When a */ is seen in the IN_JAVADOC_COMMENT&nbsp;state,=20
      switch</EM>=20
      <P><EM>// back to the DEFAULT state</EM>=20
      <P>&lt; IN_JAVADOC_COMMENT &gt; <B>TOKEN</B> : {=20
      <P>
      <DL compact>
        <DD>&lt; ENDDOC:&nbsp;"*/" &gt; : DEFAULT }=20
</DD></DL></TD></TR></TBODY></TABLE></FONT>
<P>Productions that are prefixed by <FONT face=3Dhelvetica>&lt; =
IN_JAVADOC_COMMENT=20
&gt; </FONT>apply when the lexical analyzer is in the <FONT=20
face=3Dhelvetica>IN_JAVADOC_COMMENT</FONT> state. Productions that have =
no such=20
prefix apply in the <FONT face=3Dhelvetica>DEFAULT</FONT> state. It=20
is&nbsp;possible to list any number of states (comma separated) before a =

production. The special prefix <FONT face=3Dhelvetica>&lt; * &gt; =
</FONT>indicates=20
that the production can apply in all states.=20
<P>Lexical states are also useful for avoiding complex regular =
expressions.=20
Suppose you want to skip C style comments. You could write a regular =
expression=20
production:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>SKIP</B>&nbsp;:&nbsp;{&nbsp; &lt; "/*"(~["*"])* "*"(~["/"]=20
      (~["*"])* "*")* "/" &gt; } </TD></TR></TBODY></TABLE></FONT>
<P>But how confident are you that this is right?<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFtNtAAD"=20
name=3DtthFrefAAD><SUP>3</SUP></A>&nbsp;The following version uses a =
lexical state=20
called <FONT face=3Dhelvetica>IN_COMMENT</FONT> to make things much =
clearer:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><EM>// When a /* is seen in the DEFAULT&nbsp;state, skip it and =
switch=20
      to the IN_COMMENT&nbsp;state</EM>=20
      <P><B>SKIP</B>&nbsp;: {=20
      <P>
      <DL compact>
        <DD>"/*":&nbsp;IN_COMMENT } </DD></DL>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P><EM>// When any other character is seen in the =
IN_COMMENT&nbsp;state,=20
      skip it.</EM>=20
      <P>&lt; IN_COMMENT &gt; <B>SKIP</B> : {=20
      <P>
      <DL compact>
        <DD>&lt; &nbsp;~[] &gt; } </DD></DL>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P><EM>// When a */ is seen in the IN_COMMENT&nbsp;state, skip it =
and=20
      switch back to the DEFAULT state</EM>=20
      <P>&lt; IN_COMMENT &gt; <B>SKIP</B> : {=20
      <P>
      <DL compact>
        <DD>"*/": DEFAULT } </DD></DL></TD></TR></TBODY></TABLE></FONT>
<P>The previous example also illustrates a subtle behavioural difference =
between=20
using lexical states and performing the same task with a single, =
apparently=20
equivalent, regular expression. Consider tokenizing the =
C&nbsp;"statement":=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><TT>i =3D j/*p ;</TT> </TD></TR></TBODY></TABLE></FONT>
<P>Assuming that there are no occurrences of <FONT =
face=3Dhelvetica>*/</FONT>=20
later in the file, this is an error (since a comment starts, but doesn't =
end)=20
and should be diagnosed. If we use a single, complex, regular expression =
to find=20
comments, then the lexical error will be missed and, in this example at =
least, a=20
syntactically correct sequence of seven tokens will be found. If we use =
the=20
lexical states approach then the behaviour is different, though again =
incorrect;=20
the comment will be skipped; an EOF token will be produced after the =
token for=20
"<TT>j</TT>"<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFtNtAAE"=20
name=3DtthFrefAAE><SUP>4</SUP></A>; no error will be reported. We can =
correct the=20
lexical states approach, however, with the use of <FONT=20
face=3Dhelvetica><B>MORE</B></FONT>; see Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#more">3.11</A>,=20
"What is <FONT face=3Dhelvetica><B>MORE</B>?</FONT>" .=20
<P>
<H2><A name=3Dtth_sEc3.9>3.9</A>&nbsp;&nbsp;Can the parser force a =
switch to a new=20
lexical state?</H2>
<P>Yes, but it is very easy to create bugs by doing so. You can call the =
token=20
manager's method <FONT face=3Dhelvetica>SwitchTo</FONT> from within a =
semantic=20
action in the parser like this=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>{&nbsp;token_source.SwitchTo(<EM>name_of_state</EM>) ; }=20
</TD></TR></TBODY></TABLE></FONT>
<P>However, owing to look-ahead, the token manager may be well ahead of =
the=20
parser. Consider Figure 1.2; at any point in the parse, there are a =
number of=20
tokens on the conveyer belt, waiting to be used by the parser; =
technically the=20
conveyer belt is a queue of tokens held within the parser object. Any =
change of=20
state will take effect for the first token not yet in the queue. =
Syntactic=20
look-ahead usually means there is at least one token in the queue, but =
there may=20
be many more.=20
<P>If you are going to force a state change from the parser be sure =
that, at=20
that point in the parsing, the token manager is a known and fixed number =
of=20
tokens ahead of the parser, and that you know what that number is.=20
<P>If you ever feel tempted to call <FONT =
face=3Dhelvetica>SwitchTo</FONT> from=20
the parser, stop and try to think of an alternative method that is =
harder to get=20
wrong.=20
<P>
<H2><A name=3Dtth_sEc3.10>3.10</A>&nbsp;&nbsp;Is there a way to make =
SwitchTo=20
safer?</H2>
<P>Brian Goetz submitted the following code to make sure that, when a =
SwitchTo=20
is done, any queued tokens are removed from the queue. There are three =
parts to=20
the solution:=20
<P>
<UL>
  <LI>In the parser add a subroutine <FONT =
face=3Dhelvetica>SetState</FONT> to=20
  change the state. This subroutine can be found at <A=20
  =
href=3D"http://www.engr.mun.ca/~theo/JavaCC-FAQ/SetState.txt">http://www.=
engr.mun.ca/~theo/JavaCC-FAQ/SetState.txt</A>.=20
  Use this subroutine to change states within semantic actions of the =
parser.=20
  <P></P>
  <LI>In the token manager add a subroutine:=20
  <P><FONT face=3Dhelvetica></P>
  <TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
    <TBODY>
    <TR>
      <TD>TOKEN_MGR_DECLS : {=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>// Required by SetState=20
          <DT><B></B>
          <DD>void backup(int n) { input_stream.backup(n); } </DD></DL>
        <P>} </P></TD></TR></TBODY></TABLE></FONT>
  <P></P>
  <LI>Use the <FONT face=3Dhelvetica>USER_CHAR_STREAM</FONT> option and =
use <FONT=20
  face=3Dhelvetica>BackupCharStream</FONT> as the <FONT=20
  face=3Dhelvetica>CharStream</FONT> class. <FONT=20
  face=3Dhelvetica>BackupCharStream</FONT> can be found at <A=20
  =
href=3D"http://www.webmacro.org/cvs/cvsweb.cgi/webmacro/src/org/webmacro/=
parser/BackupCharStream.java">http://www.webmacro.org/cvs/cvsweb.cgi/webm=
acro/src/org/webmacro/parser/BackupCharStream.java</A>.=20

  <P></P></LI></UL>
<P>
<H2><A name=3Dtth_sEc3.11>3.11</A>&nbsp;&nbsp;What is <FONT=20
face=3Dhelvetica>MORE</FONT>?<A name=3Dmore></A></H2>
<P>Regular expression productions are classified as one of four kinds:=20
<P>
<UL>
  <LI><FONT face=3Dhelvetica><B>TOKEN</B></FONT>, <FONT=20
  face=3Dhelvetica><B>SKIP</B></FONT>, and <FONT=20
  face=3Dhelvetica><B>SPECIAL_TOKEN</B></FONT> are discussed in Question =
<A=20
  =
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#token-skip-special">3.7</A>,=20
  "What are <FONT face=3Dhelvetica><B>TOKEN</B></FONT>, <FONT=20
  face=3Dhelvetica><B>SKIP</B></FONT>, and <FONT=20
  face=3Dhelvetica><B>SPECIAL_TOKEN</B></FONT>?" .=20
  <P></P>
  <LI><FONT face=3Dhelvetica><B>MORE</B></FONT>.=20
  <P></P></LI></UL>
<P><FONT face=3Dhelvetica><B>MORE</B></FONT> means that no token should =
be=20
produced yet. Rather the characters matched will form part of the next =
token to=20
be recognized. <FONT face=3Dhelvetica><B>MORE</B></FONT> means that =
there will be=20
more to the token. After a sequence of one or more <FONT=20
face=3Dhelvetica><B>MORE</B></FONT> productions have been applied, we =
must reach a=20
production that is marked <FONT face=3Dhelvetica><B>TOKEN</B></FONT>, =
<FONT=20
face=3Dhelvetica><B>SKIP</B></FONT>, <FONT=20
face=3Dhelvetica><B>SPECIAL_TOKEN</B></FONT>. The token produced (or not =
produced=20
in the case of <FONT face=3Dhelvetica><B>SKIP</B></FONT>) will contain =
the saved=20
up characters from the preceding <FONT =
face=3Dhelvetica><B>MORE</B></FONT>=20
productions. Note that if the end of the input is encountered when the =
token=20
manager is looking for more of a token, then a <FONT=20
face=3Dhelvetica>TokenMgrError</FONT> is thrown. The assumption made by =
JavaCC is=20
that the <FONT face=3Dhelvetica>EOF</FONT> token should correspond =
exactly to the=20
end of the input, not to some characters leading up to the end of the =
input.=20
<P>Let's revisit and fix the comment example from Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#states">3.8</A>,=20
"What are lexical states all about?" . The problem was that unterminated =

comments were simply skipped rather than producing an error. We can =
correct this=20
problem using <FONT face=3Dhelvetica><B>MORE</B></FONT> productions to =
combine the=20
entire comment into a single token.=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><EM>// When a /* is seen in the DEFAULT&nbsp;state, skip it and =
switch=20
      to the IN_COMMENT&nbsp;state</EM>=20
      <P><B>MORE</B>&nbsp;: {=20
      <P>
      <DL compact>
        <DD>"/*":&nbsp;IN_COMMENT } </DD></DL>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P><EM>// When any other character is seen in the =
IN_COMMENT&nbsp;state,=20
      skip it.</EM>=20
      <P>&lt; IN_COMMENT &gt; <B>MORE</B> : {=20
      <P>
      <DL compact>
        <DD>&lt; &nbsp;~[] &gt; } </DD></DL>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P><EM>// When a */ is seen in the IN_COMMENT&nbsp;state, skip it =
and=20
      switch back to the DEFAULT state</EM>=20
      <P>&lt; IN_COMMENT &gt; <B>SKIP</B> : {=20
      <P>
      <DL compact>
        <DD>"*/": DEFAULT } </DD></DL></TD></TR></TBODY></TABLE></FONT>
<P>Suppose that a file ends with "<TT>/*a</TT>". Then no token can be=20
recognized, because the end of file is found when the token manager only =
has a=20
partly recognized token. Instead a <FONT =
face=3Dhelvetica>TokenMgrError</FONT>=20
will be thrown.=20
<P>
<H2><A name=3Dtth_sEc3.12>3.12</A>&nbsp;&nbsp;Why do the example Java =
and C++=20
parsers report an error when the last line of a file is a single line=20
comment?</H2>
<P>The file is likely missing a newline character (or the =
equivalent)&nbsp;at=20
the end of the last line.=20
<P>These parsers use lexical states and <B>MORE</B> type regular =
expression=20
productions to process single line comments thusly:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>MORE</B> : {=20
      <P>
      <DL compact>
        <DD>"//": IN_SINGLE_LINE_COMMENT } </DD></DL>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P>&lt; IN_SINGLE_LINE_COMMENT &gt; <B>SPECIAL_TOKEN</B> : {=20
      <P>
      <DL compact>
        <DD>&lt; SINGLE_LINE_COMMENT: "\n"<FONT =
face=3Dsymbol>|</FONT>"\r"<FONT=20
        face=3Dsymbol>|</FONT>"\r\n" &gt; : DEFAULT } </DD></DL>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P>&lt; IN_SINGLE_LINE_COMMENT &gt; <B>MORE</B>&nbsp;:&nbsp;{=20
      <P>
      <DL compact>
        <DD>&lt; &nbsp;~[] &gt; } =
</DD></DL></TD></TR></TBODY></TABLE></FONT>
<P>Clearly if an EOF is encountered while the token manager is still =
looking for=20
more of the current token, there should be a TokenMgrError thrown.=20
<P>Both the Java and the C++ standards agree with the example .jj files, =
but=20
some compilers are more liberal and do not insist on that final newline. =
If you=20
want the more liberal interpretation, try=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>SPECIAL_TOKEN</B> : {=20
      <P>
      <DL compact>
        <DD>&lt; SINGLE_LINE_COMMENT: "//"(~["\n","\r"])* ("\n"<FONT=20
        face=3Dsymbol>|</FONT>"\r"<FONT face=3Dsymbol>|</FONT>"\r\n")? =
&gt; }=20
      </DD></DL></TD></TR></TBODY></TABLE></FONT>
<P>
<H2><A name=3Dtth_sEc3.13>3.13</A>&nbsp;&nbsp;What is a lexical =
action?</H2>
<P>Sometimes you want some piece of Java code to be executed immediately =
after a=20
token is matched. Lexical actions are placed immediately after the =
regular=20
expression in a regular expression production. For example:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>TOKEN :&nbsp;{=20
      <P>
      <DL compact>
        <DD>&lt; TAB&nbsp;:&nbsp;"\t" &gt; &nbsp;{ tabcount+=3D1; } =
</DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>The Java statement <FONT face=3Dhelvetica>{ tabcount+=3D1; }</FONT> =
will be=20
executed after the production is applied.=20
<P>
<H2><A name=3Dtth_sEc3.14>3.14</A>&nbsp;&nbsp;What is a common token =
action?</H2>
<P>A common token action is simply a subroutine that is called after =
each <FONT=20
face=3Dhelvetica>Token</FONT> is matched. Note that this does not apply =
to=20
"skipped tokens"&nbsp;nor to "special tokens".=20
<P>
<H2><A name=3Dtth_sEc3.15>3.15</A>&nbsp;&nbsp;How do I throw a =
ParseException=20
instead of a TokenMgrError?</H2>
<P>If you don't want any TokenMgrErrors being thrown, try putting a =
regular=20
expression production at the very end of your .jj file that will match =
any=20
character:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>&lt; * &gt; <B>TOKEN</B> :=20
      <P>{=20
      <P>&lt; UNEXPECTED_CHAR : ~[] &gt;=20
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>However, this may not do the trick. In particular, if you use MORE, =
it may be=20
hard to avoid TokenMgrErrors altogether. It is best to make a policy of =
catching=20
TokenMgrErrors as well as ParseExceptions, whenever you call an entry =
point to=20
the parser.=20
<P>
<H2><A name=3Dtth_sEc3.16>3.16</A>&nbsp;&nbsp;Why are line and column =
numbers not=20
recorded?</H2>
<P>In version 2.1 a new feature was introduced. You now have the option =
that the=20
line and column numbers will not be recorded in the Token objects. The =
option is=20
called <FONT face=3Dhelvetica>KEEP_LINE_COLUMN</FONT>. The default is =
<FONT=20
face=3Dhelvetica>true</FONT>, so not knowing about this option =
<EM>shouldn't</EM>=20
hurt you.=20
<P>However, there appears to be a bug in the GUI&nbsp;interface to =
JavaCC=20
(javaccw.exe), which sets this option to <FONT =
face=3Dhelvetica>false</FONT> (even=20
if you explicitly set it to <FONT face=3Dhelvetica>true</FONT> in the =
.jj file).=20
<P>The solution is to delete <B>all</B> generated files (see Question <A =

href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#option-changed">2.3</A>,=20
`` I changed option <I>x</I>; why am I having trouble?'' ) and =
henceforth to not=20
use the GUI&nbsp;interface to JavaCC.=20
<P>
<H1><A name=3Dtth_chAp4>Chapter 4 </A><BR>The Parser and Lookahead</H1>
<P>
<H2><A name=3Dtth_sEc4.1>4.1</A>&nbsp;&nbsp;Where should I draw the line =
between=20
lexical analysis and parsing?</H2>
<P>This question is dependant on the application. A lot of simple =
applications=20
only require a token manager. However, many people try to do too much =
with the=20
lexical analyzer, for example they try to write an expression parser =
using only=20
the lexical analyzer.=20
<P>
<H2><A name=3Dtth_sEc4.2>4.2</A>&nbsp;&nbsp;What is recursive descent=20
parsing?</H2>
<P>JavaCC's generated parser classes work by the method of "recursive =
descent".=20
This means that each BNF production in the .jj file is translated into a =

subroutine with roughly the following mandate:=20
<P>
<BLOCKQUOTE><EM>If there is a prefix of the input sequence of tokens =
that=20
  matches this nonterminal's definition,</EM>=20
  <P><EM>then remove that prefix from the input sequence</EM>=20
  <P><EM>else throw a ParseException</EM> </P></BLOCKQUOTE>
<P>
<H2><A name=3Dtth_sEc4.3>4.3</A>&nbsp;&nbsp;What is left-recursion and =
why can't I=20
use it?</H2>
<P>Left-recursion is when a nonterminal contains a recursive reference =
to itself=20
that is not preceded by something that will consume tokens.=20
<P>The parser class produced by JavaCC works by recursive descent.=20
Left-recursion is banned to prevent the generated subroutines from =
calling=20
themselves recursively ad-infinitum. Consider the following obviously =
left=20
recursive production=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> A()&nbsp;: {} {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>A() B() </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>C() </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>This will translate to a Java subroutine of the form=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> A()&nbsp;: {}&nbsp;{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD><B>if</B>(&nbsp;<EM>some condition</EM> )&nbsp;{=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>A() ;=20
          <DT><B></B>
          <DD>B() ; } </DD></DL>
        <DT><B></B>
        <DD><B>else</B> {=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>C() ; } </DD></DL></DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>Now if the condition is ever true, we have an infinite recursion.=20
<P>Luckly JavaCC will produce an error message, if you have =
left-recursive=20
productions.=20
<P>
<H2><A name=3Dtth_sEc4.4>4.4</A>&nbsp;&nbsp;What is "lookahead"?</H2>
<P>To use JavaCC effectively you have to understand how it looks ahead =
in the=20
token stream to decide what to do. Your maintainer strongly recommends =
reading=20
the lookahead mini-tutorial in the JavaCC&nbsp;documentation. (See =
Section<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#javacc-doc">2.1</A>)=20
. The following questions of the FAQ address some common problems and=20
misconceptions about lookahead. Ken Beesley has kindly contributed some =
<A=20
href=3D"http://www.engr.mun.ca/~theo/JavaCC-FAQ/kens-javacc-lookahead-sum=
mary.txt">supplementary=20
documentation</A>.=20
<P>
<H2><A name=3Dtth_sEc4.5>4.5</A>&nbsp;&nbsp;I get a message saying =
"Warning:=20
Choice Conflict ... "; what should I do?</H2>
<P>Some of JavaCC's most common error messages goes something like this=20
<P>
<BLOCKQUOTE><EM>Warning:&nbsp;Choice conflict ...</EM>=20
  <P><EM>Consider using a lookahead of 2 for ...</EM> </P></BLOCKQUOTE>
<P>Read the message carefully. Understand why there is a choice conflict =
(choice=20
conflicts will be explained shortly) and take appropriate action. The=20
appropriate action, in my experience, is rarely to use a lookahead of 2. =

<P>So what is a choice conflict. Well suppose you have a BNF production=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> a()&nbsp;:&nbsp;{}&nbsp;{=20
      <P>
      <DL compact>
        <DD>&lt; ID &gt; &nbsp;b()&nbsp; </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; ID &gt; &nbsp;c() </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>When the parser applies this production, it must choose between =
expanding it=20
to <FONT face=3Dhelvetica>&lt; ID &gt; &nbsp;b()</FONT> and expanding it =
to <FONT=20
face=3Dhelvetica>&lt; ID &gt; &nbsp;c()</FONT>. The default method of =
making such=20
choices is to look at the next token. But if the next token is of kind =
<FONT=20
face=3Dhelvetica>ID</FONT> then either choice is appropriate. So you =
have a=20
"choice conflict". For alternation (i.e. <FONT face=3Dsymbol>|</FONT>) =
the default=20
choice is the first choice.=20
<P>To resolve this choice conflict you can add a "LOOKAHEAD =
specification"to the=20
first alternative. For example, if nonterminal <FONT =
face=3Dhelvetica>b</FONT> and=20
nonterminal <FONT face=3Dhelvetica>c</FONT> can be distinguished on the =
basis of=20
the token after the <FONT face=3Dhelvetica>ID</FONT> token, then the =
parser need=20
only lookahead 2 tokens. You tell JavaCC this by writing:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> a()&nbsp;:&nbsp;{}&nbsp;{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>LOOKAHEAD(&nbsp;2 )=20
        <DD>&lt; ID &gt; &nbsp;b()&nbsp; </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; ID &gt; &nbsp;c() </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>Ok, but suppose that <FONT face=3Dhelvetica>b</FONT> and <FONT=20
face=3Dhelvetica>c</FONT> can start out the same and are only =
distinguishable by=20
how they end. No predetermined limit on the length of the lookahead will =
do. In=20
this case, you can use "syntactic lookahead". This means you have the =
parser=20
look ahead to see if a particular syntactic pattern is matched before =
committing=20
to a choice. Syntactic lookahead in this case would look like this:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> a()&nbsp;:&nbsp;{}&nbsp;{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD><EM>// Take the first alternative if an &lt; ID &gt; =
followed by a=20
        b() appears next</EM>=20
        <DT><B></B>
        <DD>LOOKAHEAD(&nbsp; &lt; ID &gt; &nbsp;b() )=20
        <DD>&lt; ID &gt; &nbsp;b()&nbsp; </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; ID &gt; &nbsp;c() </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>Another way to resolve conflicts is to rewrite the grammar. The above =

nonterminal can be rewritten as=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> a()&nbsp;:&nbsp;{}&nbsp;{=20
      <P>
      <DL compact>
        <DD>&lt; ID &gt;=20
        <P></P>
        <DT><B></B>
        <DD>(=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>b()&nbsp; </DD></DL>
        <DD><FONT face=3Dsymbol>|</FONT>=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>c() </DD></DL>
        <DT><B></B>
        <DD>) </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>which may resolve the conflict.=20
<P>Choice conflicts also come up in loops. Consider=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> paramList()&nbsp;:&nbsp;{}&nbsp;{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>param()=20
        <DT><B></B>
        <DD>(=20
        <P>
        <DL compact>
          <DD>&lt; COMMA &gt;=20
          <P></P>
          <DT><B></B>
          <DD>param() </DD></DL>
        <DT><B></B>
        <DD>)*=20
        <DT><B></B>
        <DD>(=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>( &lt; COMMA &gt; )?&nbsp; &lt; ELLIPSIS &gt;=20
          <P></P></DD></DL>
        <DT><B></B>
        <DD>)? </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>There is a choice of whether to stay in the * loop or to exit it and =
process=20
the optional <FONT face=3Dhelvetica>ELLIPSIS</FONT>. But the default =
method of=20
making the choice based on the next token does not work; a <FONT=20
face=3Dhelvetica>COMMA</FONT> token could be the first thing seen in the =
loop=20
body, or it could be the first thing after the loop body. For loops the =
default=20
choice is to stay in the loop.=20
<P>To solve this example we could use a lookahead of 2 at the =
appropriate choice=20
point (assuming a param can not be empty and that one can't start with =
an <FONT=20
face=3Dhelvetica>ELLIPSIS</FONT>.=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> paramList()&nbsp;:&nbsp;{}&nbsp;{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>param()=20
        <DT><B></B>
        <DD>(=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>LOOKAHEAD(2)=20
          <DD>&lt; COMMA &gt;=20
          <P></P>
          <DT><B></B>
          <DD>param() </DD></DL>
        <DT><B></B>
        <DD>)*=20
        <DT><B></B>
        <DD>(=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>( &lt; COMMA &gt; )?&nbsp; &lt; ELLIPSIS &gt;=20
          <P></P></DD></DL>
        <DT><B></B>
        <DD>)? </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>We could also rewrite the grammar, replacing the loop with a =
recursion.=20
<P>Sometimes the right think to do is nothing. Consider this classical =
example,=20
again from programming languages=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> statement()&nbsp;: {}=20
      <P>{=20
      <P>
      <DL compact>
        <DD>&lt; IF &gt; &nbsp;exp() &lt; THEN &gt; =
&nbsp;statement()&nbsp;=20
        <DT><B></B>
        <DD>(&nbsp; &lt; ELSE &gt; &nbsp;statement()&nbsp;)? </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD><EM>...other possible statements...</EM> </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>Because an <FONT face=3Dhelvetica>ELSE</FONT> token could =
legitimately follow a=20
<FONT face=3Dhelvetica>statement</FONT>, there is a conflict. The fact =
that an=20
<FONT face=3Dhelvetica>ELSE</FONT> appears next is not enough to =
indicate that the=20
optional "<FONT face=3Dhelvetica> &lt; ELSE &gt; =
&nbsp;statement()</FONT>"should=20
be parsed. Thus there is a conflict. The default for parsers is to take =
an=20
option rather than to leave it; and that turns out to be the right=20
interpretation in this case (at least for C, C++, Java, Pascal, etc.). =
If you=20
want, you can write:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> statement()&nbsp;: {}=20
      <P>{=20
      <P>
      <DL compact>
        <DD>&lt; IF &gt; &nbsp;exp() &lt; THEN &gt; =
&nbsp;statement()&nbsp;=20
        <DT><B></B>
        <DD>(&nbsp;LOOKAHEAD(&nbsp; &lt; ELSE &gt; )&nbsp; &lt; ELSE =
&gt;=20
        &nbsp;statement()&nbsp;)? </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD><EM>...other possible statements...</EM> </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>to suppress the warning.=20
<P>
<H2><A name=3Dtth_sEc4.6>4.6</A>&nbsp;&nbsp;I&nbsp;added a LOOKAHEAD =
specification=20
and the warning went away; does that mean I&nbsp;fixed the problem?</H2>
<P>No. JavaCC&nbsp;will not report choice conflict warnings if you use a =

LOOKAHEAD specification. The absence of a warning doesn't mean that =
you've=20
solved the problem correctly, it just means that you added a LOOKAHEAD=20
specification.=20
<P>Consider the following example:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> eg()&nbsp;: {}=20
      <P>{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>LOOKAHEAD(2)=20
        <DD>&lt; A &gt; &nbsp; &lt; B &gt; &nbsp; &lt; C &gt;=20
        <P></P></DD></DL>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; A &gt; &nbsp; &lt; B &gt; &nbsp; &lt; D &gt;=20
        <P></P></DD></DL>} </TD></TR></TBODY></TABLE></FONT>
<P>Clearly the lookahead is insufficient (lookahead 3 would do the =
trick), but=20
JavaCC produces no warning. When you add a&nbsp;LOOKAHEAD specification, =
JavaCC=20
assumes you know what you are doing and suppresses any warnings.=20
<P>
<H2><A name=3Dtth_sEc4.7>4.7</A>&nbsp;&nbsp;Are semantic actions =
executed during=20
syntactic lookahead?</H2>
<P>No.=20
<P>
<H2><A name=3Dtth_sEc4.8>4.8</A>&nbsp;&nbsp;Are nested syntactic =
lookahead=20
specifications evaluated during syntactic lookahead?</H2>
<P>No!=20
<P>This can is a bit surprising. Consider a grammar=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>void start( ) : { } {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>LOOKAHEAD( a() )=20
        <DT><B></B>
        <DD>a()=20
        <DD>&lt; EOF &gt;=20
        <P></P></DD></DL>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>w()=20
        <DD>&lt; EOF &gt;=20
        <P></P></DD></DL>}=20
      <P>void a( ) : { } {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>(=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>LOOKAHEAD( w() y() )=20
          <DT><B></B>
          <DD>w() </DD></DL>
        <DD><FONT face=3Dsymbol>|</FONT>=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>w() x() </DD></DL>
        <DT><B></B>
        <DD>)=20
        <DT><B></B>
        <DD>y() </DD></DL>
      <P>}=20
      <P>void w() : {} { ''w'' }=20
      <P>void x() : {} { ''x'' }=20
      <P>void y() : {} { ''y'' } </P></TD></TR></TBODY></TABLE></FONT>
<P>and an input sequence of "wxy". You might expect that this string =
will be=20
parsed without error, but it isn't. The lookahead on <FONT=20
face=3Dhelvetica>a()</FONT> fails so the parser takes the second (wrong) =

alternative in <FONT face=3Dhelvetica>start</FONT>. So why does the =
lookahead on=20
<FONT face=3Dhelvetica>a()</FONT> fail?&nbsp;The lookahead specification =
within=20
<FONT face=3Dhelvetica>a()</FONT> is intended to steer the parser to the =
second=20
alternative when the remaining input starts does not start with "wy". =
However=20
during syntactic lookahead, this inner syntactic lookahead is ignored. =
The=20
parser considers first whether the remaining input, "wxy",&nbsp;is =
matched by=20
the alternation <FONT face=3Dhelvetica>(w()&nbsp;<FONT=20
face=3Dsymbol>|</FONT>&nbsp;w() x())</FONT>. First it tries the first =
alternative=20
<FONT face=3Dhelvetica>w()</FONT>; this succeeds and so the alternation =
<FONT=20
face=3Dhelvetica>(w()&nbsp;<FONT face=3Dsymbol>|</FONT>&nbsp;w() x())=20
</FONT>succeeds. Next the parser does a lookahead for <FONT=20
face=3Dhelvetica>y()</FONT> on a remaining input of "xy"; this of course =
fails, so=20
the whole lookahead on <FONT face=3Dhelvetica>a()</FONT> fails. =
Lookahead does not=20
backtrack and try the second alternative of the alternation. Once one=20
alternative of an alternation has succeeded, the whole alternation is =
considered=20
to have succeeded; other alternatives are not considered. Nor does =
lookahead pay=20
attention to nested synactic LOOKAHEAD specifications.=20
<P>This problem usually comes about when the =
LOOKAHEAD&nbsp;specification looks=20
past the end of the choice it applies to. So a solution to the above =
example is=20
to interchange the order of choices like this:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>void a( ) : { } {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>(=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>LOOKAHEAD( w() x() )=20
          <DT><B></B>
          <DD>w() x() </DD></DL>
        <DD><FONT face=3Dsymbol>|</FONT>=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>w() </DD></DL>
        <DT><B></B>
        <DD>)=20
        <DT><B></B>
        <DD>y() </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>Another solution sometimes is to distribute so that the earlier =
choice is=20
longer. In the above example, we can write=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>void a( ) : { } {=20
      <P>
      <DL compact>
        <DD>
        <DL compact>
          <DT><B></B>
          <DD>LOOKAHEAD( w() y() )=20
          <DT><B></B>
          <DD>w() y() </DD></DL>
        <DD><FONT face=3Dsymbol>|</FONT>=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>w() x() y() </DD></DL></DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>Generally it is a bad idea to write syntactic look-ahead =
specifications that=20
look beyond the end of the choice they apply to. If you have a =
production <BR=20
clear=3Dall></P>
<TABLE border=3D0 width=3D"100%">
  <TBODY>
  <TR>
    <TD>
      <TABLE align=3Dcenter>
        <TBODY>
        <TR>
          <TD noWrap align=3Dmiddle><I>a</I><FONT =
face=3Dsymbol>=AE</FONT> <I>A</I>=20
            | =
<I>B</I></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>and you=20
transliterate it into JavaCC as=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>void a()&nbsp;:&nbsp;{}&nbsp;{ LOOKAHEAD(<I>C</I>) <I>A</I> =
<FONT=20
      face=3Dsymbol>|</FONT>&nbsp;<I>B</I> } =
</TD></TR></TBODY></TABLE></FONT>
<P>then it is a good idea that <I>L</I>(<I>C</I>) (the language of =
strings=20
matched by <I>C</I>) is a set of prefixes of <I>L</I>(<I>A</I>). That is =
<BR=20
clear=3Dall></P>
<TABLE border=3D0 width=3D"100%">
  <TBODY>
  <TR>
    <TD>
      <TABLE align=3Dcenter>
        <TBODY>
        <TR>
          <TD noWrap align=3Dmiddle><FONT face=3Dsymbol>"</FONT><I>u</I> =
<FONT=20
            face=3Dsymbol>=CE</FONT> <I>L</I>(<I>C</I>)=B7<FONT=20
            face=3Dsymbol>$</FONT><I>v</I> <FONT =
face=3Dsymbol>=CE</FONT> <FONT=20
            face=3Dsymbol>S</FONT><SUP><FONT =
face=3Dsymbol>*</FONT></SUP>=B7<I>uv</I>=20
            <FONT face=3Dsymbol>=CE</FONT>=20
  =
<I>L</I>(<I>A</I>)</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>In =
some=20
cases to accomplish this you can put the ``longer'' choice first (that =
is, the=20
choice that doesn't include prefixes of the other); in other cases you =
can use=20
distributivity to lengthen the choices.=20
<P>
<H2><A name=3Dtth_sEc4.9>4.9</A>&nbsp;&nbsp;Are parameters passed during =
syntactic=20
lookahead?</H2>
<P>No.=20
<P>
<H2><A name=3Dtth_sEc4.10>4.10</A>&nbsp;&nbsp;Are semantic actions =
executed during=20
syntactic lookahead?</H2>
<P>No.=20
<P>
<H2><A name=3Dtth_sEc4.11>4.11</A>&nbsp;&nbsp;Is semantic lookahead =
evaluated=20
during syntactic lookahead?</H2>
<P>Yes. It is also evaluated during evaluation of LOOKAHEAD( <I>n</I> ), =
for=20
<I>n</I> &gt; 1.=20
<P>
<H2><A name=3Dtth_sEc4.12>4.12</A>&nbsp;&nbsp;Can local&nbsp;variables =
(including=20
parameters) be used in semantic lookahead?</H2>
<P>Yes to a point.=20
<P>The problem is that semantic lookahead specifications are evaluated =
during=20
syntactic lookahead (and during lookahead of more than 1 token). But the =

subroutine generated to do the syntactic lookahead for a nonterminal =
will not=20
declare the parameters or the other local variables of the nonterminal. =
This=20
means that the code to do the semantic lookahead will fail to compile =
(in this=20
subroutine)&nbsp;if it mentions parameters or other local variables.=20
<P>So if you use local variables in a semantic lookahead specification =
within=20
the BNF production for a nonterminal <I>n</I>, make sure that <I>n</I> =
is not=20
used in syntactic lookahead, or in a lookahead of more than 1 token.=20
<P>This is a case of three rights not making a right! It is right that =
semantic=20
lookahead is evaluated in during syntactic lookahead, it is right (or at =
least=20
useful) that local variables can be mentioned in semantic lookahead, and =
it is=20
right that local variables do not exist during syntactic lookahead. Yet =
putting=20
these three features together tricks JavaCC into producing uncompilable =
code.=20
Perhaps a future version of JavaCC will put these interacting features =
on a=20
firmer footing.=20
<P>
<H2><A name=3Dtth_sEc4.13>4.13</A>&nbsp;&nbsp;How does JavaCC differ =
from standard=20
LL(1) parsing?</H2>
<P>Well first off JavaCC is more flexible. It lets you use multiple =
token=20
lookahead, syntactic lookahead, and semantic lookahead. If you don't use =
these=20
features, you'll find that JavaCC is only subtly different from=20
LL(1)&nbsp;parsing; it does not calculate "follow sets"in the standard =
way - in=20
fact it can't as JavaCC has no idea what your starting nonterminal will =
be.=20
<P>
<H2><A name=3Dtth_sEc4.14>4.14</A>&nbsp;&nbsp;How do I communicate from =
the parser=20
to the token manager?</H2>
<P>It is usually a bad idea to try to have the parser try to influence =
the way=20
the token manager does its job. The reason is that the token manager may =
produce=20
tokens long before the parser consumes them. This is a result of =
lookahead.=20
<P>Often the work-around is to use lexical states to have the token =
manager=20
change its behaviour on its own.=20
<P>In other cases, the work-around is to have the token manager not =
change its=20
bevhaviour and have the parser compensate. For example in parsing C, you =
need to=20
know if an identifier is a type or not. If you were using lex or yacc, =
you would=20
probably write your parser in terms of token kinds ID and TYPEDEF_NAME. =
The=20
parser will add typedef names to the symbol table after parsing each =
typedef=20
definition. The lexical analyzer will look up identifiers in the symbol =
table to=20
decide which token kind to use. This works because with lex and yacc, =
the=20
lexical analyzer is always one token ahead of the parser. In JavaCC, it =
is=20
better to just use one token kind, ID, and use a nonterminal in place of =

TYPEDEF_NAME:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> typedef_name() : {} {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>LOOKAHEAD( { getToken(1).kind =3D=3D ID &amp;&amp; =
symtab.isTypedefName(=20
        getToken(1).image ) } )=20
        <DD>&lt; ID &gt; } </DD></DL></TD></TR></TBODY></TABLE></FONT>
<P>But you have to be careful using semantic look-ahead like this. It =
could=20
still cause trouble. Consider doing a syntactic lookahead on nonterminal =
`<FONT=20
face=3Dhelvetica>statement'</FONT>. If the next statement is something =
like=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>{ typedef int T ; T i ; i =3D 0 ; return i ; }=20
</TD></TR></TBODY></TABLE></FONT>
<P>The lookahead will fail since the semantic action putting T in the =
symbol=20
table will not be done during the lookahead! Luckly in C, there should =
be no=20
need to do a syntactic lookahead on statements.=20
<P>[TBD. Think through this example very carefully.]=20
<P>
<H2><A name=3Dtth_sEc4.15>4.15</A>&nbsp;&nbsp;How do I communicate from =
the token=20
manager to the parser?</H2>
<P>As with communication between from the parser to the token manager, =
this can=20
be tricky because the token manager is often well ahead of the parser.=20
<P>For example, if you calculate the value associated with a particular =
token=20
kind in the token manager and store that value in a simple variable, =
that=20
variable may well be overwritten by the time the parser consumes the =
relevant=20
token. Instead you can use a queue. The token manager puts information =
into the=20
queue and the parser takes it out.=20
<P>Another solution is to use a table. For example in dealing with=20
<TT>#line</TT> directives in C or C++, you can have the token manager =
fill a=20
table indicating on which physical lines the<FONT=20
face=3Dhelvetica>&nbsp;</FONT><TT>#line</TT> directives occur and what =
the value=20
given by the <TT>#line</TT> is. Then the parser can use this table to =
calculate=20
the "source line number"from the physical line numbers stored in the =
Tokens.=20
<P>
<H2><A name=3Dtth_sEc4.16>4.16</A>&nbsp;&nbsp;What does it mean to put a =
regular=20
expression within a BNF&nbsp;production?<A=20
name=3Dwhat-means-reg-exp-in-bnf></A></H2>
<P>It is possible to embed a regular expression within a =
BNF&nbsp;production.=20
For example=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><EM>//A regular expression production</EM>=20
      <P><B>TOKEN</B>&nbsp;: {&nbsp; &lt; ABC :&nbsp;"abc"&nbsp; &gt; }=20
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P><EM>//A BNF production</EM>=20
      <P><B>void</B> nonterm()&nbsp;:&nbsp;{}&nbsp;{=20
      <P>
      <DL compact>
        <DD>"abc"=20
        <P></P>
        <DD>"def"=20
        <P></P>
        <DD>&lt; (["0"-"9"])+ &gt;=20
        <P></P>
        <DD>"abc"=20
        <P></P>
        <DD>"def"=20
        <P></P>
        <DD>&lt; (["0"-"9"])+ &gt;=20
        <P></P></DD></DL>} </TD></TR></TBODY></TABLE></FONT>
<P>There are six regular expressions within the BNF&nbsp;production. The =
first=20
is simply a Java string and is the same string that appears in the =
earlier=20
regular expression production. The second is simply a Java string, but =
does not=20
(we will assume) appear in a regular expression production. The third is =
a=20
"complex regular"expression. The next three simply duplicate the first =
three.=20
<P>The code above is essentially equivalent to the following:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><EM>//A regular expression production</EM>=20
      <P><B>TOKEN</B>&nbsp;: {&nbsp; &lt; ABC :&nbsp;"abc"&nbsp; &gt; }=20
      <P><B>TOKEN</B>&nbsp;: {&nbsp; &lt; ANON0 :&nbsp;"def"&nbsp; &gt; =
}=20
      <P><B>TOKEN</B>&nbsp;: {&nbsp; &lt; ANON1 :&nbsp; &lt; =
(["0"-"9"])+ &gt; }=20

      <P><B>TOKEN</B>&nbsp;: {&nbsp; &lt; ANON2 :&nbsp; &lt; =
(["0"-"9"])+ &gt; }=20

      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P><EM>//A BNF production</EM>=20
      <P><B>void</B> nonterm()&nbsp;:&nbsp;{}=20
      <P>{=20
      <P>
      <DL compact>
        <DD>&lt; ABC &gt;=20
        <P></P>
        <DD>&lt; ANON0 &gt;=20
        <P></P>
        <DD>&lt; ANON1 &gt;=20
        <P>&lt; ABC &gt;=20
        <P></P>
        <DD>&lt; ANON0 &gt;=20
        <P></P>
        <DD>&lt; ANON2 &gt;=20
        <P></P></DD></DL>} </TD></TR></TBODY></TABLE></FONT>
<P>In general when a regular expression is a Java string and identical =
to=20
regular expression occurring in a regular expression production<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFtNtAAF"=20
name=3DtthFrefAAF><SUP>5</SUP></A>, then the Java string is =
interchangeable with=20
the token kind from the regular expression production.=20
<P>When a regular expression is a Java string, but there is no =
corresponding=20
regular expression production, then JavaCC essentially makes up a =
corresponding=20
regular expression production. This is shown by the <FONT=20
face=3Dhelvetica>"def"</FONT>which becomes an anonymous regular =
expression=20
production. Note that all occurrences of the same string end up =
represented by a=20
single regular expression production.=20
<P>Finally consider the two occurrences of the complex regular =
expression <FONT=20
face=3Dhelvetica>&lt; (["0"-"9"])+ &gt; </FONT>. Each one is turned into =
a=20
different regular expression production. This spells trouble, as the =
<FONT=20
face=3Dhelvetica>ANON2</FONT> regular expression production will never =
succeed.=20
(See Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#more-than-one">3.3</A>.=20
`` What if more than one regular expression matches a prefix of the =
remaining=20
input?'' )=20
<P>See also Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#when-reg-exp-in-bnf">4.17</A>,=20
`` When should regular expressions be put directly into a =
BNF&nbsp;production?''=20
.=20
<P>
<H2><A name=3Dtth_sEc4.17>4.17</A>&nbsp;&nbsp;When should regular =
expressions be=20
put directly into a BNF&nbsp;production?<A =
name=3Dwhen-reg-exp-in-bnf></A></H2>
<P>First read Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#what-means-reg-exp-in-bnf">4.16</A>,=20
`` What does it mean to put a regular expression within a =
BNF&nbsp;production?''=20
.=20
<P>For regular expressions that are simply strings, you might as well =
put them=20
directly into the BNF&nbsp;productions, and not bother with defining =
them in a=20
regular expression production.<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFtNtAAG"=20
name=3DtthFrefAAG><SUP>6</SUP></A> For more complex regular expressions, =
it is=20
best to give them a name, using a regular expression production. There =
are two=20
reasons for this. The first is error reporting. If you give a complex =
regular=20
expression a name, that name will be used in the message attached to any =

ParseExceptions generated. If you don't give it a name, JavaCC will make =
up a=20
name like " &lt; token of kind 42 &gt; ". The second is perspicuity. =
Consider=20
the following example:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> letter_number_letters()&nbsp;:&nbsp;{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>Token letter, number, letters; } </DD></DL>
      <P>{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>letter=3D &lt; ["a"-"z"] &gt;=20
        <P></P>
        <DT><B></B>
        <DD>number=3D &lt; ["0"-"9"] &gt;=20
        <P></P>
        <DT><B></B>
        <DD>letters=3D &lt; (["a"-"z"])+ &gt;=20
        <P></P>
        <DT><B></B>
        <DD>{&nbsp;<B>return</B> <EM>some function of letter, number and =

        letters</EM> ; } </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>The intention is to be able to parse strings like "<TT>a9abc</TT>". =
Written=20
this way it is a bit hard to see what is wrong. Rewrite it as=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>TOKEN</B>&nbsp;:&nbsp; &lt; =
&nbsp;LETTER&nbsp;:&nbsp;["a"-"z"] &gt;=20
      }=20
      <P><B>TOKEN</B>&nbsp;:&nbsp; &lt; &nbsp;NUMBER&nbsp;: ["0"-"9"] =
&gt; }=20
      <P><B>TOKEN</B>&nbsp;:&nbsp; &lt; =
&nbsp;LETTERS&nbsp;:&nbsp;(["a"-"z"])+=20
      &gt; }=20
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P><B>void</B> letter_number_letters()&nbsp;:&nbsp;{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>Token letter, number, letters; } </DD></DL>
      <P>{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>letter=3D &lt; LETTER &gt;=20
        <P></P>
        <DT><B></B>
        <DD>number=3D &lt; NUMBER &gt;=20
        <P></P>
        <DT><B></B>
        <DD>letters=3D &lt; LETTERS &gt;=20
        <P></P>
        <DT><B></B>
        <DD>{&nbsp;<B>return</B> <EM>some function of letter, number and =

        letters</EM> ; } </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>and it might be easier to see the error. On a string like =
"<TT>z7d</TT>"the=20
token manager will find a <FONT face=3Dhelvetica>LETTER</FONT>, a <FONT=20
face=3Dhelvetica>NUMBER</FONT> and then another <FONT=20
face=3Dhelvetica>LETTER</FONT>; the BNF&nbsp;production can not succeed. =
(See=20
Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#more-than-one">3.3</A>,=20
`` What if more than one regular expression matches a prefix of the =
remaining=20
input?'' )=20
<P>
<H2><A name=3Dtth_sEc4.18>4.18</A>&nbsp;&nbsp;How do I parse a sequence =
without=20
allowing duplications?</H2>
<P>This turns out to be a bit tricky. Of course you can list all the=20
alteratives. Say you want A, B, C, each optionally, in any order, with =
no=20
duplications; well there are only 16 possibilities:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> abc()&nbsp;:&nbsp;{} {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>[ &lt; A &gt; &nbsp;[ &lt; B &gt; &nbsp;[ &lt; C &gt; =
&nbsp;] ] ]=20
        </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; A &gt; &nbsp; &lt; C &gt; [ &lt; B &gt; &nbsp;] =
</DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; B &gt; &nbsp;[ &lt; A &gt; &nbsp;[ &lt; C &gt; &nbsp;] =
]=20
      </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; B &gt; &nbsp; &lt; C &gt; [ &lt; A &gt; &nbsp;] =
</DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; C &gt; &nbsp;[ &lt; A &gt; &nbsp;[ &lt; B &gt; &nbsp;] =
]=20
      </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; C &gt; &nbsp; &lt; B &gt; &nbsp;[&nbsp; &lt; A &gt; =
&nbsp;]=20
        </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>This approach is already ugly and won't scale.=20
<P>A better approach is to use semantic actions to record what has been =
seen=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>void</B> abc()&nbsp;:&nbsp;{}&nbsp;{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>(=20
        <P>
        <DL compact>
          <DD>&lt; A &gt;=20
          <P></P>
          <DT><B></B>
          <DD>{ if(&nbsp;<EM>seen an A already</EM> ) throw=20
          ParseException("Duplicate A");=20
          <DT><B></B>
          <DD>else <EM>record an A</EM> } </DD></DL>
        <DD><FONT face=3Dsymbol>|</FONT>=20
        <P>
        <DL compact>
          <DD>&lt; B &gt;=20
          <P></P>
          <DT><B></B>
          <DD>{ if(&nbsp;<EM>seen an B already</EM> ) throw=20
          ParseException("Duplicate B");=20
          <DT><B></B>
          <DD>else <EM>record an B</EM> } </DD></DL>
        <DD><FONT face=3Dsymbol>|</FONT>=20
        <P>
        <DL compact>
          <DD>&lt; C &gt;=20
          <P></P>
          <DT><B></B>
          <DD>{ if(&nbsp;<EM>seen an C already</EM> ) throw=20
          ParseException("Duplicate C");=20
          <DT><B></B>
          <DD>else <EM>record an C</EM> } </DD></DL>
        <DT><B></B>
        <DD>)* </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>The problem with this approach is that it will not work well with =
syntactic=20
lookahead. Ninety-nine percent of the time you won't care about this =
problem,=20
but consider the following highly contrived example:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>void toughChoice()&nbsp;:&nbsp;{}=20
      <P>{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>LOOKAHEAD(&nbsp;abc()&nbsp;)=20
        <DT><B></B>
        <DD>abc() </DD></DL>
      <P>
      <P><FONT face=3Dsymbol>|</FONT>=20
      <P>
      <DL compact>
        <DD>&lt; A &gt; &lt; A &gt; &lt; B &gt; &lt; B &gt;=20
        <P></P></DD></DL>} </TD></TR></TBODY></TABLE></FONT>
<P>When the input is two <FONT face=3Dhelvetica>A</FONT>'s followed by =
two <FONT=20
face=3Dhelvetica>B</FONT>'s, the second choice should be taken. If you =
use the=20
first (ugly) version of <FONT face=3Dhelvetica>abc</FONT>, above, then =
that's what=20
happens. If you use the second (nice) version of <FONT=20
face=3Dhelvetica>abc</FONT>, then the first choice is taken, since =
syntactically=20
<FONT face=3Dhelvetica>abc</FONT> is <FONT face=3Dhelvetica>( &lt; A =
&gt;=20
&nbsp;<FONT face=3Dsymbol>|</FONT>&nbsp; &lt; B &gt; &nbsp;<FONT=20
face=3Dsymbol>|</FONT>&nbsp; &lt; C &gt; )*.</FONT>=20
<P>
<H2><A name=3Dtth_sEc4.19>4.19</A>&nbsp;&nbsp;How do I&nbsp;deal with =
keywords=20
that aren't reserved?</H2>
<P>In Java, C++, and many other languages, keywords, like "int", "for",=20
"throw"and so on are <EM>reserved</EM>, meaning that you can't use them =
for any=20
purpose other than that defined by the language; in particular you can =
use them=20
for variable names, function names, class names, etc. In some =
applications,=20
keywords are not reserved. For example, in the PL/I language, the =
following is a=20
valid statement=20
<P><TT>if if =3D then then then =3D else ; else else =3D if ;</TT>=20
<P>For a more modern example, in parsing URL's, we might want to treat =
the word=20
"http"as a keyword, but we don't want to prevent it being used as a host =
name or=20
a path segment. Suppose we write the following productions<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFtNtAAH"=20
name=3DtthFrefAAH><SUP>7</SUP></A>:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>TOKEN&nbsp;:&nbsp;{&nbsp; &lt; HTTP&nbsp;:&nbsp;"http" &gt; }=20
      <P>TOKEN&nbsp;:&nbsp;{ &lt; LABEL&nbsp;:&nbsp; &lt; ALPHANUM &gt; =
<FONT=20
      face=3Dsymbol>|</FONT> &lt; ALPHANUM &gt; ( &lt; ALPHANUM &gt; =
<FONT=20
      face=3Dsymbol>|</FONT>"-")* &lt; ALPHANUM &gt; }=20
      <P>void httpURL()&nbsp;:&nbsp;{}&nbsp;{ &lt; HTTP &gt; =
&nbsp;":""//"host()=20
      port_path_and_query() }=20
      <P>void host() :&nbsp;{}&nbsp;{&nbsp; &lt; LABEL &gt; ("." &lt; =
LABEL &gt;=20
      )* } </P></TD></TR></TBODY></TABLE></FONT>
<P>Both the regular expressions labelled <FONT =
face=3Dhelvetica>HTTP</FONT> and=20
<FONT face=3Dhelvetica>LABEL</FONT>, match the string "<TT>http</TT>". =
As covered=20
in Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#more-than-one">3.3</A>,=20
`` What if more than one regular expression matches a prefix of the =
remaining=20
input?'' the first rule will be chosen; thus the URL=20
<P>
<CENTER><TT>http://www.http.org/</TT> </CENTER>
<P>will not be accepted by the grammar. So what can you do? There are =
basically=20
two strategies: replace keywords with semantic lookahead, or put more =
choices in=20
the grammar.=20
<P><B>Replacing keywords with semantic lookahead.</B> Here we eliminate =
the=20
offending keyword production. In the example we would eliminate the =
regular=20
expression production labelled HTTP. Then we have to rewrite httpURL as=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>void httpURL()&nbsp;:&nbsp;{}&nbsp;{=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>LOOKAHEAD( {getToken(1).kind =3D=3D LABEL=20
        &amp;&amp;&nbsp;getToken(1).image.equals("http")} )=20
        <DD>&lt; LABEL &gt; &nbsp;":""//"host() port_path_and_query() }=20
    </DD></DL></TD></TR></TBODY></TABLE></FONT>
<P>The added semantic lookahead ensures that the URL&nbsp;really begins =
with a=20
LABEL which is actually the keyword "http". [TBD&nbsp;Check this =
example.]=20
<P><B>Putting more choices in the grammar.</B> Going back to the =
original=20
grammar, we can see that, the problem is that where we say we expect a =
<FONT=20
face=3Dhelvetica>LABEL</FONT> we actually intended to expect either a =
<FONT=20
face=3Dhelvetica>LABEL</FONT> or a <FONT face=3Dhelvetica>HTTP</FONT>. =
We can=20
rewrite the last production as=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>void host()&nbsp;:&nbsp;{}&nbsp;{&nbsp;label() ("."label())* }=20
      <P>void label()&nbsp;:&nbsp;{}&nbsp;{&nbsp; &lt; LABEL &gt; =
&nbsp;<FONT=20
      face=3Dsymbol>|</FONT>&nbsp; &lt; HTTP &gt; &nbsp;}=20
</P></TD></TR></TBODY></TABLE></FONT>
<P>
<H2><A name=3Dtth_sEc4.20>4.20</A>&nbsp;&nbsp;There's an error in the =
input, so=20
why doesn't my parser throw a ParseException?</H2>
<P>Perhaps you forgot the <FONT face=3Dhelvetica>&lt; EOF &gt; </FONT>in =
the=20
production for your start nonterminal.=20
<P>
<H1><A name=3Dtth_chAp5>Chapter 5 </A><BR>Semantic Actions</H1>
<P>
<H2><A name=3Dtth_sEc5.1>5.1</A>&nbsp;&nbsp;I've written/found a parser, =
but it=20
doesn't do anything?</H2>
<P>You need to add semantic actions. Semantic actions are bits of Java =
code that=20
get executed as the parser parses.=20
<P>
<H2><A name=3Dtth_sEc5.2>5.2</A>&nbsp;&nbsp;How do I capture and =
traverse a=20
sequence of tokens?<A name=3Dcapture-and-traverse></A></H2>
<P>Each Token object has a pointer to the next Token object. Well that's =
not=20
quite right. There are two kinds of Token objects. There are regular =
token=20
objects, created by regular expression productions prefixed by the =
keyword <FONT=20
face=3Dhelvetica>TOKEN</FONT>. And, there are special token objects, =
created by=20
regular expression productions prefixed by the keyword <FONT=20
face=3Dhelvetica>SPECIAL_TOKEN</FONT>. Each regular Token object has a =
pointer to=20
the next regular Token object. We'll deal with the special tokens later. =

<P>Now since the tokens are nicely linked into a list, we can represent =
a=20
sequence of tokens occurring in the document with a class by pointing to =
the=20
first token in the sequence and the first token to follow the sequence.=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>class</B> TokenList {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD><B>private</B> Token head ;=20
        <DT><B></B>
        <DD><B>private</B> Token tail ; </DD></DL>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>TokenList( Token head, Token tail ) {=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD>this.head =3D head ;=20
          <DT><B></B>
          <DD>this.tail =3D tail ; } </DD></DL>
        <DT><B></B>
        <DD>... </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>We can create such a list using semantic actions in the parser like =
this:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>TokenList CompilationUnit() : {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>Token head ; </DD></DL>
      <P>} {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>{ head =3D getToken( 1 ) ; }=20
        <DT><B></B>
        <DD>[ PackageDeclaration() ] ( ImportDeclaration() )* (=20
        TypeDeclaration() )*=20
        <DD>&lt; EOF &gt;=20
        <P></P>
        <DT><B></B>
        <DD>{&nbsp;return new TokenList( head, getToken(0) ) ; } =
</DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>To print regular tokens in the list, we can simply traverse the list=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>class</B> TokenList {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>...=20
        <DT><B></B>
        <DD><B>void</B> print( PrintStream os ) {=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD><B>for</B>( Token p =3D head ; p !=3D tail ; p =3D p.next =
) {=20
          <P>
          <DL compact>
            <DT><B></B>
            <DD>os.print( p.image ) ; } } </DD></DL></DD></DL>
        <DT><B></B>
        <DD>... </DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>This method of traversing the list of tokens is appropriate for many=20
applications.=20
<P>Here is some of what I&nbsp;got from printing the tokens of a Java =
file:=20
<P><BR clear=3Dall></P>
<TABLE border=3D0 width=3D"100%">
  <TBODY>
  <TR>
    <TD>
      <TABLE align=3Dcenter>
        <TBODY>
        <TR>
          <TD noWrap=20
            =
align=3Dmiddle><TT>publicclassToken</TT>{<TT>publicintkind</TT><TT>;</TT>=
<TT>publicintbeginLine</TT><TT>,</TT></TD></TR></TBODY></TABLE></TD></TR>=
</TBODY></TABLE>Obviously=20
this is not much good for either human or machine consumption. I could =
just=20
print a space between each pair of adjacent tokens. A nicer solution is =
to=20
capture all the spaces and comments using special tokens. Each <FONT=20
face=3Dhelvetica>Token</FONT> object (whether regular or special) has a =
field=20
called <FONT face=3Dhelvetica>specialToken</FONT>, which points to the =
special=20
token that appeared in the text immediately prior, if there was one, and =
is null=20
otherwise. So prior to printing the image of each token, we print the =
image of=20
the preceding special token, if any:=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD><B>class</B> TokenList {=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD>...=20
        <DT><B></B>
        <DD><B>private</B> <B>void</B> printSpecialTokens( PrintStream =
ps, Token=20
        st ) {=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD><B>if</B>( st !=3D null ) {=20
          <P>
          <DL compact>
            <DT><B></B>
            <DD>printSpecialTokens( ps, st.specialToken ) ;=20
            <DT><B></B>
            <DD>ps.print( st.image ) ; } } =
</DD></DL></DD></DL></DD></DL>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
      <P>
      <DL compact>
        <DT><B></B>
        <DD><B>void</B> printWithSpecials( PrintStream ps ) {=20
        <P>
        <DL compact>
          <DT><B></B>
          <DD><B>for</B>( Token p =3D head ; p !=3D tail ; p =3D p.next =
) {=20
          <P>
          <DL compact>
            <DT><B></B>
            <DD>printSpecialTokens( ps, p.specialToken ) ;=20
            <DT><B></B>
            <DD>ps.print( p.image ) ; } } </DD></DL></DD></DL></DD></DL>
      <P>} </P></TD></TR></TBODY></TABLE></FONT>
<P>If you want to capture and print a whole file, don't forget about the =
special=20
tokens that precede the <FONT face=3Dhelvetica>EOF</FONT> token.=20
<P>
<H1><A name=3Dtth_chAp6>Chapter 6 </A><BR>JJTree and JTB<A=20
name=3Djjtree-and-jtb></A></H1>
<P>TBD. Your maintainer knows little about either of these tools and =
would=20
especially appreciate volunteers to contribute to this part of the FAQ.=20
<P>
<H2><A name=3Dtth_sEc6.1>6.1</A>&nbsp;&nbsp;What are JJTree and =
JTB?</H2>
<P>These are preprocessors that produce .jj files. The .jj files =
produced will=20
produce parsers that produce trees.=20
<P>
<H2><A name=3Dtth_sEc6.2>6.2</A>&nbsp;&nbsp;Where can I&nbsp;find =
JJTree?</H2>
<P>JJTree comes with JavaCC. See Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#where-is-javacc">1.9</A>,=20
`` Where can I&nbsp;get JavaCC?''. .=20
<P>
<H2><A name=3Dtth_sEc6.3>6.3</A>&nbsp;&nbsp;Where can I find JTB?</H2>
<P>See <A href=3D"http://www.cs.purdue.edu/jtb/">JTB: The Java Tree =
Builder=20
Homepage</A>..=20
<P>
<H1><A name=3Dtth_chAp7>Chapter 7 </A><BR>Applications of JavaCC</H1>
<P>
<H2><A name=3Dtth_sEc7.1>7.1</A>&nbsp;&nbsp;Where can I find a parser =
for=20
<I>x</I>?</H2>
<P>First look in Dongwon Lee's <A=20
href=3D"http://www.cobase.cs.ucla.edu/pub/javacc/">JavaCC Grammar =
Repository</A>.=20
<P>Then ask the newsgroup or the mailing list.=20
<P>
<H2><A name=3Dtth_sEc7.2>7.2</A>&nbsp;&nbsp;How do I parse arithmetic=20
expressions?</H2>
<P>See the examples that come with JavaCC.=20
<P>See any text on compiling.=20
<P>See <A=20
href=3D"http://www.engr.mun.ca/~theo/Misc/index.html#parsingExps">Parsing=
=20
Epressions by Recursive Descent</A>.=20
<P>
<H2><A name=3Dtth_sEc7.3>7.3</A>&nbsp;&nbsp;I'm writing a programming =
language=20
interpreter; how do I deal with loops?</H2>
<P>A lot of people who want to write an interpreter for a programming =
language=20
seem to start with a calculator for expressions, evaluating during =
parsing, as=20
is quite reasonable. Then they add, say, assignments and if-then-else=20
statements, and all goes well. Now they want to add loops. Having =
committed to=20
the idea that they are evaluating while parsing they want to know how =
back up=20
the token manager so that loop-bodies can be reparsed, and thus =
reevaluated,=20
over and over and over again.=20
<P>It's an interesting idea, but it's clear that JavaCC will not make =
this=20
approach pleasant. Your maintainer suggests translating to an =
intermediate code=20
during parsing, and then executing the intermediate code. A tree makes a =

convenient intermediate code. Consider using JJTree or JTB (see Chapter =
<A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#jjtree-and-jtb">6</A>=20
).=20
<P>If you still want to back up the token manager. I&nbsp;suggest that =
you start=20
by tokenizing the entire file, capturing the tokens in a list (see =
Question <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#capture-and-traverse">5.2</A>,=20
`` How do I capture and traverse a sequence of tokens?''. ) or, better, =
a=20
Vector. Now write a custom token manager that delivers this captured =
sequence of=20
tokens, and also allows backing up.=20
<P>
<H1><A name=3Dtth_chAp8>Chapter 8 </A><BR>Comparing JavaCC with other =
tools</H1>
<P>[TBD. Your maintainer would welcome comparisons with&nbsp;ANTLR, CUP, =
JLex,=20
JFlex, and any others that users can contribute. My limited =
understanding is=20
that CUP&nbsp;is similar to Yacc and Bison, and that JLex and JFlex are =
similar=20
to Lex and Flex.]=20
<P>
<H2><A name=3Dtth_sEc8.1>8.1</A>&nbsp;&nbsp;Since <I>LL</I>(1) <FONT=20
face=3Dsymbol>=CC</FONT> <I>LALR</I>(1), wouldn't a tool based on =
LALR&nbsp;parsing=20
be better?</H2>
<P>It's true that there are strictly more languages that can be =
described by=20
LALR(1) grammars than by LL(1) grammars. Furthermore almost every =
parsing=20
problem that arises in programming languages has an =
LALR(1)&nbsp;solution and=20
the same can not be said for LL(1).=20
<P>But the situation in parser generators is a big more complicated. =
JavaCC is=20
based on LL(1) parsing, but it allows you to use grammars that are not =
LL(1). As=20
long as you can use JavaCC's look-ahead specification to guide the =
parsing where=20
the LL(1) rules are not sufficient, JavaCC&nbsp;can handle any grammar =
that is=20
not left-recursive. Similarly tools based on LALR(1) or =
LR(1)&nbsp;parsing=20
generally allow input grammars outside those classes.=20
<P>A case in point is the handling of if-statements in C, Java, and =
similar=20
languages. Abstracted, the grammar is <BR clear=3Dall></P>
<TABLE border=3D0 width=3D"100%">
  <TBODY>
  <TR>
    <TD>
      <TABLE align=3Dcenter>
        <TBODY>
        <TR>
          <TD noWrap align=3Dmiddle><I>S</I><FONT =
face=3Dsymbol>=AE</FONT> <I>x</I>=20
            | <I>iS</I> | =
<I>iSeS</I></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>The=20
theoretical result is that there is no LL(1) grammar that can handle the =

construct, but there is an LALR(1) grammar. Experienced parser generator =
users=20
ignore this result. Both users of LALR(1)&nbsp;based parser generator =
(such as=20
yacc) and users of LL(1)&nbsp;based parser generators (such as JavaCC) =
generally=20
use the same ambiguous set of grammar rules, which is neither LALR(1) =
nor LL(1),=20
and use other mechanisms to resolve the ambiguity.=20
<P>
<H2><A name=3Dtth_sEc8.2>8.2</A>&nbsp;&nbsp;How does JavaCC compare with =
Lex and=20
Flex?</H2>
<P>Lex is the lexical analyzer supplied for many years with most =
versions of=20
Unix. Flex is a freely distributable relative associated with the GNU =
project.=20
JavaCC and lex/flex are actually quite similar. Both work essentially =
the same=20
way, turning a set of regular expressions into a big finite state =
automaton and=20
use the same rules (for example the maximal munch rule). The big =
difference is=20
the lex and flex produce C, whereas JavaCC produces Java.=20
<P>One facility that lex and flex have, that JavaCC lacks, is the =
ability to=20
look ahead in the input stream past the end of the matched token. For a =
classic=20
example, to recognize the Fortran keyword "DO", you have to look forward =
in the=20
input stream to find a comma. This is because=20
<P><TT>DO 10 I =3D 1,20</TT>=20
<P>is a do-statement, whereas=20
<P><TT>DO 10 I</TT>=20
<P>is an assignment to a variable called <TT>DO10I</TT> (Fortran totally =
ignores=20
blanks). Dealing with this sort of thing is easy in lex, but very hard =
in=20
JavaCC.=20
<P>However JavaCC does have some nice features that Lex and Flex=20
lack:&nbsp;Common token actions, MORE rules, SPECIAL_TOKEN rules.=20
<P>
<H2><A name=3Dtth_sEc8.3>8.3</A>&nbsp;&nbsp;How does JavaCC compare with =
other=20
Yacc and Bison?</H2>
<P>Yacc is a parser generator developed at Bell labs. Bison is a freely=20
distributable reimplementation associated with the GNU&nbsp;project. =
Yacc and=20
Bison produce C whereas JavaCC produces Java.=20
<P>The other big difference is that Yacc and Bison work bottom-up, =
whereas=20
JavaCC works top-down. This means that Yacc and Bison make choices after =

consuming all the tokens associated with the choice, whereas JavaCC has =
to make=20
its choices prior to consuming any of the tokens associated with the =
choice.=20
However, JavaCC's lookahead capabilities allow it to peek well ahead in =
the=20
token stream without consuming any tokens; the lookahead capabilities =
ameliorate=20
most of the disadvantages of the top-down approach.=20
<P>Yacc and Bison require BNF grammars, whereas JavaCC accepts=20
EBNF&nbsp;grammars. In a BNF grammar, each nonterminal is described as =
choice of=20
zero or more&nbsp;sequences of zero or more&nbsp;terminals and =
nonterminals.=20
EBNF&nbsp;extends BNF with looping, optional parts, and allows choices =
anywhere,=20
not just at the top level. For this reason Yacc/Bison grammars tend to =
have more=20
nonterminals than JavaCC grammars and to be harder to read. For example =
the=20
JavaCC production=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>void eg() :&nbsp;{}&nbsp;{a()&nbsp;(b() [","])* }=20
</TD></TR></TBODY></TABLE></FONT>
<P>might be written as=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>eg : a eg1=20
      <P>;=20
      <P>eg1 : /* empty */=20
      <P>
      <DL compact>
        <DD><FONT face=3Dsymbol>|</FONT>eg1 b optcomma </DD></DL>
      <P>;=20
      <P>optcomma : /* empty */=20
      <P>
      <DL compact>
        <DD><FONT face=3Dsymbol>|</FONT>&nbsp;',' </DD></DL>
      <P>; </P></TD></TR></TBODY></TABLE></FONT>
<P>More importantly, it is often easier to write semantic actions for =
JavaCC=20
grammars than for Yacc grammars, because there is less need to =
communicate=20
values from one rule to another.=20
<P>Yacc has no equivalent of JavaCC's parameterized nonterminals. While =
it is=20
fairly easy to pass information up the parse-tree in Yacc (and JavaCC), =
it is=20
hard to pass information down the tree in Yacc. For example, if in the =
above=20
example, if we computed information in parsing the <FONT =
face=3Dhelvetica>a</FONT>=20
that we wanted to pass to the <FONT face=3Dhelvetica>b</FONT>, this is =
easy in=20
JavaCC, using parameters, but hard in Yacc.=20
<P>As the example above shows, Yacc has no scruples about left-recursive =

productions.=20
<P>My assessment is that if your language is totally unsuitable for =
top-down=20
parsing, you'll be happier with a bottom-up parser like Yacc or Bison. =
However,=20
if your language can be parsed top-down without too many appeals to =
lookahead,=20
then JavaCC's combination of EBNF and parameters can make life much more =

enjoyable.=20
<P></P>
<HR>

<H3>Footnotes:</H3>
<P><A name=3DtthFtNtAAB></A><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFrefAAB"><SUP>1</SUP></A>Another=20
way of looking at it is that JavaCC is of little help in this regard. =
However,=20
if you want to produce trees there are two tools, based on JavaCC, that =
are less=20
flexible and more helpful, these are JJTree and JTB. See Chapter <A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#jjtree-and-jtb">6</A>=20
.=20
<P><A name=3DtthFtNtAAC></A><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFrefAAC"><SUP>2</SUP></A>JavaCC's=20
terminology here is a bit unusual. The conventional name for what JavaCC =
calls a=20
"token kind"&nbsp;is "terminal"&nbsp;and the set of all token kinds is =
the=20
=E4lphabet"&nbsp;of the EBNF&nbsp;grammar.=20
<P><A name=3DtthFtNtAAD></A><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFrefAAD"><SUP>3</SUP></A>This=20
example is quoted from <BR clear=3Dall></P>
<TABLE border=3D0 width=3D"100%">
  <TBODY>
  <TR>
    <TD>
      <TABLE align=3Dcenter>
        <TBODY>
        <TR>
          <TD noWrap=20
            =
align=3Dmiddle><I>examples</I>/<I>JJTreeExamples</I>/<I>eg</I>4.<I>jjt</I=
></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>Your=20
maintainer inspected it carefully before copying it into another .jjt =
file. As=20
testing revealed, it is not, however, correct, which shows that even the =
experts=20
can be befuddled by complex regular expressions, sometimes. Can you spot =
the=20
error? A correct regular expression is=20
<P><FONT face=3Dhelvetica></P>
<TABLE border=3D2 width=3D"90%" bgColor=3D#ffffcc align=3Dcenter>
  <TBODY>
  <TR>
    <TD>&lt; "/*"(~["*"] <FONT face=3Dsymbol>|</FONT>("*")+ ~["/"])* =
("*")+ "/"=20
      &gt; </TD></TR></TBODY></TABLE></FONT>
<P>... I&nbsp;think.=20
<P><A name=3DtthFtNtAAE></A><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFrefAAE"><SUP>4</SUP></A>The=20
rule that an <FONT face=3Dhelvetica>EOF</FONT> token is produced at the =
end of the=20
file applies regardless of the lexical state.=20
<P><A name=3DtthFtNtAAF></A><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFrefAAF"><SUP>5</SUP></A>And=20
provided that regular expression applies in the DEFAULT lexical state.=20
<P><A name=3DtthFtNtAAG></A><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFrefAAG"><SUP>6</SUP></A>Ok=20
there are still a few reasons to use a regular expression production. =
One is if=20
you are using lexical states other than DEFAULT. Another is if you want =
to=20
ignore the case of a word. Also, some people just like to have an =
alphabetical=20
list of their keywords somewhere.=20
<P><A name=3DtthFtNtAAH></A><A=20
href=3D"http://www.idevelopment.info/data/Programming/java/JavaCC/The_Jav=
aCC_FAQ.htm#tthFrefAAH"><SUP>7</SUP></A>This=20
example is based on the syntax for HTTP&nbsp;URLs in RFC: 2616 of the =
IETF by=20
R.&nbsp;Fielding, <EM>et. al</EM>. However, I've made a number of=20
simplifications and omissions for the sake of a simpler example. =
<BR><BR></P>
<HR>
<SMALL>File translated from T<SUB><FONT size=3D-1>E</FONT></SUB>X by <A=20
href=3D"http://hutchinson.belmont.ma.us/tth/">T<SUB><FONT=20
size=3D-1>T</FONT></SUB>H</A>, version 3.11.<BR>On 2 Jul 2002, =
10:50.</SMALL>=20
</BODY></HTML>

------=_NextPart_000_0000_01CA351D.C4D99D00
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-Location: http://www.idevelopment.info/data/Programming/java/JavaCC/token-manager.png

iVBORw0KGgoAAAANSUhEUgAAAycAAAJsAQAAAADPOuEfAAAABlBMVEUAAAAAAAClZ7nPAAAAAnRS
TlMAAQGU/a4AAAACYktHRAAB3YoTpAAAAAlwSFlzAAASdAAAEnQB3mYfeAAAETVJREFUeNrt3U+P
48h1AHDKfVACBEMjewqwGNqnvWY9lxmgV7RPPu5HyAI+7NGz6MPsYNtd3RgjnUOQRk7BAOPhxwgM
O2YPGrByaAw/QAxTDRlDBDaGlImAJFisl6oiKVESSbEokjutLe5Oo5ui+BNZ9V79ISUpAP0vRAGp
SEUqUpGKVAZXfADLh4h8qVsAuo/pXxj0R9gA/jt95BvDAScC/pMg44pt8MjfQ5n4OGA7mTzC9lI5
WVNeH7ENPm2poOKxHPuVyqso3WAP5TMfx5liVSi/Stoo8OkcYAHgAJ5CAhCzdRjA/RTglj9yDeQM
wUsgP2MPJXQbg20goLgAP3gDcI6YcsGIJFd+gOC/KYEy5d+B/LitQo/j4W/p03SmPC8qzkMEU/6I
z5UrIMfsoQhnGwgo9IRMTmmpcwWvKXQdLSnTzBSD/2yn4FQhGwr9EWSKUaoQ0dhnyixT/OxVRrTu
pYqilSuohXK5ofi7FNBFlF+lirmtxKmiw4aSJOLKi/XSL5yxekXsjM3L6xj9EVWUfpKI1zEvVSbb
NTlJFR4vcLxScCSsxH9BXLmoVGjs01fyvZVCjoRjP4SPuTI1txScKgu2Efx+pdAkIKpg9Gbt70K2
rFtswXLR74ZQNjemmaWBAt0oRN+x4aKF4m+fyR1H4Ysr5G+U5st43LI/9kao6xXqrZSdhbCxTFsp
kWA/MmqlBKK91Va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+hPmvLXx+Pr59qWElQo6YX9MsV6NbdePbeshWMcR86/nfpT7DvkK8fQ59bkK983HkNjJapU7D84
9h+wBb5v/jpy35LAwUFATnzTdN6fnfhg/rq5wqZgqZJsK8atZd+mirGw3pIvHez4TDEcBzPlZYlS
TLjF97/8R7VinP8dnlFF0UbWrZIriuY41yehrvyDgOJWKypVPI0qHz/ZUB6c4LGQAtXKzw2MgSp6
Ell/ASdIFR0c5+wEpnrUjeIwxaJKtKG8o4pfqlSUPr88VlHHfFb6VDFfsjr2LK9jBq9jfmnpk6pW
jCpuebz41ivs2DQyniyW8XLi03h5e3oSBcaTpsoz3sNI3PLYj2bHeEbL5fr0b3ns48cq+chnsf+9
k5DGvoASF5SNPIbZ/8j3F+QznsfIRIePfJrH0NUJoXkMGuax/wQY0y3sksxfsziCmf836esYRAns
7baynWLXK1vtvqhS1+7/V6bYQn2YaqW8p7RS+uyPpYprul31LUt7sH9cKn32k1dKn33+XAl6Hb+s
Kz2NxXKFDggw7PkOpYhXcbteYcMyax+FDR+McqWQH6x958gNVnvMHYq/79yFUzF3sZYfMFrsOzU6
r1Bm+aQ2ffR8z3lr9u6PsjmlZRJ2u3ozX1Sv9DejWFT6mR3dVDp6L6dRr5BuFFSv9DMDv6UYnVex
MsXtvIqVKZ28Y9TapfRyLWlL6eW62LbiKXsv6m6l+0Uq+ynqIMr4QM5YMJgyHkTRDuiMBaRvhTUr
Ae5b8WgiVZQhztj5aJByOaA6digK+4GVIZRwkGPxYYioDA5EYXm//zPG3lob96+ErCPeuzJnPeTe
lekgsa8NoaQzPH0r4SDZkg2fnipDxL4cv3xXR0ms9Mcg69iHOK7UZLxIRSpSkYpUulVmFZ9b1q3S
63JQyv8D76Zr4QKIjIoAAAAASUVORK5CYII=

------=_NextPart_000_0000_01CA351D.C4D99D00
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-Location: http://www.idevelopment.info/data/Programming/java/JavaCC/parser.png

iVBORw0KGgoAAAANSUhEUgAAAssAAANiAQAA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