Category : UNIX Files
Archive   : PCCTS130.ZIP
Filename : PCCTS.TAR

 
Output of file : PCCTS.TAR contained in archive : PCCTS130.ZIP

pccts/EXTEND.nonprinting.char 644 1377 31 11354 5655551640 11500 Printing non-printing chars for syntax errors

for ANTLR 1.10 (and hopefully 1.20)

by

[email protected] (Tom Moog)

/******************************************************************************/
/*
zzexpand_text

For use with pccts
No copyright restrictions
No liability accepted

Copies a string from the source to the destination while replacing
recognized characters with a string from a table. Non-printable
characters NOT found in the table are expanded with a string
composed of their octal equivalent. If the destination string
is not long enough to contain the expanded string a "..." is
appended to the output.

Returns a pointer to the destination string.

Example using the default table:

"abc" -> "abc"
"abc\n" -> "abc"
"abc\n\fdef" -> "abc

def"
"abc\tdef" -> "abcdef"
"abc\1\2\177" -> "abc<\001><\002>"

Prototype:

char *zzexpand_text (char *source,
Zzexpand_text_entry *table,
char *dest,
size_t ldest)

If the table is coded as 0 then the default table is used
*/

/*
Initial Release: 9-Mar-94
*/

#include
#include

#include "expandtext.h"

#if __STDC__
#include
#define ZZCHAR_MASK UCHAR_MAX
#else
#define ZZCHAR_MASK 255
#endif

Zzexpand_text_entry
zzdefault_expand_text_table[]={
#ifdef __STDC__
{'\a' ,""},
#else
{'\007' ,""},
#endif
{'\b' ,""},
{'\t' ,""},
{'\n' ,"\n"},
{'\v' ,""},
{'\f' ,"\n\n"},
{'\r' ,"\n"},
{'\033' ,""},
{'\177' ,""},
{0 ,0},
};

Zzexpand_text_entry (*zzexpand_text_table)[]=0;

/******************************************************************************/


#ifdef __STDC__
char * zzexpand_text (char *source,
Zzexpand_text_entry *table,
char *dest,
size_t ldest)
#else
char * zzexpand_text (source,
table,
dest,
ldest)

char *source;
Zzexpand_text_entry *table;
char *dest;
size_t ldest;
#endif

{
static Zzexpand_text_entry *current_table;
static char *d;
static Zzexpand_text_entry *next;
static int amount_left;
static char *replace;
static int extra_newline;
static char char_as_octal[12];
static int l;
static char dot_dot_dot[]=" ...";

extra_newline=0;
d=dest;

amount_left=ldest-sizeof(dot_dot_dot)-5;
/* Leave room for " ..." + null */

if (dest==0) return dest;
if (source==0) {
*dest=0;
return dest;
};

if (ldest <= 0) return dest;

if (amount_left <=0) {
strncpy(dest,dot_dot_dot,ldest);
dest[ldest-1]=0;
return dest;
};

if (table==0) {
current_table=zzdefault_expand_text_table;
} else {
current_table=table;
};

for ( ;*source!=0;source++) {

if (amount_left <= 0) {
amount_left=(-1);
break;
};

/* first search the table then check isprint so that user can
choose how to represent a space character or anyother printable
character */

next=current_table;
for ( ;(next->text!=0) &&
(next->match!=*source);
next++) { continue; };

/* not in table: */
/* if printable copy directly to the destination */
/* otherwise encode as octal character */

if (next->text==0) {
if (isprint(*source)) {
extra_newline=0; /* printable */
*d++=*source;
amount_left--;
} else { /* not printable */

sprintf (char_as_octal,"<\\%.3o>",(*source) & ZZCHAR_MASK);

l=strlen(char_as_octal);
amount_left-=l;
if (amount_left < 0) {
break;
};
strcpy(d,char_as_octal);
d+=l;
};
} else { /* in table */
replace=next->text;
l=strlen(replace);
amount_left-=l;
if (amount_left < 0) {
break;
};
/* check for two artificial newlines in a row */

if (*replace=='\n') { /* does expansion text start with \n */
if (d==dest) { /* don't insert \n at start */
replace++;
amount_left--;
l--;
};
if (extra_newline) { /* don't insert two \n */
d--;
amount_left++;
};
};
strcpy (d,replace);
d+=l;
if (replace[l-1]=='\n') {
extra_newline=1;
} else {
extra_newline=0;
};
};
};


if (extra_newline) {
d--;
};

/* Don't get alarmed - remember that some extra space was reserved */

if (amount_left < 0) {
strcpy (d,dot_dot_dot);
d+=strlen(dot_dot_dot);
};

*d=0;
return dest;
}


pccts/NOTES.BCC 644 1377 31 12250 5655551641 6504 20 July 94
Version 1.21 of pccts

At the moment this file is available via anonymous FTP at

Node: marvin.ecn.purdue.edu
File: pub/pccts/1.21/NOTES.BCC

Mail corrections or additions to David Seidel <[email protected]>
===============================================================================
Notes on Building PCCTS 1.21 with Borland C++

David Seidel, Innovative Data Concepts Incorporated
CompuServe: 71333,1575
Internet: [email protected]
[email protected]

I have gotten ANTLR and DLG to succesfully build with BCC 4.0, but have found
from experience that ANTLR, in particular, is likely to run out of memory
with grammars over a certain size, or with larger values for the -k and -ck
options. Now that BCC 4.02 and the new Borland Power Pack for DOS is now
available, I feel that there is no excuse not to build these tools as
32-bit executables, as they ought to be.

For people without the Power Pack, the makefiles below should be fairly easily
modified to build 16-bit real-mode executables, but I don't really recommend
it. As an alternative, you might consider the highly regarded DJGPP compiler
(a DOS port of the Gnu GCC compiler, with a DOS extender included). Hopefully
some other PCCTS who has DJGPP can provode whatever advice is necessary. The
Watcom compiler is also an excellent possibility (albeit a commercial one),
and I hope to make available Watcom makefiles in the near future.

Here are the makefiles I am using. Both makefiles use a compiler configuration
file that contains compiler switches such as optimization settings. I call
this file bor32.cfg and keep a copy in both the ANTLR and DLG subdirectories.

==== File: bor32.cfg (cut here) ===============================================
-w-
-RT-
-x-
-N-
-k-
-d
-O2-e-l
-Z
-D__STDC__=1
==== End of file bor32.cfg (cut here) =========================================

==== File: antlr\bor32.mak (cut here) =========================================
#
# ANTLR 1.21 Makefile for Borland C++ 4.02 with DPMI 32-bit DOS extender by
# David Seidel
# Innovative Data Concepts Incorporated
# [email protected] (or) [email protected]
#
# Notes: 1. Compiler switches (optimization etc.) are contained in the
# file bor32.cfg.
# 2. This makefile requires Borland C++ 4.02 or greater with
# the DOS Power Pack add-on package.
# 3. Change the BCCDIR macro below to the topmost directory in
# which BCC is installed on your system.
#

BCCDIR = d:\bc4
CC = bcc32
SET = ..\support\set
PCCTS_H = ..\h
ANTLR = ..\bin\antlr
DLG = ..\bin\dlg
CFLAGS = -I$(BCCDIR)\include -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN \
+bor32.cfg
LIBS = dpmi32 cw32
OBJ_EXT = obj
OBJS = antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj fset.obj \
gen.obj globals.obj hash.obj lex.obj main.obj misc.obj pred.obj dialog.obj \
set.obj

.c.obj:
$(CC) -c $(CFLAGS) {$&.c }

antlr.exe: $(OBJS)
tlink32 @&&|
-Tpe -ax -c -s -L$(BCCDIR)\lib +
$(BCCDIR)\lib\c0x32 $**
[email protected]

$(LIBS)
;
|
copy *.exe ..\bin


# *********** Target list of PC machines ***********
#
# Don't worry about the ambiguity messages coming from antlr
# for making antlr.c etc... [should be 10 of them, I think]
#

# leave this commented out for initial build!
#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g
# $(ANTLR) antlr.g

antlr.$(OBJ_EXT): antlr.c mode.h tokens.h

scan.$(OBJ_EXT): scan.c mode.h tokens.h

# leave this commented out for initial build!
#scan.c mode.h: parser.dlg
# $(DLG) -C2 parser.dlg scan.c

set.$(OBJ_EXT): $(SET)\set.c
$(CC) -c $(CFLAGS) $(SET)\set.c

==== End of file antlr\bor32.mak (cut here) ===================================

==== File: dlg\bor32.mak (cut here) ===========================================
#
# DLG 1.21 Makefile for Borland C++ 4.02 with DPMI 32-bit DOS extender by
# David Seidel
# Innovative Data Concepts Incorporated
# [email protected] (or) [email protected]
#
# Notes: 1. Compiler switches (optimization etc.) are contained in the
# file bor32.cfg.
# 2. This makefile requires Borland C++ 4.02 or greater with
# the DOS Power Pack add-on package.
# 3. Change the BCCDIR macro below to the topmost directory in
# which BCC is installed on your system.
#


BCCDIR = d:\bc4
CC = bcc32
SET = ..\support\set
PCCTS_H = ..\h
ANTLR = ..\bin\antlr
DLG = ..\bin\dlg
CFLAGS = -I$(BCCDIR)\include -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN \
+bor32.cfg
LIBS = dpmi32 cw32
OBJ_EXT = obj
OBJS = dlg_p.obj dlg_a.obj main.obj err.obj support.obj \
output.obj relabel.obj automata.obj set.obj

.c.obj:
$(CC) -c $(CFLAGS) {$&.c }

dlg.exe : $(OBJS)
tlink32 @&&|
-Tpe -ax -c -s -L$(BCCDIR)\lib +
c0x32 $**
[email protected]

$(LIBS)
;
|
copy *.exe ..\bin

dlg_p.obj: dlg_p.c

dlg_a.obj: dlg_a.c

main.obj: main.c

err.obj: err.c

support.obj: support.c

output.obj: output.c

relabel.obj: relabel.c

automata.obj: automata.c

set.$(OBJ_EXT): $(SET)\set.c
$(CC) -c $(CFLAGS) $(SET)\set.c

==== End of file dlg\bor32.mak (cut here) =====================================






};

/* first search the table then check isprint so that user can
choose how to represent a space character or anyother printable
character */

next=current_table;
for ( ;(next->text!=0) &&
(next->match!=*source);
next++) { continue; };

/* not in table: */
/* if printable copy directly to the destination pccts/NOTES.OS2 644 1377 31 20223 5655551644 6522 14 April 94
Version 1.20 of pccts

At the moment this help file is available via anonymous FTP at

Node: marvin.ecn.purdue.edu
File: pub/pccts/1.20/NOTES.OS2

Mail corrections or additions to Steve Robenalt
===============================================================================
Notes on building PCCTS under OS/2 2.X with the C Set compilers.

The supplied makefiles can be used to build PCCTS under OS/2 with minimal
trouble. First you need to edit the makefiles such that the Unix specific
defaults are commented out, then uncomment the lines which are specific
to OS/2 and C Set/2 compilers as originally set up by Ed Harfmann. Note
also that you need to use the target list which reflects the appropriate
naming conventions. Some of the lines now need to be changed to reflect
differences in conventions between the operating systems: 1) change forward
slashes in directories to backslashes, 2) change command line parameters
from -option to /option (note that this applies to C Set, not ANTLR and DLG
options), and 3) change rm to del for clean and scrub targets.

To build ANTLR for the first time:

note: I tried various combinations of "touch"ing files to try to prevent nmake
from using ANTLR to rebuild itself, and was unsuccessful.

In the section labelled "Target list of PC machines", comment out the
scan.c and antlr.c dependencies. This prevents nmake from trying to invoke
ANTLR to build itself. After you have built ANTLR successfully for the first
time, you can uncomment these lines and it will build itself normally. (If you
had a working 1.10 installation before, you can also use the older binaries
when building the new ones.)

An example of the resulting makefile, with all the extra baggage for Unix, DOS,
and OS/2 1.X is shown here:

----- cut here -----

#
# Makefile for ANTLR 1.20
#
# SOFTWARE RIGHTS
#
# We reserve no LEGAL rights to the Purdue Compiler Construction Tool
# Set (PCCTS) -- PCCTS is in the public domain. An individual or
# company may do whatever they wish with source code distributed with
# PCCTS or the code generated by PCCTS, including the incorporation of
# PCCTS, or its output, into commerical software.
#
# We encourage users to develop software with PCCTS. However, we do ask
# that credit is given to us for developing PCCTS. By "credit",
# we mean that if you incorporate our source code into one of your
# programs (commercial product, research project, or otherwise) that you
# acknowledge this fact somewhere in the documentation, research report,
# etc... If you like PCCTS and have developed a nice tool with the
# output, please mention that you developed it using PCCTS. In
# addition, we ask that this header remain intact in our source code.
# As long as these guidelines are kept, we expect to continue enhancing
# this system and expect to make other tools available as they are
# completed.
#
# ANTLR 1.20
# Terence Parr
# Purdue University
# With AHPCRC, University of Minnesota
# 1989-1994
#
# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by
# Ed Harfmann
# Micro Data Base Systems
# Lafayette, Indiana
# - With updates by Steve Robenalt 4/94
#
SET=..\support\set
PCCTS_H=..\h

#
# C-Set/2 for OS/2
#
CC=icc
CFLAGS= /I. /I$(SET) /I$(PCCTS_H) /Sa /W3 /DUSER_ZZSYN
OUT_OBJ = /Fo
LIBS=
ANTLR=..\bin\antlr
DLG=..\bin\dlg
OBJ_EXT = obj

antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \
fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \
misc.obj set.obj pred.obj dialog.obj
link386 @<<
$** /NOI
[email protected] /STACK:32768

$(LIBS: = +^
)
$(DEF_FILE) $(LFLAGS) ;
<<
copy *.exe ..\bin

#
# *********** Target list of PC machines ***********
#
# Don't worry about the ambiguity messages coming from antlr
# for making antlr.c etc... [should be 10 of them, I think]
#
#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g
# $(ANTLR) antlr.g

antlr.$(OBJ_EXT): antlr.c mode.h tokens.h

scan.$(OBJ_EXT): scan.c mode.h tokens.h

#scan.c mode.h: parser.dlg
# $(DLG) -C2 parser.dlg scan.c

set.$(OBJ_EXT): $(SET)\set.c
$(CC) $(CFLAGS) /C $(OUT_OBJ)set.$(OBJ_EXT) $(SET)\set.c

#
# what files does PCCTS generate (both ANTLR and DLG)
#

PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h

SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \
hash.c lex.c main.c misc.c $(SET)\set.c pred.c dialog.c

#
# ****** These next targets are common to UNIX and PC world ********
#

#clean up all the intermediate files
clean:
del *.$(OBJ_EXT)

#remove everything in clean plus the PCCTS files generated
scrub:
del $(PCCTS_GEN) *.$(OBJ_EXT)

----- cut here -----

To build DLG for the first time:

Follow the same steps as were used to build ANTLR, changing the slashes and
commands, targets, and extensions for OS/2. Comment out the dependencies for
dlg_p.c and dlg_a.c to prevent nmake from trying to invoke ANTLR and DLG to
build DLG (unless you have 1.10 binaries).

An example of the resulting makefile, with all the extra baggage for Unix, DOS,
and OS/2 1.X is shown here:

----- cut here -----

#
# Makefile for DLG 1.20
# Terence Parr
# Purdue University
# 1989-1993
#
# Ported to IBM C-Set/2 and Microsoft 6.0 by
# Ed Harfmann
# Micro Data Base Systems
# Lafayette, Indiana
# - With updates by Steve Robenalt 4/94
#
SET=..\support\set
PCCTS_H=..\h

#
# C-Set/2 for OS/2
#
CC=icc
CFLAGS= /I. /I$(SET) /I$(PCCTS_H) /Sa /W3
OUT_OBJ = /Fo
LIBS=
ANTLR=..\bin\antlr
DLG=..\bin\dlg
OBJ_EXT=obj

dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \
output.obj relabel.obj automata.obj
link386 @<<
$** /NOI
[email protected] /STACK:32768

$(LIBS: = +^
)
$(DEF_FILE) $(LFLAGS) ;
<<
copy *.exe ..\bin

SRC = dlg_p.c dlg_a.c main.c err.c $(SET)\set.c support.c output.c \
relabel.c automata.c

#dlg_p.c parser.dlg err.c tokens.h : dlg_p.g
# $(ANTLR) dlg_p.g

#dlg_a.c mode.h : parser.dlg
# $(DLG) -C2 parser.dlg dlg_a.c

dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h
$(CC) $(CFLAGS) /c dlg_p.c

dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h
$(CC) $(CFLAGS) /c dlg_a.c

main.$(OBJ_EXT) : main.c dlg.h
$(CC) $(CFLAGS) /c main.c

set.$(OBJ_EXT) : $(SET)\set.c
$(CC) /c $(CFLAGS) $(SET)\set.c

lint:
lint *.c

#clean up all the intermediate files
clean:
del *.$(OBJ_EXT)

----- cut here -----

Once you have built ANTLR and DLG successfully, you will also want to build
the genmk utility, located at ~\pccts\support\genmk. The makefile in this
directory is relatively simple to modify, so I won't repeat it here.

At this point, you can test the executables by building one of the sample
programs, such as the Pascal or C example under ~pccts\lang. The prototype
makefile which is in these directories will work fine as a base, with OS/2
specific modifications as noted above. Note that the /Sa flag defines the
ANSI C mode of the compiler which is not the default. The default mode
does not define __STDC__ and will lead to lots of errors.

A sample pascal makefile is shown below:

----- cut here -----

GRM =pascal.g
LEX_FILE =pscan.dlg
GSRC=pascal.c err.c pscan.c ttree.c adebug.c
GOBJ=pascal.obj err.obj pscan.obj ttree.obj adebug.obj

PCCTS_GEN= pascal.c err.c $(LEX_FILE) pscan.c mode.h tokens.h

SRC =$(GSRC) pmain.c sym.c
OBJ =$(GOBJ) pmain.obj sym.obj
INCL = ..\..\h
SYM = ..\..\support\sym
ANTLR = ..\..\bin\antlr
DLG = ..\..\bin\dlg

CFLAGS=/I. /I$(INCL) /Sa
AFLAGS= -fl $(LEX_FILE) -gh

pascal.exe : $(OBJ)
$(CC) $(CFLAGS) /Fopascal.exe $(OBJ)

pascal.c $(LEX_FILE) : $(GRM)
$(ANTLR) $(AFLAGS) $(GRM)

mode.h pscan.c : $(LEX_FILE)
$(DLG) -C2 $(LEX_FILE) pscan.c

pmain.obj : pmain.c pascal.h

pascal.obj : pascal.c mode.h tokens.h

sym.obj : $(SYM)\sym.c
icc /c /Fo sym.obj $(CFLAGS) $(SYM)\sym.c

err.obj : err.c

clean:
del $(PCCTS_GEN) *.obj


----- cut here -----

The C example can be built in much the same way.

If you have problems compiling anything, I would appreciate hearing about
it. I was able to get everything built and working without changing any
of the supplied or generated C code, so if you find that you need to make
changes to any code, I've probably written something up incorrectly.

Please post comments to the mailing list for PCCTS at:

[email protected]

since I am most likely to see them there.

- Steve Robenalt


if (*replace=='\n') { /* does expansion text start with \n */
if (d==dest) { /* don't insert \n at start */
replace++;
amount_left--;
l--;
};
if (extra_newline) { /* don't insert two \n */
d--;
amount_left++;
};
};
strcpy (d,replace);
d+=l;
if (replace[l-1]=='\n') {
extra_newline=1;
} else {
extra_newpccts/NOTES.newbie 644 1377 31 550760 5655551643 7425 31 October 94
Version 1.23 of pccts

This help file is available via anonymous FTP at:

Node: everest.ee.umn.edu [128.101.144.112]
File: /pub/pccts/1.23/NOTES.newbie

Mirror sites for pccts:

Europe:

Node: ftp.th-darmstadt.de [130.83.55.75]
Directory: pub/programming/languages/compiler-compiler/pccts

According to the FAQ this is updated daily.

Also:

Node: ftp.uu.net
Directory: languages/tools/pccts

Pre-built binaries for pccts are available in:

Node: everest.ee.umn.edu [128.101.144.112]
Directory: /pub/pccts/binaries/PC
Directory: /pub/pccts/binaries/SGI
Directory: /pub/pccts/binaries/Ultrix4.3
etc.

Note: There is no guarantee that these binaries will be
up-to-date. They are contributed by users of these machines
rather than the pccts developers.

Contributed Files are in:

Node: everest.ee.umn.edu [128.101.144.112]
Directory: /pub/pccts/contrib

Mail corrections or additions to [email protected]

The format of NOTES.newbie has been changed to make it easier to look for
changes from one version to the next using difference programs.

Page 2
===============================================================================
Miscellaneous
-------------------------------------------------------------------------------
(Item 1)
##. NEVER choose rule names, #token names, #lexclass names, #errclass
names, etc. which coincide with the reserved words of your C or C++
compiler. Be awake to name collisions with your favorite libraries
and #include files. One can only imagine the results of definitions like:

#token FILE "file"

const: "[0-9]*"
(Item 2)
##. Tokens begin with uppercase characters. Rules begin with lowercase
characters.
(Item 3)
##. When passing the name of the start rule to the ANTLR macro don't
forget to code the trailing function arguments:

/* Not using ASTs */ ANTLR (grammar(),stdin);
/* Using ASTs */ ANTLR (grammar(&ASTroot),stdin);

/* *** Wrong *** */ ANTLR (grammar,stdin);
(Item 4)
##. When you see a syntax error message that has quotation marks on
separate lines:

line 1: syntax error at "
" missing ID

that probably means that the offending element contains a newline.
(Item 5)
##. Even if your C compiler does not support C++ style comments,
you can use them in the *non-action* portion of the ANTLR source code.
Inside an action (i.e. <<...>> ) you have to obey the comment
conventions of your compiler.
(Item 6)
##. To place the C right shift operator (">>") inside an Antlr action
("<<...>>") precede it with a backslash: "\>>" If you forget to do
this you'll probably get the error message:

warning: Missing <<; found dangling >>

No special action is required for the shift left operator.

This doesn't work with #lexaction or #header because the ">>" will be
passed on to DLG which has exactly the same problem as Antlr. The
only workaround I found for these special cases was to place the following
in an #include file "shiftr.h":

#define SHIFTR >>

where it is never seen by either Antlr or DLG. Then I placed a #include
"shiftr.h" in the #lexaction.
Page 3

(Item 7)
##. The C grammar distributed with pccts in pccts/lang/C has some
shortcomings. It was written quite a while ago and has not been updated.
It was written as an exercise, not as an end in itself.

The "proto" program does not invoke a C pre-processor. If your code
needs the C pre-processor one must invoke it separately. On my system
one can use "cc -E ..." or "cc -P ..." to direct the output of the C
pre-processor to the file specified by -o.

The C grammar does not know about #pragma which appears in the #include
files of some systems.

There are some contributed versions of C grammars on node everest
in /pub/pccts/contrib. They are "pure" grammars and have no action
routines.
(Item 8)
##. To place main() in a ".c" file rather than a grammar file (".g")
place:

#include "stdpccts.h"

before invoking the ANTRLR macro. Contributed by N.F. Ross.
(Item 9)
##. ANTLR counts a line which is continued across a newline using
the backslash convention as a single line. For example:

#header <<
#define abcd alpha\
beta\
gamma\
delta
>>

This will cause line numbers in ANTLR error messages to be off by 3 compared
to most text editors.
(Item 10)
##. The Purdue Computer Science Department maintains a WWW directory
which includes a pccts page:

URL http://tempest.ecn.purdue.edu:8001/
(Item 11)
##. In the discussions below one sometimes refers to "k=1" or "k>1". The
value of k is the number of tokens of lookahead. However it is not
necessarily the same as the value of the switch "-k" on Antlr's command
line. The number of tokens of lookahead maintained by Antlr/DLG is the
maximum of the "-k" switch and the "-ck" switch. Actually this is a
half-truth. Antlr rounds the maximum to the next higher power of 2 and
calls this "LL_K". Thus if one were to invoke Antlr with -k=1 -ck=3 the
value of LL_K (and the number of buffers allocated for lookahead tokens)
will actually be 4.
Page 4

(Item 12)
##. Suppose one wants to parse files that "include" other files. The
code in ANTLR (antlr.g) for handling #tokdefs statements demonstrates
how this may be done.

grammar: ...

| "#tokdefs" QuotedTerm

<<{

zzantlr_state st; /* defined in antlr.h */
struct zzdlg_state dst; /* defined in dlgdef.h */
FILE *f;

UserTokenDefsFile = mystrdup(LATEXT(1));
zzsave_antlr_state(&st);
zzsave_dlg_state(&dst);
f = fopen(StripQuotes(LATEXT(1)),"r");
if ( f==NULL ) {
warn(eMsg1("cannot open token defs file '%s'",
LATEXT(1)+1));}
else {
ANTLRm( enum_file(), f, PARSE_ENUM_FILE);
UserDefdTokens = 1;
}
zzrestore_antlr_state(&st);
zzrestore_dlg_state(&dst);
}>>

The code uses zzsave_antlr_state() and zzsave_dlg_state() to save the state
of the current parse. The ANTLRm macro specifies a starting rule for ANTLR
of "enum_file" and starts DLG in the PARSE_ENUM_FILE state rather than the
default state (which is the current state - whatever it might be). Because
enum_file() is called without any arguments it appears that enum_file() does
not use ASTs nor pass back any attributes. Contributed by Terence J. Parr.
(Item 13)
##. If an action becomes too large then it will overflow an ANTLR buffer
("... error: action buffer overflow: size 4000").

In cases where the code does NOT contain any references such as #[...],
#(...), $xxx, #yyy etc. (which requires substitution by Antlr) you can put
the action in an include file and then place a #include in the action
This is almost always effective with #lexaction and the main action.

Suggested by David Seidel ([email protected]).

In other cases you must re-make Antlr with a larger value for ZZLEXBUFSIZE.
The change can by made to the default value for ZZLEXBUFSIZE near line 73
of pccts/h/antlr.h or by adding a statement like:

#define ZZLEXBUFSIZE 8192

to pccts/antlr/antlr.g in the #header.

Splitting an action of a rule into two smaller actions will not work if
the second action needs to refer to zzlextext.
Page 5

(Item 14)
##. When one is using multiple input files (for example "a.g" and "b.g"
to generate "a.c" and "b.c") the only way to place file scope information
in b.c is to place it in #header of the first grammar file. ANTLR won't
allow file scope information to be copied from b.g into b.c using
"<<...>>" notation. If one did place a file scope action in the b.g, ANTLR
would try to interpret it as the fail action of the last rule appearing in
a.g. (the first grammar file). The workaround is to #include b.c in
another file which has your file scope declarations. You'll probably
need to #include "stdpccts.h" before your file scope definitions.
(Item 15)
##. Multiple parsers can coexist in the same application through use of
the #parser directive (in C output mode). The #parser statement is not used
with the ANTLR C++ output option because one can simply instantiate a new
parser object. The statement "#parser xyz" adds the prefix "xyz" to all
rule names and many pccts defined names. This is done as something of an
afterthought by creating the #include file remap.h with definitions like
the following:

#define statement xyz_statement /* a rule redefined */
#define zztokenLA xyz_zztokenLA /* pccts global redefined */
#define AST xyz_AST /* pccts typedef redefined */
#define setwd1 xyz_setwd1 /* token test sets */
#define zzerr_1 xyz_zzerr_1 /* error sets */


Page 6
===============================================================================
Section on switches and options
-------------------------------------------------------------------------------
(Item 16)
##. Invoking antlr or DLG with nothing else on the command line will
cause them to print out a switch summary.
(Item 17)
##. Don't forget about the ANTLR -gd option which provides a trace of
rules which are triggered and exited.

The trace option can be useful in sometimes unexpected ways. For example,
by suitably defining the macros zzTRACEIN and zzTRACEOUT before the
#include of "antlr.h" one can accumulate information on how often each
rule is invoked.
(Item 18)
##. When you want to inspect the code generated by ANTLR you may want to
use the ANTLR -gs switch. This causes ANTLR to test for a token being
an element of a lookahead set by using explicit tests with meaningful
token names rather by using the faster bit oriented operations which are
difficult to read.
(Item 19)
##. When using the ANTLR -gk option you probably want to use the DLG -i
option. As far as I can tell neither option works by itself.
Unfortunately they have different abbreviations so that one can't
use the same symbol for both in a makefile.
(Item 20)
##. When you are debugging code in the rule section and there is no
change to the lexical scanner, you can avoid regeneration of scanner.c
by using the ANTLR -gx option. However some items from stdpccts.h
can affect the scanner, such as -k -ck and the addition of semantic
predicates - so this optimization should be used with a little care.
(Item 21)
##. One cannot use an interactive scanner (ANTLR -gk option) with the
ANTLR infinite lookahead and backtracking options (syntactic predicates).
(Item 22)
##. If you want backtracking, but not the prefetching of characters and
tokens that one gets with lookahead, then you might want to try using
your own input routine and then using ANTLRs (input supplied by string)
or ANTLRf (input supplied by function) rather than plain ANTLR which
is used in most of the examples.

See Example 4 below for an example of an ANTLRf input function.
(Item 23)
##. The format used in #line directive is controlled by the macro

#define LineInfoFormatStr "# %d \"%s\"\n"

which is defined in generic.h. A change requires recompilation of ANTLR.

With Antlr switch -gl may cause Antlr to sometimes place #line directives
in a column other than column 1 when processing semantic predicates. The
temporary workaround is to change the format string to:

#define LineInfoFormatStr "\n# %d \"%s\"\n"

This bug is present in version 1.23.
(Item 24)
##. To make the lexical scanner case insensitive use the DLG -ci
switch. The analyzer does not change the text, it just ignores case
when matching it against the regular expressions.

The problem in version 1.10 with the -ci switch is fixed in versions >= 1.20.
Page 7

(Item 25)
##. In order to use a different name for the mode.h file it is necessary
to supply the new name using both the ANTLR -fm switch and the DLG -m switch.
ANTLR does not generate mode.h, but it does generate #include statements
which reference it.

===============================================================================
C++ Mode
-------------------------------------------------------------------------------
(Item 26)
##. Prior to version 1.23 when using backtracking (syntactic predicates)
ANTLRtoken must have been explicitly derived from ANTLRCommonBacktrackingToken
rather than ANTLRCommonToken. With version 1.23 Antlr generates a typedef for
the base class so that the correct one is automatically chosen.

Page 8
===============================================================================
Section on #token, #tokclass, #tokdef #errclass (but not #lexclass)
-------------------------------------------------------------------------------
(Item 27)
##. If you can't figure out what the DLG lexer is doing try inserting
the following code near line 434 of pccts/h/dlgauto.h:

#include "string.h"

old--> (*actions[accepts[state]])(); /* invokes action routine */

add--> {char zzcharstring[]="?"; /* put zzchar in string */
zzcharstring[0]=zzchar;

printf ("\nNLA=%s zzlextext=(%s) zzchar=(%s) %s\n",
zztokens[NLA], /* token name */
(strcmp (zzlextext,"\n")==0 ? "newline" : zzlextext),
/* render \n as "newline" */
(strcmp (zzcharstring,"\n")==0 ? "newline" : zzcharstring),
/* render \n as "newline" */
(zzadd_erase==1 ? "zzskip()" : /* called zzskip() ? */
zzadd_erase==2 ? "zzmore()" : /* called zzmore() ? */
"")); /* none of the above */
};

NLA: the the token number of the token just identified
this is a macro
zztokens: array indexed by token number giving the token name
zzlextext: the text of the token just identified
zzchar: the lookahead character
(Item 28)
##. To gobble up everything to a newline use: "~[\n]*".
(Item 29)
##. To match any single character use: "~[]".
(Item 30)
##. The char * array "zztokens" in err.c contains the text for the name of
each token (indexed by the token number). This can be extremely useful
for debugging and error messages.
(Item 31)
##. If a #token symbol is spelled incorrectly in a rule it will not be
reported by ANTLR unless the ANTLR -w2 option is set. ANTLR will assign
it a new #token number which, of course, will never be matched. Look at
token.h for misspelled terminals or inspect "zztokens[]" in err.c.
(Item 32)
##. If you happen to define the same #token name twice (perhaps
because of inadvertent duplication of a name) you will receive no
error messages from ANTLR or DLG. ANTLR will simply use the later
definition and forget the earlier one. Using the ANTLR -w2 option
does not change this behavior.
(Item 33)
##. One cannot continue a regular expression in a #token statement across
lines. If one tries to use "\" to continue the line the lexical analyzer
will think you are trying to match a newline character.
(Item 34)
##. The escaped literals in #token regular expressions are not identical
to the ANSI escape sequences. For instance "\v" will yield a match
for "v", not a vertical tab.

\t \n \r \b - the only escaped letters
Page 9

(Item 35)
##. In #token regular expressions spaces and tabs which are
not escaped are ignored - thus making it easy to add white space to
a regular expression.

#token symbol "[a-z A-Z] [a-z A-Z 0-9]*"
(Item 36)
##. You can achieve a limited form of one character lookahead in the
#token statement action by using zzchar which contains the character
following the regular expression just recognized. See Example 11.
(Item 37)
##. The regular expressions appearing in #errclass declarations must
be unique.
(Item 38)
##. You cannot supply an action (even a null action) for a #token
statement without a regular expression. You'll receive the message:

warning: action cannot be attached to a token name
(...token name...); ignored

This is a minor problem when the #token is created for use with
attributes or ASTs nodes and has no regular expression:

#token CAST_EXPR
#token SUBSCRIPT_EXPR
#token ARGUMENT_LIST

<<
... Code related to parsing
>>

ANTLR assumes the code block is the action associated with the #token
immediately preceding it. It is not obvious what the problem is because
the line number referenced is the END of the code block (">>") rather
than the beginning. My solution is to follow such #token statements
with a #token which does have a regular expression (or a rule).
(Item 39)
##. Since the lexical analyzer wants to find the longest possible string
that matches a regular expression, it is probably best not to use expressions
like "~[]*" which will gobble up everything to the end-of-file.
(Item 40)
##. Calls to zzskip() and zzmore() should appear only in #token actions
(or in code called from #token actions). They don't belong in the actions
of rules. Routine zzskip() causes DLG to throw away the text just
collected and to start looking for another regular expression. Routine
zzmore() tells DLG that the token is not complete and to look for more
text. They are purely lexical actions.
(Item 41)
##. The lexical routines zzmode(), zzskip(), and zzmore() do NOT work like
coroutines. Basically, all they do is set status bits or fields in a
structure owned by the lexical analyzer and then return immediately. Thus it
is OK to call these routines anywhere from within a lexical action. You
can even call them from within a subroutine called from a lexical action
routine.

See Example 5 below for routines which maintain a stack of modes.
Page 10

(Item 42)
##. When a string is matched by two #token regular expressions of equal
length, the lexical analyzer will choose the one which appears first in
the source code. Thus more specific regular expressions should appear
before more general ones:

#token HELP "help" /* should appear before "symbol" */
#token symbol "[a-zA-Z]*" /* should appear after keywords */

Some of these may be caught by using the DLG switch -Wambiguity.
Consider the following grammar:

#header <<
#include "charbuf.h"
>>
<<
int main() {
ANTLR (statement(),stdin);
return 0;
}
>>

#token WhiteSpace "[\ \t]" <>
#token ID "[a-z A-Z]*"
#token HELP "HELP"

statement
: HELP "@" <> /* a1 */
| "inline" "@" <> /* a2 */
| ID "@" <> /* a3 */
;

Is an in-line regular expression treated any differently than a regular
expression appearing in a #token statement ? No! ANTLR/DLG does *NOT*
check for a match to "inline" (line a2) before attempting a match to the
regular expressions defined by #token statements. The first two
alternatives ("a1" and "a2") will NEVER be matched. All of this will be
clear from examination of the file "parser.dlg".

Another way of looking at this is to recognize that the conversion of
character strings to tokens takes place in DLG, not Antlr, and that all
that is happening with an in-line regular expression is that Antlr is
allowing you to define a token's regular expression in a more convenient
fashion - not changing the fundamental behavior.

If one builds the example above using the DLG switch -Wambiguity one gets
the message:

dlg warning: ambigious regular expression 3 4
dlg warning: ambigious regular expression 3 5

Page 11
The numbers which appear in the DLG message refer to the assigned token
numbers. Examine the array zztokens[] in err.c to find the regular
expression which corresponds to the token number reported by DLG.

ANTLRChar *zztokens[6]={
/* 00 */ "Invalid",
/* 01 */ "@",
/* 02 */ "WhiteSpace",
/* 03 */ "ID",
/* 04 */ "HELP",
/* 05 */ "inline"
};

One can also look at the file "scan.c" in which action 4 would
appear in the function "static void act4() {...}".

The best advice is to follow the example of the Master, TJP, and place
things like #token ID at the end of the grammar file.
(Item 43)
##. The DLG lexical analyzer is not able to backtrack. Consider the
following example:

#token "[\ \t]*] <>
#token ELSE "else"
#token ELSEIF "else [\ \t]* if"
#token STOP "stop"

with input:

else stop

When DLG gets to the end of "else" it realizes that the spaces will allow
it to match a longer string than "else" by itself. So DLG starts to accept
the spaces. When DLG gets to the initial "s" in "stop" it realizes it has
gone too far - but it can't backtrack. It passes back an error status to
ANTLR which (normally) prints out something like:

invalid token near line 1 (text was 'else ') ...

There is an "extra" space between the "else" and the closing single quote
mark.

This problem is not detected by the DLG option -Wambiguity.
Page 12

(Item 44)
##. The scheme outlined above works well because the regular expression
for ELSE is a prefix of ELSEIF. This is not always the case. If only
one character of lookahead is necessary to distinguish the two tokens
one can use zzchar. This is an excerpt from Example 11:

#token Range ".."
#token Int "[0-9]*"
#token Float "[0-9]*.[0-9]*"
< zzchar == '.') {
NLA=Int;
zzmode(LC_Range);
};
>>

In this excerpt, a Range can be distinguished from a Float by seeing
if the first "." is followed by a second ".".

If more than one character of lookahead is necessary and it appears
difficult to solve using #lexclass, semantic predicates, or other
mechanisms you might want to consider using the University of California
Berkeley flex, which is a super-set of lex. An example of how to use
flex with Antlr is available on everest in /pub/pccts/contrib.
(Item 45)
##. In converting a long list of tokens appearing in a rule to use #tokclass
I simply replaced the rule, in situ, with the #tokclass directive and did a
global replace of the rule name with a new name in which the first letter
was capitalized. It took me a while to realize that the ANTLR message:

xxx.g, line 123: warning: redefinition of tokclass or conflict
w/token 'Literal'; ignored

meant that I had used the #tokclass "Literal" before it was defined.
Only rules, not tokens, can be used in forward references. The problem
was fixed by moving the #tokclass statement up to the #token section of
the file.
(Item 46)
##. The char * variable zzbegexpr and zzendexpr point to the start and end
of the string last matched by a regular expression in a #token statement.

However, the char array pointed to by zzlextext may be larger than the
string pointed to by zzbegexpr and zzendexpr because it includes substrings
accumulated through the use of zzmore().
(Item 47)
##. The preprocessor symbol ZZCOL in the lexical scanner controls the
update of column information. This doesn't cause the zzsyn() routine to
report the position of tokens causing the error. You'll still have to
write that yourself. The problem, I think, is that, due to look-ahead,
the value of zzendcol will not be synchronized with the token causing the
error, so that the problem becomes non-trivial.
(Item 48)
##. If you want to use ZZCOL to keep track of the column position
remember to adjust zzendcol in the lexical action when a character is not
one print position wide (e.g. tabs or non-printing characters).
(Item 49)
##. The column information (zzbegcol and zzendcol) is not immediately
updated if a token's action routine calls zzmore(). In cases where
zzmore() is central the lexical analysis (e.g. Example 8 which combines
whitespace with the token that follows) it may be better to write ones own
column position routine rather than using the pccts supplied code.
Page 13

(Item 50)
##. Variables zzbegcol and zzendcol are the column positions of the
token just analyzed by DLG. When LL_K=1 this is generally the same as the
token just analyzed by Antlr. When LL_K > 1 the information in zzbegcol and
zzendcol will be several tokens ahead of where Antlr is and thus will
give misleading information.
(Item 51)
##. In version 1.00 it was common to change the token code based on
semantic routines in the #token actions. With the addition of semantic
predicates in 1.06 this technique is now frowned upon.

Old style:

#token TypedefName
#token ID "[a-z A-Z]*"
<<{if (isTypedefName(LATEXT(1))) NLA=TypedefName;};>>

New Style:

#token ID "[a-z A-Z]*"

typedefName : <> ID;

The "old" technique is appropriate for making LEXICAL decisions based on
the input: for instance treating whitespace differently in different
contexts. The reason why the "new" style is especially important is that
with infinite lookahead, of which guess mode is one case, it is not
possible to make semantic decisions in the lexer because the parsing
doesn't even begin until the lexing is complete.

See the section on semantic predicates for a longer explanation.
Page 14

(Item 52)
##. DLG has no operator like grep's "^" which anchors a pattern to the
beginning of a line. One can use tests based on zzbegcol only if column
information is selected (#define ZZCOL) AND one is NOT using infinite
lookahead mode (syntactic predicates). A technique which does not depend
on zzbegcol is to look for the newline character and then enter a special
#lexclass.

Consider the problem of recognizing lines which have a "!" as the first
character of a line. A possible solution suggested by Doug Cuthbertson
is:

#token "\n" <>

*** or ***

#token "\n" < if (zzchar=='!') zzmode(BEGIN_LINE);>>

#lexclass BEGIN_LINE
#token BANG "!" <>
#token "~[]" <>

When a newline is encountered the #lexclass BEGIN_LINE is entered. If
the next character is a "!" it returns the token "BANG" and returns
to #lexclass START. If the next character is anything else it calls
zzmore to accumulate additional characters for the token and, as before,
returns to #lexclass START. (The order of calls to zzmode() and zzmore()
is not significant).

There are two limitations to this.

a. If there are other single character tokens which can appear in the first
column then using zzmore() won't be sufficient to work around the problem
because the entire (one character) token has already been consumed. Thus
all single character tokens which can appear in column 1 must appear in
both #lexclass START and #lexclass BEGIN_LINE.

b. The first character of the first line is not preceded by a newline.
thus DLG will be starting in the wrong state. Thus you might want to rename
"BEGIN_LINE" to "START" and "START" to "NORMAL".

Another solution is to use ANTLRf (input from a function) to insert
your own function to do the kind of lexical processing which is difficult
to express in DLG.

In 1.20 the macro ANTLRm was added. it is similar to ANTLR, but has an
extra argument which allows one to specify the lexical class which is
passed to zzmode() to specify the initial #lexclass state of DLG.
(Item 53)
##. In version 1.10 there were problems using 8 bit characters with DLG.
Versions >= 1.20 of ANTLR/DLG work with 8 bit character sets when they are
compiled in a mode in which char variables are by default unsigned (the
g++ option "-funsigned-char"). This should be combined with a call to
setlocale (LC_ALL,"") to replace the default locale of "C" with the user's
native locale. This is system dependent - it works with Unix systems but
not DOS. Contributed by Ulfar Erlingsson ([email protected]).

See Example 4 below.
(Item 54)
##. Example 8 demonstrates how to pass whitespace through DLG for
such applications as pretty-printers.
Page 15

(Item 55)
##. In version 1.30 it will be possible to test whether a token is
a member of a #tokclass named "A" with a statement like the following:

if (set_el(LA(1),A_set)) {...}

set_el(unsigned,set) is defined in pccts/support/set/set.c

Until that time a workaround is to define all members of a #tokclass
together so as to take advantage of the knowledge that Antlr assigns
#token numbers sequentially. With that information one can write:

if (LA(1) >= first_token_in_tokclass_A &&
LA(1) <= last_token_in_tokclass_A) {...}

([email protected]).

Page 16
===============================================================================
Section on #lexclass
-------------------------------------------------------------------------------
(Item 56)
##. Example 10 gives a simple illustration of #lexclass.
(Item 57)
##. Special care should be taken when using "in-line" regular expressions
in rules if there are multiple lexical classes #lexclass). ANTLR will
place such regular expressions in the last lexical class defined. If
the last lexical class was not START you may be surprised.

#lexclass START
....
#lexclass COMMENT
....

inline_example: symbol "=" expression

This will place "=" in the #lexclass COMMENT (where
it will never be matched) rather than the START #lexclass
where the user meant it to be.

Since it is okay to specify parts of the #lexclass in several pieces
it might be a good idea when using #lexclass to place "#lexclass START"
just before the first rule - then any in-line definitions of tokens
will be placed in the START #lexclass automatically.

#lexclass START
...
#lexclass A
...
#lexclass B
...
#lexclass START
(Item 58)
##. A good example of the use of #lexclass are the definitions for C
and C++ style comments, character literals, and string literals which
can be found in pccts/lang/C/decl.g - or see Example 1 below.
(Item 59)
##. The initial #lexclass of DLG is set by a data statement to START
(which is 0). Unlike ANTLRm, the traditional ANTLR macros (ANTLRf, ANTLRs,
and ANTLR) do NOT reset the #lexclass. If you call ANTLR multiple times
during a program (for instance to parse each statement of a line-oriented
language independently) DLG will resume in the #lexclass that it was in
when ANTLR returned. If you want to restart DLG in the START state you
should precede the call to ANTLR with

zzmode(START);
or use:
ANTLRm (myStartRule(),myStartMode);
Page 17

(Item 60)
##. Consider the problem of a grammar in which a statement is composed
of clauses, each of which has its own #lexclass and in which a given
word is "reserved" in some clauses and not others:

#1;1-JAN-94 01:23:34;enable;a b c d;this is a comment;
#2;1-JAN-94 08:01:56;operator;smith;move to another station;
#3;1-JAN-94 09:10:11;move;old pos=5.0 new pos=6.0;operator request;
#4;1-JAN-94 10:11:12;set-alarm;beeper;2-JAN-94 00:00:01;

One would like to reuse a #lexclass if possible. There is no problem with
maintaining a stack of modes (#lexclass numbers) and pushing a new mode
onto the stack each time a new #lexclass subroutine is called. How to do
this is demonstrated in Example 5. The problem appears when it is
necessary to leave a #lexclass and return more than one level. To be more
specific, a #token action can only be executed when one or more characters
is consumed - so to return through three levels of #lexclass calls would
appear to require the consumption of at least three characters. In the
case of balanced constructs like "...", and '...', or (...) this is not a
problem since the terminating character can be used to trigger the #token
action. However, if the scan is terminated by a "separator", such as the
semi-colon above (";"), one cannot use the same technique. Once the
semi-colon is consumed it is unavailable for the other #lexclass routines
on the stack to see.

My solution is to allow the user to specify (during the call to pushMode)
a "lookahead" routine to be called when the corresponding element of the
mode stack is popped. At that point the "lookahead" routine can examine
zzchar to determine whether it also wants to pop the stack, and so on up
the mode stack. The consumption of a single character can result in
popping multiple modes from the mode stack based on a single character of
lookahead. See the second part of Example 5 below.

Continuing with the example of the log file (above): each statement type
has its fields in a specific order. When the statement type is recognized
a pointer is set to a list of the #lexclasses which is in the same order as
the remaining fields of that kind of statement. An action attached to
every #token which recognizes a semi-colon (";") advances a pointer in
the list of #lexclasses and then changes the #lexclass by calling zzmode()
to set the #lexclass for the next field of the statement.

Page 18
===============================================================================
Section on rules
-------------------------------------------------------------------------------
(Item 61)
##. If you can't figure out what Antlr is doing try adding the -gd
switch (debug via rule trace) and the -gs switch (perform lookahead
tests using symbolic names for tokens rather than bit-oriented set
tests).
(Item 62)
##. Antlr can't handle left-handed recursion. A rule such as:

expr : expr Op expr
| Number
| String
;

will have to be rewritten to something like this:

expr : Number (Op expr)*
| String (Op expr)*
;
(Item 63)
##. Another sort of transformation required by Antlr is left-factoring:

rule : STOP WHEN expr
| STOP ON expr
| STOP IN expr
:

These are easily distinguishable when k=2, but with a small amount of
work they can be into a k=1 grammar:

rule : STOP ( WHEN expr
| ON expr
| IN expr
)
;

or
rule : STOP rule_suffix
;
rule_suffix : WHEN expr
| ON expr
| IN expr
;

An extreme case of a grammar requiring a rewrite is in Example 12.
(Item 64)
##. If a rule is not used (is an orphan) it can lead to unanticipated
reports of ambiguity. Use the ANTLR cross-reference option (-cr) to
locate rules which are not referenced. Not verified in version 1.20.
(Item 65)
##. ANTLR attempts to deduce "start" rules by looking for rules which
are not referenced by any other rules. When it finds such a rule it
assumes that an EOF token ("@") should be there and adds one if the
user did not code one. This is the only case, according to TJP, when
ANTLR adds something to the user's grammar.
Page 19

(Item 66)
##. To express the idea "any single token is acceptable at this point"
use the "." token wild-card. This can be very useful for providing a
context dependent error message, rather than the all purpose message
"syntax error".

if-stmt : IF "\(" expr "\)" stmt
| IF . < "enclosed in parenthesis");
PARSE_FAIL;
>>

It is probably best not to use expressions such as:

ignore: (.)* /* Not a good idea */

which will gobble up everything to the end-of-file.
(Item 67)
##. New to version 1.20 is the "~" operator for tokens. It allows
one to specify tokens which must NOT match in order to match a rule.

The "~" operator cannot be applied to rules. To express the idea
"if this rule doesn't match try to match this other rule" use
syntactic predicates.
(Item 68)
##. Some constructs which are bound to cause warnings about
ambiguities:

rule : a { ( b | c )* };

rule : a { b };
b : ( c )*;

rule : a c*;
a : b { c };

rule : a { b | c | };
Page 20

(Item 69)
##. Don't confuse init-actions with actions which precede a rule
(leading-actions). If the first element following the start of a rule
or sub-rule is an action it is always interpreted as an init-action.

An init-action occurs in a scope which include the entire rule or sub-rule.
An action which is NOT an init-action is enclosed in "{" and "}" during
generation of code for the rule and has essentially zero scope - the
action itself.

The difference between an init-action and an action which precedes a rule
can be especially confusing when an action appears at the start of an
alternative:

These APPEAR to be almost identical, but they aren't:

b : <> b1 > [i] /* b1 <<...>> is an init-action */
| <> b2 > [j] /* b2 <<...>> is part of the rule */
; /* and will cause a compilation error */

On line "b1" the <<...>> appears immediately after the beginning of the
rule making it an init-action. On line "b2" the <<...>> does NOT appear at
the start of a rule or sub-rule, thus it is interpreted as an action which
happens to precede the rule.

This can be especially dangerous if you are in the habit of rearranging
the order of alternatives in a rule. For instance:

Changing this:

b : <> <> b1 > [i] /* c1 */
| <> b1 > [i] /* c2 */
;

to:

b : /* empty production */ /* d1 */
| <> <> b1 > [i] /* d2 */
| <> b1 > [i]
;

or to this:

b
: <> b1 > [i] /* e1 */
| <> <> b1 > [i] /* e2 */

changes an init-action into a non-init action, and vice-versa.
Page 21

(Item 70)
##. A particularly nasty form of the init-action problem is when
an empty sub-rule has an associated action:

rule!: ID (
/* empty */
<<#0=#[ID,$1.1];>>
| array_bounds
<<#0=#[T_array_declaration,$1.1],#1);>>
)
;

Since there is no reserved word in pccts for epsilon, the action
for the empty arm of the sub-rule becomes the init-action. For
this reason it's wise to follow one of the following conventions
(1) represent epsilon with an empty rule "()" or (2) put empty
as the last rule in a list of alternatives:

rule!: ID (
() <<#0=#[ID,$1.1];>>
| array_bounds
<<#0=#[T_array_declaration,$1.1],#1);>>
)
;

The cost of using "()" to represent epsilon is the execution of the macro
zzBLOCK() at the start of the sub-rule and zzEXIT() at the end of the
sub-rule. Macro zzBLOCK() creates a temporary stack pointer for the
attribute stack and checks for overflow. Macro zzEXIT() pops any
attributes that might have been placed on attribute stack. Since no
attribute stack operations take place for epsilon this is wasted CPU
cycles, however this is probably not a significant cost for many users.
(Item 71)
##. Another form of problem caused by init-action occurs when one
comments out a rule in the grammar in order to test an idea:

rule /* a1 */
: < /* a2 */
//// rule_a /* a3 */
| rule_b /* a4 */
| rule_c /* a5 */

In this case one only wanted to comment out the "rule_a" reference
in line "a3". The reference is indeed gone, but the change has
introduced an epsilon production - which probably creates a large
number of ambiguities. Without the init-action the ":" would have
probably have been commented out also, and ANTLR would report a
syntax error - thus preventing one from shooting oneself in the foot.
(Item 72)
##. In the case of sub-rules such as (...)+, (...)*, and {...} the
init-action is executed just once before the sub-rule is entered.
Consider the following example from section 3.6.1 (page 29) of the 1.00
manual:

a : <> // initialize list
Type
( <> // initialize index
Var <>
)*
<>
;
Page 22

(Item 73)
##. Associativity and precedence of operations is determined by
nesting of rules. In the example below "=" associates to the right
and has the lowest precedence. Operators "+" and "*" associate to
the left with "*" having the highest precedence.

expr0 : expr1 {"=" expr0};
expr1 : expr2 ("\+" expr2)*;
expr2 : expr3 ("\*" expr3)*;
expr3 : ID;

See Example 2.
(Item 74)
##. Fail actions for a rule can be placed after the final ";" of
a rule. These will be:

"executed after a syntax error is detected but before
a message is printed and the attributes have been destroyed.
However, attributes are not valid here because one does not
know at what point the error occurred and which attributes
even exist. Fail actions are often useful for cleaning up
data structures or freeing memory."

(Page 29 of 1.00 manual)

Example of a fail action:

a : <>
( Var <> )+
<>
; <>
************** <--- Fail Action
(Item 75)
##. When you have rules with large amounts of lookahead (that may
cross several lines) you can use the ANTLR -gk option to make an
ANTLR-generated parser delay lookahead fetches until absolutely
necessary. To get better line number information (e.g. for error
messages or #line directives) place an action which will save
"zzline" in a variable at the start of the production where you
want better line number information:

a : <>
<> A B C
<< /* use saveCurrentLine not zzline here */ >>
| <> A B D
<< /* use saveCurrentLine not zzline here */ >>
;

After the production has been matched you can use saveCurrentLine
rather than the bogus "zzline".

Contributed by Terence "The ANTLR Guy" Parr ([email protected])

In version 1.20 a new macro, ZZINF_LINE(), was added to extract line
information in a manner similar to LATEXT when using infinite lookahead
mode. See the page 6 of the 1.20 release notes for more information.
There is nothing like ZZINF_COL() for column information, but it should
be easy to create using ZZINF_LINE() as a model. Maybe.
(Item 76)
##. An easy way to get a list of the names of all the rules is
to grep tokens.h for the string "void" or edit the output from ANTLR
run with the -cr option (cross-reference).
Page 23

(Item 77)
##. It took me a while to understand in an intuitive way the difference
between full LL(k) lookahead given by the ANTLR -k switch and the
linear approximation given by the ANTLR -ck switch. This was in spite
of the example given in section 5 (pages 18 to 21) of the 1.10 release notes.

Most of the time I run ANTLR with -k 1 and -ck 2. Because I didn't
understand the linear approximation I didn't understand the warnings about
ambiguity. I couldn't understand why ANLTR would complain about something
which I thought was obviously parse-able with the lookahead available.
Was it a bug or was it me ? I would try to make the messages go away
totally, which was sometimes very hard. If I had understood the linear
approximation I might have been able to fix them easily or at least have
realized that there was no problem with the grammar, just with the
limitations of the linear approximation.

I will restrict the discussion to the case of "-k 1" and "-ck 2".

Consider the following example:

rule1 : rule2a | rule2b | rule2c ;
rule2a : A X | B Y | C Z ;
rule2b : B X | B Z ;
rule2c : C X ;

It should be clear that with the sentence being only two tokens this
should be parseable with LL(2).

Instead, because k=1 and ck=2 ANTLR will produce the following messages:

/pccts120/bin/antlr -k 1 -gs -ck 2 -gh example.g
Antlr parser generator Version 1.20 1989-1994
example.g, line 23: warning: alts 1 and 2 of the rule itself
ambiguous upon { B }, { X Z }
example.g, line 23: warning: alts 1 and 3 of the rule itself
ambiguous upon { C }, { X }

The code generated resembles the following:

if (LA(1)==A || LA(1)==B || LA(1)==C) &&
(LA(2)==X || LA(2)==Y || LA(2)==Z) then rule2a()

else if (LA(1)==B) &&
(LA(2)==X || LA(2)==Y) then rule2b()

else if (LA(1)==C) &&
(LA(2)==Z) then rule3a()
...

This might be called "product-of-sums". There is an "or" part for
LA(1), an "or" part for LA(2), and they are combined using "and".
To match, the first lookahead token must be in the first set and the second
lookahead token must be in the second set. It doesn't matter that what
one really wants is:

Page 24
if (LA(1)==A && LA(2)==X) ||
(LA(1)==B && LA(2)==Y) ||
(LA(1)==C && LA(2)==Z) then rule2a()

else if (LA(1)==B && LA(2)==X) ||
(LA(1)==B && LA(2)==Z) then rule2b()

else if (LA(1)==C && LA(2)==X) then rule2c()

This happens to be "product-of-sums" but the real problem is that each
product involves one element from LA(1) and one from LA(2) and as the
number of possible tokens increases the number of terms grows as N**2.
With the linear approximation the number of terms grows (surprise)
linearly in the number of tokens.

ANTLR won't do this with k=1, it will only do "product-of-sums". However,
all is not lost - you simply add a few well chosen semantic predicates
which you have computed using your LL(k>1), all purpose, carbon based,
analog computer.

The linear approximation selects for each branch of the "if" a set which
MAY include more than what is wanted. It never selects a subset of the
correct lookahead sets! We simply insert a hand-coded version of the
LL(2) computation. It's ugly, especially in this case, but it fixes the
problem. In large grammars it may not be possible to run ANTLR with k=2,
so this fixes a few rules which cause problems. The generated parser may
run faster because it will have to evaluate fewer terms at execution time.

<<
int bypass_rule2a() {
if ( LA(1)==B && LA(2)==Y ) return 0;
if ( LA(1)==B ) return 1;
if ( LA(1)==C && LA(2)==X ) return 1;
return 0;
}
>>

rule1 :
<>? rule2a | rule2b | rule2c ;
rule2a : A X | B Y | C Z ;
rule2b : B X | B Z ;
rule2c : C X ;

The real cases I've coded have shorter code sequences in the semantic
predicate. I coded this as a function to make it easier to read and
because there is a bug in 1.1x and 1.2x which prevents semantic predicates
from crossing lines. Another reason to use a function (or macro) is to
make it easier to read the generated code to determine when your semantic
predicate is being hoisted too high (it's easy to find references to a
function name with the editor - but difficult to locate a particular
sequence of "LA(1)" and "LA(2)" tests. Predicate hoisting is a separate
issue which is described elsewhere in this note.

Page 25
In some cases of reported ambiguity it is not necessary to add semantic
predicates because no VALID token sequence could get to the wrong rule.
If the token sequence were invalid it would be detected by the grammar
eventually, although perhaps not where one might wish. In other cases
the only necessary action is a reordering of the ambiguous rules so
that a more specific rule is tested first. The error messages still
appear, but one can ignore them or place a trivial semantic predicate
(i.e. <<1>>? ) in front of the later rules. This makes ANTLR happy
because it thinks you've added a semantic predicate which fixes things.

Some constructs just invite problems. For instance in C++ with a suitable
definition of the class "C" one can write:

C a,b,c /* a1 */
a.func1(b); /* a2 */
a.func2()=c; /* a3 */
a = b; /* a4 */
a.operator =(b); /* a5 */

Statement a5 happens to place an "=" (or any of the usual C++ operators)
in a token position where it can cause a lot of ambiguity in the lookahead.
set. I eventually solved this particular problem by creating a special
#lexclass for things which follow "operator". I use an entirely different
token number for such operators - thereby avoiding the whole problem.

//
// C++ operator sequences
//
// operator
// operator
//
// There must be at least one non-alphanumeric character between
// "operator" and operator name - otherwise they would be run
// together - ("operatorint" instead of "operator int")
//

#lexclass LEX_OPERATOR
#token FILLER_C1 "[\ \t]*"
< if( isalnum(zzchar) ) zzmode(START);
>>
#token OPERATOR_STRING "[\+\-\*\/\%\^\&\|\~\!\=\<\>]*"
<>
#token FILLER_C2 "\(\) | \[\] "
<>


Page 26
===============================================================================
Section on Attributes
-------------------------------------------------------------------------------
(Item 78)
##. With version 1.30 one will no longer have to refer to attributes or
ASTs of a rule using numbers.

prior to version 1.30:
rule : X Y Z <>

with version 1.30:
rule : x:X y:Y z:Z <>

Many of the examples in this section need to be revised to reflect the
use of symbolic tags.
(Item 79)
##. Attributes are built automatically only for terminals. For
rules (non-terminals) one must assign an attribute to $0, use the
$[token,...] convention for creating attributes, or use zzcr_attr().
(Item 80)
##. The way to access the text (or whatever) part of an attribute
depends on the way the attribute is stored.

If one uses the pccts supplied routine "pccts/h/charbuf.h" then

id : "[a-z]+" <>

If one uses the pccts supplied routine "pccts/h/charptr.c" and
"pccts/h/charptr.h" then:

id : "[a-z]+" <>

If one uses the pccts supplied routine "pccts/h/int.h" (which
stores numbers only) then:

number : "[0-9]+" <>

Note the use of %d rather than %s in the printf() format.
(Item 81)
##. The expression $$ refers to the attribute of the named rule.
The expression $0 refers to the attribute of the the enclosing rule,
(which might be a sub-rule).

rule : a b (c d (e f g) h) i

For (e f g) $0 becomes $3 of (c d ... h). For (c d ... h) $0 becomes
$3 of (a b ... i). However $$ always is equivalent to $rule.
(Item 82)
##. If you define a zzcr_attr() or zzmk_attr() which allocates resources
such as strings from the heap don't forget to define a zzd_attr() routine
to release the resources when the attribute is deleted.
(Item 83)
##. Attributes go out of scope when the rule or sub-rule that defines
them is exited. Don't try to pass them to an outer rule or a sibling
rule. The only exception is $0 which may be passed back to the containing
rule as a return argument. However, if the attribute contains a pointer
which is copied (e.g. pccts/h/charptr.c) then extra caution is required
because of the actions of zzd_attr(). For C++ users this should be
implemented in the class copy constructor. The version of pccts/h/charptr.*
distributed with pccts does not use C++ features. See the next item for
more information.
Page 27

(Item 84)
##. The pccts/h/charptr.c routines use a pointer to a string. The string
itself will go out of scope when the rule or sub-rule is exited. Why ?
The string is copied to the heap when ANTLR calls the routine zzcr_attr()
supplied by charptr.c - however ANTLR also calls the charptr.c supplied
routine zzd_attr() (which frees the allocated string) as soon as the rule or
sub-rule exits. The result is that in order to pass charptr.c strings to
outer rules (for instance to $0) it is necessary to make an independent
copy of the string using strdup or else zero the pointer to prevent its
deallocation.
(Item 85)
##. To initialize $0 of a sub-rule use a construct like the following:

decl : typeID
Var <<$2.type = $1;>>
( "," Var <<$2.type = $0;>>)*[$1]
**** <--------------

See section 4.1.6.1 (page 29) of the 1.00 manual
(Item 86)
##. One can use the zzdef0() macro to define a standard method for
initializing $0 of a rule or sub-rule. If the macro is defined it is
invoked as zzdef0(&($0)).

See section 4.1.6.1 (page 29) of the 1.00 manual

I believe that for C++ users this would be handled by the class constructor.
(Item 87)
##. If you construct temporary attributes in the middle of the
recognition of a rule, remember to deallocate the structure should the
rule fail. The code for failure goes after the ";" and before the next
rule. For this reason it is sometimes desirable to defer some processing
until the rule is recognized rather than the most convenient place.

#include "pccts/h/charptr.h"

;statement!
: <>
{ID COLON <> }
statement_without_label
<<#0=#(#[T_statement,label],#2);
if (label!=0) free(label);
// AST #1 is undefined
// AST #2 is returned by
// statement_without_label
>>
;<>

In the above example attributes are handled by charptr.*. Readers of this
note have been warned earlier about its dangers. The routine I have
written to construct ASTs from attributes (invoked by #[int,char *]) knows
about this behavior and automatically makes a copy of the character string
when it constructs the AST. This makes the copy created by the explicit
call to MYstrdup redundant once the AST has been constructed. If the call
to "statement_without_label" fails then the temporary copy must be
deallocated.

Page 28
===============================================================================
Section on ASTs
-------------------------------------------------------------------------------
(Item 88)
##. With version 1.30 one will no longer have to refer to attributes or
ASTs of a rule using numbers:

prior to version 1.30:
rule ! : x y z <<#0=#(#1 #2 #3);>>

with version 1.30:
rule ! : xx:x yy:y zz:z <<#0=#(#xx,#yy,#zz);>>

Many of the examples in this section need to be revised to reflect the
use of symbolic tags.
(Item 89)
##. If you define a zzcr_ast() or zzmk_ast() which allocates resources
such as strings from the heap don't forget to define a zzd_ast() routine
to release the resources when the AST is deleted. For C++ users this
should be implemented as part of the class destructor.
(Item 90)
##. Don't confuse #[...] with #(...).

The first creates a single AST node (usually from a token identifier and
an attribute) using the routine zzmk_ast(). The zzmk_ast() routine must be
supplied by the user (or selected from one of the pccts supplied ones such
as pccts/h/charbuf.h, pccts/h/charptr.*, and pccts/h/int.h).

The second creates an AST list (usually more than a single node) from other
ASTs by filling in the "down" field of the first node in the list to create
a root node, and the "sibling" fields of each of remaining ASTs in the
list. A null pointer is put in the sibling field of the last AST in the
list. This is performed by the pccts supplied routine zztmake().

#token ID "[a-z]*"
#token COLON ":"
#token STMT_WITH_LABEL

id! : ID <<#0=#[STMT_WITH_LABEL,$1];>> /* a1 */

Creates an AST. The AST (a single node)
contains STMT_WITH_LABEL in the token
field - given a traditional version of
zzmk_ast().

rule! : id COLON expr /* a2 */
<<#0=#(#1,#3);>>

Creates an AST list with the ID at its
root and "expr" as its first (and only) child.

The following example (a3) is equivalent to a1, but more confusing because
the two steps above have been combined into a single action statement:

rule! : ID COLON expr
<<#0=#(#[STMT_WITH_LABEL,$1],#3);>> /* a3 */
Page 29

(Item 91)
##. If you construct temporary ASTs in the middle of the recognition of a
rule, remember to deallocate the structure should the rule fail. The code
for failure goes after the ";" and before the next rule. For this reason
it is sometimes desirable to defer some processing until the rule is
recognized rather than the most appropriate place. For C++ users this
might be implemented as part of the class destructor.

If the temporary is an AST returned by a called rule then you'll probably
have to call zzfree_ast() to release the entire AST tree. Consider
the following example:

obj_name! /* a1 */
: <> /* a2 */
class_name <> /* a3 */
( /* a4 */
() /* empty */ /* a5 */
<<#0=node;node=0;>> /* a6 */
| COLON_COLON follows_dot_class[node] /* a7 */
<<#0=#2;node=0;>> /* a8 */
) /* a9 */
......... /* a10 */
/* a11 */
; <> /* a12 */

In this case "class_name" may return a full AST tree (not a trivial tree)
because of information required to represent template classes (e.g.
dictionary is a "class_name"). This tree ("node") is passed to
another rule ("follows_dot_class") which uses it to construct another AST
tree which incorporates it. If "follows_dot_class" succeeds then node is
set to 0 (lines a6 or a8) because the tree is now referenced via #2. If
"follows_dot_class" fails then the entire tree created by class_name must
be deallocated (line a12). The temporary "node" must be used because there
is no convenient way (such as #1.1) to refer to class_name from within the
sub-rule.

Please note the use of an empty sub-rule ("()" on line a5) to avoid the nasty
init-action problem mentioned earlier.
(Item 92)
##. Example 6 shows debugging code to help locate ASTs that were created
but never deleted.
(Item 93)
##. If you want to place prototypes for routines that have an AST
as an argument in the #header directive you should explicitly
#include "ast.h" after the #define AST_FIELDS and before any references
to AST:

#define AST_FIELDS int token;char *text;
#include "ast.h"
#define zzcr_ast(ast,attr,tok,astText) \
create_ast(ast,attr,tok,text)
void create_ast (AST *ast,Attr *attr,int tok,char *text);
Page 30

(Item 94)
##. The make-a-root operator for ASTs ("^") can be applied only to
terminals. (This includes items identified in #token ,#tokclass, and
#tokdef statements). I think this is because a child rule might return a
tree rather than a single AST. If it did then it could not be made into a
root as it is already a root and the corresponding fields of the structure
are already in use. To make an AST returned by a called rule a root use
the expression: #(root-rule sibling1 sibling2 sibling3).

add ! : expr ("\+"^ expr) ; // Is ok

addOperator ! : expr (AddOp expr) // Is NOT ok
addOp : "\+" | "-"; //

Example 2 describes a workaround for this restriction.
(Item 95)
##. Because it is not possible to use an already constructed AST tree
as the root of a new tree (unless it's a trivial tree with no children)
one should be suspicious of any constructs like the following:

rule! : ........ <<#0=#(#1,...)...;>>
** <=====================

If #1 is a non-trivial tree its existing children will be lost when the
new tree is constructed for assignment to #0.
(Item 96)
##. Do not assign to #0 of a rule unless automatic construction of ASTs
has been disabled using the "!" operator:

a! : x y z <<#0=#(#1 #2 #3);>> // ok
a : x y z <<#0=#(#1 #2 #3);>> // NOT ok

The reason for the restriction is that assignment to #0 will cause any
ASTs pointed to by #0 to be lost when the pointer is overwritten.

The stated restriction is somewhat stronger than necessary. You can
assign to #0 even when using automated AST construction, if the old
tree pointed to by #0 is part of the new tree constructed by #(...).
For example:

#token COMMA ","
#token STMT_LIST

stmt_list: stmt (COMMA stmt)* <<#0=#(#[STMT_LIST],#0);>>

The automatically constructed tree pointed to by #0 is just put at the
end of the new list, so nothing is lost.

If you reassign to #0 in the middle of the rule, automatic tree
construction will result in the addition of remaining elements at the end
of the new tree. This is not recommended by TJP.

Special care must be used when combining the make-a-root operator
(e.g. rule: expr OP^ expr) with this transgression (assignment to #0 when
automatic tree construction is selected).
Page 31

(Item 97)
##. Even when automatic construction of ASTs is turned off in a rule the
called rules still return the ASTs that they constructed. The same applies
when the "!" operator is applied to a called rule. This is hard to
believe when one sees a rule like the following:

rule: a! b! c!

generate (in part) a sequence of operations like:

_ast = NULL; a(&_ast);
_ast = NULL; b(&_ast);
_ast = NULL; c(&_ast);

It appears that the AST pointer is being assigned to a temporary where it
becomes inaccessible. This is not the case at all. The called rule is
responsible for placing a pointer to the AST which is constructed onto a
stack of AST pointers. The stack of AST pointers is normally in global
scope with ZZAST_STACKSIZE elements.

(The "!" operator simply inhibits the automatic construction of the
AST trees. It does not prevent the construction of the ASTs themselves.
When calling a rule which constructs ASTs and not using the result one
must destroy the constructed AST using zzfree_ast() in order to avoid a
memory leak. See Example 6 below for code which aids in tracking lost
ASTs).

Consider the following examples (using the list notation of page 45 of
the 1.00 manual):

a: A;
b: B;
c: C;

#token T_abc_node

rule : a b c ; <<;>> /* AST list (0 A B C) without root */
rule ! : a b c <<#0=#(0,#1,#2,#3);>> /* AST list (0 A B C) without root */
rule : a! b! c! <<#0=#(0,#1,#2,#3);>> /* AST list (0 A B C) without root */
rule : a^ b c /* AST tree (A B C) with root A */
rule ! : a b c <<#0=#(#1,#2,#3);>> /* AST tree (A B C) with root A */

rule ! : a b c <<#0=#(#[T_abc_node,0],#1,#2,#3);>>
/* AST tree (T_abc_node A B C) */
/* with root T_abc_node */
rule : a b c <<#0=#(#[T_abc_node,0],#0);>> /* the same as above */
rule : a! b! c! <<#0=#(#[T_abc_node,0],#1,#2,#3);>> /* the same as above */

rule ! : a b c <<#0=#(toAST(T_abc_node),#1,#2,#3);>> /* the same as above */
rule : a b c <<#0=#(toAST(T_abc_node),#0);>> /* the same as above */
rule : a! b! c! <<#0=#(toAST(T_abc_node),#1,#2,#3);>> /* the same as above */

The routine "toAST()" calls zzmk_ast() to construct an AST given the token
number. For a typical version of zzmk_ast() it would look something like the
following:

AST * toAST (int tokenID) {
return zzmk_ast (zzastnew(),tokenID,NULL);
}

Page 32
I find toAST() more convenient than passing the extra arguments to zzmk_ast()
using a construct like #[T_abc_node,0] or writing zzmk_ast() with varargs.
Using varargs defeats most forms of inter-procedural type checking (unless you
are using C++ which allows overloaded function names).
(Item 98)
##. There is an idiom which can be useful when combining automatic AST
construction with optional clauses in a grammar. Suppose one wants to
make the following transformation:

rule : lhs => #(toAST(T_simple),#1)
rule : lhs rhs => #(toAST(T_complex),#1,#2)

Both lhs and rhs considered separately may be suitable for automatic
construction of ASTs, but the change in the label from "simple" to "complex"
appears to require manual tree construction. Use the following idiom:

rule : lhs (
() <<#0=#(toAST(T_simple),#0);>>
| rhs <<#0=#(toAST(T_complex),#0,#1);>>
)
(Item 99)
##. If you use ASTs you have to pass a root AST to ANTLR.

AST *root=NULL;
again:
ANTLR (start(&root),stdin);
walk_the_tree(root);
zzfree_ast(root);
root=NULL;
goto again;
(Item 100)
##. zzfree_ast(AST *tree) will recursively descend the AST tree and free
all sub-trees. The user should supply a routine zzd_ast() to free any
resources used by a single node - such as pointers to character strings
allocated on the heap. See Example 2 on associativity and precedence.
(Item 101)
##. AST elements in rules are assigned numbers in the same fashion as
attributes with three exceptions:

1. A hole is left in the sequence when sub-rules are encountered.
(e.g. "(...)+", "(...)*", and "{...}").
2. #0 is the AST of the named rule, not the sub-rule - see the next item
3. There is nothing analogous to $i.j notation (which allows one
to refer to attributes from earlier in the rule). In other words,
you can't use #i.j notation to refer to an AST created earlier
in the rule.

========================================================
Version 1.30 of Antlr allows one to use symbolic tags
rather than numbers to refer to matched elements of a rule.
They are similar in appearance to Sorcerer.
See the version 1.3 release notes for more information
========================================================

Consider the following example:

a : b // B is #1 for the rule
(c d)* // C is #1 when scope is inside the sub-rule
// D is #2 when scope is inside the sub-rule
// You may *NOT* refer to b as #1.1
e // E is #3 for the rule
// There is NO #2 for the rule
Page 33

(Item 102)
##. The expression #0 refers to the AST of the named rule. Thus it is
a misnomer and (for consistentcy) should probably have been named ## or #$.
There is nothing equivalent to $0 for ASTs. This is probably because
sub-rules aren't assigned AST numbers in a rule. See above.
(Item 103)
##. Associativity and precedence of operations is determined by nesting
of rules. In the example below "=" associates to the right and has the
lowest precedence. Operators "+" and "*" associate to the left with "*"
having the highest precedence.

expr0 : expr1 {"=" expr0};
expr1 : expr2 ("\+" expr2)*;
expr2 : expr3 ("\*" expr3)*;
expr3 : ID;

In Example 2 the zzpre_ast() routine is used to walk all the AST nodes.
The AST nodes are numbered during creation so that one can see the order in
which they are created and the order in which they are deleted. Do not
confuse the "#" in the sample output with the AST numbers used to refer to
elements of a rule in the action part of a the rule. The "#" in the
sample output are just to make it simpler to match elements of the
expression tree with the order in which zzd_ast() is called for each node in
the tree.
(Item 104)
##. If the make-a-root operator were NOT used in the rules:

;expr0 : expr1 {"=" expr0}
;expr1 : expr2 ("\+" expr2)*
;expr2 : expr3 ("\*" expr3)*
;expr3 : ID

With input:

a+b*c

The output would be:

a <#1> \+ <#2> b <#3> \* <#4> c <#5> NEWLINE <#6>

zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
Page 34

(Item 105)
##. Suppose that one wanted to replace the terminal "+" with the rule:

addOp : "\+" | "-" ;

Then one would be unable to use the "make-a-root" operator because it can
be applied only to terminals.

There are two workarounds. The #tokclass feature allows one to write:

#tokclass AddOp { "\+" "\-"}

A #tokclass identifier may be used in a rule wherever a simple #token
identifier may be used.

The other workaround is much more complicated:

expr : (expr0 NEWLINE)
;expr0 : expr1 {"="^ expr0}
;expr1! : expr2 <<#0=#1;>>
(addOp expr2 <<#0=#(#1,#0,#2);>> )*
;expr2 : expr3 ("\*"^ expr3)*
;expr3 : ID
;addOp : "\+" | "\-"

With input:

a-b-c

The output is:

( \- <#4> ( \- <#2> a <#1> b <#3> ) c <#5> ) NEWLINE <#6>

The "!" for rule "expr1" disables automatic constructions of ASTs in the
rule. This allows one to manipulate #0 manually. If the expression had
no addition operator then the sub-rule "(addOp expr)*" would not be
executed and #0 will be assigned the AST constructed by rule expr2 (i.e.
AST #1). However if there is an addOp present then each time the sub-rule
is rescanned due to the "(...)*" the current tree in #0 is placed as the
first of two siblings underneath a new tree. This new tree has the AST
returned by addOp (AST #1 of the addOp sub-rule) as the root.
(Item 106)
##. There is an option for doubly linked ASTs in the module ast.c. It is
controlled by #define zzAST_DOUBLE. Even with zzAST_DOUBLE only the right
and down fields are filled while the AST tree is constructed. Once the tree
is constructed the user must call the routine zzdouble_link(tree,NULL,NULL) to
traverse the tree and fill in the left and up fields. See page 12 of the
1.06 manual for more information.
(Item 107)
##. If a rule which creates an AST is called and the result is not
linked into the tree being constructed then zzd_ast() will not be called
to release the resources used by the rule. Prior to version 1.20
this was especially important when rules were used in syntactic predicates.
Versions >= 1.20 bypasses construction of all ASTs during guess mode.

Page 35
===============================================================================
Section on Semantic Predicates
-------------------------------------------------------------------------------
(Item 108)
##. There is a bug in 1.1x and 1.2x which prevents semantic predicates
from including string literals. The predicate is incorrectly
"string-ized" in the call to zzfailed_predicate.

rule: <>? ID
/* Will not work */

The workaround is to place the literal in a string constant and use
the variable name.
(Item 109)
##. There is a bug in 1.1x and 1.2x which prevents semantic predicates from
crossing lines unless one uses an escaped newline.

rule: < this_works_in_120)>>? x y z;
(Item 110)
##. Semantic predicates are enclosed in "<<... >>?" but because they are
inside "if" statements they normally do not end with a ";" - unlike other
code enclosed in "<<...>>" in ANTLR.
(Item 111)
##. If one leaves an extra space after the close of the action:

<<...>> ? instead of <<...>>?

then ANTLR won't recognize it as a semantic predicate.
(Item 112)
##. Init-actions are ignored as far as the hoisting of semantic predicates
is concerned.
Page 36

(Item 113)
##. Semantic predicates which are not the first element in the rule or
sub-rule become "validation predicates" and are not used for prediction.
After all, if there are no alternatives, then there is no need for
prediction - and alternatives exist only at the left edge of rules
and sub-rules. Even if the semantic predicates are on the left edge it
is no guarantee that it will be part of the prediction expression.
Consider the following two examples:

a : << LA(1)==ID ? propX(LATEXT(1)) : 1 >>? ID glob /* a1 */
| ID glob /* a2 */
;
b : << LA(1)==ID ? propX(LATEXT(1)) : 1 >>? ID glob /* b1 */
| NUMBER glob /* b2 */
;

Rule a requires the semantic predicate to disambiguate alternatives
a1 and a2 because the rules are otherwise identical. Rule b has a
token type of NUMBER in alternative b2 so it can be distinguished from
b1 without evaluation of the semantic predicate during prediction. In
both cases the semantic predicate will also be evaluated inside the rule.

When the tokens which can follow a rule allow ANTLR to disambiguate the
expression without resort to semantic predicates ANTLR may not evaluate
the semantic predicate in the prediction code. For example:

simple_func : <>? ID
complex_func : <>? ID

function_call : "(" ")"

func : simple_func function_call
| complex_func "." ID function_call

In this case, a "simple_func" MUST be followed by a "(", and a
"complex_func" MUST be followed by a ".", so it is unnecessary to evaluate
the semantic predicates in order to predict which of the alternative to
use. A simple test of the lookahead tokens is sufficient. As stated
before, the semantic predicates will still be used to validate the rule.
Page 37

(Item 114)
##. Suppose that the requirement that all semantic predicates which are
used in prediction expressions must appear at the left hand edge of a rule
were lifted? Consider the following code segment:

cast_expr /* a1 */
: LP typedef RP cast_expr /* a2 */
| expr13 /* a3 */
;expr13 /* a4 */
: id_name /* a5 */
| LP cast_expr RP /* a6 */
;typedef /* a7 */
: <>? ID /* a8 */
;id_name /* a9 */
: ID /* a10 */

Now consider the token sequences:

Token: #1 #2 #3 #4
-- ----------------------- -- --
"(" ID-which-is-typedef ")" ID
"(" ID-which-is-NOT-typedef ")"

Were the semantic predicate at line a8 hoisted to predict which alternative
of cast_expr to use (a2 or a3) the program would use the wrong lookahead
token (LA(1) and LATEXT(1)) rather than LA(2) and LATEXT(2) to check for an
ID which satisfies "isTypedefName()". This is because it is preceded by a
"(". This problem could perhaps be solved by application of sufficient
ingenuity, however, in the meantime the solution is to rewrite the rules
so as to move the decision point to the left edge of the production.

First perform in-line expansion of expr13 (line a3) in cast_expr:

cast_expr /* b1 */
: LP typedef RP cast_expr /* b2 */
| id_name /* b3 */
| LP cast_expr RP /* b4 */

Secondly, move the alternatives (in cast_expr) beginning with LP to a
separate rule so that "typedef" and "cast_expr" will be on the left edge:

cast_expr /* c1 */
: LP cast_expr_suffix /* c2 */
| id_name /* c3 */
;cast_expr_suffix /* c4 */
: typedef RP cast_expr /* c5 */
| cast_expr RP /* c6 */
;typedef /* c7 */
: <>? ID /* c8 */
;id_name /* c9 */
: ID /* c10 */

This will result in the desired treatment of the semantic predicate to
choose from alternatives c5 and c6.
Page 38

(Item 115)
##. Validation predicates are evaluated by the parser. If they fail a
call to zzfailed_predicate(string) is made. To disable the message
redefine the macro zzfailed_predicate(string) or use the optional
"failed predicate" action which is enclosed in "[" and "]" and follows
immediately after the predicate:

a : < isTypedef(LATEXT(1)) : 1>>?[printf("Not a typedef\n");]

Douglas Cuthbertson ([email protected]_qmail.hanscom.af.mil)
has pointed out that Antlr fails to put the fail action inside "{...}"
which can lead to problems when the action contains multiple statements.
(Item 116)
##. An expression in a semantic predicate (e.g. <>? ) should not
have side-effects. If there is no match then the rest of the rule using the
semantic predicate won't be executed.
Page 39

(Item 117)
##. What is the "context" of a semantic predicate ? Answer due to TJP:

The context of a predicate is the set of k-strings (comprised of lookahead
symbols) that can be matched following the execution of a predicate. For
example,

a : <

>? alpha ;

The context of "p" is LOOK(alpha) where LOOK(alpha) is the set of
lookahead k-strings for alpha.

Normally, one should compute the context for ANTLR (manually) because
ANTLR is not smart enough to know the nature of your predicate and does not
know how much context information is needed; it's conservative and tries
to compute full LL(k) lookahead. Normally, you only need one token:

class_name: <>? ID ;

This example is incomplete, the predicate should really be:

class_name: <>? ID ;

This says, "I can tell you something if you have an ID, otherwise
just assume that the rule is semantically valid." This only makes a
difference if the predicate is *hoisted* out of the rule. Here is an
example that won't work because it doesn't have context check in the
predicates:

a : ( class_name | NUM )
| type_name
;

class_name : <>? ID ;

type_name : <>? ID ;

The prediction for production one of rule "a" will be:

if ( LA(1) in { ID, NUM } && isClass(LATEXT(1)) ) { ...

Clearly, NUM will never satisfy isClass(), so the production will never
match.

When you ask ANTLR to compute context, it can check for missing predicates.
With -prc on, for this grammar:

a : b
| <>? ID
| <>? NUM
;

b : <>? ID
| NUM
;

ANTLR reports:

warning alt 1 of rule itself has no predicate to resolve
ambiguity upon \{ NUM \}
Page 40

(Item 118)
##. A documented restriction of ANTLR is the inability to hoist multiple
semantic predicates. However, no error message is given when one attempts
this. When compiled with k=1 and ck=2 this generates inappropriate code
in "statement" when attempting to predict "expr":

#header <<

#include "charbuf.h"

int istypedefName (char *);
int isCommand (char *);

>>

#token BARK
#token GROWL
#token ID

statement
: expr
| declaration
;expr
: commandName BARK
| typedefName GROWL
;declaration
: typedefName BARK
;typedefName
: <>? ID
;commandName
: <>? ID
;

The generated code resembles the following:

void statement()
{
if ( (LA(1)==ID) &&
(LA(2)==BARK || LA(2)==GROWL) &&
( (LA(1)==ID ? isCommand(LATEXT(1)) : 1) ||
(LA(1)==ID ? istypedefName(LATEXT(1)) : 1)) ) {
expr();
} else {
if ( (LA(1)==ID) &&
(LA(2)==BARK) &&
(LA(1)==ID ? istypedefName(LATEXT(1)) : 1)) ) {
declaration();
} ...

The problem is that " BARK" will be passed to expr() rather
than declaration().

Some help is obtained by using leading actions to inhibit hoisting as
described in the next notes. (Don't confuse leading actions with
init-actions.) However, omitting all semantic predicates in the prediction
expression doesn't help if one requires them to predict the rule.
Page 41

(Item 119)
##. Leading actions will inhibit the hoisting of semantic predicates into
the prediction of rules.

expr_rhs
: <<;>> <<>> expr0
| command

See the section about known bugs for a more complete example.
(Item 120)
##. When using semantic predicates in ANTLR is is *IMPORTANT* to
understand what the "-prc on" ("predicate context computation")
option does and what "-prc off" doesn't do. Consider the following
example:

+------------------------------------------------------+
| Note: All examples in this sub-section are based on |
| code generated with -k=1 and -ck=1. |
+------------------------------------------------------+

expr : upper
| lower
| number
;

upper : <>? ID ;
lower : <>? ID ;
number : NUMBER ;

With "-prc on" ("-prc off" is the default) the code for expr() to predict
upper() would resemble:

if (LA(1)==ID && isU(LATEXT(1)) && LA(1)==ID) { /* a1 */
upper(zzSTR); /* a2 */
} /* a3 */
else { /* a4 */
if (LA(1)==ID && isL(LATEXT(1)) && LA(1)==ID) { /* a5 */
lower(zzSTR); /* a6 */
} /* a7 */
else { /* a8 */
if (LA(1)==NUMBER) { /* a9 */
zzmatch(NUMBER); /* a10 */
} /* a11 */
else /* a12 */
{zzFAIL();goto fail;} /* a13 */
} /* a14 */
} ...
...

*******************************************************
*** ***
*** Starting with version 1.20: ***
*** Predicate tests appear AFTER lookahead tests ***
*** ***
*******************************************************

Note that each test of LATEXT(i) is guarded by a test of the token type
(e.g. "LA(1)==ID && isU(LATEXT(1)").

Page 42
With "-prc off" the code would resemble:

if (isU(LATEXT(1)) && LA(1)==ID) { /* b1 */
upper(zzSTR); /* b2 */
} /* b3 */
else { /* b4 */
if (isL(LATEXT(1)) && LA(1)==ID) { /* b5 */
lower(zzSTR); /* b6 */
} /* b7 */
else { /* b8 */
if ( (LA(1)==NUMBER) ) { /* b9 */
zzmatch(NUMBER); /* b10 */
} /* b11 */
else /* b12 */
{zzFAIL();goto fail;} /* b13 */
} /* b14 */
} ...
...

Thus when coding the grammar for use with "-prc off" it is necessary
to do something like:

upper : <>? ID ;
lower : <>? ID ;

This will make sure that if the token is of type NUMBER that it is not
passed to isU() or isL() when using "-prc off".

So, you say to yourself, "-prc on" is good and "-prc off" is bad. Wrong.

Consider the following slightly more complicated example in which the
first alternative of rule "expr" contains tokens of two different types:

expr : ( upper | NUMBER ) NUMBER
| lower
| ID
;

upper : <>? ID ;
lower : <>? ID ;
number : NUMBER ;

With "-prc off" the code would resemble:

...
{ /* c1 */
if (LA(1)==ID && isU(LATEXT(1)) && /* c2 */
( LA(1)==ID || LA(1)==NUMBER) ) { /* c3 */
{ /* c4 */
if (LA(1)==ID) { /* c5 */
upper(zzSTR); /* c6 */
} /* c7 */
else { /* c8 */
if (LA(1)==NUMBER) { /* c9 */
zzmatch(NUMBER); /* c10 */
} /* c11 */
else {zzFAIL();goto fail;}/* c12 */
} /* c13 */
} ...
...

Page 43
Note that if the token is a NUMBER (i.e. LA(1)==NUMBER) then the clause at
line c2 ("LA(1)==ID && ...") will always be false, which implies that the
test in the "if" statement (lines c2/c3) will always be false. (In other
words LA(1)==NUMBER implies LA(1)!=ID). Thus the sub-rule for NUMBER at
line c9 can never be reached.

With "-prc on" essentially the same code is generated, although it
is not necessary to manually code a test for token type ID preceding
the call to "isU()".

The workaround is to to bypass the heart of the predicate when
testing the wrong type of token.

upper : <>? ID ;
lower : <>? ID ;

Then with "-prc off" the code would resemble:
...
{ /* d1 */
if ( (LA(1)==ID ? isU(LATEXT(1)) : 1) && /* d2 */
(LA(1)==ID || LA(1)==NUMBER) ) { /* d3 */
...
...

With this correction the body of the "if" statement is now reachable
even if the token type is NUMBER - the "if" statement does what one
wants.

With "-prc on" the code would resemble:

... /* e1 */
if (LA(1)==ID && /* e2 */
(LA(1)==ID ? isU(LATEXT(1)) : 1) && /* e3 */
(LA(1)==ID || LA(1)==NUMBER) ) { /* e4 */
...
...

Note that the problem of the unreachable "if" statement body has
reappeared because of the redundant test ("e2") added by the predicate
computation.

The lesson seems to be: when using rules which have alternatives which
are "visible" to ANTLR (within the lookahead distance) that have different
token types it is probably dangerous to use "-prc on".
Page 44

(Item 121)
##. You cannot use downward inheritance to pass parameters
to semantic predicates which are NOT validation predicates. The
problem appears when the semantic predicate is hoisted into a
parent rule to predict which rule to call:

For instance:

a : b1 [flag]
| b2
| b3

b1 [int flag]
: <>? ID ;

b2 :
: <>? ID ;

b3 : ID ;

When the semantic predicate is evaluated within rule "a" to determine
whether to call b1, b2, or b3 the compiler will discover that there
is no variable named "flag" for procedure "a()". If you are unlucky
enough to have a variable named "flag" in a() then you will have a
VERY difficult-to-find bug.

The -prc option has no effect on this behavior.

It is possible that a leading action (init-actions are ignored for purposes
of hoisting) will inhibit the hoisting of the predicate and make this code
work. I have not verified this with versions 1.2x.
(Item 122)
##. Another reason why semantic predicates must not have side effects is
that when they are hoisted into a parent rule in order to decide which
rule to call they will be invoked twice: once as part of the prediction
and a second time as part of the validation of the rule.

Consider the example above of upper and lower. When the input does
in fact match "upper" the routine isU() will be called twice: once inside
expr() to help predict which rule to call, and a second time in upper() to
validate the prediction. If the second test fails the macro zzpred_fail()
is called.

As far as I can tell, there is no simple way to disable the use of a
semantic predicate for validation after it has been used for prediction.
Page 45

(Item 123)
##. I had a problem in which I needed to do a limited amount of
lookahead, but didn't want to use all the machinery of syntactic
predicates. I found that I could enlarge the set of expressions accepted
by "expr" and then look at the AST created in order to determined what
rules could follow:

cast_expr /* a1 */
: <> /* a2 */
/* a3 */
LP! predefined_type RP! cast_expr /* a4 */
<<#0=#(toAST(T_cast),#0);>> /* a5 */
| LP! expr0 RP! /* a6 */
<token)==T_class_name) { /* a7 */
isCast=1; /* a8 */
} else { /* a9 */
isCast=0; /* a10 */
}; /* a11 */
>> /* a12 */
( <<;>> <>? /* a13 */
<> /* a14 */
cast_expr /* a15 */
<<#0=#(toAST(T_cast),#0);>> /* a16 */
/* a17 */
| <> /* a18 */
() /* empty */ /* a19 */
) /* a20 */
| unary_expr /* a21 */

Later on I gave up on this approach and decided to use syntactic
predicates anyway. It not only solved this problem, but others
where it was more difficult to patch up the grammar. I can't bring
myself to remove the example, though.

Page 46
===============================================================================
Section on Syntactic Predicates (also known as "Guess Mode")
-------------------------------------------------------------------------------
(Item 124)
##. The terms "infinite lookahead", "guess mode","syntactic predicates"
are all equivalent. Sometimes the term "backtracking" is used as well,
although " backtracking" can sometimes be used to discuss lexing and DLG
as well. The term "syntactic predicate" emphasizes that is handled by the
parser. The term "guess mode" emphasizes that the parser may have to
backtrack. The term "infinite lookahead" emphasizes the implementation in
ANTLR: the entire input is read, processed, and tokenized by DLG before
ANTLR begins parsing.
(Item 125)
##. An expression in a syntactic predicate should not have side-effects.
If there is no match then the rule which uses the syntactic predicate won't be
executed.
(Item 126)
##. In some extremely unusual cases a user wants side-effects during guess
mode. In this case one can use exploit the fact that Antlr always
executes init-actions, even when in guess mode:

rule : (guess)? A
| B
;
guess : <>
A ( <> ) B
;

The init-action in the sub-rule will always be executed, even in guess-mode.
Contributed by TJP.
(Item 127)
##. When using syntactic predicates the entire input buffer is read and
tokenized by DLG before parsing by ANTLR begins. If a "wrong" guess
requires that parsing be rewound to an earlier point all attributes
that were creating during the "guess" are destroyed and the parsing
begins again and it creates new attributes at it reparses the (previously)
tokenized input.
(Item 128)
##. In infinite lookahead mode the line and column information is
hopelessly out-of-sync because zzline will contain the line number of
the last line of input - the entire input was parsed before
scanning was begun. The line and column information is not restored
during backtracking. To keep track of the line information in a meaningful
way one has to use the ZZINF_LINE macro which was added to pccts in version
1.20.

Putting line and column information in a field of the attribute will not
help. The attributes are created by ANTLR, not DLG, and when ANTLR
backtracks it destroys any attributes that were created in making the
incorrect guess.
(Item 129)
##. As infinite lookahead mode causes the entire input to be scanned
by DLG before ANTLR begins parsing, one cannot depend on feedback from
the parser to the lexer to handle things like providing special token codes
for items which are in a symbol table (the "lex hack" for typedefs
in the C language). Instead one MUST use semantic predicates which allow
for such decisions to be made by the parser.
(Item 130)
##. One cannot use an interactive scanner (ANTLR -gk option) with the
ANTLR infinite lookahead and backtracking options (syntactic predicates).
Page 47

(Item 131)
##. An example of the need for syntactic predicates is the case where
relational expressions involving "<" and ">" are enclosed in angle bracket
pairs.

Relation: a < b
Array Index: b
Problem: a < b
vs. b < a>

I was going to make this into an extended example, but I haven't had
time yet.
(Item 132)
##. Version 1.20 fixes a problem in 1.10 in which ASTs were constructed
during guess mode. In version 1.10 care had to be taken to deallocate the
ASTs that were created in the rules which were invoked in guess mode.
(Item 133)
##. The following is an example of the use of syntactic predicates.

program : ( s SEMI )* ;

s : ( ID EQUALS )? ID EQUALS e
| e
;

e : t ( PLUS t | MINUS t )* ;

t : f ( TIMES f | DIV f )* ;

f : Num
| ID
| "\(" e "\)"
;

When compiled with k=1:

antlr -fe err.c -fh stdpccts.h -fl parser.dlg -ft tokens.h \
-fm mode.h -k 1 test.g

One gets the following warning:

warning: alts 1 and 2 of the rule itself ambiguous upon { ID }

even though the manual suggests that this is okay. The only problem is
that ANTLR 1.10 should NOT issue this error message unless the -w2 option
is selected.

Included with permission of S. Salters

Page 48
===============================================================================
Section on Inheritance
-------------------------------------------------------------------------------
(Item 134)
##. A rule which uses upward inheritance:

rule > [int result] : x | y | z;

Is simply declaring a function which returns an "int" as a function
value. If the function has more than one item passed via upward
inheritance then ANTLR creates a structure to hold the result and
then copies each component of the structure to the upward inheritance
variables.
(Item 135)
##. When writing a rule that uses downward inheritance:

rule [int *x] : r1 r2 r3

one should remember that the arguments passed via downward inheritance are
simply arguments to a function. If one is using downward inheritance
syntax to pass results back to the caller (really upward inheritance !)
then it is necessary to pass the address of the variable which will receive
the result.
(Item 136)
##. ANTLR is smart enough to combine the declaration for an AST with
the items declared via downward inheritance when constructing the
prototype for a function which uses both ASTs and downward inheritance.

Page 49
===============================================================================
Section on LA, LATEXT, NLA, and NLATEXT
-------------------------------------------------------------------------------
(Item 137)
##. Do not use LA(i) or LATEXT(i) in the action routines of #token
statements. To refer to the token code (in a #token action) of the token
just recognized use "NLA". NLA is an lvalue (can appear on the left hand
side of an assignment statement). To refer to the text just recognized
use zzlextext (the entire text), NLATEXT. One can also use
zzbegexpr/zzendexpr which refer to the regular expression just matched.
The char array pointed to by zzlextext may be larger than the string
pointed to by zzbegexpr and zzendexpr because it includes substrings
accumulated through the use of zzmore().
(Item 138)
##. Extra care must be taken in using LA(i) and LATEXT(i) when in
interactive mode (Antlr switch -gk) because Antlr doesn't guarantee that
it will fetch lookahead tokens until absolutely necessary. It is somewhat
safer to refer to lookahead information in semantic predicates, but care
is still required. I have summarized the output from Example 7:

-----------------------------------------------------------------------
k=1 k=1 k=3 k=3 k=3
standard infinite standard interactive infinite
-----------------------------------------------------------------------
for a semantic predicate
------------------------
LA(0) Next Next -- -- --
LA(1) Next Next Next Next Next
zzlextext Next Next Next -- Next
ZZINF_LA(0) Next Next
ZZINF_LA(1) NextNext NextNext
-----------------
for a rule action
-----------------
LA(0) Prev Prev -- Prev --
LA(1) Prev Prev Prev Next Prev
zzlextext Prev Prev Prev -- Prev
ZZINF_LA(0) Prev Prev
ZZINF_LA(1) Next Next
-----------------------------------------------------------------------

The entries "prev" and "next" means that the left hand item refers to the
token which precedes (or follows) the action which generated the output.

For semantic predicate entries think of the following rule:

rule : <>? Next NextNext;

For rule-action entries think of the following rule:

rule : Prev <> Next NextNext;
(Item 139)
##. Example 7 below gives some diagnostic output for a k=3 grammar compiled
with "standard" options, interactive options (AFLAGS=-gk), and infinite
lookahead option (CFLAGS=-DZZINF_LOOK).
(Item 140)
##. Example 8 shows how to modify the lookahead token NLA.
Page 50

(Item 141)
##. I find it helpful to think of lexical processing by DLG as a process
which fills a pipeline and of Antlr as a process which empties a pipeline.
(This relationship is exposed in C++ mode because DLG passes an object of
a certain class to Antlr).

With LL_K=1 the pipeline is only one item deep and is trivial and pretty much
invisible. It is invisible because one can make a decision in Antlr which
affects how the very next token is processed. For instance with LL_K=1 it is
possible to change the DLG mode in an Antlr action with zzmode() and have
the next token (the one following the one just parsed by Antlr) parsed
according to the new #lexclass.

With LL_K>1 the pipeline is not invisible. DLG will put a number of tokens
into the pipeline and Antlr will analyze them in the same order. How many
tokens are in the pipeline depends on options one has chosen.

Case 1: If one has infinite lookahead mode ("(...)?") (also known as
syntactic predicates) then the pipeline is as huge as the input stream
since the entire input is tokenized by DLG before Antlr even begins
analysis.

Case 2: If you have demand lookahead (interactive mode) then you'll have a
varying amount of lookahead depending on how much Antlr thinks it needs to
parse the thing it is working on. This may be zero (or maybe its 1 token)
up to k tokens. Naturally it takes extra work by Antlr to keep track of
how many tokens are in the pipe and how many are needed to parse the next
rule.

Case 3: In "normal" mode DLG tries to stay exactly k tokens ahead of
Antlr. This is a half-truth. It rounds k up to the next power of
2 so that with k=3 it actually has a pipeline of 4 tokens. If one says
"k=3" the analysis is still k=3, but the pipeline size is rounded up
because TJP decided it was better to use a bit-wise "and" then some other
mechanism to compute (n+1) mod k - where n is the position in a circular
buffer.

Page 51
===============================================================================
Section on Prototypes
-------------------------------------------------------------------------------
(Item 142)
##. Prototype for typical create_attr routine:

#define zzcr_attr(attr,token,text) \
create_attr(attr,token,text)

void create_attr (Attrib *attr,int token,char *text);
(Item 143)
##. Prototype for a typical create_ast routine invoked to automatically
construct an AST from an attribute:

#define zzcr_ast(ast,attr,tok,astText) \
create_ast(ast,attr,tok,text)

void create_ast (AST *ast,Attr *attr,int tok,char *text);
(Item 144)
##. Prototype for a typical make_ast routine invoked by the #[...]
notation.

AST *zzmk_ast (AST *ast,int token,char *text)
(Item 145)
##. Prototype for a typical zzd_ast macro which is invoked when destroying
an AST node:

#define zzd_ast(node) delete_ast(node)

void delete_ast (AST * node);
(Item 146)
##. Prototype for zzdef0 macro to initialize $0 of a rule:

#define zzdef0(attr) define_attr_0 (attr)

void define_attr_0 (Attrib *attr);
(Item 147)
##. Prototype for ANTLR (these are actually macros):

read from file: void ANTLR (void startRule(...),FILE *)
read from string: void ANTLRs (void startRule(...),zzchar_t *)
read from function: void ANTLRf (void startRule(...),int (*)())
read from file: void ANTLRm
(void startRule(...),FILE *,int lexclass)

In the call to ANTLRf the function behaves like getchar()
in that it returns EOF (-1) to indicate end-of-file.

If ASTs are used or there is downward or upward inheritance then the
call to the startRule must pass these arguments:

AST *root;
ANTLRf (startRule(&root),stdin);

Page 52
===============================================================================
Section on ANTLR/DLG Internals and Routines That Might Be Useful
-------------------------------------------------------------------------------
****************************
****************************
** **
** Use at your own risk **
** **
****************************
****************************
(Item 148)
##. Sometimes I have wanted to add code which appears before every
#token action or after every #token action. Rather than modify every
#token statement one could add code to pccts/h/dlgauto.h near line 430:

(*actions)[accepts[state]]();

This statement is executed for every #token statement. Even #token
statements without a user-written action contain the required action:

NLA=TokenIdentifier

Following the statement near line 430 of dlgauto.h would be an appropriate
place to insert debug code to print out token definitions. The name
for token "i" is in the char * array zztokens[i] (defined in antlr.h).
(Item 149)
##. static int zzauto - defined in dlgauto.h

Current DLG mode. This is used by zzmode() only.
(Item 150)
##. void zzerr (char * s) defined in dlgauto.h

Defaults to zzerrstd(char *s) in dlgauto.h

Unless replaced by a user-written error reporting routine:

fprintf(stderr,
"%s near line %d (text was '%s')\n",
((s == NULL) ? "Lexical error" : s),
zzline,zzlextext);

This should probably be "void zzerr (const char * s)".
(Item 151)
##. static char zzebuf[70] defined in dlgauto.h

Page 53
===============================================================================
Section on Known Minor Bugs in pccts (in reverse chronological order)
-------------------------------------------------------------------------------
(Item 152)
##. Fixed in 1.30b2: The generation of sets for #errclass may reference
bits beyond the end of the set. Modify line 462 in pccts/antlr/bits.c:

old: endp = &(f->setword[NumWords(TokenNum-1)]);
workaround: endp = &(f->setword[f->n]);
(Item 153)
##. The fail action following a semantic predicate is not enclosed
in "{...}". This can lead to problems when the fail action contains
more than one statement. Reported by Douglas Cuthbertson
([email protected]_qmail.hanscom.af.mil).
(Item 154)
##. Fixed in 1.23: In version 1.22 (and earlier versions) when there are
more than 255 #token statements then a truncation problem occurs in
zzedecode() during the creation of the zzerr(i) for err.c. The problem was
reported in netnews #517.
(Item 155)
##. Fixed in 1.23: In version 1.22 (and earlier versions) there is a bug in
set_sub().
(Item 156)
##. Reported as fixed in 1.23: In C++ mode in versions 1.20, 1.21, and
1.22 there is a bug which can cause ANTLR to generate an ast temporary
with the same label more than once in a module. A patch to to genast.c is
described in netnews note #449. The problem was reported by Sanjay
Ghemawat ([email protected])
(Item 157)
##. Reported as fixed in 1.22: The following problem was first reported
by Carle Patrice in netnews note #347. TJP describes the problem in
netnews note #428:

It is related to lookahead computation for k=3 with a hoisted
predicate. I have reduced the error to this case:

a : (A B | B C) | b ;

b : <>? B B ;

It did not compute the correct lookahead decision for
alternative one in rule "a". It should generate:

if ( (LA(1)==A || LA(1)==B) && (LA(2)==B || LA(2)==C) &&
!((LA(1)==B&&(LA(2)==B))) ) {
...
}
else blah

*NOT* simply:

if ( (LA(1)==A || LA(1)==B) && (LA(2)==B || LA(2)==C) ) {
...
}
else blah
(Item 158)
##. Reported as fixed in 1.21: With version 1.20 (1-Apr-94) of ANTLR the
-w2 switch will sometimes cause items to be reported as lacking an
associated regular expression when they actually do have an associated
regular expression. Sometimes #lexclass names and #tokclass names will
also be reported.
Page 54

(Item 159)
##. The UPDATE.120 of (1-Apr-94) reports that there are problems in
combining guess mode and semantic predicates under some circumstances.
(Item 160)
##. Reported as fixed in 1.21: In version 1.20 there is a bug in the
1-Apr-94 distribution of routine _zzsetmatch() which appears when used
with ANTLR -gk (demand lookahead.
(Item 161)
##. Reported as fixed in 1.21: In version 1.20 a rule which returns more
than two arguments (via upward inheritance) generates code which cannot be
compiled by a strict K&R compiler. It is accepted by ANSI compilers,
however. Reported by Joachim Schrod ([email protected]).
(Item 162)
##. Reported fixed in 1.20: In version 1.10 there was a bug in the
hoisting of semantic predicates when all alternatives of a rule had the
same lookahead token. Consider the following (compiled with -prc off -k 1
-ck 3):

;obj_name
: global_func_id
| simple_class SUFFIX_DOT
| ID

;simple_class
: <<(LA(1)==ID ? isClass(LATEXT(1)) : 1)>>? ID

;global_func_id
: <<(LA(1)==ID ? isFunction(LATEXT(1)) : 1)>>? ID

In version 1.2x the generated code resembles:

void obj_name(void) {
if ( (LA(1)==ID) &&
(LA(1)==ID ? isFunction(LATEXT(1)) : 1)) ) {
global_func_id();
} else {
if ( (LA(1)==ID) &&
(LA(2)==SUFFIX_DOT) ) {
simple_class();
} else {
if ( (LA(1)==ID) ) {
zzmatch(ID);
...

The workaround, previously, was to precede semantic predicates with an
action (such as "<<;>>") which inhibits hoisting into the prediction
expression.

Page 55
#header
<<
#include "charptr.h"
>>

#token QUESTION
#token COMMA
#token ID

#token Eof "@"

#token SUFFIX_DOT

statement
: (information_request)?
| obj_name

;information_request
: QUESTION id_list ( QUESTION )*
| id_list ( QUESTION )+

;id_list
: obj_name ( COMMA | obj_name )*

;simple_class
: <<(LA(1)==ID ? isClass(LATEXT(1)) : 1)>>? ID

;global_func_id
: <<(LA(1)==ID ? isFunction(LATEXT(1)) : 1)>>? ID

;obj_name
: <<;>> global_func_id
| <<;>> simple_class SUFFIX_DOT
| ID
;

Page 56
===============================================================================
Ideas on the Construction of ASTs and their use with Sorcerer
-------------------------------------------------------------------------------
Consider the problem of a grammar which would normally require two
passes through the source code to properly analyze. In some cases
it is convenient to perform a first pass which creates AST trees
and perform the second pass by analyzing the AST trees with Sorcerer.

1) Define an AST node that contains the information you'll need in the
second pass. For example,

/*
* Parse trees are represented by an abstract-syntax-tree (AST)
* (forward declare the pointer here). Refer to parse.h for description
* of parse_info.
*/
typedef struct parse_struct *ast_ref;

/* parser attributes ($-symbols) & AST nodes */
typedef struct parse_struct *pinfo_ref;

/*
* the parse structure is used to describe both attributes and
* AST nodes
*/

struct parse_struct {
pinfo_ref right; /* points to siblings */
pinfo_ref down; /* points to children */
int token; /* token number (see tokens.h) */
char *text; /* input text */
src_pos pos; /* position in source file */
object_ref obj; /* object description (id's) */
type_ref typ; /* type description (expr's) */
const_value value; /* value of a constant expression */
} ;

/*
* define Abstract Syntax Tree (AST) nodes
*/

/* ast_ref was forward-defined */
typedef struct parse_struct AST;

/*
* the Pass-1 (parse phase) parse-attributes ($-variables)
* have the same structure as an AST node.
*/
typedef struct parse_struct Attrib, *Attrib_ref;


In the code above, the parse-attribute was defined to have the same
structure as an AST node. This isn't a requirement, but just makes it
easier to pass information produced in the first pass on to subsequent
passes.

Page 57
2) Have the first pass build a symbol table as it parses the input, perform
semantic checks, and build an AST. Use the -gt (generate tree) option on
ANTLR, and override the automatically generated tree construction operations
as needed. For example,

var_declare:
<< pvec_ref v_list;
int i;
boolean has_var_section = FALSE;
>>
VAR^
(
var_id_list > [v_list] COLON
{ extern_kw
| static_kw
}
type
<<
for (i = 0; i < v_list->len; ++i) {
object_ref v = (object_ref) v_list->val[i];
define_var(v, $4.typ);
}
>>
{ ASSIGNMENT expr
<< mark_var_use(#2, VAR_RHS); >>
}
SEMI
<< free_pvec(v_list); >>
)+
;
var_id_list > [pvec_ref v_list]:
<< object_ref this_var;
$v_list = new_pvec();
>>
ID
<< this_var = new_var_id(&$1);
if (this_var != NULL) append_pvec($v_list, (void *)this_var);
>>
(
COMMA ID
<< this_var = new_var_id(&$2);
if (this_var != NULL) append_pvec($v_list, (void *)this_var);
>>
)*
;

The "pvec" stuff above is just a vector of pointers that can be
extended automatically. A linked list would work just as well. The
idea is that we must first collect the declared variables, then
parse the type declaration, then apply bind the type to the declared
variables. We used ANTLR's auto-tree-generation mode, and didn't
override its actions with our own. Therefore, the following Sorcerer
fragment will recognize the AST built for a variable declaration:

Page 58
var_declare:
#( VAR
( v_list: var_id_list COLON
{ EXTERN | STATIC }
type
{ ASSIGNMENT expr }
SEMI
)+
)
;
var_id_list:
ID ( COMMA ID)*
;

Here's an example, where we use explicit rules to build an AST:

expr!:
simple_expr
<< $expr = $1; #0 = #1; >>
( rel_op simple_expr
<< parse_binary_op(&$expr, &$1, &$2); #0 = #(NULL, #0, #1, #2); >>
)*
<< $expr.token = EXPR;
$expr.text = "expr";
#0 = #(#[&$expr], #0);
>>
;

The construct, #[&$expr] first takes the address of the $expr
attribute (attributes are structures, not pointers, in this example),
and then applies the #[] operation which makes a call to the routine
that creates an AST node, given an attribute (or attribute address
in our case). It takes a while to get the hang of where the &'s
#'s, and $'s go, but can be a real time-saver once you master it.
What we're doing above is building a special EXPR (expression) node.
This node would be parsed as follows in subsequent passes, using
Sorcerer:

expr: #( e: EXPR
l_oprnd: simple_expr << e->typ = l_oprnd->typ; >>
(op: rel_op r_oprnd: simple_expr
<<
e->typ = std_bool_type->obj_type;
if (op->token == IN) {
/* no type conversion checking for IN.
* try to rewrite simple IN ops.
*/
if (is_simple_in_op(l_oprnd, op, r_oprnd)) {
rewrite_simple_in_op(l_oprnd, op, r_oprnd);
}
} else {
cvt_term(&l_oprnd, op, r_oprnd, _t);
}
>>
)*
);

Page 59
We left in the actual actions of the second (Sorcerer driven) pass.
Notice how the Sorcerer grammar labels various parts of the expr
node ("e", "l_oprnd", "op", and "r_oprnd"). This gives the second
pass access to each node, as it is recognized.

The second pass uses the "typ" field, which contains the type of
the ID, expression, or literal parsed by the first pass. In the
actions above, we are propagating additional type information (for
example, the result of a relational op is always a boolean, checking
for implicit type conversions, and handling simple cases of Pascal's
IN operation). The fragment above is from a Pascal to Ada translator,
so the translator has to make Pascal's implicit type conversions
between integer and real into explicit Ada type conversions, and
has to convert operations on sets (i.e. IN) into operations on
packed boolean arrays, in Ada, or calls to runtime routines.

Sometimes when you are building the AST for a given construct,
you need to use information gained from semantic analysis. An
example is the "assignment" or "call" statement:

/*
* If a variable access appears alone, then it must be either a call to
* procedure with no parameters, or an indirection through a pointer
* to a procedure with no parameters.
*/
assign_or_call_stmt!:
<< type_ref r_type = NULL;
ast_ref v;
>>
variable
<< v = #1;
$assign_or_call_stmt = $1;
$assign_or_call_stmt.token = PROC_CALL;
$assign_or_call_stmt.text = "proc_call";
r_type = $assign_or_call_stmt.typ;
if (v != NULL && v->obj != NULL
&& v->obj->obj_result != NULL
&& v->obj->obj_kind == func_obj
&& v->down->token == ID
&& v->down->right == NULL) {
object_ref func = v->obj;
/* function name used on left hand side;
* convert to reference to the function's return value
*/
v->obj = func->obj_result;
v->typ = func->obj_result->obj_type;
v->down->text = func->obj_result->obj_name;
v->down->obj = func->obj_result;
v->down->typ = func->obj_result->obj_type;
}
#0 = v;
>>

Page 60
{ ASSIGNMENT expr
<< $assign_or_call_stmt.token = ASSIGNMENT;
$assign_or_call_stmt.text = ":=";
mark_var_use(#2, VAR_RHS);
mark_var_use(v, VAR_LHS);
#0 = #(NULL, #0, #[&$1], #2);
>>
| ( LPAREN actual_param_list RPAREN
<< mark_actual_param_use(#2, r_type);
mark_var_use(v, VAR_RHS);
#0 = #(NULL, #0, #[&$1], #2, #[&$3]);
>>
)
}
<< #0 = #( #[&$assign_or_call_stmt], #0); >>
;

The problem we're solving is that both an assignment statement and a
procedure call statement begin with a "variable". Since ANTLR is
LL-based, this statement construct is "ambiguous" in that both statement
types (assignment and call) begin with the same non-terminal. A
"variable" includes such operations as array subscripting, pointer
deferencing, and record field selection. Thus, a "variable" may comprise
an arbitrary number of tokens.

We might use syntactic predicates as a form a look-ahead to resolve the
two cases above, but instead I decided to make the assumption that we have
"PROC_CALL", and to correct that "guess" once we see the assignment
operation. Thus, the above rule will build one of the following two AST
structures:

assign_stmt:
#( ASSIGNMENT
variable ASSIGNMENT expr
)
;
call_stmt:
#( PROC_CALL
variable {LPAREN actual_param_list RPAREN}
)
;

In your AST, you might want to drop unnecessary syntactic tokens such as
ASSIGNMENT, LPAREN, RPAREN, COMMA, COLON, etc. We kept them, because we
thought it would be necessary for certain parts of source-to-source
translation. We don't think that's true, any more, but have not gone back
and changed the AST structure either.

Page 61
3) Build a separate Sorcerer grammar file to recognize the AST that you
have built, and then add your second pass actions. These actions will
access fields in the AST node, that were filled in by the first pass. For
example, identifiers will probably have an "object_ref" that points to the
object named by the identifier, and expression (EXPR) nodes will have a
"typ" field that gives the expression's type. You might also add a "value"
field that gives the value of a literal, named literal, or statically
evaluated constant expression. See the code fragments above for some ideas
on how this is done.

Conclusions:

1) You'll need an ANTLR (.g) description for pass1, and a separate
Sorcerer (.sor) description for pass2. Often the pass2 AST
representation is much more regular and well-formed than the
original text token stream used by pass1.

2) It can be a bit intimidating putting the pieces together.
Try it incrementally, trying a small subset of your larger
problem.

3) There are a lot of ways to go with how you represent
attributes ($-variables), AST nodes, and the things that
go on in various passes. For example, you might have
pass1 simply build the AST and perform *no* symbol definitions
or semantic checks. Then pass2 might walk the tree and build
the symbol, and make various checks. Pass2 might also disambiguate
cases that look syntactically similar, and can only be disambiguated
using symbol definitions. Then, you could have a pass3 (another
Sorcerer driven tree-walk) that does the 'real work' of your
compiler/translator.

Contributed by Gary Funck ([email protected])

Page 62
===============================================================================
Example 1 of #lexclass
===============================================================================
Borrowed code
-------------------------------------------------------------------------------
/*
* Various tokens
*/
#token "[\t\ ]+" << zzskip(); >> /* Ignore whitespace */
#token "\n" << zzline++; zzskip(); >> /* Count lines */

#token "\"" << zzmode(STRINGS); zzmore(); >>
#token "'" << zzmode(CHARACTERS); zzmore(); >>
#token "/\*" << zzmode(COMMENT); zzskip(); >>
#token "//" << zzmode(CPPCOMMENT); zzskip(); >>

/*
* C++ String literal handling
*/
#lexclass STRINGS
#token STRING "\"" << zzmode(START); >>
#token "\\\"" << zzmore(); >>
#token "\\n" << zzreplchar('\n'); zzmore(); >>
#token "\\r" << zzreplchar('\r'); zzmore(); >>
#token "\\t" << zzreplchar('\t'); zzmore(); >>
#token "\\[1-9][0-9]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 10));
zzmore(); >>
#token "\\0[0-7]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 8));
zzmore(); >>
#token "\\0x[0-9a-fA-F]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 16));
zzmore(); >>
#token "\\~[\n\r]" << zzmore(); >>
#token "[\n\r]" << zzline++; zzmore(); /* Print warning */ >>
#token "~[\"\n\r\\]+" << zzmore(); >>

/*
* C++ Character literal handling
*/
#lexclass CHARACTERS
#token CHARACTER "'" << zzmode(START); >>
#token "\\'" << zzmore(); >>
#token "\\n" << zzreplchar('\n'); zzmore(); >>
#token "\\r" << zzreplchar('\r'); zzmore(); >>
#token "\\t" << zzreplchar('\t'); zzmore(); >>
#token "\\[1-9][0-9]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 10));
zzmore(); >>
#token "\\0[0-7]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 8));
zzmore(); >>
#token "\\0x[0-9a-fA-F]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 16));
zzmore(); >>
#token "\\~[\n\r]" << zzmore(); >>
#token "[\n\r]" << zzline++; zzmore(); /* Print warning */ >>
#token "~[\'\n\r\\]" << zzmore(); >>

Page 63
/*
* C-style comment handling
*/
#lexclass COMMENT
#token "\*/" << zzmode(START); zzskip(); >>
#token "~[\*]*" << zzskip(); >>
#token "\*~[/]" << zzskip(); >>

/*
* C++-style comment handling
*/
#lexclass CPPCOMMENT
#token "[\n\r]" << zzmode(START); zzskip(); >>
#token "~[\n\r]" << zzskip(); >>

#lexclass START

/*
* Assorted literals
*/
#token OCT_NUM "0[0-7]*"
#token L_OCT_NUM "0[0-7]*[Ll]"
#token INT_NUM "[1-9][0-9]*"
#token L_INT_NUM "[1-9][0-9]*[Ll]"
#token HEX_NUM "0[Xx][0-9A-Fa-f]+"
#token L_HEX_NUM "0[Xx][0-9A-Fa-f]+[Ll]"
#token FLOAT_NUM "([1-9][0-9]*{.[0-9]*} | {0}.[0-9]+) {[Ee]{[\+\-]}[0-9]+}"

/*
* Identifiers
*/
#token Identifier "[_a-zA-Z][_a-zA-Z0-9]*"

Page 64
===============================================================================
Example 2: ASTs
===============================================================================
#header <<

#include "charbuf.h"
#include

int nextSerial;

#define AST_FIELDS int token; int serial; char *text;
#include "ast.h"

#define zzcr_ast(ast,attr,tok,astText) \
(ast)->token=tok; \
(ast)->text=strdup( (char *) &( ( (attr)->text ) ) ); \
nextSerial++; \
(ast)->serial=nextSerial; \

#define zzd_ast(node) delete_ast(node)

void delete_ast (AST *node);

>>

<<

AST *root=NULL;

void show(AST *tree) {
if (tree->token==ID) {
printf (" %s <#%d> ",
tree->text,tree->serial);}
else {
printf (" %s <#%d> ",
zztokens[tree->token],
tree->serial);
};
}
void before (AST *tree) {
printf ("(");
}
void after (AST *tree) {
printf (")");
}


void delete_ast(AST *node) {
printf ("\nzzd_ast called for \n",node->serial);
free (node->text);
return;
}

Page 65
int main() {
nextSerial=0;
ANTLR (expr(&root),stdin);
printf ("\n");
zzpre_ast(root,show,before,after);
printf ("\n");
zzfree_ast(root);
return 0;
}
>>

#token WhiteSpace "[\ \t]" <>
#token ID "[a-z A-Z]*"
#token NEWLINE "\n"
#token OpenAngle "<"
#token CloseAngle ">"

expr : (expr0 NEWLINE)

;expr0 : expr1 {"="^ expr0}
;expr1 : expr2 ("\+"^ expr2)*
;expr2 : expr3 ("\*"^ expr3)*
;expr3 : ID
-------------------------------------------------------------------------------
Sample output from this program:

a=b=c=d
( = <#2> a <#1> ( = <#4> b <#3> ( = <#6> c <#5> d <#7> ))) NEWLINE <#8>
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for

a+b*c
( \+ <#2> a <#1> ( \* <#4> b <#3> c <#5> )) NEWLINE <#6>
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for

a*b+c
( \+ <#4> ( \* <#2> a <#1> b <#3> ) c <#5> ) NEWLINE <#6>
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for

Page 66
===============================================================================
Example 3: Syntactic Predicates
===============================================================================
Not completed.
===============================================================================
Example 4: DLG input function
===============================================================================
This example demonstrates the use of a DLG input function to work
around a limitation of DLG. In this example the user wants to
recognize an exclamation mark as the first character of a line and
treat it differently from an exclamation mark elsewhere. The
workaround is for the input function to return a non-printing
character (binary 1) when it finds an "!" in column 1. If it reads a
genuine binary 1 in column 1 of the input text it returns a "?".

The parse is started by:

int DLGchar (void);
...
ANTLRf (expr(&root),DLGchar);
...
-------------------------------------------------------------------------------
#token BANG "!"
#token BANG_COL1 "\01"
#token WhiteSpace "[\ \t]" <>
#token ID "[a-z A-Z]*"
#token NEWLINE "\n"

expr! : (bang <>
| bang1 <>
| id <>
)* "@"

;bang! : BANG ID NEWLINE

;bang1! : BANG_COL1 ID NEWLINE

;id! : ID NEWLINE
;
-------------------------------------------------------------------------------

Page 67
#include

/*
Antlr DLG input function - See page 18 of pccts 1.00 manual
*/

static int firstTime=1;

static int c;

int DLGchar (void) {
if (feof(stdin)) {
return EOF;
};
if (firstTime || c=='\n') {
firstTime=0;
c=fgetc(stdin);
if (c==EOF) return (EOF);
if (c=='!') return ('\001');
if (c=='\001') return ('?');
return (c);
} else {
c=fgetc(stdin);
return (c);
};
};

Page 68
===============================================================================
Example 5: Maintaining a Stack of DLG Modes
===============================================================================
Contributed by David Seidel

When placed in a #lexaction or a separate file then the modifier "static"
must be dropped from the declaration of zzauto (line 61) in "dlgauto.h".

These routines have now been incorporated in pccts version 1.30b4. They
are defined in pccts/h/err.h and are guarded by #ifdef USER_ZZMODE_STACK.

This example will be dropped if they are still part of 1.31 upon its official
release.
-------------------------------------------------------------------------------
#define MAX_MODE ???
#define ZZMAXSTK (MAX_MODE * 2)

static int zzmstk[ZZMAXSTK] = { -1 };
static int zzmdep = 0;
static char msgArea[100];

void
#ifdef __STDC__
zzmpush( int m )
#else
zzmpush( m )
int m;
#endif
{
if(zzmdep == ZZMAXSTK - 1)
{ sprintf(msgArea, "Mode stack overflow ");
zzerr(msgArea);
}
else
{ zzmstk[zzmdep++] = zzauto;
zzmode(m);
}
}

void
zzmpop()
{
if(zzmdep == 0)
{ sprintf(msgArea, "Mode stack underflow ");
zzerr(msgArea);
}
else
{ zzmdep--;
zzmode(zzmstk[zzmdep]);
}
}

Page 69
-------------------------------------------------------------------------------
A modified version of the above routine which allows the user to pass a
a routine to be executed when the mode is popped from the stack.

When placed in a #lexaction or a separate file then the modifier "static"
must be dropped from the declaration of zzauto (line 61) in "dlgauto.h".
-------------------------------------------------------------------------------
#define ZZMAXSTK ????

static int zzmstk[ZZMAXSTK] = { -1 }; /* stack of DLG modes */
static void (*zzfuncstk[ZZMAXSTK])(); /* stack of pointer to functions */
static int zzmdep = 0;
static char msgArea[100];

void pushMode( int m ,void (*func)())
{
if(zzmdep == ZZMAXSTK - 1)
{ sprintf(msgArea, "Mode stack overflow ");
zzerr(msgArea);
}
else
{ zzmstk[zzmdep] = zzauto;
zzfuncstk[zzmdep] = func;
zzmdep++;
zzmode(m);
}
}

void popMode()
{
void (*thisFunc)();
if(zzmdep == 0)
{ sprintf(msgArea, "Mode stack underflow ");
zzerr(msgArea);
}
else
{ zzmdep--;
thisFunc=zzfuncstk[zzmdep];
zzmode(zzmstk[zzmdep]);
zzmstk[zzmdep]=0;
zzfuncstk[zzmdep]=0;
/* this call might result in indirect recursion of popMode() */
if (thisFunc!=0) {
(*thisFunc)();
};
}
}

void resetModeStack() {
zzmdep=0;
zzmstk[0]=0;
zzfuncstk[0]=0;
}

/* if the lookahead character is a semi-colon then keep on popping */

void popOnSC() {
if (zzchar==';') popMode();
}

Page 70
===============================================================================
Example 6: Debug code for create_ast, mk_ast, delete_ast to locate lost ASTs
===============================================================================
This is an example of code which tries to keep track of lost ASTs using
a doubly linked list of all ASTs maintained by calls from create_ast()
and mk_ast() to zzastnew_userhook(). When ASTs are deleted by calls
to zzastdelete_userhook() from the user's AST delete routines they are
removed from the doubly linked list. Any ASTs left over after zzfree_ast()
must be considered lost.

This method does not monitor ASTs created by zzdup_ast() because it does
not call the create_ast() or mk_ast() routines.
-------------------------------------------------------------------------------
The #header section must include a definition of AST_FIELDS with the
equivalent of:

struct _ast *flink, *blink;
-------------------------------------------------------------------------------
int main() {
...
again:
...
reset_ASTlistHead(); /* <======================== */
ANTLR (sourcecode(&root),stdin);
treewalk(root);
zzfree_ast(root);
root=NULL;
print_lost_ast(); /* <======================= */
printf ("\n");}
...
goto again;
...
}
-------------------------------------------------------------------------------
#ifndef H_ZZNEWAST_USERHOOK
#define H_ZZNEWAST_USERHOOK

void reset_ASTlistHead(void);
void zzunhook_tree(void);
void zzastnew_userhook(AST *newNode);
void zzastdelete_userhook (AST *singleNode);
void print_lost_ast (void);
void treewalk(AST *tree);

#endif
-------------------------------------------------------------------------------
#include "stdpccts.h"
#include "stdlib.h"
#include "zzastnew_userhook.h"

static AST ASTlistHead;
static int ASTserialNumber;

void reset_ASTlistHead(void) {
while (ASTlistHead.flink!=0 && ASTlistHead.flink!= &ASTlistHead) {
zzfree_ast(ASTlistHead.flink);
};
ASTlistHead.flink=&ASTlistHead;
ASTlistHead.blink=&ASTlistHead;
ASTserialNumber=1;
return;
}

Page 71
/* Stop tracking ASTs in a tree without actually deleting them */

void zzunhook_tree (AST * tree) {

while (tree != 0) {
zzunhook_tree (tree->down);
zzastdelete_userhook (tree);
tree=tree->right;
};
return;
}

/* Track new AST */

void zzastnew_userhook(AST *newNode) {

AST *prev;

prev=ASTlistHead.blink;
prev->flink=newNode;
ASTlistHead.blink=newNode;
newNode->blink=prev;
newNode->flink=&ASTlistHead;
newNode->serialNumber=ASTserialNumber;
ASTserialNumber++;
return;
}

/* Stop tracking an AST */

void zzastdelete_userhook (AST *singleNode) {

AST *fnode;
AST *bnode;

if (singleNode!=0) {
fnode=singleNode->flink;
bnode=singleNode->blink;
fnode->blink=bnode;
bnode->flink=fnode;
singleNode->serialNumber=0;
singleNode->flink=0;
singleNode->blink=0;
};
return;
}

/* Print ASTs that are still on list */

void print_lost_ast () {

AST *node;

for (node=ASTlistHead.flink;
node!=0 && node!= &ASTlistHead;
node=node->flink) {
printf ("**** Start of lost AST listing **** %d\n",node->serialNumber);
treewalk (node); /* user supplied routine */
printf ("\n**** End of lost AST listing ****\n");
};
}

Page 72
-------------------------------------------------------------------------------
These routines print out the AST tree. This will be application dependent.
-------------------------------------------------------------------------------
#include "stdpccts.h"
#include "stdlib.h"

static int treenest=0;

void treeindent(int nesting) {
int i;
for (i=0;i printf (" ");
};
return;
}

void treewalk1 (AST *tree) {
while (tree != NULL) {
treeindent(treenest);
printf ("%s",zztokens[tree->token]);
if (tree->text != NULL) {
printf (" %s",tree->text);
};
printf ("\n");
treenest++;
treewalk1 (tree->down);
treenest--;
tree=tree->right;
};
return;
}

void treewalk (AST *tree) {
treenest=0;
treewalk1(tree);
return;
}

Page 73
===============================================================================
Example 7: Difference Between Various Types of Lookahead in Antlr/DLG
===============================================================================
The following grammar with k=1 and standard lookahead is meant to show how
zzlextext and LATEXT(i) differ for the case k=1 and k=3 (see later
examples).

The use of LA(1) and LATEXT(1) in semantic predicates is OK, but their use
in actions is NOT recommended because, as the examples below show, there is
a variation in what LATEXT(1) means when it appears in an action.

Use attributes to refer to tokens already encountered.
-------------------------------------------------------------------------------
#header <<

#include "charbuf.h"

#define ZZCOL

>>

<<

/* Can't put quoted strings in semantic predicates in version 1.23 */

#define Semantic_Predicate_Of_1 "Semantic Predicate Of 1"

int AntlrCount=0;

int main() {
again: ANTLR (statement(),stdin);
return 0;
}

#define LANL(i) (*LATEXT(i) == '\n' ? "NL" : LATEXT(i))
#define LAINFNL(i) (*ZZINF_LATEXT(i) == '\n' ? "NL" : ZZINF_LATEXT(i))

void laDump(char * label) {
AntlrCount++;
printf ("\tRecognized: %s (AntlrCount=%d)\n",label,AntlrCount);
printf ("\tValue of zzbegcol: %d\n",zzbegcol);
printf ("\tLATEXT(0..1)={%s,%s}\n",
LANL(0),LANL(1));
printf ("\tzzlextext=%s\n",(zzlextext[0]=='\n' ? "NL" : zzlextext) );
#ifdef ZZINF_LOOK
printf ("\tZZINF_LATEXT(0..1)={%s,%s}\n",
LAINFNL(0),LAINFNL(1));
#endif
return;
}

>>

#lexaction <<

int DLGcount=0;

>>

Page 74
#token ID "[a-z]*"
< DLGcount,zzbegcol,zzlextext);>>
#token WS "[\ \t]*"
<>
#token NL "\n"
< DLGcount,zzbegcol);
zzendcol=0;
zzline++;>>

statement : (formats) * "@"

;formats
: format1
| format2

;format1 :
<<(laDump(Semantic_Predicate_Of_1),1)>>?
ID
<>
ID
<>
ID
<>
NL
< Format 1 After: ID ID ID NL");>>
;format2 :
ID ID ID;
-------------------------------------------------------------------------------
The input data file:
-------------------------------------------------------------------------------
a b c
d e f

Page 75
-------------------------------------------------------------------------------
The output from the standard and the interactive parser were identical in
this case.
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 3
LATEXT(0..1)={b,b}
zzlextext=b
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 5
LATEXT(0..1)={c,c}
zzlextext=c
DLGcount: 6 Col 6 NL
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 6
LATEXT(0..1)={NL,NL}
zzlextext=NL
DLGcount: 7 Col 1 ID=(d)
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
Recognized: Semantic Predicate Of 1 (AntlrCount=9)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
Recognized: Semantic Predicate Of 1 (AntlrCount=10)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
Recognized: After first ID of 1 (AntlrCount=11)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
DLGcount: 8 Col 2 WS


Page 76
-------------------------------------------------------------------------------
The same grammar and input file when compiled with -DZZINF_LOOK
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
DLGcount: 6 Col 6 NL
DLGcount: 7 Col 1 ID=(d)
DLGcount: 8 Col 2 WS
DLGcount: 9 Col 3 ID=(e)
DLGcount: 10 Col 4 WS
DLGcount: 11 Col 5 ID=(f)
DLGcount: 12 Col 6 NL
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
ZZINF_LATEXT(0..1)={a,b}
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
ZZINF_LATEXT(0..1)={a,b}
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
ZZINF_LATEXT(0..1)={a,b}
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
ZZINF_LATEXT(0..1)={a,b}
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 1
LATEXT(0..1)={b,b}
zzlextext=b
ZZINF_LATEXT(0..1)={b,c}
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 1
LATEXT(0..1)={c,c}
zzlextext=c
ZZINF_LATEXT(0..1)={c,NL}
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 1
LATEXT(0..1)={NL,NL}
zzlextext=NL
ZZINF_LATEXT(0..1)={NL,d}
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
ZZINF_LATEXT(0..1)={d,e}


Page 77
-------------------------------------------------------------------------------
The following grammar with k=3 is meant to show aspects of lookahead choices.
-------------------------------------------------------------------------------
#header <<

#include "charbuf.h"

#define ZZCOL

>>

<<

/* Can't put quoted strings in semantic predicates in version 1.23 */

#define Semantic_Predicate_Of_1 "Semantic Predicate Of 1"

int AntlrCount=0;

int main() {
again: ANTLR (statement(),stdin);
return 0;
}

#define LANL(i) (*LATEXT(i) == '\n' ? "NL" : LATEXT(i))
#define LAINFNL(i) (*ZZINF_LATEXT(i) == '\n' ? "NL" : ZZINF_LATEXT(i))

void laDump(char * label) {
AntlrCount++;
printf ("\tRecognized: %s (AntlrCount=%d)\n",label,AntlrCount);
printf ("\tValue of zzbegcol: %d\n",zzbegcol);
printf ("\tLATEXT(0..3)={%s,%s,%s,%s}\n",
LANL(0),LANL(1),LANL(2),LANL(3));
printf ("\tzzlextext=%s\n",(zzlextext[0]=='\n' ? "NL" : zzlextext) );
#ifdef ZZINF_LOOK
printf ("\tZZINF_LATEXT(0..3)={%s,%s,%s,%s}\n",
LAINFNL(0),LAINFNL(1),LAINFNL(2),LAINFNL(3));
#endif
return;
}

>>

#lexaction <<

int DLGcount=0;

>>

#token ID "[a-z]*"
< DLGcount,zzbegcol,zzlextext);>>
#token WS "[\ \t]*"
<>
#token NL "\n"
< DLGcount,zzbegcol);
zzendcol=0;
zzline++;>>

Page 78
statement : (formats) * "@"

;formats
: format1
| format2

;format1 :
<<(laDump(Semantic_Predicate_Of_1),1)>>?
ID
<>
ID
<>
ID
<>
NL
< Format 1 After: ID ID ID NL");>>
;format2 :
ID ID ID NL < Format 2: ID ID ID");>>
;
-------------------------------------------------------------------------------
The input data file:
-------------------------------------------------------------------------------
a b c
d e f

Page 79
-------------------------------------------------------------------------------
When built with version 1.23 and "standard" options: AFLAGS = -k 3
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
DLGcount: 6 Col 6 NL
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
DLGcount: 7 Col 1 ID=(d)
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 1
LATEXT(0..3)={d,b,c,NL}
zzlextext=b
DLGcount: 8 Col 2 WS
DLGcount: 9 Col 3 ID=(e)
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 3
LATEXT(0..3)={e,c,NL,d}
zzlextext=c
DLGcount: 10 Col 4 WS
DLGcount: 11 Col 5 ID=(f)
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 5
LATEXT(0..3)={f,NL,d,e}
zzlextext=NL
DLGcount: 12 Col 6 NL
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 6
LATEXT(0..3)={NL,d,e,f}
zzlextext=d
Recognized: Semantic Predicate Of 1 (AntlrCount=9)
Value of zzbegcol: 6
LATEXT(0..3)={NL,d,e,f}
zzlextext=d
Recognized: Semantic Predicate Of 1 (AntlrCount=10)
Value of zzbegcol: 6
LATEXT(0..3)={NL,d,e,f}
zzlextext=d
Recognized: After first ID of 1 (AntlrCount=11)
Value of zzbegcol: 6
LATEXT(0..3)={NL,d,e,f}
zzlextext=d


Page 80
-------------------------------------------------------------------------------
When built with version 1.23 and "interactive" options: AFLAGS = -k 3 -gk
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 1
LATEXT(0..3)={,a,,}
zzlextext=
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 5
LATEXT(0..3)={,a,b,c}
zzlextext=
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 5
LATEXT(0..3)={,a,b,c}
zzlextext=
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 5
LATEXT(0..3)={a,b,c,}
zzlextext=
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 5
LATEXT(0..3)={b,c,,a}
zzlextext=
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 5
LATEXT(0..3)={c,,a,b}
zzlextext=
DLGcount: 6 Col 6 NL
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
DLGcount: 7 Col 1 ID=(d)
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 1
LATEXT(0..3)={NL,d,b,c}
zzlextext=b
DLGcount: 8 Col 2 WS
DLGcount: 9 Col 3 ID=(e)
DLGcount: 10 Col 4 WS
DLGcount: 11 Col 5 ID=(f)
Recognized: Semantic Predicate Of 1 (AntlrCount=9)
Value of zzbegcol: 5
LATEXT(0..3)={NL,d,e,f}
zzlextext=NL
Recognized: Semantic Predicate Of 1 (AntlrCount=10)
Value of zzbegcol: 5
LATEXT(0..3)={NL,d,e,f}
zzlextext=NL
Recognized: After first ID of 1 (AntlrCount=11)
Value of zzbegcol: 5
LATEXT(0..3)={d,e,f,NL}
zzlextext=NL


Page 81
-------------------------------------------------------------------------------
When built with version 1.23 and infinite lookahead options:
AFLAGS = -k 3
CFLAGS = -DZZINF_LOOK
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
DLGcount: 6 Col 6 NL
DLGcount: 7 Col 1 ID=(d)
DLGcount: 8 Col 2 WS
DLGcount: 9 Col 3 ID=(e)
DLGcount: 10 Col 4 WS
DLGcount: 11 Col 5 ID=(f)
DLGcount: 12 Col 6 NL
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 1
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
ZZINF_LATEXT(0..3)={a,b,c,NL}
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 1
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
ZZINF_LATEXT(0..3)={a,b,c,NL}
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 1
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
ZZINF_LATEXT(0..3)={a,b,c,NL}
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 1
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
ZZINF_LATEXT(0..3)={a,b,c,NL}
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 1
LATEXT(0..3)={d,b,c,NL}
zzlextext=b
ZZINF_LATEXT(0..3)={b,c,NL,d}
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 1
LATEXT(0..3)={e,c,NL,d}
zzlextext=c
ZZINF_LATEXT(0..3)={c,NL,d,e}
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 1
LATEXT(0..3)={f,NL,d,e}
zzlextext=NL
ZZINF_LATEXT(0..3)={NL,d,e,f}
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 1
LATEXT(0..3)={NL,d,e,f}
zzlextext=d
ZZINF_LATEXT(0..3)={d,e,f,NL}


Page 82
===============================================================================
Example 8: Preserving whitespace during lexing
===============================================================================
The following program passes whitespace through DLG to the parser by
combining the whitespace with the token which follows it. It is up to the
user to determine how to handle the leading whitespace during attribute
and AST creation.

In this example whitespace ("#token WS") includes only the space character:
it does not include tab or newline. Maintaining accurate column
information when using zzmore() requires some extra work (as mentioned
in a note in the section on lexical issues.

The routines in "charbuf.h" assume that tokens are no longer than
"D_TextSize" characters. The value can be changed from its default value
of 30 by "#define D_TextSize ..." in the #header prior to the #include of
"charbuf.h".

It was built with k=1.
-------------------------------------------------------------------------------
#header <<

#include "charbuf.h"

#define ZZCOL

>>

<<

int AntlrCount=0;

int main() {
again: ANTLR (statement(),stdin);
return 0;
}

static char xlateBuf[100];

char * xlate (char * s) {
char * p=s;
char * q=xlateBuf;
if (*p == 0) {
*q='@';q++;
};
while (*p != 0) {
if (*p == ' ') {
*q='-';q++;
} else if (*p == '\t') {
*q='\\';q++;*q='t';q++;
} else if (*p == '\n') {
*q='\\';q++;*q='n';q++;
} else {
*q=*p;q++;
};
p++;
};
*q=0;
return (xlateBuf);
}

Page 83
void laDump(char * label) {
AntlrCount++;
printf ("\tRecognized: %s (AntlrCount=%d) ",label,AntlrCount);
printf ("zzlextext=(%s)\n",xlate(zzlextext));
return;
}

>>

#lexaction <<

int DLGcount=0;

>>

#token ID "[a-z]*"
< DLGcount,zzbegcol,zzlextext);>>
#token WS "[\ ]*"
< zzmore();>>
#token NL "\n"
< DLGcount,zzbegcol);
zzendcol=0;
zzline++;
>>

statement : (line) * "@"

;line : (ID <> ) * NL

;

Page 84
===============================================================================
Example 9: Passing column information through DLG using a kludge
===============================================================================
The following demonstrates a kludge which allows one to pass column
information through DLG for for use with attributes (or ASTs) even when
using modes with lookahead with LL_K>1 or using infinite lookahead
mode. This technique is probably not necessary with C++ mode.
-------------------------------------------------------------------------------
#header <<

#include "col_charbuf.h"

#define ZZCOL

#include "shiftr.h"

#define COL_BITS_PER_BYTE 6
#define COL_BITS_MASK ( (1 << COL_BITS_PER_BYTE) - 1 )

>>

<<

int main() {
again: ANTLR (statement(),stdin);
return 0;
}

void create_attr (Attrib *a,int tok,char *t) {
char * p;
char * q;
int i=0;

a->col=0;

for (p=t;*p != '\001' && *p != 0;p++) {
if (i < D_TextSize-1) {
a->text[i]=*p;
i++;
};
};

a->text[i]=0;

if (*p == '\001') {
a->col=p[1] & COL_BITS_MASK +
( (p[2] & COL_BITS_MASK) << COL_BITS_PER_BYTE );
};

printf ("create_attr: Col %d text=(%s)\n",a->col,a->text);
return;
}

>>

Page 85
#lexaction <<

int DLGcount=0;
char encodedCol[5];

void record() {
encodedCol[0]='\001';
encodedCol[1]=zzbegcol & COL_BITS_MASK;
encodedCol[2]=(zzbegcol SHIFTR COL_BITS_PER_BYTE) & COL_BITS_MASK;
encodedCol[4]=0;
/***
**** if (strlen(zzlextext) > ZZLEXBUFSIZE - sizeof(encodedCol) ) {...}
***/
strcat(zzlextext,encodedCol);
return;
}
>>

#token ID "[a-z A-Z 0-9]*"
< DLGcount,zzbegcol,zzlextext);record();>>
#token WS "[\ \t]*"
< DLGcount,zzbegcol);zzskip();>>
#token NL "\n"
< DLGcount,zzbegcol);
zzendcol=0;
zzline++;
zzskip();>>

statement : (formats) * "@" ;
formats : ( ID ) * NL ;
-------------------------------------------------------------------------------
File: col_charbuf.h
-------------------------------------------------------------------------------
#ifndef ZZCHARBUF_H
#define ZZCHARBUF_H

#include

#ifndef D_TextSize
#define D_TextSize 30

#endif

typedef struct {
char text[D_TextSize];
int col;
} Attrib;

void create_attr(Attrib *a,int tok,char *t);

#define zzcr_attr(a,tok,t) create_attr(a,tok,t)

#endif
-------------------------------------------------------------------------------
File: shiftr.h
-------------------------------------------------------------------------------
#ifndef SHIFTR
#define SHIFTR >>
#endif

Page 86
===============================================================================
Example 10: Use of #lexclass
===============================================================================
The user has a grammar in which an asterisk ("*") is normally used to indicate
multiplication. However, if "*" is the first token appearing in a statement
then it indicates a comment. Comments are terminated by a newline. Statements
are separated by semi-colons (";"). How does one use #lexclass to separate
the different lexical analysis required for comments and arithmetic
statements ?

For this example the recognized tokens have been reduced to identifiers and "*".

This code requires many #token actions to have the statement:

foundToken=1;

If this is inconvenient the user can modify dlgauto.h as outlined in
"Section on ANTLR/DLG Internals" to call a user-supplied routine (defined
inside the #lexaction) just after each call to the #token action routine.
-------------------------------------------------------------------------------
#header <<

#include "charbuf.h"

>>

<<
int main() {
again: ANTLR (program(),stdin);
return 0;
}
>>

#lexaction <<

int foundToken=0;

>>

#lexclass START

#token ID "[a-z A-Z]*" <>
#token SC ";" <>
#token WS "[\ \t]*" <>
#token NL "\n" <>
#token STAR "\*" < zzmode(LC_COMMENT);
zzmore();};
>>
#lexclass LC_COMMENT
#token COMMENT "~[\n]*" < zzmode(START);
>>
program : (statement) * "@"

;statement
: COMMENT <>
| (ID | STAR ) * SC <>
;

Page 87
===============================================================================
Example 11: Use of zzchar and #lexclass
===============================================================================
Consider the problem of distinguishing floating point numbers from
range expressions such as those used in Pascal:

range: 1..23
range: a..z
float: 1.23

As a first effort one might try:

#token ID "[a-z]*"
#token Int "[0-9]*"
#token Range ".."
#token Float "[0-9]*.[0-9]*"

The problem is that "1..23" looks like the floating point number "1." with
an illegal "." at the end. DLG always takes the longest matching string,
so "1." will always look more appetizing than "1". What one needs to do
is to look at the character following "1." to see if it is another ".",
and if it is to assume that it is a range expression. The flex lexer has
trailing context, but DLG doesn't - except for the single character in
zzchar.

A solution in DLG is to write the #token Float action routine to look
at what's been accepted and at zzchar in order to decide what to do:
------------------------------------------------------------------------
#header <<#include "int.h">>

#token Range ".."
#token Int "[0-9]*"
#token Float "[0-9]*.[0-9]*"
< zzchar == '.') {
NLA=Int;
zzmode(LC_Range);
};
>>
#token WS "\ " <>
#token NL "\n" <>

#lexclass LC_Range

// consume second "." of range token ("..") and return to normal mode

#token Range "." <>

<< int main() {
ANTLR (rule(),stdin);
}
>>
rule: ( Range <>
| Int <>
| Float <>
)*
;

Page 88
===============================================================================
Example 12: Rewriting a grammar so it be handled by Antlr
===============================================================================
The original grammar was in this form:

command := SET var BECOMES expr
| SET var BECOMES QUOTE QUOTE
| SET var BECOMES QUOTE expr QUOTE
| SET var BECOMES QUOTE command QUOTE

expr := QUOTE anyCharButQuote QUOTE
| expr AddOp expr
| expr MulOp expr

The repetition of "SET var BECOMES" for command would require k=4 to
get to the interesting part. The first step is to left-factor command:

command := SET var BECOMES
( expr
| QUOTE QUOTE
| QUOTE expr QUOTE
| QUOTE command QUOTE
)

The definition of expr uses left recursion which must be eliminated
when using Antlr:

op := AddOp
| MulOp

expr := QUOTE anyCharButQuote QUOTE (op expr)*

Since expr begins with QUOTE and all the alternatives of the sub-rule
of command also start with QUOTE this too can be left-factored:

command := SET var BECOMES QUOTE
( expr_suffix
| QUOTE
| expr QUOTE
| command QUOTE
)

expr_suffix := anyCharButQuote QUOTE (op expr)*
expr := QUOTE expr_suffix

The final grammar can be built by Antlr with k=2.

Page 89
#header <<#include "charbuf.h">>

<<
int main() {
ANTLR(repeat(),stdin);
return 0;
}
>>
#token Q "\""
#token SVB "svb"
#token Qbar "[a-z A-Z]*"
#token AddOp "\+"
#token MulOp "\*"
#token WS "\ " <>
#token NL "\n" <>

repeat : ( command )+ "@";
command : SVB Q ( expr_suffix
| expr Q
| Q <>

| command Q <>
);

expr_suffix : Qbar Q <>
{ op expr };
expr : Q expr_suffix;
op : AddOp | MulOp ;
-------------------------------------------------------------------------------
pccts/NOTES.visual.C++ 644 1377 31 10003 5655551641 7721 How to port PCCTS 1.10 (and 1.20 hopefully) to Visual C++

By

John Hall

Here is how to compile an ANTLR grammar in Visual C++. These steps
describe how to have your ANTLR grammar parse the input file the user
selects when they choose File Open in your Windows application. (Even
if you aren't using Visual C++, the steps should be portable enough to
other compilers.)

* Make sure that ANTLR and DLG generate ANSI code (use the -ga
switch).

* Set the following compiler flags in Visual C++ (these are in the
Memory Model category of the compiler options in the Project
Options menu):

FLAG MEANING
==== ==============================================================
/AL Large memory model (multiple data segments; data items must be
smaller than 64K).

/Gtn Allocates all items whose size is greater than or equal to n
in a new data segment. (I let n be 256: /Gt256.)

/Gx- All references to data items are done with far addressing in
case they are placed in a far segment.

* Add the following member variable to the attributes section of your
derived CDocument class (you will need to make sure you also
include stdio.h):

FILE *fp;

* Add the following method to your derived CDocument class:

BOOL CAppDoc::OnOpenDocument(const char* pszPathName)
{
// Call CDocument's OnOpenDocument to do housekeeping for us
// DON'T add anything to the loading section of Serialize
if (!CDocument::OnOpenDocument(pszPathName))
return FALSE;

// Open input file
if ((fp = fopen(pszPathName, "r")) == NULL)
return FALSE;

// Parse input file
ANTLR(start(), fp);

// Close input file
fclose(fp);
return TRUE;
}

(Note: additional code may be necessary, depending on your parser.
For example, if your parser uses PCCTS's symbol table library, you
will need to insert calls to zzs_init and zzs_done.)

* Compile the generated C files as C++ files. (I renamed the files
to have a .CPP extension to fool Visual C++ into thinking they were
C++ files. One might also use the /Tp switch, but that switch
requires you separately include the filename.) [I used this step
as an easy out for all the external linking errors I was getting
that I couldn't fix by declaring things extern "C".]

* Make sure the __STDC__ portion of the generated files gets
compiled. (Either define __STDC__ yourself or else change all
occurrences of __STDC__ to __cplusplus in the generated files. You
can define __STDC__ in the Preprocessor category of the compiler
options.)

That last step is important for Visual C++, but may not apply to other
compilers. For C++ compilers, whether __STDC__ is defined is
implementation dependent (ARM, page 379). Apparently, Visual C++ does
not to define it; it also does not support "old style" C function
definitions (which is okay, according to page 404 of the ARM). Those
two things together caused problems when trying to port the code.
When it saw this:

#ifdef __STDC__
void
globals(AST **_root)
#else
globals(_root)
AST **_root;
#endif

it skipped the __STDC__ section and tried to process the "old style"
function definition, where it choked.

When you finally get your parser to compile and link without error,
you may get General Protection Fault errors at run time. The problem
I had was that a NULL was passed to a variable argument function
without an explicit cast. The function grabbed a pointer (32-bits)
off the stack using va_arg, but the NULL was passed silently as the
integer 0 (16 bits), making the resulting pointer was invalid. (This
was in PCCTS's sample C parser.)

There is one other thing I might suggest to help you avoid a run-time
error. Make sure you redefine the default error reporting function,
zzsyn. To do this, put "#define USER_ZZSYN" in your #header section
and put your own zzsyn somewhere. You can then pop up a MessageBox or
print the error to some output window.

ls" to call a user-supplied routine (defined
inside the #lexaction) just after each call to the #token action routine.
-------------------------------------------------------------------------------
#header <<

#include "charbuf.h"

>>

<<
int main() {
again: ANTLR (program(),stdin);
return 0;
}
>>

#lexaction <<

int foundToken=0;

>>

#lexclass START

#token ID "[a-z A-Z]*" <>
#token SC ";" <>
#token WS "[\ \t]*" <
Terence Parr
Parr Research Corporation
5517 Pleasant Ave
Minneapolis MN 55419
[email protected]
612 825-1901

Joe/Jane PCCTS user
1 Easy Street
World At Large

Dear PCCTS user,

As the primary author of the tools in the Purdue Compiler Construction
Tool Set (PCCTS), it has been mainly my responsibility to design,
develop, and maintain these public-domain tools. To support myself, I
have been doing translation work for the Army High Performance
Computer Research Center as a postdoctoral fellow. Unfortunately, it
has become increasingly difficult to satisfy both my employers and the
PCCTS community; moreover, funding for my fellowship has been reduced.

As of August 1, 1994 I plan to leave academia for the private sector
so that I may more fully support PCCTS. Parr Research Corporation
will continue to provide all tools, that are currently in the
public-domain, totally free of charge and without copyright
restrictions; i.e., ANTLR, DLG, and SORCERER. My goal is to foster
growth in the PCCTS community---I am committed to providing
sophisticated language tools.

As the corporation grows, I hope to provide real documentation (in the
form of a book), a graphical user interface for developing and
debugging large language applications, and better user support (via a
``help'' line).

To support the corporation (and the development of PCCTS), I will rely
on consulting fees, seminar fees, contract work, and ``maintenance
contracts'' with industrial affiliates. Pursuant to this, if you would
be interested in having Parr Research perform one of these services
for you or would just like to talk about the possibility, please
contact me via email, phone, or normal mail. Parr Research would also
like to form ``strategic partner'' relationships with other organizations.

Thanks for your interest in PCCTS. May your troubles be few and your
programs bug-free.

Best Regards,

Terence Parr


BOOL CAppDoc::OnOpenDocument(const char* pszPathName)
{
// Call CDocument's OnOpenDocument to do housekeeping for us
// DON'T add anything to the loading section of Serialize
if (pccts/README 644 1377 31 15531 5655551640 6167
Welcome to PCCTS 1.30

November 1, 1994


Parr Research Corporation
with
Purdue University Electrical Engineering
and
University of Minnesota, AHPCRC

Terence Parr
Russell Quong
Will Cohen
Hank Dietz


INSTALLATION

This document describes the installation of PCCTS 1.30 on UNIX
and non-UNIX machines. The UNIX installation is trivial while the
non-UNIX folks have a bit more work to do as an install script
explicitly for there machine will not exist--they will have to
interpret the install script.

PCCTS 1.30 includes a number of different programs and examples
in the software release package -- most of which like to live in their
own directories. The install script will build a standard hierarchy.
Or, if you get the tar file off the ftp site, the hierarchy will be
constructed automatically by tar.

The PCCTS executables (antlr, dlg) may be placed anywhere the user
wishes but the install script places them in the bin directory created
during installation.

1.0. UNIX USERS

This section is for UNIX users and describes the most convenient
installation procedure.

1.1. FORMAT: pccts.tar

To begin installation, place the pccts.tar file into the directory
where you want to place a pccts subdirectory. Untar the file with

tar xvf pccts.tar

and cd into it. To install PCCTS, simply type

make

which will build the standard PCCTS directory hierarchy (under the
directory where you ran the install script) and build executable
versions of antlr and dlg.

1.2. FORMAT: pccts.bag

To begin installation, the user should create a directory (usually
called pccts) where the PCCTS source subtree is to be created. Place
the pccts.bag file and the install script into this directory and cd
into it. To install PCCTS, simply type

sh install

which will build the standard PCCTS directory hierarchy (under the
directory where you ran the install script), "unbag" all of the files
and build executable versions of antlr and dlg.

If you do not have the 'sh' shell, you'll need the install.unbag.reqd
file.

2.0. NON-UNIX USERS

ANTLR was written using portable (we hope), vanilla K&R-style C,
ANSI C, and C++. It has been successfully ported to a variety of
environments. We do not provide an installation script explicitly for
non-Unix users. You must interpret the install script and perform the
analogous operations on your machine. There is an install script,
install.mpw, for Macintosh programmers.

IMPORTANT NOTE: For PC users: You must create the parser.dlg and
"touch" scan.c in antlr and dlg directories or the
makefiles will try to execute antlr and dlg, which
don't exist yet. The first time, you want only to
compile the C files in order to obtain an executable
for antlr and dlg. From this point, a change in
antlr.g or dlg_p.g will force antlr/dlg to regenerate
themselves.

You must define symbol PC if you want things to work
out right for use on a DOS, OS/2, Windows machine.
This affects the config.h file, which you can change
as you wish.

For Mac programmers using MPW (Macintosh Programmer's Workshop),
define symbol MPW to get the correct config.h stuff included.

3.0. EMAIL VERSION RECIPIENTS

If you received PCCTS via email response from
[email protected] you have one additional installation step to
perform over the ftp folks (and pccts.tar is unavailable). You will
have received a number of bite-size chunks of pccts which are small
enough to be emailed (~1500 lines each). You must reconstruct the
PCCTS files before you can begin installation. In order to rebuild an
original file, you must have "one.c" which will take the chunks and
pack them together. If you are a non-UNIX type, you must have the
"unbag.c" file which unbags the bags created by our mail archiver.
UNIX folks use the shell to unbag as they would for shar files (this
will be done automatically by the install script).

To install PCCTS, place all PCCTS mail messages into a pccts
directory, remove the mail headers from one.c. Then compile one.c
with:

cc -o one one.c

and then type:

./one f1 f2 ... fn

where f1..fn are the parts of PCCTS source sent as chunks (i.e. these
files will be all the files you received NOT including one.c, unbag.c,
README, install and the request acknowledge banner). There is no need
to remove mail headers from the chunk files and they may appear in any
order. The subject line of the mail will identify it as a chunk and a
chunk of what file. The "one" program should be used to put pccts.bag
back together. You are now in a position to begin normal PCCTS
installation. All files you receive should go into a pccts directory.

Note that all files which arrive in "chunks" must be put back
together using "one". Beware that you do not mix chunks from more
than one original file. For instance, do not specify all chunks that
you collect from the PCCTS mailbot on the "one" command line unless
you have requested only one original file that was split into multiple
files. Each chunk knows which original file it is a part of, where it
goes in that file and how many total chunks are required to rebuild
that original.

4.0. WORD SIZE AND PC USERS

The config.h file now sets up the word size for your compiler
automatically.


TUTORIAL

The advanced tutorial should be placed in a directory at the
same level as antlr, dlg, support etc... Do a

sh advtut.bag

to unbag (or use the unbag program) and then type

make -s all

which will create executables called tut1-tut4. Naturally, if you got
the tutorials from the ftp site, the tar format of the tutorials can
be obtained for easier installation.

Unfortunately, the tutorials have changed little since the 1.06
release. With luck, these will be enhanced and an AST tutorial will
appear.

NEW FEATURES

o Element labels

o Parser exception handling


MACHINE COMPATIBILITY

PCCTS is known to compile "out of the box" on the following machines
and/or operating systems: [didn't have time to retest on all these
machines, but seems to be highly portable still].

o DECSTATION 5000

o SGI, Running IRIX 4.0.5

o Sun SparcStation (cc, gcc, g++, Cfront, acc)

o VAX C under VMS

o Linux SLS 0.99, gcc/g++

o 386 PC, NetBSD 0.9, gcc 2.4.5

o HP 9000/755, HP-UX 9.01, HP cc

o 486 PC, OS/2 2.1 (w/long filenames), IBM C Set++ 2.1


INCOMPATIBILITIES

Please see the release notes.


CREDITS

Please see the history.ps or history.txt.
l script.

PCCTS 1.30 includes a number of different programs and examples
in the software release package -- most of which like to live in their
own directories.pccts/RIGHTS 644 1377 31 2163 5655551672 6214
SOFTWARE RIGHTS

We reserve no LEGAL rights to the Purdue Compiler Construction Tool
Set (PCCTS) -- PCCTS is in the public domain. An individual or
company may do whatever they wish with source code distributed with
PCCTS or the code generated by PCCTS, including the incorporation of
PCCTS, or its output, into commerical software.

We encourage users to develop software with PCCTS. However, we do ask
that credit is given to us for developing PCCTS. By "credit", we mean
that if you incorporate our source code into one of your programs
(commercial product, research project, or otherwise) that you
acknowledge this fact somewhere in the documentation, research report,
etc... If you like PCCTS and have developed a nice tool with the
output, please mention that you developed it using PCCTS. In
addition, we ask that this header remain intact in our source code.
As long as these guidelines are kept, we expect to continue enhancing
this system and expect to make other tools available as they are
completed.

ANTLR 1.30
Terence Parr
Parr Research Corporation
with Purdue University and AHPCRC, University of Minnesota
1989-1994
ill be
constructed automatically by tar.

The PCCTS executables (antlr, dlg) may be placed anywhere the user
wishes but the install script places them in the bin directory created
during installation.

1.0. UNIX USERS

This section is for UNIX users and describes the most convenient
installation procedure.

1.1. FORMAT: pccts.tar

To begin installation, place the pccts.tar file into the pccts/UPDAT106.ps 644 1377 31 237761 5655551664 7020 %!PS-Adobe-1.0
%%Creator: bug.ecn.purdue.edu:pccts (Purdue Compiler-Construction Tool Set,,,,Ex;ee;hankd;)
%%Title: stdin (ditroff)
%%CreationDate: Mon Dec 7 17:34:40 1992
%%EndComments
% Start of psdit.pro -- prolog for ditroff translator
% Copyright (c) 1985,1987 Adobe Systems Incorporated. All Rights Reserved.
% GOVERNMENT END USERS: See Notice file in TranScript library directory
% -- probably /usr/lib/ps/Notice
% RCS: $Header: /home/aquarium/prm/usr/src/usr.lib/ps/lib/RCS/psdit.pro,v 1.2 89/02/24 09:57:06 prm Exp $
/$DITroff 180 dict def $DITroff begin
%% Psfig additions

/DocumentInitState [ matrix currentmatrix currentlinewidth currentlinecap
currentlinejoin currentdash currentgray currentmiterlimit ] cvx def

/startFig {
/SavedState save def
userdict maxlength dict begin
currentpoint transform

DocumentInitState setmiterlimit setgray setdash setlinejoin setlinecap
setlinewidth setmatrix

itransform moveto

/ury exch def
/urx exch def
/lly exch def
/llx exch def
/y exch 72 mul resolution div def
/x exch 72 mul resolution div def

currentpoint /cy exch def /cx exch def

/sx x urx llx sub div def % scaling for x
/sy y ury lly sub div def % scaling for y

sx sy scale % scale by (sx,sy)

cx sx div llx sub
cy sy div ury sub translate

/DefFigCTM matrix currentmatrix def

/initmatrix {
DefFigCTM setmatrix
} def
/defaultmatrix {
DefFigCTM exch copy
} def

/initgraphics {
DocumentInitState setmiterlimit setgray setdash
setlinejoin setlinecap setlinewidth setmatrix
DefFigCTM setmatrix
} def

/showpage {
initgraphics
} def

} def
% Args are llx lly urx ury (in figure coordinates)
/clipFig {
currentpoint 6 2 roll
newpath 4 copy
4 2 roll moveto
6 -1 roll exch lineto
exch lineto
exch lineto
closepath clip
newpath
moveto
} def
% doclip, if called, will always be just after a `startfig'
/doclip { llx lly urx ury clipFig } def
/endFig {
end SavedState restore
} def
/globalstart {
% Push details about the enviornment on the stack.
fontnum fontsize fontslant fontheight firstpage
mh my resolution slotno currentpoint
pagesave restore gsave
} def
/globalend {
grestore moveto
/slotno exch def /resolution exch def /my exch def
/mh exch def /firstpage exch def /fontheight exch def
/fontslant exch def /fontsize exch def /fontnum exch def
F
/pagesave save def
} def

%% end XMOD additions
/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def
/xi {0 72 11 mul translate 72 resolution div dup neg scale 0 0 moveto
/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def F
/pagesave save def}def
/PB{save /psv exch def currentpoint translate
resolution 72 div dup neg scale 0 0 moveto}def
/PE{psv restore}def
/m1 matrix def /m2 matrix def /m3 matrix def /oldmat matrix def
/tan{dup sin exch cos div}bind def
/point{resolution 72 div mul}bind def
/dround {transform round exch round exch itransform}bind def
/xT{/devname exch def}def
/xr{/mh exch def /my exch def /resolution exch def}def
/xp{}def
/xs{docsave restore end}def
/xt{}def
/xf{/fontname exch def /slotno exch def fontnames slotno get fontname eq not
{fonts slotno fontname findfont put fontnames slotno fontname put}if}def
/xH{/fontheight exch def F}bind def
/xS{/fontslant exch def F}bind def
/s{/fontsize exch def /fontheight fontsize def F}bind def
/f{/fontnum exch def F}bind def
/F{fontheight 0 le {/fontheight fontsize def}if
fonts fontnum get fontsize point 0 0 fontheight point neg 0 0 m1 astore
fontslant 0 ne{1 0 fontslant tan 1 0 0 m2 astore m3 concatmatrix}if
makefont setfont .04 fontsize point mul 0 dround pop setlinewidth}bind def
/X{exch currentpoint exch pop moveto show}bind def
/N{3 1 roll moveto show}bind def
/Y{exch currentpoint pop exch moveto show}bind def
/S /show load def
/ditpush{}def/ditpop{}def
/AX{3 -1 roll currentpoint exch pop moveto 0 exch ashow}bind def
/AN{4 2 roll moveto 0 exch ashow}bind def
/AY{3 -1 roll currentpoint pop exch moveto 0 exch ashow}bind def
/AS{0 exch ashow}bind def
/MX{currentpoint exch pop moveto}bind def
/MY{currentpoint pop exch moveto}bind def
/MXY /moveto load def
/cb{pop}def % action on unknown char -- nothing for now
/n{}def/w{}def
/p{pop showpage pagesave restore /pagesave save def}def
/abspoint{currentpoint exch pop add exch currentpoint pop add exch}def
/dstroke{currentpoint stroke moveto}bind def
/Dl{2 copy 2 copy gsave 0 eq exch 0 eq and
{rlineto currentlinecap 1 setlinecap stroke setlinecap}
{rlineto stroke}
ifelse grestore rmoveto}bind def
/arcellipse{oldmat currentmatrix pop
currentpoint translate 1 diamv diamh div scale /rad diamh 2 div def
rad 0 rad -180 180 arc oldmat setmatrix}def
/Dc{gsave dup /diamv exch def /diamh exch def arcellipse dstroke
grestore diamh 0 rmoveto}def
/De{gsave /diamv exch def /diamh exch def arcellipse dstroke
grestore diamh 0 rmoveto}def
/Da{currentpoint /by exch def /bx exch def /fy exch def /fx exch def
/cy exch def /cx exch def /rad cx cx mul cy cy mul add sqrt def
/ang1 cy neg cx neg atan def /ang2 fy fx atan def cx bx add cy by add
2 copy rad ang1 ang2 arcn stroke exch fx add exch fy add moveto}def
/Barray 200 array def % 200 values in a wiggle
/D~{mark}def
/D~~{counttomark Barray exch 0 exch getinterval astore /Bcontrol exch def pop
/Blen Bcontrol length def Blen 4 ge Blen 2 mod 0 eq and
{Bcontrol 0 get Bcontrol 1 get abspoint /Ycont exch def /Xcont exch def
Bcontrol 0 2 copy get 2 mul put Bcontrol 1 2 copy get 2 mul put
Bcontrol Blen 2 sub 2 copy get 2 mul put
Bcontrol Blen 1 sub 2 copy get 2 mul put
/Ybi /Xbi currentpoint 3 1 roll def def 0 2 Blen 4 sub
{/i exch def
Bcontrol i get 3 div Bcontrol i 1 add get 3 div
Bcontrol i get 3 mul Bcontrol i 2 add get add 6 div
Bcontrol i 1 add get 3 mul Bcontrol i 3 add get add 6 div
/Xbi Xcont Bcontrol i 2 add get 2 div add def
/Ybi Ycont Bcontrol i 3 add get 2 div add def
/Xcont Xcont Bcontrol i 2 add get add def
/Ycont Ycont Bcontrol i 3 add get add def
Xbi currentpoint pop sub Ybi currentpoint exch pop sub rcurveto
}for dstroke}if}def
end
/ditstart{$DITroff begin
/nfonts 60 def % NFONTS makedev/ditroff dependent!
/fonts[nfonts{0}repeat]def
/fontnames[nfonts{()}repeat]def
/docsave save def
}def

% character outcalls
/oc {/pswid exch def /cc exch def /name exch def
/ditwid pswid fontsize mul resolution mul 72000 div def
/ditsiz fontsize resolution mul 72 div def
ocprocs name known{ocprocs name get exec}{name cb}
ifelse}def
/fractm [.65 0 0 .6 0 0] def
/fraction
{/fden exch def /fnum exch def gsave /cf currentfont def
cf fractm makefont setfont 0 .3 dm 2 copy neg rmoveto
fnum show rmoveto currentfont cf setfont(\244)show setfont fden show
grestore ditwid 0 rmoveto} def
/oce {grestore ditwid 0 rmoveto}def
/dm {ditsiz mul}def
/ocprocs 50 dict def ocprocs begin
(14){(1)(4)fraction}def
(12){(1)(2)fraction}def
(34){(3)(4)fraction}def
(13){(1)(3)fraction}def
(23){(2)(3)fraction}def
(18){(1)(8)fraction}def
(38){(3)(8)fraction}def
(58){(5)(8)fraction}def
(78){(7)(8)fraction}def
(sr){gsave .05 dm .16 dm rmoveto(\326)show oce}def
(is){gsave 0 .15 dm rmoveto(\362)show oce}def
(->){gsave 0 .02 dm rmoveto(\256)show oce}def
(<-){gsave 0 .02 dm rmoveto(\254)show oce}def
(==){gsave 0 .05 dm rmoveto(\272)show oce}def
end
% DIThacks fonts for some special chars
50 dict dup begin
/FontType 3 def
/FontName /DIThacks def
/FontMatrix [.001 0.0 0.0 .001 0.0 0.0] def
/FontBBox [-220 -280 900 900] def% a lie but ...
/Encoding 256 array def
0 1 255{Encoding exch /.notdef put}for
Encoding
dup 8#040/space put %space
dup 8#110/rc put %right ceil
dup 8#111/lt put %left top curl
dup 8#112/bv put %bold vert
dup 8#113/lk put %left mid curl
dup 8#114/lb put %left bot curl
dup 8#115/rt put %right top curl
dup 8#116/rk put %right mid curl
dup 8#117/rb put %right bot curl
dup 8#120/rf put %right floor
dup 8#121/lf put %left floor
dup 8#122/lc put %left ceil
dup 8#140/sq put %square
dup 8#141/bx put %box
dup 8#142/ci put %circle
dup 8#143/br put %box rule
dup 8#144/rn put %root extender
dup 8#145/vr put %vertical rule
dup 8#146/ob put %outline bullet
dup 8#147/bu put %bullet
dup 8#150/ru put %rule
dup 8#151/ul put %underline
pop
/DITfd 100 dict def
/BuildChar{0 begin
/cc exch def /fd exch def
/charname fd /Encoding get cc get def
/charwid fd /Metrics get charname get def
/charproc fd /CharProcs get charname get def
charwid 0 fd /FontBBox get aload pop setcachedevice
40 setlinewidth
newpath 0 0 moveto gsave charproc grestore
end}def
/BuildChar load 0 DITfd put
%/UniqueID 5 def
/CharProcs 50 dict def
CharProcs begin
/space{}def
/.notdef{}def
/ru{500 0 rls}def
/rn{0 750 moveto 500 0 rls}def
/vr{20 800 moveto 0 -770 rls}def
/bv{20 800 moveto 0 -1000 rls}def
/br{20 770 moveto 0 -1040 rls}def
/ul{0 -250 moveto 500 0 rls}def
/ob{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath stroke}def
/bu{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath fill}def
/sq{80 0 rmoveto currentpoint dround newpath moveto
640 0 rlineto 0 640 rlineto -640 0 rlineto closepath stroke}def
/bx{80 0 rmoveto currentpoint dround newpath moveto
640 0 rlineto 0 640 rlineto -640 0 rlineto closepath fill}def
/ci{355 333 rmoveto currentpoint newpath 333 0 360 arc
50 setlinewidth stroke}def

/lt{20 -200 moveto 0 550 rlineto currx 800 2cx s4 add exch s4 a4p stroke}def
/lb{20 800 moveto 0 -550 rlineto currx -200 2cx s4 add exch s4 a4p stroke}def
/rt{20 -200 moveto 0 550 rlineto currx 800 2cx s4 sub exch s4 a4p stroke}def
/rb{20 800 moveto 0 -500 rlineto currx -200 2cx s4 sub exch s4 a4p stroke}def
/lk{20 800 moveto 20 300 -280 300 s4 arcto pop pop 1000 sub
currentpoint stroke moveto
20 300 4 2 roll s4 a4p 20 -200 lineto stroke}def
/rk{20 800 moveto 20 300 320 300 s4 arcto pop pop 1000 sub
currentpoint stroke moveto
20 300 4 2 roll s4 a4p 20 -200 lineto stroke}def
/lf{20 800 moveto 0 -1000 rlineto s4 0 rls}def
/rf{20 800 moveto 0 -1000 rlineto s4 neg 0 rls}def
/lc{20 -200 moveto 0 1000 rlineto s4 0 rls}def
/rc{20 -200 moveto 0 1000 rlineto s4 neg 0 rls}def
end

/Metrics 50 dict def Metrics begin
/.notdef 0 def
/space 500 def
/ru 500 def
/br 0 def
/lt 250 def
/lb 250 def
/rt 250 def
/rb 250 def
/lk 250 def
/rk 250 def
/rc 250 def
/lc 250 def
/rf 250 def
/lf 250 def
/bv 250 def
/ob 350 def
/bu 350 def
/ci 750 def
/bx 750 def
/sq 750 def
/rn 500 def
/ul 500 def
/vr 0 def
end

DITfd begin
/s2 500 def /s4 250 def /s3 333 def
/a4p{arcto pop pop pop pop}def
/2cx{2 copy exch}def
/rls{rlineto stroke}def
/currx{currentpoint pop}def
/dround{transform round exch round exch itransform} def
end
end
/DIThacks exch definefont pop

ditstart
(psc)xT
576 1 1 xr
1(Times-Roman)xf 1 f
2(Times-Italic)xf 2 f
3(Times-Bold)xf 3 f
4(Times-BoldItalic)xf 4 f
5(Helvetica)xf 5 f
6(Helvetica-Bold)xf 6 f
7(Courier)xf 7 f
8(Courier-Bold)xf 8 f
9(Symbol)xf 9 f
10(DIThacks)xf 10 f
10 s
1 f
xi
%%EndProlog

%%Page: 1 1
10 s 0 xH 0 xS 1 f
8 s
15 s
1237 704(The)N
1453(Purdue)X
1823(Compiler)X
2308(Construction)X
2960(Tool)X
3217(Set)X
13 s
1872 960(Version)N
2228(1.06)X
2436(Update)X
2 f
11 s
1981 1216(December)N
2363(1,)X
2451(1992)X
3 f
576 1600(1.)N
686(Enhancements)X
1 f
776 1756(This)N
961(section)X
1239(describes)X
1594(the)X
1730(update)X
1993(of)X
2094(PCCTS)X
2392(Version)X
2698(1.00)X
2880(to)X
2977(Version)X
3284(1.06)X
3467(\(1.01-1.05)X
3862(were)X
576 1884(internal)N
873(releases\).)X
1251(The)X
1415(list)X
1551(of)X
1651(changes)X
1961(here)X
2139(is)X
2225(not)X
2365(complete)X
2716(since)X
2924(many)X
3147(``little'')X
3453(\256xes)X
3645(were)X
3841(made)X
576 2012(\(actually,)N
933(the)X
1067(predicated)X
1460(parsing)X
1745(feature)X
2015(is)X
2100(major\).)X
2406(Here,)X
2625(we)X
2754(concentrate)X
3187(on)X
3302(the)X
3437(enhancements)X
3963(to)X
576 2140(the)N
716(system;)X
1018(\256le)X
7 f
1194(BUGS100)X
1 f
1597(contains)X
1923(a)X
1994(list)X
2135(of)X
2240(the)X
2380(bug)X
2543(\256xes)X
2740(incorporated)X
3216(in)X
3316(the)X
3455(1.06)X
3640(release.)X
3959(In)X
576 2268(addition,)N
916(note)X
1096(that)X
1257(the)X
1393(manual)X
1681(has)X
1826(not)X
1967(been)X
2161(updated)X
2468(and)X
2623(will)X
2789(not)X
2931(be)X
3043(until)X
3235(the)X
3372(next)X
3553(major)X
3788(release)X
576 2396(\(or)N
700(until)X
885(we)X
1009(get)X
1139(around)X
1405(to)X
1496(it\).)X
3 f
576 2652(1.1.)N
752(Predicated)X
1180(Parsing)X
1491(\320)X
1601(ALPHA)X
1931(Version)X
1 f
776 2808(Normally,)N
1158(parsing)X
1439(is)X
1520(a)X
1582(function)X
1899(of)X
1995(syntax)X
2248(alone.)X
2506(Semantics)X
2892(\(meaning/value)X
3464(of)X
3560(the)X
3691(input\))X
3925(are)X
576 2936(not)N
738(taken)X
978(into)X
1165(account)X
1488(when)X
1727(parsing)X
2035(decisions)X
2412(are)X
2568(made\320context-free)X
3320(parsing.)X
3671(Typically,)X
576 3064(languages,)N
973(such)X
1157(as)X
1253(C++,)X
1457(have)X
1646(some)X
1855(rules)X
2049(which)X
2287(require)X
2559(the)X
2690(lexical)X
2949(analyzer)X
3270(to)X
3362(consult)X
3640(the)X
3772(symbol)X
576 3192(table)N
779(to)X
879(determine)X
1263(what)X
1465(token)X
1691(\(e.g.)X
1877(classname)X
2269(verses)X
2518(enumerated)X
2959(name)X
3180(verses)X
3429(typedef)X
3723(name\))X
3973(is)X
576 3320(given)N
802(to)X
901(the)X
1039(parser.)X
1327(However,)X
1700(lexical)X
1966(analyzers)X
2328(have)X
2525(no)X
2644(context)X
2935(information)X
3383(except)X
3644(the)X
3783(current)X
576 3448(token)N
811(of)X
923(lookahead)X
1324(and)X
1490(must)X
1701(be)X
1823(coerced)X
2135(via)X
2282(\257ags)X
2487(to)X
2595(yield)X
2811(the)X
2958(various)X
3256(token)X
3491(types.)X
3760(Ad)X
3905(hoc)X
576 3576(approaches)N
995(become)X
1293(increasingly)X
1748(dif\256cult)X
2052(to)X
2145(implement)X
2549(as)X
2647(the)X
2780(number)X
3074(of)X
3172(ambiguities)X
3610(\(due)X
3791(to)X
3885(lack)X
576 3704(of)N
671(semantic)X
1007(information\))X
1475(in)X
1566(a)X
1627(grammar)X
1967(rises.)X
776 3860(Context)N
1080(dictates)X
1374(the)X
1506(scope)X
1730(of)X
1827(variables)X
2169(in)X
2262(programming)X
2766(languages.)X
3186(Because)X
3503(only)X
3685(the)X
3818(parser)X
576 3988(has)N
718(context)X
1003(information,)X
1467(it)X
1542(is)X
1626(reasonable)X
2027(to)X
2121(assume)X
2405(that)X
2563(the)X
2696(parser)X
2935(is)X
3019(the)X
3151(correct)X
3419(place)X
3629(to)X
3722(maintain)X
576 4116(and)N
727(access)X
975(the)X
1107(symbol)X
1391(table;)X
1612(there)X
1812(are)X
1943(other)X
2148(situtations)X
2536(in)X
2629(which)X
2868(it)X
2942(is)X
3025(useful)X
3264(to)X
3357(have)X
3547(context)X
3831(direct)X
576 4244(parsing.)N
914(Unfortunately,)X
1465(most)X
1672(parser)X
1921(generators)X
2322(do)X
2445(not)X
2593(allow)X
2824(grammar)X
3177(actions)X
3462(to)X
3566(in\257uence)X
3924(the)X
576 4372(parse;)N
822(i.e.)X
966(parsing)X
1261(is)X
1356(a)X
1431(function)X
1762(of)X
1872(syntax)X
2139(alone.)X
2411(Because)X
2741(PCCTS)X
3048(generates)X
3417(recursive-descent)X
576 4500(LL\(k\))N
813(parsers)X
1088(in)X
1184(C,)X
1292(allowing)X
1628(user-de\256ned)X
2089(C)X
2175(actions)X
2452(to)X
2548(in\257uence)X
2898(parsing)X
3184(is)X
3270(a)X
3336(straightforward)X
3905(and)X
576 4628(natural)N
843(addition)X
1155(to)X
1246(the)X
1376(PCCTS)X
1669(description)X
2084(meta-language.)X
2670(Although)X
3026(bottom-up)X
3417(parsing)X
3699(strategies)X
576 4756(can)N
729(allow)X
956(actions)X
1237(to)X
1337(direct)X
1569(parsing,)X
1881(bottom-up)X
2280(parser)X
2524(have)X
2720(much)X
2946(less)X
3108(semantic)X
3452(information;)X
3924(i.e.)X
576 4884(LR)N
729(and)X
897(LALR)X
1168(techniques)X
1586(allow)X
1823(only)X
2 f
2021(S)X
1 f
(-attributed)S
2474(grammars)X
2867(whereas)X
3195(LL)X
3344(allows)X
2 f
3615(L)X
1 f
3664(-attributed)X
576 5012(grammars)N
968(\(for)X
1139(example,)X
1500(LL)X
1648(always)X
1932(knows)X
2201(which)X
2455(set)X
2592(of)X
2704(rules)X
2914(it)X
3003(is)X
3101(currently)X
3458(trying)X
3708(to)X
3816(match)X
576 5140(whereas)N
885(LALR)X
1137(does)X
1320(not,)X
1477(in)X
1568(general;)X
1874(see)X
2008(your)X
2191(favorite)X
2487(book)X
2685(on)X
2795(parsing)X
3076(theory\).)X
776 5296(In)N
871(this)X
1021(section,)X
1315(we)X
1439(introduce)X
1794(a)X
1855(rudimentary)X
2308(version)X
2590(of)X
2686(predicates,)X
3088(with)X
3268(a)X
3330(full)X
3476 0.2885(implementation)AX
576 5424(to)N
683(appear)X
955(in)X
1062(future)X
1310(releases.)X
1670(To)X
1806(support)X
2108(context-sensitive)X
2744(parsing)X
3041(PCCTS)X
3349(1.06)X
3541(allows)X
3809(a)X
3886(new)X
576 5552(action)N
814(type)X
988(called)X
2 f
1221(predicate)X
1 f
1576(\()X
7 f
1605(-pr)X
1 f
1786(must)X
1980(be)X
2085(used\),)X
2319(which)X
2556(is)X
2637(denoted:)X
7 f
9 s
576 5716(<>?)N

2 p
%%Page: 2 2
9 s 0 xH 0 xS 7 f
1 f
2244 376(-)N
2286(2)X
2340(-)X
11 s
576 704(or,)N
693(optionally,)X
7 f
9 s
576 868 -0.1947(<>?[fail_action])AN
1 f
11 s
576 1072(where)N
825(the)X
968(second)X
1248(notation)X
1574(``passes'')X
1950(an)X
2069(argument)X
2438(of)X
2547(an)X
2666(action)X
2918(to)X
3023(the)X
3167(predicate)X
3526(operator)X
3855(``?'',)X
576 1200(which)N
821(is)X
910(executed)X
1253(upon)X
1459(predicate)X
1812(failure.)X
2115(A)X
2207(predicate)X
2559(is)X
2647(a)X
2715(C)X
2803(action)X
3048(that)X
3210(evaluates)X
3567(to)X
3665(either)X
3895(true)X
576 1328(\(success\))N
926(or)X
1028(false)X
1223(\(failure\))X
1540(and)X
1696(can)X
1847(be)X
1959(used)X
2149(for)X
2280(both)X
2 f
2466(semantic)X
2808(validation)X
1 f
3196(and)X
3352(for)X
2 f
3483(disambiguating)X
1 f
576 1456(syntactic)N
912(con\257icts)X
1233(in)X
1324(the)X
1454(underlying)X
1858(grammar.)X
776 1612(Validation)N
1174(predicates)X
1556(are)X
1688(used)X
1874(as)X
1972(simple)X
2233(tests)X
2415(and)X
2567(are)X
2699(functionally)X
3151(equivalent)X
3544(to)X
3639(the)X
3773(follow-)X
576 1740(ing)N
711(normal)X
983(action:)X
7 f
9 s
576 1904(if)N
705(\()X
791(!predicate)X
1264(\))X
1350({)X
2 f
1393(error)X
1563(message;)X
1849(exit)X
1971(rule)X
7 f
2087(})X
1 f
11 s
576 2108(or,)N
693(when)X
905(a)X
966(fail)X
1106(action)X
1344(is)X
1425(present:)X
7 f
9 s
576 2272(if)N
705(\()X
791(!predicate)X
1264(\))X
1350({fail_action})X
1 f
11 s
576 2476(For)N
720(example,)X
7 f
9 s
576 2640(a)N
748(:)X
920(A)X
1006(<>?)X
1436(B)X
748 2728(;)N
1 f
11 s
576 2932(Matches)N
7 f
941(A)X
1 f
994(,)X
1052(evaluates)X
7 f
1447(pred)X
1 f
1659(,)X
1717(and)X
1880(matches)X
7 f
2237(B)X
1 f
2327(if)X
7 f
2449(pred)X
1 f
2698(is)X
2794(true)X
2968(else)X
3142(an)X
3262(error)X
3469(is)X
3565(reported)X
3895(\(i.e.)X
576 3060(``)N
7 f
634(failed)X
1014(predicate)X
1553('pred')X
1 f
1871(''\))X
1989(and)X
2147(rule)X
7 f
2346(a)X
1 f
2430(is)X
2520(exited)X
2766(before)X
3020(matching)X
7 f
3410(B)X
1 f
3463(.)X
3537(To)X
3665(generate)X
3993(a)X
576 3188(more)N
779(useful)X
1016(error)X
1208(message,)X
1550(the)X
1680(user)X
1848(may)X
2022(specify)X
2298(a)X
2359(fail)X
2499(action:)X
7 f
9 s
576 3352(a)N
748(:)X
920(A)X
1006(<>?[fail])X
1694(B)X
748 3440(;)N
1 f
11 s
576 3644(which)N
813(executes)X
7 f
1169(fail)X
1 f
1403(when)X
7 f
1646(pred)X
1 f
1880(evaluates)X
2230(to)X
2321(false.)X
776 3800(A)N
867(predicate)X
1218(which)X
1461(validates)X
1803(a)X
1870(production)X
2280(can,)X
2452(at)X
2544(the)X
2680(same)X
2889(time,)X
3097(be)X
3208(used)X
3397(to)X
3494(disambiguate)X
3993(a)X
576 3928(syntactically)N
1055(ambiguous)X
1474(grammar)X
1824(structure.)X
2208(To)X
2338(be)X
2452(a)X
2522(candidate,)X
2913(a)X
2983(predicate)X
3337(must)X
3540(appear)X
3805(on)X
3924(the)X
576 4056(extreme)N
887(left)X
1032(edge)X
1226(of)X
1327(a)X
1394(production.)X
1848(Disambiguating)X
2440(predicates)X
2825(are)X
2960(used)X
3149(in)X
3246(the)X
3382(alternative)X
3783(predic-)X
576 4184(tion)N
743(expressions)X
1182(to)X
1280(enable)X
1539(or)X
1641(disable)X
1920(certain)X
2189(alternative)X
2591(productions)X
3035(of)X
3136(a)X
3203(block)X
3427(\(rule)X
3621(or)X
3722(subrule\).)X
576 4312(Parsing)N
862(in)X
953(this)X
1103(new)X
1271(environment)X
1739(can)X
1883(be)X
1988(viewed)X
2264(in)X
2355(this)X
2505(way:)X
2 f
576 4468(step)N
740(1:)X
835(Disable)X
1131(invalid)X
1399(productions)X
1 f
776 4596(An)N
2 f
905(invalid)X
1 f
1173(production)X
1577(is)X
1658(a)X
1719(production)X
2123(whose)X
2369(disambiguating)X
2936(predicate)X
3281(evaluates)X
3631(to)X
3722(false.)X
2 f
576 4752(step)N
740(2:)X
835(Parse)X
1062(as)X
1162(normal)X
1438(block)X
1 f
776 4880(Once)N
983(a)X
1044(list)X
1175(of)X
2 f
1270(valid)X
1 f
1469(productions)X
1907(has)X
2046(been)X
2234(found,)X
2483(they)X
2657(are)X
2786(parsed)X
3037(as)X
3132(a)X
3193(normal)X
3465(rule)X
3624(or)X
3719(subrule.)X
576 5036(Essentially,)N
1018(disambiguating)X
1595(predicates)X
1985(``gate'')X
2281(alternative)X
2687(productions)X
3136(in)X
3238(and)X
3398(out)X
3544(depending)X
3944(on)X
576 5164(their)N
819(``applicability''.)X
1503(Productions)X
2005(without)X
2356(predicates)X
2794(have)X
3041(an)X
3205(implied)X
3556(predicate)X
3959(of)X
7 f
576 5292(<>?)N
1 f
1053(;)X
1100(i.e.)X
1230(they)X
1404(are)X
1533(always)X
1799(valid.)X
776 5448(A)N
881(single)X
1134(predicate)X
1499(can)X
1663(be)X
1788(used)X
1991(as)X
2106(both)X
2305(a)X
2386(validation)X
2782(and)X
2951(a)X
3033(disambiguating)X
3621(predicate\320)X
576 5576(ANTLR)N
893(determines)X
1303(which)X
1541(way)X
1710(to)X
1802(use)X
1942(them)X
2142 0.2404(automatically.)AX
2691(The)X
2851(role)X
3011(taken)X
3225(by)X
3336(a)X
3398(predicate)X
3744(depends)X
576 5704(on)N
693(its)X
806(location)X
1120(in)X
1218(the)X
1355(grammar.)X
1746(Predicates)X
2137(are)X
2274(all)X
2393(considered)X
2804(validation)X
3188(predicates)X
3575(as)X
3678(they)X
3860(must)X
576 5832(always)N
853(evaluate)X
1180(to)X
1282(true)X
1452(for)X
1587(parsing)X
1879(of)X
1985(the)X
2126(enclosing)X
2497(production)X
2912(to)X
3014(continue.)X
3395(However,)X
3771(when)X
3993(a)X

3 p
%%Page: 3 3
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(3)X
2348(-)X
576 704(grammatical)N
1042(ambiguity)X
1425(is)X
1508(discovered,)X
1935(ANTLR)X
2252(searches)X
2573(for)X
2 f
2699(visible)X
1 f
2954(predicates)X
3335(to)X
3428(disambiguate)X
3924(the)X
576 832(construct.)N
973(A)X
1066(visible)X
1332(predicate)X
1685(is)X
1774(one)X
1931(which)X
2176(can)X
2328(be)X
2441(evaluated)X
2809(in)X
2908(a)X
2976(production)X
3387(prediction)X
3774(expres-)X
576 960(sion)N
759(without)X
1065(consuming)X
1488(a)X
1563(token)X
1795(or)X
1904(executing)X
2283(an)X
2403(action)X
2656(\(except)X
2952 0.3317(initialization)AX
3438(actions\);)X
3779(e.g.)X
3943(all)X
576 1088(disambiguating)N
1149(predicates)X
1534(appear)X
1796(on)X
1912(the)X
2048(left)X
2194(edge)X
2388(of)X
2489(some)X
2702(production.)X
3155(Fail)X
3320(actions)X
3597(are)X
3731(not)X
3871(used)X
576 1216(in)N
678(prediction)X
1070(expressions)X
1514(because)X
1826(a)X
1899(failed)X
2134(predicate)X
2491(disables)X
2809(a)X
2882(production;)X
3323(it)X
3407(does)X
3602(not)X
3749(report)X
3993(a)X
576 1344(syntax)N
841(error)X
1045(unless)X
1299(no)X
1421(other)X
2 f
1636(viable)X
1 f
1886(predicates)X
2277(are)X
2418(present;)X
2731(a)X
2804(viable)X
3054(production)X
3470(is)X
3563(one)X
3724(which)X
3973(is)X
576 1472(predicted)N
939(by)X
1062(the)X
1205(lookahead.)X
1646(The)X
1818(action)X
2069(of)X
2178(moving)X
2484(a)X
2559(predicate)X
2918(into)X
3092(a)X
3167(prediction)X
3561(expression)X
3973(is)X
576 1600(called)N
2 f
822(hoisting)X
1 f
1107(;)X
1167(currently,)X
1542(at)X
1641(most)X
1848(one)X
2010(predicate)X
2368(can)X
2525(be)X
2643(hoisted)X
2932(per)X
3078(ambiguous)X
3499(production.)X
3959(In)X
576 1728(general,)N
879(predicates)X
1258(may)X
1432(only)X
1611(be)X
1716(a)X
1777(function)X
2093(of:)X
576 1884(User)N
763(variables)X
776 2012(This)N
964(is)X
1054(dangerous)X
1446(as)X
1550(hoisting)X
1866(may)X
2049(evaluate)X
2374(the)X
2513(predicate)X
2867(in)X
2967(a)X
3038(scope)X
3270(where)X
3516(the)X
3656(variable\(s\))X
776 2140(does)N
971(not)X
1118(exist;)X
1344(e.g.)X
1505(using)X
1730(rule)X
1901(parameters)X
2321(can)X
2476(be)X
2592(a)X
2664(problem)X
2991(if)X
3078(a)X
3150(predicate)X
3506(that)X
3672(references)X
776 2268(them)N
975(is)X
1056(hoisted)X
1333(outside)X
1610(of)X
1705(the)X
1835(rule.)X
576 2424(Attributes)N
776 2552(Only)N
979(attributes)X
1336(in)X
1433(the)X
1569(left)X
1715(context)X
2003(can)X
2153(be)X
2264(used;)X
2478(i.e.)X
2614(attributes)X
2971(of)X
3072(rules/tokens)X
3526(created)X
3808(before)X
776 2680(the)N
906(predicate)X
1251(is)X
1332(evaluated.)X
576 2836(Lookahead)N
776 2964(The)N
935(next)X
2 f
1109(k)X
1 f
1170(tokens)X
1422(of)X
1517(lookahead)X
1901(can)X
2045(be)X
2150(tested)X
2378(via)X
7 f
2539(LA\(i\))X
1 f
2804(,)X
7 f
2879(LATEXT\(i\))X
1 f
3356(.)X
576 3120(Also,)N
3 f
793(predicates)X
1208(may)X
1398(not)X
1549(have)X
1754(side-effects)X
1 f
2197(\(user)X
2401(must)X
2602(undo)X
2807(anything)X
3145(that)X
3307(was)X
3473(changed)X
3796(if)X
3880(they)X
576 3248(do;)N
712(in)X
804(other)X
1008(words,)X
1267(they)X
1442(must)X
1637(``backtrack''\).)X
2191(See)X
2340(the)X
2470(Future)X
2722(Work)X
2944(section)X
3216(for)X
3340(information)X
3779(regard-)X
576 3376(ing)N
711(the)X
841(use)X
980(of)X
1075(predicates)X
1454(and)X
1603(extremely)X
1978(large)X
2176(lookahead)X
2560(buffers.)X
776 3532(Consider)N
1116(the)X
1246(following)X
1611(simple)X
1869(grammar:)X
7 f
9 s
576 3696(a)N
748(:)X
920(<>?)X
1393(A)X
1479(B)X
9 f
748 3784(|)N
7 f
891(<>?)X
1364(A)X
1450(C)X
748 3872(;)N
1 f
11 s
576 4076(This)N
755(grammar)X
1095(is)X
1176(LL\(2\))X
1408(\()X
7 f
1437(-k)X
1596(2)X
1 f
1649(\))X
1700(and)X
1849(ANTLR)X
2164(would)X
2406(not)X
2541(report)X
2773(an)X
2878(ambiguity.)X
3303(However,)X
3668(it)X
3740(is)X
3822(LL\(1\))X
576 4204(ambiguous)N
985(\()X
7 f
1014(-k)X
1173(1)X
1 f
1226(\))X
1277(and)X
7 f
1457(antlr)X
1775(t.g)X
1 f
1956(would)X
2198(generate)X
2518(a)X
2579(warning)X
2889(message:)X
7 f
9 s
576 4368(t.g,)N
791(line)X
1006(1:)X
1135(warning:)X
1522(alts)X
1737(1)X
1823(and)X
1995(2)X
2081(of)X
2210(rule)X
2425(ambiguous)X
2855(upon)X
3070({)X
3156(A)X
3242(})X
1 f
11 s
576 4572(Now,)N
799(if)X
884(we)X
1017(allow)X
1244(predicates)X
1632(to)X
1732(be)X
1846(used)X
2038(with)X
7 f
2257(antlr)X
2575(-pr)X
2787(t.g)X
1 f
2946(,)X
2999(then)X
3182(ANTLR)X
3507(\256nds)X
3710(that)X
3875(both)X
576 4700(predicates)N
970(are)X
1114(visible)X
1387(and)X
1551(can)X
1710(be)X
1830(used)X
2028(to)X
2133(disambiguate)X
2640(the)X
2784(production;)X
3227(it)X
3313(is)X
3408(up)X
3532(to)X
3637(the)X
3781(user)X
3963(to)X
576 4828(ensure)N
833(that)X
994(the)X
1130(predicates)X
1515(do,)X
1654(in)X
1752(fact,)X
1935(disambiguate)X
2435(the)X
2572(predicate.)X
2968(ANTLR)X
3290(would)X
3539(generate)X
3866(code)X
576 4956(similar)N
844(to)X
935(the)X
1065(following:)X
7 f
9 s
576 5120(a\(\))N
576 5208({)N
748 5296(if)N
877(\()X
963(pred1)X
1221(&&)X
1350(LA\(1\)==A)X
1737(\))X
1823({)X
748 5384(})N
748 5472(else)N
963(if)X
1092(\()X
1178(pred2)X
1436(&&)X
1565(LA\(1\)==A)X
1952(\))X
2038({)X
748 5560(})N
748 5648(else)N
2 f
963(error)X
7 f
1115(;)X
576 5736(})N

4 p
%%Page: 4 4
9 s 0 xH 0 xS 7 f
1 f
2244 376(-)N
2286(4)X
2340(-)X
11 s
576 704(The)N
737(following)X
1104(grammars)X
1480(are)X
1611(syntactically)X
2082(and)X
2233(semantically)X
2704(equivalent)X
3096(to)X
3189(the)X
3321(above)X
3555(grammar,)X
3919(but)X
576 832(the)N
706(predicates)X
1085(are)X
1214(not)X
1349(hoisted)X
1626(trivially:)X
7 f
9 s
576 996(a)N
748(:)X
920(\()X
1006(<>?)X
1479(A)X
1565(B)X
1651(\))X
9 f
748 1084(|)N
7 f
891(<>?)X
1364(A)X
1450(C)X
748 1172(;)N
1 f
11 s
576 1376(ANTLR)N
907(looks)X
1136(inside)X
1385(the)X
1531(subrule)X
1829(of)X
1941(production)X
2362(one)X
2528(and)X
2694(\256nds)X
2904(that)X
7 f
3107(pred1)X
1 f
3411(can)X
3572(be)X
3694(evaluated)X
576 1504(before)N
834(executing)X
1211(an)X
1328(action)X
1578(and)X
1738(before)X
1995(matching)X
2357(a)X
2429(token;)X
2683(it)X
2766(is)X
2858(hoisted)X
3146(for)X
3281(use)X
3431(in)X
3533(the)X
3674(prediction)X
576 1632(expression)N
974(of)X
1069(rule)X
7 f
1259(a)X
1 f
1312(.)X
1378(Predicates)X
1762(can)X
1906(be)X
2011(hoisted)X
2288(from)X
2481(other)X
2684(rules)X
2877(as)X
2972(well:)X
7 f
9 s
576 1796(a)N
748(:)X
920(b)X
9 f
748 1884(|)N
7 f
891(c)X
748 1972(;)N
576 2148(b)N
748(:)X
920(<>?)X
1393(A)X
1479(B)X
748 2236(;)N
576 2412(c)N
748(:)X
920(<>?)X
1393(A)X
1479(C)X
748 2500(;)N
1 f
11 s
576 2704(Rule)N
7 f
810(a)X
1 f
899(would)X
1155(still)X
1325(have)X
1527(the)X
1671(same)X
1889(production)X
2308(prediction)X
2703(expression.)X
3160(The)X
3334(following)X
3714(grammar)X
576 2832(does)N
759(not)X
894(have)X
1082(predicates)X
1461(that)X
1616(can)X
1760(be)X
1865(hoisted)X
2142(to)X
2233(disambiguate)X
2726(the)X
2856(prediction:)X
7 f
9 s
576 2996(a)N
748(:)X
920(A)X
1006(<>?)X
1479(B)X
2081(/*)X
2210(cannot)X
2511(hoist)X
2769(past)X
2984(token)X
3242(*/)X
9 f
748 3084(|)N
7 f
891(<>)X
1364(<>?)X
1837(A)X
1923(C)X
2052(/*)X
2181(cannot)X
2482(hoist)X
2740(past)X
2955(action)X
3256(*/)X
748 3172(;)N
1 f
11 s
776 3376(Now,)N
992(consider)X
1314(how)X
1489(a)X
1552(simpli\256ed)X
1930(version)X
2213(of)X
2310(K&R)X
2525(C)X
2608(variable)X
2916(and)X
3067(function)X
3385(declarations)X
3836(could)X
576 3504(be)N
681(speci\256ed:)X
7 f
9 s
576 3668(decl:)N
920(/*)X
1049(variable)X
1436(definition,)X
1952(function)X
2339 -0.1964(DECLARATION/DEFINITION)AX
3328(*/)X
920 3756(type)N
1135(declarator)X
1608(\()X
1694(func_body)X
9 f
2124(|)X
7 f
2181(";")X
2353(\))X
9 f
748 3844(|)N
7 f
891(/*)X
1020(function)X
1407(DEFINITION)X
1880(*/)X
920 3932(declarator)N
1393(func_body)X
748 4020(;)N
576 4196(type:)N
920("int")X
9 f
748 4284(|)N
7 f
891("float")X
9 f
748 4372(|)N
7 f
891(WORD)X
748 4460(;)N
576 4636(declarator)N
748 4724(:)N
920(WORD)X
1135({)X
1221("\\\(")X
1436(args)X
1651("\\\)")X
1866(})X
748 4812(;)N
576 4988(func_body)N
748 5076(:)N
920(\()X
1006(decl)X
1221(\)*)X
1350("\\{")X
1565(\(decl\)*)X
1909(\(stat\)*)X
2253("\\}")X
748 5164(;)N
1 f
11 s
576 5368(unfortunately,)N
1098(rule)X
7 f
1291(decl)X
1 f
1528(is)X
1612(totally)X
1865(ambiguous)X
2278(in)X
2373(the)X
2507(LL\(1\))X
2743(sense)X
2959(\(and)X
3141(in)X
3236(the)X
3370(LL\(k\))X
3606(sense\))X
3851(since)X
7 f
576 5496(WORD)N
1 f
820(can)X
974(begin)X
1202(both)X
1390(alternatives)X
1828(of)X
1932(rule)X
7 f
2131(decl)X
1 f
2343(.)X
2418(Increasing)X
2815(the)X
2954(lookahead)X
3347(to)X
3447(two)X
3610(tokens)X
3871(does)X
576 5624(not)N
730(help)X
923(as)X
1037(the)X
1186(alternatives)X
1634(are)X
1782(ambiguous)X
2211(upon)X
7 f
2460(WORDWORD)X
1 f
2884(.)X
2970(Alternative)X
3409(one)X
3578(could)X
3816(match)X
7 f
576 5752(my_type)N
1000(var)X
1 f
1188(and)X
1344(alternative)X
1746(two)X
1907(could)X
2132(match)X
7 f
2408(func)X
2673(my_type)X
1 f
3044(;)X
3098(hence,)X
3354(the)X
3491(second)X
3763(alterna-)X
576 5880(tive)N
745(matches)X
1070(at)X
1170(least)X
1368(one)X
1531(invalid)X
1813(sentence.)X
2196(This)X
2389(is)X
2484(because)X
2799(the)X
7 f
2975(\()X
3081(decl)X
3346(\)*)X
1 f
3489(subrule)X
3785(of)X
3895(rule)X

5 p
%%Page: 5 5
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(5)X
2348(-)X
7 f
576 704(func_body)N
1 f
1053(,)X
1098(which)X
1336(would)X
1579(match)X
1818(the)X
1949(second)X
7 f
2247(WORD)X
1 f
2482(of)X
7 f
2609(WORD)X
2874(WORD)X
1 f
3086(,)X
3131(does)X
3314(not)X
3449(know)X
3666(if)X
3742(an)X
3847(argu-)X
576 832(ment)N
775(list)X
906(was)X
1064(seen)X
1242(previously)X
1636(or)X
1731(not.)X
1910(The)X
2069(question)X
2391(of)X
2487(whether)X
2793(to)X
2885(match)X
3124(a)X
3186(parameter)X
3561(de\256nition)X
3923(list)X
576 960(after)N
766(a)X
834(declarator)X
1215(is)X
1303(context-sensitive)X
1929(because)X
2235(a)X
2302(function)X
2624(header)X
2886(may)X
3066(or)X
3167(may)X
3347(not)X
3488(have)X
3682(been)X
3876(seen)X
576 1088 0.3187(immediately)AN
1041(beforehand.)X
776 1244(One)N
954(way)X
1132(in)X
1233(which)X
1480(this)X
1640(subset)X
1892(could)X
2120(be)X
2235(recognized)X
2653(is)X
2744(to)X
2845(recognize)X
3219(a)X
3290(large)X
3498(superset)X
3818(of)X
3924(the)X
576 1372(language)N
916(and)X
1065(then,)X
1261(using)X
1474(actions,)X
1768(verify)X
2000(that)X
2155(the)X
2285(input)X
2489(was)X
2647(valid:)X
7 f
9 s
576 1536(decl:)N
920({type})X
1221(declarator)X
1694(\()X
1780(func_body)X
9 f
2210(|)X
7 f
2267(";")X
2439(\))X
748 1624(;)N
1 f
11 s
576 1828(But,)N
760(jamming)X
1109(everything)X
1520(together)X
1843(makes)X
2102(action)X
2352(introduction)X
2818(more)X
3033(complicated.)X
3544(It)X
3633(is)X
3727(better)X
3963(to)X
576 1956(specify)N
852(the)X
982(input)X
1186(language)X
1526(exactly)X
1803(with)X
1982(predicates.)X
776 2112(To)N
903(overcome)X
1279(the)X
1416(ambiguity)X
1804(in)X
1902(rule)X
7 f
2099(decl)X
1 f
2340(and)X
2496(to)X
2594(ensure)X
2852(that)X
3014(only)X
3200(a)X
3268(function)X
3591(declarator)X
3973(is)X
576 2240(followed)N
911(by)X
1021(a)X
1082(parameter)X
1456(de\256nition,)X
1839(we)X
1963(augment)X
2289(the)X
2419(grammar)X
2759(as)X
2854(follows:)X
7 f
9 s
576 2404(decl:)N
920(< 1178(is_func;>>)X
920 2580(/*)N
1049(variable)X
1436(definition,)X
1952(function)X
2339 -0.1964(DECLARATION/DEFINITION)AX
3328(*/)X
920 2668(type)N
1135(declarator)X
1608(>)X
1694([is_func])X
920 2756(\()N
1092 -0.1942(<>?[printf\("warning:)AX
2382(declarator)X
2855(not)X
3027(func\\n"\);])X
1092 2844(func_body)N
9 f
920 2932(|)N
7 f
1063(";")X
920 3020(\))N
9 f
748 3196(|)N
7 f
891(/*)X
1020(function)X
1407(DEFINITION)X
1880(*/)X
920 3284(declarator)N
1393(>)X
1479([is_func])X
920 3372 -0.1942(<>?[printf\("warning:)AN
2210(expecting)X
2640(func)X
2855(header)X
3156(not)X
3328(%s\\n",)X
3629(LATEXT\(1\)\);])X
920 3460(func_body)N
748 3548(;)N
576 3724(type:)N
920("int")X
9 f
748 3812(|)N
7 f
891("float")X
9 f
748 3900(|)N
7 f
891(< 1493(?)X
1579 -0.1992(isTYPE\(LATEXT\(1\)\))AX
2353(:)X
2439(1>>?)X
920 3988(WORD)N
748 4076(;)N
576 4252(declarator)N
1049(>)X
1135([int)X
1350(is_func])X
748 4340(:)N
920(< 1522(?)X
1608 -0.1985(!isTYPE\(LATEXT\(1\)\))AX
2425(:)X
2511(1>>?)X
920 4428(WORD)N
1135(\()X
1221("\\\(")X
1436(<<$is_func=1;>>)X
2124(args)X
2339("\\\)")X
9 f
2554(|)X
7 f
2611(<<$is_func=0;>>)X
3299(\))X
748 4516(;)N
576 4692(func_body)N
748 4780(:)N
920(\()X
1006(decl)X
1221(\)*)X
1350("\\{")X
1565(\(decl\)*)X
1909(\(stat\)*)X
2253("\\}")X
748 4868(;)N
1 f
11 s
576 5072(In)N
675(rule)X
7 f
869(type)X
1 f
1081(,)X
1129(we)X
1257(add)X
1410(a)X
1475(predicate)X
1824(that)X
1983(ensures)X
2272(that,)X
2453(if)X
2533(the)X
2667(lookahead)X
3055(is)X
3140(a)X
7 f
3236(WORD)X
1 f
3448(,)X
3496(that)X
3655(the)X
7 f
3820(WORD)X
1 f
576 5200(is,)N
692(in)X
796(fact,)X
985(a)X
1059(user-de\256ned)X
1528(type;)X
1740(nothing)X
2045(can)X
2202(be)X
2320(said)X
2497(if)X
2586(the)X
2729(lookahead)X
3126(is)X
3220(something)X
3623(else,)X
3817(so)X
3930(we)X
576 5328(return)N
813(success)X
1103(in)X
1199(that)X
1359(case;)X
1562(i.e.)X
1697(the)X
1833(predicate)X
2184(does)X
2373(not)X
2514(apply)X
2738(for)X
2868(that)X
3029(lookahead)X
3419(\(context\).)X
3809(If)X
3895(rule)X
7 f
576 5456(declarator)N
1 f
1135(is)X
1223(called,)X
1485(a)X
1553(failure)X
1812(of)X
1914(the)X
2051(predicate)X
2403(will)X
2570(report)X
2809(a)X
2877(semantic)X
3220(error.)X
3463(In)X
3565(our)X
3711(example,)X
576 5584(the)N
711(predicate)X
1061(is)X
1147(also)X
1317(hoisted)X
1600(for)X
1730(use)X
1875(as)X
1976(a)X
2043(disambiguating)X
2616(predicate)X
2967(in)X
3064(rule)X
7 f
3260(decl)X
1 f
3472(.)X
3544(The)X
3709(predicate)X
576 5712(in)N
676(rule)X
7 f
875(declarator)X
1 f
1436(ensures)X
1730(that,)X
1915(if)X
1999(the)X
2137(lookahead)X
2529(is)X
2618(a)X
7 f
2718(WORD)X
1 f
2930(,)X
2982(that)X
3145(the)X
7 f
3314(WORD)X
1 f
3556(is)X
3645(not)X
3788(a)X
3857(user-)X
576 5840(de\256ned)N
857(type.)X
1075(As)X
1194(before,)X
1462(it)X
1534(is)X
1615(also)X
1779(hoisted)X
2056(to)X
2147(rule)X
7 f
2337(decl)X
1 f
2571(to)X
2662(disambiguate)X
3156(the)X
3287(second)X
3554(production)X
3959(of)X

6 p
%%Page: 6 6
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(6)X
2348(-)X
576 704(that)N
744(rule.)X
960(Both)X
1167(productions)X
1617(of)X
1724(rule)X
7 f
1926(decl)X
1 f
2172(have)X
2372(predicates)X
2763(that)X
2930(are)X
3071(hoisted)X
3360(into)X
3532(the)X
3674(prediction)X
576 832(expressions)N
1033(for)X
1182(those)X
1415(productions;)X
1903(ANTLR)X
2243(assumes)X
2583(that)X
2763(the)X
2918(hoisted)X
3221(predicates)X
3 f
3626(completely)X
1 f
576 960(disambiguate)N
1071(the)X
1203(decision,)X
1543(which)X
1782(is)X
1864(true)X
2024(in)X
2116(our)X
2256(case.)X
2474(The)X
2634(\256rst)X
2794(predicate)X
3140(physically)X
3526(present)X
3803(in)X
3895(rule)X
7 f
576 1088(decl)N
1 f
818(ensures)X
1111(that,)X
1296(if)X
1380(a)X
1449(function)X
1773(body)X
1979(is)X
2068(coming)X
2363(up,)X
2503(the)X
2641(declarator)X
3024(was)X
3191(a)X
3261(function)X
3586(header.)X
3895(The)X
576 1216(second)N
853(predicate)X
1209(in)X
1311(rule)X
7 f
1512(decl)X
1 f
1757(again)X
1981(ensures)X
2277(that)X
2443(a)X
2515(function)X
2842(header)X
3108(was)X
3276(seen)X
3464(before)X
3720(trying)X
3963(to)X
576 1344(match)N
814(a)X
875(function)X
1191(body.)X
1433(The)X
1592(variable)X
7 f
1929(is_func)X
1 f
2322(is)X
2403(set)X
2523(to)X
2615(the)X
2746(return)X
2979(value)X
3193(of)X
3289(rule)X
7 f
3480(declarator)X
1 f
4010(,)X
576 1472(which)N
813(is)X
894(set)X
1014(by)X
1124(two)X
1278(simple)X
1536(actions)X
1808(in)X
7 f
1930(declarator)X
1 f
2460(.)X
776 1628(Currently,)N
1184(the)X
1340(context)X
1649(under)X
1898(which)X
2162(predicates)X
2568(are)X
2724(evaluated)X
3111(may)X
3312(not)X
3474(be)X
3606(correct;)X
3924(i.e.)X
576 1756(currently)N
916(ANTLR)X
1231(does)X
1414(not)X
1549(compute)X
1875(the)X
2005(context)X
2287(from)X
2480(which)X
2717(it)X
2789(hoists)X
3017(a)X
3078(predicate.)X
3467(For)X
3611(example,)X
7 f
9 s
576 1920(a)N
748(:)X
920(b)X
1006(B)X
9 f
748 2008(|)N
7 f
891(\(X)X
1020(Y)X
9 f
1106(|)X
7 f
1163(A)X
1249(C\))X
748 2096(;)N
576 2272(b)N
748(:)X
920(<>?)X
1350(A)X
748 2360(;)N
1 f
11 s
576 2564(The)N
741(predicate)X
7 f
1124(pred)X
1 f
1365(will)X
1532(be)X
1644(hoisted)X
1928(for)X
2059(use)X
2205(in)X
2303(disambiguating)X
2877(rule)X
7 f
3074(a)X
1 f
3127(.)X
3200(However,)X
3572(the)X
3709(predicate)X
576 2692(will)N
745(be)X
859(evaluate)X
1184(regardless)X
1571(of)X
1675(whether)X
7 f
2020(A)X
1 f
2073(,)X
2126(which)X
2372(is)X
2462(its)X
2577(context,)X
2890(or)X
7 f
3025(X)X
1 f
3109(is)X
3199(on)X
3318(the)X
3457(input)X
3669(stream.)X
3978(It)X
576 2820(may)N
753(be)X
861(invalid)X
1132(to)X
1226(apply)X
1447(the)X
1580(predicate)X
1928(when)X
2143(the)X
2277(lookahead)X
2665(is)X
7 f
2781(X)X
1 f
2834(.)X
2904(The)X
3067(user)X
3239(may)X
3417(overcome)X
3790(this)X
3944(by)X
576 2948(changing)N
7 f
952(pred)X
1 f
1186(thus:)X
7 f
9 s
576 3112(a)N
748(:)X
920(b)X
1006(B)X
9 f
748 3200(|)N
7 f
891(\(X)X
1020(Y)X
9 f
1106(|)X
7 f
1163(A)X
1249(C\))X
748 3288(;)N
576 3464(b)N
748(:)X
920(< 1393(?)X
1479(pred)X
1694(:)X
1780(TRUE>>?)X
2124(A)X
748 3552(;)N
1 f
11 s
576 3756(which)N
813(will)X
973(ensure)X
1224(that)X
1379(the)X
1509(predicate)X
1854(is)X
1935(only)X
2114(evaluated)X
2474(when)X
7 f
2717(A)X
1 f
2792(is)X
2873(seen)X
3051(on)X
3161(the)X
3291(input)X
3495(stream.)X
776 3912(Another)N
1088(problem)X
1406(area)X
1576(lies)X
1723(in)X
1816(that)X
1973(hoisting)X
2282(can)X
2428(occur)X
2647(in)X
2740(situations)X
3104(that)X
3262(will)X
3425(break)X
3645(the)X
3778(seman-)X
576 4040(tics.)N
765(For)X
909(example:)X
7 f
9 s
576 4204(a)N
748(:)X
920(b[3])X
9 f
748 4292(|)N
7 f
891(A)X
748 4380(;)N
576 4556(b[int)N
834(i])X
748 4644(:)N
834(<>?)X
1307(A)X
748 4732(;)N
1 f
11 s
576 4936(The)N
751(predicate)X
7 f
1143(f\(i\))X
1 f
1393(will)X
1569(be)X
1690(hoisted)X
1983(to)X
2090(rule)X
7 f
2296(a)X
1 f
2387(where)X
2639(the)X
2785(parameter)X
7 f
3206(i)X
1 f
3297(is)X
3394(not)X
3546(even)X
3751(de\256ned.)X
576 5064(Either)N
816(do)X
927(not)X
1063(do)X
1174(this)X
1325(or)X
1421(put)X
1557(a)X
1619(predicate)X
1965(\(dummy)X
2287(or)X
2383(otherwise\))X
2777(between)X
3093(the)X
3224(decision)X
3541(and)X
3691(the)X
3822(predi-)X
576 5192(cate)N
740(you)X
894(do)X
1004(not)X
1139(wish)X
1327(to)X
1418(be)X
1523(hoisted:)X

7 p
%%Page: 7 7
11 s 0 xH 0 xS 1 f
9 s
7 f
1 f
2244 376(-)N
2286(7)X
2340(-)X
7 f
576 712(a)N
748(:)X
920(<<1>>?)X
1221(b[3])X
9 f
748 800(|)N
7 f
891(A)X
748 888(;)N
576 1064(b[int)N
834(i])X
748 1152(:)N
834(<>?)X
1307(A)X
748 1240(;)N
1 f
11 s
776 1444(This)N
956(is)X
1038(an)X
1144(alpha)X
1358(release)X
1625(feature)X
1892(in)X
1984(that)X
2140(it)X
2213(is)X
2295(not)X
2431(anywhere)X
2795(near)X
2969(what)X
3164(we)X
3290(want)X
3485(it)X
3559(to)X
3652(do)X
3764(and)X
3915(has)X
576 1572(NOT)N
788(been)X
986(thoroughly)X
1405(tested.)X
1687(User)X
1884(beware.)X
2213(We)X
2367(do)X
2487(not)X
2632(guarantee)X
3006(that)X
3171(the)X
3310(syntax)X
3571(of)X
3675(predicates)X
576 1700(will)N
744(stay)X
916(this)X
1074(way;)X
1275(however,)X
1630(the)X
1769(semantics)X
2148(will)X
2317(not)X
2461(change.)X
2785(We)X
2938(want)X
3140(users)X
3351(to)X
3451(play)X
3634(with)X
3822(predi-)X
576 1828(cates)N
774(to)X
865(\256nd)X
1024(new,)X
1214(better)X
1437(or)X
1532(different)X
1857(ways)X
2059(of)X
2154(doing)X
2377(things.)X
2659(We)X
3 f
2803(really)X
1 f
3041(want)X
3234(user)X
3402(feedback)X
3741(on)X
3851(these)X
576 1956(critters)N
849(before)X
1101(a)X
1168(full)X
1319 0.2885(implementation)AX
1903(is)X
1990(developed.)X
2424(For)X
2575(example,)X
2925(how)X
3105(do)X
3222(you)X
3383(want)X
3583(the)X
3720(parser)X
3963(to)X
576 2084(respond)N
876(if)X
952(no)X
1062(valid,)X
1283(viable)X
1521(production)X
1925(is)X
2006(found?)X
7 f
9 s
576 2248(a)N
748(:)X
920(<>?)X
1264(A)X
9 f
748 2336(|)N
7 f
891(<>?)X
1235(A)X
9 f
748 2424(|)N
7 f
891(B)X
748 2512(;)N
1 f
11 s
576 2716(If)N
656(the)X
786(input)X
990(were)X
7 f
1213(C)X
1 f
1266(,)X
1310(a)X
1371(correct)X
1637(error)X
1829(message)X
2149(would)X
2391(be)X
2496(reported:)X
7 f
9 s
576 2880(line)N
791(1:)X
920(syntax)X
1221(error)X
1479(at)X
1608("C")X
1780(missing)X
2124({)X
2210(A)X
2296(B)X
2382(})X
1 f
11 s
576 3084(This)N
765(is)X
856(the)X
996(correct)X
1272(message)X
1602(because)X
1912(it)X
1994(is)X
2085(truly)X
2284(a)X
2355(syntax,)X
2639(as)X
2744(opposed)X
3069(to)X
3170(semantic,)X
3538(error.)X
3784(On)X
3924(the)X
576 3212(other)N
780(hand,)X
996(upon)X
1195(input)X
7 f
1431(A)X
1 f
1484(,)X
1529(when)X
1742(predicates)X
7 f
2152(p1)X
1 f
2280(and)X
7 f
2460(p2)X
1 f
2588(are)X
2717(false,)X
2927(the)X
3057(parser)X
3293(reports)X
3559(the)X
3689(following)X
576 3340(bizarre)N
842(message:)X
7 f
9 s
576 3504(line)N
791(1:)X
920(syntax)X
1221(error)X
1479(at)X
1608("A")X
1 f
11 s
576 3708(which)N
814(is)X
896(not)X
1032(very)X
1211(meaningful.)X
1680(The)X
1840(fail)X
1981(function,)X
7 f
2351(zzFAIL)X
1 f
2669(,)X
2715(found)X
2944(that,)X
3123(in)X
3216(fact,)X
7 f
3425(A)X
1 f
3502(is)X
3585(syntactically)X
576 3836(valid)N
778(and)X
930(got)X
1068(confused)X
1410(because)X
1713(an)X
1821(error)X
2016(was)X
2177(raised;)X
2437(this)X
2590(is)X
2674(because)X
2977(the)X
3109(fail)X
3251(routine)X
3525(has)X
3666(no)X
3778(seman-)X
576 3964(tic)N
700(information.)X
1196(A)X
1294(suitable)X
1604(de\256nition)X
1978(of)X
2086(error)X
2292(reporting)X
2651(in)X
2756(the)X
2900(predicate)X
3259(environment)X
3741(must)X
3949(be)X
576 4092(created.)N
776 4248(Please)N
1159(send)X
1478(any)X
1763(suggestions/questions)X
2691(to)X
7 f
2950 0.1974([email protected])AX
1 f
4010(,)X
7 f
576 4376 0.1974([email protected])AN
1 f
1811(or)X
2059(use)X
2351(the)X
2633(email)X
3004(server)X
3392(mechanism)X
3968(at)X
7 f
576 4504 0.1974([email protected])AN
1 f
1665(\(send)X
1884(a)X
7 f
1983(Subject:)X
1 f
2436(line)X
2598(of)X
2700(``question)X
3086(antlr'')X
3335(and)X
3491(\256ll)X
3619(in)X
3718(the)X
3856(body)X
576 4632(of)N
671(the)X
801(email)X
1020(with)X
1199(your)X
1382(suggestion/question\).)X
3 f
576 4888(1.2.)N
752(1.06)X
928(Is)X
1018(Written)X
1338(in)X
1434(1.00)X
1 f
776 5044(The)N
938(grammar)X
1281(for)X
1408(the)X
1541(PCCTS)X
1836(meta-language)X
2380(\(\256le)X
2547(format\))X
2836(has)X
2979(been)X
3171(implemented)X
3659(in)X
3754(Version)X
576 5172(1.00,)N
777(making)X
1067(heavy)X
1301(use)X
1442(of)X
7 f
1570(#lexclass)X
1 f
2071(directives.)X
2482(File)X
7 f
2675(lexhelp.c)X
1 f
3176(has)X
3317(been)X
3507(eliminated)X
3905(due)X
576 5300(to)N
667(the)X
797(superiority)X
1201(of)X
1296(1.00)X
1472(to)X
1563(1.00B.)X

8 p
%%Page: 8 8
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(8)X
2348(-)X
3 f
576 704(1.3.)N
752(ANTLR)X
1081(Compiles)X
1455(Under)X
1716(ANSI)X
1947(C)X
1 f
776 860(Because)N
1100(of)X
1204(the)X
1343(rewrite)X
1623(of)X
1727(the)X
1866(grammar)X
2215(and)X
2373(some)X
2591(rewrites)X
2906(of)X
3011(ANTLR)X
3336(code,)X
3556(ANTLR)X
3881(now)X
576 988(compiles)N
948(with)X
1158(ANSI)X
1415(compilers)X
1816(without)X
2139(a)X
2231(wimper)X
2553(\(except)X
2864(for)X
3018(two)X
3202(``)X
7 f
3260(unknown)X
3714(escape)X
576 1116(sequence)N
1 f
1000('')X
1080(warnings\).)X
1497(Your)X
1699(mileage)X
2001(may)X
2175(vary.)X
3 f
576 1372(1.4.)N
752(Grammar)X
1155(Files)X
1354(Distributed)X
7 f
776 1528(antlr.g)N
1 f
1175(and)X
7 f
1362(dlg_p.g)X
1 f
1762(are)X
1898(now)X
2078(included)X
2411(in)X
2509(the)X
2646(source)X
2904(distribution)X
3341(for)X
3472(1.06.)X
3699(Note)X
3899(that)X
576 1656(the)N
710(1.00)X
890(PCCTS)X
1186(\(both)X
1398(ANTLR)X
1717(and)X
1870(DLG\))X
2104(are)X
2236(required)X
2554(to)X
2648(process)X
2936(these)X
3142(grammar)X
3485(\256les.)X
3701(DO)X
3852(NOT)X
576 1784(DESTROY)N
1003(YOUR)X
1273(OLD)X
1475(COPY)X
1731(OF)X
1865(1.00)X
2041(PCCTS)X
2333(\(at)X
2448(least)X
2632(save)X
2810(the)X
2940(executables\).)X
3 f
576 2040(1.5.)N
752(Script)X
1004(Generates)X
1407(Make\256les)X
1791(for)X
1925(PCCTS)X
2235(Projects)X
1 f
776 2196(A)N
877(C)X
974(program)X
1310(called)X
7 f
1590(genmk.c)X
1 f
1999(is)X
2096(available)X
2453(in)X
2560(the)X
7 f
2737(support)X
1 f
3146(directory)X
3503(of)X
3615(the)X
3762(PCCTS)X
576 2324(release)N
842(which)X
1079(has)X
1218(the)X
1348(following)X
1713(usage:)X
7 f
576 2480(genmk)N
894(project)X
1318(f1.g)X
1583(f2.g)X
1848(...)X
2060(fn.g)X
1 f
576 2636(It)N
658(generates)X
1018(a)X
1085(make\256le)X
1418(that)X
1580(creates)X
1853(an)X
1965(executable,)X
7 f
2424(project)X
1 f
2795(,)X
2846(from)X
3046(a)X
3114(set)X
3241(of)X
3343(grammar)X
3690(\256les.)X
3910(For)X
576 2764(example,)N
7 f
950(genmk)X
1268(t)X
1374(t.g)X
1 f
1555(generates:)X
7 f
9 s
576 2928(#)N
576 3016(#)N
662(PCCTS)X
920(makefile)X
1307(for:)X
1522(t.g)X
576 3104(#)N
576 3192(DLG_FILE)N
963(=)X
1049(parser.dlg)X
576 3280(ERR_FILE)N
963(=)X
1049(err.c)X
576 3368(HDR_FILE)N
963(=)X
1049(stdpccts.h)X
576 3456(TOK_FILE)N
963(=)X
1049(tokens.h)X
576 3544(K)N
662(=)X
748(1)X
576 3632(ANTLR_H)N
920(=)X
1006(.)X
576 3720(BIN)N
748(=)X
834(.)X
576 3808(ANTLR)N
834(=)X
920($\(BIN\)/antlr)X
576 3896(DLG)N
748(=)X
834($\(BIN\)/dlg)X
576 3984(CFLAGS)N
877(=)X
963(-I.)X
1135(-I$\(ANTLR_H\))X
576 4072(AFLAGS)N
877(=)X
963(-fe)X
1135(err.c)X
1393(-fh)X
1565(stdpccts.h)X
2038(-fl)X
2210(parser.dlg)X
2683(-ft)X
2855(tokens.h)X
3242(-k)X
3371($\(K\))X
576 4160(-gk)N
576 4248(DFLAGS)N
877(=)X
963(-C2)X
1135(-i)X
576 4336(GRM)N
748(=)X
834(t.g)X
576 4424(SRC)N
748(=)X
834(scan.c)X
1135(t.c)X
1307(err.c)X
576 4512(OBJ)N
748(=)X
834(scan.o)X
1135(t.o)X
1307(err.o)X
576 4724(t:)N
705($\(OBJ\))X
1006($\(SRC\))X
920 4812(cc)N
1049(-o)X
1178(t)X
1264($\(CFLAGS\))X
1694($\(OBJ\))X
576 4988(t.c)N
748(parser.dlg)X
1221(:)X
1307(t.g)X
920 5076($\(ANTLR\))N
1307($\(AFLAGS\))X
1737(t.g)X
576 5252(scan.c)N
877(:)X
963(parser.dlg)X
920 5340($\(DLG\))N
1221($\(DFLAGS\))X
1651(parser.dlg)X
2124(scan.c)X
1 f
11 s
576 5544(This)N
775(program)X
1115(is)X
1216(handy)X
1474(when)X
1707(beginning)X
2103(a)X
2185(new)X
2374(PCCTS)X
2687(project)X
2975(or)X
3091(when)X
3324(\256rst)X
3504(learning)X
3836(about)X
576 5672(PCCTS.)N

9 p
%%Page: 9 9
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(9)X
2348(-)X
3 f
576 704(1.6.)N
752(DLG)X
965(Supports)X
1329(Case)X
1531(Insensitive)X
1954(Scanners)X
1 f
776 860(DLG)N
983(has)X
1127(two)X
1286(new)X
1459(options)X
1746(which)X
1988(provide)X
2284(control)X
2562(over)X
2746(the)X
2882(case)X
3061(sensitivity)X
3453(of)X
3554(the)X
3690(generated)X
576 988(scanner.)N
918(Speci\256cally,)X
1387(case)X
1568(insensitivity)X
2031(implies)X
2322(that)X
2485(when)X
2705(a)X
2774(character)X
3126(is)X
3215(referenced)X
3615(in)X
3714(a)X
3783(regular)X
576 1116(expression,)N
996(DLG)X
1198(behaves)X
1503(as)X
1598(if)X
1674(the)X
1804(user)X
1972(had)X
2121(typed)X
2339(both)X
2518(upper)X
2740(and)X
2889(lower)X
3111(case)X
3284(versions)X
3600(of)X
3696(that)X
3852(char-)X
576 1244(acter;)N
794(i.e.)X
7 f
955(\()X
2 f
1008(a)X
7 f
9 f
(|)S
2 f
1070(A)X
7 f
1124(\))X
1 f
1199(where)X
2 f
1435(a)X
1 f
1501(is)X
1582(some)X
1790(character.)X
2178(The)X
2337(new)X
2505(options)X
2787(are:)X
7 f
576 1400(-ci)N
1 f
776(Make)X
998(lexical)X
1256(analyzer)X
1576(case)X
1749(insensitive)X
7 f
576 1556(-cs)N
1 f
776(Make)X
998(lexical)X
1256(analyzer)X
1576(case)X
1749(sensitive)X
2080(\(default\).)X
3 f
576 1812(1.7.)N
752(Delayed)X
1077(Lookahead)X
1520(Fetches)X
1825(in)X
1921(Generated)X
2339(Parser)X
1 f
776 1968(Currently,)N
1158(PCCTS)X
1450(generates)X
1804(parsers)X
2074(which)X
2311(always)X
2577(have)X
2 f
2765(k)X
1 f
2826(tokens)X
3078(of)X
3173(lookahead.)X
3601(This)X
3780(is)X
3861(done)X
576 2096(by)N
704(following)X
1087(the)X
1235(strategy)X
1554(that)X
1727(another)X
2031(token)X
2267(is)X
2366(fetched)X
2665(\()X
7 f
2694(zzCONSUME)X
1 f
3171(\))X
3240(when)X
3469(one)X
3635(is)X
3733(matched)X
576 2224(\()N
7 f
605(zzmatch)X
1 f
976(\).)X
1092(This)X
1292(can)X
1457(be)X
1583(a)X
1665(problem)X
2002(for)X
2147(actions)X
2440(that)X
2616(need)X
2825(to)X
2938(occur)X
3177(after)X
3382(a)X
3465(token)X
3705(has)X
3866(been)X
576 2352(matched,)N
937(but)X
1090(before)X
1354(the)X
1502(next)X
1694(token)X
1930(of)X
2043(lookahead)X
2445(is)X
2544(fetched.)X
2887(This)X
3083(is)X
3181(somewhat)X
3577(overcome)X
3963(in)X
576 2480(PCCTS)N
868(1.00)X
1044(by)X
1154(delaying)X
1480(the)X
1610(fetch)X
1808(if)X
1884(an)X
1989(action)X
2227(is)X
2308(found)X
2535 0.3187(immediately)AX
3000(after)X
3183(a)X
3244(token)X
3462(reference.)X
3855(With)X
576 2608(the)N
724(new)X
910(delayed)X
1224(lookahead)X
1626(scheme,)X
1952(the)X
2100(next)X
2292(token)X
2528(is)X
2627(not)X
2780(consumed)X
3177(until)X
3380(the)X
3527(next)X
3718(match)X
3973(is)X
576 2736(required.)N
936(This)X
1116(means)X
1364(that)X
1520(any)X
1670(action)X
1909(before)X
2156(the)X
2287(next)X
2462(match)X
2701(\(not)X
2866(necessarily)X
3280(adjacent)X
3597(to)X
3690(the)X
3822(previ-)X
576 2864(ous)N
724(match\))X
995(will)X
1159(be)X
1268(executed)X
1607(before)X
1857(a)X
1922(lookahead)X
2310(fetch)X
2512(occurs.)X
2811(Turn)X
3008(on)X
3121(ANTLR)X
3439(option)X
7 f
3721(-gk)X
1 f
3905(and)X
576 2992(DLG)N
785(option)X
7 f
1071(-i)X
1 f
1206(to)X
1304(enable)X
1563(this)X
1720(feature.)X
2037(This)X
2223(feature)X
2496(appears)X
2793(to)X
2891(work)X
3100(with)X
3287(AST's)X
3546(and)X
3703(attributes)X
576 3120(with)N
769(the)X
913(constraints)X
1330(mentioned)X
1738(below)X
1988(in)X
2092(the)X
2235 0.2891(incompatibilities)AX
2866(section)X
3151(\(e.g.)X
3342(use)X
3494(of)X
7 f
3633(LA\()X
2 f
3792(i)X
7 f
3817(\))X
1 f
3905(and)X
7 f
576 3248(LATEXT\()N
2 f
947(i)X
7 f
972(\))X
1 f
1047(has)X
1186(been)X
1374(restricted\).)X
1797(It)X
1874(has)X
2014(been)X
2203(tested)X
2432(with)X
2612(the)X
2743(C)X
2825(\()X
2 f
2854(k>)X
1 f
2952(1)X
3019(and)X
3169(Pascal)X
3417(\()X
2 f
3446(k==)X
1 f
3603(1\))X
3699(examples)X
576 3376(provided)N
911(in)X
1002(the)X
1132(release)X
1398(and)X
1547(with)X
1726(several)X
1997(other)X
2200(large)X
2398(grammars.)X
776 3532(This)N
956(feature)X
1223(is)X
1305(primarily)X
1657(useful)X
1895(for)X
2020(developers)X
2425(of)X
2522(interactive)X
2919(tools.)X
3159(Previously,)X
3582(it)X
3656(was)X
3 f
3816(really)X
1 f
576 3660(hard)N
766(to)X
869(get)X
1010(PCCTS)X
1313(to)X
1415(generate)X
1746(truly)X
1946(interactive)X
2352(tools.)X
2601(It)X
2688(appeared)X
3038(as)X
3144(if)X
3231(the)X
3372(parser)X
3619(was)X
3788(always)X
576 3788(waiting)N
863(on)X
973(a)X
1034(token)X
1252(fetch)X
1450(rather)X
1677(than)X
1851(executing)X
2216(an)X
2321(appropriate)X
2744(action.)X
3026(E.g.)X
3190(in)X
3281(PCCTS)X
3573(1.00,)X
7 f
9 s
576 3952(a)N
662(:)X
748(\()X
834("A")X
1006("B")X
1178("C")X
1350("\\n")X
1565(\))X
1651(< 2253(it\\n"\);>>)X
662 4040(;)N
1 f
11 s
576 4244(would)N
827(not)X
971(print)X
7 f
1201(got)X
1413(it)X
1 f
1551(until)X
1746(one)X
1905(token)X
2133(after)X
2326(the)X
2466(newline)X
2777(had)X
2936(been)X
3134(typed.)X
3406(PCCTS)X
3708(1.06)X
3894(will)X
576 4372(generate)N
903(parsers)X
1180(that)X
1342(print)X
1538(the)X
1675(message)X
2002 0.3187(immediately)AX
2474(upon)X
2679(newline)X
2987(and)X
3142(will)X
3308(exit)X
3469(without)X
3767(waiting)X
576 4500(for)N
700(another)X
986(token)X
1204(as)X
1299(there)X
1497(are)X
1626(no)X
1736(token)X
1954(references)X
2336(following)X
2701(the)X
2831(action.)X
776 4656(Another)N
1090(way)X
1262(in)X
1357(which)X
1598(delayed)X
1898(lookahead)X
2286(is)X
2371(useful)X
2612(lies)X
2761(in)X
2856(translators)X
3249(which)X
3490(add)X
3643(symbols)X
3963(to)X
576 4784(the)N
716(symbol)X
1008(table)X
1212(which)X
1459(must)X
1663(be)X
1778(examined)X
2153(by)X
2272(a)X
2342(lexical)X
2609(action.)X
2900(If)X
2989(a)X
3059(lookahead)X
3452(fetch)X
3659(occurs)X
3919(too)X
576 4912(fast,)N
747(the)X
877(lexical)X
1135(action)X
1373(may)X
1547(miss)X
1731(the)X
1861(introduction)X
2315(of)X
2410(a)X
2471(symbol)X
2753(into)X
2913(the)X
3043(symbol)X
3325(table.)X
776 5068(This)N
955(feature)X
1221(is)X
1302(a)X
1363(bit)X
1479(\257aky)X
1677(for)X
1801(the)X
1931(moment\320)X
7 f
2309(LA\()X
2 f
2468(i)X
7 f
2493(\))X
1 f
2568(and)X
7 f
2748(LATEXT\()X
2 f
3119(i)X
7 f
3144(\))X
1 f
3219(will)X
3379(generally)X
3730(not)X
3866(have)X
576 5196(the)N
713(same)X
923(values)X
1177(as)X
1279(when)X
1498(the)X
7 f
1665(-gk)X
1 f
1852(option)X
2106(is)X
2193(not)X
2334(used)X
2523(\(for)X
2 f
2682(k)X
1 f
2721(>=2\).)X
2966(Use)X
3130(attributes)X
3487(to)X
3584(access)X
3836(token)X
576 5324(values;)N
856(the)X
994(lookahead)X
1386(buffer)X
1630(is)X
1719(not)X
1862(really)X
2093(a)X
2162(user)X
2338(object.)X
2628(If)X
2716(you)X
2878(insist)X
3095(upon)X
3301(accessing)X
3668(the)X
3807(looka-)X
576 5452(head)N
772(buffer,)X
1038(use)X
7 f
1216(LA\(0\))X
1 f
1511(and)X
7 f
1699(LATEXT\(0\))X
1 f
2176(,)X
2227(which)X
2471(typically)X
2810(access)X
3063(the)X
3200(last)X
3352(token)X
3577(matched)X
3905(and)X
576 5580(last)N
722(text)X
878(matched)X
1201(respectively;)X
1676(this)X
1828(is)X
1911(distinguished)X
2406(from)X
7 f
2632(LA\(1\))X
1 f
2897(,)X
2943(which)X
3182(means)X
3431(the)X
3563(next)X
3739(token)X
3959(of)X
576 5708(lookahead.)N
1009(Accessing)X
1397(the)X
1532(next)X
1711(token)X
1934(of)X
2034(lookahead)X
2423(is)X
2509(invalid)X
2782(because)X
3087(it)X
3164(will)X
3328(not)X
3467(be)X
3576(fetched)X
3861(from)X
576 5836(the)N
706(input)X
910(stream)X
1167(until)X
1352(needed)X
1623(\(just)X
1802(before)X
2048(the)X
2178(next)X
2352(decision)X
2668(or)X
2763(match\).)X

10 p
%%Page: 10 10
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(10)X
2370(-)X
3 f
576 704(1.8.)N
752(Tutorials)X
1122(Available)X
1 f
776 860(With)N
982(release)X
1255(1.06,)X
1460(we)X
1592(are)X
1729(distributing)X
2167(both)X
2354(a)X
2423(beginning)X
2806(and)X
2963(advanced)X
3325(tutorial.)X
3655(They)X
3866(have)X
576 988(not)N
711(been)X
899(thoroughly)X
1308(``debugged'')X
1788(much)X
2006(are)X
2135(much)X
2353(better)X
2576(than)X
2750(nothing:)X
576 1144(Beginning)N
776 1272(This)N
955(tutorial)X
1233(introduces)X
1622(the)X
1752(basic)X
1955(functionality)X
2429(of)X
2525(PCCTS)X
2818(by)X
2929(example.)X
3295(The)X
3455(user)X
3624(need)X
3813(not)X
3949(be)X
776 1400(familiar)N
1079(with)X
1259(parsing)X
1541(theory)X
1789(or)X
1885(other)X
2089(compiler)X
2426(tools,)X
2643(but)X
2778(any)X
2927(familiarity)X
3323(reduces)X
3613(the)X
3743(learning)X
776 1528(curve)N
993(substantially.)X
576 1684(Advanced)N
776 1812(Constructing)N
1268(a)X
1343(translator)X
1713(can)X
1872(be)X
1992(viewed)X
2283(as)X
2393(an)X
2513(iterative)X
2840(re\256nement)X
3254(process)X
3554(moving)X
3861(from)X
776 1940(language)N
1119(recognition)X
1546(to)X
1640(intermediate-form)X
2307(transformation.)X
2895(This)X
3077(tutorial)X
3358(presents)X
3671(one)X
3822(possi-)X
776 2068(ble)N
914(sequence)X
1266(of)X
1369(re\256nements.)X
1854(It)X
1938(uses)X
2119(as)X
2222(many)X
2448(features)X
2756(of)X
2860(PCCTS)X
3161(as)X
3265(is)X
3355(reasonable)X
3762(without)X
776 2196(regards)N
1071(to)X
1177 0.3313(optimality.)AX
1623(It)X
1714(develops)X
2064(a)X
2139(compiler)X
2489(for)X
2627(a)X
2702(simple)X
2974(string)X
3211(manipulation)X
3714(language)X
776 2324(called)N
2 f
1009(sc)X
1 f
1082(.)X
1148(The)X
1307(resulting)X
1638(compiler)X
1974(generates)X
2328(code)X
2516(for)X
2640(a)X
2701(simple)X
2959(stack)X
3162(machine.)X
3 f
576 2580(1.9.)N
752(Error)X
994(Messages)X
1367(for)X
2 f
1501(k>)X
1 f
1599(1)X
776 2736(Previous)N
1110(versions)X
1429(of)X
1528(PCCTS)X
1824(did)X
1963(not)X
2102(handle)X
2363(error)X
2559(message)X
2883(correctly)X
3222(for)X
2 f
3350(k>)X
1 f
3448(1.)X
3562(For)X
3711(example,)X
576 2864(with)N
755(two)X
909(tokens)X
1161(of)X
1256(lookahead)X
1640(and)X
1789(the)X
1919(following)X
2284(grammar:)X
7 f
9 s
576 3028(a)N
662(:)X
748("A")X
920("B")X
1092("D")X
9 f
662 3116(|)N
7 f
719("A")X
891("C")X
1063("E")X
662 3204(;)N
1 f
11 s
576 3408(an)N
681(incorrect)X
1016(input)X
1220(of)X
1315(A)X
1400(D)X
1485(D)X
1570(would)X
1812(yield:)X
7 f
9 s
576 3572(line)N
791(1:)X
920(syntax)X
1221(error)X
1479(at)X
1608("A")X
1780(missing)X
2124(A)X
1 f
11 s
576 3776(which)N
823(is)X
914(wrong)X
1170(\(and)X
1358(incredibly)X
1748(confusing\).)X
2200(The)X
2369(new)X
2547(error)X
2749(mechanism)X
3183(generates)X
3548(the)X
3689(following)X
576 3904(error)N
768(message)X
1088(upon)X
1286(the)X
1416(same)X
1619(incorrect)X
1954(input:)X
7 f
9 s
576 4068(line)N
791(1:)X
920(syntax)X
1221(error)X
1479(at)X
1608("A)X
1737(D";)X
1909("D")X
2081(not)X
2253(in)X
2382({)X
2468(B)X
2554(C)X
2640(})X
1 f
11 s
576 4272(which)N
815(is)X
898(in\256nitely)X
1242(superior.)X
1598(Unfortunately,)X
2138(situations)X
2501(may)X
2677(arise)X
2868(when)X
3083(even)X
3274(this)X
3427(method)X
3717(will)X
3880(give)X
576 4400(an)N
685(invalid)X
957(message.)X
1325(This)X
1508(may)X
1686(occur)X
1907(when)X
2123(alternatives)X
2556(have)X
2748(lookahead)X
3136(sequences)X
3518(which)X
3759(are)X
3891(per-)X
576 4528(mutations)N
947(of)X
1042(the)X
1172(same)X
1375(tokens.)X
776 4684(The)N
939(de\256nition)X
1304(of)X
1403(the)X
1537(standard)X
1861(error)X
2057(reporting)X
2406(function,)X
7 f
2779(zzsyn\(\))X
1 f
3176(has)X
3319(been)X
3511(modi\256ed.)X
3895(The)X
576 4812(parameter)N
950(list)X
1081(is)X
1162(now:)X
7 f
9 s
576 4976(void)N
576 5064(zzsyn\(char)N
1049(*text,)X
834 5152(int)N
1006(tok,)X
834 5240(char)N
1049(*egroup,)X
834 5328(unsigned)N
1221(*eset,)X
834 5416(int)N
1006(etok,)X
834 5504(int)N
1006(k,)X
834 5592(char)N
1049(*bad_text\);)X

11 p
%%Page: 11 11
9 s 0 xH 0 xS 7 f
11 s
1 f
2209 416(-)N
2260(11)X
2370(-)X
576 704(Users)N
804(can)X
955(ignore)X
1209(this)X
1366(as)X
1468(it)X
1547(is)X
1635(transparent)X
2056(to)X
2155(them;)X
2387(unless,)X
2659(of)X
2762(course,)X
3043(the)X
3181(standard)X
3509(error)X
3709(reporting)X
576 832(must)N
770(be)X
875(modi\256ed.)X
1255(In)X
1350(addition,)X
7 f
1715(zzFAIL)X
1 f
2055(is)X
2136(now)X
2309(a)X
2370(function)X
2686(rather)X
2913(than)X
3087(a)X
3148(macro.)X
3 f
576 1088(1.10.)N
796(Trace)X
1038(Facility)X
1345(has)X
1494(Exit)X
1673(Macro)X
1 f
776 1244(Previously,)N
1215(only)X
1413(an)X
1537(entry)X
1759(trace)X
1971(macro)X
2232(was)X
2409(inserted)X
2729(in)X
2839(parsers)X
3128(when)X
3359(the)X
7 f
3539(-gd)X
1 f
3739(ANTLR)X
576 1372(option)N
847(was)X
1028(used.)X
1277(An)X
1428(exit)X
1605(macro)X
1869(has)X
2030(been)X
2240(de\256ned)X
2543(which)X
2802(resulted)X
3125(in)X
7 f
3269(zzTRACE)X
1 f
3684(becoming)X
7 f
576 1500(zzTRACEIN)N
1 f
1053(.)X
1126(Also,)X
1344(a)X
1413(default)X
1688(trace)X
1889(macro)X
2139(prints)X
2370(out)X
2513(``)X
7 f
2571(enter)X
2889(rule)X
2 f
3154(rule)X
1 f
3296('')X
3384(if)X
3468(no)X
3586(default)X
3861(trace)X
576 1628(macros)N
863(are)X
1003(de\256ned.)X
1339(To)X
1470(de\256ne)X
1718(your)X
1912(own,)X
2118(the)X
2259(macro)X
2512(de\256nitions)X
2918(must)X
3123(appear)X
3389(in)X
3490(the)X
7 f
3661(#header)X
1 f
576 1756(action.)N
863(As)X
987(before,)X
1260(the)X
1395(sole)X
1565(argument)X
1926(to)X
2023(the)X
2159(trace)X
2358(routines)X
2670(is)X
2757(a)X
2824(string)X
3053(representing)X
3516(the)X
3652(rule)X
3817(which)X
576 1884(has)N
715(been)X
903(entered)X
1184(or)X
1279(is)X
1360(about)X
1578(to)X
1669(be)X
1774(exited.)X
3 f
576 2140(1.11.)N
796(Resource)X
1164(Limitation)X
1 f
776 2296(Occasionally,)N
1293(ANTLR)X
1621(is)X
1715(unable)X
1985(to)X
2090(analyze)X
2395(a)X
2470(grammar)X
2824(submitted)X
3209(by)X
3333(the)X
3477(user.)X
3703(This)X
3896(rare)X
576 2424(situation)N
909(can)X
1059(only)X
1244(occur)X
1467(when)X
1684(the)X
1819(grammar)X
2164(is)X
2250(large)X
2453(and)X
2607(the)X
2742(amount)X
3034(of)X
3134(lookahead)X
3523(is)X
3609(greater)X
3880(than)X
576 2552(one.)N
773(A)X
862(nonlinear)X
1221(analysis)X
1531(algorithm)X
1901(is)X
1986(used)X
2173(by)X
2287(PCCTS)X
2583(to)X
2678(handle)X
2939(the)X
3073(general)X
3358(case)X
3535(of)X
2 f
3635(LL\(k\))X
1 f
3857(pars-)X
576 2680(ing.)N
761(The)X
926(average)X
1227(complexity)X
1653(of)X
1753(analysis,)X
2086(however,)X
2437(is)X
2523(near)X
2701(linear)X
2929(due)X
3083(to)X
3179(some)X
3392(fancy)X
3614(footwork)X
3963(in)X
576 2808(the)N
706 0.2885(implementation)AX
1284(which)X
1521(reduces)X
1811(the)X
1941(number)X
2232(of)X
2327(calls)X
2511(to)X
2602(the)X
2732(full)X
2 f
2877(LL\(k\))X
1 f
3094(algorithm.)X
776 2964(To)N
899(avoid)X
1120(the)X
1253(situation)X
1583(where)X
1822(ANTLR)X
2140(takes)X
2346(23)X
2459(hours)X
2679(of)X
2778(CPU)X
2975(time)X
3159(and)X
3312(then)X
3490(runs)X
3667(out)X
3806(of)X
3905(vir-)X
576 3092(tual)N
746(memory,)X
1099(use)X
1253(the)X
7 f
1429(-rl)X
2 f
1641(n)X
1 f
1722(resource)X
2055(limit)X
2260(option)X
2522(where)X
2 f
2772(n)X
1 f
2852(is)X
2947(the)X
3091(maximum)X
3486(number)X
3791(of)X
3900(tree)X
576 3220(nodes)N
810(to)X
908(be)X
1020(used)X
1210(by)X
1327(the)X
1464(analysis)X
1778(algorithm.)X
2196(An)X
2333(error)X
2533(message)X
2861(will)X
3029(be)X
3142(displayed,)X
3532(if)X
3616(this)X
3774(limit)X
3973(is)X
576 3348(reached,)N
899(which)X
1142(indicates)X
1484(which)X
1726(grammar)X
2071(construct)X
2421(was)X
2584(being)X
2807(analyzed)X
3147(when)X
3364(ANTLR)X
3684(hit)X
3805(a)X
3871(non-)X
576 3476(linearity.)N
944(Use)X
1109(this)X
1266(option)X
1521(if)X
1604(ANTLR)X
1926(seems)X
2170(to)X
2268(go)X
2385(off)X
2516(to)X
2614(lunch)X
2839(and)X
2995(your)X
3185(disk)X
3361(start)X
3542(swapping;)X
3934(try)X
2 f
576 3604(n)N
1 f
(=10000)S
918(to)X
1015(start.)X
1239(Once)X
1452(the)X
1587(offending)X
1956(construct)X
2306(has)X
2450(been)X
2643(identi\256ed,)X
3026(try)X
3151(to)X
3247(remove)X
3538(the)X
3673(ambiguity)X
576 3732(that)N
738(ANTLR)X
1060(was)X
1225(trying)X
1465(to)X
1563(overcome)X
1939(with)X
2125(large)X
2330(lookahead)X
2721(analysis.)X
3078(Future)X
3337(versions)X
3659(of)X
3762(PCCTS)X
576 3860(may)N
750(incorporate)X
1173(a)X
1234(known)X
1495(algorithm)X
1861(that)X
2016(does)X
2199(not)X
2334(exhibit)X
2602(this)X
2752(exponential)X
3186(behavior.)X
3 f
576 4116(1.12.)N
796(Rule)X
994(Pre\256x)X
1241(Option)X
1 f
776 4272(An)N
909(ANTLR)X
1228(option)X
1480(has)X
1623(been)X
1815(added)X
2051(that)X
2210(pre\256xes)X
2514(all)X
2630(functions)X
2985(corresponding)X
3515(to)X
3611(rules)X
3809(with)X
3993(a)X
576 4400(pre\256x.)N
848(This)X
1028(can)X
1173(be)X
1279(used)X
1463(to)X
1554(provide)X
1845(symbol)X
2127(hiding)X
2375(in)X
2466(your)X
2649(project)X
2916(to)X
3007(isolate)X
3260(the)X
3390(parser.)X
3670(It)X
3746(can)X
3890(also)X
576 4528(be)N
681(used)X
864(to)X
955(allow)X
1173(rule)X
1332(names)X
1579(that)X
1734(correspond)X
2146(to)X
2237(C)X
2318(keywords)X
2681(such)X
2864(as)X
2959(if)X
3035(and)X
7 f
3215(typedef)X
1 f
3586(.)X
3 f
576 4784(1.13.)N
796(Standard)X
1170(PCCTS)X
1480(Header)X
1 f
776 4940(Two)N
965(new)X
1139(ANTLR)X
1460(options)X
1748(have)X
1942(been)X
2136(added)X
2374(that)X
2536(control)X
2815(the)X
2952(creation)X
3265(of)X
3367(a)X
3435(standard)X
3762(PCCTS)X
576 5068(header)N
842(\256le)X
987(\320)X
7 f
1138(stdpccts.h)X
1 f
1668(.)X
1743(Option)X
7 f
2050(-gh)X
1 f
2240(instructs)X
2570(ANTLR)X
2894(to)X
2994(create)X
3235(a)X
3305(\256le,)X
7 f
3502(stdpccts.h)X
1 f
576 5196(unless)N
7 f
849(-fh)X
1 f
1031(is)X
1113(used,)X
1319(which)X
1557(contains)X
1874(all)X
1986(header)X
2243(information)X
2683(needed)X
2955(by)X
3066(non-PCCTS)X
3520(generated)X
3885(\256les)X
576 5324(that)N
736(want)X
934(to)X
1030(access)X
1281(PCCTS)X
1578(symbols.)X
1943(For)X
2092(example,)X
2440(it)X
2517(indicates)X
2858(the)X
2 f
2993(k)X
1 f
3059(of)X
3159(the)X
3294(parser,)X
3557(whether)X
3866(trees)X
576 5452(are)N
711(being)X
935(constructed,)X
1391(whether)X
1702(lookahead)X
2092(is)X
2179(to)X
2276(be)X
2387(delayed,)X
2711(and)X
2866(indicates)X
3208(what)X
3407(the)X
3544(user)X
3719(speci\256ed)X
576 5580(in)N
671(the)X
7 f
836(#header)X
1 f
1233(action)X
1475(in)X
1570(the)X
1703(grammar)X
2046(\256le.)X
2228(Previously,)X
2652(the)X
2785(user)X
2956(had)X
3108(to)X
3202(manually)X
3556(construct)X
3904(this)X
576 5708(information)N
1018(from)X
1214(the)X
1347(grammar)X
1690(\256le)X
1828(in)X
1922(order)X
2132(to)X
2226(place)X
2437(the)X
2570(information)X
3012(in)X
3106(a)X
3170(non-PCCTS)X
3627(C)X
3712(\256le.)X
3895(The)X
7 f
576 5836(-fh)N
1 f
757(option)X
1005(is)X
1086(merely)X
1353(used)X
1536(to)X
1627(rename)X
7 f
1939(stdpccts.h)X
1 f
2469(.)X

12 p
%%Page: 12 12
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(12)X
2370(-)X
3 f
576 704(1.14.)N
796(Doubly-Linked)X
1391(AST's)X
1 f
776 860(A)N
870(new)X
1047(function)X
1372(is)X
1462(available)X
1812(in)X
7 f
1943(ast.c)X
1 f
2239(which)X
2485(will)X
2654(doubly-link)X
3097(any)X
3255(tree)X
3419(that)X
3584(is)X
3675(passed)X
3941(in.)X
576 988(To)N
703(use)X
849(this)X
1006(option,)X
1282(the)X
1418(user)X
1592(must)X
1792(de\256ne)X
2035(zzAST_DOUBLE)X
2707(in)X
2804(the)X
7 f
2971(#header)X
1 f
3370(directive)X
3707(or)X
3808(on)X
3924(the)X
576 1116(command-line)N
1118(of)X
1223(the)X
1363(C)X
1454(compile.)X
1815(This)X
2004(de\256nes)X
7 f
2316(left)X
1 f
2560(and)X
7 f
2750(up)X
1 f
2888(\256elds)X
3111 0.2604(automatically)AX
3625(in)X
3726(the)X
3866(AST)X
576 1244(node)N
770(typedef.)X
1101(ANTLR)X
1417(generated)X
1782(parsers,)X
2075(normally,)X
2438(only)X
2617(construct)X
2962(singly-linked)X
3450(trees.)X
3682(The)X
3841(\256elds)X
576 1372(can)N
720(be)X
825(\256lled)X
1029(in)X
1120(via)X
1250(code)X
1438(similar)X
1706(to)X
1797(the)X
1927(following:)X
7 f
9 s
576 1536(#header)N
920(<<)X
576 1624(#define)N
920(AST_FIELDS)X
2 f
1476(user-\256elds)X
7 f
1776(;)X
576 1712(>>)N
576 1888(<<)N
576 1976(main\(\))N
576 2064({)N
756 2152(AST)N
928(*root)X
1186(=)X
1272(NULL;)X
756 2328 -0.1979(ANTLR\(start\(&root\),)AN
1616(stdin\);)X
756 2416 -0.1979(zzdouble_link\(root,)AN
1616(NULL,)X
1874(NULL\);)X
576 2504(})N
1 f
11 s
576 2708(where)N
812(the)X
942(function)X
1258(is)X
1339(de\256ned)X
1620(as:)X
7 f
9 s
576 2872 -0.1992(zzdouble_link\(AST)AN
1350(*t,)X
1522(AST)X
1694(*left,)X
1995(AST)X
2167(*up\);)X
3 f
11 s
576 3176(1.15.)N
796(C++)X
981(Compatible)X
1443(Parsers)X
1 f
776 3332(PCCTS)N
1070(parsers)X
1342(may)X
1518(now)X
1693(be)X
1800(compiled)X
2153(with)X
2334(C++)X
2517(compilers;)X
2914(i.e.)X
3046(the)X
3178(output)X
3428(is)X
3511(more)X
3716(ANSI)X
3944(C-)X
576 3460(like)N
738(than)X
919(before.)X
1216(It)X
1299(has)X
1445(been)X
1639(successfully)X
2097(compiled)X
2454(with)X
2639(GCC)X
2848(2.2,)X
3008(but)X
3149(not)X
3290(with)X
3475(GCC)X
3684(1.37.)X
3910(We)X
576 3588(do)N
688(not)X
825(guarantee)X
1191(anything.)X
1568(To)X
1690(be)X
1797(safe,)X
1984(use)X
2125(the)X
7 f
2288(-ga)X
1 f
2471(option)X
2721(so)X
2823(that)X
2980(PCCTS)X
3275(generates)X
3632(ANSI-style)X
576 3716(prototypes)N
970(for)X
1094(functions)X
1444(generated)X
1808(from)X
2001(rules.)X
2238(As)X
2357(a)X
2418(simple)X
2676(example,)X
3019(consider:)X
7 f
9 s
576 3880(#header)N
920(<<)X
576 3968(#include)N
963("charbuf.h")X
576 4056(/*)N
705(stdio.h)X
1049(is)X
1178(included,)X
1608(by)X
1737(default,)X
2124(but)X
2296(doesn't)X
2640(seem)X
2855(to)X
2984(bother)X
3285(stream.h)X
3672(*/)X
576 4144(#include)N
963()X
576 4232(#include)N
963()X
576 4320(>>)N
576 4496(#token)N
877("[\\)X
1049(\\t\\n]")X
1350(<>)X
576 4672(<<)N
576 4760(main\(\))N
576 4848({)N
920 4936(ANTLR\(a\(\),)N
1393(stdin\);)X
920 5024(cout)N
1135(<<)X
1264("end)X
1479(of)X
1608(C++)X
1780(test\\n";)X
576 5112(})N
576 5200(>>)N
576 5376(a)N
920(:)X
1264("A")X
1436("B")X
1608(<<)X
1737(cout)X
1952(<<)X
2081($1.text)X
2425(<<)X
2554($2.text)X
2898(<<)X
3027("\\n";)X
3285(>>)X
920 5464(;)N
1 f
11 s
576 5668(which)N
813(does)X
996(not)X
1131(do)X
1241(much:)X

13 p
%%Page: 13 13
11 s 0 xH 0 xS 1 f
9 s
2226 376(-)N
2268(13)X
2358(-)X
7 f
576 712(%)N
662(t)X
576 800(A)N
662(B)X
576 888(AB)N
576 976(end)N
748(of)X
877(C++)X
1049(test)X
576 1064(%)N
1 f
11 s
576 1268(but)N
719(it)X
799(does)X
990(compile)X
1305(with)X
1492(G++)X
1685(2.2)X
1825(except)X
2086(that)X
2250(a)X
2320(warning)X
2639(is)X
2729(generated)X
3102(concerning)X
7 f
3555(strncpy\(\))X
1 f
576 1396(not)N
714(being)X
935(declared)X
1258(before)X
1507(use.)X
1693(This)X
1875(is)X
1958(trivial)X
2194(to)X
2287(\256x,)X
2426(of)X
2523(course)X
2776(\320)X
2888(by)X
3000(modifying)X
3392(the)X
7 f
3555(charbuf.h)X
1 f
576 1524(\256le.)N
755(We)X
899(compiled)X
1250(this)X
1400(with:)X
7 f
9 s
576 1688(antlr)N
834(-k)X
963(2)X
1049(-gk)X
1221(-ga)X
1393(t.g)X
576 1776(Antlr)N
834(parser)X
1135(generator)X
1651(Version)X
1995(1.06)X
2296(1989-1992)X
576 1864(dlg)N
748(-C2)X
920(-i)X
1049(parser.dlg)X
1522(scan.c)X
576 1952(dlg)N
791(Version)X
1135(1.06)X
1436(1989-1992)X
576 2040(g++)N
748(-I.)X
920(-I../1.06/h)X
1436(-g)X
1565(-c)X
1694(scan.c)X
576 2128(g++)N
748(-I.)X
920(-I../1.06/h)X
1436(-g)X
1565(-c)X
1694(t.c)X
576 2216(t.c:)N
791(In)X
920(function)X
1307(`struct)X
1651(Attrib)X
1952(zzconstr_attr)X
2554(\(int,)X
2812(char)X
3027(*\)':)X
576 2304(t.c:19:)N
920(warning:)X
1307(implicit)X
1694(declaration)X
2210(of)X
2339(function)X
2726(`strncpy')X
576 2392(g++)N
748(-I.)X
920(-I../1.06/h)X
1436(-g)X
1565(-c)X
1694(err.c)X
576 2480(g++)N
748(-o)X
877(t)X
963(-I.)X
1135(-I../1.06/h)X
1651(-g)X
1780(scan.o)X
2081(t.o)X
2253(err.o)X
1 f
11 s
576 2684(We)N
720(anticipate)X
1086(a)X
1147(rewrite)X
1418(to)X
1509(be)X
1614(more)X
1817(C++)X
1998(sometime)X
2364(in)X
2455(the)X
2585(future.)X
3 f
576 2940(2.)N
686(Acknowledgements)X
1 f
776 3096(We)N
928(acknowledge)X
1422(Dan)X
1598(Lawrence)X
1974(of)X
2077(MDBS)X
2356(for)X
2488(the)X
2627(new)X
2804(error)X
3005(reporting)X
3359(facility)X
3641(concerning)X
576 3224(greater)N
844(than)X
1020(one)X
1171(token)X
1391(of)X
1488(lookahead;)X
1899(Dana)X
2108(Hoggatt,)X
2438(also)X
2604(of)X
2701(MDBS,)X
2996(suggested)X
3366(the)X
3497(rule)X
3657(pre\256x)X
3885(idea)X
576 3352(\()N
7 f
605(-gp)X
1 f
817(option\))X
1125(and)X
1305(beta)X
1505(tested)X
1764(1.06.)X
2015(We)X
2190(thank)X
2439(Ed)X
2590(Harfmann)X
3000(of)X
3127(MDBS)X
3430(for)X
3586(creating)X
3924(the)X
7 f
576 3480(makefile.os2)N
1 f
1241(\256les)X
1417(and)X
1573(porting)X
1857(it)X
1936(to)X
2034(the)X
2171(PC.)X
2352(We)X
2503(acknowledge)X
2995(the)X
3131(following)X
3502(beta)X
3677(testers)X
3930(for)X
576 3608(1.06)N
827(\(alphabetically\):)X
1525(Thomas)X
1906(Buehlman)X
2366(\([email protected]\),)X
3582(Peter)X
3861(Dahl)X
576 3736(\([email protected]\),)N
1715(Chris)X
2055(Song)X
2385(\([email protected]\),)X
3384(Ariel)X
3714(Tamches)X
576 3864(\([email protected]\).)N
1575(We)X
1723(reference)X
2075(Russell)X
2361(Quong)X
2626(\([email protected]\))X
3548(of)X
3648(Purdue)X
3924(EE)X
576 3992(for)N
784(his)X
993(work)X
1279(with)X
1541(us)X
1724(on)X
1917(de\256ning)X
2311(and)X
2543(re\256ning)X
2922(predicates.)X
3428(Ariel)X
3714(Tamches)X
576 4120(\([email protected]\))N
1537(deserves)X
1871(attention)X
2213(for)X
2347(hacking)X
2658(on)X
2778(the)X
2918(particulars)X
3322(of)X
3427(the)X
3568(alpha-release)X
576 4248(predicates.)N
3 f
576 4504(3.)N
686(Machine)X
1036(Compatibility)X
1 f
776 4660(PCCTS)N
1068(Version)X
1368(1.06)X
1544(has)X
1683(been)X
1871(tested)X
2099(on)X
2209(the)X
2339(following)X
2704(platforms:)X
576 4816(Sun)N
735(3/60)X
576 4972(Sun)N
735(SPARC)X
1036(I,)X
1109(II)X
576 5128(Encore)N
847(Multimax)X
1218(running)X
1514(Umax)X
1751(4.3)X
576 5284(Sun)N
735(sparcstation)X
1178(IPX)X
576 5440(NeXTstation)N
576 5596(Decstation)N
975(3100)X
1173(running)X
1469(Ultrix)X
1702(4.2)X

14 p
%%Page: 14 14
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(14)X
2370(-)X
576 704(DEC)N
774(5000)X
576 860(Linux)N
809(on)X
919(386PC)X
576 1016(Microsoft)N
945(C)X
1026(6.0)X
1158(on)X
1268(PC)X
1398(OS/2,)X
1623(DOS)X
576 1172(CSET/2)N
883(C)X
964(compiler)X
1300(on)X
1410(PC)X
1540(OS/2)X
576 1328(IBM)N
764(RS6000)X
576 1484(MIPS)N
803(r2000)X
3 f
576 1740(4.)N
686(Incompatibilities)X
1 f
776 1896(Due)N
945(to)X
1037(the)X
1168(bug)X
1324(\256xes)X
1514(in)X
1607(1.06,)X
1807(``new'')X
2093(ambiguities)X
2530(may)X
2706(appear)X
2964(in)X
3057(your)X
3242(grammar.)X
3628(These)X
3862(were)X
576 2024(always)N
842(there\320ANTLR)X
1421(simply)X
1684(did)X
1819(not)X
1954(\256nd)X
2113(them.)X
2356(The)X
2515(analysis)X
2821(is)X
2902(more)X
3105(correct.)X
776 2180(Calls)N
996(to)X
7 f
1134(zzTRACE)X
1 f
1543(are)X
1688(no)X
1814(longer)X
2078(generated)X
2459(by)X
2586(the)X
7 f
2764(-gd)X
1 f
2962(option.)X
3271(Now,)X
7 f
3533(zzTRACEIN)X
1 f
4010(,)X
7 f
576 2308(zzTRACEOUT)N
1 f
1128(are)X
1257(called)X
1490(at)X
1576(the)X
1706(beginning)X
2081(and)X
2230(end)X
2379(of)X
2474(functions,)X
2846(respectively.)X
776 2464(The)N
948(way)X
1129(in)X
1233(which)X
1483(PCCTS)X
1788(translates)X
2156(actions)X
2441(has)X
2593(been)X
2795(changed;)X
3149(before)X
3409(they)X
3597(were)X
3803(parsed)X
576 2592(with)N
760(a)X
826(C)X
912(function,)X
1255(now)X
1433(the)X
7 f
1599(#lexclass)X
1 f
2103(facility)X
2381(is)X
2467(being)X
2690(used.)X
2921(Some)X
3148(differences)X
3564(in)X
3659(translation)X
576 2720(may)N
758(be)X
871(discovered;)X
1307(e.g.)X
1464(a)X
1533(character)X
1885(may)X
2067(need)X
2263(to)X
2362(be)X
2475(escaped)X
2783(with)X
7 f
3001(\\)X
1 f
3084(whereas)X
3402(before)X
3657(the)X
3796(simple)X
576 2848(character)N
920(was)X
1078(suf\256cient.)X
776 3004(The)N
942(user)X
1117(should)X
1381(no)X
1498(longer)X
1752(set)X
1879(the)X
2016(next)X
2197(token)X
2422(of)X
2524(lookahead)X
2915(or)X
3017(the)X
3154(text)X
3316(of)X
3418(the)X
3555(next)X
3737(token)X
3963(in)X
576 3132(the)N
727(lexical)X
1006(analyzer)X
1347(using)X
7 f
1612(LA\(1\))X
1 f
1920(and)X
7 f
2121(LATEXT\(1\))X
1 f
2598(.)X
2685(This)X
2885(is)X
2987(incompatible)X
3492(with)X
3692(the)X
7 f
3873(-gk)X
1 f
576 3260(option;)N
849(hence,)X
7 f
1129(NLA)X
1 f
1310(and)X
7 f
1490(NLATEXT)X
1 f
1883(should)X
2140(be)X
2245(used)X
2428(instead)X
2700(where)X
2936(the)X
7 f
3097(N)X
1 f
3172(means)X
3419(``next''.)X
776 3416(The)N
7 f
967(-ga)X
1 f
1149(does)X
1333(not)X
1469(generate)X
1791(anything)X
2124(different)X
2451(as)X
2548(the)X
2680(code)X
2870(generator)X
3226(now)X
3401(dumps)X
3660(both)X
3841(K&R)X
576 3544(and)N
725(ANSI)X
951(with)X
7 f
1161(#ifdef)X
1 f
1479('s)X
1564(around)X
1830(the)X
1960(ANSI)X
2186(code.)X
776 3700(Previously,)N
1203(no)X
1319(prototype)X
1685(was)X
1849(given)X
2073(when)X
7 f
2322(-ga)X
1 f
2509(was)X
2673(off.)X
2847(Now,)X
3067(prototypes)X
3467(are)X
3603(always)X
3876(gen-)X
576 3828(erated)N
839(\(with)X
1073(the)X
1229(appropriated)X
7 f
1753(#ifdef)X
1 f
2071('s\).)X
2255(These)X
2513(prototypes)X
2933(can)X
3103(con\257ict)X
3416(with)X
3621(the)X
3777(outside)X
576 3956(environment)N
1050(if)X
1132(the)X
1269(rule)X
1435(names)X
1689(are)X
1825(things)X
2070(like)X
7 f
2263(if)X
1 f
2398(and)X
7 f
2585(stat)X
1 f
2826(\(which)X
3099(is)X
3187(a)X
3255(system)X
3529(call\).)X
3759(Use)X
3924(the)X
7 f
576 4084(-gp)N
2 f
788(pre\256x)X
1 f
1010(option)X
1258(to)X
1349(pre\256x)X
1576(all)X
1687(functions)X
2037(corresponding)X
2562(to)X
2653(rules)X
2846(with)X
3025(a)X
3086(string)X
3309(of)X
3404(your)X
3587(choice.)X
3 f
576 4340(5.)N
686(Future)X
967(Work:)X
1 f
776 4496(Predicates)N
1175(are)X
1319(still)X
1490(under)X
1727(development.)X
2264(We)X
2424(expect)X
2692(an)X
2813(enhanced)X
3183(version)X
3480(of)X
3591(PCCTS)X
3899(that)X
576 4624(computes)N
936(context)X
1218(and)X
1367(hoists)X
1595(more)X
1798(aggressively.)X
776 4780(Often)N
1004(a)X
1071(grammar)X
1417(construct)X
1768(cannot)X
2031(be)X
2142(left)X
2288(factored)X
2604(to)X
2701(remove)X
2993(an)X
3104(ambiguity.)X
3536(This)X
3722(typically)X
576 4908(arises)N
805(in)X
903(the)X
1040(situation)X
1373(that)X
1534(the)X
1670(common)X
2007(pre\256x)X
2240(can)X
2390(be)X
2501(arbitrarily)X
2882(long.)X
3111(Fortunately,)X
3568(input)X
3778(is)X
3865(typi-)X
576 5036(cally)N
782(\256nite)X
998(and)X
1159(one)X
1320(could)X
1550(scan)X
1740(past)X
1916(these)X
2132(constructs)X
2524(given)X
2755(enough)X
3049(lookahead.)X
3490(This)X
3682(is)X
3776(not)X
3924(the)X
576 5164(same)N
782(thing)X
989(as)X
1087(backtracking)X
1567(as)X
1665(the)X
1798(parser)X
2037(never)X
2257(backs)X
2482(up;)X
2619(it)X
2693(simply)X
2958(looks)X
3173(ahead)X
3402(really)X
3627(far)X
3748(to)X
3841(make)X
576 5292(a)N
637(decision.)X
997(This)X
1176(can)X
1320(easily)X
1548(be)X
1653(handled)X
1954(with)X
2133(a)X
2194(predicate)X
2539(of)X
2634(the)X
2764(form:)X
7 f
9 s
576 5456 -0.1964(< 2 f
1522(context)X
7 f
1730(\)>>?)X
1 f
11 s
576 5660(which)N
816(would)X
1061(look)X
1243(ahead)X
1473(in)X
1567(the)X
1700(lookahead)X
2087(buffer)X
2326(to)X
2420(see)X
2558(if)X
2638(the)X
2 f
2772(context)X
1 f
3053(occurred)X
3386(within)X
3638(some)X
3850(\256nite)X
576 5788(number)N
875(of)X
978(tokens.)X
1282(This)X
1469(concept)X
1773(is)X
1862(very)X
2047(similar)X
2322(to)X
2420(LR-Regular)X
2870(\(LRR\))X
3129(parsers)X
3406(for)X
3537(those)X
3752(familiar)X

15 p
%%Page: 15 15
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(15)X
2370(-)X
576 704(with)N
766(parsing)X
1058(theory.)X
1360(Note)X
1564(that)X
1731(this)X
1893(is)X
1986(a)X
2059(very)X
2249(fast,)X
2432(cheap)X
2671(way)X
2851(to)X
2954(get)X
3096(something)X
3498(resembling)X
3924(the)X
576 832(power)N
817(of)X
912(backtracking.)X
776 988(Attribute)N
1131(names)X
1392(are)X
1535(expected)X
1884(to)X
1989(be)X
2108(enhanced.)X
2521(For)X
2680(example,)X
3038(instead)X
3325(of)X
3435($i,)X
3563($)X
2 f
(token_name)S
1 f
576 1116(could)N
794(be)X
899(used:)X
7 f
9 s
576 1280(a)N
662(:)X
748(WORD)X
963(TYPE)X
1178(< 1737(%s\\n",)X
2038($WORD,)X
2339($TYPE\);>>)X
662 1368(;)N
1 f
11 s
776 1572(We)N
920(expect)X
1172(to)X
1263(have)X
1451(a)X
1512(graphical)X
1862(user)X
2030(interface)X
2360(to)X
2451(PCCTS)X
2743(sometime)X
3109(in)X
3200(the)X
3331(future)X
3564(which)X
3802(allows)X
576 1700(entry)N
781(of)X
878(grammars)X
1254(using)X
1469(syntax)X
1723(diagram)X
2036(notation.)X
2394(The)X
2555(interface)X
2887(is)X
2970(expected)X
3307(to)X
3400(run)X
3541(under)X
3765(X)X
3851(Win-)X
576 1828(dows.)N
776 1984(We)N
940(anticipate)X
1327(a)X
1409(version)X
1711(that)X
1887(supports)X
2228(object-oriented)X
2805(programming)X
3328(and)X
3498(generates)X
3873(C++)X
576 2112(instead)N
858(of)X
963(ANSI)X
1199(C.)X
1334(For)X
1488(the)X
1627(moment,)X
1970(PCCTS)X
2271(is)X
2361(compatible)X
2785(with)X
2973(C++,)X
3185(but)X
3329(future)X
3570(versions)X
3894(will)X
576 2240(support)N
862(C++.)X
776 2396(Future)N
1067(versions,)X
1443(both)X
1661(C)X
1781(and)X
1970(C++,)X
2213(will)X
2413(be)X
2558(able)X
2767(to)X
2898(refer)X
3125(to)X
3256(PCCTS)X
3588(symbols)X
3944(by)X
7 f
576 2524(pccts.)N
2 f
894(symbol)X
1 f
1165(instead)X
1437(of)X
7 f
1563(zz)X
2 f
1669(symbol)X
1 f
1918(.)X
1984(E.g.)X
7 f
2179(zzskip\(\))X
1 f
2625(will)X
2785(become)X
7 f
3112(pccts.skip\(\))X
1 f
3748(.)X
776 2680(DLG)N
993(will)X
1168(soon)X
1371(use)X
1525(lookahead)X
1924(of)X
2034(its)X
2155(own)X
2343(to)X
2450(allow)X
2684(the)X
2830(recognition)X
3270(of)X
3381(more)X
3600(complicated)X
576 2808(expressions;)N
1039(speci\256cally,)X
1491(those)X
1705(which)X
1948(have)X
2142(left)X
2288(substrings)X
2673(in)X
2770(common)X
3106(with)X
3290(other)X
3498(regular)X
3774(expres-)X
576 2936(sions.)N
776 3092(We)N
932(expect)X
1196(future)X
1440(versions)X
1767(of)X
1874(PCCTS)X
2178(to)X
2281(dump)X
2516(grammar)X
2868(analysis)X
3186(and)X
3347(parser)X
3596(construction)X
576 3220(statistics)N
903(such)X
1086(as)X
1181(how)X
1354(many)X
1572(rules)X
1765(required)X
2080(1)X
2146(token)X
2364(of)X
2459(lookahead,)X
2865(how)X
3038(many)X
3256(ambiguities)X
3691(etc...)X

15 p
%%Trailer
xt

xs
14
11 s 0 xH 0pccts/UPDAT110.ps 644 1377 31 421545 5655551666 7010 %!PS-Adobe-1.0
%%Creator: garage.ecn.purdue.edu:pccts (Purdue Compiler-Construction Tool Set,,,,Ex;ee;hankd;)
%%Title: stdin (ditroff)
%%CreationDate: Mon Aug 30 14:57:01 1993
%%EndComments
% Start of psdit.pro -- prolog for ditroff translator
% Copyright (c) 1985,1987 Adobe Systems Incorporated. All Rights Reserved.
% GOVERNMENT END USERS: See Notice file in TranScript library directory
% -- probably /usr/lib/ps/Notice
% RCS: $Header: /home/aquarium/prm/usr/src/usr.lib/ps/lib/RCS/psdit.pro,v 1.2 89/02/24 09:57:06 prm Exp $
/$DITroff 180 dict def $DITroff begin
%% Psfig additions

/DocumentInitState [ matrix currentmatrix currentlinewidth currentlinecap
currentlinejoin currentdash currentgray currentmiterlimit ] cvx def

/startFig {
/SavedState save def
userdict maxlength dict begin
currentpoint transform

DocumentInitState setmiterlimit setgray setdash setlinejoin setlinecap
setlinewidth setmatrix

itransform moveto

/ury exch def
/urx exch def
/lly exch def
/llx exch def
/y exch 72 mul resolution div def
/x exch 72 mul resolution div def

currentpoint /cy exch def /cx exch def

/sx x urx llx sub div def % scaling for x
/sy y ury lly sub div def % scaling for y

sx sy scale % scale by (sx,sy)

cx sx div llx sub
cy sy div ury sub translate

/DefFigCTM matrix currentmatrix def

/initmatrix {
DefFigCTM setmatrix
} def
/defaultmatrix {
DefFigCTM exch copy
} def

/initgraphics {
DocumentInitState setmiterlimit setgray setdash
setlinejoin setlinecap setlinewidth setmatrix
DefFigCTM setmatrix
} def

/showpage {
initgraphics
} def

} def
% Args are llx lly urx ury (in figure coordinates)
/clipFig {
currentpoint 6 2 roll
newpath 4 copy
4 2 roll moveto
6 -1 roll exch lineto
exch lineto
exch lineto
closepath clip
newpath
moveto
} def
% doclip, if called, will always be just after a `startfig'
/doclip { llx lly urx ury clipFig } def
/endFig {
end SavedState restore
} def
/globalstart {
% Push details about the enviornment on the stack.
fontnum fontsize fontslant fontheight firstpage
mh my resolution slotno currentpoint
pagesave restore gsave
} def
/globalend {
grestore moveto
/slotno exch def /resolution exch def /my exch def
/mh exch def /firstpage exch def /fontheight exch def
/fontslant exch def /fontsize exch def /fontnum exch def
F
/pagesave save def
} def

%% end XMOD additions
/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def
/xi {0 72 11 mul translate 72 resolution div dup neg scale 0 0 moveto
/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def F
/pagesave save def}def
/PB{save /psv exch def currentpoint translate
resolution 72 div dup neg scale 0 0 moveto}def
/PE{psv restore}def
/m1 matrix def /m2 matrix def /m3 matrix def /oldmat matrix def
/tan{dup sin exch cos div}bind def
/point{resolution 72 div mul}bind def
/dround {transform round exch round exch itransform}bind def
/xT{/devname exch def}def
/xr{/mh exch def /my exch def /resolution exch def}def
/xp{}def
/xs{docsave restore end}def
/xt{}def
/xf{/fontname exch def /slotno exch def fontnames slotno get fontname eq not
{fonts slotno fontname findfont put fontnames slotno fontname put}if}def
/xH{/fontheight exch def F}bind def
/xS{/fontslant exch def F}bind def
/s{/fontsize exch def /fontheight fontsize def F}bind def
/f{/fontnum exch def F}bind def
/F{fontheight 0 le {/fontheight fontsize def}if
fonts fontnum get fontsize point 0 0 fontheight point neg 0 0 m1 astore
fontslant 0 ne{1 0 fontslant tan 1 0 0 m2 astore m3 concatmatrix}if
makefont setfont .04 fontsize point mul 0 dround pop setlinewidth}bind def
/X{exch currentpoint exch pop moveto show}bind def
/N{3 1 roll moveto show}bind def
/Y{exch currentpoint pop exch moveto show}bind def
/S /show load def
/ditpush{}def/ditpop{}def
/AX{3 -1 roll currentpoint exch pop moveto 0 exch ashow}bind def
/AN{4 2 roll moveto 0 exch ashow}bind def
/AY{3 -1 roll currentpoint pop exch moveto 0 exch ashow}bind def
/AS{0 exch ashow}bind def
/MX{currentpoint exch pop moveto}bind def
/MY{currentpoint pop exch moveto}bind def
/MXY /moveto load def
/cb{pop}def % action on unknown char -- nothing for now
/n{}def/w{}def
/p{pop showpage pagesave restore /pagesave save def}def
/abspoint{currentpoint exch pop add exch currentpoint pop add exch}def
/dstroke{currentpoint stroke moveto}bind def
/Dl{2 copy 2 copy gsave 0 eq exch 0 eq and
{rlineto currentlinecap 1 setlinecap stroke setlinecap}
{rlineto stroke}
ifelse grestore rmoveto}bind def
/arcellipse{oldmat currentmatrix pop
currentpoint translate 1 diamv diamh div scale /rad diamh 2 div def
rad 0 rad -180 180 arc oldmat setmatrix}def
/Dc{gsave dup /diamv exch def /diamh exch def arcellipse dstroke
grestore diamh 0 rmoveto}def
/De{gsave /diamv exch def /diamh exch def arcellipse dstroke
grestore diamh 0 rmoveto}def
/Da{currentpoint /by exch def /bx exch def /fy exch def /fx exch def
/cy exch def /cx exch def /rad cx cx mul cy cy mul add sqrt def
/ang1 cy neg cx neg atan def /ang2 fy fx atan def cx bx add cy by add
2 copy rad ang1 ang2 arcn stroke exch fx add exch fy add moveto}def
/Barray 200 array def % 200 values in a wiggle
/D~{mark}def
/D~~{counttomark Barray exch 0 exch getinterval astore /Bcontrol exch def pop
/Blen Bcontrol length def Blen 4 ge Blen 2 mod 0 eq and
{Bcontrol 0 get Bcontrol 1 get abspoint /Ycont exch def /Xcont exch def
Bcontrol 0 2 copy get 2 mul put Bcontrol 1 2 copy get 2 mul put
Bcontrol Blen 2 sub 2 copy get 2 mul put
Bcontrol Blen 1 sub 2 copy get 2 mul put
/Ybi /Xbi currentpoint 3 1 roll def def 0 2 Blen 4 sub
{/i exch def
Bcontrol i get 3 div Bcontrol i 1 add get 3 div
Bcontrol i get 3 mul Bcontrol i 2 add get add 6 div
Bcontrol i 1 add get 3 mul Bcontrol i 3 add get add 6 div
/Xbi Xcont Bcontrol i 2 add get 2 div add def
/Ybi Ycont Bcontrol i 3 add get 2 div add def
/Xcont Xcont Bcontrol i 2 add get add def
/Ycont Ycont Bcontrol i 3 add get add def
Xbi currentpoint pop sub Ybi currentpoint exch pop sub rcurveto
}for dstroke}if}def
end
/ditstart{$DITroff begin
/nfonts 60 def % NFONTS makedev/ditroff dependent!
/fonts[nfonts{0}repeat]def
/fontnames[nfonts{()}repeat]def
/docsave save def
}def

% character outcalls
/oc {/pswid exch def /cc exch def /name exch def
/ditwid pswid fontsize mul resolution mul 72000 div def
/ditsiz fontsize resolution mul 72 div def
ocprocs name known{ocprocs name get exec}{name cb}
ifelse}def
/fractm [.65 0 0 .6 0 0] def
/fraction
{/fden exch def /fnum exch def gsave /cf currentfont def
cf fractm makefont setfont 0 .3 dm 2 copy neg rmoveto
fnum show rmoveto currentfont cf setfont(\244)show setfont fden show
grestore ditwid 0 rmoveto} def
/oce {grestore ditwid 0 rmoveto}def
/dm {ditsiz mul}def
/ocprocs 50 dict def ocprocs begin
(14){(1)(4)fraction}def
(12){(1)(2)fraction}def
(34){(3)(4)fraction}def
(13){(1)(3)fraction}def
(23){(2)(3)fraction}def
(18){(1)(8)fraction}def
(38){(3)(8)fraction}def
(58){(5)(8)fraction}def
(78){(7)(8)fraction}def
(sr){gsave .05 dm .16 dm rmoveto(\326)show oce}def
(is){gsave 0 .15 dm rmoveto(\362)show oce}def
(->){gsave 0 .02 dm rmoveto(\256)show oce}def
(<-){gsave 0 .02 dm rmoveto(\254)show oce}def
(==){gsave 0 .05 dm rmoveto(\272)show oce}def
end
% DIThacks fonts for some special chars
50 dict dup begin
/FontType 3 def
/FontName /DIThacks def
/FontMatrix [.001 0.0 0.0 .001 0.0 0.0] def
/FontBBox [-220 -280 900 900] def% a lie but ...
/Encoding 256 array def
0 1 255{Encoding exch /.notdef put}for
Encoding
dup 8#040/space put %space
dup 8#110/rc put %right ceil
dup 8#111/lt put %left top curl
dup 8#112/bv put %bold vert
dup 8#113/lk put %left mid curl
dup 8#114/lb put %left bot curl
dup 8#115/rt put %right top curl
dup 8#116/rk put %right mid curl
dup 8#117/rb put %right bot curl
dup 8#120/rf put %right floor
dup 8#121/lf put %left floor
dup 8#122/lc put %left ceil
dup 8#140/sq put %square
dup 8#141/bx put %box
dup 8#142/ci put %circle
dup 8#143/br put %box rule
dup 8#144/rn put %root extender
dup 8#145/vr put %vertical rule
dup 8#146/ob put %outline bullet
dup 8#147/bu put %bullet
dup 8#150/ru put %rule
dup 8#151/ul put %underline
pop
/DITfd 100 dict def
/BuildChar{0 begin
/cc exch def /fd exch def
/charname fd /Encoding get cc get def
/charwid fd /Metrics get charname get def
/charproc fd /CharProcs get charname get def
charwid 0 fd /FontBBox get aload pop setcachedevice
40 setlinewidth
newpath 0 0 moveto gsave charproc grestore
end}def
/BuildChar load 0 DITfd put
%/UniqueID 5 def
/CharProcs 50 dict def
CharProcs begin
/space{}def
/.notdef{}def
/ru{500 0 rls}def
/rn{0 750 moveto 500 0 rls}def
/vr{20 800 moveto 0 -770 rls}def
/bv{20 800 moveto 0 -1000 rls}def
/br{20 770 moveto 0 -1040 rls}def
/ul{0 -250 moveto 500 0 rls}def
/ob{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath stroke}def
/bu{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath fill}def
/sq{80 0 rmoveto currentpoint dround newpath moveto
640 0 rlineto 0 640 rlineto -640 0 rlineto closepath stroke}def
/bx{80 0 rmoveto currentpoint dround newpath moveto
640 0 rlineto 0 640 rlineto -640 0 rlineto closepath fill}def
/ci{355 333 rmoveto currentpoint newpath 333 0 360 arc
50 setlinewidth stroke}def

/lt{20 -200 moveto 0 550 rlineto currx 800 2cx s4 add exch s4 a4p stroke}def
/lb{20 800 moveto 0 -550 rlineto currx -200 2cx s4 add exch s4 a4p stroke}def
/rt{20 -200 moveto 0 550 rlineto currx 800 2cx s4 sub exch s4 a4p stroke}def
/rb{20 800 moveto 0 -500 rlineto currx -200 2cx s4 sub exch s4 a4p stroke}def
/lk{20 800 moveto 20 300 -280 300 s4 arcto pop pop 1000 sub
currentpoint stroke moveto
20 300 4 2 roll s4 a4p 20 -200 lineto stroke}def
/rk{20 800 moveto 20 300 320 300 s4 arcto pop pop 1000 sub
currentpoint stroke moveto
20 300 4 2 roll s4 a4p 20 -200 lineto stroke}def
/lf{20 800 moveto 0 -1000 rlineto s4 0 rls}def
/rf{20 800 moveto 0 -1000 rlineto s4 neg 0 rls}def
/lc{20 -200 moveto 0 1000 rlineto s4 0 rls}def
/rc{20 -200 moveto 0 1000 rlineto s4 neg 0 rls}def
end

/Metrics 50 dict def Metrics begin
/.notdef 0 def
/space 500 def
/ru 500 def
/br 0 def
/lt 250 def
/lb 250 def
/rt 250 def
/rb 250 def
/lk 250 def
/rk 250 def
/rc 250 def
/lc 250 def
/rf 250 def
/lf 250 def
/bv 250 def
/ob 350 def
/bu 350 def
/ci 750 def
/bx 750 def
/sq 750 def
/rn 500 def
/ul 500 def
/vr 0 def
end

DITfd begin
/s2 500 def /s4 250 def /s3 333 def
/a4p{arcto pop pop pop pop}def
/2cx{2 copy exch}def
/rls{rlineto stroke}def
/currx{currentpoint pop}def
/dround{transform round exch round exch itransform} def
end
end
/DIThacks exch definefont pop

ditstart
(psc)xT
576 1 1 xr
1(Times-Roman)xf 1 f
2(Times-Italic)xf 2 f
3(Times-Bold)xf 3 f
4(Times-BoldItalic)xf 4 f
5(Helvetica)xf 5 f
6(Helvetica-Bold)xf 6 f
7(Courier)xf 7 f
8(Courier-Bold)xf 8 f
9(Symbol)xf 9 f
10(DIThacks)xf 10 f
10 s
1 f
xi
%%EndProlog

%%Page: 1 1
10 s 0 xH 0 xS 1 f
15 s
1237 680(The)N
1453(Purdue)X
1823(Compiler)X
2308(Construction)X
2960(Tool)X
3217(Set)X
13 s
1726 784(Version)N
2082(1.10)X
2290(Release)X
2639(Notes)X
3 f
1909 992(ANTLR)N
1 f
2298(and)X
3 f
2474(DLG)X
2 f
11 s
2016 1200(August)N
2283(31,)X
2415(1993)X
2068 1408(Terence)N
2373(Parr)X
1 f
1345 1512(Army)N
1572(High)X
1770(Performance)X
2241(Computing)X
2661(Research)X
3005(Center,)X
1989 1616(University)N
2383(of)X
2478(MN)X
10 s
1965 1720(\()N
7 f
1992([email protected])X
1 f
(\))S
2 f
11 s
1817 1928(Will)N
1987(Cohen)X
2239(and)X
2393(Hank)X
2605(Dietz)X
1 f
1727 2032(School)N
1994(of)X
2089(Electrical)X
2450(Engineering)X
1982 2136(Purdue)N
2253(University)X
10 s
1773 2240(\()N
7 f
1800([email protected])X
1 f
(\))S
1797 2344(\()N
7 f
1824([email protected])X
1 f
(\))S
3 f
11 s
576 2656(1.)N
686(Introduction)X
1 f
776 2816(This)N
958(document)X
1331(describes)X
1683(the)X
1816(changes/enhancements)X
2648(in)X
2742(PCCTS)X
3037(since)X
3243(version)X
3528(1.06.)X
3752(As)X
3875(with)X
576 2920(the)N
725(1.06)X
920(release)X
1205(notes,)X
1454(these)X
1676(notes)X
1903(do)X
2032(not)X
2186(constitute)X
2571(the)X
2720(complete)X
3084(reference)X
3450(manual.)X
3794(Unfor-)X
576 3024(tunately,)N
906(the)X
1037(reference)X
1386(manual)X
1669(is)X
1751(in)X
1843(the)X
1974(same)X
2179(condition)X
2537(as)X
2634(it)X
2708(was)X
2868(for)X
2994(the)X
3126(1.00)X
3304(release)X
3572(in)X
3665(the)X
3797(Spring)X
576 3128(of)N
673(1992.)X
917(We)X
1063(are)X
1194(working)X
1511(on)X
1623(a)X
1686(total)X
1868(rewrite)X
2141(of)X
2238(the)X
2370(manual,)X
2676(which)X
2914(might)X
3144(end)X
3294(up)X
3405(in)X
3497(a)X
3559(book)X
3758(consist-)X
576 3232(ing)N
730(of)X
844(the)X
993(theory)X
1259(behind)X
1540(practical)X
2 f
10 s
1883(k)X
1 f
11 s
1919(-token)X
2185(lookahead)X
2588(for)X
2 f
10 s
2729(k)X
2778(>)X
1 f
(1)S
11 s
2913(\(Terence)X
3266(Parr's)X
3516(Ph.D.)X
3780(thesis\),)X
576 3336(ANTLR)N
891 0.2885(implementation)AX
1469(notes,)X
1699(and)X
1848(the)X
1978(PCCTS)X
2270(user's)X
2501(manual.)X
776 3468(The)N
955(1.10)X
1151(release)X
1438(of)X
1554(PCCTS)X
1867(has)X
2027(four)X
2216(main)X
2436(enhancements:)X
3003(fully)X
3213(implemented)X
3718(semantic)X
576 3572(predicates)N
966(\()X
7 f
995(<<...>>?)X
1 f
1419(\),)X
1503(in\256nite)X
1787(lookahead)X
2182(\(plus)X
2391(selective)X
2732(backtracking)X
3219(that)X
3384(uses)X
3567(it\),)X
3700(increased)X
576 3676(ANTLR)N
891(\(see)X
7 f
1085(-ck)X
1 f
1266(and)X
7 f
1446(ZZUSE_MACROS)X
1 f
2104(sections\))X
2439(and)X
2588(DLG)X
2790(speed,)X
3034(and)X
3183(the)X
3313(ability)X
3562(to)X
3654(link)X
3815(multi-)X
576 3780(ple)N
709(ANTLR)X
1027(parsers)X
1300(together.)X
1658(A)X
1746(number)X
2040(of)X
2138(bug)X
2294(\256xes)X
2484(have)X
2674(been)X
2864(incorporated)X
3333(as)X
3430(well.)X
3650(The)X
3811(tutori-)X
576 3884(als)N
696(have)X
884(not)X
1019(been)X
1207(updated)X
1508(much)X
1726(for)X
1850(this)X
2000(release.)X
776 4016(To)N
897(better)X
1121(support)X
1408(our)X
1548(user's,)X
1803(we)X
1929(have)X
2119(established)X
2535(a)X
2598(mailing)X
2893(list)X
3026(called)X
7 f
3292(pccts-users)X
1 f
3899(that)X
576 4120(you)N
739(can)X
892(subscribe)X
1255(to)X
1354(by)X
1472(sending)X
1776(email)X
2003(to)X
7 f
2133 0.1937([email protected])AX
1 f
3806(with)X
3993(a)X
576 4224(body)N
798(of)X
917(``)X
7 f
975(subscribe)X
1529(pccts-users)X
2 f
2158(your-name)X
1 f
2538(''.)X
2687(Users)X
2933(that)X
3113(have)X
3326(registered)X
3720(with)X
3924(the)X
576 4328(PCCTS)N
883(mail)X
1077(server)X
1327(at)X
7 f
1458 0.1974([email protected]due.edu)AX
1 f
2554(have)X
3 f
2756(not)X
1 f
2914(been)X
3116 0.2604(automatically)AX
3634(subscribed.)X
576 4432(Once)N
788(you)X
947(have)X
1140(subscribed,)X
1565(posting)X
1852(a)X
1918(message)X
2243(to)X
2340(the)X
2476(PCCTS)X
2774(community)X
3205(is)X
3292(as)X
3393(simple)X
3657(as)X
3758(sending)X
576 4536(email)N
810(to)X
7 f
947 0.1950([email protected])AX
1 f
2362(\(with)X
2585(any)X
2749(Subject:)X
3097(and)X
3260(body\).)X
3545(You)X
3732(can)X
3890(also)X
576 4640(send)N
760(a)X
822(body)X
1021(of)X
7 f
1148(help)X
1 f
1383(to)X
7 f
1506 0.1932([email protected])AX
1 f
3331(to)X
3423(get)X
3554(help)X
3729(on)X
3841(using)X
576 4744(the)N
706(mailing)X
999(list)X
1130(server.)X
776 4876(We)N
927(have)X
1122(\256nally)X
1377(agreed)X
1641(on)X
1759(a)X
1828(numbering)X
2240(scheme)X
2534(for)X
2666(PCCTS)X
2966(releases:)X
2 f
10 s
3317(x.yz)X
1 f
11 s
3470(where)X
2 f
10 s
3712(x)X
1 f
11 s
3778(re\257ects)X
576 4980(the)N
724(major)X
970(release)X
1254(number)X
1563(\(new)X
1778(tool)X
1956(additions\),)X
2 f
10 s
2369(y)X
1 f
11 s
2445(re\257ects)X
2739(major)X
2984(new)X
3169(feature)X
3452(additions,)X
3837(and)X
2 f
10 s
4001(z)X
1 f
11 s
576 5084(re\257ects)N
852(bug)X
1006(\256xes)X
1194(and)X
1343(minor)X
1576(feature)X
1842(additions)X
2188(\(minor)X
2450(releases\).)X
9 s
10 f
576 5480(hhhhhhhhhhhhhhhh)N
1 f
576 5568(Partial)N
783(support)X
1018(for)X
1121(this)X
1244(work)X
1412(has)X
1528(come)X
1704(from)X
1864(the)X
1972(Army)X
2160(Research)X
2444(Of\256ce)X
2644(contract)X
2896(number)X
3136(DAAL03-89-C-0038)X
576 5656(with)N
722(the)X
828(Army)X
1014(High)X
1176(Performance)X
1562(Computing)X
1904(Research)X
2186(Center)X
2396(at)X
2466(the)X
2572(U)X
2642(of)X
2720(MN.)X

2 p
%%Page: 2 2
9 s 0 xH 0 xS 1 f
11 s
2231 416(-)N
2282(2)X
2348(-)X
3 f
576 704(2.)N
686(Semantic)X
1055(Predicates)X
1 f
776 860(The)N
938(fundamental)X
1404(idea)X
1576(behind)X
1841(semantic)X
2180(predicates)X
2562(has)X
2704(not)X
2842(changed)X
3160(since)X
3366(the)X
3499(1.06)X
3678(release)X
3944(\320)X
576 988(semantic)N
917(predicates)X
1301(indicate)X
1608(the)X
1743(semantic)X
2083(validity)X
2380(of)X
2479(continuing)X
2883(with)X
3066(the)X
3200(parse)X
3411(or)X
3510(of)X
3609(predicting)X
3993(a)X
576 1116(particular)N
941(production.)X
1394(However,)X
1764(we)X
1893(now)X
2071(collect)X
3 f
2334(all)X
1 f
2455(predicates)X
2839(visible)X
3102(to)X
3198(a)X
3264(syntactically)X
3738(ambigu-)X
576 1244(ous)N
724(parsing)X
1008(decision)X
1327(rather)X
1557(than)X
1734(just)X
1887(the)X
2020(\256rst)X
2182(one)X
2334(encountered)X
2789(as)X
2887(in)X
2981(1.06.)X
3204(In)X
3302(addition,)X
3639(the)X
3772(context)X
576 1372(of)N
677(the)X
813(predicate)X
1164(can)X
1314(be)X
1425(computed)X
1801(and)X
1956(hoisted)X
2239(with)X
2425(the)X
2562(predicates;)X
2973(helpful)X
3252(warning)X
3569(are)X
3705(also)X
3876(gen-)X
576 1500(erated)N
815(for)X
941(incompletely)X
1427(disambiguated)X
1966(parser)X
2204(decisions.)X
2600(The)X
2761(only)X
2942(backward)X
3306 0.2891(incompatibilities)AX
3925(are)X
576 1628(that)N
739(parsing)X
1028(does)X
1219(not)X
1362(halt)X
1525 0.2604(automatically)AX
2037(if)X
2121(a)X
2190(semantic)X
2534(validation)X
2918(predicate)X
3272(fails)X
3455(and)X
3613(the)X
7 f
3783(-pr)X
1 f
3973(is)X
576 1756(obsolete)N
892(\320)X
1003(the)X
1134(speci\256cation)X
1603(of)X
1699(a)X
1761(predicate)X
2107(implies)X
2391(that)X
2547(it)X
2620(may)X
2795(be)X
2901(used)X
3085(by)X
3196(ANTLR)X
3512(to)X
3603(validate)X
3905(and)X
576 1884(disambiguate)N
1069(as)X
1164(it)X
1236(sees)X
1404(\256t.)X
1544(In)X
1639(this)X
1789(section)X
2061(we)X
2185(discuss)X
2461(all)X
2572(of)X
2667(these)X
2870(issues.)X
3 f
576 2140(2.1.)N
752(Visible)X
1034(Semantic)X
1403(Predicates)X
1 f
776 2296(Given)N
1021(a)X
1091(syntactically)X
1569(ambiguous)X
1987(parser)X
2232(decision)X
2557(\(or,)X
2712(more)X
2924(accurately,)X
3339(a)X
3409(non-deterministic)X
576 2424(decision\),)N
947(ANTLR)X
1266(attempts)X
1592(to)X
1686(resolve)X
1965(it)X
2040(with)X
2222(semantic)X
2561(information)X
3000(\320)X
3113(ANTLR)X
3431(searches)X
3753(for)X
2 f
3880(visi-)X
576 2552(ble)N
1 f
713(predicates.)X
1143(A)X
1235(visible)X
1500(predicate)X
1852(is)X
1940(a)X
2009(semantic)X
2353(predicate)X
2706(that)X
2869(could)X
3095(be)X
3208(evaluated)X
3576(without)X
3876(con-)X
576 2680(suming)N
867(an)X
981(input)X
1194(token)X
1421(or)X
1525(executing)X
1898(a)X
1967(user)X
2143(action)X
2389(\(except)X
2678 0.3317(initialization)AX
3157(actions,)X
3459(which)X
3704(generally)X
576 2808(de\256ne)N
818(variables\).)X
1236(All)X
1376(visible)X
1639(predicates)X
2023(reside)X
2260(on)X
2375(the)X
2510(left)X
2655(edge)X
2848(of)X
2949(productions;)X
3418(predicates)X
3803(not)X
3944(on)X
576 2936(the)N
710(left)X
854(edge)X
1046(can)X
1194(only)X
1377(function)X
1697(as)X
2 f
1796(validation)X
1 f
2181(predicates)X
2564(\(see)X
2731(1.06)X
2911(release)X
3181(notes\).)X
3466(Consider)X
3810(a)X
3875(sim-)X
576 3064(ple)N
706(example:)X
7 f
9 s
576 3228(a)N
776(:)X
976(<<)X
2 f
10 s
1062(pred)X
1 f
7 s
1218 3244(1)N
7 f
9 s
1252 3228(>>?)N
1467(ID)X
10 s
9 f
1596(a)X
9 s
776 3316(|)N
7 f
976(<<)X
2 f
10 s
1062(pred)X
1 f
7 s
1218 3332(2)N
7 f
9 s
1252 3316(>>?)N
1467(ID)X
10 s
9 f
1596(b)X
9 s
7 f
776 3404(;)N
1 f
11 s
576 3608(Assuming)N
965(that)X
1130(lookahead)X
1524(information)X
1973(is)X
2065(insuf\256cient)X
2495(to)X
2597(predict)X
2875(productions)X
3324(of)X
3430(rule)X
7 f
3631(a)X
1 f
3684(,)X
3739(ANTLR)X
576 3736(would)N
823(incorporate)X
2 f
10 s
1249(pred)X
1 f
7 s
1405 3752(1)N
11 s
1466 3736(into)N
1631(the)X
1766(prediction)X
2151(expression)X
2554(for)X
2683(the)X
2818(\256rst)X
2982(production)X
3391(and)X
2 f
10 s
3543(pred)X
1 f
7 s
3699 3752(2)N
11 s
3760 3736(into)N
3924(the)X
576 3864(second)N
843(prediction)X
1224(expression.)X
1667(Multiple)X
1995(predicates)X
2375(can)X
2520(be)X
2626(hoisted)X
2904(\(which)X
3171(may)X
3346(or)X
3442(may)X
3617(not)X
3754(be)X
3861(what)X
576 3992(you)N
730(want\):)X
7 f
9 s
576 4156(decl:)N
936(<<)X
2 f
10 s
1022(pred)X
1 f
7 s
1178 4172(1)N
7 f
9 s
1212 4156(>>?)N
1384(var)X
9 f
756 4244(|)N
7 f
936(<<)X
2 f
10 s
1022(pred)X
1 f
7 s
1178 4260(2)N
7 f
9 s
1212 4244(>>?)N
1384(ID)X
756 4332(;)N
576 4420(var)N
756(:)X
936 -0.1964(<>?)AX
1925(ID)X
756 4508(;)N
1 f
11 s
576 4712(In)N
681(this)X
841(case,)X
1046(the)X
1186(prediction)X
1576(expression)X
1984(for)X
2118(production)X
2532(one)X
2691(of)X
2796(rule)X
7 f
2997(decl)X
1 f
3242(would)X
3495(resemble)X
3846(\(with)X
576 4840(context)N
858(computation)X
1322(turned)X
1569(off)X
1693(\320)X
1803(see)X
1937(below\):)X
7 f
9 s
576 5004(if)N
705(\()X
2 f
10 s
791(pred)X
1 f
7 s
947 5020(1)N
7 f
9 s
1024 5004(&&)N
1153 -0.1992(is_var\(LATEXT\(1\)\))AX
1927(&&)X
2056(LA\(1\)==ID)X
2486(\))X
2572({)X
756 5092(var\(\);)N
576 5180(})N
619 5268(...)N
1 f
11 s
576 5472(Here,)N
795(two)X
954(visible)X
1217(predicates)X
1601(were)X
1798(found)X
2030(to)X
2126(disambiguate)X
2625(the)X
2761(prediction)X
3147(of)X
3248(the)X
3384(\256rst)X
3549(production)X
3959(of)X
576 5600(rule)N
7 f
766(decl)X
1 f
1000(whereas)X
1309(only)X
1488(one)X
1637(was)X
1795(found)X
2022(for)X
2146(the)X
2276(prediction)X
2656(of)X
2751(the)X
2881(second)X
3147(production.)X

3 p
%%Page: 3 3
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(3)X
2348(-)X
776 704(The)N
938(action)X
1179(of)X
1277(evaluating)X
1670(a)X
1734(predicate)X
2082(in)X
2176(a)X
2241(decision)X
2561(is)X
2646(called)X
2 f
2883(hoisting)X
1 f
3168(.)X
3238(In)X
3337(the)X
3471(\256rst)X
3634(example)X
3959(of)X
576 832(this)N
739(section,)X
1046(predicates)X
1438(were)X
1643(not)X
1791(moved)X
2066(since)X
2282(they)X
2469(reside)X
2714(at)X
2813(the)X
2956(decision)X
3285(point)X
3502(in)X
3606(rule)X
7 f
3809(a)X
1 f
3862(,)X
3919(but)X
576 960(technically)N
996(we)X
1130(say)X
1279(that)X
1444(they)X
1628(were)X
1830(hoisted)X
2117(into)X
2287(the)X
2427(decision.)X
2797(In)X
2903(the)X
3044(second)X
3321(example,)X
2 f
10 s
3673(pred)X
1 f
7 s
3829 976(1)N
11 s
3896 960(was)N
576 1088(hoisted)N
866(from)X
7 f
1103(decl)X
1 f
1350(and)X
7 f
1543 0.1992(is_var\(LATEXT\(1\)\))AX
1 f
2479(was)X
2650(hoisted)X
2940(from)X
3146(rule)X
7 f
3349(var)X
1 f
3542(to)X
3645(predict)X
3924(the)X
576 1216(\256rst)N
735(production)X
1139(of)X
7 f
1265(decl)X
1 f
1477(.)X
3 f
576 1472(2.2.)N
752(Context)X
1071(of)X
1166(Semantic)X
1535(Predicates)X
1 f
776 1628(In)N
875(release)X
1145(1.06,)X
1347(predicates)X
1730(were)X
1927(hoisted)X
2209(without)X
2506(computing)X
2911(and)X
3065(hoisting)X
3377(the)X
3512(context)X
3799(of)X
3899(that)X
576 1756(predicate.)N
989(Context)X
1314(is)X
1418(important)X
1807(because,)X
2152(as)X
2270(we)X
2417(saw)X
2598(in)X
2712(the)X
2865(last)X
3033(section,)X
3350(predicates)X
3752(may)X
3949(be)X
576 1884(evaluated)N
940(in)X
1035(totally)X
1288(different)X
1617(rules.)X
1858(Imagine)X
2173(a)X
2238(rule)X
2401(that)X
2560(had)X
2713(many)X
2935(alternative)X
3335(productions,)X
3800(two)X
3959(of)X
576 2012(which)N
813(were)X
1005(syntactically)X
1474(nondeterministic)X
2090(because)X
2390(of)X
2485(a)X
2546(common)X
2877(lookahead)X
3261(of)X
7 f
3387(ID)X
1 f
3515(\(assuming)X
3899(that)X
576 2140(only)N
755(one)X
904(symbol)X
1186(of)X
1281(lookahead)X
1665(is)X
1746(available)X
2087(for)X
2211(simplicity\).)X
7 f
9 s
576 2304(a)N
756(:)X
936(A)X
1022(...)X
9 f
756 2392(|)N
7 f
936(B)X
1022(...)X
9 f
756 2480(|)N
7 f
936(classname)X
9 f
756 2568(|)N
7 f
936(C)X
1022(...)X
9 f
756 2656(|)N
7 f
936(varname)X
9 f
756 2744(|)N
7 f
936(D)X
1022(...)X
756 2832(;)N
576 2920(classname)N
756 3008(:)N
936(<<)X
2 f
10 s
1022(pred)X
1 f
7 s
1178 3024(1)N
7 f
9 s
1212 3008(>>?)N
1384(ID)X
756 3096(;)N
576 3184(varname)N
756 3272(:)N
936(<<)X
2 f
10 s
1022(pred)X
1 f
7 s
1178 3288(2)N
7 f
9 s
1212 3272(>>?)N
1384(ID)X
756 3360(;)N
1 f
11 s
576 3564(Simply)N
863(incorporating)X
2 f
10 s
1367(pred)X
7 s
1514 3580(i)N
1 f
11 s
1568 3564(into)N
1738(the)X
1878(production)X
2292(prediction)X
2682(expressions)X
3124(for)X
3258(alternatives)X
3697(three)X
3905(and)X
576 3692(\256ve)N
730(is)X
811(not)X
946(safe)X
1109(for)X
1233(two)X
1387(reasons:)X
576 3848([1])N
776(Evaluation)X
1185(of)X
2 f
10 s
1282(pred)X
7 s
1429 3864(i)N
1 f
11 s
1477 3848(may)N
1655(cause)X
1876(a)X
1941(program)X
2266(execution)X
2636(error)X
2833(if)X
2914(evaluated)X
3279(on)X
3394(the)X
3529(wrong)X
3780(type)X
3959(of)X
776 3976(data.)N
2 f
10 s
989(pred)X
7 s
1136 3992(i)N
1 f
11 s
1182 3976(will)N
1344(be)X
1451(evaluated)X
1813(on)X
1925(any)X
2076(input,)X
2304(which)X
2543(is)X
7 f
2657({A,)X
2871(B,)X
3032(C,)X
3193(D,)X
3354(ID})X
1 f
3537(in)X
3630(our)X
3771(case)X
3944(\320)X
2 f
10 s
776 4104(pred)N
7 s
923 4120(i)N
1 f
11 s
967 4104(may)N
1141(``core'')X
1430(if)X
1506(fed)X
1640(non-)X
7 f
1801(ID)X
1 f
1929(token)X
2147(types.)X
576 4260([2])N
2 f
10 s
776(pred)X
7 s
923 4276(i)N
1 f
11 s
974 4260(may)N
1156(give)X
1338(misleading)X
1756(results)X
2016(even)X
2212(if)X
2296(it)X
2376(does)X
2567(not)X
2710(``core''.)X
2 f
10 s
3049(pred)X
7 s
3196 4276(i)N
1 f
11 s
3248 4260(may)N
3430(return)X
3670(false)X
3866(even)X
776 4388(though)N
1043(the)X
1173(production)X
1577(is)X
1658(not)X
1793(dependent)X
2177(on)X
2287(the)X
2417(predicate)X
2762(for)X
2886(that)X
3041(token)X
3259(type.)X
3477(For)X
3621(example:)X
7 f
9 s
776 4552(a)N
948(:)X
1120(\(var)X
9 f
1335(|)X
7 f
1392(NUM\))X
1607(...)X
9 f
948 4640(|)N
7 f
1091 -0.1960(<>?)AX
2166(ID)X
2295(...)X
948 4728(;)N
776 4816(var)N
948(:)X
1120 -0.1964(<>?)AX
2195(ID)X
948 4904(;)N
1 f
11 s
776 5108(The)N
958(\256rst)X
1141(production)X
1569(will)X
3 f
1753(never)X
1 f
2009(match)X
2271(a)X
7 f
2387(NUM)X
1 f
2592(because)X
7 f
2947 0.1992(is_var\(LATEXT\(1\)\))AX
1 f
3894(will)X
776 5236(always)N
1046(evaluate)X
1366(to)X
1461(false)X
1653(for)X
1781(that)X
1939(token)X
2160(type)X
2337(since)X
2543(numbers)X
2871(are)X
3003(not)X
3141(variables)X
3484(ever)X
3660(\(the)X
3822(predi-)X
776 5364(cate)N
940(in)X
7 f
1062(var)X
1 f
1243(is)X
1324(hoisted)X
1601(for)X
1725(use)X
1864(in)X
1955(the)X
2085(decision)X
2401(for)X
2525(rule)X
7 f
2715(a)X
1 f
2768(\).)X
576 5520(The)N
735(way)X
903(to)X
994(solve)X
1202(both)X
1381(problems)X
1731(is)X
1812(to)X
1903(change)X
2 f
10 s
2172(pred)X
7 s
2319 5536(i)N
1 f
11 s
2363 5520(to:)N
7 f
9 s
576 5684(LA\(1\)==ID)N
1006(?)X
2 f
10 s
1092(pred)X
7 s
1239 5700(i)N
7 f
9 s
1304 5684(:)N
1390(1)X

4 p
%%Page: 4 4
9 s 0 xH 0 xS 7 f
11 s
1 f
2231 416(-)N
2282(4)X
2348(-)X
576 704(The)N
7 f
767(1)X
1 f
843(merely)X
1111(indicates)X
1448(that)X
1604(if)X
1682(the)X
1814(lookahead)X
2200(is)X
2283(not)X
2420(an)X
7 f
2558(ID)X
1 f
2688(then)X
2864(enable)X
3118(the)X
3250(production)X
3656(for)X
3782(normal)X
576 832(parsing)N
857(\320)X
972(we)X
1101(have)X
1293(no)X
1407(semantic)X
1747(information)X
2190(that)X
2349(establishes)X
2757(the)X
2891(validity)X
3188(or)X
3287(invalidity)X
3653(of)X
3752(the)X
3886(pro-)X
576 960(duction.)N
776 1116(Context)N
1081(computation)X
1548(similar)X
1819(to)X
1913(this)X
2067(is)X
2152(can)X
2300(now)X
2477(be)X
2586(done)X
2783 0.2604(automatically)AX
3291(\()X
7 f
3320(-prc)X
3589(on)X
1 f
3695(\).)X
3794(Unfor-)X
576 1244(tunately,)N
914(as)X
1018(mentioned)X
1422(previously)X
1825(in)X
1925(this)X
2084(document,)X
2485(computing)X
2894(full)X
2 f
10 s
3046(LL)X
1 f
3147(\()X
2 f
3174(k)X
1 f
3216(\))X
11 s
3274(lookahead)X
3666(is,)X
3777(in)X
3876(gen-)X
576 1372(eral,)N
766(an)X
886(exponential)X
1335(problem;)X
1691(hence,)X
1955(for)X
2094(large)X
2307(grammars)X
2696(you)X
2865(may)X
3054(want)X
3262(to)X
3368(keep)X
3571(this)X
3736(off)X
3875(with)X
7 f
576 1500(-prc)N
842(off)X
1 f
1024(\(default\))X
1350(and)X
1500(include)X
1783(context)X
2066(tests)X
2246(manually)X
2598(in)X
2690(your)X
2874(predicates.)X
3298(The)X
3458(old)X
7 f
3625(-pr)X
1 f
3806(option)X
576 1628(to)N
669(turn)X
835(on)X
947(parsing)X
1230(with)X
1412(predicates)X
1794(is)X
1878(now)X
2054(ignored)X
2348(as)X
2446(the)X
2579(speci\256cation)X
3050(of)X
3148(a)X
3212(predicate)X
3560(indicates)X
3899(that)X
576 1756(it)N
648(should)X
905(be)X
1010(used.)X
776 1912(ANTLR)N
1097(does)X
1286(its)X
1398(best)X
1568(to)X
1665(warn)X
1868(the)X
2004(user)X
2178(when)X
2396(a)X
2464(possibly)X
2787(incompletely)X
3278(disambiguated)X
3822(gram-)X
576 2040(mar)N
736(has)X
876(been)X
1065(speci\256ed.)X
1445(In)X
1541(other)X
1745(words,)X
2004(when)X
2217(a)X
2279(syntactically)X
2749(ambiguous)X
3158(decision)X
3474(is)X
3555(resolved)X
3875(with)X
576 2168(semantic)N
918(predicates,)X
1325(all)X
1442(mutually)X
1785(ambiguous)X
2200(productions)X
2644(must)X
2844(have)X
3039(at)X
3132(least)X
3323(one)X
3479(semantic)X
3822(predi-)X
576 2296(cate)N
740(associated)X
1124(with)X
1303(it.)X
1419(For)X
1563(example:)X
7 f
9 s
576 2460(a)N
748(:)X
920(<<)X
2 f
10 s
1006(pred)X
7 f
9 s
1153(>>?)X
1368(ID)X
1497(...)X
9 f
748 2548(|)N
7 f
891(ID)X
1020(...)X
748 2636(;)N
1 f
11 s
576 2840(This)N
763(grammar)X
1111(will)X
1279(yield)X
1486(a)X
1555(warning)X
1873(when)X
2094(run)X
2242(through)X
2547(ANTLR)X
2871(with)X
7 f
3090(-w2)X
1 f
3280(set)X
3409(because)X
3718(semantic)X
576 2968(information)N
1015(was)X
1173(not)X
1308(provided)X
1643(to)X
1734(indicate)X
2036(the)X
2166(validity)X
2459(of)X
2554(the)X
2684(second)X
2950(production:)X
7 f
8 s
576 3132(t.g,)N
766(line)X
956(1:)X
1070(warning:)X
1412(alt)X
1564(2)X
1640(of)X
1754(the)X
1906(rule)X
2096(itself)X
2362(has)X
2514(no)X
2628 -0.4219(predicate)AX
3008(to)X
3122(resolve)X
3426 -0.4219(ambiguity)AX
1 f
11 s
576 3336(However,)N
960(rule)X
7 f
1169(a)X
1 f
1264(will)X
1444(behave)X
1735(correctly)X
2090(because)X
2410(if)X
2 f
10 s
2504(pred)X
1 f
11 s
2693(fails,)X
2909(the)X
3059(second)X
3345(production)X
3769(will)X
3949(be)X
576 3464(attempted)N
969(as)X
1086(the)X
1238(default)X
1527(case)X
1722(\(remember)X
2151(that)X
2327(a)X
2409(missing)X
2727(semantic)X
3084(predicate)X
3450(is)X
3552(equivalent)X
3963(to)X
7 f
576 3592(<<1>>?)N
1 f
894(\).)X
992(Adding)X
1281(a)X
1345(third)X
1537(production)X
1944(that)X
2102(began)X
2337(with)X
7 f
2550(ID)X
1 f
2681(would)X
2926(not)X
3064(behave)X
3338(correctly)X
3676(as)X
3775(the)X
3909(last)X
7 f
576 3720(ID)N
1 f
682(-pre\256xed)X
1021(production)X
1425(would)X
1667(never)X
1884(be)X
1989(matched.)X
776 3876(As)N
906(a)X
978(more)X
1192(complicated)X
1657(example,)X
2011(consider)X
2342(the)X
2483(following)X
2859(incorrectly)X
3274(disambiguated)X
3822(gram-)X
576 4004(mar:)N
7 f
9 s
576 4168(a)N
748(:)X
920(b)X
9 f
748 4256(|)N
7 f
891(<<)X
2 f
10 s
977(pred)X
1 f
7 s
1133 4272(1)N
7 f
9 s
1167 4256(>>?)N
1339(ID)X
9 f
748 4344(|)N
7 f
891(<<)X
2 f
10 s
977(pred)X
1 f
7 s
1133 4360(2)N
7 f
9 s
1167 4344(>>?)N
1339(NUM)X
748 4432(;)N
576 4608(b)N
748(:)X
920(<<)X
2 f
10 s
1006(pred)X
1 f
7 s
1162 4624(3)N
7 f
9 s
1196 4608(>>?)N
1368(ID)X
9 f
748 4696(|)N
7 f
891(NUM)X
748 4784(;)N
1 f
11 s
576 4988(Rule)N
7 f
801(a)X
1 f
881(cannot)X
1143(predict)X
1415(which)X
1657(production)X
2066(to)X
2163(match)X
2407(upon)X
2611(lookahead)X
7 f
3032(ID)X
1 f
3166(or)X
7 f
3298(NUM)X
1 f
3457(.)X
3529(Alternatives)X
3988(2)X
576 5116(and)N
737(3)X
815(have)X
1015(been)X
1215(disambiguated,)X
1786(but)X
1933(the)X
2075(\256rst)X
2246(production)X
2662(hoists)X
2902(a)X
2975(predicate)X
3331(that)X
3497(only)X
3687(``covers'')X
7 f
576 5244(ID)N
1 f
682('s.)X
811(As)X
930(a)X
991(result,)X
1231(the)X
1361(following)X
1726(message)X
2046(is)X
2127(generated)X
2491(by)X
2601(ANTLR:)X
7 f
8 s
576 5408(t.g,)N
766(line)X
956(1:)X
1070(warning:)X
1412(alt)X
1564(1)X
1640(of)X
1754(the)X
1906(rule)X
2096(itself)X
2362(has)X
2514(no)X
2628 -0.4219(predicate)AX
3008(to)X
3122(resolve)X
3426 -0.4219(ambiguity)AX
3806(upon)X
3996({)X
4072(NUM)X
4224(})X
1 f
11 s
576 5612(This)N
755(detection)X
1101(is)X
1182(a)X
1243(great)X
1441(help)X
1615(during)X
1867(grammar)X
2207(development.)X

5 p
%%Page: 5 5
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(5)X
2348(-)X
776 704(Ambiguity)N
1187(warnings)X
1537(are)X
1672(now)X
1851(turned)X
2104(off)X
2234(for)X
2365(decisions)X
2722(that)X
2884(have)X
3079(semantic)X
3422(predicates)X
3808(cover-)X
576 832(ing)N
711(all)X
822(ambiguous)X
1231(lookahead)X
1615(sequences.)X
3 f
576 1088(2.3.)N
752(Failure)X
1049(of)X
1144(predicates)X
1 f
776 1244(Predicates)N
1162(that)X
1319(are)X
1450(not)X
1588(used)X
1774(in)X
1868(disambiguating)X
2438(parsing)X
2722(decisions)X
3075(are)X
3207(called)X
3443(validation)X
3822(predi-)X
576 1372(cates.)N
824(Previously,)X
1251(validation)X
1633(predicates)X
2017(that)X
2177(failed)X
2405(during)X
2662(parsing)X
2948(printed)X
3225(out)X
3365(a)X
3431(message)X
3756(and)X
3910(ter-)X
576 1500(minated)N
883(the)X
1013(parser:)X
7 f
9 s
576 1664(if)N
705(\()X
791(!)X
2 f
10 s
834(pred)X
7 f
9 s
1024(\))X
1110({fprintf\(stderr,)X
1841("failed)X
2185(predicate:)X
2658('pred'\\n\);)X
3131(exit\(1\);})X
1 f
11 s
576 1868(The)N
758(latest)X
990(release)X
1279(of)X
1397(ANTLR)X
1735(generates)X
2112(a)X
2197(call)X
2371(to)X
2486(a)X
2571(macro)X
2837(that)X
3016(the)X
3170(user)X
3362(may)X
3560(de\256ne)X
3821(called)X
7 f
576 1996(zzfailed_pred\(\))N
1 f
1371(,)X
1415(which)X
1652(is)X
1733(passed)X
1989(a)X
2050(string)X
2273(representing)X
2730(the)X
2860(predicate)X
3205(that)X
3360(failed:)X
7 f
9 s
576 2160(if)N
705(\()X
791(!)X
2 f
10 s
834(pred)X
7 f
9 s
1024(\))X
1110 -0.1957({zzfailed_pred\("pred"\);})AX
1 f
11 s
576 2364(while)N
794(this)X
944(solution)X
1251(is)X
1332(not)X
1467(ideal,)X
1683(it)X
1755(is)X
1836(much)X
2054(better)X
2277(than)X
2451(before.)X
3 f
576 2620(3.)N
686(In\256nite)X
982(lookahead)X
1391(and)X
1555(Backtracking)X
1 f
776 2776(There)N
1009(are)X
1144(a)X
1211(number)X
1508(of)X
1609(grammatical)X
2079(constructs)X
2464(that)X
2626(normal)X
2 f
10 s
2903(LL)X
1 f
3004(\()X
2 f
3031(k)X
1 f
3073(\))X
11 s
3129(recursive-descent)X
3773(parsing)X
576 2904(cannot)N
850(handle.)X
1168(The)X
1344(most)X
1555(obvious)X
1873(example)X
2211(would)X
2470(be)X
2592(left-recursion,)X
3126(but)X
3277(left-recursion)X
3789(can)X
3949(be)X
576 3032(removed)N
907(by)X
1018(well-known)X
1461(algorithms.)X
1906(The)X
2066(nastiest)X
2354(grammar)X
2695(construct)X
3041(is)X
3124(one)X
3275(in)X
3368(which)X
3607(two)X
3763(alterna-)X
576 3160(tive)N
734(productions)X
1175(cannot)X
1435(be)X
1543(distinguished)X
2039(without)X
2334(examining)X
2731(all)X
2844(or)X
2941(most)X
3137(of)X
3234(the)X
3366(production.)X
3816(While)X
576 3288(left-factoring)N
1069(can)X
1219(handle)X
1483(many)X
1708(of)X
1810(these)X
2020(cases,)X
2256(some)X
2471(cannot)X
2735(be)X
2847(handled)X
3155(due)X
3311(to)X
3409(things)X
3654(like)X
3816(action)X
576 3416(placement,)N
991(non-identical)X
1487(left-factors,)X
1925(or)X
2028(alternatives)X
2465(productions)X
2911(that)X
3074(cannot)X
3338(be)X
3450(reorganized)X
3894(into)X
576 3544(the)N
711(same)X
919(rule.)X
1127(The)X
1291(solution)X
1604(to)X
1701(the)X
1837(arbitrarily-large)X
2423(common)X
2760(left-factor)X
3140(problem)X
3462(is)X
3549(simply)X
3818(to)X
3915(use)X
576 3672(arbitrary)N
910(lookahead;)X
1328(i.e.,)X
1489(as)X
1593(much)X
1820(lookahead)X
2213(as)X
2317(necessary)X
2689(to)X
2789(uniquely)X
3129(determine)X
3513(which)X
3759(produc-)X
576 3800(tion)N
736(to)X
827(apply.)X
776 3956(ANTLR)N
1102(1.10)X
1289(provides)X
1625(two)X
1790(mechanisms)X
2259(for)X
2394(using)X
2618(``in\256nite'')X
3018(amounts)X
3350(of)X
3456(lookahead.)X
3895(The)X
576 4084(\256rst)N
736(is)X
818(to)X
910(use)X
1050(semantic)X
1387(predicates)X
1767(in)X
1859(conjunction)X
2299(with)X
2479(a)X
2540(user-de\256ned)X
2996(function)X
3312(that)X
3467(scans)X
3679(arbitrarily)X
576 4212(ahead)N
810(using)X
1031(a)X
1100(set)X
1228(of)X
1331(macros)X
1615(provided)X
1958(in)X
2057(this)X
2215(release.)X
2533(The)X
2700(second)X
2974(is)X
3063(a)X
3132(more)X
3343 0.4732(implicit)AX
3650(scheme)X
3944(by)X
576 4340(which)N
823(the)X
963(user)X
1141(can)X
1295(annotate)X
1625(those)X
1842(sections)X
2157(of)X
2261(the)X
2400(grammar,)X
2771(which)X
3017(defy)X
3204(normal)X
3485(LL\(k\))X
3726(analysis,)X
576 4468(with)N
2 f
768(syntactic)X
1117(predicates)X
1 f
1484(.)X
1563(ANTLR)X
1891(will)X
2064(then)X
2251(generate)X
2584(code)X
2785(that)X
2953(simply)X
3229(tries)X
3416(out)X
3564(the)X
3708(indicated)X
576 4596(alternative)N
977(production)X
1387(to)X
1484(see)X
1624(if)X
1706(it)X
1783(would)X
2030(match)X
2273(a)X
2339(portion)X
2621(of)X
2721(the)X
2856(remaining)X
3241(input.)X
3494(If)X
3579(not,)X
3741(the)X
3876(gen-)X
576 4724(erated)N
815(parser)X
1053(would)X
1297(try)X
1419(the)X
1551(next)X
1727(viable)X
1967(alternative)X
2364(production.)X
2814(This)X
2995(scheme)X
3283(is)X
3366(a)X
3429(form)X
3625(of)X
3723(selective)X
576 4852(backtracking)N
1068(\(and,)X
1282(hence,)X
1545(can)X
1703(recognize)X
2081(the)X
2225(class)X
2432(of)X
2541(context)X
2837(free)X
3009(languages\))X
3426(where)X
3676(most)X
3884(of)X
3993(a)X
576 4980(parser)N
828(is)X
925(deterministic)X
1425(and)X
1590(only)X
1785(the)X
1931(``hard'')X
2241(parts)X
2450(are)X
2596(done)X
2806(using)X
3036(trial-and-error.)X
3617(As)X
3753(a)X
3831(direct)X
576 5108(consequence,)N
1079(ANTLR)X
1403(can)X
1556(now)X
1738(generate)X
2067(parsers)X
2346(with)X
2534(the)X
2673(semantic)X
3018(\257exibility)X
3394(of)X
3498(LL\(k\),)X
3761(that)X
3925(are)X
576 5236(stronger)N
894(than)X
1076(full)X
1229(LR\(k\))X
1474(\(in)X
1602(theory\),)X
1908(and)X
2065(are)X
2202(nearly)X
2452(linear)X
2683(in)X
2782(complexity;)X
3235(note)X
3417(that)X
3580(the)X
3718(semantic)X
576 5364(predicates)N
967(\(\256rst)X
1167(introduced)X
1578(in)X
1681(the)X
1823(1.06)X
2011(release\))X
2318(can)X
2474(take)X
2654(ANTLR-generated)X
3351(parsers)X
3632(beyond)X
3924(the)X
576 5492(context-free)N
1023(language)X
1363(limit)X
1554(into)X
1714(the)X
1844(context-sensitive.)X
776 5648(We)N
927(begin)X
1153(this)X
1311(section)X
1591(by)X
1709(introducing)X
2146(the)X
2284(notion)X
2540(of)X
2643(in\256nite)X
2924(lookahead)X
3316(through)X
3620(an)X
3733(example)X
576 5776(problem)N
909(that)X
1081(we)X
1222(solve)X
1447(with)X
1643(semantic)X
1996(and)X
2162(then)X
2353(with)X
2549(syntactic)X
2902(predicates.)X
3341(Following)X
3742(this,)X
3930(we)X

6 p
%%Page: 6 6
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(6)X
2348(-)X
576 704(describe)N
896(in)X
992(detail)X
1216(the)X
1351(syntax)X
1608(and)X
1763(use)X
1908(of)X
2009(syntactic)X
2351(predicates,)X
2758(which)X
3001(employ)X
3294(in\256nite)X
3573(lookahead)X
3963(to)X
576 832(perform)N
881(selective)X
1212(backtracking.)X
3 f
576 1088(3.1.)N
752(Examples)X
1 f
776 1244(This)N
963(section)X
1243(presents)X
1561(a)X
1630(simple)X
1896(grammar)X
2244(whose)X
2498(productions)X
2945(have)X
3142(common)X
3482(left-factors)X
3899(that)X
576 1372(we)N
708(assume,)X
1019(for)X
1150(the)X
1287(sake)X
1472(of)X
1574(demonstration)X
2108(purposes,)X
2471(to)X
2569(be)X
2681(non)X
2842(left-factorable.)X
3414(With)X
3620(nothing)X
3919(but)X
576 1500(the)N
716(grammar,)X
1088(ANTLR)X
1413(would)X
1666(be)X
1782(unable)X
2050(to)X
2152(construct)X
2508(a)X
2580(deterministic)X
3075(parser.)X
3366(We)X
3521(\256rst)X
3691(provide)X
3993(a)X
576 1628(solution)N
890(by)X
1007(writing)X
1291(a)X
1359(function)X
1682(that)X
1844(explicitly)X
2208(accesses)X
2534(the)X
2671(in\256nite)X
2950(lookahead)X
3340(buffer)X
3582(to)X
3679(determine)X
576 1756(which)N
822(production)X
1235(should)X
1501(be)X
1615(attempted.)X
2039(This)X
2227(solution)X
2543(is)X
2633(ef\256cient,)X
2975(but)X
3119(would)X
3370(become)X
3675(somewhat)X
576 1884(tedious)N
859(for)X
988(the)X
1123(programmer)X
1585(if)X
1666(it)X
1743(had)X
1897(to)X
1993(be)X
2103(done)X
2301(for)X
2430(each)X
2618(such)X
2806(problem)X
3127(in)X
3223(a)X
3289(large)X
3492(grammar.)X
3881(For-)X
576 2012(tunately,)N
911(an)X
1022(easier)X
1255(and)X
1410(more)X
1619(concise)X
1911(solution)X
2224(is)X
2311(provided)X
2652(by)X
2768(syntactic)X
3110(predicates,)X
3517(which)X
3760(we)X
3890(also)X
576 2140(demonstrate)N
1029(using)X
1242(the)X
1372(same)X
1575(grammar.)X
776 2296(Consider)N
1116(ML)X
1270(which)X
1507(has)X
1646(multiple)X
1964(assignment)X
2383(and)X
2532(list)X
2663(statements.)X
3102(E.g.,)X
7 f
9 s
576 2460(stat:)N
920(list)X
1135(Assign)X
1436(list)X
1651(";")X
1952(< 2597(=)X
2683(list\\n"\);>>)X
9 f
748 2548(|)N
7 f
891(list)X
1106(";")X
1923 -0.1969(<>)AX
748 2636(;)N
1 f
11 s
576 2840(This)N
762(grammar)X
1109(is)X
1198(not)X
2 f
10 s
1339(LL)X
1 f
1440(\()X
2 f
1467(k)X
1 f
1509(\))X
11 s
1566(for)X
1698(any)X
2 f
10 s
1853(k)X
1 f
11 s
1919(as)X
7 f
2053(list)X
1 f
2295(can)X
2447(be)X
2560(arbitrarily)X
2943(long.)X
3174(The)X
3341(following)X
3714(grammar)X
576 2968(using)N
790(semantic)X
1127(predicates)X
1507(to)X
1599(access)X
1846(the)X
1977(in\256nite)X
2251(lookahead)X
2636(buffer)X
2873(to)X
2965(explicitly)X
3323(compute)X
3649(which)X
3886(pro-)X
576 3096(duction)N
863(will)X
1023(be)X
1128(matched.)X

7 p
%%Page: 7 7
11 s 0 xH 0 xS 1 f
9 s
7 f
1 f
2244 376(-)N
2286(7)X
2340(-)X
7 f
576 712(/*)N
705(example)X
1049(use)X
1221(of)X
1350(the)X
1522(infinite)X
1909(lookahead)X
2339(buffer)X
2640(macros)X
619 800(*)N
705(compile)X
1049(with:)X
619 888(*)N
936(antlr)X
1194(list.g)X
619 976(*)N
936(dlg)X
1108(parser.dlg)X
1581(scan.c)X
619 1064(*)N
936(cc)X
1065(-I)X
2 f
1151(antlr_includes)X
7 f
1610(-DZZINF_LOOK)X
2169(-o)X
2298(list)X
2513(list.c)X
2814(scan.c)X
3115(err.c)X
619 1152(*/)N
576 1240(#header)N
920(<<#include)X
1393("charbuf.h">>)X
576 1416(<<)N
576 1504(main\(\))N
877({)X
963(ANTLR\(stat\(\),)X
1565(stdin\);)X
1909(})X
576 1680(/*)N
705(Scan)X
920(for)X
1092(a)X
1178("=",)X
1393(but)X
1565(only)X
1780(before)X
2081(a)X
2167(";")X
2339(--)X
2468(return)X
2769(1)X
2855(if)X
2984(found,)X
3285(else)X
3500(0)X
705 1768(This)N
920(performs)X
1307(the)X
1479(same)X
1694(function)X
2081(as)X
2210(using)X
2468(the)X
2640(syntactic)X
3070(predicate:)X
920 1856(\(list)N
1178(Assign)X
1479(list)X
1694(";"\)?)X
705 1944(but)N
877(uses)X
1092(a)X
1178(semantic)X
1565(predicate)X
1995(coupled)X
2339(with)X
2554(the)X
2726 -0.1985(infinite-lookahead)AX
3543(feature.)X
705 2032(It)N
834(is)X
963(somewhat)X
1350(faster)X
1651(as)X
1780(it)X
1909(does)X
2124(not)X
2296(actually)X
2683(*parse*)X
3027(the)X
3199("list)X
3457(=",)X
3629(it)X
3758(just)X
705 2120(scans)N
963(ahead.)X
705 2296(MUST)N
920(HAVE)X
1135("ZZINF_LOOK")X
1694(PREPROCESSOR)X
2253(FLAG)X
2468(DEFINED)X
705 2384(\(in)N
877(#header)X
1221(or)X
1350(on)X
1479(compiler)X
1866(command)X
2210(line\))X
705 2472(*/)N
576 2560(which\(\))N
576 2648({)N
748 2736(int)N
920(i;)X
748 2912(for)N
920(\(i=1;)X
1178 -0.1985(ZZINF_LA_VALID\(i\);)AX
1995(i++\))X
748 3000({)N
920 3088(if)N
1049(\()X
1135(ZZINF_LA\(i\))X
1651(==)X
1780(Assign)X
2081(\))X
2167(return)X
2468(1;)X
920 3176(else)N
1135(if)X
1264(\()X
1350(ZZINF_LA\(i\))X
1866(==)X
1995(Semi)X
2210(\))X
2296(return)X
2597(0;)X
748 3264(})N
748 3352(return)N
1049(0;)X
576 3440(})N
576 3528(>>)N
576 3704(#token)N
1296("[\\)X
1468(\\t]+")X
2027(<>)X
576 3792(#token)N
1296("\\n")X
2027(< 2543(zzline++;>>)X
576 3880(#token)N
877(Assign)X
1296("=")X
576 3968(#token)N
877(Semi)X
1296(";")X
576 4144(stat:)N
877(<>?)X
1436(list)X
1651(Assign)X
1952(list)X
2167(";")X
2339(< 2984(=)X
3070(list\\n"\);>>)X
9 f
748 4232(|)N
7 f
891(list)X
1106(";")X
2310 -0.1969(<>)AX
748 4320(;)N
576 4496(list:)N
920("\\\(")X
1135(elem)X
1350(\(",")X
1565(elem\)*)X
1866("\\\)")X
748 4584(;)N
576 4760(elem:)N
920(ID)X
9 f
748 4848(|)N
7 f
891(INT)X
748 4936(;)N
576 5112(#token)N
877(ID)X
1296("[a-zA-Z]+")X
576 5200(#token)N
877(INT)X
1296("[0-9]+")X
1 f
11 s
576 5404(The)N
735(in\256nite)X
1008(lookahead)X
1392(buffer)X
1628(may)X
1802(be)X
1907(accessed)X
2236(with)X
2415(the)X
2545(following)X
2910(macros:)X
7 f
576 5560(ZZINF_LA\()N
2 f
10 s
1053(i)X
7 f
11 s
1075(\))X
1 f
776 5688(Return)N
1100(the)X
2 f
10 s
1290(i)X
7 s
1321 5656(th)N
1 f
11 s
1455 5688(token)N
1736(of)X
1894(lookahead)X
2341(relative)X
2691(to)X
2845(the)X
3038(current)X
3372(position.)X
3786(Hence,)X
7 f
776 5816(ZZINF_LA\(1\))N
1 f
1359(..)X
7 f
(ZZINF_LA\()S
2 f
10 s
1880(k)X
7 f
11 s
1916(\))X
1 f
1995(are)X
2128(equivalent)X
2521(to)X
7 f
2646(LA\(1\))X
1 f
2911(..)X
7 f
(LA\()S
2 f
10 s
3114(k)X
7 f
11 s
3150(\))X
1 f
3203(.)X
3272(The)X
3434(difference)X
3815(is)X
3899(that)X

8 p
%%Page: 8 8
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(8)X
2348(-)X
2 f
10 s
776 704(i)N
1 f
11 s
836(can)X
996(range)X
1229(from)X
1438(the)X
1584(current)X
1871(token)X
2105(of)X
2216(lookahead)X
2616(until)X
2818(the)X
2965(last)X
3127(token)X
3362(of)X
3474(lookahead)X
3875(with)X
7 f
776 832(ZZINF_LA\()N
2 f
10 s
1253(i)X
7 f
11 s
1275(\))X
1 f
1328(.)X
7 f
576 988(ZZINF_LATEXT\()N
2 f
10 s
1265(i)X
7 f
11 s
1287(\))X
1 f
776 1116(Identical)N
1107(to)X
7 f
1229(ZZINF_LA\()X
2 f
10 s
1706(i)X
7 f
11 s
1728(\))X
1 f
1803(except)X
2055(that)X
2210(the)X
2340(text)X
2495(of)X
2590(the)X
2 f
10 s
2718(i)X
7 s
2749 1084(th)N
1 f
11 s
2821 1116(token)N
3039(is)X
3120(returned.)X
7 f
576 1272(ZZINF_LA_VALID\()N
2 f
10 s
1371(i)X
7 f
11 s
1393(\))X
1 f
776 1400(Returns)N
1072(1)X
1138(if)X
2 f
10 s
1212(i)X
1 f
11 s
1256(if)X
1332(at)X
1418(least)X
2 f
10 s
1600(i)X
1 f
11 s
1644(non-EOF)X
1993(tokens)X
2245(are)X
2374(left)X
2514(in)X
2605(the)X
2735(input)X
2939(stream)X
3196(else)X
3355(it)X
3427(returns)X
3693(0.)X
576 1556(Naturally,)N
959(the)X
1095(use)X
1240(of)X
1342(in\256nite)X
1622(lookahead)X
2013(by)X
2130(de\256ning)X
7 f
2479(ZZINF_LOOK)X
1 f
3038(is)X
3126(inconsistent)X
3577(with)X
3763(interac-)X
576 1684(tive)N
731(parsers)X
1001(as)X
1096(the)X
1226(entire)X
1449(input)X
1653(stream)X
1910(is)X
1991(read)X
2164(in)X
2255(before)X
2501(parsing)X
2782(begins.)X
776 1840(As)N
896(mentioned)X
1292(above,)X
1547(this)X
1699(method)X
1988(could)X
2208(be)X
2315(tedious)X
2594(for)X
2720(large)X
2920(grammars,)X
3318(hence,)X
3569(ANTLR)X
3886(pro-)X
576 1968(vides)N
796(a)X
869(more)X
1084(elegant)X
1372(solution.)X
1734(The)X
1904(same)X
2118(problem)X
2445(can)X
2600(be)X
2716(solved)X
2979(with)X
3169(a)X
3241(syntactic)X
3588(predicate)X
3944(by)X
576 2096(changing)N
921(rule)X
7 f
1111(stat)X
1 f
1345(in)X
1436(the)X
1566(following)X
1931(way:)X
7 f
9 s
576 2260(stat:)N
920(\()X
1006(list)X
1221(Assign)X
1522(list)X
1737(";")X
1909(\)?)X
2296(< 2941(=)X
3027(list\\n"\);>>)X
9 f
748 2348(|)N
7 f
891(list)X
1106(";")X
2267 -0.1969(<>)AX
748 2436(;)N
1 f
11 s
576 2640(Using)N
824(this)X
990 0.4732(implicit)AX
1305(method,)X
1630(the)X
1776(need)X
1981(for)X
2122(the)X
2269(semantic)X
2622(predicate)X
2984(and)X
3150(the)X
7 f
3328(which\(\))X
1 f
3738(function)X
576 2768(disappears.)N
776 2924(Let's)N
982(now)X
1159(consider)X
1483(a)X
1548(small)X
1766(chunk)X
2007(of)X
2106(the)X
2240(vast)X
2408(C++)X
2593(declaration)X
3011(syntax.)X
3311(Can)X
3479(you)X
3637(tell)X
3777(exactly)X
576 3052(what)N
769(type)X
943(of)X
1038(object)X
7 f
1307(f)X
1 f
1382(is)X
1463(after)X
1646(having)X
1908(seen)X
2086(the)X
2216(left)X
2356(parenthesis?)X
7 f
9 s
576 3216(int)N
748(f\()X
1 f
11 s
576 3420(The)N
739(answer)X
1013(is)X
1098(``no.''.)X
1394(Object)X
7 f
1686(f)X
1 f
1765(could)X
1988(be)X
2098(an)X
2208(integer)X
2480 0.3187(initialized)AX
2862(to)X
2958(some)X
3171(previously)X
3570(de\256ned)X
3856(sym-)X
576 3548(bol)N
7 f
742(a)X
1 f
795(:)X
7 f
9 s
576 3712(int)N
748(f\(a\);)X
1 f
11 s
576 3916(or)N
671(a)X
732(function)X
1048(prototype)X
1408(or)X
1503(de\256nition:)X
7 f
9 s
576 4080(int)N
748(f\(float)X
1092(a\))X
1221({...})X
1 f
11 s
576 4284(The)N
735(following)X
1100(is)X
1181(a)X
1242(greatly)X
1509(simpli\256ed)X
1885(grammar)X
2225(for)X
2349(these)X
2552(two)X
2706(declaration)X
3120(types:)X
7 f
9 s
576 4448(decl:)N
936(type)X
1151(ID)X
1280("\\\(")X
1495(expr_list)X
1925("\\\)")X
2140(";")X
9 f
756 4536(|)N
7 f
936(type)X
1151(ID)X
1280("\\\(")X
1495(arg_decl_list)X
2097("\\\)")X
2312(func_def)X
756 4624(;)N
1 f
11 s
576 4828(One)N
755(notices)X
1038(that)X
1205(left-factoring)X
7 f
1735(type)X
2012(ID)X
2183("\\\(")X
1 f
2429(would)X
2683(be)X
2800(trivial)X
3046(because)X
3358(our)X
3509(grammar)X
3861(is)X
3954(so)X
576 4956(small)N
795(and)X
949(the)X
1084(left-pre\256xes)X
1536(are)X
1670(identical.)X
2046(However,)X
2415(if)X
2495(a)X
2560(user)X
2732(action)X
2974(were)X
3170(required)X
3489(before)X
3739(recogni-)X
576 5084(tion)N
736(of)X
831(the)X
961(reference)X
1309(to)X
1400(rule)X
7 f
1590(type)X
1 f
1802(,)X
1846(left-factoring)X
2333(would)X
2575(not)X
2710(be)X
2815(possible:)X
7 f
9 s
576 5248(decl:)N
936(< 1151(dummy)X
1409(init)X
1624(action)X
1925(so)X
2054(next)X
2269(action)X
2570(is)X
2699(not)X
2871(taken)X
3129(as)X
3258(init)X
3473(*/>>)X
936 5336(< 1538(init\\n"\);>>)X
2097(type)X
2312(ID)X
2441("\\\(")X
2656(expr_list)X
3086("\\\)")X
3301(";")X
9 f
756 5424(|)N
7 f
936(< 1581(def\\n"\);>>)X
2097(type)X
2312(ID)X
2441("\\\(")X
2656(arg_decl_list)X
3258("\\\)")X
3473(func_def)X
756 5512(;)N
1 f
11 s
576 5716(The)N
738(solution)X
1048(to)X
1142(the)X
1275(problem)X
1594(involves)X
1919(looking)X
2215(arbitrarily)X
2594(ahead)X
2825(\()X
7 f
2854(type)X
1 f
3092(could)X
3314(be)X
3423(arbitrarily)X
3802(big,)X
3963(in)X
576 5844(general\))N
907(to)X
1018(determine)X
1413(what)X
1626(appears)X
1936(after)X
2139(the)X
2289(left-parenthesis.)X
2918(This)X
3117(problem)X
3453(is)X
3554(easily)X
3802(solved)X

9 p
%%Page: 9 9
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(9)X
2348(-)X
576 704 0.4306(implicitly)AN
944(by)X
1054(using)X
1267(the)X
1397(new)X
7 f
1596(\(...\)?)X
2 f
1936(syntactic)X
2272(predicate)X
1 f
2605(:)X
7 f
9 s
576 868(decl:)N
936(\()X
1108(<<;>>)X
1366(< 1968(init\\n"\);>>)X
2484(type)X
2699(ID)X
2828("\\\(")X
3043(expr_list)X
3473("\\\)")X
3688(";")X
3946(\)?)X
9 f
756 956(|)N
7 f
936(< 1581(def\\n"\);>>)X
2097(type)X
2312(ID)X
2441("\\\(")X
2656(arg_decl_list)X
3258("\\\)")X
3473(func_def)X
756 1044(;)N
1 f
11 s
576 1248(The)N
7 f
770(\(...\)?)X
1 f
1114(says)X
1291(that)X
1450(it)X
1526(is)X
1611(impossible)X
2020(to)X
2116(decide,)X
2395(from)X
2593(the)X
2728(left)X
2873(edge)X
3066(of)X
3166(rule)X
7 f
3361(decl)X
1 f
3600(with)X
3784(a)X
3850(\256nite)X
576 1376(amount)N
874(of)X
980(lookahead,)X
1397(which)X
1645(production)X
2059(to)X
2160(predict.)X
2481(Any)X
2664(grammar)X
3014(construct)X
3369(inside)X
3612(a)X
7 f
3714(\(...\)?)X
1 f
576 1504(block)N
804(is)X
895(attempted)X
1276(and,)X
1457(if)X
1543(it)X
1625(fails,)X
1831(the)X
1971(next)X
2155(alternative)X
2560(production)X
2974(that)X
3139(could)X
3368(match)X
3617(the)X
3758(input)X
3973(is)X
576 1632(attempted.)N
1000(This)X
1188(represents)X
1575(selective)X
1915(backtracking)X
2401(and)X
2559(is)X
2648(similar)X
2924(to)X
3023(allowing)X
3362(ANTLR)X
3685(parsers)X
3963(to)X
576 1760(guess)N
795(without)X
1090(being)X
1311(``penalized'')X
1790(for)X
1917(being)X
2138(wrong.)X
2431(Note)X
2627(that)X
2785(the)X
2918(\256rst)X
3080(action)X
3321(of)X
3419(any)X
3571(block)X
3792(is)X
3876(con-)X
576 1888(sidered)N
859(an)X
971(init)X
1118(action)X
1362(and,)X
1539(hence,)X
1794(cannot)X
2057(be)X
2168(disabled)X
2490(\(by)X
2635(placing)X
2923(it)X
3001(inside)X
7 f
3271({...})X
1 f
3536(\))X
3593(since)X
3802(it)X
3880(may)X
576 2016(de\256ne)N
813(variables;)X
1178(the)X
1308(\256rst)X
1467(action)X
1705(of)X
1800(the)X
1930(block)X
2148(is)X
2229(a)X
2290(dummy)X
2582(action.)X
776 2172(At)N
890(this)X
1045(point,)X
1276(some)X
1489(readers)X
1769(may)X
1948(argue)X
2170(that)X
2330(scanning)X
2670(ahead)X
2902(arbitrarily)X
3282(far,)X
3428(using)X
3646(the)X
3781(in\256nite)X
576 2300(lookahead)N
970(via)X
1110(a)X
1181(semantic)X
1527(or)X
1632(syntactic)X
1978(predicate,)X
2355(renders)X
2644(the)X
2783(parser)X
3028(non-linear)X
3421(in)X
3521(nature.)X
3816(While)X
576 2428(this)N
726(is)X
807(true,)X
988(the)X
1118(slowdown)X
1501(is)X
1582(negligible)X
1958(as)X
2053(the)X
2183(parser)X
2419(is)X
2500(mostly)X
2763(linear.)X
3030(Further,)X
3333(it)X
3406(is)X
3488(better)X
3712(to)X
3804(have)X
3993(a)X
576 2556(capability)N
947(that)X
1102(is)X
1183(slightly)X
1471(inef\256cient)X
1851(than)X
2025(not)X
2160(to)X
2251(have)X
2439(the)X
2569(capability)X
2940(at)X
3026(all.)X
3 f
576 2812(3.2.)N
752(Syntactic)X
1121(Predicates)X
1 f
776 2968(Just)N
947(as)X
1054(semantic)X
1402(predicates)X
1793(indicate)X
2107(when)X
2331(a)X
2404(production)X
2821(is)X
2915(valid,)X
2 f
3149(syntactic)X
1 f
3498(predicates)X
3890(also)X
576 3096(indicate)N
879(when)X
1092(a)X
1154(production)X
1559(is)X
1641(a)X
1703(candidate)X
2064(for)X
2189(recognition.)X
2658(The)X
2818(difference)X
3197(lies)X
3342(in)X
3433(the)X
3563(type)X
3737(of)X
3832(infor-)X
576 3224(mation)N
855(used)X
1049(to)X
1152(predict)X
1431(alternative)X
1838(productions.)X
2332(Semantic)X
2695(predicates)X
3086(employ)X
3385(information)X
3836(about)X
576 3352(the)N
708(``meaning'')X
1152(of)X
1249(the)X
1381(input)X
1587(\(e.g.,)X
1789(symbol)X
2073(table)X
2269(information\))X
2739(whereas)X
3050(syntactic)X
3387(predicates)X
3767(employ)X
576 3480(structural)N
937(information)X
1382(like)X
1543(normal)X
2 f
10 s
1819(LL)X
1 f
1920(\()X
2 f
1947(k)X
1 f
1989(\))X
11 s
2044(parsing)X
2331(decisions.)X
2731(Syntactic)X
3088(predicates)X
3473(specify)X
3755(a)X
3822(gram-)X
576 3608(matical)N
866(construct)X
1218(that)X
1380(must)X
1580(be)X
1691(seen)X
1875(on)X
1991(the)X
2127(input)X
2337(stream)X
2600(for)X
2730(a)X
2797(production)X
3207(to)X
3304(be)X
3415(valid.)X
3664(Moreover,)X
576 3736(this)N
738(construct)X
1095(may)X
1281(match)X
1531(input)X
1747(streams)X
2050(that)X
2217(are)X
2358(arbitrarily)X
2745(long;)X
2961(normal)X
2 f
10 s
3244(LL)X
1 f
3345(\()X
2 f
3372(k)X
1 f
3414(\))X
11 s
3476(parsers)X
3759(are)X
3901(res-)X
576 3864(tricted)N
827(to)X
921(using)X
1137(the)X
1270(next)X
2 f
10 s
1445(k)X
1 f
11 s
1506(symbols)X
1825(of)X
1923(lookahead.)X
2354(This)X
2536(section)X
2811(describes)X
3163(the)X
3296(form)X
3492(and)X
3643(use)X
3784(of)X
3881(syn-)X
576 3992(tactic)N
790(predicates)X
1169(as)X
1264(well)X
1438(as)X
1533(their)X
1717 0.2679(implementation.)AX
3 f
576 4248(3.2.1.)N
818(Syntactic)X
1187(Predicate)X
1566(Form)X
1 f
776 4404(Syntactic)N
1127(predictions)X
1541(have)X
1729(the)X
1859(form)X
7 f
9 s
576 4568(\()N
10 s
9 f
662(a)X
9 s
7 f
755(\)?)X
10 s
9 f
884(b)X
1 f
11 s
576 4772(or,)N
693(the)X
823(shorthand)X
1192(form)X
7 f
9 s
576 4936(\()N
10 s
9 f
662(a)X
9 s
7 f
755(\)?)X
1 f
11 s
576 5140(which)N
813(is)X
894(identical)X
1221(to)X
7 f
9 s
576 5304(\()N
10 s
9 f
662(a)X
9 s
7 f
755(\)?)X
10 s
9 f
884(a)X
1 f
11 s
576 5508(where)N
10 s
9 f
818(a)X
11 s
1 f
898(and)X
10 s
9 f
1054(b)X
11 s
1 f
1129(are)X
1267(arbitrary)X
1601(Extended)X
1965(BNF)X
2167(\(EBNF\))X
2481(grammar)X
2830(fragments)X
3213(that)X
3377(do)X
3496(not)X
3640(de\256ne)X
3886(new)X
576 5636(nonterminals.)N
1108(The)X
1272(notation)X
1589(is)X
1675(similar)X
1948(to)X
2043(the)X
7 f
2208(\()X
10 s
9 f
2261(a)X
11 s
7 f
2311(\)*)X
1 f
2443(and)X
7 f
2627(\()X
10 s
9 f
2680(a)X
11 s
7 f
2730(\)+)X
1 f
2862(closure)X
3142(blocks)X
3398(already)X
3683(present)X
3963(in)X
576 5764(PCCTS.)N
920(The)X
1087(meaning)X
1421(of)X
1524(the)X
1662(long)X
1849(form)X
2050(syntactic)X
2394(predicate)X
2747(is:)X
2883(``)X
3 f
2941(If)X
10 s
9 f
3033(a)X
3035(a)X
11 s
3 f
3116(is)X
3206(matched)X
3559(on)X
3683(the)X
3831(input)X

10 p
%%Page: 10 10
11 s 0 xH 0 xS 3 f
1 f
2209 416(-)N
2260(10)X
2370(-)X
3 f
576 704(stream,)N
878(attempt)X
1192(to)X
1287(recognize)X
10 s
9 f
1664(b)X
1666(b)X
11 s
3 f
1710(.)X
1 f
('')S
1812(Note)X
2005(the)X
2135(similarity)X
2497(to)X
2588(the)X
2 f
2718(semantic)X
3053(predicate)X
1 f
3386(:)X
7 f
9 s
576 868(<<)N
10 s
9 f
662(a)X
9 s
7 f
712(>>?)X
10 s
9 f
884(b)X
1 f
11 s
576 1072(which)N
813(means:)X
1085(``)X
3 f
1143(If)X
10 s
9 f
1226(a)X
1228(a)X
11 s
3 f
1300(evaluates)X
1669(to)X
1764(true)X
1942(at)X
2037(parser)X
2303(run-time,)X
2679(attempt)X
2993(to)X
3088(match)X
10 s
9 f
3342(b)X
3344(b)X
1 f
11 s
3388(.'')X
776 1228(Decisions,)N
1173(which)X
1416(are)X
1551(nondeterministic)X
2173(\(non-)X
2 f
10 s
2363(LL)X
1 f
2464(\()X
2 f
2491(k)X
1 f
2533(\))X
11 s
2588(for)X
2718(\256nite)X
2 f
10 s
2926(k)X
1 f
11 s
2962(\),)X
3041(are)X
3176(resolved)X
3502(via)X
7 f
3669(\(..\)?)X
1 f
3963(in)X
576 1356(the)N
706(following)X
1071(manner:)X
7 f
9 s
576 1520(a)N
748(:)X
10 s
9 f
920(g)X
1 f
7 s
953 1536(1)N
7 f
9 s
9 f
748 1608(|)N
10 s
891(g)X
1 f
7 s
924 1624(2)N
7 f
9 s
705 1696(...)N
9 f
748 1784(|)N
7 f
891(\()X
10 s
9 f
977(a)X
2 f
7 s
1027 1800(i)N
7 f
9 s
1092 1784(\)?)N
10 s
9 f
1221(g)X
2 f
7 s
1254 1800(i)N
7 f
9 s
705 1872(...)N
9 f
748 1960(|)N
10 s
891(g)X
2 f
7 s
928 1976(j)N
7 f
9 s
705 2048(...)N
9 f
748 2136(|)N
10 s
891(g)X
2 f
7 s
924 2152(n)N
7 f
9 s
748 2224(;)N
1 f
11 s
576 2428(where)N
826(productions)X
2 f
10 s
1276(i)X
1 f
11 s
1334(and)X
2 f
10 s
1501(j)X
1 f
11 s
1559(are)X
1702(mutually)X
2053(nondistinguishable)X
2756(from)X
2963(the)X
3107(left-edge.)X
3500(If)X
3594(production)X
2 f
10 s
4010(i)X
1 f
11 s
576 2556(fails,)N
779(production)X
2 f
10 s
1194(j)X
1 f
11 s
1245(will)X
1412(be)X
1524(attempted.)X
1946(Typically,)X
2336(the)X
2472(number)X
2769(of)X
2870(syntactic)X
3212(predicates)X
3597(employed)X
3973(is)X
2 f
10 s
576 2684(n)N
9 f
629(-)X
1 f
673(1)X
11 s
741(where)X
2 f
10 s
981(n)X
1 f
11 s
1049(is)X
1136(the)X
1272(number)X
1569(of)X
1671(mutually)X
2015(nondeterministic)X
2638(productions)X
3083(in)X
3181(a)X
3249(decision;)X
3597(the)X
3734(last)X
3886(pro-)X
576 2812(duction)N
863(is)X
944(attempted)X
1315(by)X
1425(default.)X
776 2968(When)N
1011(a)X
1075(production)X
1483(to)X
1578(be)X
1687(predicted)X
2041(must)X
2239(be)X
2348(predicted)X
2702(with)X
2885(itself)X
3088(\(nothing)X
3413(less)X
3571(sophisticated)X
576 3096(is)N
657(suf\256cient\))X
1036(or)X
1131(when)X
1343(ef\256ciency)X
1712(is)X
1793(not)X
1928(a)X
1989(major)X
2217(concern,)X
2539(the)X
2669(short)X
2867(form)X
3060(is)X
3141(used:)X
7 f
9 s
576 3260(a)N
748(:)X
10 s
9 f
920(g)X
1 f
7 s
953 3276(1)N
7 f
9 s
9 f
748 3348(|)N
10 s
891(g)X
1 f
7 s
924 3364(2)N
7 f
9 s
705 3436(...)N
9 f
748 3524(|)N
7 f
891(\()X
10 s
9 f
977(g)X
2 f
7 s
1010 3540(i)N
7 f
9 s
1075 3524(\)?)N
705 3612(...)N
9 f
748 3700(|)N
10 s
891(g)X
2 f
7 s
928 3716(j)N
7 f
9 s
705 3788(...)N
9 f
748 3876(|)N
10 s
891(g)X
2 f
7 s
924 3892(n)N
7 f
9 s
748 3964(;)N
3 f
11 s
576 4268(3.2.2.)N
818(Modi\256ed)X
2 f
10 s
1176(LL)X
1 f
1277(\()X
2 f
1304(k)X
1 f
1346(\))X
3 f
11 s
1395(Parsing)X
1706(Scheme)X
1 f
776 4424(Decisions)N
1146(that)X
1302(are)X
1432(not)X
1568(augmented)X
1978(with)X
2158(syntactic)X
2495(predicates)X
2875(are)X
3005(parsed)X
3257 0.2305(deterministically)AX
3875(with)X
576 4552(\256nite)N
783(lookahead)X
1170(up)X
1283(to)X
1377(depth)X
2 f
10 s
1596(k)X
1 f
11 s
1657(as)X
1755(is)X
1839(normal)X
2114(for)X
2241(PCCTS-generated)X
2906(parsers.)X
3222(When)X
3456(at)X
3544(least)X
3730(one)X
3881(syn-)X
576 4680(tactic)N
790(predicate)X
1135(is)X
1216(present)X
1492(in)X
1583(a)X
1644(decision,)X
1982(rule)X
2141(recognition)X
2565(proceeds)X
2899(as)X
2994(follows:)X
576 4964([1])N
776(Find)X
967(the)X
1104(\256rst)X
2 f
1270(viable)X
1 f
1515(production;)X
1952(i.e.)X
2090(the)X
2228(\256rst)X
2395(production)X
2807(in)X
2906(the)X
3044(alternative)X
3447(list)X
3586(predicted)X
3944(by)X
776 5092(the)N
939(current)X
1242(\256nite)X
1478(lookahead,)X
1916(according)X
2317(to)X
2440(the)X
2602(associated)X
3018(\256nite-lookahead)X
3645(prediction-)X
776 5220(expression.)N
576 5376([2])N
776(If)X
856(the)X
986(\256rst)X
1145(element)X
1447(in)X
1538(that)X
1693(production)X
2097(is)X
2178(not)X
2313(a)X
2374(syntactic)X
2710(predicate,)X
3077(predict)X
3344(that)X
3500(production)X
3905(and)X
776 5504(go)N
886(to)X
977([4])X
1101(else)X
1260(attempt)X
1548(to)X
1639(match)X
1877(its)X
1983(predicting)X
2363(grammar)X
2703(fragment.)X
576 5660([3])N
776(If)X
866(the)X
1006(grammar)X
1356(fragment)X
1706(is)X
1797(matched,)X
2150(predict)X
2427(the)X
2567(associated)X
2962(production)X
3377(and)X
3537(go)X
3658(to)X
3760([4])X
3895(else)X
776 5788(\256nd)N
935(the)X
1065(next)X
1239(viable)X
1477(production)X
1881(and)X
2030(go)X
2140(to)X
2231([2].)X

11 p
%%Page: 11 11
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(11)X
2370(-)X
576 704([4])N
776(Proceed)X
1081(with)X
1260(the)X
1390(normal)X
1662(recognition)X
2086(of)X
2181(the)X
2311(production)X
2715(predicted)X
3065(in)X
3156([2])X
3280(or)X
3375([3].)X
576 988(For)N
720(successful)X
1103(predicates,)X
1504(both)X
1683(the)X
1813(predicting)X
2193(grammar)X
2533(fragment)X
2873(and)X
3022(the)X
3152(remainder)X
3532(of)X
3628(the)X
3759(produc-)X
576 1116(tion)N
750(are)X
892(actually)X
1207(matched,)X
1563(hence,)X
1825(the)X
1968(short)X
2179(form,)X
7 f
2438(\()X
10 s
9 f
2491(a)X
11 s
7 f
2541(\)?)X
1 f
2647(,)X
2704(actually)X
3019(matches)X
10 s
9 f
3341(a)X
11 s
1 f
3426(twice)X
3639(\320)X
3762(once)X
3963(to)X
576 1244(predict)N
843(and)X
992(once)X
1180(to)X
1271(apply)X
10 s
9 f
1487(a)X
11 s
1 f
1559(normally.)X
3 f
576 1500(3.2.3.)N
818(Syntactic)X
1187(Predicate)X
1566(Placement)X
1 f
776 1656(Syntactic)N
1128(predicates)X
1508(may)X
1683(only)X
1864(appear)X
2122(as)X
2219(the)X
2351(\256rst)X
2512(element)X
2816(of)X
2913(a)X
2976(production)X
3382(because)X
3684(that)X
3841(is)X
3924(the)X
576 1784(only)N
760(place)X
973(decisions)X
1328(are)X
1462(required.)X
1826(For)X
1975(example,)X
2323(the)X
7 f
2489(\(..\)?)X
1 f
2781(block)X
3004(in)X
3100(the)X
3235(\256rst)X
3398(production)X
3806(of)X
3905(fol-)X
576 1912(lowing)N
843(grammar)X
1183(has)X
1322(little)X
1508(utility.)X
7 f
9 s
576 2076(a)N
748(:)X
10 s
9 f
920(g)X
1 f
7 s
953 2092(1)N
7 f
9 s
1030 2076(\()N
10 s
9 f
1116(a)X
9 s
7 f
1209(\)?)X
10 s
9 f
1338(b)X
9 s
748 2164(|)N
10 s
891(g)X
1 f
7 s
924 2180(2)N
7 f
9 s
705 2252(...)N
9 f
748 2340(|)N
10 s
891(g)X
2 f
7 s
924 2356(n)N
7 f
9 s
748 2428(;)N
1 f
11 s
576 2632(There)N
808(is)X
894(no)X
1009(question)X
1335(that)X
10 s
9 f
1493(b)X
11 s
1 f
1564(is)X
1650(to)X
1746(be)X
1856(matched)X
2182(after)X
10 s
9 f
2368(g)X
7 s
1 f
2401 2648(1)N
11 s
2463 2632(and)N
2618(trying)X
2857(to)X
2954(predict)X
3227(this)X
3383(situation)X
3716(is)X
3803(redun-)X
576 2760(dant.)N
776 2916(Syntactic)N
1131(predicates)X
1514(may)X
1692(appear)X
1953(on)X
2068(the)X
2203(left)X
2348(edge)X
2541(of)X
2641(any)X
2795(production)X
3204(within)X
3457(any)X
3611(subrule,)X
3919(not)X
576 3044(just)N
726(in)X
817(productions)X
1255(at)X
1341(the)X
1471(rule)X
1630(block)X
1848(level.)X
3 f
576 3300(3.2.4.)N
818(Nested)X
1093(Syntactic)X
1462(Predicate)X
1841(Invocation)X
1 f
776 3456(Because)N
1106(syntactic)X
1457(predicates)X
1851(may)X
2041(reference)X
2405(any)X
2570(de\256ned)X
2867(nonterminal)X
3332(and)X
3497(because)X
3813(of)X
3924(the)X
576 3584(recursive)N
933(nature)X
1188(of)X
1296(grammars,)X
1704(it)X
1788(is)X
1881(possible)X
2204(for)X
2340(the)X
2482(parser)X
2730(to)X
2833(return)X
3077(to)X
3180(a)X
3253(point)X
3469(in)X
3572(the)X
3714(grammar)X
576 3712(which)N
830(had)X
996(already)X
1294(requested)X
1671(backtracking.)X
2210(This)X
2407(nested)X
2672(invocation)X
3085(poses)X
3320(no)X
3448(problem)X
3782(from)X
3993(a)X
576 3840(theoretical)N
971(point)X
1175(of)X
1270(view,)X
1485(but)X
1620(can)X
1764(cause)X
1981(unexpected)X
2404(parsing)X
2685(delays)X
2932(in)X
3023(practice.)X
3 f
576 4096(3.2.5.)N
818(Grammar)X
1221(Fragments)X
1648(within)X
1910(Syntactic)X
2279(Predicates)X
1 f
776 4252(The)N
949(grammar)X
1303(fragments)X
1691(within)X
7 f
1984(\()X
10 s
9 f
2037(a)X
11 s
7 f
2087(\)?)X
1 f
2229(may)X
2417(be)X
2536(any)X
2699(valid)X
2912(PCCTS)X
3218(production)X
3636(right-hand-)X
576 4380(side;)N
767(i.e.)X
899(any)X
1050(expression)X
1450(except)X
1704(new)X
1874(nonterminal)X
2325(de\256nitions.)X
10 s
9 f
2764(a)X
11 s
1 f
2837(may)X
3012(contain)X
3295(semantic)X
3632(actions)X
3905(and)X
576 4508(semantic)N
912(predicates,)X
1313(although)X
1644(only)X
1823(the)X
1953(semantic)X
2289(predicates)X
2668(will)X
2828(be)X
2933(executed)X
3268(during)X
3520(prediction.)X
3 f
576 4764(3.2.6.)N
818(Ef\256ciency)X
1 f
776 4920(In)N
875(terms)X
1097(of)X
1196(ef\256ciency,)X
1591(the)X
1725(order)X
1936(of)X
2035(alternative)X
2434(productions)X
2876(in)X
2971(a)X
3036(decision)X
3356(is)X
3442(signi\256cant.)X
3881(Pro-)X
576 5048(ductions)N
911(in)X
1015(a)X
1089(PCCTS)X
1394(grammar)X
1747(are)X
1889(always)X
2168(attempted)X
2552(in)X
2656(the)X
2799(order)X
3019(speci\256ed.)X
3411(For)X
3568(example,)X
3924(the)X
576 5176(parsing)N
865(strategy)X
1174(outline)X
1450(above)X
1690(indicates)X
2035(that)X
2199(the)X
2338(following)X
2712(rule)X
2880(is)X
2970(most)X
3173(ef\256cient)X
3493(when)X
10 s
9 f
3712(g)X
7 s
1 f
3745 5192(1)N
11 s
3810 5176(is)N
3900(less)X
576 5304(complex)N
902(than)X
10 s
9 f
1074(g)X
7 s
1 f
1107 5320(2)N
11 s
1141 5304(.)N
7 f
9 s
576 5468(a)N
756(:)X
928(\()X
10 s
9 f
971(g)X
1 f
7 s
1004 5484(1)N
7 f
9 s
1038 5468(\)?)N
9 f
748 5556(|)N
10 s
891(g)X
1 f
7 s
924 5572(2)N
7 f
9 s
756 5644(;)N

12 p
%%Page: 12 12
9 s 0 xH 0 xS 7 f
11 s
1 f
2209 416(-)N
2260(12)X
2370(-)X
776 704(Any)N
953(parsing)X
1238(decisions)X
1592(made)X
1809(inside)X
2047(a)X
7 f
2144(\(..\)?)X
1 f
2436(block)X
2659(are)X
2793(made)X
3011 0.2305(deterministically)AX
3633(unless)X
3880(they)X
576 832(themselves)N
990(are)X
1119(pre\256xed)X
1429(with)X
1608(syntactic)X
1944(predicates.)X
2367(For)X
2511(example,)X
7 f
9 s
576 996(a)N
756(:)X
936(\()X
1022(\(A\)+)X
1237(X)X
9 f
1323(|)X
7 f
1380(\(B\)+)X
1595(X)X
1681(\)?)X
9 f
756 1084(|)N
7 f
936(\(A\)*)X
1151(Y)X
756 1172(;)N
1 f
11 s
576 1376(speci\256es)N
901(that)X
1056(the)X
1186(parser)X
1422(should)X
1679(attempt)X
1967(to)X
2058(match)X
2296(the)X
2426(nonpredicated)X
2947(subrule)X
7 f
9 s
756 1540(\()N
936(\(A\)+)X
1151(X)X
9 f
756 1628(|)N
7 f
936(\(B\)+)X
1151(X)X
756 1716(\))N
1 f
11 s
576 1920(using)N
803(normal)X
1089(the)X
1233(normal)X
1519(\256nite-lookahead)X
2128(parsing)X
2423(strategy.)X
2782(If)X
2876(a)X
2952(sentence)X
3292(recognizable)X
3779(by)X
3904(this)X
576 2048(grammar)N
919(fragment)X
1262(is)X
1346(found)X
1576(on)X
1689(the)X
1822(input)X
2029(stream,)X
2310(then)X
2486(restore)X
2749(the)X
2881(state)X
3067(of)X
3164(the)X
3296(parser)X
3534(to)X
3627(what)X
3822(it)X
3896(was)X
576 2176(before)N
824(the)X
956(predicate)X
1303(invocation)X
1700(and)X
1852(parse)X
2062(the)X
2195(grammar)X
2538(fragment)X
2881(again;)X
3122(else,)X
3306(if)X
3385(the)X
3518(attempt)X
3809(failed,)X
576 2304(apply)N
794(the)X
924(next)X
1098(production)X
1502(in)X
1593(the)X
1723(outer)X
1926(block:)X
7 f
9 s
576 2468(\(A\)*)N
791(Y)X
3 f
11 s
576 2772(3.2.7.)N
818(Resolving)X
1207(Ambiguous)X
1659(C++)X
1844(Statements)X
1 f
776 2928(Quoting)N
1090(from)X
1286(Ellis)X
1474(and)X
1626(Stroustrup)X
2018([``The)X
2267(Annotated)X
2659(C++)X
2843(Reference)X
3224(Manual,'')X
3599(Margaret)X
3947(A.)X
576 3056(Ellis)N
782(and)X
952(Bjarne)X
1230(Stroustrup,)X
1662(Addison)X
2003(Wesley)X
2310(Publishing)X
2731(Company;)X
3141(Reading,)X
3499(Massachusetts;)X
576 3184(1990],)N
776 3340(``There)N
1064(is)X
1148(an)X
1256(ambiguity)X
1640(in)X
1735(the)X
1869(grammar)X
2213(involving)X
2 f
2578(expression-statements)X
1 f
3381(and)X
2 f
3534(declara-)X
776 3468(tions)N
1 f
948(...)X
1041(The)X
1205(general)X
1491(cases)X
1702(cannot)X
1963(be)X
2072(resolved)X
2396(without)X
2692(backtracking...)X
3239(In)X
3338(particular,)X
3724(the)X
776 3596(lookahead)N
1160(needed)X
1431(to)X
1522(disambiguate)X
2015(this)X
2165(case)X
2338(is)X
2419(not)X
2554(limited.'')X
576 3752(The)N
735(authors)X
1016(use)X
1155(the)X
1285(following)X
1650(examples)X
2005(to)X
2096(make)X
2309(their)X
2493(point:)X
7 f
9 s
576 3916(T\(*a\)->m=7;)N
1264(//)X
2 f
1393(expression-statement)X
7 f
576 4004(T\(*a\)\(int\);)N
1264(//)X
2 f
1393(declaration)X
1 f
11 s
576 4208(Clearly,)N
880(the)X
1010(two)X
1164(types)X
1372(of)X
1467(statements)X
1862(are)X
1991(not)X
2126(distinguishable)X
2683(from)X
2876(the)X
3006(left)X
3146(as)X
3241(an)X
3346(arbitrary)X
3671(amount)X
3959(of)X
576 4336(symbols)N
893(may)X
1068(be)X
1174(seen)X
1353(before)X
1600(a)X
1661(decision)X
1977(can)X
2121(be)X
2226(made;)X
2464(here,)X
2659(the)X
7 f
2820(->)X
1 f
2948(symbol)X
3230(is)X
3311(the)X
3441(\256rst)X
3600(clue)X
3769(that)X
3924(the)X
576 4464(\256rst)N
735(example)X
1056(is)X
1137(a)X
1198(statement.)X
1603(Quoting)X
1914(Ellis)X
2099(and)X
2248(Stroustrup)X
2637(further,)X
776 4620(``In)N
929(a)X
990(parser)X
1226(with)X
1405(backtracking)X
1882(the)X
2012(disambiguating)X
2579(rule)X
2738(can)X
2882(be)X
2987(stated)X
3215(very)X
3393(simply:)X
776 4748([1])N
900(If)X
980(it)X
1052(looks)X
1265(like)X
1420(a)X
2 f
1481(declaration)X
1 f
1888(,)X
1932(it)X
2004(is;)X
2110(otherwise)X
776 4876([2])N
900(if)X
976(it)X
1048(looks)X
1261(like)X
1416(an)X
2 f
1521(expression)X
1 f
1897(,)X
1941(it)X
2013(is;)X
2119(otherwise)X
776 5004([3])N
900(it)X
972(is)X
1053(a)X
1114(syntax)X
1366(error.'')X
576 5160(The)N
735(solution)X
1042(in)X
1133(PCCTS)X
1425(using)X
1638(syntactic)X
1974(predicates)X
2353(is)X
2434(simply:)X
7 f
9 s
576 5324(stat:)N
920(\(declaration\)?)X
9 f
748 5412(|)N
7 f
891(expression)X
748 5500(;)N
1 f
11 s
576 5704(The)N
734(semantics)X
1103(of)X
1197(rule)X
7 f
1386(stat)X
1 f
1619(are)X
1747(exactly)X
2023(that)X
2177(of)X
2271(the)X
2401(quoted)X
2663(solution.)X
3014(The)X
3173(production)X
7 f
3608(declara-)X
576 5832(tion)N
1 f
816(will,)X
1004(however,)X
1356(be)X
1467(recognized)X
1881(twice)X
2100(upon)X
2304(a)X
2371(valid)X
2576(declaration)X
2996(and)X
3150(once)X
3343(upon)X
3546(an)X
3656(expression)X

13 p
%%Page: 13 13
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(13)X
2370(-)X
576 704(to)N
667(decide)X
919(that)X
1074(it)X
1146(is)X
1227(not)X
1362(a)X
1423(declaration.)X
3 f
576 960(3.2.8.)N
818(Revisiting)X
1217(the)X
1356(ML)X
1520(Example)X
1 f
776 1116(To)N
902(illustrate)X
1240(the)X
1376(utility)X
1617(of)X
1718(the)X
1854(full)X
2005(form)X
2204(of)X
2305(syntactic)X
2647(predicates,)X
3054(reconsider)X
3448(the)X
3584(grammar)X
3930(for)X
576 1244(the)N
706(ML-style)X
1056(statements)X
1451(provided)X
1786(in)X
1877(the)X
2007(example)X
2328(section)X
2600(above:)X
7 f
9 s
576 1408(stat:)N
936(list)X
1151("=")X
1323(list)X
1538(";")X
9 f
756 1496(|)N
7 f
936(list)X
1151(";")X
756 1584(;)N
1 f
11 s
576 1788(Rule)N
7 f
799(stat)X
1 f
1036(is)X
1120(not)X
2 f
10 s
1256(LL)X
1 f
11 s
1369(because)X
7 f
1703(list)X
1 f
1940(could)X
2162(be)X
2271(arbitrarily)X
2650(long)X
2833(and,)X
3008(hence,)X
3261(predicting)X
3645(which)X
3886(pro-)X
576 1916(duction)N
866(to)X
960(apply)X
1181(beforehand)X
1601(is)X
1685(impossible)X
2093(with)X
2275(a)X
2339(\256nite)X
2546(lookahead)X
2933(depth.)X
3197(There)X
3426(are)X
3557(two)X
3713(solutions)X
576 2044(in)N
670(using)X
886(syntactic)X
1225(predicates,)X
1630(one)X
1783(more)X
1990(ef\256cient)X
2305(than)X
2483(the)X
2617(other.)X
2868(The)X
3031(\256rst)X
3194(method)X
3485(is,)X
3592(as)X
3691(before,)X
3963(to)X
576 2172(specify:)N
7 f
9 s
576 2336(stat:)N
936(\(list)X
1194("=")X
1366(list)X
1581(";"\)?)X
9 f
756 2424(|)N
7 f
936(list)X
1151(";")X
756 2512(;)N
1 f
11 s
576 2716(However,)N
946(this)X
1102(speci\256cation)X
1576(unnecessarily)X
2083(matches)X
2400(the)X
7 f
2567(list)X
1 f
2807(following)X
3178(the)X
3314(assignment)X
3739(operator)X
576 2844(twice.)N
833(A)X
918(more)X
1121(ef\256cient,)X
1454(but)X
1589(functionally)X
2038(equivalent,)X
2450(speci\256cation)X
2918(is)X
2999(as)X
3094(follows:)X
7 f
9 s
576 3008(stat:)N
936(\(list)X
1194("="\)?)X
1452(list)X
1667("=")X
1839(list)X
2054(";")X
9 f
756 3096(|)N
7 f
936(list)X
1151(";")X
756 3184(;)N
1 f
11 s
576 3388(This)N
756(description)X
1171(indicates)X
1508(that,)X
1686(as)X
1782(soon)X
1971(as)X
2067(the)X
7 f
2229("=")X
1 f
2411(has)X
2551(been)X
2740(seen,)X
2941(the)X
3073(\256rst)X
3234(production)X
3640(is)X
3723(uniquely)X
576 3516(predicted.)N
3 f
576 3772(3.2.9.)N
818(Syntactic)X
1187(Predicates)X
1600(Effect)X
1846(on)X
1961(Grammar)X
2364(Analysis)X
1 f
776 3928(ANTLR)N
1097(still)X
1259(constructs)X
1644(normal)X
2 f
10 s
1921(LL)X
1 f
2022(\()X
2 f
2049(k)X
1 f
2091(\))X
11 s
2147(decisions)X
2504(throughout)X
2920(predicated)X
3316(parsers.)X
3637(Only)X
3842(when)X
576 4056(necessary)N
948(are)X
1086(arbitrary)X
1420(lookahead)X
1812(predictors)X
2194(used.)X
2429(Constructing)X
2 f
10 s
2913(LL)X
1 f
3014(\()X
2 f
3041(k)X
1 f
3083(\))X
11 s
3140(parsers)X
3418(is)X
3507(an)X
3620(exponential)X
576 4184(problem)N
895(that)X
1053(ANTLR)X
1371(goes)X
1557(to)X
1651(great)X
1852(lengths)X
2132(to)X
2226(avoid)X
2447(or)X
2545(reduce)X
2804(in)X
2898(size)X
3060(on)X
3173(average.)X
3516(Unfortunately,)X
576 4312(for)N
706(large)X
910(grammars)X
1290(and)X
2 f
10 s
1443(k)X
1 f
11 s
1507(values)X
1760(of)X
1860(more)X
2068(than)X
2247(2)X
2318(or)X
2418(3)X
2489(ANTLR)X
2809(can)X
2958(take)X
3132(an)X
3242(impractical)X
3667(amount)X
3959(of)X
576 4440(time.)N
800(Part)X
964(of)X
1059(the)X
1189(bene\256t)X
1451(of)X
7 f
1577(\(..\)?)X
1 f
1864(blocks)X
2116(is)X
2197(that,)X
2374(by)X
2484(de\256nition,)X
2867(they)X
3041(defy)X
2 f
10 s
3217(LL)X
1 f
3318(\()X
2 f
3345(k)X
1 f
3387(\))X
11 s
3436(analysis.)X
3786(Hence,)X
576 4568(the)N
716(exponential,)X
1182(full)X
2 f
10 s
1335(LL)X
1 f
1436(\()X
2 f
1463(k)X
1 f
1505(\))X
11 s
1564(grammar)X
1914(analysis)X
2230(is)X
2321(turned)X
2578(off)X
2712(for)X
2846(any)X
3005(production)X
3419(beginning)X
3804(with)X
3993(a)X
576 4696(syntactic)N
917(predicate.)X
1311(In)X
1411(its)X
1522(place,)X
1757(a)X
1823(linear)X
2051(approximation)X
2594(to)X
2 f
10 s
2689(LL)X
1 f
2790(\()X
2 f
2817(k)X
1 f
2859(\))X
11 s
2914(analysis,)X
3248(called)X
2 f
10 s
3485(LL)X
1 f
7 s
3582 4664(1)N
10 s
3616 4696(\()N
2 f
3643(k)X
1 f
3685(\))X
11 s
3712(,)X
3762(is)X
3849(used.)X
576 4824(This)N
756(reduces)X
1047(the)X
1178(number)X
1470(of)X
1566(times)X
1781(that)X
1937(arbitrary)X
2263(lookahead)X
7 f
2679(\(..\)?)X
1 f
2967(blocks)X
3220(are)X
3349(attempted)X
3720(unneces-)X
576 4952(sarily,)N
816(though)X
1083(no)X
1193(\256nite)X
1397(lookahead)X
1781(decision)X
2097(is)X
2178(actually)X
2480(required)X
2795(as)X
2890(the)X
3020(arbitrary)X
3345(lookahead)X
3729(mechan-)X
576 5080(ism)N
726(will)X
886(accurately)X
1270(predict)X
1537(the)X
1667(production.)X
776 5236(If)N
865(the)X
1004(current)X
1284(\256nite)X
1497(lookahead)X
1890(can)X
2043(predict)X
2319(which)X
2565(production)X
2978(to)X
3079(apply,)X
3329(syntactic)X
3675(predicates)X
576 5364(are)N
722(not)X
874(evaluated.)X
1294(For)X
1454(example,)X
1813(referring)X
2158(to)X
2265(the)X
2411(C++)X
2608(declaration)X
3038(versus)X
3300(expression)X
3714(grammar)X
576 5492(example)N
902(above,)X
1161(if)X
1243(the)X
1379(current)X
1656(input)X
1866(token)X
2090(were)X
7 f
2319(42)X
1 f
2425(,)X
2475(rule)X
7 f
2671(stat)X
1 f
2911(would)X
3159 0.3187(immediately)AX
3630(attempt)X
3924(the)X
576 5620(second)N
852(production)X
1256(\320)X
7 f
1407(expression)X
1 f
1937(.)X
2013(On)X
2152(the)X
2292(other)X
2504(hand,)X
2728(if)X
2813(the)X
2952(current)X
3232(input)X
3445(token)X
3672(were)X
7 f
3904(ID)X
1 f
4010(,)X
576 5748(then)N
753(the)X
7 f
917(declaration)X
1 f
1525(rule)X
1687(would)X
1933(be)X
2042(attempted)X
2417(before)X
2667(attempting)X
7 f
3103(expression)X
1 f
3633(.)X
3703(If)X
3787(neither)X
576 5876(productions)N
1014(successfully)X
1466(match)X
1704(the)X
1834(input,)X
2060(a)X
2121(syntax)X
2373(occurs.)X

14 p
%%Page: 14 14
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(14)X
2370(-)X
776 704(When)N
1009(constructing)X
1468(\256nite)X
1673(lookahead)X
2058(sets,)X
2235(the)X
2367(grammar)X
2709(fragment)X
3051(within)X
3301(the)X
7 f
3464(\(..\)?)X
1 f
3753(block)X
3973(is)X
576 832(ignored.)N
911(In)X
1006(other)X
1209(words,)X
2 f
10 s
1465(FIRST)X
7 s
1674 848(k)N
1 f
10 s
1705 832(\(\()N
9 f
1759(a)X
1 f
1809(\)?)X
9 f
1892(b)X
1 f
1936(\))X
11 s
1985(is)X
2 f
10 s
2064(FIRST)X
7 s
2273 848(k)N
1 f
10 s
2304 832(\()N
9 f
2331(b)X
1 f
2375(\))X
11 s
2402(.)X
3 f
576 1088(3.2.10.)N
862(The)X
1031(Effect)X
1277(of)X
1372(Nondeterminism)X
2024(upon)X
2237(Translation)X
2700(and)X
2864(Semantic)X
3233(Predicates)X
1 f
776 1244(Syntactic)N
1137(predicates)X
1526(are,)X
1687(by)X
1807(de\256nition,)X
2200(not)X
2346(guaranteed)X
2765(to)X
2867(match)X
3116(the)X
3257(current)X
3539(input.)X
3798(There-)X
576 1372(fore,)N
766(actions)X
1043(with)X
1227(side-effects,)X
1680(for)X
1808(which)X
2049(no)X
2163(``undo'')X
2481(exists,)X
2730(cannot)X
2991(be)X
3100(executed)X
3439(during)X
3695(nondeter-)X
576 1500(ministic)N
892(syntactic)X
1236(prediction)X
1624(\(``guess'')X
1994(mode\).)X
2293(This)X
2480(section)X
2760(describes)X
3118(how)X
3300(ANTLR)X
3624(handles)X
3924(the)X
576 1628(execution)N
941(of)X
1036(user-supplied)X
1532(actions)X
1804(and)X
1953(semantic)X
2289(predicates.)X
3 f
576 1884(3.2.10.1.)N
928(The)X
1097(Effect)X
1343(upon)X
1556(User)X
1753(Actions)X
1 f
776 2040(PCCTS)N
1072(language)X
1416(speci\256cations)X
1922(do)X
2036(not)X
2175(allow)X
2397(the)X
2531(execution)X
2900(of)X
2999(any)X
3152(semantic)X
3493(action)X
3736(during)X
3993(a)X
576 2168(syntactic)N
918(prediction)X
1304(as)X
1405(no)X
1521(undo)X
1725(mechanism)X
2155(exists;)X
2409(this)X
2564(conservative)X
3036(scheme)X
3327(avoids)X
3584(affecting)X
3924(the)X
576 2296(parser)N
812(state)X
996(in)X
1087(an)X
1192(irreversible)X
1615(manner.)X
1945(The)X
2104(only)X
2283(exception)X
2648(to)X
2739(this)X
2890(rule)X
3050(is)X
3132(that)X
3288 0.3317(initialization)AX
3760(actions,)X
576 2424(which)N
819(usually)X
1102(de\256ne)X
1345(variables)X
1691(visible)X
1955(to)X
2052(the)X
2187(entire)X
2415(rule/function,)X
2920(are)X
3054(not)X
3194(enclosed)X
3529(in)X
7 f
3656(if)X
3820({..})X
1 f
576 2552(statements)N
974(to)X
1068(``gate'')X
1356(them)X
1558(out;)X
1721(hence,)X
1973 0.3317(initialization)AX
2447(actions)X
2722(with)X
2904(side)X
3072(effects)X
3332(must)X
3530(be)X
3639(avoided)X
3944(by)X
576 2680(the)N
706(PCCTS)X
998(user.)X
3 f
576 2936(3.2.10.2.)N
928(The)X
1097(Effect)X
1343(upon)X
1556(Semantic)X
1925(Predicates)X
1 f
776 3092(Semantic)N
1146(predicates)X
1544(are)X
1692(always)X
1977(evaluated)X
2356(because)X
2675(they)X
2868(are)X
3016(restricted)X
3385(to)X
3496(side-effect-free)X
576 3220(expressions.)N
1066(During)X
1350(arbitrary)X
1688(lookahead)X
2085(prediction,)X
2500(the)X
2643(semantic)X
2992(predicates)X
3384(that)X
3552(are)X
3694(evaluated)X
576 3348(must)N
774(be)X
883(functions)X
1237(of)X
1336(values)X
1587(computed)X
1961(when)X
2177(actions)X
2453(were)X
2649(turned)X
2900(on.)X
3058(For)X
3206(example,)X
3553(if)X
3634(your)X
3822(gram-)X
576 3476(mar)N
738(has)X
880(a)X
944(predicate)X
1291(that)X
1448(examines)X
1805(the)X
1937(symbol)X
2221(table,)X
2439(all)X
2552(symbols)X
2870(needed)X
3143(to)X
3236(direct)X
3461(the)X
3593(parse)X
3802(during)X
576 3604(prediction)N
967(must)X
1172(be)X
1288(entered)X
1581(into)X
1753(the)X
1895(table)X
2101(before)X
2359(prediction)X
2751(has)X
2902(begun.)X
3195(Consider)X
3547(the)X
3689(following)X
576 3732(grammar)N
916(fragment)X
1256(which)X
1493(recognizes)X
1891(simpli\256ed)X
2267(C)X
2348(declarations.)X
7 f
9 s
576 3896(decl:)N
936("typedef")X
1366(type)X
1581(declarator)X
2054(";")X
3096(/*)X
3225(define)X
3526(new)X
3698(type)X
3913(*/)X
9 f
756 3984(|)N
7 f
936(\()X
1022(type)X
1237(declarator)X
1710("\\{")X
1925(\)?)X
2054(type)X
2269(declarator)X
2742(func_body)X
3276(/*)X
3405(define)X
3706(function)X
4093(*/)X
9 f
756 4072(|)N
7 f
936(type)X
1151(declarators)X
1667(";")X
3096(/*)X
3225(def/decl)X
3612(var\(s\))X
3913(*/)X
756 4160(;)N
576 4336(type:)N
936(built_in_type)X
9 f
756 4424(|)N
7 f
936 -0.1960(<>?)AX
1968(ID)X
756 4512(;)N
576 4688(declarator)N
756 4776(:)N
936(...)X
936 4864(/*)N
1065(recognizes)X
1538(a)X
1624(declarator)X
2097(such)X
2312(as)X
2441(``array[3]'')X
3000(*/)X
936 4952(/*)N
1065(add)X
1237(symbols,)X
1624(both)X
1839(types)X
2097(and)X
2269(vars,)X
2527(to)X
2656(the)X
2828(symbol)X
3129(table)X
3387(*/)X
756 5040(;)N
1 f
11 s
576 5244(This)N
757(rule)X
918(is)X
1001(unnecessarily)X
1504(inef\256cient,)X
1908(but)X
2045(will)X
2207(illustrate)X
2541(the)X
2674(evaluation)X
3067(of)X
3165(semantic)X
3504(predicates)X
3886(dur-)X
576 5372(ing)N
718(nondeterministic)X
1341(prediction.)X
1772(For)X
1922(the)X
2058(purposes)X
2398(of)X
2499(our)X
2644(discussion,)X
3061(we)X
3191(restrict)X
3464(new)X
3638(types)X
3852(to)X
3949(be)X
576 5500(introduced)N
979(using)X
1196(a)X
7 f
1292(typedef)X
1 f
1689(\(structures)X
2086(and)X
2239(unions)X
2500(are)X
2633(not)X
2772(allowed\).)X
3150(Consider)X
3495(the)X
3630(recognition)X
576 5628(of)N
671(the)X
801(two)X
955(sentences:)X

15 p
%%Page: 15 15
11 s 0 xH 0 xS 1 f
9 s
7 f
1 f
2226 376(-)N
2268(15)X
2358(-)X
7 f
576 712(typedef)N
920(int)X
1092(My_int;)X
576 800(My_int)N
877(i;)X
1 f
11 s
576 1004(The)N
739(\256rst)X
902(production)X
1310(of)X
1409(rule)X
7 f
1603(decl)X
1 f
1841(will)X
2005(match)X
2247(the)X
2382(\256rst)X
2546(sentence,)X
2898(adding)X
7 f
3196(My_int)X
1 f
3541(to)X
3637(the)X
3772(symbol)X
576 1132(table)N
778(as)X
881(a)X
950(type)X
1132(name.)X
1397(Production)X
1813(two)X
1974(of)X
7 f
2107(decl)X
1 f
2348(attempts)X
2677(to)X
2775(match)X
3020(the)X
3157(second)X
3430(sentence)X
3762(with)X
3948(its)X
576 1260(syntactic)N
918(predicate.)X
1313(Rule)X
7 f
1539(type)X
1 f
1779(is)X
1866(entered,)X
2175(which)X
2418(evaluates)X
7 f
2806 0.1985(is_type\(LATEXT\(1\)\))AX
1 f
3789(\(where)X
7 f
576 1388(is_type\(\))N
1 f
1075(is)X
1156(some)X
1364(user-de\256ned)X
1820(function)X
2136(that)X
2291(looks)X
2504(up)X
2614(its)X
2720(symbol)X
3002(argument)X
3357(in)X
3448(the)X
3578(symbol)X
3860(table)X
576 1516(and)N
729(returns)X
999(true)X
1162(if)X
1242(that)X
1401(symbol)X
1687(is)X
1772(de\256ned)X
2057(and)X
2210(is)X
2295(a)X
2360(type\).)X
2611(Because)X
2930(the)X
3065(text)X
3225(of)X
3325(the)X
3460(current)X
3736(token)X
3959(of)X
576 1644(lookahead,)N
7 f
1015(My_int)X
1 f
1333(,)X
1379(is)X
1462(a)X
1525(valid)X
1725(type,)X
1922(the)X
2053(predicate)X
2399(evaluates)X
2750(to)X
2842(true.)X
3046(Production)X
3456(two)X
3611(of)X
7 f
3738(type)X
1 f
3973(is)X
576 1772(applicable)N
973(semantically)X
1455(and)X
1617(is,)X
1733(therefore,)X
2107(applied.)X
2446(After)X
2666(consuming)X
7 f
3119(My_int)X
1 f
3437(,)X
3494(the)X
3637(parser)X
3886(suc-)X
576 1900(cessfully)N
915(applies)X
7 f
1222(declarator)X
1 f
1778(to)X
7 f
1904(i)X
1 f
1957(.)X
2027(The)X
2190(next)X
2368(input)X
2576(token)X
2797(is)X
7 f
2912(;)X
1 f
2990(which)X
3230(does)X
3416(not)X
3554(match)X
3826(.)X
3895(The)X
576 2028(nondeterministic)N
1192(prediction)X
1572(fails)X
1746(and)X
1895(production)X
2299(three)X
2497(is)X
2578(predicted)X
2928(by)X
3038(default)X
3305(and)X
3454(is)X
3535(applied.)X
776 2184(The)N
935(second)X
1201(production)X
1605(of)X
1700(rule)X
7 f
1890(decl)X
1 f
2124(could)X
2342(not)X
2477(be)X
2582(rewritten)X
2922(as)X
7 f
9 s
576 2348(\()N
662(type)X
877(declarator)X
1350(func_body)X
1836(\)?)X
2016(/*)X
2145(define)X
2446(function)X
2833(*/)X
1 f
11 s
576 2552(because,)N
901(presumably,)X
1359(a)X
1423(func_body)X
1825(could)X
2047(de\256ne)X
2288(new)X
2460(types.)X
2716(The)X
2879(actions)X
3155(that)X
3314(add)X
3467(these)X
3674(new)X
3846(types)X
576 2680(to)N
673(the)X
809(symbol)X
1097(table)X
1297(would)X
1545(not)X
1686(be)X
1796(executed,)X
2158(however,)X
2509(as)X
2609(the)X
2744(parser)X
2985(would)X
3232(be)X
3342(in)X
3438(nondeterministic)X
576 2808(mode.)N
846(Although)X
1209(the)X
1347(semantic)X
1691(predicates)X
2079(would)X
2330(be)X
2444(evaluated)X
2813(correctly,)X
3179(the)X
3318(symbol)X
3609(table)X
3812(would)X
576 2936(not)N
713(hold)X
894(the)X
1026(information)X
1467(necessary)X
1832(to)X
1925(parse)X
2134(the)X
2266(function)X
2583(body)X
2782(during)X
3035(nondeterministic)X
3652(prediction.)X
576 3064(Also,)N
789(this)X
942(revision)X
1251(is)X
1335(very)X
1516(inef\256cient)X
1899(as)X
1997(it)X
2072(would)X
2317(match)X
2559(the)X
2693(entire)X
2920(function,)X
3262(which)X
3503(could)X
3725(be)X
3834(large,)X
576 3192(twice.)N
3 f
576 3448(3.2.11.)N
862(Comparing)X
1314(the)X
1453(Use)X
1611(of)X
1706(Semantic)X
2075(and)X
2239(Syntactic)X
2608(Predicates)X
1 f
776 3604(Language)N
1152(constructs)X
1538(exists)X
1768(that)X
1930(are)X
2066(totally)X
2322(ambiguous)X
2738(syntactically,)X
3236(but)X
3379(easily)X
3615(distinguish-)X
576 3732(able)N
751(semantically.)X
1270(For)X
1420(example,)X
1769(array)X
1977(references)X
2365(and)X
2520(function)X
2842(calls)X
3032(in)X
3129(Fortran)X
3415(are)X
3549(identical)X
3881(syn-)X
576 3860(tactically,)N
950(but)X
1090(very)X
1273(different)X
1603(semantically.)X
2121(The)X
2285(associated)X
2675(grammatical)X
3145(description)X
3565(is)X
3652(non-)X
2 f
10 s
3813(LL)X
1 f
3914(\()X
2 f
3941(k)X
1 f
3983(\))X
11 s
4010(,)X
576 3988(non-)N
2 f
10 s
737(LALR)X
1 f
936(\()X
2 f
963(k)X
1 f
1005(\))X
11 s
1032(,)X
1091(and)X
1255(non-context-free;)X
1903(not)X
2053(even)X
2256(backtracking)X
2748(or)X
2857(in\256nite)X
3144(lookahead)X
3542(will)X
3716(help)X
3904(this)X
576 4116(problem.)N
7 f
9 s
576 4280(expratom:)N
1092(ID)X
1221("\\\(")X
1436(expr_list)X
1866("\\\)")X
9 f
920 4368(|)N
7 f
1063(ID)X
1192("\\\(")X
1407(expr_list)X
1837("\\\)")X
877 4456(...)N
920 4544(;)N
1 f
11 s
576 4748(where)N
7 f
846(expr_list)X
1 f
1348(is)X
1432(some)X
1643(rule)X
1806(matching)X
2161(a)X
2226(comma-separated)X
2873(expression)X
3275(list.)X
3454(Putting)X
7 f
3767(\(..\)?)X
1 f
576 4876(around)N
852(the)X
992(\256rst)X
1161(alternative)X
1566(production)X
1980(will)X
2150(not)X
2295(change)X
2576(the)X
2715(fact)X
2878(that)X
3042(both)X
3230(productions)X
3677(match)X
3924(the)X
576 5004(same)N
795(sentence.)X
1180(However,)X
1561(semantic)X
1913(predicates)X
2308(may)X
2498(be)X
2620(used)X
2820(to)X
2928(semantically)X
3414(disambiguate)X
3924(the)X
576 5132(rule:)N
7 f
9 s
576 5296(expratom:)N
1092 -0.1969(<>?)AX
2167(ID)X
2296("\\\(")X
2511(expr_list)X
2941("\\\)")X
9 f
920 5384(|)N
7 f
1063 -0.1964(<>?)AX
2138(ID)X
2267("\\\(")X
2482(expr_list)X
2912("\\\)")X
877 5472(...)N
920 5560(;)N

16 p
%%Page: 16 16
9 s 0 xH 0 xS 7 f
11 s
1 f
2209 416(-)N
2260(16)X
2370(-)X
3 f
576 704(3.2.12.)N
862(Implementation)X
1 f
776 860(The)N
950(discussion)X
1354(thus)X
1538(far)X
1673(has)X
1828(described)X
2203(the)X
2349(functionality)X
2839(of)X
2950(syntactic)X
3302(predicates,)X
3719(but)X
3870(their)X
576 988 0.2885(implementation)AN
1158(is)X
1243(an)X
1352(equally)X
1638(important)X
2008(topic)X
2211(so)X
2314(that)X
2472(users)X
2677(can)X
2824(understand)X
3235(the)X
3368(new)X
3539(ANTLR)X
3857(pars-)X
576 1116(ing)N
718(mechanism)X
1149(\(e.g.,)X
1356(so)X
1463(that)X
1625(users)X
1834(can)X
1986(follow)X
2246(along)X
2472(in)X
2571(a)X
2640(debugger)X
2997(while)X
3223(tracking)X
3542(down)X
3767(bugs)X
3963(in)X
576 1244(their)N
760(grammar\).)X
776 1400(Because)N
1100(productions)X
1547(are)X
1685(assumed)X
2019(to)X
2119(be)X
2234(attempted)X
2615(in)X
2716(the)X
2856(order)X
3073(speci\256ed,)X
3440(a)X
3511(nested)X
3768(if-then-)X
576 1528(else)N
746(structure)X
1087(is)X
1179(generated.)X
1598(To)X
1729(illustrate)X
2072(the)X
2213(integration)X
2629(of)X
2735(syntactic)X
3082(predicates)X
3472(into)X
3642(the)X
3782(normal)X
576 1656(ANTLR)N
891(code)X
1079(generation)X
1473(scheme,)X
1781(consider)X
2101(the)X
2231(following)X
2596(abstract)X
2892(grammar.)X
7 f
9 s
576 1820(a)N
756(:)X
10 s
9 f
936(g)X
1 f
7 s
969 1836(1)N
7 f
9 s
705 1908(...)N
9 f
756 1996(|)N
7 f
936(\()X
10 s
9 f
1022(a)X
2 f
7 s
1072 2012(i)N
7 f
9 s
1137 1996(\)?)N
10 s
9 f
1266(g)X
2 f
7 s
1299 2012(i)N
7 f
9 s
705 2084(...)N
9 f
756 2172(|)N
7 f
936(\()X
10 s
9 f
1022(a)X
2 f
7 s
1076 2188(j)N
7 f
9 s
1141 2172(\)?)N
10 s
9 f
1270(g)X
2 f
7 s
1307 2188(j)N
7 f
9 s
705 2260(...)N
9 f
756 2348(|)N
10 s
936(g)X
2 f
7 s
969 2364(m)N
7 f
9 s
756 2436(;)N
1 f
11 s
576 2640(ANTLR)N
891(generates)X
1245(the)X
1375(following,)X
1762(``slightly)X
2108(sanitized'',)X
2524(code:)X

17 p
%%Page: 17 17
11 s 0 xH 0 xS 1 f
9 s
7 f
1 f
2226 376(-)N
2268(17)X
2358(-)X
7 f
576 712(a\(\))N
576 800({)N
748 888(zzGUESS_BLOCK)N
748 976(if)N
877(\()X
963(\()X
10 s
9 f
1006(t)X
1 f
7 s
1041 992(1)N
7 f
9 s
1075 976(,)N
1161(...,)X
10 s
9 f
1376(t)X
2 f
7 s
1411 992(k)N
7 f
9 s
1442 976(\))N
2 f
10 s
9 f
1528(\316)X
2 f
1628(LOOK)X
7 s
1841 992(k)N
1 f
10 s
1872 976(\()N
7 f
9 f
1899(g)X
1 f
7 s
1932 992(1)N
10 s
1966 976(\))N
7 f
9 s
2036(\))X
2122({)X
2 f
10 s
920 1064(match)N
7 f
9 f
1170(g)X
1 f
7 s
1203 1080(1)N
7 f
9 s
1237 1064(;)N
748 1152(})N
748 1240(else)N
963({)X
920 1328(zzGUESS)N
920 1416(if)N
1049(\()X
1135(!zzrv)X
1393(&&)X
1522(\()X
10 s
9 f
1565(t)X
1 f
7 s
1600 1432(1)N
7 f
9 s
1634 1416(,)N
1720(...,)X
10 s
9 f
1935(t)X
2 f
7 s
1970 1432(k)N
7 f
9 s
2001 1416(\))N
2 f
10 s
9 f
2087(\316)X
2 f
2187(LOOK)X
7 s
2400 1432(k)N
1 f
10 s
2431 1416(\()N
7 f
9 f
2458(g)X
2 f
7 s
2491 1432(i)N
1 f
10 s
2513 1416(\))N
7 f
9 s
2583(\))X
2669({)X
2 f
10 s
1092 1504(match)N
7 f
9 f
1342(a)X
2 f
7 s
1392 1520(i)N
7 f
9 s
1414 1504(;)N
1092 1592(zzGUESS_DONE)N
2 f
10 s
1092 1680(match)N
7 f
9 f
1342(g)X
2 f
7 s
1375 1696(i)N
7 f
9 s
1397 1680(;)N
920 1768(})N
920 1856(else)N
1135({)X
1092 1944(if)N
1221(\()X
1307(zzguessing)X
1780(\))X
1866(zzGUESS_DONE;)X
1092 2032(zzGUESS)N
1092 2120(if)N
1221(\()X
1307(!zzrv)X
1565(&&)X
1694(\()X
10 s
9 f
1737(t)X
1 f
7 s
1772 2136(1)N
7 f
9 s
1806 2120(,)N
1892(...,)X
10 s
9 f
2107(t)X
2 f
7 s
2142 2136(k)N
7 f
9 s
2173 2120(\))N
2 f
10 s
9 f
2259(\316)X
2 f
2359(LOOK)X
7 s
2572 2136(k)N
1 f
10 s
2603 2120(\()N
7 f
9 f
2630(g)X
2 f
7 s
2667 2136(j)N
1 f
10 s
2689 2120(\))N
7 f
9 s
2759(\))X
2845({)X
2 f
10 s
1264 2208(match)N
7 f
9 f
1514(a)X
2 f
7 s
1568 2224(j)N
7 f
9 s
1590 2208(;)N
1264 2296(zzGUESS_DONE)N
2 f
10 s
1264 2384(match)N
7 f
9 f
1514(g)X
2 f
7 s
1551 2400(j)N
7 f
9 s
1573 2384(;)N
1092 2472(})N
1092 2560(else)N
1307({)X
1264 2648(if)N
1393(\()X
1479(zzguessing)X
1952(\))X
2038(zzGUESS_DONE;)X
1264 2736(if)N
1393(\()X
1479(\()X
10 s
9 f
1522(t)X
1 f
7 s
1557 2752(1)N
7 f
9 s
1591 2736(,)N
1677(...,)X
10 s
9 f
1892(t)X
2 f
7 s
1927 2752(k)N
7 f
9 s
1958 2736(\))N
2 f
10 s
9 f
2044(\316)X
2 f
2144(LOOK)X
7 s
2357 2752(k)N
1 f
10 s
2388 2736(\()N
7 f
9 f
2415(g)X
2 f
7 s
2448 2752(m)N
1 f
10 s
2494 2736(\))N
7 f
9 s
2564(\))X
2650({)X
2 f
10 s
1436 2824(match)N
7 f
9 f
1686(g)X
2 f
7 s
1719 2840(m)N
7 f
9 s
1765 2824(;)N
1264 2912(})N
1264 3000(else)N
1479(goto)X
1694(fail;)X
1092 3088(})N
920 3176(})N
748 3264(})N
748 3352(return;)N
576 3440(fail:)N
748 3528(if)N
877(\()X
963(zzguessing)X
1436(\))X
1522({zzGUESS_FAIL;})X
2 f
748 3616(gen)N
870(syntax)X
1072(error)X
1242(message)X
7 f
1486(;)X
2 f
748 3704(resynch)N
990(parser)X
7 f
1178(;)X
576 3792(})N
1 f
11 s
576 3996(where)N
2 f
10 s
811(LOOK)X
7 s
1024 4012(k)N
1 f
10 s
1055 3996(\()N
9 f
1082(g)X
1 f
1115(\))X
11 s
1165(is)X
1247(the)X
1378(set)X
1499(of)X
1595(lookahead)X
2 f
10 s
1978(k)X
1 f
11 s
2014(-tuples)X
2277(that)X
2433(predict)X
10 s
9 f
2700(g)X
11 s
1 f
2733(.)X
2801(This)X
2982(notation)X
3296(is)X
3379(used)X
3564(as)X
3661(a)X
3724(conveni-)X
576 4124(ence)N
759(here)X
932(whereas)X
1241(ANTLR)X
1556(generates)X
1910(decisions)X
2260(that)X
2415(use)X
2554(as)X
2649(little)X
2835(lookahead)X
3219(as)X
3314(possible)X
3625(in)X
3716(practice.)X
776 4280(The)N
935(macros/variables)X
1554(themselves)X
1968(are)X
2097(de\256ned)X
2378(as)X
2473(follows:)X
7 f
576 4436(zzGUESS_BLOCK)N
1 f
776 4564(De\256ne)N
1060(a)X
1149(block)X
1395(of)X
1518(memory)X
1862(to)X
1981(hold)X
2188(the)X
2346(current)X
2645(parser)X
2909(state)X
3121(and)X
3298(the)X
3456(return)X
3717(value)X
3959(of)X
7 f
776 4692(setjmp\(\))N
1 f
1200(,)X
7 f
1275(zzrv)X
1 f
1487(.)X
7 f
576 4848(zzGUESS)N
1 f
776 4976(Save)N
981(the)X
1123(current)X
1406(parser)X
1654(state,)X
1872(turn)X
2049(on)X
2172(guessing)X
2515(mode)X
2746(and)X
2908(call)X
7 f
3102(setjmp\(\))X
1 f
3561(to)X
3665(record)X
3924(the)X
776 5104(current)N
1047(C)X
1128(run-time)X
1454(stack)X
1657(state.)X
1885(The)X
2044(result)X
2262(of)X
7 f
2388(setjmp\(\))X
1 f
2834(is)X
2915(placed)X
3167(into)X
7 f
3358(zzrv)X
1 f
3570(.)X
7 f
576 5260(zzGUESS_FAIL)N
1 f
776 5388(Long)N
984(jump)X
1188(\320)X
1298(restore)X
1559(the)X
1689(C)X
1770(run-time)X
2096(stack)X
2299(to)X
2390(the)X
2520(state)X
2704(it)X
2776(held)X
2950(before)X
3196(guessing)X
3526(began.)X
7 f
576 5544(zzGUESS_DONE)N
1 f
776 5672(Restore)N
1067(the)X
1197(parser)X
1433(state)X
1617(to)X
1708(the)X
1838(previously)X
2232(saved)X
2454(contents.)X

18 p
%%Page: 18 18
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(18)X
2370(-)X
7 f
576 704(zzguessing)N
1 f
776 832(This)N
973(variable)X
1297(is)X
1396(1)X
1480(if)X
1574(a)X
1653(prediction)X
2052(is)X
2152(currently)X
2511(underway)X
2898(and)X
3066(0)X
3151(when)X
3382(normal)X
3673(parsing)X
3973(is)X
776 960(proceeding.)N
1233(User)X
1420(actions)X
1692(are)X
1821(turned)X
2068(off)X
2192(when)X
2404(this)X
2554(variable)X
2860(is)X
2941(1.)X
7 f
576 1116(zzrv)N
1 f
776 1244(This)N
961(variable)X
1273(is)X
1360(the)X
1496(result)X
1720(of)X
1821(doing)X
2050(the)X
7 f
2217(setjmp\(\))X
1 f
2669(call,)X
2847(which)X
3091(returns)X
3364(0)X
3437(always.)X
3754(When)X
3993(a)X
7 f
776 1372(longjmp\(\))N
1 f
1282(occurs,)X
1562(the)X
1699(C)X
1787(run-time)X
2120(stack)X
2330(will)X
2497(be)X
2609(reset)X
2804(to)X
2902(the)X
3039(state)X
3229(held)X
3409(at)X
3501(the)X
3637(time)X
3823(of)X
3924(the)X
7 f
776 1500(setjmp\(\))N
1 f
1223(and)X
7 f
1404(zzrv)X
1 f
1639(will)X
1800(be)X
1906(set)X
2027(to)X
2119(a)X
2181(nonzero)X
2487(value.)X
2745(In)X
2841(the)X
2972(view)X
3166(of)X
3262(the)X
3393(C)X
3476(program,)X
3820(it)X
3894(will)X
776 1628(appear)N
1043(as)X
1149(if)X
1236(the)X
7 f
1408(setjmp\(\))X
1 f
1865(has)X
2015(returned)X
2341(without)X
2644(ever)X
2828(having)X
3101(attempted)X
3483(the)X
3624(code)X
3823(in)X
3924(the)X
7 f
776 1756(if)N
1 f
904(following)X
1269(it;)X
1366(execution)X
1731(continues)X
2091(past)X
2255(the)X
7 f
2416(if)X
1 f
2544(the)X
2674(second)X
2940(time.)X
576 1912(All)N
711(semantic)X
1047(actions)X
1319(except)X
1571 0.3317(initialization)AX
2042(actions)X
2314(are)X
2443(enclosed)X
2773(in)X
7 f
9 s
576 2076(zzNON_GUESS_MODE)N
1307({)X
2 f
756 2164(user-de\256ned-semantic-action)N
7 f
1596(;)X
576 2252(})N
1 f
11 s
576 2456(so)N
678(that)X
835(they)X
1011(can)X
1157(be)X
1265(``turned)X
1573(off'')X
1758(during)X
2013(a)X
2077(prediction.)X
7 f
2566(zzNON_GUESS_MODE)X
1 f
3439(is)X
3523(de\256ned)X
3807(as)X
3905(fol-)X
576 2584(lows:)N
7 f
9 s
576 2748(if)N
705(\()X
791(!zzguessing)X
1307(\))X
1 f
11 s
576 2952(The)N
741(effect)X
969(of)X
1070(this)X
1226(type)X
1406(of)X
1507(code)X
1701(generation)X
2101(is)X
2189(that)X
2351(a)X
2419(stack)X
2629(of)X
2731(parser)X
2974(states)X
3199(is)X
3287(maintained)X
3709(such)X
3899(that)X
576 3080(nested)N
823(nondeterministic)X
1439(predictions)X
1853(can)X
1997(be)X
2102(made.)X
776 3236(As)N
911(an)X
1032 0.2708(optimization,)AX
1540(when)X
1768(the)X
1914(prediction)X
2310(grammar)X
2666(fragment)X
3023(for)X
3164(a)X
3242(production)X
3663(is)X
3761(regular,)X
576 3364(simpler)N
863(recognition)X
1287(schemes)X
1607(could)X
1825(be)X
1930(used.)X
3 f
576 3620(4.)N
686(DLG)X
899(Enhancements)X
1 f
776 3776(There)N
1005(have)X
1195(been)X
1385(a)X
1448(number)X
1741(of)X
1838(changes)X
2146(to)X
2240(dlg)X
2378(from)X
2574(1.06)X
2753(to)X
2847(1.10.)X
3070(The)X
3232(main)X
3434(difference)X
3815(is)X
3899(that)X
576 3904(DLG)N
788(execution)X
1162(speed)X
1393(is)X
1483(up)X
1602(to)X
1702(7)X
1777(times)X
2000(faster)X
2226(than)X
2409(the)X
2548(1.06)X
2733(version.)X
3067(A)X
7 f
3192(-Wambiguity)X
1 f
3806(option)X
576 4032(has)N
735(been)X
943(added)X
1195(to)X
1306(indicate)X
1628(where)X
1884(ambiguities)X
2339(in)X
2450(DLG)X
2672(speci\256cations)X
3194(exists.)X
3481(It)X
3578(numbers)X
3924(the)X
576 4160(expressions)N
1015(and)X
1171(prints)X
1401(out)X
1543(for)X
1674(an)X
1786(accept)X
2040(state)X
2231(the)X
2368(possible)X
2686(expressions)X
3125(that)X
3287(could)X
3512(be)X
3624(recognized.)X
576 4288(Also,)N
787(a)X
849(macro)X
1093(called)X
7 f
1359(ANTLRs\(\))X
1 f
1807(has)X
1948(been)X
2138(added)X
2372(that)X
2529(behaves)X
2836(just)X
2988(like)X
7 f
3176(ANTLR\(\))X
1 f
3571(except)X
3825(that)X
3982(it)X
576 4416(accepts)N
857(input)X
1061(from)X
1254(a)X
1315(string)X
1538(rather)X
1765(than)X
1939(a)X
2000(stream:)X
7 f
9 s
576 4580(#define)N
920(ANTLRs\(rule,)X
1479(string\))X
1836({...})X
3 f
11 s
576 4884(5.)N
686(Linear-Approximation)X
1569(Lookahead)X
1 f
776 5040(ANTLR-generated)N
1476(parsers)X
1760(predict)X
2041(which)X
2292(rule)X
2465(alternative)X
2874(to)X
2979(match)X
3232(by)X
3357(examining)X
3767(up)X
3892(to)X
2 f
10 s
3996(k)X
1 f
11 s
576 5168(symbols)N
903(of)X
1009(lookahead.)X
1448(Unfortunately,)X
1997(computing)X
2408(\(during)X
2700(ANTLR)X
3026(grammar)X
3377(analysis\))X
3722(and)X
3881(exa-)X
576 5296(mining)N
856(\(during)X
1144(parser)X
1387(execution\))X
1788(the)X
1925(set)X
2052(of)X
2155(possible)X
2 f
10 s
2472(k)X
1 f
11 s
2508(-sequences)X
2923(is)X
3012(an)X
3125(exponentially)X
3636(large)X
3842(prob-)X
576 5424(lem.)N
776(A)X
862(linear)X
1086(approximation)X
1624(to)X
1716(this)X
1867(full)X
2013(lookahead)X
2398(exists)X
2622(that)X
2778(requires)X
3084(linear)X
3308(time)X
3488(to)X
3579(compute)X
3905(and)X
576 5552(to)N
667(test;)X
838(further,)X
1122(this)X
1273(approximation)X
1811(handles)X
2103(the)X
2234(majority)X
2557(of)X
2653(parsing)X
2935(lookahead)X
3320(decisions.)X
3715(To)X
3836(avoid)X
576 5680(the,)N
747(possibly)X
1082(exponential,)X
1557(computation)X
2040(of)X
2154(full)X
2318(lookahead,)X
2743(ANTLR)X
3077(attempts)X
3417(to)X
3526(use)X
3683(the)X
3831(linear)X
576 5808(approximation)N
1137(\256rst)X
1296(\320)X
1430(computing)X
1854(full)X
2023(lookahead)X
2432(as)X
2552(a)X
2638(last)X
2808(resort.)X
3099(The)X
3283(reason)X
3559(that)X
3739(ANTLR)X

19 p
%%Page: 19 19
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(19)X
2370(-)X
576 704(occasionally)N
1043(goes)X
1230(``off)X
1416(the)X
1550(deep)X
1742(end'')X
1953(when)X
2169(analyzing)X
2538(some)X
2750(big)X
2889(grammars)X
3267(is)X
3351(that)X
3509(ANTLR)X
3827(found)X
576 832(a)N
662(parsing)X
968(decision)X
1309(that)X
1490(could)X
1734(not)X
1895(be)X
2026(solved)X
2304(with)X
2509(the)X
2665(approximate)X
3154(lookahead)X
3564(and)X
3739(required)X
576 960(exponential)N
1010(time)X
1190(to)X
1281(compute)X
1607(the)X
1737(full)X
1882(lookahead.)X
776 1116(Because)N
1098(the)X
1235(approximation)X
1780(has)X
1927(linear)X
2158(time)X
2346(and)X
2503(space)X
2728(complexity,)X
3178(its)X
3292(lookahead)X
3684(depth)X
3910(can)X
576 1244(be)N
696(much)X
929(deeper)X
1200(than)X
1388(that)X
1557(of)X
1666(the)X
1810(full)X
1969(lookahead.)X
2411(Consequently,)X
2954(the)X
3098(approximate)X
3575(lookahead)X
3973(is)X
576 1372(sometimes)N
980(stronger)X
1294(than)X
1472(the)X
1606(full)X
1755(lookahead)X
2143(because)X
2447(it)X
2523(can)X
2671(look)X
2855(farther)X
3116(ahead)X
3348(without)X
3645(consuming)X
576 1500(an)N
688(impractical)X
1115(amount)X
1409(of)X
1511(system)X
1785(resources.)X
2189(We)X
2340(have)X
2535(added)X
2774(an)X
2886(ANTLR)X
3208(option,)X
3484(called)X
7 f
3754(-ck)X
2 f
3966(n)X
1 f
(,)S
576 1628(that)N
735(allows)X
991(the)X
1125(user)X
1298(to)X
1394(specify)X
1675(how)X
1853(deep)X
2046(the)X
2181(linear)X
2409(approximation)X
2951(analysis)X
3262(should)X
3524(go)X
3639(before)X
3890(giv-)X
576 1756(ing)N
724(up)X
847(and)X
1009(trying)X
1254(the)X
1396(full)X
1553(lookahead)X
1949(computation.)X
2469(This)X
2660(new)X
2840(feature)X
3118(is)X
3211(best)X
3387(described)X
3758(with)X
3949(an)X
576 1884(example:)N
7 f
9 s
576 2048(a)N
756(:)X
936(\(A)X
1065(B)X
9 f
1108(|)X
7 f
1122(C)X
1208(D\))X
1337(E)X
9 f
756 2136(|)N
7 f
936(A)X
1022(D)X
1108(F)X
756 2224(;)N
1 f
11 s
576 2428(The)N
741(full)X
2 f
10 s
890(LL)X
1 f
991(\(2\))X
11 s
1113(lookahead)X
1503(\(as)X
1633(would)X
1881(be)X
1992(computed)X
2368(by)X
2484(``)X
7 f
2542(antlr)X
2866(-k)X
3031(2)X
3143(...)X
1 f
3302(''\))X
3417(is)X
3504(summarized)X
3963(in)X
576 2556(the)N
706(following)X
1071(table)X
10 f
1800 2660 -0.1818(iiiiiiiiiiiiiiiiiiiiiii)AN
2 f
10 s
2206 2788(LL)N
1 f
2307(\(2\))X
11 s
10 f
1800 2828 -0.1818(iiiiiiiiiiiiiiiiiiiiiii)AN
1 f
1844 2956(Lookahead)N
2367(Alternative)X
10 f
1800 2996 -0.1818(iiiiiiiiiiiiiiiiiiiiiii)AN
1 f
1967 3124(A)N
2052(B)X
2543(1)X
7 f
1960 3252(C)N
2066(D)X
2539(1)X
1960 3380(A)N
2066(D)X
2539(2)X
1 f
10 f
1800 3420 -0.1818(iiiiiiiiiiiiiiiiiiiiiii)AN
1800(c)X
3364(c)Y
3276(c)Y
3188(c)Y
3100(c)Y
3012(c)Y
2924(c)Y
2836(c)Y
2748(c)Y
2301 3420(c)N
3356(c)Y
3268(c)Y
3180(c)Y
3092(c)Y
3004(c)Y
2916(c)Y
2808 3420(c)N
3364(c)Y
3276(c)Y
3188(c)Y
3100(c)Y
3012(c)Y
2924(c)Y
2836(c)Y
2748(c)Y
1 f
576 3624(whereas)N
893(the)X
1031(linear)X
1262(approximate)X
1734(lookahead,)X
2149(denoted)X
2 f
10 s
2457(LL)X
1 f
7 s
2554 3592(1)N
10 s
2588 3624(\(2\))N
11 s
2713(\(as)X
2846(would)X
3097(be)X
3211(computed)X
3590(by)X
3709(``)X
7 f
3767(antlr)X
576 3752(-ck)N
788(2)X
894(...)X
1 f
1053(''\),)X
1184(is)X
10 f
1704 3856(i)N
1716(iiiiiiiiiiiiiiiiiiiiiiiiiii)X
2 f
10 s
2191 3984(LL)N
1 f
7 s
2288 3952(1)N
10 s
2322 3984(\(2\))N
11 s
10 f
1704 4024(i)N
1716(iiiiiiiiiiiiiiiiiiiiiiiiiii)X
1 f
1844 4152(Lookahead)N
2463(Alternative)X
10 f
1704 4192(i)N
1716(iiiiiiiiiiiiiiiiiiiiiiiiiii)X
7 f
1748 4320({A,C})N
2066({B,D})X
2635(1)X
1854 4448({A})N
2066({D})X
2635(2)X
1 f
10 f
1704 4488(i)N
1716(iiiiiiiiiiiiiiiiiiiiiiiiiii)X
1704(c)X
4472(c)Y
4384(c)Y
4296(c)Y
4208(c)Y
4120(c)Y
4032(c)Y
3944(c)Y
2397 4488(c)N
4464(c)Y
4376(c)Y
4288(c)Y
4200(c)Y
4112(c)Y
2904 4488(c)N
4472(c)Y
4384(c)Y
4296(c)Y
4208(c)Y
4120(c)Y
4032(c)Y
3944(c)Y
1 f
576 4692(where)N
816(lookahead)X
7 f
1235({A,C})X
1557({B,D})X
1 f
1848(implies)X
2135(that)X
2294(the)X
2428(\256rst)X
2591(symbol)X
2877(of)X
2976(lookahead)X
3364(can)X
3512(be)X
3621(either)X
7 f
3879(A)X
1 f
3959(or)X
7 f
576 4820(C)N
1 f
660(and)X
818(the)X
957(second)X
1232(can)X
1385(be)X
1499(either)X
7 f
1762(B)X
1 f
1846(or)X
7 f
1981(D)X
1 f
2034(;)X
2090(this)X
2249(lookahead)X
2641(therefore)X
2988(matches)X
3307(the)X
3445(set)X
3573(of)X
3676(sequences)X
7 f
576 4948({A)N
750(B,)X
924(A)X
1045(D,)X
1219(C)X
1340(B,)X
1514(C)X
1635(D})X
1 f
1741(,)X
1800(which)X
2053(is)X
2150(like)X
2321(the)X
2467(cross)X
2685(product)X
2992(of)X
3103(the)X
3249(sets)X
3419(\(note)X
3638(the)X
3784(loss)X
3959(of)X
576 5076(sequence)N
937(information,)X
1414(which)X
1667(results)X
1935(in)X
2042(the)X
2188(approximation\).)X
2814(The)X
2989(decision)X
3321(is)X
2 f
10 s
3416(LL)X
1 f
3517(\(2\))X
11 s
3611(,)X
3671(but)X
3822(is)X
3919(not)X
2 f
10 s
576 5204(LL)N
1 f
7 s
673 5172(1)N
10 s
707 5204(\(2\))N
11 s
824(because)X
1125(the)X
1256(sequence)X
7 f
1632(A)X
1739(D)X
1 f
1815(predicts)X
2117(both)X
2297(alternatives)X
2727(\(i.e.,)X
7 f
2941(A)X
1 f
3018(can)X
3164(be)X
3271(seen)X
3451(\256rst)X
3612(by)X
3724(both)X
3905(and)X
7 f
576 5332(D)N
1 f
654(can)X
801(be)X
909(seen)X
1090(second\).)X
1432(However,)X
1800(if)X
1879(ANTLR)X
2197(were)X
2392(allowed)X
2696(to)X
2790(look)X
2972(3)X
3041(symbols)X
3360(ahead)X
3587(\320)X
2 f
10 s
3697(LL)X
1 f
7 s
3794 5300(1)N
10 s
3828 5332(\(3\))N
11 s
3944(\320)X
576 5460(the)N
707(linear)X
931(approximation)X
1469(would)X
1712(be)X
1818(suf\256cient)X
2169(and)X
2319(the)X
2450(complex)X
2 f
10 s
2775(LL)X
1 f
2876(\(3\))X
11 s
2993(would)X
3236(not)X
3372(be)X
3479(computed.)X
3895(The)X
2 f
10 s
576 5588(LL)N
1 f
7 s
673 5556(1)N
10 s
707 5588(\(3\))N
11 s
823(information)X
1262(\(``)X
7 f
1349(antlr)X
1667(-ck)X
1879(3)X
1 f
1932(''\))X
2041(is)X
2122(summarized)X
2575(in)X
2666(the)X
2796(following)X
3161(table:)X

20 p
%%Page: 20 20
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(20)X
2370(-)X
10 f
1598 616(i)N
1602(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X
2 f
10 s
2191 744(LL)N
1 f
7 s
2288 712(1)N
10 s
2322 744(\(3\))N
11 s
10 f
1598 784(i)N
1602(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X
1 f
1844 912(Lookahead)N
2569(Alternative)X
10 f
1598 952(i)N
1602(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X
7 f
1642 1080({A,C})N
1960({B,D})X
2278({E})X
2741(1)X
1748 1208({A})N
1960({D})X
2172({F})X
2741(2)X
1 f
10 f
1598 1248(i)N
1602(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X
1598(c)X
1232(c)Y
1144(c)Y
1056(c)Y
968(c)Y
880(c)Y
792(c)Y
704(c)Y
2503 1248(c)N
1224(c)Y
1136(c)Y
1048(c)Y
960(c)Y
872(c)Y
3010 1248(c)N
1232(c)Y
1144(c)Y
1056(c)Y
968(c)Y
880(c)Y
792(c)Y
704(c)Y
1 f
576 1452(Notice)N
837(that,)X
1018(now,)X
1217(the)X
1351(third)X
1544(symbol)X
1830(of)X
1929(lookahead)X
2317(alone)X
2534(can)X
2683(uniquely)X
3019(identify)X
3321(which)X
3563(alternative)X
3963(to)X
576 1580(predict.)N
776 1736(Let's)N
979(augment)X
1305(our)X
1444(example)X
1765(to)X
1856(have)X
2044(one)X
2 f
10 s
2191(LL)X
1 f
2292(\(2\))X
11 s
2408(decision)X
2724(and)X
2873(one)X
2 f
10 s
3020(LL)X
1 f
7 s
3117 1704(1)N
10 s
3151 1736(\(3\))N
11 s
3267(decision:)X
7 f
9 s
576 1900(a)N
748(:)X
920(\(A)X
1049(B)X
9 f
1135(|)X
7 f
1192(C)X
1278(D\))X
1407(E)X
1579(/*)X
2 f
10 s
1708(LL)X
1 f
7 s
1805 1868(1)N
10 s
1839 1900(\(3\))N
7 f
9 s
1976(*/)X
9 f
748 1988(|)N
7 f
891(A)X
977(D)X
1063(F)X
1149(b)X
748 2076(;)N
576 2164(b)N
748(:)X
920(\(A)X
1049(B)X
9 f
1135(|)X
7 f
1192(C)X
1278(D\))X
1407(Z)X
1579(/*)X
2 f
10 s
1708(LL)X
1 f
1809(\(2\))X
7 f
9 s
1946(*/)X
9 f
748 2252(|)N
7 f
891(A)X
977(D)X
1063(Z)X
748 2340(;)N
1 f
11 s
576 2544(Although)N
2 f
10 s
937(LL)X
1 f
1038(\(3\))X
11 s
1162(\(``)X
7 f
1249(antlr)X
1575(-k)X
1742(3)X
1856(...)X
1 f
2015(''\))X
2133(handles)X
2433(both)X
2621(the)X
2 f
10 s
2758(LL)X
1 f
7 s
2855 2512(1)N
10 s
2889 2544(\(3\))N
11 s
3014(and)X
2 f
10 s
3170(LL)X
1 f
3271(\(2\))X
11 s
3396(decisions,)X
3777(we)X
3910(can)X
576 2672(make)N
801(ANTLR)X
1128(and)X
1289(the)X
1431(resulting)X
1774(parser)X
2022(more)X
2237(ef\256cient)X
2560(by)X
2682(specifying)X
3082(``)X
7 f
3140(antlr)X
3469(-ck)X
3692(3)X
3809(-k)X
3979(2)X
576 2800(...)N
1 f
735(''.)X
859(The)X
1018(resulting)X
1349(parser)X
1585(decisions)X
1935(are)X
2064(illustrated)X
2440(in)X
2531(the)X
2661(following)X
3026(\(sanitized\))X
3420(code)X
3608(fragment:)X
7 f
9 s
576 2964(a\(\))N
576 3052({)N
748 3140(/*)N
877(there)X
1135(are)X
1307(no)X
1436(sequence)X
1823(comparisons)X
2339(for)X
2511(rule)X
2726('a')X
2898(because)X
2 f
10 s
3242(LL)X
1 f
7 s
3339 3108(1)N
10 s
3373 3140(\(3\))N
7 f
9 s
791 3228(*)N
877(is)X
1006(sufficient)X
1479(and)X
1651(full)X
2 f
10 s
1866(LL)X
1 f
1967(\(3\))X
7 f
9 s
2104(analysis)X
2491(is)X
2620(not)X
2792(invoked)X
791 3316(*/)N
748 3404(if)N
877(\()X
963(LA\(1\))X
2 f
10 s
9 f
1178(\316)X
7 f
9 s
1235({A,C})X
1493(&&)X
1622(LA\(2\))X
2 f
10 s
9 f
1837(\316)X
7 f
9 s
1894({B,D})X
2152(&&)X
2281(LA\(3\)==E)X
2668(\))X
2754({)X
920 3492(if)N
1049(\()X
1135(\(LA\(1\)==A\))X
1608(\))X
1694({)X
1092 3580(zzmatch\(A\);)N
1608(zzCONSUME;)X
1092 3668(zzmatch\(B\);)N
1608(zzCONSUME;)X
920 3756(})N
920 3844(else)N
1135(if)X
1264(\()X
1350(\(LA\(1\)==C\))X
1823(\))X
1909({)X
1092 3932(zzmatch\(C\);)N
1608(zzCONSUME;)X
1092 4020(zzmatch\(D\);)N
1608(zzCONSUME;)X
920 4108(})N
920 4196(zzmatch\(E\);)N
1436(zzCONSUME;)X
748 4284(})N
748 4372(else)N
963(if)X
1092(\()X
1178(\(LA\(1\)==A\))X
1651(&&)X
1780(\(LA\(2\)==D\))X
2253(&&)X
2382(\(LA\(3\)==F\))X
2855(\))X
2941({)X
920 4460(zzmatch\(A\);)N
1436(zzCONSUME;)X
920 4548(zzmatch\(D\);)N
1436(zzCONSUME;)X
920 4636(zzmatch\(F\);)N
1436(zzCONSUME;)X
920 4724(b\(\);)N
748 4812(})N
576 4900(})N

21 p
%%Page: 21 21
9 s 0 xH 0 xS 7 f
1 f
2226 376(-)N
2268(21)X
2358(-)X
7 f
576 712(b\(\))N
576 800({)N
756 888(/*)N
2 f
10 s
885(LL)X
1 f
986(\(2\))X
7 f
9 s
1123(decision)X
1510(*/)X
748 976(if)N
877(\()X
963 -0.1974(\(LA\(1\)==A&&LA\(2\)==B\))AX
9 f
1866(||)X
7 f
1937 -0.1974(\(LA\(1\)==C&&LA\(2\)==D\))AX
2840(\))X
2926({)X
920 1064(if)N
1049(\()X
1135(\(LA\(1\)==A\))X
1608(\))X
1694({)X
1092 1152(zzmatch\(A\);)N
1608(zzCONSUME;)X
1092 1240(zzmatch\(B\);)N
1608(zzCONSUME;)X
920 1328(})N
920 1416(else)N
1135(if)X
1264(\()X
1350(\(LA\(1\)==C\))X
1823(\))X
1909({)X
1092 1504(zzmatch\(C\);)N
1608(zzCONSUME;)X
1092 1592(zzmatch\(D\);)N
1608(zzCONSUME;)X
920 1680(})N
748 1768(})N
748 1856(else)N
963(if)X
1092(\()X
1178 -0.1985(LA\(1\)==A&&LA\(2\)==D)AX
1995(\))X
2081({)X
920 1944(zzmatch\(A\);)N
1436(zzCONSUME;)X
920 2032(zzmatch\(D\);)N
1436(zzCONSUME;)X
920 2120(zzmatch\(Z\);)N
1436(zzCONSUME;)X
748 2208(})N
576 2296(})N
1 f
11 s
776 2500(These)N
1014(examples)X
1375(are)X
1510(small)X
1730(and,)X
1907(hence,)X
2162(the)X
2298(savings)X
2590(are)X
2726(not)X
2868(apparent,)X
3222(but)X
3364(the)X
3501(``compressed'')X
576 2628(approximation)N
1119(to)X
1216(full)X
1366(lookahead)X
1755(can)X
1904(be)X
2014(used)X
2202(to)X
2298(reduce)X
2559(the)X
2694(ANTLR)X
3014(execution)X
3384(time)X
3569(and)X
3723(resulting)X
576 2756(parser)N
812(speed/size.)X
3 f
576 3012(6.)N
686(Faster)X
947(Compilation)X
1439(of)X
1534(ANTLR-Generated)X
2288(Parsers)X
1 f
776 3168(Previous)N
1117(versions)X
1443(of)X
1549(ANTLR)X
1875(used)X
2069(macros)X
2356(rather)X
2594(than)X
2779(function)X
3106(calls)X
3301(for)X
3436(many)X
3665(operations)X
576 3296(during)N
829(parsing.)X
1155(Because)X
1471(the)X
1602(macros)X
1879(were)X
2072(invoked)X
2379(numerous)X
2748(times,)X
2984(compilation)X
3429(of)X
3524(these)X
3727(\256les)X
3896(was)X
576 3424(slow)N
772(and)X
929(generated)X
1301(large)X
1507(object)X
1753(\256les.)X
1974(The)X
2142(operations)X
2540(are)X
2678(now,)X
2882(by)X
3001(default,)X
3299(function)X
3624(calls)X
3817(which)X
576 3552(makes)N
828(compilation)X
1278(about)X
1501(2)X
1572(times)X
1791(as)X
1891(fast)X
2044(and)X
2197(results)X
2453(in)X
2548(object)X
2790(\256les)X
2963(about)X
3185(half)X
3348(as)X
3447(large.)X
3693(The)X
3856(mac-)X
576 3680(ros)N
748(can)X
935(be)X
1083(used)X
1309(if)X
1428(necessary)X
1834(by)X
1987(de\256ning)X
7 f
2372(ZZUSE_MACROS)X
1 f
3073(on)X
3226(the)X
3400(compile)X
3751(line)X
3950(\()X
7 f
3979(-)X
576 3808(DZZUSE_MACROS)N
1 f
1265(\).)X
3 f
576 4064(7.)N
686(Linking)X
1008(Together)X
1372(Multiple)X
1718(ANTLR)X
2047(Parsers)X
1 f
776 4220(Because)N
1102(of)X
1208(the)X
1349(lack)X
1530(of)X
1637(sophisticated)X
2132(``information)X
2641(hiding'')X
2959(in)X
3062(C,)X
3177(many)X
3407(ANTLR)X
3734(program)X
576 4348(symbols)N
911(are)X
1059(globally)X
1390(visible)X
1667(and,)X
1857(hence,)X
2124(linking)X
2415(multiple)X
2751(ANTLR-generated)X
3455(parsers)X
3743(together)X
576 4476(would)N
820(cause)X
1039(many)X
1260(name)X
1476(collisions.)X
1884(To)X
2007(overcome)X
2379(this,)X
2554(we)X
2681(have)X
2872(introduced)X
3274(a)X
3338(new)X
3509(ANTLR)X
3827(direc-)X
576 4604(tive:)N
7 f
9 s
576 4768(#parser)N
920("my_parser_name")X
1 f
11 s
576 4972(which)N
853(pre\256xes)X
1193(all)X
1344(global,)X
1649(externally)X
2064(visible)X
2362(symbols)X
2718(with)X
2938(pre\256x)X
7 f
3237(my_parser_name_)X
1 f
576 5100(\(remember)N
990(this)X
1146(when)X
1364(debugging)X
1763(ANTLR)X
2083(parsers\).)X
2431(This,)X
2637(clearly,)X
2926(renders)X
3211(the)X
3346(previous)X
3676(``generate)X
576 5228(pre\256x'')N
872(option)X
1131(\()X
7 f
1160(-gp)X
1 f
1319(\))X
1381(obsolete.)X
1752(Variables,)X
2144(functions)X
2505(and)X
2665(rule)X
2835(names)X
3094(are)X
3235(remapped)X
3616(through)X
3924(the)X
576 5356(inclusion)N
943(of)X
1059(a)X
1141(\256le)X
1297(called)X
7 f
1582(remap.h)X
1 f
1953(,)X
2018(which)X
2276(is)X
2377 0.2604(automatically)AX
2901(generated)X
3285(by)X
3415(ANTLR)X
3750(when)X
3982(it)X
576 5484(encounters)N
979(a)X
7 f
1071(#parser)X
1 f
1464(directive.)X
1839(In)X
1934(the)X
2064(future,)X
2318(we)X
2442(expect)X
2694(this)X
2844(to)X
2935(be)X
3040(the)X
3170(name)X
3383(of)X
3478(a)X
3539(C++)X
3720(object)X
3959(of)X
576 5612(some)N
906(class)X
7 f
1251(Parser)X
1 f
1569(;)X
1737(variables)X
2198(and)X
2468(functions)X
2939(will)X
3220(be)X
3446(referenced)X
3959(as)X
7 f
576 5740 0.1950(my_parser_name.var_or_func)AN
1 f
1954(.)X

22 p
%%Page: 22 22
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(22)X
2370(-)X
776 704(Consider)N
1125(the)X
1264(following)X
1638(ANTLR)X
1962(example.)X
2336(Files)X
7 f
2570(t.g)X
1 f
2760(and)X
7 f
2949(t2.g)X
1 f
3192(are)X
3331(identical)X
3668(except)X
3930(for)X
576 832(the)N
706(parser)X
942(name.)X
576 988(File)N
7 f
767(t.g)X
9 s
720 1152(#header)N
1064(<<#include)X
1537("charbuf.h">>)X
720 1328(#parser)N
1064("t")X
720 1504(<<)N
720 1592(void)N
935(parse_t\(\))X
720 1680({)N
892 1768(ANTLR\(a\(\),)N
1365(stdin\);)X
720 1856(})N
720 1944(>>)N
720 2120(#token)N
1021("[\\)X
1193(\\t\\n]")X
1752(<>)X
720 2296(a)N
806(:)X
892(INT)X
1064(INT)X
806 2384(;)N
720 2560(#token)N
1021(INT)X
1193("[0-9]+")X
1 f
11 s
576 2764(File)N
7 f
767(t2.g)X
9 s
720 2928(#header)N
1064(<<#include)X
1537("charbuf.h">>)X
720 3104(#parser)N
1064("t2")X
720 3280(<<)N
720 3368(void)N
935(parse_t2\(\))X
720 3456({)N
892 3544(ANTLR\(a\(\),)N
1365(stdin\);)X
720 3632(})N
720 3720(>>)N
720 3896(#token)N
1021("[\\)X
1193(\\t\\n]")X
1752(<>)X
720 4072(a)N
806(:)X
892(INT)X
1064(INT)X
806 4160(;)N
720 4336(#token)N
1021(INT)X
1193("[0-9]+")X
1 f
11 s
576 4540(File)N
7 f
767(main.c)X
9 s
720 4704(#include)N
1107()X
720 4880(extern)N
1021(void)X
1236(parse_ter\(\);)X
720 4968(extern)N
1021(void)X
1236(parse_ter2\(\);)X
720 5144(main\(\))N
720 5232({)N
892 5320(parse_ter\(\);)N
892 5408(parse_ter2\(\);)N
720 5496(})N
1 f
11 s
576 5700(File)N
7 f
767(makefile)X

23 p
%%Page: 23 23
11 s 0 xH 0 xS 7 f
9 s
1 f
2226 376(-)N
2268(23)X
2358(-)X
7 f
720 712(DLG_FILE)N
1107(=)X
1193(parser.dlg)X
720 800(ERR_FILE)N
1107(=)X
1193(err.c)X
720 888(HDR_FILE)N
1107(=)X
1193(stdpccts.h)X
720 976(TOK_FILE)N
1107(=)X
1193(tokens.h)X
720 1064(K)N
806(=)X
892(1)X
720 1152(ANTLR_H)N
1064(=)X
1150(../h)X
720 1240(BIN)N
892(=)X
978(../bin)X
720 1328(ANTLR)N
978(=)X
1064(../bin/antlr)X
720 1416(DLG)N
892(=)X
978($\(BIN\)/dlg)X
720 1504(CFLAGS)N
1021(=)X
1107(-I.)X
1279(-I$\(ANTLR_H\))X
1838(-g)X
720 1592(AFLAGS)N
1021(=)X
1107(-fe)X
1279(err.c)X
1537(-fl)X
1709(parser.dlg)X
2182(-ft)X
2354(tokens.h)X
2741(-fr)X
2913(remap.h)X
3257(-fm)X
3429(mode.h)X
3773(\\)X
1107 1680(-gt)N
1279(-gk)X
720 1768(AFLAGS2=)N
1107(-fe)X
1279(t2_err.c)X
1666(-fl)X
1838(t2_parser.dlg)X
2440(-ft)X
2612(t2_tokens.h)X
3128(-fr)X
3300(t2_remap.h)X
3773(\\)X
1107 1856(-fm)N
1279(t2_mode.h)X
1709(-gt)X
1881(-gk)X
720 1944(DFLAGS)N
1021(=)X
1107(-C2)X
1279(-i)X
720 2032(GRM)N
892(=)X
978(t.g)X
720 2120(SRC1)N
935(=)X
1021(scan.c)X
1322(t.c)X
1494(err.c)X
720 2208(SRC2)N
935(=)X
1021(t2.c)X
1236(t2_scan.c)X
1666(t2_err.c)X
2053(main.c)X
720 2296(OBJ1)N
935(=)X
1021(scan.o)X
1322(t.o)X
1494(err.o)X
720 2384(OBJ2)N
935(=)X
1021(t2.o)X
1236(t2_scan.o)X
1666(t2_err.o)X
2053(main.o)X
720 2472(CC=g++)N
720 2648(t:)N
849($\(OBJ1\))X
1193($\(OBJ2\))X
892 2736($\(CC\))N
1150(-o)X
1279(t)X
1365($\(CFLAGS\))X
1795($\(OBJ1\))X
2139($\(OBJ2\))X
720 2912(t.o)N
892(:)X
978(mode.h)X
1279(tokens.h)X
1666(t.g)X
720 3088(scan.c)N
1021(mode.h)X
1322(:)X
1408(parser.dlg)X
892 3176($\(DLG\))N
1193($\(DFLAGS\))X
1623(parser.dlg)X
2096(scan.c)X
720 3352(t.c)N
892(parser.dlg)X
1365(tokens.h)X
1752(:)X
1838(t.g)X
892 3440($\(ANTLR\))N
1279($\(AFLAGS\))X
1709(t.g)X
720 3616(t2.o)N
935(:)X
1021(t2_mode.h)X
1451(t2_tokens.h)X
1967(t2.g)X
720 3792(t2_scan.c)N
1150(t2_mode.h)X
1580(:)X
1666(t2_parser.dlg)X
892 3880($\(DLG\))N
1193($\(DFLAGS\))X
1623(-m)X
1752(t2_mode.h)X
2182(t2_parser.dlg)X
2784(t2_scan.c)X
720 4056(t2.c)N
935(t2_parser.dlg)X
1537(t2_tokens.h)X
2053(:)X
2139(t2.g)X
892 4144($\(ANTLR\))N
1279($\(AFLAGS2\))X
1752(t2.g)X
1 f
11 s
576 4348(The)N
735(input)X
939(to)X
1030(the)X
1160(parser)X
1396(is)X
1477(4)X
1543(integers)X
1844(because)X
2144(each)X
2327(of)X
2422(the)X
2552(invoked)X
2858(parsers)X
3128(matches)X
3439(2.)X
776 4504(The)N
962(preprocessor)X
1459(symbol)X
7 f
1799(zzparser)X
1 f
2272(is)X
2380(set)X
2528(the)X
2686(parser)X
2950(name)X
3191(string)X
3442(speci\256ed)X
3805(in)X
3924(the)X
7 f
576 4632(#parser)N
1000("name")X
1 f
1340(directive.)X
776 4788(WARNING:)N
1254(the)X
1392(remapping)X
1799(of)X
1902(symbols)X
2226(to)X
2326(avoid)X
2553(collisions)X
2923(is)X
3013(not)X
3157(a)X
3227(foolproof)X
3590(system.)X
3910(For)X
576 4916(example,)N
922(if)X
1001(you)X
1157(have)X
1347(a)X
1410(rule)X
1571(named)X
7 f
1861(type)X
1 f
2097(and)X
2248(a)X
2311(\256eld)X
2492(in)X
2585(a)X
2648(structure)X
2980(named)X
7 f
3270(type)X
1 f
3482(,)X
3528(the)X
3660(\256eld)X
3841(name)X
576 5044(will)N
737(get)X
868(renamed)X
1194(as)X
1290(well)X
1464(\320)X
1575(this)X
1726(is)X
1808(the)X
1939(price)X
2138(you)X
2293(pay)X
2443(for)X
2568(being)X
2787(able)X
2957(to)X
3049(link)X
3210(things)X
3449(together)X
3762(without)X
576 5172(C++.)N
3 f
576 5428(8.)N
686(Creating)X
1040(Customized)X
1506(Syntax)X
1787(Error)X
2029(Routines)X
1 f
776 5584(Many)N
1008(users)X
1215(have)X
1408(asked)X
1635(how)X
1813(to)X
1909(create)X
2146(their)X
2335(own)X
7 f
2544(zzsyn\(\))X
1 f
2942(error)X
3140(handling)X
3477(routine.)X
3799(Here's)X
576 5712(how:)N

24 p
%%Page: 24 24
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(24)X
2370(-)X
576 704([1])N
776(Make)X
998(new)X
7 f
1197(zzsyn\(\))X
1 f
1590(with)X
1769(same)X
1972(parameters.)X
576 860([2])N
776(De\256ne)X
1032(the)X
1162(preprocessor)X
1632(symbol)X
7 f
1945(USER_ZZSYN)X
1 f
2497(on)X
2607(the)X
2737(compile)X
3044(line)X
3199(\()X
7 f
3228(-DUSER_ZZSYN)X
1 f
3864(\).)X
3 f
576 1116(9.)N
686(Lexical)X
983(Changes)X
1327(to)X
1422(ANTLR)X
1751(Input)X
1 f
776 1272(The)N
958(manner)X
1267(in)X
1381(which)X
1641(ANTLR)X
1979(interprets)X
2358(user)X
2550(actions)X
2846(has)X
3009(changed.)X
3392(Strings,)X
3710(character)X
576 1400(literals,)N
861(and)X
1010(C/C++)X
1275(comments)X
1660(are)X
1789(now)X
1962(totally)X
2211(ignored.)X
2546(For)X
2690(example,)X
7 f
9 s
576 1564(<<)N
756 1652(//)N
885(nothing)X
1229(in)X
1358(here)X
1573(is)X
1702(examined)X
2089($1)X
2218(')X
2304(")X
756 1740(/*)N
885(or)X
1014(in)X
1143(here)X
1358(')X
1444(")X
1530($)X
1616(#[jfd])X
1917('"''''")X
2261(*/)X
756 1828('"')N
928(//)X
1057(that's)X
1358(a)X
1444(character)X
756 1916("'")N
928(//)X
1057(that's)X
1358(an)X
1487(apostrophe)X
756 2004("$1)N
928(is",)X
1143($1)X
1272(/*)X
1401($1)X
1530(inside)X
1831(string)X
2132(is)X
2261(ignored)X
2605(*/)X
576 2092(>>)N
1 f
11 s
576 2296(As)N
706(a)X
778(result)X
1007(of)X
1113(this)X
1274(change,)X
1578(you)X
1743(may)X
1928(experience)X
2342(a)X
2414(slight)X
2644(difference)X
3033(in)X
3135(how)X
3319(ANTLR)X
3646(treats)X
3871(your)X
576 2424(actions.)N
892(Comments)X
1297(inside)X
1530(actions)X
1802(are)X
1931(still)X
2087(passed)X
2343(through)X
2639(to)X
2730(the)X
2860(parser.)X
776 2580(C++)N
957(comments)X
1342(are)X
1471(now)X
1644(accepted)X
1974(outside)X
2251(of)X
2346(actions)X
2618(as)X
2713(well:)X
7 f
9 s
576 2744(//)N
705(this)X
920(rule)X
1135(does)X
1350(nothing)X
576 2832(a)N
662(:)X
748(;)X
1 f
11 s
576 3036(Watch)N
828(out)X
963(for)X
1087(this:)X
7 f
9 s
662 3200(...)N
662 3288(<<)N
791(//)X
920(a)X
1006(comment)X
1350(>>)X
662 3376(...)N
576 3464(a)N
662(:)X
748(A)X
662 3552(;)N
1 f
11 s
576 3756(The)N
737(C++)X
920(style)X
1112(comment)X
1466(in)X
1560(side)X
1727(the)X
1860(action)X
2101(will)X
2264(scarf)X
2459(til)X
2559(end)X
2711(of)X
2809(line)X
2967(and)X
3119(ignore)X
3369(the)X
7 f
3533(>>)X
1 f
3664(end)X
3816(action)X
576 3884(symbol.)N
902(This)X
1081(could)X
1299(be)X
1404(avoided,)X
1727(but)X
1862(I'm)X
2011(feeling)X
2278(lazy)X
2447(just)X
2597(now.)X
3 f
576 4140(10.)N
730(New)X
917(ANTLR)X
1246(Options)X
1 f
776 4296(Release)N
1072(1.10)X
1248(introduces)X
1637(the)X
1767(following)X
2132(ANTLR)X
2447(command-line)X
2979(options:)X
7 f
576 4452(-)N
1 f
776(ANTLR)X
1091(now)X
1264(accepts)X
1545(input)X
1749(from)X
7 f
1973(stdin)X
1 f
2260(by)X
2370(using)X
2583(the)X
7 f
2744(-)X
1 f
2819(option;)X
3092(e.g.,)X
7 f
9 s
776 4616(antlr)N
1034(-)X
1 f
11 s
776 4820(A)N
861(\256le)X
996(called)X
7 f
1260(stdin.c)X
1 f
1653(is)X
1734(created)X
2010(as)X
2105(the)X
2235(output)X
2483(parser.)X
3 f
576 4976(-ck)N
2 f
725(n)X
1 f
786(Use)X
954(up)X
1074(to)X
2 f
1175(n)X
1 f
1251(symbols)X
1577(of)X
1682(lookahead)X
2076(when)X
2298(using)X
2521(compressed)X
2968(\(linear)X
3230(approximation\))X
3807(looka-)X
776 5104(head.)N
1014(This)X
1199(type)X
1379(of)X
1480(lookahead)X
1870(is)X
1957(very)X
2141(cheap)X
2374(to)X
2471(compute)X
2803(and)X
2958(is)X
3045(attempted)X
3421(before)X
3672(full)X
3822(LL\(k\))X
776 5232(lookahead,)N
1217(which)X
1489(is)X
1605(of)X
1735(exponential)X
2204(complexity)X
2659(in)X
2785(the)X
2950(worst)X
3202(case.)X
3454(In)X
3585(general,)X
3924(the)X
776 5360(compressed)N
1218(lookahead)X
1607(can)X
1756(be)X
1866(much)X
2089(deeper)X
2349(\(e.g,)X
7 f
2562(-ck)X
2778(10)X
1 f
2884(\))X
2939(than)X
3117(the)X
3251(full)X
3400(lookahead)X
3788(\(which)X
776 5488(usually)N
1053(must)X
1247(be)X
1352(less)X
1506(than)X
1680(4\).)X
7 f
576 5644(-fm)N
2 f
788(mode_\256le)X
1 f
776 5772(Rename)N
1087(\256le)X
1222(with)X
1401(lexical)X
1659(mode)X
1877(de\256nitions,)X
2 f
2294(mode.h)X
1 f
2550(,)X
2594(to)X
2685(\256le.)X

25 p
%%Page: 25 25
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(25)X
2370(-)X
3 f
576 704(-fr)N
2 f
695(\256le)X
1 f
803(Rename)X
1129(\256le)X
1279(which)X
1532(remaps)X
1824(globally)X
2152(visible)X
2426(symbols,)X
2 f
2780(remap.h)X
1 f
3070(,)X
3130(to)X
3237(\256le.)X
3432(This)X
3627(\256le)X
3778(is)X
3875(only)X
776 832(created)N
1052(if)X
1128(a)X
7 f
1220(#parser)X
1 f
1613(directive)X
1944(is)X
2025(found.)X
3 f
576 988(-prc)N
754(on)X
1 f
776 1116(Turn)N
969(on)X
1079(the)X
1209(computation)X
1673(and)X
1822(hoisting)X
2129(of)X
2224(predicate)X
2569(context.)X
3 f
576 1272(-prc)N
754(off)X
1 f
776 1400(Turn)N
970(off)X
1095(the)X
1227(computation)X
1693(and)X
1844(hoisting)X
2153(of)X
2250(predicate)X
2597(context.)X
2925(This)X
3106(option)X
3356(makes)X
3605(1.10)X
3783(behave)X
776 1528(like)N
931(the)X
1061(1.06)X
1237(release)X
1503(with)X
1682(option)X
3 f
1930(-pr)X
1 f
2069(on)X
2179(\(default\).)X
3 f
576 1684(-w1)N
1 f
776(Set)X
914(low)X
1071(warning)X
1384(level.)X
1625(Do)X
1757(not)X
1896(warn)X
2097(if)X
2177(semantic)X
2517(predicates)X
2900(and/or)X
3151(\(...\)?)X
3340(blocks)X
3596(are)X
3729(assumed)X
776 1812(to)N
867(cover)X
1084(ambiguous)X
1493(alternatives.)X
3 f
576 1968(-w2)N
1 f
776(Ambiguous)X
1211(parsing)X
1494(decisions)X
1846(yield)X
2047(warnings)X
2393(even)X
2584(if)X
2663(semantic)X
3002(predicates)X
3384(or)X
3482(\(...\)?)X
3670(blocks)X
3925(are)X
776 2096(used.)N
1017(Warn)X
1248(if)X
7 f
1369(-prc)X
1648(on)X
1 f
1790(and)X
1952(some)X
2173(lookahead)X
2570(sequences)X
2961(are)X
3103(not)X
3251(disambiguated)X
3801(with)X
3993(a)X
776 2224(hoisted)N
1053(predicate.)X
3 f
576 2480(11.)N
730(ANTLR)X
1059(Generates)X
1462(``Androgynous'')X
2108(Code)X
1 f
776 2636(The)N
951(distribution)X
1397(source)X
1664(of)X
1775(1.06)X
1968(PCCTS)X
2277(was)X
2452(generated)X
2833(using)X
3063(1.06)X
3256(on)X
3383(a)X
3461(32-bit)X
3711(machine.)X
576 2764(Unfortunately,)N
1117(the)X
1250(source)X
1504(code)X
1695(dumped)X
2004(bit)X
2123(sets)X
2280(to)X
2374(arrays)X
2613(of)X
7 f
2742(unsigned)X
1 f
3166('s)X
3254(according)X
3626(to)X
3720(the)X
3852(word)X
576 2892(size)N
740(of)X
840(the)X
975(machine)X
1301(that)X
1461(generated)X
1830(the)X
1965(parser)X
2201(\320)X
2316(regardless)X
2699(of)X
2799(the)X
2934(word)X
3142(size)X
3307(of)X
3408(the)X
3544(various)X
3831(target)X
576 3020(machines.)N
976(To)X
1097(overcome)X
1467(this,)X
1640(ANTLR)X
1956(always)X
2223(dumps)X
2481(its)X
2588(bit)X
2705(sets)X
2860(as)X
2956(arrays)X
3193(of)X
7 f
3320(unsigned)X
3798(char)X
1 f
4010(,)X
576 3148(which)N
816(are)X
948(8)X
1017(bits)X
1170(\(or)X
1297(more\))X
1532(on)X
1645(any)X
1797(machine)X
2121(that)X
2279(we'd)X
2479(ever)X
2655(want)X
2851(to)X
2945(work)X
3150(on.)X
3307(As)X
3430(a)X
3495(result,)X
3739(ANTLR)X
576 3276(itself)N
781(should)X
1044(bootstrap)X
1400(on)X
1516(any)X
1671(machine)X
1998(with)X
2182(a)X
2248(C)X
2334(compiler)X
2675(a)X
2741(enough)X
3027(memory.)X
3392(We)X
3541(have)X
3734(gotten)X
3982(it)X
576 3404(to)N
682(compile)X
1004(with)X
1198(16-bit)X
1446(Microsoft)X
1830(and)X
1994(Borland)X
2315(C)X
2412(on)X
2538(the)X
2684(PC)X
2830(with)X
3025(only)X
3220(a)X
3297(few)X
3466(whimpers.)X
3895(The)X
576 3532(make\256les)N
936(in)X
1027(the)X
1157(ANTLR)X
1472(and)X
1621(DLG)X
1823(directories)X
2217(have)X
2405(sections)X
2711(for)X
2835(each)X
3018(of)X
3113(the)X
3243(various)X
3524(compilers.)X
3 f
576 3788(12.)N
730(Printing)X
1066(out)X
1210(grammars)X
1 f
776 3944(Using)N
1008(the)X
7 f
1169(-p)X
1 f
1297(option)X
1545(generates)X
1899(grammar)X
2239(listings)X
2517(that)X
2672(are)X
2801(somewhat)X
3180(nicer.)X
3 f
576 4200(13.)N
730(C)X
815(Grammar)X
1218(Changes)X
1 f
776 4356(The)N
945(C)X
1036(grammar)X
1386(example)X
1717(has)X
1866(been)X
2064(augmented)X
2483(with)X
2672(a)X
7 f
2774(-both)X
1 f
3071(option)X
3329(that)X
3495(prints)X
3729(out)X
3875(both)X
576 4484(K&R)N
789(and)X
938(ANSI)X
1164(C)X
1245(prototypes)X
1639(for)X
1763(functions)X
2113(de\256ned)X
2394(in)X
2485(the)X
2615(input)X
2819(\256le.)X
2998(E.g.)X

26 p
%%Page: 26 26
11 s 0 xH 0 xS 1 f
9 s
7 f
1 f
2226 376(-)N
2268(26)X
2358(-)X
7 f
576 712(%)N
662(proto)X
920(-both)X
576 800(void)N
791(f\(a,b\))X
576 888(int)N
748(a;)X
576 976(char)N
791(*b;)X
576 1064({;})N
576 1152(\303D)N
619 1240(void)N
576 1328(#ifdef)N
877(__STDC__)X
576 1416(f\()N
705(int)X
877(a,)X
1006(char)X
1221(*b)X
1350(\))X
576 1504(#else)N
576 1592(f\()N
705(a,)X
834(b)X
920(\))X
619 1680(int)N
791(a;)X
619 1768(char)N
834(*b;)X
576 1856(#endif)N
1 f
11 s
576 2060(Functions)N
946(that)X
1101(already)X
1382(employ)X
1669(ANSI)X
1895(C)X
1976(style)X
2165(argument)X
2520(de\256nitions)X
2915(are)X
3044(handled)X
3345(as)X
3440(well.)X
3 f
576 2316(14.)N
730(C++)X
915(Now)X
1107(Compiles)X
1481(ANTLR)X
1810(Itself)X
1 f
776 2472(We)N
928(have)X
1124(modi\256ed)X
1468(the)X
1606(source)X
1865(code)X
2061(of)X
2164(ANTLR)X
2487(to)X
2586(compile)X
2901(under)X
3131(C++.)X
3364(It)X
3448(is)X
3538(not)X
3682(written)X
3963(to)X
576 2600(take)N
751(advantage)X
1136(of)X
1237(C++'s)X
1487(extensions)X
1887(to)X
1984(C,)X
2093(however,)X
2445(except)X
2703(in)X
2800(rare)X
2964(instances.)X
3359(C++'s)X
3608(stricter)X
3880(type)X
576 2728(checking)N
916(motivated)X
1292(the)X
1422(modi\256cation.)X
3 f
576 2984(15.)N
730(New)X
917(Preprocessor)X
1432(Symbol)X
1 f
776 3140(ANTLR)N
1092(now)X
1266(generates)X
1621(a)X
7 f
1715(#define)X
1 f
2110(called)X
7 f
2376(ANTLR_VERSION)X
1 f
3089(that)X
3246(is)X
3329(set)X
3451(to)X
3544(the)X
3676(version)X
3959(of)X
576 3268(ANTLR)N
891(that)X
1046(generated)X
1410(the)X
1540(parser.)X
1820(For)X
1964(this)X
2114(release,)X
2402(you)X
2556(will)X
2716(see:)X
7 f
9 s
576 3432(#define)N
920(ANTLR_VERSION)X
1522(110)X
1 f
11 s
576 3636(in)N
667(the)X
797(output)X
1045(\256les,)X
1236(which)X
1473(is)X
1554(an)X
1659(integer)X
1926(equivalent)X
2316(of)X
2411(the)X
2541(version)X
2822(number.)X
3 f
576 3892(16.)N
730(Attribute)X
1103(Warning)X
1 f
776 4048(A)N
861(number)X
1152(of)X
1248(users)X
1451(have)X
1640(had)X
1790(trouble)X
2063(with)X
2243(the)X
7 f
2405(charptr.h)X
1 f
2905(attributes.)X
3301(Please)X
3549(note)X
3724(that)X
3880(they)X
576 4176(do)N
3 f
701(not)X
1 f
860(make)X
1088(copies)X
1350(and)X
1514(that)X
1684(the)X
1829(memory)X
2159(is)X
2254(freed)X
2470(after)X
2667(the)X
2811(scope)X
3047(exits.)X
3294(For)X
3452(example,)X
3809(this)X
3973(is)X
3 f
576 4304(wrong)N
1 f
843(because)X
1149(the)X
1285(memory)X
1607(for)X
1737(the)X
7 f
1904($1)X
1 f
2038(attribute)X
2361(of)X
7 f
2493(A)X
1 f
2574(or)X
7 f
2706(B)X
1 f
2787(in)X
2884(the)X
7 f
3051(\(...\))X
1 f
3344(scope)X
3573(will)X
3740(be)X
3852(freed)X
576 4432(upon)N
774(exit)X
929(even)X
1117(though)X
7 f
1415($0)X
1 f
1543(will)X
1703(still)X
1859(point)X
2063(to)X
2154(it.)X
7 f
9 s
576 4596 -0.1992(#header<<#include)AN
1350("charptr.h">>)X
576 4772(<<)N
576 4860(#include)N
963("charptr.c")X
576 4948(main\(\))N
877({)X
963 -0.1992(ANTLR\(a\(\),stdin\);)AX
1737(})X
576 5036(>>)N
576 5212(#token)N
877("[\\)X
1049(\\t\\n]")X
1608(<<)X
1737(zzskip\(\);)X
2167(>>)X
576 5388(a:)N
705("ick")X
963(\("A")X
1178(<<)X
1307($0=$1;)X
1608(>>)X
9 f
1694(|)X
7 f
1751("B")X
1923(<<)X
2052($0=$1;)X
2353(>>\))X
2525("ugh")X
705 5476(<<)N
834(printf\("$1,)X
1350($2,)X
1522($3)X
1651(are)X
1823(%s,)X
1995(%s,)X
2167(%s\\n",$1,)X
2597($2,)X
2769($3\);)X
2984(>>)X
619 5564(;)N

27 p
%%Page: 27 27
9 s 0 xH 0 xS 7 f
11 s
1 f
2209 416(-)N
2260(27)X
2370(-)X
576 704(One)N
749(should)X
1011(make)X
1229(a)X
1296(copy)X
1495(of)X
1596(the)X
1732(local)X
1932(attribute)X
2255(\(or)X
2385(use)X
7 f
2561(charbuf.h)X
1 f
3038(\))X
3095(as)X
3196(the)X
3332(mem)X
3537(is)X
3624(freed)X
3832(at)X
3924(the)X
576 832(end)N
725(of)X
820(the)X
950(scope)X
1172(\()X
7 f
1201($0=strdup\($1\);)X
1 f
1943(\).)X
3 f
576 1088(17.)N
730(Generation)X
1178(of)X
1273(Line)X
1467(Information)X
1 f
776 1244(The)N
935(normal)X
1207(form)X
1400(of)X
1495(line)X
1650(information)X
2089(is:)X
7 f
9 s
576 1408(#)N
2 f
662(line_number)X
1044("\256le")X
1 f
11 s
576 1612(However,)N
941(many)X
1159(compilers,)X
1551(such)X
1734(as)X
1829(Borland)X
2135(C,)X
2238(prefer)X
2469(it)X
2541(as)X
7 f
9 s
576 1776(#line)N
2 f
834(line_number)X
1216("\256le")X
1 f
11 s
576 1980(This)N
756(can)X
901(be)X
1007(easily)X
1236(changed)X
1553(by)X
1665(looking)X
1959(\256le)X
7 f
2127(generic.h)X
1 f
2628(in)X
2721(the)X
7 f
2884(antlr)X
1 f
3173(directory)X
3515(for)X
3641(the)X
3773(follow-)X
576 2108(ing:)N
7 f
9 s
576 2272(/*)N
705(User)X
920(may)X
1092(redefine)X
1479(how)X
1651(line)X
1866(information)X
2382(looks)X
2640(*/)X
576 2360(#define)N
920 -0.1992(LineInfoFormatStr)AX
1694("#)X
1823(%d)X
1952(\\"%s\\"\\n")X
1 f
11 s
576 2564(Simply)N
854(change)X
1125(it)X
1197(as)X
1292(your)X
1475(compiler)X
1811(wants)X
2038(it)X
2110(and)X
2259(recompile)X
2634(the)X
2764(antlr)X
2948(source.)X
3 f
576 2820(18.)N
730(Incompatibilities)X
1 f
776 2976(There)N
1014(should)X
1282(be)X
1398(very)X
1588(few)X
1753 0.2891(incompatibilities)AX
2383(with)X
2574(your)X
2769(1.06-based)X
3186(grammars.)X
3616(Should)X
3900(you)X
576 3104(\256nd)N
735(any)X
884(please)X
1126(let)X
1237(us)X
1337(know.)X
776 3260(1.06)N
952(semantic)X
1288(predicates)X
1667(were)X
1859(not)X
1994(hoisted)X
2271(into)X
2431(parsing)X
2712(decisions)X
3062(without)X
3354(the)X
7 f
3515(-pr)X
1 f
3697(\257ag)X
3852(\(now)X
576 3388(obsolete\).)N
965(In)X
1060(1.10,)X
1258(the)X
1388(use)X
1527(of)X
1622(a)X
1683(predicate)X
2028(indicates)X
2364(that)X
2519(it)X
2591(may)X
2765(be)X
2870(hoisted.)X
776 3544(Semantic)N
1127(predicates)X
1506(used)X
1689(to)X
1780(halt)X
1935(parser)X
2171(upon)X
2369(failure)X
2621(whereas)X
2930(1.10)X
3106(does)X
3289(not.)X
776 3700(The)N
940(interpretation)X
1443(of)X
1543(strings,)X
1827(character)X
2177(literals,)X
2468(and)X
2623(comments)X
3014(are)X
3149(now)X
3328(handled)X
3635(differently;)X
576 3828(see)N
710(above.)X
3 f
576 4084(19.)N
730(Future)X
1011(Directions)X
1 f
776 4240(This)N
974(section)X
1265(brie\257y)X
1537(describes)X
1906(some)X
2134(of)X
2249(the)X
2399(future)X
2651(enhancements)X
3192(either)X
3435(being)X
3673(discussed,)X
576 4368(planned,)N
899(or)X
994(developed.)X
10 f
576 4524(g)N
1 f
776(A)X
868(graphical)X
1225(user)X
1400(interface)X
1737(is)X
1825(planned)X
2133(for)X
2264(ANTLR)X
2586(grammars)X
2967(that)X
3129(will)X
3296(allow)X
3521(the)X
3659(simultane-)X
776 4652(ous)N
920 0.2138(display/manipulation)AX
1689(of)X
1784(BNF)X
1977(and)X
2126(syntax)X
2378(diagram)X
2689(representations)X
3244(of)X
3339(user)X
3507(grammars.)X
10 f
576 4808(g)N
1 f
776(A)X
865(source-to-source)X
1476(translator-generator)X
2196(called)X
2434(SORCERER)X
2917(is)X
3003(in)X
3099(prototype)X
3464(form.)X
3706(It's)X
3850(input)X
776 4936(looks)N
997(like)X
1159(ANTLR)X
1481(and)X
1637(is)X
1725(integrated)X
2107(so)X
2214(that)X
2376(one)X
2532(description)X
2953(will)X
3120(contain)X
3409(lexical,)X
3696(syntactic,)X
776 5064(and)N
925(tree-translation)X
1481(information.)X
10 f
576 5220(g)N
1 f
776(A)X
864(number)X
1158(of)X
1256(groups)X
1520(are)X
1652(working)X
1970(on)X
2083(a)X
2148(C++)X
2333(grammar.)X
2721(Things)X
2992(are)X
3125(starting)X
3416(to)X
3511(heat)X
3684(up)X
3798(as)X
3897(it)X
3973(is)X
776 5348(pretty)N
1004(much)X
1222(certain)X
1484(that)X
1639(1.10)X
1815(ANTLR)X
2130(is)X
2211(the)X
2341(minimum)X
2708(necessary)X
3071(system)X
3338(to)X
3429(parse)X
3636(C++.)X
10 f
576 5504(g)N
1 f
776(A)X
861(code-generator)X
1410(generator,)X
1786(called)X
2019(PIGG,)X
2267(is)X
2348(in)X
2439(prototype)X
2799(form.)X
10 f
576 5660(g)N
1 f
776(An)X
905(assembler)X
1279(generator)X
1633(is)X
1714(in)X
1805(prototype)X
2165(form.)X

28 p
%%Page: 28 28
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(28)X
2370(-)X
10 f
576 704(g)N
1 f
776(DLG)X
978(backtracking)X
1455(will)X
1615(be)X
1720(added.)X
10 f
576 860(g)N
1 f
776(A)X
880(new)X
1067(``magic'')X
1440(token)X
1677(type,)X
1892(``.'',)X
2093(will)X
2272(be)X
2396(introduced)X
2814(which)X
3070(means)X
3336(``match)X
3652(any)X
3821(single)X
776 988(token.'')N
10 f
576 1144(g)N
1 f
776(A)X
873(new)X
1053(operator)X
1380(will)X
1552(be)X
1669(introduced,)X
2102(``)X
7 f
2160(\304)X
1 f
2213('',)X
2327(which)X
2576(will)X
2748(allow)X
2978(constructs)X
3369(like)X
7 f
3568(\304\(A)X
9 f
3727(|)X
7 f
3745(B)X
9 f
3798(|)X
7 f
3816(C\))X
1 f
3944(\320)X
776 1272(implying)N
1118(``match)X
1414(a)X
1475(single)X
1708(token)X
3 f
1926(not)X
1 f
2070(from)X
2263(the)X
2393(set)X
2513({A,)X
2662(B,)X
2765(C}.'')X
10 f
576 1428(g)N
1 f
776(A)X
861(new)X
1029(ANTLR)X
1344(directive)X
1675(will)X
1835(be)X
1940(introduced:)X
7 f
9 s
776 1592(#tokclass)N
2 f
1206(name)X
7 f
1405({)X
2 f
1491(token_list)X
7 f
1814(})X
1 f
11 s
776 1796(that)N
942(creates)X
1219(a)X
1291(set)X
1422(of)X
1528(tokens)X
1792(like)X
1959(the)X
7 f
2132(#errclass)X
1 f
2643(directive,)X
3008(but)X
3155(one)X
3316(which)X
3565(can)X
3721(be)X
3838(refer-)X
776 1924(enced)N
1003(in)X
1094(the)X
1224(grammar.)X
1608(For)X
1752(example:)X
7 f
9 s
776 2088(#tokclass)N
1206(AOP)X
1378({)X
1464(")X
9 f
1507(-)X
7 f
1547(")X
1633("+")X
1805(})X
776 2176(#tokclass)N
1206(MOP)X
1378({)X
1464("/")X
1636(")X
1722(})X
776 2264(#tokclass)N
1206(OP)X
1378({)X
1464(AOP)X
1636(MOP)X
1808(})X
819 2352(...)N
776 2440(e)N
862(:)X
948(e1)X
1077(\()X
1163(AOP)X
1335(e1)X
1464(\)*)X
1593(;)X
776 2528(e1:)N
948(e2)X
1077(\()X
1163(MOP)X
1335(e2)X
1464(\)*)X
1593(;)X
819 2616(...)N
1 f
11 s
10 f
576 2820(g)N
1 f
776(Simple)X
1063(left-factoring)X
1564(will)X
1738(be)X
1857(introduced)X
2271(to)X
2377(remove)X
2678(identical)X
3020(left)X
3175(factors)X
3451(from)X
3659(alternative)X
776 2948(productions)N
1214(\(assuming)X
1598(user)X
1766(actions)X
2038(do)X
2148(not)X
2283(interfere\).)X
10 f
576 3104(g)N
1 f
776(A)X
875(version)X
1170(of)X
1279(ANTLR)X
1608(\(called)X
1884(ANTLR-lite?\))X
2424(is)X
2520(being)X
2753(considered)X
3171(that)X
3341(would)X
3598(accept)X
3860(most)X
776 3232(ANTLR)N
1103(description)X
1529(syntax,)X
1815(delay)X
2040(grammar)X
2392(analysis)X
2710(to)X
2813(run)X
2964(time)X
3156(\(where)X
3433(it)X
3516(could)X
3745(be)X
3861(done)X
776 3360(much)N
1013(more)X
1235(quickly)X
1522(\320)X
1651(with)X
1849(nonexponential)X
2434(complexity\),)X
2924(scan)X
3121(for)X
3264(tokens)X
3535(with)X
3733(an)X
3857(NFA)X
776 3488(regular-expression)N
1457(interpreter)X
1850(rather)X
2081(a)X
2146(DFA,)X
2369(and)X
2522(place)X
2734(all)X
2849(output)X
3101(in)X
3196(one)X
3349(nice)X
3522(little)X
3712(\256le.)X
3895(The)X
776 3616(reduction)N
1131(in)X
1222(parser)X
1458(size)X
1617(would)X
1859(be)X
1964(substantial,)X
2386(but)X
2521(at)X
2607(a)X
2668(parser)X
2904(run-time)X
3230(cost.)X
3 f
576 3872(20.)N
730(Portability)X
1 f
776 4028(PCCTS)N
1084(1.10)X
1276(is)X
1373(known)X
1650(to)X
1757(compile)X
2081(``out)X
2291(of)X
2403(the)X
2550(box'')X
2779(on)X
2906(the)X
3053(following)X
3435(machines)X
3807(and/or)X
576 4156(operating)N
931(systems:)X
576 4312([1])N
776(DECSTATION)X
1349(5000)X
576 4468([2])N
776(SGI,)X
961(Running)X
1287(IRIX)X
1489(4.0.5)X
576 4624([3])N
776(Sun)X
935(SparcStation)X
1408(\(cc,)X
1559(gcc,)X
1725(g++,)X
1913(Cfront\))X
576 4780([4])N
776(DOS)X
973(and)X
1122(OS/2,)X
1347(Microsft)X
1672(C)X
1753(6.0,)X
1907(16)X
2017(bit)X
576 4936([5])N
776(DOS)X
973(and)X
1122(OS/2,)X
1347(Borland)X
1653(C/C++,)X
1940(16)X
2050(bit)X
576 5092([6])N
776(OS/2,)X
1001(IBM)X
1189(C-Set/2,)X
1503(32)X
1613(bit)X
576 5248([7])N
776(VAX)X
987(C)X
1068(under)X
1290(VMS)X
576 5404([8])N
776(Linux)X
1009(0.99,)X
1207(gcc/g++)X
576 5560([9])N
776(NeXT)X
1017(box)X
576 5716([10])N
776(Amiga,)X
1060(AmigaDOS--SAS/C)X
1800(Development)X
2297(System)X
2579(V)X
2664(5.10b)X

29 p
%%Page: 29 29
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(29)X
2370(-)X
3 f
576 704(21.)N
730(Beta)X
923(Testers)X
1 f
776 860(The)N
942(following)X
1314(is)X
1402(a)X
1470(group)X
1704(of)X
1806(persons)X
2103(\(listed)X
2353(alphabetically\))X
2907(that,)X
3091(in)X
3189(some)X
3404(way,)X
3601(have)X
3797(helped)X
576 988(shape)N
798(and/or)X
1045(debug)X
1282(the)X
1412(latest)X
1621(release)X
1887(of)X
1982(PCCTS.)X
576 1144([1])N
776(Steven)X
1038(Anderson,)X
1423(\([email protected]\))X
576 1300([2])N
776(Douglas)X
1091(B.)X
1194(Cuthbertson,)X
1669(\([email protected]\))X
576 1456([3])N
776(Peter)X
979(Dahl,)X
1194(\([email protected]\))X
576 1612([4])N
776(Ed)X
896(Harfmann,)X
1296(\([email protected]\))X
576 1768([5])N
776(Randy)X
1028(Helzerman,)X
1458(\([email protected]\))X
576 1924([6])N
776(Stephen)X
1082(Hite,)X
1278(\([email protected]\))X
576 2080([7])N
776(Dana)X
983("Muck")X
1282(Hoggatt,)X
1610(\([email protected]\))X
576 2236([8])N
776(Roy)X
945(Levow,)X
1233(\([email protected]\))X
576 2392([9])N
776(John)X
964(Mejia,)X
1214(\([email protected]\))X
576 2548([10])N
776(David)X
1013(Poole,)X
1258(\([email protected]\))X
576 2704([11])N
776(Russell)X
1058(Quong,)X
1341(\([email protected]\))X
576 2860([12])N
776(Aaron)X
1017(Sawdey,)X
1339(\([email protected]\))X
576 3016([13])N
776(Fred)X
959(Scholldorf,)X
1375(\([email protected]\))X
576 3172([14])N
776(Sumana)X
1082(Srinivasan,)X
1498(\([email protected]\))X
576 3328([15])N
776(Ariel)X
979(Tamches,)X
1341(\([email protected]\))X

29 p
%%Trailer
xt

xs

1667(were)X
1859(not)X
1994(hoisted)X
2271(into)X
2431(parsing)X
2712(decisions)X
3062(without)X
3354(the)X
7 f
3515(-pr)X
1 f
3697(\257ag)X
3852(\(now)X
pccts/UPDAT120.ps 644 1377 31 432176 5655551667 7014 %!PS-Adobe-2.0
%%Creator: dvips 5.519 Copyright 1986, 1993 Radical Eye Software
%%Title: UPDAT120.dvi
%%CreationDate: Sat Aug 20 15:58:22 1994
%%Pages: 22
%%PageOrder: Ascend
%%BoundingBox: 0 0 612 792
%%DocumentFonts: Times-Roman Times-Italic Courier Times-Bold
%%EndComments
%DVIPSCommandLine: dvips -o UPDAT120.ps UPDAT120
%DVIPSSource: TeX output 1994.08.20:1558
%%BeginProcSet: texc.pro
/TeXDict 250 dict def TeXDict begin /N{def}def /B{bind def}N /S{exch}N
/X{S N}B /TR{translate}N /isls false N /vsize 11 72 mul N /hsize 8.5 72
mul N /landplus90{false}def /@rigin{isls{[0 landplus90{1 -1}{-1 1}
ifelse 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale
isls{landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div
hsize mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul
TR matrix currentmatrix dup dup 4 get round 4 exch put dup dup 5 get
round 5 exch put setmatrix}N /@landscape{/isls true N}B /@manualfeed{
statusdict /manualfeed true put}B /@copies{/#copies X}B /FMat[1 0 0 -1 0
0]N /FBB[0 0 0 0]N /nn 0 N /IE 0 N /ctr 0 N /df-tail{/nn 8 dict N nn
begin /FontType 3 N /FontMatrix fntrx N /FontBBox FBB N string /base X
array /BitMaps X /BuildChar{CharBuilder}N /Encoding IE N end dup{/foo
setfont}2 array copy cvx N load 0 nn put /ctr 0 N[}B /df{/sf 1 N /fntrx
FMat N df-tail}B /dfs{div /sf X /fntrx[sf 0 0 sf neg 0 0]N df-tail}B /E{
pop nn dup definefont setfont}B /ch-width{ch-data dup length 5 sub get}
B /ch-height{ch-data dup length 4 sub get}B /ch-xoff{128 ch-data dup
length 3 sub get sub}B /ch-yoff{ch-data dup length 2 sub get 127 sub}B
/ch-dx{ch-data dup length 1 sub get}B /ch-image{ch-data dup type
/stringtype ne{ctr get /ctr ctr 1 add N}if}B /id 0 N /rw 0 N /rc 0 N /gp
0 N /cp 0 N /G 0 N /sf 0 N /CharBuilder{save 3 1 roll S dup /base get 2
index get S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx 0 ch-xoff
ch-yoff ch-height sub ch-xoff ch-width add ch-yoff setcachedevice
ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-yoff .1 add]/id
ch-image N /rw ch-width 7 add 8 idiv string N /rc 0 N /gp 0 N /cp 0 N{
rc 0 ne{rc 1 sub /rc X rw}{G}ifelse}imagemask restore}B /G{{id gp get
/gp gp 1 add N dup 18 mod S 18 idiv pl S get exec}loop}B /adv{cp add /cp
X}B /chg{rw cp id gp 4 index getinterval putinterval dup gp add /gp X
adv}B /nd{/cp 0 N rw exit}B /lsh{rw cp 2 copy get dup 0 eq{pop 1}{dup
255 eq{pop 254}{dup dup add 255 and S 1 and or}ifelse}ifelse put 1 adv}
B /rsh{rw cp 2 copy get dup 0 eq{pop 128}{dup 255 eq{pop 127}{dup 2 idiv
S 128 and or}ifelse}ifelse put 1 adv}B /clr{rw cp 2 index string
putinterval adv}B /set{rw cp fillstr 0 4 index getinterval putinterval
adv}B /fillstr 18 string 0 1 17{2 copy 255 put pop}for N /pl[{adv 1 chg}
{adv 1 chg nd}{1 add chg}{1 add chg nd}{adv lsh}{adv lsh nd}{adv rsh}{
adv rsh nd}{1 add adv}{/rc X nd}{1 add set}{1 add clr}{adv 2 chg}{adv 2
chg nd}{pop nd}]dup{bind pop}forall N /D{/cc X dup type /stringtype ne{]
}if nn /base get cc ctr put nn /BitMaps get S ctr S sf 1 ne{dup dup
length 1 sub dup 2 index S get sf div put}if put /ctr ctr 1 add N}B /I{
cc 1 add D}B /bop{userdict /bop-hook known{bop-hook}if /SI save N @rigin
0 0 moveto /V matrix currentmatrix dup 1 get dup mul exch 0 get dup mul
add .99 lt{/QV}{/RV}ifelse load def pop pop}N /eop{SI restore showpage
userdict /eop-hook known{eop-hook}if}N /@start{userdict /start-hook
known{start-hook}if pop /VResolution X /Resolution X 1000 div /DVImag X
/IE 256 array N 0 1 255{IE S 1 string dup 0 3 index put cvn put}for
65781.76 div /vsize X 65781.76 div /hsize X}N /p{show}N /RMat[1 0 0 -1 0
0]N /BDot 260 string N /rulex 0 N /ruley 0 N /v{/ruley X /rulex X V}B /V
{}B /RV statusdict begin /product where{pop product dup length 7 ge{0 7
getinterval dup(Display)eq exch 0 4 getinterval(NeXT)eq or}{pop false}
ifelse}{false}ifelse end{{gsave TR -.1 -.1 TR 1 1 scale rulex ruley
false RMat{BDot}imagemask grestore}}{{gsave TR -.1 -.1 TR rulex ruley
scale 1 1 false RMat{BDot}imagemask grestore}}ifelse B /QV{gsave
transform round exch round exch itransform moveto rulex 0 rlineto 0
ruley neg rlineto rulex neg 0 rlineto fill grestore}B /a{moveto}B /delta
0 N /tail{dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{S p tail}
B /c{-4 M}B /d{-3 M}B /e{-2 M}B /f{-1 M}B /g{0 M}B /h{1 M}B /i{2 M}B /j{
3 M}B /k{4 M}B /w{0 rmoveto}B /l{p -4 w}B /m{p -3 w}B /n{p -2 w}B /o{p
-1 w}B /q{p 1 w}B /r{p 2 w}B /s{p 3 w}B /t{p 4 w}B /x{0 S rmoveto}B /y{
3 2 roll p a}B /bos{/SS save N}B /eos{SS restore}B end
%%EndProcSet
%%BeginProcSet: texps.pro
TeXDict begin /rf{findfont dup length 1 add dict begin{1 index /FID ne 2
index /UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll
exec 0 exch 5 -1 roll VResolution Resolution div mul neg 0 0]/Metrics
exch def dict begin Encoding{exch dup type /integertype ne{pop pop 1 sub
dup 0 le{pop}{[}ifelse}{FontMatrix 0 get div Metrics 0 get div def}
ifelse}forall Metrics /Metrics currentdict end def[2 index currentdict
end definefont 3 -1 roll makefont /setfont load]cvx def}def
/ObliqueSlant{dup sin S cos div neg}B /SlantFont{4 index mul add}def
/ExtendFont{3 -1 roll mul exch}def /ReEncodeFont{/Encoding exch def}def
end
%%EndProcSet
%%BeginProcSet: special.pro
TeXDict begin /SDict 200 dict N SDict begin /@SpecialDefaults{/hs 612 N
/vs 792 N /ho 0 N /vo 0 N /hsc 1 N /vsc 1 N /ang 0 N /CLIP 0 N /rwiSeen
false N /rhiSeen false N /letter{}N /note{}N /a4{}N /legal{}N}B
/@scaleunit 100 N /@hscale{@scaleunit div /hsc X}B /@vscale{@scaleunit
div /vsc X}B /@hsize{/hs X /CLIP 1 N}B /@vsize{/vs X /CLIP 1 N}B /@clip{
/CLIP 2 N}B /@hoffset{/ho X}B /@voffset{/vo X}B /@angle{/ang X}B /@rwi{
10 div /rwi X /rwiSeen true N}B /@rhi{10 div /rhi X /rhiSeen true N}B
/@llx{/llx X}B /@lly{/lly X}B /@urx{/urx X}B /@ury{/ury X}B /magscale
true def end /@MacSetUp{userdict /md known{userdict /md get type
/dicttype eq{userdict begin md length 10 add md maxlength ge{/md md dup
length 20 add dict copy def}if end md begin /letter{}N /note{}N /legal{}
N /od{txpose 1 0 mtx defaultmatrix dtransform S atan/pa X newpath
clippath mark{transform{itransform moveto}}{transform{itransform lineto}
}{6 -2 roll transform 6 -2 roll transform 6 -2 roll transform{
itransform 6 2 roll itransform 6 2 roll itransform 6 2 roll curveto}}{{
closepath}}pathforall newpath counttomark array astore /gc xdf pop ct 39
0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if}N
/txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR pop 1 -1
scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3 get
ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip
not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub neg 0
TR}if yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{noflips{TR
pop pop 270 rotate 1 -1 scale}if xflip yflip and{TR pop pop 90 rotate 1
-1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg
TR}if xflip yflip not and{TR pop pop 90 rotate ppr 3 get ppr 1 get neg
sub neg 0 TR}if yflip xflip not and{TR pop pop 270 rotate ppr 2 get ppr
0 get neg sub neg 0 S TR}if}ifelse scaleby96{ppr aload pop 4 -1 roll add
2 div 3 1 roll add 2 div 2 copy TR .96 dup scale neg S neg S TR}if}N /cp
{pop pop showpage pm restore}N end}if}if}N /normalscale{Resolution 72
div VResolution 72 div neg scale magscale{DVImag dup scale}if 0 setgray}
N /psfts{S 65781.76 div N}N /startTexFig{/psf$SavedState save N userdict
maxlength dict begin /magscale false def normalscale currentpoint TR
/psf$ury psfts /psf$urx psfts /psf$lly psfts /psf$llx psfts /psf$y psfts
/psf$x psfts currentpoint /psf$cy X /psf$cx X /psf$sx psf$x psf$urx
psf$llx sub div N /psf$sy psf$y psf$ury psf$lly sub div N psf$sx psf$sy
scale psf$cx psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub TR
/showpage{}N /erasepage{}N /copypage{}N /p 3 def @MacSetUp}N /doclip{
psf$llx psf$lly psf$urx psf$ury currentpoint 6 2 roll newpath 4 copy 4 2
roll moveto 6 -1 roll S lineto S lineto S lineto closepath clip newpath
moveto}N /endTexFig{end psf$SavedState restore}N /@beginspecial{SDict
begin /SpecialSave save N gsave normalscale currentpoint TR
@SpecialDefaults count /ocount X /dcount countdictstack N}N /@setspecial
{CLIP 1 eq{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto
closepath clip}if ho vo TR hsc vsc scale ang rotate rwiSeen{rwi urx llx
sub div rhiSeen{rhi ury lly sub div}{dup}ifelse scale llx neg lly neg TR
}{rhiSeen{rhi ury lly sub div dup scale llx neg lly neg TR}if}ifelse
CLIP 2 eq{newpath llx lly moveto urx lly lineto urx ury lineto llx ury
lineto closepath clip}if /showpage{}N /erasepage{}N /copypage{}N newpath
}N /@endspecial{count ocount sub{pop}repeat countdictstack dcount sub{
end}repeat grestore SpecialSave restore end}N /@defspecial{SDict begin}
N /@fedspecial{end}B /li{lineto}B /rl{rlineto}B /rc{rcurveto}B /np{
/SaveX currentpoint /SaveY X N 1 setlinecap newpath}N /st{stroke SaveX
SaveY moveto}N /fil{fill SaveX SaveY moveto}N /ellipse{/endangle X
/startangle X /yrad X /xrad X /savematrix matrix currentmatrix N TR xrad
yrad scale 0 0 1 startangle endangle arc savematrix setmatrix}N end
%%EndProcSet
TeXDict begin 40258431 52099146 1000 600 600
(/usr/home/parrt/PCCTS/doc/UPDAT120.dvi) @start /Fa 139[28
32 37 2[42 46 69 1[46 5[37 3[42 12[55 46 60 1[51 1[60
1[55 10[60 10[42 2[42 42 42 2[21 46[{}21 83.333336 /Times-Bold
rf /Fb 135[50 72 50 55 33 39 44 1[55 50 55 83 28 2[28
1[50 1[44 55 44 55 50 10[72 1[66 55 72 1[61 1[72 94 66
3[78 78 61 66 72 72 66 72 7[50 50 50 50 50 50 50 50 50
50 1[25 33 1[57 6[50 36[{}49 100.000000 /Times-Bold rf
/Fc 135[37 3[23 32 32 1[42 42 42 1[23 2[23 42 42 1[37
42 37 1[42 51[28 45[{}16 83.333336 /Times-Italic rf /Fd
139[40 4[40 40 40 1[40 5[40 3[40 12[40 42[40 40 4[40
35[{}11 66.666664 /Courier rf /Fe 139[70 70 3[70 70 70
1[70 3[70 70 70 70 64[70 35[{}11 116.666672 /Courier
rf /Ff 1 111 df<000F13FC383FC3FF3971E707803861EC03D8C1F813C013F013E00003
EB078013C0A2EC0F00EA0780A2EC1E041506D80F00130C143C1518EC1C30001EEB1FE000
0CEB07C01F157D9426>110 D E /Fg 205[25 25 49[{}2 50.000000
/Times-Roman rf /Fh 3 111 df B3A55B133E5B5BEA03F0EA7FC048C8FCEA7FC0EA03F0C67E137C7F133F7FB3A580130F80
6D7E6D7EEB00FCEC3FE014071B4B7BB726>102 D<12FCB47EEA07E0EA01F86C7E137E13
3E133F7FB3A580130F6D7E6D7EEB01F89038007FC0EC1FE0EC7FC0903801F800EB03E049
5A495A131F91C7FCB3A55B133E137E5B485AEA07E0EAFF8000FCC8FC1B4B7BB726>I<12
6012F07EA21278127CA2123C123EA2121E121FA27E7FA212077FA26C7EA212017FA21200
7FA21378137CA2133C133EA2131E131FA27F80A26D7EA2130380A2130180A2130080A214
78147CA2143C143EA280A2801580A2140715C0A2140315E0A2140115F0A2140015F8A215
7815301D4B7CB726>110 D E /Fi 21 122 df<123C127E12FFA4127E123C08087A8715>
58 D<0007B812E05AD9E0009038001FC00180491307261E00011403001C16015D481780
1403123000705C006016030207150012E0485CA2140FC792C7FC5DA2141FA25DA2143FA2
5DA2147FA292C9FCA25CA25CA21301A25CA21303A25CA21307A25C130F497E007FB512FC
A233337EB22D>84 D 5B3807C000120FEB8001001F5CEA3F00A21403485C127EA2140700FE5C5A1640020F1360
007CEC80E016C0141FEC3F81003C017F1380003EEBEF83261E01CF1300390F0787C73907
FE03FE3900F800F823207E9F29>97 D<137EEA1FFEA2EA007CA213FCA25BA21201A25BA2
1203A25BA21207A25BEBC1F0380FC7FEEBDE0F9038B8078001F013C0381FE00301C013E0
138013005A15F0123EA2007E130715E0127CA2140F00FC14C05AA2EC1F80150000785B14
3E5C007C5B383C01F06C485A380F0FC06CB4C7FCEA01F81C347DB321>I<14FE903807FF
C090381F01E090387C00703901F801F03803F0033807E007EA0FC0EA1F80EC03E048C8FC
A2127EA212FE5AA45AA415181538007C147015E06CEB03C06CEB0F00380F807E3803FFF0
C613801D207D9F21>I 00A25DA2153EEB01F090380FFC7EEB3F0F90387C037C01F813FC3801F001EA03E048486C
5A120FEB8001121FD83F005BA214035A007E5CA2140712FE485C1640020F1360007C15E0
ED80C0141FEC3F81003C017F1380003EEBEF83261E01CF1300390F0787C73907FE03FE39
00F800F824347EB328>I 5A120F485A383F0001EC03C0007EEB0F80ECFE00387FFFF8B5128000FCC8FCA55AA36C14
18007C143815706C14E0EC03C06CEB0F003807807E3803FFF038007F801D207D9F24>I<
141F9138FFC180903903F0F7C0903807C03790380F803F90381F001F133E49EB0F8013FC
49131F120148481400A25D120749133EA2157E120F49137CA215FC12075D140114030003
13076D485A0001131D3800F07BEB7FE390380F83E0EB00031407A25DA2140F001C5C127F
4AC7FC5C00FE137E007E13F8387803F0383FFFC0D807FEC8FC222F7F9F25>103
D 803903F1FFE09038F3C1F09038EF00F813FC4848137C5BA25B484813FC5D5BA2001F1301
5D13001403485CA2003E1307EDC020007E1570020F1360007C148016E000FC15C0150148
EC03801600158F48EB03FC48EB01F024347BB32C>I EB038090C7FCABEA01F0EA07FCEA0E1EEA1C1F1218123812301270EA603F133EEAE07EEA
407C120013FC5B1201A25B12035B142000071370EBC060120FEB80E014C0138114801383
38078700EA03FEEA00F814327EB11A>I 7EA2137CA213FCA25BA21201A25B15F80003EB03FEEC07079038E01E0F9138383F800007
13709138E07F00EBC1C0EBC380390FC7001C01CE90C7FC5B13F8121F13FFEB1FC0EB07F0
EA3F016D7E123E1502007E14071506127C150E00FC140CA248141CEC7838EC7C7048EB1F
E048EB078021347BB328>107 D<133FEA0FFFA2EA003EA2137EA2137CA213FCA213F8A2
1201A213F0A21203A213E0A21207A213C0A2120FA21380A2121FA21300A25AA2123EA212
7EA2127C1308EAFC0C131CEAF818A3133813301370EA7CE0EA3FC0EA0F8010347CB317>
I<2703E001FCEB0FE03C0FF807FF803FFC3C1C7C1E07C0F03E3C183E3803E1C01F003801
70EBE3800030903AE001E7000F26703FC001FE1480006001805B02005BD8E07F0103141F
D8C07E4A1400D8407C5C120001FC01075C183E495C187E0001020F147CA2494A13FCF0F8
040003021F150E0501130C49020013F0191C00074A1518F0E03849013E15701960F0F1E0
49013C9038007F8090C70038EC3E003F207E9F44>I<3903E001FC3A0FF807FF803A1C7C
1E07C03A183E3803E0003813700030EBE00126703FC07F006013801400D8E07F1303D8C0
7E5CEA407C120001FC13075E5B150F00015DA249131FEE00800003ED01C0033F13804913
3E160300071600ED3C0749140E160CED3E3C49EB0FF090C7EA07C02A207E9F2E>I FE903807FF8090381F03E090387C01F03901F800F84848137C485A4848133E485AA248C7
FCA2127E157E12FE5AA215FE15FC5AEC01F8A2EC03F0A2EC07E0007CEB0FC0EC1F806CEB
3F006C137C380F81F03803FFC0C690C7FC1F207D9F25>I<013E133E9039FF80FFC03A01
C7C3C1E0903983E700F0000301EE13F8D903FC1378000749137C00065B5CEA0E07000C15
7E00045B1200010F14FE16FC5CA2011F130116F81400A249EB03F016E0013E130716C001
7FEB0F80ED1F00EC803E017D5B9038FDE1F89038FC7FE0D9F81FC7FC91C8FC1201A25BA2
1203A25BA21207A25B120FB5FCA2272F829F27>I<3903E007E0390FF81FF8391C7C381C
39183EF03C39383FC0FE003013800070EB81FC00601301133E39E07E007000C01400EA40
7C120013FCA25BA21201A25BA21203A25BA21207A25BA35B90C8FC1F207E9F23>114
D 038091C7FC13F8EBFFC014F86C13FE6C7F013F138013039038003FC0140F1407127E00FE
1480A3EC0F005A00E0131E0070137C383C01F0380FFFC0D803FEC7FC1B207C9F24>I<13
07EB0F80A3131F1400A35B133EA3137E137CB512FCA23800FC005BA312015BA312035BA3
12075BA3120F5B14101438001F13301300147014E014C01301EB0380380F8700EA07FEEA
01F8162E7EAD1C>I<01F814E0D803FC1301D80F1F1303EA0C0F121C00381407D8301F14
C01270126049130FD8E03E14801240EA007E017C131F01FC14005BA25D0001143E5B1602
ED7E03ED7C07160615FC160E0201130C0203131C3A00F8077C1890397C1E3E3890393FF8
1FF0903907E007C028207E9F2C>I<01F8EB01C0D803FC1303D80F1F1307EA0C0F121C00
38140FD8301F14801270126049131FD8E03E14001240EA007E017C5B01FC133E5BA2157E
0001147C5BA215FC5DA25BEBF0014A5A14073800F80FEB7C1F90383FFBE0EB0FE3EB0003
14075DA20007495AEA1F80003F49C7FC5C143E495A003E5B381801F0381E07C0D807FFC8
FCEA01F8222F7E9F26>121 D E /Fj 4 117 df<137CEA0FFCA2C65AA21201A25BA21203
A25BA21207A2EBC1F8EBC7FE380FDE1F9038F80F8013E0EBC007381F800FA21300A25AEC
1F00123EA2007E133EA2007C140C147C00FC141814F8481430147815E048EB3FC048EB0F
001E287BA727>104 D<130E131FA2131E130C90C7FCA9EA03E0EA0FF0EA1C78EA387C12
3012605B12C0A2EA01F0A3485AA2485AA2EBC180EA0F81EB8300EA1F031306120F131CEA
07F8EA01E011277DA617>I<390F801FC0391FE07FF03931F0E0F83930FB807C3860FF00
5B5BEAC1F85B1201A248485BA34A5AEA07C01660EC03E016C0390F8007C0EDC1801403ED
C70090380001FE000EEB007823197D9829>110 D<130E131E133EA45BA45BB512E0A238
00F800485AA4485AA4485AA4485A1460A214C0EA1F00EB0180380F0300138EEA07FCEA01
F013247EA319>116 D E /Fk 205[29 29 49[{}2 58.333336 /Times-Roman
rf /Fl 59[50 71[50 1[50 50 50 50 50 50 50 50 50 1[50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 3[50 1[50
50 1[50 50 1[50 50 50 50 50 50 50 50 50 50 50 1[50 1[50
50 50 50 50 50 50 50 50 50 50 50 1[50 6[50 50 50 50 1[50
50 1[50 50 50 50 3[50 50 50 50 33[{}71 83.333336 /Courier
rf /Fm 5 104 df<007FB81280B912C0A26C17803204799641>0
D 14FCA36C14F8A26C14F06C14E06C14C06C1480C6EBFE006D5AEB0FE01F207BA42A>15
D<127012FCB4FCEA7FC0EA1FF0EA07FCEA01FF38007FC0EB1FF0EB07FCEB01FF9038007F
C0EC1FF0EC07FCEC01FF9138007FC0ED1FF0ED07FCED01FF9238007FC0EE1FF0EE07FCEE
01FF9338007FC0171F177F933801FF80933807FC00EE1FF0EE7FC04B48C7FCED07FCED1F
F0ED7FC04A48C8FCEC07FCEC1FF0EC7FC04948C9FCEB07FCEB1FF0EB7FC04848CAFCEA07
FCEA1FF0EA7FC048CBFC12FC1270CCFCAD007FB81280B912C0A26C1780324279B441>21
D F8EA7FE048C8FCEA7FE0EA03F8EA00FE137F6D7E131F80130FB3A7801307A26D7E6D7E6D
7EEC3F80EC0FF814011D537ABD2A>102 D<12FCEAFFC0EA07F0EA01FCEA007E7F80131F
80130FB3A7801307806D7E6D7EEB007EEC1FF0EC07F8EC1FF0EC7E00495A495A495A5C13
0F5CB3A7131F5C133F91C7FC137E485AEA07F0EAFFC000FCC8FC1D537ABD2A>I
E /Fn 25 122 df<121C127FEAFF80A5EA7F00121C0909798817>58
D<124012F812FE6C7EEA3FE0EA0FF8EA03FEC66C7EEB3FE0EB0FF8EB03FE903800FF80EC
3FE0EC0FF8EC03FE913800FF80ED3FE0ED0FF8ED03FE923800FF80EE3FE0EE0FF8EE03FE
933800FF80EF3FC0A2EFFF80933803FE00EE0FF8EE3FE0EEFF80DB03FEC7FCED0FF8ED3F
E0EDFF80DA03FEC8FCEC0FF8EC3FE0ECFF80D903FEC9FCEB0FF8EB3FE0EBFF80D803FECA
FCEA0FF8EA3FE0EAFF8048CBFC12F81260323279AD41>62 D<176017E0831601A2160316
07A2160FA2161F1637A2EE67F8166316C315011683ED0303A21506150E150C03187FA2ED
30011570156015C0A2EC0180140315001406835C1600021FB5FC5CA20260C7FCA25C495A
8349C8FC8313065BA25B133813301370D801F81680D807FCEC01FFB500C0017F13FFA25C
383B7DBA3E>65 D<0107B6FCA25E90260007FCC8FC5D5D140FA25DA2141FA25DA2143FA2
5DA2147FA292C9FCA25CA25CA21301A25CA21303A25CA2130718404A15C0A2010F150118
804A1403A2011F16005F4A1406170E013F151E171C4A143C177C017F5D160391C7120F49
EC7FF0B8FCA25F32397DB839>76 D<0107B612F8EFFF8018E0903B0007F8001FF84BEB03
FCEF00FE020F157FA24BEC3F80A2021F16C0A25DA2143FF07F805DA2027FEDFF006092C7
485A4D5A4A4A5A4D5A4AEC1F80057EC7FC0101EC07F891B612C094C8FC9139FC000FC001
03EC03F0707E4A80707E1307177E5C177F010F5D5F5CA2011F1401A25CA2133F16034A4A
1360A2017F17E019C091C700011301496CED0380B6903900FE0700EF7F0EEF1FFCCAEA07
F03B3A7DB83F>82 D<0003B812FEA25A903AF8003FC00101C0913880007E4848163C90C7
007F141C121E001C92C7FCA2485CA200305C007017180060130112E0485CA21403C71600
5DA21407A25DA2140FA25DA2141FA25DA2143FA25DA2147FA292C9FCA25CA25CA21301A2
5CA21303A25CEB0FFC007FB67EA293C8FC37397EB831>84 D<14FCEB03FF90380F838790
393F01DF8090387E00FF49137F485A4848EB3F0012075B48485B001F147EA2485A15FE00
7F5C90C7FCA21401485C5AA214035D48150CA20207131CEDE018A2140F007C1538021F13
30007E013F1370003E01731360261F01E313E03A0F8381F1C03A03FF00FF80D800FCEB3E
0026267DA42C>97 D<133FEA1FFFA3C67E137EA313FE5BA312015BA312035BA31207EBE0
FCEBE3FF9038E707C0390FFE03E09038F801F001F013F8EBE000485A15FC5BA2123F90C7
FCA214015A127EA2140312FE4814F8A2140715F05AEC0FE0A215C0EC1F80143F00781400
007C137E5C383C01F86C485A380F07C06CB4C7FCEA01FC1E3B7CB924>I FFF0903807E03890380F801C90383F000E137E49137E484813FE485A485A120F4913FC00
1F1400485AA2127F90C8FCA35A5AA45AA315031507007E1406150E003E143C003F14706C
14E0390F8007C03907E03F003801FFF838003FC020267DA424>I<167EED3FFEA3150016
FCA21501A216F8A21503A216F0A21507A216E0A2150FA202FC13C0EB03FF90380F839F90
383F01DF90397E00FF8049137F485A4848133F000715005B48485B121F157E485A15FE12
7F90C75AA214015A485CA21403A248ECF00CA20207131C161815E0140F007C1538021F13
30007E013F1370003E01731360261F01E313E03A0F8381F1C03A03FF00FF80D800FCEB3E
00273B7DB92B>I 5A485A1207485A49131E001F141C153C484813F8EC03E0007FEB3FC09038FFFE0014E090
C8FC5A5AA7007E140315071506003E140E003F143C6C14706C6C13E0EC07C03903E03F00
3801FFF838003FC020267DA427>I 3F91C9FCA35B90387E03F8EC1FFEEC7C1F9039FEE00F80D9FDC07F9038FF80071400485A
5BA249130F12035BA2151F00075D5BA2153F000F92C7FC5B5D157E121F499038FE018015
FC02011303003F02F8130013005EEDF00648150E007E5D1618163800FE010013F048EC7F
C00038021FC7FC293B7CB930>104 D<14E0EB01F81303A314F0EB01C090C7FCAC13F8EA
03FEEA070F000E1380121C121812381230EA701F1260A2EAE03F00C013005BEA007EA213
FE5B1201A25B12035BA20007131813E0000F1338EBC030A21470EB806014E014C01381EB
838038078700EA03FEEA00F815397EB71D>I<1507ED1F80153FA31600150E92C7FCACEC
0F80EC7FE0ECF1F0903801C0F8EB038049487E1306130E130C131CEB1801133801305BA2
EB0003A25DA21407A25DA2140FA25DA2141FA25DA2143FA292C7FCA25CA2147EA214FEA2
5CA213015C121C387E03F0A238FE07E0495A5CD8F81FC8FCEA707EEA3FF8EA0FC0214981
B722>I ED1FF0ED783801FEEBE07C9039FC01C1FCEC0381EC07010001010E13F8EBF81C91383800
E04A130000035BEBF1C0EBF38001F7C8FCEA07FEA2EBFFC0EBE7F8380FE1FCEBC07E147F
80001F80D9801F1330A21670003F013F13600100130016E016C05A007EEB1F01ED038016
0000FEEB0F8748EB03FE0038EB00F8263B7CB92B>I 3FA21400A25BA2137EA213FEA25BA21201A25BA21203A25BA21207A25BA2120FA25BA212
1FA25BA2123FA290C7FCA25AA2EA7E06A212FE130EEAFC0CA3131C1318EA7C381330EA3E
706C5AEA07C0123B7CB919>I 1F07C03D1C1F0E00F83803E0001849D9FC707F003801B890387CE001003001F0EB7DC000
7049EB7F800060491400A24A01FE1303D8E03F5C00C090C7FCA2000002011407495F017E
5CA20303140F01FE5F495C181F03075D1201494A013F13601900030F4A13E00003057E13
C0495C1901031F027C138000071803494AEC07001906033F150E000FEF3C3C4991C7EA1F
F0D80380010EEC07C043267EA449>I 0E01F00018011C7F0038EBB800003013F000705B0060497FA24A485AEAE03F00C01300A2
00001403495C137EA2150701FE5C5B150F5E120149011F13301680033F13700003ED0060
5B17E0033E13C00007150149EC038017005E000FEC1E1E49EB0FF8D80380EB03E02C267E
A432>I E0485A4848EB03F0120F5B121F48481307A2127F90C7FCA2150F5A4815E0A2151F16C0A2
48EC3F8016005D157E007E5C4A5A003E495A003F495A6C495A6C6C48C7FC3807E07E3801
FFF038003F8024267DA428>I<90390F8007E090393FE01FF8903971F0383E9039E0F8F0
1F903AC0F9C00F800001D9FF8013C049EB000700035B010015E05C1301120700065BA2D8
0003140FA25CA20107141FA24A14C0A2010F143F17805CEE7F00131F167E4A5B1501013F
5C6E485A4B5A6E485A90397F701F80DA383EC7FC90387E1FF8EC07E001FEC9FCA25BA212
01A25BA21203A25B1207B512C0A32B3582A42A>I<3901F001F83907FC07FE390E3E1E07
3A1C1F380F800018EB303F003813F0003013E0007001C013001260EC801C92C7FCEAE03F
00C090C8FCA212005B137EA313FE5BA312015BA312035BA312075BA3120F5BEA03802126
7EA425>114 D<147F903803FFC090380780E090381E007049133815184913789038F801
F813F0A215F03901F800E015007FEBFFE06C13FC14FF6D13806D13C06D13E01303903800
3FF0140714031401123E127E00FE14E0A348EB03C012C06CEB07800070EB0F006C133E00
1E13F83807FFE0000190C7FC1D267CA427>I 3F91C7FC007FB51280A2B6FCD8007EC7FCA313FE5BA312015BA312035BA312075BA3120F
EBC006A2140E001F130CEB801C1418143814301470000F5BEB81C03807C7806CB4C7FCEA
00F819357EB31E>I<137C48B414702607878013F8390E07C001120C121C003814031230
D8700F5C12601507EAE01F00C001805B133F0000EB000FA2495C137E151F13FE495CA215
3F120149EC00C0A2ED7F011780157EA2160303FE130002015B0000903803BE069039FC07
3E0E90397E1E1F1C90391FFC0FF8903907E003E02A267EA430>I<137C48B41470260787
8013F8390E07C001120C121C00381403003015F0EA700F12601507D8E01F14E000C01380
133F0000EB000F16C05B137E151F01FE14805BA2153F000115005BA25D157EA315FE5D14
0100001303EBFC0790387E1FF8EB1FFDEB07E1EB00035DA21407D81F805B003F495AA24A
5A92C7FCEB003E00305B00385B6C485A380E07C06CB4C8FCEA01FC25367EA429>121
D E /Fo 81[65 51[52 2[84 58 65 39 45 52 1[65 58 65 97
32 65 1[32 65 58 1[52 65 52 65 58 12[78 65 2[71 90 84
110 78 2[45 90 1[71 1[84 84 1[84 7[58 58 58 58 58 58
58 58 58 58 2[39 1[66 43[{}47 116.666672 /Times-Bold
rf /Fp 47[83 21[37 10[46 46 3[37 47[37 42 42 60 42 42
23 32 28 42 42 42 42 65 23 42 23 23 42 42 28 37 42 37
42 37 3[28 1[28 1[60 60 78 60 60 51 46 55 1[46 60 60
74 51 60 32 28 60 60 46 51 60 55 55 60 3[47 1[23 23 42
42 42 42 42 42 42 42 42 42 23 21 28 21 47 1[28 28 28
2[42 42 34 34[{}81 83.333336 /Times-Roman rf /Fq 81[37
51[29 33 1[48 33 33 18 26 22 1[33 33 33 52 18 33 18 18
33 33 22 29 33 29 33 29 11[48 41 1[44 1[37 48 48 59 41
3[48 48 2[48 44 1[48 7[33 33 4[33 2[33 1[17 22 17 37
1[22 22 40[{}48 66.666664 /Times-Roman rf /Fr 1 4 df<133013381330A20040
130800F0133C00FC13FC383E31F0380FB7C03801FE00EA0030EA01FE380FB7C0383E31F0
38FC30FC00F0133C0040130800001300A21338133016157C9620>3
D E /Fs 134[33 3[37 21 29 29 2[37 37 54 5[37 21 33 37
2[37 51[25 45[{}14 75.000000 /Times-Italic rf /Ft 59[45
45 70[45 1[45 45 45 45 45 45 45 45 45 45 45 45 45 45
45 45 45 45 45 45 45 45 45 45 45 45 3[45 45 45 45 1[45
45 45 45 45 45 45 45 45 45 45 45 45 2[45 1[45 45 45 45
45 45 45 45 45 45 45 45 45 45 45 45 2[45 45 45 45 45
45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 33[{}84
75.000000 /Courier rf /Fu 47[75 85[33 37 1[54 37 37 21
29 25 1[37 37 37 58 21 37 21 21 37 37 25 33 37 33 37
33 7[54 4[46 42 50 1[42 54 54 1[46 4[54 1[46 54 50 50
54 7[37 5[37 37 37 37 21 19 25 19 42 1[25 25 40[{}51
75.000000 /Times-Roman rf /Fv 139[25 29 33 14[33 42 37
31[54 65[{}7 75.000000 /Times-Bold rf /Fw 136[60 1[60
60 1[60 60 60 60 60 60 4[60 60 1[60 60 60 1[60 32[60
17[60 46[{}17 100.000000 /Courier rf /Fx 134[50 2[50
50 28 39 33 1[50 50 50 78 28 2[28 50 50 33 44 50 44 1[44
9[94 1[72 1[55 66 1[55 1[72 89 61 2[33 72 2[61 1[66 1[72
7[50 1[50 1[50 50 1[50 50 50 1[25 33 25 44[{}42 100.000000
/Times-Roman rf /Fy 1 4 df<130C131EA50060EB018000F0EB03C038FC0C0F00FE13
1F393F8C7F00380FCCFC3803FFF038007F80011EC7FCEB7F803803FFF0380FCCFC383F8C
7F39FE0C1FC000FC130F38F01E030060EB0180000090C7FCA5130C1A1D7C9E23>3
D E /Fz 69[55 11[50 3[55 48[44 44 66 44 50 28 39 39 50
50 50 50 72 28 44 1[28 50 50 28 44 50 44 50 50 9[83 2[55
50 61 72 61 72 66 1[55 1[44 2[72 1[61 72 66 1[61 5[33
3[50 1[50 50 1[50 50 50 28 25 33 25 67 1[33 33 40[{}56
100.000000 /Times-Italic rf /FA 47[141 91[39 55 3[71
2[39 6[63 3[63 12[86 78 94 1[78 1[102 10[94 16[71 71
71 1[35 46[{}17 141.666672 /Times-Roman rf end
%%EndProlog
%%BeginSetup
%%Feature: *Resolution 600dpi
TeXDict begin

%%EndSetup
%%Page: 1 1
1 0 bop 996 139 a FA(PCCTS)36 b(1.20)f(\320)g(Release)f(Notes)681
380 y Fz(T)-9 b(er)l(ence)26 b(J)n(.)f(P)-8 b(arr)1287
344 y Fy(\003)499 496 y Fx(Uni)n(v)o(ersity)22 b(of)j(Minnesota)248
612 y(Army)f(High-Performance)h(Computing)656 728 y(Research)h(Center)
492 845 y(Minneapolis,)d(MN)i(55415)595 961 y Fw([email protected])2467
380 y Fz(Russell)f(W)-9 b(.)24 b(Quong)2169 496 y Fx(School)h(of)g
(Electrical)f(Engineering)2459 612 y(Purdue)h(Uni)n(v)o(ersity)2351
728 y(W)-9 b(.)25 b(Laf)o(ayette,)g(IN)g(47907)2223 845
y Fw([email protected])1507 1193 y Fz(W)-5 b(illiam)23
b(E.)i(Cohen)1208 1310 y Fx(School)g(of)g(Electrical)g(Engineering)1498
1426 y(Purdue)g(Uni)n(v)o(ersity)1391 1542 y(W)-9 b(.)24
b(Laf)o(ayette,)h(IN)g(47907)1232 1658 y Fw([email protected])1529
1851 y Fx(August)f(20,)g(1994)1721 2233 y Fv(Abstract)320
2370 y Fu(This)14 b(document)i(describes)f(the)g(1.20)g(release)f(of)h
(the)g(Purdue)g(Compiler)f(Construction)i(T)-6 b(ool)14
b(Set)g(\(PCCTS\).)e(A)i(number)208 2462 y(of)23 b(ne)n(w)i(features)f
(ha)o(v)o(e)g(been)g(added)h(since)f(1.10)h(\(August)f(1993\),)i(b)o
(ut)d(the)h(main)g(addition)g(is)g(the)g(introduction)h(of)e(C++)208
2553 y(support.)k(The)19 b(C++)g(support)h(will)e(be)h(described)h(in)f
(a)g(forthcoming)h(paper)o(\320it)e(is)h(merely)g(summarized)h(here.)
320 2644 y(PCCTS)11 b(is)g(in)g(the)g(public-domain)g(and)g(can)g(be)g
(obtained)g(at)g Ft(marvin.ecn.purdue.edu)g Fu(in)g Ft(pub/pccts/1.20)p
Fu(.)208 2736 y(Y)-8 b(ou)17 b(can)h(join)g(the)g Ft(pccts-users)d
Fu(mailing)j(list)f(dealing)h(with)f(tools)h(ANTLR,)e(DLG)h(\(and)h
(SORCERER\))e(by)i(emailing)208 2827 y Ft
([email protected])13 b Fu(with)19 b(a)g(body)i(of)e
Ft(subscribe)43 b(pccts-users)17 b Fs(your)o(-name-)208
2918 y(or)o(-r)m(et-addr)p Fu(.)320 3010 y(The)j(authors)h(mak)o(e)g
(no)f(claims)g(that)g(this)g(softw)o(are)g(will)g(do)g(what)g(you)h(w)o
(ant,)g(that)f(this)g(manual)g(is)g(an)o(y)h(good,)g(or)f(that)208
3101 y(the)f(softw)o(are)g(actually)h(w)o(orks\320use)g(PCCTS)e(at)h
(your)h(o)n(wn)g(risk.)27 b(Bug)20 b(reports)g(and/or)g(cheery)g
(reports)f(of)h(its)e(usefulness)208 3192 y(are)g(v)o(ery)i(welcome,)f
(ho)n(we)n(v)o(er)l(.)p 0 4951 1488 4 v 84 5005 a Fr(\003)120
5028 y Fq(P)o(artial)27 b(support)f(for)g(this)g(w)o(ork)g(has)g(come)g
(from)f(the)h(Army)f(Research)j(Of)n(\256ce)e(contract)i(number)e(D)m
(AAL03-89-C-0038)i(with)e(the)g(Army)f(High)0 5107 y(Performance)19
b(Computing)f(Research)i(Center)e(at)g(the)g(U)e(of)h(MN.)1839
5356 y Fp(1)p eop
%%Page: 2 2
2 1 bop 0 -210 a Fo(1)116 b(Intr)n(oduction)0 -24 y Fp(The)18
b(1.20)g(release)h(is)h(primarily)d(to)i(introduce)e(C++)i(support)f
(for)g(PCCTS,)i(b)n(ut)f(includes)f(some)h(nice)f(o)o(v)o(erall)g
(enhancements)0 75 y(and)26 b(important)f(b)n(ug)h(\256x)o(es.)48
b(The)26 b(C++)h(support)e(is)j(only)d(of)h Fn(beta)h
Fp(quality)e(and,)i(as)h(such,)f(can)f(be)h(e)o(xpected)e(to)h(change)f
(in)0 175 y(future)19 b(releases.)125 275 y(W)-7 b(e)19
b(anticipate)e(more)g(frequent)f(releases)i(to)g(PCCTS)h(in)f(the)g
(future)f(rather)g(than)g(big,)h(twice-a-year)m(,)e(releases)j(to)f
(pro)o(vide)0 374 y(f)o(aster)i(b)n(ug)g(\256x)o(es)g(and)g(feature)f
(enhancements.)125 474 y(The)g(main)h(1.20)f(features)h(and)f
(enhancements)f(are)125 657 y Fm(\017)41 b Fp(Added)19
b(\252)p Fl(#tokclass)p Fp(\272)f(\(de\256ne)i(a)g(set)h(of)f(tok)o
(ens\),)f(\252)p Fl(.)p Fp(\272)30 b(\(wildcard)19 b(operator\),)f
(\252)p Fl(\304)p Fp(\272)i(\()p Fn(not)g Fp(operator\).)125
823 y Fm(\017)41 b Fp(Added)19 b(\252)p Fn(T)536 835
y Fk(1)568 823 y Fl(..)p Fn(T)717 835 y Fj(n)762 823
y Fp(\272)h(tok)o(en)g(range)f(operator)-5 b(.)125 989
y Fm(\017)41 b Fp(Added)19 b(\252)p Fl(#tokdefs)p Fp(\272)g(so)h
(programmers)e(can)i(ha)n(v)o(e)f(prede\256ned)f(tok)o(en)i(type)g(v)n
(alues.)125 1155 y Fm(\017)41 b Fp(A)20 b(ne)n(w)-5 b(,)20
b(impro)o(v)o(ed)d Fl(genmk)j Fp(program.)125 1321 y
Fm(\017)41 b Fp(Line)19 b(numbers)g(are)h(no)n(w)g(track)o(ed)f(when)h
(using)f(in\256nite)h(lookahead.)125 1487 y Fm(\017)41
b Fp(Added)19 b(C++)h(support)f(for)h(ANTLR)g(and)g(DLG)g(output.)125
1653 y Fm(\017)41 b Fp(Added)19 b(\252)p Fl(-o)49 b Fn(dir)r
Fp(\272)21 b(option)e(to)h(specify)g(where)g(all)g(output)f(should)g
(go.)125 1819 y Fm(\017)41 b Fp(A)20 b(fe)n(w)f(nasty)h(code)f
(generation)f(b)n(ugs)h(were)h(\256x)o(ed)f(as)h(well)g(as)h(a)f(fe)n
(w)g(b)n(ugs)f(relating)g(to)h(semantic)f(predicate)g(hoisting.)0
2099 y Fo(2)116 b(T)-11 b(ok)o(en)28 b(Classes)0 2285
y Fp(A)23 b(tok)o(en)e(class)i(is)g(set)g(of)f(tok)o(ens)f(that)h(can)g
(be)g(referenced)e(as)j(one)e(entity;)i(the)o(y)e(are)h(equi)n(v)n
(alent)f(to)h(a)g(subrule)f(consisting)h(of)0 2384 y(its)f(member)e
(tok)o(ens)h(separated)f(by)h(\252)p Fl(|)p Fp(\272s.)29
b(The)20 b(basic)h(syntax)e(is:)125 2567 y Ft(#tokclass)43
b Fi(tcl)q(ass)h Fh(f)h Fi(T)943 2575 y Fg(1)972 2567
y Fi(::T)1059 2575 y Ff(n)1147 2567 y Fh(g)0 2766 y Fp(where)28
b Fn(T)281 2778 y Fj(i)337 2766 y Fp(is)h(a)g(tok)o(en)f(reference)e
(\(either)i(a)h(tok)o(en)f(label)g(or)g(a)h(re)o(gular)e(e)o(xpression)
f(in)j(double-quotes\))c(or)j(a)h(tok)o(en)f(class)0
2866 y(reference;)19 b(tok)o(en)g(classes)i(may)f(ha)n(v)o(e)g(o)o(v)o
(erlapping)c(tok)o(ens.)125 2965 y(The)21 b(dif)n(ference)e(between)i
(a)h(tok)o(en)f(class)h(and)f(a)h(sub)n(ule)f(lies)i(in)e(ef)n
(\256cienc)o(y)-5 b(.)32 b(A)22 b(reference)d(to)j(a)g(tok)o(en)f
(class)h(is)h(a)f(simple)0 3065 y(set)h(membership)d(test)j(during)e
(parser)g(e)o(x)o(ecution)f(rather)h(than)h(a)g(linear)g(search)g(of)g
(the)g(tok)o(ens)f(in)i(a)f(subrule.)34 b(Furthermore,)0
3165 y(the)21 b(set)h(membership)d(will)j(be)f(much)f(smaller)h(than)g
(a)h(series)f(of)g Fl(if)p Fp(-statements)g(in)g(a)g(recursi)n(v)o
(e-descent)e(parser)-5 b(.)31 b(Note)21 b(that)0 3264
y(automaton-based)c(parsers)i(\(both)g Fn(LALR)i Fp(and)e
Fn(LL)p Fp(\))h(automatically)e(perform)g(this)j(type)e(of)h(set)h
(membership)d(\(speci\256cally)-5 b(,)0 3364 y(a)21 b(table)f
(lookup\),)e(b)n(ut)i(lack)g(the)g(\257e)o(xibility)g(of)f(recursi)n(v)
o(e-descent)f(parsers)i(such)g(as)g(those)g(constructed)f(by)h(ANTLR.)
125 3464 y(Figure)33 b(1)h(is)i(a)e(sample)g(ANTLR)h(1.20)e(program)f
(that)i(recognizes)f(a)i(simple)f(mythical)f(assembly)h(language)e
(with)0 3563 y(statements)20 b(such)g(as:)125 3746 y
Ft(#segment)43 b(data)125 3837 y(a)89 b(ds)45 b(42)125
3928 y(b)89 b(ds)45 b(13)125 4020 y(#segment)e(code)259
4111 y(load)h(r1,)h(a)259 4202 y(load)f(r2,)h(b)259 4294
y(add)89 b(r1,r2,r3)259 4385 y(print)44 b(r3)0 4584 y
Fp(Referencing)18 b(tok)o(en)i(class)h Fl(REGISTER)e
Fp(is)i(the)g(same)f(as)h(referencing)125 4767 y Ft(\()44
b("r0")g(|)h("r1")f(|)h("r2")f(|)h("r3")f(\))125 4966
y Fp(A)27 b(wildcard)f(tok)o(en)g(is)i(also)f(a)n(v)n(ailable)f(that)h
(refers)f(to)h(an)g(implied)f(tok)o(en)g(class)i(consisting)e(of)h(all)
g(tok)o(ens)g(referenced)0 5066 y(within)20 b(a)h(grammar)-5
b(.)27 b(It)21 b(can)f(be)g(used)g(to)g(ignore)f(pieces)h(of)g(the)h
(input:)1839 5356 y(2)p eop
%%Page: 3 3
3 2 bop 312 1028 a Ft(#header)44 b(<<#include)f("charbuf.h">>)312
1211 y(< Fh(g)p Ft(>>)312 1394 y(#tokclass)h(OPCODE)133 b Fh(f)45
b Ft("add")f("store")g("load")g("call")g("ret")g("print")f
Fh(g)312 1485 y Ft(#tokclass)h(REGISTER)f Fh(f)i Ft("r0")g("r1")f("r2")
g("r3")g Fh(g)312 1668 y Ft(#token)g("[\\)h(\\t]+")178
b(<>)312 1759 y(#token)44 b("\\n")403 b(< b(zzline++;>>)312 1942 y(prog:)134 b("#segment")43 b("data")h
(\(data\)*)671 2033 y("#segment")f("code")h(\(stat\)*)492
2124 y(;)312 2307 y(stat:)134 b(OPCODE)44 b(operands)492
2398 y(;)312 2581 y(operands)492 2672 y(:)134 b(ID)492
2763 y(|)g(REGISTER)492 2855 y(|)g(REGISTER)44 b(",")g(NUM)492
2946 y(|)134 b(REGISTER)44 b(",")g(REGISTER)f(",")i(REGISTER)492
3037 y(;)312 3220 y(data:)134 b(ID)45 b("ds")f(NUM)492
3311 y(;)312 3494 y(#token)g(NUM)224 b("[0-9]+")312 3585
y(#token)44 b(ID)269 b("[a-zA-Z]+")819 3859 y Fp(Figure)19
b(1:)30 b(ANTLR)20 b(Recognizer)f(for)h(Simple)g(Assembly)g(Language)
1839 5356 y(3)p eop
%%Page: 4 4
4 3 bop 125 -201 a Ft(ig)89 b(:)134 b("begin)p Fh(f)p
Ft(ignore)p Fh(g)p Ft(")483 -110 y(.)483 -19 y("end)p
Fh(f)p Ft(ignore)p Fh(g)p Ft(")304 72 y(;)0 263 y Fp(which)24
b(matches)h(an)o(y)f(single)h(tok)o(en)f(between)g Fl(begin)p
Fm(f)p Fl(ignore)p Fm(g)f Fp(and)h Fl(end)p Fm(f)p Fl(ignore)p
Fm(g)p Fp(,)g(or)g(the)h(wildcard)f(can)h(be)g(used)0
363 y(for)20 b(error)f(detection:)125 464 y Ft(if)89
b(:)134 b("if")44 b(expr)h("then")e(stat)304 555 y(|)134
b(.)314 b(<>)304
646 y(;)125 837 y Fp(The)19 b(programmer)f(should)h(be)h(careful)f(not)
h(to)g(do)g(things)g(lik)o(e)g(this:)125 955 y Ft(ig)89
b(:)134 b("begin)p Fh(f)p Ft(ignore)p Fh(g)p Ft(")483
1046 y(\()45 b(.)g(\)*)483 1138 y("end)p Fh(f)p Ft(ignore)p
Fh(g)p Ft(")304 1229 y(;)0 1420 y Fp(because)18 b(the)g(loop)f
(generated)g(for)g(the)h Fl(\()50 b(.)99 b(\)*)19 b Fp(block)e(will)i
(ne)n(v)o(er)e(terminate\320)p Fl("end)p Fm(f)p Fl(ignore)p
Fm(g)p Fl(")d Fp(is)19 b(also)g(matched)e(by)0 1520 y(the)j(wildcard.)
125 1619 y(Rather)28 b(than)g(using)g(the)h(wildcard)f(to)g(match)h
(lar)o(ge)e(tok)o(en)h(classes,)k(it)d(is)h(often)d(best)i(to)g(use)g
(the)g Fn(not)g Fp(operator)-5 b(.)53 b(F)o(or)0 1719
y(e)o(xample,)125 1836 y Ft(ig)89 b(:)134 b("begin)p
Fh(f)p Ft(ignore)p Fh(g)p Ft(")483 1928 y(\()45 b(\304"end)p
Fh(f)p Ft(ignore)p Fh(g)p Ft(")e(\)*)483 2019 y("end)p
Fh(f)p Ft(ignore)p Fh(g)p Ft(")304 2110 y(;)0 2301 y
Fp(where)20 b Fl(\304)g Fp(is)h(the)f Fn(not)h Fp(operator)-5
b(.)28 b(The)20 b Fl(if)g Fp(e)o(xample)f(could)g(be)h(re)n(written)g
(as:)125 2419 y Ft(if)89 b(:)134 b("if")44 b(expr)h("then")e(stat)304
2510 y(|)179 b("if")g(< (if-statement"\);>>)304 2602 y(;)125 2792 y Fp(The)22
b Fn(not)h Fp(operator)e(may)h(be)g(applied)g(to)g(tok)o(en)g(class)h
(references)f(and)f(tok)o(en)h(references)f(only)h(\(it)h(may)f(not)g
(be)h(applied)0 2892 y(to)d(subrules,)g(for)f(e)o(xample\).)125
2992 y(The)g(wildcard)h(operator)e(and)i(the)g Fn(not)h
Fp(operator)d(ne)n(v)o(er)h(result)h(in)g(a)h(set)g(containing)d(the)j
(end-of-\256le)d(tok)o(en)h(type.)125 3091 y(One)g(\256nal)h(tok)o(en)g
(operator)e(has)i(been)f(introduced\320the)e(range)i(operator)f(of)i
(the)f(form)g Fn(T)2765 3103 y Fk(1)2798 3091 y Fl(..)p
Fn(T)2947 3103 y Fj(n)2991 3091 y Fp(.)30 b(The)20 b(v)n(aue)f(of)g
Fn(T)3505 3103 y Fk(1)3559 3091 y Fp(must)0 3191 y(be)i(less)h(than)e
Fn(T)459 3203 y Fj(n)526 3191 y Fp(and)g(the)h(v)n(alues)g(in)g
(between)f(should)g(be)h(v)n(alid)f(tok)o(en)h(types.)31
b(In)21 b(general,)e(this)j(feature)e(should)g(be)h(used)f(in)0
3291 y(conjunction)e(with)i Fl(#tokdefs)f Fp(so)i(that)f(the)g
(programmer)e(controls)h(the)h(tok)o(en)f(type)h(v)n(alues.)125
3390 y(An)g(e)o(xample)f(range)g(operator)f(is:)125 3508
y Ft(#tokdefs)43 b("mytokens.h")125 3691 y(a)h(:)h(OpStart)f(..)g
(OpEnd)g(operand)g(;)125 3882 y Fp(This)20 b(feature)f(is)i(perhaps)e
(unneeded)f(due)i(to)g(the)g(more)g(po)n(werful)e(tok)o(en)h(class)j
(directi)n(v)o(e.)0 4162 y Fo(3)116 b(New)29 b(Dir)n(ecti)o(v)o(e)e
Fe(#tokdefs)0 4347 y Fp(It)19 b(is)h(often)e(the)h(case)g(that)g(the)g
(user)g(is)h(interested)e(in)h(specifying)e(the)i(tok)o(en)f(types)h
(rather)f(than)g(ha)n(ving)g(ANTLR)h(generate)f(its)0
4447 y(o)n(wn;)d(typically)-5 b(,)12 b(this)h(situation)g(arises)g
(when)g(the)g(user)g(w)o(ants)g(to)g(link)g(an)g(ANTLR-generated)g
(parser)g(with)g(a)g(non)o(-DL)o(G-b)o(ased)0 4547 y(scanner)-5
b(.)29 b(T)-7 b(o)20 b(get)g(ANTLR)h(to)f(use)h(pre-assigned)d(tok)o
(en)h(types,)h(specify)125 4729 y Ft(#tokdefs)43 b(")p
Fi(my)s(tok)r(ens:h)p Ft(")0 4928 y Fp(before)24 b(an)o(y)h(tok)o(en)g
(de\256nitions)g(where)g Fn(my)s(tok)s(ens:h)h Fp(is)g(a)h(\256le)f
(with)g(only)f(a)h(list)h(of)f Fl(#define)p Fp(s)f(or)g(an)h
Fl(enum)g Fp(de\256nition)0 5028 y(with)20 b(optional)f(comments.)1839
5356 y(4)p eop
%%Page: 5 5
5 4 bop 125 -210 a Fp(When)25 b(this)h(directi)n(v)o(e)e(is)i(used,)g
(ne)n(w)g(tok)o(en)e(label)h(de\256nitions)g(will)h(not)f(be)h(allo)n
(wed)e(\(either)h(e)o(xplicit)g(de\256nitions)f(lik)o(e)0
-110 y Fl(#token)49 b(A)29 b Fp(or)f(implicit)g(de\256nitions)g(such)g
(as)i(a)f(reference)d(to)j(a)g(tok)o(en)f(label)g(in)h(a)g(rule\).)54
b(Ho)n(we)n(v)o(er)m(,)28 b(the)h(programmer)0 -11 y(may)24
b(attach)g(re)o(gular)e(e)o(xpressions)h(and)h(le)o(xical)g(actions)g
(to)g(the)g(tok)o(en)f(labels)i(de\256ned)e(in)h Fn(my)s(tok)s(ens:h)p
Fp(.)41 b(F)o(or)24 b(e)o(xample,)f(if)0 89 y Fn(my)s(tok)s(ens:h)d
Fp(contained:)125 272 y Ft(#define)43 b(A)i(2)0 471 y
Fp(and)20 b Fl(t.g)g Fp(contained:)125 584 y Ft(#tokdefs)43
b("mytokens.h")125 766 y(#token)g(A)i("blah")125 949
y(a)f(:)h(A)g(B;)0 1140 y Fp(ANTLR)20 b(w)o(ould)g(report)f(the)h
(follo)n(wing)f(error)g(message:)125 1258 y Ft(Antlr)44
b(parser)f(generator)133 b(Version)44 b(1.20)134 b(1989-1994)125
1349 y(t.g,)44 b(line)g(5:)g(error:)g(implicit)g(token)g(definition)f
(not)h(allowed)g(with)g(#tokdefs)0 1720 y Fo(4)116 b(New)29
b Fe(genmk)0 1906 y Fp(The)24 b Fl(genmk)g Fp(program)e(has)j(been)e
(substantially)h(upgraded.)39 b(It)24 b(no)n(w)g(generates)f
Fl(clean)h Fp(and)g Fl(scrub)g Fp(tar)o(gets,)h(generates)0
2006 y(more)13 b(accurate)h(\256le)h(dependencies)d(and,)i(most)g
(importantly)-5 b(,)13 b(generates)g(mak)o(e\256les)i(for)e(PCCTS)j
(C++)e(mode.)27 b(The)14 b(command)0 2105 y(line)20 b(options)g(are)g
(de\256ned)f(as)i(follo)n(ws:)125 2288 y Fm(\017)41 b
Fl(-CC)p Fp(:)20 b(Generate)f(C++)i(output)e(from)g(both)g(ANTLR)i(and)
f(DLG.)125 2454 y Fm(\017)41 b Fl(-class)48 b Fn(cl)r
Fp(:)32 b(Name)21 b(of)g(the)g(grammar)f(class)i(de\256ned)e(in)i(the)f
(grammar)f(\256les.)33 b(This)22 b(is)g(only)e(a)i(v)n(alid)f(option)f
(if)i Fl(-CC)208 2554 y Fp(w)o(as)f(seen)f(before)f(it)i(on)e(the)i
(command)d(line.)125 2720 y Fm(\017)41 b Fl(-dlg-class)48
b Fn(cl)r Fp(:)33 b(Name)23 b(of)f(DLG)g(le)o(x)o(er)g(class)h(\(def)o
(ault)e(is)j Fl(DLGLexer)p Fp(\).)34 b(This)23 b(is)g(only)f(a)h(v)n
(alid)f(option)f(if)i Fl(-CC)208 2819 y Fp(w)o(as)17
b(seen)f(before)f(it)i(on)f(the)g(command)e(line.)28
b(The)16 b(option)f(is)i(placed)f(on)f(the)i(DLG)f(command)e(line)j(as)
g(the)f Fl(-cl)g Fp(option.)125 2985 y Fm(\017)41 b Fl(-header)48
b Fn(h)p Fp(:)30 b(Name)20 b(of)g(the)g(ANTLR)h(standard)e(header)g
(information)e(\(def)o(ault=no)h(\256le\).)125 3151 y
Fm(\017)41 b Fl(-o)49 b Fn(dir)r Fp(:)44 b(Directory)25
b(where)h(output)g(\256les)h(should)f(go)g(\(def)o(ault="."\).)47
b(This)27 b(is)g(v)o(ery)f(nice)g(for)g(k)o(eeping)g(the)g(source)208
3251 y(directory)18 b(clear)i(of)g(ANTLR)g(and)g(DLG)g(spa)o(wn.)125
3417 y Fm(\017)41 b Fl(-project)48 b Fn(pr)r(oj)5 b Fp(:)31
b(Name)20 b(of)g(e)o(x)o(ecutable)e(to)i(create)g(\(def)o(ault=)p
Fl(t)p Fp(\).)125 3583 y Fm(\017)41 b Fl(-token-types)47
b Fn(t)p Fp(:)42 b(T)-7 b(ok)o(en)25 b(types)h(are)h(in)f(this)h
(\256le;)i(this)e(option)e(implies)h(that)g(the)h(normal)e
Fl(tokens.h)g Fp(is)i(not)208 3683 y(to)e(be)g(generated)f(or)h(used)g
(for)g(tok)o(en)g(type)g(de\256nitions)f(\(in)h(C)i(output)d(mode,)h
(ho)n(we)n(v)o(er)m(,)g Fl(tokens.h)f Fp(may)h(still)i(be)208
3782 y(required)18 b(because)h(we)i(ha)n(v)o(e)f(jammed)f(some)h
(function)e(prototypes)h(in)h(the)g(\256le)h(as)g(well\).)125
3948 y Fm(\017)41 b Fl(-trees)p Fp(:)i(Generate)27 b(ASTs;)k(basically)
d(turns)f(on)g(the)g Fl(-gt)h Fp(option)e(of)h(ANTLR,)g(b)n(ut)h(also)g
(results)f(in)h(a)g(tar)o(get)e(to)208 4048 y(compile)19
b(the)h(AST)h(support)d(\256le)j(\(in)f(C++)h(mode)e(only\).)125
4214 y Fm(\017)41 b Fl(-user-lexer)p Fp(:)25 b(Do)17
b(not)e(create)h(a)h(DLG-based)d(scanner)-5 b(.)28 b(T)l(urns)15
b(on)h(ANTLR)g Fl(-gx)g Fp(command)e(line)i(option.)27
b(T)l(urns)208 4314 y(of)n(f)19 b(generation)f(of)i(tar)o(gets)g(for)f
(DLG)i(scanners.)125 4496 y(F)o(or)26 b(e)o(xample,)h(to)h(create)f(a)g
(mak)o(e\256le)g(for)f(a)i(grammar)d(in)i Fl(test.g)g
Fp(with)g(project)f(name)h Fl(t)g Fp(that)h(uses)f(a)h(DLG-based)0
4596 y(scanner)m(,)19 b(use:)125 4779 y Ft(genmk)44 b(-project)f(t)i
(test.g)0 4978 y Fp(T)-7 b(o)20 b(specify)g(multiple)f(\256les)j
(\(comprising)c(the)i(same)g(grammar\))e(use:)1839 5356
y(5)p eop
%%Page: 6 6
6 5 bop 125 -210 a Ft(genmk)44 b(-project)f(t)i(test.g)e(test2.g)h
(test3.g)0 -11 y Fp(T)-7 b(o)20 b(create)g(a)h(basic)f(C++)h(mode)e
(mak)o(e\256le)h(for)g(a)g(grammar)f(class)i Fl(Expr)f
Fp(in)g(\256le)h Fl(test.g)f Fp(and)f(project)h Fl(t)g
Fp(use:)125 172 y Ft(genmk)44 b(-project)f(t)i(-CC)f(-class)g(Expr)g
(test.g)0 371 y Fp(T)-7 b(o)20 b(rename)f(the)i(def)o(ault)e
Fl(DLGLexer)g Fp(class)j(and)d(\(associated)h(\256les\))h(to)f
Fl(Scanner)f Fp(for)h(DLG,)g(use:)125 554 y Ft(genmk)44
b(-project)f(t)i(-CC)f(-class)g(Expr)g(-dlg-class)f(Scanner)h(test.g)0
753 y Fp(T)-7 b(o)20 b(create)g(a)h(mak)o(e\256le)f(for)f(a)i(C++)g
(parser)e(that)i(uses)f(a)h(non-DLG-based)c(scanner)m(,)i(use:)125
936 y Ft(genmk)44 b(-project)f(t)i(-CC)f(-class)g(Expr)g(-user-lexer)f
(test.g)0 1135 y Fp(T)-7 b(o)19 b(create)g(a)g(mak)o(e\256le)g(that)g
(uses)g(a)g(hand-b)n(uilt)e(parser)i(for)f(a)h(grammar)f(that)h(uses)g
(\252)p Fl(#tokdefs)48 b("mytokens.h")p Fp(\272,)17 b(use:)125
1318 y Ft(genmk)44 b(-project)f(t)i(-CC)f(-class)g(Expr)g(-user-lexer)f
(-token-types)g(mytokens.h)g(test.g)0 1698 y Fo(5)116
b(Line)28 b(Numbers)g(and)g(In\256nite)g(Lookahead)0
1883 y Fp(Because)f(ANTLR-generated)d(parsers)i(that)g(use)h
(in\256nite)f(lookahead)e(\(i.e.,)j(syntactic)f(predicates\))g(scan)g
(the)g(entire)g(input)0 1983 y(stream)16 b(before)e(actual)h(parsing)g
(be)o(gins,)g(the)h(normal)e(line)i(number)e(v)n(ariable)h
Fl(zzline)g Fp(is)h(meaningless\320it)f(al)o(w)o(ays)h(\252points\272)0
2082 y(to)j(the)g(last)g(line)g(in)g(the)g(\256le.)29
b(T)-7 b(o)19 b(o)o(v)o(ercome)d(this,)k(we)f(ha)n(v)o(e)f(added)f(a)j
(ne)n(w)e(macro)g(\(member)f(function)g Fl(inf)p 3169
2082 25 4 v 29 w(line\(int)49 b Fn(i)p Fl(\))0 2182 y
Fp(in)20 b(C++)h(mode\):)125 2365 y Ft(ZZINF)p 354 2365
23 4 v 26 w(LINE\()p Fi(i)p Ft(\))0 2564 y Fp(for)28
b Fn(i)35 b Fm(\025)f Fp(1.)55 b Fl(ZZINF)p 662 2564
25 4 v 29 w(LINE\(1\))28 b Fp(is)i(the)e(line)h(number)e(of)i(the)f
(tok)o(en)g(about)g(to)h(be)g(matched.)53 b(The)29 b(follo)n(wing)e(e)o
(xample)0 2664 y(illustrates)21 b(the)f(use)g(of)g(the)g(ne)n(w)g
(macro:)125 2764 y Ft(#header)43 b(<<#include)g("charbuf.h">>)125
2947 y(< Fh(g)p Ft(>>)125 3130 y(#token)f("[)p Fh(n)i Ft(\\t]+")358
b(<>)125 3221 y(#token)43 b("\\n")582 b(< b(zzline++;>>)125 3312 y(#token)g(Equal)h("=")125 3404
y(#token)f(Semi)89 b(";")125 3586 y(stat:)133 b(\(list)44
b(Equal\)?)g(list)g(Equal)g(list)g(";")134 b(< b(=)h(list\\n"\);>>)304 3678 y(|)134 b(list)44 b(";")1255
b(<>)304 3769 y(;)125 3951 y(list:)133
b(")p Fh(n)p Ft(\(")45 b(elem)f(\(",")g(elem\)*)g(")p
Fh(n)p Ft(\)")304 4043 y(;)125 4225 y(elem:)133 b(< b(line=0;>>)483 4317 y(< 23 4 v 26 w(LINE\(1\);>>)e(WORD)h(< (\045d\\n",)g(line\);>>)304 4408 y(|)134 b(< b(=)h(ZZINF)p 1116 4408 V 26 w(LINE\(1\);>>)e(INT)h(< (at)h(line)h(\045d\\n",)e(line\);>>)304 4499 y(;)125
4682 y(#token)g(WORD)i("[a-zA-Z]+")125 4773 y(#token)e(INT)90
b("[0-9]+")125 4964 y Fp(The)12 b(line)g(number)g(recording)g(befo)o
(re)g(the)g(reco)o(gn)o(ition)f(of)h Fl(WORD)g Fp(an)o(d)g
Fl(INT)g Fp(in)g Fl(elem)g Fp(is)g(don)o(e)g(becau)o(se)g
Fl(ZZINF)p 3382 4964 25 4 v 24 w(LINE\(1\))0 5064 y Fp(refers)20
b(to)g(the)g(line)h(number)d(for)i(the)g(tok)o(en)f(about)g(to)i(be)f
(matched.)1839 5356 y(6)p eop
%%Page: 7 7
7 6 bop 27 -293 a
28943975 3025961 3025960 35259023 31969935 38284984 startTexFig
27 -293 a
%%BeginDocument: blk.ps
1 setlinejoin
/M { moveto } bind def /S { show } bind def
/R { rmoveto } bind def /L { lineto } bind def
/B { newpath 0 0 M 0 1 L 1 1 L 1 0 L closepath } bind def
/CS { closepath stroke } bind def
/S {
/fixwidth exch def
dup length /nchars exch def
dup stringwidth pop
fixwidth exch sub nchars div
exch 0 exch ashow
} def
/bwproc {
rgbproc
dup length 3 idiv string 0 3 0
5 -1 roll {
add 2 1 roll 1 sub dup 0 eq
{ pop 3 idiv 3 -1 roll dup 4 -1 roll dup
3 1 roll 5 -1 roll put 1 add 3 0 }
{ 2 1 roll } ifelse
} forall
pop pop pop
} def
systemdict /colorimage known not {
/colorimage {
pop
pop
/rgbproc exch def
{ bwproc } image
} def
} if
1 1 scale
0 setlinewidth
/drawtri {
/y3 exch def
/x3 exch def
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
0 setgray
newpath
x1 y1 moveto
x2 y2 lineto
x3 y3 lineto
closepath
stroke
} bind def
/filltri {
/y3 exch def
/x3 exch def
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
newpath
x1 y1 moveto
x2 y2 lineto
x3 y3 lineto
closepath
fill
} bind def
/cliptri {
/y3 exch def
/x3 exch def
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
0 setgray
newpath
x1 y1 moveto
x2 y2 lineto
x3 y3 lineto
closepath
clip
} bind def
/imgscanrgb {
gsave
translate
/scandy exch def
/scandx exch def
/istr scandx 3 mul string def
scandx scandy scale
scandx scandy 8
[scandx 0 0 scandy neg 0 scandy]
{currentfile istr readhexstring pop}
false 3
colorimage
grestore
} bind def
/imgscanbw {
gsave
translate
/scandy exch def
/scandx exch def
/istr scandx string def
scandx scandy scale
scandx scandy 8
[scandx 0 0 scandy neg 0 scandy]
{currentfile istr readhexstring pop}
image
grestore
} bind def
/showcaseisoencoding [
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /minus /period /slash
/zero /one /two /three /four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
/at /A /B /C /D /E /F /G
/H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W
/X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c /d /e /f /g
/h /i /j /k /l /m /n /o
/p /q /r /s /t /u /v /w
/x /y /z /braceleft
/bar /braceright /asciitilde /guilsinglright
/fraction /florin /quotesingle /quotedblleft
/guilsinglleft /fi /fl /endash
/dagger /daggerdbl /bullet /quotesinglbase
/quotedblbase /quotedblright /ellipsis /trademark
/dotlessi /grave /acute /circumflex
/tilde /macron /breve /dotaccent
/dieresis /perthousand /ring /cedilla
/Ydieresis /hungarumlaut /ogonek /caron
/emdash /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis ] def
/showcasedingbatencoding [
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /a1 /a2 /a202 /a3 /a4 /a5 /a119 /a118 /a117
/a11 /a12 /a13 /a14 /a15 /a16 /a105 /a17 /a18 /a19
/a20 /a21 /a22 /a23 /a24 /a25 /a26 /a27 /a28 /a6 /a7
/a8 /a9 /a10 /a29
/a30 /a31 /a32 /a33 /a34 /a35 /a36 /a37 /a38 /a39
/a40 /a41 /a42 /a43 /a44 /a45 /a46 /a47 /a48 /a49
/a50 /a51 /a52 /a53 /a54 /a55 /a56 /a57 /a58 /a59
/a60 /a61 /a62 /a63 /a64 /a65 /a66 /a67 /a68 /a69
/a70 /a71 /a72 /a73 /a74 /a203 /a75 /a204 /a76 /a77 /a78
/a79 /a81 /a82 /a83 /a84 /a97 /a98 /a99 /a100 /.notdef
/a205 /a85 /a206 /a86 /a87 /a88 /a89 /a90 /a91 /a92 /a93
/a94 /a95 /a96
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /a101 /a102 /a103 /a104 /a106 /a107 /a108
/a112 /a111 /a110 /a109
/a120 /a121 /a122 /a123 /a124 /a125 /a126 /a127 /a128 /a129
/a130 /a131 /a132 /a133 /a134 /a135 /a136 /a137 /a138 /a139
/a140 /a141 /a142 /a143 /a144 /a145 /a146 /a147 /a148 /a149
/a150 /a151 /a152 /a153 /a154 /a155 /a156 /a157 /a158 /a159
/a160 /a161 /a163 /a164 /a196 /a165 /a192 /a166 /a167 /a168
/a169 /a170 /a171 /a172 /a173 /a162 /a174 /a175 /a176 /a177
/a178 /a179 /a193 /a180 /a199 /a181 /a200 /a182 /.notdef
/a201 /a183 /a184 /a197 /a185 /a194 /a198 /a186 /a195 /a187
/a188 /a189 /a190 /a191 /.notdef
] def
/Courier findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-SHOWISO exch definefont pop
/Times-Roman findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Times-Roman-SHOWISO exch definefont pop
/newfont 10 dict def
newfont begin

/FontType 3 def
/FontMatrix [1 0 0 1 0 0] def
/FontBBox [0 0 1 1] def
/Encoding 256 array def
0 1 255 {Encoding exch /.notdef put} for

/CharProcs 1 dict def
CharProcs begin
/.notdef {} def

end

/BuildChar {
1 0
0 0 1 1
setcachedevice
exch begin
Encoding exch get
CharProcs exch get
end
exec
} def
end
/PatternFont newfont definefont pop

/#copies 1 def
gsave
gsave
matrix currentmatrix
[73 0 0 -39 361 576] concat
B
setmatrix
0 0 0 setrgbcolor
1.000000 setlinewidth
gsave stroke grestore
grestore
gsave
0 0 0 setrgbcolor
1.000000 setlinewidth
newpath
141 575 M
214 575 L
214 536 L
141 536 L
closepath
stroke
grestore
gsave
gsave
matrix currentmatrix
[1 0 0 1 154 552] concat
newpath
0 0 M 0 13 L 50 13 L 50 0 L
closepath setmatrix
0 0 0 setrgbcolor
grestore
newpath
152 550 M 152 567 L 206 567 L 206 550 L
closepath clip newpath
0 0 0 setrgbcolor
matrix currentmatrix
[1 0 0 1 154 552] concat
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
0 1.81818 M (DLGLexer) 48 S
setmatrix
grestore
gsave
gsave
matrix currentmatrix
[1 0 0 1 378 552] concat
newpath
0 0 M 0 13 L 38 13 L 38 0 L
closepath setmatrix
0 0 0 setrgbcolor
grestore
newpath
376 550 M 376 567 L 418 567 L 418 550 L
closepath clip newpath
0 0 0 setrgbcolor
matrix currentmatrix
[1 0 0 1 378 552] concat
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
0 1.81818 M (Parser) 36 S
setmatrix
grestore
gsave
gsave
matrix currentmatrix
[1 0 0 1 46 564] concat
newpath
0 0 M 0 13 L 86 13 L 86 0 L
closepath setmatrix
0 0 0 setrgbcolor
grestore
newpath
44 562 M 44 579 L 134 579 L 134 562 L
closepath clip newpath
0 0 0 setrgbcolor
matrix currentmatrix
[1 0 0 1 46 564] concat
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
0 1.81818 M (DLGInputStream) 84 S
setmatrix
grestore
gsave
gsave
matrix currentmatrix
[1 0 0 1 240 568.5] concat
newpath
0 0 M 0 13 L 98 13 L 98 0 L
closepath setmatrix
0 0 0 setrgbcolor
grestore
newpath
238 566.5 M 238 583.5 L 340 583.5 L 340 566.5 L
closepath clip newpath
0 0 0 setrgbcolor
matrix currentmatrix
[1 0 0 1 240 568.5] concat
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
0 1.81818 M (ANTLRTokenBuffer) 96 S
setmatrix
grestore
gsave
gsave
matrix currentmatrix
[1 0 0 1 446 564] concat
newpath
0 0 M 0 17 L 32.672 17 L 32.672 0 L
closepath setmatrix
0 0 0 setrgbcolor
grestore
newpath
444 562 M 444 583 L 480.672 583 L 480.672 562 L
closepath clip newpath
0 0 0 setrgbcolor
matrix currentmatrix
[1 0 0 1 446 564] concat
/Times-Roman-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
0 2.4 M (output) 30.672 S
setmatrix
grestore
gsave
matrix currentmatrix
[72 0 0 -18 252 567] concat
B
setmatrix
0 0 0 setrgbcolor
1.000000 setlinewidth
gsave stroke grestore
grestore
gsave
0 0 0 setrgbcolor
gsave
0 setlinejoin
361 558 translate
0 rotate
1.1 1.1 scale
newpath 0 0 M -20 -5 L -20 5 L closepath fill
grestore
1.000000 setlinewidth
newpath
324 558 M
342 558 L
stroke
grestore
gsave
0 0 0 setrgbcolor
gsave
0 setlinejoin
253 558 translate
0 rotate
1.1 1.1 scale
newpath 0 0 M -20 -5 L -20 5 L closepath fill
grestore
1.000000 setlinewidth
newpath
216 558 M
234 558 L
stroke
grestore
gsave
0 0 0 setrgbcolor
gsave
0 setlinejoin
145 558 translate
0 rotate
1.1 1.1 scale
newpath 0 0 M -20 -5 L -20 5 L closepath fill
grestore
1.000000 setlinewidth
newpath
54 558 M
126 558 L
stroke
grestore
gsave
0 0 0 setrgbcolor
gsave
0 setlinejoin
487 558 translate
0 rotate
1.1 1.1 scale
newpath 0 0 M -20 -5 L -20 5 L closepath fill
grestore
1.000000 setlinewidth
newpath
432 558 M
468 558 L
stroke
grestore
grestore
showpage
%%EndDocument

endTexFig
1083 273 a Fp(Figure)19 b(2:)30 b(PCCTS)21 b(C++)g(P)o(arsing)f(Block)
g(Diagram)125 540 y(This)g(feature)f(does)h(not)g(w)o(ork)f(correctly)g
(in)i(C++)f(mode)g(when)f Fl(-gk)h Fp(ANTLR)h(option)e(is)i(used.)0
821 y Fo(6)116 b(C++)30 b(P)o(arser)e(Or)o(ganization)0
1006 y Fp([)p Fz(The)h(C++)h(Output)e(of)g(PCCTS)i(1.20)f(is)f
(consider)l(ed)g(only)h(\252beta\272)g(quality)-5 b(.)47
b(Expect)29 b(a)g(futur)l(e)f(r)l(elease)0 1106 y(to)c(r)l(equir)l(e)h
(c)o(hang)o(es)f(in)h(most)f(par)o(ser)o(s)f(written)i(assuming)e(ver)o
(sion)h(1.20)g(C++)i(output.)p Fp(])125 1205 y([)p Fz(Also)40
b(note)h(that)g(the)g(C++)i(output)d(has)i(only)f(been)h(tested)f
(under)g(g++)h(2.5.7)f(and)g(cannot)g(be)0 1305 y(guar)o(anteed)28
b(to)i(compile)g(under)f(any)h(other)g(C++)h(compiler)o(s;)h(indeed,)f
(g++)f(2.4.5)f(will)h(not)g(compile)0 1405 y(our)24 b(test)h(cases.)p
Fp(])125 1504 y(Computer)e(language)h(recognition)f(is)j(generally)e
(vie)n(wed)h(conceptually)e(as)j(a)g(parser)e(that)i(parses)f(tok)o
(ens)g(tak)o(en)g(from)0 1604 y(a)e(tok)o(en)g(stream)g(\256lled)g(by)f
(a)i(le)o(xical)f(analyzer)e(\(scanner\))h(that)h(tak)o(es)g
(characters)f(from)g(an)h(input)f(stream.)38 b(In)23
b(practice,)g(the)0 1703 y(tok)o(en)d(and)g(character)f(streams)i(end)f
(up)g(being)g(merely)f(function)g(calls)i(to)g(an)g(input)f(routine)f
(while)h(the)h(separation)e(between)0 1803 y(parser)h(and)f(scanner)h
(tends)g(to)g(become)f(blurred.)125 1903 y(F)o(or)25
b(the)h(C++)g(output)f(of)h(ANTLR)g(and)f(DLG,)h(we)g(ha)n(v)o(e)f
(chosen)g(to)h(create)g(a)g(class)h(hierarchy)d(that)i(re\257ects)g
(the)g(nice)0 2002 y(conceptual)f(separation)h(between)g(recognition)e
(subtasks.)49 b(Figure)27 b(2)g(represents)f(the)g(class)i
(interactions)e(that)h(mirror)f(the)0 2102 y(standard)19
b(parsing)g(block)g(diagram.)28 b(In)20 b(C++)h(code,)e(the)h(block)g
(diagram)e(is)k(\252constructed\272)c(by)104 2285 y(1.)41
b(Attaching)19 b(an)h(input)f(stream)h(to)h(a)f(DLG-based)f(scanner)m
(,)208 2534 y Ft(DLGFileInput)42 b(in\(stdin\);)i(/*)g(create)g(an)g
(input)g(stream)g(for)g(DLG)h(to)f(get)h(chars)f(from)g(*/)208
2658 y(DLGLexer)f(scan\(&in,2000\);/*)f(create)i(scanner)f(reading)h
(from)g(stdin)g(w/bufsize==2000)f(*/)104 2957 y Fp(2.)e(Pro)o(viding)19
b(a)j(tok)o(en)f(to)h(DLG)g(for)f(it)h(to)g(continually)e(\256ll)i(in)g
(\(the)f(scanner)g(is)i(totally)e(separated)g(from)g(the)g(parser)g
(and,)208 3057 y(hence,)e(has)h(no)g(idea)g(ho)n(w)g(big)f(the)i
(programmer')-5 b(s)17 b(tok)o(en)j(is\))2022 3027 y
Fk(1)208 3306 y Ft(ANTLRToken)43 b(aToken;)208 3430 y
(scan.setToken\(&aToken\);)104 3729 y Fp(3.)e(Attaching)19
b(the)h(tok)o(en)f(stream)h(to)h(a)f(parser)208 3978
y Ft(Parser)43 b(p\(&scan\);)0 4294 y Fp(T)-7 b(o)20
b(start)h(parsing,)e(it)i(is)g(suf)n(\256cient)f(to)g(call)h(the)f
Fl(Parser)g Fp(member)e(function)h(associated)h(with)g(the)g(grammar)f
(rule:)125 4476 y Ft(p.starting)p 579 4476 23 4 v 25
w(rule\()f Fs(any)p 954 4476 V 27 w(ar)m(gs)p Ft(\);)125
4676 y Fp(T)-7 b(o)20 b(specify)f(the)i(name)e(of)h(the)g(parser)g
(class)h(to)f(construct,)f(the)h(programmer)e(encloses)i(all)g(rules)h
(and)e(actions)h(in)125 4858 y Ft(class)44 b(Parser)f
Fh(f)p 0 4930 1488 4 v 90 4985 a Fg(1)120 5009 y Fq(Note)19
b(that)h(if)f(C++)g(allo)n(wed)i(typenames)f(to)f(be)g(passed)h(around)
f(as)g(objects,)h(the)g(scanner)g(could)g(simply)f(be)g(initialized)k
(with)c(the)h(correct)g(typename.)0 5088 y(Also,)d(since)h
(constructors)h(cannot)g(be)e(virtual)i(\(polymorphic\))g(a)e
(DLG-based)h(tok)o(en)g(must)f(be)g(able)i(to)e(answer)h(a)f(message)g
(called)j Fd(makeToken\(\))p Fq(.)1839 5356 y Fp(7)p
eop
%%Page: 8 8
8 7 bop 585 -293 a
20129218 4012687 11511808 23155179 31641026 27167866 startTexFig
585 -293 a
%%BeginDocument: aspawn.ps
1 setlinejoin
/M { moveto } bind def /S { show } bind def
/R { rmoveto } bind def /L { lineto } bind def
/B { newpath 0 0 M 0 1 L 1 1 L 1 0 L closepath } bind def
/CS { closepath stroke } bind def
/newfont 10 dict def
newfont begin

/FontType 3 def
/FontMatrix [1 0 0 1 0 0] def
/FontBBox [0 0 1 1] def
/Encoding 256 array def
0 1 255 {Encoding exch /.notdef put} for

/CharProcs 1 dict def
CharProcs begin
/.notdef {} def

end

/BuildChar {
1 0
0 0 1 1
setcachedevice
exch begin
Encoding exch get
CharProcs exch get
end
exec
} def
end
/PatternFont newfont definefont pop

/bwproc {
rgbproc
dup length 3 idiv string 0 3 0
5 -1 roll {
add 2 1 roll 1 sub dup 0 eq
{ pop 3 idiv 3 -1 roll dup 4 -1 roll dup
3 1 roll 5 -1 roll put 1 add 3 0 }
{ 2 1 roll } ifelse
} forall
pop pop pop
} def
systemdict /colorimage known not {
/colorimage {
pop
pop
/rgbproc exch def
{ bwproc } image
} def
} if
/incr {
2 1 roll dup 3 -1 roll
5 -1 roll dup 6 1 roll cvi put
3 1 roll dup 4 1 roll add 3 1 roll
} bind def
/scanspan {
/xb2 exch def
/xg2 exch def
/xr2 exch def
/xx2 exch def
/xb1 exch def
/xg1 exch def
/xr1 exch def
/xx1 exch def
/dx xx2 xx1 sub def
dx 0 ne {
/drdx xr2 xr1 sub dx div def
/dgdx xg2 xg1 sub dx div def
/dbdx xb2 xb1 sub dx div def
}{
/drdx 0 def
/dgdx 0 def
/dbdx 0 def
} ifelse
/len dx 1 add cvi 3 mul def
len string dup dup
xr1 drdx 3 -1 roll
0 3 len 1 sub { incr } for
pop pop pop
xg1 dgdx 3 -1 roll
1 3 len 1 sub { incr } for
pop pop pop
xb1 dbdx 3 -1 roll
2 3 len 1 sub { incr } for
3 1 roll pop pop
} bind def
/scantrap {
/trapsave save def
/b4 exch def
/g4 exch def
/r4 exch def
/x4 exch def
/b3 exch def
/g3 exch def
/r3 exch def
/x3 exch def
/b2 exch def
/g2 exch def
/r2 exch def
/y2 exch def
/x2 exch def
/b1 exch def
/g1 exch def
/r1 exch def
/y1 exch def
/x1 exch def
/dy y1 y2 sub def
dy 0 ne {
/dxdy12 x2 x1 sub dy div def
/dxdy43 x3 x4 sub dy div def
/drdy12 r2 r1 sub dy div def
/drdy43 r3 r4 sub dy div def
/dgdy12 g2 g1 sub dy div def
/dgdy43 g3 g4 sub dy div def
/dbdy12 b2 b1 sub dy div def
/dbdy43 b3 b4 sub dy div def
}{
/dxdy12 0 def
/dxdy43 0 def
/drdy12 0 def
/drdy43 0 def
/dgdy12 0 def
/dgdy43 0 def
/dbdy12 0 def
/dbdy43 0 def
} ifelse
y1 -1 y2 {
x4 x1 sub 0 lt { exit } if
/y exch def
/traploopsave save def
x1 r1 g1 b1 x4 r4 g4 b4 scanspan
/img exch def
/xlen x4 x1 sub 1 add def
x1 y translate
xlen 1 scale
xlen cvi 1 8 [xlen 0 0 0.9 0 0] { img } false 3 colorimage
traploopsave restore
/x1 x1 dxdy12 add def
/r1 r1 drdy12 add def
/g1 g1 dgdy12 add def
/b1 b1 dbdy12 add def
/x4 x4 dxdy43 add def
/r4 r4 drdy43 add def
/g4 g4 dgdy43 add def
/b4 b4 dbdy43 add def
} for
trapsave restore
} def
/d {
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/q {
newpath
moveto
lineto
lineto
lineto
closepath
stroke
} bind def
/draw3 {
setgray
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/F3 {
setgray
newpath
moveto
lineto
lineto
closepath
fill
} bind def
/F4 {
setgray
newpath
moveto
lineto
lineto
lineto
closepath
fill
} bind def
/F5 {
setgray
newpath
moveto
lineto
lineto
lineto
lineto
closepath
fill
} bind def
/showcaseisoencoding [
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /minus /period /slash
/zero /one /two /three /four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
/at /A /B /C /D /E /F /G
/H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W
/X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c /d /e /f /g
/h /i /j /k /l /m /n /o
/p /q /r /s /t /u /v /w
/x /y /z /braceleft
/bar /braceright /asciitilde /guilsinglright
/fraction /florin /quotesingle /quotedblleft
/guilsinglleft /fi /fl /endash
/dagger /daggerdbl /bullet /quotesinglbase
/quotedblbase /quotedblright /ellipsis /trademark
/dotlessi /grave /acute /circumflex
/tilde /macron /breve /dotaccent
/dieresis /perthousand /ring /cedilla
/Ydieresis /hungarumlaut /ogonek /caron
/emdash /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis ] def
/Helvetica-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Helvetica-Bold-SHOWISO exch definefont pop
/Courier-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-Bold-SHOWISO exch definefont pop
/Courier findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-SHOWISO exch definefont pop
/Times-Roman findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Times-Roman-SHOWISO exch definefont pop
gsave
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
336 400 M
456 368 L
stroke
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
336 400 M
380 368 L
stroke
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
336 400 M
320 368 L
stroke
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
336 400 M
264 368 L
stroke
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
336 400 M
200 368 L
stroke
grestore
0 0 0 setrgbcolor
gsave
newpath
421 352 M 401 365 L 511 365 L 511 352 L
closepath clip newpath
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
431 356 M 0 0 (tokens.h) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
341 352 M 321 365 L 443 365 L 443 352 L
closepath clip newpath
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
351 356 M 0 0 (parser.dlg) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
293 352 M 273 365 L 371 365 L 371 352 L
closepath clip newpath
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
303 356 M 0 0 (file.C) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
229 352 M 209 365 L 319 365 L 319 352 L
closepath clip newpath
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
239 356 M 0 0 (Parser.h) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
165 352 M 145 365 L 255 365 L 255 352 L
closepath clip newpath
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
175 356 M 0 0 (Parser.C) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
309 400 M 289 413 L 381 413 L 381 400 L
closepath clip newpath
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
319 404 M 0 0 (ANTLR) ashow
grestore
grestore
showpage
%%EndDocument

endTexFig
1045 398 a Fp(Figure)20 b(3:)29 b(ANTLR-Generated)19
b(Files)i(in)f(C++)h(Mode)1285 516 y
9077883 3749560 17037475 16840130 26115358 20589690 startTexFig
1285 516 a
%%BeginDocument: dspawn.ps
1 setlinejoin
/M { moveto } bind def /S { show } bind def
/R { rmoveto } bind def /L { lineto } bind def
/B { newpath 0 0 M 0 1 L 1 1 L 1 0 L closepath } bind def
/CS { closepath stroke } bind def
/newfont 10 dict def
newfont begin

/FontType 3 def
/FontMatrix [1 0 0 1 0 0] def
/FontBBox [0 0 1 1] def
/Encoding 256 array def
0 1 255 {Encoding exch /.notdef put} for

/CharProcs 1 dict def
CharProcs begin
/.notdef {} def

end

/BuildChar {
1 0
0 0 1 1
setcachedevice
exch begin
Encoding exch get
CharProcs exch get
end
exec
} def
end
/PatternFont newfont definefont pop

/bwproc {
rgbproc
dup length 3 idiv string 0 3 0
5 -1 roll {
add 2 1 roll 1 sub dup 0 eq
{ pop 3 idiv 3 -1 roll dup 4 -1 roll dup
3 1 roll 5 -1 roll put 1 add 3 0 }
{ 2 1 roll } ifelse
} forall
pop pop pop
} def
systemdict /colorimage known not {
/colorimage {
pop
pop
/rgbproc exch def
{ bwproc } image
} def
} if
/incr {
2 1 roll dup 3 -1 roll
5 -1 roll dup 6 1 roll cvi put
3 1 roll dup 4 1 roll add 3 1 roll
} bind def
/scanspan {
/xb2 exch def
/xg2 exch def
/xr2 exch def
/xx2 exch def
/xb1 exch def
/xg1 exch def
/xr1 exch def
/xx1 exch def
/dx xx2 xx1 sub def
dx 0 ne {
/drdx xr2 xr1 sub dx div def
/dgdx xg2 xg1 sub dx div def
/dbdx xb2 xb1 sub dx div def
}{
/drdx 0 def
/dgdx 0 def
/dbdx 0 def
} ifelse
/len dx 1 add cvi 3 mul def
len string dup dup
xr1 drdx 3 -1 roll
0 3 len 1 sub { incr } for
pop pop pop
xg1 dgdx 3 -1 roll
1 3 len 1 sub { incr } for
pop pop pop
xb1 dbdx 3 -1 roll
2 3 len 1 sub { incr } for
3 1 roll pop pop
} bind def
/scantrap {
/trapsave save def
/b4 exch def
/g4 exch def
/r4 exch def
/x4 exch def
/b3 exch def
/g3 exch def
/r3 exch def
/x3 exch def
/b2 exch def
/g2 exch def
/r2 exch def
/y2 exch def
/x2 exch def
/b1 exch def
/g1 exch def
/r1 exch def
/y1 exch def
/x1 exch def
/dy y1 y2 sub def
dy 0 ne {
/dxdy12 x2 x1 sub dy div def
/dxdy43 x3 x4 sub dy div def
/drdy12 r2 r1 sub dy div def
/drdy43 r3 r4 sub dy div def
/dgdy12 g2 g1 sub dy div def
/dgdy43 g3 g4 sub dy div def
/dbdy12 b2 b1 sub dy div def
/dbdy43 b3 b4 sub dy div def
}{
/dxdy12 0 def
/dxdy43 0 def
/drdy12 0 def
/drdy43 0 def
/dgdy12 0 def
/dgdy43 0 def
/dbdy12 0 def
/dbdy43 0 def
} ifelse
y1 -1 y2 {
x4 x1 sub 0 lt { exit } if
/y exch def
/traploopsave save def
x1 r1 g1 b1 x4 r4 g4 b4 scanspan
/img exch def
/xlen x4 x1 sub 1 add def
x1 y translate
xlen 1 scale
xlen cvi 1 8 [xlen 0 0 0.9 0 0] { img } false 3 colorimage
traploopsave restore
/x1 x1 dxdy12 add def
/r1 r1 drdy12 add def
/g1 g1 dgdy12 add def
/b1 b1 dbdy12 add def
/x4 x4 dxdy43 add def
/r4 r4 drdy43 add def
/g4 g4 dgdy43 add def
/b4 b4 dbdy43 add def
} for
trapsave restore
} def
/d {
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/q {
newpath
moveto
lineto
lineto
lineto
closepath
stroke
} bind def
/draw3 {
setgray
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/F3 {
setgray
newpath
moveto
lineto
lineto
closepath
fill
} bind def
/F4 {
setgray
newpath
moveto
lineto
lineto
lineto
closepath
fill
} bind def
/F5 {
setgray
newpath
moveto
lineto
lineto
lineto
lineto
closepath
fill
} bind def
/showcaseisoencoding [
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /minus /period /slash
/zero /one /two /three /four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
/at /A /B /C /D /E /F /G
/H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W
/X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c /d /e /f /g
/h /i /j /k /l /m /n /o
/p /q /r /s /t /u /v /w
/x /y /z /braceleft
/bar /braceright /asciitilde /guilsinglright
/fraction /florin /quotesingle /quotedblleft
/guilsinglleft /fi /fl /endash
/dagger /daggerdbl /bullet /quotesinglbase
/quotedblbase /quotedblright /ellipsis /trademark
/dotlessi /grave /acute /circumflex
/tilde /macron /breve /dotaccent
/dieresis /perthousand /ring /cedilla
/Ydieresis /hungarumlaut /ogonek /caron
/emdash /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis ] def
/Helvetica-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Helvetica-Bold-SHOWISO exch definefont pop
/Courier-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-Bold-SHOWISO exch definefont pop
/Courier findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-SHOWISO exch definefont pop
/Times-Roman findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Times-Roman-SHOWISO exch definefont pop
gsave
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
328 300 M
364 272 L
stroke
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
328 300 M
288 272 L
stroke
grestore
0 0 0 setrgbcolor
gsave
newpath
325 256 M 305 269 L 427 269 L 427 256 L
closepath clip newpath
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
335 260 M 0 0 (DLGLexer.h) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
249 256 M 229 269 L 351 269 L 351 256 L
closepath clip newpath
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
259 260 M 0 0 (DLGLexer.C) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
309 300 M 289 313 L 369 313 L 369 300 L
closepath clip newpath
/Courier-SHOWISO findfont 10 scalefont setfont
0 0 0 setrgbcolor
319 304 M 0 0 (DLG) ashow
grestore
grestore
showpage
%%EndDocument

endTexFig
1098 1174 a Fp(Figure)f(4:)29 b(DLG-Generated)19 b(Files)i(in)f(C++)h
(Mode)304 1441 y Ft(...)125 1532 y Fh(g)0 1731 y Fp(Currently)-5
b(,)38 b(e)o(xactly)d(one)h(class)h(may)e(be)h(de\256ned.)76
b(F)o(or)36 b(the)g(de\256ned)f(class,)41 b(ANTLR)36
b(generates)f(a)i(deri)n(v)o(ed)d(class)j(of)0 1831 y
Fl(ANTLRParser)25 b Fp(which)i(accepts)f(tok)o(ens)g(\()p
Fl(ANTLRToken)p Fp(\))f(from)h(a)h(class)h(deri)n(v)o(ed)d(from)h
Fl(ANTLRTokenBase)p Fp(.)46 b(This)0 1931 y(tok)o(en)19
b(stream)h(can)f(be)h(either)g(a)g(user)g(de\256ned)e(scanner)h(or)h(a)
g(DLG-based)f(scanner)-5 b(.)28 b(DLG)20 b(generates)f(a)i(class)f
(\(def)o(ault)f(name)0 2030 y(is)24 b Fl(DLGLexer)p Fp(\))d(that)i(is)g
(deri)n(v)o(ed)e(from)h Fl(DLGLexerBase)p Fp(.)35 b(DLG-based)21
b(scanners)h(read)h(input)f(from)f(deri)n(v)o(ed)g(classes)j(of)0
2130 y Fl(DLGInputStream)p Fp(,)18 b(the)i(most)g(common)f(being)g
Fl(DLGFileInput)p Fp(.)125 2229 y(Figures)d(3)h(and)f(4)h(describe)f
(the)h(\256les)g(constructed)e(from)h(ANTLR)h(and)f(DLG)h(in)g(C++)g
(mode)f(in)h(the)g(case)g(where)f(ANTLR)0 2329 y(w)o(as)31
b(gi)n(v)o(en)d(a)j(grammar)d(called)i Fl(file.g)f Fp(containing)f
(\252)p Fl(class)49 b(Parser)f Fm(f)p Fl(...)p Fm(g)p
Fp(\272)29 b(and)g(DLG)h(w)o(as)h(gi)n(v)o(en)e(the)h(usual)0
2429 y Fl(parser.dlg)p Fp(.)55 b(If)30 b(the)f Fl(#tokdefs)f
Fp(directi)n(v)o(e)g(were)i(used,)h(then)e(the)g Fl(tokens.h)f
Fp(\256le)i(w)o(ould)f(not)g(be)g(generated)f(by)0 2528
y(ANTLR)g(and)g(if)g(the)g(ANTLR)g(command)e(line)i(option)f(for)h
(user)n(-de\256ned)e(scanners)h(\()p Fl(-gx)p Fp(\))h(were)f(used,)j
Fl(parser.dlg)0 2628 y Fp(w)o(ould)g(not)h(be)g(generated)f(\()p
Fl(#tokdefs)g Fp(and)g Fl(-gx)i Fp(operate)e(independently)e(of)j(each)
g(other\).)61 b(Files)32 b Fl(Parser.h)e Fp(and)0 2728
y Fl(Parser.C)24 b Fp(represent)g(the)h(class)h(de\256nition)e(and)g
(support)f(code)i(for)f(the)h(output)f(parser)-5 b(.)43
b(The)25 b(actual)f(recursi)n(v)o(e-descent)0 2827 y(parser)15
b(generated)f(from)h Fl(file.g)g Fp(is)i(placed)e(in)h
Fl(file.C)p Fp(;)g(there)f(may)h(be)f(multiple)h(input)f(\256les)i(and)
e(for)g(reasons)g(of)h(separate)0 2927 y(compilation,)e(we)i(do)g(not)f
(put)g(the)h(parser)f(functions)f(into)h(the)h Fl(Parser.C)e
Fp(\256le.)28 b(File)17 b Fl(tokens.h)d Fp(contains)h(an)h(enumerated)0
3026 y(type)25 b Fl(TokenType)e Fp(describing)h(the)h(set)h(of)e
(de\256ned)g(tok)o(en)g(types.)44 b(Files)26 b Fl(DLGLexer.C)d
Fp(and)i Fl(DLGLexer.h)f Fp(embody)0 3126 y(the)i(class)h(de\256nition)
e(of)h(the)g(scanner)f(described)g(by)g Fl(parser.dlg)p
Fp(.)46 b(The)25 b(C++)i(support)e(code)g(for)h(ANTLR)g(and)f(DLG)0
3226 y(output)g(is)j(not)e(dependent)f(on)h Fl(#defines)g
Fp(as)h(the)g(C)h(output)d(is.)50 b(F)o(or)26 b(e)o(xample,)h(\252)p
Fl(#define)48 b(DEMAND)p 3244 3226 25 4 v 29 w(LOOK)p
Fp(\272)26 b(is)i(not)0 3325 y(generated)17 b(by)i(ANTLR)g(in)h(C++)f
(mode.)28 b(The)19 b(support)f(code)g(senses)i(a)f(\257ag)h(in)f(the)g
(parser)f(structure)h(that)g(indicates)g(whether)0 3425
y(to)h(consume)f(lookahead)f(on)i(demand)f(or)h(to)g(continually)e
(\256ll)j(the)g(lookahead)c(\252pipe.)-6 b(\272)125 3525
y(The)18 b(communication)d(medium)i(between)h(scanner)g(and)f(parser)h
(is)i(an)e Fl(ANTLRToken)f Fp(\(the)h(name)g(is)i(\256x)o(ed)d(for)h
(the)h(class)0 3624 y(name\))24 b(where)g(the)g(communications)e
(channel)h(is)j(an)e Fl(ANTLRTokenStream)p Fp(.)40 b(T)-7
b(ok)o(ens)24 b(are)h(no)f(longer)f(simply)h(a)h(tok)o(en)0
3724 y(type;)j(further)m(,)d(attrib)n(utes,)i(as)f(de\256ned)f(by)g
(ANTLR)h(1.10,)f(are)h(no)f(longer)g(de\256ned.)44 b(F)o(or)25
b(v)o(ersion)g(1.20,)g(we)h(combine)f(the)0 3823 y(pre)n(vious)h
(de\256nitions)h(to)h(create)f(an)h(abstract)f(tok)o(en,)i
Fl(ANTLRToken)d Fp(under)h(the)g Fl(ANTLRTokenBase)f
Fp(hierarchy)-5 b(,)26 b(that)0 3923 y(contains)g(at)i(least)f(the)g
(tok)o(en)f(type,)i(b)n(ut)f(may)f(include)g(an)o(ything)f(else)j
(required)d(by)h(the)h(user)-5 b(.)50 b(When)26 b(using)h(DLG-based)0
4023 y(scanners,)19 b Fl(ANTLRToken)f Fp(must)i(be)f(deri)n(v)o(ed)f
(from)h Fl(DLGBasedToken)e Fp(which)j(adds)f(beha)n(vior)f(needed)g(by)
h(DLG)h(\(DLG-)0 4122 y(based)14 b(scanners)g(need)g(to)h(be)f(able)h
(to)g(set/get)g(the)f(te)o(xt)h(of)f(a)h(tok)o(en\).)26
b(A)15 b(common)e(tok)o(en)h(de\256nition,)g Fl(ANTLRCommonToken)p
Fp(,)0 4222 y(is)29 b(prede\256ned)c(to)j(be)g(the)f(usual)h(tok)o(en)f
(type)g(plus)h(a)g(\256x)o(ed-size)f(te)o(xt)g(b)n(uf)n(fer)f
(\(similar)i(to)g(the)f(old)h Fl(Attrib)f Fp(de\256nition)f(in)0
4322 y Fl(charbuf.h)p Fp(\).)49 b(The)26 b(minimal)h(tok)o(en)f
(de\256nition)g(is)j(still)f(the)f(size)h(of)f(an)g(inte)o(ger)f(\()p
Fl(sizeof\(enum)47 b(TokenType\))p Fp(\).)0 4421 y(T)-7
b(o)30 b(access)h(the)f(tok)o(ens)f(in)i(a)f(tok)o(en)f(stream)h(from)f
(the)h(parser)m(,)i Fl($)p Fc(i)e Fp(v)n(ariables)f(are)h(used.)59
b(Ho)n(we)n(v)o(er)m(,)30 b(these)g(v)n(ariables)g(are)0
4521 y(consistently)19 b(pointers)h(to)g(type)g Fl(ANTLRToken)f
Fp(in)h(C++)h(mode)e(whereas)h(in)g(C)h(mode)e Fl($)p
Fc(i)i Fp(v)n(ariables)e(are)i(of)f(type)f Fl(Attrib)p
Fp(.)125 4620 y(The)g(minimal)h(programmer)n(-supplied)15
b(code)20 b(requirements)e(to)i(get)h(a)f(C++)h(parser)f(going)f(are:)
104 4803 y(1.)41 b(A)19 b(function)e(that)h(constructs)g(the)h(v)n
(arious)f(objects)g(in)h(the)f(C++)i(parser)e(block)f(diagram)h(in)h
(Figure)f(2)g(and)g(in)m(v)n(ok)o(es)g(one)208 4903 y(of)h(the)i
(parser)e(member)g(rules)h(in)h(your)e Fl(Parser)g Fp(class.)104
5069 y(2.)41 b(A)20 b(de\256nition)f(for)h Fl(ANTLRToken)p
Fp(.)28 b(An)20 b(easy)g(w)o(ay)g(to)h(accomplish)e(this)h(is)i(to)e
(do)g(the)g(follo)n(wing:)1839 5356 y(8)p eop
%%Page: 9 9
9 8 bop 208 -85 a Ft(typedef)43 b(ANTLRCommonToken)f(ANTLRToken;)h(/*)i
(a)f(token)g(is)h(token)f(type)g(and)g(text)h(*/)104
214 y Fp(3.)c(A)20 b(class)h(de\256nition)e(in)i(the)f(grammar)e
(\256le\(s\).)125 396 y(The)25 b(v)n(arious)f(de\256nitions)g(need)h
(not)g(be)g(placed)g(in)g(the)g Fl(#header)g Fp(action)g(as)h(in)f(C)i
(output)d(mode.)43 b(The)25 b(ne)o(xt)g(section)0 496
y(pro)o(vides)18 b(a)j(complete)e(e)o(xample)g(that)h(illustrates)h
(all)g(of)f(the)g(con)m(v)o(entions)d(described)i(in)h(this)h(section.)
0 734 y Fb(6.1)99 b(A)25 b(Simple)g(C++)g(Example)0 889
y Fp(Figure)32 b(5)h(is)h(a)g(simple)f(e)o(xample)e(that)i(illustrates)
h(a)f(simple)g(DLG-based)f(scanner)g(with)h(an)g(ANTLR)h(grammar)d
(class.)0 989 y(Assuming)23 b(that)g(the)h(e)o(xample)e(is)i(in)f(a)h
(\256le)g(called)f Fl(test.g)p Fp(,)h(an)f(e)o(x)o(ecutable)f(parser)g
(may)h(be)h(obtained)d(via)j(the)f(follo)n(wing)0 1088
y(command)18 b(sequence:)125 1206 y Ft(antlr)44 b(-CC)g(test.g)125
1297 y(dlg)g(-CC)g(parser.dlg)125 1389 y(C++)g(-c)g
(-I/usr/local/pccts/include)d(-o)j(test.o)g(test.C)125
1480 y(C++)g(-c)g(-I/usr/local/pccts/include)d(-o)j(Expr.o)g(Expr.C)125
1571 y(C++)g(-c)g(-I/usr/local/pccts/include)d(-o)j(DLGLexer.o)f
(DLGLexer.C)125 1663 y(C++)h(-o)g(t)h(test.o)f(Expr.o)g(DLGLexer.o)f
(\\)528 1754 y(/usr/local/pccts/antlrx.o)e(\\)528 1845
y(/usr/local/pccts/dlgx.o)g(\\)0 2036 y Fp(where)20 b
Fl(antlrx.o)f Fp(and)g Fl(dlgx.o)h Fp(are)g(support)f(code)h(modules.)0
2274 y Fb(6.2)99 b(Grammar)25 b(Classes)0 2430 y Fp(A)c(grammar)d
(class)j(is)g(de\256ned)f(as)h(follo)n(ws)125 2612 y
Ft(class)44 b(Parser)f Fh(f)304 2704 y Fi(actions)304
2795 y(r)r(ul)q(es)125 2886 y Fh(g)0 3085 y Fp(The)20
b(actions)g(may)g(contain)f(an)o(y)g(normal)g(C++)i(code)e(that)i(is)g
(v)n(alid)e(within)h(a)h(C++)g(class)g(de\256nition)2946
3055 y Fk(2)2978 3085 y Fp(.)29 b(F)o(or)20 b(e)o(xample,)125
3268 y Ft(class)44 b(Parser)f Fh(f)125 3359 y Ft(< (i;>>)125 3451 y(< Ft(;)g Fh(g)p Ft(>>)125 3633 y(rule)f(:)g(A)h(B)g(;)125
3816 y Fh(g)0 4015 y Fp(w)o(ould)19 b(result)i(in)f(a)h(C++)f(class)i
(de\256nition)d(of:)p 0 4069 1488 4 v 90 4125 a Fg(2)120
4148 y Fq(Actually)l(,)28 b(an)o(y)d(normal)h(ANTLR)e(directi)n(v)o(e)k
(such)e(as)e Fd(#token)g Fq(de\256nitions)j(may)e(be)g(placed)i
(inside,)h(b)o(ut)d(it)g(is)g(best)h(to)f(separate)i(them)e(from)g(the)
0 4227 y(grammar)17 b(class)1839 5356 y Fp(9)p eop
%%Page: 10 10
10 9 bop 312 983 a Ft(<<)312 1074 y(typedef)44 b(ANTLRCommonToken)e
(ANTLRToken;)h(/*)i(user)f(must)g(define)g(ANTLRToken)f(*/)312
1257 y(/*)i("DLGLexer")e(must)h(match)g(DLG)h(command)e(line)h(\(-cl)h
(option\);)e(DLGLexer)h(is)g(default)g(*/)312 1348 y(#include)g
("DLGLexer.h")312 b(/*)44 b(include)g(definition)f(of)i(DLGLexer.)312
1439 y(main\(\))312 1531 y Fh(f)492 1622 y Ft(DLGFileInput)e
(in\(stdin\);)g(/*)h(create)g(an)h(input)f(stream)f(for)i(DLG)f(to)h
(get)f(chars)g(from)g(*/)492 1713 y(DLGLexer)f(scan\(&in,2000\);/*)f
(create)i(scanner)g(reading)f(from)i(stdin)f(w/bufsize==2000)312
1805 y(*/)492 1896 y(ANTLRToken)f(aToken;)268 b(/*)44
b(create)g(a)h(token)f(for)g(DLG)g(to)h(fill)f(in)h(*/)492
1987 y(scan.setToken\(&aToken\);)492 2078 y(Expr)f(parser\(&scan\);)222
b(/*)44 b(create)g(a)h(parser)f(of)g(type)g(Expr)g(hooked)g(to)h(the)f
(scanner)312 2170 y(*/)492 2352 y(parser.e\(\);)581 b(/*)44
b(start)g(parsing)g(at)g(rule)h('e')f(of)g(that)h(parser)e(*/)312
2444 y Fh(g)312 2535 y Ft(>>)312 2718 y(#token)h("[\\)h(\\t\\n]+")88
b(<>)312 2809 y(#token)44 b(Eof)h("@")312
2992 y(class)f(Expr)h Fh(f)717 b Ft(/*)45 b(Define)f(a)g(grammar)g
(class)g(*/)312 3083 y(e)135 b(:)f(IDENTIFIER)43 b(NUMBER)h(Eof)671
3174 y(<getText\(\),)g
($2->getText\(\)\);>>)492 3266 y(;)312 3357 y Fh(g)312
3540 y Ft(#token)h(IDENTIFIER)133 b("[a-z]+")312 3631
y(#token)44 b(NUMBER)313 b("[0-9]+")982 3905 y Fp(Figure)19
b(5:)30 b(Sample)20 b(ANTLR)g(Grammar)f(for)h(C++)g(Output)1818
5356 y(10)p eop
%%Page: 11 11
11 10 bop 535 -293 a
20918600 7367557 1512980 40061091 22431580 47428648 startTexFig
535 -293 a
%%BeginDocument: tokhier.ps
1 setlinejoin
/M { moveto } bind def /S { show } bind def
/R { rmoveto } bind def /L { lineto } bind def
/B { newpath 0 0 M 0 1 L 1 1 L 1 0 L closepath } bind def
/CS { closepath stroke } bind def
/newfont 10 dict def
newfont begin

/FontType 3 def
/FontMatrix [1 0 0 1 0 0] def
/FontBBox [0 0 1 1] def
/Encoding 256 array def
0 1 255 {Encoding exch /.notdef put} for

/CharProcs 1 dict def
CharProcs begin
/.notdef {} def

end

/BuildChar {
1 0
0 0 1 1
setcachedevice
exch begin
Encoding exch get
CharProcs exch get
end
exec
} def
end
/PatternFont newfont definefont pop

/bwproc {
rgbproc
dup length 3 idiv string 0 3 0
5 -1 roll {
add 2 1 roll 1 sub dup 0 eq
{ pop 3 idiv 3 -1 roll dup 4 -1 roll dup
3 1 roll 5 -1 roll put 1 add 3 0 }
{ 2 1 roll } ifelse
} forall
pop pop pop
} def
systemdict /colorimage known not {
/colorimage {
pop
pop
/rgbproc exch def
{ bwproc } image
} def
} if
/incr {
2 1 roll dup 3 -1 roll
5 -1 roll dup 6 1 roll cvi put
3 1 roll dup 4 1 roll add 3 1 roll
} bind def
/scanspan {
/xb2 exch def
/xg2 exch def
/xr2 exch def
/xx2 exch def
/xb1 exch def
/xg1 exch def
/xr1 exch def
/xx1 exch def
/dx xx2 xx1 sub def
dx 0 ne {
/drdx xr2 xr1 sub dx div def
/dgdx xg2 xg1 sub dx div def
/dbdx xb2 xb1 sub dx div def
}{
/drdx 0 def
/dgdx 0 def
/dbdx 0 def
} ifelse
/len dx 1 add cvi 3 mul def
len string dup dup
xr1 drdx 3 -1 roll
0 3 len 1 sub { incr } for
pop pop pop
xg1 dgdx 3 -1 roll
1 3 len 1 sub { incr } for
pop pop pop
xb1 dbdx 3 -1 roll
2 3 len 1 sub { incr } for
3 1 roll pop pop
} bind def
/scantrap {
/trapsave save def
/b4 exch def
/g4 exch def
/r4 exch def
/x4 exch def
/b3 exch def
/g3 exch def
/r3 exch def
/x3 exch def
/b2 exch def
/g2 exch def
/r2 exch def
/y2 exch def
/x2 exch def
/b1 exch def
/g1 exch def
/r1 exch def
/y1 exch def
/x1 exch def
/dy y1 y2 sub def
dy 0 ne {
/dxdy12 x2 x1 sub dy div def
/dxdy43 x3 x4 sub dy div def
/drdy12 r2 r1 sub dy div def
/drdy43 r3 r4 sub dy div def
/dgdy12 g2 g1 sub dy div def
/dgdy43 g3 g4 sub dy div def
/dbdy12 b2 b1 sub dy div def
/dbdy43 b3 b4 sub dy div def
}{
/dxdy12 0 def
/dxdy43 0 def
/drdy12 0 def
/drdy43 0 def
/dgdy12 0 def
/dgdy43 0 def
/dbdy12 0 def
/dbdy43 0 def
} ifelse
y1 -1 y2 {
x4 x1 sub 0 lt { exit } if
/y exch def
/traploopsave save def
x1 r1 g1 b1 x4 r4 g4 b4 scanspan
/img exch def
/xlen x4 x1 sub 1 add def
x1 y translate
xlen 1 scale
xlen cvi 1 8 [xlen 0 0 0.9 0 0] { img } false 3 colorimage
traploopsave restore
/x1 x1 dxdy12 add def
/r1 r1 drdy12 add def
/g1 g1 dgdy12 add def
/b1 b1 dbdy12 add def
/x4 x4 dxdy43 add def
/r4 r4 drdy43 add def
/g4 g4 dgdy43 add def
/b4 b4 dbdy43 add def
} for
trapsave restore
} def
/d {
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/q {
newpath
moveto
lineto
lineto
lineto
closepath
stroke
} bind def
/draw3 {
setgray
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/F3 {
setgray
newpath
moveto
lineto
lineto
closepath
fill
} bind def
/F4 {
setgray
newpath
moveto
lineto
lineto
lineto
closepath
fill
} bind def
/F5 {
setgray
newpath
moveto
lineto
lineto
lineto
lineto
closepath
fill
} bind def
/showcaseisoencoding [
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /minus /period /slash
/zero /one /two /three /four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
/at /A /B /C /D /E /F /G
/H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W
/X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c /d /e /f /g
/h /i /j /k /l /m /n /o
/p /q /r /s /t /u /v /w
/x /y /z /braceleft
/bar /braceright /asciitilde /guilsinglright
/fraction /florin /quotesingle /quotedblleft
/guilsinglleft /fi /fl /endash
/dagger /daggerdbl /bullet /quotesinglbase
/quotedblbase /quotedblright /ellipsis /trademark
/dotlessi /grave /acute /circumflex
/tilde /macron /breve /dotaccent
/dieresis /perthousand /ring /cedilla
/Ydieresis /hungarumlaut /ogonek /caron
/emdash /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis ] def
/Helvetica-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Helvetica-Bold-SHOWISO exch definefont pop
/Courier-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-Bold-SHOWISO exch definefont pop
/Courier findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-SHOWISO exch definefont pop
gsave
0 0 0 setrgbcolor
gsave
newpath
13 657 M -7 673 L 237 673 L 237 657 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
23 662 M -0.2 0 (TokenForUserDefined) ashow
-0.2 0 (Scanner) ashow
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
284 656 M
284 624 L
stroke
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
204 704 M
284 672 L
stroke
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
204 704 M
108 672 L
stroke
grestore
0 0 0 setrgbcolor
gsave
newpath
217 609 M 197 625 L 371 625 L 371 609 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
227 614 M -0.2 0 (ANTLRCommonToken) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
225 657 M 205 673 L 358 673 L 358 657 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
235 662 M -0.2 0 (DLGBasedToken) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
145 705 M 125 721 L 285 721 L 285 705 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
155 710 M -0.2 0 (ANTLRTokenBase) ashow
grestore
grestore
showpage
%%EndDocument

endTexFig
1331 823 a Fp(Figure)19 b(6:)30 b(C++)20 b(T)-7 b(ok)o(en)20
b(Hierarchy)125 1099 y Ft(class)44 b(Parser)f(:)i(public)f(ANTLRParser)
f Fh(f)125 1190 y Ft(protected:)304 1281 y(static)h(ANTLRChar)f(*)p
1115 1281 23 4 v 27 w(token)p 1367 1281 V 26 w(tbl[];)125
1373 y(private:)304 1464 y(static)h(SetWordType)f(setwd1[4];)125
1555 y(private:)125 1647 y(public:)304 1738 y(Parser\(ANTLRTokenStream)
e(*lexer\);)304 1829 y(Parser\(ANTLRTokenStream)g(*lexer,)i(TokenType)h
(eof\);)304 1921 y(void)g(rule\(\);)125 2012 y(public:)f(int)i(i;)125
2103 y(int)f(f\(\))g Fh(f)h Fi(bl)q(ah)p Ft(;)g Fh(g)125
2195 y(g)p Ft(;)0 2523 y Fb(6.3)99 b(ANTLR)26 b(P)o(arser)f(Classes)0
2679 y Fa(6.3.1)81 b(ANTLR)21 b(T)-8 b(ok)o(ens)0 2835
y Fp(In)26 b(C++)i(output)d(mode,)i(a)g(tok)o(en)f(is)h(an)g(object)f
(that)h(represents)f(an)g(abstraction)g(of)g(a)h(le)o(xical)f(object)h
(found)d(on)j(the)f(input)0 2934 y(stream)c(by)g(the)g(scanner)-5
b(.)35 b(An)22 b(ANTLR-generated)e(parser)h(accepts)h(input)g(as)h
(sequence)e(of)h(tok)o(ens)f(in)i(the)f(form)f(of)h(a)g(tok)o(en)0
3034 y(stream)30 b(where)g(the)g(tok)o(en)g(stream)g(is)i(usually)d
(managed)g(by)h(a)h(le)o(xical)f(analyzer)f(\(typically)g(DLG\).)h(A)h
(tok)o(en)f(contains,)0 3134 y(minimally)-5 b(,)15 b(a)i(tok)o(en)f
(type)g(that)g(is)i(used)e(by)g(the)g(parser)g(to)g(recognize)f
(grammatical)g(structure.)27 b(Optionally)-5 b(,)15 b(the)i(programmer)
0 3233 y(can)j(add)f(\256elds)h(speci\256c)g(to)g(the)f(tok)o(en)g
(class)i(to)f(carry)f(application-speci\256c)e(information.)27
b(T)-7 b(o)20 b(f)o(acilitate)g(error)e(reporting,)g(it)0
3333 y(is)j(common)d(practice)i(to)g(include)g(a)g(te)o(xt)g(string)g
(associate)h(with)f(each)g(tok)o(en)f(and)h(possibly)f(the)i(line)f
(number)-5 b(.)125 3433 y(Figure)19 b(6)g(depicts)h(the)f(hierarchy)f
(of)h(tok)o(en)g(base)h(classes)h(a)n(v)n(ailable)e(to)h(the)f
(programmer)-5 b(.)27 b(Because)20 b(an)f(ANTLR)h(parser)0
3532 y(must)28 b(be)g(able)g(to)g(mak)o(e)f(local)h(copies)g(of)g
(input)f(tok)o(ens,)i(the)f(name)f(of)h(the)g(programmer')-5
b(s)25 b(tok)o(en)i(de\256nition)g(is)i(\256x)o(ed)e(to)0
3632 y(be)k Fl(ANTLRToken)p Fp(;)36 b(we)31 b(do)g(this)h(for)f(ef)n
(\256cienc)o(y)f(reasons)g(as)i(specifying)e(a)i(size)g(to)f(the)h
(parser)e(and)h(then)g(asking)f(it)i(to)0 3731 y(allocate)26
b(memory)e(on)i(the)g(heap)f(is)i(much)e(slo)n(wer)h(than)g(de\256ning)
f(a)h(local)g(object)g(on)f(the)i(stack.)47 b(The)25
b(most)h(basic)h(tok)o(en,)0 3831 y Fl(ANTLRTokenBase)15
b Fp(kno)n(ws)i(ho)n(w)g(to)g(set)h(and)f(get)g(its)h(tok)o(en)f(type)g
(and)f(to)i(get)f(its)i(te)o(xt)e(representation;)f(the)h(latter)h(is)g
(needed)0 3931 y(to)26 b(satisfy)f(an)h(ANTLR-generated)d(parser')-5
b(s)25 b(ur)o(ge)f(to)i(print)f(meaningful)e(syntax)i(error)f(messages)
i(\(because)e(the)i(te)o(xt)f(of)g(a)0 4030 y(tok)o(en)20
b(is)h(not)g(required,)d(this)k(function)d(returns)g(the)i(empty)f
(string)g(unless)h(rede\256ned)e(in)i(a)g(subclass\).)30
b Fl(ANTLRToken)20 b Fp(must)0 4130 y(ha)n(v)o(e)g(a)g(blank)f
(constructor:)125 4313 y Ft(ANTLRToken\(\))42 b(;)0 4512
y Fp(so)21 b(that)f(the)g(parser)g(can)g(allocate)g(local)g(copies)g
(if)g(required.)125 4611 y(When)k(using)h(DLG-based)e(scanners,)j
(additional)d(beha)n(vior)h(is)h(required)f(of)g(a)i(tok)o(en.)42
b(DLG)25 b(must)g(be)g(able)g(to)g(set)h(the)0 4711 y(te)o(xt)20
b(and)g(tok)o(en)f(type)h(for)f(an)h Fl(ANTLRToken)p
Fp(.)28 b(A)21 b Fl(virtual)e Fp(function)g(called)125
4894 y Ft(virtual)43 b(void)h(makeToken\(TokenType)e(t,)i(ANTLRChar)g
(*s\);)1818 5356 y Fp(11)p eop
%%Page: 12 12
12 11 bop 852 -293 a
15919186 7367557 16511221 23220961 32430407 30588518 startTexFig
852 -293 a
%%BeginDocument: tokstream.ps
1 setlinejoin
/M { moveto } bind def /S { show } bind def
/R { rmoveto } bind def /L { lineto } bind def
/B { newpath 0 0 M 0 1 L 1 1 L 1 0 L closepath } bind def
/CS { closepath stroke } bind def
/newfont 10 dict def
newfont begin

/FontType 3 def
/FontMatrix [1 0 0 1 0 0] def
/FontBBox [0 0 1 1] def
/Encoding 256 array def
0 1 255 {Encoding exch /.notdef put} for

/CharProcs 1 dict def
CharProcs begin
/.notdef {} def

end

/BuildChar {
1 0
0 0 1 1
setcachedevice
exch begin
Encoding exch get
CharProcs exch get
end
exec
} def
end
/PatternFont newfont definefont pop

/bwproc {
rgbproc
dup length 3 idiv string 0 3 0
5 -1 roll {
add 2 1 roll 1 sub dup 0 eq
{ pop 3 idiv 3 -1 roll dup 4 -1 roll dup
3 1 roll 5 -1 roll put 1 add 3 0 }
{ 2 1 roll } ifelse
} forall
pop pop pop
} def
systemdict /colorimage known not {
/colorimage {
pop
pop
/rgbproc exch def
{ bwproc } image
} def
} if
/incr {
2 1 roll dup 3 -1 roll
5 -1 roll dup 6 1 roll cvi put
3 1 roll dup 4 1 roll add 3 1 roll
} bind def
/scanspan {
/xb2 exch def
/xg2 exch def
/xr2 exch def
/xx2 exch def
/xb1 exch def
/xg1 exch def
/xr1 exch def
/xx1 exch def
/dx xx2 xx1 sub def
dx 0 ne {
/drdx xr2 xr1 sub dx div def
/dgdx xg2 xg1 sub dx div def
/dbdx xb2 xb1 sub dx div def
}{
/drdx 0 def
/dgdx 0 def
/dbdx 0 def
} ifelse
/len dx 1 add cvi 3 mul def
len string dup dup
xr1 drdx 3 -1 roll
0 3 len 1 sub { incr } for
pop pop pop
xg1 dgdx 3 -1 roll
1 3 len 1 sub { incr } for
pop pop pop
xb1 dbdx 3 -1 roll
2 3 len 1 sub { incr } for
3 1 roll pop pop
} bind def
/scantrap {
/trapsave save def
/b4 exch def
/g4 exch def
/r4 exch def
/x4 exch def
/b3 exch def
/g3 exch def
/r3 exch def
/x3 exch def
/b2 exch def
/g2 exch def
/r2 exch def
/y2 exch def
/x2 exch def
/b1 exch def
/g1 exch def
/r1 exch def
/y1 exch def
/x1 exch def
/dy y1 y2 sub def
dy 0 ne {
/dxdy12 x2 x1 sub dy div def
/dxdy43 x3 x4 sub dy div def
/drdy12 r2 r1 sub dy div def
/drdy43 r3 r4 sub dy div def
/dgdy12 g2 g1 sub dy div def
/dgdy43 g3 g4 sub dy div def
/dbdy12 b2 b1 sub dy div def
/dbdy43 b3 b4 sub dy div def
}{
/dxdy12 0 def
/dxdy43 0 def
/drdy12 0 def
/drdy43 0 def
/dgdy12 0 def
/dgdy43 0 def
/dbdy12 0 def
/dbdy43 0 def
} ifelse
y1 -1 y2 {
x4 x1 sub 0 lt { exit } if
/y exch def
/traploopsave save def
x1 r1 g1 b1 x4 r4 g4 b4 scanspan
/img exch def
/xlen x4 x1 sub 1 add def
x1 y translate
xlen 1 scale
xlen cvi 1 8 [xlen 0 0 0.9 0 0] { img } false 3 colorimage
traploopsave restore
/x1 x1 dxdy12 add def
/r1 r1 drdy12 add def
/g1 g1 dgdy12 add def
/b1 b1 dbdy12 add def
/x4 x4 dxdy43 add def
/r4 r4 drdy43 add def
/g4 g4 dgdy43 add def
/b4 b4 dbdy43 add def
} for
trapsave restore
} def
/d {
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/q {
newpath
moveto
lineto
lineto
lineto
closepath
stroke
} bind def
/draw3 {
setgray
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/F3 {
setgray
newpath
moveto
lineto
lineto
closepath
fill
} bind def
/F4 {
setgray
newpath
moveto
lineto
lineto
lineto
closepath
fill
} bind def
/F5 {
setgray
newpath
moveto
lineto
lineto
lineto
lineto
closepath
fill
} bind def
/showcaseisoencoding [
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /minus /period /slash
/zero /one /two /three /four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
/at /A /B /C /D /E /F /G
/H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W
/X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c /d /e /f /g
/h /i /j /k /l /m /n /o
/p /q /r /s /t /u /v /w
/x /y /z /braceleft
/bar /braceright /asciitilde /guilsinglright
/fraction /florin /quotesingle /quotedblleft
/guilsinglleft /fi /fl /endash
/dagger /daggerdbl /bullet /quotesinglbase
/quotedblbase /quotedblright /ellipsis /trademark
/dotlessi /grave /acute /circumflex
/tilde /macron /breve /dotaccent
/dieresis /perthousand /ring /cedilla
/Ydieresis /hungarumlaut /ogonek /caron
/emdash /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis ] def
/Helvetica-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Helvetica-Bold-SHOWISO exch definefont pop
/Courier-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-Bold-SHOWISO exch definefont pop
/Courier findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-SHOWISO exch definefont pop
gsave
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
448 400 M
448 368 L
stroke
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
380 448 M
448 416 L
stroke
grestore
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
380 448 M
308 416 L
stroke
grestore
0 0 0 setrgbcolor
gsave
newpath
413 353 M 393 369 L 511 369 L 511 353 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
423 358 M -0.2 0 (DLGLexer) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
397 401 M 377 417 L 523 417 L 523 401 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
407 406 M -0.2 0 (DLGLexerBase) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
241 401 M 221 417 L 409 417 L 409 401 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
251 406 M -0.2 0 (UserDefinedScanner) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
317 449 M 297 465 L 471 465 L 471 449 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
327 454 M -0.2 0 (ANTLRTokenStream) ashow
grestore
grestore
showpage
%%EndDocument

endTexFig
1363 823 a Fp(Figure)19 b(7:)30 b(C++)20 b(T)-7 b(ok)o(en)20
b(Streams)0 1090 y(is)j(used)e(because)g(constructors)f(cannot)g(be)i
Fl(virtual)f Fp(in)h(C++)g(and)f(we)h(cannot)e(pass)i(the)g(class)h(to)
e(DLG)h(so)g(that)g(it)g(kno)n(ws)0 1190 y(ho)n(w)e(to)g(create)g(and)g
(initialize)g(an)g Fl(ANTLRToken)p Fp(.)28 b(It)20 b(is)h(in)m(v)n(ok)o
(ed)e(in)h(the)g(follo)n(wing)f(manner:)125 1373 y Ft(token)p
354 1373 23 4 v 26 w(to)p 470 1373 V 26 w(fill->makeToken\(gettok\(\),)
p 1662 1373 V 68 w(lextext\);)0 1572 y Fp(where)f Fl(token)p
477 1572 25 4 v 29 w(to)p 606 1572 V 29 w(fill)g Fp(is)h(a)g(pointer)e
(to)h(an)h Fl(ANTLRToken)p Fp(.)27 b(This)18 b(tok)o(en,)g(again,)f
(cannot)g(be)h(created)g(by)g(DLG)g(because)0 1671 y(it')-5
b(s)30 b(size)g(is)g(unkno)n(wn)d(to)i(the)h(DLG)f(support)f(code.)55
b(It)30 b(must)f(be)g(created)g(by)g(the)g(programmer)d(\(normally)h
(just)j(a)g(local)0 1771 y(v)n(ariable\))19 b(and)g(its)j(address)d
(passed)h(to)h(the)f(DLG-based)f(scanner)g(via)i(member)d(function)h
Fl(setToken\(\))p Fp(.)125 1871 y(The)28 b(programmer)e(de\256nes)j(an)
g Fl(ANTLRToken)e Fp(class)j(by)f(deri)n(ving)e(a)j(class)f(from)f
Fl(DLGBasedToken)g Fp(\(if)g(DLG)i(is)0 1970 y(being)19
b(used\320)p Fl(ANTLRTokenBase)f Fp(otherwise\).)28 b(F)o(or)20
b(e)o(xample,)e(a)j(common)d(tok)o(en)h(is)j(pro)o(vided)17
b(with)k(PCCTS:)125 2088 y Ft(class)44 b(ANTLRCommonToken)e(:)i(public)
g(DLGBasedToken)f Fh(f)125 2179 y Ft(protected:)304 2271
y(ANTLRChar)p 757 2271 23 4 v 70 w(text[ANTLRCommonTokenTEXTSIZE+1];)
125 2362 y(public:)304 2453 y(ANTLRCommonToken\(TokenType)d(t,)45
b(ANTLRChar)e(*s\))h(:)h(DLGBasedToken\(t,s\))663 2545
y Fh(f)g Ft(setText\(s\);)e Fh(g)304 2636 y Ft(ANTLRCommonToken\(\))f
Fh(f)p Ft(;)p Fh(g)304 2727 y Ft(ANTLRChar)h(*getText\(\))g
Fh(f)j Ft(return)p 1647 2727 V 70 w(text;)e Fh(g)304
2819 y Ft(void)g(setText\(ANTLRChar)e(*s\))i Fh(f)i Ft(strncpy\()p
1962 2819 V 25 w(text,)e(s,)h(ANTLRCommonTokenTEXTSIZE\);)40
b Fh(g)125 2910 y(g)p Ft(;)0 3101 y Fp(Because)24 b(the)h(parser)e(is)i
(attached)f(to)g(a)h(DLG-based)e(scanner)m(,)h(the)g(parser)g(has)g
(access)h(to)f(the)h(current)d(input)i(line)g(number;)0
3201 y(consequently)-5 b(,)17 b(the)j(line)h(number)d(is)j(not)f
(stored)g(in)g(this)h(tok)o(en)e(de\256nition.)125 3300
y(In)13 b(C)i(output)d(mode,)i(a)g(type)f(called)h Fl(Attrib)f
Fp(is)h(de\256ned)f(by)g(the)h(programmer)d(and)i(a)h(required)e(macro)
g Fl(zzcr)p 3327 3300 25 4 v 30 w(attr\(\))h Fp(is)0
3400 y(in)m(v)n(ok)o(ed)i(to)h(set)h(the)f(attrib)n(utes.)28
b(In)16 b(C++,)h(these)g(items)g(correspond)c(to)k Fl(ANTLRToken)e
Fp(and)g Fl(makeToken\(\))p Fp(,)h(respecti)n(v)o(ely)-5
b(.)125 3499 y(There)24 b(is)j(not)e(a)h(softw)o(are)g(stack)g(of)f
(attrib)n(utes)h(or)f Fl(ANTLRToken)p Fp(s)g(in)h(C++)g(output)e
(mode\320local)g(tok)o(en)h(copies)h(are)0 3599 y(local)20
b(v)n(ariables)g(\(on)f(the)h(hardw)o(are)f(stack\))h(for)g(ef)n
(\256cienc)o(y)e(and)i(ease)h(of)e(deb)n(ugging.)0 3820
y Fa(6.3.2)81 b(ANTLR)21 b(T)-8 b(ok)o(en)22 b(Str)o(eams)0
3976 y Fp(In)d(C++)g(mode,)f(an)h(ANTLR-generated)e(parser)h(consumes)h
Fl(ANTLRToken)p Fp(s)f(from)g(an)h Fl(ANTLRTokenStream)d
Fp(which)j(is)0 4075 y(an)h(object)f(that)h(acts)g(lik)o(e)g(a)g
(pipeline)f(between)g(the)g(parser)h(and)f(le)o(xical)g(analyzer;)g
(the)g(le)o(xical)h(analyzer)m(,)e(in)i(turn,)f(consumes)0
4175 y(characters)i(from)g(a)i(te)o(xt-based)e(input)g(stream.)35
b(An)22 b Fl(ANTLRTokenStream)e Fp(supplies)i(a)g(stream)g(of)g(tok)o
(ens)g(by)g(returning)0 4275 y(the)f(\252ne)o(xt\272)f(tok)o(en)g(for)g
(each)h(call)g(to)g Fl(nextToken\(\))f Fp(and)g(also)h(kno)n(ws)f(ho)n
(w)h(to)g(return)f(the)h(current)e(te)o(xt)i(and)f(line)h(number)0
4374 y(of)f(the)h(current)f(tok)o(en.)29 b(An)21 b Fl(ANTLRTokenStream)
d Fp(can)j(be)g(an)o(ything)d(from)i(a)h(simple)g(array)e(of)i
Fl(TokenType)p Fp(s)f(to)h(a)g(full)0 4474 y(DLG-based)e(scanner)-5
b(.)29 b(Figure)19 b(7)i(depicts)f(the)g(tok)o(en)f(stream)h(hierarchy)
-5 b(.)125 4574 y(T)e(o)12 b(attach)g(a)g(non-DLG-based)g(scanner)g(to)
g(an)g(ANTLR-gener)o(ated)f(parser)l(,)d(the)k(programmer)g(subclasses)
g Fl(ANTLRTokenStream)p Fp(.)0 4673 y(F)o(or)20 b(e)o(xample,)1818
5356 y(12)p eop
%%Page: 13 13
13 12 bop 1385 -293 a
7499121 4210033 3881123 32693534 11380244 36903567 startTexFig
1385 -293 a
%%BeginDocument: parhier.ps
1 setlinejoin
/M { moveto } bind def /S { show } bind def
/R { rmoveto } bind def /L { lineto } bind def
/B { newpath 0 0 M 0 1 L 1 1 L 1 0 L closepath } bind def
/CS { closepath stroke } bind def
/newfont 10 dict def
newfont begin

/FontType 3 def
/FontMatrix [1 0 0 1 0 0] def
/FontBBox [0 0 1 1] def
/Encoding 256 array def
0 1 255 {Encoding exch /.notdef put} for

/CharProcs 1 dict def
CharProcs begin
/.notdef {} def

end

/BuildChar {
1 0
0 0 1 1
setcachedevice
exch begin
Encoding exch get
CharProcs exch get
end
exec
} def
end
/PatternFont newfont definefont pop

/bwproc {
rgbproc
dup length 3 idiv string 0 3 0
5 -1 roll {
add 2 1 roll 1 sub dup 0 eq
{ pop 3 idiv 3 -1 roll dup 4 -1 roll dup
3 1 roll 5 -1 roll put 1 add 3 0 }
{ 2 1 roll } ifelse
} forall
pop pop pop
} def
systemdict /colorimage known not {
/colorimage {
pop
pop
/rgbproc exch def
{ bwproc } image
} def
} if
/incr {
2 1 roll dup 3 -1 roll
5 -1 roll dup 6 1 roll cvi put
3 1 roll dup 4 1 roll add 3 1 roll
} bind def
/scanspan {
/xb2 exch def
/xg2 exch def
/xr2 exch def
/xx2 exch def
/xb1 exch def
/xg1 exch def
/xr1 exch def
/xx1 exch def
/dx xx2 xx1 sub def
dx 0 ne {
/drdx xr2 xr1 sub dx div def
/dgdx xg2 xg1 sub dx div def
/dbdx xb2 xb1 sub dx div def
}{
/drdx 0 def
/dgdx 0 def
/dbdx 0 def
} ifelse
/len dx 1 add cvi 3 mul def
len string dup dup
xr1 drdx 3 -1 roll
0 3 len 1 sub { incr } for
pop pop pop
xg1 dgdx 3 -1 roll
1 3 len 1 sub { incr } for
pop pop pop
xb1 dbdx 3 -1 roll
2 3 len 1 sub { incr } for
3 1 roll pop pop
} bind def
/scantrap {
/trapsave save def
/b4 exch def
/g4 exch def
/r4 exch def
/x4 exch def
/b3 exch def
/g3 exch def
/r3 exch def
/x3 exch def
/b2 exch def
/g2 exch def
/r2 exch def
/y2 exch def
/x2 exch def
/b1 exch def
/g1 exch def
/r1 exch def
/y1 exch def
/x1 exch def
/dy y1 y2 sub def
dy 0 ne {
/dxdy12 x2 x1 sub dy div def
/dxdy43 x3 x4 sub dy div def
/drdy12 r2 r1 sub dy div def
/drdy43 r3 r4 sub dy div def
/dgdy12 g2 g1 sub dy div def
/dgdy43 g3 g4 sub dy div def
/dbdy12 b2 b1 sub dy div def
/dbdy43 b3 b4 sub dy div def
}{
/dxdy12 0 def
/dxdy43 0 def
/drdy12 0 def
/drdy43 0 def
/dgdy12 0 def
/dgdy43 0 def
/dbdy12 0 def
/dbdy43 0 def
} ifelse
y1 -1 y2 {
x4 x1 sub 0 lt { exit } if
/y exch def
/traploopsave save def
x1 r1 g1 b1 x4 r4 g4 b4 scanspan
/img exch def
/xlen x4 x1 sub 1 add def
x1 y translate
xlen 1 scale
xlen cvi 1 8 [xlen 0 0 0.9 0 0] { img } false 3 colorimage
traploopsave restore
/x1 x1 dxdy12 add def
/r1 r1 drdy12 add def
/g1 g1 dgdy12 add def
/b1 b1 dbdy12 add def
/x4 x4 dxdy43 add def
/r4 r4 drdy43 add def
/g4 g4 dgdy43 add def
/b4 b4 dbdy43 add def
} for
trapsave restore
} def
/d {
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/q {
newpath
moveto
lineto
lineto
lineto
closepath
stroke
} bind def
/draw3 {
setgray
newpath
moveto
lineto
lineto
closepath
stroke
} bind def
/F3 {
setgray
newpath
moveto
lineto
lineto
closepath
fill
} bind def
/F4 {
setgray
newpath
moveto
lineto
lineto
lineto
closepath
fill
} bind def
/F5 {
setgray
newpath
moveto
lineto
lineto
lineto
lineto
closepath
fill
} bind def
/showcaseisoencoding [
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /minus /period /slash
/zero /one /two /three /four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
/at /A /B /C /D /E /F /G
/H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W
/X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c /d /e /f /g
/h /i /j /k /l /m /n /o
/p /q /r /s /t /u /v /w
/x /y /z /braceleft
/bar /braceright /asciitilde /guilsinglright
/fraction /florin /quotesingle /quotedblleft
/guilsinglleft /fi /fl /endash
/dagger /daggerdbl /bullet /quotesinglbase
/quotedblbase /quotedblright /ellipsis /trademark
/dotlessi /grave /acute /circumflex
/tilde /macron /breve /dotaccent
/dieresis /perthousand /ring /cedilla
/Ydieresis /hungarumlaut /ogonek /caron
/emdash /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis ] def
/Helvetica-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Helvetica-Bold-SHOWISO exch definefont pop
/Courier-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-Bold-SHOWISO exch definefont pop
/Courier findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding showcaseisoencoding def
currentdict
end
/Courier-SHOWISO exch definefont pop
gsave
0 0 0 setrgbcolor
gsave
0 0 0 setrgbcolor
1 setlinewidth
newpath
116 544 M
116 512 L
stroke
grestore
0 0 0 setrgbcolor
gsave
newpath
49 497 M 29 513 L 203 513 L 203 497 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
59 502 M -0.2 0 (UserGrammarClass) ashow
grestore
0 0 0 setrgbcolor
gsave
newpath
65 545 M 45 561 L 184 561 L 184 545 L
closepath clip newpath
/Courier-SHOWISO findfont 12 scalefont setfont
0 0 0 setrgbcolor
75 550 M -0.2 0 (ANTLRParser) ashow
grestore
grestore
showpage
%%EndDocument

endTexFig
1330 423 a Fp(Figure)19 b(8:)30 b(C++)21 b(P)o(arser)f(Hierarchy)125
699 y Ft(class)44 b(MyTokenStream)e(:)j(public)f(ANTLRTokenStream)e
Fh(f)125 790 y Ft(private:)259 881 y(char)i(c;)125 973
y(public:)259 1064 y(MyTokenStream\(\))e Fh(f)k Ft(c)e(=)h
(getchar\(\);)e Fh(g)259 1155 y Ft(ANTLRTokenBase)g(*nextToken\(\);)125
1247 y Fh(g)p Ft(;)0 1438 y Fp(where)26 b Fl
(MyTokenStream::nextToken\(\))21 b Fp(is)28 b(some)e(function)e(that)i
(embodies)f(a)i(le)o(xical)f(analyzer;)i(i.e.,)f(it)g(breaks)0
1537 y(up)22 b(the)g(input)g(stream)g(into)g(v)n(ocab)n(ulary)e
(symbols.)35 b Fl(nextToken\(\))20 b Fp(returns)i(a)h(pointer)e(to)h
(an)g Fl(ANTLRToken)f Fp(that)h(it)h(has)0 1637 y(initialized.)0
1858 y Fa(6.3.3)81 b(ANTLR)21 b(P)o(arsers)0 2013 y Fp(All)k
(ANTLR-generated)c(parsers)j(in)g(C++)h(mode)e(are)h(deri)n(v)o(ed)e
(classes)j(of)e Fl(ANTLRParser)p Fp(.)40 b(No)24 b(preprocessor)d
(symbols)0 2113 y(are)g(used)g(to)g(de\256ne)g(the)g(structure)f(of)h
(the)g(parser)f(as)i(is)g(done)e(in)h(C)i(mode.)30 b(In)21
b(this)h(w)o(ay)-5 b(,)21 b(the)g(ANTLR-parser)f(support)f(code)0
2213 y(can)k(be)g(compiled)f(separately)h(and)g(link)o(ed)f(with)i(dif)
n(ferent)d(parsers.)39 b(The)23 b(support)f(code)g(senses)i(object)f(v)
n(ariables)g(such)g(as)0 2312 y Fl(demand)p 305 2312
25 4 v 29 w(look)d Fp(and)f Fl(can)p 844 2312 V 30 w(use)p
1024 2312 V 29 w(inf)p 1203 2312 V 29 w(look)p Fp(.)29
b(Figure)20 b(8)g(depicts)g(the)g(parser)g(class)h(hierarchy)-5
b(.)125 2412 y(A)20 b(fe)n(w)g(of)g(the)g(public)f(interf)o(ace)g
(functions)f(are)i(w)o(orth)g(mentioning.)27 b(T)-7 b(o)20
b(access)g(the)g Fn(i)2681 2382 y Fj(th)2769 2412 y Fp(tok)o(en)g(type)
f(of)h(lookahead,)d(use)125 2595 y Ft(inline)43 b(TokenType)h(LA\(int)f
(i\);)0 2794 y Fp(T)-7 b(o)20 b(access)h(a)g(pointer)e(to)h(the)g
Fn(i)889 2764 y Fj(th)978 2794 y Fl(ANTLRToken)f Fp(of)h(lookahead,)d
(use)125 2977 y Ft(inline)43 b(ANTLRTokenBase)g(*LT\(int)g(i\);)125
3176 y Fp(When)17 b(using)g(a)h(non-DLG-based)d(scanner)m(,)h(the)i
(user)f(must)h(inform)e(the)i(parser)f(what)g(tok)o(en)g(type)g(should)
g(be)g(considered)0 3275 y(end-of-input.)26 b(This)19
b(tok)o(en)g(type)h(will)g(then)f(be)h(used)f(by)h(the)g(error)e(reco)o
(v)o(ery)f(f)o(acilities)k(to)f(scan)f(past)h(bogus)f(tok)o(ens)g
(without)0 3375 y(going)g(be)o(yond)f(the)i(end)g(of)g(input.)125
3558 y Ft(void)44 b(setEofToken\(TokenType)d(t\);)125
3757 y Fp(The)23 b(programmer)e(commonly)h(wishes)j(to)f(modify)e(the)i
(standard)f(error)g(reporting)f(f)o(acility)-5 b(.)41
b(T)-7 b(o)24 b(do)f(so)i(in)f(C++)h(mode,)0 3857 y(simply)20
b(subclass)g Fl(Parser)g Fp(and)g(rede\256ne)f Fl(syn\(\))h
Fp(where)f Fl(Parser)h Fp(is)h(your)e(grammar)f(class.)125
4039 y Ft(void)44 b(syn\(ANTLRTokenBase)d(*tok,)j(ANTLRChar)g(*egroup,)
528 4131 y(SetWordType)f(*eset,)h(TokenType)f(etok,)h(int)g(k\);)125
4330 y Fp(When)20 b Fl(syn\(\))f Fp(is)i(rede\256ned,)e(so)h(should)g
Fl(edecode\(\))p Fp(:)125 4512 y Ft(void)44 b(edecode\(SetWordType)d
(*\);)125 4712 y Fp(Upon)27 b(catastrophic)f(error)m(,)j(the)f(follo)n
(wing)e(function)g(is)j(called)f(\(and)f(should)g(ne)n(v)o(er)g
(return\).)51 b(The)28 b(programmer)d(can)0 4811 y(subclass)20
b Fl(Parser)g Fp(and)g(rede\256ne)f Fl(ANTLRPanic)p Fp(:)125
4994 y Ft(void)44 b(ANTLRPanic\(ANTLRChar)d(*msg\);)1818
5356 y Fp(13)p eop
%%Page: 14 14
14 13 bop 125 -210 a Fp(The)19 b(follo)n(wing)g(functions)g(are)h(the)g
(analog)f(of)h(the)g(C)h(mode)f(in\256nite)g(lookahead)e(macros.)125
-92 y Ft(int)44 b(inf)p 443 -92 23 4 v 26 w(LA)p 559
-92 V 27 w(valid\(int)f(i\);)125 -1 y(int)h(inf)p 443
-1 V 26 w(LA\(int)g(i\);)125 91 y(inline)f(inf)p 577
91 V 27 w(line\(int)g(i\);)125 282 y Fp(The)19 b(follo)n(wing)g
Fl(protected)g Fp(member)g(functions)g(can)h(also)g(be)g(rede\256ned:)
125 399 y Ft(virtual)43 b(void)h(tracein\(ANTLRChar)e(*r\);)125
491 y(virtual)h(void)h(traceout\(ANTLRChar)e(*r\);)125
682 y Fp(The)36 b(v)n(arious)f(ANTLR)i(parser)f(class)i(de\256nitions)d
(could)h(ha)n(v)o(e)g(bene\256ted)g(greatly)f(from)h(templates)g(and)g
(multiple)0 781 y(inheritance,)28 b(b)n(ut)g(no)g(current)e(C++)j
(compiler)d(implements)h(these)h(reliably;)k(i.e.,)d(because)e(of)h
(features)f(lik)o(e)i(this)f(C++)h(is)0 881 y(totally)20
b(nonportable)d(due)j(to)g(compiler)f(limitations.)0
1118 y Fb(6.4)99 b(AST)26 b(Classes)0 1274 y Fp(T)-7
b(o)12 b(use)g(ASTs)g(with)g(ANTLR)g(in)g(C++)g(mode,)i(the)e(user)g
(simply)g(deri)n(v)o(es)g(a)g(class)g(from)g(either)g
Fl(ASTBase)g Fp(or)g Fl(ASTDoublyLinked)o(Base)0 1374
y Fp(and)22 b(adds)g(the)g(desired)f(\256elds.)36 b(The)22
b(AST)g(classes)i(automatically)c(kno)n(w)h(ho)n(w)h(to)g(do)g(a)h
(preorder)d(tra)n(v)o(ersal)h(of)h(an)g(AST)-6 b(,)23
b(the)0 1473 y(programmer)17 b(should)i(rede\256ne)125
1591 y Ft(virtual)43 b(void)h(preorder)p 1071 1591 V
26 w(action\(\))f Fh(f)j Ft(;)e Fh(g)125 1682 y Ft(virtual)f(void)h
(preorder)p 1071 1682 V 26 w(before)p 1367 1682 V 26
w(action\(\))f Fh(f)j Ft(printf\(")d(\("\);)h Fh(g)125
1774 y Ft(virtual)f(void)h(preorder)p 1071 1774 V 26
w(after)p 1322 1774 V 26 w(action\(\))f Fh(f)j Ft(printf\(")d(\)"\);)h
Fh(g)0 1965 y Fp(in)20 b(their)g(deri)n(v)o(ed)f(class)i(if)f
(required.)28 b(Figure)19 b(9)h(pro)o(vides)f(a)i(simple)f(e)o(xample)e
(of)i(ho)n(w)g(to)g(use)h(ASTs.)125 2064 y(The)e Fl(zzmk)p
479 2064 25 4 v 30 w(ast\(\))g Fp(and)h Fl(zzcr)p 1119
2064 V 29 w(ast\(\))g Fp(functions)f(are)h(no)n(w)f(embodied)g(by)g
(the)i(AST)f(class)h(constructor)-5 b(.)125 2164 y(#-v)n(ariables)18
b(are)i(used)g(as)h(before)e(and)g(are)i(pointers)e(to)h(the)g
(node\(s\))f(created)h(by)f(tok)o(en)h(and)f(rule)h(references.)0
2402 y Fb(6.5)99 b(DLG)25 b(Classes)0 2557 y Fp(DLG)16
b(generates)f(a)h(class)h(\(def)o(ault)d(name)h(is)i
Fl(DLGLexer)p Fp(\))d(that)i(is)h(deri)n(v)o(ed)d(from)h
Fl(DLGLexerBase)p Fp(.)26 b(DLG-based)14 b(scanners)0
2657 y(read)22 b(input)f(from)h(deri)n(v)o(ed)e(classes)k(of)e
Fl(DLGInputStream)p Fp(,)e(the)j(most)f(common)e(being)i
Fl(DLGFileInput)p Fp(.)34 b(A)22 b(number)0 2756 y(of)e(functions)f
(can)h(be)g(rede\256ned)e(in)j(deri)n(v)o(ed)d(classes;)k(the)e
(interesting)f(ones)h(are:)125 2874 y Ft(virtual)43 b(void)h
(erraction\(\);)125 2966 y(void)178 b(DLGPanic\(DLGChar)42
b(*msg\);)125 3057 y(virtual)h(ANTLRTokenBase)g(*nextToken\(\);)125
3248 y Fp(The)13 b Fl(nextToken\(\))f Fp(function)g(can)h(be)g
(rede\256ned)f(in)i(a)g(subclass)g(so)g(that)f(it)i(kno)n(ws)d(what)i
(an)f Fl(ANTLRToken)g Fp(looks)g(lik)o(e.)0 3347 y(The)23
b(standard)f Fl(nextToken\(\))g Fp(does)h(not)f(ha)n(v)o(e)h(this)h
(luxury)d(and,)i(hence,)g(the)h(user)f(is)h(required)d(to)j(pro)o(vide)
d(DLG-based)0 3447 y(scanners)f(with)g(an)g Fl(ANTLRToken)f
Fp(to)h(\256ll)h(in.)125 3547 y(The)27 b(function)f Fl
(trackColumns\(\))g Fp(can)i(be)g(called)f(to)h(turn)g(on)f(column)g
(tracking.)51 b(This)28 b(is)g(analogous)f(to)h(setting)0
3646 y(preprocessor)18 b(symbol)h Fl(ZZCOL)h Fp(in)g(C)h(mode.)0
3884 y Fb(6.6)99 b(ANTLR)26 b(P)o(arsers)f(and)g(Hand-Built)h(Scanners)
0 4040 y Fp(Because)15 b(of)f(the)h(clean)g(separation)e(of)i(parsing)e
(subtasks)i(follo)n(wed)e(by)i(ANTLR,)g(it)g(is)h(a)f(tri)n(vial)f
(matter)h(to)g(link)f(in)h(a)g(hand-b)n(uilt)0 4139 y(scanner)k(or)h
(an)o(y)f(non-DLG-based)e(scanner)-5 b(.)28 b(Simply)20
b(turn)f(on)g(the)h Fl(-gx)g Fp(ANTLR)g(command)e(line)i(option,)e
(which)i(turns)f(of)n(f)0 4239 y(the)j(generation)d(of)i(DLG)h(input,)f
(and)g(attach)h(an)f(instance)g(of)h(your)e(scanner)h(to)g(an)h
(instance)f(of)g(the)h(parser)f(class)h(generated)0 4339
y(by)k(ANTLR.)h(Figures)g(10,)g(11,)h(and)f(12)f(represent)g(a)h
(complete)f(e)o(xample.)47 b(The)27 b(call)g(to)g Fl(setEofToken\(\))e
Fp(is)j(done)d(to)0 4438 y(inform)g(ANTLR)h(what)g(tok)o(en)f(type)g
(is)i(considered)d(end)i(of)g(input;)i(this)e(is)h(necessary)e(for)h
(all)g(hand-b)n(uilt)e(parsers)i(so)g(that)0 4538 y(ANTLR)20
b(does)g(not)g(try)g(to)h(resynchronize,)c(after)j(a)g(syntax)g(error)m
(,)e(be)o(yond)g(the)i(end)g(of)g(input.)0 4775 y Fb(6.7)99
b(New)25 b(Supplied)i(Files)125 4931 y Fm(\017)41 b Fl(antlrx.h)p
Fp(:)28 b(All)21 b(ANTLR)f(parser)g(support)f(classes)i(and)f(the)g
Fl(ANTLRParser)f Fp(class)i(itself.)125 5097 y Fm(\017)41
b Fl(antlrx.C)p Fp(:)19 b(ANTLR)h(parser)g(support)f(code.)1818
5356 y(14)p eop
%%Page: 15 15
15 14 bop 312 252 a Ft(<<)312 343 y(typedef)44 b(ANTLRCommonToken)e
(ANTLRToken;)312 435 y(#include)i("DLGLexer.h")312 617
y(class)g(AST)h(:)f(public)g(ASTBase)g Fh(f)312 709 y
Ft(public:)492 800 y(ANTLRToken)f(token;)851 b(/*)44
b(this)g(is)h(what)f(I)h(want)f(inside)g(*/)492 891 y(AST\(ANTLRToken)e
(*t\))j Fh(f)g Ft(token)f(=)g(*t;)h Fh(g)90 b Ft(/*)44
b(how)h(to)f(make)g(an)h(AST)f(node)g(*/)492 983 y(void)g(preorder)p
1080 983 23 4 v 25 w(action\(\))g Fh(f)671 1074 y Ft(char)g(*s)h(=)f
(token.getText\(\);)671 1165 y(printf\(")g(\045s",)g(s\);)492
1257 y Fh(g)312 1348 y(g)p Ft(;)312 1531 y(main\(\))312
1622 y Fh(f)492 1713 y Ft(ANTLRToken)f(aToken;)492 1805
y(DLGFileInput)g(in\(stdin\);)492 1896 y(DLGLexer)g(scan\(&in,2000\);)
492 1987 y(scan.setToken\(&aToken\);)492 2078 y(Expr)h
(parser\(&scan\);)492 2261 y(ASTBase)f(*root)h(=)h(NULL;)134
b(//)44 b(make)g(a)h(pointer)f(to)g(fill)g(in)492 2352
y(parser.e\(&root\);)356 b(//)44 b(don't)g(forget)g(to)h(pass)f(the)g
(ptr)g(to)h(the)f(rule)492 2535 y(root->preorder\(\);)311
b(//)44 b(do)h(a)f(preorder)g(traversal)492 2626 y(printf\("\\n"\);)312
2718 y Fh(g)312 2809 y Ft(>>)312 2992 y(#token)g("[\\)h(\\t\\n]+")88
b(<>)312 3083 y(#token)44 b(Eof)h("@")312
3266 y(class)f(Expr)h Fh(f)717 b Ft(/*)45 b(Define)f(a)g(grammar)g
(class)g(*/)312 3448 y(e)135 b(:)f(IDENTIFIER\303n)43
b(Eof!)671 3540 y(< (#1->token.getText\(\),#2->token.getText\(\)\);>)o(>)492
3631 y(;)312 3814 y(n)135 b(:)f(NUMBER)492 3905 y(;)312
4088 y Fh(g)312 4270 y Ft(#token)44 b(IDENTIFIER)133
b("[a-z]+")312 4362 y(#token)44 b(NUMBER)313 b("[0-9]+")1172
4636 y Fp(Figure)19 b(9:)30 b(ANTLR)20 b(Grammar)f(Using)h(ASTs)1818
5356 y(15)p eop
%%Page: 16 16
16 15 bop 312 438 a Ft(<<)312 529 y(typedef)44 b(ANTLRCommonToken)e
(ANTLRToken;)312 621 y(#include)i("MyTokenStream.h")312
712 y(main\(\))312 803 y Fh(f)492 895 y Ft(MyTokenStream)e(scan;)i(/*)h
(create)f(one)g(of)h(my)f(scanners)g(*/)492 986 y(Expr)g
(parser\(&scan\);)e(/*)j(create)f(a)g(parser)g(of)h(type)f(Expr)g
(hooked)g(to)g(my)h(scanner)f(*/)492 1077 y(parser.setEofToken\(Eof\);)
492 1169 y(parser.e\(\);)312 1260 y Fh(g)312 1351 y Ft(>>)312
1534 y(class)g(Expr)h Fh(f)312 1625 y Ft(e)135 b(:)f(IDENTIFIER)43
b(NUMBER)h(Eof)492 1716 y(;)312 1808 y Fh(g)858 2082
y Fp(Figure)20 b(10:)29 b(ANTLR)20 b(Example)f(That)h(Uses)h
(Hand-Built)e(Scanner)312 3536 y Ft(#include)44 b("ATokenStream.h")312
3628 y(class)g(MyTokenStream)f(:)i(public)f(ANTLRTokenStream)e
Fh(f)312 3719 y Ft(private:)447 3810 y(char)i(c;)312
3902 y(public:)447 3993 y(MyTokenStream\(\))e Fh(f)j
Ft(c)g(=)g(getchar\(\);)e Fh(g)447 4084 y Ft(ANTLRTokenBase)f
(*nextToken\(\);)312 4176 y Fh(g)p Ft(;)1063 4450 y Fp(Figure)20
b(11:)29 b(Hand-Built)19 b(Scanner)g(Class)j(De\256nition)1818
5356 y(16)p eop
%%Page: 17 17
17 16 bop 312 526 a Ft(#include)44 b()312 617
y(#include)g()312 709 y(#include)g()312
800 y(#include)g()312 891 y(#include)g("tokens.h")f(/*)i
(include)e(token)h(defs)g(*/)312 983 y(#include)g("antlrx.h")f(/*)i
(include)e(all)i(the)f(ANTLR)g(yuck)g(*/)312 1074 y(#include)g
("MyTokenStream.h")312 1165 y(typedef)g(ANTLRCommonToken)e(ANTLRToken;)
312 1348 y(/*)j(Recognizes)e(Tokens)h(IDENTIFIER)f(and)h(NUMBER)g(*/)
312 1439 y(ANTLRTokenBase)f(*MyTokenStream::nextToken\(\))312
1531 y Fh(f)492 1622 y Ft(static)h(ANTLRToken)f(resultToken;)g(/*)h(we)
h(will)f(return)g(a)g(pointer)g(to)g(this)h(guy)f(*/)492
1713 y(ANTLRChar)f(TokenBuffer[100];)492 1805 y(int)h(index=0;)492
1987 y(while)g(\()g(c==')h(')f(||)h(c=='\\n')e(\))i(c=getchar\(\);)492
2170 y(if)f(\(c==EOF\))g Fh(f)p Ft(resultToken.setType\(Eof\);)d
(return)j(&resultToken;)p Fh(g)492 2352 y Ft(if)g(\(isdigit\(c\)\))f
Fh(f)671 2444 y Ft(while)h(\(isdigit\(c\)\))f(])i Fh(f)850
2535 y Ft(TokenBuffer[index++]=c;)850 2626 y(c)g(=)g(getchar\(\);)671
2718 y Fh(g)671 2809 y Ft(TokenBuffer[index]='\\0';)671
2900 y(resultToken.makeToken\(NUMBER,)40 b(TokenBuffer\);)671
2992 y(return)k(&resultToken;)492 3083 y Fh(g)492 3266
y Ft(if)g(\(isalpha\(c\)\))f Fh(f)671 3357 y Ft(while)h
(\(isalpha\(c\)\))f Fh(f)850 3448 y Ft(TokenBuffer[index++]=c;)850
3540 y(c)i(=)g(getchar\(\);)671 3631 y Fh(g)671 3722
y Ft(TokenBuffer[index]='\\0';)671 3814 y
(resultToken.makeToken\(IDENTIFIER,)39 b(TokenBuffer\);)671
3905 y(return)44 b(&resultToken;)492 3996 y Fh(g)312
4088 y(g)900 4362 y Fp(Figure)20 b(12:)29 b(Hand-Built)19
b(Scanner)g Fl(nextToken\(\))g Fp(Function)1818 5356
y(17)p eop
%%Page: 18 18
18 17 bop 125 -210 a Fm(\017)41 b Fl(dlgx.h)p Fp(:)28
b(DLG)21 b(scanner)e(support)g(classes)i(and)f Fl(DLGLexerBase)e
Fp(class.)125 -44 y Fm(\017)41 b Fl(dlgx.C)p Fp(:)19
b(DLG)i(scanner)e(support)g(code.)125 122 y Fm(\017)41
b Fl(astx.h)p Fp(:)28 b(AST)21 b(class)g(de\256nition.)125
288 y Fm(\017)41 b Fl(astx.C)p Fp(:)19 b(AST)i(support)e(code.)125
454 y Fm(\017)41 b Fl(DLexer.C)p Fp(:)18 b(Support)g(code)h(that)h
(must)g(be)f(a)o(w)o(are)g(of)h(the)f(particular)f(scanner)h(generated)
f(by)h(DLG.)h(This)f(is)i(an)e(ugly)208 554 y(mechanism)f(and)i(will)h
(change)e(in)h(future)f(v)o(ersions.)125 720 y Fm(\017)41
b Fl(AToken.h)p Fp(:)24 b(De\256nitions)12 b(for)g(classes)g
Fl(ANTLRTokenBase)p Fp(,)f Fl(DLGBasedToken)p Fp(,)g(and)h
Fl(ANTLRCommonToken)p Fp(.)125 886 y Fm(\017)41 b Fl(ATokenStream.h)p
Fp(:)27 b(De\256nition)19 b(of)h(class)i Fl(ANTLRTokenStream)p
Fp(.)0 1124 y Fb(6.8)99 b($-V)-9 b(ariables)24 b(in)h(C++)g(Mode)0
1279 y Fp(Because)g(attrib)n(utes)g(do)f(not)h(e)o(xist)g(in)g(C++)g
(mode,)g($-v)n(ariables)e(point)h(to)h Fl(ANTLRToken)p
Fp(s.)42 b(Further)m(,)24 b($-v)n(ariables)f(do)i(not)0
1379 y(e)o(xist)20 b(for)g(rule)f(references.)28 b(Rule)20
b(ar)o(guments)e(and)i(return)f(v)n(alues)g(should)g(be)h(used)g
(instead.)29 b(W)-7 b(e)21 b(anticipate)e(the)i(remo)o(v)n(al)d(of)0
1479 y($-v)n(ariables)i(all)i(together)e(in)i(future)e(releases)i(in)g
(f)o(a)n(v)n(or)f(of)g(labels)h(for)e(rule)i(elements)f(such)g(as)h(in)
g(the)g(tree-parser)e(generator)0 1578 y(SORCERER.)125
1678 y($-v)n(ariables)e(are)i(pointers)f(to)i Fl(ANTLRToken)p
Fp(s)e(e)o(xclusi)n(v)o(ely)f(in)j(C++)f(mode.)0 1916
y Fb(6.9)99 b(Semantic)26 b(Pr)n(edicates)0 2071 y Fp(Semantic)19
b(predicates)f(should)g(reference)f Fl(LT\()p Fn(i)p
Fl(\)->getText\(\))f Fp(instead)j(of)g Fl(LATEXT\()p
Fn(i)p Fl(\))e Fp(as)j Fl(LATEXT)e Fp(does)h(not)g(e)o(xist.)0
2309 y Fb(6.10)99 b(Con)l(v)o(erting)25 b(a)g(1.10)f(Grammar)h(to)g
(1.20)f(C++)g(Grammar)0 2465 y Fp(This)e(section)f(describes)g(the)g
(procedure)e(we)j(used)f(to)h(con)m(v)o(ert)d(the)j(PCCTS)h(1.10)d(C)j
(grammar)c(from)i(C)h(to)g(C++)g(mode)e(\(this)0 2564
y(co)o(v)o(ers)f(most,)h(b)n(ut)g(not)g(all)h(issues\);)g(\252your)d
(mileage)i(may)g(v)n(ary)-5 b(.)f(\272)125 2747 y Fm(\017)41
b Fp(Remo)o(v)o(e)19 b Fl(#parser)g Fp(directi)n(v)o(e)g(if)h(an)o(y)-5
b(.)125 2913 y Fm(\017)41 b Fl(typedef)20 b(ANTLRToken)g
Fp(to)i(something)e(or)h(deri)n(v)o(e)f(a)h(class.)34
b(Remo)o(v)o(e)20 b Fl(#include)48 b("charbuf.h")20 b
Fp(or)h(other)208 3012 y(pre)n(vious)d Fl(Attrib)i Fp(de\256nition.)125
3179 y Fm(\017)41 b Fp(Add)19 b(a)i(grammar)d(class)k(\252wrapper\272)c
(around)g(your)h(grammar)g(rules.)125 3345 y Fm(\017)41
b Fp(Con)m(v)o(ert)27 b(AST)i(stuf)n(f:)46 b(\(1\))28
b(mak)o(e)h(a)g Fl(class)49 b(AST)28 b Fp(de\256nition.)54
b(\(2\))28 b(Add)g(\256elds)i(in)e Fl(AST)p 2935 3345
25 4 v 30 w(FIELDS)g Fp(macro)g(to)h(the)208 3444 y Fl(class)48
b(AST)30 b Fp(de\256nition)e(as)i(\256elds.)56 b(\(3\))29
b(Remo)o(v)o(e)f Fl(zzcr)p 2026 3444 V 29 w(ast)h Fp(and)f(mak)o(e)h
(that)g(the)h(constructor)-5 b(.)54 b(\(4\))29 b(Remo)o(v)o(e)208
3544 y Fl(zzmk)p 413 3544 V 29 w(ast)19 b Fp(if)h(you)f(ha)n(v)o(e)g
(it)h(and)f(mak)o(e)g(it)h(another)e(constructor)g(\(no)h(need)g(to)g
(con)m(v)o(ert)f(an)o(y)g Fl(#[args])h Fp(references)f(in)208
3643 y(the)i(grammar\).)125 3810 y Fm(\017)41 b Fp(Add)19
b(a)i Fl(#include)48 b("DLGLexer.h")19 b Fp(in)h(the)g(parser)g(\(or)f
(whate)n(v)o(er)g(you)g(call)i(the)f(le)o(xical)g(analyzer)f(class\).)
125 3976 y Fm(\017)41 b Fp(Con)m(v)o(ert)18 b(all)j Fl($)p
Fn(i:bl)r(ah)e Fp(to)h Fl($)p Fn(i)p Fm(\000)i Fn(>)h(bl)r(ah)p
Fp(.)125 4142 y Fm(\017)41 b Fp(Con)m(v)o(ert)18 b(all)j
Fl(LATEXT\()p Fn(i)p Fl(\))e Fp(to)h Fl(LT\()p Fn(i)p
Fl(\)->getText\(\))p Fp(.)125 4308 y Fm(\017)41 b Fp(De\256nitions)19
b(in)i Fl(#header)e Fp(can)h(come)g(afterw)o(ards)f(\(i.e.,)h(do)f(not)
h(use)h(the)f(directi)n(v)o(e)f(an)o(ymore\).)125 4474
y Fm(\017)41 b Fp(Con)m(v)o(ert)18 b(all)j Fl($0=)p Fn(bl)r(ah)p
Fp(,)e Fl($$=)p Fn(bl)r(ah)p Fp(,)f(or)i Fl($)p Fn(r)r(ul)r(e)p
Fl(=)p Fn(bl)r(ah)f Fp(to)h(a)h(return)e(v)n(alue)g(or)h
(\252by-reference\272)d(ar)o(gument.)125 4640 y Fm(\017)41
b Fp(Con)m(v)o(ert)18 b(the)i Fl(ANTLR\(\))g Fp(macro)f(reference)g
(into)h(the)g(series)h(of)e(object)h(de\256nitions)g(outline)f(in)h
(this)h(document.)1818 5356 y(18)p eop
%%Page: 19 19
19 18 bop 0 -210 a Fo(7)116 b(Semantic)28 b(Pr)n(edicate)f(Hoisting)0
-24 y Fp(The)22 b(hoisting)g(of)h(predicates)f(in)h(v)o(ersion)e(1.10)h
(had)g(a)h(number)e(of)i(b)n(ugs)f(that)h(ha)n(v)o(e)f(been)g(\256x)o
(ed.)37 b(In)22 b(addition,)g(v)o(ersion)g(1.20)0 75
y(has)17 b(changed)d(the)j(semantics)f(of)g(semantic)g(predicate)f
(hoisting)h(slightly)g(to)g(gain)g(a)h(useful)f(feature.)26
b(W)-7 b(e)18 b(be)o(gin)d(by)h(describing)0 175 y(the)k(b)n(ug)g
(\256x.)125 275 y(The)f(follo)n(wing)g(grammar)f(no)n(w)i(beha)n(v)o
(es)f(as)i(adv)o(ertised:)125 392 y Ft(a)44 b(:)h(<>?)f(b)214
484 y(|)h(ID)214 575 y(;)125 666 y(b)f(:)h(<>?)f(ID)214
758 y(|)h(<>?)f(ID)214 849 y(;)125 1040 y Fp(It)20
b(results)h(in)f(the)g(follo)n(wing)f(code)g(for)h Fl(a)p
Fp(:)125 1158 y Ft(void)44 b(a\(void\))125 1249 y Fh(f)304
1340 y Ft(...)304 1432 y(if)g(\()h
(\(LA\(1\)==ID\)&&\(\(p1\)&&\(\(p2\)||\(p3\)\)\))39 b(\))45
b Fh(f)483 1523 y Ft(if)g(\(!\(p1\)\))e(zzfailed)p 1340
1523 23 4 v 26 w(pred\(\(ANTLRChar)f(*\)")89 b(p1"\);)44
b(//unused)483 1614 y(b\(\);)304 1706 y Fh(g)304 1797
y Ft(else)g Fh(f)483 1888 y Ft(if)h(\()f(\(LA\(1\)==ID\))f(\))i
Fh(f)663 1980 y Ft(zzmatch\(ID\);)d(zzCONSUME;)483 2071
y Fh(g)483 2162 y Ft(else)i(...)125 2254 y Fh(g)0 2444
y Fp(Note)21 b(that)g(the)g(follo)n(wing)f(semantics)h(indicate)f(the)h
(correct)f(semantic)h(v)n(alidity)f(of)h(production)d(one)j(of)g
Fl(a)p Fp(:)31 b(\252)p Fl(p1)21 b Fp(and)g(\()p Fl(p2)g
Fp(or)0 2544 y Fl(p3)p Fp(\).)-6 b(\272)29 b(In)20 b(v)o(ersion)f
(1.10,)g(the)h(\252or\272)g(w)o(as)h(an)f(\252and.)-6
b(\272)125 2644 y(In)19 b(1.10,)f(we)j(indicated)d(that)i(predicates)f
(were)h(hoisting)e(ONL)-8 b(Y)20 b(if)g(the)g(grammar)e(w)o(as)i
(syntactically)f(ambiguous.)27 b(This)0 2743 y(had)g(the)g(unfortunate)
d(ef)n(fect)j(of)g(making)e(it)j(impossible)f(to)g(include)f(a)i
(predicate)e(in)h(the)g(loop)f(decision)h(for)f Fl(\(..\)+)h
Fp(and)0 2843 y Fl(\(..\)*)k Fp(subrules)g(if)h(only)e(one)h(alternati)
n(v)o(e)f(w)o(as)j(present.)62 b(W)-7 b(e)33 b(ha)n(v)o(e)e(changed)e
(the)j(meaning)e(of)h(semantic)g(predicates)0 2943 y(slightly)25
b(so)g(that)h(if)f(only)f(one)h(alternati)n(v)o(e)f(e)o(xists)h(in)h(a)
f(looping)e(subrule,)j(all)f(visible)g(predicates)g(are)g(AL)-6
b(W)c(A)h(YS)26 b(hoisting.)0 3042 y(F)o(or)20 b(e)o(xample,)125
3160 y Ft(a)44 b(:)h(<>)537 b(//)44 b(match)g(exactly)g(5)h
(A's)304 3251 y(\()g(<0>>?)e(A)i(<>)e(\)+)214
3342 y(;)125 3533 y Fp(In)18 b(1.10,)f(this)j(w)o(ould)d(ha)n(v)o(e)h
(resulting)g(in)h(a)g(loop)f(that)h(only)e(tested)i(the)g(lookahead.)26
b(In)19 b(1.20,)e(the)i(follo)n(wing)e(is)i(generated)0
3633 y(for)h(the)g Fl(\(..\)+)g Fp(loop:)125 3751 y Ft(if)44
b(\(\(\(i>0\)\)\))f Fh(f)304 3842 y Ft(do)h Fh(f)483
3933 y Ft(if)h(\(!\(i>0\)\))e(zzfailed)p 1385 3933 V
26 w(pred\(\(ANTLRChar)f(*\)")89 b(i>0"\);)44 b(//)h(unused)483
4025 y(zzLOOP\(zztasp2\);)304 4116 y Fh(g)g Ft(while)f(\()h
(\(LA\(1\)==A\)&&\(\(i>0\)\))c(\);)125 4207 y Fh(g)0
4579 y Fo(8)116 b(C)29 b(AST)f(Changes)0 4764 y Fp(In)e(C)h(mode,)f
(the)h(programmer)c(can)j(de\256ne)f(the)h(preprocessor)e(symbol)i
Fl(USER)p 2404 4764 25 4 v 29 w(DEFINED)p 2783 4764 V
28 w(AST)g Fp(which)g(allo)n(ws)h(the)f(pro-)0 4864 y(grammer)19
b(to)i(de\256ne)f(the)h Fl(AST)f Fp(type)h(themselv)o(es.)30
b(The)20 b(macro)g Fl(AST)p 2043 4864 V 29 w(REQUIRED)p
2472 4864 V 28 w(FIELDS)h Fp(is)g(the)g(minimum)e(set)j(of)e(AST)0
4964 y(\256elds)h(needed)e(by)g(ANTLR;)i(as)g(such,)e(it)i(functions)e
(lik)o(e)i(inheritance)d(in)j(C++.)29 b(F)o(or)20 b(e)o(xample,)1818
5356 y(19)p eop
%%Page: 20 20
20 19 bop 125 -201 a Ft(typedef)43 b(struct)p 801 -201
23 4 v 71 w(ast)h Fh(f)663 -110 y Ft(AST)p 802 -110 V
26 w(REQUIRED)p 1188 -110 V 25 w(FIELDS;)g(//)h(order)f(is)g
(unimportant)681 -19 y Fs(my)19 b(stuf)o(f)p Ft(;)483
72 y Fh(g)45 b Ft(AST;)0 263 y Fp(The)17 b(structure)f(name)h(must)g
(be)p 934 263 25 4 v 48 w Fl(ast)g Fp(for)g(the)g Fl(AST)p
1515 263 V 29 w(REQUIRED)p 1944 263 V 29 w(FIELDS)f Fp(to)i(w)o(ork.)28
b(If)17 b(it)h(is)g(not)f(used,)g(the)h(structure)e(name)0
363 y(can)k(be)g(an)o(ything.)0 642 y Fo(9)116 b(New)29
b(Command-Line)e(Options)0 827 y Fp(The)20 b(follo)n(wing)e(ANTLR)j
(command)d(line)i(options)g(are)g(ne)n(w:)125 1002 y
Fm(\017)41 b Fl(-CC)p Fp(:)20 b(Generate)f(C++)i(output.)125
1165 y Fm(\017)41 b Fl(-o)p Fp(:)28 b(Directory)16 b(where)h(output)f
(\256les)i(should)e(go)h(\(def)o(ault="."\).)26 b(This)18
b(is)g(v)o(ery)e(nice)i(for)e(k)o(eeping)g(the)i(source)e(directory)208
1264 y(clear)k(of)g(ANTLR)g(and)g(DLG)g(spa)o(wn.)125
1427 y Fm(\017)41 b Fl(-ct)p Fp(:)28 b(Do)17 b(not)g(mak)o(e)f(copies)h
(of)g(tok)o(ens)g(passed)g(to)g(the)g(parser)g(in)g(C++)h(mode)e(\(def)
o(ault=to)g(cop)o(y\).)27 b(When)17 b(using)f(DLG)208
1527 y(in)22 b(conjunction)d(with)j(ANTLR,)g(you)f(will)i(al)o(w)o(ays)
f(w)o(ant)g(ANTLR)g(to)g(mak)o(e)g(copies)f(because)g(DLG)h(only)f(has)
i(space)208 1626 y(for)e(one)h Fl(ANTLRToken)f Fp(\(which)g(is)j
(passed)e(to)g(the)h(scanner)e(with)i Fl(setToken)p Fp(\);)f(this)h
(address)e(is)j(al)o(w)o(ays)e(returned)208 1726 y(and,)d(hence,)g
(without)h(copies,)f(all)i($-v)n(ariables)d(w)o(ould)i(point)f(to)i
(the)f(same)g Fl(ANTLRToken)p Fp(.)0 1900 y(The)g Fl(-ai)g
Fp(option)f(has)h(been)g(remo)o(v)o(ed)e(in)i(anticipation)f(of)h(an)g
(ANTLR)g(graphical)f(interf)o(ace.)125 2000 y(The)g(follo)n(wing)g(DLG)
h(command)f(line)h(options)f(are)h(ne)n(w:)125 2175 y
Fm(\017)41 b Fl(-CC)p Fp(:)20 b(Generate)f(C++)i(output.)125
2337 y Fm(\017)41 b Fl(-o)p Fp(:)28 b(Directory)16 b(where)h(output)f
(\256les)i(should)e(go)h(\(def)o(ault="."\).)26 b(This)18
b(is)g(v)o(ery)e(nice)i(for)e(k)o(eeping)g(the)i(source)e(directory)208
2437 y(clear)k(of)g(ANTLR)g(and)g(DLG)g(spa)o(wn.)125
2600 y Fm(\017)41 b Fl(-cl)49 b Fn(cl)r(ass)p Fp(:)26
b(Specify)15 b(a)g(class)h(name)e(for)h(DLG)g(to)g(generate.)26
b(The)15 b(def)o(ault)f(is)i Fl(DLGLexer)p Fp(.)27 b
Fn(cl)r(ass)14 b Fp(will)i(be)f(a)g(subclass)208 2699
y(of)k Fl(DLGLexerBase)p Fp(.)0 2874 y(Also)26 b(note)f(that)h(in)g
(C++)g(mode,)g(DLG)g(no)n(w)f(does)h(not)f(accept)h(the)f(output)g
(\256le)h(name)f(on)h(the)g(command)d(line.)46 b(The)26
b(class)0 2974 y(name)20 b(speci\256ed)f(\(or)h(the)g(def)o(ault)g(of)g
Fl(DLGLexer)p Fp(\))f(is)i(used)f(to)g(deri)n(v)o(e)f(the)h(output)f
(\256le)i(name:)125 3156 y Ft(dlg)44 b Fi(options)h(par)r(ser)n(:dl)q
(g)0 3535 y Fo(10)116 b(Miscellaneous)29 b(New)f(Additions)0
3720 y Fp(The)20 b(follo)n(wing)e(minor)i(changes)f(were)h(made:)125
3895 y Fm(\017)41 b Fp(A)16 b(ne)n(w)g(character)e(type)i(is)h(used)e
(for)h(ANTLR)g(and)f(DLG)h Fl(ANTLRChar)f Fp(and)h Fl(DLGChar)f
Fp(respecti)n(v)o(ely)f(in)i(C++)h(mode.)208 3994 y(Normally)i(these)i
(are)f('char',)f(b)n(ut)i(you)f(can)g(change)f(the)i
Fl(typedef)f Fp(to)h(whate)n(v)o(er)e(you)g(wish)i(\(you)f(can)g(e)n(v)
o(en)g(mak)o(e)g(it)208 4094 y(a)g(class\).)125 4257
y Fm(\017)41 b Fp(ASTs)20 b(were)h(incorrectly)d(handled)h(in)h
(conjunction)e(with)i(1.10)f(syntactic)h(predicates\320this)f(has)i
(been)e(\256x)o(ed.)125 4420 y Fm(\017)41 b Fp(The)14
b(return)g(v)n(alues)g(of)g(rule)o(s)g(were)g(still)g(assigned)f(in)g
(gu)o(ess)h(mod)o(e)g(\(wh)o(en)f(using)g(syn)o(tactic)h(p)o(red)o
(icates\);)c(the)k(ar)o(guments)208 4519 y(are)20 b(still)h(e)n(v)n
(aluated.)28 b(This)20 b(is)h(perhaps)e(not)h(too)g(bright.)125
4682 y Fm(\017)41 b Fp(W)-7 b(arnings)19 b(about)h(missing)g
Fl(#header)f Fp(no)n(w)h(require)f(that)h Fl(-w2)g Fp(ANTLR)h(option)e
(be)h(set.)125 4845 y Fm(\017)41 b Fp(Allo)n(ws)20 b
Fl(#parser)g Fp(to)g(come)f(\256rst)i(\(before)e Fl(#header)p
Fp(\))125 5008 y Fm(\017)41 b Fp(Fix)o(ed)17 b(a)h(b)n(ug)g(so)g(that)g
(\252)p Fl(\(A)50 b(B\)+)f(A)h(C)p Fp(\272)18 b(will)h(no)n(w)e
(terminate)g(the)h(loop)f(upon)g(\252)p Fl(A)50 b(C)p
Fp(\272)18 b(whereas)f(before)g(it)i(w)o(ould)e(just)208
5107 y(loop)i(fore)n(v)o(er)f(\(it)j(w)o(as)g(not)e(using)h(enough)e
(lookahead\).)1818 5356 y(20)p eop
%%Page: 21 21
21 20 bop 125 -210 a Fm(\017)41 b Fp(When)17 b(a)h(tok)o(en)e(label)i
(\(for)e(which)h(there)g(is)h(no)f(re)o(gular)f(e)o(xpression\))g(is)i
(referenced)d(in)j(a)g(rule,)f(a)h(w)o(arning)e(is)i(generated)208
-110 y(\(if)i(the)g(ANTLR)g(command)f(line)h(option)f
Fl(-w2)h Fp(is)h(speci\256ed\).)125 56 y Fm(\017)41 b
Fp(Fix)o(ed)21 b(a)i(nasty)f(b)n(ug)g(that)h(caused)f(ANTLR)g(to)h
(loop)e(fore)n(v)o(er)g(\(and)g(a)i(day\))f(upon)f(v)o(ery)g(lar)o(ge)g
(grammars)g(with)i(lots)g(of)208 156 y(optional)18 b(subrules.)125
322 y Fm(\017)41 b Fp(ANTLR)16 b(itself)h(tends)e(to)i(gi)n(v)o(e)e
(better)h(error)f(messages)h(no)n(w;)h(e.g.,)f(le)o(xical)g(errors)f
(gi)n(v)o(e)g(the)h(\256le)h(no)n(w)e(and)h(grammatical)208
421 y(errors)j(\(emplo)o(ying)f Fl(#errclass)p Fp(es\))h(are)h(more)f
(readable.)0 701 y Fo(11)116 b(Futur)n(e)0 887 y Fp(Our)21
b(w)o(ork)f(on)h(ANTLR)h(continues)e(to)h(be)g(hea)n(vily)g
(in\257uenced)e(by)i(the)g(feedback)f(from)g(our)g(industrial)h(and)f
(academic)h(user)0 987 y(community)-5 b(.)27 b(As)21
b(such,)e(we)i(are)f(currently)e(de)n(v)o(eloping)g(or)i(planning)e
(the)i(follo)n(wing)f(impro)o(v)o(ements)e(and)j(tools.)125
1169 y Fm(\017)41 b Fp(Good)28 b(error)h(reco)o(v)o(ery)e(and)i
(reporting)f(is)j(notoriously)c(dif)n(\256cult)i(to)h(achie)n(v)o(e)f
(with)h(parser)f(generators,)h(especially)208 1269 y
Fn(LALR)q Fp(-based)i(tools.)69 b(W)-7 b(e)35 b(are)f(de)n(v)o(eloping)
d(a)j(sophisticated)f(error)g(handling)f(mechanism)g(analogous)g(to)i
(C++)208 1368 y(e)o(xception)18 b(handling)g(called)i
Fc(par)o(ser)h(e)n(xception)e(handling)f Fp(that)i(approaches)f(the)h
(\257e)o(xibility)f(of)h(hand-b)n(uilt)f(parsers.)125
1534 y Fm(\017)41 b Fp(The)18 b(recognition)e(strength)i(of)g(hand-b)n
(uilt)f(parsers)h(arises)h(from)e(the)i(f)o(act)g(that)f
(arbitrarily-comple)o(x)d(e)o(xpressions)i(can)208 1634
y(be)23 b(used)g(to)h(distinguish)f(between)f(alternati)n(v)o(e)g
(productions.)37 b(W)-7 b(e)25 b(will)f(introduce)e(a)i(ne)n(w)f(type)g
(of)g(predicate)g(called)208 1734 y(a)31 b Fc(pr)m(ediction)e(pr)m
(edicate)g Fp(that)i(constitutes)f(the)h(entire)f(prediction)f(e)o
(xpression)g(for)h(a)g(particular)g(production;)j(i.e.,)208
1833 y(ANTLR)17 b(does)f(not)g(generate)g(code)g(to)h(test)g(lookahead)
e(for)h(the)g(associated)h(production.)25 b(W)-7 b(e)18
b(anticipate)e(the)h(notation:)208 1933 y(\252)p Fl(<<)p
Fc(this-is-the-entir)m(e-pr)m(ediction-e)n(xpr)m(ession)p
Fl(>>?!)p Fp(\272)o(.)125 2099 y Fm(\017)41 b Fp(A)22
b(graphical)e(user)h(interf)o(ace)g(is)h(planned)e(and)h(a)h(coder)e
(has)i(been)f(tentati)n(v)o(ely)f(\252pressed\272)h(into)g(service.)33
b(This)22 b(\252GUI\272)208 2199 y(will)17 b(display)g(syntax)f
(diagrams)h(on)f(the)h(screen)g(and,)g(hence,)g(ambiguities)f(in)h(the)
g(grammar)f(can)h(be)g(highlighted.)26 b(The)208 2298
y(output)19 b(of)g(the)i(GUI)f(will)h(be)f(an)g(ANTLR)h(grammar)d(or)i
(a)h(PostScript)f(representation)e(of)i(the)g(syntax)f(diagram.)125
2464 y Fm(\017)41 b Fp(W)-7 b(e)12 b(intend)g(to)g(yank)g(the)g
(in\256nite)g(lookahead)g(mechanism)g(ou)o(t)g(of)g Fl(ANTLRP)o(arser)g
Fp(an)o(d)g(pu)o(t)g(it)g(in)g Fl(ANTLRTokenS)o(tream)208
2564 y Fp(where)19 b(it)i(belongs.)125 2747 y([)p Fz(The)j(user)o(s)f
(of)h(PCCTS)i(should)c(be)j(for)l(e)o(warned)e(that)h(we)h(anticipate)d
(a)i(br)l(eak)h(with)f(total)f(bac)n(kwar)l(d)0 2846
y(compatibility)29 b(for)i(a)g(futur)l(e)g(r)l(elease)h(\(perhaps)f
(PCCTS)h(2.00\).)55 b(This)31 b(r)l(elease)h(is)f(intended)g(to)g
(\256x)g(the)0 2946 y(odious)22 b(C)h(output)e(g)o(ener)o(ated)h(by)h
(the)g(curr)l(ent)f(ver)o(sion)h(of)f(ANTLR/DLG)i(and)e(will)h(r)l
(esult)f(in)g(a)h(modi\256ed)0 3045 y(gr)o(ammar)g(meta-langua)o(g)o(e)
h(plus)g(the)h(r)l(emo)o(val)g(of)f(some)h(par)o(sing)e(modes.)36
b(Any)25 b(book)g(on)f(PCCTS)i(to)f(be)0 3145 y(written)30
b(will)g(describe)g(this)g(ver)o(sion)f(of)h(r)l(eality)-5
b(.)52 b(Also)30 b(r)l(emember)h(that)e(the)h(C++)i(output)d(is)h
(going)f(to)0 3245 y(c)o(hang)o(e)24 b(as)h(we)g(learn)f(mor)l(e)h
(about)f(it.)p Fp(])0 3525 y Fo(12)116 b(Ackno)o(wledgements)0
3711 y Fp(Thanks)22 b(are)g(due)g(to)h(Sumana)f(Srini)n(v)n(asan,)f
(Mik)o(e)i(Mone)o(gan,)d(and)i(Ste)n(v)o(e)h(Narof)n(f)e(of)h(NeXT)-6
b(,)23 b(Inc.)36 b(for)22 b(their)g(e)o(xtensi)n(v)o(e)f(help)0
3810 y(in)k(the)g(initial)h(de\256nition)e(of)g(the)h(ANTLR)h(C++)f
(parser)-5 b(.)44 b(The)o(y)24 b(are)h(also)g(instrumental)f(in)h(the)g
(ongoing)e(design)h(of)h(parser)0 3910 y(e)o(xception)18
b(handling.)125 4009 y(W)-7 b(e)25 b(thank)e(Gary)g(Funck)h(at)g
(Intrepid)f(for)g(his)i(e)o(xtensi)n(v)o(e)d(testing)i(of)g(ANTLR)g
(and)g(DLG)g(plus)g(his)h(constant)e(stream)h(of)0 4109
y(e)o(xcellent)19 b(suggestions.)125 4209 y(Ste)n(v)o(e)14
b(Robenalt)g(at)g(Rockwell)g(is)g(single-h)o(an)o(ded)o(ly)f(push)o
(ing)g(the)g Fl(com)o(p.com)o(piler)o(s.pcct)o(s)h Fp(n)o(e)n(ws)g(g)o
(ro)o(up)f(thr)o(ou)o(gh)o(,)0 4308 y(is)21 b(helping)e(with)h(the)h(w)
o(orkshop,)d(and)h(is)i(porting)e(PCCTS)j(to)e(a)h(number)d(of)i(dif)n
(ferent)e(platforms.)125 4408 y(W)-7 b(e)21 b(thank)e(T)-7
b(om)20 b(Moog)f(\()p Fl([email protected])p Fp(\))e(for)j(his)g(f)o
(antastic)h Fl(NOTES.newbie)d Fp(information.)125 4508
y(Ariel)d(T)-7 b(amches)14 b(\()p Fl([email protected])p
Fp(\))d(deserv)o(es)j(credit)h(for)f(spending)g(a)h(week)g(of)f(his)i
(Christmas)f(v)n(acation)e(in)0 4607 y(the)19 b(wilds)g(of)g(Minnesota)
f(helping)g(me)g(with)i(the)f(C++)g(output;)f(he)h(de)n(v)o(eloped)e
(the)h(majority)g(of)h(the)g(code)f(for)g(the)h(hand-b)n(uilt)0
4707 y(scanner)g(C++)i(e)o(xample.)125 4806 y(The)g(C++)h(output)f(w)o
(as)h(also)g(in\257uenced)e(by)i(Thom)e(W)-7 b(ood)22
b(\()p Fl([email protected])p Fp(\))c(and)j(Randy)g(Helzerman)0
4906 y Fl([email protected])p Fp(.)1818 5356 y(21)p
eop
%%Page: 22 22
22 21 bop 125 -210 a Fp(Anthon)o(y)23 b(Green)i(at)h(V)-5
b(isible)26 b(Decisions,)h(John)e(Hall)h(at)g(W)-7 b(orcester)26
b(Polytechnic)e(Institute,)j(De)n(vin)e(Hook)o(er)f(at)i(Ellery)0
-110 y(Systems,)e(K)n(enneth)f(D.)g(W)-7 b(einert)24
b(at)g(Information)d(Handling)h(Services,)h(and)g(Ro)o(y)h(Le)n(v)n(o)n
(w)f(at)g(Florida)g(Atlantic)h(Uni)n(v)o(ersity)0 -11
y(helped)19 b(beta)h(test)h(1.20.)125 89 y(Sriram)c(Sankar)f(at)i(Sun)g
(Microsystems)f(has)h(help)f(deb)n(ug)f(a)i(number)e(of)h(features)g
(including)f(the)i(in\256nite)f(lookahead)e(line)0 189
y(number)j(tracking)h(and)h(has)g(pro)o(vided)e(a)j(\256x)f(to)g(mak)o
(e)g(DLG)g Fl(char)p Fp(-size)g(independent,)e(which)h(we)i(hope)e(to)h
(include)f(soon.)125 288 y(John)g(Hall)i(\()p Fl([email protected])p
Fp(\))c(ported)i(PCCTS)i(to)f(V)-5 b(isual)21 b(C++.)125
388 y(W)-7 b(e)33 b(w)o(ould)f(also)h(lik)o(e)g(to)g(thank)f(the)h
(multitude)e(of)i(other)f(users)h(of)f(PCCTS)i(for)e(their)h(e)o
(xcellent)e(suggestions)h(and)0 488 y(beta-testing)19
b(of)h(the)g(ne)n(w)g(C++)h(parsers.)1818 5356 y(22)p
eop
%%Trailer
end
userdict /end-hook known{end-hook}if
%%EOF
i(C++)h(mode.)208 3994 y(Normally)i(these)i
(are)f('char',)f(b)n(ut)i(you)f(can)g(change)f(the)i
Fl(typedef)f Fp(to)h(whate)n(v)o(er)e(you)g(wish)i(\(you)f(can)g(e)n(v)
o(en)g(mak)o(e)g(it)208 4094 y(a)g(class\).)125 4257
y Fm(\017)41 b Fp(ASTs)20 b(were)h(incorrectly)d(handled)h(in)h
(conjunction)e(with)i(1.10)f(syntactic)h(predicates\320this)f(has)i
(been)e(\256x)o(ed.)125 4420 y Fpccts/UPDAT121.ps 644 1377 31 166314 5655551670 7005 %!PS-Adobe-2.0
%%Creator: dvips 5.519 Copyright 1986, 1993 Radical Eye Software
%%Title: UPDAT121.dvi
%%CreationDate: Sat Aug 20 15:57:55 1994
%%Pages: 10
%%PageOrder: Ascend
%%BoundingBox: 0 0 612 792
%%DocumentFonts: Times-Roman Times-Italic Courier Times-Bold
%%EndComments
%DVIPSCommandLine: dvips -o UPDAT121.ps UPDAT121
%DVIPSSource: TeX output 1994.08.20:1557
%%BeginProcSet: texc.pro
/TeXDict 250 dict def TeXDict begin /N{def}def /B{bind def}N /S{exch}N
/X{S N}B /TR{translate}N /isls false N /vsize 11 72 mul N /hsize 8.5 72
mul N /landplus90{false}def /@rigin{isls{[0 landplus90{1 -1}{-1 1}
ifelse 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale
isls{landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div
hsize mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul
TR matrix currentmatrix dup dup 4 get round 4 exch put dup dup 5 get
round 5 exch put setmatrix}N /@landscape{/isls true N}B /@manualfeed{
statusdict /manualfeed true put}B /@copies{/#copies X}B /FMat[1 0 0 -1 0
0]N /FBB[0 0 0 0]N /nn 0 N /IE 0 N /ctr 0 N /df-tail{/nn 8 dict N nn
begin /FontType 3 N /FontMatrix fntrx N /FontBBox FBB N string /base X
array /BitMaps X /BuildChar{CharBuilder}N /Encoding IE N end dup{/foo
setfont}2 array copy cvx N load 0 nn put /ctr 0 N[}B /df{/sf 1 N /fntrx
FMat N df-tail}B /dfs{div /sf X /fntrx[sf 0 0 sf neg 0 0]N df-tail}B /E{
pop nn dup definefont setfont}B /ch-width{ch-data dup length 5 sub get}
B /ch-height{ch-data dup length 4 sub get}B /ch-xoff{128 ch-data dup
length 3 sub get sub}B /ch-yoff{ch-data dup length 2 sub get 127 sub}B
/ch-dx{ch-data dup length 1 sub get}B /ch-image{ch-data dup type
/stringtype ne{ctr get /ctr ctr 1 add N}if}B /id 0 N /rw 0 N /rc 0 N /gp
0 N /cp 0 N /G 0 N /sf 0 N /CharBuilder{save 3 1 roll S dup /base get 2
index get S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx 0 ch-xoff
ch-yoff ch-height sub ch-xoff ch-width add ch-yoff setcachedevice
ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-yoff .1 add]/id
ch-image N /rw ch-width 7 add 8 idiv string N /rc 0 N /gp 0 N /cp 0 N{
rc 0 ne{rc 1 sub /rc X rw}{G}ifelse}imagemask restore}B /G{{id gp get
/gp gp 1 add N dup 18 mod S 18 idiv pl S get exec}loop}B /adv{cp add /cp
X}B /chg{rw cp id gp 4 index getinterval putinterval dup gp add /gp X
adv}B /nd{/cp 0 N rw exit}B /lsh{rw cp 2 copy get dup 0 eq{pop 1}{dup
255 eq{pop 254}{dup dup add 255 and S 1 and or}ifelse}ifelse put 1 adv}
B /rsh{rw cp 2 copy get dup 0 eq{pop 128}{dup 255 eq{pop 127}{dup 2 idiv
S 128 and or}ifelse}ifelse put 1 adv}B /clr{rw cp 2 index string
putinterval adv}B /set{rw cp fillstr 0 4 index getinterval putinterval
adv}B /fillstr 18 string 0 1 17{2 copy 255 put pop}for N /pl[{adv 1 chg}
{adv 1 chg nd}{1 add chg}{1 add chg nd}{adv lsh}{adv lsh nd}{adv rsh}{
adv rsh nd}{1 add adv}{/rc X nd}{1 add set}{1 add clr}{adv 2 chg}{adv 2
chg nd}{pop nd}]dup{bind pop}forall N /D{/cc X dup type /stringtype ne{]
}if nn /base get cc ctr put nn /BitMaps get S ctr S sf 1 ne{dup dup
length 1 sub dup 2 index S get sf div put}if put /ctr ctr 1 add N}B /I{
cc 1 add D}B /bop{userdict /bop-hook known{bop-hook}if /SI save N @rigin
0 0 moveto /V matrix currentmatrix dup 1 get dup mul exch 0 get dup mul
add .99 lt{/QV}{/RV}ifelse load def pop pop}N /eop{SI restore showpage
userdict /eop-hook known{eop-hook}if}N /@start{userdict /start-hook
known{start-hook}if pop /VResolution X /Resolution X 1000 div /DVImag X
/IE 256 array N 0 1 255{IE S 1 string dup 0 3 index put cvn put}for
65781.76 div /vsize X 65781.76 div /hsize X}N /p{show}N /RMat[1 0 0 -1 0
0]N /BDot 260 string N /rulex 0 N /ruley 0 N /v{/ruley X /rulex X V}B /V
{}B /RV statusdict begin /product where{pop product dup length 7 ge{0 7
getinterval dup(Display)eq exch 0 4 getinterval(NeXT)eq or}{pop false}
ifelse}{false}ifelse end{{gsave TR -.1 -.1 TR 1 1 scale rulex ruley
false RMat{BDot}imagemask grestore}}{{gsave TR -.1 -.1 TR rulex ruley
scale 1 1 false RMat{BDot}imagemask grestore}}ifelse B /QV{gsave
transform round exch round exch itransform moveto rulex 0 rlineto 0
ruley neg rlineto rulex neg 0 rlineto fill grestore}B /a{moveto}B /delta
0 N /tail{dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{S p tail}
B /c{-4 M}B /d{-3 M}B /e{-2 M}B /f{-1 M}B /g{0 M}B /h{1 M}B /i{2 M}B /j{
3 M}B /k{4 M}B /w{0 rmoveto}B /l{p -4 w}B /m{p -3 w}B /n{p -2 w}B /o{p
-1 w}B /q{p 1 w}B /r{p 2 w}B /s{p 3 w}B /t{p 4 w}B /x{0 S rmoveto}B /y{
3 2 roll p a}B /bos{/SS save N}B /eos{SS restore}B end
%%EndProcSet
%%BeginProcSet: texps.pro
TeXDict begin /rf{findfont dup length 1 add dict begin{1 index /FID ne 2
index /UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll
exec 0 exch 5 -1 roll VResolution Resolution div mul neg 0 0]/Metrics
exch def dict begin Encoding{exch dup type /integertype ne{pop pop 1 sub
dup 0 le{pop}{[}ifelse}{FontMatrix 0 get div Metrics 0 get div def}
ifelse}forall Metrics /Metrics currentdict end def[2 index currentdict
end definefont 3 -1 roll makefont /setfont load]cvx def}def
/ObliqueSlant{dup sin S cos div neg}B /SlantFont{4 index mul add}def
/ExtendFont{3 -1 roll mul exch}def /ReEncodeFont{/Encoding exch def}def
end
%%EndProcSet
%%BeginProcSet: special.pro
TeXDict begin /SDict 200 dict N SDict begin /@SpecialDefaults{/hs 612 N
/vs 792 N /ho 0 N /vo 0 N /hsc 1 N /vsc 1 N /ang 0 N /CLIP 0 N /rwiSeen
false N /rhiSeen false N /letter{}N /note{}N /a4{}N /legal{}N}B
/@scaleunit 100 N /@hscale{@scaleunit div /hsc X}B /@vscale{@scaleunit
div /vsc X}B /@hsize{/hs X /CLIP 1 N}B /@vsize{/vs X /CLIP 1 N}B /@clip{
/CLIP 2 N}B /@hoffset{/ho X}B /@voffset{/vo X}B /@angle{/ang X}B /@rwi{
10 div /rwi X /rwiSeen true N}B /@rhi{10 div /rhi X /rhiSeen true N}B
/@llx{/llx X}B /@lly{/lly X}B /@urx{/urx X}B /@ury{/ury X}B /magscale
true def end /@MacSetUp{userdict /md known{userdict /md get type
/dicttype eq{userdict begin md length 10 add md maxlength ge{/md md dup
length 20 add dict copy def}if end md begin /letter{}N /note{}N /legal{}
N /od{txpose 1 0 mtx defaultmatrix dtransform S atan/pa X newpath
clippath mark{transform{itransform moveto}}{transform{itransform lineto}
}{6 -2 roll transform 6 -2 roll transform 6 -2 roll transform{
itransform 6 2 roll itransform 6 2 roll itransform 6 2 roll curveto}}{{
closepath}}pathforall newpath counttomark array astore /gc xdf pop ct 39
0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if}N
/txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR pop 1 -1
scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3 get
ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip
not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub neg 0
TR}if yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{noflips{TR
pop pop 270 rotate 1 -1 scale}if xflip yflip and{TR pop pop 90 rotate 1
-1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg
TR}if xflip yflip not and{TR pop pop 90 rotate ppr 3 get ppr 1 get neg
sub neg 0 TR}if yflip xflip not and{TR pop pop 270 rotate ppr 2 get ppr
0 get neg sub neg 0 S TR}if}ifelse scaleby96{ppr aload pop 4 -1 roll add
2 div 3 1 roll add 2 div 2 copy TR .96 dup scale neg S neg S TR}if}N /cp
{pop pop showpage pm restore}N end}if}if}N /normalscale{Resolution 72
div VResolution 72 div neg scale magscale{DVImag dup scale}if 0 setgray}
N /psfts{S 65781.76 div N}N /startTexFig{/psf$SavedState save N userdict
maxlength dict begin /magscale false def normalscale currentpoint TR
/psf$ury psfts /psf$urx psfts /psf$lly psfts /psf$llx psfts /psf$y psfts
/psf$x psfts currentpoint /psf$cy X /psf$cx X /psf$sx psf$x psf$urx
psf$llx sub div N /psf$sy psf$y psf$ury psf$lly sub div N psf$sx psf$sy
scale psf$cx psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub TR
/showpage{}N /erasepage{}N /copypage{}N /p 3 def @MacSetUp}N /doclip{
psf$llx psf$lly psf$urx psf$ury currentpoint 6 2 roll newpath 4 copy 4 2
roll moveto 6 -1 roll S lineto S lineto S lineto closepath clip newpath
moveto}N /endTexFig{end psf$SavedState restore}N /@beginspecial{SDict
begin /SpecialSave save N gsave normalscale currentpoint TR
@SpecialDefaults count /ocount X /dcount countdictstack N}N /@setspecial
{CLIP 1 eq{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto
closepath clip}if ho vo TR hsc vsc scale ang rotate rwiSeen{rwi urx llx
sub div rhiSeen{rhi ury lly sub div}{dup}ifelse scale llx neg lly neg TR
}{rhiSeen{rhi ury lly sub div dup scale llx neg lly neg TR}if}ifelse
CLIP 2 eq{newpath llx lly moveto urx lly lineto urx ury lineto llx ury
lineto closepath clip}if /showpage{}N /erasepage{}N /copypage{}N newpath
}N /@endspecial{count ocount sub{pop}repeat countdictstack dcount sub{
end}repeat grestore SpecialSave restore end}N /@defspecial{SDict begin}
N /@fedspecial{end}B /li{lineto}B /rl{rlineto}B /rc{rcurveto}B /np{
/SaveX currentpoint /SaveY X N 1 setlinecap newpath}N /st{stroke SaveX
SaveY moveto}N /fil{fill SaveX SaveY moveto}N /ellipse{/endangle X
/startangle X /yrad X /xrad X /savematrix matrix currentmatrix N TR xrad
yrad scale 0 0 1 startangle endangle arc savematrix setmatrix}N end
%%EndProcSet
TeXDict begin 40258431 52099146 1000 600 600
(/usr/home/parrt/PCCTS/doc/UPDAT121.dvi) @start /Fa 1
62 df<007FB812F8B912FCA3CCFCAEB912FCA36C17F836167B9F41>61
D E /Fb 2 117 df<137CEA0FFCA2C65AA21201A25BA21203A25BA21207A2EBC1F8EBC7
FE380FDE1F9038F80F8013E0EBC007381F800FA21300A25AEC1F00123EA2007E133EA200
7C140C147C00FC141814F8481430147815E048EB3FC048EB0F001E287BA727>104
D<130E131E133EA45BA45BB512E0A23800F800485AA4485AA4485AA4485A1460A214C0EA
1F00EB0180380F0300138EEA07FCEA01F013247EA319>116 D E
/Fc 7 108 df<121C127FEAFF80A5EA7F00121C0909798817>58
D<124012F812FE6C7EEA3FE0EA0FF8EA03FEC66C7EEB3FE0EB0FF8EB03FE903800FF80EC
3FE0EC0FF8EC03FE913800FF80ED3FE0ED0FF8ED03FE923800FF80EE3FE0EE0FF8EE03FE
933800FF80EF3FC0A2EFFF80933803FE00EE0FF8EE3FE0EEFF80DB03FEC7FCED0FF8ED3F
E0EDFF80DA03FEC8FCEC0FF8EC3FE0ECFF80D903FEC9FCEB0FF8EB3FE0EBFF80D803FECA
FCEA0FF8EA3FE0EAFF8048CBFC12F81260323279AD41>62 D<176017E0831601A2160316
07A2160FA2161F1637A2EE67F8166316C315011683ED0303A21506150E150C03187FA2ED
30011570156015C0A2EC0180140315001406835C1600021FB5FC5CA20260C7FCA25C495A
8349C8FC8313065BA25B133813301370D801F81680D807FCEC01FFB500C0017F13FFA25C
383B7DBA3E>65 D<0107B6FCA25E90260007FCC8FC5D5D140FA25DA2141FA25DA2143FA2
5DA2147FA292C9FCA25CA25CA21301A25CA21303A25CA2130718404A15C0A2010F150118
804A1403A2011F16005F4A1406170E013F151E171C4A143C177C017F5D160391C7120F49
EC7FF0B8FCA25F32397DB839>76 D<0107B612F8EFFF8018E0903B0007F8001FF84BEB03
FCEF00FE020F157FA24BEC3F80A2021F16C0A25DA2143FF07F805DA2027FEDFF006092C7
485A4D5A4A4A5A4D5A4AEC1F80057EC7FC0101EC07F891B612C094C8FC9139FC000FC001
03EC03F0707E4A80707E1307177E5C177F010F5D5F5CA2011F1401A25CA2133F16034A4A
1360A2017F17E019C091C700011301496CED0380B6903900FE0700EF7F0EEF1FFCCAEA07
F03B3A7DB83F>82 D<14E0EB01F81303A314F0EB01C090C7FCAC13F8EA03FEEA070F000E
1380121C121812381230EA701F1260A2EAE03F00C013005BEA007EA213FE5B1201A25B12
035BA20007131813E0000F1338EBC030A21470EB806014E014C01381EB838038078700EA
03FEEA00F815397EB71D>105 D 91C8FCA35B017EEB07C0ED1FF0ED783801FEEBE07C9039FC01C1FCEC0381EC0701000101
0E13F8EBF81C91383800E04A130000035BEBF1C0EBF38001F7C8FCEA07FEA2EBFFC0EBE7
F8380FE1FCEBC07E147F80001F80D9801F1330A21670003F013F13600100130016E016C0
5A007EEB1F01ED0380160000FEEB0F8748EB03FE0038EB00F8263B7CB92B>107
D E /Fd 134[42 3[46 28 32 37 1[46 42 46 69 23 46 1[23
46 2[37 46 37 46 42 12[55 1[60 2[65 37[28 28 40[{}23
83.333336 /Times-Bold rf /Fe 1 16 df 14E04814F04814F8A24814FCA3B612FEA86C14FCA36C14F8A26C14F06C14E06C14C06C14
80C6EBFE006D5AEB0FE01F207BA42A>15 D E /Ff 81[55 52[50
3[55 33 39 44 2[50 55 83 28 55 1[28 55 1[33 44 55 44
55 50 10[72 1[66 55 72 1[61 1[72 94 66 4[78 61 1[72 72
66 72 8[50 50 50 50 50 50 50 50 2[25 33 1[57 6[50 36[{}45
100.000000 /Times-Bold rf /Fg 2 104 df 131F91C7FCB3A55B133E5B5BEA03F0EA7FC048C8FCEA7FC0EA03F0C67E137C7F133F7FB3
A580130F806D7E6D7EEB00FCEC3FE014071B4B7BB726>102 D<12FCB47EEA07E0EA01F8
6C7E137E133E133F7FB3A580130F6D7E6D7EEB01F89038007FC0EC1FE0EC7FC0903801F8
00EB03E0495A495A131F91C7FCB3A55B133E137E5B485AEA07E0EAFF8000FCC8FC1B4B7B
B726>I E /Fh 206[25 49[{}1 50.000000 /Times-Roman rf
/Fi 206[29 49[{}1 58.333336 /Times-Roman rf /Fj 133[32
37 37 55 1[42 23 32 32 1[42 42 42 60 23 37 23 23 42 42
23 37 42 37 42 42 3[32 1[32 3[69 2[46 10[28 5[55 8[28
11[21 28 1[56 43[{}34 83.333336 /Times-Italic rf /Fk
133[50 50 50 50 50 50 50 50 50 1[50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 8[50 50 1[50 50 50 50 1[50
50 50 50 50 50 1[50 1[50 50 50 50 50 50 50 50 50 50 1[50
1[50 7[50 50 1[50 50 50 50 1[50 50 50 3[50 2[50 33[{}61
83.333336 /Courier rf /Fl 81[65 53[58 84 1[65 39 45 52
1[65 58 65 97 32 65 1[32 65 58 39 52 65 52 1[58 13[65
84 3[84 110 3[45 2[71 2[84 78 84 8[58 58 58 58 58 58
58 58 2[29 2[66 43[{}40 116.666672 /Times-Bold rf /Fm
47[83 21[37 10[46 46 3[37 47[37 42 42 60 42 42 23 32
28 42 42 42 42 65 23 42 23 23 42 42 28 37 42 37 42 37
3[28 1[28 1[60 60 78 1[60 51 46 55 60 46 60 60 74 51
2[28 60 60 46 51 60 55 55 60 1[37 3[23 23 42 42 42 42
42 42 42 42 42 42 23 21 28 21 47 1[28 28 28 2[42 36[{}77
83.333336 /Times-Roman rf /Fn 81[37 52[33 1[48 1[33 18
26 22 1[33 33 33 52 18 33 1[18 33 33 22 29 33 29 33 29
11[48 2[44 1[37 48 48 59 41 2[22 48 3[48 44 1[48 7[33
33 4[33 2[33 1[17 22 17 44[{}41 66.666664 /Times-Roman
rf /Fo 1 4 df<133013381330A20040130800F0133C00FC13FC383E31F0380FB7C03801
FE00EA0030EA01FE380FB7C0383E31F038FC30FC00F0133C0040130800001300A2133813
3016157C9620>3 D E /Fp 134[33 3[37 21 1[29 2[37 37 54
7[33 37 2[37 51[25 45[{}11 75.000000 /Times-Italic rf
/Fq 131[45 1[45 45 45 45 45 45 45 45 45 45 45 45 45 45
45 45 45 45 45 45 45 45 45 45 45 45 45 3[45 6[45 45 45
45 45 45 45 45 45 45 2[45 1[45 45 45 45 45 45 45 45 45
45 45 45 45 45 7[45 45 45 45 45 45 45 45 45 45 45 45
45 3[45 45 33[{}69 75.000000 /Courier rf /Fr 47[75 21[33
11[42 3[33 47[33 37 37 54 37 37 21 29 25 37 37 37 37
58 21 37 21 21 37 37 25 33 37 33 37 33 12[46 42 50 1[42
54 54 66 46 4[54 42 46 54 50 50 54 5[21 1[37 4[37 37
37 37 37 21 19 25 19 42 1[25 25 25 39[{}60 75.000000
/Times-Roman rf /Fs 139[25 29 33 14[33 42 37 31[54 65[{}7
75.000000 /Times-Bold rf /Ft 138[60 60 1[60 60 60 60
60 60 1[60 3[60 1[60 60 60 1[60 12[60 19[60 17[60 4[60
60 40[{}19 100.000000 /Courier rf /Fu 134[50 2[50 50
28 39 33 1[50 50 50 78 28 2[28 50 50 33 44 50 44 1[44
5[33 3[94 1[72 1[55 66 1[55 1[72 89 61 2[33 72 2[61 1[66
1[72 7[50 1[50 1[50 50 1[50 50 50 1[25 33 25 44[{}43
100.000000 /Times-Roman rf /Fv 1 4 df<130C131EA50060EB018000F0EB03C038FC
0C0F00FE131F393F8C7F00380FCCFC3803FFF038007F80011EC7FCEB7F803803FFF0380F
CCFC383F8C7F39FE0C1FC000FC130F38F01E030060EB0180000090C7FCA5130C1A1D7C9E
23>3 D E /Fw 81[50 52[44 44 66 44 50 28 39 39 1[50 50
50 72 28 44 1[28 50 50 28 44 50 44 50 50 3[39 5[83 2[55
50 61 72 61 1[66 1[55 1[44 2[72 2[72 66 1[61 14[50 50
50 28 25 33 1[67 1[33 33 40[{}47 100.000000 /Times-Italic
rf /Fx 47[141 91[39 55 3[71 2[39 6[63 3[63 12[86 78 94
1[78 1[102 10[94 16[71 71 2[35 46[{}16 141.666672 /Times-Roman
rf end
%%EndProlog
%%BeginSetup
%%Feature: *Resolution 600dpi
TeXDict begin

%%EndSetup
%%Page: 1 1
1 0 bop 996 139 a Fx(PCCTS)36 b(1.21)f(\320)g(Release)f(Notes)681
380 y Fw(T)-9 b(er)l(ence)26 b(J)n(.)f(P)-8 b(arr)1287
344 y Fv(\003)499 496 y Fu(Uni)n(v)o(ersity)22 b(of)j(Minnesota)248
612 y(Army)f(High-Performance)h(Computing)656 728 y(Research)h(Center)
492 845 y(Minneapolis,)d(MN)i(55415)595 961 y Ft([email protected])2467
380 y Fw(Russell)f(W)-9 b(.)24 b(Quong)2169 496 y Fu(School)h(of)g
(Electrical)f(Engineering)2459 612 y(Purdue)h(Uni)n(v)o(ersity)2351
728 y(W)-9 b(.)25 b(Laf)o(ayette,)g(IN)g(47907)2223 845
y Ft([email protected])691 1193 y Fu([)p Fw(This)f(author)g(list)g
(only)g(includes)g(active)h(participates)e(for)h(1.21])1529
1387 y Fu(August)g(20,)g(1994)1721 1768 y Fs(Abstract)320
1905 y Fr(This)f(document)h(describes)g(the)g(1.21)f(release)h(of)f
(the)g(Purdue)h(Compiler)f(Construction)i(T)-6 b(ool)23
b(Set)f(\(PCCTS\).)f(Aside)208 1997 y(from)29 b(a)g(fe)n(w)g(b)o(ug)h
(\256x)o(es,)h(this)e(release)h(merely)f(cleans)h(up)g(the)f(C++)g
(output\320the)h(C++)f(interf)o(ace)h(has)f(been)h(changed)208
2088 y(slightly)16 b(since)h(1.20)h(\(March)f(31,)h(1994\).)27
b(The)17 b(original)g(1.00)g(manual)h(and)f(all)f(release)h(notes)h
(are)f(required)g(for)g(a)g(complete)208 2179 y(documentation)j(set)f
(for)g(PCCTS.)e(A)h(book)i(is)f(in)g(the)g(w)o(orks)g(and)h(the)f
(papers)h(pro)o(vided)g(at)e(the)h Fq(ftp)f Fr(site)h(don')o(t)g(hurt.)
320 2271 y(PCCTS)11 b(is)g(in)g(the)g(public-domain)g(and)g(can)g(be)g
(obtained)g(at)g Fq(marvin.ecn.purdue.edu)g Fr(in)g Fq(pub/pccts/1.21)p
Fr(.)208 2362 y(The)27 b(ne)n(wsgroup)i Fq(comp.compilers.tools.pccts)
23 b Fr(pro)o(vides)29 b(a)f(discussion)g(forum.)54 b(Alternati)n(v)o
(ely)-5 b(,)29 b(you)g(can)208 2453 y(join)37 b(the)h
Fq(pccts-users)d Fr(mailing)j(list)f(dealing)h(with)f(tools)h(ANTLR,)e
(DLG)g(\(and)j(SORCERER\))c(by)j(emailing)208 2545 y
Fq([email protected])13 b Fr(with)19
b(a)g(body)i(of)e Fq(subscribe)43 b(pccts-users)17 b
Fp(your)o(-name-)208 2636 y(or)o(-r)m(et-addr)p Fr(.)25
b(T)-6 b(o)11 b(recei)n(v)o(e)g(future)g(release)g(broadcast)g
(messages,)17 b(re)o(gister)11 b(yourself)g(by)g(sending)g(email)g(to)g
Fq([email protected])208 2727 y Fr(with)18 b(a)h(\252)p
Fq(Subject:)p Fr(\272)26 b(line)19 b(of)g(\252)p Fq(register)p
Fr(\272.)320 2819 y(The)h(authors)h(mak)o(e)g(no)f(claims)g(that)g
(this)g(softw)o(are)g(will)g(do)g(what)g(you)h(w)o(ant,)g(that)f(this)g
(manual)g(is)g(an)o(y)h(good,)g(or)f(that)208 2910 y(the)f(softw)o(are)
g(actually)h(w)o(orks\320use)g(PCCTS)e(at)h(your)h(o)n(wn)g(risk.)27
b(Bug)20 b(reports)g(and/or)g(cheery)g(reports)f(of)h(its)e(usefulness)
208 3001 y(are)g(v)o(ery)i(welcome,)f(ho)n(we)n(v)o(er)l(.)320
3093 y(From)g(the)g(1.21)h(release)f(forw)o(ard,)h(the)g(maintenance)g
(and)g(support)h(of)e(all)g(PCCTS)e(tools)j(will)e(be)i(primarily)f
(pro)o(vided)208 3184 y(by)k(P)o(arr)g(Research)h(Corporation,)h
(Minneapolis)g(MN\320an)e(or)o(ganization)h(founded)h(on)f(the)g
(principles)g(of)f(e)o(xcellence)h(in)208 3275 y(research)30
b(and)g(inte)o(grity)g(in)f(b)o(usiness;)35 b(we)30 b(are)f(de)n(v)o
(oted)i(to)f(pro)o(viding)g(really)g(cool)g(softw)o(are)g(tools.)59
b(Please)29 b(see)h(\256le)208 3367 y Fq(PCCTS.FUTURE)15
b Fr(for)j(more)h(information.)27 b(All)17 b(PCCTS)g(tools)h(currently)
h(in)f(the)g(public)g(domain)i(will)d(continue)i(to)f(be)g(in)208
3458 y(the)h(public)g(domain.)p 0 4951 1488 4 v 84 5005
a Fo(\003)120 5028 y Fn(P)o(artial)27 b(support)f(for)g(this)g(w)o(ork)
g(has)g(come)g(from)f(the)h(Army)f(Research)j(Of)n(\256ce)e(contract)i
(number)e(D)m(AAL03-89-C-0038)i(with)e(the)g(Army)f(High)0
5107 y(Performance)19 b(Computing)f(Research)i(Center)e(at)g(the)g(U)e
(of)h(MN.)1839 5356 y Fm(1)p eop
%%Page: 2 2
2 1 bop 243 -293 a
25523322 2368143 0 0 25523322 2368143 startTexFig
243 -293 a
%%BeginDocument: blk.eps
/$F2psDict 200 dict def
$F2psDict begin
$F2psDict /mtrx matrix put
/l {lineto} bind def
/m {moveto} bind def
/s {stroke} bind def
/n {newpath} bind def
/gs {gsave} bind def
/gr {grestore} bind def
/clp {closepath} bind def
/graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
4 -2 roll mul setrgbcolor} bind def
/col-1 {} def
/col0 {0 0 0 setrgbcolor} bind def
/col1 {0 0 1 setrgbcolor} bind def
/col2 {0 1 0 setrgbcolor} bind def
/col3 {0 1 1 setrgbcolor} bind def
/col4 {1 0 0 setrgbcolor} bind def
/col5 {1 0 1 setrgbcolor} bind def
/col6 {1 1 0 setrgbcolor} bind def
/col7 {1 1 1 setrgbcolor} bind def
end
/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
/$F2psEnd {$F2psEnteredState restore end} def

$F2psBegin
0 setlinecap 0 setlinejoin
-46.0 126.0 translate 0.900 -0.900 scale
0.500 setlinewidth
n 349 126 m 349 109 l 239 109 l 239 126 l
clp gs col-1 s gr
/Courier findfont 10.00 scalefont setfont
245 120 m
gs 1 -1 scale (ANTLRTokenBuffer) col-1 show gr
n 209 139 m 209 99 l 139 99 l 139 139 l
clp gs col-1 s gr
n 449 139 m 449 99 l 379 99 l 379 139 l
clp gs col-1 s gr
n 80 118 m 139 118 l gs col-1 s gr
n 131.000 116.000 m 139.000 118.000 l 131.000 120.000 l gs 2 setlinejoin col-1 s gr
n 209 119 m 239 119 l gs col-1 s gr
n 231.000 117.000 m 239.000 119.000 l 231.000 121.000 l gs 2 setlinejoin col-1 s gr
n 349 119 m 379 119 l gs col-1 s gr
n 371.000 117.000 m 379.000 119.000 l 371.000 121.000 l gs 2 setlinejoin col-1 s gr
n 449 119 m 479 119 l gs col-1 s gr
n 471.000 117.000 m 479.000 119.000 l 471.000 121.000 l gs 2 setlinejoin col-1 s gr
/Courier findfont 10.00 scalefont setfont
382 118 m
gs 1 -1 scale (ANTLRParser) col-1 show gr
/Courier findfont 10.00 scalefont setfont
151 119 m
gs 1 -1 scale (DLGLexer) col-1 show gr
/Courier findfont 10.00 scalefont setfont
51 112 m
gs 1 -1 scale (DLGInputStream) col-1 show gr
/Times-Roman findfont 11.00 scalefont setfont
454 114 m
gs 1 -1 scale (output) col-1 show gr
$F2psEnd
%%EndDocument

endTexFig
833 190 a Fm(Figure)19 b(1:)30 b(Ov)o(ervie)n(w)18 b(of)i(the)h(C++)f
(classes)i(generated)c(by)i(ANTLR.)0 457 y Fl(1)116 b(Intr)n(oduction)0
643 y Fm(The)17 b(PCCTS)i(1.21)d(release)i(is)g(mainly)f(an)g(upgrade)f
(for)g(the)i(C++)g(output.)27 b(The)17 b(test)h(e)o(xamples)f(ha)n(v)o
(e)g(no)n(w)f(been)h(successfully)0 742 y(compiled)31
b(under)g(a)i(number)d(of)i(C++)h(compilers.)65 b(Further)m(,)34
b(C++)f(mode)e(may)h(no)n(w)g(use)h(arbitrary)d(lookahead)h(with)h(a)0
842 y(\252sliding)18 b(windo)n(w\272)f(of)h(lookahead)e(rather)i(than)g
(reading)f(in)h(the)g(entire)g(input)g(\256le)h(before)e(commencement)f
(of)i(parsing.)27 b(An)o(y)0 941 y(grammars)22 b(written)h(with)h(1.20)
e(C++)i(output)e(should)h(be)g(easy)h(to)f(con)m(v)o(ert)f(to)i(1.21.)
37 b(The)23 b(C++)h(interf)o(ace)f(section)g(pro)o(vides)0
1041 y(the)d(ne)n(w)g(parser)g(de\256nition)f(and)g(in)m(v)n(ocation)g
(sequence.)28 b(The)19 b(C++)i(output)e(is)i(still)g(considered)e
(alpha)g(quality)-5 b(,)19 b(b)n(ut)h(within)g(a)0 1141
y(release)g(or)g(tw)o(o,)g(it)h(should)e(be)i(up)e(to)i(\252parr\272.)
125 1240 y(A)g(number)e(of)h(b)n(ug)g(\256x)o(es)h(ha)n(v)o(e)f(been)g
(done)g(and)g(a)h(v)o(ery)f(nice)g(con\256guration)e(\256le)k(has)f
(been)f(produced)e(to)j(aid)f(in)h(porting)0 1340 y(PCCTS.)125
1440 y(Scott)d(Hane)o(y)f(at)i(La)o(wrence)d(Li)n(v)o(ermore)g
(National)i(Labs)g(has)g(done)f(a)i(f)o(ab)n(ulous)e(port)h(of)g(PCCTS)
h(1.21)e(to)h(the)g(Macintosh)0 1539 y(\(primarily)g(MPW\).)0
1819 y Fl(2)116 b(Con\256guration)28 b(File)0 2005 y
Fm(A)17 b(ne)n(w)f(\256le,)i Fk(config.h)p Fm(,)e(is)h(pro)o(vided)d
(to)j(mak)o(e)f(porting)f(ANTLR,)h(DLG,)g(and)g(SORCERER)i(easier)-5
b(.)29 b(This)17 b(\256le)g(de\256nes)f(\256le)0 2105
y(names,)28 b(standard)d(symbols)h(such)h(as)p 1155 2105
25 4 v 1185 2105 V 87 w Fk(USE)p 1365 2105 V 29 w(PROTOS)f
Fm(and)g Fk(CPP)p 2017 2105 V 30 w(FILE)p 2247 2105 V
29 w(SUFFIX)p Fm(,)g(directory)e(characters,)k(and)e(v)n(arious)0
2204 y(things)20 b(for)f(standard)g(ports)h(such)g(as)h(MPW)-8
b(.)125 2304 y(The)19 b(\256le)i Fk(support/set.h)e Fm(need)g(no)h
(longer)f(be)h(modi\256ed)f(for)g(16)h(bit)h(compilers.)125
2403 y(De\256ne)f(preprocessor)e(symbol)h Fk(PC)h Fm(to)h(enable)e(a)i
(b)n(unch)e(of)g(PC)j(stuf)n(f)e(lik)o(e)g Fk(.obj)g
Fm(for)g(object)f(\256les)i(and)f(\252)0 2503 y(\272)h(for)e(the)h
(directory)f(symbol.)125 2603 y(De\256ne)h(preprocessor)e(symbol)h
Fk(MPW)h Fm(to)g(enable)g(a)g(b)n(unch)f(of)h(Mac)h(stuf)n(f.)0
2883 y Fl(3)116 b(C++)30 b(Interface)0 3068 y Fj([W)-8
b(arning:)39 b(The)25 b(C++)i(output)d(is)i(still)g(in)g(a)f(state)h
(of)f(c)o(hang)o(e)f(as)h(we)h(learn)g(mor)m(e)f(about)f(what)h(it)h
(should)e(look)h(lik)o(e)o(.)45 b(This)0 3168 y(should)19
b(stabilize)i(soon])p Fm(.)125 3268 y(When)15 b(generating)f(recursi)n
(v)o(e-descent)f(parsers)i(in)h(C++,)h(ANTLR)f(creates)g(separate)g
(C++)g(classes)h(for)e(the)h(input)f(stream,)0 3367 y(the)24
b(le)o(xical)f(analyzer)f(\(scanner\),)h(the)g(tok)o(en)g(b)n(uf)n(fer)
m(,)g(and)g(the)h(parser)-5 b(.)39 b(Conceptually)-5
b(,)22 b(these)i(these)f(classes)i(\256t)g(together)d(as)0
3467 y(sho)n(wn)16 b(in)h(Figure)f(1,)h(and)f(in)h(f)o(act,)g(the)g
(ANTLR-generated)d(classes)k(\252snap)f(together\272)e(in)i(an)f
(identical)g(f)o(ashion.)28 b(T)-7 b(o)16 b(initialize)0
3567 y(the)k(parser)m(,)f(the)h(programmer)e(simply)104
3749 y(1.)41 b(attaches)20 b(an)g(input)f(stream)h(object)g(to)g(a)h
(DLG-based)e(scanner)2058 3719 y Fi(1)2090 3749 y Fm(,)104
3849 y(2.)41 b(attaches)20 b(a)g(scanner)g(to)g(a)h(tok)o(en)e(b)n(uf)n
(fer)g(object,)g(and)104 3948 y(3.)41 b(attaches)20 b(the)g(tok)o(en)f
(b)n(uf)n(fer)g(to)i(a)f(parser)g(object)f(generated)g(by)h(ANTLR.)125
4131 y(The)f(follo)n(wing)g(code)g(illustrates,)i(for)e(a)i(parser)f
(object)f Fk(Expr)p Fm(,)h(ho)n(w)g(these)g(classes)h(\256t)g(together)
-5 b(.)p 0 4202 1488 4 v 90 4257 a Fh(1)120 4281 y Fn(If)16
b(the)i(user)f(has)h(constructed)h(their)g(o)n(wn)e(scanner)m(,)h(the)o
(y)g(w)o(ould)g(attach)i(it)d(here.)1839 5356 y Fm(2)p
eop
%%Page: 3 3
3 2 bop 125 -201 a Fq(main\(\))125 -110 y Fg(f)304 -19
y Fq(DLGFileInput)43 b(in\(stdin\);)491 b(//)45 b(get)f(an)g(input)g
(stream)g(for)h(DLG)304 72 y(DLGLexer)e(scan\(&in,2000\);)446
b(//)45 b(connect)e(a)i(scanner)f(to)g(an)h(input)f(stream)304
164 y(ANTLRTokenBuffer)e(pipe\(&scan,)h(k\);)89 b(//)45
b(connect)e(scanner)h(and)g(parser)g(via)g(``pipe'')304
255 y(ANTLRToken)f(aToken;)304 346 y(scan.setToken\(&aToken\);)489
b(//)45 b(give)f(DLG)g(access)g(to)g(a)h(virtual)f(table)304
438 y(Expr)g(parser\(&pipe\);)670 b(//)45 b(make)f(a)g(parser)g
(connected)g(to)g(the)g(pipe)304 529 y(parser.init\(\);)894
b(//)45 b(initialize)e(the)h(parser)304 620 y(parser.e\(\);)1029
b(//)45 b(begin)f(parsing;)88 b(e)45 b(=)f(start)g(symbol)125
712 y Fg(g)0 903 y Fm(where)17 b Fk(ANTLRToken)g Fm(is)h(programmer)n
(-de\256ned)13 b(and)18 b(must)f(be)h(a)g(subclass)g(of)g
Fk(ANTLRAbstractToken)d Fm(\(or)i(one)g(of)h(the)0 1002
y(prede\256ned)j(classes)j(belo)n(w)f(it\).)38 b(T)-7
b(o)24 b(start)f(parsing,)g(it)h(is)g(suf)n(\256cient)e(to)i(call)f
(the)g Fk(Expr)g Fm(member)f(function)f(associated)i(with)0
1102 y(the)d(grammar)f(rule;)h(here,)f Fk(e)i Fm(is)g(the)f(start)h
(symbol.)125 1202 y(T)-7 b(o)19 b(specify)f(the)h(name)g(of)g(the)g
(parser)g(class)h(in)f(an)g(ANTLR)g(grammar)f(description,)f(enclose)i
(the)g(appropriate)e(rules)i(and)0 1301 y(actions)h(in)g(a)h(C++)g
(class)g(de\256nition,)e(as)i(follo)n(ws.)125 1412 y
Fq(class)44 b(Expr)g Fg(f)125 1504 y Fq(<>)125
1595 y(<<)125 1686 y(public:)304 1778 y(void)g(print\(\);)125
1869 y(>>)125 1960 y(e)134 b(:)g(INT)45 b(\("\\*")f(INT\)*)f(;)304
2035 y(.)304 2068 y(.)304 2101 y(.)762 b(//)44 b(other)g(grammar)g
(rules)125 2193 y Fg(g)0 2384 y Fm(Thus,)25 b(a)g(parser)g(object)f(is)
i(simply)e(a)h(set)h(of)e(actions)h(and)f(routines)g(for)g(matching)f
(a)i(rule.)43 b(Consequently)-5 b(,)23 b(it)j(is)g(natural)d(to)0
2483 y(ha)n(v)o(e)d(man)o(y)g(separate)g(parser)g(objects.)31
b(F)o(or)21 b(e)o(xample,)e(if)i(parsing)f(C)i(code,)e(we)h(might)f(ha)
n(v)o(e)g(dif)n(ferent)f(parser)i(classes)g(for)g(C)0
2583 y(e)o(xpressions,)e(for)g(C)i(function)e(de\256nitions,)g(and)h
(for)f(assembly)h(code.)29 b(P)o(arsing)19 b(multiple)h(languages)f(or)
h(parts)g(of)g(languages)0 2683 y(simply)j(in)m(v)n(olv)o(es)e
(switching)i(parsers)g(objects.)37 b(F)o(or)23 b(e)o(xample,)f(assume)h
(you)f(ha)n(v)o(e)g(a)i(w)o(orking)d(C)j(language)d(front-end.)35
b(T)-7 b(o)0 2782 y(e)n(v)n(aluate)18 b(C)i(e)o(xpressions)d(in)i(a)h
(deb)n(ugger)m(,)c(just)j(use)h(the)e(parser)h(object)f(for)g(C)i(e)o
(xpressions)e(\(assuming)f(the)i(semantic)g(actions)0
2882 y(were)h(\257e)o(xible)g(enough\).)125 2981 y(Currently)-5
b(,)22 b(ANTLR)h(only)f(allo)n(ws)i(one)e(class)i(de\256nition)e(per)h
(grammar)-5 b(.)37 b(This)23 b(will)h(change)e(in)h(future)f(v)o
(ersions)g(when)0 3081 y(we)f(\256gure)e(out)h(ho)n(w)g(grammar)e
(class)j(inheritance)e(should)g(w)o(ork.)125 3181 y(T)-7
b(o)13 b(ensure)g(compatibility)g(among)g(d)o(if)n(fer)o(ent)g(in)o(pu)
o(t)g(streams,)c(le)o(x)o(ers,)k(tok)o(en)g(b)n(uf)n(fers,)e(and)i
(parsers,)g(all)g(objects)g(are)g(deri)n(v)o(ed)0 3280
y(from)k(one)h(of)f(the)i(four)e(common)f(bases)i(classes)i
Fk(DLGInputStream)p Fm(,)c Fk(DLGLexer)h Fm(\(or)g Fk(ANTLRTokenStream)
f Fm(if)i(you)0 3380 y(roll)i(your)f(o)n(wn)h(le)o(x)o(er\),)e
Fk(ANTLRTokenBuffer)g Fm(or)i Fk(ANTLRParser)p Fm(.)125
3480 y(Please)g(see)h(the)f(C++)h(sample)f(\256les)h(collected)f(in)g
(the)g Fk(testcpp.tar)f Fm(\256le.)0 3716 y Ff(3.1)99
b(C++)25 b(T)-9 b(ok)o(en)26 b(De\256nitions)0 3872 y
Fm(T)-7 b(o)19 b(increase)f(\257e)o(xibility)-5 b(,)18
b(the)h(tok)o(en)f(class)h(hierarchy)e(has)i(changed)e(since)i(release)
f(1.20;)h(see)g(Figure)f(2.)29 b(W)-7 b(e)20 b(did)e(this)h(mainly)0
3971 y(so)c(that)h(the)f(minimal)f(tok)o(en)g(is)i(simply)f(an)g
Fk(int)p Fm(.)27 b(Some)15 b(programmers)d(ha)n(v)o(e)j(e)o(xisting)f
(scanners)h(which)f(cannot)g(be)h(modi\256ed.)0 4071
y(W)-7 b(e)28 b(encountered)d(one)h(such)h(scanner)f(that)h(de\256ned)g
(tok)o(ens)f(to)h(be)g(inte)o(gers;)j(hence,)e(a)g(mandatory)c(virtual)
j(table)g(pointer)0 4171 y(inside)20 b(each)g(tok)o(en)f(object)h(w)o
(ould)f(render)g(ANTLR)i(and)e(their)h(system)h(incompatible.)125
4270 y(The)e(classes)j(are)e(described)f(as)i(follo)n(ws:)125
4446 y Fe(\017)41 b Fm(An)18 b Fk(ANTLRAbstractToken)e
Fm(cannot)i(be)h(instantiated)f(and)g(can)g(be)h(subclassed)f(for)h
(truly)f(unusual)f(tok)o(en)h(de\256ni-)208 4545 y(tions;)23
b(this)g(requires)e(changes)g(to)h(the)g(functions)f(in)i
Fk(ANTLRParser)d Fm(which)i(obtain)f(the)h(tok)o(en)g(type)g(from)f(a)h
(tok)o(en)208 4645 y(object)d(such)h(as)h Fk(ANTLRParser::LT\(\))p
Fm(.)125 4808 y Fe(\017)41 b Fm(If)22 b(a)h(programmer)c(w)o(ants)k(a)g
(tok)o(en)e(object)h(that)h(merely)e(holds)h(a)h(tok)o(en)f(type)g(and)
g(does)g(not)g(contain)f(a)i(virtual)f(table,)208 4908
y(the)o(y)c(may)g(subclass)h Fk(ANTLRLightweightToken)p
Fm(.)26 b(Ho)n(we)n(v)o(er)m(,)17 b(because)h(ANTLR)h(w)o(ants)h(to)f
(kno)n(w)e(the)i(te)o(xt)g(and)208 5008 y(line)k(number)f(associated)h
(with)h(a)g(tok)o(en)f(for)g(error)f(reporting)g(purposes,)h
Fk(ANTLRParser)f Fm(must)i(be)f(subclassed)g(to)208 5107
y(rede\256ne)c(the)h(error)f(handling)f(routines)i(such)g(as)g
Fk(ANTLRParser::syn\(\))p Fm(.)1839 5356 y(3)p eop
%%Page: 4 4
4 3 bop 1127 -293 a
11577589 12432752 0 0 11577589 12432752 startTexFig
1127 -293 a
%%BeginDocument: newtokens.ps
/$F2psDict 32 dict def
$F2psDict begin
$F2psDict /mtrx matrix put

end
/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
/$F2psEnd {$F2psEnteredState restore end} def
%%EndProlog

$F2psBegin
1 setlinecap 1 setlinejoin
-90 99 translate
0.000000 189.000000 translate 0.900 -0.900 scale
1.000 setlinewidth
newpath 199 284 moveto 199 309 lineto stroke
newpath 201.000 301.000 moveto 199.000 309.000 lineto 197.000 301.000 lineto stroke
newpath 199 244 moveto 199 264 lineto stroke
newpath 201.000 256.000 moveto 199.000 264.000 lineto 197.000 256.000 lineto stroke
newpath 199 204 moveto 199 229 lineto stroke
newpath 201.000 221.000 moveto 199.000 229.000 lineto 197.000 221.000 lineto stroke
newpath 199 164 moveto 199 184 lineto stroke
newpath 201.000 176.000 moveto 199.000 184.000 lineto 197.000 176.000 lineto stroke
newpath 199 124 moveto 199 149 lineto stroke
newpath 201.000 141.000 moveto 199.000 149.000 lineto 197.000 141.000 lineto stroke
/Courier findfont 12.000 scalefont setfont
99 319 moveto
1 -1 scale
(ANTLRCommonBacktrackingToken) gsave 0.000 rotate show grestore 1 -1 scale
/Courier findfont 12.000 scalefont setfont
144 279 moveto
1 -1 scale
(ANTLRCommonToken) gsave 0.000 rotate show grestore 1 -1 scale
/Courier findfont 12.000 scalefont setfont
154 239 moveto
1 -1 scale
(DLGBasedToken) gsave 0.000 rotate show grestore 1 -1 scale
/Courier findfont 12.000 scalefont setfont
149 199 moveto
1 -1 scale
(ANTLRTokenBase) gsave 0.000 rotate show grestore 1 -1 scale
/Courier findfont 12.000 scalefont setfont
124 159 moveto
1 -1 scale
(ANTLRLightweightToken) gsave 0.000 rotate show grestore 1 -1 scale
/Courier findfont 12.000 scalefont setfont
134 119 moveto
1 -1 scale
(ANTLRAbstractToken) gsave 0.000 rotate show grestore 1 -1 scale
$F2psEnd
%%EndDocument

endTexFig
1219 1465 a Fm(Figure)20 b(2:)29 b(C++)21 b(T)-7 b(ok)o(en)19
b(Class-Hierarchy)-5 b(.)125 1732 y Fe(\017)41 b Fm(Class)30
b Fk(ANTLRTokenBase)c Fm(describes)j(the)f(beha)n(vior)f(of)i(tok)o(en)
f(objects)g(as)i(desired)e(by)g(ANTLR.)h(Speci\256cally)-5
b(,)208 1832 y(ANTLR)25 b(tok)o(en)f(objects)h(kno)n(w)f(their)h(tok)o
(en)g(type,)g(line)h(number)m(,)e(and)g(associated)h(input)g(te)o(xt.)
43 b(This)26 b(is)g(mainly)e(for)208 1931 y(error)19
b(reporting)f(purposes.)125 2097 y Fe(\017)41 b Fm(An)o(y)12
b(ANTLR)g(grammar)g(that)g(uses)g(DLG)g(to)g(produce)g(a)g(scanner)g
(must)g(deri)n(v)n(e)g(a)g(tok)o(en)f(class)h(from)g
Fk(DLGBa)o(sedTok)o(en)p Fm(.)208 2197 y(This)20 b(class)h(adds)f(a)h
Fk(int)p 993 2197 25 4 v 79 w(line)f Fm(\256eld)g(to)g(the)h(tok)o(en)e
(object.)125 2363 y Fe(\017)41 b Fm(Class)21 b Fk(ANTLRCommonToken)d
Fm(is)j(deri)n(v)o(ed)e(from)g Fk(DLGBasedToken)f Fm(and)i(contains)f
(a)i(te)o(xt)f(\256eld.)125 2529 y Fe(\017)41 b Fm(Class)14
b Fk(ANTLRCommonBacktrackingToken)g Fm(is)g(the)g(sam)o(e)g(as)g
Fk(AN)o(TLRCo)o(mmonTo)o(ken)f Fm(e)o(xc)o(ept)h(th)o(at)g(it)g(sh)o
(ou)o(ld)208 2629 y(be)22 b(used)g(when)g(syntactic)g(predicates)g(are)
g(used)g(in)h(the)g(ANTLR)f(grammar)f Fd(OR)i Fm(when)e(lookahead)g
Fc(k)29 b(>)d Fm(1.)36 b(See)23 b(the)208 2728 y(C++)d(test)h(\256les)h
(and)d(Section)h(3.3.)125 2911 y(The)j(programmer)e(must)i(still)i
(de\256ne)e(type)g Fk(ANTLRToken)g Fm(to)h(be)f(one)g(of)h(the)g
(prede\256ned)d(classes)k(or)e(to)h(one)f(of)h(their)0
3011 y(o)n(wn)c(just)g(as)h(in)g(1.20.)125 3110 y(If)31
b(you)g(de\256ned)g(your)f(o)n(wn)h Fk(ANTLRToken::makeToken\(\))d
Fm(for)j(the)h(1.20)f(release,)j(it')-5 b(s)33 b(return)e(type)g(must)h
(be)0 3210 y(changed)18 b(to)125 3392 y Fq(virtual)43
b(ANTLRLightweightToken)e(*makeToken\(TokenType,)h(ANTLRChar)h(*,)i
(int\);)0 3730 y Ff(3.2)99 b(The)26 b(Mysterious)f Ft(makeToken\(\))d
Ff(Function)0 3885 y Fm(Some)f(readers)f(may)g(w)o(onder)g(why)g
(function)f Fk(makeToken\(\))h Fm(is)h(required)f(at)h(all)h(and)e(why)
g(the)h(programmer)d(has)j(to)g(pass)0 3985 y(the)j(address)g(of)g(an)g
Fk(ANTLRToken)e Fm(into)i(DLG)h(during)d(parser)h(initialization.)41
b(Why)23 b(cannot)g(the)h(constructor)f(be)h(used)f(to)0
4085 y(create)h(a)g(tok)o(en)f(and)g(so)h(on?)40 b(The)23
b(reason)h(lies)g(with)g(the)g(scanner)m(,)f(which)h(must)g(construct)e
(the)i(tok)o(en)f(objects.)40 b(The)23 b(DLG)0 4184 y(support)i
(routines)g(are)h(typically)g(in)g(a)h(precompiled)d(object)h(\256le)i
(that)g(is)g(link)o(ed)e(in)i(re)o(gardless)e(of)g(your)g(tok)o(en)h
(de\256nition.)0 4284 y(Hence,)20 b(DLG)g(must)g(be)g(able)g(to)h
(create)f(tok)o(ens)f(of)h(an)o(y)g(type.)125 4384 y(Because)d(objects)
g(in)g(C++)g(are)g(not)g(\252self-conscious\272)e(\(i.e.,)i(the)o(y)g
(don')o(t)e(kno)n(w)h(their)h(o)n(wn)f(type\),)h(DLG)g(has)g(no)g(idea)
g(what)0 4483 y(the)f(appropriate)e(constructor)h(is.)28
b(Constructors)16 b(cannot)f(be)h(virtual)g(an)o(yw)o(ay;)g(so,)h(we)g
(had)f(to)g(come)g(up)g(with)g(a)h(\252constructor\272)0
4583 y(that)29 b(is)h(virtual)f(and)g(that)g(acts)h(lik)o(e)f(a)h(f)o
(actory\320it)e(returns)h(the)g(address)g(of)f(a)i(\(possibly)e(ne)n
(w\))h(tok)o(en)f(object)h(upon)f(each)0 4682 y(in)m(v)n(ocation)18
b(rather)i(than)f(just)i(initializing)f(an)g(e)o(xisting)f(object.)125
4782 y(Because)24 b(classes)h(are)f(not)g(\256rst-class)h(objects)f(in)
g(C++)h(\(i.e.,)f(you)f(cannot)g(pass)i(class)g(names)f(around\),)e(we)
j(must)f(pass)0 4882 y(DLG)i(the)h(address)e(of)h(an)g
Fk(ANTLRToken)f Fm(tok)o(en)h(object)f(so)i(DLG)f(has)g(access)h(to)g
(the)f(appropriate)e(virtual)h(table)h(and)g(is,)0 4981
y(thus,)20 b(able)g(to)g(call)h(the)f(appropriate)e Fk(makeToken\(\))p
Fm(.)125 5081 y(This)i(weirdness)g(w)o(ould)f(disappear)g(if)i(all)f
(objects)g(kne)n(w)g(their)g(type)f(or)h(if)h(class)g(names)f(were)g
(\256rst-class)h(objects.)1839 5356 y(4)p eop
%%Page: 5 5
5 4 bop 125 -210 a Fm(Here)30 b(is)h(the)f(code)g(fragment)e(in)j(DLG)f
(that)g(constructs)g(the)g(tok)o(en)f(objects)h(that)h(are)f(passed)g
(to)g(the)h(parser)e(via)i(the)0 -110 y Fk(ANTLRTokenBuffer)p
Fm(:)125 72 y Fq(ANTLRAbstractToken)41 b(*DLGLexerBase::)125
164 y(getToken\(\))125 255 y Fg(f)304 346 y Fq(if)j(\()h(token)p
757 346 23 4 v 26 w(vtbl==NULL)e(\))i(DLGPanic\("NULL)d(token)p
2263 346 V 26 w(vtbl"\);)304 438 y(TokenType)h(tt)i(=)f
(nextTokenType\(\);)304 529 y(DLGBasedToken)f(*tk;)304
620 y(tk)h(=)h(\(DLGBasedToken)d(*\)token)p 1519 620
V 26 w(vtbl->makeToken\(tt,)p 2442 620 V 69 w(lextext,)p
2873 620 V 70 w(line\);)304 712 y(tk->setLine\()p 848
712 V 25 w(line\);)304 803 y(return)i(tk;)125 894 y Fg(g)0
1232 y Ff(3.3)99 b(ANTLR)26 b(T)-9 b(ok)o(en)26 b(Buffers)g(and)g(Str)n
(eams)0 1387 y Fm(The)f(1.20)f(release)h(of)f(PCCTS)j(connected)c(an)i
Fk(ANTLRTokenStream)d Fm(to)j(the)g(parser)g(to)g(pro)o(vide)e(tok)o
(ens.)43 b(In)25 b(an)g(ef)n(fort)0 1487 y(to)15 b(isolate)g(the)g
(arbitrary)e(lookahead)g(mechanism)g(from)h(the)h(parser)f(class,)j
(1.21)c(introduces)h Fk(ANTLRTokenBuffer)p Fm(s.)25 b(The)0
1587 y(parser)12 b(is)g(\252attached\272)g(to)g(an)g
Fk(ANTLRTokenBuffer)g Fm(via)g(interf)o(ace)g(functio)o(ns)g
Fk(getToke)o(n\(\))g Fm(and)f Fk(buffer)o(edToke)o(n\(\))p
Fm(.)0 1686 y(The)22 b(object)g(that)g(actually)g(consumes)f
(characters)g(and)h(constructs)g(tok)o(ens,)g(a)h(deri)n(v)n(ati)n(v)o
(ed)c(of)j Fk(ANTLRTokenStream)p Fm(,)f(is)0 1786 y(connected)c(to)j
(the)f Fk(ANTLRTokenBuffer)e Fm(via)j(interf)o(ace)e(function)g
Fk(getToken\(\))g Fm(where)h Fk(ANTLRTokenStream)e Fm(is)0
1885 y(really)k(just)i(a)f(beha)n(vior)e(\(class)i(with)g(no)f(data\).)
34 b([C++)22 b(does)f(not)h(ha)n(v)o(e)f(this)h(abstraction)f(and)g
(hence)g(we)h(simply)f(ha)n(v)o(e)g(come)0 1985 y(up)f(with)g(a)h(f)o
(anc)o(y)e(name)g(for)h(\252)p Fk(void)49 b(*)p Fm(\272].)125
2085 y(De\256ne)12 b Fk(DEBUG)p 614 2085 25 4 v 28 w(TOKENBUFFER)g
Fm(to)g(ha)n(v)o(e)g(ANTLR)g(do)g(e)o(xtra)g(checking)g(to)g(ensure)g
(yo)o(ur)f(ar)o(g)o(um)o(ents)h(to)g(the)g Fk(ANTLRT)o(okenBu)o(ffer)0
2184 y Fm(constructor)23 b(mak)o(e)i(sense.)44 b(Y)-9
b(ou)24 b(must)h(specify)g(enough)e(minimum)g(arbitrary)h(lookahead)f
(to)i(co)o(v)o(er)e(the)i(\256nite)h(lookahead)0 2284
y(speci\256ed)20 b(on)g(the)g(ANTLR)g(command)f(line.)125
2384 y(The)12 b Fk(ANTLRTokenBuffer)g Fm(class)g(maintains)g(a)g
(\252sliding)g(windo)n(w\272)g(of)g(look)o(ahea)o(d)g(into)g(the)g
Fk(ANT)o(LRTok)o(enStre)o(am)p Fm(;)0 2483 y(a)23 b(minimum)f(windo)n
(w)f(size)j(must)f(be)g(speci\256ed)f(during)f(tok)o(en)i(b)n(uf)n(fer)
e(construction.)35 b(This)23 b(set)h(of)e(pointers)g(can)h(point)f(to)h
(a)0 2583 y(single)d(or)g(multiple)g(tok)o(en)f(objects.)29
b(The)20 b(follo)n(wing)e(scenarios)i(are)g(possible:)104
2766 y(1.)41 b Fd(The)21 b(parser)f(does)h(not)f(need)g(to)g(backtrack)
g(\(no)g(syntactic)f(pr)o(edicates\))p Fm(.)307 2932
y Fe(\017)41 b Fm(If)31 b(DLG)g(is)h(used)e(to)h(produce)e(an)i
Fk(ANTLRTokenStream)p Fm(,)g(then)f Fk(makeToken\(\))f
Fm(can)i(simply)f(\256ll)i(in)f(a)390 3031 y Fk(static)p
Fm(,)20 b(local)g(cop)o(y)g(of)g(an)g Fk(ANTLRToken)f
Fm(and)h(return)f(the)h(same)h(address)f(continuously)-5
b(.)26 b(Here)21 b(is)g(ho)n(w)f(an)390 3131 y Fk(ANTLRCommonToken)e
Fm(\252computes\272)h(a)h(tok)o(en)g(for)f(DLG.)390 3330
y Fq(virtual)44 b(ANTLRLightweightToken)d(*makeToken\(TokenType)h(tt,)i
(ANTLRChar)f(*txt,)h(int)h(line\))749 3421 y Fg(f)928
3513 y Fq(static)f(ANTLRCommonToken)e(t;)928 3604 y(t.setType\(tt\);)h
(t.setText\(txt\);)f(t.setLine\(line\);)928 3695 y(return)i(&t;)749
3787 y Fg(g)307 4019 y Fe(\017)d Fm(If)24 b(you)f(mak)o(e)g(your)f(o)n
(wn)h(scanner)m(,)h(you)e(can)i(return)e(the)i(same)g(object)f(just)i
(lik)o(e)e(DLG)h(does.)40 b(F)o(or)23 b(e)o(xample,)g(a)390
4119 y(scanner)d(that)g(simply)g(returned)e(tok)o(ens)i(with)g
(increasing)f(inte)o(ger)g(tok)o(en)h(types)g(could)f(be)h(de\256ned)f
(as)i(follo)n(ws:)390 4318 y Fq(ANTLRAbstractToken)42
b(*MyLexer::getToken\(\))390 4409 y Fg(f)570 4501 y Fq(static)h
(MyToken)h(t;)570 4592 y(static)f(int)i(i=1;)570 4683
y(t.setType\(i++\);)570 4775 y(return)e(&t;)390 4866
y Fg(g)390 5082 y Fm(where)20 b Fk(MyLexer)f Fm(is)i(the)g(name)e(of)h
(your)f(scanner)g(class.)1839 5356 y(5)p eop
%%Page: 6 6
6 5 bop 208 -210 a Fm(In)17 b(both)g(cases,)h(the)g(scanner)f(has)h
(the)g(option)e(to)i(return)e(the)i(same)g(physical)e(object)h
(\(modi\256ed)g(each)g(time)h(the)f(scanner)208 -110
y(is)k(called\))e(or)h(return)f(a)i(stream)f(of)g(physical)f(dif)n
(ferent)f(tok)o(en)i(objects.)208 23 y(ANTLR)j(by)g(def)o(ault)g(mak)o
(es)g(a)h(cop)o(y)e(of)h(all)h(objects)f(sent)h(to)f(the)g(parser)g
(and)g(so)g(the)h Fk($)p Fm(-v)n(ariables)e(point)g(to)i(distinct,)208
122 y(local)18 b(copies)h(of)f(the)h(tok)o(en)f(objects)g(passed)h(to)f
(the)h(tok)o(en)f(b)n(uf)n(fer)-5 b(.)28 b(This)19 b(is)g(unnecessary)e
(if)i(you)f(pass)h(distinct)g(objects)208 222 y(to)31
b(the)h(tok)o(en)e(b)n(uf)n(fer)g(in)i(the)g(\256rst)g(place;)37
b(the)31 b(ANTLR)h Fk(-ct)f Fm(command)f(line)h(option)g(can)g(be)g
(used)h(to)f(turn)g(this)208 322 y(redundant)20 b(cop)o(ying)i(of)n(f.)
37 b([)p Fj(W)-8 b(arning)p Fm(:)34 b(It)24 b(is)g(v)o(ery)e(possible)h
(that)g(in)g(a)h(future)d(v)o(ersion,)i(the)g(tok)o(en)f(b)n(uf)n(fer)g
(will)i(do)f(the)208 421 y(cop)o(ying)18 b(rather)h(than)h(the)g
(parser].)104 587 y(2.)41 b Fd(The)28 b(parser)g(must)h(be)f(able)g(to)
f(backtrack)p Fm(.)51 b(In)28 b(this)g(case,)i(physically)c(distinct)h
(tok)o(ens)h(must)f(be)h(passed)g(to)g(the)208 687 y
Fk(ANTLRTokenBuffer)h Fm(by)i Fk(ANTLRTokenStream::getToken\(\))p
Fm(.)59 b(During)30 b(backtracking,)i(the)f(parser)208
786 y(reloads)20 b(its)i(local)f(tok)o(en)f(type)h(cache)g(from)f(the)h
Fk(ANTLRTokenBuffer)p Fm(')-5 b(s)19 b(sliding)i(windo)n(w)f(of)g(tok)o
(en)h(pointers.)31 b(If)208 886 y(the)23 b(tok)o(en)f(pointers)h(all)h
(pointed)e(to)h(the)h(same)f(tok)o(en,)g(the)h(lookahead)d(cache)i(in)g
(the)h(parser)e(could)h(not)g(be)g(reloaded)208 986 y(correctly)-5
b(.)307 1168 y Fe(\017)41 b Fm(If)c(DLG)g(is)h(used)f(to)g(produce)e
(an)i Fk(ANTLRTokenStream)p Fm(,)h(DLG)f(cannot)f(simply)h(modify)e
(and)i(return)390 1268 y(the)k(same)f(tok)o(en)g(object.)89
b(Currently)-5 b(,)44 b(the)c Fk(new)g Fm(operator)f(is)i(used)f(by)g
(the)h(prede\256ned)d(tok)o(en)i(objects)390 1368 y(such)d(as)g
Fk(ANTLRCommonBacktrackingToken)p Fm(.)74 b(The)37 b(programmer)d(is)j
(free)g(to)g(subclass)g(and)f(re-)390 1467 y(de\256ne)f
Fk(makeToken\(\))e Fm(to)i(use)g(a)h(more)e(ef)n(\256cient)g(memory)g
(allocator)-5 b(.)72 b(Here)35 b(is)h(the)f(de\256nition)f(of)h(the)390
1567 y Fk(ANTLRCommonBacktrackingToken)p Fm(.)390 1766
y Fq(class)44 b(ANTLRCommonBacktrackingToken)c(:)45 b(public)f
(ANTLRCommonToken)e Fg(f)390 1857 y Fq(public:)570 1949
y(virtual)h(ANTLRLightweightToken)e(*makeToken\(TokenType)h(tt,)i
(ANTLRChar)g(*txt,)g(int)390 2040 y(line\))749 2131 y
Fg(f)928 2223 y Fq(ANTLRCommonToken)e(*t)j(=)f(new)h(ANTLRCommonToken;)
928 2314 y(t->setType\(tt\);)d(t->setText\(txt\);)h
(t->setLine\(line\);)928 2405 y(return)h(t;)749 2497
y Fg(g)570 2588 y Fq(ANTLRCommonBacktrackingToken\(TokenTy)o(pe)39
b(t,)44 b(ANTLRChar)g(*s\))g(:)h(ANTLRCommonToken\(t,s\))749
2679 y Fg(f)p Fq(;)p Fg(g)570 2771 y Fq
(ANTLRCommonBacktrackingToken\(\))39 b Fg(f)p Fq(;)p
Fg(g)390 2862 y(g)p Fq(;)307 3094 y Fe(\017)i Fm(If)23
b(the)f(programmer)e(de\256nes)i(his/her)h(o)n(wn)f(scanner)m(,)g(then)
g(the)o(y)g(must)g(return)g(distinct)h(tok)o(en)e(objects)i(as)g(well.)
390 3194 y(F)o(or)d(e)o(xample,)f(we)h(could)f(modify)g(our)g
Fk(getToken\(\))g Fm(abo)o(v)o(e)g(in)h(the)g(follo)n(wing)f(w)o(ay:)
390 3393 y Fq(virtual)44 b(ANTLRAbstractToken)e(*MyLexer::getToken\(\))
749 3485 y Fg(f)928 3576 y Fq(static)i(MyToken)g(*t)g(=)h(new)f
(MyToken;)928 3667 y(static)g(int)g(i=1;)928 3759 y(t->setType\(i++\);)
928 3850 y(return)g(t;)749 3941 y Fg(g)208 4224 y Fm(F)o(or)16
b(backtracking)d(parsers,)k(the)f Fk(-ct)h Fm(command)d(line)i(option)f
(should)h(be)g(used)g(to)h(turn)e(of)n(f)h(redundant)e(cop)o(ying)g
(tok)o(en)208 4323 y(object)19 b(cop)o(ying)g(because)g(the)h
Fk(ANTLRTokenBuffer)e Fm(will)j(already)e(contain)g(distinct)i
(objects.)208 4456 y Fj(It)f(is)h(the)f(pr)l(o)o(gr)o(ammer)o(s)g(r)m
(esponsibility)g(to)h(tr)o(ac)n(k)f(and)f(to)i Fk(delete)e
Fj(any)h Fk(ANTLRToken)f Fj(objects)h(that)g(the)n(y)f(cr)m(eate)o(.)0
4694 y Ff(3.4)99 b(Access)25 b(to)g(the)h(Lookahead)g(Buffer)0
4849 y Fm(ANTLR)15 b(parsers)g(may)g(access)h(the)f Fc(i)1076
4819 y Fb(th)1160 4849 y Fm(tok)o(en)f(object)h(of)g(lookahead)e(via)i
(the)g Fk(ANTLRParser::LT\()p Fc(i)p Fk(\))d Fm(function.)26
b Fk(LT\(1\))0 4949 y Fm(al)o(w)o(ays)20 b(returns)e(a)i(pointer)e(to)i
(the)f(tok)o(en)g(object)g(for)f(the)i(ne)o(xt)e(lookahead)g(symbol.)28
b(Y)-9 b(ou)18 b(may)h(look)g(ahead)f(until)i(end-of-\256le)0
5049 y(if)27 b(necessary)-5 b(.)46 b(De\256ne)26 b Fk(DEBUG)p
967 5049 25 4 v 29 w(TOKENBUFFER)f Fm(to)i(ha)n(v)o(e)e(ANTLR)i(do)f(e)
o(xtra)f(checking)g(to)h(ensure)g(your)f(ar)o(guments)f(to)1839
5356 y(6)p eop
%%Page: 7 7
7 6 bop 0 -210 a Fm(the)26 b Fk(ANTLRTokenBuffer)e Fm(constructor)g
(mak)o(e)i(sense)g(and)g(that)g(your)f(calls)i(to)f Fk(LT\(\))g
Fm(are)h(ok.)46 b(Y)-9 b(ou)26 b(may)g(check)f Fc(i)h
Fm(for)0 -110 y(v)n(alidity)d(by)h(calling)f Fk
(inputTokens->bufferSize\(\))d Fm(where)k Fk(inputTokens)e
Fm(is)j(an)f(member)f(v)n(ariable)g(of)h(your)0 -11 y
Fk(ANTLRParser)p Fm(;)e(References)g(to)h Fk(LT\()p Fc(i)p
Fk(\))f Fm(be)o(yond)f(the)h(end)g(of)h(\256le)g(returns)f(a)h(pointer)
e(to)i(the)f Fk(ANTLRToken)g Fm(for)g(end)g(of)0 89 y(\256le)f(as)g
(you)e(ha)n(v)o(e)h(prescribed.)125 189 y(Semantic)f(predicates)h(in)g
(C++)h(mode)e(should)g(use)i(the)f(follo)n(wing)e(rather)i(than)f
Fk(LATEXT\(\))p Fm(.)29 b(F)o(or)19 b(e)o(xample,)125
371 y Fq(typename)43 b(:)i(<getText\(\)\)>>?)40
b(ID)k(;)125 571 y Fm(The)19 b Fk(LA\()p Fc(i)p Fk(\))h
Fm(function)e(access)j(the)f(local)h(parser)e(tok)o(en)h(type)f(cache)h
(and,)f(hence,)h(is)h(only)e(v)n(alid)h(for)f Fc(i)k
Fa(=)g Fm(1)p Fc(::k)s Fm(.)0 808 y Ff(3.5)99 b(Arbitrary)26
b(Lookahead)g(and)f(Semantic)h(Pr)n(edicates)0 964 y
Fm(There)17 b(are)i(language)d(constructs)i(that)g(truly)g(need)f(a)i
(combined)d(syntactic)i(and)g(semantic)g(predicate)f(to)i(be)f(parsed)g
(correctly)-5 b(.)0 1064 y(One)19 b(possible)g(solution)f(is)i(to)f
(use)g(a)h(semantic)e(predicate)g(that)h(calls)h(a)f(function)f(that)h
(\252spins\272)g(ahead)f(looking)f(at)j(the)f(in\256nite)0
1163 y(tok)o(en)g(b)n(uf)n(fer)g(and)h(checks)g(for)f(semantic)h(v)n
(alidity)f(as)i(well.)30 b(F)o(or)20 b(e)o(xample,)125
1346 y Fq(int)44 b(isQualClassName\(\))125 1437 y Fg(f)304
1528 y Fq(int)g(i=1;)304 1620 y(ANTLRToken)f(*tk)h(=)h(LT\(1\);)304
1802 y(if)f(\()h(LA\(1\)!=ID)e(||)i(tk==NULL)e(\))i(return)f(0;)304
1985 y(while)g(\()h(tk->getType\(\)!=Eof)c(&&)663 2076
y(\(tk->getType\(\)==ID)g(||)k(tk->getType\(\)==COLON)p
2553 2076 23 4 v 23 w(COLON\))f(\))304 2168 y Fg(f)483
2259 y Fq(tk)h(=)f(LT\(++i\);)304 2350 y Fg(g)304 2442
y Fq(if)g(\()h(isClassName\()e(LT\(i-1\)->getText\(\))f(\))i(\))h
(return)f(1;)304 2533 y(return)g(0;)125 2624 y Fg(g)125
2807 y Fq(qualified)p 534 2807 V 25 w(classname)304 2898
y(:)134 b(<>?)41 b(\()k(ID)f("::")h(\)*)f(ID)304
2990 y(;)0 3189 y Fm(where)31 b Fk(isClassName\(\))e
Fm(is)j(some)f(function)f(that)h(e)o(xamines)f(the)i(symbol)e(table)h
(to)h(determine)d(whether)i(or)g(not)g(the)0 3289 y(ar)o(gument)18
b(is)j(a)g(v)n(alid)e(class)i(name.)29 b(This)20 b(is)i(not)d
(completely)g(rob)n(ust,)g(b)n(ut)i(demonstrates)e(the)h(idea.)125
3388 y(A)26 b(mechanism)g(lik)o(e)g(this)h(is)h(required)c(to)j
(distinguish)e(between)h(quali\256ed)f(class)j(names)e(and)g
(quali\256ed)f(identi\256ers)h(in)0 3488 y(C++.)0 3725
y Ff(3.6)99 b(Global)24 b(V)-9 b(ariables)0 3881 y Fm(If)24
b(the)h(programmer)c(requires)j(a)h(v)n(ariable)e(which)h(is)h(visible)
g(to)f(all)h(rules,)h(the)o(y)d(may)h(de\256ne)g(a)h(global)f(v)n
(ariable)f(inside)i(the)0 3981 y Fk(class)d Fm(de\256nition.)33
b(Doing)21 b(so)i(renders)e(the)h(v)n(ariable)f(a)h(member)f(of)h(the)g
(class)h(and,)e(hence,)h(a)g(real)g(global)f(v)n(ariable)g(in)i(the)0
4080 y(C/C++)e(sense)g(is)g(not)f(de\256ned\320resulting)e(in)i(a)h
(cleaner)e(\(and)g(re-entrant\))f(program.)27 b(F)o(or)20
b(e)o(xample,)125 4198 y Fq(class)44 b(MyClass)f Fg(f)125
4289 y Fq(< 1008 4289 V 26 w(name;>>)125 4472 y(a)h(:)h(...)f(< 892 4472 V 26 w(file)p 1098 4472 V 26 w(name)g(=)h("blah";>>)e(;)125
4655 y Fg(g)1839 5356 y Fm(7)p eop
%%Page: 8 8
8 7 bop 0 -210 a Ff(3.7)99 b($-V)-9 b(ariables)24 b(in)h(C++)g(Mode)0
-54 y Fm(Because)g(attrib)n(utes)g(do)f(not)h(e)o(xist)g(in)g(C++)g
(mode,)g($-v)n(ariables)e(point)h(to)h Fk(ANTLRToken)p
Fm(s.)42 b(Further)m(,)24 b($-v)n(ariables)f(do)i(not)0
45 y(e)o(xist)20 b(for)g(rule)f(references.)28 b(Rule)20
b(ar)o(guments)e(and)i(return)f(v)n(alues)g(should)g(be)h(used)g
(instead.)29 b(W)-7 b(e)21 b(anticipate)e(the)i(remo)o(v)n(al)d(of)0
145 y($-v)n(ariables)i(all)i(together)e(in)i(future)e(releases)i(in)g
(f)o(a)n(v)n(or)f(of)g(labels)h(for)e(rule)i(elements)f(such)g(as)h(in)
g(the)g(tree-parser)e(generator)0 245 y(SORCERER.)125
344 y($-v)n(ariables)e(are)i(pointers)f(to)i Fk(ANTLRToken)p
Fm(s)e(e)o(xclusi)n(v)o(ely)f(in)j(C++)f(mode.)0 582
y Ff(3.8)99 b(DLG)25 b(Classes)0 738 y Fm(The)20 b(DLG)g(C++)h(interf)o
(ace)e(has)i(not)f(changed)e(from)h(a)i(programmer')-5
b(s)17 b(point)j(of)g(vie)n(w)-5 b(.)0 1018 y Fl(4)116
b(Miscellaneous)29 b(Changes)125 1203 y Fe(\017)41 b
Fm(The)28 b Fk(genmk)g Fm(program)f(has)h(been)g(upgraded)e(in)j(a)g
(fe)n(w)g(minor)e(w)o(ays.)55 b(F)o(or)28 b(e)o(xample,)h(it)h(is)f(no)
n(w)f(sensiti)n(v)o(e)h(to)g(the)208 1303 y Fk(config.h)19
b Fm(\256le;)i(hence,)e(it)i(will)g(no)n(w)e(do)h(the)g(\252right)g
(thing\272)f(for)h(the)g(PC)h(\(such)f(as)h(using)e Fk(.obj)h
Fm(instead)g(of)g Fk(.o)p Fm(\).)125 1469 y Fe(\017)41
b Fm(The)19 b(ANTLR)i Fk(-gk)f Fm(option)f(is)i(no)n(w)f(a)g(w)o
(arning)f(not)h(an)g(error)f(when)h(used)g(with)g(semantic)g
(predicates.)125 1635 y Fe(\017)41 b Fm(In)21 b(C++)i(mode,)e(the)h
(programmer)d(can)j(change)e(the)p 1780 1635 25 4 v 52
w Fk(line)i Fm(member)m(,)f(b)n(ut)h(should)f(call)h(the)g
Fk(newline\(\))f Fm(member)208 1735 y(function)13 b(instead.)28
b(Access)16 b(to)f(the)h(current)e(line)h(number)f(can)h(be)h(obtained)
e(via)h Fk(line\(\))p Fm(.)27 b(The)15 b(parser)g(normally)f(does)208
1834 y(not)24 b(access)g(the)h(line)f(number)f(directly)g(from)h(the)g
(le)o(x)o(er)f(in)i(C++)g(mode,)f(ho)n(we)n(v)o(er)-5
b(.)40 b(T)-7 b(ypically)i(,)24 b(the)g Fk(ANTLRToken)208
1934 y Fm(object)19 b(contains)h(the)g(line)g(number)f(on)g(which)h(it)
h(w)o(as)g(found.)125 2100 y Fe(\017)41 b Fm(In)20 b(C++)h(mode,)f(DLG)
g(no)n(w)g(assumes)h Fk(DLGInputStream::nextChar\(\))16
b Fm(returns)k(an)h Fk(int)f Fm(so)h(that)g(-1)f(\()p
Fk(EOF)p Fm(\))208 2200 y(is)h(handled)d(correctly)-5
b(.)0 2480 y Fl(5)116 b(New)29 b(or)g(Renamed)e(Supplied)g(Files)125
2665 y Fe(\017)41 b Fk(AParser.h)p Fm(:)28 b(All)21 b(ANTLR)f(parser)g
(support)f(classes)i(and)f(the)g Fk(ANTLRParser)f Fm(class)i(itself.)
125 2832 y Fe(\017)41 b Fk(AParser.C)p Fm(:)19 b(ANTLR)h(parser)g
(support)f(code.)125 2998 y Fe(\017)41 b Fk(DLexerBase.h)p
Fm(:)27 b(DLG)21 b(scanner)e(support)g(classes)i(and)f
Fk(DLGLexerBase)e Fm(class.)125 3164 y Fe(\017)41 b Fk(DLexerBase.C)p
Fm(:)18 b(DLG)j(scanner)e(support)g(code.)125 3330 y
Fe(\017)41 b Fk(ASTBase.h)p Fm(:)28 b(AST)21 b(class)g(de\256nition.)
125 3496 y Fe(\017)41 b Fk(ASTBase.C)p Fm(:)19 b(AST)h(support)f(code.)
125 3662 y Fe(\017)41 b Fk(DLexer.C)p Fm(:)18 b(Support)g(code)h(that)h
(must)g(be)f(a)o(w)o(are)g(of)h(the)f(particular)f(scanner)h(generated)
f(by)h(DLG.)h(This)f(is)i(an)e(ugly)208 3761 y(mechanism)f(for)i
(including)e(the)j(DF)-6 b(A)20 b(automaton)f(and)g(will)i(change)e(in)
h(future)f(v)o(ersions.)125 3927 y Fe(\017)41 b Fk(AToken.h)p
Fm(:)24 b(De\256nitions)12 b(for)g(classes)g Fk(ANTLRTokenBase)p
Fm(,)f Fk(ANTLRLightweightToken)p Fm(,)f Fk(ANTLRAbstractToken)p
Fm(,)208 4027 y Fk(DLGBasedToken)p Fm(,)18 b(and)h Fk(ANTLRCommonToken)
p Fm(.)125 4193 y Fe(\017)41 b Fk(ATokenStream.h)p Fm(:)27
b(De\256nition)19 b(of)h(class)i Fk(ANTLRTokenStream)p
Fm(.)125 4359 y Fe(\017)41 b Fk(ATokenBuffer.h)p Fm(:)27
b(De\256nition)19 b(of)h(class)i Fk(ANTLRTokenBuffer)p
Fm(.)125 4525 y Fe(\017)41 b Fk(ATokenBuffer.C)p Fm(:)18
b(Code)i(for)f(class)i Fk(ANTLRTokenBuffer)p Fm(.)1839
5356 y(8)p eop
%%Page: 9 9
9 8 bop 0 -210 a Fl(6)116 b(Bugs)29 b(Fixed)g(f)m(or)f(1.21)125
-24 y Fe(\017)41 b Fm(Fix)o(ed)23 b(a)i(hideous)e(b)n(ug)h(in)g(the)h
Fk(-gl)f Fm(generate)f(line)i(info)e(option)g(that)i(sometimes)f(put)g
(the)g(line)h(directi)n(v)o(e)e(not)h(at)h(the)208 75
y(left)20 b(edge)f(of)h(a)h(line.)125 233 y Fe(\017)41
b Fm(Fix)o(ed)19 b(a)i(b)n(ug)e(in)p 708 233 25 4 v 51
w Fk(match)g Fm(with)i Fk(-gk)f Fm(mode;)f(it)i(didn')o(t)e(w)o(ork)g
(before.)125 391 y Fe(\017)41 b Fm(Added)p 455 391 V
49 w Fk(setmatch\(\))18 b Fm(to)j(C++)g(output)e(mode.)125
548 y Fe(\017)41 b Fm(The)19 b Fk(genmk)h Fm(program)e(had)i(a)h
(number)d(of)i(small)g(b)n(ugs.)125 706 y Fe(\017)41
b Fm(In)19 b(the)i(old)f Fk(antlrx.h)f Fm(\256le)i(for)e(C++)i(output,)
e Fk(zzfailed)p 2039 706 V 28 w(pred)h Fm(w)o(as)h(missing)f(a)h
(semi-colon.)125 864 y Fe(\017)41 b Fm(The)17 b(line)g(number)f(stuf)n
(f)h(for)g(in\256nite)h(lookahead)d(w)o(as)j(scre)n(wed)f(up)h(e)n(v)o
(en)e(for)h(C)h(mode.)28 b(This)17 b(has)h(changed)e(so)i(that)g(the)
208 964 y Fk(zzline)g Fm(v)n(ariable)g(\(in)h(C)h(mode\))e
(consistently)h(for)f(an)o(y)h(mode.)28 b(F)o(or)18 b(C++)i(output,)e
(the)h Fk(newline\(\))f Fm(and)h Fk(line\(\))208 1063
y Fm(macros)d(may)g(be)g(used.)28 b(T)-7 b(o)17 b(access)g(the)g(line)g
(number)d(for)i(a)h(particular)f(tok)o(en)g(from)f(the)i(parser)m(,)f
(use)h(the)g Fk(getLine\(\))208 1163 y(ANTLRToken)h Fm(function.)125
1320 y Fe(\017)41 b Fm(The)20 b(return)g(type)g(for)h
Fk(erraction)e Fm(in)i(the)g(DLG)h(C++)f(output)f(should)g(ha)n(v)o(e)g
(been)g Fk(TokenType)g Fm(to)h(be)g(consistent)208 1420
y(with)f(the)g(other)f(le)o(xical)h(actions.)125 1578
y Fe(\017)41 b Fm(The)19 b Fk(enum)49 b(TokenType)20
b Fm(de\256nition)f(no)g(longer)g(has)i(a)f(trailing)g(comma.)125
1736 y Fe(\017)41 b Fm(DLG)20 b(sometimes)g(de\256ned)f
Fk(DfaState)g Fm(inconsistently)g(for)h(C++)h(output.)125
1893 y Fe(\017)41 b Fm(The)18 b(AST)h(stuf)n(f)g(didn')o(t)e(w)o(ork)h
(correctly)f(with)i(syntactic)g(predicates)e(because)i(of)f(a)h
(missing)g Fk(zzNON)p 3218 1893 V 29 w(GUESS)p 3497 1893
V 29 w(MODE)208 1993 y Fm(in)h(the)g Fk(zzEXIT)g Fm(macro)f(\(C)i
(mode\).)125 2151 y Fe(\017)41 b Fm(Pre)n(viously)-5
b(,)32 b(the)g Fk(-w2)g Fm(generated)f(a)h(w)o(arning)f(for)g
(basically)h(e)n(v)o(ery)e(tok)o(en)i(de\256nition)e(indicating)h(that)
h(it)h(has)f(no)208 2250 y(associated)20 b(re)o(gular)e(e)o(xpression.)
125 2408 y Fe(\017)41 b Fm(The)23 b Fk(DLGFileInput)g
Fm(class)i(no)n(w)e(al)o(w)o(ays)i(immediately)e(returns)g
Fk(EOF)h Fm(once)f(that)h(condition)f(has)h(been)f(detected)208
2508 y(once.)28 b(It)21 b(is)g(no)e(longer)g(necessary)h(to)g(type)g
(more)f(than)h(one)g(end)f(of)h(\256le)h(character)e(in)h(C++)h(mode.)0
2784 y Fl(7)116 b(Futur)n(e)125 2970 y Fe(\017)41 b Fm(Good)28
b(error)h(reco)o(v)o(ery)e(and)i(reporting)f(is)j(notoriously)c(dif)n
(\256cult)i(to)h(achie)n(v)o(e)f(with)h(parser)f(generators,)h
(especially)208 3069 y Fc(LALR)q Fm(-based)k(tools.)77
b(The)36 b(pre)n(viously)e(mentioned)g Fj(par)o(ser)j(e)n(xception)e
(handling)f Fm(w)o(as)j(discussed)f(at)h(the)f(\256rst)208
3169 y(annual)19 b(PCCTS)k(w)o(orkshop.)29 b(A)22 b(reasonable)d
(implementation/syntax)f(has)j(been)f(obtained)g(and)g(we)i(anticipate)
e(their)208 3268 y(introduction)d(by)j(the)g(end)g(of)g(1994.)125
3426 y Fe(\017)41 b Fm(The)18 b(recognition)e(strength)i(of)g(hand-b)n
(uilt)f(parsers)h(arises)h(from)e(the)i(f)o(act)g(that)f
(arbitrarily-comple)o(x)d(e)o(xpressions)i(can)208 3526
y(be)23 b(used)g(to)h(distinguish)f(between)f(alternati)n(v)o(e)g
(productions.)37 b(W)-7 b(e)25 b(will)f(introduce)e(a)i(ne)n(w)f(type)g
(of)g(predicate)g(called)208 3625 y(a)31 b Fj(pr)m(ediction)e(pr)m
(edicate)g Fm(that)i(constitutes)f(the)h(entire)f(prediction)f(e)o
(xpression)g(for)h(a)g(particular)g(production;)j(i.e.,)208
3725 y(ANTLR)17 b(does)f(not)g(generate)g(code)g(to)h(test)g(lookahead)
e(for)h(the)g(associated)h(production.)25 b(W)-7 b(e)18
b(anticipate)e(the)h(notation:)208 3825 y(\252)p Fk(<<)p
Fj(this-is-the-entir)m(e-pr)m(ediction-e)n(xpr)m(ession)p
Fk(>>?!)p Fm(\272)o(.)125 3982 y Fe(\017)41 b Fm(A)30
b(graphical)e(user)h(interf)o(ace)g(is)i(planned)d(using)h(a)h
(multi-platform)e(windo)n(w)g(library)-5 b(.)56 b(This)30
b(\252GUI\272)g(will)g(display)208 4082 y(syntax)21 b(diagrams)h(on)g
(the)g(screen)g(and,)h(hence,)f(ambiguities)f(in)i(the)f(grammar)f(can)
h(be)h(highlighted.)33 b(The)23 b(output)e(of)208 4182
y(the)c(GUI)h(will)g(be)g(an)f(ANTLR)h(grammar)e(or)h(a)h(PostScript)g
(representation)d(of)j(the)f(syntax)g(diagram.)27 b(The)18
b(GUI)f(w)o(ould)208 4281 y(be)j(an)g(actual)g(product)e(sold)i(by)g(P)
o(arr)g(Research)g(Corporation,)e(b)n(ut)i(w)o(ould)f(be)i
(tremendously)c(cool.)125 4460 y([)p Fw(The)24 b(user)o(s)f(of)h(PCCTS)
i(should)c(be)j(for)l(e)o(warned)e(that)h(we)h(anticipate)d(a)i(br)l
(eak)h(with)f(total)f(bac)n(kwar)l(d)0 4576 y(compatibility)29
b(for)i(a)g(futur)l(e)g(r)l(elease)h(\(perhaps)f(PCCTS)h(2.00\).)55
b(This)31 b(r)l(elease)h(is)f(intended)g(to)g(\256x)g(the)0
4692 y(odious)23 b(C)h(output)f(g)o(ener)o(ated)g(by)h(the)g(curr)l
(ent)g(ver)o(sion)f(of)h(ANTLR/DLG)h(and)f(a)g(number)f(of)h(other)f
(little)0 4808 y(things.)125 4908 y(W)-9 b(e)33 b(anticipate)f(an)h
(intermediate)g(br)l(eak)g(that)g(will)g(c)o(hang)o(e)g(the)g(gr)o
(ammar)f(meta-langua)o(g)o(e)o(.)60 b(Any)0 5008 y(book)20
b(on)g(PCCTS)i(to)e(be)g(written)g(will)g(describe)g(this)g(ver)o(sion)
g(of)g(r)l(eality)-5 b(.)33 b(Also)20 b(r)l(emember)g(that)g(the)g(C++)
0 5107 y(output)k(is)g(going)g(to)g(c)o(hang)o(e)g(as)h(we)g(learn)g
(mor)l(e)g(about)e(it.)p Fm(])1839 5356 y(9)p eop
%%Page: 10 10
10 9 bop 0 -210 a Fl(8)116 b(Ackno)o(wledgements)0 -24
y Fm(As)29 b(usual,)g(there)e(are)h(a)g(lar)o(ge)f(number)f(of)h
(people)g(to)h(thank)f(for)g(their)h(help)f(with)h(PCCTS)h(\(more)e
(than)g(we)h(can)g(hope)e(to)0 75 y(ackno)n(wledge)18
b(here\).)125 175 y(Thanks)j(are)h(due)g(to)g(Sumana)g(Srini)n(v)n
(asan,)f(Mik)o(e)i(Mone)o(gan,)d(and)i(Ste)n(v)o(e)g(Narof)n(f)f(of)h
(NeXT)-6 b(,)22 b(Inc.)35 b(for)22 b(their)g(continuing)0
275 y(help)i(in)h(the)g(de\256nition)e(of)h(the)h(ANTLR)g(C++)g
(output.)41 b(Further)m(,)25 b(Sumana')-5 b(s)24 b(w)o(ork)g(on)g(the)g
(C++)i(grammar)d(\(no,)h(we)h(don')o(t)0 374 y(ha)n(v)o(e)20
b(a)g(release)g(date)h(set)g(yet\))e(is)i(f)o(ab)n(ulous.)125
474 y(W)-7 b(e)24 b(thank)e(Gary)h(Funck)g(at)g(Intrepid)f(T)-6
b(echnology)21 b(for)i(his)g(w)o(ork)g(on)g(SORCERER,)i(which)d(we)i
(hope)e(to)i(release)f(soon)0 574 y(with)d(PCCTS)i(as)f(standard)e
(baggage.)27 b(He)20 b(al)o(w)o(ays)h(has)f(good)f(suggestions)g(for)h
(ANTLR)g(as)h(well.)125 673 y(Ste)n(v)o(e)h(Robenalt)h(at)g(Rockwell)g
(single-handedly)d(pushed)i(the)h Fk(comp.compilers.tools.pccts)18
b Fm(ne)n(ws)23 b(group)0 773 y(through.)k(Further)m(,)19
b(he)h(continues)f(to)h(maintain)f(the)i(F)-6 b(A)h(Q.)125
872 y(W)e(e)21 b(thank)e(Scott)i(Hane)o(y)e(at)h(La)o(wrence)f(Li)n(v)o
(ermore)f(National)i(Labs)g(for)g(his)g(Macintosh)f(port)h(of)g(PCCTS.)
125 972 y(W)-7 b(e)16 b(thank)f(T)-7 b(om)15 b(Moog)f(\()p
Fk([email protected])p Fm(\))e(for)j(his)h(continued)d(ef)n(forts)i(on)g
(the)g Fk(NOTES.newbie)f Fm(information)0 1072 y(\256le.)125
1171 y(W)-7 b(e)33 b(w)o(ould)f(also)h(lik)o(e)g(to)g(thank)f(the)h
(multitude)e(of)i(other)f(users)h(of)f(PCCTS)i(for)e(their)h(e)o
(xcellent)e(suggestions)h(and)0 1271 y(beta-testing)19
b(of)h(the)g(C++)h(output.)125 1371 y(The)e(planning)g(group)f(for)i
(the)g(\256rst)h(annual)e(PCCTS)j(w)o(orkshop)c(included:)0
1553 y Fk(Gary)49 b(Funck)298 b(,)594
b(Intrepid)48 b(Technology,)g(Inc.)0 1653 y(Steve)h(Robenalt)98
b(,)44 b(Rockwell)k(International)0
1752 y(Ivan)h(Kissiov)198 b(,)644 b(Cadence)1818
5356 y Fm(10)p eop
%%Trailer
end
userdict /end-hook known{end-hook}if
%%EOF
25 4193 y Fe(\017)41 b Fk(ATokenStream.h)p Fm(:)27
b(De\256nition)19 b(of)h(class)i Fk(ANTLRTokenStream)p
Fm(.)125 4359 y Fe(\017)41 b Fk(ATokenBuffer.h)p Fm(:)27
b(De\256nition)19 b(of)h(class)i Fk(ANTLRTokenBuffer)p
Fm(.)125 4525 y Fe(\017)41 b Fk(ATokenBuffer.C)p Fm(:)18
b(Code)i(for)f(class)i Fk(ANTLRTopccts/UPDAT122.txt 644 1377 31 12776 5655551670 7165
PCCTS 1.22 Release Notes

Active Author for 1.22 Release:

Terence Parr
Parr Research Corporation
5517 Pleasant Ave
Minneapolis, MN 55419
[email protected]

Other authors:

Russell Quong, [email protected]
Will Cohen, [email protected]
Hank Dietz, [email protected]

August 24, 1994


This document describes the 1.22 release of the Purdue Compiler
Construction Tool Set (PCCTS). This file describes the changes
made to PCCTS 1.21 to arrive at PCCTS 1.22. A number of bug fixes
were made and the C++ output was cleaned up. The original 1.00
manual and all release notes are required for a complete
documentation set for PCCTS. A book is in the works and the
papers provided at the ftp site don't hurt.

PCCTS is in the public-domain and can be obtained at
everest.ee.umn.edu in pub/pccts/1.22. The newsgroup
comp.compilers.tools.pccts provides a discussion forum. To
receive future release broadcast messages, register yourself by
sending email to [email protected] with a ``Subject:'' line of
``register''.

The authors make no claims that this software will do what you
want, that this manual is any good, or that the software actually
works---use PCCTS at your own risk. Bug reports and/or cheery
reports of its usefulness are very welcome, however.

The maintenance and support of all PCCTS tools is primarily
provided by Parr Research Corporation, Minneapolis MN. Please see
file PCCTS.FUTURE for more information. All PCCTS tools currently
in the public domain will continue to be in the public domain.


I. NEW FEATURES

o In C++ mode, the normal parser initialization sequence is:

main()
{
DLGFileInput in(stdin);
DLGLexer scan(&in,2000);
ANTLRTokenBuffer pipe(&scan, k);
ANTLRToken aToken;
scan.setToken(&aToken);
Expr parser(&pipe);
parser.init();
parser.e();
}

As described below in ``C++ CLEANUP'', the new sequence can
be shortened somewhat to:

main()
{
DLGFileInput in(stdin);
DLGLexer scan(&in);
ANTLRTokenBuffer pipe(&scan);
ANTLRToken aToken;
scan.setToken(&aToken);
Expr parser(&pipe);
parser.init();
parser.e();
}

where the scanner text buffer size is now 2000 bytes by
default. The 'k' value of your parser (determined by the
ANTLR command line) is set automatically by the parser
constructor (it sends a message to the token buffer).

This code fragment is pretty common and we now provide
a template to allow the following:

... // other normal includes
#include "PBlackBox.h" // Standard Black Box for parsing.
main()
{
ParserBlackBox parser(stdin);
parser.parser()->prog();
}

where parser.parser() returns the instance of 'Expr' created
by the ParserBlackBox.

This is only experimental. Feel free to provide feedback or
suggest a better ``black box'' (e.g., can we do without
templates).


II. C++ CLEANUP

o You no longer have to specify the text buffer size for the lexer
constructor.

o You no longer have to specify the 'k' value for the ANTLRTokenBuffer.
This is set automatically by the parser to which the token buffer
is attached.

o Added an ``#ifndef DLGLEXER_H'' gate on the DLGLexer.h file output
from DLG. It is also sensitive to the file name; i.e., ``#ifndef
MYLEXER_H''.

o Function LT(i) now returns an ANTLRTokenBase not an ANTLRLightweightToken
because it is most token objects will be of a type derived from
ANTLRTokenBase. This allows LT(i)->getText() to be specified without
a type cast on the LTi).

o DLG defined a bunch of constants such as MAX_MODE and all the lexical
classes that you specified in your grammar. In 1.21, they were
#defines. Now they are const's in the lexer class definition. As a
result, multiple lexers with the identical lexical classes can be
linked together without collision. ZZSHIFT() became an inline function
from a macro as well. To access the constants from outside the
lexer member functions, you must use the class override; e.g.,
``scanner.mode(MyLexer::START)''.


III. THINGS TO REMEMBER

o Whenever you use k>1 or when you backtrack in C++ mode, you must
use ANTLRBacktrackingToken or something similar--that is, makeToken()
must return a stream of unique token objects. See the 1.21 release
notes.


IV. BUGS

o The syntactic predicates at k==1 where broken in 1.20 (I think) so
that they did not save the lexical text buffer. This has been
fixed.

o In testcpp/9/test.g, there should have been a 'public' on the
inheritance from ASTBase.

o zzline was updated incorrectly in C mode.

o A small bug was found in genmk that resulted in
outdir/outdir/err.o rather than outdir/err.o.

o zzreal_line was not defined in K&R C mode.

o The following grammar was not analyzed correctly (if you
can believe it ):

a : A a | ;

o The C++ AST code generation didn't generate the right code
for

a! : b <<#0=#1;>> ;

o The following didn't result in a correct parser:

a : (A B|B C) | b ;
b : <>? B B;

o When using #tokdefs, redefinition errors were reported in the
grammar file not the token definition file.


V. ACKNOWLEDGEMENTS

Kurt Fickie at the Army Research Lab suggested the ParserBlackBox class.

Thanks to all you folks to tested 1.22 before its release.

Thanks as always to the cool folks at NeXT, Inc.
\2pccts/UPDAT123.txt 644 1377 31 6454 5655551671 7143
PCCTS 1.23 Release Notes

Active Author for 1.23 Release:

Terence Parr
Parr Research Corporation
5517 Pleasant Ave
Minneapolis, MN 55419
[email protected]

Other authors:

Russell Quong, [email protected]
Will Cohen, [email protected]
Hank Dietz, [email protected]

September 13, 1994


This document describes the 1.23 release of the Purdue Compiler
Construction Tool Set (PCCTS). This file describes the changes
made to PCCTS 1.22 to arrive at PCCTS 1.23. A number of bug fixes
were made. The original 1.00 manual and all release notes are
required for a complete documentation set for PCCTS. A book is in
the works and the papers provided at the ftp site don't hurt.

PCCTS is in the public-domain and can be obtained at
everest.ee.umn.edu in pub/pccts/1.23. The newsgroup
comp.compilers.tools.pccts provides a discussion forum. To
receive future release broadcast messages, register yourself by
sending email to [email protected] with a ``Subject:'' line of
``register''.

The authors make no claims that this software will do what you
want, that this manual is any good, or that the software actually
works---use PCCTS at your own risk. Bug reports and/or cheery
reports of its usefulness are very welcome, however.

The maintenance and support of all PCCTS tools is primarily
provided by Parr Research Corporation, Minneapolis MN. Please see
file PCCTS.FUTURE for more information. All PCCTS tools currently
in the public domain will continue to be in the public domain.


I. NEW FEATURES

None.

II. CHANGES

o Made _right, _down proctected in ASTBase.

o The -ct (copy tokens) option for C++ is now gone. YOU MUST ALWAYS
HAVE ANTLRToken::makeToken() RETURN A NEW TOKEN OBJECT EVERY TIME!!
The ANTLRCommonToken has been changed to return a stream of distinct
token objects. The ANTLRCommonBacktrackingToken is now typedef'd to
be ANTLRCommonToken.

The C++ examples have been changed accordingly.

III. BUG FIXES

o Fixed bugs in HandleAmbig. It printed warnings when it shouldn't
have and also looked for predicates prematurely (before deciding if
really was an LL(k) ambig).

This may affect the analysis of your grammar. If so, let me know.

o The find_preds thing in pred.c had a minor bug where it referenced
a node without checking the type of node.

o The ParserBlackBox class derived from Object which doesn't exist
in ANTLR.

o set_sub() had an error.

o There was a bug when there are more than 255 #token statements.
Routine zzedecode in err.h near line 264 (AParser.C near line 319)
the variable "e" is used to iterate over the set of tokens. It was
declared as "SetWordType" which is "unsigned char". It should
be "int" or "unsigned".

o DLG define a static member dfa_base_no and didn't use it.

o Added zzreal_line to the list of things that are renamed for -gp.

IV. ACKNOWLEDGEMENTS

Thanks to all you folks to tested 1.23 before its release.

Thanks to Walter Smith at Apple who is putting this release onto the
Apple Developer's CD-ROM. Thanks again to Scott Haney at LLNL for
doing the MPW port of PCCTS.
all release notes are
required for a complete documentation set for PCCTS. A book is in
the works and the papers provided at the ftp site don't hurt.

PCCTS is in the public-domain and can be obtained at
evpccts/UPDAT130.txt 644 1377 31 53133 5655551671 7155
PCCTS 1.30 Release Notes

Active Authors for 1.30 Release:

Terence Parr
Parr Research Corporation
5517 Pleasant Ave
Minneapolis, MN 55419
[email protected]

Russell W. Quong
School of Electrical Engineering
Purdue University
W. Lafayette, IN 47907
[email protected]

Other authors:

Will Cohen, [email protected]
Hank Dietz, [email protected]

November 1, 1994


This document describes the 1.30 release of the Purdue Compiler
Construction Tool Set (PCCTS). This file describes the changes
made to PCCTS 1.23 to arrive at PCCTS 1.30. A number of major new
features were added and a few bug fixes were made. We imagine
that this will be the last major feature addition to the ANTLR
description language before a 2.00 version can be built. The
original 1.00 manual and all release notes are required for a
complete documentation set for PCCTS. A book is in the works and
the papers provided at the ftp site don't hurt.

PCCTS is in the public-domain and can be obtained at
everest.ee.umn.edu in pub/pccts/1.30. The newsgroup
comp.compilers.tools.pccts provides a discussion forum. To
receive future release broadcast messages, register yourself by
sending email to [email protected] with a ``Subject:'' line of
``register''.

The authors make no claims that this software will do what you
want, that this manual is any good, or that the software actually
works---use PCCTS at your own risk. Bug reports and/or cheery
reports of its usefulness are very welcome, however.

The maintenance and support of all PCCTS tools is primarily
provided by Parr Research Corporation, Minneapolis MN. Please see
file PCCTS.FUTURE for more information. All PCCTS tools currently
in the public domain will continue to be in the public domain.


I. NEW FEATURES

The only new features are element labels and parser exception
handling, but they significantly increase the capabilities of ANTLR.
The programmer now has complete control over how errors (semantic and
syntactic) are handled. Further, the element labels are generally
useful and should be considered the preferred method for accessing
lexical information about tokens. [Please note that parser exception
handling is to be considered in alpha-release state].

A. ELEMENT LABELING

Actions in an ANTLR grammar may access attributes via labels of the
form ``$label'' attached to token and rule references rather than the
conventional ``$i'' for some integer i. By using symbols instead of
integer identifiers, grammars are more readable and action parameters
are not sensitive to changes in rule element positions.

The form of a label is:

label:element

where element is either a token reference or a rule reference. To
refer to the attribute (C interface) or token pointer (C++ interface)
of that element in an action, use

$label

within an action or rule argument list. For example,

a : t:ID <getText());>>
;

[using the C++ interface]. To reference the tree variable associated
with element, use

#label

When using parser exception handling, simply reference ``label'' to
attach a handler to a particular rule reference. For example,

a : t:b
exception[t]
default : <>
;

Labels must be unique per rule as they have rule scope. Labels may be
accessed from parser exception handlers.

B. PARSER EXCEPTION HANDLING

***** CONSIDERED ALPHA QUALITY STUFF *****

ANTLR has two mechanisms for error reporting and recovery. In the
first mechanism, ANTLR automatically generates error messages using a
simple, effective heuristic that is sufficient for many applications.
However, when more sophisticated error handling is required, say for
commercial-quality software, ANTLR now supports a second mechanism
called ``parser exception handling'' that provides the flexibility of
hand-built reporting and recovery in a convenient framework. Parser
exception handling has much in common with C++ exception handling; we
do not actually use C++ exceptions in our implementation and, hence,
parser exception handling can be used with either the ANTLR C or C++
interface.

Parser exception handling provides a unified framework for reporting
and recovering from semantic and syntactic errors; note that automatic
mechanisms typically do not consider semantic errors. Parser
exception handling provides nearly the flexibility of a hand-built
parser [We have not played with the semantic recovery yet, but will
soon--you cannot define your own error signals at this point].

We illustrate the use of parser exception handlers by demonstrating
how they are used to generate a better error message than the
automatic mechanism, which simply reports where the error was detected
and what was expected. Consider matching the rule stat using the
following grammar fragment,

stat: "if" expr "then" stat { "else" stat }
| "while" expr "do" stat
| VAR ":=" expr ";"
| "begin" ( stat )+ "end"
;

expr: atom ( "\+" atom )*
;

atom: INT
| FLOAT
;

where INT, FLOAT, and VAR are defined as integer, float and identifier
tokens. Upon input

if 34+ then i:=1;

the automatic error mechanism would report

line 1: syntax error at "then" missing { INT FLOAT }.

However, because we know the context in which the expr production was
attempted, an improved error message could be generated; i.e., it
could indicate the expression was both in an if-statement and that it
was a conditional--as opposed to the right-hand-side of an assignment
statement, for example. A better message would be

line 1: if-statement: malformed conditional at "then"

One way to achieve this error message is to modify the original stat
grammar as follows

stat: "if" e:expr "then" stat { "else" stat }
exception[e]
catch MismatchedToken :
catch NoViableAlt :
<<
fprintf(stderr,
"line %d: if-statement: malformed conditional at \"%s\"\n",
zzline, LATEXT(1));
zzconsumeUntilToken(THEN);
>>
| "while" expr "do" stat
...
;
}

where THEN is the token type associated with "then"; MismatchedToken
and NoViableAlt are predefined error signals. The notation ``e:expr''
attaches the label e to the expr rule reference. Labels allow the
exception handler to catch errors encountered specifically for input
matched during that reference.

Good error handling requires programmer intervention. Automatic
mechanisms typically do not perform well, because they cannot easily
analyze the state of the parser (e.g., the symbol stack of a
table-driven parser or the program counter of a recursive-descent
parser). Knowing where to report errors and how to recover from them
must be done with a programmer's experience. While more programming
effort is required than for automatic mechanisms, ANTLR's parser
exception handling provides a convenient, sophisticated mechanism that
rivals the flexibility of hand-coded schemes.

ANTLR defaults to using the old, automatic mechanism. Any use of the
keyword "exception" triggers the new mechanism.

We now provide specific ANTLR programming details for parser exception
handling.

Syntax

A group of exception handlers may be specified after any alternative,
after the ";" of a rule definition, and default/global exceptions may
be specified before the list of rules. The syntax for an exception
group is as follows:

exception_group
: "exception" { Label_in_brackets }
( exception_handler )*
{ "default" ":" Action }
;

exception_handler
: "catch" SIGNAL ":" { Action }
;

where SIGNAL is one of:

NoViableAlt -- None of the alternatives were predicted
NoSemViableAlt -- See below
MismatchedToken -- Didn't find the token we were looking for

You can also use a "default :" clause, which matches any signal, in
your exception group.

Currently, you cannot define your own signals.

You can define multiple signals for a single action. E.g.,

exception
catch MismatchedToken :
catch NoViableAlt :
catch NoSemViableAlt :
<<
printf("stat:caught predefined signal\n");
consumeUntil(DIE_set);
>>

If a label (attached to a rule reference) is specified for an
exception group, that group may be specified after the end of the ";"
rule terminator. ANTLR can still uniquely identify which rule
reference to associate the group with; it often makes a rule cleaner
to have most of the exception handlers at the end of the rule. For
example,

a : A t:expr B
| ...
;
exception[t]
catch ...
catch ...

The NoViableAlt signal only makes sense for exception groups with
labels and for rule exception groups.


Exception Handler Order of Execution

Given a signal, S, the handler that is invoked is determined by
looking through the list of enabled handlers in a specific order.

Loosely speaking, we say that a handler is "enabled" (becomes active)
and pushed on an exception stack when it has been seen by the parser
on its way down the parse tree. A handler is "disabled" and taken off
the exception stack when the associated grammar fragment is
successfully parsed. The formal rules for enabling are:

o All global/default handlers are enabled upon parser entry.

o Exception handlers specified after an alternative become enabled
when that alternative is predicted.

o Exception handlers specified for a rule become enabled when the
rule is invoked.

o Exception handlers tied to a particular rule reference within
an alternative are enabled just before the invocation of that
rule reference.

Disabling rules are:

o All global/default handlers are disabled upon parser exit.

o Exception handlers specified after an alternative are disabled
when that alternative has been parsed completely (successfully).

o Exception handlers specified for a rule become disabled just
before the rule returns.

o Exception handlers tied to a particular rule reference within
an alternative are disabled just after the return from that
rule reference.

Upon an error condition, the parser with throw an exception signal, S;
[in the future, the user will be able to throw user-defined
exceptions]. Starting at the top of the stack, each exception group
is examined looking for a handler for S. The first S handler found on
the stack is executed. In practice, the run time stack and hardware
program counter are used to search for the appropriated handler. This
amounts to the following:

o If there is an exception specified for the enclosing alternative,
then look for S in that group first.

o If there is no exception for that alternative or that group did not
specify an S handler, then look for S in the enclosing rule's
exception group.

o Global/default handlers are like macros that are inserted into
the rule exception group for each rule.

o If there is no rule exception or that group did not specify
an S handler, then return from the enclosing rule with the current
error signal still set to S.

o If there is an exception group attached (via label) to the rule
that just returned, check that exception group for S.

o If an exception group attached to a rule reference does not have
an S handler, then look for S in the enclosing rule's exception
group.

This process continues until an S handler is found or a return
instruction is executed in starting rule.

These guidelines are best described with an example:

a : A c B
exception /* 1 */
catch MismatchedToken : <>
| C t:d D
exception /* 2 */
catch MismatchedToken : <>
catch NoViableAlt : <>
;
exception[t] /* 3 */
catch NoViableAlt : <>
exception /* 4 */
catch NoViableAlt : <>

c : E
;

d : e
;

e : F
| G
;
exception /* 5 */
catch MismatchedToken : <>

The following table summarizes the sequence in which the exception
groups are tested:

INPUT EXCEPTION GROUP TESTING SEQUENCE ACTION EXECUTED
D E B 4 ACTION5
A E D 1 ACTION1
A F B 1 ACTION6
A F B 1 ACTION6
C F B 2 ACTION2
C E D 5,2 ACTION3

The global/default handlers are like macro insertions. For example:

exception
catch NoViableAlt : <>

a : A
;
exception
catch MismatchedToken : <>

b : B
;

This is functionally equivalent to:

a : A
;
exception
catch MismatchedToken : <>
catch NoViableAlt : <>

b : B
;
exception
catch NoViableAlt : <>

[You will soon be able to throw the same or a different signal from an
exception handler. This makes sense when you want a "panic" signal to
propagate back up the parse tree so that all rules can clean up.]


Modifications to Code Generation

The following generic changes were made to facilitate exception
handling:

o Each rule reference now has a signal parameter which returns 0 if no
error occurred during that reference or it returns a nonzero signal S.

o The MATCH() macro has been modified to signal Mismatched token
rather than calling zzsyn().

o When no viable alternative is found, NoViableAlt is signaled
rather than calling the zzsyn() routine.

o The parser no longer resynchronizes automatically. See below.


Semantic Predicates and NoSemViableAlt

When the input stream does not predict any of the alternatives in the
current list of possible alternatives, NoViableAlt is signaled.
However, what happens when semantic predicates are specified in that
alternative list? It turns out that the following simple strategy
handles this case:

``If NoViableAlt is signaled and at least one semantic predicate (for
a syntactically viable alternative) failed, signal NoSemViableAlt
instead of NoViableAlt.''

It would be very misleading to just throw NoViableAlt when in fact one
or more alternatives were syntactically viable; i.e., the reason that
no alternative was predicted was due to a semantic invalidity--a
different signal must be thrown. For example,

expr : <>? ID ... /* function call */
| <>? ID ... /* array reference */
| INT
;
exception
catch NoViableAlt : <>
catch NoSemViableAlt : <>

Typically, the programmer would want to give very different error
messages for the two different situations. Specifically, giving a
message such as "syntax error at ID missing { ID INT }" would be very
misleading (i.e., wrong).

In future versions, we may enhance this to throw a different signal
depending on which predicate failed.

Semantic predicates that are not used to predict alternatives do not
yet throw signals. You must continue to use the fail-action for that
predicate.


Resynchronizing the Parser

When an error occurs while parsing rule R, the parser will generally
not be able to continue parsing anywhere within that rule--it will
return immediately after executing any exception code. The one
exception is for exceptions with labels. In this case, the parser
knows exactly where in the alternative you would like to continue
parsing from.

To allow manual resynchronization of the parser, you may use two new
functions:

zzconsumeUntil(X_set)
Consume tokens until you see a token in the token class X. ANTLR
now generates a packed bitset called X_set for each token class X.

zzconsumeUntilToken(T)
Consume tokens until you see token T.

For example,

#tokclass RESYNCH { A C }

a : b A
| b C
;

b : B
exception
catch MismatchedToken : // consume until FOLLOW(b)
<>
;

Soon, you will be able to reference the FOLLOW(R) and FIRST(R) for a
rule R to make resynchronization set construction easier.

You may also use zzset_el() to test for membership in a token class.

int zzset_el(unsigned b, SetWordType *p)

For example,

<>

In C++ mode, simply remove the "zz" prefix from the function names.


Example

The following grammar demonstrates the use of parser exception
handling using the C interface (testcpp/13/test.g provides a C++
example). Given input:

if a+ then a=b+b;

the output should be:

invalid conditional in 'if' statement
found assignment to a

----------------------------------------------------------------
#header <<#include "charbuf.h">>

<<
main()
{
ANTLR(rule(), stdin);
}
>>

#token "[\ \t]+" <>
#token "\n" <>
#token THEN "then"
#tokclass DIE { "@" "if" ID "else" }

rule: ( stat )+
;

stat: "if" t:expr "then" stat { "else" stat }
| u:ID "=" expr ";"
<>
;
exception[t]
default :
<<
printf("invalid conditional in 'if' statement\n");
zzconsumeUntilToken(THEN);
>>
exception
catch MismatchedToken :
catch NoViableAlt :
catch NoSemViableAlt :
<<
printf("stat:caught predefined signal\n");
zzconsumeUntil(DIE_set);
>>

expr: expr1 ("\+" expr1)*
;

expr1
: expr2 ("\*" expr2)*
;

expr2: ID
;

#token ID "[a-z]+"
----------------------------------------------------------------

C. LEXCLASS SAVE/RESTORE

[In the words of Ken Weinert:]

This section describes the addition of the mode stack operations
defined in Tom Moog's NOTES.newbie document. By defining a variable
USER_ZZMODE_STACK at compile time, you can include these functions for
use in your grammars.

By default, the #define ZZSTACK_MAX_MODE is set to 32 which gives a
mode stack of depth 64. If this is too shallow, defining
ZZSTACK_MAX_MODE to a different value in the makefile will override
the default.

Four functions are defined with this modification: zzmpush(),
zzmpop(), zzsave_mode_stack(), and zzrestore_mode_stack().

zzmpush(int newMode)
push the current mode on the stack and make newMode the current mode.

zzmpop()
make current the previous mode

zzsave_mode_stack(int modeStack[], int *modeLevel)
save the current mode stack and depth into indicated variables.
Analogous to zzsave_[antlr|dlg]_state().

zzrestore_mode_stack(int modeStack[], int *modeLevel)
restore the mode stack and depth from indicated variables.
Analogous to zzrestore_[antlr|dlg]_state().

II. CHANGES AND BUG FIXES

o Tokens may now be labeled rather than using the $i interface. The
two are mutually exclusive in the sense that using $i prevents usage
of $label.

o Added parser exception handling.

o Added #ifdef gate to tokens.h and class definition file for C/C++
mode.

o Made the #tokdefs file reader ignore gates on the head of files.

o You can no longer pass init-actions to blocks like this (A|B)[action].

o There was a bug in the code generation for (...)* loops for k>1.
It used a linear approximate lookahead decision instead of full LL(k).
It also used the wrong prediction expression for exiting the loop.

o Token class X now results in C/C++ bitset X_set rather than zzerr%d.

o ANTLR now allows "@" in a token class.

o Added consumeUntil and consumeUntilToken functions for resynching
parser in exception handlers.

o Added testcpp/13 to test exception handling.

o A warning is now generated if you reference a non-token element
with $i for some integer i in C++ mode.

o There was a bug in the code generation for (...)+ loops. It
did not put predicates into "do while"--just at front if-gate.
E.g.,

a : ( b )+ ;
b : <>? A;

did not work.

o For 16 bit machines, the ANTLRTokenBuffer file was using some
implementation-dependent pointer manipulation. This has been
changed.

o Semantic predicates and -gl option did not work because ANTLR
tried to insert line information at the end of a line rather
that at the beginning where the C/C++ compiler wants it.

o Added "const" to the arguments of the zzerr pointer and zzerrstd().
If you have defined a dlg error routine, you must change the definition
accordingly.


III. A FEW KNOWN BUGS

o I would like to make an auto test script for the C++ samples to
check their input/output.

o I haven't figured out how to handle deallocation of token objects
created. Sometimes the programmer has allocated them in a totally
different application and doesn't want ANTLR to track and delete
them.

o FOLLOW(rule) and FIRST(rule) capabilities need to be added to the
tokclass declaration.

o No warning is given for nonstandard signals used in parser exception
handling.

o No warning is given if $label is not defined.

o Nothing has been done about the failure of semantic predicates
with regards to exception handling.

o The demand lookahead in C++ mode is still wacked.

o Can't do multiple return values in C++ still.

o No warning is given if all alts of a block are guesses: (...)?.


IV. ACKNOWLEDGEMENTS

Thanks to all you folks who tested 1.30 before its release. Thanks to
the folks at the First Annual PCCTS workshop (held at NeXT July 1994)
who helped refine the syntax for the parser exception handling.

Thanks goes to the folks at NeXT for prodding us about good error
recovery.
which returns 0 if no
error occurred during that reference or it returns a nonzero signal S.

o The MATCH() macro has been modified to signal Mismatched token
rather than calling zzsyn().

o When no viable alternative is found, NoViableAlt is signaled
rather than calling the zzsyn() routine.

o The parser no longer resynchronizes automatically. See below.


Semantic Predicates and NoSemViableAlt

Whenpccts/antlr/ 755 1377 31 0 5655551740 6316 pccts/antlr/antlr.g 644 1377 31 127402 5655551676 7751 /*
* antlr.g -- PCCTS Version 1.xx ANTLR
*
* $Id: antlr.g,v 1.12 1994/09/20 20:00:57 parrt Exp parrt $
* $Revision: 1.12 $
*
* Parse an antlr input grammar and build a syntax-diagram.
*
* Written in itself (needs at least 1.06 to work)
*
* SOFTWARE RIGHTS
*
* We reserve no LEGAL rights to the Purdue Compiler Construction Tool
* Set (PCCTS) -- PCCTS is in the public domain. An individual or
* company may do whatever they wish with source code distributed with
* PCCTS or the code generated by PCCTS, including the incorporation of
* PCCTS, or its output, into commerical software.
*
* We encourage users to develop software with PCCTS. However, we do ask
* that credit is given to us for developing PCCTS. By "credit",
* we mean that if you incorporate our source code into one of your
* programs (commercial product, research project, or otherwise) that you
* acknowledge this fact somewhere in the documentation, research report,
* etc... If you like PCCTS and have developed a nice tool with the
* output, please mention that you developed it using PCCTS. In
* addition, we ask that this header remain intact in our source code.
* As long as these guidelines are kept, we expect to continue enhancing
* this system and expect to make other tools available as they are
* completed.
*
* ANTLR 1.30
* Terence Parr
* Parr Research Corporation
* with Purdue University and AHPCRC, University of Minnesota
* 1989-1994
*/
#header <<
#ifdef __cplusplus
#ifndef __STDC__
#define __STDC__
#endif
#endif
#include "set.h"
#include
#include "syn.h"
#include "hash.h"
#include "generic.h"
#define zzcr_attr(attr,tok,t)
>>

<<
#ifdef __STDC__
static void chkToken(char *, char *, char *, int);
#else
static void chkToken();
#endif

static int class_nest_level = 0;
extern int inAlt;
extern set attribsRefdFromAction;
extern int UsedOldStyleAttrib;
extern int UsedNewStyleLabel;
>>

#lexaction <<
/* maintained, but not used for now */
set AST_nodes_refd_in_actions = set_init;
int inAlt = 0;
set attribsRefdFromAction;
int UsedOldStyleAttrib = 0;
int UsedNewStyleLabel = 0;
>>

#lexclass STRINGS
#token QuotedTerm "\"" << zzmode(START); >>
#token "\n" <<
zzline++;
warn("eoln found in string");
zzskip();
>>
#token "\\\n" << zzline++; zzmore(); >>
#token "\\~[]" << zzmore(); >>
#token "~[\n\"\\]+" << zzmore(); >>

#lexclass ACTION_STRINGS
#token "\"" << zzmode(ACTIONS); zzmore(); >>
#token "\n" <<
zzline++;
warn("eoln found in string (in user action)");
zzskip();
>>
#token "\\\n" << zzline++; zzmore(); >>
#token "\\~[]" << zzmore(); >>
#token "~[\n\"\\]+" << zzmore(); >>

#lexclass ACTION_CHARS
#token "'" << zzmode(ACTIONS); zzmore(); >>
#token "\n" <<
zzline++;
warn("eoln found in char literal (in user action)");
zzskip();
>>
#token "\\~[]" << zzmore(); >>
#token "~[\n'\\]+" << zzmore(); >>

#lexclass ACTION_COMMENTS
#token "\*/" << zzmode(ACTIONS); zzmore(); >>
#token "\*" << zzmore(); >>
#token "\n" << zzline++; zzmore(); DAWDLE; >>
#token "~[\n\*]+" << zzmore(); >>

#lexclass TOK_DEF_COMMENTS
#token "\*/" << zzmode(PARSE_ENUM_FILE); zzmore(); >>
#token "\*" << zzmore(); >>
#token "\n" << zzline++; zzmore(); DAWDLE; >>
#token "~[\n\*]+" << zzmore(); >>

#lexclass TOK_DEF_CPP_COMMENTS
#token "\n" << zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE; >>
#token "~[\n]+" << zzskip(); >>

#lexclass ACTION_CPP_COMMENTS
#token "\n" << zzline++; zzmode(ACTIONS); zzmore(); DAWDLE; >>
#token "~[\n]+" << zzmore(); >>

#lexclass CPP_COMMENTS
#token "\n" << zzline++; zzmode(START); zzskip(); DAWDLE; >>
#token "~[\n]+" << zzskip(); >>

#lexclass COMMENTS
#token "\*/" << zzmode(START); zzskip(); >>
#token "\*" << zzskip(); >>
#token "\n" << zzline++; zzskip(); DAWDLE; >>
#token "~[\n\*]+" << zzskip(); >>

/*
* This lexical class accepts actions of type [..] and <<..>>
*
* It translates the following special items for C:
*
* $j --> "zzaArg(current zztasp, j)"
* $i.j --> "zzaArg(zztaspi, j)"
* $i.nondigit> "zzaArg(current zztasp, i).nondigit"
* $$ --> "zzaRet"
* $alnum --> "alnum" (used to ref parameters)
* $rule --> "zzaRet"
* $retval --> "_retv.retval" if > 1 return values else "_retv"
* $[token, text] --> "zzconstr_attr(token, text)"
* $[] --> "zzempty_attr()"
*
* It translates the following special items for C++:
* (attributes are now stored with 'Token' and $i's are only
* pointers to the Tokens. Rules don't have attributes now.)
*
* $j --> "_tbj" where b is the block level
* $i.j --> "_tij"
* $j->nondigit> "_tbj->nondigit"
* $$ --> "$$"
* $alnum --> "alnum" (used to ref parameters)
* $rule --> "$rule"
* $retval --> "_retv.retval" if > 1 return values else "_retv"
* $[token, text] --> invalid
* $[] --> invalid
*
* And, for trees:
*
* #0 --> "(*_root)"
* #i --> "zzastArg(i)"
* #[args] --> "zzmk_ast(zzastnew(), args)"
* #[] --> "zzastnew()"
* #( root, child1, ..., childn )
* --> "zztmake(root, child1, ...., childn, NULL)"
* #() --> "NULL"
*
* For C++, ...
*
* #0 --> "(*_root)"
* #i --> "_astbi" where b is the block level
* #alnum --> "alnum_ast" (used to ref #label)
* #[args] --> "new AST(args)"
* #[] --> "new AST"
* #( root, child1, ..., childn )
* --> "AST::tmake(root, child1, ...., childn, NULL)"
* #() --> "NULL"
*
* To escape,
*
* \] --> ]
* \) --> )
* \$ --> $
* \# --> #
*
* A stack is used to nest action terminators because they can be nested
* like crazy: << #[$[..],..] >>
*/
#lexclass ACTIONS
#token Action "\>\>" << /* these do not nest */
zzmode(START);
NLATEXT[0] = ' ';
NLATEXT[1] = ' ';
zzbegexpr[0] = ' ';
zzbegexpr[1] = ' ';
if ( zzbufovf ) {
err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));
}
>>
#token Pred "\>\>?" << /* these do not nest */
zzmode(START);
NLATEXT[0] = ' ';
NLATEXT[1] = ' ';
zzbegexpr[0] = '\0';
if ( zzbufovf ) {
err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));
}
>>
#token PassAction "\]" << if ( topint() == ']' ) {
popint();
if ( istackempty() ) /* terminate action */
{
zzmode(START);
NLATEXT[0] = ' ';
zzbegexpr[0] = ' ';
if ( zzbufovf ) {
err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));
}
}
else {
/* terminate $[..] and #[..] */
if ( GenCC ) zzreplstr("))");
else zzreplstr(")");
zzmore();
}
}
else if ( topint() == '|' ) { /* end of simple [...] */
popint();
zzmore();
}
else zzmore();
>>
#token "\n" << zzline++; zzmore(); DAWDLE; >>
#token "\>" << zzmore(); >>
#token "$" << zzmore(); >>
#token "$$" << if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}
else err("$$ use invalid in C++ mode"); >>

#token "$\[\]" << if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}
else err("$[] use invalid in C++ mode"); >>
#token "$\[" <<
pushint(']');
if ( !GenCC ) zzreplstr("zzconstr_attr(");
else err("$[..] use invalid in C++ mode");
zzmore();
>>
#token "$[0-9]+" <<{
static char buf[100];
if ( strlen(zzbegexpr)>85 )
fatal("$i attrib ref too big");
set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",
BlkLevel-1,zzbegexpr+1);
else sprintf(buf,"_t%d%s",
BlkLevel-1,zzbegexpr+1);
zzreplstr(buf);
zzmore();
UsedOldStyleAttrib = 1;
if ( UsedNewStyleLabel )
err("cannot mix old-style $i with new-style labels");
}
>>
#token "$[0-9]+." <<{
static char buf[100];
if ( strlen(zzbegexpr)>85 )
fatal("$i.field attrib ref too big");
zzbegexpr[strlen(zzbegexpr)-1] = ' ';
set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",
BlkLevel-1,zzbegexpr+1);
else sprintf(buf,"_t%d%s.",
BlkLevel-1,zzbegexpr+1);
zzreplstr(buf);
zzmore();
UsedOldStyleAttrib = 1;
if ( UsedNewStyleLabel )
err("cannot mix old-style $i with new-style labels");
}
>>
#token "$[0-9]+.[0-9]+" <<{
static char buf[100];
static char i[20], j[20];
char *p,*q;
if (strlen(zzbegexpr)>85) fatal("$i.j attrib ref too big");
for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {
if ( q == &i[20] ) fatalFL("i of $i.j attrib ref too big", FileStr[CurFile], zzline );
*q++ = *p;
}
*q = '\0';
for (p++, q= &j[0]; *p!='\0'; p++) {
if ( q == &j[20] ) fatalFL("j of $i.j attrib ref too big", FileStr[CurFile], zzline );
*q++ = *p;
}
*q = '\0';
if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);
else sprintf(buf,"_t%s%s",i,j);
zzreplstr(buf);
zzmore();
UsedOldStyleAttrib = 1;
if ( UsedNewStyleLabel )
err("cannot mix old-style $i with new-style labels");
}
>>
#token "$[_a-zA-Z][_a-zA-Z0-9]*"
<<{ static char buf[300];
zzbegexpr[0] = ' ';
if ( CurRule != NULL &&
strcmp(CurRule, &zzbegexpr[1])==0 ) {
if ( !GenCC ) zzreplstr("zzaRet");
}
else if ( CurRetDef != NULL ) {
if ( strmember(CurRetDef, &zzbegexpr[1]) ) {
if ( HasComma( CurRetDef ) ) {
require (strlen(zzbegexpr)<=285,
"$retval attrib ref too big");
sprintf(buf,"_retv.%s",&zzbegexpr[1]);
zzreplstr(buf);
}
else zzreplstr("_retv");
}
else if ( CurParmDef != NULL ) {
if ( !strmember(CurParmDef, &zzbegexpr[1]) )
warn(eMsg1("$%s not parameter or return value",&zzbegexpr[1]));
}
else warn(eMsg1("$%s not parameter or return value",&zzbegexpr[1]));
}
}
zzmore();
>>
#token "#0" << zzreplstr("(*_root)"); zzmore(); >>
#token "#\[\]" << if ( GenCC ) zzreplstr("(new AST)");
zzreplstr("zzastnew()"); zzmore();>>
#token "#\(\)" << zzreplstr("NULL"); zzmore(); >>
#token "#[0-9]+" <<{
static char buf[100];
if ( strlen(zzbegexpr)>85 )
fatal("#i AST ref too big");
if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);
else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);
zzreplstr(buf);
zzmore();
set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);
}
>>
#token "#[_a-zA-Z][_a-zA-Z0-9]*"
<<
if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||
strcmp(zzbegexpr, "#else")==0 ||
strcmp(zzbegexpr, "#endif")==0 ||
strcmp(zzbegexpr, "#ifndef")==0 ||
strcmp(zzbegexpr, "#define")==0 ||
strcmp(zzbegexpr, "#pragma")==0 ||
strcmp(zzbegexpr, "#undef")==0 ||
strcmp(zzbegexpr, "#line")==0 ||
strcmp(zzbegexpr, "#include")==0 ||
strcmp(zzbegexpr, "#error")==0) )
{
static char buf[100];
sprintf(buf, "%s_ast", zzbegexpr+1);
zzreplstr(buf);
}
zzmore();
>>
#token "#\[" <<
pushint(']');
if ( GenCC ) zzreplstr("(new AST(");
else zzreplstr("zzmk_ast(zzastnew(),");
zzmore();
>>
#token "#\(" <<
pushint('}');
if ( GenCC ) zzreplstr("ASTBase::tmake(");
else zzreplstr("zztmake(");
zzmore();
>>
#token "#" << zzmore(); >>
#token "\)" <<
if ( istackempty() )
zzmore();
else if ( topint()==')' ) {
popint();
}
else if ( topint()=='}' ) {
popint();
/* terminate #(..) */
zzreplstr(", NULL)");
}
zzmore();
>>
#token "\[" <<
pushint('|'); /* look for '|' to terminate simple [...] */
zzmore();
>>
#token "\(" <<
pushint(')');
zzmore();
>>

#token "\\\]" << zzreplstr("]"); zzmore(); >>
#token "\\\)" << zzreplstr(")"); zzmore(); >>
#token "\\>" << zzreplstr(">"); zzmore(); >>


#token "'" << zzmode(ACTION_CHARS); zzmore();>>
#token "\"" << zzmode(ACTION_STRINGS); zzmore();>>
#token "\\$" << zzreplstr("$"); zzmore(); >>
#token "\\#" << zzreplstr("#"); zzmore(); >>
#token "\\\n" << zzline++; zzmore(); >>
#token "\\~[\]\)>$#]" << zzmore(); >> /* escaped char, always ignore */
#token "/" << zzmore(); >>
#token "/\*" << zzmode(ACTION_COMMENTS); zzmore(); >>
#token "\*/" << warn("Missing /*; found dangling */ in action"); zzmore(); >>
#token "//" << zzmode(ACTION_CPP_COMMENTS); zzmore(); >>
#token "~[\n\)\(\\$#\>\]\[\"'/]+" << zzmore(); >>

#lexclass START
#token "[\t\ ]+" << zzskip(); >> /* Ignore White */
#token "[\n\r]" << zzline++; zzskip(); >> /* Track Line # */
#token "\[" << zzmode(ACTIONS); zzmore();
istackreset();
pushint(']'); >>
#token "\<\<" << action_file=CurFile; action_line=zzline;
zzmode(ACTIONS); zzmore();
istackreset();
pushint('>'); >>
#token "\"" << zzmode(STRINGS); zzmore(); >>
#token "/\*" << zzmode(COMMENTS); zzskip(); >>
#token "\*/" << warn("Missing /*; found dangling */"); zzskip(); >>
#token "//" << zzmode(CPP_COMMENTS); zzskip(); >>
#token "\>\>" << warn("Missing <<; found dangling \\>\\>"); zzskip(); >>
#token WildCard "."
#token Eof "@"
<< /* L o o k F o r A n o t h e r F i l e */
{
FILE *new_input;
new_input = NextFile();
if ( new_input == NULL ) { NLA=Eof; return; }
fclose( input );
input = new_input;
zzrdstream( input );
zzskip(); /* Skip the Eof (@) char i.e continue */
}
>>

#token LABEL

#errclass "grammar-element" { element }
#errclass "meta-symbol" { "\}" "!" ";" "\|" "\~" "^" "\)" }

/*
* Get a grammar -- Build a list of rules like:
*
* o-->Rule1--o
* |
* o-->Rule2--o
* |
* ...
* |
* o-->RuleN--o
*/
grammar : <>
( "#header" Action
<<
if ( HdrAction==NULL ) {
HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(HdrAction!=NULL, "rule grammar: cannot allocate header action");
strcpy(HdrAction, LATEXT(1));
}
else warn("additional #header statement ignored");
>>
| "#parser" QuotedTerm
<<
if ( GenCC ) {
warn("#parser meta-op incompatible with -CC; ignored");
}
else {
if ( strcmp(ParserName,"zzparser")==0 ) {
ParserName=StripQuotes(mystrdup(LATEXT(1)));
if ( RulePrefix[0]!='\0' )
{
warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored");
RulePrefix[0]='\0';
}
}
else warn("additional #parser statement ignored");
}
>>
| "#tokdefs" QuotedTerm
<<{
char *fname;
zzantlr_state st; FILE *f; struct zzdlg_state dst;
UserTokenDefsFile = mystrdup(LATEXT(1));
zzsave_antlr_state(&st);
zzsave_dlg_state(&dst);
fname = mystrdup(LATEXT(1));
f = fopen(StripQuotes(fname), "r");
if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));}
else {
ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE);
UserDefdTokens = 1;
}
zzrestore_antlr_state(&st);
zzrestore_dlg_state(&dst);
}>>
)*
( Action
<<{
UserAction *ua = newUserAction(LATEXT(1));
ua->file = action_file; ua->line = action_line;
if ( class_nest_level>0 ) list_add(&class_actions, ua);
else list_add(&BeforeActions, ua);
}>>
| laction
| aLexclass
| token
| error
| tclass
| default_exception_handler
| class_def
| "\}"
<<
if ( class_nest_level==0 )
warn("missing class definition for trailing '}'");
class_nest_level--;
>>
)*
rule <>
( rule <>
| aLexclass
| token
| error
| tclass
| class_def
| "\}"
<<
if ( class_nest_level==0 )
warn("missing class definition for trailing '}'");
class_nest_level--;
>>
)*
( Action
<<{
UserAction *ua = newUserAction(LATEXT(1));
ua->file = action_file; ua->line = action_line;
if ( class_nest_level>0 ) list_add(&class_actions, ua);
else list_add(&AfterActions, ua);
}>>
| laction
| error
| tclass
| class_def
| "\}"
<<
if ( class_nest_level==0 )
warn("missing class definition for trailing '}'");
class_nest_level--;
>>
)*
Eof
;
<>

class_def
: <>
"class"
( NonTerminal <>
| TokenTerm <>
)
<<
if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0
&& GenCC ) {
err("only one grammar class allowed in this release");
go = 0;
}
else strcpy(CurrentClassName, name);
>>
<>
"\{"
<<
no_classes_found = 0;
if ( class_nest_level>=1 ) {warn("cannot have nested classes");}
else class_nest_level++;
>>
;
<>

/*
* Build -o-->o-R-o-->o- where -o-R-o- is the block from rule 'block'.
* Construct the RuleBlk front and EndRule node on the end of the
* block. This is used to add FOLLOW pointers to the rule end. Add the
* new rule name to the Rname hash table and sets its rulenum.
* Store the parameter definitions if any are found.
*
* Note that locks are required on the RuleBlk and EndRule nodes to thwart
* infinite recursion.
*
* Return the left graph pointer == NULL to indicate error/dupl rule def.
*/
rule : <<
ListNode *ex_groups = NULL;
ExceptionGroup *eg;
RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e;
set toksrefd, rulesrefd;
char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL;
CurExGroups = NULL;
CurElementLabels = NULL;
/* We want a new element label hash table for each rule */
if ( Elabel!=NULL ) killHashTable(Elabel);
Elabel = newHashTable();
attribsRefdFromAction = empty;
>>
NonTerminal
< if ( hash_get(Rname, LATEXT(1))!=NULL ) {
err(eMsg1("duplicate rule definition: '%s'",LATEXT(1)));
CannotContinue=TRUE;
}
else
{
q = (RuleEntry *)hash_add(Rname,
LATEXT(1),
(Entry *)newRuleEntry(LATEXT(1)));
CurRule = q->str;
}
CurRuleNode = q;
f = CurFile; l = zzline;
NumRules++;
>>
{ "!" <noAST = TRUE;>> }
{ <<;>>
{"\<"}
PassAction
<< pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(pdecl!=NULL, "rule rule: cannot allocate param decl");
strcpy(pdecl, LATEXT(1));
CurParmDef = pdecl;
>>
}
{ "\>"
PassAction
<< ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(ret!=NULL, "rule rule: cannot allocate ret type");
strcpy(ret, LATEXT(1));
CurRetDef = ret;
>>
}
{ QuotedTerm <egroup=mystrdup(LATEXT(1));>> }
<<
if ( GenEClasseForRules && q!=NULL ) {
e = newECnode;
require(e!=NULL, "cannot allocate error class node");
if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);}
else a = q->egroup;
if ( Tnum( a ) == 0 )
{
e->tok = addTname( a );
list_add(&eclasses, (char *)e);
if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
/* refers to itself */
list_add(&(e->elist), mystrdup(q->str));
}
else {
warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a));
if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
free((char *)e);
}
}
>>
<>
":" <>
block[&toksrefd, &rulesrefd]
< CurRuleBlk = (Junction *)r.left;
CurRuleBlk->blockid = CurBlockID;
CurRuleBlk->jtype = RuleBlk;
if ( q!=NULL ) CurRuleBlk->rname = q->str;
CurRuleBlk->file = f;
CurRuleBlk->line = l;
CurRuleBlk->pdecl = pdecl;
CurRuleBlk->ret = ret;
CurRuleBlk->lock = makelocks();
CurRuleBlk->pred_lock = makelocks();
CurRuleBlk->tokrefs = toksrefd;
CurRuleBlk->rulerefs = rulesrefd;
p = newJunction(); /* add EndRule Node */
((Junction *)r.right)->p1 = (Node *)p;
r.right = (Node *) p;
p->jtype = EndRule;
p->lock = makelocks();
p->pred_lock = makelocks();
CurRuleBlk->end = p;
if ( q!=NULL ) q->rulenum = NumRules;
$7 = r;
>>
<<--BlkLevel;>>
";" <>
{ Action
<< a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule rule: cannot allocate error action");
strcpy(a, LATEXT(1));
CurRuleBlk->erraction = a;
>>
}
( exception_group > [eg]
<>
)*
<>
<>
<exceptions = CurExGroups;>>
<el_labels = CurElementLabels;>>
;
<>

laction : <>
"#lexaction"
Action
<<
a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule laction: cannot allocate action");
strcpy(a, LATEXT(1));
list_add(&LexActions, a);
>>
;
<>

aLexclass: "#lexclass" TokenTerm <>
;
<>

error : <>
"#errclass"
(<<;>> TokenTerm <>
| QuotedTerm <>
)
< require(e!=NULL, "cannot allocate error class node");
e->lexclass = CurrentLexClass;
if ( Tnum( (t=StripQuotes(t)) ) == 0 )
{
if ( hash_get(Texpr, t) != NULL )
warn(eMsg1("errclass name conflicts with regular expression '%s'",t));
e->tok = addTname( t );
set_orel(e->tok, &imag_tokens);
require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
"hash table mechanism is broken");
p->classname = 1; /* entry is errclass name, not token */
list_add(&eclasses, (char *)e);
}
else
{
warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t));
free( (char *)e );
go=0;
}
>>
"\{"
( NonTerminal <>
| TokenTerm <>
| QuotedTerm <>
)
<elist), t);>>
(
( NonTerminal <>
| TokenTerm <>
| QuotedTerm <>
)
<elist), t);>>
)*
"\}"
;
<>

tclass : <>
"#tokclass" TokenTerm <>
< require(e!=NULL, "cannot allocate token class node");
e->lexclass = CurrentLexClass;
if ( Tnum( t ) == 0 )
{
e->tok = addTname( t );
set_orel(e->tok, &imag_tokens);
set_orel(e->tok, &tokclasses);
require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
"hash table mechanism is broken");
p->classname = 1; /* entry is class name, not token */
p->tclass = e; /* save ptr to this tclass def */
list_add(&tclasses, (char *)e);
}
else
{
warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t));
free( (char *)e );
go=0;
}
>>
"\{"
(
( TokenTerm
< term = (TermEntry *) hash_get(Tname, LATEXT(1));
if ( term==NULL && UserDefdTokens ) {
err("implicit token definition not allowed with #tokdefs");
go = 0;
}
else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));}
}>>
| QuotedTerm
< term = (TermEntry *) hash_get(Texpr, LATEXT(1));
if ( term==NULL && UserDefdTokens ) {
err("implicit token definition not allowed with #tokdefs");
go = 0;
}
else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));}
}>>
)
<tlist), t);>>
)*
"\}"
;
<>

token : <>
"#token"
{ TokenTerm <>
{ "=" "[0-9]+" /* define the token type number */
<>
}
}
{ QuotedTerm <> }
{ Action
<<
a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule token: cannot allocate action");
strcpy(a, LATEXT(1));
>>
}
<>
;
<>

block[set *toksrefd, set *rulesrefd]
: <<
Graph g, b;
set saveblah;
int saveinalt = inAlt;
ExceptionGroup *eg;
*$toksrefd = empty;
*$rulesrefd = empty;
set_clr(AST_nodes_refd_in_actions);
CurBlockID++;
CurAltNum = 1;
saveblah = attribsRefdFromAction;
attribsRefdFromAction = empty;
>>
alt[toksrefd,rulesrefd] <>
<<
if ( ((Junction *)g.left)->p1->ntype == nAction )
{
if ( !((ActionNode *)(((Junction *)g.left)->p1))->is_predicate )
{
((ActionNode *)(((Junction *)g.left)->p1))->init_action = TRUE;
}
}
((Junction *)g.left)->blockid = CurBlockID;
>>

( exception_group > [eg]
<<
if ( eg!=NULL ) {
eg->altID = makeAltID(CurBlockID,CurAltNum);
CurAltStart->exception_label = eg->altID;
list_add(&CurExGroups, (void *)eg);
}
>>
)*
<>

( "\|" <>
alt[toksrefd,rulesrefd] <>
<<
((Junction *)g.left)->blockid = CurBlockID;
>>

( exception_group > [eg]
<<
if ( eg!=NULL ) {
eg->altID = makeAltID(CurBlockID,CurAltNum);
CurAltStart->exception_label = eg->altID;
list_add(&CurExGroups, (void *)eg);
}
>>
)*

<>

)*
<<$0 = b;>>
<>
;
<>

alt[set *toksrefd, set *rulesrefd]
: < int first_on_line = 1;
g.left=NULL; g.right=NULL;
CurAltStart = NULL;
elems = empty;
inAlt = 1;
>>
( <>
{ <> "\~" <> }
element[not, first_on_line] > [node]
<ntype!=nAction ) first_on_line = 0;>>
<<
if ( $2.left!=NULL ) {
g = Cat(g, $2);
n++;
if ( node!=NULL ) {
if ( node->ntype!=nAction ) e_num++;
/* record record number of all rule and token refs */
if ( node->ntype==nToken ) {
TokNode *tk = (TokNode *)((Junction *)$2.left)->p1;
tk->elnum = e_num;
set_orel(e_num, &elems);
}
else if ( node->ntype==nRuleRef ) {
RuleRefNode *rn = (RuleRefNode *)((Junction *)$2.left)->p1;
rn->elnum = e_num;
set_orel(e_num, $rulesrefd);
}
}
}
>>
)*
< $0 = g;
/* We want to reduce number of LT(i) calls and the number of
* local attribute variables in C++ mode (for moment, later we'll
* do for C also). However, if trees are being built, they
* require most of the attrib variables to create the tree nodes
* with; therefore, we gen a token ptr for each token ref in C++
*/
if ( GenCC && !GenAST )
set_orin($toksrefd, set_and(elems, attribsRefdFromAction));
else set_orin($toksrefd, elems);
if ( GenCC ) {
dif = set_dif(attribsRefdFromAction, elems);
if ( set_deg(dif)>0 )
err("one or more $i in action(s) refer to non-token elements");
set_free(dif);
}
set_free(elems);
set_free(attribsRefdFromAction);
inAlt = 0;
>>
;
<>

element_label > [LabelEntry *label]
: <>
LABEL <>
<<
UsedNewStyleLabel = 1;
if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i");
t = (TermEntry *) hash_get(Tname, lab);
if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab);
if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab);
if ( t!=NULL ) {
err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab));
$label = NULL;
}
else if ( r!=NULL ) {
err(eMsg1("label definition clashes with rule definition: '%s'", lab));
$label = NULL;
}
else {
/* we don't clash with anybody else */
l = (LabelEntry *) hash_get(Elabel, lab);
if ( l==NULL ) { /* ok to add new element label */
l = (LabelEntry *)hash_add(Elabel,
lab,
(Entry *)newLabelEntry(lab));
/* add to list of element labels for this rule */
list_add(&CurElementLabels, (void *)lab);
$label = l;
}
else {
err(eMsg1("label definitions must be unique per rule: '%s'", lab));
$label = NULL;
}
}
>>
":"
;

element[int not, int first_on_line] > [Node *node]
: <<
ActionNode *act;
RuleRefNode *rr;
set toksrefd, rulesrefd;
TermEntry *term;
TokNode *p=NULL; RuleRefNode *q; int approx=0;
LabelEntry *label=NULL;
$node = NULL;
>>
{element_label>[label]}
( TokenTerm
<<
term = (TermEntry *) hash_get(Tname, LATEXT(1));
if ( term==NULL && UserDefdTokens ) {
err("implicit token definition not allowed with #tokdefs");
$$.left = $$.right = NULL;
}
else {
$$ = buildToken(LATEXT(1));
p=((TokNode *)((Junction *)$$.left)->p1);
term = (TermEntry *) hash_get(Tname, LATEXT(1));
require( term!= NULL, "hash table mechanism is broken");
p->tclass = term->tclass;
p->complement = $not;
if ( label!=NULL ) {
p->el_label = label->str;
label->elem = (Node *)p;
}
}
>>
{ ".."
( QuotedTerm
<>
| TokenTerm
<>
)
}
<<
if ( p!=NULL && (p->upper_range!=0 || p->tclass || $not) )
list_add(&MetaTokenNodes, (void *)p);
>>
( "^" <astnode=ASTroot;>>
| <astnode=ASTchild;>>
| "!" <astnode=ASTexclude;>>
)
<<
if ( p!=NULL && $first_on_line ) {
CurAltStart = (Junction *)$$.left;
p->altstart = CurAltStart;
}
$node = (Node *)p;
>>
| QuotedTerm
<<
term = (TermEntry *) hash_get(Texpr, LATEXT(1));
if ( term==NULL && UserDefdTokens ) {
err("implicit token definition not allowed with #tokdefs");
$$.left = $$.right = NULL;
}
else {
$$ = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1);
p->complement = $not;
if ( label!=NULL ) {
p->el_label = label->str;
label->elem = (Node *)p;
}
}
>>
{ ".."
( QuotedTerm
<>
| TokenTerm
<>
)
}
( "^" <astnode=ASTroot;>>
| <astnode=ASTchild;>>
| "!" <astnode=ASTexclude;>>
)
<<
if ( p!=NULL && (p->upper_range!=0 || p->tclass || $not) )
list_add(&MetaTokenNodes, (void *)p);
>>
<<
if ( $first_on_line ) {
CurAltStart = (Junction *)$$.left;
p->altstart = CurAltStart;
}
$node = (Node *)p;
>>

| <>
"."
<<$$ = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1);>>
( "^" <astnode=ASTroot;>>
| <astnode=ASTchild;>>
| "!" <astnode=ASTexclude;>>
)
<>
<<
if ( $first_on_line ) {
CurAltStart = (Junction *)$$.left;
p->altstart = CurAltStart;
if ( label!=NULL ) {
p->el_label = label->str;
label->elem = (Node *)p;
}
}
$node = (Node *)p;
>>

| <>
NonTerminal
<<$$ = buildRuleRef(LATEXT(1));>>
{ "!" <p1;
q->astnode=ASTexclude;>>
}
{ {"\<"}
PassAction <p1, LATEXT(1));>>
}
<p1;>>
{ <>
"\>"
PassAction
<<
a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule element: cannot allocate assignment");
strcpy(a, LATEXT(1));
rr->assign = a;
>>
}
<<
if ( label!=NULL ) {
rr->el_label = label->str;
label->elem = (Node *)rr;
}
if ( $first_on_line ) {
CurAltStart = (Junction *)$$.left;
((RuleRefNode *)((Junction *)$$.left)->p1)->altstart = CurAltStart;
}
$node = (Node *)rr;
>>
)

| <>
Action <<$0 = buildAction(LATEXT(1),action_file,action_line, 0);>>
<>
<<$node = (Node *) ((Junction *)$0.left)->p1;>>

| <>
Pred <<$0 = buildAction(LATEXT(1),action_file,action_line, 1);>>
<p1;>>
{ <>
PassAction
<<
a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule element: cannot allocate predicate fail action");
strcpy(a, LATEXT(1));
act->pred_fail = a;
>>
}
<>
<<$node = (Node *)act;>>

| <>
<>
{ "#pragma"
( "approx" <>
| "LL(1)" <>
| "LL(2)" <>
)
}
( "\(" block[&toksrefd,&rulesrefd]
<<$$ = $2; --BlkLevel;>> "\)"
( "\*" <<$$ = makeLoop($$,approx);>>
| "\+" <<$$ = makePlus($$,approx);>>
| "?" <<$$ = makeBlk($$,approx);
FoundGuessBlk = 1;
((Junction *) ((Junction *)$$.left)->p1)->guess=1;
if ( !$first_on_line ) {
err("(...)? predicate must be first element of production");
}
>>
| <<$$ = makeBlk($$,approx);>>
)
<<
((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID;
((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd;
((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd;
>>
< CurAltStart = (Junction *)((Junction *)((Junction *)$$.left)->p1);
>>
<<$node = (Node *) ((Junction *)$$.left)->p1;>>

| "\{" block[&toksrefd,&rulesrefd]
<<$$ = makeOpt($2,approx); --BlkLevel;>>
"\}"
<<
((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID;
((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd;
((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd;
>>
< CurAltStart = (Junction *) ((Junction *)((Junction *)$$.left)->p1);
>>
<<$node = (Node *) ((Junction *)$$.left)->p1;>>

)

/* Error catching alternatives */
| "\*" <>
| "\+" <>
| "\>" <' can only appear after a nonterminal"); CannotContinue=TRUE;>>
| PassAction < [...]'");
CannotContinue=TRUE;>>
;
<>

default_exception_handler
: exception_group > [DefaultExGroup]
;

exception_group > [ExceptionGroup *eg]
: <>
"exception" <<$eg = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));>>
{ <>
PassAction /* did they attach a label? */
<<
p = LATEXT(1)+1;
p[strlen(p)-1] = '\0'; /* kill trailing space */
label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1);
if ( label==NULL )
{
err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1));
}
>>
}
( exception_handler > [h]
<handlers), (void *)h);>>
)*
{ "default" ":" Action
<<{
ExceptionHandler *eh = (ExceptionHandler *)
calloc(1, sizeof(ExceptionHandler));
char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(eh!=NULL, "exception: cannot allocate handler");
require(a!=NULL, "exception: cannot allocate action");
strcpy(a, LATEXT(1));
eh->action = a;
eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char));
require(eh->signalname!=NULL, "exception: cannot allocate sig name");
strcpy(eh->signalname, "default");
list_add(&($eg->handlers), (void *)eh);
}>>
}
<<
if ( label!=NULL ) {
/* Record ex group in sym tab for this label */
if ( label->ex_group!=NULL ) {
err(eMsg1("duplicate exception handler for label '%s'",label->str));
}
else {
label->ex_group = $eg;
/* Label the exception group itself */
$eg->label = label->str;
/* Make the labelled element pt to the exception also */
switch ( label->elem->ntype ) {
case nRuleRef :
{
RuleRefNode *r = (RuleRefNode *)label->elem;
r->ex_group = $eg;
break;
}
case nToken :
{
TokNode *t = (TokNode *)label->elem;
t->ex_group = $eg;
break;
}
}
}
/* You may want to remove this exc from the rule list
* and handle at the labeled element site.
*/
$eg = NULL;
}
>>
;
<>

exception_handler > [ExceptionHandler *eh]
: <>
"catch"
<<
$eh = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler));
require($eh!=NULL, "exception: cannot allocate handler");
>>
( NonTerminal
<<
$eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require($eh->signalname!=NULL, "exception: cannot allocate sig name");
strcpy($eh->signalname, LATEXT(1));
>>
| TokenTerm
<<
$eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require($eh->signalname!=NULL, "exception: cannot allocate sig name");
strcpy($eh->signalname, LATEXT(1));
>>
)
":"
{ <<$eh->action = NULL;>>
Action
<<
$eh->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require($eh->action!=NULL, "exception: cannot allocate action");
strcpy($eh->action, LATEXT(1));
>>
}
;
<>

#token NonTerminal "[a-z] [A-Za-z0-9_]*"
<<
while ( zzchar==' ' || zzchar=='\t' ) {
zzadvance();
}
if ( zzchar == ':' && inAlt ) NLA = LABEL;
>>
#token TokenTerm "[A-Z] [A-Za-z0-9_]*"
<<
while ( zzchar==' ' || zzchar=='\t' ) {
zzadvance();
}
if ( zzchar == ':' && inAlt ) NLA = LABEL;
>>
#token "#[A-Za-z0-9_]*" <>

#lexclass PARSE_ENUM_FILE

#token "[\t\ ]+" << zzskip(); >> /* Ignore White */
#token "[\n\r]" << zzline++; zzskip(); >> /* Track Line # */
#token "//" << zzmode(TOK_DEF_CPP_COMMENTS); zzmore(); >>
#token "/\*" << zzmode(TOK_DEF_COMMENTS); zzskip(); >>
#token "#ifdef" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
#token "#ifndef" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
#token "#else" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
#token "#endif" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
#token "@" << ; >>

enum_file[char *fname]
: ( enum_def[$fname] )+
| defines[$fname]
;

defines[char *fname]
: <>
(
"#define" ID
<>
INT
<<
v = atoi(LATEXT(1));
fprintf(stderr, "#token %s=%d\n", t, v);
TokenNum = v;
if ( v>maxt ) maxt=v;
if ( Tnum( t ) == 0 ) addForcedTname( t, v );
else {
warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);
}
>>
)+
<>
;

enum_def[char *fname]
: <>
"enum" ID
"\{"
ID
<>
( "=" INT <>
| <>
)
<<
/* fprintf(stderr, "#token %s=%d\n", t, v);*/
TokenNum = v;
if ( Tnum( t ) == 0 ) addForcedTname( t, v );
else {
warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);
}
>>
( ","
{ ID
<>
( "=" INT <>
| <>
)
<<
/* fprintf(stderr, "#token %s=%d\n", t, v);*/
TokenNum = v;
if ( Tnum( t ) == 0 ) addForcedTname( t, v );
else {
warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);
}
>>
}
)*
"\}"
";"
<>
;

#token INT "[0-9]+"
#token ID "[A-Z][_a-zA-Z0-9]*"

#lexclass START

<<
/* semantics of #token */
static void
#ifdef __STDC__
chkToken(char *t, char *e, char *a, int tnum)
#else
chkToken(t,e,a,tnum)
char *t, *e, *a;
int tnum;
#endif
{
TermEntry *p;

/* check to see that they don't try to redefine a token as a token class */
if ( t!=NULL ) {
p = (TermEntry *) hash_get(Tname, t);
if ( p!=NULL && p->classname ) {
err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t));
if ( a!=NULL ) free((char *)a);
return;
}
}

if ( t==NULL && e==NULL ) { /* none found */
err("#token requires at least token name or rexpr");
}
else if ( t!=NULL && e!=NULL ) { /* both found */
if ( UserDefdTokens ) { /* if #tokdefs, must not define new */
p = (TermEntry *) hash_get(Tname, t);
if ( p==NULL ) {
err(eMsg1("#token definition '%s' not allowed with #tokdefs; ignored",t));
return;
}
}
Tklink(t, e);
if ( a!=NULL ) {
if ( hasAction(e) ) {
err(eMsg1("redefinition of action for %s; ignored",e));
}
else setHasAction(e, a);
}
}
else if ( t!=NULL ) { /* only one found */
if ( UserDefdTokens ) {
err(eMsg1("#token definition '%s' not allowed with #tokdefs; ignored",t));
return;
}
if ( Tnum( t ) == 0 ) addTname( t );
else {
err(eMsg1("redefinition of token %s; ignored",t));
}
if ( a!=NULL ) {
err(eMsg1("action cannot be attached to a token name (%s); ignored",t));
free((char *)a);
}
}
else if ( e!=NULL ) {
if ( Tnum( e ) == 0 ) addTexpr( e );
else {
if ( hasAction(e) ) {
err(eMsg1("redefinition of action for expr %s; ignored",e));
}
else if ( a==NULL ) {
err(eMsg1("redefinition of expr %s; ignored",e));
}
}
if ( a!=NULL ) setHasAction(e, a);
}

/* if a token type number was specified, then add the token ID and 'tnum'
* pair to the ForcedTokens list. (only applies if an id was given)
*/
if ( t!=NULL && tnum>0 )
{
if ( set_el(tnum, reserved_positions) )
{
err(eMsgd("a token has already been forced to token number %d; ignored", tnum));
}
else
{
list_add(&ForcedTokens, newForcedToken(t,tnum));
set_orel(tnum, &reserved_positions);
}
}
}
>>

<<
/* ANTLR-specific syntax error message generator
* (define USER_ZZSYN when compiling so don't get 2 definitions)
*/
void
#ifdef __STDC__
zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
#else
zzsyn(text, tok, egroup, eset, etok, k, bad_text)
char *text, *egroup, *bad_text;
int tok;
int etok;
int k;
SetWordType *eset;
#endif
{
fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);
fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
if ( k==1 ) fprintf(stderr, " missing");
else
{
fprintf(stderr, "; \"%s\" not", bad_text);
if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
}
if ( zzset_deg(eset)>0 ) zzedecode(eset);
else fprintf(stderr, " %s", zztokens[etok]);
if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);
fprintf(stderr, "\n");
}
>>
ULL; FoundException = 1;>>
"exception" <<$eg = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));>>
{ <>
PassAction /* did they attach a label? */
<<
p = LATEXT(1)+1;
p[strlen(p)-1] = '\0'; /* kill trailing space */
labepccts/antlr/antlr.c 644 1377 31 135756 5655551737 7756 /*
* A n t l r T r a n s l a t i o n H e a d e r
*
* Terence Parr, Will Cohen, and Hank Dietz: 1989-1994
* Purdue University Electrical Engineering
* With AHPCRC, University of Minnesota
* ANTLR Version 1.23
*/
#include
#define ANTLR_VERSION 123

#ifdef __cplusplus
#ifndef __STDC__
#define __STDC__
#endif
#endif
#include "set.h"
#include
#include "syn.h"
#include "hash.h"
#include "generic.h"
#define zzcr_attr(attr,tok,t)
#define zzEOF_TOKEN 1
#define zzSET_SIZE 20
#include "antlr.h"
#include "tokens.h"
#include "dlgdef.h"
#include "mode.h"
ANTLR_INFO

#ifdef __STDC__
static void chkToken(char *, char *, char *, int);
#else
static void chkToken();
#endif

static int class_nest_level = 0;
extern int inAlt;
extern set attribsRefdFromAction;
extern int UsedOldStyleAttrib;
extern int UsedNewStyleLabel;

void
#ifdef __STDC__
grammar(void)
#else
grammar()
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
Graph g;
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( 1 ) {
if ( (LA(1)==85) ) {
zzmatch(85); zzCONSUME;
zzmatch(Action);

if ( HdrAction==NULL ) {
HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(HdrAction!=NULL, "rule grammar: cannot allocate header action");
strcpy(HdrAction, LATEXT(1));
}
else warn("additional #header statement ignored");
zzCONSUME;
}
else {
if ( (LA(1)==86) ) {
zzmatch(86); zzCONSUME;
zzmatch(QuotedTerm);

if ( GenCC ) {
warn("#parser meta-op incompatible with -CC; ignored");
}
else {
if ( strcmp(ParserName,"zzparser")==0 ) {
ParserName=StripQuotes(mystrdup(LATEXT(1)));
if ( RulePrefix[0]!='\0' )
{
warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored");
RulePrefix[0]='\0';
}
}
else warn("additional #parser statement ignored");
}
zzCONSUME;
}
else {
if ( (LA(1)==87) ) {
zzmatch(87); zzCONSUME;
zzmatch(QuotedTerm);
{
char *fname;
zzantlr_state st; FILE *f; struct zzdlg_state dst;
UserTokenDefsFile = mystrdup(LATEXT(1));
zzsave_antlr_state(&st);
zzsave_dlg_state(&dst);
fname = mystrdup(LATEXT(1));
f = fopen(StripQuotes(fname), "r");
if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));}
else {
ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE);
UserDefdTokens = 1;
}
zzrestore_antlr_state(&st);
zzrestore_dlg_state(&dst);
}
zzCONSUME;
}
else break;
}
}
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( 1 ) {
if ( (LA(1)==Action) ) {
zzmatch(Action);
{
UserAction *ua = newUserAction(LATEXT(1));
ua->file = action_file; ua->line = action_line;
if ( class_nest_level>0 ) list_add(&class_actions, ua);
else list_add(&BeforeActions, ua);
}
zzCONSUME;
}
else {
if ( (LA(1)==98) ) {
laction();
}
else {
if ( (LA(1)==99) ) {
aLexclass();
}
else {
if ( (LA(1)==102) ) {
token();
}
else {
if ( (LA(1)==100) ) {
error();
}
else {
if ( (LA(1)==101) ) {
tclass();
}
else {
if ( (LA(1)==118) ) {
default_exception_handler();
}
else {
if ( (LA(1)==89) ) {
class_def();
}
else {
if ( (LA(1)==88) ) {
zzmatch(88);

if ( class_nest_level==0 )
warn("missing class definition for trailing '}'");
class_nest_level--;
zzCONSUME;
}
else break;
}
}
}
}
}
}
}
}
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
rule();
g=zzaArg(zztasp1,3); SynDiag = (Junction *) zzaArg(zztasp1,3 ).left;
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( 1 ) {
if ( (LA(1)==NonTerminal) ) {
rule();
if ( zzaArg(zztasp2,1 ).left!=NULL ) {g.right = NULL; g = Or(g, zzaArg(zztasp2,1));}
}
else {
if ( (LA(1)==99) ) {
aLexclass();
}
else {
if ( (LA(1)==102) ) {
token();
}
else {
if ( (LA(1)==100) ) {
error();
}
else {
if ( (LA(1)==101) ) {
tclass();
}
else {
if ( (LA(1)==89) ) {
class_def();
}
else {
if ( (LA(1)==88) ) {
zzmatch(88);

if ( class_nest_level==0 )
warn("missing class definition for trailing '}'");
class_nest_level--;
zzCONSUME;
}
else break;
}
}
}
}
}
}
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( 1 ) {
if ( (LA(1)==Action) ) {
zzmatch(Action);
{
UserAction *ua = newUserAction(LATEXT(1));
ua->file = action_file; ua->line = action_line;
if ( class_nest_level>0 ) list_add(&class_actions, ua);
else list_add(&AfterActions, ua);
}
zzCONSUME;
}
else {
if ( (LA(1)==98) ) {
laction();
}
else {
if ( (LA(1)==100) ) {
error();
}
else {
if ( (LA(1)==101) ) {
tclass();
}
else {
if ( (LA(1)==89) ) {
class_def();
}
else {
if ( (LA(1)==88) ) {
zzmatch(88);

if ( class_nest_level==0 )
warn("missing class definition for trailing '}'");
class_nest_level--;
zzCONSUME;
}
else break;
}
}
}
}
}
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
zzmatch(Eof); zzCONSUME;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd1, 0x1);
}
}

void
#ifdef __STDC__
class_def(void)
#else
class_def()
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
int go=1; char name[MaxRuleName+1];
zzmatch(89); zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==NonTerminal) ) {
zzmatch(NonTerminal);
if(go) strncpy(name,LATEXT(1),MaxRuleName);
zzCONSUME;
}
else {
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);
if(go) strncpy(name,LATEXT(1),MaxRuleName);
zzCONSUME;
}
else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp2);
}
}

if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0
&& GenCC ) {
err("only one grammar class allowed in this release");
go = 0;
}
else strcpy(CurrentClassName, name);
if ( !GenCC ) { err("class meta-op used without C++ option"); }
zzmatch(92);

no_classes_found = 0;
if ( class_nest_level>=1 ) {warn("cannot have nested classes");}
else class_nest_level++;
zzCONSUME;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd1, 0x2);
}
}

void
#ifdef __STDC__
rule(void)
#else
rule()
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{

ListNode *ex_groups = NULL;
ExceptionGroup *eg;
RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e;
set toksrefd, rulesrefd;
char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL;
CurExGroups = NULL;
CurElementLabels = NULL;
/* We want a new element label hash table for each rule */
if ( Elabel!=NULL ) killHashTable(Elabel);
Elabel = newHashTable();
attribsRefdFromAction = empty;
zzmatch(NonTerminal);
q=NULL;
if ( hash_get(Rname, LATEXT(1))!=NULL ) {
err(eMsg1("duplicate rule definition: '%s'",LATEXT(1)));
CannotContinue=TRUE;
}
else
{
q = (RuleEntry *)hash_add(Rname,
LATEXT(1),
(Entry *)newRuleEntry(LATEXT(1)));
CurRule = q->str;
}
CurRuleNode = q;
f = CurFile; l = zzline;
NumRules++;
zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==93) ) {
zzmatch(93);
if ( q!=NULL ) q->noAST = TRUE;
zzCONSUME;
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
;
if ( (setwd1[LA(1)]&0x4) ) {
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==94) ) {
zzmatch(94); zzCONSUME;
}
zzEXIT(zztasp3);
}
}
zzmatch(PassAction);
pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(pdecl!=NULL, "rule rule: cannot allocate param decl");
strcpy(pdecl, LATEXT(1));
CurParmDef = pdecl;
zzCONSUME;
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==95) ) {
zzmatch(95); zzCONSUME;
zzmatch(PassAction);
ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(ret!=NULL, "rule rule: cannot allocate ret type");
strcpy(ret, LATEXT(1));
CurRetDef = ret;
zzCONSUME;
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==QuotedTerm) ) {
zzmatch(QuotedTerm);
if ( q!=NULL ) q->egroup=mystrdup(LATEXT(1));
zzCONSUME;
}
zzEXIT(zztasp2);
}
}

if ( GenEClasseForRules && q!=NULL ) {
e = newECnode;
require(e!=NULL, "cannot allocate error class node");
if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);}
else a = q->egroup;
if ( Tnum( a ) == 0 )
{
e->tok = addTname( a );
list_add(&eclasses, (char *)e);
if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
/* refers to itself */
list_add(&(e->elist), mystrdup(q->str));
}
else {
warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a));
if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
free((char *)e);
}
}
BlkLevel++;
zzmatch(96);
inAlt=1;
zzCONSUME;
block( &toksrefd, &rulesrefd );
r = makeBlk(zzaArg(zztasp1,7),0);
CurRuleBlk = (Junction *)r.left;
CurRuleBlk->blockid = CurBlockID;
CurRuleBlk->jtype = RuleBlk;
if ( q!=NULL ) CurRuleBlk->rname = q->str;
CurRuleBlk->file = f;
CurRuleBlk->line = l;
CurRuleBlk->pdecl = pdecl;
CurRuleBlk->ret = ret;
CurRuleBlk->lock = makelocks();
CurRuleBlk->pred_lock = makelocks();
CurRuleBlk->tokrefs = toksrefd;
CurRuleBlk->rulerefs = rulesrefd;
p = newJunction(); /* add EndRule Node */
((Junction *)r.right)->p1 = (Node *)p;
r.right = (Node *) p;
p->jtype = EndRule;
p->lock = makelocks();
p->pred_lock = makelocks();
CurRuleBlk->end = p;
if ( q!=NULL ) q->rulenum = NumRules;
zzaArg(zztasp1,7) = r;
--BlkLevel;
zzmatch(97);
inAlt=0;
zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==Action) ) {
zzmatch(Action);
a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule rule: cannot allocate error action");
strcpy(a, LATEXT(1));
CurRuleBlk->erraction = a;
zzCONSUME;
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( (LA(1)==118) ) {
eg = exception_group();

if ( eg!=NULL ) list_add(&CurExGroups, (void *)eg);
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
if ( q==NULL ) zzaArg(zztasp1,0 ).left = NULL; else zzaArg(zztasp1,0) = zzaArg(zztasp1,7);
CurRuleNode = NULL;
CurRuleBlk->exceptions = CurExGroups;
CurRuleBlk->el_labels = CurElementLabels;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd1, 0x8);
}
}

void
#ifdef __STDC__
laction(void)
#else
laction()
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
char *a;
zzmatch(98); zzCONSUME;
zzmatch(Action);

a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule laction: cannot allocate action");
strcpy(a, LATEXT(1));
list_add(&LexActions, a);
zzCONSUME;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd1, 0x10);
}
}

void
#ifdef __STDC__
aLexclass(void)
#else
aLexclass()
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
zzmatch(99); zzCONSUME;
zzmatch(TokenTerm);
lexclass(mystrdup(LATEXT(1)));
zzCONSUME;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd1, 0x20);
}
}

void
#ifdef __STDC__
error(void)
#else
error()
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
char *t=NULL; ECnode *e; int go=1; TermEntry *p;
zzmatch(100); zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
;
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);
t=mystrdup(LATEXT(1));
zzCONSUME;
}
else {
if ( (LA(1)==QuotedTerm) ) {
zzmatch(QuotedTerm);
t=mystrdup(LATEXT(1));
zzCONSUME;
}
else {zzFAIL(1,zzerr2,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp2);
}
}
e = newECnode;
require(e!=NULL, "cannot allocate error class node");
e->lexclass = CurrentLexClass;
if ( Tnum( (t=StripQuotes(t)) ) == 0 )
{
if ( hash_get(Texpr, t) != NULL )
warn(eMsg1("errclass name conflicts with regular expression '%s'",t));
e->tok = addTname( t );
set_orel(e->tok, &imag_tokens);
require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
"hash table mechanism is broken");
p->classname = 1; /* entry is errclass name, not token */
list_add(&eclasses, (char *)e);
}
else
{
warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t));
free( (char *)e );
go=0;
}
zzmatch(92); zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==NonTerminal) ) {
zzmatch(NonTerminal);
if ( go ) t=mystrdup(LATEXT(1));
zzCONSUME;
}
else {
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);
if ( go ) t=mystrdup(LATEXT(1));
zzCONSUME;
}
else {
if ( (LA(1)==QuotedTerm) ) {
zzmatch(QuotedTerm);
if ( go ) t=mystrdup(LATEXT(1));
zzCONSUME;
}
else {zzFAIL(1,zzerr3,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
zzEXIT(zztasp2);
}
}
if ( go ) list_add(&(e->elist), t);
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( (setwd1[LA(1)]&0x40) ) {
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==NonTerminal) ) {
zzmatch(NonTerminal);
if ( go ) t=mystrdup(LATEXT(1));
zzCONSUME;
}
else {
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);
if ( go ) t=mystrdup(LATEXT(1));
zzCONSUME;
}
else {
if ( (LA(1)==QuotedTerm) ) {
zzmatch(QuotedTerm);
if ( go ) t=mystrdup(LATEXT(1));
zzCONSUME;
}
else {zzFAIL(1,zzerr4,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
zzEXIT(zztasp3);
}
}
if ( go ) list_add(&(e->elist), t);
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
zzmatch(88); zzCONSUME;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd1, 0x80);
}
}

void
#ifdef __STDC__
tclass(void)
#else
tclass()
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
char *t=NULL; TCnode *e; int go=1,tok; TermEntry *p, *term;
zzmatch(101); zzCONSUME;
zzmatch(TokenTerm);
t=mystrdup(LATEXT(1));
zzCONSUME;
e = newTCnode;
require(e!=NULL, "cannot allocate token class node");
e->lexclass = CurrentLexClass;
if ( Tnum( t ) == 0 )
{
e->tok = addTname( t );
set_orel(e->tok, &imag_tokens);
set_orel(e->tok, &tokclasses);
require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
"hash table mechanism is broken");
p->classname = 1; /* entry is class name, not token */
p->tclass = e; /* save ptr to this tclass def */
list_add(&tclasses, (char *)e);
}
else
{
warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t));
free( (char *)e );
go=0;
}
zzmatch(92); zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( (setwd2[LA(1)]&0x1) ) {
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);
if ( go ) {
term = (TermEntry *) hash_get(Tname, LATEXT(1));
if ( term==NULL && UserDefdTokens ) {
err("implicit token definition not allowed with #tokdefs");
go = 0;
}
else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));}
}
zzCONSUME;
}
else {
if ( (LA(1)==QuotedTerm) ) {
zzmatch(QuotedTerm);
if ( go ) {
term = (TermEntry *) hash_get(Texpr, LATEXT(1));
if ( term==NULL && UserDefdTokens ) {
err("implicit token definition not allowed with #tokdefs");
go = 0;
}
else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));}
}
zzCONSUME;
}
else {zzFAIL(1,zzerr5,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp3);
}
}
if ( go ) list_add(&(e->tlist), t);
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
zzmatch(88); zzCONSUME;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd2, 0x2);
}
}

void
#ifdef __STDC__
token(void)
#else
token()
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
char *t=NULL, *e=NULL, *a=NULL; int tnum=0;
zzmatch(102); zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);
t=mystrdup(LATEXT(1));
zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==103) ) {
zzmatch(103); zzCONSUME;
zzmatch(104);
tnum = atoi(LATEXT(1));
zzCONSUME;
}
zzEXIT(zztasp3);
}
}
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==QuotedTerm) ) {
zzmatch(QuotedTerm);
e=mystrdup(LATEXT(1));
zzCONSUME;
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==Action) ) {
zzmatch(Action);

a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule token: cannot allocate action");
strcpy(a, LATEXT(1));
zzCONSUME;
}
zzEXIT(zztasp2);
}
}
chkToken(t, e, a, tnum);
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd2, 0x4);
}
}

void
#ifdef __STDC__
block( set *toksrefd, set *rulesrefd )
#else
block(toksrefd,rulesrefd)
set *toksrefd;
set *rulesrefd ;
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{

Graph g, b;
set saveblah;
int saveinalt = inAlt;
ExceptionGroup *eg;
* toksrefd = empty;
* rulesrefd = empty;
set_clr(AST_nodes_refd_in_actions);
CurBlockID++;
CurAltNum = 1;
saveblah = attribsRefdFromAction;
attribsRefdFromAction = empty;
alt( toksrefd,rulesrefd );
b = g = zzaArg(zztasp1,1);

if ( ((Junction *)g.left)->p1->ntype == nAction )
{
if ( !((ActionNode *)(((Junction *)g.left)->p1))->is_predicate )
{
((ActionNode *)(((Junction *)g.left)->p1))->init_action = TRUE;
}
}
((Junction *)g.left)->blockid = CurBlockID;
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( (LA(1)==118) ) {
eg = exception_group();


if ( eg!=NULL ) {
eg->altID = makeAltID(CurBlockID,CurAltNum);
CurAltStart->exception_label = eg->altID;
list_add(&CurExGroups, (void *)eg);
}
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
CurAltNum++;
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( (LA(1)==105) ) {
zzmatch(105);
inAlt=1;
zzCONSUME;
alt( toksrefd,rulesrefd );
g = Or(g, zzaArg(zztasp2,2));

((Junction *)g.left)->blockid = CurBlockID;
{
zzBLOCK(zztasp3);
zzMake0;
{
while ( (LA(1)==118) ) {
eg = exception_group();


if ( eg!=NULL ) {
eg->altID = makeAltID(CurBlockID,CurAltNum);
CurAltStart->exception_label = eg->altID;
list_add(&CurExGroups, (void *)eg);
}
zzLOOP(zztasp3);
}
zzEXIT(zztasp3);
}
}
CurAltNum++;
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
zzaArg(zztasp1,0) = b;
attribsRefdFromAction = saveblah; inAlt = saveinalt;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd2, 0x8);
}
}

void
#ifdef __STDC__
alt( set *toksrefd, set *rulesrefd )
#else
alt(toksrefd,rulesrefd)
set *toksrefd;
set *rulesrefd ;
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
int n=0,ne=0; Graph g; int e_num=0, not=0; Node *node; set elems, dif;
int first_on_line = 1;
g.left=NULL; g.right=NULL;
CurAltStart = NULL;
elems = empty;
inAlt = 1;
{
zzBLOCK(zztasp2);
zzMake0;
{
int tok;
while ( (setwd2[LA(1)]&0x10) ) {
{
zzBLOCK(zztasp3);
zzMake0;
{
not=0;
if ( (LA(1)==106) ) {
zzmatch(106);
not=1;
zzCONSUME;
}
zzEXIT(zztasp3);
}
}
node = element( not, first_on_line );

if ( node!=NULL && node->ntype!=nAction ) first_on_line = 0;

if ( zzaArg(zztasp2,2 ).left!=NULL ) {
g = Cat(g, zzaArg(zztasp2,2));
n++;
if ( node!=NULL ) {
if ( node->ntype!=nAction ) e_num++;
/* record record number of all rule and token refs */
if ( node->ntype==nToken ) {
TokNode *tk = (TokNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;
tk->elnum = e_num;
set_orel(e_num, &elems);
}
else if ( node->ntype==nRuleRef ) {
RuleRefNode *rn = (RuleRefNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;
rn->elnum = e_num;
set_orel(e_num, rulesrefd);
}
}
}
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
if ( n == 0 ) g = emptyAlt();
zzaArg(zztasp1,0) = g;
/* We want to reduce number of LT(i) calls and the number of
* local attribute variables in C++ mode (for moment, later we'll
* do for C also). However, if trees are being built, they
* require most of the attrib variables to create the tree nodes
* with; therefore, we gen a token ptr for each token ref in C++
*/
if ( GenCC && !GenAST )
set_orin( toksrefd, set_and(elems, attribsRefdFromAction));
else set_orin( toksrefd, elems);
if ( GenCC ) {
dif = set_dif(attribsRefdFromAction, elems);
if ( set_deg(dif)>0 )
err("one or more $i in action(s) refer to non-token elements");
set_free(dif);
}
set_free(elems);
set_free(attribsRefdFromAction);
inAlt = 0;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd2, 0x20);
}
}

LabelEntry *
#ifdef __STDC__
element_label(void)
#else
element_label()
#endif
{
LabelEntry * _retv;
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
TermEntry *t=NULL; LabelEntry *l=NULL; RuleEntry *r=NULL; char *lab;
zzmatch(LABEL);
lab = mystrdup(LATEXT(1));
zzCONSUME;

UsedNewStyleLabel = 1;
if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i");
t = (TermEntry *) hash_get(Tname, lab);
if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab);
if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab);
if ( t!=NULL ) {
err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab));
_retv = NULL;
}
else if ( r!=NULL ) {
err(eMsg1("label definition clashes with rule definition: '%s'", lab));
_retv = NULL;
}
else {
/* we don't clash with anybody else */
l = (LabelEntry *) hash_get(Elabel, lab);
if ( l==NULL ) { /* ok to add new element label */
l = (LabelEntry *)hash_add(Elabel,
lab,
(Entry *)newLabelEntry(lab));
/* add to list of element labels for this rule */
list_add(&CurElementLabels, (void *)lab);
_retv = l;
}
else {
err(eMsg1("label definitions must be unique per rule: '%s'", lab));
_retv = NULL;
}
}
zzmatch(96); zzCONSUME;
zzEXIT(zztasp1);
return _retv;
fail:
zzEXIT(zztasp1);
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd2, 0x40);
return _retv;
}
}

Node *
#ifdef __STDC__
element( int not, int first_on_line )
#else
element(not,first_on_line)
int not;
int first_on_line ;
#endif
{
Node * _retv;
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{

ActionNode *act;
RuleRefNode *rr;
set toksrefd, rulesrefd;
TermEntry *term;
TokNode *p=NULL; RuleRefNode *q; int approx=0;
LabelEntry *label=NULL;
_retv = NULL;
if ( (setwd2[LA(1)]&0x80) ) {
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==LABEL) ) {
label = element_label();

}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);

term = (TermEntry *) hash_get(Tname, LATEXT(1));
if ( term==NULL && UserDefdTokens ) {
err("implicit token definition not allowed with #tokdefs");
zzaRet.left = zzaRet.right = NULL;
}
else {
zzaRet = buildToken(LATEXT(1));
p=((TokNode *)((Junction *)zzaRet.left)->p1);
term = (TermEntry *) hash_get(Tname, LATEXT(1));
require( term!= NULL, "hash table mechanism is broken");
p->tclass = term->tclass;
p->complement = not;
if ( label!=NULL ) {
p->el_label = label->str;
label->elem = (Node *)p;
}
}
zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==107) ) {
zzmatch(107); zzCONSUME;
{
zzBLOCK(zztasp4);
zzMake0;
{
if ( (LA(1)==QuotedTerm) ) {
zzmatch(QuotedTerm);
if ( p!=NULL ) setUpperRange(p, LATEXT(1));
zzCONSUME;
}
else {
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);
if ( p!=NULL ) setUpperRange(p, LATEXT(1));
zzCONSUME;
}
else {zzFAIL(1,zzerr6,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp4);
}
}
}
zzEXIT(zztasp3);
}
}

if ( p!=NULL && (p->upper_range!=0 || p->tclass || not) )
list_add(&MetaTokenNodes, (void *)p);
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==108) ) {
zzmatch(108);
if ( p!=NULL ) p->astnode=ASTroot;
zzCONSUME;
}
else {
if ( (setwd3[LA(1)]&0x1) ) {
if ( p!=NULL ) p->astnode=ASTchild;
}
else {
if ( (LA(1)==93) ) {
zzmatch(93);
if ( p!=NULL ) p->astnode=ASTexclude;
zzCONSUME;
}
else {zzFAIL(1,zzerr7,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
zzEXIT(zztasp3);
}
}

if ( p!=NULL && first_on_line ) {
CurAltStart = (Junction *)zzaRet.left;
p->altstart = CurAltStart;
}
_retv = (Node *)p;
}
else {
if ( (LA(1)==QuotedTerm) ) {
zzmatch(QuotedTerm);

term = (TermEntry *) hash_get(Texpr, LATEXT(1));
if ( term==NULL && UserDefdTokens ) {
err("implicit token definition not allowed with #tokdefs");
zzaRet.left = zzaRet.right = NULL;
}
else {
zzaRet = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);
p->complement = not;
if ( label!=NULL ) {
p->el_label = label->str;
label->elem = (Node *)p;
}
}
zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==107) ) {
zzmatch(107); zzCONSUME;
{
zzBLOCK(zztasp4);
zzMake0;
{
if ( (LA(1)==QuotedTerm) ) {
zzmatch(QuotedTerm);
if ( p!=NULL ) setUpperRange(p, LATEXT(1));
zzCONSUME;
}
else {
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);
if ( p!=NULL ) setUpperRange(p, LATEXT(1));
zzCONSUME;
}
else {zzFAIL(1,zzerr8,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp4);
}
}
}
zzEXIT(zztasp3);
}
}
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==108) ) {
zzmatch(108);
if ( p!=NULL ) p->astnode=ASTroot;
zzCONSUME;
}
else {
if ( (setwd3[LA(1)]&0x2) ) {
if ( p!=NULL ) p->astnode=ASTchild;
}
else {
if ( (LA(1)==93) ) {
zzmatch(93);
if ( p!=NULL ) p->astnode=ASTexclude;
zzCONSUME;
}
else {zzFAIL(1,zzerr9,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
zzEXIT(zztasp3);
}
}

if ( p!=NULL && (p->upper_range!=0 || p->tclass || not) )
list_add(&MetaTokenNodes, (void *)p);

if ( first_on_line ) {
CurAltStart = (Junction *)zzaRet.left;
p->altstart = CurAltStart;
}
_retv = (Node *)p;
}
else {
if ( (LA(1)==WildCard) ) {
if ( not ) warn("~ WILDCARD is an undefined operation (implies 'nothing')");
zzmatch(WildCard);
zzaRet = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);
zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==108) ) {
zzmatch(108);
p->astnode=ASTroot;
zzCONSUME;
}
else {
if ( (setwd3[LA(1)]&0x4) ) {
p->astnode=ASTchild;
}
else {
if ( (LA(1)==93) ) {
zzmatch(93);
p->astnode=ASTexclude;
zzCONSUME;
}
else {zzFAIL(1,zzerr10,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
zzEXIT(zztasp3);
}
}
list_add(&MetaTokenNodes, (void *)p);

if ( first_on_line ) {
CurAltStart = (Junction *)zzaRet.left;
p->altstart = CurAltStart;
if ( label!=NULL ) {
p->el_label = label->str;
label->elem = (Node *)p;
}
}
_retv = (Node *)p;
}
else {
if ( (LA(1)==NonTerminal) ) {
if ( not ) warn("~ NONTERMINAL is an undefined operation");
zzmatch(NonTerminal);
zzaRet = buildRuleRef(LATEXT(1));
zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==93) ) {
zzmatch(93);
q = (RuleRefNode *) ((Junction *)zzaRet.left)->p1;
q->astnode=ASTexclude;
zzCONSUME;
}
zzEXIT(zztasp3);
}
}
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (setwd3[LA(1)]&0x8) ) {
{
zzBLOCK(zztasp4);
zzMake0;
{
if ( (LA(1)==94) ) {
zzmatch(94); zzCONSUME;
}
zzEXIT(zztasp4);
}
}
zzmatch(PassAction);
addParm(((Junction *)zzaRet.left)->p1, LATEXT(1));
zzCONSUME;
}
zzEXIT(zztasp3);
}
}
rr=(RuleRefNode *) ((Junction *)zzaRet.left)->p1;
{
zzBLOCK(zztasp3);
zzMake0;
{
char *a;
if ( (LA(1)==95) ) {
zzmatch(95); zzCONSUME;
zzmatch(PassAction);

a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule element: cannot allocate assignment");
strcpy(a, LATEXT(1));
rr->assign = a;
zzCONSUME;
}
zzEXIT(zztasp3);
}
}

if ( label!=NULL ) {
rr->el_label = label->str;
label->elem = (Node *)rr;
}
if ( first_on_line ) {
CurAltStart = (Junction *)zzaRet.left;
((RuleRefNode *)((Junction *)zzaRet.left)->p1)->altstart = CurAltStart;
}
_retv = (Node *)rr;
}
else {zzFAIL(1,zzerr11,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
}
zzEXIT(zztasp2);
}
}
}
else {
if ( (LA(1)==Action) ) {
if ( not ) warn("~ ACTION is an undefined operation");
zzmatch(Action);
zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 0);
zzCONSUME;
if ( first_on_line ) CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left;
_retv = (Node *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;
}
else {
if ( (LA(1)==Pred) ) {
if ( not ) warn("~ SEMANTIC-PREDICATE is an undefined operation");
zzmatch(Pred);
zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 1);
zzCONSUME;
act = (ActionNode *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;
{
zzBLOCK(zztasp2);
zzMake0;
{
char *a;
if ( (LA(1)==PassAction) ) {
zzmatch(PassAction);

a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(a!=NULL, "rule element: cannot allocate predicate fail action");
strcpy(a, LATEXT(1));
act->pred_fail = a;
zzCONSUME;
}
zzEXIT(zztasp2);
}
}
if ( first_on_line ) CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left;
_retv = (Node *)act;
}
else {
if ( (setwd3[LA(1)]&0x10) ) {
if ( not ) warn("~ BLOCK is an undefined operation");
BlkLevel++;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==109) ) {
zzmatch(109); zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==110) ) {
zzmatch(110);
approx=LL_k;
zzCONSUME;
}
else {
if ( (LA(1)==111) ) {
zzmatch(111);
approx = 1;
zzCONSUME;
}
else {
if ( (LA(1)==112) ) {
zzmatch(112);
approx = 2;
zzCONSUME;
}
else {zzFAIL(1,zzerr12,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
zzEXIT(zztasp3);
}
}
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==113) ) {
zzmatch(113); zzCONSUME;
block( &toksrefd,&rulesrefd );
zzaRet = zzaArg(zztasp2,2); --BlkLevel;
zzmatch(114); zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==115) ) {
zzmatch(115);
zzaRet = makeLoop(zzaRet,approx);
zzCONSUME;
}
else {
if ( (LA(1)==116) ) {
zzmatch(116);
zzaRet = makePlus(zzaRet,approx);
zzCONSUME;
}
else {
if ( (LA(1)==117) ) {
zzmatch(117);
zzaRet = makeBlk(zzaRet,approx);
FoundGuessBlk = 1;
((Junction *) ((Junction *)zzaRet.left)->p1)->guess=1;
if ( ! first_on_line ) {
err("(...)? predicate must be first element of production");
}
zzCONSUME;
}
else {
if ( (setwd3[LA(1)]&0x20) ) {
zzaRet = makeBlk(zzaRet,approx);
}
else {zzFAIL(1,zzerr13,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
}
zzEXIT(zztasp3);
}
}

((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;
((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;
((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;
if ( first_on_line )
CurAltStart = (Junction *)((Junction *)((Junction *)zzaRet.left)->p1);
_retv = (Node *) ((Junction *)zzaRet.left)->p1;
}
else {
if ( (LA(1)==92) ) {
zzmatch(92); zzCONSUME;
block( &toksrefd,&rulesrefd );
zzaRet = makeOpt(zzaArg(zztasp2,2),approx); --BlkLevel;
zzmatch(88);

((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;
((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;
((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;
zzCONSUME;
if ( first_on_line )
CurAltStart = (Junction *) ((Junction *)((Junction *)zzaRet.left)->p1);
_retv = (Node *) ((Junction *)zzaRet.left)->p1;
}
else {zzFAIL(1,zzerr14,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp2);
}
}
}
else {
if ( (LA(1)==115) ) {
zzmatch(115);
warn("don't you want a ')' with that '*'?"); CannotContinue=TRUE;
zzCONSUME;
}
else {
if ( (LA(1)==116) ) {
zzmatch(116);
warn("don't you want a ')' with that '+'?"); CannotContinue=TRUE;
zzCONSUME;
}
else {
if ( (LA(1)==95) ) {
zzmatch(95);
warn("'>' can only appear after a nonterminal"); CannotContinue=TRUE;
zzCONSUME;
}
else {
if ( (LA(1)==PassAction) ) {
zzmatch(PassAction);
warn("[...] out of context 'rule > [...]'");
CannotContinue=TRUE;
zzCONSUME;
}
else {zzFAIL(1,zzerr15,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
}
}
}
}
}
zzEXIT(zztasp1);
return _retv;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd3, 0x40);
return _retv;
}
}

void
#ifdef __STDC__
default_exception_handler(void)
#else
default_exception_handler()
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
DefaultExGroup = exception_group();

zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd3, 0x80);
}
}

ExceptionGroup *
#ifdef __STDC__
exception_group(void)
#else
exception_group()
#endif
{
ExceptionGroup * _retv;
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
ExceptionHandler *h; LabelEntry *label=NULL; FoundException = 1;
zzmatch(118);
_retv = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));
zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
char *p;
if ( (LA(1)==PassAction) ) {
zzmatch(PassAction);

p = LATEXT(1)+1;
p[strlen(p)-1] = '\0'; /* kill trailing space */
label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1);
if ( label==NULL )
{
err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1));
}
zzCONSUME;
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( (LA(1)==120) ) {
h = exception_handler();

list_add(&(_retv->handlers), (void *)h);
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==119) ) {
zzmatch(119); zzCONSUME;
zzmatch(96); zzCONSUME;
zzmatch(Action);
{
ExceptionHandler *eh = (ExceptionHandler *)
calloc(1, sizeof(ExceptionHandler));
char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(eh!=NULL, "exception: cannot allocate handler");
require(a!=NULL, "exception: cannot allocate action");
strcpy(a, LATEXT(1));
eh->action = a;
eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char));
require(eh->signalname!=NULL, "exception: cannot allocate sig name");
strcpy(eh->signalname, "default");
list_add(&(_retv->handlers), (void *)eh);
}
zzCONSUME;
}
zzEXIT(zztasp2);
}
}

if ( label!=NULL ) {
/* Record ex group in sym tab for this label */
if ( label->ex_group!=NULL ) {
err(eMsg1("duplicate exception handler for label '%s'",label->str));
}
else {
label->ex_group = _retv;
/* Label the exception group itself */
_retv->label = label->str;
/* Make the labelled element pt to the exception also */
switch ( label->elem->ntype ) {
case nRuleRef :
{
RuleRefNode *r = (RuleRefNode *)label->elem;
r->ex_group = _retv;
break;
}
case nToken :
{
TokNode *t = (TokNode *)label->elem;
t->ex_group = _retv;
break;
}
}
}
/* You may want to remove this exc from the rule list
* and handle at the labeled element site.
*/
_retv = NULL;
}
zzEXIT(zztasp1);
return _retv;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd4, 0x1);
return _retv;
}
}

ExceptionHandler *
#ifdef __STDC__
exception_handler(void)
#else
exception_handler()
#endif
{
ExceptionHandler * _retv;
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
char *a;
zzmatch(120);

_retv = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler));
require(_retv!=NULL, "exception: cannot allocate handler");
zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==NonTerminal) ) {
zzmatch(NonTerminal);

_retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(_retv->signalname!=NULL, "exception: cannot allocate sig name");
strcpy(_retv->signalname, LATEXT(1));
zzCONSUME;
}
else {
if ( (LA(1)==TokenTerm) ) {
zzmatch(TokenTerm);

_retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(_retv->signalname!=NULL, "exception: cannot allocate sig name");
strcpy(_retv->signalname, LATEXT(1));
zzCONSUME;
}
else {zzFAIL(1,zzerr16,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp2);
}
}
zzmatch(96); zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
_retv->action = NULL;
if ( (LA(1)==Action) ) {
zzmatch(Action);

_retv->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
require(_retv->action!=NULL, "exception: cannot allocate action");
strcpy(_retv->action, LATEXT(1));
zzCONSUME;
}
zzEXIT(zztasp2);
}
}
zzEXIT(zztasp1);
return _retv;
fail:
zzEXIT(zztasp1);
CannotContinue=TRUE;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd4, 0x2);
return _retv;
}
}

void
#ifdef __STDC__
enum_file( char *fname )
#else
enum_file(fname)
char *fname ;
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
if ( (LA(1)==133) ) {
{
zzBLOCK(zztasp2);
int zzcnt=1;
zzMake0;
{
do {
enum_def( fname );
zzLOOP(zztasp2);
} while ( (LA(1)==133) );
zzEXIT(zztasp2);
}
}
}
else {
if ( (LA(1)==130) ) {
defines( fname );
}
else {zzFAIL(1,zzerr17,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd4, 0x4);
}
}

void
#ifdef __STDC__
defines( char *fname )
#else
defines(fname)
char *fname ;
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
int v,maxt= -1; char *t;
{
zzBLOCK(zztasp2);
int zzcnt=1;
zzMake0;
{
do {
zzmatch(130); zzCONSUME;
zzmatch(ID);
t = mystrdup(LATEXT(1));
zzCONSUME;
zzmatch(INT);

v = atoi(LATEXT(1));
fprintf(stderr, "#token %s=%d\n", t, v);
TokenNum = v;
if ( v>maxt ) maxt=v;
if ( Tnum( t ) == 0 ) addForcedTname( t, v );
else {
warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);
}
zzCONSUME;
zzLOOP(zztasp2);
} while ( (LA(1)==130) );
zzEXIT(zztasp2);
}
}
TokenNum = maxt + 1;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd4, 0x8);
}
}

void
#ifdef __STDC__
enum_def( char *fname )
#else
enum_def(fname)
char *fname ;
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
int v= -1; char *t;
zzmatch(133); zzCONSUME;
zzmatch(ID); zzCONSUME;
zzmatch(134); zzCONSUME;
zzmatch(ID);
t = mystrdup(LATEXT(1));
zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==135) ) {
zzmatch(135); zzCONSUME;
zzmatch(INT);
v=atoi(LATEXT(1));
zzCONSUME;
}
else {
if ( (setwd4[LA(1)]&0x10) ) {
v++;
}
else {zzFAIL(1,zzerr18,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp2);
}
}

/* fprintf(stderr, "#token %s=%d\n", t, v);*/
TokenNum = v;
if ( Tnum( t ) == 0 ) addForcedTname( t, v );
else {
warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);
}
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( (LA(1)==136) ) {
zzmatch(136); zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==ID) ) {
zzmatch(ID);
t = mystrdup(LATEXT(1));
zzCONSUME;
{
zzBLOCK(zztasp4);
zzMake0;
{
if ( (LA(1)==135) ) {
zzmatch(135); zzCONSUME;
zzmatch(INT);
v=atoi(LATEXT(1));
zzCONSUME;
}
else {
if ( (setwd4[LA(1)]&0x20) ) {
v++;
}
else {zzFAIL(1,zzerr19,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp4);
}
}

/* fprintf(stderr, "#token %s=%d\n", t, v);*/
TokenNum = v;
if ( Tnum( t ) == 0 ) addForcedTname( t, v );
else {
warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);
}
}
zzEXIT(zztasp3);
}
}
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
zzmatch(137); zzCONSUME;
zzmatch(138);
TokenNum++;
zzCONSUME;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd4, 0x40);
}
}

/* semantics of #token */
static void
#ifdef __STDC__
chkToken(char *t, char *e, char *a, int tnum)
#else
chkToken(t,e,a,tnum)
char *t, *e, *a;
int tnum;
#endif
{
TermEntry *p;

/* check to see that they don't try to redefine a token as a token class */
if ( t!=NULL ) {
p = (TermEntry *) hash_get(Tname, t);
if ( p!=NULL && p->classname ) {
err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t));
if ( a!=NULL ) free((char *)a);
return;
}
}

if ( t==NULL && e==NULL ) { /* none found */
err("#token requires at least token name or rexpr");
}
else if ( t!=NULL && e!=NULL ) { /* both found */
if ( UserDefdTokens ) { /* if #tokdefs, must not define new */
p = (TermEntry *) hash_get(Tname, t);
if ( p==NULL ) {
err(eMsg1("#token definition '%s' not allowed with #tokdefs; ignored",t));
return;
}
}
Tklink(t, e);
if ( a!=NULL ) {
if ( hasAction(e) ) {
err(eMsg1("redefinition of action for %s; ignored",e));
}
else setHasAction(e, a);
}
}
else if ( t!=NULL ) { /* only one found */
if ( UserDefdTokens ) {
err(eMsg1("#token definition '%s' not allowed with #tokdefs; ignored",t));
return;
}
if ( Tnum( t ) == 0 ) addTname( t );
else {
err(eMsg1("redefinition of token %s; ignored",t));
}
if ( a!=NULL ) {
err(eMsg1("action cannot be attached to a token name (%s); ignored",t));
free((char *)a);
}
}
else if ( e!=NULL ) {
if ( Tnum( e ) == 0 ) addTexpr( e );
else {
if ( hasAction(e) ) {
err(eMsg1("redefinition of action for expr %s; ignored",e));
}
else if ( a==NULL ) {
err(eMsg1("redefinition of expr %s; ignored",e));
}
}
if ( a!=NULL ) setHasAction(e, a);
}

/* if a token type number was specified, then add the token ID and 'tnum'
* pair to the ForcedTokens list. (only applies if an id was given)
*/
if ( t!=NULL && tnum>0 )
{
if ( set_el(tnum, reserved_positions) )
{
err(eMsgd("a token has already been forced to token number %d; ignored", tnum));
}
else
{
list_add(&ForcedTokens, newForcedToken(t,tnum));
set_orel(tnum, &reserved_positions);
}
}
}

/* ANTLR-specific syntax error message generator
* (define USER_ZZSYN when compiling so don't get 2 definitions)
*/
void
#ifdef __STDC__
zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
#else
zzsyn(text, tok, egroup, eset, etok, k, bad_text)
char *text, *egroup, *bad_text;
int tok;
int etok;
int k;
SetWordType *eset;
#endif
{
fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);
fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
if ( k==1 ) fprintf(stderr, " missing");
else
{
fprintf(stderr, "; \"%s\" not", bad_text);
if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
}
if ( zzset_deg(eset)>0 ) zzedecode(eset);
else fprintf(stderr, " %s", zztokens[etok]);
if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);
fprintf(stderr, "\n");
}
tv;
fail:
zzEXIT(pccts/antlr/scan.c 644 1377 31 242303 5655551740 7537
/* parser.dlg -- DLG Description of scanner
*
* Generated from: antlr.g
*
* Terence Parr, Will Cohen, and Hank Dietz: 1989-1994
* Purdue University Electrical Engineering
* With AHPCRC, University of Minnesota
* ANTLR Version 1.23
*/

#include
#define ANTLR_VERSION 123

#ifdef __cplusplus
#ifndef __STDC__
#define __STDC__
#endif
#endif
#include "set.h"
#include
#include "syn.h"
#include "hash.h"
#include "generic.h"
#define zzcr_attr(attr,tok,t)
#include "antlr.h"
#include "tokens.h"
#include "dlgdef.h"
LOOKAHEAD
void zzerraction()
{
(*zzerr)("invalid token");
zzadvance();
zzskip();
}
/*
* D L G tables
*
* Generated from: parser.dlg
*
* 1989-1994 by Will Cohen, Terence Parr, and Hank Dietz
* Purdue University Electrical Engineering
* DLG Version 1.23
*/

#include "mode.h"




/* maintained, but not used for now */
set AST_nodes_refd_in_actions = set_init;
int inAlt = 0;
set attribsRefdFromAction;
int UsedOldStyleAttrib = 0;
int UsedNewStyleLabel = 0;

static void act1()
{
NLA = Eof;
/* L o o k F o r A n o t h e r F i l e */
{
FILE *new_input;
new_input = NextFile();
if ( new_input == NULL ) { NLA=Eof; return; }
fclose( input );
input = new_input;
zzrdstream( input );
zzskip(); /* Skip the Eof (@) char i.e continue */
}
}


static void act2()
{
NLA = 72;
zzskip();
}


static void act3()
{
NLA = 73;
zzline++; zzskip();
}


static void act4()
{
NLA = 74;
zzmode(ACTIONS); zzmore();
istackreset();
pushint(']');
}


static void act5()
{
NLA = 75;
action_file=CurFile; action_line=zzline;
zzmode(ACTIONS); zzmore();
istackreset();
pushint('>');
}


static void act6()
{
NLA = 76;
zzmode(STRINGS); zzmore();
}


static void act7()
{
NLA = 77;
zzmode(COMMENTS); zzskip();
}


static void act8()
{
NLA = 78;
warn("Missing /*; found dangling */"); zzskip();
}


static void act9()
{
NLA = 79;
zzmode(CPP_COMMENTS); zzskip();
}


static void act10()
{
NLA = 80;
warn("Missing <<; found dangling \>\>"); zzskip();
}


static void act11()
{
NLA = WildCard;
}


static void act12()
{
NLA = 85;
}


static void act13()
{
NLA = 86;
}


static void act14()
{
NLA = 87;
}


static void act15()
{
NLA = 88;
}


static void act16()
{
NLA = 89;
}


static void act17()
{
NLA = 92;
}


static void act18()
{
NLA = 93;
}


static void act19()
{
NLA = 94;
}


static void act20()
{
NLA = 95;
}


static void act21()
{
NLA = 96;
}


static void act22()
{
NLA = 97;
}


static void act23()
{
NLA = 98;
}


static void act24()
{
NLA = 99;
}


static void act25()
{
NLA = 100;
}


static void act26()
{
NLA = 101;
}


static void act27()
{
NLA = 102;
}


static void act28()
{
NLA = 103;
}


static void act29()
{
NLA = 104;
}


static void act30()
{
NLA = 105;
}


static void act31()
{
NLA = 106;
}


static void act32()
{
NLA = 107;
}


static void act33()
{
NLA = 108;
}


static void act34()
{
NLA = 109;
}


static void act35()
{
NLA = 110;
}


static void act36()
{
NLA = 111;
}


static void act37()
{
NLA = 112;
}


static void act38()
{
NLA = 113;
}


static void act39()
{
NLA = 114;
}


static void act40()
{
NLA = 115;
}


static void act41()
{
NLA = 116;
}


static void act42()
{
NLA = 117;
}


static void act43()
{
NLA = 118;
}


static void act44()
{
NLA = 119;
}


static void act45()
{
NLA = 120;
}


static void act46()
{
NLA = NonTerminal;

while ( zzchar==' ' || zzchar=='\t' ) {
zzadvance();
}
if ( zzchar == ':' && inAlt ) NLA = LABEL;
}


static void act47()
{
NLA = TokenTerm;

while ( zzchar==' ' || zzchar=='\t' ) {
zzadvance();
}
if ( zzchar == ':' && inAlt ) NLA = LABEL;
}


static void act48()
{
NLA = 121;
warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip();
}

static unsigned char shift0[257] = {
0, 50, 50, 50, 50, 50, 50, 50, 50, 50,
1, 2, 50, 50, 2, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 1, 26, 5, 10, 50, 50, 50,
50, 42, 43, 7, 44, 50, 50, 9, 6, 35,
33, 34, 35, 35, 35, 35, 35, 35, 35, 27,
28, 4, 32, 8, 45, 50, 48, 48, 48, 48,
48, 48, 48, 48, 48, 48, 48, 41, 48, 48,
48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
48, 48, 3, 50, 50, 38, 49, 50, 13, 47,
23, 14, 12, 21, 39, 11, 30, 47, 20, 24,
40, 31, 19, 16, 47, 15, 17, 18, 46, 47,
47, 29, 47, 47, 25, 36, 22, 37, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50
};


static void act49()
{
NLA = Eof;
}


static void act50()
{
NLA = QuotedTerm;
zzmode(START);
}


static void act51()
{
NLA = 3;

zzline++;
warn("eoln found in string");
zzskip();
}


static void act52()
{
NLA = 4;
zzline++; zzmore();
}


static void act53()
{
NLA = 5;
zzmore();
}


static void act54()
{
NLA = 6;
zzmore();
}

static unsigned char shift1[257] = {
0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 2, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 1, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 3, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4
};


static void act55()
{
NLA = Eof;
}


static void act56()
{
NLA = 7;
zzmode(ACTIONS); zzmore();
}


static void act57()
{
NLA = 8;

zzline++;
warn("eoln found in string (in user action)");
zzskip();
}


static void act58()
{
NLA = 9;
zzline++; zzmore();
}


static void act59()
{
NLA = 10;
zzmore();
}


static void act60()
{
NLA = 11;
zzmore();
}

static unsigned char shift2[257] = {
0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 2, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 1, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 3, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4
};


static void act61()
{
NLA = Eof;
}


static void act62()
{
NLA = 12;
zzmode(ACTIONS); zzmore();
}


static void act63()
{
NLA = 13;

zzline++;
warn("eoln found in char literal (in user action)");
zzskip();
}


static void act64()
{
NLA = 14;
zzmore();
}


static void act65()
{
NLA = 15;
zzmore();
}

static unsigned char shift3[257] = {
0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 2, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 3, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4
};


static void act66()
{
NLA = Eof;
}


static void act67()
{
NLA = 16;
zzmode(ACTIONS); zzmore();
}


static void act68()
{
NLA = 17;
zzmore();
}


static void act69()
{
NLA = 18;
zzline++; zzmore(); DAWDLE;
}


static void act70()
{
NLA = 19;
zzmore();
}

static unsigned char shift4[257] = {
0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 3, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 1, 4, 4, 4, 4, 2, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4
};


static void act71()
{
NLA = Eof;
}


static void act72()
{
NLA = 20;
zzmode(PARSE_ENUM_FILE); zzmore();
}


static void act73()
{
NLA = 21;
zzmore();
}


static void act74()
{
NLA = 22;
zzline++; zzmore(); DAWDLE;
}


static void act75()
{
NLA = 23;
zzmore();
}

static unsigned char shift5[257] = {
0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 3, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 1, 4, 4, 4, 4, 2, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4
};


static void act76()
{
NLA = Eof;
}


static void act77()
{
NLA = 24;
zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE;
}


static void act78()
{
NLA = 25;
zzskip();
}

static unsigned char shift6[257] = {
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 1, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2
};


static void act79()
{
NLA = Eof;
}


static void act80()
{
NLA = 26;
zzline++; zzmode(ACTIONS); zzmore(); DAWDLE;
}


static void act81()
{
NLA = 27;
zzmore();
}

static unsigned char shift7[257] = {
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 1, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2
};


static void act82()
{
NLA = Eof;
}


static void act83()
{
NLA = 28;
zzline++; zzmode(START); zzskip(); DAWDLE;
}


static void act84()
{
NLA = 29;
zzskip();
}

static unsigned char shift8[257] = {
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 1, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2
};


static void act85()
{
NLA = Eof;
}


static void act86()
{
NLA = 30;
zzmode(START); zzskip();
}


static void act87()
{
NLA = 31;
zzskip();
}


static void act88()
{
NLA = 32;
zzline++; zzskip(); DAWDLE;
}


static void act89()
{
NLA = 33;
zzskip();
}

static unsigned char shift9[257] = {
0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 3, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 1, 4, 4, 4, 4, 2, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4
};


static void act90()
{
NLA = Eof;
}


static void act91()
{
NLA = Action;
/* these do not nest */
zzmode(START);
NLATEXT[0] = ' ';
NLATEXT[1] = ' ';
zzbegexpr[0] = ' ';
zzbegexpr[1] = ' ';
if ( zzbufovf ) {
err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));
}
}


static void act92()
{
NLA = Pred;
/* these do not nest */
zzmode(START);
NLATEXT[0] = ' ';
NLATEXT[1] = ' ';
zzbegexpr[0] = '\0';
if ( zzbufovf ) {
err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));
}
}


static void act93()
{
NLA = PassAction;
if ( topint() == ']' ) {
popint();
if ( istackempty() ) /* terminate action */
{
zzmode(START);
NLATEXT[0] = ' ';
zzbegexpr[0] = ' ';
if ( zzbufovf ) {
err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));
}
}
else {
/* terminate $[..] and #[..] */
if ( GenCC ) zzreplstr("))");
else zzreplstr(")");
zzmore();
}
}
else if ( topint() == '|' ) { /* end of simple [...] */
popint();
zzmore();
}
else zzmore();
}


static void act94()
{
NLA = 37;
zzline++; zzmore(); DAWDLE;
}


static void act95()
{
NLA = 38;
zzmore();
}


static void act96()
{
NLA = 39;
zzmore();
}


static void act97()
{
NLA = 40;
if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}
else err("$$ use invalid in C++ mode");
}


static void act98()
{
NLA = 41;
if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}
else err("$[] use invalid in C++ mode");
}


static void act99()
{
NLA = 42;

pushint(']');
if ( !GenCC ) zzreplstr("zzconstr_attr(");
else err("$[..] use invalid in C++ mode");
zzmore();
}


static void act100()
{
NLA = 43;
{
static char buf[100];
if ( strlen(zzbegexpr)>85 )
fatal("$i attrib ref too big");
set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",
BlkLevel-1,zzbegexpr+1);
else sprintf(buf,"_t%d%s",
BlkLevel-1,zzbegexpr+1);
zzreplstr(buf);
zzmore();
UsedOldStyleAttrib = 1;
if ( UsedNewStyleLabel )
err("cannot mix old-style $i with new-style labels");
}
}


static void act101()
{
NLA = 44;
{
static char buf[100];
if ( strlen(zzbegexpr)>85 )
fatal("$i.field attrib ref too big");
zzbegexpr[strlen(zzbegexpr)-1] = ' ';
set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",
BlkLevel-1,zzbegexpr+1);
else sprintf(buf,"_t%d%s.",
BlkLevel-1,zzbegexpr+1);
zzreplstr(buf);
zzmore();
UsedOldStyleAttrib = 1;
if ( UsedNewStyleLabel )
err("cannot mix old-style $i with new-style labels");
}
}


static void act102()
{
NLA = 45;
{
static char buf[100];
static char i[20], j[20];
char *p,*q;
if (strlen(zzbegexpr)>85) fatal("$i.j attrib ref too big");
for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {
if ( q == &i[20] ) fatalFL("i of $i.j attrib ref too big", FileStr[CurFile], zzline );
*q++ = *p;
}
*q = '\0';
for (p++, q= &j[0]; *p!='\0'; p++) {
if ( q == &j[20] ) fatalFL("j of $i.j attrib ref too big", FileStr[CurFile], zzline );
*q++ = *p;
}
*q = '\0';
if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);
else sprintf(buf,"_t%s%s",i,j);
zzreplstr(buf);
zzmore();
UsedOldStyleAttrib = 1;
if ( UsedNewStyleLabel )
err("cannot mix old-style $i with new-style labels");
}
}


static void act103()
{
NLA = 46;
{ static char buf[300];
zzbegexpr[0] = ' ';
if ( CurRule != NULL &&
strcmp(CurRule, &zzbegexpr[1])==0 ) {
if ( !GenCC ) zzreplstr("zzaRet");
}
else if ( CurRetDef != NULL ) {
if ( strmember(CurRetDef, &zzbegexpr[1]) ) {
if ( HasComma( CurRetDef ) ) {
require (strlen(zzbegexpr)<=285,
"$retval attrib ref too big");
sprintf(buf,"_retv.%s",&zzbegexpr[1]);
zzreplstr(buf);
}
else zzreplstr("_retv");
}
else if ( CurParmDef != NULL ) {
if ( !strmember(CurParmDef, &zzbegexpr[1]) )
warn(eMsg1("$%s not parameter or return value",&zzbegexpr[1]));
}
else warn(eMsg1("$%s not parameter or return value",&zzbegexpr[1]));
}
}
zzmore();
}


static void act104()
{
NLA = 47;
zzreplstr("(*_root)"); zzmore();
}


static void act105()
{
NLA = 48;
if ( GenCC ) zzreplstr("(new AST)");
zzreplstr("zzastnew()"); zzmore();
}


static void act106()
{
NLA = 49;
zzreplstr("NULL"); zzmore();
}


static void act107()
{
NLA = 50;
{
static char buf[100];
if ( strlen(zzbegexpr)>85 )
fatal("#i AST ref too big");
if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);
else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);
zzreplstr(buf);
zzmore();
set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);
}
}


static void act108()
{
NLA = 51;

if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||
strcmp(zzbegexpr, "#else")==0 ||
strcmp(zzbegexpr, "#endif")==0 ||
strcmp(zzbegexpr, "#ifndef")==0 ||
strcmp(zzbegexpr, "#define")==0 ||
strcmp(zzbegexpr, "#pragma")==0 ||
strcmp(zzbegexpr, "#undef")==0 ||
strcmp(zzbegexpr, "#line")==0 ||
strcmp(zzbegexpr, "#include")==0 ||
strcmp(zzbegexpr, "#error")==0) )
{
static char buf[100];
sprintf(buf, "%s_ast", zzbegexpr+1);
zzreplstr(buf);
}
zzmore();
}


static void act109()
{
NLA = 52;

pushint(']');
if ( GenCC ) zzreplstr("(new AST(");
else zzreplstr("zzmk_ast(zzastnew(),");
zzmore();
}


static void act110()
{
NLA = 53;

pushint('}');
if ( GenCC ) zzreplstr("ASTBase::tmake(");
else zzreplstr("zztmake(");
zzmore();
}


static void act111()
{
NLA = 54;
zzmore();
}


static void act112()
{
NLA = 55;

if ( istackempty() )
zzmore();
else if ( topint()==')' ) {
popint();
}
else if ( topint()=='}' ) {
popint();
/* terminate #(..) */
zzreplstr(", NULL)");
}
zzmore();
}


static void act113()
{
NLA = 56;

pushint('|'); /* look for '|' to terminate simple [...] */
zzmore();
}


static void act114()
{
NLA = 57;

pushint(')');
zzmore();
}


static void act115()
{
NLA = 58;
zzreplstr("]"); zzmore();
}


static void act116()
{
NLA = 59;
zzreplstr(")"); zzmore();
}


static void act117()
{
NLA = 60;
zzreplstr(">"); zzmore();
}


static void act118()
{
NLA = 61;
zzmode(ACTION_CHARS); zzmore();
}


static void act119()
{
NLA = 62;
zzmode(ACTION_STRINGS); zzmore();
}


static void act120()
{
NLA = 63;
zzreplstr("$"); zzmore();
}


static void act121()
{
NLA = 64;
zzreplstr("#"); zzmore();
}


static void act122()
{
NLA = 65;
zzline++; zzmore();
}


static void act123()
{
NLA = 66;
zzmore();
}


static void act124()
{
NLA = 67;
zzmore();
}


static void act125()
{
NLA = 68;
zzmode(ACTION_COMMENTS); zzmore();
}


static void act126()
{
NLA = 69;
warn("Missing /*; found dangling */ in action"); zzmore();
}


static void act127()
{
NLA = 70;
zzmode(ACTION_CPP_COMMENTS); zzmore();
}


static void act128()
{
NLA = 71;
zzmore();
}

static unsigned char shift10[257] = {
0, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 4, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 16, 11, 5, 19, 19,
15, 12, 13, 18, 19, 19, 19, 9, 17, 7,
8, 8, 8, 8, 8, 8, 8, 8, 8, 19,
19, 19, 19, 1, 2, 19, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 6, 14, 3, 19, 10, 19, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19
};


static void act129()
{
NLA = Eof;
;
}


static void act130()
{
NLA = 122;
zzskip();
}


static void act131()
{
NLA = 123;
zzline++; zzskip();
}


static void act132()
{
NLA = 124;
zzmode(TOK_DEF_CPP_COMMENTS); zzmore();
}


static void act133()
{
NLA = 125;
zzmode(TOK_DEF_COMMENTS); zzskip();
}


static void act134()
{
NLA = 126;
zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
}


static void act135()
{
NLA = 127;
zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
}


static void act136()
{
NLA = 128;
zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
}


static void act137()
{
NLA = 129;
zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
}


static void act138()
{
NLA = 130;
}


static void act139()
{
NLA = 133;
}


static void act140()
{
NLA = 134;
}


static void act141()
{
NLA = 135;
}


static void act142()
{
NLA = 136;
}


static void act143()
{
NLA = 137;
}


static void act144()
{
NLA = 138;
}


static void act145()
{
NLA = INT;
}


static void act146()
{
NLA = ID;
}

static unsigned char shift11[257] = {
0, 23, 23, 23, 23, 23, 23, 23, 23, 23,
1, 2, 23, 23, 2, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 1, 23, 23, 5, 23, 23, 23,
23, 23, 23, 4, 23, 17, 23, 23, 3, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 23,
19, 23, 16, 23, 23, 23, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 23, 23, 23, 23, 22, 23, 22, 22,
22, 8, 9, 7, 22, 22, 6, 22, 22, 11,
14, 10, 22, 22, 22, 22, 12, 22, 13, 22,
22, 22, 22, 22, 15, 23, 18, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23
};

#define DfaStates 265
typedef unsigned short DfaState;

static DfaState st0[51] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 12, 12, 12, 12, 12,
12, 12, 16, 17, 12, 18, 19, 20, 21, 12,
12, 12, 22, 23, 23, 23, 24, 25, 26, 12,
12, 27, 28, 29, 30, 31, 12, 12, 32, 265,
265
};

static DfaState st1[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st2[51] = {
265, 2, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st3[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st4[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st5[51] = {
265, 265, 265, 265, 33, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st6[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st7[51] = {
265, 265, 265, 265, 265, 265, 34, 35, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st8[51] = {
265, 265, 265, 265, 265, 265, 36, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st9[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 37, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st10[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 38,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st11[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 39, 40, 41, 41, 41, 42, 41, 43, 41,
41, 41, 265, 41, 44, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st12[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st13[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 46,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st14[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 47, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st15[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 48, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st16[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st17[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 49, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 50, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st18[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st19[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st20[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st21[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st22[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st23[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 23, 23, 23, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st24[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st25[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st26[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st27[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 265, 51, 51, 265, 265, 265, 265, 51,
51, 51, 265, 51, 51, 51, 265, 265, 265, 51,
51, 52, 265, 265, 265, 265, 51, 51, 51, 51,
265
};

static DfaState st28[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st29[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st30[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st31[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st32[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 265, 51, 51, 265, 265, 265, 265, 51,
51, 51, 265, 51, 51, 51, 265, 265, 265, 51,
51, 51, 265, 265, 265, 265, 51, 51, 51, 51,
265
};

static DfaState st33[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st34[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st35[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st36[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st37[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st38[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st39[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 53, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st40[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 54, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st41[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st42[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 55, 41, 56, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st43[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 57,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st44[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 58, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st45[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st46[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 59, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st47[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 60, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st48[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 61, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st49[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 62, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st50[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 63, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st51[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 265, 51, 51, 265, 265, 265, 265, 51,
51, 51, 265, 51, 51, 51, 265, 265, 265, 51,
51, 51, 265, 265, 265, 265, 51, 51, 51, 51,
265
};

static DfaState st52[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 265, 51, 51, 265, 265, 265, 265, 51,
51, 51, 265, 64, 65, 51, 265, 265, 265, 51,
51, 51, 265, 265, 265, 265, 51, 51, 51, 51,
265
};

static DfaState st53[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 66, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st54[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 67, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st55[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 68, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st56[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 69, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st57[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
70, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st58[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 71,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st59[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 72, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st60[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 73, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st61[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 74, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st62[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 75, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st63[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 76, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st64[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 265, 51, 51, 265, 265, 265, 265, 51,
51, 51, 265, 51, 51, 51, 265, 265, 265, 51,
51, 51, 265, 265, 265, 265, 51, 51, 51, 51,
265
};

static DfaState st65[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 265, 51, 51, 265, 265, 265, 265, 51,
51, 51, 265, 51, 51, 51, 265, 265, 265, 51,
51, 51, 265, 265, 265, 265, 51, 51, 51, 51,
265
};

static DfaState st66[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 77, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st67[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 78, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st68[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 79, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st69[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 80,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st70[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 81, 41, 82, 41, 41, 41, 41, 41,
41, 41, 265, 83, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st71[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 84, 41, 41, 41, 41, 41, 41,
41, 41, 265, 85, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st72[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 86, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st73[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 87,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st74[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 88, 45, 45, 45,
265
};

static DfaState st75[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 89, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st76[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 90, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st77[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 91, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st78[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 92, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st79[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 93, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st80[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
94, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st81[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 95, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st82[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 96, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st83[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 97, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st84[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 98, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st85[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 99, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st86[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 100, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st87[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 101,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st88[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 102, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st89[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st90[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st91[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 103, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st92[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 104, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st93[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 105, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st94[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 106, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st95[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st96[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 107, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st97[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 108, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st98[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 109, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st99[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 110, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st100[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
111, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st101[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st102[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 112, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st103[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st104[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 113, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st105[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st106[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st107[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 114, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st108[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 115, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st109[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
116, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st110[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 117, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st111[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 118,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st112[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st113[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 119, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st114[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st115[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 120, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st116[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 121,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st117[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 122, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st118[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 123, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st119[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st120[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st121[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 124, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st122[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st123[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 265, 45, 45, 265, 265, 265, 265, 45,
45, 45, 265, 45, 45, 45, 265, 265, 265, 45,
45, 45, 265, 265, 265, 265, 45, 45, 45, 45,
265
};

static DfaState st124[51] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 265, 41, 41, 265, 265, 265, 265, 41,
41, 41, 265, 41, 41, 41, 265, 265, 265, 41,
41, 41, 265, 265, 265, 265, 41, 41, 41, 41,
265
};

static DfaState st125[6] = {
126, 127, 128, 129, 130, 265
};

static DfaState st126[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st127[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st128[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st129[6] = {
265, 131, 132, 131, 131, 265
};

static DfaState st130[6] = {
265, 265, 265, 265, 130, 265
};

static DfaState st131[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st132[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st133[6] = {
134, 135, 136, 137, 138, 265
};

static DfaState st134[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st135[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st136[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st137[6] = {
265, 139, 140, 139, 139, 265
};

static DfaState st138[6] = {
265, 265, 265, 265, 138, 265
};

static DfaState st139[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st140[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st141[6] = {
142, 143, 144, 145, 146, 265
};

static DfaState st142[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st143[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st144[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st145[6] = {
265, 147, 147, 147, 147, 265
};

static DfaState st146[6] = {
265, 265, 265, 265, 146, 265
};

static DfaState st147[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st148[6] = {
149, 150, 151, 152, 151, 265
};

static DfaState st149[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st150[6] = {
265, 265, 153, 265, 265, 265
};

static DfaState st151[6] = {
265, 265, 151, 265, 151, 265
};

static DfaState st152[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st153[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st154[6] = {
155, 156, 157, 158, 157, 265
};

static DfaState st155[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st156[6] = {
265, 265, 159, 265, 265, 265
};

static DfaState st157[6] = {
265, 265, 157, 265, 157, 265
};

static DfaState st158[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st159[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st160[4] = {
161, 162, 163, 265
};

static DfaState st161[4] = {
265, 265, 265, 265
};

static DfaState st162[4] = {
265, 265, 265, 265
};

static DfaState st163[4] = {
265, 265, 163, 265
};

static DfaState st164[4] = {
165, 166, 167, 265
};

static DfaState st165[4] = {
265, 265, 265, 265
};

static DfaState st166[4] = {
265, 265, 265, 265
};

static DfaState st167[4] = {
265, 265, 167, 265
};

static DfaState st168[4] = {
169, 170, 171, 265
};

static DfaState st169[4] = {
265, 265, 265, 265
};

static DfaState st170[4] = {
265, 265, 265, 265
};

static DfaState st171[4] = {
265, 265, 171, 265
};

static DfaState st172[6] = {
173, 174, 175, 176, 175, 265
};

static DfaState st173[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st174[6] = {
265, 265, 177, 265, 265, 265
};

static DfaState st175[6] = {
265, 265, 175, 265, 175, 265
};

static DfaState st176[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st177[6] = {
265, 265, 265, 265, 265, 265
};

static DfaState st178[21] = {
179, 180, 181, 182, 183, 184, 185, 181, 181, 181,
181, 186, 187, 188, 189, 190, 191, 192, 193, 181,
265
};

static DfaState st179[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st180[21] = {
265, 194, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st181[21] = {
265, 265, 181, 265, 265, 265, 265, 181, 181, 181,
181, 265, 265, 265, 265, 265, 265, 265, 181, 181,
265
};

static DfaState st182[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st183[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st184[21] = {
265, 265, 265, 265, 265, 195, 196, 197, 197, 265,
198, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st185[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st186[21] = {
265, 265, 265, 265, 265, 265, 199, 200, 201, 265,
202, 265, 203, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st187[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st188[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st189[21] = {
265, 204, 205, 206, 207, 208, 205, 205, 205, 205,
205, 209, 205, 210, 205, 205, 205, 205, 205, 205,
265
};

static DfaState st190[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st191[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st192[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 211, 212, 265,
265
};

static DfaState st193[21] = {
265, 265, 181, 265, 265, 265, 265, 181, 181, 181,
181, 265, 265, 265, 265, 265, 265, 213, 181, 181,
265
};

static DfaState st194[21] = {
265, 265, 214, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st195[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st196[21] = {
265, 265, 265, 215, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st197[21] = {
265, 265, 265, 265, 265, 265, 265, 197, 197, 216,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st198[21] = {
265, 265, 265, 265, 265, 265, 265, 217, 217, 265,
217, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st199[21] = {
265, 265, 265, 218, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st200[21] = {
265, 265, 265, 265, 265, 265, 265, 201, 201, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st201[21] = {
265, 265, 265, 265, 265, 265, 265, 201, 201, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st202[21] = {
265, 265, 265, 265, 265, 265, 265, 219, 219, 265,
219, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st203[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 220, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st204[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st205[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st206[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st207[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st208[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st209[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st210[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st211[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st212[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st213[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st214[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st215[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st216[21] = {
265, 265, 265, 265, 265, 265, 265, 221, 221, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st217[21] = {
265, 265, 265, 265, 265, 265, 265, 217, 217, 265,
217, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st218[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st219[21] = {
265, 265, 265, 265, 265, 265, 265, 219, 219, 265,
219, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st220[21] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st221[21] = {
265, 265, 265, 265, 265, 265, 265, 221, 221, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265
};

static DfaState st222[24] = {
223, 224, 225, 226, 265, 227, 265, 265, 265, 228,
265, 265, 265, 265, 265, 229, 230, 231, 232, 233,
234, 235, 265, 265
};

static DfaState st223[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st224[24] = {
265, 224, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st225[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st226[24] = {
265, 265, 265, 236, 237, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st227[24] = {
265, 265, 265, 265, 265, 265, 238, 265, 239, 240,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st228[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
241, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st229[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st230[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st231[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st232[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st233[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st234[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
234, 265, 265, 265
};

static DfaState st235[24] = {
265, 265, 265, 265, 265, 265, 242, 242, 242, 242,
242, 242, 242, 242, 242, 265, 265, 265, 265, 265,
242, 242, 242, 265
};

static DfaState st236[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st237[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st238[24] = {
265, 265, 265, 265, 265, 265, 265, 243, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st239[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 244,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st240[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
245, 246, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st241[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 247, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st242[24] = {
265, 265, 265, 265, 265, 265, 242, 242, 242, 242,
242, 242, 242, 242, 242, 265, 265, 265, 265, 265,
242, 242, 242, 265
};

static DfaState st243[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 248, 265,
249, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st244[24] = {
265, 265, 265, 265, 265, 265, 265, 250, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st245[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 251, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st246[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 252, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st247[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 253, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st248[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 254,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st249[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 255, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st250[24] = {
265, 265, 265, 265, 265, 265, 256, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st251[24] = {
265, 265, 265, 265, 265, 265, 257, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st252[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 258,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st253[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st254[24] = {
265, 265, 265, 265, 265, 265, 265, 259, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st255[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 260,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st256[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
261, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st257[24] = {
265, 265, 265, 265, 265, 265, 265, 262, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st258[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st259[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st260[24] = {
265, 265, 265, 265, 265, 265, 265, 263, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st261[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 264,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st262[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st263[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st264[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};


DfaState *dfa[265] = {
st0,
st1,
st2,
st3,
st4,
st5,
st6,
st7,
st8,
st9,
st10,
st11,
st12,
st13,
st14,
st15,
st16,
st17,
st18,
st19,
st20,
st21,
st22,
st23,
st24,
st25,
st26,
st27,
st28,
st29,
st30,
st31,
st32,
st33,
st34,
st35,
st36,
st37,
st38,
st39,
st40,
st41,
st42,
st43,
st44,
st45,
st46,
st47,
st48,
st49,
st50,
st51,
st52,
st53,
st54,
st55,
st56,
st57,
st58,
st59,
st60,
st61,
st62,
st63,
st64,
st65,
st66,
st67,
st68,
st69,
st70,
st71,
st72,
st73,
st74,
st75,
st76,
st77,
st78,
st79,
st80,
st81,
st82,
st83,
st84,
st85,
st86,
st87,
st88,
st89,
st90,
st91,
st92,
st93,
st94,
st95,
st96,
st97,
st98,
st99,
st100,
st101,
st102,
st103,
st104,
st105,
st106,
st107,
st108,
st109,
st110,
st111,
st112,
st113,
st114,
st115,
st116,
st117,
st118,
st119,
st120,
st121,
st122,
st123,
st124,
st125,
st126,
st127,
st128,
st129,
st130,
st131,
st132,
st133,
st134,
st135,
st136,
st137,
st138,
st139,
st140,
st141,
st142,
st143,
st144,
st145,
st146,
st147,
st148,
st149,
st150,
st151,
st152,
st153,
st154,
st155,
st156,
st157,
st158,
st159,
st160,
st161,
st162,
st163,
st164,
st165,
st166,
st167,
st168,
st169,
st170,
st171,
st172,
st173,
st174,
st175,
st176,
st177,
st178,
st179,
st180,
st181,
st182,
st183,
st184,
st185,
st186,
st187,
st188,
st189,
st190,
st191,
st192,
st193,
st194,
st195,
st196,
st197,
st198,
st199,
st200,
st201,
st202,
st203,
st204,
st205,
st206,
st207,
st208,
st209,
st210,
st211,
st212,
st213,
st214,
st215,
st216,
st217,
st218,
st219,
st220,
st221,
st222,
st223,
st224,
st225,
st226,
st227,
st228,
st229,
st230,
st231,
st232,
st233,
st234,
st235,
st236,
st237,
st238,
st239,
st240,
st241,
st242,
st243,
st244,
st245,
st246,
st247,
st248,
st249,
st250,
st251,
st252,
st253,
st254,
st255,
st256,
st257,
st258,
st259,
st260,
st261,
st262,
st263,
st264
};


DfaState accepts[266] = {
0, 1, 2, 3, 4, 19, 6, 0, 40, 20,
11, 48, 46, 46, 46, 46, 15, 46, 17, 18,
21, 22, 28, 29, 30, 31, 33, 47, 38, 39,
41, 42, 47, 5, 9, 7, 8, 10, 32, 48,
48, 48, 48, 48, 48, 46, 46, 46, 46, 46,
46, 47, 47, 48, 48, 48, 48, 48, 48, 46,
46, 46, 46, 46, 36, 37, 48, 48, 48, 48,
48, 48, 46, 46, 46, 46, 46, 48, 48, 48,
48, 48, 48, 48, 48, 48, 46, 46, 46, 45,
16, 48, 48, 48, 48, 27, 48, 48, 48, 48,
46, 35, 46, 12, 48, 13, 34, 48, 48, 48,
48, 46, 44, 48, 14, 48, 48, 48, 46, 25,
26, 48, 24, 43, 23, 0, 49, 50, 51, 0,
54, 53, 52, 0, 55, 56, 57, 0, 60, 59,
58, 0, 61, 62, 63, 0, 65, 64, 0, 66,
68, 70, 69, 67, 0, 71, 73, 75, 74, 72,
0, 76, 77, 78, 0, 79, 80, 81, 0, 82,
83, 84, 0, 85, 87, 89, 88, 86, 0, 90,
95, 128, 93, 94, 96, 113, 111, 114, 112, 0,
118, 119, 124, 128, 91, 97, 99, 100, 103, 109,
104, 107, 108, 110, 117, 123, 115, 122, 120, 121,
116, 127, 125, 126, 92, 98, 101, 103, 105, 108,
106, 102, 0, 129, 130, 131, 0, 0, 0, 140,
141, 142, 143, 144, 145, 146, 132, 133, 0, 0,
0, 0, 146, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 139, 0, 0, 0, 0, 136, 134,
0, 0, 137, 135, 138, 0
};

void (*actions[147])() = {
zzerraction,
act1,
act2,
act3,
act4,
act5,
act6,
act7,
act8,
act9,
act10,
act11,
act12,
act13,
act14,
act15,
act16,
act17,
act18,
act19,
act20,
act21,
act22,
act23,
act24,
act25,
act26,
act27,
act28,
act29,
act30,
act31,
act32,
act33,
act34,
act35,
act36,
act37,
act38,
act39,
act40,
act41,
act42,
act43,
act44,
act45,
act46,
act47,
act48,
act49,
act50,
act51,
act52,
act53,
act54,
act55,
act56,
act57,
act58,
act59,
act60,
act61,
act62,
act63,
act64,
act65,
act66,
act67,
act68,
act69,
act70,
act71,
act72,
act73,
act74,
act75,
act76,
act77,
act78,
act79,
act80,
act81,
act82,
act83,
act84,
act85,
act86,
act87,
act88,
act89,
act90,
act91,
act92,
act93,
act94,
act95,
act96,
act97,
act98,
act99,
act100,
act101,
act102,
act103,
act104,
act105,
act106,
act107,
act108,
act109,
act110,
act111,
act112,
act113,
act114,
act115,
act116,
act117,
act118,
act119,
act120,
act121,
act122,
act123,
act124,
act125,
act126,
act127,
act128,
act129,
act130,
act131,
act132,
act133,
act134,
act135,
act136,
act137,
act138,
act139,
act140,
act141,
act142,
act143,
act144,
act145,
act146
};

static DfaState dfa_base[] = {
0,
125,
133,
141,
148,
154,
160,
164,
168,
172,
178,
222
};

static unsigned char *b_class_no[] = {
shift0,
shift1,
shift2,
shift3,
shift4,
shift5,
shift6,
shift7,
shift8,
shift9,
shift10,
shift11
};



#define ZZSHIFT(c) (b_class_no[zzauto][1+c])
#define MAX_MODE 12
#include "dlgauto.h"

};

static DfaState st244[24] = {
265, 265, 265, 265, 265, 265, 265, 250, 265, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265, 265
};

static DfaState st245[24] = {
265, 265, 265, 265, 265, 265, 265, 265, 251, 265,
265, 265, 265, 265, 265, 265, 265, 265, 265, 265,
265, 265, 265pccts/antlr/err.c 644 1377 31 17644 5655551700 7367 /*
* A n t l r S e t s / E r