More renames for Tool Packages
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1675 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
233
Tools/CodeTools/Source/Pccts/antlr/AntlrMS.mak
Normal file
233
Tools/CodeTools/Source/Pccts/antlr/AntlrMS.mak
Normal file
@@ -0,0 +1,233 @@
|
||||
# PCCTS directory
|
||||
|
||||
# You will need to set the LIB variable similar to this.
|
||||
# LIB="C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/lib;c:/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Lib"
|
||||
|
||||
# PCCTS_HOME=<your PCCTS_HOME>
|
||||
PCCTS_HOME=$(WORKSPACE)\Tools\Source\TianoTools\Pccts
|
||||
ANTLR_SRC=$(PCCTS_HOME)\antlr
|
||||
PCCTS_H=$(PCCTS_HOME)\h
|
||||
|
||||
|
||||
# Support directories
|
||||
SET=$(PCCTS_HOME)\support\set
|
||||
|
||||
|
||||
# Compiler stuff
|
||||
CC = cl
|
||||
CFLAGS = /nologo -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \
|
||||
-D "ZZLEXBUFSIZE=65536" /D "LONGFILENAMES" /Zi /W3 -D__USE_PROTOS /wd4700
|
||||
|
||||
ANTLR_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 egman.obj mrhoist.obj fcache.obj
|
||||
|
||||
SUPPORT_OBJS = set.obj
|
||||
|
||||
# Dependencies
|
||||
|
||||
$(WORKSPACE)\Tools\bin\antlr.exe: $(ANTLR_OBJS) $(SUPPORT_OBJS)
|
||||
$(CC) $(CFLAGS) -o antlr.exe $(ANTLR_OBJS) $(SUPPORT_OBJS)
|
||||
del *.obj
|
||||
move antlr.exe $(WORKSPACE)\Tools\bin
|
||||
|
||||
|
||||
antlr.obj: $(ANTLR_SRC)\antlr.c \
|
||||
$(PCCTS_H)\antlr.h \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\mode.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
$(ANTLR_SRC)\tokens.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\antlr.c
|
||||
|
||||
scan.obj: $(ANTLR_SRC)\scan.c \
|
||||
$(PCCTS_H)\antlr.h \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgauto.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\mode.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
$(ANTLR_SRC)\tokens.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\scan.c
|
||||
|
||||
err.obj: $(ANTLR_SRC)\err.c \
|
||||
$(PCCTS_H)\antlr.h \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(PCCTS_H)\err.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
$(ANTLR_SRC)\tokens.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\err.c
|
||||
|
||||
bits.obj: $(ANTLR_SRC)\bits.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\bits.c
|
||||
|
||||
build.obj: $(ANTLR_SRC)\build.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\build.c
|
||||
|
||||
fset2.obj: $(ANTLR_SRC)\fset2.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\fset2.c
|
||||
|
||||
fset.obj: $(ANTLR_SRC)\fset.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\fset.c
|
||||
|
||||
gen.obj: $(ANTLR_SRC)\gen.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\gen.c
|
||||
|
||||
globals.obj: $(ANTLR_SRC)\globals.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\globals.c
|
||||
|
||||
hash.obj: $(ANTLR_SRC)\hash.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\hash.c
|
||||
|
||||
lex.obj: $(ANTLR_SRC)\lex.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\lex.c
|
||||
|
||||
main.obj: $(ANTLR_SRC)\main.c \
|
||||
$(PCCTS_H)\antlr.h \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\mode.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\stdpccts.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
$(ANTLR_SRC)\tokens.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\main.c
|
||||
|
||||
misc.obj: $(ANTLR_SRC)\misc.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\misc.c
|
||||
|
||||
pred.obj: $(ANTLR_SRC)\pred.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(PCCTS_H)\dlgdef.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\pred.c
|
||||
|
||||
egman.obj: $(ANTLR_SRC)\egman.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(SET)\set.h \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\egman.c
|
||||
|
||||
mrhoist.obj: $(ANTLR_SRC)\mrhoist.c \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\mrhoist.c
|
||||
|
||||
fcache.obj: $(ANTLR_SRC)\fcache.c \
|
||||
$(ANTLR_SRC)\generic.h \
|
||||
$(ANTLR_SRC)\hash.h \
|
||||
$(ANTLR_SRC)\proto.h \
|
||||
$(ANTLR_SRC)\syn.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(ANTLR_SRC)\fcache.c
|
||||
|
||||
set.obj: $(SET)\set.c \
|
||||
$(PCCTS_H)\config.h \
|
||||
$(SET)\set.h \
|
||||
|
||||
$(CC) -c $(CFLAGS) $(SET)\set.c
|
||||
|
||||
clean:
|
||||
del *.obj
|
||||
|
||||
distclean:
|
||||
del *.obj
|
||||
del $(WORKSPACE)\Tools\bin\antlr.exe
|
101
Tools/CodeTools/Source/Pccts/antlr/AntlrPPC.mak
Normal file
101
Tools/CodeTools/Source/Pccts/antlr/AntlrPPC.mak
Normal file
@@ -0,0 +1,101 @@
|
||||
# Target: antlrPPC
|
||||
# Sources: ::support:set:set.c
|
||||
# antlr.c
|
||||
# bits.c
|
||||
# build.c
|
||||
# egman.c
|
||||
# err.c
|
||||
# fcache.c
|
||||
# fset2.c
|
||||
# fset.c
|
||||
# gen.c
|
||||
# globals.c
|
||||
# hash.c
|
||||
# lex.c
|
||||
# main.c
|
||||
# misc.c
|
||||
# mrhoist.c
|
||||
# pred.c
|
||||
# scan.c
|
||||
# Created: Sunday, May 17, 1998 10:24:53 PM
|
||||
# Author: Kenji Tanaka
|
||||
MAKEFILE = antlrPPC.make
|
||||
<EFBFBD>MondoBuild<EFBFBD> = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified
|
||||
Includes = <20>
|
||||
-i "::h:" <20>
|
||||
-i "::support:set:"
|
||||
Sym<EFBFBD>PPC =
|
||||
ObjDir<EFBFBD>PPC = :Obj:
|
||||
PPCCOptions = {Includes} {Sym<EFBFBD>PPC} -w off -d MPW -d __STDC__=1 -d USER_ZZSYN
|
||||
Objects<EFBFBD>PPC = <20>
|
||||
"{ObjDir<69>PPC}set.c.x" <20>
|
||||
"{ObjDir<69>PPC}antlr.c.x" <20>
|
||||
"{ObjDir<69>PPC}bits.c.x" <20>
|
||||
"{ObjDir<69>PPC}build.c.x" <20>
|
||||
"{ObjDir<69>PPC}egman.c.x" <20>
|
||||
"{ObjDir<69>PPC}err.c.x" <20>
|
||||
"{ObjDir<69>PPC}fcache.c.x" <20>
|
||||
"{ObjDir<69>PPC}fset2.c.x" <20>
|
||||
"{ObjDir<69>PPC}fset.c.x" <20>
|
||||
"{ObjDir<69>PPC}gen.c.x" <20>
|
||||
"{ObjDir<69>PPC}globals.c.x" <20>
|
||||
"{ObjDir<69>PPC}hash.c.x" <20>
|
||||
"{ObjDir<69>PPC}lex.c.x" <20>
|
||||
"{ObjDir<69>PPC}main.c.x" <20>
|
||||
"{ObjDir<69>PPC}misc.c.x" <20>
|
||||
"{ObjDir<69>PPC}mrhoist.c.x" <20>
|
||||
"{ObjDir<69>PPC}pred.c.x" <20>
|
||||
"{ObjDir<69>PPC}scan.c.x"
|
||||
antlrPPC <EFBFBD><EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} {Objects<EFBFBD>PPC}
|
||||
PPCLink <EFBFBD>
|
||||
-o {Targ} {Sym<EFBFBD>PPC} <EFBFBD>
|
||||
{Objects<EFBFBD>PPC} <EFBFBD>
|
||||
-t 'MPST' <EFBFBD>
|
||||
-c 'MPS ' <EFBFBD>
|
||||
"{SharedLibraries}InterfaceLib" <EFBFBD>
|
||||
"{SharedLibraries}StdCLib" <EFBFBD>
|
||||
#"{SharedLibraries}MathLib" <20>
|
||||
"{PPCLibraries}StdCRuntime.o" <20>
|
||||
"{PPCLibraries}PPCCRuntime.o" <20>
|
||||
"{PPCLibraries}PPCToolLibs.o"
|
||||
"{ObjDir<69>PPC}set.c.x" <EFBFBD> {<7B>MondoBuild<6C>} "::support:set:set.c"
|
||||
{PPCC} "::support:set:set.c" -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}antlr.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} antlr.c
|
||||
{PPCC} antlr.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}bits.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} bits.c
|
||||
{PPCC} bits.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}build.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} build.c
|
||||
{PPCC} build.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}egman.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} egman.c
|
||||
{PPCC} egman.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}err.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} err.c
|
||||
{PPCC} err.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}fcache.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} fcache.c
|
||||
{PPCC} fcache.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}fset2.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} fset2.c
|
||||
{PPCC} fset2.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}fset.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} fset.c
|
||||
{PPCC} fset.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}gen.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} gen.c
|
||||
{PPCC} gen.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}globals.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} globals.c
|
||||
{PPCC} globals.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}hash.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} hash.c
|
||||
{PPCC} hash.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}lex.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} lex.c
|
||||
{PPCC} lex.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}main.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} main.c
|
||||
{PPCC} main.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}misc.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} misc.c
|
||||
{PPCC} misc.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}mrhoist.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} mrhoist.c
|
||||
{PPCC} mrhoist.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}pred.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} pred.c
|
||||
{PPCC} pred.c -o {Targ} {PPCCOptions}
|
||||
"{ObjDir<69>PPC}scan.c.x" <EFBFBD> {<EFBFBD>MondoBuild<EFBFBD>} scan.c
|
||||
{PPCC} scan.c -o {Targ} {PPCCOptions}
|
||||
|
||||
antlrPPC <EFBFBD><EFBFBD> antlr.r
|
||||
Rez antlr.r -o antlrPPC -a
|
||||
Install <EFBFBD> antlrPPC
|
||||
Duplicate -y antlrPPC "{MPW}"Tools:antlr
|
19
Tools/CodeTools/Source/Pccts/antlr/README
Normal file
19
Tools/CodeTools/Source/Pccts/antlr/README
Normal file
@@ -0,0 +1,19 @@
|
||||
ANTLR 1.33
|
||||
|
||||
This directory contains the files necessary to build ANTLR.
|
||||
|
||||
If you do a "make scrub", ANTLR will have to run on antlr.g and DLG
|
||||
will have to run on parser.dlg. Either
|
||||
|
||||
(1) ANTLR uses the previous antlr in that directory to rebuild itself
|
||||
(2) Needs to find antlr on the search path
|
||||
|
||||
You will find that running "antlr -gh antlr.g" will result in about
|
||||
10 ambiguity warnings. These are normal. Don't worry.
|
||||
|
||||
If you do a "make clean" right after installation, ANTLR and DLG should
|
||||
not need to run; only the C files will compile.
|
||||
|
||||
Don't forget to go into the makefile to uncomment the appropriate
|
||||
definitions for your OS/architecture/compiler or see the appropriate
|
||||
NOTES.?? file.
|
209
Tools/CodeTools/Source/Pccts/antlr/antlr.1
Normal file
209
Tools/CodeTools/Source/Pccts/antlr/antlr.1
Normal file
@@ -0,0 +1,209 @@
|
||||
.TH ANTLR 1 "September 1995" "ANTLR" "PCCTS Manual Pages"
|
||||
.SH NAME
|
||||
antlr \- ANother Tool for Language Recognition
|
||||
.SH SYNTAX
|
||||
.LP
|
||||
\fBantlr\fR [\fIoptions\fR] \fIgrammar_files\fR
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
\fIAntlr\fP converts an extended form of context-free grammar into a
|
||||
set of C functions which directly implement an efficient form of
|
||||
deterministic recursive-descent LL(k) parser. Context-free grammars
|
||||
may be augmented with predicates to allow semantics to influence
|
||||
parsing; this allows a form of context-sensitive parsing. Selective
|
||||
backtracking is also available to handle non-LL(k) and even
|
||||
non-LALR(k) constructs. \fIAntlr\fP also produces a definition of a
|
||||
lexer which can be automatically converted into C code for a DFA-based
|
||||
lexer by \fIdlg\fR. Hence, \fIantlr\fR serves a function much like
|
||||
that of \fIyacc\fR, however, it is notably more flexible and is more
|
||||
integrated with a lexer generator (\fIantlr\fR directly generates
|
||||
\fIdlg\fR code, whereas \fIyacc\fR and \fIlex\fR are given independent
|
||||
descriptions). Unlike \fIyacc\fR which accepts LALR(1) grammars,
|
||||
\fIantlr\fR accepts LL(k) grammars in an extended BNF notation \(em
|
||||
which eliminates the need for precedence rules.
|
||||
.PP
|
||||
Like \fIyacc\fR grammars, \fIantlr\fR grammars can use
|
||||
automatically-maintained symbol attribute values referenced as dollar
|
||||
variables. Further, because \fIantlr\fR generates top-down parsers,
|
||||
arbitrary values may be inherited from parent rules (passed like
|
||||
function parameters). \fIAntlr\fP also has a mechanism for creating
|
||||
and manipulating abstract-syntax-trees.
|
||||
.PP
|
||||
There are various other niceties in \fIantlr\fR, including the ability to
|
||||
spread one grammar over multiple files or even multiple grammars in a single
|
||||
file, the ability to generate a version of the grammar with actions stripped
|
||||
out (for documentation purposes), and lots more.
|
||||
.SH OPTIONS
|
||||
.IP "\fB-ck \fIn\fR"
|
||||
Use up to \fIn\fR symbols of lookahead when using compressed (linear
|
||||
approximation) lookahead. This type of lookahead is very cheap to
|
||||
compute and is attempted before full LL(k) lookahead, which is of
|
||||
exponential complexity in the worst case. In general, the compressed
|
||||
lookahead can be much deeper (e.g, \f(CW-ck 10\fP) than the full
|
||||
lookahead (which usually must be less than 4).
|
||||
.IP \fB-CC\fP
|
||||
Generate C++ output from both ANTLR and DLG.
|
||||
.IP \fB-cr\fP
|
||||
Generate a cross-reference for all rules. For each rule, print a list
|
||||
of all other rules that reference it.
|
||||
.IP \fB-e1\fP
|
||||
Ambiguities/errors shown in low detail (default).
|
||||
.IP \fB-e2\fP
|
||||
Ambiguities/errors shown in more detail.
|
||||
.IP \fB-e3\fP
|
||||
Ambiguities/errors shown in excruciating detail.
|
||||
.IP "\fB-fe\fP file"
|
||||
Rename \fBerr.c\fP to file.
|
||||
.IP "\fB-fh\fP file"
|
||||
Rename \fBstdpccts.h\fP header (turns on \fB-gh\fP) to file.
|
||||
.IP "\fB-fl\fP file"
|
||||
Rename lexical output, \fBparser.dlg\fP, to file.
|
||||
.IP "\fB-fm\fP file"
|
||||
Rename file with lexical mode definitions, \fBmode.h\fP, to file.
|
||||
.IP "\fB-fr\fP file"
|
||||
Rename file which remaps globally visible symbols, \fBremap.h\fP, to file.
|
||||
.IP "\fB-ft\fP file"
|
||||
Rename \fBtokens.h\fP to file.
|
||||
.IP \fB-ga\fP
|
||||
Generate ANSI-compatible code (default case). This has not been
|
||||
rigorously tested to be ANSI XJ11 C compliant, but it is close. The
|
||||
normal output of \fIantlr\fP is currently compilable under both K&R,
|
||||
ANSI C, and C++\(emthis option does nothing because \fIantlr\fP
|
||||
generates a bunch of #ifdef's to do the right thing depending on the
|
||||
language.
|
||||
.IP \fB-gc\fP
|
||||
Indicates that \fIantlr\fP should generate no C code, i.e., only
|
||||
perform analysis on the grammar.
|
||||
.IP \fB-gd\fP
|
||||
C code is inserted in each of the \fIantlr\fR generated parsing functions to
|
||||
provide for user-defined handling of a detailed parse trace. The inserted
|
||||
code consists of calls to the user-supplied macros or functions called
|
||||
\fBzzTRACEIN\fR and \fBzzTRACEOUT\fP. The only argument is a
|
||||
\fIchar *\fR pointing to a C-style string which is the grammar rule
|
||||
recognized by the current parsing function. If no definition is given
|
||||
for the trace functions, upon rule entry and exit, a message will be
|
||||
printed indicating that a particular rule as been entered or exited.
|
||||
.IP \fB-ge\fP
|
||||
Generate an error class for each non-terminal.
|
||||
.IP \fB-gh\fP
|
||||
Generate \fBstdpccts.h\fP for non-ANTLR-generated files to include.
|
||||
This file contains all defines needed to describe the type of parser
|
||||
generated by \fIantlr\fP (e.g. how much lookahead is used and whether
|
||||
or not trees are constructed) and contains the \fBheader\fP action
|
||||
specified by the user.
|
||||
.IP \fB-gk\fP
|
||||
Generate parsers that delay lookahead fetches until needed. Without
|
||||
this option, \fIantlr\fP generates parsers which always have \fIk\fP
|
||||
tokens of lookahead available.
|
||||
.IP \fB-gl\fP
|
||||
Generate line info about grammar actions in C parser of the form
|
||||
\fB#\ \fIline\fP\ "\fIfile\fP"\fR which makes error messages from
|
||||
the C/C++ compiler make more sense as they will \*Qpoint\*U into the
|
||||
grammar file not the resulting C file. Debugging is easier as well,
|
||||
because you will step through the grammar not C file.
|
||||
.IP \fB-gs\fR
|
||||
Do not generate sets for token expression lists; instead generate a
|
||||
\fB||\fP-separated sequence of \fBLA(1)==\fItoken_number\fR. The
|
||||
default is to generate sets.
|
||||
.IP \fB-gt\fP
|
||||
Generate code for Abstract-Syntax Trees.
|
||||
.IP \fB-gx\fP
|
||||
Do not create the lexical analyzer files (dlg-related). This option
|
||||
should be given when the user wishes to provide a customized lexical
|
||||
analyzer. It may also be used in \fImake\fR scripts to cause only the
|
||||
parser to be rebuilt when a change not affecting the lexical structure
|
||||
is made to the input grammars.
|
||||
.IP "\fB-k \fIn\fR"
|
||||
Set k of LL(k) to \fIn\fR; i.e. set tokens of look-ahead (default==1).
|
||||
.IP "\fB-o\fP dir
|
||||
Directory where output files should go (default="."). This is very
|
||||
nice for keeping the source directory clear of ANTLR and DLG spawn.
|
||||
.IP \fB-p\fP
|
||||
The complete grammar, collected from all input grammar files and
|
||||
stripped of all comments and embedded actions, is listed to
|
||||
\fBstdout\fP. This is intended to aid in viewing the entire grammar
|
||||
as a whole and to eliminate the need to keep actions concisely stated
|
||||
so that the grammar is easier to read. Hence, it is preferable to
|
||||
embed even complex actions directly in the grammar, rather than to
|
||||
call them as subroutines, since the subroutine call overhead will be
|
||||
saved.
|
||||
.IP \fB-pa\fP
|
||||
This option is the same as \fB-p\fP except that the output is
|
||||
annotated with the first sets determined from grammar analysis.
|
||||
.IP "\fB-prc on\fR
|
||||
Turn on the computation and hoisting of predicate context.
|
||||
.IP "\fB-prc off\fR
|
||||
Turn off the computation and hoisting of predicate context. This
|
||||
option makes 1.10 behave like the 1.06 release with option \fB-pr\fR
|
||||
on. Context computation is off by default.
|
||||
.IP "\fB-rl \fIn\fR
|
||||
Limit the maximum number of tree nodes used by grammar analysis to
|
||||
\fIn\fP. Occasionally, \fIantlr\fP is unable to analyze a grammar
|
||||
submitted by the user. This rare situation can only occur when the
|
||||
grammar is large and the amount of lookahead is greater than one. A
|
||||
nonlinear analysis algorithm is used by PCCTS to handle the general
|
||||
case of LL(k) parsing. The average complexity of analysis, however, is
|
||||
near linear due to some fancy footwork in the implementation which
|
||||
reduces the number of calls to the full LL(k) algorithm. An error
|
||||
message will be displayed, if this limit is reached, which indicates
|
||||
the grammar construct being analyzed when \fIantlr\fP hit a
|
||||
non-linearity. Use this option if \fIantlr\fP seems to go out to
|
||||
lunch and your disk start thrashing; try \fIn\fP=10000 to start. Once
|
||||
the offending construct has been identified, try to remove the
|
||||
ambiguity that \fIantlr\fP was trying to overcome with large lookahead
|
||||
analysis. The introduction of (...)? backtracking blocks eliminates
|
||||
some of these problems\ \(em \fIantlr\fP does not analyze alternatives
|
||||
that begin with (...)? (it simply backtracks, if necessary, at run
|
||||
time).
|
||||
.IP \fB-w1\fR
|
||||
Set low warning level. Do not warn if semantic predicates and/or
|
||||
(...)? blocks are assumed to cover ambiguous alternatives.
|
||||
.IP \fB-w2\fR
|
||||
Ambiguous parsing decisions yield warnings even if semantic predicates
|
||||
or (...)? blocks are used. Warn if predicate context computed and
|
||||
semantic predicates incompletely disambiguate alternative productions.
|
||||
.IP \fB-\fR
|
||||
Read grammar from standard input and generate \fBstdin.c\fP as the
|
||||
parser file.
|
||||
.SH "SPECIAL CONSIDERATIONS"
|
||||
.PP
|
||||
\fIAntlr\fP works... we think. There is no implicit guarantee of
|
||||
anything. We reserve no \fBlegal\fP rights to the software known as
|
||||
the Purdue Compiler Construction Tool Set (PCCTS) \(em 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
|
||||
commercial 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. As long as these guidelines are followed,
|
||||
we expect to continue enhancing this system and expect to make other
|
||||
tools available as they are completed.
|
||||
.SH FILES
|
||||
.IP *.c
|
||||
output C parser.
|
||||
.IP *.cpp
|
||||
output C++ parser when C++ mode is used.
|
||||
.IP \fBparser.dlg\fP
|
||||
output \fIdlg\fR lexical analyzer.
|
||||
.IP \fBerr.c\fP
|
||||
token string array, error sets and error support routines. Not used in
|
||||
C++ mode.
|
||||
.IP \fBremap.h\fP
|
||||
file that redefines all globally visible parser symbols. The use of
|
||||
the #parser directive creates this file. Not used in
|
||||
C++ mode.
|
||||
.IP \fBstdpccts.h\fP
|
||||
list of definitions needed by C files, not generated by PCCTS, that
|
||||
reference PCCTS objects. This is not generated by default. Not used in
|
||||
C++ mode.
|
||||
.IP \fBtokens.h\fP
|
||||
output \fI#defines\fR for tokens used and function prototypes for
|
||||
functions generated for rules.
|
||||
.SH "SEE ALSO"
|
||||
.LP
|
||||
dlg(1), pccts(1)
|
3564
Tools/CodeTools/Source/Pccts/antlr/antlr.c
Normal file
3564
Tools/CodeTools/Source/Pccts/antlr/antlr.c
Normal file
File diff suppressed because it is too large
Load Diff
2586
Tools/CodeTools/Source/Pccts/antlr/antlr.g
Normal file
2586
Tools/CodeTools/Source/Pccts/antlr/antlr.g
Normal file
File diff suppressed because it is too large
Load Diff
787
Tools/CodeTools/Source/Pccts/antlr/antlr.r
Normal file
787
Tools/CodeTools/Source/Pccts/antlr/antlr.r
Normal file
@@ -0,0 +1,787 @@
|
||||
/*
|
||||
File: antlrMPW.r
|
||||
Target: antlr 133MR
|
||||
Created: Monday, June 15, 1998 4:41:11 AM
|
||||
Author: Kenji Tanaka (kentar@osa.att.ne.jp)
|
||||
*/
|
||||
|
||||
#include "cmdo.r"
|
||||
|
||||
resource 'cmdo' (128, "Antlr") {
|
||||
{ /* array dialogs: 5 elements */
|
||||
/* [1] */
|
||||
295,
|
||||
"ANTLR -- Purdue Compiler Construction To"
|
||||
"ol Set (PCCTS) LL(k) parser generator.",
|
||||
{ /* array itemArray: 12 elements */
|
||||
/* [1] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{18, 23, 33, 223},
|
||||
"Read grammar from stdin",
|
||||
"-",
|
||||
"Read grammar from stdin."
|
||||
},
|
||||
/* [2] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{38, 23, 53, 310},
|
||||
"Send grammar.c/grammar.cpp to stdout",
|
||||
"-stdout",
|
||||
"Send grammar.c/grammar.cpp to stdout."
|
||||
},
|
||||
/* [3] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
MultiFiles {
|
||||
"Grammar File(s)<29>",
|
||||
"Choose the grammar specification files y"
|
||||
"ou wish to have ANTLR process.",
|
||||
{79, 22, 98, 152},
|
||||
"Grammar specification:",
|
||||
"",
|
||||
MultiInputFiles {
|
||||
{ /* array MultiTypesArray: 1 elements */
|
||||
/* [1] */
|
||||
text
|
||||
},
|
||||
".g",
|
||||
"Files ending in .g",
|
||||
"All text files"
|
||||
}
|
||||
},
|
||||
/* [4] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
Files {
|
||||
DirOnly,
|
||||
OptionalFile {
|
||||
{58, 168, 74, 298},
|
||||
{79, 169, 98, 299},
|
||||
"Output Directory",
|
||||
":",
|
||||
"-o",
|
||||
"",
|
||||
"Choose the directory where ANTLR will pu"
|
||||
"t its output.",
|
||||
dim,
|
||||
"Output Directory<72>",
|
||||
"",
|
||||
""
|
||||
},
|
||||
NoMore {
|
||||
|
||||
}
|
||||
},
|
||||
/* [5] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
Redirection {
|
||||
StandardOutput,
|
||||
{126, 27}
|
||||
},
|
||||
/* [6] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
Redirection {
|
||||
DiagnosticOutput,
|
||||
{126, 178}
|
||||
},
|
||||
/* [7] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
TextBox {
|
||||
gray,
|
||||
{117, 20, 167, 300},
|
||||
"Redirection"
|
||||
},
|
||||
/* [8] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
NestedDialog {
|
||||
5,
|
||||
{20, 324, 40, 460},
|
||||
"Parse Options<6E>",
|
||||
"Parse control options may be set with th"
|
||||
"is button."
|
||||
},
|
||||
/* [9] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
NestedDialog {
|
||||
2,
|
||||
{50, 324, 70, 460},
|
||||
"Generate Options<6E>",
|
||||
"Various command line options may be set "
|
||||
"with this button."
|
||||
},
|
||||
/* [10] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
NestedDialog {
|
||||
3,
|
||||
{78, 324, 98, 460},
|
||||
"More Options<6E>",
|
||||
"Antlr has ALOT of options. There are eve"
|
||||
"n more to be found with this button."
|
||||
},
|
||||
/* [11] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
NestedDialog {
|
||||
4,
|
||||
{106, 324, 126, 460},
|
||||
"Rename Options<6E>",
|
||||
"Options for renaming output files may be"
|
||||
" set with this button."
|
||||
},
|
||||
/* [12] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
VersionDialog {
|
||||
VersionString {
|
||||
"1.33MR"
|
||||
},
|
||||
"PCCTS was written by Terence Parr, Russe"
|
||||
"ll Quong, Will Cohen, and Hank Dietz: 19"
|
||||
"89-1998. MPW port by Scott Haney.",
|
||||
noDialog
|
||||
}
|
||||
},
|
||||
/* [2] */
|
||||
295,
|
||||
"Use this dialog to specify command line "
|
||||
"Generate Options.",
|
||||
{ /* array itemArray: 15 elements */
|
||||
/* [1] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{18, 25, 33, 225},
|
||||
"Generate C++ code",
|
||||
"-CC",
|
||||
"Generate C++ output from both ANTLR and "
|
||||
"DLG."
|
||||
},
|
||||
/* [2] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{38, 25, 53, 225},
|
||||
"Generate ASTs",
|
||||
"-gt",
|
||||
"Generate code for Abstract-Syntax-Trees "
|
||||
"(ASTs)."
|
||||
},
|
||||
/* [3] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{58, 25, 73, 225},
|
||||
"Generate line info",
|
||||
"-gl",
|
||||
"If this option is checked, ANTLR will ge"
|
||||
"nerate line info about grammaractions, t"
|
||||
"hereby making debugging easier since com"
|
||||
"pile errors will point to the grammar fi"
|
||||
"le."
|
||||
},
|
||||
/* [4] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{78, 25, 93, 225},
|
||||
"Generate error classes",
|
||||
"-ge",
|
||||
"If this option is checked, ANTLR will ge"
|
||||
"nerate an error class foreach non-termin"
|
||||
"al."
|
||||
},
|
||||
/* [5] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{98, 25, 113, 225},
|
||||
"Don't generate Code",
|
||||
"-gc",
|
||||
"If this option is checked, ANTLR will ge"
|
||||
"nerate no code, i.e. it will only perfor"
|
||||
"m analysis on the grammar."
|
||||
},
|
||||
/* [6] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{118, 25, 133, 225},
|
||||
"Delay lookahead fetches",
|
||||
"-gk",
|
||||
"If this option is checked, ANTLR will ge"
|
||||
"nerate a parser that delays lookahead fe"
|
||||
"tches until needed."
|
||||
},
|
||||
/* [7] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{138, 25, 153, 225},
|
||||
"Use newAST(...)",
|
||||
"-newAST",
|
||||
"In C++ mode use \"newAST(...)\" rather tha"
|
||||
"n \"new AST(...)\""
|
||||
},
|
||||
/* [8] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{18, 235, 33, 435},
|
||||
"Support parse traces",
|
||||
"-gd",
|
||||
"If this option is checked, ANTLR inserts"
|
||||
" code in each parsing function to provid"
|
||||
"e for user-defined handling of a detaile"
|
||||
"d parse trace. The code consists of call"
|
||||
"s to zzTRACEIN and zzTRACEOUT."
|
||||
},
|
||||
/* [9] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{38, 235, 53, 435},
|
||||
"Generate cross-references",
|
||||
"-cr",
|
||||
"If this option is checked, ANTLR will ge"
|
||||
"nerate a cross reference for all rules. "
|
||||
"For each rule it will print a list of al"
|
||||
"l other rules that refrence it."
|
||||
},
|
||||
/* [10] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{58, 235, 73, 435},
|
||||
"Don't create Lexer files",
|
||||
"-gx",
|
||||
"If this option is checked, ANTLR will no"
|
||||
"t generate DLG-related output files. Thi"
|
||||
"s option should be used if one wants a c"
|
||||
"ustom lexical analyzer or if one has mad"
|
||||
"e changes to the grammar not affecting t"
|
||||
"he lexical structure."
|
||||
},
|
||||
/* [11] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{78, 235, 93, 460},
|
||||
"Don't generate token expr sets",
|
||||
"-gs",
|
||||
"If this option is checked, ANTLR will no"
|
||||
"t generate sets for token expression set"
|
||||
"s; instead, it will generate a || separa"
|
||||
"ted sequence of LA(1)==token #. "
|
||||
},
|
||||
/* [12] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{98, 235, 113, 460},
|
||||
"Generate ANSI-compatible",
|
||||
"-ga",
|
||||
"Generate ANSI-compatible code (default=F"
|
||||
"ALSE)"
|
||||
},
|
||||
/* [13] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{118, 235, 133, 460},
|
||||
"Don't generate tokens.h",
|
||||
"-gxt",
|
||||
"Do not generate tokens.h (default=FALSE)"
|
||||
},
|
||||
/* [13] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{138, 235, 153, 460},
|
||||
"Provide \"(alpha)? beta\" info",
|
||||
"-alpha",
|
||||
"Provide additional information for \"(alpha)? beta\" error messages"
|
||||
},
|
||||
/* [14] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Tabs(1 to 8):",
|
||||
{162, 23, 177, 117},
|
||||
{163, 125, 179, 196},
|
||||
"",
|
||||
keepCase,
|
||||
"-tab",
|
||||
"Width of tabs (1 to 8) for grammar.c/gra"
|
||||
"mmar.cpp files."
|
||||
},
|
||||
/* [15] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Function Prefix:",
|
||||
{161, 236, 177, 342},
|
||||
{162, 345, 177, 454},
|
||||
"",
|
||||
keepCase,
|
||||
"-gp",
|
||||
"Prefix all generated rule functions with"
|
||||
" a string."
|
||||
}
|
||||
},
|
||||
/* [3] */
|
||||
295,
|
||||
"Use this dialog to specify still more co"
|
||||
"mmand line options.",
|
||||
{ /* array itemArray: 12 elements */
|
||||
/* [1] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RadioButtons {
|
||||
{ /* array radioArray: 3 elements */
|
||||
/* [1] */
|
||||
{38, 25, 53, 85}, "None", "", Set, "When this option is selected, ANTLR will"
|
||||
" not print the grammar to stdout.",
|
||||
/* [2] */
|
||||
{38, 100, 53, 160}, "Yes", "-p", NotSet, "When this option is selected, ANTLR will"
|
||||
" print the grammar, stripped of all acti"
|
||||
"ons and comments, to stdout.",
|
||||
/* [3] */
|
||||
{38, 175, 53, 235}, "More", "-pa", NotSet, "When this option is selected, ANTLR will"
|
||||
" print the grammar, stripped of all acti"
|
||||
"ons and comments, to stdout. It will als"
|
||||
"o annotate the output with the first set"
|
||||
"s determined from grammar analysis."
|
||||
}
|
||||
},
|
||||
/* [2] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
TextBox {
|
||||
gray,
|
||||
{28, 15, 60, 250},
|
||||
"Grammar Printing"
|
||||
},
|
||||
/* [3] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RadioButtons {
|
||||
{ /* array radioArray: 3 elements */
|
||||
/* [1] */
|
||||
{88, 25, 103, 85}, "Low", "", Set, "When this option is selected, ANTLR will"
|
||||
" show ambiguities/errors in low detail.",
|
||||
/* [2] */
|
||||
{88, 100, 103, 160}, "Medium", "-e2", NotSet, "When this option is selected, ANTLR will"
|
||||
" show ambiguities/errors in more detail.",
|
||||
/* [3] */
|
||||
{88, 175, 103, 235}, "High", "-e3", NotSet, "When this option is selected, ANTLR will"
|
||||
" show ambiguities/errors in excruciating"
|
||||
" detail."
|
||||
}
|
||||
},
|
||||
/* [4] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
TextBox {
|
||||
gray,
|
||||
{78, 15, 110, 250},
|
||||
"Error reporting"
|
||||
},
|
||||
/* [5] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{130, 22, 145, 222},
|
||||
"More warnings",
|
||||
"-w2",
|
||||
"If this option is checked, ANTLR will wa"
|
||||
"rn if semantic predicates and/or (<28>)? bl"
|
||||
"ocks are assumed to cover ambiguous alte"
|
||||
"rnatives."
|
||||
},
|
||||
/* [6] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Report when tnode usage exceeds:",
|
||||
{162, 23, 180, 253},
|
||||
{162, 255, 178, 326},
|
||||
"",
|
||||
keepCase,
|
||||
"-treport",
|
||||
"Report when tnode usage exceeds value du"
|
||||
"ring ambiguity resolution."
|
||||
},
|
||||
/* [7] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{40, 292, 55, 431},
|
||||
"Predicate",
|
||||
"-info p",
|
||||
"With the antlr \"-info p\" switch the user"
|
||||
" will receive information about the pred"
|
||||
"icate suppression in the generated file."
|
||||
},
|
||||
/* [8] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{60, 292, 75, 430},
|
||||
"Tree Nodes",
|
||||
"-info t",
|
||||
"Using \"-info t\" gives information about "
|
||||
"the total number of tnodes created and t"
|
||||
"he peak number of tnodes."
|
||||
},
|
||||
/* [9] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{80, 292, 95, 425},
|
||||
"First/follow",
|
||||
"-info f",
|
||||
"first/follow set information."
|
||||
},
|
||||
/* [10] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{100, 292, 115, 425},
|
||||
"Monitor progress",
|
||||
"-info m",
|
||||
"prints name of each rule as it is starte"
|
||||
"d and flushes output at start of each rule."
|
||||
},
|
||||
/* [11] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{120, 292, 135, 416},
|
||||
"Orphan rules",
|
||||
"-info o",
|
||||
"If there is more than one rule which is "
|
||||
"not referenced by any other rule then al"
|
||||
"l such rules are listed."
|
||||
},
|
||||
/* [12] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
TextBox {
|
||||
gray,
|
||||
{28, 279, 147, 451},
|
||||
"Extra info"
|
||||
}
|
||||
},
|
||||
/* [4] */
|
||||
295,
|
||||
"Use this dialog to specify command line "
|
||||
"options relating to renaming output file"
|
||||
"s.",
|
||||
{ /* array itemArray: 7 elements */
|
||||
/* [1] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Errors file name:",
|
||||
{35, 25, 50, 205},
|
||||
{35, 205, 51, 300},
|
||||
"err.c",
|
||||
keepCase,
|
||||
"-fe",
|
||||
"This entry specifies the name ANTLR uses"
|
||||
" for the errors file."
|
||||
},
|
||||
/* [2] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Lexical output name:",
|
||||
{60, 25, 75, 205},
|
||||
{60, 205, 76, 300},
|
||||
"parser.dlg",
|
||||
keepCase,
|
||||
"-fl",
|
||||
"This entry specifies the name ANTLR uses"
|
||||
" for the lexical output file."
|
||||
},
|
||||
/* [3] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Lexical modes name:",
|
||||
{85, 25, 100, 205},
|
||||
{85, 205, 101, 300},
|
||||
"mode.h",
|
||||
keepCase,
|
||||
"-fm",
|
||||
"This entry specifies the name ANTLR uses"
|
||||
" for the lexical mode definitions file."
|
||||
},
|
||||
/* [4] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Remap file name:",
|
||||
{110, 25, 125, 205},
|
||||
{110, 205, 126, 300},
|
||||
"remap.h",
|
||||
keepCase,
|
||||
"-fr",
|
||||
"This entry specifies the name ANTLR uses"
|
||||
" for the file that remaps globally visib"
|
||||
"le symbols."
|
||||
},
|
||||
/* [5] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Tokens file name:",
|
||||
{135, 25, 150, 205},
|
||||
{135, 205, 151, 300},
|
||||
"tokens.h",
|
||||
keepCase,
|
||||
"-ft",
|
||||
"This entry specifies the name ANTLR uses"
|
||||
" for the tokens file."
|
||||
},
|
||||
/* [6] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{160, 25, 175, 175},
|
||||
"Create std header",
|
||||
"-gh",
|
||||
"If this option is checked, ANTLR will cr"
|
||||
"eate a standard header file named, by de"
|
||||
"fault 'stdpccts.h'. This name can be alt"
|
||||
"ered using the entry right next door."
|
||||
},
|
||||
/* [7] */
|
||||
Or {
|
||||
{ /* array OrArray: 1 elements */
|
||||
/* [1] */
|
||||
6
|
||||
}
|
||||
},
|
||||
RegularEntry {
|
||||
"Std header file name:",
|
||||
{160, 175, 175, 355},
|
||||
{160, 355, 176, 450},
|
||||
"stdpccts.h",
|
||||
keepCase,
|
||||
"-fh",
|
||||
"This entry specifies the name ANTLR uses"
|
||||
" for the standard header file."
|
||||
}
|
||||
},
|
||||
/* [5] */
|
||||
295,
|
||||
"Use this dialog to specify parse options"
|
||||
".",
|
||||
{ /* array itemArray: 9 elements */
|
||||
/* [1] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Lookahead:",
|
||||
{23, 27, 38, 152},
|
||||
{46, 29, 62, 154},
|
||||
"1",
|
||||
keepCase,
|
||||
"-k",
|
||||
"This entry specifies the number of token"
|
||||
"s of lookahead."
|
||||
},
|
||||
/* [2] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Compr lookahead:",
|
||||
{22, 167, 37, 292},
|
||||
{46, 172, 62, 297},
|
||||
"",
|
||||
keepCase,
|
||||
"-ck",
|
||||
"This entry specifies the number of token"
|
||||
"s of lookahead when using compressed (li"
|
||||
"near approximation) lookahead. In genera"
|
||||
"l, the compressed lookahead is much deep"
|
||||
"er than the full lookahead."
|
||||
},
|
||||
/* [3] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Max tree nodes:",
|
||||
{22, 312, 37, 437},
|
||||
{46, 315, 62, 445},
|
||||
"",
|
||||
keepCase,
|
||||
"-rl",
|
||||
"This entry specifies the maximum number "
|
||||
"of tokens of tree nodes used by the gram"
|
||||
"mar analysis."
|
||||
},
|
||||
/* [4] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{76, 25, 91, 350},
|
||||
"Maintenance Release style hoisting",
|
||||
"-mrhoist",
|
||||
"Turn on/off k=1 Maintenance Release styl"
|
||||
"e hoisting."
|
||||
},
|
||||
/* [5] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{96, 25, 111, 431},
|
||||
"EXPERIMENTAL Maintenance Release style h"
|
||||
"oisting",
|
||||
"-mrhoistk",
|
||||
"Turn on/off k>1 EXPERIMENTAL Maintenance"
|
||||
" Release style hoisting."
|
||||
},
|
||||
/* [6] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{116, 25, 131, 363},
|
||||
"Compute context for hoisted predicates",
|
||||
"-prc on",
|
||||
"Turn on/off computation of context for h"
|
||||
"oisted predicates."
|
||||
},
|
||||
/* [7] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Ambiguity aid:",
|
||||
{140, 27, 155, 125},
|
||||
{141, 135, 155, 209},
|
||||
"",
|
||||
keepCase,
|
||||
"-aa",
|
||||
"Ambiguity aid for a rule (rule name or l"
|
||||
"ine number)."
|
||||
},
|
||||
/* [8] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
RegularEntry {
|
||||
"Limits exp growth:",
|
||||
{140, 236, 155, 361},
|
||||
{139, 372, 155, 452},
|
||||
"",
|
||||
keepCase,
|
||||
"-aad",
|
||||
"Limits exp growth of -aa listing - defau"
|
||||
"lt=1 (max=ck value)."
|
||||
},
|
||||
/* [9] */
|
||||
NotDependent {
|
||||
|
||||
},
|
||||
CheckOption {
|
||||
NotSet,
|
||||
{164, 26, 179, 366},
|
||||
"Lookahead token may appear multiple time"
|
||||
"s",
|
||||
"-aam",
|
||||
"Lookahead token may appear multiple time"
|
||||
"s in -aa listing."
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
264
Tools/CodeTools/Source/Pccts/antlr/antlr1.txt
Normal file
264
Tools/CodeTools/Source/Pccts/antlr/antlr1.txt
Normal file
@@ -0,0 +1,264 @@
|
||||
|
||||
|
||||
|
||||
ANTLR(1) PCCTS Manual Pages ANTLR(1)
|
||||
|
||||
|
||||
|
||||
NAME
|
||||
antlr - ANother Tool for Language Recognition
|
||||
|
||||
SYNTAX
|
||||
antlr [_o_p_t_i_o_n_s] _g_r_a_m_m_a_r__f_i_l_e_s
|
||||
|
||||
DESCRIPTION
|
||||
_A_n_t_l_r converts an extended form of context-free grammar into
|
||||
a set of C functions which directly implement an efficient
|
||||
form of deterministic recursive-descent LL(k) parser.
|
||||
Context-free grammars may be augmented with predicates to
|
||||
allow semantics to influence parsing; this allows a form of
|
||||
context-sensitive parsing. Selective backtracking is also
|
||||
available to handle non-LL(k) and even non-LALR(k) con-
|
||||
structs. _A_n_t_l_r also produces a definition of a lexer which
|
||||
can be automatically converted into C code for a DFA-based
|
||||
lexer by _d_l_g. Hence, _a_n_t_l_r serves a function much like that
|
||||
of _y_a_c_c, however, it is notably more flexible and is more
|
||||
integrated with a lexer generator (_a_n_t_l_r directly generates
|
||||
_d_l_g code, whereas _y_a_c_c and _l_e_x are given independent
|
||||
descriptions). Unlike _y_a_c_c which accepts LALR(1) grammars,
|
||||
_a_n_t_l_r accepts LL(k) grammars in an extended BNF notation -
|
||||
which eliminates the need for precedence rules.
|
||||
|
||||
Like _y_a_c_c grammars, _a_n_t_l_r grammars can use automatically-
|
||||
maintained symbol attribute values referenced as dollar
|
||||
variables. Further, because _a_n_t_l_r generates top-down
|
||||
parsers, arbitrary values may be inherited from parent rules
|
||||
(passed like function parameters). _A_n_t_l_r also has a mechan-
|
||||
ism for creating and manipulating abstract-syntax-trees.
|
||||
|
||||
There are various other niceties in _a_n_t_l_r, including the
|
||||
ability to spread one grammar over multiple files or even
|
||||
multiple grammars in a single file, the ability to generate
|
||||
a version of the grammar with actions stripped out (for
|
||||
documentation purposes), and lots more.
|
||||
|
||||
OPTIONS
|
||||
-ck _n
|
||||
Use up to _n symbols of lookahead when using compressed
|
||||
(linear approximation) lookahead. This type of looka-
|
||||
head is very cheap to compute and is attempted before
|
||||
full LL(k) lookahead, which is of exponential complex-
|
||||
ity in the worst case. In general, the compressed loo-
|
||||
kahead can be much deeper (e.g, -ck 10) _t_h_a_n _t_h_e _f_u_l_l
|
||||
_l_o_o_k_a_h_e_a_d (_w_h_i_c_h _u_s_u_a_l_l_y _m_u_s_t _b_e _l_e_s_s _t_h_a_n _4).
|
||||
|
||||
-CC Generate C++ output from both ANTLR and DLG.
|
||||
|
||||
-cr Generate a cross-reference for all rules. For each
|
||||
rule, print a list of all other rules that reference
|
||||
it.
|
||||
|
||||
-e1 Ambiguities/errors shown in low detail (default).
|
||||
|
||||
-e2 Ambiguities/errors shown in more detail.
|
||||
|
||||
-e3 Ambiguities/errors shown in excruciating detail.
|
||||
|
||||
-fe file
|
||||
Rename err.c to file.
|
||||
|
||||
-fh file
|
||||
Rename stdpccts.h header (turns on -gh) to file.
|
||||
|
||||
-fl file
|
||||
Rename lexical output, parser.dlg, to file.
|
||||
|
||||
-fm file
|
||||
Rename file with lexical mode definitions, mode.h, to
|
||||
file.
|
||||
|
||||
-fr file
|
||||
Rename file which remaps globally visible symbols,
|
||||
remap.h, to file.
|
||||
|
||||
-ft file
|
||||
Rename tokens.h to file.
|
||||
|
||||
-ga Generate ANSI-compatible code (default case). This has
|
||||
not been rigorously tested to be ANSI XJ11 C compliant,
|
||||
but it is close. The normal output of _a_n_t_l_r is
|
||||
currently compilable under both K&R, ANSI C, and C++-
|
||||
this option does nothing because _a_n_t_l_r generates a
|
||||
bunch of #ifdef's to do the right thing depending on
|
||||
the language.
|
||||
|
||||
-gc Indicates that _a_n_t_l_r should generate no C code, i.e.,
|
||||
only perform analysis on the grammar.
|
||||
|
||||
-gd C code is inserted in each of the _a_n_t_l_r generated pars-
|
||||
ing functions to provide for user-defined handling of a
|
||||
detailed parse trace. The inserted code consists of
|
||||
calls to the user-supplied macros or functions called
|
||||
zzTRACEIN and zzTRACEOUT. The only argument is a _c_h_a_r
|
||||
* pointing to a C-style string which is the grammar
|
||||
rule recognized by the current parsing function. If no
|
||||
definition is given for the trace functions, upon rule
|
||||
entry and exit, a message will be printed indicating
|
||||
that a particular rule as been entered or exited.
|
||||
|
||||
-ge Generate an error class for each non-terminal.
|
||||
|
||||
-gh Generate stdpccts.h for non-ANTLR-generated files to
|
||||
include. This file contains all defines needed to
|
||||
describe the type of parser generated by _a_n_t_l_r (e.g.
|
||||
how much lookahead is used and whether or not trees are
|
||||
constructed) and contains the header action specified
|
||||
by the user.
|
||||
|
||||
-gk Generate parsers that delay lookahead fetches until
|
||||
needed. Without this option, _a_n_t_l_r generates parsers
|
||||
which always have _k tokens of lookahead available.
|
||||
|
||||
-gl Generate line info about grammar actions in C parser of
|
||||
the form # _l_i_n_e "_f_i_l_e" which makes error messages from
|
||||
the C/C++ compiler make more sense as they will point
|
||||
into the grammar file not the resulting C file.
|
||||
Debugging is easier as well, because you will step
|
||||
through the grammar not C file.
|
||||
|
||||
-gs Do not generate sets for token expression lists;
|
||||
instead generate a ||-separated sequence of
|
||||
LA(1)==_t_o_k_e_n__n_u_m_b_e_r. The default is to generate sets.
|
||||
|
||||
-gt Generate code for Abstract-Syntax Trees.
|
||||
|
||||
-gx Do not create the lexical analyzer files (dlg-related).
|
||||
This option should be given when the user wishes to
|
||||
provide a customized lexical analyzer. It may also be
|
||||
used in _m_a_k_e scripts to cause only the parser to be
|
||||
rebuilt when a change not affecting the lexical struc-
|
||||
ture is made to the input grammars.
|
||||
|
||||
-k _n Set k of LL(k) to _n; i.e. set tokens of look-ahead
|
||||
(default==1).
|
||||
|
||||
-o dir
|
||||
Directory where output files should go (default=".").
|
||||
This is very nice for keeping the source directory
|
||||
clear of ANTLR and DLG spawn.
|
||||
|
||||
-p The complete grammar, collected from all input grammar
|
||||
files and stripped of all comments and embedded
|
||||
actions, is listed to stdout. This is intended to aid
|
||||
in viewing the entire grammar as a whole and to elim-
|
||||
inate the need to keep actions concisely stated so that
|
||||
the grammar is easier to read. Hence, it is preferable
|
||||
to embed even complex actions directly in the grammar,
|
||||
rather than to call them as subroutines, since the sub-
|
||||
routine call overhead will be saved.
|
||||
|
||||
-pa This option is the same as -p except that the output is
|
||||
annotated with the first sets determined from grammar
|
||||
analysis.
|
||||
|
||||
-prc on
|
||||
Turn on the computation and hoisting of predicate con-
|
||||
text.
|
||||
|
||||
-prc off
|
||||
Turn off the computation and hoisting of predicate con-
|
||||
text. This option makes 1.10 behave like the 1.06
|
||||
release with option -pr on. Context computation is off
|
||||
by default.
|
||||
|
||||
-rl _n
|
||||
Limit the maximum number of tree nodes used by grammar
|
||||
analysis to _n. Occasionally, _a_n_t_l_r is unable to
|
||||
analyze a grammar submitted by the user. This rare
|
||||
situation can only occur when the grammar is large and
|
||||
the amount of lookahead is greater than one. A non-
|
||||
linear analysis algorithm is used by PCCTS to handle
|
||||
the general case of LL(k) parsing. The average com-
|
||||
plexity of analysis, however, is near linear due to
|
||||
some fancy footwork in the implementation which reduces
|
||||
the number of calls to the full LL(k) algorithm. An
|
||||
error message will be displayed, if this limit is
|
||||
reached, which indicates the grammar construct being
|
||||
analyzed when _a_n_t_l_r hit a non-linearity. Use this
|
||||
option if _a_n_t_l_r seems to go out to lunch and your disk
|
||||
start thrashing; try _n=10000 to start. Once the
|
||||
offending construct has been identified, try to remove
|
||||
the ambiguity that _a_n_t_l_r was trying to overcome with
|
||||
large lookahead analysis. The introduction of (...)?
|
||||
backtracking blocks eliminates some of these problems -
|
||||
_a_n_t_l_r does not analyze alternatives that begin with
|
||||
(...)? (it simply backtracks, if necessary, at run
|
||||
time).
|
||||
|
||||
-w1 Set low warning level. Do not warn if semantic
|
||||
predicates and/or (...)? blocks are assumed to cover
|
||||
ambiguous alternatives.
|
||||
|
||||
-w2 Ambiguous parsing decisions yield warnings even if
|
||||
semantic predicates or (...)? blocks are used. Warn if
|
||||
predicate context computed and semantic predicates
|
||||
incompletely disambiguate alternative productions.
|
||||
|
||||
- Read grammar from standard input and generate stdin.c
|
||||
as the parser file.
|
||||
|
||||
SPECIAL CONSIDERATIONS
|
||||
_A_n_t_l_r works... we think. There is no implicit guarantee of
|
||||
anything. We reserve no legal rights to the software known
|
||||
as 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 commercial 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 pro-
|
||||
ject, 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. As long as these
|
||||
guidelines are followed, we expect to continue enhancing
|
||||
this system and expect to make other tools available as they
|
||||
are completed.
|
||||
|
||||
FILES
|
||||
*.c output C parser.
|
||||
|
||||
*.cpp
|
||||
output C++ parser when C++ mode is used.
|
||||
|
||||
parser.dlg
|
||||
output _d_l_g lexical analyzer.
|
||||
|
||||
err.c
|
||||
token string array, error sets and error support rou-
|
||||
tines. Not used in C++ mode.
|
||||
|
||||
remap.h
|
||||
file that redefines all globally visible parser sym-
|
||||
bols. The use of the #parser directive creates this
|
||||
file. Not used in C++ mode.
|
||||
|
||||
stdpccts.h
|
||||
list of definitions needed by C files, not generated by
|
||||
PCCTS, that reference PCCTS objects. This is not gen-
|
||||
erated by default. Not used in C++ mode.
|
||||
|
||||
tokens.h
|
||||
output #_d_e_f_i_n_e_s for tokens used and function prototypes
|
||||
for functions generated for rules.
|
||||
|
||||
|
||||
SEE ALSO
|
||||
dlg(1), pccts(1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
1025
Tools/CodeTools/Source/Pccts/antlr/bits.c
Normal file
1025
Tools/CodeTools/Source/Pccts/antlr/bits.c
Normal file
File diff suppressed because it is too large
Load Diff
813
Tools/CodeTools/Source/Pccts/antlr/build.c
Normal file
813
Tools/CodeTools/Source/Pccts/antlr/build.c
Normal file
@@ -0,0 +1,813 @@
|
||||
/*
|
||||
* build.c -- functions associated with building syntax diagrams.
|
||||
*
|
||||
* 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.33
|
||||
* Terence Parr
|
||||
* Parr Research Corporation
|
||||
* with Purdue University and AHPCRC, University of Minnesota
|
||||
* 1989-2001
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "pcctscfg.h"
|
||||
#include "set.h"
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
#include "dlgdef.h"
|
||||
|
||||
#define SetBlk(g, t, approx, first_set_symbol) { \
|
||||
((Junction *)g.left)->jtype = t; \
|
||||
((Junction *)g.left)->approx = approx; \
|
||||
((Junction *)g.left)->pFirstSetSymbol = first_set_symbol; \
|
||||
((Junction *)g.left)->end = (Junction *) g.right; \
|
||||
((Junction *)g.right)->jtype = EndBlk;}
|
||||
|
||||
/* Add the parameter string 'parm' to the parms field of a block-type junction
|
||||
* g.left points to the sentinel node on a block. i.e. g.left->p1 points to
|
||||
* the actual junction with its jtype == some block-type.
|
||||
*/
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
addParm( Node *p, char *parm )
|
||||
#else
|
||||
addParm( p, parm )
|
||||
Node *p;
|
||||
char *parm;
|
||||
#endif
|
||||
{
|
||||
char *q = (char *) malloc( strlen(parm) + 1 );
|
||||
require(p!=NULL, "addParm: NULL object\n");
|
||||
require(q!=NULL, "addParm: unable to alloc parameter\n");
|
||||
|
||||
strcpy(q, parm);
|
||||
if ( p->ntype == nRuleRef )
|
||||
{
|
||||
((RuleRefNode *)p)->parms = q;
|
||||
}
|
||||
else if ( p->ntype == nJunction )
|
||||
{
|
||||
((Junction *)p)->parm = q; /* only one parameter allowed on subrules */
|
||||
}
|
||||
else fatal_internal("addParm: invalid node for adding parm");
|
||||
}
|
||||
|
||||
/*
|
||||
* Build an action node for the syntax diagram
|
||||
*
|
||||
* buildAction(ACTION) ::= --o-->ACTION-->o--
|
||||
*
|
||||
* Where o is a junction node.
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
buildAction( char *action, int file, int line, int is_predicate )
|
||||
#else
|
||||
buildAction( action, file, line, is_predicate )
|
||||
char *action;
|
||||
int file;
|
||||
int line;
|
||||
int is_predicate;
|
||||
#endif
|
||||
{
|
||||
Junction *j1, *j2;
|
||||
Graph g;
|
||||
ActionNode *a;
|
||||
require(action!=NULL, "buildAction: invalid action");
|
||||
|
||||
j1 = newJunction();
|
||||
j2 = newJunction();
|
||||
a = newActionNode();
|
||||
a->action = (char *) malloc( strlen(action)+1 );
|
||||
require(a->action!=NULL, "buildAction: cannot alloc space for action\n");
|
||||
strcpy(a->action, action);
|
||||
j1->p1 = (Node *) a;
|
||||
a->next = (Node *) j2;
|
||||
a->is_predicate = is_predicate;
|
||||
|
||||
if (is_predicate) {
|
||||
PredEntry *predEntry;
|
||||
char *t;
|
||||
char *key;
|
||||
char *u;
|
||||
int inverted=0;
|
||||
|
||||
t=key=(char *)calloc(1,strlen(a->action)+1);
|
||||
|
||||
for (u=a->action; *u != '\0' ; u++) {
|
||||
if (*u != ' ') {
|
||||
if (t==key && *u=='!') {
|
||||
inverted=!inverted;
|
||||
} else {
|
||||
*t++=*u;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
*t='\0';
|
||||
|
||||
|
||||
predEntry=(PredEntry *)hash_get(Pname,key);
|
||||
a->predEntry=predEntry;
|
||||
if (predEntry != NULL) a->inverted=inverted;
|
||||
} else {
|
||||
/* MR12c */ char *strStart=a->action;
|
||||
/* MR12c */ char *strEnd;
|
||||
/* MR12c */ strEnd=strStart+strlen(strStart)-1;
|
||||
/* MR12c */ for ( ; strEnd >= strStart && isspace(*strEnd); strEnd--) *strEnd=0;
|
||||
/* MR12c */ while (*strStart != '\0' && isspace(*strStart)) strStart++;
|
||||
/* MR12c */ if (ci_strequ(strStart,"nohoist")) {
|
||||
/* MR12c */ a->noHoist=1;
|
||||
/* MR12c */ }
|
||||
}
|
||||
|
||||
g.left = (Node *) j1; g.right = (Node *) j2;
|
||||
a->file = file;
|
||||
a->line = line;
|
||||
a->rname = CurRule; /* MR10 */
|
||||
return g;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build a token node for the syntax diagram
|
||||
*
|
||||
* buildToken(TOKEN) ::= --o-->TOKEN-->o--
|
||||
*
|
||||
* Where o is a junction node.
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
buildToken( char *text )
|
||||
#else
|
||||
buildToken( text )
|
||||
char *text;
|
||||
#endif
|
||||
{
|
||||
Junction *j1, *j2;
|
||||
Graph g;
|
||||
TokNode *t;
|
||||
require(text!=NULL, "buildToken: invalid token name");
|
||||
|
||||
j1 = newJunction();
|
||||
j2 = newJunction();
|
||||
t = newTokNode();
|
||||
t->altstart = CurAltStart;
|
||||
if ( *text == '"' ) {t->label=FALSE; t->token = addTexpr( text );}
|
||||
else {t->label=TRUE; t->token = addTname( text );}
|
||||
j1->p1 = (Node *) t;
|
||||
t->next = (Node *) j2;
|
||||
g.left = (Node *) j1; g.right = (Node *) j2;
|
||||
return g;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build a wild-card node for the syntax diagram
|
||||
*
|
||||
* buildToken(TOKEN) ::= --o-->'.'-->o--
|
||||
*
|
||||
* Where o is a junction node.
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
buildWildCard( char *text )
|
||||
#else
|
||||
buildWildCard( text )
|
||||
char *text;
|
||||
#endif
|
||||
{
|
||||
Junction *j1, *j2;
|
||||
Graph g;
|
||||
TokNode *t;
|
||||
TCnode *w;
|
||||
TermEntry *p;
|
||||
require(text!=NULL, "buildWildCard: invalid token name");
|
||||
|
||||
j1 = newJunction();
|
||||
j2 = newJunction();
|
||||
t = newTokNode();
|
||||
|
||||
/* If the ref a wild card, make a token class for it */
|
||||
if ( Tnum(WildCardString) == 0 )
|
||||
{
|
||||
w = newTCnode;
|
||||
w->tok = addTname( WildCardString );
|
||||
set_orel(w->tok, &imag_tokens);
|
||||
set_orel(w->tok, &tokclasses);
|
||||
WildCardToken = w->tok;
|
||||
require((p=(TermEntry *)hash_get(Tname, WildCardString)) != NULL,
|
||||
"hash table mechanism is broken");
|
||||
p->classname = 1; /* entry is class name, not token */
|
||||
p->tclass = w; /* save ptr to this tclass def */
|
||||
list_add(&tclasses, (char *)w);
|
||||
}
|
||||
else {
|
||||
p=(TermEntry *)hash_get(Tname, WildCardString);
|
||||
require( p!= NULL, "hash table mechanism is broken");
|
||||
w = p->tclass;
|
||||
}
|
||||
|
||||
t->token = w->tok;
|
||||
t->wild_card = 1;
|
||||
t->tclass = w;
|
||||
|
||||
t->altstart = CurAltStart;
|
||||
j1->p1 = (Node *) t;
|
||||
t->next = (Node *) j2;
|
||||
g.left = (Node *) j1; g.right = (Node *) j2;
|
||||
return g;
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
setUpperRange(TokNode *t, char *text)
|
||||
#else
|
||||
setUpperRange(t, text)
|
||||
TokNode *t;
|
||||
char *text;
|
||||
#endif
|
||||
{
|
||||
require(t!=NULL, "setUpperRange: NULL token node");
|
||||
require(text!=NULL, "setUpperRange: NULL token string");
|
||||
|
||||
if ( *text == '"' ) {t->upper_range = addTexpr( text );}
|
||||
else {t->upper_range = addTname( text );}
|
||||
}
|
||||
|
||||
/*
|
||||
* Build a rule reference node of the syntax diagram
|
||||
*
|
||||
* buildRuleRef(RULE) ::= --o-->RULE-->o--
|
||||
*
|
||||
* Where o is a junction node.
|
||||
*
|
||||
* If rule 'text' has been defined already, don't alloc new space to store string.
|
||||
* Set r->text to point to old copy in string table.
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
buildRuleRef( char *text )
|
||||
#else
|
||||
buildRuleRef( text )
|
||||
char *text;
|
||||
#endif
|
||||
{
|
||||
Junction *j1, *j2;
|
||||
Graph g;
|
||||
RuleRefNode *r;
|
||||
RuleEntry *p;
|
||||
require(text!=NULL, "buildRuleRef: invalid rule name");
|
||||
|
||||
j1 = newJunction();
|
||||
j2 = newJunction();
|
||||
r = newRNode();
|
||||
r->altstart = CurAltStart;
|
||||
r->assign = NULL;
|
||||
if ( (p=(RuleEntry *)hash_get(Rname, text)) != NULL ) r->text = p->str;
|
||||
else r->text = mystrdup( text );
|
||||
j1->p1 = (Node *) r;
|
||||
r->next = (Node *) j2;
|
||||
g.left = (Node *) j1; g.right = (Node *) j2;
|
||||
return g;
|
||||
}
|
||||
|
||||
/*
|
||||
* Or two subgraphs into one graph via:
|
||||
*
|
||||
* Or(G1, G2) ::= --o-G1-o--
|
||||
* | ^
|
||||
* v |
|
||||
* o-G2-o
|
||||
*
|
||||
* Set the altnum of junction starting G2 to 1 + altnum of junction starting G1.
|
||||
* If, however, the G1 altnum is 0, make it 1 and then
|
||||
* make G2 altnum = G1 altnum + 1.
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
Or( Graph g1, Graph g2 )
|
||||
#else
|
||||
Or( g1, g2 )
|
||||
Graph g1;
|
||||
Graph g2;
|
||||
#endif
|
||||
{
|
||||
Graph g;
|
||||
require(g1.left != NULL, "Or: invalid graph");
|
||||
require(g2.left != NULL && g2.right != NULL, "Or: invalid graph");
|
||||
|
||||
((Junction *)g1.left)->p2 = g2.left;
|
||||
((Junction *)g2.right)->p1 = g1.right;
|
||||
/* set altnums */
|
||||
if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;
|
||||
((Junction *)g2.left)->altnum = ((Junction *)g1.left)->altnum + 1;
|
||||
g.left = g2.left;
|
||||
g.right = g1.right;
|
||||
return g;
|
||||
}
|
||||
|
||||
/*
|
||||
* Catenate two subgraphs
|
||||
*
|
||||
* Cat(G1, G2) ::= --o-G1-o-->o-G2-o--
|
||||
* Cat(NULL,G2)::= --o-G2-o--
|
||||
* Cat(G1,NULL)::= --o-G1-o--
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
Cat( Graph g1, Graph g2 )
|
||||
#else
|
||||
Cat( g1, g2 )
|
||||
Graph g1;
|
||||
Graph g2;
|
||||
#endif
|
||||
{
|
||||
Graph g;
|
||||
|
||||
if ( g1.left == NULL && g1.right == NULL ) return g2;
|
||||
if ( g2.left == NULL && g2.right == NULL ) return g1;
|
||||
((Junction *)g1.right)->p1 = g2.left;
|
||||
g.left = g1.left;
|
||||
g.right = g2.right;
|
||||
return g;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a subgraph an optional block
|
||||
*
|
||||
* makeOpt(G) ::= --o-->o-G-o-->o--
|
||||
* | ^
|
||||
* v |
|
||||
* o-------o
|
||||
*
|
||||
* Note that this constructs {A|B|...|Z} as if (A|B|...|Z|) was found.
|
||||
*
|
||||
* The node on the far right is added so that every block owns its own
|
||||
* EndBlk node.
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
makeOpt( Graph g1, int approx, char * pFirstSetSymbol )
|
||||
#else
|
||||
makeOpt( g1, approx, pFirstSetSymbol )
|
||||
Graph g1;
|
||||
int approx;
|
||||
char * pFirstSetSymbol;
|
||||
#endif
|
||||
{
|
||||
Junction *j1,*j2,*p;
|
||||
Graph g;
|
||||
require(g1.left != NULL && g1.right != NULL, "makeOpt: invalid graph");
|
||||
|
||||
j1 = newJunction();
|
||||
j2 = newJunction();
|
||||
((Junction *)g1.right)->p1 = (Node *) j2; /* add node to G at end */
|
||||
|
||||
/* MR21
|
||||
*
|
||||
* There is code in genBlk which recognizes the node created
|
||||
* by emptyAlt() as a special case and bypasses it. We don't
|
||||
* want this to happen for the optBlk.
|
||||
*/
|
||||
|
||||
g = emptyAlt3(); /* MR21 */
|
||||
if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;
|
||||
((Junction *)g.left)->altnum = ((Junction *)g1.left)->altnum + 1;
|
||||
for(p=(Junction *)g1.left; p->p2!=NULL; p=(Junction *)p->p2)
|
||||
{;} /* find last alt */
|
||||
p->p2 = g.left; /* add optional alternative */
|
||||
((Junction *)g.right)->p1 = (Node *)j2; /* opt alt points to EndBlk */
|
||||
g1.right = (Node *)j2;
|
||||
SetBlk(g1, aOptBlk, approx, pFirstSetSymbol);
|
||||
j1->p1 = g1.left; /* add generic node in front */
|
||||
g.left = (Node *) j1;
|
||||
g.right = g1.right;
|
||||
return g;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a graph into subblock
|
||||
*
|
||||
* makeBlk(G) ::= --o-->o-G-o-->o--
|
||||
*
|
||||
* The node on the far right is added so that every block owns its own
|
||||
* EndBlk node.
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
makeBlk( Graph g1, int approx, char * pFirstSetSymbol )
|
||||
#else
|
||||
makeBlk( g1, approx, pFirstSetSymbol )
|
||||
Graph g1;
|
||||
int approx;
|
||||
char * pFirstSetSymbol;
|
||||
#endif
|
||||
{
|
||||
Junction *j,*j2;
|
||||
Graph g;
|
||||
require(g1.left != NULL && g1.right != NULL, "makeBlk: invalid graph");
|
||||
|
||||
j = newJunction();
|
||||
j2 = newJunction();
|
||||
((Junction *)g1.right)->p1 = (Node *) j2; /* add node to G at end */
|
||||
g1.right = (Node *)j2;
|
||||
SetBlk(g1, aSubBlk, approx, pFirstSetSymbol);
|
||||
j->p1 = g1.left; /* add node in front */
|
||||
g.left = (Node *) j;
|
||||
g.right = g1.right;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a subgraph into a loop (closure) block -- (...)*
|
||||
*
|
||||
* makeLoop(G) ::= |---|
|
||||
* v |
|
||||
* --o-->o-->o-G-o-->o--
|
||||
* | ^
|
||||
* v |
|
||||
* o-----------o
|
||||
*
|
||||
* After making loop, always place generic node out front. It becomes
|
||||
* the start of enclosing block. The aLoopBlk is the target of the loop.
|
||||
*
|
||||
* Loop blks have TWO EndBlk nodes--the far right and the node that loops back
|
||||
* to the aLoopBlk node. Node with which we can branch past loop == aLoopBegin and
|
||||
* one which is loop target == aLoopBlk.
|
||||
* The branch-past (initial) aLoopBegin node has end
|
||||
* pointing to the last EndBlk node. The loop-target node has end==NULL.
|
||||
*
|
||||
* Loop blocks have a set of locks (from 1..CLL_k) on the aLoopBlk node.
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
makeLoop( Graph g1, int approx, char * pFirstSetSymbol )
|
||||
#else
|
||||
makeLoop( g1, approx, pFirstSetSymbol)
|
||||
Graph g1;
|
||||
int approx;
|
||||
char * pFirstSetSymbol;
|
||||
#endif
|
||||
{
|
||||
Junction *back, *front, *begin;
|
||||
Graph g;
|
||||
require(g1.left != NULL && g1.right != NULL, "makeLoop: invalid graph");
|
||||
|
||||
back = newJunction();
|
||||
front = newJunction();
|
||||
begin = newJunction();
|
||||
g = emptyAlt3();
|
||||
((Junction *)g1.right)->p2 = g1.left; /* add loop branch to G */
|
||||
((Junction *)g1.right)->p1 = (Node *) back; /* add node to G at end */
|
||||
((Junction *)g1.right)->jtype = EndBlk; /* mark 1st EndBlk node */
|
||||
((Junction *)g1.left)->jtype = aLoopBlk; /* mark 2nd aLoopBlk node */
|
||||
((Junction *)g1.left)->end = (Junction *) g1.right;
|
||||
((Junction *)g1.left)->lock = makelocks();
|
||||
((Junction *)g1.left)->pred_lock = makelocks();
|
||||
g1.right = (Node *) back;
|
||||
begin->p1 = (Node *) g1.left;
|
||||
g1.left = (Node *) begin;
|
||||
begin->p2 = (Node *) g.left; /* make bypass arc */
|
||||
((Junction *)g.right)->p1 = (Node *) back;
|
||||
SetBlk(g1, aLoopBegin, approx, pFirstSetSymbol);
|
||||
front->p1 = g1.left; /* add node to front */
|
||||
g1.left = (Node *) front;
|
||||
|
||||
return g1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a subgraph into a plus block -- (...)+ -- 1 or more times
|
||||
*
|
||||
* makePlus(G) ::= |---|
|
||||
* v |
|
||||
* --o-->o-G-o-->o--
|
||||
*
|
||||
* After making loop, always place generic node out front. It becomes
|
||||
* the start of enclosing block. The aPlusBlk is the target of the loop.
|
||||
*
|
||||
* Plus blks have TWO EndBlk nodes--the far right and the node that loops back
|
||||
* to the aPlusBlk node.
|
||||
*
|
||||
* Plus blocks have a set of locks (from 1..CLL_k) on the aPlusBlk node.
|
||||
*/
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
makePlus( Graph g1, int approx, char * pFirstSetSymbol)
|
||||
#else
|
||||
makePlus( g1, approx, pFirstSetSymbol)
|
||||
Graph g1;
|
||||
int approx;
|
||||
char * pFirstSetSymbol;
|
||||
#endif
|
||||
{
|
||||
int has_empty_alt_already = 0;
|
||||
Graph g;
|
||||
Junction *j2, *j3, *first_alt;
|
||||
Junction *last_alt=NULL, *p;
|
||||
require(g1.left != NULL && g1.right != NULL, "makePlus: invalid graph");
|
||||
|
||||
first_alt = (Junction *)g1.left;
|
||||
j2 = newJunction();
|
||||
j3 = newJunction();
|
||||
if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;
|
||||
((Junction *)g1.right)->p2 = g1.left; /* add loop branch to G */
|
||||
((Junction *)g1.right)->p1 = (Node *) j2; /* add node to G at end */
|
||||
((Junction *)g1.right)->jtype = EndBlk; /* mark 1st EndBlk node */
|
||||
g1.right = (Node *) j2;
|
||||
SetBlk(g1, aPlusBlk, approx, pFirstSetSymbol);
|
||||
((Junction *)g1.left)->lock = makelocks();
|
||||
((Junction *)g1.left)->pred_lock = makelocks();
|
||||
j3->p1 = g1.left; /* add node to front */
|
||||
g1.left = (Node *) j3;
|
||||
|
||||
/* add an optional branch which is the "exit" branch of loop */
|
||||
/* FIRST, check to ensure that there does not already exist
|
||||
* an optional path.
|
||||
*/
|
||||
/* find last alt */
|
||||
for(p=first_alt; p!=NULL; p=(Junction *)p->p2)
|
||||
{
|
||||
if ( p->p1->ntype == nJunction &&
|
||||
p->p1!=NULL &&
|
||||
((Junction *)p->p1)->jtype==Generic &&
|
||||
((Junction *)p->p1)->p1!=NULL &&
|
||||
((Junction *)((Junction *)p->p1)->p1)->jtype==EndBlk )
|
||||
{
|
||||
has_empty_alt_already = 1;
|
||||
}
|
||||
last_alt = p;
|
||||
}
|
||||
if ( !has_empty_alt_already )
|
||||
{
|
||||
require(last_alt!=NULL, "last_alt==NULL; bad (..)+");
|
||||
g = emptyAlt();
|
||||
last_alt->p2 = g.left;
|
||||
((Junction *)g.right)->p1 = (Node *) j2;
|
||||
|
||||
/* make sure lookahead computation ignores this alt for
|
||||
* FIRST("(..)+"); but it's still used for computing the FIRST
|
||||
* of each alternative.
|
||||
*/
|
||||
((Junction *)g.left)->ignore = 1;
|
||||
}
|
||||
|
||||
return g1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return an optional path: --o-->o--
|
||||
*/
|
||||
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
emptyAlt( void )
|
||||
#else
|
||||
emptyAlt( )
|
||||
#endif
|
||||
{
|
||||
Junction *j1, *j2;
|
||||
Graph g;
|
||||
|
||||
j1 = newJunction();
|
||||
j2 = newJunction();
|
||||
j1->p1 = (Node *) j2;
|
||||
g.left = (Node *) j1;
|
||||
g.right = (Node *) j2;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
/* MR21
|
||||
*
|
||||
* There is code in genBlk which recognizes the node created
|
||||
* by emptyAlt() as a special case and bypasses it. We don't
|
||||
* want this to happen for the optBlk.
|
||||
*/
|
||||
|
||||
Graph
|
||||
#ifdef __USE_PROTOS
|
||||
emptyAlt3( void )
|
||||
#else
|
||||
emptyAlt3( )
|
||||
#endif
|
||||
{
|
||||
Junction *j1, *j2, *j3;
|
||||
Graph g;
|
||||
|
||||
j1 = newJunction();
|
||||
j2 = newJunction();
|
||||
j3 = newJunction();
|
||||
j1->p1 = (Node *) j2;
|
||||
j2->p1 = (Node *) j3;
|
||||
g.left = (Node *) j1;
|
||||
g.right = (Node *) j3;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
/* N o d e A l l o c a t i o n */
|
||||
|
||||
TokNode *
|
||||
#ifdef __USE_PROTOS
|
||||
newTokNode( void )
|
||||
#else
|
||||
newTokNode( )
|
||||
#endif
|
||||
{
|
||||
static TokNode *FreeList = NULL;
|
||||
TokNode *p, *newblk;
|
||||
|
||||
if ( FreeList == NULL )
|
||||
{
|
||||
newblk = (TokNode *)calloc(TokenBlockAllocSize, sizeof(TokNode));
|
||||
if ( newblk == NULL )
|
||||
fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));
|
||||
for (p=newblk; p<&(newblk[TokenBlockAllocSize]); p++)
|
||||
{
|
||||
p->next = (Node *)FreeList; /* add all new token nodes to FreeList */
|
||||
FreeList = p;
|
||||
}
|
||||
}
|
||||
p = FreeList;
|
||||
FreeList = (TokNode *)FreeList->next;/* remove a TokNode node */
|
||||
p->next = NULL; /* NULL the ptr we used */
|
||||
memset( (char *) p, 0, sizeof(TokNode)); /* MR10 */
|
||||
p->ntype = nToken;
|
||||
p->rname = CurRule;
|
||||
p->file = CurFile;
|
||||
p->line = zzline;
|
||||
p->altstart = NULL;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
RuleRefNode *
|
||||
#ifdef __USE_PROTOS
|
||||
newRNode( void )
|
||||
#else
|
||||
newRNode( )
|
||||
#endif
|
||||
{
|
||||
static RuleRefNode *FreeList = NULL;
|
||||
RuleRefNode *p, *newblk;
|
||||
|
||||
if ( FreeList == NULL )
|
||||
{
|
||||
newblk = (RuleRefNode *)calloc(RRefBlockAllocSize, sizeof(RuleRefNode));
|
||||
if ( newblk == NULL )
|
||||
fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));
|
||||
for (p=newblk; p<&(newblk[RRefBlockAllocSize]); p++)
|
||||
{
|
||||
p->next = (Node *)FreeList; /* add all new rref nodes to FreeList */
|
||||
FreeList = p;
|
||||
}
|
||||
}
|
||||
p = FreeList;
|
||||
FreeList = (RuleRefNode *)FreeList->next;/* remove a Junction node */
|
||||
p->next = NULL; /* NULL the ptr we used */
|
||||
memset( (char *) p, 0, sizeof(RuleRefNode)); /* MR10 */
|
||||
p->ntype = nRuleRef;
|
||||
p->rname = CurRule;
|
||||
p->file = CurFile;
|
||||
p->line = zzline;
|
||||
p->astnode = ASTinclude;
|
||||
p->altstart = NULL;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static int junctionSeqNumber=0; /* MR10 */
|
||||
|
||||
Junction *
|
||||
#ifdef __USE_PROTOS
|
||||
newJunction( void )
|
||||
#else
|
||||
newJunction( )
|
||||
#endif
|
||||
{
|
||||
static Junction *FreeList = NULL;
|
||||
Junction *p, *newblk;
|
||||
|
||||
if ( FreeList == NULL )
|
||||
{
|
||||
newblk = (Junction *)calloc(JunctionBlockAllocSize, sizeof(Junction));
|
||||
if ( newblk == NULL )
|
||||
fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));
|
||||
for (p=newblk; p<&(newblk[JunctionBlockAllocSize]); p++)
|
||||
{
|
||||
p->p1 = (Node *)FreeList; /* add all new Junction nodes to FreeList */
|
||||
FreeList = p;
|
||||
}
|
||||
}
|
||||
p = FreeList;
|
||||
FreeList = (Junction *)FreeList->p1;/* remove a Junction node */
|
||||
p->p1 = NULL; /* NULL the ptr we used */
|
||||
memset( (char *) p, 0, sizeof(Junction)); /* MR10 */
|
||||
p->ntype = nJunction;
|
||||
p->visited = 0;
|
||||
p->jtype = Generic;
|
||||
p->rname = CurRule;
|
||||
p->file = CurFile;
|
||||
p->line = zzline;
|
||||
p->exception_label = NULL;
|
||||
p->fset = (set *) calloc(CLL_k+1, sizeof(set));
|
||||
require(p->fset!=NULL, "cannot allocate fset in newJunction");
|
||||
p->seq=++junctionSeqNumber; /* MR10 */
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
ActionNode *
|
||||
#ifdef __USE_PROTOS
|
||||
newActionNode( void )
|
||||
#else
|
||||
newActionNode( )
|
||||
#endif
|
||||
{
|
||||
static ActionNode *FreeList = NULL;
|
||||
ActionNode *p, *newblk;
|
||||
|
||||
if ( FreeList == NULL )
|
||||
{
|
||||
newblk = (ActionNode *)calloc(ActionBlockAllocSize, sizeof(ActionNode));
|
||||
if ( newblk == NULL )
|
||||
fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));
|
||||
for (p=newblk; p<&(newblk[ActionBlockAllocSize]); p++)
|
||||
{
|
||||
p->next = (Node *)FreeList; /* add all new Action nodes to FreeList */
|
||||
FreeList = p;
|
||||
}
|
||||
}
|
||||
p = FreeList;
|
||||
FreeList = (ActionNode *)FreeList->next;/* remove an Action node */
|
||||
memset( (char *) p, 0, sizeof(ActionNode)); /* MR10 */
|
||||
p->ntype = nAction;
|
||||
p->next = NULL; /* NULL the ptr we used */
|
||||
p->done = 0;
|
||||
p->pred_fail = NULL;
|
||||
p->guardpred = NULL;
|
||||
p->ampersandPred = NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* allocate the array of locks (1..CLL_k) used to inhibit infinite recursion.
|
||||
* Infinite recursion can occur in (..)* blocks, FIRST calcs and FOLLOW calcs.
|
||||
* Therefore, we need locks on aLoopBlk, RuleBlk, EndRule nodes.
|
||||
*
|
||||
* if ( lock[k]==TRUE ) then we have been here before looking for k tokens
|
||||
* of lookahead.
|
||||
*/
|
||||
char *
|
||||
#ifdef __USE_PROTOS
|
||||
makelocks( void )
|
||||
#else
|
||||
makelocks( )
|
||||
#endif
|
||||
{
|
||||
char *p = (char *) calloc(CLL_k+1, sizeof(char));
|
||||
require(p!=NULL, "cannot allocate lock array");
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
#if 0
|
||||
** #ifdef __USE_PROTOS
|
||||
** void my_memset(char *p,char value,int count)
|
||||
** #else
|
||||
** void my_memset(p,value,count)
|
||||
** char *p;
|
||||
** char value;
|
||||
** int count;
|
||||
** #endif
|
||||
** {
|
||||
** int i;
|
||||
**
|
||||
** for (i=0; i<count; i++) {
|
||||
** p[i]=value;
|
||||
** };
|
||||
** }
|
||||
#endif
|
129
Tools/CodeTools/Source/Pccts/antlr/build.xml
Normal file
129
Tools/CodeTools/Source/Pccts/antlr/build.xml
Normal file
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" ?>
|
||||
<!--
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
-->
|
||||
<project default="GenTool" basedir=".">
|
||||
<!--
|
||||
EDK antlr Tool
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
-->
|
||||
<property name="ToolName" value="antlr"/>
|
||||
|
||||
<taskdef resource="cpptasks.tasks"/>
|
||||
<typedef resource="cpptasks.types"/>
|
||||
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
|
||||
|
||||
<target name="init">
|
||||
<condition property="CheckDepends">
|
||||
<uptodate targetfile="${WORKSPACE}/Tools/bin/antlr.exe">
|
||||
<srcfiles dir="." includes="*.c *.h *.g"/>
|
||||
</uptodate>
|
||||
</condition>
|
||||
<if>
|
||||
<equals arg1="${CheckDepends}" arg2="true"/>
|
||||
<then>
|
||||
<echo message="Executable, antlr.exe, is up to date."/>
|
||||
</then>
|
||||
<else>
|
||||
<echo message="Building the EDK Pccts Tool: ${ToolName}"/>
|
||||
</else>
|
||||
</if>
|
||||
</target>
|
||||
|
||||
<target name="GenTool" depends="init" unless="CheckDepends">
|
||||
<if>
|
||||
<equals arg1="${ToolChain}" arg2="msvc"/>
|
||||
<then>
|
||||
<exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="nmake" failonerror="TRUE">
|
||||
<arg line="-f AntlrMS.mak"/>
|
||||
</exec>
|
||||
</then>
|
||||
<elseif>
|
||||
<istrue value="${cygwin}"/>
|
||||
<then>
|
||||
<exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">
|
||||
<arg line="-f makefile.cygwin"/>
|
||||
</exec>
|
||||
</then>
|
||||
</elseif>
|
||||
<elseif>
|
||||
<istrue value="${gcc}"/>
|
||||
<then>
|
||||
<exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">
|
||||
<arg line="-f makefile BIN_DIR=${BIN_DIR}"/>
|
||||
</exec>
|
||||
</then>
|
||||
</elseif>
|
||||
</if>
|
||||
<echo message="The EDK Tool: ${ToolName} build has completed!"/>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<echo message="Removing Intermediate Files Only"/>
|
||||
<if>
|
||||
<equals arg1="${ToolChain}" arg2="msvc"/>
|
||||
<then>
|
||||
<exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="nmake" failonerror="TRUE">
|
||||
<arg line="-f AntlrMS.mak clean"/>
|
||||
</exec>
|
||||
</then>
|
||||
<elseif>
|
||||
<istrue value="${cygwin}"/>
|
||||
<then>
|
||||
<exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">
|
||||
<arg line="-f makefile.cygwin clean"/>
|
||||
</exec>
|
||||
</then>
|
||||
</elseif>
|
||||
<elseif>
|
||||
<istrue value="${gcc}"/>
|
||||
<then>
|
||||
<exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">
|
||||
<arg line="-f makefile clean"/>
|
||||
</exec>
|
||||
</then>
|
||||
</elseif>
|
||||
</if>
|
||||
</target>
|
||||
|
||||
<target name="cleanall">
|
||||
<echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>
|
||||
<if>
|
||||
<equals arg1="${ToolChain}" arg2="msvc"/>
|
||||
<then>
|
||||
<exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="nmake" failonerror="FALSE">
|
||||
<arg line="-f AntlrMS.mak clean"/>
|
||||
</exec>
|
||||
</then>
|
||||
<elseif>
|
||||
<istrue value="${cygwin}"/>
|
||||
<then>
|
||||
<echo message="Building antlr with cygwin gcc"/>
|
||||
<exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="FALSE">
|
||||
<arg line="-f makefile.cygwin clean"/>
|
||||
</exec>
|
||||
</then>
|
||||
</elseif>
|
||||
<elseif>
|
||||
<istrue value="${gcc}"/>
|
||||
<then>
|
||||
<echo message="Building antlr with gcc"/>
|
||||
<exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="FALSE">
|
||||
<arg line="-f makefile clean"/>
|
||||
</exec>
|
||||
</then>
|
||||
</elseif>
|
||||
</if>
|
||||
<delete failonerror="false" quiet="true" includeEmptyDirs="true">
|
||||
<fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
</project>
|
67
Tools/CodeTools/Source/Pccts/antlr/dumpcycles.c
Normal file
67
Tools/CodeTools/Source/Pccts/antlr/dumpcycles.c
Normal file
@@ -0,0 +1,67 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "set.h"
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
dumpcycles(void)
|
||||
#else
|
||||
dumpcycles()
|
||||
#endif
|
||||
{
|
||||
Cycle *c;
|
||||
CacheEntry *f;
|
||||
ListNode *p;
|
||||
int i=0;
|
||||
int k;
|
||||
int degree;
|
||||
|
||||
for (k=1; k <= CLL_k; k++) {
|
||||
if (Cycles[k] == NULL) continue;
|
||||
|
||||
for (p = Cycles[k]->next; p!=NULL; p=p->next) {
|
||||
c = (Cycle *) p->elem;
|
||||
degree=set_deg(c->cyclicDep);
|
||||
fprintf(stderr,"Cycle %d: (degree %d) %s -->\n", i++, degree, RulePtr[c->croot]->rname);
|
||||
fprintf(stderr," *self*\n");
|
||||
MR_dumpRuleSet(c->cyclicDep);
|
||||
fprintf(stderr,"\n");
|
||||
f = (CacheEntry *)
|
||||
hash_get(Fcache,Fkey(RulePtr[c->croot]->rname,'o',k));
|
||||
if (f == NULL) {
|
||||
fprintf(stderr," *** FOLLOW(%s) must be in cache but isn't ***\n",
|
||||
RulePtr[c->croot]->rname);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
dumpfostack(int k)
|
||||
#else
|
||||
dumpfostack(k)
|
||||
int k;
|
||||
#endif
|
||||
{
|
||||
int i=0;
|
||||
int *pi;
|
||||
|
||||
fprintf(stderr,"\n");
|
||||
if (FoStack[k] == NULL) {
|
||||
fprintf(stderr,"FoStack[%d] is null\n",k);
|
||||
};
|
||||
if (FoTOS[k] == NULL) {
|
||||
fprintf(stderr,"FoTOS[%d] is null\n",k);
|
||||
}
|
||||
if (FoTOS[k] != NULL && FoStack[k] != NULL) {
|
||||
for (pi=FoStack[k]; pi <= FoTOS[k]; pi++) {
|
||||
i++;
|
||||
fprintf(stderr,"#%d rule %d %s\n",i,*pi,RulePtr[*pi]->rname);
|
||||
}
|
||||
}
|
||||
}
|
423
Tools/CodeTools/Source/Pccts/antlr/dumpnode.c
Normal file
423
Tools/CodeTools/Source/Pccts/antlr/dumpnode.c
Normal file
@@ -0,0 +1,423 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "set.h"
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void dumpset1(set s)
|
||||
#else
|
||||
void dumpset1(s)
|
||||
set s;
|
||||
#endif
|
||||
{
|
||||
if (set_nil(s)) {
|
||||
fprintf(stderr,"{}");
|
||||
} else {
|
||||
s_fprT(stderr,s);
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void dumpset(set s)
|
||||
#else
|
||||
void dumpset(s)
|
||||
set s;
|
||||
#endif
|
||||
{
|
||||
dumpset1(s);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
int isEndRule(Node * p)
|
||||
#else
|
||||
int isEndRule(p)
|
||||
Node * p;
|
||||
#endif
|
||||
{
|
||||
int result=0;
|
||||
if ( p->ntype == nJunction &&
|
||||
( (Junction *) p)->jtype == EndRule) {
|
||||
result=1;
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void dumppred1(int depth,Predicate *p)
|
||||
#else
|
||||
void dumppred1(depth,p)
|
||||
int depth;
|
||||
Predicate *p;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
int k;
|
||||
|
||||
for (i=0; i<depth ; i++) {
|
||||
fprintf(stderr," ");
|
||||
};
|
||||
if (p->expr == PRED_AND_LIST ||
|
||||
p->expr == PRED_OR_LIST) {
|
||||
fprintf(stderr," %s", (p->expr == NULL ? "null expr" : p->expr));
|
||||
if (p->inverted) fprintf(stderr," predicate inverted !");
|
||||
if (p->redundant) {
|
||||
fprintf(stderr," Redundant!");
|
||||
};
|
||||
if (p->isConst) fprintf(stderr," const %d !",p->constValue);
|
||||
fprintf(stderr,"\n");
|
||||
} else {
|
||||
fprintf(stderr,"predicate k=%d",p->k);
|
||||
k=set_int(p->completionSet);
|
||||
if (k >= 0) {
|
||||
fprintf(stderr," Incomplete Set=%d !",k);
|
||||
};
|
||||
k=set_int(p->completionTree);
|
||||
if (k >= 0) {
|
||||
fprintf(stderr," Incomplete Tree=%d !",k);
|
||||
};
|
||||
if (p->redundant) {
|
||||
fprintf(stderr," Redundant!");
|
||||
};
|
||||
fprintf(stderr," \"%s\" (%x)", (p->expr == NULL ? "null expr" : p->expr) ,p);
|
||||
if (p->source != NULL) {
|
||||
fprintf(stderr,"line %d",p->source->line);
|
||||
};
|
||||
if (p->inverted) fprintf(stderr," predicate inverted !");
|
||||
fprintf(stderr,"\n");
|
||||
for (i=0; i<depth ; i++) {
|
||||
fprintf(stderr," ");
|
||||
};
|
||||
fprintf(stderr,"scontext: ");
|
||||
dumpset(p->scontext[1]);
|
||||
for (i=0; i<depth ; i++) {
|
||||
fprintf(stderr," ");
|
||||
};
|
||||
fprintf(stderr,"tcontext: ");
|
||||
preorder(p->tcontext);
|
||||
fprintf(stderr,"\n");
|
||||
};
|
||||
fprintf(stderr,"\n");
|
||||
if (p->down != NULL) {
|
||||
dumppred1(depth+1,p->down);
|
||||
};
|
||||
if (p->right != NULL) {
|
||||
dumppred1(depth,p->right);
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void dumppred(Predicate *p)
|
||||
#else
|
||||
void dumppred(p)
|
||||
Predicate *p;
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr,"---------------------------------\n");
|
||||
dumppred1(0,p);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void dumppredtree(Predicate *p)
|
||||
#else
|
||||
void dumppredtree(p)
|
||||
Predicate *p;
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr,"predicate k=%d \"%s\" line %d\n",p->k,p->expr,p->source->line);
|
||||
dumpset(p->scontext[1]);
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void dumppredexpr(Predicate *p)
|
||||
#else
|
||||
void dumppredexpr(p)
|
||||
Predicate *p;
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr," pred expr \"%s\"\n",p->expr);
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void dt(Tree *t)
|
||||
#else
|
||||
void dt(t)
|
||||
Tree *t;
|
||||
#endif
|
||||
{
|
||||
MR_dumpTreeF(stderr,0,t,5);
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void d(Node * p)
|
||||
#else
|
||||
void d(p)
|
||||
Node * p;
|
||||
#endif
|
||||
{
|
||||
|
||||
Junction *j;
|
||||
RuleRefNode *r;
|
||||
TokNode *t;
|
||||
ActionNode *a;
|
||||
|
||||
if (p==NULL) {
|
||||
fprintf(stderr,"dumpNode: Node is NULL");
|
||||
return;
|
||||
};
|
||||
|
||||
switch (p->ntype) {
|
||||
case nJunction :
|
||||
j = (Junction *) p;
|
||||
fprintf(stderr, "Junction (#%d in rule %s line %d) ",j->seq,j->rname,j->line);
|
||||
if (j->guess) fprintf(stderr,"guess block ");
|
||||
switch (j->jtype ) {
|
||||
case aSubBlk :
|
||||
fprintf(stderr,"aSubBlk");
|
||||
break;
|
||||
case aOptBlk :
|
||||
fprintf(stderr,"aOptBlk");
|
||||
break;
|
||||
case aLoopBegin :
|
||||
fprintf(stderr,"aLoopBeginBlk");
|
||||
break;
|
||||
case aLoopBlk :
|
||||
fprintf(stderr,"aLoopBlk");
|
||||
break;
|
||||
case aPlusBlk :
|
||||
fprintf(stderr,"aPlusBlk");
|
||||
break;
|
||||
case EndBlk :
|
||||
fprintf(stderr,"EndBlk");
|
||||
break;
|
||||
case RuleBlk :
|
||||
fprintf(stderr,"RuleBlk");
|
||||
break;
|
||||
case Generic :
|
||||
fprintf(stderr,"Generic");
|
||||
break;
|
||||
case EndRule :
|
||||
fprintf(stderr,"EndRule");
|
||||
break;
|
||||
};
|
||||
if (j->halt) fprintf(stderr," halt!");
|
||||
if (j->p1) fprintf(stderr," p1 valid");
|
||||
if (j->p2) {
|
||||
if (j->p2->ntype == nJunction) {
|
||||
fprintf(stderr," (p2=#%d)",( (Junction *) j->p2)->seq);
|
||||
} else {
|
||||
fprintf(stderr," (p2 valid)");
|
||||
};
|
||||
};
|
||||
if (j->ignore) fprintf(stderr, " ignore/plus-block-bypass");
|
||||
if (j->fset != NULL && set_deg(*j->fset) != 0) {
|
||||
fprintf(stderr,"\nfset:\n");
|
||||
dumpset(*j->fset);
|
||||
};
|
||||
if (j->ftree != NULL) {
|
||||
fprintf(stderr,"\nftree:\n");
|
||||
preorder(j->ftree);
|
||||
};
|
||||
fprintf(stderr,"\n");
|
||||
break;
|
||||
case nRuleRef :
|
||||
r = (RuleRefNode *) p;
|
||||
fprintf(stderr, "RuleRefNode (in rule %s line %d) to rule %s\n", r->rname,r->line,r->text);
|
||||
break;
|
||||
case nToken :
|
||||
t = (TokNode *) p;
|
||||
fprintf(stderr, "TokNode (in rule %s line %d) token %s\n",t->rname,t->line,TerminalString(t->token));
|
||||
break;
|
||||
case nAction :
|
||||
a =(ActionNode *) p;
|
||||
if (a->is_predicate) {
|
||||
fprintf(stderr, "Predicate (in rule %s line %d) %s",a->rname,a->line,a->action);
|
||||
if (a->inverted) fprintf(stderr," action inverted !");
|
||||
if (a->guardpred != NULL) {
|
||||
fprintf(stderr," guarded");
|
||||
dumppredexpr(a->guardpred);
|
||||
if (a->ampersandPred) {
|
||||
fprintf(stderr," \"&&\" style");
|
||||
} else {
|
||||
fprintf(stderr," \"=>\" style");
|
||||
};
|
||||
};
|
||||
if (a->predEntry != NULL) fprintf(stderr," predEntry \"%s\" ",a->predEntry->str);
|
||||
fprintf(stderr,"\n");
|
||||
} else if (a->init_action) {
|
||||
fprintf(stderr, "Init-Action (in rule %s line %d) %s\n",a->rname,a->line,a->action);
|
||||
} else {
|
||||
fprintf(stderr, "Action (in rule %s line %d) %s\n",a->rname,a->line,a->action);
|
||||
};
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Node * dp1(Node * p)
|
||||
#else
|
||||
Node * dp1(p)
|
||||
Node * p;
|
||||
#endif
|
||||
{
|
||||
Node *result=NULL;
|
||||
|
||||
if (p->ntype == nJunction) {
|
||||
result=( (Junction *) p )->p1;
|
||||
d(result);
|
||||
} else {
|
||||
fprintf(stderr,"dp1: Not a Junction node");
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Node * dp2(Node * p)
|
||||
#else
|
||||
Node * dp2(p)
|
||||
Node * p;
|
||||
#endif
|
||||
{
|
||||
Node *result=NULL;
|
||||
|
||||
if (p->ntype == nJunction) {
|
||||
result=( (Junction *) p )->p2;
|
||||
d(result);
|
||||
} else {
|
||||
fprintf(stderr,"dp2: Not a Junction node");
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Node * dn(Node * p)
|
||||
#else
|
||||
Node * dn(p)
|
||||
Node * p;
|
||||
#endif
|
||||
|
||||
{
|
||||
Node *result=NULL;
|
||||
|
||||
if (p->ntype == nRuleRef) {
|
||||
result=( (RuleRefNode *)p )->next;
|
||||
} else if (p->ntype == nAction) {
|
||||
result=( (ActionNode *)p )->next;
|
||||
} else if (p->ntype == nToken) {
|
||||
result=( (TokNode *)p )->next;
|
||||
} else {
|
||||
fprintf(stderr,"No next field: Neither a RuleRefNode, ActionNode, nor TokNode");
|
||||
};
|
||||
if (result != NULL) d(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void df(Node * p)
|
||||
#else
|
||||
void df(p)
|
||||
Node * p;
|
||||
#endif
|
||||
{
|
||||
int count=0;
|
||||
Node *next;
|
||||
|
||||
fprintf(stderr,"\n#%d ",++count);
|
||||
d(p);
|
||||
|
||||
for (next=p; next != NULL && !isEndRule(next) ; ) {
|
||||
fprintf(stderr,"#%d ",++count);
|
||||
if (next->ntype == nJunction) {
|
||||
next=dp1(next);
|
||||
} else {
|
||||
next=dn(next);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Node * dfn(Node * p,int target)
|
||||
#else
|
||||
Node * dfn(p,target)
|
||||
Node * p;
|
||||
int target;
|
||||
#endif
|
||||
{
|
||||
Node *result=NULL;
|
||||
int count=0;
|
||||
Node *next;
|
||||
|
||||
fprintf(stderr,"#%d ",++count);
|
||||
d(p);
|
||||
|
||||
for (next=p; next != NULL && !isEndRule(next) ; ) {
|
||||
fprintf(stderr,"#%d ",++count);
|
||||
if (next->ntype == nJunction) {
|
||||
next=dp1(next);
|
||||
} else {
|
||||
next=dn(next);
|
||||
};
|
||||
if (count == target) {
|
||||
result=next;
|
||||
break;
|
||||
};
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int findnodeMatch;
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Junction *findnode1(Node *n)
|
||||
#else
|
||||
Junction *findnode1(n)
|
||||
Node *n;
|
||||
#endif
|
||||
{
|
||||
Node *next;
|
||||
Junction *j;
|
||||
Junction *match;
|
||||
|
||||
if (n == NULL) return NULL;
|
||||
if (n->ntype == nJunction) {
|
||||
j=(Junction *) n;
|
||||
if (j->seq == findnodeMatch) return j;
|
||||
if (j->jtype == EndRule) return NULL;
|
||||
if (j->jtype != RuleBlk && j->jtype != EndBlk) {
|
||||
if (j->p2 != NULL && !j->ignore) {
|
||||
match=findnode1(j->p2);
|
||||
if (match != NULL) return match;
|
||||
};
|
||||
};
|
||||
};
|
||||
next=MR_advance(n);
|
||||
return findnode1(next);
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Junction *findnode(int match)
|
||||
#else
|
||||
Junction *findnode(match)
|
||||
int match;
|
||||
#endif
|
||||
{
|
||||
Junction *j;
|
||||
Junction *result=NULL;
|
||||
|
||||
findnodeMatch=match;
|
||||
|
||||
for (j=SynDiag; j != NULL; j=(Junction *)j->p2) {
|
||||
require (j->ntype == nJunction && j->jtype == RuleBlk,"Not a rule block");
|
||||
result=findnode1( (Node *) j);
|
||||
if (result != NULL) break;
|
||||
};
|
||||
if (result != NULL) {
|
||||
d( (Node *) result);
|
||||
};
|
||||
return result;
|
||||
}
|
328
Tools/CodeTools/Source/Pccts/antlr/egman.c
Normal file
328
Tools/CodeTools/Source/Pccts/antlr/egman.c
Normal file
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
* egman.c
|
||||
*
|
||||
* 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.33MR10
|
||||
* 2001
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "set.h"
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
#include "proto.h"
|
||||
|
||||
static ExceptionGroup **egArray=NULL; /* ExceptionGroup by BlkLevel */
|
||||
static LabelEntry **leArray=NULL; /* LabelEntry by BlkLevel */
|
||||
static Junction **altArray=NULL; /* start of alternates */
|
||||
static int arraySize=0;
|
||||
static int highWater=0;
|
||||
static ExceptionGroup *lastEG=NULL; /* used in altFixup() */
|
||||
static int lastBlkLevel=0; /* used in altFixup() */
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
static void arrayCheck(void);
|
||||
#else
|
||||
static void arrayCheck();
|
||||
#endif
|
||||
|
||||
/* Called to add an exception group for an alternative EG */
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void egAdd(ExceptionGroup * eg)
|
||||
#else
|
||||
void egAdd(eg)
|
||||
ExceptionGroup *eg;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
|
||||
ExceptionGroup *nextEG;
|
||||
ExceptionGroup *innerEG;
|
||||
|
||||
LabelEntry *nextLE;
|
||||
LabelEntry *innerLE;
|
||||
|
||||
Junction *nextAlt;
|
||||
Junction *innerAlt;
|
||||
|
||||
lastEG=eg;
|
||||
lastBlkLevel=BlkLevel;
|
||||
|
||||
arrayCheck();
|
||||
eg->pendingLink=egArray[BlkLevel];
|
||||
egArray[BlkLevel]=eg;
|
||||
|
||||
/* EG for alternates already have their altID filled in */
|
||||
|
||||
for (i=BlkLevel+1; i<=highWater ; i++) {
|
||||
for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {
|
||||
nextEG=innerEG->pendingLink;
|
||||
innerEG->pendingLink=NULL;
|
||||
innerEG->outerEG=eg;
|
||||
};
|
||||
egArray[i]=NULL;
|
||||
};
|
||||
|
||||
/*
|
||||
* for patching up the LabelEntry you might use an EG for the
|
||||
* current alternative - unlike patching up an alternative EG
|
||||
* i.e. start the loop at BlkLevel rather than (BlkLevel+1)
|
||||
* fill it in only if the EG and the LE are for the very
|
||||
* same alternative if they're at the same BlkLevel
|
||||
* it's easier to leave the LE on this list (filled in) rather than
|
||||
* trying to selectively remove it. It will eventually be
|
||||
* removed anyway when the BlkLevel gets small enough.
|
||||
*/
|
||||
|
||||
for (i=BlkLevel; i<=highWater ; i++) {
|
||||
for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {
|
||||
nextLE=innerLE->pendingLink;
|
||||
if (BlkLevel != i ||
|
||||
innerLE->curAltNum == CurAltNum_array[BlkLevel]) {
|
||||
if (innerLE->outerEG == NULL) {
|
||||
innerLE->outerEG=eg;
|
||||
};
|
||||
};
|
||||
};
|
||||
if (BlkLevel != i) leArray[i]=NULL;
|
||||
};
|
||||
|
||||
/*
|
||||
* For the start of alternatives it is necessary to make a
|
||||
* distinction between the exception group for the current
|
||||
* alternative and the "fallback" EG for the block which
|
||||
* contains the alternative
|
||||
*
|
||||
* The fallback outerEG is used to handle the case where
|
||||
* no alternative of a block matches. In that case the
|
||||
* signal is "NoViableAlt" (or "NoSemViableAlt" and the
|
||||
* generator needs the EG of the block CONTAINING the
|
||||
* current one.
|
||||
*
|
||||
* rule: ( ( ( a
|
||||
* | b
|
||||
* )
|
||||
* | c
|
||||
* )
|
||||
* | d
|
||||
* );
|
||||
*/
|
||||
|
||||
for (i=BlkLevel; i <= highWater ; i++) {
|
||||
for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {
|
||||
nextAlt=innerAlt->pendingLink;
|
||||
|
||||
/* first fill in the EG for the current alternative */
|
||||
/* but leave it on the list in order to get the fallback EG */
|
||||
/* if the EG is at the same LEVEL as the alternative then */
|
||||
/* fill it in only if in the very same alternative */
|
||||
/* */
|
||||
/* rule: ( a */
|
||||
/* | b */
|
||||
/* | c exception ... */
|
||||
/* ) */
|
||||
/* */
|
||||
/* if the EG is outside the alternative (e.g. BlkLevel < i) */
|
||||
/* then it doesn't matter about the alternative */
|
||||
/* */
|
||||
/* rule: ( a */
|
||||
/* | b */
|
||||
/* | c */
|
||||
/* ) exception ... */
|
||||
/* */
|
||||
|
||||
#if 0
|
||||
printf("BlkLevel=%d i=%d altnum=%d CurAltNum=%d altID=%s\n",
|
||||
BlkLevel,i,innerAlt->curAltNum,CurAltNum_array[BlkLevel],eg->altID);
|
||||
#endif
|
||||
if (BlkLevel != i ||
|
||||
innerAlt->curAltNum == CurAltNum_array[BlkLevel]) {
|
||||
if (innerAlt->exception_label == NULL) {
|
||||
innerAlt->exception_label=eg->altID;
|
||||
};
|
||||
};
|
||||
|
||||
/* ocurs at a later pass then for the exception_label */
|
||||
/* if an outerEG has been found then fill in the outer EG */
|
||||
/* remove if from the list when the BlkLevel gets smaller */
|
||||
|
||||
if (BlkLevel != i) {
|
||||
if (innerAlt->outerEG == NULL) {
|
||||
innerAlt->outerEG=eg;
|
||||
};
|
||||
};
|
||||
};
|
||||
if (BlkLevel != i) altArray[i]=NULL;
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void leAdd(LabelEntry * le)
|
||||
#else
|
||||
void leAdd(le)
|
||||
LabelEntry *le;
|
||||
#endif
|
||||
|
||||
{
|
||||
arrayCheck();
|
||||
le->pendingLink=leArray[BlkLevel];
|
||||
le->curAltNum=CurAltNum_array[BlkLevel];
|
||||
leArray[BlkLevel]=le;
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void altAdd(Junction *alt)
|
||||
#else
|
||||
void altAdd(alt)
|
||||
Junction *alt;
|
||||
#endif
|
||||
|
||||
{
|
||||
arrayCheck();
|
||||
#if 0
|
||||
printf("BlkLevel=%d CurAltNum=%d\n",
|
||||
BlkLevel,CurAltNum_array[BlkLevel]);
|
||||
#endif
|
||||
alt->curAltNum=CurAltNum_array[BlkLevel];
|
||||
alt->pendingLink=altArray[BlkLevel];
|
||||
altArray[BlkLevel]=alt;
|
||||
}
|
||||
|
||||
static void
|
||||
#ifdef __USE_PROTOS
|
||||
arrayCheck(void)
|
||||
#else
|
||||
arrayCheck()
|
||||
#endif
|
||||
{
|
||||
ExceptionGroup **egArrayNew;
|
||||
LabelEntry **leArrayNew;
|
||||
Junction **altArrayNew;
|
||||
int arraySizeNew;
|
||||
int i;
|
||||
|
||||
if (BlkLevel > highWater) highWater=BlkLevel;
|
||||
|
||||
if (BlkLevel >= arraySize) {
|
||||
arraySizeNew=BlkLevel+5; /* MR20 */
|
||||
egArrayNew=(ExceptionGroup **)
|
||||
calloc(arraySizeNew,sizeof(ExceptionGroup *));
|
||||
leArrayNew=(LabelEntry **)
|
||||
calloc(arraySizeNew,sizeof(LabelEntry *));
|
||||
altArrayNew=(Junction **)
|
||||
calloc(arraySizeNew,sizeof(Junction *));
|
||||
for (i=0; i<arraySize ; i++) {
|
||||
egArrayNew[i]=egArray[i];
|
||||
leArrayNew[i]=leArray[i];
|
||||
altArrayNew[i]=altArray[i];
|
||||
};
|
||||
arraySize=arraySizeNew;
|
||||
if (egArray != NULL) free( (char *) egArray);
|
||||
if (leArray != NULL) free( (char *) leArray);
|
||||
if (altArray != NULL) free( (char *) altArray);
|
||||
egArray=egArrayNew;
|
||||
leArray=leArrayNew;
|
||||
altArray=altArrayNew;
|
||||
};
|
||||
}
|
||||
|
||||
/* always call leFixup() BEFORE egFixup() */
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
egFixup(void)
|
||||
#else
|
||||
egFixup()
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
ExceptionGroup *nextEG;
|
||||
ExceptionGroup *innerEG;
|
||||
|
||||
for (i=1; i<=highWater ; i++) {
|
||||
for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {
|
||||
nextEG=innerEG->pendingLink;
|
||||
innerEG->pendingLink=NULL;
|
||||
};
|
||||
egArray[i]=NULL;
|
||||
};
|
||||
lastEG=NULL;
|
||||
lastBlkLevel=0;
|
||||
}
|
||||
|
||||
/* always call leFixup() BEFORE egFixup() */
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void leFixup(void)
|
||||
#else
|
||||
void leFixup()
|
||||
#endif
|
||||
{
|
||||
|
||||
int i;
|
||||
LabelEntry *nextLE;
|
||||
LabelEntry *innerLE;
|
||||
|
||||
for (i=BlkLevel; i<=highWater ; i++) {
|
||||
for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {
|
||||
nextLE=innerLE->pendingLink;
|
||||
innerLE->pendingLink=NULL;
|
||||
};
|
||||
leArray[i]=NULL;
|
||||
};
|
||||
}
|
||||
|
||||
/* always call altFixup() BEFORE egFixup() */
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void altFixup(void)
|
||||
#else
|
||||
void altFixup()
|
||||
#endif
|
||||
{
|
||||
|
||||
int i;
|
||||
Junction *nextAlt;
|
||||
Junction *innerAlt;
|
||||
|
||||
for (i=BlkLevel; i<=highWater ; i++) {
|
||||
for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {
|
||||
|
||||
/* if an outerEG has been found then fill in the outer EG */
|
||||
|
||||
if (lastBlkLevel <= i) {
|
||||
if (innerAlt->outerEG == NULL) {
|
||||
innerAlt->outerEG=lastEG;
|
||||
};
|
||||
};
|
||||
nextAlt=innerAlt->pendingLink;
|
||||
innerAlt->pendingLink=NULL;
|
||||
};
|
||||
altArray[i]=NULL;
|
||||
};
|
||||
}
|
||||
|
538
Tools/CodeTools/Source/Pccts/antlr/err.c
Normal file
538
Tools/CodeTools/Source/Pccts/antlr/err.c
Normal file
@@ -0,0 +1,538 @@
|
||||
/*
|
||||
* A n t l r S e t s / E r r o r F i l e H e a d e r
|
||||
*
|
||||
* Generated from: antlr.g
|
||||
*
|
||||
* Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001
|
||||
* Parr Research Corporation
|
||||
* with Purdue University Electrical Engineering
|
||||
* With AHPCRC, University of Minnesota
|
||||
* ANTLR Version 1.33MR33
|
||||
*/
|
||||
|
||||
#define ANTLR_VERSION 13333
|
||||
#include "pcctscfg.h"
|
||||
#include "pccts_stdio.h"
|
||||
|
||||
#include "pcctscfg.h"
|
||||
#include "set.h"
|
||||
#include <ctype.h>
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
#define zzcr_attr(attr,tok,t)
|
||||
#define zzSET_SIZE 20
|
||||
#include "antlr.h"
|
||||
#include "tokens.h"
|
||||
#include "dlgdef.h"
|
||||
#include "err.h"
|
||||
|
||||
ANTLRChar *zztokens[157]={
|
||||
/* 00 */ "Invalid",
|
||||
/* 01 */ "Eof",
|
||||
/* 02 */ "QuotedTerm",
|
||||
/* 03 */ "\\n|\\r|\\r\\n",
|
||||
/* 04 */ "\\(\\n|\\r|\\r\\n)",
|
||||
/* 05 */ "\\~[]",
|
||||
/* 06 */ "~[\\n\\r\"\\]+",
|
||||
/* 07 */ "\"",
|
||||
/* 08 */ "\\n|\\r|\\r\\n",
|
||||
/* 09 */ "\\(\\n|\\r|\\r\\n)",
|
||||
/* 10 */ "\\~[]",
|
||||
/* 11 */ "~[\\n\\r\"\\]+",
|
||||
/* 12 */ "'",
|
||||
/* 13 */ "\\n|\\r|\\r\\n",
|
||||
/* 14 */ "\\~[]",
|
||||
/* 15 */ "~[\\n\\r'\\]+",
|
||||
/* 16 */ "\\*/",
|
||||
/* 17 */ "\\*",
|
||||
/* 18 */ "\\n|\\r|\\r\\n",
|
||||
/* 19 */ "~[\\n\\r\\*]+",
|
||||
/* 20 */ "\\*/",
|
||||
/* 21 */ "\\*",
|
||||
/* 22 */ "\\n|\\r|\\r\\n",
|
||||
/* 23 */ "~[\\n\\r\\*]+",
|
||||
/* 24 */ "\\n|\\r|\\r\\n",
|
||||
/* 25 */ "~[\\n\\r]+",
|
||||
/* 26 */ "\\n|\\r|\\r\\n",
|
||||
/* 27 */ "~[\\n\\r]+",
|
||||
/* 28 */ "\\n|\\r|\\r\\n",
|
||||
/* 29 */ "~[\\n\\r]+",
|
||||
/* 30 */ "\\*/",
|
||||
/* 31 */ "\\*",
|
||||
/* 32 */ "\\n|\\r|\\r\\n",
|
||||
/* 33 */ "~[\\n\\r\\*]+",
|
||||
/* 34 */ "Action",
|
||||
/* 35 */ "Pred",
|
||||
/* 36 */ "PassAction",
|
||||
/* 37 */ "consumeUntil\\( [\\ \\t]* \\{~[\\}]+\\} [\\ \\t]* \\)",
|
||||
/* 38 */ "consumeUntil\\( ~[\\)]+ \\)",
|
||||
/* 39 */ "\\n|\\r|\\r\\n",
|
||||
/* 40 */ "\\>",
|
||||
/* 41 */ "$",
|
||||
/* 42 */ "$$",
|
||||
/* 43 */ "$\\[\\]",
|
||||
/* 44 */ "$\\[",
|
||||
/* 45 */ "$[0-9]+",
|
||||
/* 46 */ "$[0-9]+.",
|
||||
/* 47 */ "$[0-9]+.[0-9]+",
|
||||
/* 48 */ "$[_a-zA-Z][_a-zA-Z0-9]*",
|
||||
/* 49 */ "#0",
|
||||
/* 50 */ "#\\[\\]",
|
||||
/* 51 */ "#\\(\\)",
|
||||
/* 52 */ "#[0-9]+",
|
||||
/* 53 */ "#line[\\ \\t]* [0-9]+ {[\\ \\t]* \"~[\"]+\" ([\\ \\t]* [0-9]*)* } (\\n|\\r|\\r\\n)",
|
||||
/* 54 */ "#line ~[\\n\\r]* (\\n|\\r|\\r\\n)",
|
||||
/* 55 */ "#[_a-zA-Z][_a-zA-Z0-9]*",
|
||||
/* 56 */ "#\\[",
|
||||
/* 57 */ "#\\(",
|
||||
/* 58 */ "#",
|
||||
/* 59 */ "\\)",
|
||||
/* 60 */ "\\[",
|
||||
/* 61 */ "\\(",
|
||||
/* 62 */ "\\\\]",
|
||||
/* 63 */ "\\\\)",
|
||||
/* 64 */ "\\>",
|
||||
/* 65 */ "'",
|
||||
/* 66 */ "\"",
|
||||
/* 67 */ "\\$",
|
||||
/* 68 */ "\\#",
|
||||
/* 69 */ "\\(\\n|\\r|\\r\\n)",
|
||||
/* 70 */ "\\~[\\]\\)>$#]",
|
||||
/* 71 */ "/",
|
||||
/* 72 */ "/\\*",
|
||||
/* 73 */ "\\*/",
|
||||
/* 74 */ "//",
|
||||
/* 75 */ "~[\\n\\r\\)\\(\\$#\\>\\]\\[\"'/]+",
|
||||
/* 76 */ "[\\t\\ ]+",
|
||||
/* 77 */ "\\n|\\r|\\r\\n",
|
||||
/* 78 */ "\\[",
|
||||
/* 79 */ "\\<\\<",
|
||||
/* 80 */ "\"",
|
||||
/* 81 */ "/\\*",
|
||||
/* 82 */ "\\*/",
|
||||
/* 83 */ "//",
|
||||
/* 84 */ "#line[\\ \\t]* [0-9]+ {[\\ \\t]* \"~[\"]+\" ([\\ \\t]* [0-9]*)* } (\\n|\\r|\\r\\n)",
|
||||
/* 85 */ "#line ~[\\n\\r]* (\\n|\\r|\\r\\n)",
|
||||
/* 86 */ "\\>\\>",
|
||||
/* 87 */ "WildCard",
|
||||
/* 88 */ "\\@",
|
||||
/* 89 */ "LABEL",
|
||||
/* 90 */ "grammar-element",
|
||||
/* 91 */ "meta-symbol",
|
||||
/* 92 */ "Pragma",
|
||||
/* 93 */ "FirstSetSymbol",
|
||||
/* 94 */ "{\\}#header",
|
||||
/* 95 */ "{\\}#first",
|
||||
/* 96 */ "{\\}#parser",
|
||||
/* 97 */ "{\\}#tokdefs",
|
||||
/* 98 */ "\\}",
|
||||
/* 99 */ "class",
|
||||
/* 100 */ "NonTerminal",
|
||||
/* 101 */ "TokenTerm",
|
||||
/* 102 */ "\\{",
|
||||
/* 103 */ "!",
|
||||
/* 104 */ "\\<",
|
||||
/* 105 */ "\\>",
|
||||
/* 106 */ ":",
|
||||
/* 107 */ ";",
|
||||
/* 108 */ "{\\}#lexaction",
|
||||
/* 109 */ "{\\}#lexmember",
|
||||
/* 110 */ "{\\}#lexprefix",
|
||||
/* 111 */ "{\\}#pred",
|
||||
/* 112 */ "\\|\\|",
|
||||
/* 113 */ "&&",
|
||||
/* 114 */ "\\(",
|
||||
/* 115 */ "\\)",
|
||||
/* 116 */ "{\\}#lexclass",
|
||||
/* 117 */ "{\\}#errclass",
|
||||
/* 118 */ "{\\}#tokclass",
|
||||
/* 119 */ "..",
|
||||
/* 120 */ "{\\}#token",
|
||||
/* 121 */ "=",
|
||||
/* 122 */ "[0-9]+",
|
||||
/* 123 */ "\\|",
|
||||
/* 124 */ "\\~",
|
||||
/* 125 */ "^",
|
||||
/* 126 */ "approx",
|
||||
/* 127 */ "LL\\(1\\)",
|
||||
/* 128 */ "LL\\(2\\)",
|
||||
/* 129 */ "\\*",
|
||||
/* 130 */ "\\+",
|
||||
/* 131 */ "?",
|
||||
/* 132 */ "=>",
|
||||
/* 133 */ "exception",
|
||||
/* 134 */ "default",
|
||||
/* 135 */ "catch",
|
||||
/* 136 */ "{\\}#[A-Za-z0-9_]*",
|
||||
/* 137 */ "[\\t\\ ]+",
|
||||
/* 138 */ "\\n|\\r|\\r\\n",
|
||||
/* 139 */ "//",
|
||||
/* 140 */ "/\\*",
|
||||
/* 141 */ "#ifdef",
|
||||
/* 142 */ "#if",
|
||||
/* 143 */ "#ifndef",
|
||||
/* 144 */ "#else",
|
||||
/* 145 */ "#endif",
|
||||
/* 146 */ "#undef",
|
||||
/* 147 */ "#import",
|
||||
/* 148 */ "ID",
|
||||
/* 149 */ "#define",
|
||||
/* 150 */ "INT",
|
||||
/* 151 */ "enum",
|
||||
/* 152 */ "\\{",
|
||||
/* 153 */ "=",
|
||||
/* 154 */ ",",
|
||||
/* 155 */ "\\}",
|
||||
/* 156 */ ";"
|
||||
};
|
||||
SetWordType zzerr1[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr2[20] = {0xfc,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xf3,
|
||||
0xbf,0xff,0xff,0xff, 0xff,0xff,0xff,0x1f};
|
||||
SetWordType zzerr3[20] = {0xfc,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xfb,
|
||||
0x3b,0xf7,0xf7,0xc7, 0xff,0xff,0xff,0x1f};
|
||||
SetWordType zzerr4[20] = {0x4,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x80,0x7,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType setwd1[157] = {0x0,0x50,0xa0,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x6a,0x20,0xa0,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x0,0x0,0x20,0x20,0x21,
|
||||
0x21,0x21,0x21,0x6e,0x6e,0x64,0x20,0x0,
|
||||
0x20,0xa0,0xa0,0xa0,0x20,0x6a,0x6a,0x6a,
|
||||
0x6e,0x20,0x20,0x20,0x20,0x66,0x6e,0x6e,
|
||||
0x20,0x66,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20};
|
||||
SetWordType zzerr5[20] = {0x0,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x1,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr6[20] = {0x4,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x7,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr7[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x6,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr8[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x4,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr9[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf0,0x70,0x1, 0x20,0x0,0x0,0x0};
|
||||
SetWordType setwd2[157] = {0x0,0xf8,0x6,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xf8,0x0,0x1,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xf8,0xf8,0xf8,0x0,0x0,
|
||||
0x0,0x1,0x2,0x6,0x0,0xf8,0xf8,0xf8,
|
||||
0xf8,0x0,0x0,0x0,0x0,0xf8,0xf8,0xf8,
|
||||
0x0,0xf8,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0xe8,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr10[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0xbc,0xf8,0x74,0x1, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr11[20] = {0x0,0x0,0x0,0x0, 0x8,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0xa0,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr12[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr13[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0xa0,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType setwd3[157] = {0x0,0xfa,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xfa,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xfa,0xfa,0xfa,0x5,0x0,
|
||||
0x5,0x0,0x0,0x0,0xe2,0xfa,0xfa,0xfa,
|
||||
0xfa,0xc0,0x80,0x5,0xe0,0xfa,0xfa,0xfa,
|
||||
0x0,0xfa,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0xfa,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr14[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr15[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr16[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr17[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr18[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x24,0x0,0x80,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr19[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr20[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf8,0x74,0x3, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr21[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf8,0x70,0x3, 0x20,0x0,0x0,0x0};
|
||||
SetWordType setwd4[157] = {0x0,0xe5,0xda,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xe5,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xed,0xe5,0xe7,0x1a,0x0,
|
||||
0x0,0x0,0x0,0x0,0xc0,0xe5,0xe5,0xe5,
|
||||
0xe5,0x0,0x0,0x0,0x0,0xe5,0xe5,0xe5,
|
||||
0x0,0xe5,0x40,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0xe5,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr22[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x3c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr23[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr24[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr25[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr26[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,
|
||||
0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
|
||||
SetWordType setwd5[157] = {0x0,0x1f,0xc1,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xdf,0xc0,0xc0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0xc0,0x0,0xc0,0x0,0x0,0xc0,0xc0,0x0,
|
||||
0x0,0x0,0x0,0x7f,0x1f,0xdf,0xc0,0xc0,
|
||||
0x0,0x0,0xc0,0x0,0x67,0x1f,0x1f,0x1f,
|
||||
0x1f,0x0,0x0,0xc0,0x60,0x1f,0x1f,0x1f,
|
||||
0x0,0x1f,0x0,0x0,0x40,0xc0,0x0,0x0,
|
||||
0x0,0x0,0xc0,0xc0,0x0,0x0,0x5f,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr27[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
|
||||
0x0,0x0,0x0,0x10, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr28[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x80,0x2,
|
||||
0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr29[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr30[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,
|
||||
0x0,0x0,0x80,0x0, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr31[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,
|
||||
0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr32[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,
|
||||
0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr33[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType setwd6[157] = {0x0,0x0,0xfd,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xe1,0xe1,0xe1,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0xfd,0x60,0xe9,0x0,0x0,0xe1,0xe1,0x0,
|
||||
0x0,0x0,0x0,0xe2,0x0,0xfd,0xfd,0xe1,
|
||||
0x20,0x0,0xe1,0x0,0xe2,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xe1,0xe2,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0xe2,0xe0,0x20,0x0,
|
||||
0x0,0x0,0xe1,0xe1,0x0,0x0,0xe2,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr34[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,
|
||||
0x0,0x0,0x80,0x0, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr35[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,
|
||||
0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr36[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,
|
||||
0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr37[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xc,
|
||||
0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr38[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
|
||||
0x84,0x9,0x8,0x18, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr39[20] = {0x0,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x1,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr40[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
|
||||
0x4,0x9,0x8,0x18, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr41[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
|
||||
0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr42[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x80,0x0,
|
||||
0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType setwd7[157] = {0x0,0x0,0xdf,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xdf,0xdf,0xff,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0xdf,0x3,0xdf,0x0,0x0,0xdf,0xdf,0x0,
|
||||
0x0,0x0,0x0,0xdf,0x0,0xdf,0xdf,0xdf,
|
||||
0x1,0x30,0xdf,0x0,0xdf,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xdf,0xdf,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0xdf,0xdf,0x1,0x0,
|
||||
0x0,0x0,0xdf,0xdf,0x0,0x0,0xdf,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr43[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
|
||||
0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr44[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xc0, 0x1,0x0,0x0,0x0};
|
||||
SetWordType zzerr45[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x30,
|
||||
0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr46[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr47[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x20,
|
||||
0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr48[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x2,0x0, 0x10,0x0,0x0,0x0};
|
||||
SetWordType zzerr49[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
|
||||
0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
|
||||
SetWordType zzerr50[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
|
||||
0x4,0x8,0xa,0x18, 0x30,0x0,0x0,0x0};
|
||||
SetWordType zzerr51[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
|
||||
0x4,0x8,0x8,0x18, 0x28,0x0,0x0,0x0};
|
||||
SetWordType zzerr52[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr53[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
|
||||
0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType setwd8[157] = {0x0,0x0,0xe1,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0xe1,0xe1,0xe1,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0xe1,0x0,0xe1,0x0,0x0,0xe3,0xe7,0x0,
|
||||
0x0,0x0,0x0,0xe1,0x0,0xe1,0xe1,0xef,
|
||||
0x0,0x0,0xe1,0x0,0xe1,0x0,0x0,0x0,
|
||||
0x0,0x0,0x10,0xef,0xe1,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0xe1,0xe1,0x0,0x0,
|
||||
0x0,0x0,0xe1,0xe1,0x0,0x10,0xe1,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr54[20] = {0x2,0x0,0x0,0x0, 0x14,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf8,0x78,0x9, 0xe0,0x0,0x0,0x0};
|
||||
SetWordType zzerr55[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf8,0x78,0x9, 0x60,0x0,0x0,0x0};
|
||||
SetWordType zzerr56[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr57[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x1c,0xf8,0x78,0x9, 0xe0,0x0,0x0,0x0};
|
||||
SetWordType setwd9[157] = {0x0,0x7c,0x1,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x7f,0x1,0x1,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x1,0x0,0x1,0x0,0x0,0x1,0x1,0x0,
|
||||
0x0,0x0,0x0,0x7f,0x7e,0x7f,0x1,0x1,
|
||||
0x0,0x0,0x1,0x0,0x7d,0x7e,0x7e,0x7e,
|
||||
0x7e,0x0,0x0,0x1,0x7d,0x7e,0x7e,0x7e,
|
||||
0x0,0x7e,0x0,0x0,0x7d,0x1,0x0,0x0,
|
||||
0x0,0x0,0x1,0x1,0x0,0x0,0x7f,0x64,
|
||||
0x64,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x80,0x0,0x0,0x0,0x0,0x0,0x80,0x0,
|
||||
0x80,0x0,0x0,0x0,0x0,0x0};
|
||||
SetWordType zzerr58[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0, 0x0,0x0,0xa0,0x0};
|
||||
SetWordType zzerr59[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0, 0x0,0x80,0xa0,0x0};
|
||||
SetWordType zzerr60[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0, 0x0,0x0,0xa0,0x0};
|
||||
SetWordType zzerr61[20] = {0x2,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0, 0x0,0x80,0xa0,0x0};
|
||||
SetWordType zzerr62[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};
|
||||
SetWordType zzerr63[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};
|
||||
SetWordType zzerr64[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};
|
||||
SetWordType zzerr65[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0, 0x0,0x0,0x10,0xc};
|
||||
SetWordType setwd10[157] = {0x0,0xc,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,
|
||||
0x3,0x0,0x0,0xf0,0xf0,0x0};
|
||||
SetWordType setwd11[157] = {0x0,0x1,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x1,0x0,0x0,0x0,0x0,0x0};
|
123
Tools/CodeTools/Source/Pccts/antlr/fcache.c
Normal file
123
Tools/CodeTools/Source/Pccts/antlr/fcache.c
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* fcache.c
|
||||
*
|
||||
* 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.33MR10
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "pcctscfg.h"
|
||||
|
||||
#include "set.h"
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
CacheEntry *dumpFcache1(char *prev)
|
||||
#else
|
||||
CacheEntry *dumpFcache1(prev)
|
||||
char *prev;
|
||||
#endif
|
||||
{
|
||||
Entry **table=Fcache;
|
||||
|
||||
int low=0;
|
||||
int hi=0;
|
||||
|
||||
CacheEntry *least=NULL;
|
||||
|
||||
Entry **p;
|
||||
|
||||
for (p=table; p<&(table[HashTableSize]); p++) {
|
||||
|
||||
CacheEntry *q =(CacheEntry *) *p;
|
||||
|
||||
if ( q != NULL && low==0 ) low = p-table;
|
||||
while ( q != NULL ) {
|
||||
if (strcmp(q->str,prev) > 0) {
|
||||
if (least == NULL) {
|
||||
least=q;
|
||||
} else {
|
||||
if (strcmp(q->str,least->str) < 0) {
|
||||
least=q;
|
||||
};
|
||||
};
|
||||
};
|
||||
q = q->next;
|
||||
};
|
||||
|
||||
if ( *p != NULL ) hi = p-table;
|
||||
}
|
||||
return least;
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void reportFcache(CacheEntry *q)
|
||||
#else
|
||||
void reportFcache(q)
|
||||
CacheEntry *q;
|
||||
#endif
|
||||
{
|
||||
char *qstr;
|
||||
|
||||
fprintf(stdout,"\nrule ");
|
||||
for (qstr=q->str; *qstr != '*' ; qstr++) {
|
||||
fprintf(stdout,"%c",*qstr);
|
||||
};
|
||||
|
||||
qstr++;
|
||||
if (*qstr == 'i') fprintf(stdout," First[");
|
||||
if (*qstr == 'o') fprintf(stdout," Follow[");
|
||||
qstr++;
|
||||
fprintf(stdout,"%s]",qstr);
|
||||
if (q->incomplete) fprintf(stdout," *** incomplete ***");
|
||||
fprintf(stdout,"\n");
|
||||
MR_dumpTokenSet(stdout,1,q->fset);
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
DumpFcache(void)
|
||||
#else
|
||||
DumpFcache()
|
||||
#endif
|
||||
{
|
||||
|
||||
char *prev="";
|
||||
int n=0;
|
||||
CacheEntry *next;
|
||||
|
||||
fprintf(stdout,"\n\nDump of First/Follow Cache\n");
|
||||
|
||||
for(;;) {
|
||||
next=dumpFcache1(prev);
|
||||
if (next == NULL) break;
|
||||
reportFcache(next);
|
||||
++n;
|
||||
prev=next->str;
|
||||
};
|
||||
fprintf(stdout,"\nEnd dump of First/Follow Cache\n");
|
||||
}
|
1555
Tools/CodeTools/Source/Pccts/antlr/fset.c
Normal file
1555
Tools/CodeTools/Source/Pccts/antlr/fset.c
Normal file
File diff suppressed because it is too large
Load Diff
2250
Tools/CodeTools/Source/Pccts/antlr/fset2.c
Normal file
2250
Tools/CodeTools/Source/Pccts/antlr/fset2.c
Normal file
File diff suppressed because it is too large
Load Diff
4797
Tools/CodeTools/Source/Pccts/antlr/gen.c
Normal file
4797
Tools/CodeTools/Source/Pccts/antlr/gen.c
Normal file
File diff suppressed because it is too large
Load Diff
286
Tools/CodeTools/Source/Pccts/antlr/generic.h
Normal file
286
Tools/CodeTools/Source/Pccts/antlr/generic.h
Normal file
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* generic.h -- generic include stuff for new PCCTS ANTLR.
|
||||
*
|
||||
* 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.33
|
||||
* Terence Parr
|
||||
* Parr Research Corporation
|
||||
* with Purdue University and AHPCRC, University of Minnesota
|
||||
* 1989-2001
|
||||
*/
|
||||
|
||||
#define StrSame 0
|
||||
|
||||
#define DefaultParserName "zzparser"
|
||||
|
||||
/* MR9 JVincent@novell.com Allow user to override default ZZLEXBUFSIZE */
|
||||
/* MR11 thm Raise antlr's own default ZZLEXBUFSIZE to 8k */
|
||||
/* MR22 thm Raise antlr's own default ZZLEXBUFSIZE to 32k */
|
||||
|
||||
#ifndef ZZLEXBUFSIZE
|
||||
#define ZZLEXBUFSIZE 32000
|
||||
#endif
|
||||
|
||||
/* Tree/FIRST/FOLLOW defines -- valid only after all grammar has been read */
|
||||
#define ALT TokenNum+1
|
||||
#define SET TokenNum+2
|
||||
#define TREE_REF TokenNum+3
|
||||
|
||||
/* E r r o r M a c r o s */
|
||||
|
||||
#define fatal(err) fatalFL(err, __FILE__, __LINE__)
|
||||
#define fatal_internal(err) fatal_intern(err, __FILE__, __LINE__)
|
||||
|
||||
|
||||
#define eMsg1(s,a) eMsg3(s,a,NULL,NULL)
|
||||
#define eMsg2(s,a,b) eMsg3(s,a,b,NULL)
|
||||
|
||||
/* S a n i t y C h e c k i n g */
|
||||
|
||||
#ifndef require
|
||||
#define require(expr, err) {if ( !(expr) ) fatal_internal(err);}
|
||||
#endif
|
||||
|
||||
/* L i s t N o d e s */
|
||||
|
||||
typedef struct _ListNode {
|
||||
void *elem; /* pointer to any kind of element */
|
||||
struct _ListNode *next;
|
||||
} ListNode;
|
||||
|
||||
/* Define a Cycle node which is used to track lists of cycles for later
|
||||
* reconciliation by ResolveFoCycles().
|
||||
*/
|
||||
typedef struct _c {
|
||||
int croot; /* cycle root */
|
||||
set cyclicDep; /* cyclic dependents */
|
||||
unsigned deg; /* degree of FOLLOW set of croot */
|
||||
} Cycle;
|
||||
|
||||
typedef struct _e {
|
||||
int tok; /* error class name == TokenStr[tok] */
|
||||
ListNode *elist; /* linked list of elements in error set */
|
||||
set eset;
|
||||
int setdeg; /* how big is the set */
|
||||
int lexclass; /* which lex class is it in? */
|
||||
} ECnode;
|
||||
|
||||
typedef struct _TCnode {
|
||||
int tok; /* token class name */
|
||||
ListNode *tlist; /* linked list of elements in token set */
|
||||
set tset;
|
||||
int lexclass; /* which lex class is it in? */
|
||||
unsigned char dumped; /* this def has been been dumped */
|
||||
unsigned char dumpedComplement; /* this def has been been dumped */
|
||||
unsigned setnum; /* which set number is this guy? (if dumped) */
|
||||
unsigned setnumComplement; /* MR23 */
|
||||
unsigned setnumErrSet; /* MR23 which set is this #tokclass error set (if dumped) */
|
||||
unsigned setnumErrSetComplement; /* MR23 */
|
||||
} TCnode;
|
||||
|
||||
typedef struct _ft {
|
||||
char *token; /* id of token type to remap */
|
||||
int tnum; /* move token type to which token position */
|
||||
} ForcedToken;
|
||||
|
||||
typedef struct _ContextGuardPredicates { /* MR13 */
|
||||
Predicate *pred; /* MR13 */
|
||||
} ContextGuardPredicates; /* MR13 */
|
||||
|
||||
#define newListNode (ListNode *) calloc(1, sizeof(ListNode));
|
||||
#define newCycle (Cycle *) calloc(1, sizeof(Cycle));
|
||||
#define newECnode (ECnode *) calloc(1, sizeof(ECnode));
|
||||
#define newTCnode (TCnode *) calloc(1, sizeof(TCnode));
|
||||
|
||||
|
||||
/* H a s h T a b l e E n t r i e s */
|
||||
|
||||
typedef struct _t { /* Token name or expression */
|
||||
char *str;
|
||||
struct _t *next;
|
||||
int token; /* token number */
|
||||
unsigned char classname; /* is it a err/tok class name or token */
|
||||
TCnode *tclass; /* ptr to token class */
|
||||
char *action;
|
||||
char *akaString;
|
||||
} TermEntry;
|
||||
|
||||
typedef struct _r { /* Rule name and ptr to start of rule */
|
||||
char *str;
|
||||
struct _t *next;
|
||||
int rulenum; /* RulePtr[rulenum]== ptr to RuleBlk junction */
|
||||
unsigned char noAST;/* gen AST construction code? (def==gen code) */
|
||||
char *egroup; /* which error group (err reporting stuff) */
|
||||
#if 0
|
||||
/* MR27 This appears to never be used. Delete this code later. */
|
||||
|
||||
ListNode *el_labels;/* list of element labels ref in all of rule */
|
||||
#endif
|
||||
ListNode *ast_labels_in_actions; /* MR27 */
|
||||
unsigned char has_rule_exception;
|
||||
char dontComputeErrorSet; /* MR14 - don't compute error set
|
||||
special for rule in alpha part of
|
||||
(alpha)? beta block */
|
||||
} RuleEntry;
|
||||
|
||||
typedef struct _f { /* cache Fi/Fo set */
|
||||
char *str; /* key == (rulename, computation, k) */
|
||||
struct _f *next;
|
||||
set fset; /* First/Follow of rule */
|
||||
set rk; /* set of k's remaining to be done after ruleref */
|
||||
int incomplete; /* only w/FOLLOW sets. Use only if complete */
|
||||
} CacheEntry;
|
||||
|
||||
typedef struct _LabelEntry { /* element labels */
|
||||
char *str;
|
||||
struct _f *next;
|
||||
Node *elem; /* which element does it point to? */
|
||||
ExceptionGroup *ex_group;
|
||||
/* Is there an exception attached to label? */
|
||||
ExceptionGroup *outerEG; /* MR7 */
|
||||
/* next EG if ex_group doesn't catch it MR7 */
|
||||
struct _LabelEntry *pendingLink; /* MR7 */
|
||||
/* too lazy to use ListNode ? MR7 */
|
||||
int curAltNum; /* MR7 */
|
||||
} LabelEntry;
|
||||
|
||||
typedef struct _SignalEntry {
|
||||
char *str;
|
||||
struct _f *next;
|
||||
int signum; /* unique signal number */
|
||||
} SignalEntry;
|
||||
|
||||
typedef struct _PredEntry { /* MR11 predicate name and ptr to string */
|
||||
char *str;
|
||||
struct _PredEntry *next;
|
||||
int file;
|
||||
int line;
|
||||
Predicate *pred;
|
||||
char *predLiteral;
|
||||
} PredEntry;
|
||||
|
||||
typedef struct _PointerStack { /* MR10 */
|
||||
int count;
|
||||
int size;
|
||||
void **data;
|
||||
} PointerStack;
|
||||
|
||||
#define newTermEntry(s) (TermEntry *) newEntry(s, sizeof(TermEntry))
|
||||
#define newRuleEntry(s) (RuleEntry *) newEntry(s, sizeof(RuleEntry))
|
||||
#define newCacheEntry(s) (CacheEntry *) newEntry(s, sizeof(CacheEntry))
|
||||
#define newLabelEntry(s) (LabelEntry *) newEntry(s, sizeof(LabelEntry))
|
||||
#define newSignalEntry(s) (SignalEntry *) newEntry(s, sizeof(SignalEntry))
|
||||
#define newPredEntry(s) (PredEntry *) newEntry(s,sizeof(PredEntry))
|
||||
|
||||
typedef struct _UserAction {
|
||||
char *action;
|
||||
int file, line;
|
||||
} UserAction;
|
||||
|
||||
|
||||
/* L e x i c a l C l a s s */
|
||||
|
||||
/* to switch lex classes, switch ExprStr and Texpr (hash table) */
|
||||
typedef struct _lc {
|
||||
char *classnum, **exprs;
|
||||
Entry **htable;
|
||||
} LClass;
|
||||
|
||||
typedef struct _exprOrder {
|
||||
char *expr;
|
||||
int lclass;
|
||||
} Expr;
|
||||
|
||||
|
||||
typedef Graph Attrib;
|
||||
|
||||
/* M a x i m u m s */
|
||||
|
||||
/* MR20 Note G. Hobbelt These values are superceded by values in hash.h */
|
||||
|
||||
#ifndef HashTableSize
|
||||
#define HashTableSize 253
|
||||
#endif
|
||||
#ifndef StrTableSize
|
||||
#define StrTableSize 15000 /* all tokens, nonterminals, rexprs stored here */
|
||||
#endif
|
||||
#define MaxLexClasses 50 /* how many automatons */
|
||||
/* TokenStart and EofToken are ignored if #tokdefs meta-op is used */
|
||||
#define TokenStart 2 /* MUST be in 1 + EofToken */
|
||||
#define EofToken 1 /* Always predefined to be 1 */
|
||||
|
||||
#ifndef MaxNumFiles
|
||||
#define MaxNumFiles 99
|
||||
#endif
|
||||
|
||||
/**** MR9 JVincent@novell.com Move to pcctscfg.h */
|
||||
/**** #define MaxFileName 300 ****/ /* MR9 Move to pcctscfg.h */ /* largest file name size */
|
||||
|
||||
#define MaxRuleName 100 /* largest rule name size */
|
||||
#define TSChunk 100 /* how much to expand TokenStr/ExprStr each time */
|
||||
#define TIChunk TSChunk /* expand TokenInd by same as TokenStr to mirror them */
|
||||
#define FoStackSize 100 /* deepest FOLLOW recursion possible */
|
||||
|
||||
#define MaxClassDeclStuff 256 /* MR10 */
|
||||
|
||||
#define NumPredefinedSignals 3
|
||||
|
||||
/* S t a n d a r d S i g n a l s */
|
||||
|
||||
#define sigNoSignal 0
|
||||
#define sigMismatchedToken 1
|
||||
#define sigNoViableAlt 2
|
||||
#define sigNoSemViableAlt 3
|
||||
|
||||
|
||||
|
||||
/* AST token types */
|
||||
#define ASTexclude 0
|
||||
#define ASTchild 1
|
||||
#define ASTroot 2
|
||||
#define ASTinclude 3 /* include subtree made by rule ref */
|
||||
|
||||
|
||||
#define PredictionVariable "zzpr_expr"
|
||||
#define PredictionLexClassSuffix "_zzpred"
|
||||
|
||||
#define WildCardString "WildCard"
|
||||
|
||||
#if 0
|
||||
/* Removed in version 1.33MR19
|
||||
Don't understand why this never caused problems before
|
||||
*/
|
||||
|
||||
/*********************************************************
|
||||
#ifndef ANTLRm
|
||||
#define ANTLRm(st, f, _m) zzbufsize = ZZLEXBUFSIZE;\
|
||||
zzmode(_m); \
|
||||
zzenterANTLR(f); \
|
||||
st; ++zzasp; \
|
||||
zzleaveANTLR(f);
|
||||
#endif
|
||||
*********************************************************/
|
||||
#endif
|
||||
|
||||
#include "proto.h"
|
||||
#include "pcctscfg.h" /* MR14 */
|
||||
#include <string.h>
|
484
Tools/CodeTools/Source/Pccts/antlr/globals.c
Normal file
484
Tools/CodeTools/Source/Pccts/antlr/globals.c
Normal file
@@ -0,0 +1,484 @@
|
||||
/*
|
||||
* globals.c -- File containing all variables/tables visible to all files.
|
||||
*
|
||||
* 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.33
|
||||
* Terence Parr
|
||||
* Parr Research Corporation
|
||||
* with Purdue University and AHPCRC, University of Minnesota
|
||||
* 1989-2001
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pcctscfg.h"
|
||||
|
||||
#include "set.h"
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
|
||||
char Version[] = "1.33MR33" ; /* PCCTS version number */ /* MRXXX */
|
||||
char VersionDef[] = "13333"; /* same (except int equiv for preproc symbol) */ /* MRXXX */
|
||||
|
||||
char LexStartSymbol[] = "START";/* Name of starting lexical class/automaton */
|
||||
char *RemapFileName = "remap.h";
|
||||
char *DlgFileName = "parser.dlg";
|
||||
char *DefFileName = "tokens.h";
|
||||
char *ErrFileName = "err.c";
|
||||
char *ModeFileName = "mode.h";
|
||||
char *StdMsgName = NULL;
|
||||
|
||||
char *ParserName = DefaultParserName;
|
||||
|
||||
/* list of PCCTS supplied support symbols; these are renamed when more than
|
||||
* one ANTLR-generated parsers are linked together to avoid name conflicts.
|
||||
* Can't use '##' ANSIC preprocessor concat operator with K&R and:
|
||||
* #define zzskip zzparser ## skip
|
||||
* will not work for ANSI/C++ as 'zzparserskip' is created w/o zzparser
|
||||
* being substituted--ack!!!
|
||||
*/
|
||||
char *StandardSymbols[] = {
|
||||
/* ANTLR stuff */
|
||||
"zzStackOvfMsg",
|
||||
"zzasp",
|
||||
"zzaStack",
|
||||
"inf_tokens",
|
||||
"inf_text",
|
||||
"inf_text_buffer",
|
||||
"inf_text_buffer_ptr",
|
||||
"inf_text_buffer_size",
|
||||
"inf_labase",
|
||||
"inf_last",
|
||||
"inf_lap",
|
||||
"zztokenLA",
|
||||
"zztextLA",
|
||||
"zzlap",
|
||||
"zzlabase",
|
||||
"zztoktext",
|
||||
"zztoken",
|
||||
"zzdirty",
|
||||
"zzguessing",
|
||||
"zzguess_start",
|
||||
"zzresynch",
|
||||
"zzinf_tokens",
|
||||
"zzinf_text",
|
||||
"zzinf_text_buffer",
|
||||
"zzinf_labase",
|
||||
"zzinf_last",
|
||||
"zzfill_inf_look",
|
||||
"zzFAIL",
|
||||
"zzsave_antlr_state",
|
||||
"zzrestore_antlr_state",
|
||||
"zzsyn",
|
||||
"zzset_el",
|
||||
"zzset_deg",
|
||||
"zzedecode",
|
||||
"_zzsetmatch",
|
||||
"_zzmatch",
|
||||
"_inf_zzgettok",
|
||||
"zzconsumeUntil",
|
||||
"zzconsumeUntilToken",
|
||||
"_zzmatch_wsig",
|
||||
"_zzsetmatch_wsig",
|
||||
"_zzmatch_wdfltsig",
|
||||
"_zzsetmatch_wdfltsig",
|
||||
"zzdflthandlers",
|
||||
/* DLG stuff */
|
||||
"zzreal_line",
|
||||
"zzcharfull",
|
||||
"zzerr",
|
||||
"zzlextext",
|
||||
"zzbegexpr",
|
||||
"zzendexpr",
|
||||
"zzbufsize",
|
||||
"zzbegcol",
|
||||
"zzendcol",
|
||||
"zzline",
|
||||
"zzchar",
|
||||
"zzbufovf",
|
||||
"zzrdstream",
|
||||
"zzrdfunc",
|
||||
"zzrdstr",
|
||||
"zzclose_stream",
|
||||
"zzsave_dlg_state",
|
||||
"zzrestore_dlg_state",
|
||||
"zzmode",
|
||||
"zzskip",
|
||||
"zzmore",
|
||||
"zzreplchar",
|
||||
"zzreplstr",
|
||||
"zzgettok",
|
||||
"zzadvance",
|
||||
"zzerrstd",
|
||||
"zzerr_in",
|
||||
"zzconstr_attr",
|
||||
"zzempty_attr",
|
||||
"zzerraction",
|
||||
"zztokens", /* list of token regular expressions */
|
||||
"dfa",
|
||||
"accepts",
|
||||
"actions",
|
||||
"zzTraceOptionValue", /* MR10 */
|
||||
"zzTraceGuessOptionValue", /* MR10 */
|
||||
"zzTraceCurrentRuleName", /* MR10 */
|
||||
"zzTraceDepth", /* MR10 */
|
||||
"zzGuessSeq", /* MR10 */
|
||||
"zzSyntaxErrCount", /* MR11 */
|
||||
"zzLexErrCount", /* MR11 */
|
||||
"zzTraceGuessDone", /* MR13 - BJS */
|
||||
"zzTraceGuessFail", /* MR13 - BJS */
|
||||
"zzTraceGuessOption", /* MR13 - BJS */
|
||||
"zzTraceIn", /* MR13 - BJS */
|
||||
"zzTraceOption", /* MR13 - BJS */
|
||||
"zzTraceOut", /* MR13 - BJS */
|
||||
"zzTraceReset", /* MR13 - BJS */
|
||||
NULL /* must be present */
|
||||
};
|
||||
|
||||
/* list of PCCTS supplied support functions; these are renamed when more than
|
||||
* one ANTLR-generated parsers are linked together to avoid name conflicts.
|
||||
*/
|
||||
char *ASTSymbols[] = {
|
||||
"AST",
|
||||
"zzast_sp",
|
||||
"zzastStack",
|
||||
"zzlink",
|
||||
"zzastnew",
|
||||
"zzsubchild",
|
||||
"zzsubroot",
|
||||
"zzpre_ast",
|
||||
"zzfree_ast",
|
||||
"zztmake",
|
||||
"zzdup_ast",
|
||||
"zztfree",
|
||||
"zzdouble_link",
|
||||
NULL /* must be present */
|
||||
};
|
||||
|
||||
/* Current ambiguity examination information */
|
||||
int CurAmbigAlt1, CurAmbigAlt2, CurAmbigline, CurAmbigfile;
|
||||
char *CurAmbigbtype;
|
||||
|
||||
|
||||
/* M e t h o d T a b l e s */
|
||||
/*
|
||||
* The following tables are used to fill syntax diagram nodes with the correct
|
||||
* function pointers for computing FIRST sets and printing themselves.
|
||||
*/
|
||||
|
||||
/* fpTraverse[node type] == pointer to function that calculates trees
|
||||
* representing the FIRST sets for that node (maintains spatial info).
|
||||
* We use 'struct _tree' not 'tree' due to a g++ 2.4.3 bug.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
struct _tree *(*fpTraverse[NumNodeTypes+1])(... /* Node *, int, set * */) = {
|
||||
NULL,
|
||||
(struct _tree *(*)(...)) tJunc,
|
||||
(struct _tree *(*)(...)) tRuleRef,
|
||||
(struct _tree *(*)(...)) tToken,
|
||||
(struct _tree *(*)(...)) tAction
|
||||
};
|
||||
#else
|
||||
Tree *(*fpTraverse[NumNodeTypes+1])() = {
|
||||
NULL,
|
||||
tJunc,
|
||||
tRuleRef,
|
||||
tToken,
|
||||
tAction
|
||||
};
|
||||
#endif
|
||||
|
||||
/* fpReach[node type] == pointer to function that calculates FIRST set for
|
||||
* that node. (r stands for reach). We use 'struct _set' not 'set'
|
||||
* due to a g++ 2.4.3 bug.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
struct _set (*fpReach[NumNodeTypes+1])(... /* Node *, int, set * */) = {
|
||||
NULL,
|
||||
(struct _set (*)(...)) rJunc,
|
||||
(struct _set (*)(...)) rRuleRef,
|
||||
(struct _set (*)(...)) rToken,
|
||||
(struct _set (*)(...)) rAction
|
||||
};
|
||||
#else
|
||||
set (*fpReach[NumNodeTypes+1])() = {
|
||||
NULL,
|
||||
rJunc,
|
||||
rRuleRef,
|
||||
rToken,
|
||||
rAction
|
||||
};
|
||||
#endif
|
||||
|
||||
/* fpPrint[node type] == pointer to function that knows how to print that node. */
|
||||
#ifdef __cplusplus
|
||||
void (*fpPrint[NumNodeTypes+1])(... /* Node * */) = {
|
||||
NULL,
|
||||
(void (*)(...)) pJunc,
|
||||
(void (*)(...)) pRuleRef,
|
||||
(void (*)(...)) pToken,
|
||||
(void (*)(...)) pAction
|
||||
};
|
||||
#else
|
||||
void (*fpPrint[NumNodeTypes+1])() = {
|
||||
NULL,
|
||||
pJunc,
|
||||
pRuleRef,
|
||||
pToken,
|
||||
pAction
|
||||
};
|
||||
#endif
|
||||
|
||||
char *decodeJType[] = {
|
||||
"invalid",
|
||||
"aSubBlk",
|
||||
"aOptBlk",
|
||||
"aLoopBlk",
|
||||
"EndBlk",
|
||||
"RuleBlk",
|
||||
"Generic",
|
||||
"EndRule",
|
||||
"aPlusBlk",
|
||||
"aLoopBegin"
|
||||
};
|
||||
|
||||
|
||||
/* H a s h T a b l e s */
|
||||
|
||||
Entry **Tname, /* Table of all token names (maps name to tok num)*/
|
||||
**Texpr, /* Table of all token expressions
|
||||
(maps expr to tok num) */
|
||||
**Rname, /* Table of all Rules (has ptr to start of rule) */
|
||||
**Fcache, /* Cache of First/Follow Computations */
|
||||
**Tcache; /* Tree cache; First/Follow for permute trees */
|
||||
Entry **Elabel; /* Table of all element label names */
|
||||
Entry **Sname; /* Signal names */
|
||||
Entry **Pname; /* symbolic predicate names MR11 */
|
||||
|
||||
|
||||
/* V a r i a b l e s */
|
||||
|
||||
int Save_argc; /* MR10 */
|
||||
char **Save_argv; /* MR10 */
|
||||
int EpToken=0; /* Imaginary Epsilon token number */
|
||||
int WildCardToken=0;
|
||||
int CurFile= -1; /* Index into FileStr table */
|
||||
char *CurPredName=NULL; /* MR11 */
|
||||
char *CurRule=NULL; /* Pointer to current rule name */
|
||||
int CurRuleDebug=0; /* MR13 debug flag */
|
||||
RuleEntry *CurRuleNode=NULL;/* Pointer to current rule node in syntax tree */
|
||||
char *CurRetDef=NULL; /* Pointer to current return type definition */
|
||||
char *CurParmDef=NULL; /* Pointer to current parameter definition */
|
||||
Junction *CurRuleBlk=NULL; /* Pointer to current block node for enclosing block */
|
||||
ListNode *CurExGroups=NULL; /* Current list of exception groups for rule/alts */
|
||||
ListNode *CurElementLabels=NULL;
|
||||
ListNode *CurAstLabelsInActions=NULL; /* MR27 */
|
||||
|
||||
/* MR10 used by <<>>? to set "label_used_in_semantic_pred" */
|
||||
/* MR10 this will force LT(i) assignment even in guess mode */
|
||||
|
||||
ListNode *CurActionLabels=NULL; /* MR10 Element Labels appearing in last action */
|
||||
int numericActionLabel=0 ; /* MR10 << ... $1 ... >> or << ... $1 ... >>? */
|
||||
ListNode *NumericPredLabels=NULL; /* MR10 << ... $1 ... >>? ONLY */
|
||||
ListNode *ContextGuardPredicateList=NULL; /* MR13 for re-evaluating predicates
|
||||
after meta tokens are defined */
|
||||
|
||||
int CurBlockID=0; /* Unique int for each block */
|
||||
int CurAltNum=0;
|
||||
Junction *CurAltStart = NULL; /* Junction node that starts the alt */
|
||||
Junction *OuterAltStart = NULL; /* For chaining exception groups MR7 */
|
||||
int NumRules=0; /* Rules are from 1 to n */
|
||||
FILE *output=NULL; /* current parser output file */
|
||||
FILE *input=NULL; /* current grammar input file */
|
||||
char *FileStr[MaxNumFiles];/* Ptr to array of file names on command-line */
|
||||
int NumFiles=0; /* current grammar file number */
|
||||
#ifdef __cplusplus
|
||||
void (**fpTrans)(...), /* array of ptrs to funcs that translate nodes */
|
||||
(**fpJTrans)(...); /* ... that translate junctions */
|
||||
#else
|
||||
void (**fpTrans)(), /* array of ptrs to funcs that translate nodes */
|
||||
(**fpJTrans)(); /* ... that translate junctions */
|
||||
#endif
|
||||
int **FoStack; /* Array of LL_k ptrs to stacks of rule numbers */
|
||||
int **FoTOS; /* FOLLOW stack top-of-stack pointers */
|
||||
Junction *SynDiag = NULL; /* Pointer to start of syntax diagram */
|
||||
int BlkLevel=1; /* Current block level. Set by antlr.g, used by
|
||||
* scanner to translate $i.j attributes */
|
||||
set reserved_positions; /* set of token positions reserved by '#token T=i' cmds */
|
||||
set all_tokens; /* set of all token types */
|
||||
set imag_tokens; /* set of all imaginary token types (EpToken, errclasses...) */
|
||||
set tokclasses; /* set of all token class token types */
|
||||
ListNode *ForcedTokens = 0; /* list of token_id/token_num pairs to remap */
|
||||
ListNode *MetaTokenNodes=NULL; /* list of meta token refs such as token classes etc... */
|
||||
int *TokenInd=NULL; /* an indirection level between token num and position
|
||||
* of that token def in TokenStr and ExprStr */
|
||||
int LastTokenCounted=0; /* ==TokenNum if no token renumbering (same as old TokenNum) */
|
||||
int TokenNum=TokenStart;
|
||||
char **TokenStr=NULL; /* map token # to token name */
|
||||
char **ExprStr=NULL; /* map token # to expr */
|
||||
Junction **RulePtr=NULL; /* map rule # to RuleBlk node of rule */
|
||||
ListNode *ExprOrder=NULL; /* list of exprs as they are found in grammar */
|
||||
ListNode *BeforeActions=NULL;/* list of grammar actions before rules */
|
||||
ListNode *AfterActions=NULL;/* list of grammar actions after rules */
|
||||
ListNode *LexActions=NULL; /* list of lexical actions */
|
||||
|
||||
/* MR1 */
|
||||
/* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
|
||||
/* MR1 via #lexmember <<....>> */
|
||||
/* MR1 via #lexprefix <<....>> */
|
||||
/* MR1 */
|
||||
|
||||
ListNode *LexMemberActions=NULL;/* list of lexical header member decl MR1 */
|
||||
ListNode *LexPrefixActions=NULL;/* list of lexical header #include decl MR1 */
|
||||
ListNode **Cycles=NULL; /* list of cycles (for each k) found when
|
||||
doing FOLLOWs */
|
||||
ListNode *eclasses=NULL; /* list of error classes */
|
||||
ListNode *tclasses=NULL; /* list of token classes */
|
||||
LClass lclass[MaxLexClasses]; /* array of lex class definitions */
|
||||
int CurrentLexClass; /* index into lclass */
|
||||
int NumLexClasses=0; /* in range 1..MaxLexClasses (init 0) */
|
||||
|
||||
char *HdrAction=NULL; /* action defined with #header */
|
||||
char *FirstAction=NULL; /* action defined with #first MR11 */
|
||||
FILE *ErrFile; /* sets and error recovery stuff */
|
||||
FILE *DefFile=NULL; /* list of tokens, return value structs, setwd defs */
|
||||
FILE *MRinfoFile=NULL; /* MR10 information file */
|
||||
int MRinfo=0; /* MR10 */
|
||||
int MRinfoSeq=0; /* MR10 */
|
||||
int InfoP=0; /* MR10 predicates */
|
||||
int InfoT=0; /* MR10 tnodes */
|
||||
int InfoF=0; /* MR10 first/follow sets */
|
||||
int InfoM=0; /* MR10 monitor progress */
|
||||
int InfoO=0; /* MR12 orphan rules */
|
||||
int TnodesInUse=0; /* MR10 */
|
||||
int TnodesPeak=0; /* MR10 */
|
||||
int TnodesAllocated=0; /* MR10 */
|
||||
int TnodesReportThreshold=0; /* MR11 */
|
||||
int PotentialSuppression=0; /* MR10 */
|
||||
int PotentialDummy=0; /* MR10 */
|
||||
int CannotContinue=FALSE;
|
||||
int OutputLL_k = 1; /* LL_k for parsing must be power of 2 */
|
||||
int action_file; /* used to track start of action */
|
||||
int action_line;
|
||||
int FoundGuessBlk=0; /* there is a (...)? block somewhere in grammar */
|
||||
int FoundException=0; /* there is an exception somewhere in grammar */
|
||||
/* MR6 Distinguish between @ operator and real exception */
|
||||
/* MR6 by keeping separate flags for @ operator and real exceptions */
|
||||
int FoundAtOperator=0; /* MR6 */
|
||||
int FoundExceptionGroup=0; /* MR6 */
|
||||
int pLevel=0; /* print Level */
|
||||
int pAlt1,pAlt2; /* print "==>" in front of these alts */
|
||||
|
||||
/* C++ output stuff */
|
||||
FILE *Parser_h, /* where subclass of ANTLRParser goes */
|
||||
*Parser_c; /* where code for subclass of ANTLRParser goes */
|
||||
char Parser_h_Name[MaxFileName+1] = "";
|
||||
char Parser_c_Name[MaxFileName+1] = "";
|
||||
char MRinfoFile_Name[MaxFileName+1] = ""; /* MR10 */
|
||||
char *ClassDeclStuff=NULL; /* MR10 */
|
||||
char *BaseClassName=NULL; /* MR22 */
|
||||
/* list of actions inside the #class {...} defs */
|
||||
ListNode *class_before_actions=NULL;
|
||||
ListNode *class_after_actions=NULL;
|
||||
|
||||
char CurrentClassName[MaxRuleName]="";
|
||||
int no_classes_found=1;
|
||||
char *UserTokenDefsFile;
|
||||
int UserDefdTokens=0; /* found #tokdefs? */
|
||||
char *OutputDirectory=TopDirectory;
|
||||
ExceptionGroup *DefaultExGroup = NULL;
|
||||
int NumSignals = NumPredefinedSignals;
|
||||
int ContextGuardTRAV=0;
|
||||
|
||||
char *MR_AmbAidRule=NULL; /* MR11 */
|
||||
int MR_AmbAidLine=0; /* MR11 */
|
||||
int MR_AmbAidDepth=0; /* MR11 */
|
||||
int MR_AmbAidMultiple=0; /* MR11 */
|
||||
int MR_skipped_e3_report=0; /* MR11 */
|
||||
int MR_usingPredNames=0; /* MR11 */
|
||||
int MR_BadExprSets=0; /* MR13 */
|
||||
int MR_Inhibit_Tokens_h_Gen=0; /* MR13 */
|
||||
int NewAST=0; /* MR13 */
|
||||
int tmakeInParser=0; /* MR23 */
|
||||
int AlphaBetaTrace=0; /* MR14 */
|
||||
int MR_BlkErr=0; /* MR21 */
|
||||
int MR_AlphaBetaMessageCount=0; /* MR14 */
|
||||
int MR_AlphaBetaWarning=0; /* MR14 */
|
||||
int MR_ErrorSetComputationActive=0; /* MR14 */
|
||||
int MR_MaintainBackTrace=0; /* MR14 */
|
||||
set MR_CompromisedRules; /* MR14 */
|
||||
|
||||
Junction *MR_RuleBlkWithHalt; /* MR10 */
|
||||
|
||||
/* C m d - L i n e O p t i o n s */
|
||||
|
||||
int LL_k=1; /* how many tokens of full lookahead */
|
||||
int CLL_k= -1; /* how many tokens of compressed lookahead */
|
||||
int PrintOut = FALSE; /* print out the grammar */
|
||||
int PrintAnnotate = FALSE;/* annotate printout with FIRST sets */
|
||||
int CodeGen=TRUE; /* Generate output code? */
|
||||
int LexGen=TRUE; /* Generate lexical files? (tokens.h, parser.dlg) */
|
||||
int GenAST=FALSE; /* Generate AST's? */
|
||||
int GenANSI=FALSE; /* Generate ANSI code where necessary */
|
||||
int GenExprSetsOpt=TRUE;/* use sets not (LA(1)==tok) expression lists */
|
||||
int GenCR=FALSE; /* Generate cross reference? */
|
||||
int GenLineInfo=FALSE; /* Generate # line "file" stuff? */
|
||||
int GenLineInfoMS=FALSE;/* Like -gl but replace "\" with "/" for MS C/C++ systems */
|
||||
int TraceGen=FALSE; /* Generate code to trace rule invocation */
|
||||
int elevel=1; /* error level for ambiguity messages */
|
||||
int GenEClasseForRules=0;/* don't generate eclass for each rule */
|
||||
int TreeResourceLimit= -1;/* don't limit tree resource */
|
||||
int DemandLookahead = 0;/* demand/delayed lookahead or not */
|
||||
char *RulePrefix = ""; /* prefix each generated rule with this */
|
||||
char *stdpccts = "stdpccts.h";/* where to generate std pccts include file */
|
||||
int GenStdPccts = 0; /* don't gen stdpccts.h? */
|
||||
int ParseWithPredicates = 1;
|
||||
int WarningLevel = 1;
|
||||
int UseStdout = 0; /* MR6 */
|
||||
int TabWidth = 2; /* MR6 */ /* MR27 */
|
||||
int HoistPredicateContext = 0;
|
||||
int MRhoisting = 0; /* MR9 */
|
||||
int MRhoistingk = 0; /* MR13 */
|
||||
int MR_debugGenRule=0; /* MR11 */
|
||||
|
||||
int GenCC = 0; /* Generate C++ output */
|
||||
|
||||
PointerStack MR_BackTraceStack={0,0,NULL}; /* MR10 */
|
||||
PointerStack MR_PredRuleRefStack={0,0,NULL}; /* MR10 */
|
||||
PointerStack MR_RuleBlkWithHaltStack={0,0,NULL}; /* MR10 */
|
||||
|
||||
/* DontCopyTokens and Pragma_DupLabeledTokens were a bad idea. I've just
|
||||
turned them off rather than backpatching the code. Who knows? We
|
||||
may need them in the future.
|
||||
*/
|
||||
int DontCopyTokens = 1; /* in C++, don't copy ANTLRToken passed to ANTLR */
|
||||
|
||||
/* Remember if LT(i), LA(i), or LATEXT(i) used in an action which is not
|
||||
a predicate. If so, give a warning for novice users.
|
||||
*/
|
||||
|
||||
int LTinTokenAction = 0; /* MR23 */
|
||||
int PURIFY = 1; /* MR23 */
|
||||
|
||||
int CurBlockID_array[MAX_BLK_LEVEL]; /* MR23 */
|
||||
int CurAltNum_array[MAX_BLK_LEVEL]; /* MR23 */
|
221
Tools/CodeTools/Source/Pccts/antlr/hash.c
Normal file
221
Tools/CodeTools/Source/Pccts/antlr/hash.c
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* hash.c
|
||||
*
|
||||
* Manage hash tables.
|
||||
*
|
||||
* The following functions are visible:
|
||||
*
|
||||
* char *mystrdup(char *); Make space and copy string
|
||||
* Entry **newHashTable(); Create and return initialized hash table
|
||||
* Entry *hash_add(Entry **, char *, Entry *)
|
||||
* Entry *hash_get(Entry **, char *)
|
||||
*
|
||||
* 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.33
|
||||
* Terence Parr
|
||||
* Parr Research Corporation
|
||||
* with Purdue University and AHPCRC, University of Minnesota
|
||||
* 1989-2001
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "pcctscfg.h"
|
||||
#include "hash.h"
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#ifdef VAXC
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#define StrSame 0
|
||||
|
||||
#define fatal(err) \
|
||||
{fprintf(stderr, "%s(%d):", __FILE__, __LINE__); \
|
||||
fprintf(stderr, " %s\n", err); exit(PCCTS_EXIT_FAILURE);}
|
||||
#define require(expr, err) {if ( !(expr) ) fatal(err);}
|
||||
|
||||
static unsigned size = HashTableSize;
|
||||
static char *strings = NULL;
|
||||
static char *strp;
|
||||
static unsigned strsize = StrTableSize;
|
||||
|
||||
/* create the hash table and string table for terminals (string table only once) */
|
||||
Entry **
|
||||
#ifdef __USE_PROTOS
|
||||
newHashTable( void )
|
||||
#else
|
||||
newHashTable( )
|
||||
#endif
|
||||
{
|
||||
Entry **table;
|
||||
|
||||
table = (Entry **) calloc(size, sizeof(Entry *));
|
||||
require( table != NULL, "cannot allocate hash table");
|
||||
if ( strings == NULL )
|
||||
{
|
||||
strings = (char *) calloc(strsize, sizeof(char));
|
||||
require( strings != NULL, "cannot allocate string table");
|
||||
strp = strings;
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
killHashTable( Entry **table )
|
||||
#else
|
||||
killHashTable( table )
|
||||
Entry **table;
|
||||
#endif
|
||||
{
|
||||
/* for now, just free table, forget entries */
|
||||
free( (char *) table ); /* MR10 cast */
|
||||
}
|
||||
|
||||
/* Given a table, add 'rec' with key 'key' (add to front of list). return ptr to entry */
|
||||
Entry *
|
||||
#ifdef __USE_PROTOS
|
||||
hash_add( Entry **table, char *key, Entry *rec )
|
||||
#else
|
||||
hash_add( table, key, rec )
|
||||
Entry **table;
|
||||
char *key;
|
||||
Entry *rec;
|
||||
#endif
|
||||
{
|
||||
unsigned h=0;
|
||||
char *p=key;
|
||||
require(table!=NULL && key!=NULL && rec!=NULL, "add: invalid addition");
|
||||
|
||||
Hash(p,h,size);
|
||||
rec->next = table[h]; /* Add to singly-linked list */
|
||||
table[h] = rec;
|
||||
return rec;
|
||||
}
|
||||
|
||||
/* Return ptr to 1st entry found in table under key (return NULL if none found) */
|
||||
Entry *
|
||||
#ifdef __USE_PROTOS
|
||||
hash_get( Entry **table, char *key )
|
||||
#else
|
||||
hash_get( table, key )
|
||||
Entry **table;
|
||||
char *key;
|
||||
#endif
|
||||
{
|
||||
unsigned h=0;
|
||||
char *p=key;
|
||||
Entry *q;
|
||||
/* require(table!=NULL && key!=NULL, "get: invalid table and/or key");*/
|
||||
if ( !(table!=NULL && key!=NULL) ) *((char *) 34) = 3;
|
||||
|
||||
Hash(p,h,size);
|
||||
for (q = table[h]; q != NULL; q = q->next)
|
||||
{
|
||||
if ( strcmp(key, q->str) == StrSame ) return( q );
|
||||
}
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
#ifdef DEBUG_HASH
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
hashStat( Entry **table )
|
||||
#else
|
||||
hashStat( table )
|
||||
Entry **table;
|
||||
#endif
|
||||
{
|
||||
static unsigned short count[20];
|
||||
int i,n=0,low=0, hi=0;
|
||||
Entry **p;
|
||||
float avg=0.0;
|
||||
|
||||
for (i=0; i<20; i++) count[i] = 0;
|
||||
for (p=table; p<&(table[size]); p++)
|
||||
{
|
||||
Entry *q = *p;
|
||||
int len;
|
||||
|
||||
if ( q != NULL && low==0 ) low = p-table;
|
||||
len = 0;
|
||||
if ( q != NULL ) fprintf(stderr, "[%d]", p-table);
|
||||
while ( q != NULL )
|
||||
{
|
||||
len++;
|
||||
n++;
|
||||
fprintf(stderr, " %s", q->str);
|
||||
q = q->next;
|
||||
if ( q == NULL ) fprintf(stderr, "\n");
|
||||
}
|
||||
count[len]++;
|
||||
if ( *p != NULL ) hi = p-table;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Storing %d recs used %d hash positions out of %d\n",
|
||||
n, size-count[0], size);
|
||||
fprintf(stderr, "%f %% utilization\n",
|
||||
((float)(size-count[0]))/((float)size));
|
||||
for (i=0; i<20; i++)
|
||||
{
|
||||
if ( count[i] != 0 )
|
||||
{
|
||||
avg += (((float)(i*count[i]))/((float)n)) * i;
|
||||
fprintf(stderr, "Bucket len %d == %d (%f %% of recs)\n",
|
||||
i, count[i], ((float)(i*count[i]))/((float)n));
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Avg bucket length %f\n", avg);
|
||||
fprintf(stderr, "Range of hash function: %d..%d\n", low, hi);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Add a string to the string table and return a pointer to it.
|
||||
* Bump the pointer into the string table to next avail position.
|
||||
*/
|
||||
char *
|
||||
#ifdef __USE_PROTOS
|
||||
mystrdup( char *s )
|
||||
#else
|
||||
mystrdup( s )
|
||||
char *s;
|
||||
#endif
|
||||
{
|
||||
char *start=strp;
|
||||
require(s!=NULL, "mystrdup: NULL string");
|
||||
|
||||
while ( *s != '\0' )
|
||||
{
|
||||
require( strp <= &(strings[strsize-2]),
|
||||
"string table overflow\nIncrease StrTableSize in hash.h and recompile hash.c\n");
|
||||
*strp++ = *s++;
|
||||
}
|
||||
*strp++ = '\0';
|
||||
|
||||
return( start );
|
||||
}
|
73
Tools/CodeTools/Source/Pccts/antlr/hash.h
Normal file
73
Tools/CodeTools/Source/Pccts/antlr/hash.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* hash.h -- define hash table entries, sizes, hash function...
|
||||
*
|
||||
* 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.33
|
||||
* Terence Parr
|
||||
* Parr Research Corporation
|
||||
* with Purdue University and AHPCRC, University of Minnesota
|
||||
* 1989-2001
|
||||
*/
|
||||
|
||||
/* H a s h T a b l e S t u f f */
|
||||
|
||||
#ifndef HashTableSize
|
||||
#define HashTableSize 553
|
||||
#endif
|
||||
|
||||
#ifndef StrTableSize
|
||||
#ifdef PC32
|
||||
#define StrTableSize 1000000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef StrTableSize
|
||||
#ifdef PC
|
||||
#define StrTableSize 655200
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef StrTableSize
|
||||
#define StrTableSize 1000000
|
||||
#endif
|
||||
|
||||
typedef struct _entry { /* Minimum hash table entry -- superclass */
|
||||
char *str;
|
||||
struct _entry *next;
|
||||
} Entry;
|
||||
|
||||
/* Hash 's' using 'size', place into h (s is modified) */
|
||||
#define Hash(s,h,size) \
|
||||
{while ( *s != '\0' ) h = (h<<1) + *s++; \
|
||||
h %= size;}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Entry *hash_get(Entry **, char *),
|
||||
**newHashTable(void),
|
||||
*hash_add(Entry **, char *, Entry *);
|
||||
|
||||
void killHashTable(Entry **);
|
||||
|
||||
#else
|
||||
Entry *hash_get(), **newHashTable(), *hash_add();
|
||||
void killHashTable(); /* MR9 23-Sep-97 */
|
||||
#endif
|
878
Tools/CodeTools/Source/Pccts/antlr/lex.c
Normal file
878
Tools/CodeTools/Source/Pccts/antlr/lex.c
Normal file
@@ -0,0 +1,878 @@
|
||||
/*
|
||||
* lex.c -- Generate all of the lexical type files: parser.dlg tokens.h
|
||||
*
|
||||
* 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.33
|
||||
* Terence Parr
|
||||
* Parr Research Corporation
|
||||
* with Purdue University and AHPCRC, University of Minnesota
|
||||
* 1989-2001
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
/* MR1 */
|
||||
/* MR1 10-Apr-97 MR1 Replace use of __STDC__ with __USE_PROTOS */
|
||||
/* MR1 */
|
||||
#include "pcctscfg.h"
|
||||
#include "set.h"
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
|
||||
#define DLGErrorString "invalid token"
|
||||
|
||||
/* Generate a complete lexical description of the lexemes found in the grammar */
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
genLexDescr( void )
|
||||
#else
|
||||
genLexDescr( )
|
||||
#endif
|
||||
{
|
||||
ListNode *p;
|
||||
FILE *dlgFile = fopen(OutMetaName(DlgFileName), "w");
|
||||
require(dlgFile!=NULL, eMsg1("genLexFile: cannot open %s", OutMetaName(DlgFileName)) );
|
||||
#ifdef SPECIAL_FOPEN
|
||||
special_fopen_actions(OutMetaName(DlgFileName)); /* MR1 */
|
||||
#endif
|
||||
fprintf(dlgFile, "<<\n");
|
||||
fprintf(dlgFile, "/* %s -- DLG Description of scanner\n", DlgFileName);
|
||||
fprintf(dlgFile, " *\n");
|
||||
fprintf(dlgFile, " * Generated from:");
|
||||
{int i; for (i=0; i<NumFiles; i++) fprintf(dlgFile, " %s", FileStr[i]);}
|
||||
fprintf(dlgFile, "\n");
|
||||
fprintf(dlgFile, " *\n");
|
||||
fprintf(dlgFile, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");
|
||||
fprintf(dlgFile, " * Purdue University Electrical Engineering\n");
|
||||
fprintf(dlgFile, " * With AHPCRC, University of Minnesota\n");
|
||||
fprintf(dlgFile, " * ANTLR Version %s\n", Version);
|
||||
fprintf(dlgFile, " */\n\n");
|
||||
if (FirstAction != NULL ) dumpAction( FirstAction, dlgFile, 0, -1, 0, 1 ); /* MR11 MR15b */
|
||||
fprintf(dlgFile, "#define ANTLR_VERSION %s\n", VersionDef);
|
||||
if ( GenCC )
|
||||
{
|
||||
if ( !UserDefdTokens ) fprintf(dlgFile, "#include \"%s\"\n", DefFileName);
|
||||
else fprintf(dlgFile, "#include %s\n", UserTokenDefsFile);
|
||||
fprintf(dlgFile, "#include \"%s\"\n", ATOKEN_H);
|
||||
if ( GenAST ) fprintf(dlgFile, "#include \"%s\"\n", ASTBASE_H);
|
||||
if ( HdrAction != NULL ) dumpAction( HdrAction, dlgFile, 0, -1, 0, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(dlgFile, "#include \"pcctscfg.h\"\n");
|
||||
fprintf(dlgFile, "#include \"pccts_stdio.h\"\n");
|
||||
if ( strcmp(ParserName, DefaultParserName)!=0 )
|
||||
fprintf(dlgFile, "#define %s %s\n", DefaultParserName, ParserName);
|
||||
if ( strcmp(ParserName, DefaultParserName)!=0 )
|
||||
fprintf(dlgFile, "#include \"%s\"\n", RemapFileName);
|
||||
if ( HdrAction != NULL ) dumpAction( HdrAction, dlgFile, 0, -1, 0, 1 );
|
||||
if ( FoundGuessBlk )
|
||||
{
|
||||
fprintf(dlgFile, "#define ZZCAN_GUESS\n");
|
||||
fprintf(dlgFile, "#include \"pccts_setjmp.h\"\n");
|
||||
}
|
||||
if ( OutputLL_k > 1 ) fprintf(dlgFile, "#define LL_K %d\n", OutputLL_k);
|
||||
if ( DemandLookahead ) fprintf(dlgFile, "#define DEMAND_LOOK\n");
|
||||
if (TraceGen) {
|
||||
fprintf(dlgFile,"#ifndef zzTRACE_RULES\n"); /* MR20 */
|
||||
fprintf(dlgFile,"#define zzTRACE_RULES\n"); /* MR20 */
|
||||
fprintf(dlgFile,"#endif\n"); /* MR22 */
|
||||
};
|
||||
fprintf(dlgFile, "#include \"antlr.h\"\n");
|
||||
if ( GenAST ) {
|
||||
fprintf(dlgFile, "#include \"ast.h\"\n");
|
||||
}
|
||||
if ( UserDefdTokens )
|
||||
fprintf(dlgFile, "#include %s\n", UserTokenDefsFile);
|
||||
/* still need this one as it has the func prototypes */
|
||||
fprintf(dlgFile, "#include \"%s\"\n", DefFileName);
|
||||
fprintf(dlgFile, "#include \"dlgdef.h\"\n");
|
||||
fprintf(dlgFile, "LOOKAHEAD\n");
|
||||
fprintf(dlgFile, "\n");
|
||||
fprintf(dlgFile, "void\n");
|
||||
fprintf(dlgFile, "#ifdef __USE_PROTOS\n");
|
||||
fprintf(dlgFile, "zzerraction(void)\n");
|
||||
fprintf(dlgFile, "#else\n");
|
||||
fprintf(dlgFile, "zzerraction()\n");
|
||||
fprintf(dlgFile, "#endif\n");
|
||||
fprintf(dlgFile, "{\n");
|
||||
fprintf(dlgFile, "\t(*zzerr)(\"%s\");\n", DLGErrorString);
|
||||
fprintf(dlgFile, "\tzzadvance();\n");
|
||||
fprintf(dlgFile, "\tzzskip();\n");
|
||||
fprintf(dlgFile, "}\n");
|
||||
}
|
||||
fprintf(dlgFile, ">>\n\n");
|
||||
|
||||
/* dump all actions */
|
||||
|
||||
/* MR1 */
|
||||
/* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
|
||||
/* MR1 via <<%%lexmember ....>> & <<%%lexprefix ...>> */
|
||||
/* MR1 */
|
||||
if (LexActions != NULL) {
|
||||
for (p = LexActions->next; p!=NULL; p=p->next)
|
||||
{
|
||||
/* MR1 */ fprintf(dlgFile, "<<%%%%lexaction\n");
|
||||
dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );
|
||||
fprintf(dlgFile, ">>\n\n");
|
||||
}
|
||||
};
|
||||
|
||||
/* MR1 */ if (GenCC) {
|
||||
/* MR1 */ fprintf(dlgFile,"<<%%%%parserclass %s>>\n\n",CurrentClassName);
|
||||
/* MR1 */ };
|
||||
|
||||
/* MR1 */ if (LexPrefixActions != NULL) {
|
||||
/* MR1 */ for (p = LexPrefixActions->next; p!=NULL; p=p->next)
|
||||
/* MR1 */ {
|
||||
/* MR1 */ fprintf(dlgFile, "<<%%%%lexprefix\n");
|
||||
/* MR1 */ dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );
|
||||
/* MR1 */ fprintf(dlgFile, ">>\n\n");
|
||||
/* MR1 */ }
|
||||
/* MR1 */ };
|
||||
|
||||
/* MR1 */ if (LexMemberActions != NULL) {
|
||||
/* MR1 */ for (p = LexMemberActions->next; p!=NULL; p=p->next)
|
||||
/* MR1 */ {
|
||||
/* MR1 */ fprintf(dlgFile, "<<%%%%lexmember\n");
|
||||
/* MR1 */ dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );
|
||||
/* MR1 */ fprintf(dlgFile, ">>\n\n");
|
||||
/* MR1 */ }
|
||||
/* MR1 */ };
|
||||
|
||||
/* dump all regular expression rules/actions (skip sentinel node) */
|
||||
if ( ExprOrder == NULL ) {
|
||||
warnNoFL("no regular expressions found in grammar");
|
||||
}
|
||||
else dumpLexClasses(dlgFile);
|
||||
fprintf(dlgFile, "%%%%\n");
|
||||
fclose( dlgFile );
|
||||
}
|
||||
|
||||
/* For each lexical class, scan ExprOrder looking for expressions
|
||||
* in that lexical class. Print out only those that match.
|
||||
* Each element of the ExprOrder list has both an expr and an lclass
|
||||
* field.
|
||||
*/
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
dumpLexClasses( FILE *dlgFile )
|
||||
#else
|
||||
dumpLexClasses( dlgFile )
|
||||
FILE *dlgFile;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
TermEntry *t;
|
||||
ListNode *p;
|
||||
Expr *q;
|
||||
|
||||
for (i=0; i<NumLexClasses; i++)
|
||||
{
|
||||
fprintf(dlgFile, "\n%%%%%s\n\n", lclass[i].classnum);
|
||||
for (p=ExprOrder->next; p!=NULL; p=p->next)
|
||||
{
|
||||
q = (Expr *) p->elem;
|
||||
if ( q->lclass != i ) continue;
|
||||
lexmode(i);
|
||||
t = (TermEntry *) hash_get(Texpr, q->expr);
|
||||
require(t!=NULL, eMsg1("genLexDescr: rexpr %s not in hash table",q->expr) );
|
||||
if ( t->token == EpToken ) continue;
|
||||
fprintf(dlgFile, "%s\n\t<<\n", StripQuotes(q->expr));
|
||||
/* replace " killed by StripQuotes() */
|
||||
q->expr[ strlen(q->expr) ] = '"';
|
||||
if ( !GenCC ) {
|
||||
if ( TokenString(t->token) != NULL )
|
||||
fprintf(dlgFile, "\t\tNLA = %s;\n", TokenString(t->token));
|
||||
else
|
||||
fprintf(dlgFile, "\t\tNLA = %d;\n", t->token);
|
||||
}
|
||||
if ( t->action != NULL ) dumpAction( t->action, dlgFile, 2,-1,0,1 );
|
||||
if ( GenCC ) {
|
||||
if ( TokenString(t->token) != NULL )
|
||||
fprintf(dlgFile, "\t\treturn %s;\n", TokenString(t->token));
|
||||
else
|
||||
fprintf(dlgFile, "\t\treturn (ANTLRTokenType)%d;\n", t->token);
|
||||
}
|
||||
fprintf(dlgFile, "\t>>\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Strip the leading path (if any) from a filename */
|
||||
char *
|
||||
#ifdef __USE_PROTOS
|
||||
StripPath( char *fileName )
|
||||
#else
|
||||
StripPath( fileName )
|
||||
char *fileName;
|
||||
#endif
|
||||
{
|
||||
char *p;
|
||||
static char dirSym[2] = DirectorySymbol;
|
||||
|
||||
if(NULL != (p = strrchr(fileName, dirSym[0])))
|
||||
p++;
|
||||
else
|
||||
p = fileName;
|
||||
|
||||
return(p);
|
||||
}
|
||||
|
||||
/* Generate a list of #defines && list of struct definitions for
|
||||
* aggregate retv's */
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
genDefFile( void )
|
||||
#else
|
||||
genDefFile( )
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
|
||||
/* If C++ mode and #tokdef used, then don't need anything in here since
|
||||
* C++ puts all definitions in the class file name.
|
||||
*/
|
||||
if ( GenCC && UserTokenDefsFile ) return;
|
||||
if ( MR_Inhibit_Tokens_h_Gen) return;
|
||||
|
||||
DefFile = fopen(OutMetaName(DefFileName), "w");
|
||||
require(DefFile!=NULL, eMsg1("genDefFile: cannot open %s", OutMetaName(DefFileName)) );
|
||||
#ifdef SPECIAL_FOPEN
|
||||
special_fopen_actions(OutMetaName(DefFileName)); /* MR1 */
|
||||
#endif
|
||||
fprintf(DefFile, "#ifndef %s\n", StripPath(gate_symbol(DefFileName)));
|
||||
fprintf(DefFile, "#define %s\n", StripPath(gate_symbol(DefFileName)));
|
||||
|
||||
fprintf(DefFile, "/* %s -- List of labelled tokens and stuff\n", DefFileName);
|
||||
fprintf(DefFile, " *\n");
|
||||
fprintf(DefFile, " * Generated from:");
|
||||
for (i=0; i<NumFiles; i++) fprintf(DefFile, " %s", FileStr[i]);
|
||||
fprintf(DefFile, "\n");
|
||||
fprintf(DefFile, " *\n");
|
||||
fprintf(DefFile, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");
|
||||
fprintf(DefFile, " * Purdue University Electrical Engineering\n");
|
||||
fprintf(DefFile, " * ANTLR Version %s\n", Version);
|
||||
fprintf(DefFile, " */\n");
|
||||
|
||||
if ( !GenCC && LexGen ) {
|
||||
fprintf(DefFile,"#define zzEOF_TOKEN %d\n",
|
||||
TokenInd!=NULL?TokenInd[EofToken]:EofToken);
|
||||
}
|
||||
|
||||
if ( !UserDefdTokens )
|
||||
{
|
||||
int first=1;
|
||||
|
||||
if ( GenCC ) fprintf(DefFile, "enum ANTLRTokenType {\n");
|
||||
for (i=1; i<TokenNum; i++)
|
||||
{
|
||||
/* Don't do EpToken or expr w/o labels */
|
||||
if ( TokenString(i)!=NULL && i != EpToken )
|
||||
{
|
||||
TermEntry *p;
|
||||
|
||||
if ( WarningLevel>1 )
|
||||
{
|
||||
int j;
|
||||
/* look in all lexclasses for the reg expr */
|
||||
|
||||
/* MR10 Derek Pappas */
|
||||
/* MR10 A #tokclass doesn't have associated regular expressiones */
|
||||
/* MR10 so don't warn user about it's omission */
|
||||
|
||||
p = (TermEntry *) hash_get(Tname, TokenString(i));
|
||||
|
||||
if (p != NULL && ! p->classname) {
|
||||
for (j=0; j<NumLexClasses; j++)
|
||||
{
|
||||
lexmode(j);
|
||||
if ( ExprString(i)!=NULL ) break;
|
||||
}
|
||||
if ( j>=NumLexClasses )
|
||||
{
|
||||
warnNoFL(eMsg1("token label has no associated rexpr: %s",TokenString(i)));
|
||||
}
|
||||
};
|
||||
}
|
||||
require((p=(TermEntry *)hash_get(Tname, TokenString(i))) != NULL,
|
||||
"token not in sym tab when it should be");
|
||||
if ( !p->classname )
|
||||
{
|
||||
if ( GenCC ) {
|
||||
if ( !first ) fprintf(DefFile, ",\n");
|
||||
first = 0;
|
||||
fprintf(DefFile, "\t%s=%d", TokenString(i), i);
|
||||
}
|
||||
else
|
||||
fprintf(DefFile, "#define %s %d\n", TokenString(i), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* MR1 */
|
||||
/* MR1 10-Apr-97 133MR1 Prevent use of varying sizes of integer */
|
||||
/* MR1 for the enum ANTLRTokenType */
|
||||
/* MR1 */
|
||||
if ( GenCC ) { /* MR1 */
|
||||
if ( !first ) fprintf(DefFile, ",\n"); /* MR14 */
|
||||
fprintf(DefFile, "\tDLGminToken=0"); /* MR1 */
|
||||
fprintf(DefFile, ",\n\tDLGmaxToken=9999};\n"); /* MR1 */
|
||||
}; /* MR1 */
|
||||
}
|
||||
|
||||
if ( !GenCC ) GenRulePrototypes(DefFile, SynDiag);
|
||||
|
||||
fprintf(DefFile, "\n#endif\n");
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
GenRemapFile( void )
|
||||
#else
|
||||
GenRemapFile( )
|
||||
#endif
|
||||
{
|
||||
if ( strcmp(ParserName, DefaultParserName)!=0 )
|
||||
{
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
f = fopen(OutMetaName(RemapFileName), "w");
|
||||
require(f!=NULL, eMsg1("GenRemapFile: cannot open %s", OutMetaName(RemapFileName)) );
|
||||
#ifdef SPECIAL_FOPEN
|
||||
special_fopen_actions(OutMetaName(RemapFileName)); /* MR1 */
|
||||
#endif
|
||||
fprintf(f, "/* %s -- List of symbols to remap\n", RemapFileName);
|
||||
fprintf(f, " *\n");
|
||||
fprintf(f, " * Generated from:");
|
||||
for (i=0; i<NumFiles; i++) fprintf(f, " %s", FileStr[i]);
|
||||
fprintf(f, "\n");
|
||||
fprintf(f, " *\n");
|
||||
fprintf(f, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");
|
||||
fprintf(f, " * Purdue University Electrical Engineering\n");
|
||||
fprintf(f, " * ANTLR Version %s\n", Version);
|
||||
fprintf(f, " */\n");
|
||||
|
||||
GenRuleFuncRedefs(f, SynDiag);
|
||||
GenPredefinedSymbolRedefs(f);
|
||||
if ( GenAST ) GenASTSymbolRedefs(f);
|
||||
GenSetRedefs(f);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate a bunch of #defines that rename all functions to be "ParserName_func" */
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
GenRuleFuncRedefs( FILE *f, Junction *p )
|
||||
#else
|
||||
GenRuleFuncRedefs( f, p )
|
||||
FILE *f;
|
||||
Junction *p;
|
||||
#endif
|
||||
{
|
||||
fprintf(f, "\n/* rename rule functions to be 'ParserName_func' */\n");
|
||||
while ( p!=NULL )
|
||||
{
|
||||
fprintf(f, "#define %s %s_%s\n", p->rname, ParserName, p->rname);
|
||||
p = (Junction *)p->p2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate a bunch of #defines that rename all standard symbols to be
|
||||
* "ParserName_symbol". The list of standard symbols to change is in
|
||||
* globals.c.
|
||||
*/
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
GenPredefinedSymbolRedefs( FILE *f )
|
||||
#else
|
||||
GenPredefinedSymbolRedefs( f )
|
||||
FILE *f;
|
||||
#endif
|
||||
{
|
||||
char **p;
|
||||
|
||||
fprintf(f, "\n/* rename PCCTS-supplied symbols to be 'ParserName_symbol' */\n");
|
||||
for (p = &StandardSymbols[0]; *p!=NULL; p++)
|
||||
{
|
||||
fprintf(f, "#define %s %s_%s\n", *p, ParserName, *p);
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate a bunch of #defines that rename all AST symbols to be
|
||||
* "ParserName_symbol". The list of AST symbols to change is in
|
||||
* globals.c.
|
||||
*/
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
GenASTSymbolRedefs( FILE *f )
|
||||
#else
|
||||
GenASTSymbolRedefs( f )
|
||||
FILE *f;
|
||||
#endif
|
||||
{
|
||||
char **p;
|
||||
|
||||
fprintf(f, "\n/* rename PCCTS-supplied AST symbols to be 'ParserName_symbol' */\n");
|
||||
for (p = &ASTSymbols[0]; *p!=NULL; p++)
|
||||
{
|
||||
fprintf(f, "#define %s %s_%s\n", *p, ParserName, *p);
|
||||
}
|
||||
}
|
||||
|
||||
/* redefine all sets generated by ANTLR; WARNING: 'zzerr', 'setwd' must match
|
||||
* use in bits.c (DumpSetWd() etc...)
|
||||
*/
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
GenSetRedefs( FILE *f )
|
||||
#else
|
||||
GenSetRedefs( f )
|
||||
FILE *f;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=1; i<=wordnum; i++)
|
||||
{
|
||||
fprintf(f, "#define setwd%d %s_setwd%d\n", i, ParserName, i);
|
||||
}
|
||||
for (i=1; i<=esetnum; i++)
|
||||
{
|
||||
fprintf(f, "#define zzerr%d %s_err%d\n", i, ParserName, i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Find all return types/parameters that require structs and def
|
||||
* all rules with ret types.
|
||||
*
|
||||
* This is for the declaration, not the definition.
|
||||
*/
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
GenRulePrototypes( FILE *f, Junction *p )
|
||||
#else
|
||||
GenRulePrototypes( f, p )
|
||||
FILE *f;
|
||||
Junction *p;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 1;
|
||||
while ( p!=NULL )
|
||||
{
|
||||
if ( p->ret != NULL )
|
||||
{
|
||||
/* MR23 */ if ( hasMultipleOperands(p->ret) )
|
||||
{
|
||||
DumpRetValStruct(f, p->ret, i);
|
||||
}
|
||||
fprintf(f, "\n#ifdef __USE_PROTOS\n");
|
||||
/* MR23 */ if ( hasMultipleOperands(p->ret) )
|
||||
{
|
||||
fprintf(f, "extern struct _rv%d", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(f, "extern ");
|
||||
DumpType(p->ret, f);
|
||||
}
|
||||
fprintf(f, " %s%s(", RulePrefix, p->rname);
|
||||
DumpANSIFunctionArgDef(f,p,1 /* emit initializers ? */);
|
||||
fprintf(f, ";\n");
|
||||
fprintf(f, "#else\n");
|
||||
/* MR23 */ if ( hasMultipleOperands(p->ret) )
|
||||
{
|
||||
fprintf(f, "extern struct _rv%d", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(f, "extern ");
|
||||
DumpType(p->ret, f);
|
||||
}
|
||||
fprintf(f, " %s%s();\n", RulePrefix, p->rname);
|
||||
fprintf(f, "#endif\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(f, "\n#ifdef __USE_PROTOS\n");
|
||||
fprintf(f, "void %s%s(", RulePrefix, p->rname);
|
||||
DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */ );
|
||||
fprintf(f, ";\n");
|
||||
#ifdef OLD
|
||||
if ( p->pdecl != NULL || GenAST )
|
||||
{
|
||||
if ( GenAST ) {
|
||||
fprintf(f, "AST **%s",(p->pdecl!=NULL)?",":"");
|
||||
}
|
||||
if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);
|
||||
}
|
||||
else fprintf(f, "void");
|
||||
fprintf(f, ");\n");
|
||||
#endif
|
||||
fprintf(f, "#else\n");
|
||||
fprintf(f, "extern void %s%s();\n", RulePrefix, p->rname);
|
||||
fprintf(f, "#endif\n");
|
||||
}
|
||||
i++;
|
||||
p = (Junction *)p->p2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Define all rules in the class.h file; generate any required
|
||||
* struct definitions first, however.
|
||||
*/
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
GenRuleMemberDeclarationsForCC( FILE *f, Junction *q )
|
||||
#else
|
||||
GenRuleMemberDeclarationsForCC( f, q )
|
||||
FILE *f;
|
||||
Junction *q;
|
||||
#endif
|
||||
{
|
||||
Junction *p = q;
|
||||
int i;
|
||||
|
||||
fprintf(f, "private:\n");
|
||||
|
||||
/* Dump dflt handler declaration */
|
||||
fprintf(f, "\tvoid zzdflthandlers( int _signal, int *_retsignal );\n\n");
|
||||
|
||||
fprintf(f, "public:\n");
|
||||
|
||||
/* Dump return value structs */
|
||||
i = 1;
|
||||
while ( p!=NULL )
|
||||
{
|
||||
if ( p->ret != NULL )
|
||||
{
|
||||
/* MR23 */ if ( hasMultipleOperands(p->ret) )
|
||||
{
|
||||
DumpRetValStruct(f, p->ret, i);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
p = (Junction *)p->p2;
|
||||
}
|
||||
|
||||
/* Dump member func defs && CONSTRUCTOR */
|
||||
fprintf(f, "\t%s(ANTLRTokenBuffer *input);\n", CurrentClassName);
|
||||
/*
|
||||
fprintf(f, "\t%s(ANTLRTokenBuffer *input, ANTLRTokenType eof);\n",
|
||||
CurrentClassName);
|
||||
*/
|
||||
|
||||
i = 1;
|
||||
p = q;
|
||||
while ( p!=NULL )
|
||||
{
|
||||
if ( p->ret != NULL )
|
||||
{
|
||||
/* MR23 */ if ( hasMultipleOperands(p->ret) )
|
||||
{
|
||||
fprintf(f, "\tstruct _rv%d", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(f, "\t");
|
||||
DumpType(p->ret, f);
|
||||
}
|
||||
fprintf(f, " %s%s(",RulePrefix,p->rname);
|
||||
DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */ );
|
||||
fprintf(f, ";\n");
|
||||
#ifdef OLD
|
||||
if ( p->pdecl != NULL || GenAST )
|
||||
{
|
||||
if ( GenAST ) fprintf(f, "ASTBase **%s",(p->pdecl!=NULL)?",":"");
|
||||
if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);
|
||||
}
|
||||
fprintf(f, ");\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(f, "\tvoid %s%s(",RulePrefix,p->rname);
|
||||
DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */);
|
||||
fprintf(f, ";\n");
|
||||
#ifdef OLD
|
||||
if ( p->pdecl != NULL || GenAST )
|
||||
{
|
||||
if ( GenAST ) fprintf(f, "ASTBase **%s",(p->pdecl!=NULL)?",":"");
|
||||
if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);
|
||||
}
|
||||
fprintf(f, ");\n");
|
||||
#endif
|
||||
}
|
||||
i++;
|
||||
p = (Junction *)p->p2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Given a list of ANSI-style parameter declarations, print out a
|
||||
* comma-separated list of the symbols (w/o types).
|
||||
* Basically, we look for a comma, then work backwards until start of
|
||||
* the symbol name. Then print it out until 1st non-alnum char. Now,
|
||||
* move on to next parameter.
|
||||
*
|
||||
*/
|
||||
|
||||
/* MR5 Jan Mikkelsen 26-May-97 - added initalComma parameter */
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
DumpListOfParmNames(char *pdecl, FILE *output, int initialComma) /* MR5 */
|
||||
#else
|
||||
DumpListOfParmNames(pdecl, output, initialComma) /* MR5 */
|
||||
char *pdecl; /* MR5 */
|
||||
FILE *output; /* MR5 */
|
||||
int initialComma; /* MR5 */
|
||||
#endif
|
||||
{
|
||||
int firstTime = 1, done = 0;
|
||||
require(output!=NULL, "DumpListOfParmNames: NULL parm");
|
||||
|
||||
if ( pdecl == NULL ) return;
|
||||
while ( !done )
|
||||
{
|
||||
if ( !firstTime || initialComma ) putc(',', output); /* MR5 */
|
||||
done = DumpNextNameInDef(&pdecl, output);
|
||||
firstTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* given a list of parameters or return values, dump the next
|
||||
* name to output. Return 1 if last one just printed, 0 if more to go.
|
||||
*/
|
||||
|
||||
/* MR23 Total rewrite */
|
||||
|
||||
int
|
||||
#ifdef __USE_PROTOS
|
||||
DumpNextNameInDef( char **q, FILE *output )
|
||||
#else
|
||||
DumpNextNameInDef( q, output )
|
||||
char **q;
|
||||
FILE *output;
|
||||
#endif
|
||||
{
|
||||
char *p;
|
||||
char *t;
|
||||
char *pDataType;
|
||||
char *pSymbol;
|
||||
char *pEqualSign;
|
||||
char *pValue;
|
||||
char *pSeparator;
|
||||
int nest = 0;
|
||||
|
||||
p = endFormal(*q,
|
||||
&pDataType,
|
||||
&pSymbol,
|
||||
&pEqualSign,
|
||||
&pValue,
|
||||
&pSeparator,
|
||||
&nest);
|
||||
|
||||
/* MR26 Handle rule arguments such as: IIR_Bool (IIR_Decl::*contstraint)()
|
||||
For this we need to strip off anything which follows the symbol.
|
||||
*/
|
||||
|
||||
/* MR26 */ t = pSymbol;
|
||||
/* MR26 */ if (t != NULL) {
|
||||
/* MR26 */ for (t = pSymbol; *t != 0; t++) {
|
||||
/* MR26 */ if (! (isalpha(*t) || isdigit(*t) || *t == '_' || *t == '$')) break;
|
||||
/* MR26 */ }
|
||||
/* MR26 */ }
|
||||
/* MR26 */ fprintf(output,strBetween(pSymbol, t, pSeparator));
|
||||
|
||||
*q = p;
|
||||
return (*pSeparator == 0);
|
||||
}
|
||||
|
||||
/* Given a list of ANSI-style parameter declarations, dump K&R-style
|
||||
* declarations, one per line for each parameter. Basically, convert
|
||||
* comma to semi-colon, newline.
|
||||
*/
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
DumpOldStyleParms( char *pdecl, FILE *output )
|
||||
#else
|
||||
DumpOldStyleParms( pdecl, output )
|
||||
char *pdecl;
|
||||
FILE *output;
|
||||
#endif
|
||||
{
|
||||
require(output!=NULL, "DumpOldStyleParms: NULL parm");
|
||||
|
||||
if ( pdecl == NULL ) return;
|
||||
while ( *pdecl != '\0' )
|
||||
{
|
||||
if ( *pdecl == ',' )
|
||||
{
|
||||
pdecl++;
|
||||
putc(';', output); putc('\n', output);
|
||||
while ( *pdecl==' ' || *pdecl=='\t' || *pdecl=='\n' ) pdecl++;
|
||||
}
|
||||
else {putc(*pdecl, output); pdecl++;}
|
||||
}
|
||||
putc(';', output);
|
||||
putc('\n', output);
|
||||
}
|
||||
|
||||
/* Take in a type definition (type + symbol) and print out type only */
|
||||
/* MR23 Total rewrite */
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
DumpType( char *s, FILE *f )
|
||||
#else
|
||||
DumpType( s, f )
|
||||
char *s;
|
||||
FILE *f;
|
||||
#endif
|
||||
{
|
||||
char *p;
|
||||
char *pDataType;
|
||||
char *pSymbol;
|
||||
char *pEqualSign;
|
||||
char *pValue;
|
||||
char *pSeparator;
|
||||
int nest = 0;
|
||||
|
||||
require(s!=NULL, "DumpType: invalid type string");
|
||||
|
||||
p = endFormal(s,
|
||||
&pDataType,
|
||||
&pSymbol,
|
||||
&pEqualSign,
|
||||
&pValue,
|
||||
&pSeparator,
|
||||
&nest);
|
||||
fprintf(f,strBetween(pDataType, pSymbol, pSeparator));
|
||||
}
|
||||
|
||||
/* check to see if string e is a word in string s */
|
||||
int
|
||||
#ifdef __USE_PROTOS
|
||||
strmember( char *s, char *e )
|
||||
#else
|
||||
strmember( s, e )
|
||||
char *s;
|
||||
char *e;
|
||||
#endif
|
||||
{
|
||||
register char *p;
|
||||
require(s!=NULL&&e!=NULL, "strmember: NULL string");
|
||||
|
||||
if ( *e=='\0' ) return 1; /* empty string is always member */
|
||||
do {
|
||||
while ( *s!='\0' && !isalnum(*s) && *s!='_' )
|
||||
++s;
|
||||
p = e;
|
||||
while ( *p!='\0' && *p==*s ) {p++; s++;}
|
||||
if ( *p=='\0' ) {
|
||||
if ( *s=='\0' ) return 1;
|
||||
if ( !isalnum (*s) && *s != '_' ) return 1;
|
||||
}
|
||||
while ( isalnum(*s) || *s == '_' )
|
||||
++s;
|
||||
} while ( *s!='\0' );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/* MR23 Replaced by hasMultipleOperands() */
|
||||
|
||||
int
|
||||
#ifdef __USE_PROTOS
|
||||
HasComma( char *s )
|
||||
#else
|
||||
HasComma( s )
|
||||
char *s;
|
||||
#endif
|
||||
{
|
||||
while (*s!='\0')
|
||||
if ( *s++ == ',' ) return 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* MR23 Total rewrite */
|
||||
|
||||
void
|
||||
#ifdef __USE_PROTOS
|
||||
DumpRetValStruct( FILE *f, char *ret, int i )
|
||||
#else
|
||||
DumpRetValStruct( f, ret, i )
|
||||
FILE *f;
|
||||
char *ret;
|
||||
int i;
|
||||
#endif
|
||||
{
|
||||
char *p = ret;
|
||||
char *pDataType;
|
||||
char *pSymbol;
|
||||
char *pEqualSign;
|
||||
char *pValue;
|
||||
char *pSeparator;
|
||||
int nest = 0;
|
||||
|
||||
fprintf(f, "\nstruct _rv%d {\n", i);
|
||||
while (*p != 0 && nest == 0) {
|
||||
p = endFormal(p,
|
||||
&pDataType,
|
||||
&pSymbol,
|
||||
&pEqualSign,
|
||||
&pValue,
|
||||
&pSeparator,
|
||||
&nest);
|
||||
fprintf(f,"\t");
|
||||
fprintf(f,strBetween(pDataType, pSymbol, pSeparator));
|
||||
fprintf(f," ");
|
||||
fprintf(f,strBetween(pSymbol, pEqualSign, pSeparator));
|
||||
fprintf(f,";\n");
|
||||
}
|
||||
fprintf(f,"};\n");
|
||||
}
|
||||
|
||||
/* given "s" yield s -- DESTRUCTIVE (we modify s if starts with " else return s) */
|
||||
char *
|
||||
#ifdef __USE_PROTOS
|
||||
StripQuotes( char *s )
|
||||
#else
|
||||
StripQuotes( s )
|
||||
char *s;
|
||||
#endif
|
||||
{
|
||||
if ( *s == '"' )
|
||||
{
|
||||
s[ strlen(s)-1 ] = '\0'; /* remove last quote */
|
||||
return( s+1 ); /* return address past initial quote */
|
||||
}
|
||||
return( s );
|
||||
}
|
1747
Tools/CodeTools/Source/Pccts/antlr/main.c
Normal file
1747
Tools/CodeTools/Source/Pccts/antlr/main.c
Normal file
File diff suppressed because it is too large
Load Diff
218
Tools/CodeTools/Source/Pccts/antlr/makefile
Normal file
218
Tools/CodeTools/Source/Pccts/antlr/makefile
Normal file
@@ -0,0 +1,218 @@
|
||||
#
|
||||
# Makefile for ANTLR 1.33
|
||||
#
|
||||
# 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.33
|
||||
# Terence Parr
|
||||
# Parr Research Corporation
|
||||
# with Purdue University
|
||||
# and AHPCRC, University of Minnesota
|
||||
# 1989-1995
|
||||
#
|
||||
# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by
|
||||
# Ed Harfmann
|
||||
# Micro Data Base Systems
|
||||
# Lafayette, Indiana
|
||||
#
|
||||
SET=../support/set
|
||||
PCCTS_H=../h
|
||||
|
||||
##
|
||||
## Uncomment the appropriate section to build
|
||||
## (both targets and 'make' variable definitions)
|
||||
## Note that UNIX is the default
|
||||
##
|
||||
|
||||
#
|
||||
# OS/2 & DOS 16 bit using MSC 6.0
|
||||
#
|
||||
#CC=cl
|
||||
#ANTLR=..\bin\antlr
|
||||
#DLG=..\bin\dlg
|
||||
#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN
|
||||
#OUT_OBJ = -Fo
|
||||
#LIBS=/NOD:LLIBCE LLIBCEP
|
||||
#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 egamn.obj
|
||||
# link @<<
|
||||
#$** /NOI
|
||||
#$@ /STACK:14336
|
||||
#
|
||||
#$(LIBS: = +^
|
||||
#)
|
||||
#$(DEF_FILE) $(LFLAGS) ;
|
||||
#<<
|
||||
# bind $@ c:\os2\doscalls.lib
|
||||
# copy *.exe ..\bin
|
||||
#
|
||||
|
||||
#
|
||||
# Borland C++ for DOS
|
||||
#
|
||||
#CC=bcc
|
||||
#ANTLR=..\bin\antlr
|
||||
#DLG=..\bin\dlg
|
||||
#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN
|
||||
#OUT_OBJ = -o
|
||||
#LIBS= emu mathl cl
|
||||
#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 egman.obj mrhoist.obj fcache.obj
|
||||
# tlink @&&|
|
||||
#C0L $**
|
||||
#$@ /Tde /c
|
||||
#
|
||||
#$(LIBS)
|
||||
#$(DEF_FILE) $(LFLAGS) ;
|
||||
#|
|
||||
# copy *.exe ..\bin
|
||||
#
|
||||
|
||||
#
|
||||
# C-Set/2 for OS/2
|
||||
#
|
||||
#CC=icc
|
||||
#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 -DUSER_ZZSYN -D__STDC__
|
||||
#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 egman.obj mrhoist.obj fcache.obj
|
||||
# link386 @<<
|
||||
#$** /NOI
|
||||
#$@ /STACK:32768
|
||||
#
|
||||
#$(LIBS: = +^
|
||||
#)
|
||||
#$(DEF_FILE) $(LFLAGS) ;
|
||||
#<<
|
||||
# copy *.exe ..\bin
|
||||
#
|
||||
|
||||
#
|
||||
# Borland C++ for OS/2
|
||||
#
|
||||
#CC=bcc
|
||||
#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -v -DUSER_ZZSYN
|
||||
#OUT_OBJ = -o
|
||||
#LIBS= c2 os2
|
||||
#
|
||||
#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 egman.obj mrhoist.obj fcache.obj
|
||||
# tlink @&&|
|
||||
#c02 $** -c -v
|
||||
#antlr.exe
|
||||
#
|
||||
#C2 os2
|
||||
#
|
||||
#|
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
#
|
||||
# UNIX (default)
|
||||
#
|
||||
CC=gcc
|
||||
COPT=-O
|
||||
ANTLR=${BIN_DIR}/antlr
|
||||
DLG=${BIN_DIR}/dlg
|
||||
OBJ_EXT=o
|
||||
OUT_OBJ = -o
|
||||
CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536
|
||||
#
|
||||
# SGI Users, use this CFLAGS
|
||||
#
|
||||
#CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262
|
||||
OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o \
|
||||
globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o
|
||||
|
||||
antlr : $(OBJ) $(SRC)
|
||||
$(CC) $(CFLAGS) -o $(BIN_DIR)/antlr $(OBJ)
|
||||
|
||||
# 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 egman.c mrhoist.c fcache.c
|
||||
|
||||
#
|
||||
# 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) -gh antlr.g
|
||||
|
||||
antlr.o : antlr.c mode.h tokens.h
|
||||
|
||||
scan.o : scan.c mode.h tokens.h
|
||||
|
||||
#scan.c mode.h: parser.dlg
|
||||
# $(DLG) -C2 parser.dlg scan.c
|
||||
|
||||
set.o : $(SET)/set.c
|
||||
$(CC) $(CFLAGS) -c -o set.o $(SET)/set.c
|
||||
|
||||
|
||||
#
|
||||
# ****** These next targets are common to UNIX and PC world ********
|
||||
#
|
||||
|
||||
#clean up all the intermediate files
|
||||
clean:
|
||||
rm -f *.$(OBJ_EXT) core
|
||||
|
||||
#remove everything in clean plus the PCCTS files generated
|
||||
scrub:
|
||||
rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core
|
219
Tools/CodeTools/Source/Pccts/antlr/makefile.cygwin
Normal file
219
Tools/CodeTools/Source/Pccts/antlr/makefile.cygwin
Normal file
@@ -0,0 +1,219 @@
|
||||
#
|
||||
# Makefile for ANTLR 1.33
|
||||
#
|
||||
# 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.33
|
||||
# Terence Parr
|
||||
# Parr Research Corporation
|
||||
# with Purdue University
|
||||
# and AHPCRC, University of Minnesota
|
||||
# 1989-1995
|
||||
#
|
||||
# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by
|
||||
# Ed Harfmann
|
||||
# Micro Data Base Systems
|
||||
# Lafayette, Indiana
|
||||
#
|
||||
SET=../support/set
|
||||
PCCTS_H=../h
|
||||
|
||||
##
|
||||
## Uncomment the appropriate section to build
|
||||
## (both targets and 'make' variable definitions)
|
||||
## Note that UNIX is the default
|
||||
##
|
||||
|
||||
#
|
||||
# OS/2 & DOS 16 bit using MSC 6.0
|
||||
#
|
||||
#CC=cl
|
||||
#ANTLR=..\bin\antlr
|
||||
#DLG=..\bin\dlg
|
||||
#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN
|
||||
#OUT_OBJ = -Fo
|
||||
#LIBS=/NOD:LLIBCE LLIBCEP
|
||||
#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 egamn.obj
|
||||
# link @<<
|
||||
#$** /NOI
|
||||
#$@ /STACK:14336
|
||||
#
|
||||
#$(LIBS: = +^
|
||||
#)
|
||||
#$(DEF_FILE) $(LFLAGS) ;
|
||||
#<<
|
||||
# bind $@ c:\os2\doscalls.lib
|
||||
# copy *.exe ..\bin
|
||||
#
|
||||
|
||||
#
|
||||
# Borland C++ for DOS
|
||||
#
|
||||
#CC=bcc
|
||||
#ANTLR=..\bin\antlr
|
||||
#DLG=..\bin\dlg
|
||||
#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN
|
||||
#OUT_OBJ = -o
|
||||
#LIBS= emu mathl cl
|
||||
#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 egman.obj mrhoist.obj fcache.obj
|
||||
# tlink @&&|
|
||||
#C0L $**
|
||||
#$@ /Tde /c
|
||||
#
|
||||
#$(LIBS)
|
||||
#$(DEF_FILE) $(LFLAGS) ;
|
||||
#|
|
||||
# copy *.exe ..\bin
|
||||
#
|
||||
|
||||
#
|
||||
# C-Set/2 for OS/2
|
||||
#
|
||||
#CC=icc
|
||||
#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 -DUSER_ZZSYN -D__STDC__
|
||||
#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 egman.obj mrhoist.obj fcache.obj
|
||||
# link386 @<<
|
||||
#$** /NOI
|
||||
#$@ /STACK:32768
|
||||
#
|
||||
#$(LIBS: = +^
|
||||
#)
|
||||
#$(DEF_FILE) $(LFLAGS) ;
|
||||
#<<
|
||||
# copy *.exe ..\bin
|
||||
#
|
||||
|
||||
#
|
||||
# Borland C++ for OS/2
|
||||
#
|
||||
#CC=bcc
|
||||
#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -v -DUSER_ZZSYN
|
||||
#OUT_OBJ = -o
|
||||
#LIBS= c2 os2
|
||||
#
|
||||
#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 egman.obj mrhoist.obj fcache.obj
|
||||
# tlink @&&|
|
||||
#c02 $** -c -v
|
||||
#antlr.exe
|
||||
#
|
||||
#C2 os2
|
||||
#
|
||||
#|
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
#
|
||||
# UNIX (default)
|
||||
#
|
||||
BIN_DIR=../../../../bin
|
||||
CC=gcc
|
||||
COPT=-O
|
||||
ANTLR=$(BIN_DIR)/antlr.exe
|
||||
DLG=${BIN_DIR}/dlg.exe
|
||||
OBJ_EXT=o
|
||||
OUT_OBJ = -o
|
||||
CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536
|
||||
#
|
||||
# SGI Users, use this CFLAGS
|
||||
#
|
||||
#CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262
|
||||
OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o \
|
||||
globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o
|
||||
|
||||
antlr : $(OBJ) $(SRC)
|
||||
$(CC) $(CFLAGS) -o $(BIN_DIR)/antlr.exe $(OBJ)
|
||||
|
||||
# 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 egman.c mrhoist.c fcache.c
|
||||
|
||||
#
|
||||
# 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) -gh antlr.g
|
||||
|
||||
antlr.o : antlr.c mode.h tokens.h
|
||||
|
||||
scan.o : scan.c mode.h tokens.h
|
||||
|
||||
#scan.c mode.h: parser.dlg
|
||||
# $(DLG) -C2 parser.dlg scan.c
|
||||
|
||||
set.o : $(SET)/set.c
|
||||
$(CC) $(CFLAGS) -c -o set.o $(SET)/set.c
|
||||
|
||||
|
||||
#
|
||||
# ****** These next targets are common to UNIX and PC world ********
|
||||
#
|
||||
|
||||
#clean up all the intermediate files
|
||||
clean:
|
||||
rm -f *.$(OBJ_EXT) core
|
||||
|
||||
#remove everything in clean plus the PCCTS files generated
|
||||
scrub:
|
||||
rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core
|
96
Tools/CodeTools/Source/Pccts/antlr/makefile1
Normal file
96
Tools/CodeTools/Source/Pccts/antlr/makefile1
Normal file
@@ -0,0 +1,96 @@
|
||||
#
|
||||
# Makefile for ANTLR 1.33
|
||||
#
|
||||
# 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.33
|
||||
# Terence Parr
|
||||
# Parr Research Corporation
|
||||
# with Purdue University
|
||||
# and AHPCRC, University of Minnesota
|
||||
# 1989-1995
|
||||
#
|
||||
# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by
|
||||
# Ed Harfmann
|
||||
# Micro Data Base Systems
|
||||
# Lafayette, Indiana
|
||||
#
|
||||
SET=../support/set
|
||||
PCCTS_H=../h
|
||||
|
||||
#
|
||||
# UNIX (default)
|
||||
#
|
||||
CC=cc
|
||||
ANTLR=${WORKSPACE}/Tools/bin/antlr
|
||||
DLG=${WORKSPACE}/Tools/bin/dlg
|
||||
OBJ_EXT=o
|
||||
OUT_OBJ = -o
|
||||
ANSI=-ansi
|
||||
AOTHER=
|
||||
CFLAGS= -O0 -g -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) $(ANSI) -DZZLEXBUFSIZE=32000
|
||||
#
|
||||
# SGI Users, use this CFLAGS
|
||||
#
|
||||
#CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262
|
||||
|
||||
OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o \
|
||||
globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o $(OBJOTHER)
|
||||
|
||||
antlr : $(OBJ) $(SRC)
|
||||
$(CC) $(CFLAGS) -o antlr $(OBJ)
|
||||
mv antlr ${WORKSPACE}/Tools/bin
|
||||
|
||||
# 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 egman.c mrhoist.c fcache.c
|
||||
|
||||
#
|
||||
# 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) -gh antlr.g $(AOTHER)
|
||||
|
||||
antlr.o : antlr.c mode.h tokens.h
|
||||
|
||||
scan.o : scan.c mode.h tokens.h
|
||||
|
||||
scan.c mode.h: parser.dlg
|
||||
$(DLG) -C2 parser.dlg scan.c
|
||||
|
||||
set.o : $(SET)/set.c
|
||||
$(CC) $(CFLAGS) -c -o set.o $(SET)/set.c
|
||||
|
||||
|
||||
#
|
||||
# ****** These next targets are common to UNIX and PC world ********
|
||||
#
|
||||
|
||||
#clean up all the intermediate files
|
||||
clean:
|
||||
rm -f *.$(OBJ_EXT) core
|
||||
|
||||
#remove everything in clean plus the PCCTS files generated
|
||||
scrub:
|
||||
rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core
|
1864
Tools/CodeTools/Source/Pccts/antlr/misc.c
Normal file
1864
Tools/CodeTools/Source/Pccts/antlr/misc.c
Normal file
File diff suppressed because it is too large
Load Diff
12
Tools/CodeTools/Source/Pccts/antlr/mode.h
Normal file
12
Tools/CodeTools/Source/Pccts/antlr/mode.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#define START 0
|
||||
#define STRINGS 1
|
||||
#define ACTION_STRINGS 2
|
||||
#define ACTION_CHARS 3
|
||||
#define ACTION_COMMENTS 4
|
||||
#define TOK_DEF_COMMENTS 5
|
||||
#define TOK_DEF_CPP_COMMENTS 6
|
||||
#define ACTION_CPP_COMMENTS 7
|
||||
#define CPP_COMMENTS 8
|
||||
#define COMMENTS 9
|
||||
#define ACTIONS 10
|
||||
#define PARSE_ENUM_FILE 11
|
3030
Tools/CodeTools/Source/Pccts/antlr/mrhoist.c
Normal file
3030
Tools/CodeTools/Source/Pccts/antlr/mrhoist.c
Normal file
File diff suppressed because it is too large
Load Diff
1387
Tools/CodeTools/Source/Pccts/antlr/parser.dlg
Normal file
1387
Tools/CodeTools/Source/Pccts/antlr/parser.dlg
Normal file
File diff suppressed because it is too large
Load Diff
821
Tools/CodeTools/Source/Pccts/antlr/pred.c
Normal file
821
Tools/CodeTools/Source/Pccts/antlr/pred.c
Normal file
@@ -0,0 +1,821 @@
|
||||
/*
|
||||
* pred.c -- source for predicate detection, manipulation
|
||||
*
|
||||
* 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.33
|
||||
* Terence Parr
|
||||
* Parr Research Corporation
|
||||
* with Purdue University and AHPCRC, University of Minnesota
|
||||
* 1989-2001
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "pcctscfg.h"
|
||||
#include "set.h"
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
#include "dlgdef.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
static void complete_context_sets(RuleRefNode *, Predicate *);
|
||||
static void complete_context_trees(RuleRefNode *, Predicate *);
|
||||
#else
|
||||
static void complete_context_sets();
|
||||
static void complete_context_trees();
|
||||
#endif
|
||||
|
||||
char *PRED_AND_LIST = "AND";
|
||||
char *PRED_OR_LIST = "OR";
|
||||
|
||||
/*
|
||||
* In C mode, return the largest constant integer found as the
|
||||
* sole argument to LATEXT(i).
|
||||
*
|
||||
* In C++ mode, return the largest constant integer found as the
|
||||
* sole argument to LT(i) given that the char before is nonalpha.
|
||||
*/
|
||||
|
||||
int
|
||||
#ifdef __USE_PROTOS
|
||||
predicateLookaheadDepth(ActionNode *a)
|
||||
#else
|
||||
predicateLookaheadDepth(a)
|
||||
ActionNode *a;
|
||||
#endif
|
||||
{
|
||||
int max_k=0;
|
||||
|
||||
if (a->predEntry != NULL) {
|
||||
MR_pred_depth(a->predEntry->pred,&max_k);
|
||||
goto PREDENTRY_EXIT;
|
||||
}
|
||||
|
||||
if ( GenCC )
|
||||
{
|
||||
/* scan for LT(i) */
|
||||
int k = 0;
|
||||
char *p = a->action;
|
||||
while ( p!=NULL )
|
||||
{
|
||||
p = strstr(p, "LT(");
|
||||
if ( p!=NULL )
|
||||
{
|
||||
if ( p>=a->action && !isalpha(*(p-1)) )
|
||||
{
|
||||
k = atoi(p+strlen("LT("));
|
||||
if ( k>max_k ) max_k=k;
|
||||
}
|
||||
p += strlen("LT(");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* scan for LATEXT(i) */
|
||||
int k = 0;
|
||||
char *p = a->action;
|
||||
while ( p!=NULL )
|
||||
{
|
||||
p = strstr(p, "LATEXT(");
|
||||
if ( p!=NULL )
|
||||
{
|
||||
p += strlen("LATEXT(");
|
||||
k = atoi(p);
|
||||
if ( k>max_k ) max_k=k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (max_k==0) {
|
||||
max_k = 1; /* MR33 Badly designed if didn't set max_k when CLL_k = 1 */
|
||||
if (CLL_k > 1) /* MR27 Don't warn if max(k,ck) == 1 */
|
||||
{
|
||||
if ( !a->frmwarned )
|
||||
{
|
||||
a->frmwarned = 1;
|
||||
warnFL(eMsg1("predicate: %s missing, bad, or with i=0; assuming i=1",
|
||||
GenCC?"LT(i)":"LATEXT(i)"),
|
||||
FileStr[a->file], a->line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* MR10 */ if ( max_k > CLL_k) {
|
||||
/* MR10 */ if ( !a->frmwarned )
|
||||
/* MR10 */ {
|
||||
/* MR10 */ a->frmwarned = 1;
|
||||
/* MR11 */ errFL(eMsgd2("predicate refers to lookahead token %d. Semantic lookahead is limited to max(k,ck)==%d",
|
||||
/* MR10 */ max_k,CLL_k),
|
||||
/* MR10 */ FileStr[a->file],a->line);
|
||||
/* MR10 */ if (max_k >= OutputLL_k) {
|
||||
/* MR10 */ if (!GenCC) {
|
||||
/* MR10 */ errFL(eMsgd(" the lookahead buffer size in C mode is %d token(s) (including the one just recognized)",
|
||||
/* MR10 */ OutputLL_k),
|
||||
/* MR10 */ FileStr[a->file],a->line);
|
||||
/* MR10 */ };
|
||||
/* MR10 */ };
|
||||
/* MR10 */ };
|
||||
/* MR10 */ max_k= CLL_k;
|
||||
/* MR10 */ };
|
||||
|
||||
PREDENTRY_EXIT:
|
||||
return max_k;
|
||||
}
|
||||
|
||||
/* Find all predicates in a block of alternatives. DO NOT find predicates
|
||||
* behind the block because that predicate could depend on things set in
|
||||
* one of the nonoptional blocks
|
||||
*/
|
||||
|
||||
Predicate *
|
||||
#ifdef __USE_PROTOS
|
||||
find_in_aSubBlk( Junction *alt )
|
||||
#else
|
||||
find_in_aSubBlk( alt )
|
||||
Junction *alt;
|
||||
#endif
|
||||
{
|
||||
Predicate *a, *head=NULL, *tail=NULL, *root=NULL;
|
||||
Junction *p = alt;
|
||||
|
||||
if (MRhoisting) {
|
||||
return MR_find_in_aSubBlk(alt);
|
||||
};
|
||||
for (; p!=NULL; p=(Junction *)p->p2)
|
||||
{
|
||||
/* ignore empty alts */
|
||||
if ( p->p1->ntype != nJunction ||
|
||||
((Junction *)p->p1)->jtype != EndBlk )
|
||||
{
|
||||
a = find_predicates(p->p1); /* get preds for this alt */
|
||||
if ( a==NULL ) continue;
|
||||
|
||||
/* make an OR list of predicates */
|
||||
if ( head==NULL )
|
||||
{
|
||||
root = new_pred();
|
||||
root->expr = PRED_OR_LIST;
|
||||
head = tail = a;
|
||||
root->down = head;
|
||||
}
|
||||
else {
|
||||
tail->right = a;
|
||||
a->left = tail;
|
||||
a->up = tail->up;
|
||||
tail = a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if just one pred, remove OR root */
|
||||
if ( root!=NULL && root->down->right == NULL )
|
||||
{
|
||||
Predicate *d = root->down;
|
||||
free( (char *) root);
|
||||
return d;
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Predicate *
|
||||
#ifdef __USE_PROTOS
|
||||
find_in_aOptBlk( Junction *alt )
|
||||
#else
|
||||
find_in_aOptBlk( alt )
|
||||
Junction *alt;
|
||||
#endif
|
||||
{
|
||||
return find_in_aSubBlk( alt );
|
||||
}
|
||||
|
||||
Predicate *
|
||||
#ifdef __USE_PROTOS
|
||||
find_in_aLoopBegin( Junction *alt )
|
||||
#else
|
||||
find_in_aLoopBegin( alt )
|
||||
Junction *alt;
|
||||
#endif
|
||||
{
|
||||
return find_in_aSubBlk( (Junction *) alt->p1 ); /* get preds in alts */
|
||||
}
|
||||
|
||||
Predicate *
|
||||
#ifdef __USE_PROTOS
|
||||
find_in_aPlusBlk( Junction *alt )
|
||||
#else
|
||||
find_in_aPlusBlk( alt )
|
||||
Junction *alt;
|
||||
#endif
|
||||
{
|
||||
require(alt!=NULL&&alt->p2!=NULL, "invalid aPlusBlk");
|
||||
return find_in_aSubBlk( alt );
|
||||
}
|
||||
|
||||
/* Look for a predicate;
|
||||
*
|
||||
* Do not pass anything but Junction nodes; no Actions, Tokens, RuleRefs.
|
||||
* This means that a "hoisting distance" of zero is the only distance
|
||||
* allowable. Init actions are ignored.
|
||||
*
|
||||
* WARNING:
|
||||
* Assumes no (..)? block after predicate for the moment.
|
||||
* Does not check to see if pred is in production that can generate
|
||||
* a sequence contained in the set of ambiguous tuples.
|
||||
*
|
||||
* Return the predicate found if any.
|
||||
*/
|
||||
|
||||
|
||||
Predicate *
|
||||
#ifdef __USE_PROTOS
|
||||
find_predicates( Node *alt )
|
||||
#else
|
||||
find_predicates( alt )
|
||||
Node *alt;
|
||||
#endif
|
||||
{
|
||||
#ifdef DBG_PRED
|
||||
Junction *j;
|
||||
RuleRefNode *r;
|
||||
TokNode *t;
|
||||
#endif
|
||||
Predicate *pred;
|
||||
|
||||
if ( alt==NULL ) return NULL;
|
||||
|
||||
#ifdef DBG_PRED
|
||||
switch ( alt->ntype )
|
||||
{
|
||||
case nJunction :
|
||||
j = (Junction *) alt;
|
||||
fprintf(stderr, "Junction(in %s)", j->rname);
|
||||
switch ( j->jtype )
|
||||
{
|
||||
case aSubBlk :
|
||||
fprintf(stderr,"aSubBlk\n");
|
||||
break;
|
||||
case aOptBlk :
|
||||
fprintf(stderr,"aOptBlk\n");
|
||||
break;
|
||||
case aLoopBegin :
|
||||
fprintf(stderr,"aLoopBeginBlk\n");
|
||||
break;
|
||||
case aLoopBlk :
|
||||
fprintf(stderr,"aLoopBlk\n");
|
||||
break;
|
||||
case aPlusBlk :
|
||||
fprintf(stderr,"aPlusBlk\n");
|
||||
break;
|
||||
case EndBlk :
|
||||
fprintf(stderr,"EndBlk\n");
|
||||
break;
|
||||
case RuleBlk :
|
||||
fprintf(stderr,"RuleBlk\n");
|
||||
break;
|
||||
case Generic :
|
||||
fprintf(stderr,"Generic\n");
|
||||
break;
|
||||
case EndRule :
|
||||
fprintf(stderr,"EndRule\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case nRuleRef :
|
||||
r = (RuleRefNode *) alt;
|
||||
fprintf(stderr, "RuleRef(in %s)\n", r->rname);
|
||||
break;
|
||||
case nToken :
|
||||
t = (TokNode *) alt;
|
||||
fprintf(stderr, "TokenNode(in %s)%s\n", t->rname, TokenString(t->token));
|
||||
break;
|
||||
case nAction :
|
||||
fprintf(stderr, "Action\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch ( alt->ntype )
|
||||
{
|
||||
case nJunction :
|
||||
{
|
||||
Predicate *a, *b;
|
||||
Junction *p = (Junction *) alt;
|
||||
|
||||
/* lock nodes */
|
||||
if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||
|
||||
p->jtype==aPlusBlk || p->jtype==EndRule )
|
||||
{
|
||||
require(p->pred_lock!=NULL, "rJunc: lock array is NULL");
|
||||
if ( p->pred_lock[1] )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
p->pred_lock[1] = TRUE;
|
||||
}
|
||||
|
||||
switch ( p->jtype )
|
||||
{
|
||||
case aSubBlk :
|
||||
a = find_in_aSubBlk(p);
|
||||
return a; /* nothing is visible past this guy */
|
||||
case aOptBlk :
|
||||
a = find_in_aOptBlk(p);
|
||||
return a;
|
||||
case aLoopBegin :
|
||||
a = find_in_aLoopBegin(p);
|
||||
return a;
|
||||
case aLoopBlk :
|
||||
a = find_in_aSubBlk(p);
|
||||
p->pred_lock[1] = FALSE;
|
||||
return a;
|
||||
case aPlusBlk :
|
||||
a = find_in_aPlusBlk(p);
|
||||
p->pred_lock[1] = FALSE;
|
||||
return a; /* nothing is visible past this guy */
|
||||
case RuleBlk :
|
||||
a = find_predicates(p->p1);
|
||||
p->pred_lock[1] = FALSE;
|
||||
return a;
|
||||
case Generic :
|
||||
a = find_predicates(p->p1);
|
||||
b = find_predicates(p->p2);
|
||||
if ( p->pred_lock!=NULL ) p->pred_lock[1] = FALSE;
|
||||
if ( a==NULL ) return b;
|
||||
if ( b==NULL ) return a;
|
||||
/* otherwise OR the two preds together */
|
||||
{
|
||||
fatal_internal("hit unknown situation during predicate hoisting");
|
||||
}
|
||||
case EndBlk :
|
||||
case EndRule : /* Find no predicates after a rule ref */
|
||||
return NULL;
|
||||
default:
|
||||
fatal_internal("this cannot be printed\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
case nAction :
|
||||
{
|
||||
ActionNode *p = (ActionNode *) alt;
|
||||
if ( p->noHoist) return NULL; /* MR12c */
|
||||
if ( p->init_action ) return find_predicates(p->next);
|
||||
if ( p->is_predicate )
|
||||
{
|
||||
Tree *t=NULL;
|
||||
#ifdef DBG_PRED
|
||||
fprintf(stderr, "predicate: <<%s>>?\n", p->action);
|
||||
#endif
|
||||
if ( p->guardpred!=NULL )
|
||||
{
|
||||
pred = predicate_dup(p->guardpred);
|
||||
MR_guardPred_plainSet(p,pred); /* MR12c */
|
||||
}
|
||||
else
|
||||
{
|
||||
pred = new_pred();
|
||||
pred->k = predicateLookaheadDepth(p);
|
||||
pred->source = p;
|
||||
pred->expr = p->action;
|
||||
if ( HoistPredicateContext && pred->k > 1 )
|
||||
{
|
||||
/* MR30 No need to use first_item_is_guess_block_extra
|
||||
since we know this is an action, not a (...)* or
|
||||
(...)+ block.
|
||||
*/
|
||||
|
||||
if ( first_item_is_guess_block((Junction *)p->next) )
|
||||
{
|
||||
warnFL("cannot compute context of predicate in front of (..)? block",
|
||||
FileStr[p->file], p->line);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConstrainSearch = 0;
|
||||
/* MR11 */ if (p->ampersandPred != NULL) {
|
||||
/* MR11 */ TRAV(p,
|
||||
/* MR11 */ pred->k,
|
||||
/* MR11 */ &(pred->completionTree), t);
|
||||
/* MR11 */ } else {
|
||||
TRAV(p->next,
|
||||
pred->k,
|
||||
&(pred->completionTree), t);
|
||||
};
|
||||
pred->tcontext = t;
|
||||
MR_check_pred_too_long(pred,pred->completionTree);
|
||||
#ifdef DBG_PRED
|
||||
fprintf(stderr, "LL(%d) context:", pred->k);
|
||||
preorder(t);
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if ( HoistPredicateContext && pred->k == 1 )
|
||||
{
|
||||
pred->scontext[1] = empty;
|
||||
/* MR30 No need to use first_item_is_guess_block_extra
|
||||
since we know this is an action.
|
||||
*/
|
||||
if ( first_item_is_guess_block((Junction *)p->next) )
|
||||
{
|
||||
warnFL("cannot compute context of predicate in front of (..)? block",
|
||||
FileStr[p->file], p->line);
|
||||
}
|
||||
else
|
||||
{
|
||||
REACH((Junction *)p->next,
|
||||
1,
|
||||
&(pred->completionSet),
|
||||
pred->scontext[1]);
|
||||
MR_check_pred_too_long(pred,pred->completionSet);
|
||||
#ifdef DBG_PRED
|
||||
fprintf(stderr, "LL(1) context:");
|
||||
s_fprT(stderr, pred->scontext[1]);
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
Predicate *d = find_predicates(p->next);
|
||||
Predicate *root;
|
||||
|
||||
/* Warning: Doesn't seem like the up pointers will all be set correctly;
|
||||
* TJP: that's ok, we're not using them now.
|
||||
*/
|
||||
if ( d!=NULL )
|
||||
{
|
||||
root = new_pred();
|
||||
root->expr = PRED_AND_LIST;
|
||||
root->down = pred;
|
||||
pred->right = d;
|
||||
pred->up = root;
|
||||
d->left = pred;
|
||||
d->up = pred->up;
|
||||
return root;
|
||||
}
|
||||
}
|
||||
return pred;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
case nRuleRef :
|
||||
{
|
||||
Predicate *a;
|
||||
RuleRefNode *p = (RuleRefNode *) alt;
|
||||
Junction *r;
|
||||
Junction *save_MR_RuleBlkWithHalt;
|
||||
|
||||
RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);
|
||||
if ( q == NULL )
|
||||
{
|
||||
warnFL( eMsg1("rule %s not defined",p->text), FileStr[p->file], p->line );
|
||||
return NULL;
|
||||
}
|
||||
r = RulePtr[q->rulenum];
|
||||
if ( r->pred_lock[1] )
|
||||
{
|
||||
/* infinite left-recursion; ignore 'cause LL sup 1 (k) analysis
|
||||
* must have seen it earlier.
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* MR10 There should only be one halt set at a time. */
|
||||
/* MR10 Life would have been easier with a global variable */
|
||||
/* MR10 (at least for this particular need) */
|
||||
/* MR10 Unset the old one and set the new one, later undo. */
|
||||
|
||||
require(r->end->halt == FALSE,"should only have one halt at a time");
|
||||
|
||||
/* MR10 */ require(MR_RuleBlkWithHalt == NULL ||
|
||||
/* MR10 */ (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),
|
||||
/* MR10 */ "RuleBlkWithHalt->end not RuleBlk or does not have halt set");
|
||||
/* MR10 */ if (MR_RuleBlkWithHalt != NULL) {
|
||||
/* MR10 */ MR_RuleBlkWithHalt->end->halt=FALSE;
|
||||
/* MR10 */ };
|
||||
|
||||
/*** fprintf(stderr,"\nSetting halt on junction #%d\n",r->end->seq); ***/
|
||||
|
||||
require(r->end->halt == FALSE,"rule->end->halt already set");
|
||||
|
||||
save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;
|
||||
|
||||
/* MR10 */ MR_pointerStackPush(&MR_RuleBlkWithHaltStack,MR_RuleBlkWithHalt);
|
||||
/* MR10 */ MR_pointerStackPush(&MR_PredRuleRefStack,p);
|
||||
|
||||
r->end->halt = TRUE;
|
||||
/* MR10 */ MR_RuleBlkWithHalt=r;
|
||||
|
||||
a = find_predicates((Node *)r);
|
||||
|
||||
require(r->end->halt == TRUE,"rule->end->halt not set");
|
||||
r->end->halt = FALSE;
|
||||
|
||||
/* MR10 */ MR_pointerStackPop(&MR_PredRuleRefStack);
|
||||
/* MR10 */ MR_RuleBlkWithHalt=(Junction *) MR_pointerStackPop(&MR_RuleBlkWithHaltStack);
|
||||
|
||||
require (MR_RuleBlkWithHalt==save_MR_RuleBlkWithHalt,
|
||||
"RuleBlkWithHaltStack not consistent");
|
||||
|
||||
/* MR10 */ require(MR_RuleBlkWithHalt == NULL ||
|
||||
/* MR10 */ (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == FALSE),
|
||||
/* MR10 */ "RuleBlkWithHalt->end not RuleBlk or has no halt set");
|
||||
/* MR10 */ if (MR_RuleBlkWithHalt != NULL) {
|
||||
/* MR10 */ MR_RuleBlkWithHalt->end->halt=TRUE;
|
||||
/* MR10 */ };
|
||||
|
||||
/*** fprintf(stderr,"\nRestoring halt on junction #%d\n",r->end->seq); ***/
|
||||
|
||||
if ( a==NULL ) return NULL;
|
||||
|
||||
/* attempt to compute the "local" FOLLOW just like in normal lookahead
|
||||
* computation if needed
|
||||
*/
|
||||
|
||||
complete_context_sets(p,a);
|
||||
complete_context_trees(p,a);
|
||||
|
||||
/* MR10 */ MR_cleanup_pred_trees(a);
|
||||
|
||||
return a;
|
||||
}
|
||||
case nToken :
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Predicate *MR_find_predicates_and_supp(Node *alt)
|
||||
#else
|
||||
Predicate *MR_find_predicates_and_supp(alt)
|
||||
Node *alt;
|
||||
#endif
|
||||
{
|
||||
Predicate *p;
|
||||
|
||||
p=find_predicates(alt);
|
||||
p=MR_suppressK(alt,p);
|
||||
return p;
|
||||
}
|
||||
|
||||
Predicate *
|
||||
#ifdef __USE_PROTOS
|
||||
new_pred( void )
|
||||
#else
|
||||
new_pred( )
|
||||
#endif
|
||||
{
|
||||
Predicate *p = (Predicate *) calloc(1,sizeof(Predicate)); /* MR10 */
|
||||
require(p!=NULL, "new_pred: cannot alloc predicate");
|
||||
p->scontext[0]=empty;
|
||||
p->scontext[1]=empty;
|
||||
p->completionTree=empty;
|
||||
p->completionSet=empty;
|
||||
p->plainSet=empty;
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
#ifdef __USE_PROTOS
|
||||
complete_context_sets( RuleRefNode *p, Predicate *a )
|
||||
#else
|
||||
complete_context_sets( p, a )
|
||||
RuleRefNode *p;
|
||||
Predicate *a;
|
||||
#endif
|
||||
{
|
||||
set rk2, b;
|
||||
int k2;
|
||||
|
||||
#ifdef DBG_PRED
|
||||
fprintf(stderr, "enter complete_context_sets\n");
|
||||
#endif
|
||||
for (; a!=NULL; a=a->right)
|
||||
{
|
||||
if ( a->expr == PRED_AND_LIST || a->expr == PRED_OR_LIST )
|
||||
{
|
||||
complete_context_sets(p,a->down);
|
||||
continue;
|
||||
}
|
||||
rk2 = b = empty;
|
||||
while ( !set_nil(a->completionSet) )
|
||||
{
|
||||
k2 = set_int(a->completionSet);
|
||||
set_rm(k2, a->completionSet);
|
||||
|
||||
REACH(p->next, k2, &rk2, b);
|
||||
set_orin(&(a->scontext[1]), b);
|
||||
set_free(b);
|
||||
}
|
||||
|
||||
set_orin(&(a->completionSet), rk2);/* remember what we couldn't do */
|
||||
set_free(rk2);
|
||||
#ifdef DBG_PRED
|
||||
fprintf(stderr, "LL(1) context for %s(addr 0x%x) after ruleref:", a->expr, a);
|
||||
s_fprT(stderr, a->scontext[1]);
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
/* complete_context_sets(p, a->down);*/
|
||||
}
|
||||
#ifdef DBG_PRED
|
||||
fprintf(stderr, "exit complete_context_sets\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
#ifdef __USE_PROTOS
|
||||
complete_context_trees( RuleRefNode *p, Predicate *a )
|
||||
#else
|
||||
complete_context_trees( p, a )
|
||||
RuleRefNode *p;
|
||||
Predicate *a;
|
||||
#endif
|
||||
{
|
||||
set rk2;
|
||||
int k2;
|
||||
Tree *u;
|
||||
|
||||
#ifdef DBG_PRED
|
||||
fprintf(stderr, "enter complete_context_trees\n");
|
||||
#endif
|
||||
for (; a!=NULL; a=a->right)
|
||||
{
|
||||
if ( a->expr == PRED_AND_LIST || a->expr == PRED_OR_LIST )
|
||||
{
|
||||
complete_context_trees(p, a->down);
|
||||
continue;
|
||||
}
|
||||
rk2 = empty;
|
||||
|
||||
/* any k left to do? if so, link onto tree */
|
||||
while ( !set_nil(a->completionTree) )
|
||||
{
|
||||
k2 = set_int(a->completionTree);
|
||||
set_rm(k2, a->completionTree);
|
||||
u = NULL;
|
||||
|
||||
TRAV(p->next, k2, &rk2, u);
|
||||
|
||||
/* any subtrees missing k2 tokens, add u onto end */
|
||||
a->tcontext = tlink(a->tcontext, u, k2);
|
||||
Tfree(u); /* MR10 */
|
||||
}
|
||||
set_orin(&(a->completionTree), rk2);/* remember what we couldn't do */
|
||||
set_free(rk2);
|
||||
#ifdef DBG_PRED
|
||||
fprintf(stderr, "LL(i<%d) context after ruleref:", LL_k);
|
||||
preorder(a->tcontext);
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
/* complete_context_trees(p, a->down);*/
|
||||
}
|
||||
#ifdef DBG_PRED
|
||||
fprintf(stderr, "exit complete_context_trees\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Walk a list of predicates and return the set of all tokens in scontext[1]'s */
|
||||
set
|
||||
#ifdef __USE_PROTOS
|
||||
covered_set( Predicate *p )
|
||||
#else
|
||||
covered_set( p )
|
||||
Predicate *p;
|
||||
#endif
|
||||
{
|
||||
set a;
|
||||
|
||||
a = empty;
|
||||
for (; p!=NULL; p=p->right)
|
||||
{
|
||||
if ( p->expr == PRED_AND_LIST || p->expr == PRED_OR_LIST )
|
||||
{
|
||||
set_orin(&a, covered_set(p->down));
|
||||
continue;
|
||||
}
|
||||
set_orin(&a, p->scontext[1]);
|
||||
set_orin(&a, covered_set(p->down));
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
/* MR10 predicate_free()
|
||||
MR10 Don't free the leaf nodes since they are part of the action node
|
||||
*/
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void predicate_free(Predicate *p)
|
||||
#else
|
||||
void predicate_free(p)
|
||||
Predicate *p;
|
||||
#endif
|
||||
{
|
||||
if (p == NULL) return;
|
||||
predicate_free(p->right);
|
||||
predicate_free(p->down);
|
||||
if (p->cloned ||
|
||||
p->source == NULL ||
|
||||
p->source->guardpred == NULL ||
|
||||
p->expr == PRED_AND_LIST ||
|
||||
p->expr == PRED_OR_LIST) {
|
||||
set_free(p->scontext[1]);
|
||||
set_free(p->completionSet);
|
||||
set_free(p->completionTree);
|
||||
set_free(p->plainSet);
|
||||
Tfree(p->tcontext);
|
||||
free( (char *) p);
|
||||
} else {
|
||||
p->right=NULL;
|
||||
p->down=NULL; /* MR13 *** debug */
|
||||
};
|
||||
}
|
||||
|
||||
/* MR10 predicate_dup() */
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Predicate * predicate_dup_xxx(Predicate *p,int contextToo)
|
||||
#else
|
||||
Predicate * predicate_dup_xxx(p,contextToo)
|
||||
Predicate *p;
|
||||
int contextToo;
|
||||
#endif
|
||||
{
|
||||
Predicate *q;
|
||||
|
||||
if (p == NULL) return NULL;
|
||||
q=new_pred();
|
||||
q->down=predicate_dup(p->down);
|
||||
q->right=predicate_dup(p->right);
|
||||
|
||||
/*
|
||||
don't replicate expr - it is read-only
|
||||
and address comparison is used to look
|
||||
for identical predicates.
|
||||
*/
|
||||
|
||||
q->expr=p->expr;
|
||||
q->k=p->k;
|
||||
q->source=p->source;
|
||||
q->cloned=1;
|
||||
q->ampersandStyle=p->ampersandStyle;
|
||||
q->inverted=p->inverted;
|
||||
q->predEntry=p->predEntry;
|
||||
q->plainSet=set_dup(p->plainSet);
|
||||
|
||||
if (contextToo) {
|
||||
q->tcontext=tdup(p->tcontext);
|
||||
q->scontext[0]=set_dup(p->scontext[0]);
|
||||
q->scontext[1]=set_dup(p->scontext[1]);
|
||||
q->completionTree=set_dup(p->completionTree);
|
||||
q->completionSet=set_dup(p->completionSet);
|
||||
};
|
||||
|
||||
/* don't need to dup "redundant" */
|
||||
|
||||
return q;
|
||||
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Predicate * predicate_dup_without_context(Predicate *p)
|
||||
#else
|
||||
Predicate * predicate_dup_without_context(p)
|
||||
Predicate *p;
|
||||
#endif
|
||||
{
|
||||
return predicate_dup_xxx(p,0);
|
||||
}
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
Predicate * predicate_dup(Predicate *p)
|
||||
#else
|
||||
Predicate * predicate_dup(p)
|
||||
Predicate *p;
|
||||
#endif
|
||||
{
|
||||
return predicate_dup_xxx(p,1);
|
||||
}
|
||||
|
852
Tools/CodeTools/Source/Pccts/antlr/proto.h
Normal file
852
Tools/CodeTools/Source/Pccts/antlr/proto.h
Normal file
@@ -0,0 +1,852 @@
|
||||
/*
|
||||
* proto.h -- function prototypes
|
||||
*
|
||||
* 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.33
|
||||
* Terence Parr
|
||||
* Parr Research Corporation
|
||||
* with Purdue University and AHPCRC, University of Minnesota
|
||||
* 1989-2001
|
||||
*/
|
||||
|
||||
/* V a r i a b l e s */
|
||||
|
||||
extern int tp;
|
||||
extern Junction *SynDiag;
|
||||
extern char Version[];
|
||||
extern char VersionDef[];
|
||||
#ifdef __cplusplus
|
||||
extern void (*fpPrint[])(...);
|
||||
#else
|
||||
extern void (*fpPrint[])();
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern struct _set (*fpReach[])(...);
|
||||
#else
|
||||
extern struct _set (*fpReach[])();
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern struct _tree *(*fpTraverse[])(...);
|
||||
#else
|
||||
extern struct _tree *(*fpTraverse[])();
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern void (**fpTrans)(...);
|
||||
#else
|
||||
extern void (**fpTrans)();
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern void (**fpJTrans)(...);
|
||||
#else
|
||||
extern void (**fpJTrans)();
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern void (*C_Trans[NumNodeTypes+1])(...);
|
||||
#else
|
||||
extern void (*C_Trans[])();
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern void (*C_JTrans[NumJuncTypes+1])(...);
|
||||
#else
|
||||
extern void (*C_JTrans[])();
|
||||
#endif
|
||||
extern int BlkLevel;
|
||||
extern int CurFile;
|
||||
extern char *CurPredName;
|
||||
extern char *CurRule;
|
||||
extern int CurRuleDebug; /* MR13 */
|
||||
extern Junction *CurRuleBlk;
|
||||
extern RuleEntry *CurRuleNode;
|
||||
extern ListNode *CurElementLabels;
|
||||
extern ListNode *CurAstLabelsInActions; /* MR27 */
|
||||
extern ListNode *ContextGuardPredicateList; /* MR13 */
|
||||
extern ListNode *CurActionLabels;
|
||||
extern int numericActionLabel; /* MR10 << ... $1 ... >> or << ... $1 ... >>? */
|
||||
extern ListNode *NumericPredLabels; /* MR10 << ... $1 ... >>? ONLY */
|
||||
extern char *FileStr[];
|
||||
extern int NumFiles;
|
||||
extern int EpToken;
|
||||
extern int WildCardToken;
|
||||
extern Entry **Tname,
|
||||
**Texpr,
|
||||
**Rname,
|
||||
**Fcache,
|
||||
**Tcache,
|
||||
**Elabel,
|
||||
**Sname,
|
||||
**Pname; /* MR11 */
|
||||
extern ListNode *ExprOrder;
|
||||
extern ListNode **Cycles;
|
||||
extern int TokenNum;
|
||||
extern int LastTokenCounted;
|
||||
extern ListNode *BeforeActions, *AfterActions, *LexActions;
|
||||
|
||||
/* MR1 */
|
||||
/* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
|
||||
/* MR1 via #lexmember <<....>> & #lexprefix <<...>> */
|
||||
/* MR1 */
|
||||
|
||||
extern ListNode *LexMemberActions; /* MR1 */
|
||||
extern ListNode *LexPrefixActions; /* MR1 */
|
||||
|
||||
extern set *fset; /* for constrained search */ /* MR11 */
|
||||
extern int maxk; /* for constrained search */ /* MR11 */
|
||||
extern int Save_argc; /* MR10 */
|
||||
extern char **Save_argv; /* MR10 */
|
||||
extern ListNode *eclasses, *tclasses;
|
||||
extern char *HdrAction;
|
||||
extern char *FirstAction; /* MR11 */
|
||||
extern FILE *ErrFile;
|
||||
extern char *RemapFileName;
|
||||
extern char *ErrFileName;
|
||||
extern char *DlgFileName;
|
||||
extern char *DefFileName;
|
||||
extern char *ModeFileName;
|
||||
extern char *StdMsgName;
|
||||
extern int NumRules;
|
||||
extern Junction **RulePtr;
|
||||
extern int LL_k;
|
||||
extern int CLL_k;
|
||||
extern char *decodeJType[];
|
||||
extern int PrintOut;
|
||||
extern int PrintAnnotate;
|
||||
extern int CodeGen;
|
||||
extern int LexGen;
|
||||
extern int esetnum;
|
||||
extern int setnum;
|
||||
extern int wordnum;
|
||||
extern int GenAST;
|
||||
extern int GenANSI;
|
||||
extern int **FoStack;
|
||||
extern int **FoTOS;
|
||||
extern int GenExprSetsOpt;
|
||||
extern FILE *DefFile;
|
||||
extern int CannotContinue;
|
||||
extern int GenCR;
|
||||
extern int GenLineInfo;
|
||||
extern int GenLineInfoMS;
|
||||
extern int action_file, action_line;
|
||||
extern int TraceGen;
|
||||
extern int CurAmbigAlt1, CurAmbigAlt2, CurAmbigline, CurAmbigfile;
|
||||
extern char *CurAmbigbtype;
|
||||
extern int elevel;
|
||||
extern int GenEClasseForRules;
|
||||
extern FILE *input, *output;
|
||||
extern char **TokenStr, **ExprStr;
|
||||
extern int CurrentLexClass, NumLexClasses;
|
||||
extern LClass lclass[];
|
||||
extern char LexStartSymbol[];
|
||||
extern char *CurRetDef;
|
||||
extern char *CurParmDef;
|
||||
extern int OutputLL_k;
|
||||
extern int TreeResourceLimit;
|
||||
extern int DemandLookahead;
|
||||
extern char *RulePrefix;
|
||||
extern int GenStdPccts;
|
||||
extern char *stdpccts;
|
||||
extern int ParseWithPredicates;
|
||||
extern int ConstrainSearch;
|
||||
extern int PURIFY; /* MR23 */
|
||||
|
||||
extern set MR_CompromisedRules; /* MR14 */
|
||||
extern int MR_AmbSourceSearch; /* MR11 */
|
||||
extern int MR_SuppressSearch; /* MR13 */
|
||||
extern int MR_AmbSourceSearchGroup; /* MR11 */
|
||||
extern int MR_AmbSourceSearchChoice; /* MR11 */
|
||||
extern int MR_AmbSourceSearchLimit; /* MR11 */
|
||||
extern int MR_usingPredNames; /* MR11 */
|
||||
extern int MR_ErrorSetComputationActive; /* MR14 */
|
||||
extern char *MR_AmbAidRule; /* MR11 */
|
||||
extern int MR_AmbAidLine; /* MR11 */
|
||||
extern int MR_AmbAidMultiple; /* MR11 */
|
||||
extern int MR_AmbAidDepth; /* MR11 */
|
||||
extern int MR_skipped_e3_report; /* MR11 */
|
||||
extern int MR_matched_AmbAidRule; /* MR11 */
|
||||
extern int MR_Inhibit_Tokens_h_Gen; /* MR13 */
|
||||
extern int NewAST; /* MR13 */
|
||||
extern int tmakeInParser; /* MR23 */
|
||||
extern int AlphaBetaTrace; /* MR14 */
|
||||
extern int MR_BlkErr; /* MR21 */
|
||||
extern int MR_AlphaBetaWarning; /* MR14 */
|
||||
extern int MR_AlphaBetaMessageCount; /* MR14 */
|
||||
extern int MR_MaintainBackTrace; /* MR14 */
|
||||
extern int MR_BadExprSets; /* MR13 */
|
||||
extern int FoundGuessBlk;
|
||||
extern int FoundException;
|
||||
extern int FoundAtOperator; /* MR6 */
|
||||
extern int FoundExceptionGroup; /* MR6 */
|
||||
extern int WarningLevel;
|
||||
extern int UseStdout; /* MR6 */
|
||||
extern int TabWidth; /* MR6 */
|
||||
extern int pLevel;
|
||||
extern int pAlt1;
|
||||
extern int pAlt2;
|
||||
extern int AImode;
|
||||
extern int HoistPredicateContext;
|
||||
extern int MRhoisting; /* MR9 */
|
||||
extern int MRhoistingk; /* MR13 */
|
||||
extern int MR_debugGenRule; /* MR11 */
|
||||
extern int GenCC;
|
||||
extern char *ParserName;
|
||||
extern char *StandardSymbols[];
|
||||
extern char *ASTSymbols[];
|
||||
extern set reserved_positions;
|
||||
extern set all_tokens;
|
||||
extern set imag_tokens;
|
||||
extern set tokclasses;
|
||||
extern ListNode *ForcedTokens;
|
||||
extern int *TokenInd;
|
||||
extern FILE *Parser_h, *Parser_c;
|
||||
extern char CurrentClassName[];
|
||||
extern int no_classes_found;
|
||||
extern char Parser_h_Name[];
|
||||
extern char Parser_c_Name[];
|
||||
extern char MRinfoFile_Name[]; /* MR10 */
|
||||
extern FILE *MRinfoFile; /* MR10 */
|
||||
extern int MRinfo; /* MR10 */
|
||||
extern int MRinfoSeq; /* MR10 */
|
||||
extern int InfoP; /* MR10 */
|
||||
extern int InfoT; /* MR10 */
|
||||
extern int InfoF; /* MR10 */
|
||||
extern int InfoM; /* MR10 */
|
||||
extern int InfoO; /* MR12 */
|
||||
extern int PotentialSuppression; /* MR10 */
|
||||
extern int PotentialDummy; /* MR10 */
|
||||
extern int TnodesInUse; /* MR10 */
|
||||
extern int TnodesPeak; /* MR10 */
|
||||
extern int TnodesReportThreshold; /* MR11 */
|
||||
extern int TnodesAllocated; /* MR10 */
|
||||
extern char *ClassDeclStuff; /* MR10 */
|
||||
extern char *BaseClassName; /* MR22 */
|
||||
extern ListNode *class_before_actions, *class_after_actions;
|
||||
extern char *UserTokenDefsFile;
|
||||
extern int UserDefdTokens;
|
||||
extern ListNode *MetaTokenNodes;
|
||||
extern char *OutputDirectory;
|
||||
extern int DontCopyTokens;
|
||||
extern int LTinTokenAction; /* MR23 */
|
||||
extern set AST_nodes_refd_in_actions;
|
||||
extern ListNode *CurExGroups;
|
||||
extern int CurBlockID;
|
||||
extern int CurAltNum;
|
||||
extern Junction *CurAltStart;
|
||||
extern Junction *OuterAltStart; /* chain exception groups MR7 */
|
||||
extern ExceptionGroup *DefaultExGroup;
|
||||
extern int NumSignals;
|
||||
extern int ContextGuardTRAV;
|
||||
extern Junction *MR_RuleBlkWithHalt; /* MR10 */
|
||||
extern PointerStack MR_BackTraceStack; /* MR10 */
|
||||
extern PointerStack MR_PredRuleRefStack; /* MR10 */
|
||||
extern PointerStack MR_RuleBlkWithHaltStack; /* MR10 */
|
||||
|
||||
/* */
|
||||
/* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */
|
||||
/* MR1 in DLG action */
|
||||
/* */
|
||||
extern int tokenActionActive; /* MR1 */
|
||||
|
||||
extern char *PRED_OR_LIST; /* MR10 */
|
||||
extern char *PRED_AND_LIST; /* MR10 */
|
||||
|
||||
#ifdef __VMS
|
||||
#define STRICMP strcasecmp /* MR21 */
|
||||
#else
|
||||
#define STRICMP stricmp /* MR21 */
|
||||
#endif
|
||||
|
||||
/* MR26 */
|
||||
#ifdef PCCTS_USE_STDARG
|
||||
extern Tree *tmake(Tree *root, ...);
|
||||
#else
|
||||
extern Tree *tmake();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
extern int STRICMP(const char*, const char*);
|
||||
extern void istackreset(void);
|
||||
extern int istacksize(void);
|
||||
extern void pushint(int);
|
||||
extern int popint( void );
|
||||
extern int istackempty( void );
|
||||
extern int topint( void );
|
||||
extern void NewSetWd( void );
|
||||
extern void DumpSetWd( void );
|
||||
extern void DumpSetWdForC( void );
|
||||
extern void DumpSetWdForCC( void );
|
||||
extern void NewSet( void );
|
||||
extern void FillSet( set );
|
||||
extern void ComputeErrorSets( void );
|
||||
extern void ComputeTokSets( void );
|
||||
extern void SubstErrorClass( set * );
|
||||
extern int DefErrSet( set *, int, char * );
|
||||
extern int DefErrSetForC( set *, int, char * );
|
||||
extern int DefErrSetForCC( set *, int, char * );
|
||||
extern int DefErrSet1(int, set *, int, char *); /* MR21 */
|
||||
extern int DefErrSetForC1(int, set *, int, char *, const char* ); /* MR21 */
|
||||
extern int DefErrSetForCC1(int, set *, int, char *, const char* ); /* MR21 */
|
||||
extern int DefErrSetWithSuffix(int, set *, int, char *, const char *); /* MR21 */
|
||||
extern void GenErrHdr( void );
|
||||
extern void dumpExpr( FILE *, char * );
|
||||
extern void addParm( Node *, char * );
|
||||
extern Graph buildAction( char *, int, int, int );
|
||||
extern Graph buildToken( char * );
|
||||
extern Graph buildWildCard( char * );
|
||||
extern Graph buildRuleRef( char * );
|
||||
extern Graph Or( Graph, Graph );
|
||||
extern Graph Cat( Graph, Graph );
|
||||
extern Graph makeOpt( Graph, int, char *);
|
||||
extern Graph makeBlk( Graph, int, char *);
|
||||
extern Graph makeLoop( Graph, int, char *);
|
||||
extern Graph makePlus( Graph, int, char *);
|
||||
extern Graph emptyAlt( void );
|
||||
extern Graph emptyAlt3( void );
|
||||
extern TokNode * newTokNode( void );
|
||||
extern RuleRefNode * newRNode( void );
|
||||
extern Junction * newJunction( void );
|
||||
extern ActionNode * newActionNode( void );
|
||||
extern char * makelocks( void );
|
||||
extern void preorder( Tree * );
|
||||
extern Tree * tnode( int );
|
||||
extern void _Tfree( Tree * );
|
||||
extern Tree * tdup( Tree * );
|
||||
extern int is_single_tuple( Tree * );
|
||||
extern Tree * tappend( Tree *, Tree * );
|
||||
extern void Tfree( Tree * );
|
||||
extern Tree * tlink( Tree *, Tree *, int );
|
||||
extern Tree * tshrink( Tree * );
|
||||
extern Tree * tflatten( Tree * );
|
||||
extern Tree * tJunc( Junction *, int, set * );
|
||||
extern Tree * tRuleRef( RuleRefNode *, int, set * );
|
||||
extern Tree * tToken( TokNode *, int, set * );
|
||||
extern Tree * tAction( ActionNode *, int, set * );
|
||||
extern int tmember( Tree *, Tree * );
|
||||
extern int tmember_constrained( Tree *, Tree * );
|
||||
extern Tree * tleft_factor( Tree * );
|
||||
extern Tree * trm_perm( Tree *, Tree * );
|
||||
extern void tcvt( set *, Tree * );
|
||||
extern Tree * permute( int, int );
|
||||
extern Tree * VerifyAmbig( Junction *, Junction *, unsigned **, set *, Tree **, Tree **, int * );
|
||||
extern set rJunc( Junction *, int, set * );
|
||||
extern set rRuleRef( RuleRefNode *, int, set * );
|
||||
extern set rToken( TokNode *, int, set * );
|
||||
extern set rAction( ActionNode *, int, set * );
|
||||
extern void HandleAmbiguity( Junction *, Junction *, Junction *, int );
|
||||
extern set First( Junction *, int, int, int * );
|
||||
extern void freeBlkFsets( Junction * );
|
||||
extern void genAction( ActionNode * );
|
||||
extern void genRuleRef( RuleRefNode * );
|
||||
extern void genToken( TokNode * );
|
||||
extern void genOptBlk( Junction * );
|
||||
extern void genLoopBlk( Junction *, Junction *, Junction *, int );
|
||||
extern void genLoopBegin( Junction * );
|
||||
extern void genPlusBlk( Junction * );
|
||||
extern void genSubBlk( Junction * );
|
||||
extern void genRule( Junction * );
|
||||
extern void genJunction( Junction * );
|
||||
extern void genEndBlk( Junction * );
|
||||
extern void genEndRule( Junction * );
|
||||
extern void genHdr( int );
|
||||
extern void genHdr1( int );
|
||||
extern void dumpAction( char *, FILE *, int, int, int, int );
|
||||
extern void dumpActionPlus(ActionNode*, char *, FILE *, int, int, int, int ); /* MR21 */
|
||||
extern Entry ** newHashTable( void );
|
||||
extern Entry * hash_add( Entry **, char *, Entry * );
|
||||
extern Entry * hash_get( Entry **, char * );
|
||||
extern void hashStat( Entry ** );
|
||||
extern char * mystrdup( char * );
|
||||
extern void genLexDescr( void );
|
||||
extern void dumpLexClasses( FILE * );
|
||||
extern void genDefFile( void );
|
||||
extern void DumpListOfParmNames( char *, FILE *, int ); /* MR5 janm 26-May-97 */
|
||||
extern int DumpNextNameInDef( char **, FILE * );
|
||||
extern void DumpOldStyleParms( char *, FILE * );
|
||||
extern void DumpType( char *, FILE * );
|
||||
extern int strmember( char *, char * );
|
||||
/* extern int HasComma( char * ); MR23 Replaced by hasMultipleOperands() */
|
||||
extern void DumpRetValStruct( FILE *, char *, int );
|
||||
extern char * StripQuotes( char * );
|
||||
extern int main( int, char *[] );
|
||||
extern void readDescr( void );
|
||||
extern FILE * NextFile( void );
|
||||
extern char * outnameX( char *, char *);
|
||||
extern char * outname( char * );
|
||||
extern void fatalFL( char *, char *, int );
|
||||
extern void fatal_intern( char *, char *, int );
|
||||
extern void cleanUp( void );
|
||||
extern char * eMsg3( char *, char *, char *, char * );
|
||||
extern char * eMsgd( char *, int );
|
||||
extern char * eMsgd2( char *, int, int );
|
||||
extern void s_fprT( FILE *, set );
|
||||
extern char * TerminalString( int );
|
||||
extern void lexclass( char * );
|
||||
extern void lexmode( int );
|
||||
extern int LexClassIndex( char * );
|
||||
extern int hasAction( char * );
|
||||
extern void setHasAction( char *, char * );
|
||||
extern int addTname( char * );
|
||||
extern int addTexpr( char * );
|
||||
extern int Tnum( char * );
|
||||
extern void Tklink( char *, char * );
|
||||
extern Entry * newEntry( char *, int );
|
||||
extern void list_add( ListNode **, void * );
|
||||
extern void list_free( ListNode **, int freeData ); /* MR10 */
|
||||
extern void list_apply( ListNode *, void (*)(void *) );
|
||||
extern int list_search_cstring (ListNode *, char *); /* MR27 */
|
||||
extern char * Fkey( char *, int, int );
|
||||
extern void FoPush( char *, int );
|
||||
extern void FoPop( int );
|
||||
extern void RegisterCycle( char *, int );
|
||||
extern void ResolveFoCycles( int );
|
||||
extern void pJunc( Junction * );
|
||||
extern void pRuleRef( RuleRefNode * );
|
||||
extern void pToken( TokNode * );
|
||||
extern void pAction( ActionNode * );
|
||||
extern void FoLink( Node * );
|
||||
extern void addFoLink( Node *, char *, Junction * );
|
||||
extern void GenCrossRef( Junction * );
|
||||
extern void defErr( char *, long, long, long, long, long, long );
|
||||
extern void genStdPCCTSIncludeFile(FILE *,char *); /* MR10 */
|
||||
extern char * pcctsBaseName(char *); /* MR32 */
|
||||
extern Predicate *find_predicates(Node *); /* MR10 */
|
||||
extern Predicate *MR_find_predicates_and_supp(Node *); /* MR13 */
|
||||
extern int predicateLookaheadDepth(ActionNode *); /* MR10 */
|
||||
extern void predicate_free(Predicate *); /* MR10 */
|
||||
extern Predicate * predicate_dup(Predicate *); /* MR10 */
|
||||
extern Predicate * predicate_dup_without_context(Predicate *); /* MR11 */
|
||||
extern void GenRulePrototypes(FILE *, Junction *);
|
||||
extern Junction *first_item_is_guess_block(Junction *);
|
||||
extern Junction *first_item_is_guess_block_extra(Junction * q); /* MR30 */
|
||||
extern Junction *analysis_point(Junction *);
|
||||
extern Tree *make_tree_from_sets(set *, set *);
|
||||
extern Tree *tdup_chain(Tree *);
|
||||
extern Tree *tdif(Tree *, Predicate *, set *, set *);
|
||||
extern set covered_set(Predicate *);
|
||||
extern void AmbiguityDialog(Junction *, int, Junction *, Junction *, int *, int *);
|
||||
extern void dumpAmbigMsg(set *, FILE *, int);
|
||||
extern void GenRuleFuncRedefs(FILE *, Junction *);
|
||||
extern void GenPredefinedSymbolRedefs(FILE *);
|
||||
extern void GenASTSymbolRedefs(FILE *);
|
||||
extern void GenRemapFile(void);
|
||||
extern void GenSetRedefs(FILE *);
|
||||
extern ForcedToken *newForcedToken(char *, int);
|
||||
extern void RemapForcedTokens(void);
|
||||
extern char *TokenOrExpr(int);
|
||||
extern void setUpperRange(TokNode *, char *);
|
||||
extern void GenParser_c_Hdr(void);
|
||||
extern void GenParser_h_Hdr(void);
|
||||
extern void GenRuleMemberDeclarationsForCC(FILE *, Junction *);
|
||||
extern int addForcedTname( char *, int );
|
||||
extern char *OutMetaName(char *);
|
||||
extern void OutFirstSetSymbol(Junction *q, char *); /* MR21 */
|
||||
extern void warnNoFL(char *err);
|
||||
extern void warnFL(char *err,char *f,int l);
|
||||
extern void warn(char *err);
|
||||
extern void warnNoCR( char *err );
|
||||
extern void errNoFL(char *err);
|
||||
extern void errFL(char *err,char *f,int l);
|
||||
extern void err(char *err);
|
||||
extern void errNoCR( char *err );
|
||||
extern void genPredTree( Predicate *p, Node *j, int ,int);
|
||||
extern UserAction *newUserAction(char *);
|
||||
extern char *gate_symbol(char *name);
|
||||
extern char *makeAltID(int blockid, int altnum);
|
||||
extern void DumpRemainingTokSets(void);
|
||||
extern void DumpANSIFunctionArgDef(FILE *f, Junction *q, int bInit); /* MR23 */
|
||||
extern void DumpFormals(FILE *, char *, int bInit); /* MR23 */
|
||||
extern char* hideDefaultArgs(const char* pdecl); /* MR22 VHS */
|
||||
extern Predicate *computePredFromContextGuard(Graph,int *msgDone); /* MR21 */
|
||||
extern void recomputeContextGuard(Predicate *); /* MR13 */
|
||||
extern Predicate *new_pred(void);
|
||||
extern void chkGTFlag(void);
|
||||
extern void leAdd(LabelEntry *); /* MR7 */
|
||||
extern void leFixup(void); /* MR7 */
|
||||
extern void egAdd(ExceptionGroup *); /* MR7 */
|
||||
extern void egFixup(void); /* MR7 */
|
||||
extern void altAdd(Junction *); /* MR7 */
|
||||
extern void altFixup(void); /* MR7 */
|
||||
extern Predicate * MR_find_in_aSubBlk(Junction *alt); /* MR10 */
|
||||
extern Predicate * MR_predFlatten(Predicate *p); /* MR10 */
|
||||
extern Predicate * MR_predSimplifyALL(Predicate *p); /* MR10 */
|
||||
extern Predicate * MR_predSimplifyALLX(Predicate *p,int skipPass3); /* MR10 */
|
||||
extern int MR_allPredLeaves(Predicate *p); /* MR10 */
|
||||
extern void MR_cleanup_pred_trees(Predicate *p); /* MR10 */
|
||||
extern int MR_predicate_context_completed(Predicate *p); /* MR10 */
|
||||
extern void MR_check_pred_too_long(Predicate *p,set completion); /* MR10 */
|
||||
extern Tree * MR_remove_epsilon_from_tree(Tree *t); /* MR10 */
|
||||
extern Tree * MR_computeTreeAND(Tree *l,Tree *r); /* MR10 */
|
||||
extern int MR_tree_equ(Tree *big, Tree *small); /* MR10 */
|
||||
extern set MR_First(int ck,Junction *j,set *incomplete); /* MR10 */
|
||||
extern set MR_compute_pred_set(Predicate *p); /* MR10 */
|
||||
extern Tree * MR_compute_pred_tree_context(Predicate *p); /* MR10 */
|
||||
extern int MR_pointerStackPush(PointerStack *,void *); /* MR10 */
|
||||
extern void * MR_pointerStackPop(PointerStack *); /* MR10 */
|
||||
extern void * MR_pointerStackTop(PointerStack *); /* MR10 */
|
||||
extern void MR_pointerStackReset(PointerStack *); /* MR10 */
|
||||
extern void MR_backTraceReport(void); /* MR10 */
|
||||
extern void MR_alphaBetaTraceReport(void); /* MR14 */
|
||||
extern void MR_dumpRuleSet(set); /* MR14 */
|
||||
extern void MR_predContextPresent(Predicate *p,int *,int *); /* MR10 */
|
||||
extern void MR_dumpPred(Predicate *p,int withContext); /* MR10 */
|
||||
extern void MR_dumpPred1(int,Predicate *p,int withContext); /* MR10 */
|
||||
extern void MR_xxxIndent(FILE *f,int depth); /* MR11 */
|
||||
extern void MR_outputIndent(int depth); /* MR11 */
|
||||
extern void MR_stderrIndent(int depth); /* MR11 */
|
||||
extern Junction * MR_ruleReferenced(RuleRefNode *rrn); /* MR10 */
|
||||
extern Junction * MR_nameToRuleBlk(char *); /* MR10 */
|
||||
extern void MR_releaseResourcesUsedInRule(Node *); /* MR10 */
|
||||
extern void MR_dumpTreeX(int depth,Tree *t,int across); /* MR10 */
|
||||
extern void MR_dumpTreeF(FILE *f,int depth,Tree *t,int across); /* MR10 */
|
||||
extern void DumpFcache(void); /* MR10 */
|
||||
extern void MR_dumpTokenSet(FILE *f,int depth,set s); /* MR10 */
|
||||
extern void MR_traceAmbSource(set *,Junction *,Junction *); /* MR11 */
|
||||
extern void MR_traceAmbSourceK(Tree *,Junction *a1,Junction *a2); /* MR11 */
|
||||
extern void MR_traceAmbSourceKclient(void); /* MR20 */
|
||||
extern Node *MR_advance(Node *); /* MR11 */
|
||||
extern int MR_offsetFromRule(Node *); /* MR11 */
|
||||
extern char *MR_ruleNamePlusOffset(Node *); /* MR11 */
|
||||
extern int MR_max_height_of_tree(Tree *); /* MR11 */
|
||||
extern int MR_all_leaves_same_height(Tree *,int); /* MR11 */
|
||||
extern void MR_projectTreeOntoSet(Tree *t,int k,set *); /* MR11 */
|
||||
extern Tree *MR_make_tree_from_set(set); /* MR11 */
|
||||
extern Predicate *MR_removeRedundantPredPass3(Predicate *); /* MR11 */
|
||||
extern void MR_pred_depth(Predicate *,int *); /* MR11 */
|
||||
extern int MR_comparePredicates(Predicate *,Predicate *); /* MR11 */
|
||||
extern Predicate * MR_unfold(Predicate *); /* MR11 */
|
||||
extern void MR_simplifyInverted(Predicate *,int); /* MR11 */
|
||||
extern int MR_secondPredicateUnreachable /* MR11 */
|
||||
(Predicate *first,Predicate *second); /* MR11 */
|
||||
extern void MR_clearPredEntry(Predicate *); /* MR11 */
|
||||
extern void MR_orphanRules(FILE *); /* MR12 */
|
||||
extern void MR_merge_contexts(Tree *); /* MR12 */
|
||||
extern int ci_strequ(char *,char *); /* MR12 */
|
||||
extern void MR_guardPred_plainSet(ActionNode *anode,Predicate *); /* MR12c */
|
||||
extern void MR_suppressSearchReport(void); /* MR12c */
|
||||
extern Predicate * MR_suppressK(Node *,Predicate *); /* MR13 */
|
||||
extern void MR_backTraceDumpItem(FILE *,int skip,Node *n); /* MR13 */
|
||||
extern void MR_backTraceDumpItemReset(void); /* MR13 */
|
||||
extern Junction * MR_junctionWithoutP2(Junction *); /* MR13 */
|
||||
extern void MR_setConstrainPointer(set *); /* MR18 */
|
||||
extern void BlockPreambleOption(Junction *q, char * pSymbol); /* MR23 */
|
||||
extern char* getInitializer(char *); /* MR23 */
|
||||
extern char *endFormal(char *pStart, /* MR23 */
|
||||
char **ppDataType, /* MR23 */
|
||||
char **ppSymbol, /* MR23 */
|
||||
char **ppEqualSign, /* MR23 */
|
||||
char **ppValue, /* MR23 */
|
||||
char **ppSeparator, /* MR23 */
|
||||
int *pNext); /* MR23 */
|
||||
extern char *strBetween(char *pStart, /* MR23 */
|
||||
char *pNext, /* MR23 */
|
||||
char *pStop); /* MR23 */
|
||||
extern int hasMultipleOperands(char *); /* MR23 */
|
||||
extern void DumpInitializers(FILE*, RuleEntry*, char*); /* MR23 */
|
||||
extern int isTermEntryTokClass(TermEntry *); /* MR23 */
|
||||
extern int isEmptyAlt(Node *, Node *); /* MR23 */
|
||||
#else
|
||||
extern int STRICMP();
|
||||
extern void istackreset();
|
||||
extern int istacksize();
|
||||
extern void pushint();
|
||||
extern int popint();
|
||||
extern int istackempty();
|
||||
extern int topint();
|
||||
extern void NewSetWd();
|
||||
extern void DumpSetWd();
|
||||
extern void DumpSetWdForC();
|
||||
extern void DumpSetWdForCC();
|
||||
extern void NewSet();
|
||||
extern void FillSet();
|
||||
extern void ComputeErrorSets();
|
||||
extern void ComputeTokSets();
|
||||
extern void SubstErrorClass();
|
||||
extern int DefErrSet();
|
||||
extern int DefErrSetForC();
|
||||
extern int DefErrSetForCC();
|
||||
extern int DefErrSet1();
|
||||
extern int DefErrSetForC1();
|
||||
extern int DefErrSetForCC1();
|
||||
extern int DefErrSetWithSuffix(); /* MR21 */
|
||||
extern void GenErrHdr();
|
||||
extern void dumpExpr();
|
||||
extern void addParm();
|
||||
extern Graph buildAction();
|
||||
extern Graph buildToken();
|
||||
extern Graph buildWildCard();
|
||||
extern Graph buildRuleRef();
|
||||
extern Graph Or();
|
||||
extern Graph Cat();
|
||||
extern Graph makeOpt();
|
||||
extern Graph makeBlk();
|
||||
extern Graph makeLoop();
|
||||
extern Graph makePlus();
|
||||
extern Graph emptyAlt();
|
||||
extern Graph emptyAlt3();
|
||||
extern TokNode * newTokNode();
|
||||
extern RuleRefNode * newRNode();
|
||||
extern Junction * newJunction();
|
||||
extern ActionNode * newActionNode();
|
||||
extern char * makelocks();
|
||||
extern void preorder();
|
||||
extern Tree * tnode();
|
||||
extern void _Tfree();
|
||||
extern Tree * tdup();
|
||||
extern int is_single_tuple();
|
||||
extern Tree * tappend();
|
||||
extern void Tfree();
|
||||
extern Tree * tlink();
|
||||
extern Tree * tshrink();
|
||||
extern Tree * tflatten();
|
||||
extern Tree * tJunc();
|
||||
extern Tree * tRuleRef();
|
||||
extern Tree * tToken();
|
||||
extern Tree * tAction();
|
||||
extern int tmember();
|
||||
extern int tmember_constrained();
|
||||
extern Tree * tleft_factor();
|
||||
extern Tree * trm_perm();
|
||||
extern void tcvt();
|
||||
extern Tree * permute();
|
||||
extern Tree * VerifyAmbig();
|
||||
extern set rJunc();
|
||||
extern set rRuleRef();
|
||||
extern set rToken();
|
||||
extern set rAction();
|
||||
extern void HandleAmbiguity();
|
||||
extern set First();
|
||||
extern void freeBlkFsets();
|
||||
extern void genAction();
|
||||
extern void genRuleRef();
|
||||
extern void genToken();
|
||||
extern void genOptBlk();
|
||||
extern void genLoopBlk();
|
||||
extern void genLoopBegin();
|
||||
extern void genPlusBlk();
|
||||
extern void genSubBlk();
|
||||
extern void genRule();
|
||||
extern void genJunction();
|
||||
extern void genEndBlk();
|
||||
extern void genEndRule();
|
||||
extern void genHdr();
|
||||
extern void genHdr1();
|
||||
extern void dumpAction();
|
||||
extern void dumpActionPlus(); /* MR21 */
|
||||
extern Entry ** newHashTable();
|
||||
extern Entry * hash_add();
|
||||
extern Entry * hash_get();
|
||||
extern void hashStat();
|
||||
extern char * mystrdup();
|
||||
extern void genLexDescr();
|
||||
extern void dumpLexClasses();
|
||||
extern void genDefFile();
|
||||
extern void DumpListOfParmNames(); /* MR5 janm 26-May-97 */
|
||||
extern int DumpNextNameInDef();
|
||||
extern void DumpOldStyleParms();
|
||||
extern void DumpType();
|
||||
extern int strmember();
|
||||
/* extern int HasComma(); MR23 Replaced by hasMultipleOperands() */
|
||||
extern void DumpRetValStruct();
|
||||
extern char * StripQuotes();
|
||||
extern int main();
|
||||
extern void readDescr();
|
||||
extern FILE * NextFile();
|
||||
extern char * outnameX();
|
||||
extern char * outname();
|
||||
extern void fatalFL();
|
||||
extern void fatal_intern();
|
||||
extern void cleanUp();
|
||||
extern char * eMsg3();
|
||||
extern char * eMsgd();
|
||||
extern char * eMsgd2();
|
||||
extern void s_fprT();
|
||||
extern char * TerminalString();
|
||||
extern void lexclass();
|
||||
extern void lexmode();
|
||||
extern int LexClassIndex();
|
||||
extern int hasAction();
|
||||
extern void setHasAction();
|
||||
extern int addTname();
|
||||
extern int addTexpr();
|
||||
extern int Tnum();
|
||||
extern void Tklink();
|
||||
extern Entry * newEntry();
|
||||
extern void list_add();
|
||||
extern void list_free(); /* MR10 */
|
||||
extern void list_apply();
|
||||
extern int list_search_cstring (); /* MR27 */
|
||||
extern char * Fkey();
|
||||
extern void FoPush();
|
||||
extern void FoPop();
|
||||
extern void RegisterCycle();
|
||||
extern void ResolveFoCycles();
|
||||
extern void pJunc();
|
||||
extern void pRuleRef();
|
||||
extern void pToken();
|
||||
extern void pAction();
|
||||
extern void FoLink();
|
||||
extern void addFoLink();
|
||||
extern void GenCrossRef();
|
||||
extern void defErr();
|
||||
extern void genStdPCCTSIncludeFile();
|
||||
extern char * pcctsBaseName(); /* MR32 */
|
||||
extern Predicate *find_predicates();
|
||||
extern Predicate *MR_find_predicates_and_supp(); /* MR13 */
|
||||
extern int predicateLookaheadDepth(); /* MR10 */
|
||||
extern void predicate_free(); /* MR10 */
|
||||
extern Predicate * predicate_dup(); /* MR10 */
|
||||
extern Predicate * predicate_dup_without_context(); /* MR11 */
|
||||
extern void GenRulePrototypes();
|
||||
extern Junction *first_item_is_guess_block();
|
||||
extern Junction *first_item_is_guess_block_extra(); /* MR30 */
|
||||
extern Junction *analysis_point();
|
||||
extern Tree *make_tree_from_sets();
|
||||
extern Tree *tdup_chain();
|
||||
extern Tree *tdif();
|
||||
extern set covered_set();
|
||||
extern void AmbiguityDialog();
|
||||
extern void dumpAmbigMsg();
|
||||
extern void GenRuleFuncRedefs();
|
||||
extern void GenPredefinedSymbolRedefs();
|
||||
extern void GenASTSymbolRedefs();
|
||||
extern void GenRemapFile();
|
||||
extern void GenSetRedefs();
|
||||
extern ForcedToken *newForcedToken();
|
||||
extern void RemapForcedTokens();
|
||||
extern char *TokenOrExpr();
|
||||
extern void setUpperRange();
|
||||
extern void GenParser_c_Hdr();
|
||||
extern void GenParser_h_Hdr();
|
||||
extern void GenRuleMemberDeclarationsForCC();
|
||||
extern int addForcedTname();
|
||||
extern char *OutMetaName();
|
||||
extern void OutFirstSetSymbol(); /* MR21 */
|
||||
extern void warnNoFL();
|
||||
extern void warnFL();
|
||||
extern void warn();
|
||||
extern void warnNoCR();
|
||||
extern void errNoFL();
|
||||
extern void errFL();
|
||||
extern void err();
|
||||
extern void errNoCR();
|
||||
extern void genPredTree();
|
||||
extern UserAction *newUserAction();
|
||||
extern char *gate_symbol();
|
||||
extern char *makeAltID();
|
||||
extern void DumpRemainingTokSets();
|
||||
extern void DumpANSIFunctionArgDef();
|
||||
extern void DumpFormals(); /* MR23 */
|
||||
extern char* hideDefaultArgs(); /* MR22 VHS */
|
||||
extern Predicate *computePredFromContextGuard();
|
||||
extern void recomputeContextGuard(); /* MR13 */
|
||||
extern Predicate *new_pred();
|
||||
extern void chkGTFlag();
|
||||
extern void leAdd(); /* MR7 */
|
||||
extern void leFixup(); /* MR7 */
|
||||
extern void egAdd(); /* MR7 */
|
||||
extern void egFixup(); /* MR7 */
|
||||
extern void altAdd(); /* MR7 */
|
||||
extern void altFixup(); /* MR7 */
|
||||
extern Predicate * MR_find_in_aSubBlk(); /* MR10 */
|
||||
extern Predicate * MR_predFlatten(); /* MR10 */
|
||||
extern Predicate * MR_predSimplifyALL(); /* MR10 */
|
||||
extern Predicate * MR_predSimplifyALLX(); /* MR10 */
|
||||
extern void MR_cleanup_pred_trees(); /* MR10 */
|
||||
extern int MR_allPredLeaves(); /* MR10 */
|
||||
extern int MR_predicate_context_completed(); /* MR10 */
|
||||
extern void MR_check_pred_too_long(); /* MR10 */
|
||||
extern Tree * MR_remove_epsilon_from_tree(); /* MR10 */
|
||||
extern Tree * MR_computeTreeAND(); /* MR10 */
|
||||
extern int MR_tree_equ(); /* MR10 */
|
||||
extern set MR_First(); /* MR10 */
|
||||
extern set MR_compute_pred_set(); /* MR10 */
|
||||
extern Tree * MR_compute_pred_tree_context(); /* MR10 */
|
||||
extern int MR_pointerStackPush(); /* MR10 */
|
||||
extern void * MR_pointerStackPop(); /* MR10 */
|
||||
extern void * MR_pointerStackTop(); /* MR10 */
|
||||
extern void MR_pointerStackReset(); /* MR10 */
|
||||
extern void MR_backTraceReport(); /* MR10 */
|
||||
extern void MR_alphaBetaTraceReport(); /* MR14 */
|
||||
extern void MR_dumpRuleSet(); /* MR14 */
|
||||
extern void MR_predContextPresent(); /* MR10 */
|
||||
extern void MR_dumpPred(); /* MR10 */
|
||||
extern void MR_dumpPred1(); /* MR10 */
|
||||
extern void MR_xxxIndent(); /* MR11 */
|
||||
extern void MR_stderrIndent(); /* MR11 */
|
||||
extern void MR_outputIndent(); /* MR11 */
|
||||
extern Junction * MR_ruleReferenced(); /* MR10 */
|
||||
extern void MR_releaseResourcesUsedInRule(); /* MR10 */
|
||||
extern void MR_dumpTreeX(); /* MR10 */
|
||||
extern void MR_dumpTreeF(); /* MR10 */
|
||||
extern void DumpFcache(); /* MR10 */
|
||||
extern void MR_dumpTokenSet(); /* MR10 */
|
||||
extern void MR_traceAmbSource(); /* MR11 */
|
||||
extern Node *MR_advance(); /* MR11 */
|
||||
extern int MR_offsetFromRule(); /* MR11 */
|
||||
extern char *MR_ruleNamePlusOffset(); /* MR11 */
|
||||
extern void MR_traceAmbSourceK(); /* MR11 */
|
||||
extern void MR_traceAmbSourceKclient(); /* [i_a] added */
|
||||
extern int MR_max_height_of_tree(); /* MR11 */
|
||||
extern int MR_all_leaves_same_height(); /* MR11 */
|
||||
extern void MR_projectTreeOntoSet(); /* MR11 */
|
||||
extern Tree *MR_make_tree_from_set(); /* MR11 */
|
||||
extern Predicate *MR_removeRedundantPredPass3(); /* MR11 */
|
||||
extern void MR_pred_depth(); /* MR11 */
|
||||
extern int MR_comparePredicates(); /* MR11 */
|
||||
extern Predicate * MR_unfold(); /* MR11 */
|
||||
extern void MR_simplifyInverted(); /* MR11 */
|
||||
extern int MR_secondPredicateUnreachable(); /* MR11 */
|
||||
extern Junction * MR_nameToRuleBlk(); /* MR10 */
|
||||
extern void MR_clearPredEntry(); /* MR11 */
|
||||
extern void MR_orphanRules(); /* MR12 */
|
||||
extern void MR_merge_contexts(); /* MR12 */
|
||||
extern int ci_strequ(); /* MR12 */
|
||||
extern void MR_guardPred_plainSet(); /* MR12c */
|
||||
extern void MR_suppressSearchReport(); /* MR12c */
|
||||
extern Predicate * MR_suppressK(); /* MR13 */
|
||||
extern void MR_backTraceDumpItem(); /* MR13 */
|
||||
extern void MR_backTraceDumpItemReset(); /* MR13 */
|
||||
extern Junction * MR_junctionWithoutP2(); /* MR13 */
|
||||
extern void MR_setConstrainPointer(); /* MR18 */
|
||||
extern void BlockPreambleOption(); /* MR23 */
|
||||
extern char* getInitializer(); /* MR23 */
|
||||
extern int hasMultipleOperands(); /* MR23 */
|
||||
extern char *endFormal(); /* MR23 */
|
||||
extern char *strBetween(); /* MR23 */
|
||||
extern void DumpInitializers(); /* MR23 */
|
||||
extern int isTermEntryTokClass(); /* MR23 */
|
||||
extern int isEmptyAlt();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* MR20 G. Hobbelt Create proper externs for dlg variables */
|
||||
|
||||
extern set attribsRefdFromAction;
|
||||
extern int inAlt;
|
||||
extern int UsedOldStyleAttrib;
|
||||
extern int UsedNewStyleLabel;
|
||||
|
||||
#define MAX_BLK_LEVEL 100 /* MR23 */
|
||||
extern int CurBlockID_array[MAX_BLK_LEVEL]; /* MR23 */
|
||||
extern int CurAltNum_array[MAX_BLK_LEVEL]; /* MR23 */
|
5735
Tools/CodeTools/Source/Pccts/antlr/scan.c
Normal file
5735
Tools/CodeTools/Source/Pccts/antlr/scan.c
Normal file
File diff suppressed because it is too large
Load Diff
31
Tools/CodeTools/Source/Pccts/antlr/stdpccts.h
Normal file
31
Tools/CodeTools/Source/Pccts/antlr/stdpccts.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef STDPCCTS_H
|
||||
#define STDPCCTS_H
|
||||
/*
|
||||
* stdpccts.h -- P C C T S I n c l u d e
|
||||
*
|
||||
* Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
|
||||
* Purdue University Electrical Engineering
|
||||
* With AHPCRC, University of Minnesota
|
||||
* ANTLR Version 1.33MR33
|
||||
*/
|
||||
|
||||
#ifndef ANTLR_VERSION
|
||||
#define ANTLR_VERSION 13333
|
||||
#endif
|
||||
|
||||
#include "pcctscfg.h"
|
||||
#include "pccts_stdio.h"
|
||||
|
||||
#include "pcctscfg.h"
|
||||
#include "set.h"
|
||||
#include <ctype.h>
|
||||
#include "syn.h"
|
||||
#include "hash.h"
|
||||
#include "generic.h"
|
||||
#define zzcr_attr(attr,tok,t)
|
||||
#define zzSET_SIZE 20
|
||||
#include "antlr.h"
|
||||
#include "tokens.h"
|
||||
#include "dlgdef.h"
|
||||
#include "mode.h"
|
||||
#endif
|
390
Tools/CodeTools/Source/Pccts/antlr/syn.h
Normal file
390
Tools/CodeTools/Source/Pccts/antlr/syn.h
Normal file
@@ -0,0 +1,390 @@
|
||||
/*
|
||||
* syn.h
|
||||
*
|
||||
* This file includes definitions and macros associated with syntax diagrams
|
||||
*
|
||||
* 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.33
|
||||
* Terence Parr
|
||||
* Parr Research Corporation
|
||||
* with Purdue University and AHPCRC, University of Minnesota
|
||||
* 1989-2001
|
||||
*/
|
||||
|
||||
#include "set.h"
|
||||
|
||||
#define NumNodeTypes 4
|
||||
#define NumJuncTypes 9
|
||||
|
||||
/* List the different node types */
|
||||
#define nJunction 1
|
||||
#define nRuleRef 2
|
||||
#define nToken 3
|
||||
#define nAction 4
|
||||
|
||||
/* Different types of junctions */
|
||||
#define aSubBlk 1
|
||||
#define aOptBlk 2
|
||||
#define aLoopBlk 3
|
||||
#define EndBlk 4
|
||||
#define RuleBlk 5
|
||||
#define Generic 6 /* just a junction--no unusual characteristics */
|
||||
#define EndRule 7
|
||||
#define aPlusBlk 8
|
||||
#define aLoopBegin 9
|
||||
|
||||
typedef int NodeType;
|
||||
|
||||
#define TreeBlockAllocSize 500
|
||||
#define JunctionBlockAllocSize 200
|
||||
#define ActionBlockAllocSize 50
|
||||
#define RRefBlockAllocSize 100
|
||||
#define TokenBlockAllocSize 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
class ActionNode;
|
||||
class Junction;
|
||||
#endif
|
||||
|
||||
/* note that 'right' is used by the tree node allocator as a ptr for linked list */
|
||||
typedef struct _tree {
|
||||
struct _tree *down, *right;
|
||||
int token;
|
||||
union {
|
||||
int rk; /* if token==EpToken, => how many more tokens req'd */
|
||||
struct _tree *tref; /* if token==TREE_REF */
|
||||
set sref; /* if token==SET */
|
||||
} v;
|
||||
#ifdef TREE_DEBUG
|
||||
int in_use;
|
||||
int seq;
|
||||
#endif
|
||||
} Tree;
|
||||
|
||||
|
||||
/* a predicate is defined to be a predicate action and a token tree with
|
||||
* context info (if used); later, this struct may include the
|
||||
* "hoisting distance" when we hoist past tokens.
|
||||
*
|
||||
* A tree is used to indicate && vs ||
|
||||
*
|
||||
* p
|
||||
* |
|
||||
* q--r
|
||||
*
|
||||
* indicates p && (q||r).
|
||||
*
|
||||
* If expr is PRED_AND_LIST or PRED_OR_LIST, then it's an operation node
|
||||
* and indicates the start of an && or || list.
|
||||
*/
|
||||
|
||||
typedef struct _Predicate {
|
||||
struct _Predicate *down, *right; /* these have to be first */
|
||||
struct _Predicate *up, *left; /* doubly-link me */
|
||||
char *expr;
|
||||
Tree *tcontext; /* used if lookahead depth of > one is needed (tree) */
|
||||
int k; /* lookahead depth for this tcontext */
|
||||
set scontext[2];/* used if lookahead depth of one is needed (set) */
|
||||
/* scontext[0] is not used; only needed so genExprSets()
|
||||
routine works (it expects an array)
|
||||
*/
|
||||
set completionTree; /* which lookahead depths are required to complete tcontext? */
|
||||
set completionSet; /* MR10 separate completion set for sets and trees */
|
||||
struct _PredEntry *predEntry; /* MR11 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
ActionNode *source; /* where did this predicate come from? */
|
||||
#else
|
||||
struct _anode *source; /* where did this predicate come from? */
|
||||
#endif
|
||||
|
||||
char cloned; /* MR10 don't want to free original guard pred */
|
||||
char redundant; /* MR10 predicate tree simplification */
|
||||
char ampersandStyle; /* MR10 (g)? && <<p>>? */
|
||||
char inverted; /* MR11 ! predName */
|
||||
char isConst; /* MR11 */
|
||||
char constValue; /* MR11 */
|
||||
char conflictReported; /* MR11 */
|
||||
|
||||
set plainSet; /* MR12b */
|
||||
|
||||
/*** remember to change new_predicate() and predicate_dup() when changing this ***/
|
||||
|
||||
} Predicate;
|
||||
|
||||
typedef struct _ExceptionHandler {
|
||||
char *signalname;
|
||||
char *action;
|
||||
} ExceptionHandler;
|
||||
|
||||
typedef struct _ExceptionGroup {
|
||||
struct _ListNode *handlers; /* list of ExceptionHandler's */
|
||||
char *label; /* label==""; implies not attached to any
|
||||
* particular rule ref.
|
||||
*/
|
||||
char *altID; /* which alt did it come from (blk#:alt#) */
|
||||
|
||||
struct _ExceptionGroup *pendingLink; /* for alternative EG MR7 */
|
||||
struct _ExceptionGroup *outerEG; /* for alternative EG MR7 */
|
||||
struct _LabelEntry *labelEntry; /* for alternative EG MR7 */
|
||||
int forRule; /* MR7 */
|
||||
int used; /* MR7 */
|
||||
} ExceptionGroup ;
|
||||
|
||||
|
||||
#define TokenString(_i) ((TokenInd!=NULL)?TokenStr[TokenInd[_i]]:TokenStr[_i])
|
||||
#define ExprString(_i) ((TokenInd!=NULL)?ExprStr[TokenInd[_i]]:ExprStr[_i])
|
||||
|
||||
|
||||
/* M e s s a g e P a s s i n g T o N o d e s */
|
||||
|
||||
/*
|
||||
* assumes a 'Junction *r' exists. This macro calls a function with
|
||||
* the pointer to the node to operate on and a pointer to the rule
|
||||
* in which it is enclosed.
|
||||
*/
|
||||
#define TRANS(p) {if ( (p)==NULL ) fatal("TRANS: NULL object"); \
|
||||
if ( (p)->ntype == nJunction ) (*(fpJTrans[((Junction *)(p))->jtype]))( p );\
|
||||
else (*(fpTrans[(p)->ntype]))( p );}
|
||||
|
||||
#define PRINT(p) {if ( (p)==NULL ) fatal("PRINT: NULL object");\
|
||||
(*(fpPrint[(p)->ntype]))( p );}
|
||||
|
||||
#define REACH(p,k,rk,a) {if ( (p)==NULL ) fatal("REACH: NULL object");\
|
||||
(a) = (*(fpReach[(p)->ntype]))( p, k, rk );}
|
||||
|
||||
#define TRAV(p,k,rk,a) {if ( (p)==NULL ) {\
|
||||
if ( ContextGuardTRAV ) (a)=NULL; \
|
||||
else fatal("TRAV: NULL object");\
|
||||
} \
|
||||
else (a) = (*(fpTraverse[(p)->ntype]))( p, k, rk );}
|
||||
|
||||
/**
|
||||
*** #define TRAV(p,k,rk,a) {if ( (p)==NULL ) fatal("TRAV: NULL object");\
|
||||
*** (a) = (*(fpTraverse[(p)->ntype]))( p, k, rk );}
|
||||
**/
|
||||
|
||||
/* All syntax diagram nodes derive from Node -- superclass
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
class Node {
|
||||
public:
|
||||
NodeType ntype;
|
||||
char *rname; /* what rule does this element live in? */
|
||||
int file; /* index in FileStr */
|
||||
int line; /* line number that element occurs on */
|
||||
};
|
||||
#else
|
||||
typedef struct _node {
|
||||
NodeType ntype;
|
||||
char *rname; /* what rule does this element live in? */
|
||||
int file; /* index in FileStr */
|
||||
int line; /* line number that element occurs on */
|
||||
} Node;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
class ActionNode : public Node {
|
||||
public:
|
||||
#else
|
||||
typedef struct _anode {
|
||||
NodeType ntype;
|
||||
char *rname; /* what rule does this action live in? */
|
||||
int file; /* index in FileStr (name of file with action) */
|
||||
int line; /* line number that action occurs on */
|
||||
#endif
|
||||
Node *next;
|
||||
char *action;
|
||||
int is_predicate; /* true if action is a <<...>>? predicate action */
|
||||
int done; /* don't dump if action dumped (used for predicates) */
|
||||
int init_action; /* is this the 1st action of 1st prod of block? */
|
||||
char *pred_fail; /* what to do/print when predicate fails */
|
||||
Predicate *guardpred; /* if '(context)? =>' was present, already done */
|
||||
unsigned char frmwarned;/* have we dumped a warning for pred yet? */
|
||||
unsigned char ctxwarned;/* have we dumped a warning for pred yet? */
|
||||
unsigned char predTooLong; /* MR10 have we dumped warning for pred yet */
|
||||
unsigned char noHoist; /* MR12 literally "noHoist" */
|
||||
Predicate *ampersandPred; /* MR10 (g)? && <<p>>? expr */
|
||||
#ifdef __cplusplus
|
||||
Junction *guardNodes; /* MR11 */
|
||||
#else
|
||||
struct _junct *guardNodes; /* MR11 */
|
||||
#endif
|
||||
struct _PredEntry *predEntry; /* MR11 */
|
||||
int inverted; /* MR11 <<!predSymbol>>? */
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#else
|
||||
} ActionNode;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
class TokNode : public Node {
|
||||
public:
|
||||
#else
|
||||
typedef struct _toknode {
|
||||
NodeType ntype;
|
||||
char *rname; /* name of rule it's in */
|
||||
int file; /* index in FileStr (name of file with rule) */
|
||||
int line; /* line number that token occurs on */
|
||||
#endif
|
||||
Node *next;
|
||||
int token;
|
||||
int astnode; /* leaf/root/excluded (used to build AST's) */
|
||||
unsigned char label;/* token label or expression ? */
|
||||
unsigned char remapped;
|
||||
/* used if token id's are forced to certain positions;
|
||||
* a function walks the tree reassigning token numbers */
|
||||
int upper_range; /* MR13 - was char */
|
||||
/* used only if Token is of type T1..T2; in this case,
|
||||
* use token..upper_range as the range; else
|
||||
* upper_range must be 0 */
|
||||
unsigned char wild_card;
|
||||
/* indicates that the token is the "." wild-card;
|
||||
* field token is ignored if wild_card is set
|
||||
*/
|
||||
unsigned int elnum; /* element number within the alternative */
|
||||
#ifdef __cplusplus
|
||||
Junction *altstart; /* pointer to node that starts alt */
|
||||
#else
|
||||
struct _junct *altstart; /* pointer to node that starts alt */
|
||||
#endif
|
||||
struct _TCnode *tclass; /* token class if tokclass ref */
|
||||
set tset; /* set of tokens represented by meta token */
|
||||
char *el_label; /* el_label:toknode */
|
||||
unsigned char complement; /* complement the set? */
|
||||
ExceptionGroup *ex_group; /* any exception[el_label] attached? */
|
||||
unsigned char use_def_MT_handler;
|
||||
unsigned char label_used_in_semantic_pred; /* MR10 */
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#else
|
||||
} TokNode;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
class RuleRefNode : public Node {
|
||||
public:
|
||||
#else
|
||||
typedef struct _rrnode {
|
||||
NodeType ntype;
|
||||
char *rname; /* name of rule it's in */
|
||||
int file; /* index in FileStr (name of file with rule)
|
||||
it's in */
|
||||
int line; /* line number that rule ref occurs on */
|
||||
#endif
|
||||
Node *next;
|
||||
char *text; /* reference to which rule */
|
||||
char *parms; /* point to parameters of rule invocation
|
||||
(if present) */
|
||||
char *assign; /* point to left-hand-side of assignment
|
||||
(if any) */
|
||||
int linked; /* Has a FoLink already been established? */
|
||||
int astnode; /* excluded? (used to build AST's) */
|
||||
unsigned int elnum; /* element number within the alternative */
|
||||
#ifdef __cplusplus
|
||||
Junction *altstart;
|
||||
#else
|
||||
struct _junct *altstart;
|
||||
#endif
|
||||
char *el_label; /* el_label:rrnode */
|
||||
ExceptionGroup *ex_group; /* any exception[el_label] attached? */
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#else
|
||||
} RuleRefNode;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
class Junction : public Node {
|
||||
public:
|
||||
#else
|
||||
typedef struct _junct {
|
||||
NodeType ntype;
|
||||
char *rname; /* name of rule junction is in */
|
||||
int file; /* index in FileStr (name of file with rule)
|
||||
if blk == RuleBlk */
|
||||
int line; /* line number that rule occurs on */
|
||||
#endif
|
||||
int seq; /* MR10 sequence number */
|
||||
char ignore; /* used by FIRST computation to ignore
|
||||
empty alt added for the (...)+ blks */
|
||||
char visited; /* used by recursive routines to avoid
|
||||
infinite recursion */
|
||||
char pvisited; /* used by print routines to avoid
|
||||
infinite recursion */
|
||||
char fvisited; /* used by FoLink() to avoid
|
||||
infinite recursion */
|
||||
char *lock; /* used by REACH to track infinite recursion */
|
||||
char *pred_lock; /* used by find_predicates to track infinite recursion */
|
||||
int altnum; /* used in subblocks. altnum==0 means not an
|
||||
alt of subrule */
|
||||
int jtype; /* annotation for code-gen/FIRST/FOLLOW.
|
||||
Junction type */
|
||||
#ifdef __cplusplus
|
||||
Junction *end; /* pointer to node with EndBlk in it
|
||||
if blk == a block type */
|
||||
#else
|
||||
struct _junct *end; /* pointer to node with EndBlk in it
|
||||
if blk == a block type */
|
||||
#endif
|
||||
Node *p1, *p2;
|
||||
char halt; /* never move past a junction with halt==TRUE */ /* MR10 was int */
|
||||
char *pdecl; /* point to declaration of parameters on rule
|
||||
(if present) */
|
||||
char *parm; /* point to parameter of block invocation
|
||||
(if present) */
|
||||
char predparm; /* indicates that the 'parm' is a predicate
|
||||
* to be used in the while loop generated
|
||||
* for blocks */ /* MR10 was int */
|
||||
char *ret; /* point to return type of rule (if present) */
|
||||
char *erraction; /* point to error action (if present) */
|
||||
int blockid; /* this is a unique ID */
|
||||
char *exception_label; /* goto label for this alt */
|
||||
set *fset; /* used for code generation */
|
||||
Tree *ftree; /* used for code generation */
|
||||
Predicate *predicate;/* predicate that can be used to disambiguate */
|
||||
char guess; /* true if (...)? block */
|
||||
char alpha_beta_guess_end; /* MR14 1 => end block of guess sub block */
|
||||
Node *guess_analysis_point; /* MR14 */
|
||||
char approx; /* limit block to use linear approx lookahead? */
|
||||
set tokrefs; /* if ith element of alt is tokref then i is member */
|
||||
set rulerefs; /* if ith element of alt is rule ref then i is member */
|
||||
struct _ListNode *exceptions; /* list of exceptions groups for rule */
|
||||
struct _ListNode *el_labels; /* list of element labels for rule */
|
||||
ExceptionGroup *outerEG; /* MR7 */
|
||||
int curAltNum; /* MR7 */
|
||||
char* pFirstSetSymbol; /* #pragma FirstSetSymbol(Foo) MR21 */
|
||||
#ifdef __cplusplus
|
||||
Junction *pendingLink; /* MR7 */
|
||||
#else
|
||||
struct _junct *pendingLink; /* MR7 */
|
||||
#endif
|
||||
char overlap_warning; /* MR10 */
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#else
|
||||
} Junction;
|
||||
#endif
|
||||
|
||||
typedef struct { Node *left, *right;} Graph;
|
||||
|
246
Tools/CodeTools/Source/Pccts/antlr/tokens.h
Normal file
246
Tools/CodeTools/Source/Pccts/antlr/tokens.h
Normal file
@@ -0,0 +1,246 @@
|
||||
#ifndef tokens_h
|
||||
#define tokens_h
|
||||
/* tokens.h -- List of labelled tokens and stuff
|
||||
*
|
||||
* Generated from: antlr.g
|
||||
*
|
||||
* Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
|
||||
* Purdue University Electrical Engineering
|
||||
* ANTLR Version 1.33MR33
|
||||
*/
|
||||
#define zzEOF_TOKEN 1
|
||||
#define Eof 1
|
||||
#define QuotedTerm 2
|
||||
#define Action 34
|
||||
#define Pred 35
|
||||
#define PassAction 36
|
||||
#define WildCard 87
|
||||
#define LABEL 89
|
||||
#define Pragma 92
|
||||
#define FirstSetSymbol 93
|
||||
#define NonTerminal 100
|
||||
#define TokenTerm 101
|
||||
#define ID 148
|
||||
#define INT 150
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void grammar(void);
|
||||
#else
|
||||
extern void grammar();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void class_def(void);
|
||||
#else
|
||||
extern void class_def();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void rule(void);
|
||||
#else
|
||||
extern void rule();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void laction(void);
|
||||
#else
|
||||
extern void laction();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void lmember(void);
|
||||
#else
|
||||
extern void lmember();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void lprefix(void);
|
||||
#else
|
||||
extern void lprefix();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void aPred(void);
|
||||
#else
|
||||
extern void aPred();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
extern Predicate * predOrExpr(void);
|
||||
#else
|
||||
extern Predicate * predOrExpr();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
extern Predicate * predAndExpr(void);
|
||||
#else
|
||||
extern Predicate * predAndExpr();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
extern Predicate * predPrimary(void);
|
||||
#else
|
||||
extern Predicate * predPrimary();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void aLexclass(void);
|
||||
#else
|
||||
extern void aLexclass();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void error(void);
|
||||
#else
|
||||
extern void error();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void tclass(void);
|
||||
#else
|
||||
extern void tclass();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void token(void);
|
||||
#else
|
||||
extern void token();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void block(set * toksrefd,set * rulesrefd);
|
||||
#else
|
||||
extern void block();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void alt(set * toksrefd,set * rulesrefd);
|
||||
#else
|
||||
extern void alt();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
extern LabelEntry * element_label(void);
|
||||
#else
|
||||
extern LabelEntry * element_label();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
extern Node * element(int old_not,int first_on_line,int use_def_MT_handler);
|
||||
#else
|
||||
extern Node * element();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void default_exception_handler(void);
|
||||
#else
|
||||
extern void default_exception_handler();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
extern ExceptionGroup * exception_group(void);
|
||||
#else
|
||||
extern ExceptionGroup * exception_group();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
extern ExceptionHandler * exception_handler(void);
|
||||
#else
|
||||
extern ExceptionHandler * exception_handler();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void enum_file(char * fname);
|
||||
#else
|
||||
extern void enum_file();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void defines(char * fname);
|
||||
#else
|
||||
extern void defines();
|
||||
#endif
|
||||
|
||||
#ifdef __USE_PROTOS
|
||||
void enum_def(char * fname);
|
||||
#else
|
||||
extern void enum_def();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
extern SetWordType zzerr1[];
|
||||
extern SetWordType zzerr2[];
|
||||
extern SetWordType zzerr3[];
|
||||
extern SetWordType zzerr4[];
|
||||
extern SetWordType setwd1[];
|
||||
extern SetWordType zzerr5[];
|
||||
extern SetWordType zzerr6[];
|
||||
extern SetWordType zzerr7[];
|
||||
extern SetWordType zzerr8[];
|
||||
extern SetWordType zzerr9[];
|
||||
extern SetWordType setwd2[];
|
||||
extern SetWordType zzerr10[];
|
||||
extern SetWordType zzerr11[];
|
||||
extern SetWordType zzerr12[];
|
||||
extern SetWordType zzerr13[];
|
||||
extern SetWordType setwd3[];
|
||||
extern SetWordType zzerr14[];
|
||||
extern SetWordType zzerr15[];
|
||||
extern SetWordType zzerr16[];
|
||||
extern SetWordType zzerr17[];
|
||||
extern SetWordType zzerr18[];
|
||||
extern SetWordType zzerr19[];
|
||||
extern SetWordType zzerr20[];
|
||||
extern SetWordType zzerr21[];
|
||||
extern SetWordType setwd4[];
|
||||
extern SetWordType zzerr22[];
|
||||
extern SetWordType zzerr23[];
|
||||
extern SetWordType zzerr24[];
|
||||
extern SetWordType zzerr25[];
|
||||
extern SetWordType zzerr26[];
|
||||
extern SetWordType setwd5[];
|
||||
extern SetWordType zzerr27[];
|
||||
extern SetWordType zzerr28[];
|
||||
extern SetWordType zzerr29[];
|
||||
extern SetWordType zzerr30[];
|
||||
extern SetWordType zzerr31[];
|
||||
extern SetWordType zzerr32[];
|
||||
extern SetWordType zzerr33[];
|
||||
extern SetWordType setwd6[];
|
||||
extern SetWordType zzerr34[];
|
||||
extern SetWordType zzerr35[];
|
||||
extern SetWordType zzerr36[];
|
||||
extern SetWordType zzerr37[];
|
||||
extern SetWordType zzerr38[];
|
||||
extern SetWordType zzerr39[];
|
||||
extern SetWordType zzerr40[];
|
||||
extern SetWordType zzerr41[];
|
||||
extern SetWordType zzerr42[];
|
||||
extern SetWordType setwd7[];
|
||||
extern SetWordType zzerr43[];
|
||||
extern SetWordType zzerr44[];
|
||||
extern SetWordType zzerr45[];
|
||||
extern SetWordType zzerr46[];
|
||||
extern SetWordType zzerr47[];
|
||||
extern SetWordType zzerr48[];
|
||||
extern SetWordType zzerr49[];
|
||||
extern SetWordType zzerr50[];
|
||||
extern SetWordType zzerr51[];
|
||||
extern SetWordType zzerr52[];
|
||||
extern SetWordType zzerr53[];
|
||||
extern SetWordType setwd8[];
|
||||
extern SetWordType zzerr54[];
|
||||
extern SetWordType zzerr55[];
|
||||
extern SetWordType zzerr56[];
|
||||
extern SetWordType zzerr57[];
|
||||
extern SetWordType setwd9[];
|
||||
extern SetWordType zzerr58[];
|
||||
extern SetWordType zzerr59[];
|
||||
extern SetWordType zzerr60[];
|
||||
extern SetWordType zzerr61[];
|
||||
extern SetWordType zzerr62[];
|
||||
extern SetWordType zzerr63[];
|
||||
extern SetWordType zzerr64[];
|
||||
extern SetWordType zzerr65[];
|
||||
extern SetWordType setwd10[];
|
||||
extern SetWordType setwd11[];
|
Reference in New Issue
Block a user