Codebase list gtkwave / 2f58098
Imported Upstream version 3.3.98 أحمد المحمودي (Ahmed El-Mahmoudy) 5 years ago
330 changed file(s) with 330 addition(s) and 105710 deletion(s). Raw diff Collapse all Expand all
0 GTKWave Wave Viewer is Copyright (C) 1999-2018 Tony Bybell.
1 Windows compatibility and PS/MIF routines are Copyright (C) 1999-2018 Udi Finkelstein.
2 Context support is Copyright (C) 2007-2018 Kermin Elliott Fleming.
3 Trace group support is Copyright (C) 2009-2018 Donald Baltus.
4 GHW and additional GUI support is Copyright (C) 2005-2018 Tristan Gingold.
5 Analog support is Copyright (C) 2005-2018 Thomas Sailer.
6 External DnD support is Copyright (C) 2008-2018 Concept Engineering GmbH.
7 FastLZ is Copyright (C) 2005-2018 Ariya Hidayat.
8 PCCTS 1.33MR is Copyright (C) 1989-2018 Terence Parr, Russell Quong, Will Cohen, Hank Dietz, and Thomas Moog.
0 GTKWave Wave Viewer is Copyright (C) 1999-2019 Tony Bybell.
1 Windows compatibility and PS/MIF routines are Copyright (C) 1999-2019 Udi Finkelstein.
2 Context support is Copyright (C) 2007-2019 Kermin Elliott Fleming.
3 Trace group support is Copyright (C) 2009-2019 Donald Baltus.
4 GHW and additional GUI support is Copyright (C) 2005-2019 Tristan Gingold.
5 Analog support is Copyright (C) 2005-2019 Thomas Sailer.
6 External DnD support is Copyright (C) 2008-2019 Concept Engineering GmbH.
7 FastLZ is Copyright (C) 2005-2019 Ariya Hidayat.
98 Some public domain clip art by contributors at http://www.sxc.hu/ website.
109 Hierarchy marker icons from the Silk icons set by Mark James found at the http://www.famfamfam.com/lab/icons/silk/ website.
1110 Portions of the TCL implementation, tcl_np.c and tcl_np.h are copyrighted by the Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState Corporation, and other parties.
12 NSAlert is Copyright (C) 2011-2018 Philipp Mayerhofer.
13 LZ4 is Copyright (C) 2011-2018 Yann Collet.
11 NSAlert is Copyright (C) 2011-2019 Philipp Mayerhofer.
12 LZ4 is Copyright (C) 2011-2019 Yann Collet.
16901690 Fix on vtype()/vtype2() to detect 'x' and make the coloration
16911691 red on newly-displayed traces. (Bug new from Dinotrace-like
16921692 rendering in 3.3.96.)
1693 3.3.98 27nov18 Removed pccts and vermin. Use xml2stems instead.
00 ##########################################################################
11
2 GTKWave 3.3.97 Wave Viewer is Copyright (C) 1999-2018 Tony Bybell.
3 Portions of GTKWave are Copyright (C) 1999-2018 Udi Finkelstein.
4 Context support is Copyright (C) 2007-2018 Kermin Elliott Fleming.
5 Trace group support is Copyright (C) 2009-2018 Donald Baltus.
6 GHW and additional GUI support is Copyright (C) 2005-2018 Tristan Gingold.
7 Analog support is Copyright (C) 2005-2018 Thomas Sailer.
8 External DnD support is Copyright (C) 2008-2018 Concept Engineering GmbH.
9 FastLZ is Copyright (C) 2005-2018 Ariya Hidayat.
10 LZ4 is Copyright (C) 2011-2018 Yann Collet.
2 GTKWave 3.3.98 Wave Viewer is Copyright (C) 1999-2019 Tony Bybell.
3 Portions of GTKWave are Copyright (C) 1999-2019 Udi Finkelstein.
4 Context support is Copyright (C) 2007-2019 Kermin Elliott Fleming.
5 Trace group support is Copyright (C) 2009-2019 Donald Baltus.
6 GHW and additional GUI support is Copyright (C) 2005-2019 Tristan Gingold.
7 Analog support is Copyright (C) 2005-2019 Thomas Sailer.
8 External DnD support is Copyright (C) 2008-2019 Concept Engineering GmbH.
9 FastLZ is Copyright (C) 2005-2019 Ariya Hidayat.
10 LZ4 is Copyright (C) 2011-2019 Yann Collet.
1111
1212 This program is free software; you can redistribute it and/or modify it
1313 under the terms of the GNU General Public License as published by the Free
2222 You should have received a copy of the GNU General Public License along
2323 with this program; if not, write to the Free Software Foundation, Inc., 51
2424 Franklin Street - Suite 500, Boston, MA 02110-1335, USA.
25
26 ##########################################################################
27
28 PCCTS 1.33MR is Copyright (C) 1989-2018 Terence Parr, Russell Quong,
29 Will Cohen, Hank Dietz, and Thomas Moog. It is in the public
30 domain. Please read contrib/pccts/RIGHTS for more information.
3125
3226 ##########################################################################
3327
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for gtkwave 3.3.97.
2 # Generated by GNU Autoconf 2.69 for gtkwave 3.3.98.
33 #
44 # Report bugs to <bybell@rocketmail.com>.
55 #
579579 # Identity of this package.
580580 PACKAGE_NAME='gtkwave'
581581 PACKAGE_TARNAME='gtkwave'
582 PACKAGE_VERSION='3.3.97'
583 PACKAGE_STRING='gtkwave 3.3.97'
582 PACKAGE_VERSION='3.3.98'
583 PACKAGE_STRING='gtkwave 3.3.98'
584584 PACKAGE_BUGREPORT='bybell@rocketmail.com'
585585 PACKAGE_URL=''
586586
14041404 # Omit some internal or obsolete options to make the list less imposing.
14051405 # This message is too long to be a string in the A/UX 3.1 sh.
14061406 cat <<_ACEOF
1407 \`configure' configures gtkwave 3.3.97 to adapt to many kinds of systems.
1407 \`configure' configures gtkwave 3.3.98 to adapt to many kinds of systems.
14081408
14091409 Usage: $0 [OPTION]... [VAR=VALUE]...
14101410
14701470
14711471 if test -n "$ac_init_help"; then
14721472 case $ac_init_help in
1473 short | recursive ) echo "Configuration of gtkwave 3.3.97:";;
1473 short | recursive ) echo "Configuration of gtkwave 3.3.98:";;
14741474 esac
14751475 cat <<\_ACEOF
14761476
16291629 test -n "$ac_init_help" && exit $ac_status
16301630 if $ac_init_version; then
16311631 cat <<\_ACEOF
1632 gtkwave configure 3.3.97
1632 gtkwave configure 3.3.98
16331633 generated by GNU Autoconf 2.69
16341634
16351635 Copyright (C) 2012 Free Software Foundation, Inc.
22732273 This file contains any messages produced by compilers while
22742274 running configure, to aid debugging if configure makes a mistake.
22752275
2276 It was created by gtkwave $as_me 3.3.97, which was
2276 It was created by gtkwave $as_me 3.3.98, which was
22772277 generated by GNU Autoconf 2.69. Invocation command line was
22782278
22792279 $ $0 $@
31403140
31413141 # Define the identity of the package.
31423142 PACKAGE='gtkwave'
3143 VERSION='3.3.97'
3143 VERSION='3.3.98'
31443144
31453145
31463146 cat >>confdefs.h <<_ACEOF
1082110821
1082210822
1082310823
10824 ac_config_files="$ac_config_files Makefile doc/Makefile contrib/Makefile contrib/pccts/IBM_VISUAL_AGE_PROJECTS/Makefile contrib/pccts/Makefile contrib/pccts/antlr/Makefile contrib/pccts/dlg/Makefile contrib/pccts/h/Makefile contrib/pccts/sorcerer/Makefile contrib/pccts/sorcerer/h/Makefile contrib/pccts/sorcerer/lib/Makefile contrib/pccts/sorcerer/test/Makefile contrib/pccts/sorcerer/test/test7/Makefile contrib/pccts/sorcerer/testcpp/Makefile contrib/pccts/support/DECmms/Makefile contrib/pccts/support/Makefile contrib/pccts/support/genmk/Makefile contrib/pccts/support/rexpr/Makefile contrib/pccts/support/set/Makefile contrib/pccts/support/sym/Makefile contrib/pccts/testcpp/Makefile contrib/rtlbrowse/Makefile contrib/vermin/Makefile contrib/xml2stems/Makefile contrib/bundle_for_osx/Makefile contrib/fst_jni/Makefile contrib/wlf2vcd/Makefile contrib/fsdb2vcd/Makefile examples/Makefile man/Makefile src/Makefile src/cocoa/Makefile src/helpers/Makefile src/liblzma/Makefile src/libbz2/Makefile src/libz/Makefile src/helpers/fst/Makefile share/Makefile share/mime/Makefile share/mime/packages/Makefile share/icons/Makefile share/icons/gnome/Makefile share/icons/gnome/16x16/Makefile share/icons/gnome/16x16/mimetypes/Makefile share/icons/gnome/32x32/Makefile share/icons/gnome/32x32/mimetypes/Makefile share/icons/gnome/48x48/Makefile share/icons/gnome/48x48/mimetypes/Makefile share/icons/hicolor/Makefile share/icons/hicolor/scalable/Makefile share/icons/hicolor/scalable/apps/Makefile share/applications/Makefile share/appdata/Makefile"
10824 ac_config_files="$ac_config_files Makefile doc/Makefile contrib/Makefile contrib/rtlbrowse/Makefile contrib/xml2stems/Makefile contrib/bundle_for_osx/Makefile contrib/fst_jni/Makefile contrib/wlf2vcd/Makefile contrib/fsdb2vcd/Makefile examples/Makefile man/Makefile src/Makefile src/cocoa/Makefile src/helpers/Makefile src/liblzma/Makefile src/libbz2/Makefile src/libz/Makefile src/helpers/fst/Makefile share/Makefile share/mime/Makefile share/mime/packages/Makefile share/icons/Makefile share/icons/gnome/Makefile share/icons/gnome/16x16/Makefile share/icons/gnome/16x16/mimetypes/Makefile share/icons/gnome/32x32/Makefile share/icons/gnome/32x32/mimetypes/Makefile share/icons/gnome/48x48/Makefile share/icons/gnome/48x48/mimetypes/Makefile share/icons/hicolor/Makefile share/icons/hicolor/scalable/Makefile share/icons/hicolor/scalable/apps/Makefile share/applications/Makefile share/appdata/Makefile"
1082510825
1082610826
1082710827
1149811498 # report actual input values of CONFIG_FILES etc. instead of their
1149911499 # values after options handling.
1150011500 ac_log="
11501 This file was extended by gtkwave $as_me 3.3.97, which was
11501 This file was extended by gtkwave $as_me 3.3.98, which was
1150211502 generated by GNU Autoconf 2.69. Invocation command line was
1150311503
1150411504 CONFIG_FILES = $CONFIG_FILES
1156411564 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1156511565 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1156611566 ac_cs_version="\\
11567 gtkwave config.status 3.3.97
11567 gtkwave config.status 3.3.98
1156811568 configured by $0, generated by GNU Autoconf 2.69,
1156911569 with options \\"\$ac_cs_config\\"
1157011570
1169811698 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
1169911699 "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
1170011700 "contrib/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/Makefile" ;;
11701 "contrib/pccts/IBM_VISUAL_AGE_PROJECTS/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/IBM_VISUAL_AGE_PROJECTS/Makefile" ;;
11702 "contrib/pccts/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/Makefile" ;;
11703 "contrib/pccts/antlr/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/antlr/Makefile" ;;
11704 "contrib/pccts/dlg/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/dlg/Makefile" ;;
11705 "contrib/pccts/h/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/h/Makefile" ;;
11706 "contrib/pccts/sorcerer/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/sorcerer/Makefile" ;;
11707 "contrib/pccts/sorcerer/h/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/sorcerer/h/Makefile" ;;
11708 "contrib/pccts/sorcerer/lib/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/sorcerer/lib/Makefile" ;;
11709 "contrib/pccts/sorcerer/test/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/sorcerer/test/Makefile" ;;
11710 "contrib/pccts/sorcerer/test/test7/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/sorcerer/test/test7/Makefile" ;;
11711 "contrib/pccts/sorcerer/testcpp/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/sorcerer/testcpp/Makefile" ;;
11712 "contrib/pccts/support/DECmms/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/support/DECmms/Makefile" ;;
11713 "contrib/pccts/support/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/support/Makefile" ;;
11714 "contrib/pccts/support/genmk/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/support/genmk/Makefile" ;;
11715 "contrib/pccts/support/rexpr/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/support/rexpr/Makefile" ;;
11716 "contrib/pccts/support/set/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/support/set/Makefile" ;;
11717 "contrib/pccts/support/sym/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/support/sym/Makefile" ;;
11718 "contrib/pccts/testcpp/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/pccts/testcpp/Makefile" ;;
1171911701 "contrib/rtlbrowse/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/rtlbrowse/Makefile" ;;
11720 "contrib/vermin/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/vermin/Makefile" ;;
1172111702 "contrib/xml2stems/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/xml2stems/Makefile" ;;
1172211703 "contrib/bundle_for_osx/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/bundle_for_osx/Makefile" ;;
1172311704 "contrib/fst_jni/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/fst_jni/Makefile" ;;
11 # Process this file with autoconf to produce a configure script.
22
33 AC_PREREQ(2.59)
4 AC_INIT(gtkwave, 3.3.97, bybell@rocketmail.com)
4 AC_INIT(gtkwave, 3.3.98, bybell@rocketmail.com)
55 AC_CONFIG_SRCDIR([src/vcd.c])
66 AM_INIT_AUTOMAKE
77 AC_CONFIG_HEADER([config.h])
905905 AC_CONFIG_FILES([Makefile
906906 doc/Makefile
907907 contrib/Makefile
908 contrib/pccts/IBM_VISUAL_AGE_PROJECTS/Makefile
909 contrib/pccts/Makefile
910 contrib/pccts/antlr/Makefile
911 contrib/pccts/dlg/Makefile
912 contrib/pccts/h/Makefile
913 contrib/pccts/sorcerer/Makefile
914 contrib/pccts/sorcerer/h/Makefile
915 contrib/pccts/sorcerer/lib/Makefile
916 contrib/pccts/sorcerer/test/Makefile
917 contrib/pccts/sorcerer/test/test7/Makefile
918 contrib/pccts/sorcerer/testcpp/Makefile
919 contrib/pccts/support/DECmms/Makefile
920 contrib/pccts/support/Makefile
921 contrib/pccts/support/genmk/Makefile
922 contrib/pccts/support/rexpr/Makefile
923 contrib/pccts/support/set/Makefile
924 contrib/pccts/support/sym/Makefile
925 contrib/pccts/testcpp/Makefile
926908 contrib/rtlbrowse/Makefile
927 contrib/vermin/Makefile
928909 contrib/xml2stems/Makefile
929910 contrib/bundle_for_osx/Makefile
930911 contrib/fst_jni/Makefile
00 ## -*- makefile
11 ##
22
3 SUBDIRS= pccts rtlbrowse vermin xml2stems bundle_for_osx fst_jni wlf2vcd fsdb2vcd
3 SUBDIRS= rtlbrowse xml2stems bundle_for_osx fst_jni wlf2vcd fsdb2vcd
325325 top_build_prefix = @top_build_prefix@
326326 top_builddir = @top_builddir@
327327 top_srcdir = @top_srcdir@
328 SUBDIRS = pccts rtlbrowse vermin xml2stems bundle_for_osx fst_jni wlf2vcd fsdb2vcd
328 SUBDIRS = rtlbrowse xml2stems bundle_for_osx fst_jni wlf2vcd fsdb2vcd
329329 all: all-recursive
330330
331331 .SUFFIXES:
77 <key>CFBundleExecutable</key>
88 <string>gtkwave</string>
99 <key>CFBundleGetInfoString</key>
10 <string>3.3.97, (C) 1999-2018 Tony Bybell http://gtkwave.sourceforge.net</string>
10 <string>3.3.98, (C) 1999-2019 Tony Bybell http://gtkwave.sourceforge.net</string>
1111 <key>CFBundleIconFile</key>
1212 <string>gtkwave.icns</string>
1313 <key>CFBundleIdentifier</key>
1717 <key>CFBundlePackageType</key>
1818 <string>APPL</string>
1919 <key>CFBundleShortVersionString</key>
20 <string>3.3.97</string>
20 <string>3.3.98</string>
2121 <key>CFBundleSignature</key>
2222 <string>????</string>
2323 <key>CFBundleVersion</key>
24 <string>3.3.97</string>
24 <string>3.3.98</string>
2525 <key>NSHumanReadableCopyright</key>
26 <string>Copyright 1999 - 2018 Tony Bybell, GNU General Public License.</string>
26 <string>Copyright 1999 - 2019 Tony Bybell, GNU General Public License.</string>
2727 <key>LSMinimumSystemVersion</key>
2828 <string>10.6</string>
2929
6666 <binary>${prefix}/bin/vztminer</binary>
6767 <binary>${prefix}/bin/fstminer</binary>
6868 <binary>${prefix}/bin/rtlbrowse</binary>
69 <binary>${prefix}/bin/vermin</binary>
7069 <binary>${prefix}/bin/xml2stems</binary>
7170
7271 <data dest="${bundle}/Contents/Resources/bin/gtkwave_bin_launcher.sh">
210209 <data dest="${bundle}/Contents/Resources/man/vcd2vzt.1">
211210 ${project}/../../man/vcd2vzt.1
212211 </data>
213 <data dest="${bundle}/Contents/Resources/man/vermin.1">
214 ${project}/../../man/vermin.1
215 </data>
216212 <data dest="${bundle}/Contents/Resources/man/vzt2vcd.1">
217213 ${project}/../../man/vzt2vcd.1
218214 </data>
+0
-522
contrib/pccts/CHANGES_FROM_131.txt less more
0 CHANGES FROM 1.31
1
2 This file contains the migration of PCCTS from 1.31 in the order that
3 changes were made. 1.32b7 is the last beta before full 1.32.
4 Terence Parr, Parr Research Corporation 1995.
5
6
7 ======================================================================
8 1.32b1
9 Added Russell Quong to banner, changed banner for output slightly
10 Fixed it so that you have before / after actions for C++ in class def
11 Fixed bug in optimizer that made it sometimes forget to set internal
12 token pointers. Only showed up when a {...} was in the "wrong spot".
13
14 ======================================================================
15 1.32b2
16 Added fixes by Dave Seidel for PC compilers in 32 bit mode (config.h
17 and set.h).
18
19 ======================================================================
20 1.32b3
21 Fixed hideous bug in code generator for wildcard and for ~token op.
22
23 from Dave Seidel
24
25 Added pcnames.bat
26 1. in antlr/main.c: change strcasecmp() to stricmp()
27
28 2. in dlg/output.c: use DLEXER_C instead on "DLexer.C"
29
30 3. in h/PBlackBox.h: use <iostream.h> instead of <stream.h>
31
32 ======================================================================
33 1.32b4
34 When the -ft option was used, any path prefix screwed up
35 the gate on the .h files
36
37 Fixed yet another bug due to the optimizer.
38
39 The exception handling thing was a bit wacko:
40
41 a : ( A B )? A B
42 | A C
43 ;
44 exception ...
45
46 caused an exception if "A C" was the input. In other words,
47 it found that A C didn't match the (A B)? pred and caused
48 an exception rather than trying the next alt. All I did
49 was to change the zzmatch_wsig() macros.
50
51 Fixed some problems in gen.c relating to the name of token
52 class bit sets in the output.
53
54 Added the tremendously cool generalized predicate. For the
55 moment, I'll give this bried description.
56
57 a : <<predicate>>? blah
58 | foo
59 ;
60
61 This implies that (assuming blah and foo are syntactically
62 ambiguous) "predicate" indicates the semantic validity of
63 applying "blah". If "predicate" is false, "foo" is attempted.
64
65 Previously, you had to say:
66
67 a : <<LA(1)==ID ? predicate : 1>>? ID
68 | ID
69 ;
70
71 Now, you can simply use "predicate" without the ?: operator
72 if you turn on ANTLR command line option: "-prc on". This
73 tells ANTLR to compute that all by itself. It computes n
74 tokens of lookahead where LT(n) or LATEXT(n) is the farthest
75 ahead you look.
76
77 If you give a predicate using "-prc on" that is followed
78 by a construct that can recognize more than one n-sequence,
79 you will get a warning from ANTLR. For example,
80
81 a : <<isTypeName(LT(1)->getText())>>? (ID|INT)
82 ;
83
84 This is wrong because the predicate will be applied to INTs
85 as well as ID's. You should use this syntax to make
86 the predicate more specific:
87
88 a : (ID)? => <<isTypeName(LT(1)->getText())>>? (ID|INT)
89 ;
90
91 which says "don't apply the predicate unless ID is the
92 current lookahead context".
93
94 You cannot currently have anything in the "(context)? =>"
95 except sequences such as:
96
97 ( LPAREN ID | LPAREN SCOPE )? => <<pred>>?
98
99 I haven't tested this THAT much, but it does work for the
100 C++ grammar.
101
102 ======================================================================
103 1.32b5
104
105 Added getLine() to the ANTLRTokenBase and DLGBasedToken classes
106 left line() for backward compatibility.
107 ----
108 Removed SORCERER_TRANSFORM from the ast.h stuff.
109 -------
110 Fixed bug in code gen of ANTLR such that nested syn preds work more
111 efficiently now. The ANTLRTokenBuffer was getting very large
112 with nested predicates.
113 ------
114 Memory leak is now gone from ANTLRTokenBuf; all tokens are deleted.
115 For backward compatibility reasons, you have to say parser->deleteTokens()
116 or mytokenbuffer->deleteTokens() but later it will be the default mode.
117 Say this after the parser is constructed. E.g.,
118
119 ParserBlackBox<DLGLexer, MyParser, ANTLRToken> p(stdin);
120 p.parser()->deleteTokens();
121 p.parser()->start_symbol();
122
123
124 ==============================
125 1.32b6
126
127 Changed so that deleteTokens() will do a delete ((ANTLRTokenBase *))
128 on the ptr. This gets the virtual destructor.
129
130 Fixed some weird things in the C++ header files (a few return types).
131
132 Made the AST routines correspond to the book and SORCERER stuff.
133
134 New token stuff: See testcpp/14/test.g
135
136 ANTLR accepts a #pragma gc_tokens which says
137 [1] Generate label = copy(LT(1)) instead of label=LT(1) for
138 all labeled token references.
139 [2] User now has to define ANTLRTokenPtr (as a class or a typedef
140 to just a pointer) as well as the ANTLRToken class itself.
141 See the example.
142
143 To delete tokens in token buffer, use deleteTokens() message on parser.
144
145 All tokens that fall off the ANTLRTokenBuffer get deleted
146 which is what currently happens when deleteTokens() message
147 has been sent to token buffer.
148
149 We always generate ANTLRTokenPtr instead of 'ANTLRToken *' now.
150 Then if no pragma set, ANTLR generates a
151
152 class ANTLRToken;
153 typedef ANTLRToken *ANTLRTokenPtr;
154
155 in each file.
156
157 Made a warning for x:rule_ref <<$x>>; still no warning for $i's, however.
158 class BB {
159
160 a : x:b y:A <<$x
161 $y>>
162 ;
163
164 b : B;
165
166 }
167 generates
168 Antlr parser generator Version 1.32b6 1989-1995
169 test.g, line 3: error: There are no token ptrs for rule references: '$x'
170
171 ===================
172 1.32b7:
173
174 [With respect to token object garbage collection (GC), 1.32b7
175 backtracks from 1.32b6, but results in better and less intrusive GC.
176 This is the last beta version before full 1.32.]
177
178 BIGGEST CHANGES:
179
180 o The "#pragma gc_tokens" is no longer used.
181
182 o .C files are now .cpp files (hence, makefiles will have to
183 be changed; or you can rerun genmk). This is a good move,
184 but causes some backward incompatibility problems. You can
185 avoid this by changing CPP_FILE_SUFFIX to ".C" in pccts/h/config.h.
186
187 o The token object class hierarchy has been flattened to include
188 only three classes: ANTLRAbstractToken, ANTLRCommonToken, and
189 ANTLRCommonNoRefCountToken. The common token now does garbage
190 collection via ref counting.
191
192 o "Smart" pointers are now used for garbage collection. That is,
193 ANTLRTokenPtr is used instead of "ANTLRToken *".
194
195 o The antlr.1 man page has been cleaned up slightly.
196
197 o The SUN C++ compiler now complains less about C++ support code.
198
199 o Grammars which subclass ANTLRCommonToken must wrap all token
200 pointer references in mytoken(token_ptr). This is the only
201 serious backward incompatibility. See below.
202
203
204 MINOR CHANGES:
205
206 --------------------------------------------------------
207 1 deleteTokens()
208
209 The deleteTokens() message to the parser or token buffer has been changed
210 to one of:
211
212 void noGarbageCollectTokens() { inputTokens->noGarbageCollectTokens(); }
213 void garbageCollectTokens() { inputTokens->garbageCollectTokens(); }
214
215 The token buffer deletes all non-referenced tokens by default now.
216
217 --------------------------------------------------------
218 2 makeToken()
219
220 The makeToken() message returns a new type. The function should look
221 like:
222
223 virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
224 ANTLRChar *txt,
225 int line)
226 {
227 ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);
228 t->setLine(line);
229 return t;
230 }
231
232 --------------------------------------------------------
233 3 TokenType
234
235 Changed TokenType-> ANTLRTokenType (often forces changes in AST defs due
236 to #[] constructor called to AST(tokentype, string)).
237
238 --------------------------------------------------------
239 4 AST()
240
241 You must define AST(ANTLRTokenPtr t) now in your AST class definition.
242 You might also have to include ATokPtr.h above the definition; e.g.,
243 if AST is defined in a separate file, such as AST.h, it's a good idea
244 to include ATOKPTR_H (ATokPtr.h). For example,
245
246 #include ATOKPTR_H
247 class AST : public ASTBase {
248 protected:
249 ANTLRTokenPtr token;
250 public:
251 AST(ANTLRTokenPtr t) { token = t; }
252 void preorder_action() {
253 char *s = token->getText();
254 printf(" %s", s);
255 }
256 };
257
258 Note the use of smart pointers rather than "ANTLRToken *".
259
260 --------------------------------------------------------
261 5 SUN C++
262
263 From robertb oakhill.sps.mot.com Bob Bailey. Changed ANTLR C++ output
264 to avoid an error in Sun C++ 3.0.1. Made "public" return value
265 structs created to hold multiple return values public.
266
267 --------------------------------------------------------
268 6 genmk
269
270 Fixed genmk so that target List.* is not included anymore. It's
271 called SList.* anyway.
272
273 --------------------------------------------------------
274 7 \r vs \n
275
276 Scott Vorthmann <vorth cmu.edu> fixed antlr.g in ANTLR so that \r
277 is allowed as the return character as well as \n.
278
279 --------------------------------------------------------
280 8 Exceptions
281
282 Bug in exceptions attached to labeled token/tokclass references. Didn't gen
283 code for exceptions. This didn't work:
284
285 a : "help" x:ID
286 ;
287 exception[x]
288 catch MismatchedToken : <<printf("eh?\n");>>
289
290 Now ANTLR generates (which is kinda big, but necessary):
291
292 if ( !_match_wsig(ID) ) {
293 if ( guessing ) goto fail;
294 _signal=MismatchedToken;
295 switch ( _signal ) {
296 case MismatchedToken :
297 printf("eh?\n");
298 _signal = NoSignal;
299 break;
300 default :
301 goto _handler;
302 }
303 }
304
305 which implies that you can recover and continue parsing after a missing/bad
306 token reference.
307
308 --------------------------------------------------------
309 9 genmk
310
311 genmk now correctly uses config file for CPP_FILE_SUFFIX stuff.
312
313 --------------------------------------------------------
314 10 general cleanup / PURIFY
315
316 Anthony Green <green vizbiz.com> suggested a bunch of good general
317 clean up things for the code; he also suggested a few things to
318 help out the "PURIFY" memory allocation checker.
319
320 --------------------------------------------------------
321 11 $-variable references.
322
323 Manuel ORNATO indicated that a $-variable outside of a rule caused
324 ANTLR to crash. I fixed this.
325
326 12 Tom Moog suggestion
327
328 Fail action of semantic predicate needs "{}" envelope. FIXED.
329
330 13 references to LT(1).
331
332 I have enclosed all assignments such as:
333
334 _t22 = (ANTLRTokenPtr)LT(1);
335
336 in "if ( !guessing )" so that during backtracking the reference count
337 for token objects is not increased.
338
339
340 TOKEN OBJECT GARBAGE COLLECTION
341
342 1 INTRODUCTION
343
344 The class ANTLRCommonToken is now garbaged collected through a "smart"
345 pointer called ANTLRTokenPtr using reference counting. Any token
346 object not referenced by your grammar actions is destroyed by the
347 ANTLRTokenBuffer when it must make room for more token objects.
348 Referenced tokens are then destroyed in your parser when local
349 ANTLRTokenPtr objects are deleted. For example,
350
351 a : label:ID ;
352
353 would be converted to something like:
354
355 void yourclass::a(void)
356 {
357 zzRULE;
358 ANTLRTokenPtr label=NULL; // used to be ANTLRToken *label;
359 zzmatch(ID);
360 label = (ANTLRTokenPtr)LT(1);
361 consume();
362 ...
363 }
364
365 When the "label" object is destroyed (it's just a pointer to your
366 input token object LT(1)), it decrements the reference count on the
367 object created for the ID. If the count goes to zero, the object
368 pointed by label is deleted.
369
370 To correctly manage the garbage collection, you should use
371 ANTLRTokenPtr instead of "ANTLRToken *". Most ANTLR support code
372 (visible to the user) has been modified to use the smart pointers.
373
374 ***************************************************************
375 Remember that any local objects that you create are not deleted when a
376 lonjmp() is executed. Unfortunately, the syntactic predicates (...)?
377 use setjmp()/longjmp(). There are some situations when a few tokens
378 will "leak".
379 ***************************************************************
380
381 2 DETAILS
382
383 o The default is to perform token object garbage collection.
384 You may use parser->noGarbageCollectTokens() to turn off
385 garbage collection.
386
387
388 o The type ANTLRTokenPtr is always defined now (automatically).
389 If you do not wish to use smart pointers, you will have to
390 redefined ANTLRTokenPtr by subclassing, changing the header
391 file or changing ANTLR's code generation (easy enough to
392 do in gen.c).
393
394 o If you don't use ParserBlackBox, the new initialization sequence is:
395
396 ANTLRTokenPtr aToken = new ANTLRToken;
397 scan.setToken(mytoken(aToken));
398
399 where mytoken(aToken) gets an ANTLRToken * from the smart pointer.
400
401 o Define C++ preprocessor symbol DBG_REFCOUNTTOKEN to see a bunch of
402 debugging stuff for reference counting if you suspect something.
403
404
405 3 WHY DO I HAVE TO TYPECAST ALL MY TOKEN POINTERS NOW??????
406
407 If you subclass ANTLRCommonToken and then attempt to refer to one of
408 your token members via a token pointer in your grammar actions, the
409 C++ compiler will complain that your token object does not have that
410 member. For example, if you used to do this
411
412 <<
413 class ANTLRToken : public ANTLRCommonToken {
414 int muck;
415 ...
416 };
417 >>
418
419 class Foo {
420 a : t:ID << t->muck = ...; >> ;
421 }
422
423 Now, you must do change the t->muck reference to:
424
425 a : t:ID << mytoken(t)->muck = ...; >> ;
426
427 in order to downcast 't' to be an "ANTLRToken *" not the
428 "ANTLRAbstractToken *" resulting from ANTLRTokenPtr::operator->().
429 The macro is defined as:
430
431 /*
432 * Since you cannot redefine operator->() to return one of the user's
433 * token object types, we must down cast. This is a drag. Here's
434 * a macro that helps. template: "mytoken(a-smart-ptr)->myfield".
435 */
436 #define mytoken(tp) ((ANTLRToken *)(tp.operator->()))
437
438 You have to use macro mytoken(grammar-label) now because smart
439 pointers are not specific to a parser's token objects. In other
440 words, the ANTLRTokenPtr class has a pointer to a generic
441 ANTLRAbstractToken not your ANTLRToken; the ANTLR support code must
442 use smart pointers too, but be able to work with any kind of
443 ANTLRToken. Sorry about this, but it's C++'s fault not mine. Some
444 nebulous future version of the C++ compilers should obviate the need
445 to downcast smart pointers with runtime type checking (and by allowing
446 different return type of overridden functions).
447
448 A way to have backward compatible code is to shut off the token object
449 garbage collection; i.e., use parser->noGarbageCollectTokens() and
450 change the definition of ANTLRTokenPtr (that's why you get source code
451 <wink>).
452
453
454 PARSER EXCEPTION HANDLING
455
456 I've noticed some weird stuff with the exception handling. I intend
457 to give this top priority for the "book release" of ANTLR.
458
459 ==========
460 1.32 Full Release
461
462 o Changed Token class hierarchy to be (Thanks to Tom Moog):
463
464 ANTLRAbstractToken
465 ANTLRRefCountToken
466 ANTLRCommonToken
467 ANTLRNoRefCountCommonToken
468
469 o Added virtual panic() to ANTLRAbstractToken. Made ANTLRParser::panic()
470 virtual also.
471
472 o Cleaned up the dup() stuff in AST hierarchy to use shallowCopy() to
473 make node copies. John Farr at Medtronic suggested this. I.e.,
474 if you want to use dup() with either ANTLR or SORCERER or -transform
475 mode with SORCERER, you must defined shallowCopy() as:
476
477 virtual PCCTS_AST *shallowCopy()
478 {
479 return new AST;
480 p->setDown(NULL);
481 p->setRight(NULL);
482 return p;
483 }
484
485 or
486
487 virtual PCCTS_AST *shallowCopy()
488 {
489 return new AST(*this);
490 }
491
492 if you have defined a copy constructor such as
493
494 AST(const AST &t) // shallow copy constructor
495 {
496 token = t.token;
497 iconst = t.iconst;
498 setDown(NULL);
499 setRight(NULL);
500 }
501
502 o Added a warning with -CC and -gk are used together. This is broken,
503 hence a warning is appropriate.
504
505 o Added warning when #-stuff is used w/o -gt option.
506
507 o Updated MPW installation.
508
509 o "Miller, Philip W." <MILLERPW f1groups.fsd.jhuapl.edu> suggested
510 that genmk be use RENAME_OBJ_FLAG RENAME_EXE_FLAG instead of
511 hardcoding "-o" in genmk.c.
512
513 o made all exit() calls use EXIT_SUCCESS or EXIT_FAILURE.
514
515 ===========================================================================
516 1.33
517
518 EXIT_FAILURE and EXIT_SUCCESS were not always defined. I had to modify
519 a bunch of files to use PCCTS_EXIT_XXX, which forces a new version. Sorry
520 about that.
521
+0
-2448
contrib/pccts/CHANGES_FROM_133.txt less more
0 =======================================================================
1 List of Implemented Fixes and Changes for Maintenance Releases of PCCTS
2 =======================================================================
3
4 DISCLAIMER
5
6 The software and these notes are provided "as is". They may include
7 typographical or technical errors and their authors disclaims all
8 liability of any kind or nature for damages due to error, fault,
9 defect, or deficiency regardless of cause. All warranties of any
10 kind, either express or implied, including, but not limited to, the
11 implied warranties of merchantability and fitness for a particular
12 purpose are disclaimed.
13
14
15 -------------------------------------------------------
16 Note: Items #153 to #1 are now in a separate file named
17 CHANGES_FROM_133_BEFORE_MR13.txt
18 -------------------------------------------------------
19
20 #312. (Changed in MR33) Bug caused by change #299.
21
22 In change #299 a warning message was suppressed when there was
23 no LT(1) in a semantic predicate and max(k,ck) was 1. The
24 changed caused the code which set a default predicate depth for
25 the semantic predicate to be left as 0 rather than set to 1.
26
27 This manifested as an error at line #1559 of mrhost.c
28
29 Reported by Peter Dulimov.
30
31 #311. (Changed in MR33) Added sorcer/lib to Makefile.
32
33 Reported by Dale Martin.
34
35 #310. (Changed in MR32) In C mode zzastPush was spelled zzastpush in one case.
36
37 Reported by Jean-Claude Durand
38
39 #309. (Changed in MR32) Renamed baseName because of VMS name conflict
40
41 Renamed baseName to pcctsBaseName to avoid library name conflict with
42 VMS library routine. Reported by Jean-François PIÉRONNE.
43
44 #308. (Changed in MR32) Used "template" as name of formal in C routine
45
46 In astlib.h routine ast_scan a formal was named "template". This caused
47 problems when the C code was compiled with a C++ compiler. Reported by
48 Sabyasachi Dey.
49
50 #307. (Changed in MR31) Compiler dependent bug in function prototype generation
51
52 The code which generated function prototypes contained a bug which
53 was compiler/optimization dependent. Under some circumstance an
54 extra character would be included in portions of a function prototype.
55
56 Reported by David Cook.
57
58 #306. (Changed in MR30) Validating predicate following a token
59
60 A validating predicate which immediately followed a token match
61 consumed the token after the predicate rather than before. Prior
62 to this fix (in the following example) isValidTimeScaleValue() in
63 the predicate would test the text for TIMESCALE rather than for
64 NUMBER:
65
66 time_scale :
67 TIMESCALE
68 <<isValidTimeScaleValue(LT(1)->getText())>>?
69 ts:NUMBER
70 ( us:MICROSECOND << tVal = ...>>
71 | ns:NANOSECOND << tVal = ... >>
72 )
73
74 Reported by Adalbert Perbandt.
75
76 #305. (Changed in MR30) Alternatives with guess blocks inside (...)* blocks.
77
78 In MR14 change #175 fixed a bug in the prediction expressions for guess
79 blocks which were of the form (alpha)? beta. Unfortunately, this
80 resulted in a new bug as exemplified by the example below, which computed
81 the first set for r as {B} rather than {B C}:
82
83 r : ( (A)? B
84 | C
85 )*
86
87 This example doesn't make any sense as A is not a prefix of B, but it
88 illustrates the problem. This bug did not appear for:
89
90 r : ( (A)?
91 | C
92 )*
93
94 because it does not use the (alpha)? beta form.
95
96 Item #175 fixed an asymmetry in ambiguity messages for the following
97 constructs which appear to have identical ambiguities (between repeating
98 the loop vs. exiting the loop). MR30 retains this fix, but the implementation
99 is slightly different.
100
101 r_star : ( (A B)? )* A ;
102 r_plus : ( (A B)? )+ A ;
103
104 Reported by Arpad Beszedes (beszedes inf.u-szeged.hu).
105
106 #304. (Changed in MR30) Crash when mismatch between output value counts.
107
108 For a rule such as:
109
110 r1 : r2>[i,j];
111 r2 >[int i, int j] : A;
112
113 If there were extra actuals for the reference to rule r2 from rule r1
114 there antlr would crash. This bug was introduced by change #276.
115
116 Reported by Sinan Karasu.
117
118 #303. (Changed in MR30) DLGLexerBase::replchar
119
120 DLGLexerBase::replchar and the C mode routine zzreplchar did not work
121 properly when the new character was 0.
122
123 Reported with fix by Philippe Laporte
124
125 #302. (Changed in MR28) Fix significant problems in initial release of MR27.
126
127 #301. (Changed in MR27) Default tab stops set to 2 spaces.
128
129 To have antlr generate true tabs rather than spaces, use "antlr -tab 0".
130 To generate 4 spaces per tab stop use "antlr -tab 4"
131
132 #300. (Changed in MR27)
133
134 Consider the following methods of constructing an AST from ID:
135
136 rule1!
137 : id:ID << #0 = #[id]; >> ;
138
139 rule2!
140 : id:ID << #0 = #id; >> ;
141
142 rule3
143 : ID ;
144
145 rule4
146 : id:ID << #0 = #id; >> ;
147
148 For rule_2, the AST corresponding to id would always be NULL. This
149 is because the user explicitly suppressed AST construction using the
150 "!" operator on the rule. In MR27 the use of an AST expression
151 such as #id overrides the "!" operator and forces construction of
152 the AST.
153
154 This fix does not apply to C mode ASTs when the ASTs are referenced
155 using numbers rather than symbols.
156
157 For C mode, this requires that the (optional) function/macro zzmk_ast
158 be defined. This functions copies information from an attribute into
159 a previously allocated AST.
160
161 Reported by Jan Langer (jan langernetz.de)
162
163 #299. (Changed in MR27) Don't warn if k=1 and semantic predicate missing LT(i)
164
165 If a semantic does not have a reference to LT(i) or (C mode LATEXT(i))
166 then pccts doesn't know how many lookahead tokens to use for context.
167 However, if max(k,ck) is 1 then there is really only one choice and
168 the warning is unnecessary.
169
170 #298. (Changed in MR27) Removed "register" for lastpos in dlgauto.c zzgettok
171
172 #297. (Changed in MR27) Incorrect prototypes when used with classic C
173
174 There were a number of errors in function headers when antlr was
175 built with compilers that do not have __STDC__ or __cplusplus set.
176
177 The functions which have variable length argument lists now use
178 PCCTS_USE_STDARG rather than __USE_PROTOTYPES__ to determine
179 whether to use stdargs or varargs.
180
181 #296. (Changed in MR27) Complex return types in rules.
182
183 The following return type was not properly handled when
184 unpacking a struct with containing multiple return values:
185
186 rule > [int i, IIR_Bool (IIR_Decl::*constraint)()] : ...
187
188 Instead of using "constraint", the program got lost and used
189 an empty string.
190
191 Reported by P.A. Wilsey.
192
193 #295. (Changed in MR27) Extra ";" following zzGUESS_DONE sometimes.
194
195 Certain constructs with guess blocks in MR23 led to extra ";"
196 preceding the "else" clause of an "if".
197
198 Reported by P.A. Wilsey.
199
200 #294. (Changed in MR27) Infinite loop in antlr for nested blocks
201
202 An oversight in detecting an empty alternative sometimes led
203 to an infinite loop in antlr when it encountered a rule with
204 nested blocks and guess blocks.
205
206 Reported by P.A. Wilsey.
207
208 #293. (Changed in MR27) Sorcerer optimization of _t->type()
209
210 Sorcerer generated code may contain many calls to _t->type() in a
211 single statement. This change introduces a temporary variable
212 to eliminate unnnecesary function calls.
213
214 Change implemented by Tom Molteno (tim videoscript.com).
215
216 #292. (Changed in MR27)
217
218 WARNING: Item #267 changes the signature of methods in the AST class.
219
220 **** Be sure to revise your AST functions of the same name ***
221
222 #291. (Changed in MR24)
223
224 Fix to serious code generation error in MR23 for (...)+ block.
225
226 #290. (Changed in MR23)
227
228 Item #247 describes a change in the way {...} blocks handled
229 an error. Consider:
230
231 r1 : {A} b ;
232 b : B;
233
234 with input "C".
235
236 Prior to change #247, the error would resemble "expected B -
237 found C". This is correct but incomplete, and therefore
238 misleading. In #247 it was changed to "expected A, B - found
239 C". This was fine, except for users of parser exception
240 handling because the exception was generated in the epilogue
241 for {...} block rather than in rule b. This made it difficult
242 for users of parser exception handling because B was not
243 expected in that context. Those not using parser exception
244 handling didn't notice the difference.
245
246 The current change restores the behavior prior to #247 when
247 parser exceptions are present, but retains the revised behavior
248 otherwise. This change should be visible only when exceptions
249 are in use and only for {...} blocks and sub-blocks of the form
250 (something|something | something | epsilon) where epsilon represents
251 an empty production and it is the last alternative of a sub-block.
252 In contrast, (something | epsilon | something) should generate the
253 same code as before, even when exceptions are used.
254
255 Reported by Philippe Laporte (philippe at transvirtual.com).
256
257 #289. (Changed in MR23) Bug in matching complement of a #tokclass
258
259 Prior to MR23 when a #tokclass was matched in both its complemented form
260 and uncomplemented form, the bit set generated for its first use was used
261 for both cases. However, the prediction expression was correctly computed
262 in both cases. This meant that the second case would never be matched
263 because, for the second appearance, the prediction expression and the
264 set to be matched would be complements of each other.
265
266 Consider:
267
268 #token A "a"
269 #token B "b"
270 #token C "c"
271 #tokclass AB {A B}
272
273 r1 : AB /* alt 1x */
274 | ~AB /* alt 1y */
275 ;
276
277 Prior to MR23, this resulted in alternative 1y being unreachable. Had it
278 been written:
279
280 r2 : ~AB /* alt 2x */
281 : AB /* alt 2y */
282
283 then alternative 2y would have become unreachable.
284
285 This bug was only for the case of complemented #tokclass. For complemented
286 #token the proper code was generated.
287
288 #288. (Changed in MR23) #errclass not restricted to choice points
289
290 The #errclass directive is supposed to allow a programmer to define
291 print strings which should appear in syntax error messages as a replacement
292 for some combinations of tokens. For instance:
293
294 #errclass Operator {PLUS MINUS TIMES DIVIDE}
295
296 If a syntax message includes all four of these tokens, and there is no
297 "better" choice of error class, the word "Operator" will be used rather
298 than a list of the four token names.
299
300 Prior to MR23 the #errclass definitions were used only at choice points
301 (which call the FAIL macro). In other cases where there was no choice
302 (e.g. where a single token or token class were matched) the #errclass
303 information was not used.
304
305 With MR23 the #errclass declarations are used for syntax error messages
306 when matching a #tokclass, a wildcard (i.e. "*"), or the complement of a
307 #token or #tokclass (e.g. ~Operator).
308
309 Please note that #errclass may now be defined using #tokclass names
310 (see Item #284).
311
312 Reported by Philip A. Wilsey.
313
314 #287. (Changed in MR23) Print name for #tokclass
315
316 Item #148 describes how to give a print name to a #token so that,for
317 example, #token ID could have the expression "identifier" in syntax
318 error messages. This has been extended to #tokclass:
319
320 #token ID("identifier") "[a-zA-Z]+"
321 #tokclass Primitive("primitive type")
322 {INT, FLOAT, CHAR, FLOAT, DOUBLE, BOOL}
323
324 This is really a cosmetic change, since #tokclass names do not appear
325 in any error messages.
326
327 #286. (Changed in MR23) Makefile change to use of cd
328
329 In cases where a pccts subdirectory name matched a directory identified
330 in a $CDPATH environment variable the build would fail. All makefile
331 cd commands have been changed from "cd xyz" to "cd ./xyz" in order
332 to avoid this problem.
333
334 #285. (Changed in MR23) Check for null pointers in some dlg structures
335
336 An invalid regular expression can cause dlg to build an invalid
337 structure to represent the regular expression even while it issues
338 error messages. Additional pointer checks were added.
339
340 Reported by Robert Sherry.
341
342 #284. (Changed in MR23) Allow #tokclass in #errclass definitions
343
344 Previously, a #tokclass reference in the definition of an
345 #errclass was not handled properly. Instead of being expanded
346 into the set of tokens represented by the #tokclass it was
347 treated somewhat like an #errclass. However, in a later phase
348 when all #errclass were expanded into the corresponding tokens
349 the #tokclass reference was not expanded (because it wasn't an
350 #errclass). In effect the reference was ignored.
351
352 This has been fixed.
353
354 Problem reported by Mike Dimmick (mike dimmick.demon.co.uk).
355
356 #283. (Changed in MR23) Option -tmake invoke's parser's tmake
357
358 When the string #(...) appears in an action antlr replaces it with
359 a call to ASTBase::tmake(...) to construct an AST. It is sometimes
360 useful to change the tmake routine so that it has access to information
361 in the parser - something which is not possible with a static method
362 in an application where they may be multiple parsers active.
363
364 The antlr option -tmake replaces the call to ASTBase::tmake with a call
365 to a user supplied tmake routine.
366
367 #282. (Changed in MR23) Initialization error for DBG_REFCOUNTTOKEN
368
369 When the pre-processor symbol DBG_REFCOUNTTOKEN is defined
370 incorrect code is generated to initialize ANTLRRefCountToken::ctor and
371 dtor.
372
373 Fix reported by Sven Kuehn (sven sevenkuehn.de).
374
375 #281. (Changed in MR23) Addition of -noctor option for Sorcerer
376
377 Added a -noctor option to suppress generation of the blank ctor
378 for users who wish to define their own ctor.
379
380 Contributed by Jan Langer (jan langernetz.de).
381
382 #280. (Changed in MR23) Syntax error message for EOF token
383
384 The EOF token now receives special treatment in syntax error messages
385 because there is no text matched by the eof token. The token name
386 of the eof token is used unless it is "@" - in which case the string
387 "<eof>" is used.
388
389 Problem reported by Erwin Achermann (erwin.achermann switzerland.org).
390
391 #279. (Changed in MR23) Exception groups
392
393 There was a bug in the way that exception groups were attached to
394 alternatives which caused problems when there was a block contained
395 in an alternative. For instance, in the following rule;
396
397 statement : IF S { ELSE S }
398 exception ....
399 ;
400
401 the exception would be attached to the {...} block instead of the
402 entire alternative because it was attached, in error, to the last
403 alternative instead of the last OPEN alternative.
404
405 Reported by Ty Mordane (tymordane hotmail.com).
406
407 #278. (Changed in MR23) makefile changes
408
409 Contributed by Tomasz Babczynski (faster lab05-7.ict.pwr.wroc.pl).
410
411 The -cfile option is not absolutely needed: when extension of
412 source file is one of the well-known C/C++ extensions it is
413 treated as C/C++ source
414
415 The gnu make defines the CXX variable as the default C++ compiler
416 name, so I added a line to copy this (if defined) to the CCC var.
417
418 Added a -sor option: after it any -class command defines the class
419 name for sorcerer, not for ANTLR. A file extended with .sor is
420 treated as sorcerer input. Because sorcerer can be called multiple
421 times, -sor option can be repeated. Any files and classes (one class
422 per group) after each -sor makes one tree parser.
423
424 Not implemented:
425
426 1. Generate dependences for user c/c++ files.
427 2. Support for -sor in c mode not.
428
429 I have left the old genmk program in the directory as genmk_old.c.
430
431 #277. (Changed in MR23) Change in macro for failed semantic predicates
432
433 In the past, a semantic predicate that failed generated a call to
434 the macro zzfailed_pred:
435
436 #ifndef zzfailed_pred
437 #define zzfailed_pred(_p) \
438 if (guessing) { \
439 zzGUESS_FAIL; \
440 } else { \
441 something(_p)
442 }
443 #endif
444
445 If a user wished to use the failed action option for semantic predicates:
446
447 rule : <<my_predicate>>? [my_fail_action] A
448 | ...
449
450
451 the code for my_fail_action would have to contain logic for handling
452 the guess part of the zzfailed_pred macro. The user should not have
453 to be aware of the guess logic in writing the fail action.
454
455 The zzfailed_pred has been rewritten to have three arguments:
456
457 arg 1: the stringized predicate of the semantic predicate
458 arg 2: 0 => there is no user-defined fail action
459 1 => there is a user-defined fail action
460 arg 3: the user-defined fail action (if defined)
461 otherwise a no-operation
462
463 The zzfailed_pred macro is now defined as:
464
465 #ifndef zzfailed_pred
466 #define zzfailed_pred(_p,_hasuseraction,_useraction) \
467 if (guessing) { \
468 zzGUESS_FAIL; \
469 } else { \
470 zzfailed_pred_action(_p,_hasuseraction,_useraction) \
471 }
472 #endif
473
474
475 With zzfailed_pred_action defined as:
476
477 #ifndef zzfailed_pred_action
478 #define zzfailed_pred_action(_p,_hasuseraction,_useraction) \
479 if (_hasUserAction) { _useraction } else { failedSemanticPredicate(_p); }
480 #endif
481
482 In C++ mode failedSemanticPredicate() is a virtual function.
483 In C mode the default action is a fprintf statement.
484
485 Suggested by Erwin Achermann (erwin.achermann switzerland.org).
486
487 #276. (Changed in MR23) Addition of return value initialization syntax
488
489 In an attempt to reduce the problems caused by the PURIFY macro I have
490 added new syntax for initializing the return value of rules and the
491 antlr option "-nopurify".
492
493 A rule with a single return argument:
494
495 r1 > [Foo f = expr] :
496
497 now generates code that resembles:
498
499 Foo r1(void) {
500 Foo _retv = expr;
501 ...
502 }
503
504 A rule with more than one return argument:
505
506 r2 > [Foo f = expr1, Bar b = expr2 ] :
507
508 generates code that resembles:
509
510 struct _rv1 {
511 Foo f;
512 Bar b;
513 }
514
515 _rv1 r2(void) {
516 struct _rv1 _retv;
517 _retv.f = expr1;
518 _retv.b = expr2;
519 ...
520 }
521
522 C++ style comments appearing in the initialization list may cause problems.
523
524 #275. (Changed in MR23) Addition of -nopurify option to antlr
525
526 A long time ago the PURIFY macro was introduced to initialize
527 return value arguments and get rid of annying messages from program
528 that checked for unitialized variables.
529
530 This has caused significant annoyance for C++ users that had
531 classes with virtual functions or non-trivial contructors because
532 it would zero the object, including the pointer to the virtual
533 function table. This could be defeated by redefining
534 the PURIFY macro to be empty, but it was a constant surprise to
535 new C++ users of pccts.
536
537 I would like to remove it, but I fear that some existing programs
538 depend on it and would break. My temporary solution is to add
539 an antlr option -nopurify which disables generation of the PURIFY
540 macro call.
541
542 The PURIFY macro should be avoided in favor of the new syntax
543 for initializing return arguments described in item #275.
544
545 To avoid name clash, the PURIFY macro has been renamed PCCTS_PURIFY.
546
547 #274. (Changed in MR23) DLexer.cpp renamed to DLexer.h
548 (Changed in MR23) ATokPtr.cpp renamed to ATokPtrImpl.h
549
550 These two files had .cpp extensions but acted like .h files because
551 there were included in other files. This caused problems for many IDE.
552 I have renamed them. The ATokPtrImpl.h was necessary because there was
553 already an ATokPtr.h.
554
555 #273. (Changed in MR23) Default win32 library changed to multi-threaded DLL
556
557 The model used for building the Win32 debug and release libraries has changed
558 to multi-threaded DLL.
559
560 To make this change in your MSVC 6 project:
561
562 Project -> Settings
563 Select the C++ tab in the right pane of the dialog box
564 Select "Category: Code Generation"
565 Under "Use run-time library" select one of the following:
566
567 Multi-threaded DLL
568 Debug Multi-threaded DLL
569
570 Suggested by Bill Menees (bill.menees gogallagher.com)
571
572 #272. (Changed in MR23) Failed semantic predicate reported via virtual function
573
574 In the past, a failed semantic predicated reported the problem via a
575 macro which used fprintf(). The macro now expands into a call on
576 the virtual function ANTLRParser::failedSemanticPredicate().
577
578 #271. (Changed in MR23) Warning for LT(i), LATEXT(i) in token match actions
579
580 An bug (or at least an oddity) is that a reference to LT(1), LA(1),
581 or LATEXT(1) in an action which immediately follows a token match
582 in a rule refers to the token matched, not the token which is in
583 the lookahead buffer. Consider:
584
585 r : abc <<action alpha>> D <<action beta>> E;
586
587 In this case LT(1) in action alpha will refer to the next token in
588 the lookahead buffer ("D"), but LT(1) in action beta will refer to
589 the token matched by D - the preceding token.
590
591 A warning has been added for users about this when an action
592 following a token match contains a reference to LT(1), LA(1), or LATEXT(1).
593
594 This behavior should be changed, but it appears in too many programs
595 now. Another problem, perhaps more significant, is that the obvious
596 fix (moving the consume() call to before the action) could change the
597 order in which input is requested and output appears in existing programs.
598
599 This problem was reported, along with a fix by Benjamin Mandel
600 (beny sd.co.il). However, I felt that changing the behavior was too
601 dangerous for existing code.
602
603 #270. (Changed in MR23) Removed static objects from PCCTSAST.cpp
604
605 There were some statically allocated objects in PCCTSAST.cpp
606 These were changed to non-static.
607
608 #269. (Changed in MR23) dlg output for initializing static array
609
610 The output from dlg contains a construct similar to the
611 following:
612
613 struct XXX {
614 static const int size;
615 static int array1[5];
616 };
617
618 const int XXX::size = 4;
619 int XXX::array1[size+1];
620
621
622 The problem is that although the expression "size+1" used in
623 the definition of array1 is equal to 5 (the expression used to
624 declare array), it is not considered equivalent by some compilers.
625
626 Reported with fix by Volker H. Simonis (simonis informatik.uni-tuebingen.de)
627
628 #268. (Changed in MR23) syn() routine output when k > 1
629
630 The syn() routine is supposed to print out the text of the
631 token causing the syntax error. It appears that it always
632 used the text from the first lookahead token rather than the
633 appropriate one. The appropriate one is computed by comparing
634 the token codes of lookahead token i (for i = 1 to k) with
635 the FIRST(i) set.
636
637 This has been corrected in ANTLRParser::syn().
638
639 Reported by Bill Menees (bill.menees gogallagher.com)
640
641 #267. (Changed in MR23) AST traversal functions client data argument
642
643 The AST traversal functions now take an extra (optional) parameter
644 which can point to client data:
645
646 preorder_action(void* pData = NULL)
647 preorder_before_action(void* pData = NULL)
648 preorder_after_action(void* pData = NULL)
649
650 **** Warning: this changes the AST signature. ***
651 **** Be sure to revise your AST functions of the same name ***
652
653 Bill Menees (bill.menees gogallagher.com)
654
655 #266. (Changed in MR23) virtual function printMessage()
656
657 Bill Menees (bill.menees gogallagher.com) has completed the
658 tedious taks of replacing all calls to fprintf() with calls
659 to the virtual function printMessage(). For classes which
660 have a pointer to the parser it forwards the printMessage()
661 call to the parser's printMessage() routine.
662
663 This should make it significanly easier to redirect pccts
664 error and warning messages.
665
666 #265. (Changed in MR23) Remove "labase++" in C++ mode
667
668 In C++ mode labase++ is called when a token is matched.
669 It appears that labase is not used in C++ mode at all, so
670 this code has been commented out.
671
672 #264. (Changed in MR23) Complete rewrite of ParserBlackBox.h
673
674 The parser black box (PBlackBox.h) was completely rewritten
675 by Chris Uzdavinis (chris atdesk.com) to improve its robustness.
676
677 #263. (Changed in MR23) -preamble and -preamble_first rescinded
678
679 Changes for item #253 have been rescinded.
680
681 #262. (Changed in MR23) Crash with -alpha option during traceback
682
683 Under some circumstances a -alpha traceback was started at the
684 "wrong" time. As a result, internal data structures were not
685 initialized.
686
687 Reported by Arpad Beszedes (beszedes inf.u-szeged.hu).
688
689 #261. (Changed in MR23) Defer token fetch for C++ mode
690
691 Item #216 has been revised to indicate that use of the defer fetch
692 option (ZZDEFER_FETCH) requires dlg option -i.
693
694 #260. (MR22) Raise default lex buffer size from 8,000 to 32,000 bytes.
695
696 ZZLEXBUFSIZE is the size (in bytes) of the buffer used by dlg
697 generated lexers. The default value has been raised to 32,000 and
698 the value used by antlr, dlg, and sorcerer has also been raised to
699 32,000.
700
701 #259. (MR22) Default function arguments in C++ mode.
702
703 If a rule is declared:
704
705 rr [int i = 0] : ....
706
707 then the declaration generated by pccts resembles:
708
709 void rr(int i = 0);
710
711 however, the definition must omit the default argument:
712
713 void rr(int i) {...}
714
715 In the past the default value was not omitted. In MR22
716 the generated code resembles:
717
718 void rr(int i /* = 0 */ ) {...}
719
720 Implemented by Volker H. Simonis (simonis informatik.uni-tuebingen.de)
721
722
723 Note: In MR23 this was changed so that nested C style comments
724 ("/* ... */") would not cause problems.
725
726 #258. (MR22) Using a base class for your parser
727
728 In item #102 (MR10) the class statement was extended to allow one
729 to specify a base class other than ANTLRParser for the generated
730 parser. It turned out that this was less than useful because
731 the constructor still specified ANTLRParser as the base class.
732
733 The class statement now uses the first identifier appearing after
734 the ":" as the name of the base class. For example:
735
736 class MyParser : public FooParser {
737
738 Generates in MyParser.h:
739
740 class MyParser : public FooParser {
741
742 Generates in MyParser.cpp something that resembles:
743
744 MyParser::MyParser(ANTLRTokenBuffer *input) :
745 FooParser(input,1,0,0,4)
746 {
747 token_tbl = _token_tbl;
748 traceOptionValueDefault=1; // MR10 turn trace ON
749 }
750
751 The base class constructor must have a signature similar to
752 that of ANTLRParser.
753
754 #257. (MR21a) Removed dlg statement that -i has no effect in C++ mode.
755
756 This was incorrect.
757
758 #256. (MR21a) Malformed syntax graph causes crash after error message.
759
760 In the past, certain kinds of errors in the very first grammar
761 element could cause the construction of a malformed graph
762 representing the grammar. This would eventually result in a
763 fatal internal error. The code has been changed to be more
764 resistant to this particular error.
765
766 #255. (MR21a) ParserBlackBox(FILE* f)
767
768 This constructor set openByBlackBox to the wrong value.
769
770 Reported by Kees Bakker (kees_bakker tasking.nl).
771
772 #254. (MR21a) Reporting syntax error at end-of-file
773
774 When there was a syntax error at the end-of-file the syntax
775 error routine would substitute "<eof>" for the programmer's
776 end-of-file symbol. This substitution is now done only when
777 the programmer does not define his own end-of-file symbol
778 or the symbol begins with the character "@".
779
780 Reported by Kees Bakker (kees_bakker tasking.nl).
781
782 #253. (MR21) Generation of block preamble (-preamble and -preamble_first)
783
784 *** This change was rescinded by item #263 ***
785
786 The antlr option -preamble causes antlr to insert the code
787 BLOCK_PREAMBLE at the start of each rule and block. It does
788 not insert code before rules references, token references, or
789 actions. By properly defining the macro BLOCK_PREAMBLE the
790 user can generate code which is specific to the start of blocks.
791
792 The antlr option -preamble_first is similar, but inserts the
793 code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol
794 PreambleFirst_123 is equivalent to the first set defined by
795 the #FirstSetSymbol described in Item #248.
796
797 I have not investigated how these options interact with guess
798 mode (syntactic predicates).
799
800 #252. (MR21) Check for null pointer in trace routine
801
802 When some trace options are used when the parser is generated
803 without the trace enabled, the current rule name may be a
804 NULL pointer. A guard was added to check for this in
805 restoreState.
806
807 Reported by Douglas E. Forester (dougf projtech.com).
808
809 #251. (MR21) Changes to #define zzTRACE_RULES
810
811 The macro zzTRACE_RULES was being use to pass information to
812 AParser.h. If this preprocessor symbol was not properly
813 set the first time AParser.h was #included, the declaration
814 of zzTRACEdata would be omitted (it is used by the -gd option).
815 Subsequent #includes of AParser.h would be skipped because of
816 the #ifdef guard, so the declaration of zzTracePrevRuleName would
817 never be made. The result was that proper compilation was very
818 order dependent.
819
820 The declaration of zzTRACEdata was made unconditional and the
821 problem of removing unused declarations will be left to optimizers.
822
823 Diagnosed by Douglas E. Forester (dougf projtech.com).
824
825 #250. (MR21) Option for EXPERIMENTAL change to error sets for blocks
826
827 The antlr option -mrblkerr turns on an experimental feature
828 which is supposed to provide more accurate syntax error messages
829 for k=1, ck=1 grammars. When used with k>1 or ck>1 grammars the
830 behavior should be no worse than the current behavior.
831
832 There is no problem with the matching of elements or the computation
833 of prediction expressions in pccts. The task is only one of listing
834 the most appropriate tokens in the error message. The error sets used
835 in pccts error messages are approximations of the exact error set when
836 optional elements in (...)* or (...)+ are involved. While entirely
837 correct, the error messages are sometimes not 100% accurate.
838
839 There is also a minor philosophical issue. For example, suppose the
840 grammar expects the token to be an optional A followed by Z, and it
841 is X. X, of course, is neither A nor Z, so an error message is appropriate.
842 Is it appropriate to say "Expected Z" ? It is correct, it is accurate,
843 but it is not complete.
844
845 When k>1 or ck>1 the problem of providing the exactly correct
846 list of tokens for the syntax error messages ends up becoming
847 equivalent to evaluating the prediction expression for the
848 alternatives twice. However, for k=1 ck=1 grammars the prediction
849 expression can be computed easily and evaluated cheaply, so I
850 decided to try implementing it to satisfy a particular application.
851 This application uses the error set in an interactive command language
852 to provide prompts which list the alternatives available at that
853 point in the parser. The user can then enter additional tokens to
854 complete the command line. To do this required more accurate error
855 sets then previously provided by pccts.
856
857 In some cases the default pccts behavior may lead to more robust error
858 recovery or clearer error messages then having the exact set of tokens.
859 This is because (a) features like -ge allow the use of symbolic names for
860 certain sets of tokens, so having extra tokens may simply obscure things
861 and (b) the error set is use to resynchronize the parser, so a good
862 choice is sometimes more important than having the exact set.
863
864 Consider the following example:
865
866 Note: All examples code has been abbreviated
867 to the absolute minimum in order to make the
868 examples concise.
869
870 star1 : (A)* Z;
871
872 The generated code resembles:
873
874 old new (with -mrblkerr)
875 --//----------- --------------------
876 for (;;) { for (;;) {
877 match(A); match(A);
878 } }
879 match(Z); if (! A and ! Z) then
880 FAIL(...{A,Z}...);
881 }
882 match(Z);
883
884
885 With input X
886 old message: Found X, expected Z
887 new message: Found X, expected A, Z
888
889 For the example:
890
891 star2 : (A|B)* Z;
892
893 old new (with -mrblkerr)
894 ------------- --------------------
895 for (;;) { for (;;) {
896 if (!A and !B) break; if (!A and !B) break;
897 if (...) { if (...) {
898 <same ...> <same ...>
899 } }
900 else { else {
901 FAIL(...{A,B,Z}...) FAIL(...{A,B}...);
902 } }
903 } }
904 match(B); if (! A and ! B and !Z) then
905 FAIL(...{A,B,Z}...);
906 }
907 match(B);
908
909 With input X
910 old message: Found X, expected Z
911 new message: Found X, expected A, B, Z
912 With input A X
913 old message: Found X, expected Z
914 new message: Found X, expected A, B, Z
915
916 This includes the choice of looping back to the
917 star block.
918
919 The code for plus blocks:
920
921 plus1 : (A)+ Z;
922
923 The generated code resembles:
924
925 old new (with -mrblkerr)
926 ------------- --------------------
927 do { do {
928 match(A); match(A);
929 } while (A) } while (A)
930 match(Z); if (! A and ! Z) then
931 FAIL(...{A,Z}...);
932 }
933 match(Z);
934
935 With input A X
936 old message: Found X, expected Z
937 new message: Found X, expected A, Z
938
939 This includes the choice of looping back to the
940 plus block.
941
942 For the example:
943
944 plus2 : (A|B)+ Z;
945
946 old new (with -mrblkerr)
947 ------------- --------------------
948 do { do {
949 if (A) { <same>
950 match(A); <same>
951 } else if (B) { <same>
952 match(B); <same>
953 } else { <same>
954 if (cnt > 1) break; <same>
955 FAIL(...{A,B,Z}...) FAIL(...{A,B}...);
956 } }
957 cnt++; <same>
958 } }
959
960 match(Z); if (! A and ! B and !Z) then
961 FAIL(...{A,B,Z}...);
962 }
963 match(B);
964
965 With input X
966 old message: Found X, expected A, B, Z
967 new message: Found X, expected A, B
968 With input A X
969 old message: Found X, expected Z
970 new message: Found X, expected A, B, Z
971
972 This includes the choice of looping back to the
973 star block.
974
975 #249. (MR21) Changes for DEC/VMS systems
976
977 Jean-François Piéronne (jfp altavista.net) has updated some
978 VMS related command files and fixed some minor problems related
979 to building pccts under the DEC/VMS operating system. For DEC/VMS
980 users the most important differences are:
981
982 a. Revised makefile.vms
983 b. Revised genMMS for genrating VMS style makefiles.
984
985 #248. (MR21) Generate symbol for first set of an alternative
986
987 pccts can generate a symbol which represents the tokens which may
988 appear at the start of a block:
989
990 rr : #FirstSetSymbol(rr_FirstSet) ( Foo | Bar ) ;
991
992 This will generate the symbol rr_FirstSet of type SetWordType with
993 elements Foo and Bar set. The bits can be tested using code similar
994 to the following:
995
996 if (set_el(Foo, &rr_FirstSet)) { ...
997
998 This can be combined with the C array zztokens[] or the C++ routine
999 tokenName() to get the print name of the token in the first set.
1000
1001 The size of the set is given by the newly added enum SET_SIZE, a
1002 protected member of the generated parser's class. The number of
1003 elements in the generated set will not be exactly equal to the
1004 value of SET_SIZE because of synthetic tokens created by #tokclass,
1005 #errclass, the -ge option, and meta-tokens such as epsilon, and
1006 end-of-file.
1007
1008 The #FirstSetSymbol must appear immediately before a block
1009 such as (...)+, (...)*, and {...}, and (...). It may not appear
1010 immediately before a token, a rule reference, or action. However
1011 a token or rule reference can be enclosed in a (...) in order to
1012 make the use of #pragma FirstSetSymbol legal.
1013
1014 rr_bad : #FirstSetSymbol(rr_bad_FirstSet) Foo; // Illegal
1015
1016 rr_ok : #FirstSetSymbol(rr_ok_FirstSet) (Foo); // Legal
1017
1018 Do not confuse FirstSetSymbol sets with the sets used for testing
1019 lookahead. The sets used for FirstSetSymbol have one element per bit,
1020 so the number of bytes is approximately the largest token number
1021 divided by 8. The sets used for testing lookahead store 8 lookahead
1022 sets per byte, so the length of the array is approximately the largest
1023 token number.
1024
1025 If there is demand, a similar routine for follow sets can be added.
1026
1027 #247. (MR21) Misleading error message on syntax error for optional elements.
1028
1029 ===================================================
1030 The behavior has been revised when parser exception
1031 handling is used. See Item #290
1032 ===================================================
1033
1034 Prior to MR21, tokens which were optional did not appear in syntax
1035 error messages if the block which immediately followed detected a
1036 syntax error.
1037
1038 Consider the following grammar which accepts Number, Word, and Other:
1039
1040 rr : {Number} Word;
1041
1042 For this rule the code resembles:
1043
1044 if (LA(1) == Number) {
1045 match(Number);
1046 consume();
1047 }
1048 match(Word);
1049
1050 Prior to MR21, the error message for input "$ a" would be:
1051
1052 line 1: syntax error at "$" missing Word
1053
1054 With MR21 the message will be:
1055
1056 line 1: syntax error at "$" expecting Word, Number.
1057
1058 The generate code resembles:
1059
1060 if ( (LA(1)==Number) ) {
1061 zzmatch(Number);
1062 consume();
1063 }
1064 else {
1065 if ( (LA(1)==Word) ) {
1066 /* nothing */
1067 }
1068 else {
1069 FAIL(... message for both Number and Word ...);
1070 }
1071 }
1072 match(Word);
1073
1074 The code generated for optional blocks in MR21 is slightly longer
1075 than the previous versions, but it should give better error messages.
1076
1077 The code generated for:
1078
1079 { a | b | c }
1080
1081 should now be *identical* to:
1082
1083 ( a | b | c | )
1084
1085 which was not the case prior to MR21.
1086
1087 Reported by Sue Marvin (sue siara.com).
1088
1089 #246. (Changed in MR21) Use of $(MAKE) for calls to make
1090
1091 Calls to make from the makefiles were replaced with $(MAKE)
1092 because of problems when using gmake.
1093
1094 Reported with fix by Sunil K.Vallamkonda (sunil siara.com).
1095
1096 #245. (Changed in MR21) Changes to genmk
1097
1098 The following command line options have been added to genmk:
1099
1100 -cfiles ...
1101
1102 To add a user's C or C++ files into makefile automatically.
1103 The list of files must be enclosed in apostrophes. This
1104 option may be specified multiple times.
1105
1106 -compiler ...
1107
1108 The name of the compiler to use for $(CCC) or $(CC). The
1109 default in C++ mode is "CC". The default in C mode is "cc".
1110
1111 -pccts_path ...
1112
1113 The value for $(PCCTS), the pccts directory. The default
1114 is /usr/local/pccts.
1115
1116 Contributed by Tomasz Babczynski (t.babczynski ict.pwr.wroc.pl).
1117
1118 #244. (Changed in MR21) Rename variable "not" in antlr.g
1119
1120 When antlr.g is compiled with a C++ compiler, a variable named
1121 "not" causes problems. Reported by Sinan Karasu
1122 (sinan.karasu boeing.com).
1123
1124 #243 (Changed in MR21) Replace recursion with iteration in zzfree_ast
1125
1126 Another refinement to zzfree_ast in ast.c to limit recursion.
1127
1128 NAKAJIMA Mutsuki (muc isr.co.jp).
1129
1130
1131 #242. (Changed in MR21) LineInfoFormatStr
1132
1133 Added an #ifndef/#endif around LineInfoFormatStr in pcctscfg.h.
1134
1135 #241. (Changed in MR21) Changed macro PURIFY to a no-op
1136
1137 ***********************
1138 *** NOT IMPLEMENTED ***
1139 ***********************
1140
1141 The PURIFY macro was changed to a no-op because it was causing
1142 problems when passing C++ objects.
1143
1144 The old definition:
1145
1146 #define PURIFY(r,s) memset((char *) &(r),'\\0',(s));
1147
1148 The new definition:
1149
1150 #define PURIFY(r,s) /* nothing */
1151 #endif
1152
1153 #240. (Changed in MR21) sorcerer/h/sorcerer.h _MATCH and _MATCHRANGE
1154
1155 Added test for NULL token pointer.
1156
1157 Suggested by Peter Keller (keller ebi.ac.uk)
1158
1159 #239. (Changed in MR21) C++ mode AParser::traceGuessFail
1160
1161 If tracing is turned on when the code has been generated
1162 without trace code, a failed guess generates a trace report
1163 even though there are no other trace reports. This
1164 make the behavior consistent with other parts of the
1165 trace system.
1166
1167 Reported by David Wigg (wiggjd sbu.ac.uk).
1168
1169 #238. (Changed in MR21) Namespace version #include files
1170
1171 Changed reference from CStdio to cstdio (and other
1172 #include file names) in the namespace version of pccts.
1173 Should have known better.
1174
1175 #237. (Changed in MR21) ParserBlackBox(FILE*)
1176
1177 In the past, ParserBlackBox would close the FILE in the dtor
1178 even though it was not opened by ParserBlackBox. The problem
1179 is that there were two constructors, one which accepted a file
1180 name and did an fopen, the other which accepted a FILE and did
1181 not do an fopen. There is now an extra member variable which
1182 remembers whether ParserBlackBox did the open or not.
1183
1184 Suggested by Mike Percy (mpercy scires.com).
1185
1186 #236. (Changed in MR21) tmake now reports down pointer problem
1187
1188 When ASTBase::tmake attempts to update the down pointer of
1189 an AST it checks to see if the down pointer is NULL. If it
1190 is not NULL it does not do the update and returns NULL.
1191 An attempt to update the down pointer is almost always a
1192 result of a user error. This can lead to difficult to find
1193 problems during tree construction.
1194
1195 With this change, the routine calls a virtual function
1196 reportOverwriteOfDownPointer() which calls panic to
1197 report the problem. Users who want the old behavior can
1198 redefined the virtual function in their AST class.
1199
1200 Suggested by Sinan Karasu (sinan.karasu boeing.com)
1201
1202 #235. (Changed in MR21) Made ANTLRParser::resynch() virtual
1203
1204 Suggested by Jerry Evans (jerry swsl.co.uk).
1205
1206 #234. (Changed in MR21) Implicit int for function return value
1207
1208 ATokenBuffer:bufferSize() did not specify a type for the
1209 return value.
1210
1211 Reported by Hai Vo-Ba (hai fc.hp.com).
1212
1213 #233. (Changed in MR20) Converted to MSVC 6.0
1214
1215 Due to external circumstances I have had to convert to MSVC 6.0
1216 The MSVC 5.0 project files (.dsw and .dsp) have been retained as
1217 xxx50.dsp and xxx50.dsw. The MSVC 6.0 files are named xxx60.dsp
1218 and xxx60.dsw (where xxx is the related to the directory/project).
1219
1220 #232. (Changed in MR20) Make setwd bit vectors protected in parser.h
1221
1222 The access for the setwd array in the parser header was not
1223 specified. As a result, it would depend on the code which
1224 preceded it. In MR20 it will always have access "protected".
1225
1226 Reported by Piotr Eljasiak (eljasiak zt.gdansk.tpsa.pl).
1227
1228 #231. (Changed in MR20) Error in token buffer debug code.
1229
1230 When token buffer debugging is selected via the pre-processor
1231 symbol DEBUG_TOKENBUFFER there is an erroneous check in
1232 AParser.cpp:
1233
1234 #ifdef DEBUG_TOKENBUFFER
1235 if (i >= inputTokens->bufferSize() ||
1236 inputTokens->minTokens() < LLk ) /* MR20 Was "<=" */
1237 ...
1238 #endif
1239
1240 Reported by David Wigg (wiggjd sbu.ac.uk).
1241
1242 #230. (Changed in MR20) Fixed problem with #define for -gd option
1243
1244 There was an error in setting zzTRACE_RULES for the -gd (trace) option.
1245
1246 Reported by Gary Funck (gary intrepid.com).
1247
1248 #229. (Changed in MR20) Additional "const" for literals
1249
1250 "const" was added to the token name literal table.
1251 "const" was added to some panic() and similar routine
1252
1253 #228. (Changed in MR20) dlg crashes on "()"
1254
1255 The following token defintion will cause DLG to crash.
1256
1257 #token "()"
1258
1259 When there is a syntax error in a regular expression
1260 many of the dlg routines return a structure which has
1261 null pointers. When this is accessed by callers it
1262 generates the crash.
1263
1264 I have attempted to fix the more common cases.
1265
1266 Reported by Mengue Olivier (dolmen bigfoot.com).
1267
1268 #227. (Changed in MR20) Array overwrite
1269
1270 Steveh Hand (sassth unx.sas.com) reported a problem which
1271 was traced to a temporary array which was not properly
1272 resized for deeply nested blocks. This has been fixed.
1273
1274 #226. (Changed in MR20) -pedantic conformance
1275
1276 G. Hobbelt (i_a mbh.org) and THM made many, many minor
1277 changes to create prototypes for all the functions and
1278 bring antlr, dlg, and sorcerer into conformance with
1279 the gcc -pedantic option.
1280
1281 This may require uses to add pccts/h/pcctscfg.h to some
1282 files or makefiles in order to have __USE_PROTOS defined.
1283
1284 #225 (Changed in MR20) AST stack adjustment in C mode
1285
1286 The fix in #214 for AST stack adjustment in C mode missed
1287 some cases.
1288
1289 Reported with fix by Ger Hobbelt (i_a mbh.org).
1290
1291 #224 (Changed in MR20) LL(1) and LL(2) with #pragma approx
1292
1293 This may take a record for the oldest, most trival, lexical
1294 error in pccts. The regular expressions for LL(1) and LL(2)
1295 lacked an escape for the left and right parenthesis.
1296
1297 Reported by Ger Hobbelt (i_a mbh.org).
1298
1299 #223 (Changed in MR20) Addition of IBM_VISUAL_AGE directory
1300
1301 Build files for antlr, dlg, and sorcerer under IBM Visual Age
1302 have been contributed by Anton Sergeev (ags mlc.ru). They have
1303 been placed in the pccts/IBM_VISUAL_AGE directory.
1304
1305 #222 (Changed in MR20) Replace __STDC__ with __USE_PROTOS
1306
1307 Most occurrences of __STDC__ replaced with __USE_PROTOS due to
1308 complaints from several users.
1309
1310 #221 (Changed in MR20) Added #include for DLexerBase.h to PBlackBox.
1311
1312 Added #include for DLexerBase.h to PBlackBox.
1313
1314 #220 (Changed in MR19) strcat arguments reversed in #pred parse
1315
1316 The arguments to strcat are reversed when creating a print
1317 name for a hash table entry for use with #pred feature.
1318
1319 Problem diagnosed and fix reported by Scott Harrington
1320 (seh4 ix.netcom.com).
1321
1322 #219. (Changed in MR19) C Mode routine zzfree_ast
1323
1324 Changes to reduce use of recursion for AST trees with only right
1325 links or only left links in the C mode routine zzfree_ast.
1326
1327 Implemented by SAKAI Kiyotaka (ksakai isr.co.jp).
1328
1329 #218. (Changed in MR19) Changes to support unsigned char in C mode
1330
1331 Changes to antlr.h and err.h to fix omissions in use of zzchar_t
1332
1333 Implemented by SAKAI Kiyotaka (ksakai isr.co.jp).
1334
1335 #217. (Changed in MR19) Error message when dlg -i and -CC options selected
1336
1337 *** This change was rescinded by item #257 ***
1338
1339 The parsers generated by pccts in C++ mode are not able to support the
1340 interactive lexer option (except, perhaps, when using the deferred fetch
1341 parser option.(Item #216).
1342
1343 DLG now warns when both -i and -CC are selected.
1344
1345 This warning was suggested by David Venditti (07751870267-0001 t-online.de).
1346
1347 #216. (Changed in MR19) Defer token fetch for C++ mode
1348
1349 Implemented by Volker H. Simonis (simonis informatik.uni-tuebingen.de)
1350
1351 Normally, pccts keeps the lookahead token buffer completely filled.
1352 This requires max(k,ck) tokens of lookahead. For some applications
1353 this can cause deadlock problems. For example, there may be cases
1354 when the parser can't tell when the input has been completely consumed
1355 until the parse is complete, but the parse can't be completed because
1356 the input routines are waiting for additional tokens to fill the
1357 lookahead buffer.
1358
1359 When the ANTLRParser class is built with the pre-processor option
1360 ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred
1361 until LA(i) or LT(i) is called.
1362
1363 To test whether this option has been built into the ANTLRParser class
1364 use "isDeferFetchEnabled()".
1365
1366 Using the -gd trace option with the default tracein() and traceout()
1367 routines will defeat the effort to defer the fetch because the
1368 trace routines print out information about the lookahead token at
1369 the start of the rule.
1370
1371 Because the tracein and traceout routines are virtual it is
1372 easy to redefine them in your parser:
1373
1374 class MyParser {
1375 <<
1376 virtual void tracein(ANTLRChar * ruleName)
1377 { fprintf(stderr,"Entering: %s\n", ruleName); }
1378 virtual void traceout(ANTLRChar * ruleName)
1379 { fprintf(stderr,"Leaving: %s\n", ruleName); }
1380 >>
1381
1382 The originals for those routines are pccts/h/AParser.cpp
1383
1384 This requires use of the dlg option -i (interactive lexer).
1385
1386 This is implemented only for C++ mode.
1387
1388 This is experimental. The interaction with guess mode (syntactic
1389 predicates)is not known.
1390
1391 #215. (Changed in MR19) Addition of reset() to DLGLexerBase
1392
1393 There was no obvious way to reset the lexer for reuse. The
1394 reset() method now does this.
1395
1396 Suggested by David Venditti (07751870267-0001 t-online.de).
1397
1398 #214. (Changed in MR19) C mode: Adjust AST stack pointer at exit
1399
1400 In C mode the AST stack pointer needs to be reset if there will
1401 be multiple calls to the ANTLRx macros.
1402
1403 Reported with fix by Paul D. Smith (psmith baynetworks.com).
1404
1405 #213. (Changed in MR18) Fatal error with -mrhoistk (k>1 hoisting)
1406
1407 When rearranging code I forgot to un-comment a critical line of
1408 code that handles hoisting of predicates with k>1 lookahead. This
1409 is now fixed.
1410
1411 Reported by Reinier van den Born (reinier vnet.ibm.com).
1412
1413 #212. (Changed in MR17) Mac related changes by Kenji Tanaka
1414
1415 Kenji Tanaka (kentar osa.att.ne.jp) has made a number of changes for
1416 Macintosh users.
1417
1418 a. The following Macintosh MPW files aid in installing pccts on Mac:
1419
1420 pccts/MPW_Read_Me
1421
1422 pccts/install68K.mpw
1423 pccts/installPPC.mpw
1424
1425 pccts/antlr/antlr.r
1426 pccts/antlr/antlr68K.make
1427 pccts/antlr/antlrPPC.make
1428
1429 pccts/dlg/dlg.r
1430 pccts/dlg/dlg68K.make
1431 pccts/dlg/dlgPPC.make
1432
1433 pccts/sorcerer/sor.r
1434 pccts/sorcerer/sor68K.make
1435 pccts/sorcerer/sorPPC.make
1436
1437 They completely replace the previous Mac installation files.
1438
1439 b. The most significant is a change in the MAC_FILE_CREATOR symbol
1440 in pcctscfg.h:
1441
1442 old: #define MAC_FILE_CREATOR 'MMCC' /* Metrowerks C/C++ Text files */
1443 new: #define MAC_FILE_CREATOR 'CWIE' /* Metrowerks C/C++ Text files */
1444
1445 c. Added calls to special_fopen_actions() where necessary.
1446
1447 #211. (Changed in MR16a) C++ style comment in dlg
1448
1449 This has been fixed.
1450
1451 #210. (Changed in MR16a) Sor accepts \r\n, \r, or \n for end-of-line
1452
1453 A user requested that Sorcerer be changed to accept other forms
1454 of end-of-line.
1455
1456 #209. (Changed in MR16) Name of files changed.
1457
1458 Old: CHANGES_FROM_1.33
1459 New: CHANGES_FROM_133.txt
1460
1461 Old: KNOWN_PROBLEMS
1462 New: KNOWN_PROBLEMS.txt
1463
1464 #208. (Changed in MR16) Change in use of pccts #include files
1465
1466 There were problems with MS DevStudio when mixing Sorcerer and
1467 PCCTS in the same source file. The problem is caused by the
1468 redefinition of setjmp in the MS header file setjmp.h. In
1469 setjmp.h the pre-processor symbol setjmp was redefined to be
1470 _setjmp. A later effort to execute #include <setjmp.h> resulted
1471 in an effort to #include <_setjmp.h>. I'm not sure whether this
1472 is a bug or a feature. In any case, I decided to fix it by
1473 avoiding the use of pre-processor symbols in #include statements
1474 altogether. This has the added benefit of making pre-compiled
1475 headers work again.
1476
1477 I've replaced statements:
1478
1479 old: #include PCCTS_SETJMP_H
1480 new: #include "pccts_setjmp.h"
1481
1482 Where pccts_setjmp.h contains:
1483
1484 #ifndef __PCCTS_SETJMP_H__
1485 #define __PCCTS_SETJMP_H__
1486
1487 #ifdef PCCTS_USE_NAMESPACE_STD
1488 #include <Csetjmp>
1489 #else
1490 #include <setjmp.h>
1491 #endif
1492
1493 #endif
1494
1495 A similar change has been made for other standard header files
1496 required by pccts and sorcerer: stdlib.h, stdarg.h, stdio.h, etc.
1497
1498 Reported by Jeff Vincent (JVincent novell.com) and Dale Davis
1499 (DalDavis spectrace.com).
1500
1501 #207. (Changed in MR16) dlg reports an invalid range for: [\0x00-\0xff]
1502
1503 -----------------------------------------------------------------
1504 Note from MR23: This fix does not work. I am investigating why.
1505 -----------------------------------------------------------------
1506
1507 dlg will report that this is an invalid range.
1508
1509 Diagnosed by Piotr Eljasiak (eljasiak no-spam.zt.gdansk.tpsa.pl):
1510
1511 I think this problem is not specific to unsigned chars
1512 because dlg reports no error for the range [\0x00-\0xfe].
1513
1514 I've found that information on range is kept in field
1515 letter (unsigned char) of Attrib struct. Unfortunately
1516 the letter value internally is for some reasons increased
1517 by 1, so \0xff is represented here as 0.
1518
1519 That's why dlg complains about the range [\0x00-\0xff] in
1520 dlg_p.g:
1521
1522 if ($$.letter > $2.letter) {
1523 error("invalid range ", zzline);
1524 }
1525
1526 The fix is:
1527
1528 if ($$.letter > $2.letter && 255 != $$2.letter) {
1529 error("invalid range ", zzline);
1530 }
1531
1532 #206. (Changed in MR16) Free zzFAILtext in ANTLRParser destructor
1533
1534 The ANTLRParser destructor now frees zzFAILtext.
1535
1536 Problem and fix reported by Manfred Kogler (km cast.uni-linz.ac.at).
1537
1538 #205. (Changed in MR16) DLGStringReset argument now const
1539
1540 Changed: void DLGStringReset(DLGChar *s) {...}
1541 To: void DLGStringReset(const DLGChar *s) {...}
1542
1543 Suggested by Dale Davis (daldavis spectrace.com)
1544
1545 #204. (Changed in MR15a) Change __WATCOM__ to __WATCOMC__ in pcctscfg.h
1546
1547 Reported by Oleg Dashevskii (olegdash my-dejanews.com).
1548
1549 #203. (Changed in MR15) Addition of sorcerer to distribution kit
1550
1551 I have finally caved in to popular demand. The pccts 1.33mr15
1552 kit will include sorcerer. The separate sorcerer kit will be
1553 discontinued.
1554
1555 #202. (Changed) in MR15) Organization of MS Dev Studio Projects in Kit
1556
1557 Previously there was one workspace that contained projects for
1558 all three parts of pccts: antlr, dlg, and sorcerer. Now each
1559 part (and directory) has its own workspace/project and there
1560 is an additional workspace/project to build a library from the
1561 .cpp files in the pccts/h directory.
1562
1563 The library build will create pccts_debug.lib or pccts_release.lib
1564 according to the configuration selected.
1565
1566 If you don't want to build pccts 1.33MR15 you can download a
1567 ready-to-run kit for win32 from http://www.polhode.com/win32.zip.
1568 The ready-to-run for win32 includes executables, a pre-built static
1569 library for the .cpp files in the pccts/h directory, and a sample
1570 application
1571
1572 You will need to define the environment variable PCCTS to point to
1573 the root of the pccts directory hierarchy.
1574
1575 #201. (Changed in MR15) Several fixes by K.J. Cummings (cummings peritus.com)
1576
1577 Generation of SETJMP rather than SETJMP_H in gen.c.
1578
1579 (Sor B19) Declaration of ref_vars_inits for ref_var_inits in
1580 pccts/sorcerer/sorcerer.h.
1581
1582 #200. (Changed in MR15) Remove operator=() in AToken.h
1583
1584 User reported that WatCom couldn't handle use of
1585 explicit operator =(). Replace with equivalent
1586 using cast operator.
1587
1588 #199. (Changed in MR15) Don't allow use of empty #tokclass
1589
1590 Change antlr.g to disallow empty #tokclass sets.
1591
1592 Reported by Manfred Kogler (km cast.uni-linz.ac.at).
1593
1594 #198. Revised ANSI C grammar due to efforts by Manuel Kessler
1595
1596 Manuel Kessler (mlkessler cip.physik.uni-wuerzburg.de)
1597
1598 Allow trailing ... in function parameter lists.
1599 Add bit fields.
1600 Allow old-style function declarations.
1601 Support cv-qualified pointers.
1602 Better checking of combinations of type specifiers.
1603 Release of memory for local symbols on scope exit.
1604 Allow input file name on command line as well as by redirection.
1605
1606 and other miscellaneous tweaks.
1607
1608 This is not part of the pccts distribution kit. It must be
1609 downloaded separately from:
1610
1611 http://www.polhode.com/ansi_mr15.zip
1612
1613 #197. (Changed in MR14) Resetting the lookahead buffer of the parser
1614
1615 Explanation and fix by Sinan Karasu (sinan.karasu boeing.com)
1616
1617 Consider the code used to prime the lookahead buffer LA(i)
1618 of the parser when init() is called:
1619
1620 void
1621 ANTLRParser::
1622 prime_lookahead()
1623 {
1624 int i;
1625 for(i=1;i<=LLk; i++) consume();
1626 dirty=0;
1627 //lap = 0; // MR14 - Sinan Karasu (sinan.karusu boeing.com)
1628 //labase = 0; // MR14
1629 labase=lap; // MR14
1630 }
1631
1632 When the parser is instantiated, lap=0,labase=0 is set.
1633
1634 The "for" loop runs LLk times. In consume(), lap = lap +1 (mod LLk) is
1635 computed. Therefore, lap(before the loop) == lap (after the loop).
1636
1637 Now the only problem comes in when one does an init() of the parser
1638 after an Eof has been seen. At that time, lap could be non zero.
1639 Assume it was lap==1. Now we do a prime_lookahead(). If LLk is 2,
1640 then
1641
1642 consume()
1643 {
1644 NLA = inputTokens->getToken()->getType();
1645 dirty--;
1646 lap = (lap+1)&(LLk-1);
1647 }
1648
1649 or expanding NLA,
1650
1651 token_type[lap&(LLk-1)]) = inputTokens->getToken()->getType();
1652 dirty--;
1653 lap = (lap+1)&(LLk-1);
1654
1655 so now we prime locations 1 and 2. In prime_lookahead it used to set
1656 lap=0 and labase=0. Now, the next token will be read from location 0,
1657 NOT 1 as it should have been.
1658
1659 This was never caught before, because if a parser is just instantiated,
1660 then lap and labase are 0, the offending assignment lines are
1661 basically no-ops, since the for loop wraps around back to 0.
1662
1663 #196. (Changed in MR14) Problems with "(alpha)? beta" guess
1664
1665 Consider the following syntactic predicate in a grammar
1666 with 2 tokens of lookahead (k=2 or ck=2):
1667
1668 rule : ( alpha )? beta ;
1669 alpha : S t ;
1670 t : T U
1671 | T
1672 ;
1673 beta : S t Z ;
1674
1675 When antlr computes the prediction expression with one token
1676 of lookahead for alts 1 and 2 of rule t it finds an ambiguity.
1677
1678 Because the grammar has a lookahead of 2 it tries to compute
1679 two tokens of lookahead for alts 1 and 2 of t. Alt 1 clearly
1680 has a lookahead of (T U). Alt 2 is one token long so antlr
1681 tries to compute the follow set of alt 2, which means finding
1682 the things which can follow rule t in the context of (alpha)?.
1683 This cannot be computed, because alpha is only part of a rule,
1684 and antlr can't tell what part of beta is matched by alpha and
1685 what part remains to be matched. Thus it impossible for antlr
1686 to properly determine the follow set of rule t.
1687
1688 Prior to 1.33MR14, the follow of (alpha)? was computed as
1689 FIRST(beta) as a result of the internal representation of
1690 guess blocks.
1691
1692 With MR14 the follow set will be the empty set for that context.
1693
1694 Normally, one expects a rule appearing in a guess block to also
1695 appear elsewhere. When the follow context for this other use
1696 is "ored" with the empty set, the context from the other use
1697 results, and a reasonable follow context results. However if
1698 there is *no* other use of the rule, or it is used in a different
1699 manner then the follow context will be inaccurate - it was
1700 inaccurate even before MR14, but it will be inaccurate in a
1701 different way.
1702
1703 For the example given earlier, a reasonable way to rewrite the
1704 grammar:
1705
1706 rule : ( alpha )? beta
1707 alpha : S t ;
1708 t : T U
1709 | T
1710 ;
1711 beta : alpha Z ;
1712
1713 If there are no other uses of the rule appearing in the guess
1714 block it will generate a test for EOF - a workaround for
1715 representing a null set in the lookahead tests.
1716
1717 If you encounter such a problem you can use the -alpha option
1718 to get additional information:
1719
1720 line 2: error: not possible to compute follow set for alpha
1721 in an "(alpha)? beta" block.
1722
1723 With the antlr -alpha command line option the following information
1724 is inserted into the generated file:
1725
1726 #if 0
1727
1728 Trace of references leading to attempt to compute the follow set of
1729 alpha in an "(alpha)? beta" block. It is not possible for antlr to
1730 compute this follow set because it is not known what part of beta has
1731 already been matched by alpha and what part remains to be matched.
1732
1733 Rules which make use of the incorrect follow set will also be incorrect
1734
1735 1 #token T alpha/2 line 7 brief.g
1736 2 end alpha alpha/3 line 8 brief.g
1737 2 end (...)? block at start/1 line 2 brief.g
1738
1739 #endif
1740
1741 At the moment, with the -alpha option selected the program marks
1742 any rules which appear in the trace back chain (above) as rules with
1743 possible problems computing follow set.
1744
1745 Reported by Greg Knapen (gregory.knapen bell.ca).
1746
1747 #195. (Changed in MR14) #line directive not at column 1
1748
1749 Under certain circunstances a predicate test could generate
1750 a #line directive which was not at column 1.
1751
1752 Reported with fix by David Kågedal (davidk lysator.liu.se)
1753 (http://www.lysator.liu.se/~davidk/).
1754
1755 #194. (Changed in MR14) (C Mode only) Demand lookahead with #tokclass
1756
1757 In C mode with the demand lookahead option there is a bug in the
1758 code which handles matches for #tokclass (zzsetmatch and
1759 zzsetmatch_wsig).
1760
1761 The bug causes the lookahead pointer to get out of synchronization
1762 with the current token pointer.
1763
1764 The problem was reported with a fix by Ger Hobbelt (hobbelt axa.nl).
1765
1766 #193. (Changed in MR14) Use of PCCTS_USE_NAMESPACE_STD
1767
1768 The pcctscfg.h now contains the following definitions:
1769
1770 #ifdef PCCTS_USE_NAMESPACE_STD
1771 #define PCCTS_STDIO_H <Cstdio>
1772 #define PCCTS_STDLIB_H <Cstdlib>
1773 #define PCCTS_STDARG_H <Cstdarg>
1774 #define PCCTS_SETJMP_H <Csetjmp>
1775 #define PCCTS_STRING_H <Cstring>
1776 #define PCCTS_ASSERT_H <Cassert>
1777 #define PCCTS_ISTREAM_H <istream>
1778 #define PCCTS_IOSTREAM_H <iostream>
1779 #define PCCTS_NAMESPACE_STD namespace std {}; using namespace std;
1780 #else
1781 #define PCCTS_STDIO_H <stdio.h>
1782 #define PCCTS_STDLIB_H <stdlib.h>
1783 #define PCCTS_STDARG_H <stdarg.h>
1784 #define PCCTS_SETJMP_H <setjmp.h>
1785 #define PCCTS_STRING_H <string.h>
1786 #define PCCTS_ASSERT_H <assert.h>
1787 #define PCCTS_ISTREAM_H <istream.h>
1788 #define PCCTS_IOSTREAM_H <iostream.h>
1789 #define PCCTS_NAMESPACE_STD
1790 #endif
1791
1792 The runtime support in pccts/h uses these pre-processor symbols
1793 consistently.
1794
1795 Also, antlr and dlg have been changed to generate code which uses
1796 these pre-processor symbols rather than having the names of the
1797 #include files hard-coded in the generated code.
1798
1799 This required the addition of "#include pcctscfg.h" to a number of
1800 files in pccts/h.
1801
1802 It appears that this sometimes causes problems for MSVC 5 in
1803 combination with the "automatic" option for pre-compiled headers.
1804 In such cases disable the "automatic" pre-compiled headers option.
1805
1806 Suggested by Hubert Holin (Hubert.Holin Bigfoot.com).
1807
1808 #192. (Changed in MR14) Change setText() to accept "const ANTLRChar *"
1809
1810 Changed ANTLRToken::setText(ANTLRChar *) to setText(const ANTLRChar *).
1811 This allows literal strings to be used to initialize tokens. Since
1812 the usual token implementation (ANTLRCommonToken) makes a copy of the
1813 input string, this was an unnecessary limitation.
1814
1815 Suggested by Bob McWhirter (bob netwrench.com).
1816
1817 #191. (Changed in MR14) HP/UX aCC compiler compatibility problem
1818
1819 Needed to explicitly declare zzINF_DEF_TOKEN_BUFFER_SIZE and
1820 zzINF_BUFFER_TOKEN_CHUNK_SIZE as ints in pccts/h/AParser.cpp.
1821
1822 Reported by David Cook (dcook bmc.com).
1823
1824 #190. (Changed in MR14) IBM OS/2 CSet compiler compatibility problem
1825
1826 Name conflict with "_cs" in pccts/h/ATokenBuffer.cpp
1827
1828 Reported by David Cook (dcook bmc.com).
1829
1830 #189. (Changed in MR14) -gxt switch in C mode
1831
1832 The -gxt switch in C mode didn't work because of incorrect
1833 initialization.
1834
1835 Reported by Sinan Karasu (sinan boeing.com).
1836
1837 #188. (Changed in MR14) Added pccts/h/DLG_stream_input.h
1838
1839 This is a DLG stream class based on C++ istreams.
1840
1841 Contributed by Hubert Holin (Hubert.Holin Bigfoot.com).
1842
1843 #187. (Changed in MR14) Rename config.h to pcctscfg.h
1844
1845 The PCCTS configuration file has been renamed from config.h to
1846 pcctscfg.h. The problem with the original name is that it led
1847 to name collisions when pccts parsers were combined with other
1848 software.
1849
1850 All of the runtime support routines in pccts/h/* have been
1851 changed to use the new name. Existing software can continue
1852 to use pccts/h/config.h. The contents of pccts/h/config.h is
1853 now just "#include "pcctscfg.h".
1854
1855 I don't have a record of the user who suggested this.
1856
1857 #186. (Changed in MR14) Pre-processor symbol DllExportPCCTS class modifier
1858
1859 Classes in the C++ runtime support routines are now declared:
1860
1861 class DllExportPCCTS className ....
1862
1863 By default, the pre-processor symbol is defined as the empty
1864 string. This if for use by MSVC++ users to create DLL classes.
1865
1866 Suggested by Manfred Kogler (km cast.uni-linz.ac.at).
1867
1868 #185. (Changed in MR14) Option to not use PCCTS_AST base class for ASTBase
1869
1870 Normally, the ASTBase class is derived from PCCTS_AST which contains
1871 functions useful to Sorcerer. If these are not necessary then the
1872 user can define the pre-processor symbol "PCCTS_NOT_USING_SOR" which
1873 will cause the ASTBase class to replace references to PCCTS_AST with
1874 references to ASTBase where necessary.
1875
1876 The class ASTDoublyLinkedBase will contain a pure virtual function
1877 shallowCopy() that was formerly defined in class PCCTS_AST.
1878
1879 Suggested by Bob McWhirter (bob netwrench.com).
1880
1881 #184. (Changed in MR14) Grammars with no tokens generate invalid tokens.h
1882
1883 Reported by Hubert Holin (Hubert.Holin bigfoot.com).
1884
1885 #183. (Changed in MR14) -f to specify file with names of grammar files
1886
1887 In DEC/VMS it is difficult to specify very long command lines.
1888 The -f option allows one to place the names of the grammar files
1889 in a data file in order to bypass limitations of the DEC/VMS
1890 command language interpreter.
1891
1892 Addition supplied by Bernard Giroud (b_giroud decus.ch).
1893
1894 #182. (Changed in MR14) Output directory option for DEC/VMS
1895
1896 Fix some problems with the -o option under DEC/VMS.
1897
1898 Fix supplied by Bernard Giroud (b_giroud decus.ch).
1899
1900 #181. (Changed in MR14) Allow chars > 127 in DLGStringInput::nextChar()
1901
1902 Changed DLGStringInput to cast the character using (unsigned char)
1903 so that languages with character codes greater than 127 work
1904 without changes.
1905
1906 Suggested by Manfred Kogler (km cast.uni-linz.ac.at).
1907
1908 #180. (Added in MR14) ANTLRParser::getEofToken()
1909
1910 Added "ANTLRToken ANTLRParser::getEofToken() const" to match the
1911 setEofToken routine.
1912
1913 Requested by Manfred Kogler (km cast.uni-linz.ac.at).
1914
1915 #179. (Fixed in MR14) Memory leak for BufFileInput subclass of DLGInputStream
1916
1917 The BufFileInput class described in Item #142 neglected to release
1918 the allocated buffer when an instance was destroyed.
1919
1920 Reported by Manfred Kogler (km cast.uni-linz.ac.at).
1921
1922 #178. (Fixed in MR14) Bug in "(alpha)? beta" guess blocks first sets
1923
1924 In 1.33 vanilla, and all maintenance releases prior to MR14
1925 there is a bug in the handling of guess blocks which use the
1926 "long" form:
1927
1928 (alpha)? beta
1929
1930 inside a (...)*, (...)+, or {...} block.
1931
1932 This problem does *not* apply to the case where beta is omitted
1933 or when the syntactic predicate is on the leading edge of an
1934 alternative.
1935
1936 The problem is that both alpha and beta are stored in the
1937 syntax diagram, and that some analysis routines would fail
1938 to skip the alpha portion when it was not on the leading edge.
1939 Consider the following grammar with -ck 2:
1940
1941 r : ( (A)? B )* C D
1942
1943 | A B /* forces -ck 2 computation for old antlr */
1944 /* reports ambig for alts 1 & 2 */
1945
1946 | B C /* forces -ck 2 computation for new antlr */
1947 /* reports ambig for alts 1 & 3 */
1948 ;
1949
1950 The prediction expression for the first alternative should be
1951 LA(1)={B C} LA(2)={B C D}, but previous versions of antlr
1952 would compute the prediction expression as LA(1)={A C} LA(2)={B D}
1953
1954 Reported by Arpad Beszedes (beszedes inf.u-szeged.hu) who provided
1955 a very clear example of the problem and identified the probable cause.
1956
1957 #177. (Changed in MR14) #tokdefs and #token with regular expression
1958
1959 In MR13 the change described by Item #162 caused an existing
1960 feature of antlr to fail. Prior to the change it was possible
1961 to give regular expression definitions and actions to tokens
1962 which were defined via the #tokdefs directive.
1963
1964 This now works again.
1965
1966 Reported by Manfred Kogler (km cast.uni-linz.ac.at).
1967
1968 #176. (Changed in MR14) Support for #line in antlr source code
1969
1970 Note: this was implemented by Arpad Beszedes (beszedes inf.u-szeged.hu).
1971
1972 In 1.33MR14 it is possible for a pre-processor to generate #line
1973 directives in the antlr source and have those line numbers and file
1974 names used in antlr error messages and in the #line directives
1975 generated by antlr.
1976
1977 The #line directive may appear in the following forms:
1978
1979 #line ll "sss" xx xx ...
1980
1981 where ll represents a line number, "sss" represents the name of a file
1982 enclosed in quotation marks, and xxx are arbitrary integers.
1983
1984 The following form (without "line") is not supported at the moment:
1985
1986 # ll "sss" xx xx ...
1987
1988 The result:
1989
1990 zzline
1991
1992 is replaced with ll from the # or #line directive
1993
1994 FileStr[CurFile]
1995
1996 is updated with the contents of the string (if any)
1997 following the line number
1998
1999 Note
2000 ----
2001 The file-name string following the line number can be a complete
2002 name with a directory-path. Antlr generates the output files from
2003 the input file name (by replacing the extension from the file-name
2004 with .c or .cpp).
2005
2006 If the input file (or the file-name from the line-info) contains
2007 a path:
2008
2009 "../grammar.g"
2010
2011 the generated source code will be placed in "../grammar.cpp" (i.e.
2012 in the parent directory). This is inconvenient in some cases
2013 (even the -o switch can not be used) so the path information is
2014 removed from the #line directive. Thus, if the line-info was
2015
2016 #line 2 "../grammar.g"
2017
2018 then the current file-name will become "grammar.g"
2019
2020 In this way, the generated source code according to the grammar file
2021 will always be in the current directory, except when the -o switch
2022 is used.
2023
2024 #175. (Changed in MR14) Bug when guess block appears at start of (...)*
2025
2026 In 1.33 vanilla and all maintenance releases prior to 1.33MR14
2027 there is a bug when a guess block appears at the start of a (...)+.
2028 Consider the following k=1 (ck=1) grammar:
2029
2030 rule :
2031 ( (STAR)? ZIP )* ID ;
2032
2033 Prior to 1.33MR14, the generated code resembled:
2034
2035 ...
2036 zzGUESS_BLOCK
2037 while ( 1 ) {
2038 if ( ! LA(1)==STAR) break;
2039 zzGUESS
2040 if ( !zzrv ) {
2041 zzmatch(STAR);
2042 zzCONSUME;
2043 zzGUESS_DONE
2044 zzmatch(ZIP);
2045 zzCONSUME;
2046 ...
2047
2048 Note that the routine uses STAR for the prediction expression
2049 rather than ZIP. With 1.33MR14 the generated code resembles:
2050
2051 ...
2052 while ( 1 ) {
2053 if ( ! LA(1)==ZIP) break;
2054 ...
2055
2056 This problem existed only with (...)* blocks and was caused
2057 by the slightly more complicated graph which represents (...)*
2058 blocks. This caused the analysis routine to compute the first
2059 set for the alpha part of the "(alpha)? beta" rather than the
2060 beta part.
2061
2062 Both (...)+ and {...} blocks handled the guess block correctly.
2063
2064 Reported by Arpad Beszedes (beszedes inf.u-szeged.hu) who provided
2065 a very clear example of the problem and identified the probable cause.
2066
2067 #174. (Changed in MR14) Bug when action precedes syntactic predicate
2068
2069 In 1.33 vanilla, and all maintenance releases prior to MR14,
2070 there was a bug when a syntactic predicate was immediately
2071 preceded by an action. Consider the following -ck 2 grammar:
2072
2073 rule :
2074 <<int i;>>
2075 (alpha)? beta C
2076 | A B
2077 ;
2078
2079 alpha : A ;
2080 beta : A B;
2081
2082 Prior to MR14, the code generated for the first alternative
2083 resembled:
2084
2085 ...
2086 zzGUESS
2087 if ( !zzrv && LA(1)==A && LA(2)==A) {
2088 alpha();
2089 zzGUESS_DONE
2090 beta();
2091 zzmatch(C);
2092 zzCONSUME;
2093 } else {
2094 ...
2095
2096 The prediction expression (i.e. LA(1)==A && LA(2)==A) is clearly
2097 wrong because LA(2) should be matched to B (first[2] of beta is {B}).
2098
2099 With 1.33MR14 the prediction expression is:
2100
2101 ...
2102 if ( !zzrv && LA(1)==A && LA(2)==B) {
2103 alpha();
2104 zzGUESS_DONE
2105 beta();
2106 zzmatch(C);
2107 zzCONSUME;
2108 } else {
2109 ...
2110
2111 This will only affect users in which alpha is shorter than
2112 than max(k,ck) and there is an action immediately preceding
2113 the syntactic predicate.
2114
2115 This problem was reported by reported by Arpad Beszedes
2116 (beszedes inf.u-szeged.hu) who provided a very clear example
2117 of the problem and identified the presence of the init-action
2118 as the likely culprit.
2119
2120 #173. (Changed in MR13a) -glms for Microsoft style filenames with -gl
2121
2122 With the -gl option antlr generates #line directives using the
2123 exact name of the input files specified on the command line.
2124 An oddity of the Microsoft C and C++ compilers is that they
2125 don't accept file names in #line directives containing "\"
2126 even though these are names from the native file system.
2127
2128 With -glms option, the "\" in file names appearing in #line
2129 directives is replaced with a "/" in order to conform to
2130 Microsoft compiler requirements.
2131
2132 Reported by Erwin Achermann (erwin.achermann switzerland.org).
2133
2134 #172. (Changed in MR13) \r\n in antlr source counted as one line
2135
2136 Some MS software uses \r\n to indicate a new line. Antlr
2137 now recognizes this in counting lines.
2138
2139 Reported by Edward L. Hepler (elh ece.vill.edu).
2140
2141 #171. (Changed in MR13) #tokclass L..U now allowed
2142
2143 The following is now allowed:
2144
2145 #tokclass ABC { A..B C }
2146
2147 Reported by Dave Watola (dwatola amtsun.jpl.nasa.gov)
2148
2149 #170. (Changed in MR13) Suppression for predicates with lookahead depth >1
2150
2151 In MR12 the capability for suppression of predicates with lookahead
2152 depth=1 was introduced. With MR13 this had been extended to
2153 predicates with lookahead depth > 1 and released for use by users
2154 on an experimental basis.
2155
2156 Consider the following grammar with -ck 2 and the predicate in rule
2157 "a" with depth 2:
2158
2159 r1 : (ab)* "@"
2160 ;
2161
2162 ab : a
2163 | b
2164 ;
2165
2166 a : (A B)? => <<p(LATEXT(2))>>? A B C
2167 ;
2168
2169 b : A B C
2170 ;
2171
2172 Normally, the predicate would be hoisted into rule r1 in order to
2173 determine whether to call rule "ab". However it should *not* be
2174 hoisted because, even if p is false, there is a valid alternative
2175 in rule b. With "-mrhoistk on" the predicate will be suppressed.
2176
2177 If "-info p" command line option is present the following information
2178 will appear in the generated code:
2179
2180 while ( (LA(1)==A)
2181 #if 0
2182
2183 Part (or all) of predicate with depth > 1 suppressed by alternative
2184 without predicate
2185
2186 pred << p(LATEXT(2))>>?
2187 depth=k=2 ("=>" guard) rule a line 8 t1.g
2188 tree context:
2189 (root = A
2190 B
2191 )
2192
2193 The token sequence which is suppressed: ( A B )
2194 The sequence of references which generate that sequence of tokens:
2195
2196 1 to ab r1/1 line 1 t1.g
2197 2 ab ab/1 line 4 t1.g
2198 3 to b ab/2 line 5 t1.g
2199 4 b b/1 line 11 t1.g
2200 5 #token A b/1 line 11 t1.g
2201 6 #token B b/1 line 11 t1.g
2202
2203 #endif
2204
2205 A slightly more complicated example:
2206
2207 r1 : (ab)* "@"
2208 ;
2209
2210 ab : a
2211 | b
2212 ;
2213
2214 a : (A B)? => <<p(LATEXT(2))>>? (A B | D E)
2215 ;
2216
2217 b : <<q(LATEXT(2))>>? D E
2218 ;
2219
2220
2221 In this case, the sequence (D E) in rule "a" which lies behind
2222 the guard is used to suppress the predicate with context (D E)
2223 in rule b.
2224
2225 while ( (LA(1)==A || LA(1)==D)
2226 #if 0
2227
2228 Part (or all) of predicate with depth > 1 suppressed by alternative
2229 without predicate
2230
2231 pred << q(LATEXT(2))>>?
2232 depth=k=2 rule b line 11 t2.g
2233 tree context:
2234 (root = D
2235 E
2236 )
2237
2238 The token sequence which is suppressed: ( D E )
2239 The sequence of references which generate that sequence of tokens:
2240
2241 1 to ab r1/1 line 1 t2.g
2242 2 ab ab/1 line 4 t2.g
2243 3 to a ab/1 line 4 t2.g
2244 4 a a/1 line 8 t2.g
2245 5 #token D a/1 line 8 t2.g
2246 6 #token E a/1 line 8 t2.g
2247
2248 #endif
2249 &&
2250 #if 0
2251
2252 pred << p(LATEXT(2))>>?
2253 depth=k=2 ("=>" guard) rule a line 8 t2.g
2254 tree context:
2255 (root = A
2256 B
2257 )
2258
2259 #endif
2260
2261 (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) ) {
2262 ab();
2263 ...
2264
2265 #169. (Changed in MR13) Predicate test optimization for depth=1 predicates
2266
2267 When the MR12 generated a test of a predicate which had depth 1
2268 it would use the depth >1 routines, resulting in correct but
2269 inefficient behavior. In MR13, a bit test is used.
2270
2271 #168. (Changed in MR13) Token expressions in context guards
2272
2273 The token expressions appearing in context guards such as:
2274
2275 (A B)? => <<test(LT(1))>>? someRule
2276
2277 are computed during an early phase of antlr processing. As
2278 a result, prior to MR13, complex expressions such as:
2279
2280 ~B
2281 L..U
2282 ~L..U
2283 TokClassName
2284 ~TokClassName
2285
2286 were not computed properly. This resulted in incorrect
2287 context being computed for such expressions.
2288
2289 In MR13 these context guards are verified for proper semantics
2290 in the initial phase and then re-evaluated after complex token
2291 expressions have been computed in order to produce the correct
2292 behavior.
2293
2294 Reported by Arpad Beszedes (beszedes inf.u-szeged.hu).
2295
2296 #167. (Changed in MR13) ~L..U
2297
2298 Prior to MR13, the complement of a token range was
2299 not properly computed.
2300
2301 #166. (Changed in MR13) token expression L..U
2302
2303 The token U was represented as an unsigned char, restricting
2304 the use of L..U to cases where U was assigned a token number
2305 less than 256. This is corrected in MR13.
2306
2307 #165. (Changed in MR13) option -newAST
2308
2309 To create ASTs from an ANTLRTokenPtr antlr usually calls
2310 "new AST(ANTLRTokenPtr)". This option generates a call
2311 to "newAST(ANTLRTokenPtr)" instead. This allows a user
2312 to define a parser member function to create an AST object.
2313
2314 Similar changes for ASTBase::tmake and ASTBase::link were not
2315 thought necessary since they do not create AST objects, only
2316 use existing ones.
2317
2318 #164. (Changed in MR13) Unused variable _astp
2319
2320 For many compilations, we have lived with warnings about
2321 the unused variable _astp. It turns out that this varible
2322 can *never* be used because the code which references it was
2323 commented out.
2324
2325 This investigation was sparked by a note from Erwin Achermann
2326 (erwin.achermann switzerland.org).
2327
2328 #163. (Changed in MR13) Incorrect makefiles for testcpp examples
2329
2330 All the examples in pccts/testcpp/* had incorrect definitions
2331 in the makefiles for the symbol "CCC". Instead of CCC=CC they
2332 had CC=$(CCC).
2333
2334 There was an additional problem in testcpp/1/test.g due to the
2335 change in ANTLRToken::getText() to a const member function
2336 (Item #137).
2337
2338 Reported by Maurice Mass (maas cuci.nl).
2339
2340 #162. (Changed in MR13) Combining #token with #tokdefs
2341
2342 When it became possible to change the print-name of a
2343 #token (Item #148) it became useful to give a #token
2344 statement whose only purpose was to giving a print name
2345 to the #token. Prior to this change this could not be
2346 combined with the #tokdefs feature.
2347
2348 #161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h
2349
2350 #160. (Changed in MR13) Omissions in list of names for remap.h
2351
2352 When a user selects the -gp option antlr creates a list
2353 of macros in remap.h to rename some of the standard
2354 antlr routines from zzXXX to userprefixXXX.
2355
2356 There were number of omissions from the remap.h name
2357 list related to the new trace facility. This was reported,
2358 along with a fix, by Bernie Solomon (bernard ug.eds.com).
2359
2360 #159. (Changed in MR13) Violations of classic C rules
2361
2362 There were a number of violations of classic C style in
2363 the distribution kit. This was reported, along with fixes,
2364 by Bernie Solomon (bernard ug.eds.com).
2365
2366 #158. (Changed in MR13) #header causes problem for pre-processors
2367
2368 A user who runs the C pre-processor on antlr source suggested
2369 that another syntax be allowed. With MR13 such directives
2370 such as #header, #pragma, etc. may be written as "\#header",
2371 "\#pragma", etc. For escaping pre-processor directives inside
2372 a #header use something like the following:
2373
2374 \#header
2375 <<
2376 \#include <stdio.h>
2377 >>
2378
2379 #157. (Fixed in MR13) empty error sets for rules with infinite recursion
2380
2381 When the first set for a rule cannot be computed due to infinite
2382 left recursion and it is the only alternative for a block then
2383 the error set for the block would be empty. This would result
2384 in a fatal error.
2385
2386 Reported by Darin Creason (creason genedax.com)
2387
2388 #156. (Changed in MR13) DLGLexerBase::getToken() now public
2389
2390 #155. (Changed in MR13) Context behind predicates can suppress
2391
2392 With -mrhoist enabled the context behind a guarded predicate can
2393 be used to suppress other predicates. Consider the following grammar:
2394
2395 r0 : (r1)+;
2396
2397 r1 : rp
2398 | rq
2399 ;
2400 rp : <<p LATEXT(1)>>? B ;
2401 rq : (A)? => <<q LATEXT(1)>>? (A|B);
2402
2403 In earlier versions both predicates "p" and "q" would be hoisted into
2404 rule r0. With MR12c predicate p is suppressed because the context which
2405 follows predicate q includes "B" which can "cover" predicate "p". In
2406 other words, in trying to decide in r0 whether to call r1, it doesn't
2407 really matter whether p is false or true because, either way, there is
2408 a valid choice within r1.
2409
2410 #154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>
2411
2412 A common error, even among experienced pccts users, is to code
2413 an init-action to inhibit hoisting rather than a leading action.
2414 An init-action does not inhibit hoisting.
2415
2416 This was coded:
2417
2418 rule1 : <<;>> rule2
2419
2420 This is what was meant:
2421
2422 rule1 : <<;>> <<;>> rule2
2423
2424 With MR13, the user can code:
2425
2426 rule1 : <<;>> <<nohoist>> rule2
2427
2428 The following will give an error message:
2429
2430 rule1 : <<nohoist>> rule2
2431
2432 If the <<nohoist>> appears as an init-action rather than a leading
2433 action an error message is issued. The meaning of an init-action
2434 containing "nohoist" is unclear: does it apply to just one
2435 alternative or to all alternatives ?
2436
2437
2438
2439
2440
2441
2442
2443
2444 -------------------------------------------------------
2445 Note: Items #153 to #1 are now in a separate file named
2446 CHANGES_FROM_133_BEFORE_MR13.txt
2447 -------------------------------------------------------
+0
-3666
contrib/pccts/CHANGES_FROM_133_BEFORE_MR13.txt less more
0
1 ------------------------------------------------------------
2 This is the second part of a two part file.
3 This is a list of changes to pccts 1.33 prior to MR13
4 For more recent information see CHANGES_FROM_133.txt
5 ------------------------------------------------------------
6
7 DISCLAIMER
8
9 The software and these notes are provided "as is". They may include
10 typographical or technical errors and their authors disclaims all
11 liability of any kind or nature for damages due to error, fault,
12 defect, or deficiency regardless of cause. All warranties of any
13 kind, either express or implied, including, but not limited to, the
14 implied warranties of merchantability and fitness for a particular
15 purpose are disclaimed.
16
17
18 #153. (Changed in MR12b) Bug in computation of -mrhoist suppression set
19
20 Consider the following grammar with k=1 and "-mrhoist on":
21
22 r1 : (A)? => ((p>>? x /* l1 */
23 | r2 /* l2 */
24 ;
25 r2 : A /* l4 */
26 | (B)? => <<q>>? y /* l5 */
27 ;
28
29 In earlier versions the mrhoist routine would see that both l1 and
30 l2 contained predicates and would assume that this prevented either
31 from acting to suppress the other predicate. In the example above
32 it didn't realize the A at line l4 is capable of suppressing the
33 predicate at l1 even though alt l2 contains (indirectly) a predicate.
34
35 This is fixed in MR12b.
36
37 Reported by Reinier van den Born (reinier@vnet.ibm.com)
38
39 #153. (Changed in MR12a) Bug in computation of -mrhoist suppression set
40
41 An oversight similar to that described in Item #152 appeared in
42 the computation of the set that "covered" a predicate. If a
43 predicate expression included a term such as p=AND(q,r) the context
44 of p was taken to be context(q) & context(r), when it should have
45 been context(q) | context(r). This is fixed in MR12a.
46
47 #152. (Changed in MR12) Bug in generation of predicate expressions
48
49 The primary purpose for MR12 is to make quite clear that MR11 is
50 obsolete and to fix the bug related to predicate expressions.
51
52 In MR10 code was added to optimize the code generated for
53 predicate expression tests. Unfortunately, there was a
54 significant oversight in the code which resulted in a bug in
55 the generation of code for predicate expression tests which
56 contained predicates combined using AND:
57
58 r0 : (r1)* "@" ;
59 r1 : (AAA)? => <<p LATEXT(1)>>? r2 ;
60 r2 : (BBB)? => <<q LATEXT(1)>>? Q
61 | (BBB)? => <<r LATEXT(1)>>? Q
62 ;
63
64 In MR11 (and MR10 when using "-mrhoist on") the code generated
65 for r0 to predict r1 would be equivalent to:
66
67 if ( LA(1)==Q &&
68 (LA(1)==AAA && LA(1)==BBB) &&
69 ( p && ( q || r )) ) {
70
71 This is incorrect because it expresses the idea that LA(1)
72 *must* be AAA in order to attempt r1, and *must* be BBB to
73 attempt r2. The result was that r1 became unreachable since
74 both condition can not be simultaneously true.
75
76 The general philosophy of code generation for predicates
77 can be summarized as follows:
78
79 a. If the context is true don't enter an alt
80 for which the corresponding predicate is false.
81
82 If the context is false then it is okay to enter
83 the alt without evaluating the predicate at all.
84
85 b. A predicate created by ORing of predicates has
86 context which is the OR of their individual contexts.
87
88 c. A predicate created by ANDing of predicates has
89 (surprise) context which is the OR of their individual
90 contexts.
91
92 d. Apply these rules recursively.
93
94 e. Remember rule (a)
95
96 The correct code should express the idea that *if* LA(1) is
97 AAA then p must be true to attempt r1, but if LA(1) is *not*
98 AAA then it is okay to attempt r1, provided that *if* LA(1) is
99 BBB then one of q or r must be true.
100
101 if ( LA(1)==Q &&
102 ( !(LA(1)==AAA || LA(1)==BBB) ||
103 ( ! LA(1) == AAA || p) &&
104 ( ! LA(1) == BBB || q || r ) ) ) {
105
106 I believe this is fixed in MR12.
107
108 Reported by Reinier van den Born (reinier@vnet.ibm.com)
109
110 #151a. (Changed in MR12) ANTLRParser::getLexer()
111
112 As a result of several requests, I have added public methods to
113 get a pointer to the lexer belonging to a parser.
114
115 ANTLRTokenStream *ANTLRParser::getLexer() const
116
117 Returns a pointer to the lexer being used by the
118 parser. ANTLRTokenStream is the base class of
119 DLGLexer
120
121 ANTLRTokenStream *ANTLRTokenBuffer::getLexer() const
122
123 Returns a pointer to the lexer being used by the
124 ANTLRTokenBuffer. ANTLRTokenStream is the base
125 class of DLGLexer
126
127 You must manually cast the ANTLRTokenStream to your program's
128 lexer class. Because the name of the lexer's class is not fixed.
129 Thus it is impossible to incorporate it into the DLGLexerBase
130 class.
131
132 #151b.(Changed in MR12) ParserBlackBox member getLexer()
133
134 The template class ParserBlackBox now has a member getLexer()
135 which returns a pointer to the lexer.
136
137 #150. (Changed in MR12) syntaxErrCount and lexErrCount now public
138
139 See Item #127 for more information.
140
141 #149. (Changed in MR12) antlr option -info o (letter o for orphan)
142
143 If there is more than one rule which is not referenced by any
144 other rule then all such rules are listed. This is useful for
145 alerting one to rules which are not used, but which can still
146 contribute to ambiguity. For example:
147
148 start : a Z ;
149 unused: a A ;
150 a : (A)+ ;
151
152 will cause an ambiguity report for rule "a" which will be
153 difficult to understand if the user forgets about rule "unused"
154 simply because it is not used in the grammar.
155
156 #148. (Changed in MR11) #token names appearing in zztokens,token_tbl
157
158 In a #token statement like the following:
159
160 #token Plus "\+"
161
162 the string "Plus" appears in the zztokens array (C mode) and
163 token_tbl (C++ mode). This string is used in most error
164 messages. In MR11 one has the option of using some other string,
165 (e.g. "+") in those tables.
166
167 In MR11 one can write:
168
169 #token Plus ("+") "\+"
170 #token RP ("(") "\("
171 #token COM ("comment begin") "/\*"
172
173 A #token statement is allowed to appear in more than one #lexclass
174 with different regular expressions. However, the token name appears
175 only once in the zztokens/token_tbl array. This means that only
176 one substitute can be specified for a given #token name. The second
177 attempt to define a substitute name (different from the first) will
178 result in an error message.
179
180 #147. (Changed in MR11) Bug in follow set computation
181
182 There is a bug in 1.33 vanilla and all maintenance releases
183 prior to MR11 in the computation of the follow set. The bug is
184 different than that described in Item #82 and probably more
185 common. It was discovered in the ansi.g grammar while testing
186 the "ambiguity aid" (Item #119). The search for a bug started
187 when the ambiguity aid was unable to discover the actual source
188 of an ambiguity reported by antlr.
189
190 The problem appears when an optimization of the follow set
191 computation is used inappropriately. The result is that the
192 follow set used is the "worst case". In other words, the error
193 can lead to false reports of ambiguity. The good news is that
194 if you have a grammar in which you have addressed all reported
195 ambiguities you are ok. The bad news is that you may have spent
196 time fixing ambiguities that were not real, or used k=2 when
197 ck=2 might have been sufficient, and so on.
198
199 The following grammar demonstrates the problem:
200
201 ------------------------------------------------------------
202 expr : ID ;
203
204 start : stmt SEMI ;
205
206 stmt : CASE expr COLON
207 | expr SEMI
208 | plain_stmt
209 ;
210
211 plain_stmt : ID COLON ;
212 ------------------------------------------------------------
213
214 When compiled with k=1 and ck=2 it will report:
215
216 warning: alts 2 and 3 of the rule itself ambiguous upon
217 { IDENTIFIER }, { COLON }
218
219 When antlr analyzes "stmt" it computes the first[1] set of all
220 alternatives. It finds an ambiguity between alts 2 and 3 for ID.
221 It then computes the first[2] set for alternatives 2 and 3 to resolve
222 the ambiguity. In computing the first[2] set of "expr" (which is
223 only one token long) it needs to determine what could follow "expr".
224 Under a certain combination of circumstances antlr forgets that it
225 is trying to analyze "stmt" which can only be followed by SEMI and
226 adds to the first[2] set of "expr" the "global" follow set (including
227 "COLON") which could follow "expr" (under other conditions) in the
228 phrase "CASE expr COLON".
229
230 #146. (Changed in MR11) Option -treport for locating "difficult" alts
231
232 It can be difficult to determine which alternatives are causing
233 pccts to work hard to resolve an ambiguity. In some cases the
234 ambiguity is successfully resolved after much CPU time so there
235 is no message at all.
236
237 A rough measure of the amount of work being peformed which is
238 independent of the CPU speed and system load is the number of
239 tnodes created. Using "-info t" gives information about the
240 total number of tnodes created and the peak number of tnodes.
241
242 Tree Nodes: peak 1300k created 1416k lost 0
243
244 It also puts in the generated C or C++ file the number of tnodes
245 created for a rule (at the end of the rule). However this
246 information is not sufficient to locate the alternatives within
247 a rule which are causing the creation of tnodes.
248
249 Using:
250
251 antlr -treport 100000 ....
252
253 causes antlr to list on stdout any alternatives which require the
254 creation of more than 100,000 tnodes, along with the lookahead sets
255 for those alternatives.
256
257 The following is a trivial case from the ansi.g grammar which shows
258 the format of the report. This report might be of more interest
259 in cases where 1,000,000 tuples were created to resolve the ambiguity.
260
261 -------------------------------------------------------------------------
262 There were 0 tuples whose ambiguity could not be resolved
263 by full lookahead
264 There were 157 tnodes created to resolve ambiguity between:
265
266 Choice 1: statement/2 line 475 file ansi.g
267 Choice 2: statement/3 line 476 file ansi.g
268
269 Intersection of lookahead[1] sets:
270
271 IDENTIFIER
272
273 Intersection of lookahead[2] sets:
274
275 LPARENTHESIS COLON AMPERSAND MINUS
276 STAR PLUSPLUS MINUSMINUS ONESCOMPLEMENT
277 NOT SIZEOF OCTALINT DECIMALINT
278 HEXADECIMALINT FLOATONE FLOATTWO IDENTIFIER
279 STRING CHARACTER
280 -------------------------------------------------------------------------
281
282 #145. (Documentation) Generation of Expression Trees
283
284 Item #99 was misleading because it implied that the optimization
285 for tree expressions was available only for trees created by
286 predicate expressions and neglected to mention that it required
287 the use of "-mrhoist on". The optimization applies to tree
288 expressions created for grammars with k>1 and for predicates with
289 lookahead depth >1.
290
291 In MR11 the optimized version is always used so the -mrhoist on
292 option need not be specified.
293
294 #144. (Changed in MR11) Incorrect test for exception group
295
296 In testing for a rule's exception group the label a pointer
297 is compared against '\0'. The intention is "*pointer".
298
299 Reported by Jeffrey C. Fried (Jeff@Fried.net).
300
301 #143. (Changed in MR11) Optional ";" at end of #token statement
302
303 Fixes problem of:
304
305 #token X "x"
306
307 <<
308 parser action
309 >>
310
311 Being confused with:
312
313 #token X "x" <<lexical action>>
314
315 #142. (Changed in MR11) class BufFileInput subclass of DLGInputStream
316
317 Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class
318 BufFileInput derived from DLGInputStream which provides a
319 function lookahead(char *string) to test characters in the
320 input stream more than one character ahead.
321
322 The default amount of lookahead is specified by the constructor
323 and defaults to 8 characters. This does *not* include the one
324 character of lookahead maintained internally by DLG in member "ch"
325 and which is not available for testing via BufFileInput::lookahead().
326
327 This is a useful class for overcoming the one-character-lookahead
328 limitation of DLG without resorting to a lexer capable of
329 backtracking (like flex) which is not integrated with antlr as is
330 DLG.
331
332 There are no restrictions on copying or using BufFileInput.* except
333 that the authorship and related information must be retained in the
334 source code.
335
336 The class is located in pccts/h/BufFileInput.* of the kit.
337
338 #141. (Changed in MR11) ZZDEBUG_CONSUME for ANTLRParser::consume()
339
340 A debug aid has been added to file ANTLRParser::consume() in
341 file AParser.cpp:
342
343 #ifdef ZZDEBUG_CONSUME_ACTION
344 zzdebug_consume_action();
345 #endif
346
347 Suggested by Sramji Ramanathan (ps@kumaran.com).
348
349 #140. (Changed in MR11) #pred to define predicates
350
351 +---------------------------------------------------+
352 | Note: Assume "-prc on" for this entire discussion |
353 +---------------------------------------------------+
354
355 A problem with predicates is that each one is regarded as
356 unique and capable of disambiguating cases where two
357 alternatives have identical lookahead. For example:
358
359 rule : <<pred(LATEXT(1))>>? A
360 | <<pred(LATEXT(1))>>? A
361 ;
362
363 will not cause any error messages or warnings to be issued
364 by earlier versions of pccts. To compare the text of the
365 predicates is an incomplete solution.
366
367 In 1.33MR11 I am introducing the #pred statement in order to
368 solve some problems with predicates. The #pred statement allows
369 one to give a symbolic name to a "predicate literal" or a
370 "predicate expression" in order to refer to it in other predicate
371 expressions or in the rules of the grammar.
372
373 The predicate literal associated with a predicate symbol is C
374 or C++ code which can be used to test the condition. A
375 predicate expression defines a predicate symbol in terms of other
376 predicate symbols using "!", "&&", and "||". A predicate symbol
377 can be defined in terms of a predicate literal, a predicate
378 expression, or *both*.
379
380 When a predicate symbol is defined with both a predicate literal
381 and a predicate expression, the predicate literal is used to generate
382 code, but the predicate expression is used to check for two
383 alternatives with identical predicates in both alternatives.
384
385 Here are some examples of #pred statements:
386
387 #pred IsLabel <<isLabel(LATEXT(1))>>?
388 #pred IsLocalVar <<isLocalVar(LATEXT(1))>>?
389 #pred IsGlobalVar <<isGlobalVar(LATEXT(1)>>?
390 #pred IsVar <<isVar(LATEXT(1))>>? IsLocalVar || IsGlobalVar
391 #pred IsScoped <<isScoped(LATEXT(1))>>? IsLabel || IsLocalVar
392
393 I hope that the use of EBNF notation to describe the syntax of the
394 #pred statement will not cause problems for my readers (joke).
395
396 predStatement : "#pred"
397 CapitalizedName
398 (
399 "<<predicate_literal>>?"
400 | "<<predicate_literal>>?" predOrExpr
401 | predOrExpr
402 )
403 ;
404
405 predOrExpr : predAndExpr ( "||" predAndExpr ) * ;
406
407 predAndExpr : predPrimary ( "&&" predPrimary ) * ;
408
409 predPrimary : CapitalizedName
410 | "!" predPrimary
411 | "(" predOrExpr ")"
412 ;
413
414 What is the purpose of this nonsense ?
415
416 To understand how predicate symbols help, you need to realize that
417 predicate symbols are used in two different ways with two different
418 goals.
419
420 a. Allow simplification of predicates which have been combined
421 during predicate hoisting.
422
423 b. Allow recognition of identical predicates which can't disambiguate
424 alternatives with common lookahead.
425
426 First we will discuss goal (a). Consider the following rule:
427
428 rule0: rule1
429 | ID
430 | ...
431 ;
432
433 rule1: rule2
434 | rule3
435 ;
436
437 rule2: <<isX(LATEXT(1))>>? ID ;
438 rule3: <<!isX(LATEXT(1)>>? ID ;
439
440 When the predicates in rule2 and rule3 are combined by hoisting
441 to create a prediction expression for rule1 the result is:
442
443 if ( LA(1)==ID
444 && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...
445
446 This is inefficient, but more importantly, can lead to false
447 assumptions that the predicate expression distinguishes the rule1
448 alternative with some other alternative with lookahead ID. In
449 MR11 one can write:
450
451 #pred IsX <<isX(LATEXT(1))>>?
452
453 ...
454
455 rule2: <<IsX>>? ID ;
456 rule3: <<!IsX>>? ID ;
457
458 During hoisting MR11 recognizes this as a special case and
459 eliminates the predicates. The result is a prediction
460 expression like the following:
461
462 if ( LA(1)==ID ) { rule1(); ...
463
464 Please note that the following cases which appear to be equivalent
465 *cannot* be simplified by MR11 during hoisting because the hoisting
466 logic only checks for a "!" in the predicate action, not in the
467 predicate expression for a predicate symbol.
468
469 *Not* equivalent and is not simplified during hoisting:
470
471 #pred IsX <<isX(LATEXT(1))>>?
472 #pred NotX <<!isX(LATEXT(1))>>?
473 ...
474 rule2: <<IsX>>? ID ;
475 rule3: <<NotX>>? ID ;
476
477 *Not* equivalent and is not simplified during hoisting:
478
479 #pred IsX <<isX(LATEXT(1))>>?
480 #pred NotX !IsX
481 ...
482 rule2: <<IsX>>? ID ;
483 rule3: <<NotX>>? ID ;
484
485 Now we will discuss goal (b).
486
487 When antlr discovers that there is a lookahead ambiguity between
488 two alternatives it attempts to resolve the ambiguity by searching
489 for predicates in both alternatives. In the past any predicate
490 would do, even if the same one appeared in both alternatives:
491
492 rule: <<p(LATEXT(1))>>? X
493 | <<p(LATEXT(1))>>? X
494 ;
495
496 The #pred statement is a start towards solving this problem.
497 During ambiguity resolution (*not* predicate hoisting) the
498 predicates for the two alternatives are expanded and compared.
499 Consider the following example:
500
501 #pred Upper <<isUpper(LATEXT(1))>>?
502 #pred Lower <<isLower(LATEXT(1))>>?
503 #pred Alpha <<isAlpha(LATEXT(1))>>? Upper || Lower
504
505 rule0: rule1
506 | <<Alpha>>? ID
507 ;
508
509 rule1:
510 | rule2
511 | rule3
512 ...
513 ;
514
515 rule2: <<Upper>>? ID;
516 rule3: <<Lower>>? ID;
517
518 The definition of #pred Alpha expresses:
519
520 a. to test the predicate use the C code "isAlpha(LATEXT(1))"
521
522 b. to analyze the predicate use the information that
523 Alpha is equivalent to the union of Upper and Lower,
524
525 During ambiguity resolution the definition of Alpha is expanded
526 into "Upper || Lower" and compared with the predicate in the other
527 alternative, which is also "Upper || Lower". Because they are
528 identical MR11 will report a problem.
529
530 -------------------------------------------------------------------------
531 t10.g, line 5: warning: the predicates used to disambiguate rule rule0
532 (file t10.g alt 1 line 5 and alt 2 line 6)
533 are identical when compared without context and may have no
534 resolving power for some lookahead sequences.
535 -------------------------------------------------------------------------
536
537 If you use the "-info p" option the output file will contain:
538
539 +----------------------------------------------------------------------+
540 |#if 0 |
541 | |
542 |The following predicates are identical when compared without |
543 | lookahead context information. For some ambiguous lookahead |
544 | sequences they may not have any power to resolve the ambiguity. |
545 | |
546 |Choice 1: rule0/1 alt 1 line 5 file t10.g |
547 | |
548 | The original predicate for choice 1 with available context |
549 | information: |
550 | |
551 | OR expr |
552 | |
553 | pred << Upper>>? |
554 | depth=k=1 rule rule2 line 14 t10.g |
555 | set context: |
556 | ID |
557 | |
558 | pred << Lower>>? |
559 | depth=k=1 rule rule3 line 15 t10.g |
560 | set context: |
561 | ID |
562 | |
563 | The predicate for choice 1 after expansion (but without context |
564 | information): |
565 | |
566 | OR expr |
567 | |
568 | pred << isUpper(LATEXT(1))>>? |
569 | depth=k=1 rule line 1 t10.g |
570 | |
571 | pred << isLower(LATEXT(1))>>? |
572 | depth=k=1 rule line 2 t10.g |
573 | |
574 | |
575 |Choice 2: rule0/2 alt 2 line 6 file t10.g |
576 | |
577 | The original predicate for choice 2 with available context |
578 | information: |
579 | |
580 | pred << Alpha>>? |
581 | depth=k=1 rule rule0 line 6 t10.g |
582 | set context: |
583 | ID |
584 | |
585 | The predicate for choice 2 after expansion (but without context |
586 | information): |
587 | |
588 | OR expr |
589 | |
590 | pred << isUpper(LATEXT(1))>>? |
591 | depth=k=1 rule line 1 t10.g |
592 | |
593 | pred << isLower(LATEXT(1))>>? |
594 | depth=k=1 rule line 2 t10.g |
595 | |
596 | |
597 |#endif |
598 +----------------------------------------------------------------------+
599
600 The comparison of the predicates for the two alternatives takes
601 place without context information, which means that in some cases
602 the predicates will be considered identical even though they operate
603 on disjoint lookahead sets. Consider:
604
605 #pred Alpha
606
607 rule1: <<Alpha>>? ID
608 | <<Alpha>>? Label
609 ;
610
611 Because the comparison of predicates takes place without context
612 these will be considered identical. The reason for comparing
613 without context is that otherwise it would be necessary to re-evaluate
614 the entire predicate expression for each possible lookahead sequence.
615 This would require more code to be written and more CPU time during
616 grammar analysis, and it is not yet clear whether anyone will even make
617 use of the new #pred facility.
618
619 A temporary workaround might be to use different #pred statements
620 for predicates you know have different context. This would avoid
621 extraneous warnings.
622
623 The above example might be termed a "false positive". Comparison
624 without context will also lead to "false negatives". Consider the
625 following example:
626
627 #pred Alpha
628 #pred Beta
629
630 rule1: <<Alpha>>? A
631 | rule2
632 ;
633
634 rule2: <<Alpha>>? A
635 | <<Beta>>? B
636 ;
637
638 The predicate used for alt 2 of rule1 is (Alpha || Beta). This
639 appears to be different than the predicate Alpha used for alt1.
640 However, the context of Beta is B. Thus when the lookahead is A
641 Beta will have no resolving power and Alpha will be used for both
642 alternatives. Using the same predicate for both alternatives isn't
643 very helpful, but this will not be detected with 1.33MR11.
644
645 To properly handle this the predicate expression would have to be
646 evaluated for each distinct lookahead context.
647
648 To determine whether two predicate expressions are identical is
649 difficult. The routine may fail to identify identical predicates.
650
651 The #pred feature also compares predicates to see if a choice between
652 alternatives which is resolved by a predicate which makes the second
653 choice unreachable. Consider the following example:
654
655 #pred A <<A(LATEXT(1)>>?
656 #pred B <<B(LATEXT(1)>>?
657 #pred A_or_B A || B
658
659 r : s
660 | t
661 ;
662 s : <<A_or_B>>? ID
663 ;
664 t : <<A>>? ID
665 ;
666
667 ----------------------------------------------------------------------------
668 t11.g, line 5: warning: the predicate used to disambiguate the
669 first choice of rule r
670 (file t11.g alt 1 line 5 and alt 2 line 6)
671 appears to "cover" the second predicate when compared without context.
672 The second predicate may have no resolving power for some lookahead
673 sequences.
674 ----------------------------------------------------------------------------
675
676 #139. (Changed in MR11) Problem with -gp in C++ mode
677
678 The -gp option to add a prefix to rule names did not work in
679 C++ mode. This has been fixed.
680
681 Reported by Alexey Demakov (demakov@kazbek.ispras.ru).
682
683 #138. (Changed in MR11) Additional makefiles for non-MSVC++ MS systems
684
685 Sramji Ramanathan (ps@kumaran.com) has supplied makefiles for
686 building antlr and dlg with Win95/NT development tools that
687 are not based on MSVC5. They are pccts/antlr/AntlrMS.mak and
688 pccts/dlg/DlgMS.mak.
689
690 The first line of the makefiles require a definition of PCCTS_HOME.
691
692 These are in additiion to the AntlrMSVC50.* and DlgMSVC50.*
693 supplied by Jeff Vincent (JVincent@novell.com).
694
695 #137. (Changed in MR11) Token getType(), getText(), getLine() const members
696
697 --------------------------------------------------------------------
698 If you use ANTLRCommonToken this change probably does not affect you.
699 --------------------------------------------------------------------
700
701 For a long time it has bothered me that these accessor functions
702 in ANTLRAbstractToken were not const member functions. I have
703 refrained from changing them because it require users to modify
704 existing token class definitions which are derived directly
705 from ANTLRAbstractToken. I think it is now time.
706
707 For those who are not used to C++, a "const member function" is a
708 member function which does not modify its own object - the thing
709 to which "this" points. This is quite different from a function
710 which does not modify its arguments
711
712 Most token definitions based on ANTLRAbstractToken have something like
713 the following in order to create concrete definitions of the pure
714 virtual methods in ANTLRAbstractToken:
715
716 class MyToken : public ANTLRAbstractToken {
717 ...
718 ANTLRTokenType getType() {return _type; }
719 int getLine() {return _line; }
720 ANTLRChar * getText() {return _text; }
721 ...
722 }
723
724 The required change is simply to put "const" following the function
725 prototype in the header (.h file) and the definition file (.cpp if
726 it is not inline):
727
728 class MyToken : public ANTLRAbstractToken {
729 ...
730 ANTLRTokenType getType() const {return _type; }
731 int getLine() const {return _line; }
732 ANTLRChar * getText() const {return _text; }
733 ...
734 }
735
736 This was originally proposed a long time ago by Bruce
737 Guenter (bruceg@qcc.sk.ca).
738
739 #136. (Changed in MR11) Added getLength() to ANTLRCommonToken
740
741 Classes ANTLRCommonToken and ANTLRCommonTokenNoRefCountToken
742 now have a member function:
743
744 int getLength() const { return strlen(getText()) }
745
746 Suggested by Sramji Ramanathan (ps@kumaran.com).
747
748 #135. (Changed in MR11) Raised antlr's own default ZZLEXBUFSIZE to 8k
749
750 #134a. (ansi_mr10.zip) T.J. Parr's ANSI C grammar made 1.33MR11 compatible
751
752 There is a typographical error in the definition of BITWISEOREQ:
753
754 #token BITWISEOREQ "!=" should be "\|="
755
756 When this change is combined with the bugfix to the follow set cache
757 problem (Item #147) and a minor rearrangement of the grammar
758 (Item #134b) it becomes a k=1 ck=2 grammar.
759
760 #134b. (ansi_mr10.zip) T.J. Parr's ANSI C grammar made 1.33MR11 compatible
761
762 The following changes were made in the ansi.g grammar (along with
763 using -mrhoist on):
764
765 ansi.g
766 ======
767 void tracein(char *) ====> void tracein(const char *)
768 void traceout(char *) ====> void traceout(const char *)
769
770 <LT(1)->getType()==IDENTIFIER ? isTypeName(LT(1)->getText()) : 1>>?
771 ====> <<isTypeName(LT(1)->getText())>>?
772
773 <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \
774 isTypeName(LT(2)->getText()) : 1>>?
775 ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?
776
777 <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \
778 isTypeName(LT(2)->getText()) : 1>>?
779 ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?
780
781 added to init(): traceOptionValueDefault=0;
782 added to init(): traceOption(-1);
783
784 change rule "statement":
785
786 statement
787 : plain_label_statement
788 | case_label_statement
789 | <<;>> expression SEMICOLON
790 | compound_statement
791 | selection_statement
792 | iteration_statement
793 | jump_statement
794 | SEMICOLON
795 ;
796
797 plain_label_statement
798 : IDENTIFIER COLON statement
799 ;
800
801 case_label_statement
802 : CASE constant_expression COLON statement
803 | DEFAULT COLON statement
804 ;
805
806 support.cpp
807 ===========
808 void tracein(char *) ====> void tracein(const char *)
809 void traceout(char *) ====> void traceout(const char *)
810
811 added to tracein(): ANTLRParser::tracein(r); // call superclass method
812 added to traceout(): ANTLRParser::traceout(r); // call superclass method
813
814 Makefile
815 ========
816 added to AFLAGS: -mrhoist on -prc on
817
818 #133. (Changed in 1.33MR11) Make trace options public in ANTLRParser
819
820 In checking T.J. Parr's ANSI C grammar for compatibility with
821 1.33MR11 discovered that it was inconvenient to have the
822 trace facilities with protected access.
823
824 #132. (Changed in 1.33MR11) Recognition of identical predicates in alts
825
826 Prior to 1.33MR11, there would be no ambiguity warning when the
827 very same predicate was used to disambiguate both alternatives:
828
829 test: ref B
830 | ref C
831 ;
832
833 ref : <<pred(LATEXT(1)>>? A
834
835 In 1.33MR11 this will cause the warning:
836
837 warning: the predicates used to disambiguate rule test
838 (file v98.g alt 1 line 1 and alt 2 line 2)
839 are identical and have no resolving power
840
841 ----------------- Note -----------------
842
843 This is different than the following case
844
845 test: <<pred(LATEXT(1))>>? A B
846 | <<pred(LATEXT(1)>>? A C
847 ;
848
849 In this case there are two distinct predicates
850 which have exactly the same text. In the first
851 example there are two references to the same
852 predicate. The problem represented by this
853 grammar will be addressed later.
854
855 #131. (Changed in 1.33MR11) Case insensitive command line options
856
857 Command line switches like "-CC" and keywords like "on", "off",
858 and "stdin" are no longer case sensitive in antlr, dlg, and sorcerer.
859
860 #130. (Changed in 1.33MR11) Changed ANTLR_VERSION to int from string
861
862 The ANTLR_VERSION was not an integer, making it difficult to
863 perform conditional compilation based on the antlr version.
864
865 Henceforth, ANTLR_VERSION will be:
866
867 (base_version * 10000) + release number
868
869 thus 1.33MR11 will be: 133*100+11 = 13311
870
871 Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE).
872
873 #129. (Changed in 1.33MR11) Addition of ANTLR_VERSION to <parserName>.h
874
875 The following code is now inserted into <parserName>.h amd
876 stdpccts.h:
877
878 #ifndef ANTLR_VERSION
879 #define ANTLR_VERSION 13311
880 #endif
881
882 Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE)
883
884 #128. (Changed in 1.33MR11) Redundant predicate code in (<<pred>>? ...)+
885
886 Prior to 1.33MR11, the following grammar would generate
887 redundant tests for the "while" condition.
888
889 rule2 : (<<pred>>? X)+ X
890 | B
891 ;
892
893 The code would resemble:
894
895 if (LA(1)==X) {
896 if (pred) {
897 do {
898 if (!pred) {zzfailed_pred(" pred");}
899 zzmatch(X); zzCONSUME;
900 } while (LA(1)==X && pred && pred);
901 } else {...
902
903 With 1.33MR11 the redundant predicate test is omitted.
904
905 #127. (Changed in 1.33MR11)
906
907 Count Syntax Errors Count DLG Errors
908 ------------------- ----------------
909
910 C++ mode ANTLRParser:: DLGLexerBase::
911 syntaxErrCount lexErrCount
912 C mode zzSyntaxErrCount zzLexErrCount
913
914 The C mode variables are global and initialized to 0.
915 They are *not* reset to 0 automatically when antlr is
916 restarted.
917
918 The C++ mode variables are public. They are initialized
919 to 0 by the constructors. They are *not* reset to 0 by the
920 ANTLRParser::init() method.
921
922 Suggested by Reinier van den Born (reinier@vnet.ibm.com).
923
924 #126. (Changed in 1.33MR11) Addition of #first <<...>>
925
926 The #first <<...>> inserts the specified text in the output
927 files before any other #include statements required by pccts.
928 The only things before the #first text are comments and
929 a #define ANTLR_VERSION.
930
931 Requested by and Esa Pulkkinen (esap@cs.tut.fi) and Alexin
932 Zoltan (alexin@inf.u-szeged.hu).
933
934 #125. (Changed in 1.33MR11) Lookahead for (guard)? && <<p>>? predicates
935
936 When implementing the new style of guard predicate (Item #113)
937 in 1.33MR10 I decided to temporarily ignore the problem of
938 computing the "narrowest" lookahead context.
939
940 Consider the following k=1 grammar:
941
942 start : a
943 | b
944 ;
945
946 a : (A)? && <<pred1(LATEXT(1))>>? ab ;
947 b : (B)? && <<pred2(LATEXT(1))>>? ab ;
948
949 ab : A | B ;
950
951 In MR10 the context for both "a" and "b" was {A B} because this is
952 the first set of rule "ab". Normally, this is not a problem because
953 the predicate which follows the guard inhibits any ambiguity report
954 by antlr.
955
956 In MR11 the first set for rule "a" is {A} and for rule "b" it is {B}.
957
958 #124. A Note on the New "&&" Style Guarded Predicates
959
960 I've been asked several times, "What is the difference between
961 the old "=>" style guard predicates and the new style "&&" guard
962 predicates, and how do you choose one over the other" ?
963
964 The main difference is that the "=>" does not apply the
965 predicate if the context guard doesn't match, whereas
966 the && form always does. What is the significance ?
967
968 If you have a predicate which is not on the "leading edge"
969 it cannot be hoisted. Suppose you need a predicate that
970 looks at LA(2). You must introduce it manually. The
971 classic example is:
972
973 castExpr :
974 LP typeName RP
975 | ....
976 ;
977
978 typeName : <<isTypeName(LATEXT(1))>>? ID
979 | STRUCT ID
980 ;
981
982 The problem is that typeName isn't on the leading edge
983 of castExpr, so the predicate isTypeName won't be hoisted into
984 castExpr to help make a decision on which production to choose.
985
986 The *first* attempt to fix it is this:
987
988 castExpr :
989 <<isTypeName(LATEXT(2))>>?
990 LP typeName RP
991 | ....
992 ;
993
994 Unfortunately, this won't work because it ignores
995 the problem of STRUCT. The solution is to apply
996 isTypeName() in castExpr if LA(2) is an ID and
997 don't apply it when LA(2) is STRUCT:
998
999 castExpr :
1000 (LP ID)? => <<isTypeName(LATEXT(2))>>?
1001 LP typeName RP
1002 | ....
1003 ;
1004
1005 In conclusion, the "=>" style guarded predicate is
1006 useful when:
1007
1008 a. the tokens required for the predicate
1009 are not on the leading edge
1010 b. there are alternatives in the expression
1011 selected by the predicate for which the
1012 predicate is inappropriate
1013
1014 If (b) were false, then one could use a simple
1015 predicate (assuming "-prc on"):
1016
1017 castExpr :
1018 <<isTypeName(LATEXT(2))>>?
1019 LP typeName RP
1020 | ....
1021 ;
1022
1023 typeName : <<isTypeName(LATEXT(1))>>? ID
1024 ;
1025
1026 So, when do you use the "&&" style guarded predicate ?
1027
1028 The new-style "&&" predicate should always be used with
1029 predicate context. The context guard is in ADDITION to
1030 the automatically computed context. Thus it useful for
1031 predicates which depend on the token type for reasons
1032 other than context.
1033
1034 The following example is contributed by Reinier van den Born
1035 (reinier@vnet.ibm.com).
1036
1037 +-------------------------------------------------------------------------+
1038 | This grammar has two ways to call functions: |
1039 | |
1040 | - a "standard" call syntax with parens and comma separated args |
1041 | - a shell command like syntax (no parens and spacing separated args) |
1042 | |
1043 | The former also allows a variable to hold the name of the function, |
1044 | the latter can also be used to call external commands. |
1045 | |
1046 | The grammar (simplified) looks like this: |
1047 | |
1048 | fun_call : ID "(" { expr ("," expr)* } ")" |
1049 | /* ID is function name */ |
1050 | | "@" ID "(" { expr ("," expr)* } ")" |
1051 | /* ID is var containing fun name */ |
1052 | ; |
1053 | |
1054 | command : ID expr* /* ID is function name */ |
1055 | | path expr* /* path is external command name */ |
1056 | ; |
1057 | |
1058 | path : ID /* left out slashes and such */ |
1059 | | "@" ID /* ID is environment var */ |
1060 | ; |
1061 | |
1062 | expr : .... |
1063 | | "(" expr ")"; |
1064 | |
1065 | call : fun_call |
1066 | | command |
1067 | ; |
1068 | |
1069 | Obviously the call is wildly ambiguous. This is more or less how this |
1070 | is to be resolved: |
1071 | |
1072 | A call begins with an ID or an @ followed by an ID. |
1073 | |
1074 | If it is an ID and if it is an ext. command name -> command |
1075 | if followed by a paren -> fun_call |
1076 | otherwise -> command |
1077 | |
1078 | If it is an @ and if the ID is a var name -> fun_call |
1079 | otherwise -> command |
1080 | |
1081 | One can implement these rules quite neatly using && predicates: |
1082 | |
1083 | call : ("@" ID)? && <<isVarName(LT(2))>>? fun_call |
1084 | | (ID)? && <<isExtCmdName>>? command |
1085 | | (ID "(")? fun_call |
1086 | | command |
1087 | ; |
1088 | |
1089 | This can be done better, so it is not an ideal example, but it |
1090 | conveys the principle. |
1091 +-------------------------------------------------------------------------+
1092
1093 #123. (Changed in 1.33MR11) Correct definition of operators in ATokPtr.h
1094
1095 The return value of operators in ANTLRTokenPtr:
1096
1097 changed: unsigned ... operator !=(...)
1098 to: int ... operator != (...)
1099 changed: unsigned ... operator ==(...)
1100 to: int ... operator == (...)
1101
1102 Suggested by R.A. Nelson (cowboy@VNET.IBM.COM)
1103
1104 #122. (Changed in 1.33MR11) Member functions to reset DLG in C++ mode
1105
1106 void DLGFileReset(FILE *f) { input = f; found_eof = 0; }
1107 void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }
1108
1109 Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)
1110
1111 #121. (Changed in 1.33MR11) Another attempt to fix -o (output dir) option
1112
1113 Another attempt is made to improve the -o option of antlr, dlg,
1114 and sorcerer. This one by JVincent (JVincent@novell.com).
1115
1116 The current rule:
1117
1118 a. If -o is not specified than any explicit directory
1119 names are retained.
1120
1121 b. If -o is specified than the -o directory name overrides any
1122 explicit directory names.
1123
1124 c. The directory name of the grammar file is *not* stripped
1125 to create the main output file. However it is stil subject
1126 to override by the -o directory name.
1127
1128 #120. (Changed in 1.33MR11) "-info f" output to stdout rather than stderr
1129
1130 Added option 0 (e.g. "-info 0") which is a noop.
1131
1132 #119. (Changed in 1.33MR11) Ambiguity aid for grammars
1133
1134 The user can ask for additional information on ambiguities reported
1135 by antlr to stdout. At the moment, only one ambiguity report can
1136 be created in an antlr run.
1137
1138 This feature is enabled using the "-aa" (Ambiguity Aid) option.
1139
1140 The following options control the reporting of ambiguities:
1141
1142 -aa ruleName Selects reporting by name of rule
1143 -aa lineNumber Selects reporting by line number
1144 (file name not compared)
1145
1146 -aam Selects "multiple" reporting for a token
1147 in the intersection set of the
1148 alternatives.
1149
1150 For instance, the token ID may appear dozens
1151 of times in various paths as the program
1152 explores the rules which are reachable from
1153 the point of an ambiguity. With option -aam
1154 every possible path the search program
1155 encounters is reported.
1156
1157 Without -aam only the first encounter is
1158 reported. This may result in incomplete
1159 information, but the information may be
1160 sufficient and much shorter.
1161
1162 -aad depth Selects the depth of the search.
1163 The default value is 1.
1164
1165 The number of paths to be searched, and the
1166 size of the report can grow geometrically
1167 with the -ck value if a full search for all
1168 contributions to the source of the ambiguity
1169 is explored.
1170
1171 The depth represents the number of tokens
1172 in the lookahead set which are matched against
1173 the set of ambiguous tokens. A depth of 1
1174 means that the search stops when a lookahead
1175 sequence of just one token is matched.
1176
1177 A k=1 ck=6 grammar might generate 5,000 items
1178 in a report if a full depth 6 search is made
1179 with the Ambiguity Aid. The source of the
1180 problem may be in the first token and obscured
1181 by the volume of data - I hesitate to call
1182 it information.
1183
1184 When the user selects a depth > 1, the search
1185 is first performed at depth=1 for both
1186 alternatives, then depth=2 for both alternatives,
1187 etc.
1188
1189 Sample output for rule grammar in antlr.g itself:
1190
1191 +---------------------------------------------------------------------+
1192 | Ambiguity Aid |
1193 | |
1194 | Choice 1: grammar/70 line 632 file a.g |
1195 | Choice 2: grammar/82 line 644 file a.g |
1196 | |
1197 | Intersection of lookahead[1] sets: |
1198 | |
1199 | "\}" "class" "#errclass" "#tokclass" |
1200 | |
1201 | Choice:1 Depth:1 Group:1 ("#errclass") |
1202 | 1 in (...)* block grammar/70 line 632 a.g |
1203 | 2 to error grammar/73 line 635 a.g |
1204 | 3 error error/1 line 894 a.g |
1205 | 4 #token "#errclass" error/2 line 895 a.g |
1206 | |
1207 | Choice:1 Depth:1 Group:2 ("#tokclass") |
1208 | 2 to tclass grammar/74 line 636 a.g |
1209 | 3 tclass tclass/1 line 937 a.g |
1210 | 4 #token "#tokclass" tclass/2 line 938 a.g |
1211 | |
1212 | Choice:1 Depth:1 Group:3 ("class") |
1213 | 2 to class_def grammar/75 line 637 a.g |
1214 | 3 class_def class_def/1 line 669 a.g |
1215 | 4 #token "class" class_def/3 line 671 a.g |
1216 | |
1217 | Choice:1 Depth:1 Group:4 ("\}") |
1218 | 2 #token "\}" grammar/76 line 638 a.g |
1219 | |
1220 | Choice:2 Depth:1 Group:5 ("#errclass") |
1221 | 1 in (...)* block grammar/83 line 645 a.g |
1222 | 2 to error grammar/93 line 655 a.g |
1223 | 3 error error/1 line 894 a.g |
1224 | 4 #token "#errclass" error/2 line 895 a.g |
1225 | |
1226 | Choice:2 Depth:1 Group:6 ("#tokclass") |
1227 | 2 to tclass grammar/94 line 656 a.g |
1228 | 3 tclass tclass/1 line 937 a.g |
1229 | 4 #token "#tokclass" tclass/2 line 938 a.g |
1230 | |
1231 | Choice:2 Depth:1 Group:7 ("class") |
1232 | 2 to class_def grammar/95 line 657 a.g |
1233 | 3 class_def class_def/1 line 669 a.g |
1234 | 4 #token "class" class_def/3 line 671 a.g |
1235 | |
1236 | Choice:2 Depth:1 Group:8 ("\}") |
1237 | 2 #token "\}" grammar/96 line 658 a.g |
1238 +---------------------------------------------------------------------+
1239
1240 For a linear lookahead set ambiguity (where k=1 or for k>1 but
1241 when all lookahead sets [i] with i<k all have degree one) the
1242 reports appear in the following order:
1243
1244 for (depth=1 ; depth <= "-aad depth" ; depth++) {
1245 for (alternative=1; alternative <=2 ; alternative++) {
1246 while (matches-are-found) {
1247 group++;
1248 print-report
1249 };
1250 };
1251 };
1252
1253 For reporting a k-tuple ambiguity, the reports appear in the
1254 following order:
1255
1256 for (depth=1 ; depth <= "-aad depth" ; depth++) {
1257 while (matches-are-found) {
1258 for (alternative=1; alternative <=2 ; alternative++) {
1259 group++;
1260 print-report
1261 };
1262 };
1263 };
1264
1265 This is because matches are generated in different ways for
1266 linear lookahead and k-tuples.
1267
1268 #118. (Changed in 1.33MR11) DEC VMS makefile and VMS related changes
1269
1270 Revised makefiles for DEC/VMS operating system for antlr, dlg,
1271 and sorcerer.
1272
1273 Reduced names of routines with external linkage to less than 32
1274 characters to conform to DEC/VMS linker limitations.
1275
1276 Jean-Francois Pieronne discovered problems with dlg and antlr
1277 due to the VMS linker not being case sensitive for names with
1278 external linkage. In dlg the problem was with "className" and
1279 "ClassName". In antlr the problem was with "GenExprSets" and
1280 "genExprSets".
1281
1282 Added genmms, a version of genmk for the DEC/VMS version of make.
1283 The source is in directory pccts/support/DECmms.
1284
1285 All VMS contributions by Jean-Francois Pieronne (jfp@iname.com).
1286
1287 #117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code
1288
1289 The hoisting of predicates into rules to create prediction
1290 expressions is a problem in antlr. Consider the following
1291 example (k=1 with -prc on):
1292
1293 start : (a)* "@" ;
1294 a : b | c ;
1295 b : <<isUpper(LATEXT(1))>>? A ;
1296 c : A ;
1297
1298 Prior to 1.33MR10 the code generated for "start" would resemble:
1299
1300 while {
1301 if (LA(1)==A &&
1302 (!LA(1)==A || isUpper())) {
1303 a();
1304 }
1305 };
1306
1307 This code is wrong because it makes rule "c" unreachable from
1308 "start". The essence of the problem is that antlr fails to
1309 recognize that there can be a valid alternative within "a" even
1310 when the predicate <<isUpper(LATEXT(1))>>? is false.
1311
1312 In 1.33MR10 with -mrhoist the hoisting of the predicate into
1313 "start" is suppressed because it recognizes that "c" can
1314 cover all the cases where the predicate is false:
1315
1316 while {
1317 if (LA(1)==A) {
1318 a();
1319 }
1320 };
1321
1322 With the antlr "-info p" switch the user will receive information
1323 about the predicate suppression in the generated file:
1324
1325 --------------------------------------------------------------
1326 #if 0
1327
1328 Hoisting of predicate suppressed by alternative without predicate.
1329 The alt without the predicate includes all cases where
1330 the predicate is false.
1331
1332 WITH predicate: line 7 v1.g
1333 WITHOUT predicate: line 7 v1.g
1334
1335 The context set for the predicate:
1336
1337 A
1338
1339 The lookahead set for the alt WITHOUT the semantic predicate:
1340
1341 A
1342
1343 The predicate:
1344
1345 pred << isUpper(LATEXT(1))>>?
1346 depth=k=1 rule b line 9 v1.g
1347 set context:
1348 A
1349 tree context: null
1350
1351 Chain of referenced rules:
1352
1353 #0 in rule start (line 5 v1.g) to rule a
1354 #1 in rule a (line 7 v1.g)
1355
1356 #endif
1357 --------------------------------------------------------------
1358
1359 A predicate can be suppressed by a combination of alternatives
1360 which, taken together, cover a predicate:
1361
1362 start : (a)* "@" ;
1363
1364 a : b | ca | cb | cc ;
1365
1366 b : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;
1367
1368 ca : A ;
1369 cb : B ;
1370 cc : C ;
1371
1372 Consider a more complex example in which "c" covers only part of
1373 a predicate:
1374
1375 start : (a)* "@" ;
1376
1377 a : b
1378 | c
1379 ;
1380
1381 b : <<isUpper(LATEXT(1))>>?
1382 ( A
1383 | X
1384 );
1385
1386 c : A
1387 ;
1388
1389 Prior to 1.33MR10 the code generated for "start" would resemble:
1390
1391 while {
1392 if ( (LA(1)==A || LA(1)==X) &&
1393 (! (LA(1)==A || LA(1)==X) || isUpper()) {
1394 a();
1395 }
1396 };
1397
1398 With 1.33MR10 and -mrhoist the predicate context is restricted to
1399 the non-covered lookahead. The code resembles:
1400
1401 while {
1402 if ( (LA(1)==A || LA(1)==X) &&
1403 (! (LA(1)==X) || isUpper()) {
1404 a();
1405 }
1406 };
1407
1408 With the antlr "-info p" switch the user will receive information
1409 about the predicate restriction in the generated file:
1410
1411 --------------------------------------------------------------
1412 #if 0
1413
1414 Restricting the context of a predicate because of overlap
1415 in the lookahead set between the alternative with the
1416 semantic predicate and one without
1417 Without this restriction the alternative without the predicate
1418 could not be reached when input matched the context of the
1419 predicate and the predicate was false.
1420
1421 WITH predicate: line 11 v4.g
1422 WITHOUT predicate: line 12 v4.g
1423
1424 The original context set for the predicate:
1425
1426 A X
1427
1428 The lookahead set for the alt WITHOUT the semantic predicate:
1429
1430 A
1431
1432 The intersection of the two sets
1433
1434 A
1435
1436 The original predicate:
1437
1438 pred << isUpper(LATEXT(1))>>?
1439 depth=k=1 rule b line 15 v4.g
1440 set context:
1441 A X
1442 tree context: null
1443
1444 The new (modified) form of the predicate:
1445
1446 pred << isUpper(LATEXT(1))>>?
1447 depth=k=1 rule b line 15 v4.g
1448 set context:
1449 X
1450 tree context: null
1451
1452 #endif
1453 --------------------------------------------------------------
1454
1455 The bad news about -mrhoist:
1456
1457 (a) -mrhoist does not analyze predicates with lookahead
1458 depth > 1.
1459
1460 (b) -mrhoist does not look past a guarded predicate to
1461 find context which might cover other predicates.
1462
1463 For these cases you might want to use syntactic predicates.
1464 When a semantic predicate fails during guess mode the guess
1465 fails and the next alternative is tried.
1466
1467 Limitation (a) is illustrated by the following example:
1468
1469 start : (stmt)* EOF ;
1470
1471 stmt : cast
1472 | expr
1473 ;
1474 cast : <<isTypename(LATEXT(2))>>? LP ID RP ;
1475
1476 expr : LP ID RP ;
1477
1478 This is not much different from the first example, except that
1479 it requires two tokens of lookahead context to determine what
1480 to do. This predicate is NOT suppressed because the current version
1481 is unable to handle predicates with depth > 1.
1482
1483 A predicate can be combined with other predicates during hoisting.
1484 In those cases the depth=1 predicates are still handled. Thus,
1485 in the following example the isUpper() predicate will be suppressed
1486 by line #4 when hoisted from "bizarre" into "start", but will still
1487 be present in "bizarre" in order to predict "stmt".
1488
1489 start : (bizarre)* EOF ; // #1
1490 // #2
1491 bizarre : stmt // #3
1492 | A // #4
1493 ;
1494
1495 stmt : cast
1496 | expr
1497 ;
1498
1499 cast : <<isTypename(LATEXT(2))>>? LP ID RP ;
1500
1501 expr : LP ID RP ;
1502 | <<isUpper(LATEXT(1))>>? A
1503
1504 Limitation (b) is illustrated by the following example of a
1505 context guarded predicate:
1506
1507 rule : (A)? <<p>>? // #1
1508 (A // #2
1509 |B // #3
1510 ) // #4
1511 | <<q>> B // #5
1512 ;
1513
1514 Recall that this means that when the lookahead is NOT A then
1515 the predicate "p" is ignored and it attempts to match "A|B".
1516 Ideally, the "B" at line #3 should suppress predicate "q".
1517 However, the current version does not attempt to look past
1518 the guard predicate to find context which might suppress other
1519 predicates.
1520
1521 In some cases -mrhoist will lead to the reporting of ambiguities
1522 which were not visible before:
1523
1524 start : (a)* "@";
1525 a : bc | d;
1526 bc : b | c ;
1527
1528 b : <<isUpper(LATEXT(1))>>? A;
1529 c : A ;
1530
1531 d : A ;
1532
1533 In this case there is a true ambiguity in "a" between "bc" and "d"
1534 which can both match "A". Without -mrhoist the predicate in "b"
1535 is hoisted into "a" and there is no ambiguity reported. However,
1536 with -mrhoist, the predicate in "b" is suppressed by "c" (as it
1537 should be) making the ambiguity in "a" apparent.
1538
1539 The motivations for these changes were hoisting problems reported
1540 by Reinier van den Born (reinier@vnet.ibm.com) and several others.
1541
1542 #116. (Changed in 1.33MR10) C++ mode: tracein/traceout rule name is (const char *)
1543
1544 The prototype for C++ mode routine tracein (and traceout) has changed from
1545 "char *" to "const char *".
1546
1547 #115. (Changed in 1.33MR10) Using guess mode with exception handlers in C mode
1548
1549 The definition of the C mode macros zzmatch_wsig and zzsetmatch_wsig
1550 neglected to consider guess mode. When control passed to the rule's
1551 parse exception handler the routine would exit without ever closing the
1552 guess block. This would lead to unpredictable behavior.
1553
1554 In 1.33MR10 the behavior of exceptions in C mode and C++ mode should be
1555 identical.
1556
1557 #114. (Changed in 1.33MR10) difference in [zz]resynch() between C and C++ modes
1558
1559 There was a slight difference in the way C and C++ mode resynchronized
1560 following a parsing error. The C routine would sometimes skip an extra
1561 token before attempting to resynchronize.
1562
1563 The C routine was changed to match the C++ routine.
1564
1565 #113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr
1566
1567 The existing context guarded predicate:
1568
1569 rule : (guard)? => <<p>>? expr
1570 | next_alternative
1571 ;
1572
1573 generates code which resembles:
1574
1575 if (lookahead(expr) && (!guard || pred)) {
1576 expr()
1577 } else ....
1578
1579 This is not suitable for some applications because it allows
1580 expr() to be invoked when the predicate is false. This is
1581 intentional because it is meant to mimic automatically computed
1582 predicate context.
1583
1584 The new context guarded predicate uses the guard information
1585 differently because it has a different goal. Consider:
1586
1587 rule : (guard)? && <<p>>? expr
1588 | next_alternative
1589 ;
1590
1591 The new style of context guarded predicate is equivalent to:
1592
1593 rule : <<guard==true && pred>>? expr
1594 | next_alternative
1595 ;
1596
1597 It generates code which resembles:
1598
1599 if (lookahead(expr) && guard && pred) {
1600 expr();
1601 } else ...
1602
1603 Both forms of guarded predicates severely restrict the form of
1604 the context guard: it can contain no rule references, no
1605 (...)*, no (...)+, and no {...}. It may contain token and
1606 token class references, and alternation ("|").
1607
1608 Addition for 1.33MR11: in the token expression all tokens must
1609 be at the same height of the token tree:
1610
1611 (A ( B | C))? && ... is ok (all height 2)
1612 (A ( B | ))? && ... is not ok (some 1, some 2)
1613 (A B C D | E F G H)? && ... is ok (all height 4)
1614 (A B C D | E )? && ... is not ok (some 4, some 1)
1615
1616 This restriction is required in order to properly compute the lookahead
1617 set for expressions like:
1618
1619 rule1 : (A B C)? && <<pred>>? rule2 ;
1620 rule2 : (A|X) (B|Y) (C|Z);
1621
1622 This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)
1623
1624 #112. (Changed in 1.33MR10) failed validation predicate in C guess mode
1625
1626 John Lilley (jlilley@empathy.com) suggested that failed validation
1627 predicates abort a guess rather than reporting a failed error.
1628 This was installed in C++ mode (Item #4). Only now was it noticed
1629 that the fix was never installed for C mode.
1630
1631 #111. (Changed in 1.33MR10) moved zzTRACEIN to before init action
1632
1633 When the antlr -gd switch is present antlr generates calls to
1634 zzTRACEIN at the start of a rule and zzTRACEOUT at the exit
1635 from a rule. Prior to 1.33MR10 Tthe call to zzTRACEIN was
1636 after the init-action, which could cause confusion because the
1637 init-actions were reported with the name of the enclosing rule,
1638 rather than the active rule.
1639
1640 #110. (Changed in 1.33MR10) antlr command line copied to generated file
1641
1642 The antlr command line is now copied to the generated file near
1643 the start.
1644
1645 #109. (Changed in 1.33MR10) improved trace information
1646
1647 The quality of the trace information provided by the "-gd"
1648 switch has been improved significantly. Here is an example
1649 of the output from a test program. It shows the rule name,
1650 the first token of lookahead, the call depth, and the guess
1651 status:
1652
1653 exit rule gusxx {"?"} depth 2
1654 enter rule gusxx {"?"} depth 2
1655 enter rule gus1 {"o"} depth 3 guessing
1656 guess done - returning to rule gus1 {"o"} at depth 3
1657 (guess mode continues - an enclosing guess is still active)
1658 guess done - returning to rule gus1 {"Z"} at depth 3
1659 (guess mode continues - an enclosing guess is still active)
1660 exit rule gus1 {"Z"} depth 3 guessing
1661 guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)
1662 enter rule gus1 {"o"} depth 3
1663 guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)
1664 guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)
1665 exit rule gus1 {"Z"} depth 3
1666 line 1: syntax error at "Z" missing SC
1667 ...
1668
1669 Rule trace reporting is controlled by the value of the integer
1670 [zz]traceOptionValue: when it is positive tracing is enabled,
1671 otherwise it is disabled. Tracing during guess mode is controlled
1672 by the value of the integer [zz]traceGuessOptionValue. When
1673 it is positive AND [zz]traceOptionValue is positive rule trace
1674 is reported in guess mode.
1675
1676 The values of [zz]traceOptionValue and [zz]traceGuessOptionValue
1677 can be adjusted by subroutine calls listed below.
1678
1679 Depending on the presence or absence of the antlr -gd switch
1680 the variable [zz]traceOptionValueDefault is set to 0 or 1. When
1681 the parser is initialized or [zz]traceReset() is called the
1682 value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.
1683 The value of [zz]traceGuessOptionValue is always initialzed to 1,
1684 but, as noted earlier, nothing will be reported unless
1685 [zz]traceOptionValue is also positive.
1686
1687 When the parser state is saved/restored the value of the trace
1688 variables are also saved/restored. If a restore causes a change in
1689 reporting behavior from on to off or vice versa this will be reported.
1690
1691 When the -gd option is selected, the macro "#define zzTRACE_RULES"
1692 is added to appropriate output files.
1693
1694 C++ mode
1695 --------
1696 int traceOption(int delta)
1697 int traceGuessOption(int delta)
1698 void traceReset()
1699 int traceOptionValueDefault
1700
1701 C mode
1702 --------
1703 int zzTraceOption(int delta)
1704 int zzTraceGuessOption(int delta)
1705 void zzTraceReset()
1706 int zzTraceOptionValueDefault
1707
1708 The argument "delta" is added to the traceOptionValue. To
1709 turn on trace when inside a particular rule one:
1710
1711 rule : <<traceOption(+1);>>
1712 (
1713 rest-of-rule
1714 )
1715 <<traceOption(-1);>>
1716 ; /* fail clause */ <<traceOption(-1);>>
1717
1718 One can use the same idea to turn *off* tracing within a
1719 rule by using a delta of (-1).
1720
1721 An improvement in the rule trace was suggested by Sramji
1722 Ramanathan (ps@kumaran.com).
1723
1724 #108. A Note on Deallocation of Variables Allocated in Guess Mode
1725
1726 NOTE
1727 ------------------------------------------------------
1728 This mechanism only works for heap allocated variables
1729 ------------------------------------------------------
1730
1731 The rewrite of the trace provides the machinery necessary
1732 to properly free variables or undo actions following a
1733 failed guess.
1734
1735 The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded
1736 as part of the zzGUESS macro. When a guess is opened
1737 the value of zzrv is 0. When a longjmp() is executed to
1738 undo the guess, the value of zzrv will be 1.
1739
1740 The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded
1741 as part of the zzGUESS_DONE macro. This is executed
1742 whether the guess succeeds or fails as part of closing
1743 the guess.
1744
1745 The guessSeq is a sequence number which is assigned to each
1746 guess and is incremented by 1 for each guess which becomes
1747 active. It is needed by the user to associate the start of
1748 a guess with the failure and/or completion (closing) of a
1749 guess.
1750
1751 Guesses are nested. They must be closed in the reverse
1752 of the order that they are opened.
1753
1754 In order to free memory used by a variable during a guess
1755 a user must write a routine which can be called to
1756 register the variable along with the current guess sequence
1757 number provided by the zzUSER_GUESS_HOOK macro. If the guess
1758 fails, all variables tagged with the corresponding guess
1759 sequence number should be released. This is ugly, but
1760 it would require a major rewrite of antlr 1.33 to use
1761 some mechanism other than setjmp()/longjmp().
1762
1763 The order of calls for a *successful* guess would be:
1764
1765 zzUSER_GUESS_HOOK(guessSeq,0);
1766 zzUSER_GUESS_DONE_HOOK(guessSeq);
1767
1768 The order of calls for a *failed* guess would be:
1769
1770 zzUSER_GUESS_HOOK(guessSeq,0);
1771 zzUSER_GUESS_HOOK(guessSeq,1);
1772 zzUSER_GUESS_DONE_HOOK(guessSeq);
1773
1774 The default definitions of these macros are empty strings.
1775
1776 Here is an example in C++ mode. The zzUSER_GUESS_HOOK and
1777 zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine
1778 can be used without change in both C and C++ versions.
1779
1780 ----------------------------------------------------------------------
1781 <<
1782
1783 #include "AToken.h"
1784
1785 typedef ANTLRCommonToken ANTLRToken;
1786
1787 #include "DLGLexer.h"
1788
1789 int main() {
1790
1791 {
1792 DLGFileInput in(stdin);
1793 DLGLexer lexer(&in,2000);
1794 ANTLRTokenBuffer pipe(&lexer,1);
1795 ANTLRCommonToken aToken;
1796 P parser(&pipe);
1797
1798 lexer.setToken(&aToken);
1799 parser.init();
1800 parser.start();
1801 };
1802
1803 fclose(stdin);
1804 fclose(stdout);
1805 return 0;
1806 }
1807
1808 >>
1809
1810 <<
1811 char *s=NULL;
1812
1813 #undef zzUSER_GUESS_HOOK
1814 #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);
1815 #undef zzUSER_GUESS_DONE_HOOK
1816 #define zzUSER_GUESS_DONE_HOOK(guessSeq) myGuessHook(guessSeq,2);
1817
1818 void myGuessHook(int guessSeq,int zzrv) {
1819 if (zzrv == 0) {
1820 fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);
1821 } else if (zzrv == 1) {
1822 free (s);
1823 s=NULL;
1824 fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);
1825 } else if (zzrv == 2) {
1826 free (s);
1827 s=NULL;
1828 fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);
1829 };
1830 }
1831
1832 >>
1833
1834 #token A "a"
1835 #token "[\t \ \n]" <<skip();>>
1836
1837 class P {
1838
1839 start : (top)+
1840 ;
1841
1842 top : (which) ? <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>
1843 | other <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>
1844 ; <<if (s != NULL) free(s); s=NULL; >>
1845
1846 which : which2
1847 ;
1848
1849 which2 : which3
1850 ;
1851 which3
1852 : (label)? <<fprintf(stderr,"%s is a label\n",s);>>
1853 | (global)? <<fprintf(stderr,"%s is a global\n",s);>>
1854 | (exclamation)? <<fprintf(stderr,"%s is an exclamation\n",s);>>
1855 ;
1856
1857 label : <<s=strdup(LT(1)->getText());>> A ":" ;
1858
1859 global : <<s=strdup(LT(1)->getText());>> A "::" ;
1860
1861 exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;
1862
1863 other : <<s=strdup(LT(1)->getText());>> "other" ;
1864
1865 }
1866 ----------------------------------------------------------------------
1867
1868 This is a silly example, but illustrates the idea. For the input
1869 "a ::" with tracing enabled the output begins:
1870
1871 ----------------------------------------------------------------------
1872 enter rule "start" depth 1
1873 enter rule "top" depth 2
1874 User hook: starting guess #1
1875 enter rule "which" depth 3 guessing
1876 enter rule "which2" depth 4 guessing
1877 enter rule "which3" depth 5 guessing
1878 User hook: starting guess #2
1879 enter rule "label" depth 6 guessing
1880 guess failed
1881 User hook: failed guess #2
1882 guess done - returning to rule "which3" at depth 5 (guess mode continues
1883 - an enclosing guess is still active)
1884 User hook: ending guess #2
1885 User hook: starting guess #3
1886 enter rule "global" depth 6 guessing
1887 exit rule "global" depth 6 guessing
1888 guess done - returning to rule "which3" at depth 5 (guess mode continues
1889 - an enclosing guess is still active)
1890 User hook: ending guess #3
1891 enter rule "global" depth 6 guessing
1892 exit rule "global" depth 6 guessing
1893 exit rule "which3" depth 5 guessing
1894 exit rule "which2" depth 4 guessing
1895 exit rule "which" depth 3 guessing
1896 guess done - returning to rule "top" at depth 2 (guess mode ends)
1897 User hook: ending guess #1
1898 enter rule "which" depth 3
1899 .....
1900 ----------------------------------------------------------------------
1901
1902 Remember:
1903
1904 (a) Only init-actions are executed during guess mode.
1905 (b) A rule can be invoked multiple times during guess mode.
1906 (c) If the guess succeeds the rule will be called once more
1907 without guess mode so that normal actions will be executed.
1908 This means that the init-action might need to distinguish
1909 between guess mode and non-guess mode using the variable
1910 [zz]guessing.
1911
1912 #107. (Changed in 1.33MR10) construction of ASTs in guess mode
1913
1914 Prior to 1.33MR10, when using automatic AST construction in C++
1915 mode for a rule, an AST would be constructed for elements of the
1916 rule even while in guess mode. In MR10 this no longer occurs.
1917
1918 #106. (Changed in 1.33MR10) guess variable confusion
1919
1920 In C++ mode a guess which failed always restored the parser state
1921 using zzGUESS_DONE as part of zzGUESS_FAIL. Prior to 1.33MR10,
1922 C mode required an explicit call to zzGUESS_DONE after the
1923 call to zzGUESS_FAIL.
1924
1925 Consider:
1926
1927 rule : (alpha)? beta
1928 | ...
1929 ;
1930
1931 The generated code resembles:
1932
1933 zzGUESS
1934 if (!zzrv && LA(1)==ID) { <==== line #1
1935 alpha
1936 zzGUESS_DONE
1937 beta
1938 } else {
1939 if (! zzrv) zzGUESS_DONE <==== line #2a
1940 ....
1941
1942 However, in some cases line #2 was rendered:
1943
1944 if (guessing) zzGUESS_DONE <==== line #2b
1945
1946 This would work for simple test cases, but would fail in
1947 some cases where there was a guess while another guess was active.
1948 One kind of failure would be to match up the zzGUESS_DONE at line
1949 #2b with the "outer" guess which was still active. The outer
1950 guess would "succeed" when only the inner guess should have
1951 succeeded.
1952
1953 In 1.33MR10 the behavior of zzGUESS and zzGUESS_FAIL in C and
1954 and C++ mode should be identical.
1955
1956 The same problem appears in 1.33 vanilla in some places. For
1957 example:
1958
1959 start : { (sub)? } ;
1960
1961 or:
1962
1963 start : (
1964 B
1965 | ( sub )?
1966 | C
1967 )+
1968 ;
1969
1970 generates incorrect code.
1971
1972 The general principle is:
1973
1974 (a) use [zz]guessing only when deciding between a call to zzFAIL
1975 or zzGUESS_FAIL
1976
1977 (b) use zzrv in all other cases
1978
1979 This problem was discovered while testing changes to item #105.
1980 I believe this is now fixed. My apologies.
1981
1982 #105. (Changed in 1.33MR10) guess block as single alt of (...)+
1983
1984 Prior to 1.33MR10 the following constructs:
1985
1986 rule_plus : (
1987 (sub)?
1988 )+
1989 ;
1990
1991 rule_star : (
1992 (sub)?
1993 )*
1994 ;
1995
1996 generated incorrect code for the guess block (which could result
1997 in runtime errors) because of an incorrect optimization of a
1998 block with only a single alternative.
1999
2000 The fix caused some changes to the fix described in Item #49
2001 because there are now three code generation sequences for (...)+
2002 blocks containing a guess block:
2003
2004 a. single alternative which is a guess block
2005 b. multiple alternatives in which the last is a guess block
2006 c. all other cases
2007
2008 Forms like "rule_star" can have unexpected behavior when there
2009 is a syntax error: if the subrule "sub" is not matched *exactly*
2010 then "rule_star" will consume no tokens.
2011
2012 Reported by Esa Pulkkinen (esap@cs.tut.fi).
2013
2014 #104. (Changed in 1.33MR10) -o option for dlg
2015
2016 There was problem with the code added by item #74 to handle the
2017 -o option of dlg. This should fix it.
2018
2019 #103. (Changed in 1.33MR10) ANDed semantic predicates
2020
2021 Rescinded.
2022
2023 The optimization was a mistake.
2024 The resulting problem is described in Item #150.
2025
2026 #102. (Changed in 1.33MR10) allow "class parser : .... {"
2027
2028 The syntax of the class statement ("class parser-name {")
2029 has been extended to allow for the specification of base
2030 classes. An arbirtrary number of tokens may now appear
2031 between the class name and the "{". They are output
2032 again when the class declaration is generated. For
2033 example:
2034
2035 class Parser : public MyBaseClassANTLRparser {
2036
2037 This was suggested by a user, but I don't have a record
2038 of who it was.
2039
2040 #101. (Changed in 1.33MR10) antlr -info command line switch
2041
2042 -info
2043
2044 p - extra predicate information in generated file
2045
2046 t - information about tnode use:
2047 at the end of each rule in generated file
2048 summary on stderr at end of program
2049
2050 m - monitor progress
2051 prints name of each rule as it is started
2052 flushes output at start of each rule
2053
2054 f - first/follow set information to stdout
2055
2056 0 - no operation (added in 1.33MR11)
2057
2058 The options may be combined and may appear in any order.
2059 For example:
2060
2061 antlr -info ptm -CC -gt -mrhoist on mygrammar.g
2062
2063 #100a. (Changed in 1.33MR10) Predicate tree simplification
2064
2065 When the same predicates can be referenced in more than one
2066 alternative of a block large predicate trees can be formed.
2067
2068 The difference that these optimizations make is so dramatic
2069 that I have decided to use it even when -mrhoist is not selected.
2070
2071 Consider the following grammar:
2072
2073 start : ( all )* ;
2074
2075 all : a
2076 | d
2077 | e
2078 | f
2079 ;
2080
2081 a : c A B
2082 | c A C
2083 ;
2084
2085 c : <<AAA(LATEXT(2))>>?
2086 ;
2087
2088 d : <<BBB(LATEXT(2))>>? B C
2089 ;
2090
2091 e : <<CCC(LATEXT(2))>>? B C
2092 ;
2093
2094 f : e X Y
2095 ;
2096
2097 In rule "a" there is a reference to rule "c" in both alternatives.
2098 The length of the predicate AAA is k=2 and it can be followed in
2099 alternative 1 only by (A B) while in alternative 2 it can be
2100 followed only by (A C). Thus they do not have identical context.
2101
2102 In rule "all" the alternatives which refer to rules "e" and "f" allow
2103 elimination of the duplicate reference to predicate CCC.
2104
2105 The table below summarized the kind of simplification performed by
2106 1.33MR10. In the table, X and Y stand for single predicates
2107 (not trees).
2108
2109 (OR X (OR Y (OR Z))) => (OR X Y Z)
2110 (AND X (AND Y (AND Z))) => (AND X Y Z)
2111
2112 (OR X (... (OR X Y) ... )) => (OR X (... Y ... ))
2113 (AND X (... (AND X Y) ... )) => (AND X (... Y ... ))
2114 (OR X (... (AND X Y) ... )) => (OR X (... ... ))
2115 (AND X (... (OR X Y) ... )) => (AND X (... ... ))
2116
2117 (AND X) => X
2118 (OR X) => X
2119
2120 In a test with a complex grammar for a real application, a predicate
2121 tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".
2122
2123 In 1.33MR10 there is a greater effort to release memory used
2124 by predicates once they are no longer in use.
2125
2126 #100b. (Changed in 1.33MR10) Suppression of extra predicate tests
2127
2128 The following optimizations require that -mrhoist be selected.
2129
2130 It is relatively easy to optimize the code generated for predicate
2131 gates when they are of the form:
2132
2133 (AND X Y Z ...)
2134 or (OR X Y Z ...)
2135
2136 where X, Y, Z, and "..." represent individual predicates (leaves) not
2137 predicate trees.
2138
2139 If the predicate is an AND the contexts of the X, Y, Z, etc. are
2140 ANDed together to create a single Tree context for the group and
2141 context tests for the individual predicates are suppressed:
2142
2143 --------------------------------------------------
2144 Note: This was incorrect. The contexts should be
2145 ORed together. This has been fixed. A more
2146 complete description is available in item #152.
2147 ---------------------------------------------------
2148
2149 Optimization 1: (AND X Y Z ...)
2150
2151 Suppose the context for Xtest is LA(1)==LP and the context for
2152 Ytest is LA(1)==LP && LA(2)==ID.
2153
2154 Without the optimization the code would resemble:
2155
2156 if (lookaheadContext &&
2157 !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||
2158 ( (! LA(1)==LP || Xtest) &&
2159 (! (LA(1)==LP || LA(2)==ID) || Xtest)
2160 )) {...
2161
2162 With the -mrhoist optimization the code would resemble:
2163
2164 if (lookaheadContext &&
2165 ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...
2166
2167 Optimization 2: (OR X Y Z ...) with identical contexts
2168
2169 Suppose the context for Xtest is LA(1)==ID and for Ytest
2170 the context is also LA(1)==ID.
2171
2172 Without the optimization the code would resemble:
2173
2174 if (lookaheadContext &&
2175 ! (LA(1)==ID || LA(1)==ID) ||
2176 (LA(1)==ID && Xtest) ||
2177 (LA(1)==ID && Ytest) {...
2178
2179 With the -mrhoist optimization the code would resemble:
2180
2181 if (lookaheadContext &&
2182 (! LA(1)==ID) || (Xtest || Ytest) {...
2183
2184 Optimization 3: (OR X Y Z ...) with distinct contexts
2185
2186 Suppose the context for Xtest is LA(1)==ID and for Ytest
2187 the context is LA(1)==LP.
2188
2189 Without the optimization the code would resemble:
2190
2191 if (lookaheadContext &&
2192 ! (LA(1)==ID || LA(1)==LP) ||
2193 (LA(1)==ID && Xtest) ||
2194 (LA(1)==LP && Ytest) {...
2195
2196 With the -mrhoist optimization the code would resemble:
2197
2198 if (lookaheadContext &&
2199 (zzpf=0,
2200 (LA(1)==ID && (zzpf=1) && Xtest) ||
2201 (LA(1)==LP && (zzpf=1) && Ytest) ||
2202 !zzpf) {
2203
2204 These may appear to be of similar complexity at first,
2205 but the non-optimized version contains two tests of each
2206 context while the optimized version contains only one
2207 such test, as well as eliminating some of the inverted
2208 logic (" !(...) || ").
2209
2210 Optimization 4: Computation of predicate gate trees
2211
2212 When generating code for the gates of predicate expressions
2213 antlr 1.33 vanilla uses a recursive procedure to generate
2214 "&&" and "||" expressions for testing the lookahead. As each
2215 layer of the predicate tree is exposed a new set of "&&" and
2216 "||" expressions on the lookahead are generated. In many
2217 cases the lookahead being tested has already been tested.
2218
2219 With -mrhoist a lookahead tree is computed for the entire
2220 lookahead expression. This means that predicates with identical
2221 context or context which is a subset of another predicate's
2222 context disappear.
2223
2224 This is especially important for predicates formed by rules
2225 like the following:
2226
2227 uppperCaseVowel : <<isUpperCase(LATEXT(1))>>? vowel;
2228 vowel: : <<isVowel(LATEXT(1))>>? LETTERS;
2229
2230 These predicates are combined using AND since both must be
2231 satisfied for rule upperCaseVowel. They have identical
2232 context which makes this optimization very effective.
2233
2234 The affect of Items #100a and #100b together can be dramatic. In
2235 a very large (but real world) grammar one particular predicate
2236 expression was reduced from an (unreadable) 50 predicate leaves,
2237 195 LA(1) terms, and 5500 characters to an (easily comprehensible)
2238 3 predicate leaves (all different) and a *single* LA(1) term.
2239
2240 #99. (Changed in 1.33MR10) Code generation for expression trees
2241
2242 Expression trees are used for k>1 grammars and predicates with
2243 lookahead depth >1. This optimization must be enabled using
2244 "-mrhoist on". (Clarification added for 1.33MR11).
2245
2246 In the processing of expression trees, antlr can generate long chains
2247 of token comparisons. Prior to 1.33MR10 there were many redundant
2248 parenthesis which caused problems for compilers which could handle
2249 expressions of only limited complexity. For example, to test an
2250 expression tree (root R A B C D), antlr would generate something
2251 resembling:
2252
2253 (LA(1)==R && (LA(2)==A || (LA(2)==B || (LA(2)==C || LA(2)==D)))))
2254
2255 If there were twenty tokens to test then there would be twenty
2256 parenthesis at the end of the expression.
2257
2258 In 1.33MR10 the generated code for tree expressions resembles:
2259
2260 (LA(1)==R && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D))
2261
2262 For "complex" expressions the output is indented to reflect the LA
2263 number being tested:
2264
2265 (LA(1)==R
2266 && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D
2267 || LA(2)==E || LA(2)==F)
2268 || LA(1)==S
2269 && (LA(2)==G || LA(2)==H))
2270
2271
2272 Suggested by S. Bochnak (S.Bochnak@@microTool.com.pl),
2273
2274 #98. (Changed in 1.33MR10) Option "-info p"
2275
2276 When the user selects option "-info p" the program will generate
2277 detailed information about predicates. If the user selects
2278 "-mrhoist on" additional detail will be provided explaining
2279 the promotion and suppression of predicates. The output is part
2280 of the generated file and sandwiched between #if 0/#endif statements.
2281
2282 Consider the following k=1 grammar:
2283
2284 start : ( all ) * ;
2285
2286 all : ( a
2287 | b
2288 )
2289 ;
2290
2291 a : c B
2292 ;
2293
2294 c : <<LATEXT(1)>>?
2295 | B
2296 ;
2297
2298 b : <<LATEXT(1)>>? X
2299 ;
2300
2301 Below is an excerpt of the output for rule "start" for the three
2302 predicate options (off, on, and maintenance release style hoisting).
2303
2304 For those who do not wish to use the "-mrhoist on" option for code
2305 generation the option can be used in a "diagnostic" mode to provide
2306 valuable information:
2307
2308 a. where one should insert null actions to inhibit hoisting
2309 b. a chain of rule references which shows where predicates are
2310 being hoisted
2311
2312 ======================================================================
2313 Example of "-info p" with "-mrhoist on"
2314 ======================================================================
2315 #if 0
2316
2317 Hoisting of predicate suppressed by alternative without predicate.
2318 The alt without the predicate includes all cases where the
2319 predicate is false.
2320
2321 WITH predicate: line 11 v36.g
2322 WITHOUT predicate: line 12 v36.g
2323
2324 The context set for the predicate:
2325
2326 B
2327
2328 The lookahead set for alt WITHOUT the semantic predicate:
2329
2330 B
2331
2332 The predicate:
2333
2334 pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
2335
2336 set context:
2337 B
2338 tree context: null
2339
2340 Chain of referenced rules:
2341
2342 #0 in rule start (line 1 v36.g) to rule all
2343 #1 in rule all (line 3 v36.g) to rule a
2344 #2 in rule a (line 8 v36.g) to rule c
2345 #3 in rule c (line 11 v36.g)
2346
2347 #endif
2348 &&
2349 #if 0
2350
2351 pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
2352
2353 set context:
2354 X
2355 tree context: null
2356
2357 #endif
2358 ======================================================================
2359 Example of "-info p" with the default -prc setting ( "-prc off")
2360 ======================================================================
2361 #if 0
2362
2363 OR
2364 pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
2365
2366 set context:
2367 nil
2368 tree context: null
2369
2370 pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
2371
2372 set context:
2373 nil
2374 tree context: null
2375
2376 #endif
2377 ======================================================================
2378 Example of "-info p" with "-prc on" and "-mrhoist off"
2379 ======================================================================
2380 #if 0
2381
2382 OR
2383 pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
2384
2385 set context:
2386 B
2387 tree context: null
2388
2389 pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
2390
2391 set context:
2392 X
2393 tree context: null
2394
2395 #endif
2396 ======================================================================
2397
2398 #97. (Fixed in 1.33MR10) "Predicate applied for more than one ... "
2399
2400 In 1.33 vanilla, the grammar listed below produced this message for
2401 the first alternative (only) of rule "b":
2402
2403 warning: predicate applied for >1 lookahead 1-sequences
2404 [you may only want one lookahead 1-sequence to apply.
2405 Try using a context guard '(...)? =>'
2406
2407 In 1.33MR10 the message is issued for both alternatives.
2408
2409 top : (a)*;
2410 a : b | c ;
2411
2412 b : <<PPP(LATEXT(1))>>? ( AAA | BBB )
2413 | <<QQQ(LATEXT(1))>>? ( XXX | YYY )
2414 ;
2415
2416 c : AAA | XXX;
2417
2418 #96. (Fixed in 1.33MR10) Guard predicates ignored when -prc off
2419
2420 Prior to 1.33MR10, guard predicate code was not generated unless
2421 "-prc on" was selected.
2422
2423 This was incorrect, since "-prc off" (the default) is supposed to
2424 disable only AUTOMATIC computation of predicate context, not the
2425 programmer specified context supplied by guard predicates.
2426
2427 #95. (Fixed in 1.33MR10) Predicate guard context length was k, not max(k,ck)
2428
2429 Prior to 1.33MR10, predicate guards were computed to k tokens rather
2430 than max(k,ck). Consider the following grammar:
2431
2432 a : ( A B C)? => <<AAA(LATEXT(1))>>? (A|X) (B|Y) (C|Z) ;
2433
2434 The code generated by 1.33 vanilla with "-k 1 -ck 3 -prc on"
2435 for the predicate in "a" resembles:
2436
2437 if ( (! LA(1)==A) || AAA(LATEXT(1))) {...
2438
2439 With 1.33MR10 and the same options the code resembles:
2440
2441 if ( (! (LA(1)==A && LA(2)==B && LA(3)==C) || AAA(LATEXT(1))) {...
2442
2443 #94. (Fixed in 1.33MR10) Predicates followed by rule references
2444
2445 Prior to 1.33MR10, a semantic predicate which referenced a token
2446 which was off the end of the rule caused an incomplete context
2447 to be computed (with "-prc on") for the predicate under some circum-
2448 stances. In some cases this manifested itself as illegal C code
2449 (e.g. "LA(2)==[Ep](1)" in the k=2 examples below:
2450
2451 all : ( a ) *;
2452
2453 a : <<AAA(LATEXT(2))>>? ID X
2454 | <<BBB(LATEXT(2))>>? Y
2455 | Z
2456 ;
2457
2458 This might also occur when the semantic predicate was followed
2459 by a rule reference which was shorter than the length of the
2460 semantic predicate:
2461
2462 all : ( a ) *;
2463
2464 a : <<AAA(LATEXT(2))>>? ID X
2465 | <<BBB(LATEXT(2))>>? y
2466 | Z
2467 ;
2468
2469 y : Y ;
2470
2471 Depending on circumstance, the resulting context might be too
2472 generous because it was too short, or too restrictive because
2473 of missing alternatives.
2474
2475 #93. (Changed in 1.33MR10) Definition of Purify macro
2476
2477 Ofer Ben-Ami (gremlin@cs.huji.ac.il) has supplied a definition
2478 for the Purify macro:
2479
2480 #define PURIFY(r, s) memset((char *) &(r), '\0', (s));
2481
2482 Note: This may not be the right thing to do for C++ objects that
2483 have constructors. Reported by Bonny Rais (bonny@werple.net.au).
2484
2485 For those cases one should #define PURIFY to an empty macro in the
2486 #header or #first actions.
2487
2488 #92. (Fixed in 1.33MR10) Guarded predicates and hoisting
2489
2490 When a guarded predicate participates in hoisting it is linked into
2491 a predicate expression tree. Prior to 1.33MR10 this link was never
2492 cleared and the next time the guard was used to construct a new
2493 tree the link could contain a spurious reference to another element
2494 which had previosly been joined to it in the semantic predicate tree.
2495
2496 For example:
2497
2498 start : ( all ) *;
2499 all : ( a | b ) ;
2500
2501 start2 : ( all2 ) *;
2502 all2 : ( a ) ;
2503
2504 a : (A)? => <<AAA(LATEXT(1))>>? A ;
2505 b : (B)? => <<BBB(LATEXT(1))>>? B ;
2506
2507 Prior to 1.33MR10 the code for "start2" would include a spurious
2508 reference to the BBB predicate which was left from constructing
2509 the predicate tree for rule "start" (i.e. or(AAA,BBB) ).
2510
2511 In 1.33MR10 this problem is avoided by cloning the original guard
2512 each time it is linked into a predicate tree.
2513
2514 #91. (Changed in 1.33MR10) Extensive changes to semantic pred hoisting
2515
2516 ============================================
2517 This has been rendered obsolete by Item #117
2518 ============================================
2519
2520 #90. (Fixed in 1.33MR10) Semantic pred with LT(i) and i>max(k,ck)
2521
2522 There is a bug in antlr 1.33 vanilla and all maintenance releases
2523 prior to 1.33MR10 which allows semantic predicates to reference
2524 an LT(i) or LATEXT(i) where i is larger than max(k,ck). When
2525 this occurs antlr will attempt to mark the ith element of an array
2526 in which there are only max(k,ck) elements. The result cannot
2527 be predicted.
2528
2529 Using LT(i) or LATEXT(i) for i>max(k,ck) is reported as an error
2530 in 1.33MR10.
2531
2532 #89. Rescinded
2533
2534 #88. (Fixed in 1.33MR10) Tokens used in semantic predicates in guess mode
2535
2536 Consider the behavior of a semantic predicate during guess mode:
2537
2538 rule : a:A (
2539 <<test($a)>>? b:B
2540 | c:C
2541 );
2542
2543 Prior to MR10 the assignment of the token or attribute to
2544 $a did not occur during guess mode, which would cause the
2545 semantic predicate to misbehave because $a would be null.
2546
2547 In 1.33MR10 a semantic predicate with a reference to an
2548 element label (such as $a) forces the assignment to take
2549 place even in guess mode.
2550
2551 In order to work, this fix REQUIRES use of the $label format
2552 for token pointers and attributes referenced in semantic
2553 predicates.
2554
2555 The fix does not apply to semantic predicates using the
2556 numeric form to refer to attributes (e.g. <<test($1)>>?).
2557 The user will receive a warning for this case.
2558
2559 Reported by Rob Trout (trout@mcs.cs.kent.edu).
2560
2561 #87. (Fixed in 1.33MR10) Malformed guard predicates
2562
2563 Context guard predicates may contain only references to
2564 tokens. They may not contain references to (...)+ and
2565 (...)* blocks. This is now checked. This replaces the
2566 fatal error message in item #78 with an appropriate
2567 (non-fatal) error messge.
2568
2569 In theory, context guards should be allowed to reference
2570 rules. However, I have not had time to fix this.
2571 Evaluation of the guard takes place before all rules have
2572 been read, making it difficult to resolve a forward reference
2573 to rule "zzz" - it hasn't been read yet ! To postpone evaluation
2574 of the guard until all rules have been read is too much
2575 for the moment.
2576
2577 #86. (Fixed in 1.33MR10) Unequal set size in set_sub
2578
2579 Routine set_sub() in pccts/support/set/set.h did not work
2580 correctly when the sets were of unequal sizes. Rewrote
2581 set_equ to make it simpler and remove unnecessary and
2582 expensive calls to set_deg(). This routine was not used
2583 in 1.33 vanila.
2584
2585 #85. (Changed in 1.33MR10) Allow redefinition of MaxNumFiles
2586
2587 Raised the maximum number of input files to 99 from 20.
2588 Put a #ifndef/#endif around the "#define MaxNumFiles 99".
2589
2590 #84. (Fixed in 1.33MR10) Initialize zzBadTok in macro zzRULE
2591
2592 Initialize zzBadTok to NULL in zzRULE macro of AParser.h.
2593 in order to get rid of warning messages.
2594
2595 #83. (Fixed in 1.33MR10) False warnings with -w2 for #tokclass
2596
2597 When -w2 is selected antlr gives inappropriate warnings about
2598 #tokclass names not having any associated regular expressions.
2599 Since a #tokclass is not a "real" token it will never have an
2600 associated regular expression and there should be no warning.
2601
2602 Reported by Derek Pappas (derek.pappas@eng.sun.com)
2603
2604 #82. (Fixed in 1.33MR10) Computation of follow sets with multiple cycles
2605
2606 Reinier van den Born (reinier@vnet.ibm.com) reported a problem
2607 in the computation of follow sets by antlr. The problem (bug)
2608 exists in 1.33 vanilla and all maintenance releases prior to 1.33MR10.
2609
2610 The problem involves the computation of follow sets when there are
2611 cycles - rules which have mutual references. I believe the problem
2612 is restricted to cases where there is more than one cycle AND
2613 elements of those cycles have rules in common. Even when this
2614 occurs it may not affect the code generated - but it might. It
2615 might also lead to undetected ambiguities.
2616
2617 There were no changes in antlr or dlg output from the revised version.
2618
2619 The following fragment demonstates the problem by giving different
2620 follow sets (option -pa) for var_access when built with k=1 and ck=2 on
2621 1.33 vanilla and 1.33MR10:
2622
2623 echo_statement : ECHO ( echo_expr )*
2624 ;
2625
2626 echo_expr : ( command )?
2627 | expression
2628 ;
2629
2630 command : IDENTIFIER
2631 { concat }
2632 ;
2633
2634 expression : operand ( OPERATOR operand )*
2635 ;
2636
2637 operand : value
2638 | START command END
2639 ;
2640
2641 value : concat
2642 | TYPE operand
2643 ;
2644
2645 concat : var_access { CONCAT value }
2646 ;
2647
2648 var_access : IDENTIFIER { INDEX }
2649
2650 ;
2651 #81. (Changed in 1.33MR10) C mode use of attributes and ASTs
2652
2653 Reported by Isaac Clark (irclark@mindspring.com).
2654
2655 C mode code ignores attributes returned by rules which are
2656 referenced using element labels when ASTs are enabled (-gt option).
2657
2658 1. start : r:rule t:Token <<$start=$r;>>
2659
2660 The $r refrence will not work when combined with
2661 the -gt option.
2662
2663 2. start : t:Token <<$start=$t;>>
2664
2665 The $t reference works in all cases.
2666
2667 3. start : rule <<$0=$1;>>
2668
2669 Numeric labels work in all cases.
2670
2671 With MR10 the user will receive an error message for case 1 when
2672 the -gt option is used.
2673
2674 #80. (Fixed in 1.33MR10) (...)? as last alternative of block
2675
2676 A construct like the following:
2677
2678 rule : a
2679 | (b)?
2680 ;
2681
2682 does not make sense because there is no alternative when
2683 the guess block fails. This is now reported as a warning
2684 to the user.
2685
2686 Previously, there was a code generation error for this case:
2687 the guess block was not "closed" when the guess failed.
2688 This could cause an infinite loop or other problems. This
2689 is now fixed.
2690
2691 Example problem:
2692
2693 #header<<
2694 #include <stdio.h>
2695 #include "charptr.h"
2696 >>
2697
2698 <<
2699 #include "charptr.c"
2700 main ()
2701 {
2702 ANTLR(start(),stdin);
2703 }
2704 >>
2705
2706 #token "[\ \t]+" << zzskip(); >>
2707 #token "[\n]" << zzline++; zzskip(); >>
2708
2709 #token Word "[a-z]+"
2710 #token Number "[0-9]+"
2711
2712
2713 start : (test1)?
2714 | (test2)?
2715 ;
2716 test1 : (Word Word Word Word)?
2717 | (Word Word Word Number)?
2718 ;
2719 test2 : (Word Word Number Word)?
2720 | (Word Word Number Number)?
2721 ;
2722
2723 Test data which caused infinite loop:
2724
2725 a 1 a a
2726
2727 #79. (Changed in 1.33MR10) Use of -fh with multiple parsers
2728
2729 Previously, antlr always used the pre-processor symbol
2730 STDPCCTS_H as a gate for the file stdpccts.h. This
2731 caused problems when there were multiple parsers defined
2732 because they used the same gate symbol.
2733
2734 In 1.33MR10, the -fh filename is used to generate the
2735 gate file for stdpccts.h. For instance:
2736
2737 antlr -fh std_parser1.h
2738
2739 generates the pre-processor symbol "STDPCCTS_std_parser1_H".
2740
2741 Reported by Ramanathan Santhanam (ps@kumaran.com).
2742
2743 #78. (Changed in 1.33MR9) Guard predicates that refer to rules
2744
2745 ------------------------
2746 Please refer to Item #87
2747 ------------------------
2748
2749 Guard predicates are processed during an early phase
2750 of antlr (during parsing) before all data structures
2751 are completed.
2752
2753 There is an apparent bug in earlier versions of 1.33
2754 which caused guard predicates which contained references
2755 to rules (rather than tokens) to reference a structure
2756 which hadn't yet been initialized.
2757
2758 In some cases (perhaps all cases) references to rules
2759 in guard predicates resulted in the use of "garbage".
2760
2761 #79. (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)
2762
2763 Previously, the maximum length file name was set
2764 arbitrarily to 300 characters in antlr, dlg, and sorcerer.
2765
2766 The config.h file now attempts to define the maximum length
2767 filename using _MAX_PATH from stdlib.h before falling back
2768 to using the value 300.
2769
2770 #78. (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)
2771
2772 Put #ifndef/#endif around definition of ZZLEXBUFSIZE in
2773 antlr.
2774
2775 #77. (Changed in 1.33MR9) Arithmetic overflow for very large grammars
2776
2777 In routine HandleAmbiguities() antlr attempts to compute the
2778 number of possible elements in a set that is order of
2779 number-of-tokens raised to the number-of-lookahead-tokens power.
2780 For large grammars or large lookahead (e.g. -ck 7) this can
2781 cause arithmetic overflow.
2782
2783 With 1.33MR9, arithmetic overflow in this computation is reported
2784 the first time it happens. The program continues to run and
2785 the program branches based on the assumption that the computed
2786 value is larger than any number computed by counting actual cases
2787 because 2**31 is larger than the number of bits in most computers.
2788
2789 Before 1.33MR9 overflow was not reported. The behavior following
2790 overflow is not predictable by anyone but the original author.
2791
2792 NOTE
2793
2794 In 1.33MR10 the warning message is suppressed.
2795 The code which detects the overflow allows the
2796 computation to continue without an error. The
2797 error message itself made made users worry.
2798
2799 #76. (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)
2800
2801 Jeff Vincent has convinced me to make ANTLRCommonToken and
2802 ANTLRCommonNoRefCountToken use variable length strings
2803 allocated from the heap rather than fixed length strings.
2804 By suitable definition of setText(), the copy constructor,
2805 and operator =() it is possible to maintain "copy" semantics.
2806 By "copy" semantics I mean that when a token is copied from
2807 an existing token it receives its own, distinct, copy of the
2808 text allocated from the heap rather than simply a pointer
2809 to the original token's text.
2810
2811 ============================================================
2812 W * A * R * N * I * N * G
2813 ============================================================
2814
2815 It is possible that this may cause problems for some users.
2816 For those users I have included the old version of AToken.h as
2817 pccts/h/AToken_traditional.h.
2818
2819 #75. (Changed in 1.33MR9) Bruce Guenter (bruceg@qcc.sk.ca)
2820
2821 Make DLGStringInput const correct. Since this is infrequently
2822 subclassed, it should affect few users, I hope.
2823
2824 #74. (Changed in 1.33MR9) -o (output directory) option
2825
2826 Antlr does not properly handle the -o output directory option
2827 when the filename of the grammar contains a directory part. For
2828 example:
2829
2830 antlr -o outdir pccts_src/myfile.g
2831
2832 causes antlr create a file called "outdir/pccts_src/myfile.cpp.
2833 It SHOULD create outdir/myfile.cpp
2834
2835 The suggested code fix has been installed in antlr, dlg, and
2836 Sorcerer.
2837
2838 #73. (Changed in 1.33MR9) Hoisting of semantic predicates and -mrhoist
2839
2840 ============================================
2841 This has been rendered obsolete by Item #117
2842 ============================================
2843
2844 #72. (Changed in 1.33MR9) virtual saveState()/restoreState()/guess_XXX
2845
2846 The following methods in ANTLRParser were made virtual at
2847 the request of S. Bochnak (S.Bochnak@microTool.com.pl):
2848
2849 saveState() and restoreState()
2850 guess(), guess_fail(), and guess_done()
2851
2852 #71. (Changed in 1.33MR9) Access to omitted command line argument
2853
2854 If a switch requiring arguments is the last thing on the
2855 command line, and the argument is omitted, antlr would core.
2856
2857 antlr test.g -prc
2858
2859 instead of
2860
2861 antlr test.g -prc off
2862
2863 #70. (Changed in 1.33MR9) Addition of MSVC .dsp and .mak build files
2864
2865 The following MSVC .dsp and .mak files for pccts and sorcerer
2866 were contributed by Stanislaw Bochnak (S.Bochnak@microTool.com.pl)
2867 and Jeff Vincent (JVincent@novell.com)
2868
2869 PCCTS Distribution Kit
2870 ----------------------
2871 pccts/PCCTSMSVC50.dsw
2872
2873 pccts/antlr/AntlrMSVC50.dsp
2874 pccts/antlr/AntlrMSVC50.mak
2875
2876 pccts/dlg/DlgMSVC50.dsp
2877 pccts/dlg/DlgMSVC50.mak
2878
2879 pccts/support/msvc.dsp
2880
2881 Sorcerer Distribution Kit
2882 -------------------------
2883 pccts/sorcerer/SorcererMSVC50.dsp
2884 pccts/sorcerer/SorcererMSVC50.mak
2885
2886 pccts/sorcerer/lib/msvc.dsp
2887
2888 #69. (Changed in 1.33MR9) Change "unsigned int" to plain "int"
2889
2890 Declaration of max_token_num in misc.c as "unsigned int"
2891 caused comparison between signed and unsigned ints giving
2892 warning message without any special benefit.
2893
2894 #68. (Changed in 1.33MR9) Add void return for dlg internal_error()
2895
2896 Get rid of "no return value" message in internal_error()
2897 in file dlg/support.c and dlg/dlg.h.
2898
2899 #67. (Changed in Sor) sor.g: lisp() has no return value
2900
2901 Added a "void" for the return type.
2902
2903 #66. (Added to Sor) sor.g: ZZLEXBUFSIZE enclosed in #ifndef/#endif
2904
2905 A user needed to be able to change the ZZLEXBUFSIZE for
2906 sor. Put the definition of ZZLEXBUFSIZE inside #ifndef/#endif
2907
2908 #65. (Changed in 1.33MR9) PCCTSAST::deepCopy() and ast_dup() bug
2909
2910 Jeff Vincent (JVincent@novell.com) found that deepCopy()
2911 made new copies of only the direct descendents. No new
2912 copies were made of sibling nodes, Sibling pointers are
2913 set to zero by shallowCopy().
2914
2915 PCCTS_AST::deepCopy() has been changed to make a
2916 deep copy in the traditional sense.
2917
2918 The deepCopy() routine depends on the behavior of
2919 shallowCopy(). In all sor examples I've found,
2920 shallowCopy() zeroes the right and down pointers.
2921
2922 Original Tree Original deepCopy() Revised deepCopy
2923 ------------- ------------------- ----------------
2924 a->b->c A A
2925 | | |
2926 d->e->f D D->E->F
2927 | | |
2928 g->h->i G G->H->I
2929 | |
2930 j->k J->K
2931
2932 While comparing deepCopy() for C++ mode with ast_dup for
2933 C mode I found a problem with ast_dup().
2934
2935 Routine ast_dup() has been changed to make a deep copy
2936 in the traditional sense.
2937
2938 Original Tree Original ast_dup() Revised ast_dup()
2939 ------------- ------------------- ----------------
2940 a->b->c A->B->C A
2941 | | |
2942 d->e->f D->E->F D->E->F
2943 | | |
2944 g->h->i G->H->I G->H->I
2945 | | |
2946 j->k J->K J->K
2947
2948
2949 I believe this affects transform mode sorcerer programs only.
2950
2951 #64. (Changed in 1.33MR9) anltr/hash.h prototype for killHashTable()
2952
2953 #63. (Changed in 1.33MR8) h/charptr.h does not zero pointer after free
2954
2955 The charptr.h routine now zeroes the pointer after free().
2956
2957 Reported by Jens Tingleff (jensting@imaginet.fr)
2958
2959 #62. (Changed in 1.33MR8) ANTLRParser::resynch had static variable
2960
2961 The static variable "consumed" in ANTLRParser::resynch was
2962 changed into an instance variable of the class with the
2963 name "resynchConsumed".
2964
2965 Reported by S.Bochnak@microTool.com.pl
2966
2967 #61. (Changed in 1.33MR8) Using rule>[i,j] when rule has no return values
2968
2969 Previously, the following code would cause antlr to core when
2970 it tried to generate code for rule1 because rule2 had no return
2971 values ("upward inheritance"):
2972
2973 rule1 : <<int i; int j>>
2974 rule2 > [i,j]
2975 ;
2976
2977 rule2 : Anything ;
2978
2979 Reported by S.Bochnak@microTool.com.pl
2980
2981 Verified correct operation of antlr MR8 when missing or extra
2982 inheritance arguments for all combinations. When there are
2983 missing or extra arguments code will still be generated even
2984 though this might cause the invocation of a subroutine with
2985 the wrong number of arguments.
2986
2987 #60. (Changed in 1.33MR7) Major changes to exception handling
2988
2989 There were significant problems in the handling of exceptions
2990 in 1.33 vanilla. The general problem is that it can only
2991 process one level of exception handler. For example, a named
2992 exception handler, an exception handler for an alternative, or
2993 an exception for a subrule always went to the rule's exception
2994 handler if there was no "catch" which matched the exception.
2995
2996 In 1.33MR7 the exception handlers properly "nest". If an
2997 exception handler does not have a matching "catch" then the
2998 nextmost outer exception handler is checked for an appropriate
2999 "catch" clause, and so on until an exception handler with an
3000 appropriate "catch" is found.
3001
3002 There are still undesirable features in the way exception
3003 handlers are implemented, but I do not have time to fix them
3004 at the moment:
3005
3006 The exception handlers for alternatives are outside the
3007 block containing the alternative. This makes it impossible
3008 to access variables declared in a block or to resume the
3009 parse by "falling through". The parse can still be easily
3010 resumed in other ways, but not in the most natural fashion.
3011
3012 This results in an inconsistentcy between named exception
3013 handlers and exception handlers for alternatives. When
3014 an exception handler for an alternative "falls through"
3015 it goes to the nextmost outer handler - not the "normal
3016 action".
3017
3018 A major difference between 1.33MR7 and 1.33 vanilla is
3019 the default action after an exception is caught:
3020
3021 1.33 Vanilla
3022 ------------
3023 In 1.33 vanilla the signal value is set to zero ("NoSignal")
3024 and the code drops through to the code following the exception.
3025 For named exception handlers this is the "normal action".
3026 For alternative exception handlers this is the rule's handler.
3027
3028 1.33MR7
3029 -------
3030 In 1.33MR7 the signal value is NOT automatically set to zero.
3031
3032 There are two cases:
3033
3034 For named exception handlers: if the signal value has been
3035 set to zero the code drops through to the "normal action".
3036
3037 For all other cases the code branches to the nextmost outer
3038 exception handler until it reaches the handler for the rule.
3039
3040 The following macros have been defined for convenience:
3041
3042 C/C++ Mode Name
3043 --------------------
3044 (zz)suppressSignal
3045 set signal & return signal arg to 0 ("NoSignal")
3046 (zz)setSignal(intValue)
3047 set signal & return signal arg to some value
3048 (zz)exportSignal
3049 copy the signal value to the return signal arg
3050
3051 I'm not sure why PCCTS make a distinction between the local
3052 signal value and the return signal argument, but I'm loathe
3053 to change the code. The burden of copying the local signal
3054 value to the return signal argument can be given to the
3055 default signal handler, I suppose.
3056
3057 #59. (Changed in 1.33MR7) Prototypes for some functions
3058
3059 Added prototypes for the following functions to antlr.h
3060
3061 zzconsumeUntil()
3062 zzconsumeUntilToken()
3063
3064 #58. (Changed in 1.33MR7) Added defintion of zzbufsize to dlgauto.h
3065
3066 #57. (Changed in 1.33MR7) Format of #line directive
3067
3068 Previously, the -gl directive for line 1234 would
3069 resemble: "# 1234 filename.g". This caused problems
3070 for some compilers/pre-processors. In MR7 it generates
3071 "#line 1234 filename.g".
3072
3073 #56. (Added in 1.33MR7) Jan Mikkelsen <janm@zeta.org.au>
3074
3075 Move PURIFY macro invocaton to after rule's init action.
3076
3077 #55. (Fixed in 1.33MR7) Unitialized variables in ANTLRParser
3078
3079 Member variables inf_labase and inf_last were not initialized.
3080 (See item #50.)
3081
3082 #54. (Fixed in 1.33MR6) Brad Schick (schick@interacess.com)
3083
3084 Previously, the following constructs generated the same
3085 code:
3086
3087 rule1 : (A B C)?
3088 | something-else
3089 ;
3090
3091 rule2 : (A B C)? ()
3092 | something-else
3093 ;
3094
3095 In all versions of pccts rule1 guesses (A B C) and then
3096 consume all three tokens if the guess succeeds. In MR6
3097 rule2 guesses (A B C) but consumes NONE of the tokens
3098 when the guess succeeds because "()" matches epsilon.
3099
3100 #53. (Explanation for 1.33MR6) What happens after an exception is caught ?
3101
3102 The Book is silent about what happens after an exception
3103 is caught.
3104
3105 The following code fragment prints "Error Action" followed
3106 by "Normal Action".
3107
3108 test : Word ex:Number <<printf("Normal Action\n");>>
3109 exception[ex]
3110 catch NoViableAlt:
3111 <<printf("Error Action\n");>>
3112 ;
3113
3114 The reason for "Normal Action" is that the normal flow of the
3115 program after a user-written exception handler is to "drop through".
3116 In the case of an exception handler for a rule this results in
3117 the exection of a "return" statement. In the case of an
3118 exception handler attached to an alternative, rule, or token
3119 this is the code that would have executed had there been no
3120 exception.
3121
3122 The user can achieve the desired result by using a "return"
3123 statement.
3124
3125 test : Word ex:Number <<printf("Normal Action\n");>>
3126 exception[ex]
3127 catch NoViableAlt:
3128 <<printf("Error Action\n"); return;>>
3129 ;
3130
3131 The most powerful mechanism for recovery from parse errors
3132 in pccts is syntactic predicates because they provide
3133 backtracking. Exceptions allow "return", "break",
3134 "consumeUntil(...)", "goto _handler", "goto _fail", and
3135 changing the _signal value.
3136
3137 #52. (Fixed in 1.33MR6) Exceptions without syntactic predicates
3138
3139 The following generates bad code in 1.33 if no syntactic
3140 predicates are present in the grammar.
3141
3142 test : Word ex:Number <<printf("Normal Action\n");>>
3143 exception[ex]
3144 catch NoViableAlt:
3145 <<printf("Error Action\n");>>
3146
3147 There is a reference to a guess variable. In C mode
3148 this causes a compiler error. In C++ mode it generates
3149 an extraneous check on member "guessing".
3150
3151 In MR6 correct code is generated for both C and C++ mode.
3152
3153 #51. (Added to 1.33MR6) Exception operator "@" used without exceptions
3154
3155 In MR6 added a warning when the exception operator "@" is
3156 used and no exception group is defined. This is probably
3157 a case where "\@" or "@" is meant.
3158
3159 #50. (Fixed in 1.33MR6) Gunnar Rxnning (gunnar@candleweb.no)
3160 http://www.candleweb.no/~gunnar/
3161
3162 Routines zzsave_antlr_state and zzrestore_antlr_state don't
3163 save and restore all the data needed when switching states.
3164
3165 Suggested patch applied to antlr.h and err.h for MR6.
3166
3167 #49. (Fixed in 1.33MR6) Sinan Karasu (sinan@boeing.com)
3168
3169 Generated code failed to turn off guess mode when leaving a
3170 (...)+ block which contained a guess block. The result was
3171 an infinite loop. For example:
3172
3173 rule : (
3174 (x)?
3175 | y
3176 )+
3177
3178 Suggested code fix implemented in MR6. Replaced
3179
3180 ... else if (zzcnt>1) break;
3181
3182 with:
3183
3184 C++ mode:
3185 ... else if (zzcnt>1) {if (!zzrv) zzGUESS_DONE; break;};
3186 C mode:
3187 ... else if (zzcnt>1) {if (zzguessing) zzGUESS_DONE; break;};
3188
3189 #48. (Fixed in 1.33MR6) Invalid exception element causes core
3190
3191 A label attached to an invalid construct can cause
3192 pccts to crash while processing the exception associated
3193 with the label. For example:
3194
3195 rule : t:(B C)
3196 exception[t] catch MismatchedToken: <<printf(...);>>
3197
3198 Version MR6 generates the message:
3199
3200 reference in exception handler to undefined label 't'
3201
3202 #47. (Fixed in 1.33MR6) Manuel Ornato
3203
3204 Under some circumstances involving a k >1 or ck >1
3205 grammar and a loop block (i.e. (...)* ) pccts will
3206 fail to detect a syntax error and loop indefinitely.
3207 The problem did not exist in 1.20, but has existed
3208 from 1.23 to the present.
3209
3210 Fixed in MR6.
3211
3212 ---------------------------------------------------
3213 Complete test program
3214 ---------------------------------------------------
3215 #header<<
3216 #include <stdio.h>
3217 #include "charptr.h"
3218 >>
3219
3220 <<
3221 #include "charptr.c"
3222 main ()
3223 {
3224 ANTLR(global(),stdin);
3225 }
3226 >>
3227
3228 #token "[\ \t]+" << zzskip(); >>
3229 #token "[\n]" << zzline++; zzskip(); >>
3230
3231 #token B "b"
3232 #token C "c"
3233 #token D "d"
3234 #token E "e"
3235 #token LP "\("
3236 #token RP "\)"
3237
3238 #token ANTLREOF "@"
3239
3240 global : (
3241 (E liste)
3242 | liste
3243 | listed
3244 ) ANTLREOF
3245 ;
3246
3247 listeb : LP ( B ( B | C )* ) RP ;
3248 listec : LP ( C ( B | C )* ) RP ;
3249 listed : LP ( D ( B | C )* ) RP ;
3250 liste : ( listeb | listec )* ;
3251
3252 ---------------------------------------------------
3253 Sample data causing infinite loop
3254 ---------------------------------------------------
3255 e (d c)
3256 ---------------------------------------------------
3257
3258 #46. (Fixed in 1.33MR6) Robert Richter
3259 (Robert.Richter@infotech.tu-chemnitz.de)
3260
3261 This item from the list of known problems was
3262 fixed by item #18 (below).
3263
3264 #45. (Fixed in 1.33MR6) Brad Schick (schick@interaccess.com)
3265
3266 The dependency scanner in VC++ mistakenly sees a
3267 reference to an MPW #include file even though properly
3268 #ifdef/#endif in config.h. The suggested workaround
3269 has been implemented:
3270
3271 #ifdef MPW
3272 .....
3273 #define MPW_CursorCtl_Header <CursorCtl.h>
3274 #include MPW_CursorCtl_Header
3275 .....
3276 #endif
3277
3278 #44. (Fixed in 1.33MR6) cast malloc() to (char *) in charptr.c
3279
3280 Added (char *) cast for systems where malloc returns "void *".
3281
3282 #43. (Added to 1.33MR6) Bruce Guenter (bruceg@qcc.sk.ca)
3283
3284 Add setLeft() and setUp methods to ASTDoublyLinkedBase
3285 for symmetry with setRight() and setDown() methods.
3286
3287 #42. (Fixed in 1.33MR6) Jeff Katcher (jkatcher@nortel.ca)
3288
3289 C++ style comment in antlr.c corrected.
3290
3291 #41. (Added in 1.33MR6) antlr -stdout
3292
3293 Using "antlr -stdout ..." forces the text that would
3294 normally go to the grammar.c or grammar.cpp file to
3295 stdout.
3296
3297 #40. (Added in 1.33MR6) antlr -tab to change tab stops
3298
3299 Using "antlr -tab number ..." changes the tab stops
3300 for the grammar.c or grammar.cpp file. The number
3301 must be between 0 and 8. Using 0 gives tab characters,
3302 values between 1 and 8 give the appropriate number of
3303 space characters.
3304
3305 #39. (Fixed in 1.33MR5) Jan Mikkelsen <janm@zeta.org.au>
3306
3307 Commas in function prototype still not correct under
3308 some circumstances. Suggested code fix installed.
3309
3310 #38. (Fixed in 1.33MR5) ANTLRTokenBuffer constructor
3311
3312 Have ANTLRTokenBuffer ctor initialize member "parser" to null.
3313
3314 #37. (Fixed in 1.33MR4) Bruce Guenter (bruceg@qcc.sk.ca)
3315
3316 In ANTLRParser::FAIL(int k,...) released memory pointed to by
3317 f[i] (as well as f itself. Should only free f itself.
3318
3319 #36. (Fixed in 1.33MR3) Cortland D. Starrett (cort@shay.ecn.purdue.edu)
3320
3321 Neglected to properly declare isDLGmaxToken() when fixing problem
3322 reported by Andreas Magnusson.
3323
3324 Undo "_retv=NULL;" change which caused problems for return values
3325 from rules whose return values weren't pointers.
3326
3327 Failed to create bin directory if it didn't exist.
3328
3329 #35. (Fixed in 1.33MR2) Andreas Magnusson
3330 (Andreas.Magnusson@mailbox.swipnet.se)
3331
3332 Repair bug introduced by 1.33MR1 for #tokdefs. The original fix
3333 placed "DLGmaxToken=9999" and "DLGminToken=0" in the TokenType enum
3334 in order to fix a problem with an aggresive compiler assigning an 8
3335 bit enum which might be too narrow. This caused #tokdefs to assume
3336 that there were 9999 real tokens. The repair to the fix causes antlr to
3337 ignore TokenTypes "DLGmaxToken" and "DLGminToken" in a #tokdefs file.
3338
3339 #34. (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)
3340
3341 Previously there was no public function for changing the line
3342 number maintained by the lexer.
3343
3344 #33. (Fixed in 1.33MR1) Franklin Chen (chen@adi.com)
3345
3346 Accidental use of EXIT_FAILURE rather than PCCTS_EXIT_FAILURE
3347 in pccts/h/AParser.cpp.
3348
3349 #32. (Fixed in 1.33MR1) Franklin Chen (chen@adi.com)
3350
3351 In PCCTSAST.cpp lines 405 and 466: Change
3352
3353 free (t)
3354 to
3355 free ( (char *)t );
3356
3357 to match prototype.
3358
3359 #31. (Added to 1.33MR1) Pointer to parser in ANTLRTokenBuffer
3360 Pointer to parser in DLGLexerBase
3361
3362 The ANTLRTokenBuffer class now contains a pointer to the
3363 parser which is using it. This is established by the
3364 ANTLRParser constructor calling ANTLRTokenBuffer::
3365 setParser(ANTLRParser *p).
3366
3367 When ANTLRTokenBuffer::setParser(ANTLRParser *p) is
3368 called it saves the pointer to the parser and then
3369 calls ANTLRTokenStream::setParser(ANTLRParser *p)
3370 so that the lexer can also save a pointer to the
3371 parser.
3372
3373 There is also a function getParser() in each class
3374 with the obvious purpose.
3375
3376 It is possible that these functions will return NULL
3377 under some circumstances (e.g. a non-DLG lexer is used).
3378
3379 #30. (Added to 1.33MR1) function tokenName(int token) standard
3380
3381 The generated parser class now includes the
3382 function:
3383
3384 static const ANTLRChar * tokenName(int token)
3385
3386 which returns a pointer to the "name" corresponding
3387 to the token.
3388
3389 The base class (ANTLRParser) always includes the
3390 member function:
3391
3392 const ANTLRChar * parserTokenName(int token)
3393
3394 which can be accessed by objects which have a pointer
3395 to an ANTLRParser, but do not know the name of the
3396 parser class (e.g. ANTLRTokenBuffer and DLGLexerBase).
3397
3398 #29. (Added to 1.33MR1) Debugging DLG lexers
3399
3400 If the pre-processor symbol DEBUG_LEXER is defined
3401 then DLexerBase will include code for printing out
3402 key information about tokens which are recognized.
3403
3404 The debug feature of the lexer is controlled by:
3405
3406 int previousDebugValue=lexer.debugLexer(newValue);
3407
3408 a value of 0 disables output
3409 a value of 1 enables output
3410
3411 Even if the lexer debug code is compiled into DLexerBase
3412 it must be enabled before any output is generated. For
3413 example:
3414
3415 DLGFileInput in(stdin);
3416 MyDLG lexer(&in,2000);
3417
3418 lexer.setToken(&aToken);
3419
3420 #if DEBUG_LEXER
3421 lexer.debugLexer(1); // enable debug information
3422 #endif
3423
3424 #28. (Added to 1.33MR1) More control over DLG header
3425
3426 Version 1.33MR1 adds the following directives to PCCTS
3427 for C++ mode:
3428
3429 #lexprefix <<source code>>
3430
3431 Adds source code to the DLGLexer.h file
3432 after the #include "DLexerBase.h" but
3433 before the start of the class definition.
3434
3435 #lexmember <<source code>>
3436
3437 Adds source code to the DLGLexer.h file
3438 as part of the DLGLexer class body. It
3439 appears immediately after the start of
3440 the class and a "public: statement.
3441
3442 #27. (Fixed in 1.33MR1) Comments in DLG actions
3443
3444 Previously, DLG would not recognize comments as a special case.
3445 Thus, ">>" in the comments would cause errors. This is fixed.
3446
3447 #26. (Fixed in 1.33MR1) Removed static variables from error routines
3448
3449 Previously, the existence of statically allocated variables
3450 in some of the parser's member functions posed a danger when
3451 there was more than one parser active.
3452
3453 Replaced with dynamically allocated/freed variables in 1.33MR1.
3454
3455 #25. (Fixed in 1.33MR1) Use of string literals in semantic predicates
3456
3457 Previously, it was not possible to place a string literal in
3458 a semantic predicate because it was not properly "stringized"
3459 for the report of a failed predicate.
3460
3461 #24. (Fixed in 1.33MR1) Continuation lines for semantic predicates
3462
3463 Previously, it was not possible to continue semantic
3464 predicates across a line because it was not properly
3465 "stringized" for the report of a failed predicate.
3466
3467 rule : <<ifXYZ()>>?[ a very
3468 long statement ]
3469
3470 #23. (Fixed in 1.33MR1) {...} envelope for failed semantic predicates
3471
3472 Previously, there was a code generation error for failed
3473 semantic predicates:
3474
3475 rule : <<xyz()>>?[ stmt1; stmt2; ]
3476
3477 which generated code which resembled:
3478
3479 if (! xyz()) stmt1; stmt2;
3480
3481 It now puts the statements in a {...} envelope:
3482
3483 if (! xyz()) { stmt1; stmt2; };
3484
3485 #22. (Fixed in 1.33MR1) Continuation of #token across lines using "\"
3486
3487 Previously, it was not possible to continue a #token regular
3488 expression across a line. The trailing "\" and newline caused
3489 a newline to be inserted into the regular expression by DLG.
3490
3491 Fixed in 1.33MR1.
3492
3493 #21. (Fixed in 1.33MR1) Use of ">>" (right shift operator in DLG actions
3494
3495 It is now possible to use the C++ right shift operator ">>"
3496 in DLG actions by using the normal escapes:
3497
3498 #token "shift-right" << value=value \>\> 1;>>
3499
3500 #20. (Version 1.33/19-Jan-97 Karl Eccleson <karle@microrobotics.co.uk>
3501 P.A. Keller (P.A.Keller@bath.ac.uk)
3502
3503 There is a problem due to using exceptions with the -gh option.
3504
3505 Suggested fix now in 1.33MR1.
3506
3507 #19. (Fixed in 1.33MR1) Tom Piscotti and John Lilley
3508
3509 There were problems suppressing messages to stdin and stdout
3510 when running in a window environment because some functions
3511 which uses fprint were not virtual.
3512
3513 Suggested change now in 1.33MR1.
3514
3515 I believe all functions containing error messages (excluding those
3516 indicating internal inconsistency) have been placed in functions
3517 which are virtual.
3518
3519 #18. (Version 1.33/ 22-Nov-96) John Bair (jbair@iftime.com)
3520
3521 Under some combination of options a required "return _retv" is
3522 not generated.
3523
3524 Suggested fix now in 1.33MR1.
3525
3526 #17. (Version 1.33/3-Sep-96) Ron House (house@helios.usq.edu.au)
3527
3528 The routine ASTBase::predorder_action omits two "tree->"
3529 prefixes, which results in the preorder_action belonging
3530 to the wrong node to be invoked.
3531
3532 Suggested fix now in 1.33MR1.
3533
3534 #16. (Version 1.33/7-Jun-96) Eli Sternheim <eli@interhdl.com>
3535
3536 Routine consumeUntilToken() does not check for end-of-file
3537 condition.
3538
3539 Suggested fix now in 1.33MR1.
3540
3541 #15. (Version 1.33/8 Apr 96) Asgeir Olafsson <olafsson@cstar.ac.com>
3542
3543 Problem with tree duplication of doubly linked ASTs in ASTBase.cpp.
3544
3545 Suggested fix now in 1.33MR1.
3546
3547 #14. (Version 1.33/28-Feb-96) Andreas.Magnusson@mailbox.swipnet.se
3548
3549 Problem with definition of operator = (const ANTLRTokenPtr rhs).
3550
3551 Suggested fix now in 1.33MR1.
3552
3553 #13. (Version 1.33/13-Feb-96) Franklin Chen (chen@adi.com)
3554
3555 Sun C++ Compiler 3.0.1 can't compile testcpp/1 due to goto in
3556 block with destructors.
3557
3558 Apparently fixed. Can't locate "goto".
3559
3560 #12. (Version 1.33/10-Nov-95) Minor problems with 1.33 code
3561
3562 The following items have been fixed in 1.33MR1:
3563
3564 1. pccts/antlr/main.c line 142
3565
3566 "void" appears in classic C code
3567
3568 2. no makefile in support/genmk
3569
3570 3. EXIT_FAILURE/_SUCCESS instead of PCCTS_EXIT_FAILURE/_SUCCESS
3571
3572 pccts/h/PCCTSAST.cpp
3573 pccts/h/DLexerBase.cpp
3574 pccts/testcpp/6/test.g
3575
3576 4. use of "signed int" isn't accepted by AT&T cfront
3577
3578 pccts/h/PCCTSAST.h line 42
3579
3580 5. in call to ANTLRParser::FAIL the var arg err_k is passed as
3581 "int" but is declared "unsigned int".
3582
3583 6. I believe that a failed validation predicate still does not
3584 get put in a "{...}" envelope, despite the release notes.
3585
3586 7. The #token ">>" appearing in the DLG grammar description
3587 causes DLG to generate the string literal "\>\>" which
3588 is non-conforming and will cause some compilers to
3589 complain (scan.c function act10 line 143 of source code).
3590
3591 #11. (Version 1.32b6) Dave Kuhlman (dkuhlman@netcom.com)
3592
3593 Problem with file close in gen.c. Already fixed in 1.33.
3594
3595 #10. (Version 1.32b6/29-Aug-95)
3596
3597 pccts/antlr/main.c contains a C++ style comments on lines 149
3598 and 176 which causes problems for most C compilers.
3599
3600 Already fixed in 1.33.
3601
3602 #9. (Version 1.32b4/14-Mar-95) dlgauto.h #include "config.h"
3603
3604 The file pccts/h/dlgauto.h should probably contain a #include
3605 "config.h" as it uses the #define symbol __USE_PROTOS.
3606
3607 Added to 1.33MR1.
3608
3609 #8. (Version 1.32b4/6-Mar-95) Michael T. Richter (mtr@igs.net)
3610
3611 In C++ output mode anonymous tokens from in-line regular expressions
3612 can create enum values which are too wide for the datatype of the enum
3613 assigned by the C++ compiler.
3614
3615 Fixed in 1.33MR1.
3616
3617 #7. (Version 1.32b4/6-Mar-95) C++ does not imply __STDC__
3618
3619 In err.h the combination of # directives assumes that a C++
3620 compiler has __STDC__ defined. This is not necessarily true.
3621
3622 This problem also appears in the use of __USE_PROTOS which
3623 is appropriate for both Standard C and C++ in antlr/gen.c
3624 and antlr/lex.c
3625
3626 Fixed in 1.33MR1.
3627
3628 #6. (Version 1.32 ?/15-Feb-95) Name conflict for "TokenType"
3629
3630 Already fixed in 1.33.
3631
3632 #5. (23-Jan-95) Douglas_Cuthbertson.JTIDS@jtids_qmail.hanscom.af.mil
3633
3634 The fail action following a semantic predicate is not enclosed in
3635 "{...}". This can lead to problems when the fail action contains
3636 more than one statement.
3637
3638 Fixed in 1.33MR1.
3639
3640 #4 . (Version 1.33/31-Mar-96) jlilley@empathy.com (John Lilley)
3641
3642 Put briefly, a semantic predicate ought to abort a guess if it fails.
3643
3644 Correction suggested by J. Lilley has been added to 1.33MR1.
3645
3646 #3 . (Version 1.33) P.A.Keller@bath.ac.uk
3647
3648 Extra commas are placed in the K&R style argument list for rules
3649 when using both exceptions and ASTs.
3650
3651 Fixed in 1.33MR1.
3652
3653 #2. (Version 1.32b6/2-Oct-95) Brad Schick <schick@interaccess.com>
3654
3655 Construct #[] generates zzastnew() in C++ mode.
3656
3657 Already fixed in 1.33.
3658
3659 #1. (Version 1.33) Bob Bailey (robert@oakhill.sps.mot.com)
3660
3661 Previously, config.h assumed that all PC systems required
3662 "short" file names. The user can now override that
3663 assumption with "#define LONGFILENAMES".
3664
3665 Added to 1.33MR1.
+0
-2049
contrib/pccts/CHANGES_SUMMARY.txt less more
0 ======================================================================
1
2 CHANGES_SUMMARY.TXT
3
4 A QUICK overview of changes from 1.33 in reverse order
5
6 A summary of additions rather than bug fixes and minor code changes.
7
8 Numbers refer to items in CHANGES_FROM_133*.TXT
9 which may contain additional information.
10
11 DISCLAIMER
12
13 The software and these notes are provided "as is". They may include
14 typographical or technical errors and their authors disclaims all
15 liability of any kind or nature for damages due to error, fault,
16 defect, or deficiency regardless of cause. All warranties of any
17 kind, either express or implied, including, but not limited to, the
18 implied warranties of merchantability and fitness for a particular
19 purpose are disclaimed.
20
21 ======================================================================
22
23 #258. You can specify a user-defined base class for your parser
24
25 The base class must constructor must have a signature similar to
26 that of ANTLRParser.
27
28 #253. Generation of block preamble (-preamble and -preamble_first)
29
30 The antlr option -preamble causes antlr to insert the code
31 BLOCK_PREAMBLE at the start of each rule and block.
32
33 The antlr option -preamble_first is similar, but inserts the
34 code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol
35 PreambleFirst_123 is equivalent to the first set defined by
36 the #FirstSetSymbol described in Item #248.
37
38 #248. Generate symbol for first set of an alternative
39
40 rr : #FirstSetSymbol(rr_FirstSet) ( Foo | Bar ) ;
41
42 #216. Defer token fetch for C++ mode
43
44 When the ANTLRParser class is built with the pre-processor option
45 ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred
46 until LA(i) or LT(i) is called.
47
48 #215. Use reset() to reset DLGLexerBase
49 #188. Added pccts/h/DLG_stream_input.h
50 #180. Added ANTLRParser::getEofToken()
51 #173. -glms for Microsoft style filenames with -gl
52 #170. Suppression for predicates with lookahead depth >1
53
54 Consider the following grammar with -ck 2 and the predicate in rule
55 "a" with depth 2:
56
57 r1 : (ab)* "@"
58 ;
59
60 ab : a
61 | b
62 ;
63
64 a : (A B)? => <<p(LATEXT(2))>>? A B C
65 ;
66
67 b : A B C
68 ;
69
70 Normally, the predicate would be hoisted into rule r1 in order to
71 determine whether to call rule "ab". However it should *not* be
72 hoisted because, even if p is false, there is a valid alternative
73 in rule b. With "-mrhoistk on" the predicate will be suppressed.
74
75 If "-info p" command line option is present the following information
76 will appear in the generated code:
77
78 while ( (LA(1)==A)
79 #if 0
80
81 Part (or all) of predicate with depth > 1 suppressed by alternative
82 without predicate
83
84 pred << p(LATEXT(2))>>?
85 depth=k=2 ("=>" guard) rule a line 8 t1.g
86 tree context:
87 (root = A
88 B
89 )
90
91 The token sequence which is suppressed: ( A B )
92 The sequence of references which generate that sequence of tokens:
93
94 1 to ab r1/1 line 1 t1.g
95 2 ab ab/1 line 4 t1.g
96 3 to b ab/2 line 5 t1.g
97 4 b b/1 line 11 t1.g
98 5 #token A b/1 line 11 t1.g
99 6 #token B b/1 line 11 t1.g
100
101 #endif
102
103 A slightly more complicated example:
104
105 r1 : (ab)* "@"
106 ;
107
108 ab : a
109 | b
110 ;
111
112 a : (A B)? => <<p(LATEXT(2))>>? (A B | D E)
113 ;
114
115 b : <<q(LATEXT(2))>>? D E
116 ;
117
118
119 In this case, the sequence (D E) in rule "a" which lies behind
120 the guard is used to suppress the predicate with context (D E)
121 in rule b.
122
123 while ( (LA(1)==A || LA(1)==D)
124 #if 0
125
126 Part (or all) of predicate with depth > 1 suppressed by alternative
127 without predicate
128
129 pred << q(LATEXT(2))>>?
130 depth=k=2 rule b line 11 t2.g
131 tree context:
132 (root = D
133 E
134 )
135
136 The token sequence which is suppressed: ( D E )
137 The sequence of references which generate that sequence of tokens:
138
139 1 to ab r1/1 line 1 t2.g
140 2 ab ab/1 line 4 t2.g
141 3 to a ab/1 line 4 t2.g
142 4 a a/1 line 8 t2.g
143 5 #token D a/1 line 8 t2.g
144 6 #token E a/1 line 8 t2.g
145
146 #endif
147 &&
148 #if 0
149
150 pred << p(LATEXT(2))>>?
151 depth=k=2 ("=>" guard) rule a line 8 t2.g
152 tree context:
153 (root = A
154 B
155 )
156
157 #endif
158
159 (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) ) {
160 ab();
161 ...
162
163 #165. (Changed in MR13) option -newAST
164
165 To create ASTs from an ANTLRTokenPtr antlr usually calls
166 "new AST(ANTLRTokenPtr)". This option generates a call
167 to "newAST(ANTLRTokenPtr)" instead. This allows a user
168 to define a parser member function to create an AST object.
169
170 #161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h
171
172 #158. (Changed in MR13) #header causes problem for pre-processors
173
174 A user who runs the C pre-processor on antlr source suggested
175 that another syntax be allowed. With MR13 such directives
176 such as #header, #pragma, etc. may be written as "\#header",
177 "\#pragma", etc. For escaping pre-processor directives inside
178 a #header use something like the following:
179
180 \#header
181 <<
182 \#include <stdio.h>
183 >>
184
185 #155. (Changed in MR13) Context behind predicates can suppress
186
187 With -mrhoist enabled the context behind a guarded predicate can
188 be used to suppress other predicates. Consider the following grammar:
189
190 r0 : (r1)+;
191
192 r1 : rp
193 | rq
194 ;
195 rp : <<p LATEXT(1)>>? B ;
196 rq : (A)? => <<q LATEXT(1)>>? (A|B);
197
198 In earlier versions both predicates "p" and "q" would be hoisted into
199 rule r0. With MR12c predicate p is suppressed because the context which
200 follows predicate q includes "B" which can "cover" predicate "p". In
201 other words, in trying to decide in r0 whether to call r1, it doesn't
202 really matter whether p is false or true because, either way, there is
203 a valid choice within r1.
204
205 #154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>
206
207 A common error, even among experienced pccts users, is to code
208 an init-action to inhibit hoisting rather than a leading action.
209 An init-action does not inhibit hoisting.
210
211 This was coded:
212
213 rule1 : <<;>> rule2
214
215 This is what was meant:
216
217 rule1 : <<;>> <<;>> rule2
218
219 With MR13, the user can code:
220
221 rule1 : <<;>> <<nohoist>> rule2
222
223 The following will give an error message:
224
225 rule1 : <<nohoist>> rule2
226
227 If the <<nohoist>> appears as an init-action rather than a leading
228 action an error message is issued. The meaning of an init-action
229 containing "nohoist" is unclear: does it apply to just one
230 alternative or to all alternatives ?
231
232 #151a. Addition of ANTLRParser::getLexer(), ANTLRTokenStream::getLexer()
233
234 You must manually cast the ANTLRTokenStream to your program's
235 lexer class. Because the name of the lexer's class is not fixed.
236 Thus it is impossible to incorporate it into the DLGLexerBase
237 class.
238
239 #151b.(Changed in MR12) ParserBlackBox member getLexer()
240
241 #150. (Changed in MR12) syntaxErrCount and lexErrCount now public
242
243 #149. (Changed in MR12) antlr option -info o (letter o for orphan)
244
245 If there is more than one rule which is not referenced by any
246 other rule then all such rules are listed. This is useful for
247 alerting one to rules which are not used, but which can still
248 contribute to ambiguity.
249
250 #148. (Changed in MR11) #token names appearing in zztokens,token_tbl
251
252 One can write:
253
254 #token Plus ("+") "\+"
255 #token RP ("(") "\("
256 #token COM ("comment begin") "/\*"
257
258 The string in parenthesis will be used in syntax error messages.
259
260 #146. (Changed in MR11) Option -treport for locating "difficult" alts
261
262 It can be difficult to determine which alternatives are causing
263 pccts to work hard to resolve an ambiguity. In some cases the
264 ambiguity is successfully resolved after much CPU time so there
265 is no message at all.
266
267 A rough measure of the amount of work being peformed which is
268 independent of the CPU speed and system load is the number of
269 tnodes created. Using "-info t" gives information about the
270 total number of tnodes created and the peak number of tnodes.
271
272 Tree Nodes: peak 1300k created 1416k lost 0
273
274 It also puts in the generated C or C++ file the number of tnodes
275 created for a rule (at the end of the rule). However this
276 information is not sufficient to locate the alternatives within
277 a rule which are causing the creation of tnodes.
278
279 Using:
280
281 antlr -treport 100000 ....
282
283 causes antlr to list on stdout any alternatives which require the
284 creation of more than 100,000 tnodes, along with the lookahead sets
285 for those alternatives.
286
287 The following is a trivial case from the ansi.g grammar which shows
288 the format of the report. This report might be of more interest
289 in cases where 1,000,000 tuples were created to resolve the ambiguity.
290
291 -------------------------------------------------------------------------
292 There were 0 tuples whose ambiguity could not be resolved
293 by full lookahead
294 There were 157 tnodes created to resolve ambiguity between:
295
296 Choice 1: statement/2 line 475 file ansi.g
297 Choice 2: statement/3 line 476 file ansi.g
298
299 Intersection of lookahead[1] sets:
300
301 IDENTIFIER
302
303 Intersection of lookahead[2] sets:
304
305 LPARENTHESIS COLON AMPERSAND MINUS
306 STAR PLUSPLUS MINUSMINUS ONESCOMPLEMENT
307 NOT SIZEOF OCTALINT DECIMALINT
308 HEXADECIMALINT FLOATONE FLOATTWO IDENTIFIER
309 STRING CHARACTER
310 -------------------------------------------------------------------------
311
312 #143. (Changed in MR11) Optional ";" at end of #token statement
313
314 Fixes problem of:
315
316 #token X "x"
317
318 <<
319 parser action
320 >>
321
322 Being confused with:
323
324 #token X "x" <<lexical action>>
325
326 #142. (Changed in MR11) class BufFileInput subclass of DLGInputStream
327
328 Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class
329 BufFileInput derived from DLGInputStream which provides a
330 function lookahead(char *string) to test characters in the
331 input stream more than one character ahead.
332 The class is located in pccts/h/BufFileInput.* of the kit.
333
334 #140. #pred to define predicates
335
336 +---------------------------------------------------+
337 | Note: Assume "-prc on" for this entire discussion |
338 +---------------------------------------------------+
339
340 A problem with predicates is that each one is regarded as
341 unique and capable of disambiguating cases where two
342 alternatives have identical lookahead. For example:
343
344 rule : <<pred(LATEXT(1))>>? A
345 | <<pred(LATEXT(1))>>? A
346 ;
347
348 will not cause any error messages or warnings to be issued
349 by earlier versions of pccts. To compare the text of the
350 predicates is an incomplete solution.
351
352 In 1.33MR11 I am introducing the #pred statement in order to
353 solve some problems with predicates. The #pred statement allows
354 one to give a symbolic name to a "predicate literal" or a
355 "predicate expression" in order to refer to it in other predicate
356 expressions or in the rules of the grammar.
357
358 The predicate literal associated with a predicate symbol is C
359 or C++ code which can be used to test the condition. A
360 predicate expression defines a predicate symbol in terms of other
361 predicate symbols using "!", "&&", and "||". A predicate symbol
362 can be defined in terms of a predicate literal, a predicate
363 expression, or *both*.
364
365 When a predicate symbol is defined with both a predicate literal
366 and a predicate expression, the predicate literal is used to generate
367 code, but the predicate expression is used to check for two
368 alternatives with identical predicates in both alternatives.
369
370 Here are some examples of #pred statements:
371
372 #pred IsLabel <<isLabel(LATEXT(1))>>?
373 #pred IsLocalVar <<isLocalVar(LATEXT(1))>>?
374 #pred IsGlobalVar <<isGlobalVar(LATEXT(1)>>?
375 #pred IsVar <<isVar(LATEXT(1))>>? IsLocalVar || IsGlobalVar
376 #pred IsScoped <<isScoped(LATEXT(1))>>? IsLabel || IsLocalVar
377
378 I hope that the use of EBNF notation to describe the syntax of the
379 #pred statement will not cause problems for my readers (joke).
380
381 predStatement : "#pred"
382 CapitalizedName
383 (
384 "<<predicate_literal>>?"
385 | "<<predicate_literal>>?" predOrExpr
386 | predOrExpr
387 )
388 ;
389
390 predOrExpr : predAndExpr ( "||" predAndExpr ) * ;
391
392 predAndExpr : predPrimary ( "&&" predPrimary ) * ;
393
394 predPrimary : CapitalizedName
395 | "!" predPrimary
396 | "(" predOrExpr ")"
397 ;
398
399 What is the purpose of this nonsense ?
400
401 To understand how predicate symbols help, you need to realize that
402 predicate symbols are used in two different ways with two different
403 goals.
404
405 a. Allow simplification of predicates which have been combined
406 during predicate hoisting.
407
408 b. Allow recognition of identical predicates which can't disambiguate
409 alternatives with common lookahead.
410
411 First we will discuss goal (a). Consider the following rule:
412
413 rule0: rule1
414 | ID
415 | ...
416 ;
417
418 rule1: rule2
419 | rule3
420 ;
421
422 rule2: <<isX(LATEXT(1))>>? ID ;
423 rule3: <<!isX(LATEXT(1)>>? ID ;
424
425 When the predicates in rule2 and rule3 are combined by hoisting
426 to create a prediction expression for rule1 the result is:
427
428 if ( LA(1)==ID
429 && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...
430
431 This is inefficient, but more importantly, can lead to false
432 assumptions that the predicate expression distinguishes the rule1
433 alternative with some other alternative with lookahead ID. In
434 MR11 one can write:
435
436 #pred IsX <<isX(LATEXT(1))>>?
437
438 ...
439
440 rule2: <<IsX>>? ID ;
441 rule3: <<!IsX>>? ID ;
442
443 During hoisting MR11 recognizes this as a special case and
444 eliminates the predicates. The result is a prediction
445 expression like the following:
446
447 if ( LA(1)==ID ) { rule1(); ...
448
449 Please note that the following cases which appear to be equivalent
450 *cannot* be simplified by MR11 during hoisting because the hoisting
451 logic only checks for a "!" in the predicate action, not in the
452 predicate expression for a predicate symbol.
453
454 *Not* equivalent and is not simplified during hoisting:
455
456 #pred IsX <<isX(LATEXT(1))>>?
457 #pred NotX <<!isX(LATEXT(1))>>?
458 ...
459 rule2: <<IsX>>? ID ;
460 rule3: <<NotX>>? ID ;
461
462 *Not* equivalent and is not simplified during hoisting:
463
464 #pred IsX <<isX(LATEXT(1))>>?
465 #pred NotX !IsX
466 ...
467 rule2: <<IsX>>? ID ;
468 rule3: <<NotX>>? ID ;
469
470 Now we will discuss goal (b).
471
472 When antlr discovers that there is a lookahead ambiguity between
473 two alternatives it attempts to resolve the ambiguity by searching
474 for predicates in both alternatives. In the past any predicate
475 would do, even if the same one appeared in both alternatives:
476
477 rule: <<p(LATEXT(1))>>? X
478 | <<p(LATEXT(1))>>? X
479 ;
480
481 The #pred statement is a start towards solving this problem.
482 During ambiguity resolution (*not* predicate hoisting) the
483 predicates for the two alternatives are expanded and compared.
484 Consider the following example:
485
486 #pred Upper <<isUpper(LATEXT(1))>>?
487 #pred Lower <<isLower(LATEXT(1))>>?
488 #pred Alpha <<isAlpha(LATEXT(1))>>? Upper || Lower
489
490 rule0: rule1
491 | <<Alpha>>? ID
492 ;
493
494 rule1:
495 | rule2
496 | rule3
497 ...
498 ;
499
500 rule2: <<Upper>>? ID;
501 rule3: <<Lower>>? ID;
502
503 The definition of #pred Alpha expresses:
504
505 a. to test the predicate use the C code "isAlpha(LATEXT(1))"
506
507 b. to analyze the predicate use the information that
508 Alpha is equivalent to the union of Upper and Lower,
509
510 During ambiguity resolution the definition of Alpha is expanded
511 into "Upper || Lower" and compared with the predicate in the other
512 alternative, which is also "Upper || Lower". Because they are
513 identical MR11 will report a problem.
514
515 -------------------------------------------------------------------------
516 t10.g, line 5: warning: the predicates used to disambiguate rule rule0
517 (file t10.g alt 1 line 5 and alt 2 line 6)
518 are identical when compared without context and may have no
519 resolving power for some lookahead sequences.
520 -------------------------------------------------------------------------
521
522 If you use the "-info p" option the output file will contain:
523
524 +----------------------------------------------------------------------+
525 |#if 0 |
526 | |
527 |The following predicates are identical when compared without |
528 | lookahead context information. For some ambiguous lookahead |
529 | sequences they may not have any power to resolve the ambiguity. |
530 | |
531 |Choice 1: rule0/1 alt 1 line 5 file t10.g |
532 | |
533 | The original predicate for choice 1 with available context |
534 | information: |
535 | |
536 | OR expr |
537 | |
538 | pred << Upper>>? |
539 | depth=k=1 rule rule2 line 14 t10.g |
540 | set context: |
541 | ID |
542 | |
543 | pred << Lower>>? |
544 | depth=k=1 rule rule3 line 15 t10.g |
545 | set context: |
546 | ID |
547 | |
548 | The predicate for choice 1 after expansion (but without context |
549 | information): |
550 | |
551 | OR expr |
552 | |
553 | pred << isUpper(LATEXT(1))>>? |
554 | depth=k=1 rule line 1 t10.g |
555 | |
556 | pred << isLower(LATEXT(1))>>? |
557 | depth=k=1 rule line 2 t10.g |
558 | |
559 | |
560 |Choice 2: rule0/2 alt 2 line 6 file t10.g |
561 | |
562 | The original predicate for choice 2 with available context |
563 | information: |
564 | |
565 | pred << Alpha>>? |
566 | depth=k=1 rule rule0 line 6 t10.g |
567 | set context: |
568 | ID |
569 | |
570 | The predicate for choice 2 after expansion (but without context |
571 | information): |
572 | |
573 | OR expr |
574 | |
575 | pred << isUpper(LATEXT(1))>>? |
576 | depth=k=1 rule line 1 t10.g |
577 | |
578 | pred << isLower(LATEXT(1))>>? |
579 | depth=k=1 rule line 2 t10.g |
580 | |
581 | |
582 |#endif |
583 +----------------------------------------------------------------------+
584
585 The comparison of the predicates for the two alternatives takes
586 place without context information, which means that in some cases
587 the predicates will be considered identical even though they operate
588 on disjoint lookahead sets. Consider:
589
590 #pred Alpha
591
592 rule1: <<Alpha>>? ID
593 | <<Alpha>>? Label
594 ;
595
596 Because the comparison of predicates takes place without context
597 these will be considered identical. The reason for comparing
598 without context is that otherwise it would be necessary to re-evaluate
599 the entire predicate expression for each possible lookahead sequence.
600 This would require more code to be written and more CPU time during
601 grammar analysis, and it is not yet clear whether anyone will even make
602 use of the new #pred facility.
603
604 A temporary workaround might be to use different #pred statements
605 for predicates you know have different context. This would avoid
606 extraneous warnings.
607
608 The above example might be termed a "false positive". Comparison
609 without context will also lead to "false negatives". Consider the
610 following example:
611
612 #pred Alpha
613 #pred Beta
614
615 rule1: <<Alpha>>? A
616 | rule2
617 ;
618
619 rule2: <<Alpha>>? A
620 | <<Beta>>? B
621 ;
622
623 The predicate used for alt 2 of rule1 is (Alpha || Beta). This
624 appears to be different than the predicate Alpha used for alt1.
625 However, the context of Beta is B. Thus when the lookahead is A
626 Beta will have no resolving power and Alpha will be used for both
627 alternatives. Using the same predicate for both alternatives isn't
628 very helpful, but this will not be detected with 1.33MR11.
629
630 To properly handle this the predicate expression would have to be
631 evaluated for each distinct lookahead context.
632
633 To determine whether two predicate expressions are identical is
634 difficult. The routine may fail to identify identical predicates.
635
636 The #pred feature also compares predicates to see if a choice between
637 alternatives which is resolved by a predicate which makes the second
638 choice unreachable. Consider the following example:
639
640 #pred A <<A(LATEXT(1)>>?
641 #pred B <<B(LATEXT(1)>>?
642 #pred A_or_B A || B
643
644 r : s
645 | t
646 ;
647 s : <<A_or_B>>? ID
648 ;
649 t : <<A>>? ID
650 ;
651
652 ----------------------------------------------------------------------------
653 t11.g, line 5: warning: the predicate used to disambiguate the
654 first choice of rule r
655 (file t11.g alt 1 line 5 and alt 2 line 6)
656 appears to "cover" the second predicate when compared without context.
657 The second predicate may have no resolving power for some lookahead
658 sequences.
659 ----------------------------------------------------------------------------
660
661 #132. (Changed in 1.33MR11) Recognition of identical predicates in alts
662
663 Prior to 1.33MR11, there would be no ambiguity warning when the
664 very same predicate was used to disambiguate both alternatives:
665
666 test: ref B
667 | ref C
668 ;
669
670 ref : <<pred(LATEXT(1)>>? A
671
672 In 1.33MR11 this will cause the warning:
673
674 warning: the predicates used to disambiguate rule test
675 (file v98.g alt 1 line 1 and alt 2 line 2)
676 are identical and have no resolving power
677
678 ----------------- Note -----------------
679
680 This is different than the following case
681
682 test: <<pred(LATEXT(1))>>? A B
683 | <<pred(LATEXT(1)>>? A C
684 ;
685
686 In this case there are two distinct predicates
687 which have exactly the same text. In the first
688 example there are two references to the same
689 predicate. The problem represented by this
690 grammar will be addressed later.
691
692
693 #127. (Changed in 1.33MR11)
694
695 Count Syntax Errors Count DLG Errors
696 ------------------- ----------------
697
698 C++ mode ANTLRParser:: DLGLexerBase::
699 syntaxErrCount lexErrCount
700 C mode zzSyntaxErrCount zzLexErrCount
701
702 The C mode variables are global and initialized to 0.
703 They are *not* reset to 0 automatically when antlr is
704 restarted.
705
706 The C++ mode variables are public. They are initialized
707 to 0 by the constructors. They are *not* reset to 0 by the
708 ANTLRParser::init() method.
709
710 Suggested by Reinier van den Born (reinier@vnet.ibm.com).
711
712 #126. (Changed in 1.33MR11) Addition of #first <<...>>
713
714 The #first <<...>> inserts the specified text in the output
715 files before any other #include statements required by pccts.
716 The only things before the #first text are comments and
717 a #define ANTLR_VERSION.
718
719 Requested by and Esa Pulkkinen (esap@cs.tut.fi) and Alexin
720 Zoltan (alexin@inf.u-szeged.hu).
721
722 #124. A Note on the New "&&" Style Guarded Predicates
723
724 I've been asked several times, "What is the difference between
725 the old "=>" style guard predicates and the new style "&&" guard
726 predicates, and how do you choose one over the other" ?
727
728 The main difference is that the "=>" does not apply the
729 predicate if the context guard doesn't match, whereas
730 the && form always does. What is the significance ?
731
732 If you have a predicate which is not on the "leading edge"
733 it is cannot be hoisted. Suppose you need a predicate that
734 looks at LA(2). You must introduce it manually. The
735 classic example is:
736
737 castExpr :
738 LP typeName RP
739 | ....
740 ;
741
742 typeName : <<isTypeName(LATEXT(1))>>? ID
743 | STRUCT ID
744 ;
745
746 The problem is that isTypeName() isn't on the leading edge
747 of typeName, so it won't be hoisted into castExpr to help
748 make a decision on which production to choose.
749
750 The *first* attempt to fix it is this:
751
752 castExpr :
753 <<isTypeName(LATEXT(2))>>?
754 LP typeName RP
755 | ....
756 ;
757
758 Unfortunately, this won't work because it ignores
759 the problem of STRUCT. The solution is to apply
760 isTypeName() in castExpr if LA(2) is an ID and
761 don't apply it when LA(2) is STRUCT:
762
763 castExpr :
764 (LP ID)? => <<isTypeName(LATEXT(2))>>?
765 LP typeName RP
766 | ....
767 ;
768
769 In conclusion, the "=>" style guarded predicate is
770 useful when:
771
772 a. the tokens required for the predicate
773 are not on the leading edge
774 b. there are alternatives in the expression
775 selected by the predicate for which the
776 predicate is inappropriate
777
778 If (b) were false, then one could use a simple
779 predicate (assuming "-prc on"):
780
781 castExpr :
782 <<isTypeName(LATEXT(2))>>?
783 LP typeName RP
784 | ....
785 ;
786
787 typeName : <<isTypeName(LATEXT(1))>>? ID
788 ;
789
790 So, when do you use the "&&" style guarded predicate ?
791
792 The new-style "&&" predicate should always be used with
793 predicate context. The context guard is in ADDITION to
794 the automatically computed context. Thus it useful for
795 predicates which depend on the token type for reasons
796 other than context.
797
798 The following example is contributed by Reinier van den Born
799 (reinier@vnet.ibm.com).
800
801 +-------------------------------------------------------------------------+
802 | This grammar has two ways to call functions: |
803 | |
804 | - a "standard" call syntax with parens and comma separated args |
805 | - a shell command like syntax (no parens and spacing separated args) |
806 | |
807 | The former also allows a variable to hold the name of the function, |
808 | the latter can also be used to call external commands. |
809 | |
810 | The grammar (simplified) looks like this: |
811 | |
812 | fun_call : ID "(" { expr ("," expr)* } ")" |
813 | /* ID is function name */ |
814 | | "@" ID "(" { expr ("," expr)* } ")" |
815 | /* ID is var containing fun name */ |
816 | ; |
817 | |
818 | command : ID expr* /* ID is function name */ |
819 | | path expr* /* path is external command name */ |
820 | ; |
821 | |
822 | path : ID /* left out slashes and such */ |
823 | | "@" ID /* ID is environment var */ |
824 | ; |
825 | |
826 | expr : .... |
827 | | "(" expr ")"; |
828 | |
829 | call : fun_call |
830 | | command |
831 | ; |
832 | |
833 | Obviously the call is wildly ambiguous. This is more or less how this |
834 | is to be resolved: |
835 | |
836 | A call begins with an ID or an @ followed by an ID. |
837 | |
838 | If it is an ID and if it is an ext. command name -> command |
839 | if followed by a paren -> fun_call |
840 | otherwise -> command |
841 | |
842 | If it is an @ and if the ID is a var name -> fun_call |
843 | otherwise -> command |
844 | |
845 | One can implement these rules quite neatly using && predicates: |
846 | |
847 | call : ("@" ID)? && <<isVarName(LT(2))>>? fun_call |
848 | | (ID)? && <<isExtCmdName>>? command |
849 | | (ID "(")? fun_call |
850 | | command |
851 | ; |
852 | |
853 | This can be done better, so it is not an ideal example, but it |
854 | conveys the principle. |
855 +-------------------------------------------------------------------------+
856
857 #122. (Changed in 1.33MR11) Member functions to reset DLG in C++ mode
858
859 void DLGFileReset(FILE *f) { input = f; found_eof = 0; }
860 void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }
861
862 Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)
863
864 #119. (Changed in 1.33MR11) Ambiguity aid for grammars
865
866 The user can ask for additional information on ambiguities reported
867 by antlr to stdout. At the moment, only one ambiguity report can
868 be created in an antlr run.
869
870 This feature is enabled using the "-aa" (Ambiguity Aid) option.
871
872 The following options control the reporting of ambiguities:
873
874 -aa ruleName Selects reporting by name of rule
875 -aa lineNumber Selects reporting by line number
876 (file name not compared)
877
878 -aam Selects "multiple" reporting for a token
879 in the intersection set of the
880 alternatives.
881
882 For instance, the token ID may appear dozens
883 of times in various paths as the program
884 explores the rules which are reachable from
885 the point of an ambiguity. With option -aam
886 every possible path the search program
887 encounters is reported.
888
889 Without -aam only the first encounter is
890 reported. This may result in incomplete
891 information, but the information may be
892 sufficient and much shorter.
893
894 -aad depth Selects the depth of the search.
895 The default value is 1.
896
897 The number of paths to be searched, and the
898 size of the report can grow geometrically
899 with the -ck value if a full search for all
900 contributions to the source of the ambiguity
901 is explored.
902
903 The depth represents the number of tokens
904 in the lookahead set which are matched against
905 the set of ambiguous tokens. A depth of 1
906 means that the search stops when a lookahead
907 sequence of just one token is matched.
908
909 A k=1 ck=6 grammar might generate 5,000 items
910 in a report if a full depth 6 search is made
911 with the Ambiguity Aid. The source of the
912 problem may be in the first token and obscured
913 by the volume of data - I hesitate to call
914 it information.
915
916 When the user selects a depth > 1, the search
917 is first performed at depth=1 for both
918 alternatives, then depth=2 for both alternatives,
919 etc.
920
921 Sample output for rule grammar in antlr.g itself:
922
923 +---------------------------------------------------------------------+
924 | Ambiguity Aid |
925 | |
926 | Choice 1: grammar/70 line 632 file a.g |
927 | Choice 2: grammar/82 line 644 file a.g |
928 | |
929 | Intersection of lookahead[1] sets: |
930 | |
931 | "\}" "class" "#errclass" "#tokclass" |
932 | |
933 | Choice:1 Depth:1 Group:1 ("#errclass") |
934 | 1 in (...)* block grammar/70 line 632 a.g |
935 | 2 to error grammar/73 line 635 a.g |
936 | 3 error error/1 line 894 a.g |
937 | 4 #token "#errclass" error/2 line 895 a.g |
938 | |
939 | Choice:1 Depth:1 Group:2 ("#tokclass") |
940 | 2 to tclass grammar/74 line 636 a.g |
941 | 3 tclass tclass/1 line 937 a.g |
942 | 4 #token "#tokclass" tclass/2 line 938 a.g |
943 | |
944 | Choice:1 Depth:1 Group:3 ("class") |
945 | 2 to class_def grammar/75 line 637 a.g |
946 | 3 class_def class_def/1 line 669 a.g |
947 | 4 #token "class" class_def/3 line 671 a.g |
948 | |
949 | Choice:1 Depth:1 Group:4 ("\}") |
950 | 2 #token "\}" grammar/76 line 638 a.g |
951 | |
952 | Choice:2 Depth:1 Group:5 ("#errclass") |
953 | 1 in (...)* block grammar/83 line 645 a.g |
954 | 2 to error grammar/93 line 655 a.g |
955 | 3 error error/1 line 894 a.g |
956 | 4 #token "#errclass" error/2 line 895 a.g |
957 | |
958 | Choice:2 Depth:1 Group:6 ("#tokclass") |
959 | 2 to tclass grammar/94 line 656 a.g |
960 | 3 tclass tclass/1 line 937 a.g |
961 | 4 #token "#tokclass" tclass/2 line 938 a.g |
962 | |
963 | Choice:2 Depth:1 Group:7 ("class") |
964 | 2 to class_def grammar/95 line 657 a.g |
965 | 3 class_def class_def/1 line 669 a.g |
966 | 4 #token "class" class_def/3 line 671 a.g |
967 | |
968 | Choice:2 Depth:1 Group:8 ("\}") |
969 | 2 #token "\}" grammar/96 line 658 a.g |
970 +---------------------------------------------------------------------+
971
972 For a linear lookahead set ambiguity (where k=1 or for k>1 but
973 when all lookahead sets [i] with i<k all have degree one) the
974 reports appear in the following order:
975
976 for (depth=1 ; depth <= "-aad depth" ; depth++) {
977 for (alternative=1; alternative <=2 ; alternative++) {
978 while (matches-are-found) {
979 group++;
980 print-report
981 };
982 };
983 };
984
985 For reporting a k-tuple ambiguity, the reports appear in the
986 following order:
987
988 for (depth=1 ; depth <= "-aad depth" ; depth++) {
989 while (matches-are-found) {
990 for (alternative=1; alternative <=2 ; alternative++) {
991 group++;
992 print-report
993 };
994 };
995 };
996
997 This is because matches are generated in different ways for
998 linear lookahead and k-tuples.
999
1000 #117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code
1001
1002 The hoisting of predicates into rules to create prediction
1003 expressions is a problem in antlr. Consider the following
1004 example (k=1 with -prc on):
1005
1006 start : (a)* "@" ;
1007 a : b | c ;
1008 b : <<isUpper(LATEXT(1))>>? A ;
1009 c : A ;
1010
1011 Prior to 1.33MR10 the code generated for "start" would resemble:
1012
1013 while {
1014 if (LA(1)==A &&
1015 (!LA(1)==A || isUpper())) {
1016 a();
1017 }
1018 };
1019
1020 This code is wrong because it makes rule "c" unreachable from
1021 "start". The essence of the problem is that antlr fails to
1022 recognize that there can be a valid alternative within "a" even
1023 when the predicate <<isUpper(LATEXT(1))>>? is false.
1024
1025 In 1.33MR10 with -mrhoist the hoisting of the predicate into
1026 "start" is suppressed because it recognizes that "c" can
1027 cover all the cases where the predicate is false:
1028
1029 while {
1030 if (LA(1)==A) {
1031 a();
1032 }
1033 };
1034
1035 With the antlr "-info p" switch the user will receive information
1036 about the predicate suppression in the generated file:
1037
1038 --------------------------------------------------------------
1039 #if 0
1040
1041 Hoisting of predicate suppressed by alternative without predicate.
1042 The alt without the predicate includes all cases where
1043 the predicate is false.
1044
1045 WITH predicate: line 7 v1.g
1046 WITHOUT predicate: line 7 v1.g
1047
1048 The context set for the predicate:
1049
1050 A
1051
1052 The lookahead set for the alt WITHOUT the semantic predicate:
1053
1054 A
1055
1056 The predicate:
1057
1058 pred << isUpper(LATEXT(1))>>?
1059 depth=k=1 rule b line 9 v1.g
1060 set context:
1061 A
1062 tree context: null
1063
1064 Chain of referenced rules:
1065
1066 #0 in rule start (line 5 v1.g) to rule a
1067 #1 in rule a (line 7 v1.g)
1068
1069 #endif
1070 --------------------------------------------------------------
1071
1072 A predicate can be suppressed by a combination of alternatives
1073 which, taken together, cover a predicate:
1074
1075 start : (a)* "@" ;
1076
1077 a : b | ca | cb | cc ;
1078
1079 b : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;
1080
1081 ca : A ;
1082 cb : B ;
1083 cc : C ;
1084
1085 Consider a more complex example in which "c" covers only part of
1086 a predicate:
1087
1088 start : (a)* "@" ;
1089
1090 a : b
1091 | c
1092 ;
1093
1094 b : <<isUpper(LATEXT(1))>>?
1095 ( A
1096 | X
1097 );
1098
1099 c : A
1100 ;
1101
1102 Prior to 1.33MR10 the code generated for "start" would resemble:
1103
1104 while {
1105 if ( (LA(1)==A || LA(1)==X) &&
1106 (! (LA(1)==A || LA(1)==X) || isUpper()) {
1107 a();
1108 }
1109 };
1110
1111 With 1.33MR10 and -mrhoist the predicate context is restricted to
1112 the non-covered lookahead. The code resembles:
1113
1114 while {
1115 if ( (LA(1)==A || LA(1)==X) &&
1116 (! (LA(1)==X) || isUpper()) {
1117 a();
1118 }
1119 };
1120
1121 With the antlr "-info p" switch the user will receive information
1122 about the predicate restriction in the generated file:
1123
1124 --------------------------------------------------------------
1125 #if 0
1126
1127 Restricting the context of a predicate because of overlap
1128 in the lookahead set between the alternative with the
1129 semantic predicate and one without
1130 Without this restriction the alternative without the predicate
1131 could not be reached when input matched the context of the
1132 predicate and the predicate was false.
1133
1134 WITH predicate: line 11 v4.g
1135 WITHOUT predicate: line 12 v4.g
1136
1137 The original context set for the predicate:
1138
1139 A X
1140
1141 The lookahead set for the alt WITHOUT the semantic predicate:
1142
1143 A
1144
1145 The intersection of the two sets
1146
1147 A
1148
1149 The original predicate:
1150
1151 pred << isUpper(LATEXT(1))>>?
1152 depth=k=1 rule b line 15 v4.g
1153 set context:
1154 A X
1155 tree context: null
1156
1157 The new (modified) form of the predicate:
1158
1159 pred << isUpper(LATEXT(1))>>?
1160 depth=k=1 rule b line 15 v4.g
1161 set context:
1162 X
1163 tree context: null
1164
1165 #endif
1166 --------------------------------------------------------------
1167
1168 The bad news about -mrhoist:
1169
1170 (a) -mrhoist does not analyze predicates with lookahead
1171 depth > 1.
1172
1173 (b) -mrhoist does not look past a guarded predicate to
1174 find context which might cover other predicates.
1175
1176 For these cases you might want to use syntactic predicates.
1177 When a semantic predicate fails during guess mode the guess
1178 fails and the next alternative is tried.
1179
1180 Limitation (a) is illustrated by the following example:
1181
1182 start : (stmt)* EOF ;
1183
1184 stmt : cast
1185 | expr
1186 ;
1187 cast : <<isTypename(LATEXT(2))>>? LP ID RP ;
1188
1189 expr : LP ID RP ;
1190
1191 This is not much different from the first example, except that
1192 it requires two tokens of lookahead context to determine what
1193 to do. This predicate is NOT suppressed because the current version
1194 is unable to handle predicates with depth > 1.
1195
1196 A predicate can be combined with other predicates during hoisting.
1197 In those cases the depth=1 predicates are still handled. Thus,
1198 in the following example the isUpper() predicate will be suppressed
1199 by line #4 when hoisted from "bizarre" into "start", but will still
1200 be present in "bizarre" in order to predict "stmt".
1201
1202 start : (bizarre)* EOF ; // #1
1203 // #2
1204 bizarre : stmt // #3
1205 | A // #4
1206 ;
1207
1208 stmt : cast
1209 | expr
1210 ;
1211
1212 cast : <<isTypename(LATEXT(2))>>? LP ID RP ;
1213
1214 expr : LP ID RP ;
1215 | <<isUpper(LATEXT(1))>>? A
1216
1217 Limitation (b) is illustrated by the following example of a
1218 context guarded predicate:
1219
1220 rule : (A)? <<p>>? // #1
1221 (A // #2
1222 |B // #3
1223 ) // #4
1224 | <<q>> B // #5
1225 ;
1226
1227 Recall that this means that when the lookahead is NOT A then
1228 the predicate "p" is ignored and it attempts to match "A|B".
1229 Ideally, the "B" at line #3 should suppress predicate "q".
1230 However, the current version does not attempt to look past
1231 the guard predicate to find context which might suppress other
1232 predicates.
1233
1234 In some cases -mrhoist will lead to the reporting of ambiguities
1235 which were not visible before:
1236
1237 start : (a)* "@";
1238 a : bc | d;
1239 bc : b | c ;
1240
1241 b : <<isUpper(LATEXT(1))>>? A;
1242 c : A ;
1243
1244 d : A ;
1245
1246 In this case there is a true ambiguity in "a" between "bc" and "d"
1247 which can both match "A". Without -mrhoist the predicate in "b"
1248 is hoisted into "a" and there is no ambiguity reported. However,
1249 with -mrhoist, the predicate in "b" is suppressed by "c" (as it
1250 should be) making the ambiguity in "a" apparent.
1251
1252 The motivations for these changes were hoisting problems reported
1253 by Reinier van den Born (reinier@vnet.ibm.com) and several others.
1254
1255 #113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr
1256
1257 The existing context guarded predicate:
1258
1259 rule : (guard)? => <<p>>? expr
1260 | next_alternative
1261 ;
1262
1263 generates code which resembles:
1264
1265 if (lookahead(expr) && (!guard || pred)) {
1266 expr()
1267 } else ....
1268
1269 This is not suitable for some applications because it allows
1270 expr() to be invoked when the predicate is false. This is
1271 intentional because it is meant to mimic automatically computed
1272 predicate context.
1273
1274 The new context guarded predicate uses the guard information
1275 differently because it has a different goal. Consider:
1276
1277 rule : (guard)? && <<p>>? expr
1278 | next_alternative
1279 ;
1280
1281 The new style of context guarded predicate is equivalent to:
1282
1283 rule : <<guard==true && pred>>? expr
1284 | next_alternative
1285 ;
1286
1287 It generates code which resembles:
1288
1289 if (lookahead(expr) && guard && pred) {
1290 expr();
1291 } else ...
1292
1293 Both forms of guarded predicates severely restrict the form of
1294 the context guard: it can contain no rule references, no
1295 (...)*, no (...)+, and no {...}. It may contain token and
1296 token class references, and alternation ("|").
1297
1298 Addition for 1.33MR11: in the token expression all tokens must
1299 be at the same height of the token tree:
1300
1301 (A ( B | C))? && ... is ok (all height 2)
1302 (A ( B | ))? && ... is not ok (some 1, some 2)
1303 (A B C D | E F G H)? && ... is ok (all height 4)
1304 (A B C D | E )? && ... is not ok (some 4, some 1)
1305
1306 This restriction is required in order to properly compute the lookahead
1307 set for expressions like:
1308
1309 rule1 : (A B C)? && <<pred>>? rule2 ;
1310 rule2 : (A|X) (B|Y) (C|Z);
1311
1312 This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)
1313
1314 #109. (Changed in 1.33MR10) improved trace information
1315
1316 The quality of the trace information provided by the "-gd"
1317 switch has been improved significantly. Here is an example
1318 of the output from a test program. It shows the rule name,
1319 the first token of lookahead, the call depth, and the guess
1320 status:
1321
1322 exit rule gusxx {"?"} depth 2
1323 enter rule gusxx {"?"} depth 2
1324 enter rule gus1 {"o"} depth 3 guessing
1325 guess done - returning to rule gus1 {"o"} at depth 3
1326 (guess mode continues - an enclosing guess is still active)
1327 guess done - returning to rule gus1 {"Z"} at depth 3
1328 (guess mode continues - an enclosing guess is still active)
1329 exit rule gus1 {"Z"} depth 3 guessing
1330 guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)
1331 enter rule gus1 {"o"} depth 3
1332 guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)
1333 guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)
1334 exit rule gus1 {"Z"} depth 3
1335 line 1: syntax error at "Z" missing SC
1336 ...
1337
1338 Rule trace reporting is controlled by the value of the integer
1339 [zz]traceOptionValue: when it is positive tracing is enabled,
1340 otherwise it is disabled. Tracing during guess mode is controlled
1341 by the value of the integer [zz]traceGuessOptionValue. When
1342 it is positive AND [zz]traceOptionValue is positive rule trace
1343 is reported in guess mode.
1344
1345 The values of [zz]traceOptionValue and [zz]traceGuessOptionValue
1346 can be adjusted by subroutine calls listed below.
1347
1348 Depending on the presence or absence of the antlr -gd switch
1349 the variable [zz]traceOptionValueDefault is set to 0 or 1. When
1350 the parser is initialized or [zz]traceReset() is called the
1351 value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.
1352 The value of [zz]traceGuessOptionValue is always initialzed to 1,
1353 but, as noted earlier, nothing will be reported unless
1354 [zz]traceOptionValue is also positive.
1355
1356 When the parser state is saved/restored the value of the trace
1357 variables are also saved/restored. If a restore causes a change in
1358 reporting behavior from on to off or vice versa this will be reported.
1359
1360 When the -gd option is selected, the macro "#define zzTRACE_RULES"
1361 is added to appropriate output files.
1362
1363 C++ mode
1364 --------
1365 int traceOption(int delta)
1366 int traceGuessOption(int delta)
1367 void traceReset()
1368 int traceOptionValueDefault
1369
1370 C mode
1371 --------
1372 int zzTraceOption(int delta)
1373 int zzTraceGuessOption(int delta)
1374 void zzTraceReset()
1375 int zzTraceOptionValueDefault
1376
1377 The argument "delta" is added to the traceOptionValue. To
1378 turn on trace when inside a particular rule one:
1379
1380 rule : <<traceOption(+1);>>
1381 (
1382 rest-of-rule
1383 )
1384 <<traceOption(-1);>>
1385 ; /* fail clause */ <<traceOption(-1);>>
1386
1387 One can use the same idea to turn *off* tracing within a
1388 rule by using a delta of (-1).
1389
1390 An improvement in the rule trace was suggested by Sramji
1391 Ramanathan (ps@kumaran.com).
1392
1393 #108. A Note on Deallocation of Variables Allocated in Guess Mode
1394
1395 NOTE
1396 ------------------------------------------------------
1397 This mechanism only works for heap allocated variables
1398 ------------------------------------------------------
1399
1400 The rewrite of the trace provides the machinery necessary
1401 to properly free variables or undo actions following a
1402 failed guess.
1403
1404 The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded
1405 as part of the zzGUESS macro. When a guess is opened
1406 the value of zzrv is 0. When a longjmp() is executed to
1407 undo the guess, the value of zzrv will be 1.
1408
1409 The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded
1410 as part of the zzGUESS_DONE macro. This is executed
1411 whether the guess succeeds or fails as part of closing
1412 the guess.
1413
1414 The guessSeq is a sequence number which is assigned to each
1415 guess and is incremented by 1 for each guess which becomes
1416 active. It is needed by the user to associate the start of
1417 a guess with the failure and/or completion (closing) of a
1418 guess.
1419
1420 Guesses are nested. They must be closed in the reverse
1421 of the order that they are opened.
1422
1423 In order to free memory used by a variable during a guess
1424 a user must write a routine which can be called to
1425 register the variable along with the current guess sequence
1426 number provided by the zzUSER_GUESS_HOOK macro. If the guess
1427 fails, all variables tagged with the corresponding guess
1428 sequence number should be released. This is ugly, but
1429 it would require a major rewrite of antlr 1.33 to use
1430 some mechanism other than setjmp()/longjmp().
1431
1432 The order of calls for a *successful* guess would be:
1433
1434 zzUSER_GUESS_HOOK(guessSeq,0);
1435 zzUSER_GUESS_DONE_HOOK(guessSeq);
1436
1437 The order of calls for a *failed* guess would be:
1438
1439 zzUSER_GUESS_HOOK(guessSeq,0);
1440 zzUSER_GUESS_HOOK(guessSeq,1);
1441 zzUSER_GUESS_DONE_HOOK(guessSeq);
1442
1443 The default definitions of these macros are empty strings.
1444
1445 Here is an example in C++ mode. The zzUSER_GUESS_HOOK and
1446 zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine
1447 can be used without change in both C and C++ versions.
1448
1449 ----------------------------------------------------------------------
1450 <<
1451
1452 #include "AToken.h"
1453
1454 typedef ANTLRCommonToken ANTLRToken;
1455
1456 #include "DLGLexer.h"
1457
1458 int main() {
1459
1460 {
1461 DLGFileInput in(stdin);
1462 DLGLexer lexer(&in,2000);
1463 ANTLRTokenBuffer pipe(&lexer,1);
1464 ANTLRCommonToken aToken;
1465 P parser(&pipe);
1466
1467 lexer.setToken(&aToken);
1468 parser.init();
1469 parser.start();
1470 };
1471
1472 fclose(stdin);
1473 fclose(stdout);
1474 return 0;
1475 }
1476
1477 >>
1478
1479 <<
1480 char *s=NULL;
1481
1482 #undef zzUSER_GUESS_HOOK
1483 #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);
1484 #undef zzUSER_GUESS_DONE_HOOK
1485 #define zzUSER_GUESS_DONE_HOOK(guessSeq) myGuessHook(guessSeq,2);
1486
1487 void myGuessHook(int guessSeq,int zzrv) {
1488 if (zzrv == 0) {
1489 fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);
1490 } else if (zzrv == 1) {
1491 free (s);
1492 s=NULL;
1493 fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);
1494 } else if (zzrv == 2) {
1495 free (s);
1496 s=NULL;
1497 fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);
1498 };
1499 }
1500
1501 >>
1502
1503 #token A "a"
1504 #token "[\t \ \n]" <<skip();>>
1505
1506 class P {
1507
1508 start : (top)+
1509 ;
1510
1511 top : (which) ? <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>
1512 | other <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>
1513 ; <<if (s != NULL) free(s); s=NULL; >>
1514
1515 which : which2
1516 ;
1517
1518 which2 : which3
1519 ;
1520 which3
1521 : (label)? <<fprintf(stderr,"%s is a label\n",s);>>
1522 | (global)? <<fprintf(stderr,"%s is a global\n",s);>>
1523 | (exclamation)? <<fprintf(stderr,"%s is an exclamation\n",s);>>
1524 ;
1525
1526 label : <<s=strdup(LT(1)->getText());>> A ":" ;
1527
1528 global : <<s=strdup(LT(1)->getText());>> A "::" ;
1529
1530 exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;
1531
1532 other : <<s=strdup(LT(1)->getText());>> "other" ;
1533
1534 }
1535 ----------------------------------------------------------------------
1536
1537 This is a silly example, but illustrates the idea. For the input
1538 "a ::" with tracing enabled the output begins:
1539
1540 ----------------------------------------------------------------------
1541 enter rule "start" depth 1
1542 enter rule "top" depth 2
1543 User hook: starting guess #1
1544 enter rule "which" depth 3 guessing
1545 enter rule "which2" depth 4 guessing
1546 enter rule "which3" depth 5 guessing
1547 User hook: starting guess #2
1548 enter rule "label" depth 6 guessing
1549 guess failed
1550 User hook: failed guess #2
1551 guess done - returning to rule "which3" at depth 5 (guess mode continues
1552 - an enclosing guess is still active)
1553 User hook: ending guess #2
1554 User hook: starting guess #3
1555 enter rule "global" depth 6 guessing
1556 exit rule "global" depth 6 guessing
1557 guess done - returning to rule "which3" at depth 5 (guess mode continues
1558 - an enclosing guess is still active)
1559 User hook: ending guess #3
1560 enter rule "global" depth 6 guessing
1561 exit rule "global" depth 6 guessing
1562 exit rule "which3" depth 5 guessing
1563 exit rule "which2" depth 4 guessing
1564 exit rule "which" depth 3 guessing
1565 guess done - returning to rule "top" at depth 2 (guess mode ends)
1566 User hook: ending guess #1
1567 enter rule "which" depth 3
1568 .....
1569 ----------------------------------------------------------------------
1570
1571 Remember:
1572
1573 (a) Only init-actions are executed during guess mode.
1574 (b) A rule can be invoked multiple times during guess mode.
1575 (c) If the guess succeeds the rule will be called once more
1576 without guess mode so that normal actions will be executed.
1577 This means that the init-action might need to distinguish
1578 between guess mode and non-guess mode using the variable
1579 [zz]guessing.
1580
1581 #101. (Changed in 1.33MR10) antlr -info command line switch
1582
1583 -info
1584
1585 p - extra predicate information in generated file
1586
1587 t - information about tnode use:
1588 at the end of each rule in generated file
1589 summary on stderr at end of program
1590
1591 m - monitor progress
1592 prints name of each rule as it is started
1593 flushes output at start of each rule
1594
1595 f - first/follow set information to stdout
1596
1597 0 - no operation (added in 1.33MR11)
1598
1599 The options may be combined and may appear in any order.
1600 For example:
1601
1602 antlr -info ptm -CC -gt -mrhoist on mygrammar.g
1603
1604 #100a. (Changed in 1.33MR10) Predicate tree simplification
1605
1606 When the same predicates can be referenced in more than one
1607 alternative of a block large predicate trees can be formed.
1608
1609 The difference that these optimizations make is so dramatic
1610 that I have decided to use it even when -mrhoist is not selected.
1611
1612 Consider the following grammar:
1613
1614 start : ( all )* ;
1615
1616 all : a
1617 | d
1618 | e
1619 | f
1620 ;
1621
1622 a : c A B
1623 | c A C
1624 ;
1625
1626 c : <<AAA(LATEXT(2))>>?
1627 ;
1628
1629 d : <<BBB(LATEXT(2))>>? B C
1630 ;
1631
1632 e : <<CCC(LATEXT(2))>>? B C
1633 ;
1634
1635 f : e X Y
1636 ;
1637
1638 In rule "a" there is a reference to rule "c" in both alternatives.
1639 The length of the predicate AAA is k=2 and it can be followed in
1640 alternative 1 only by (A B) while in alternative 2 it can be
1641 followed only by (A C). Thus they do not have identical context.
1642
1643 In rule "all" the alternatives which refer to rules "e" and "f" allow
1644 elimination of the duplicate reference to predicate CCC.
1645
1646 The table below summarized the kind of simplification performed by
1647 1.33MR10. In the table, X and Y stand for single predicates
1648 (not trees).
1649
1650 (OR X (OR Y (OR Z))) => (OR X Y Z)
1651 (AND X (AND Y (AND Z))) => (AND X Y Z)
1652
1653 (OR X (... (OR X Y) ... )) => (OR X (... Y ... ))
1654 (AND X (... (AND X Y) ... )) => (AND X (... Y ... ))
1655 (OR X (... (AND X Y) ... )) => (OR X (... ... ))
1656 (AND X (... (OR X Y) ... )) => (AND X (... ... ))
1657
1658 (AND X) => X
1659 (OR X) => X
1660
1661 In a test with a complex grammar for a real application, a predicate
1662 tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".
1663
1664 In 1.33MR10 there is a greater effort to release memory used
1665 by predicates once they are no longer in use.
1666
1667 #100b. (Changed in 1.33MR10) Suppression of extra predicate tests
1668
1669 The following optimizations require that -mrhoist be selected.
1670
1671 It is relatively easy to optimize the code generated for predicate
1672 gates when they are of the form:
1673
1674 (AND X Y Z ...)
1675 or (OR X Y Z ...)
1676
1677 where X, Y, Z, and "..." represent individual predicates (leaves) not
1678 predicate trees.
1679
1680 If the predicate is an AND the contexts of the X, Y, Z, etc. are
1681 ANDed together to create a single Tree context for the group and
1682 context tests for the individual predicates are suppressed:
1683
1684 --------------------------------------------------
1685 Note: This was incorrect. The contexts should be
1686 ORed together. This has been fixed. A more
1687 complete description is available in item #152.
1688 ---------------------------------------------------
1689
1690 Optimization 1: (AND X Y Z ...)
1691
1692 Suppose the context for Xtest is LA(1)==LP and the context for
1693 Ytest is LA(1)==LP && LA(2)==ID.
1694
1695 Without the optimization the code would resemble:
1696
1697 if (lookaheadContext &&
1698 !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||
1699 ( (! LA(1)==LP || Xtest) &&
1700 (! (LA(1)==LP || LA(2)==ID) || Xtest)
1701 )) {...
1702
1703 With the -mrhoist optimization the code would resemble:
1704
1705 if (lookaheadContext &&
1706 ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...
1707
1708 Optimization 2: (OR X Y Z ...) with identical contexts
1709
1710 Suppose the context for Xtest is LA(1)==ID and for Ytest
1711 the context is also LA(1)==ID.
1712
1713 Without the optimization the code would resemble:
1714
1715 if (lookaheadContext &&
1716 ! (LA(1)==ID || LA(1)==ID) ||
1717 (LA(1)==ID && Xtest) ||
1718 (LA(1)==ID && Ytest) {...
1719
1720 With the -mrhoist optimization the code would resemble:
1721
1722 if (lookaheadContext &&
1723 (! LA(1)==ID) || (Xtest || Ytest) {...
1724
1725 Optimization 3: (OR X Y Z ...) with distinct contexts
1726
1727 Suppose the context for Xtest is LA(1)==ID and for Ytest
1728 the context is LA(1)==LP.
1729
1730 Without the optimization the code would resemble:
1731
1732 if (lookaheadContext &&
1733 ! (LA(1)==ID || LA(1)==LP) ||
1734 (LA(1)==ID && Xtest) ||
1735 (LA(1)==LP && Ytest) {...
1736
1737 With the -mrhoist optimization the code would resemble:
1738
1739 if (lookaheadContext &&
1740 (zzpf=0,
1741 (LA(1)==ID && (zzpf=1) && Xtest) ||
1742 (LA(1)==LP && (zzpf=1) && Ytest) ||
1743 !zzpf) {
1744
1745 These may appear to be of similar complexity at first,
1746 but the non-optimized version contains two tests of each
1747 context while the optimized version contains only one
1748 such test, as well as eliminating some of the inverted
1749 logic (" !(...) || ").
1750
1751 Optimization 4: Computation of predicate gate trees
1752
1753 When generating code for the gates of predicate expressions
1754 antlr 1.33 vanilla uses a recursive procedure to generate
1755 "&&" and "||" expressions for testing the lookahead. As each
1756 layer of the predicate tree is exposed a new set of "&&" and
1757 "||" expressions on the lookahead are generated. In many
1758 cases the lookahead being tested has already been tested.
1759
1760 With -mrhoist a lookahead tree is computed for the entire
1761 lookahead expression. This means that predicates with identical
1762 context or context which is a subset of another predicate's
1763 context disappear.
1764
1765 This is especially important for predicates formed by rules
1766 like the following:
1767
1768 uppperCaseVowel : <<isUpperCase(LATEXT(1))>>? vowel;
1769 vowel: : <<isVowel(LATEXT(1))>>? LETTERS;
1770
1771 These predicates are combined using AND since both must be
1772 satisfied for rule upperCaseVowel. They have identical
1773 context which makes this optimization very effective.
1774
1775 The affect of Items #100a and #100b together can be dramatic. In
1776 a very large (but real world) grammar one particular predicate
1777 expression was reduced from an (unreadable) 50 predicate leaves,
1778 195 LA(1) terms, and 5500 characters to an (easily comprehensible)
1779 3 predicate leaves (all different) and a *single* LA(1) term.
1780
1781 #98. (Changed in 1.33MR10) Option "-info p"
1782
1783 When the user selects option "-info p" the program will generate
1784 detailed information about predicates. If the user selects
1785 "-mrhoist on" additional detail will be provided explaining
1786 the promotion and suppression of predicates. The output is part
1787 of the generated file and sandwiched between #if 0/#endif statements.
1788
1789 Consider the following k=1 grammar:
1790
1791 start : ( all ) * ;
1792
1793 all : ( a
1794 | b
1795 )
1796 ;
1797
1798 a : c B
1799 ;
1800
1801 c : <<LATEXT(1)>>?
1802 | B
1803 ;
1804
1805 b : <<LATEXT(1)>>? X
1806 ;
1807
1808 Below is an excerpt of the output for rule "start" for the three
1809 predicate options (off, on, and maintenance release style hoisting).
1810
1811 For those who do not wish to use the "-mrhoist on" option for code
1812 generation the option can be used in a "diagnostic" mode to provide
1813 valuable information:
1814
1815 a. where one should insert null actions to inhibit hoisting
1816 b. a chain of rule references which shows where predicates are
1817 being hoisted
1818
1819 ======================================================================
1820 Example of "-info p" with "-mrhoist on"
1821 ======================================================================
1822 #if 0
1823
1824 Hoisting of predicate suppressed by alternative without predicate.
1825 The alt without the predicate includes all cases where the
1826 predicate is false.
1827
1828 WITH predicate: line 11 v36.g
1829 WITHOUT predicate: line 12 v36.g
1830
1831 The context set for the predicate:
1832
1833 B
1834
1835 The lookahead set for alt WITHOUT the semantic predicate:
1836
1837 B
1838
1839 The predicate:
1840
1841 pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
1842
1843 set context:
1844 B
1845 tree context: null
1846
1847 Chain of referenced rules:
1848
1849 #0 in rule start (line 1 v36.g) to rule all
1850 #1 in rule all (line 3 v36.g) to rule a
1851 #2 in rule a (line 8 v36.g) to rule c
1852 #3 in rule c (line 11 v36.g)
1853
1854 #endif
1855 &&
1856 #if 0
1857
1858 pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
1859
1860 set context:
1861 X
1862 tree context: null
1863
1864 #endif
1865 ======================================================================
1866 Example of "-info p" with the default -prc setting ( "-prc off")
1867 ======================================================================
1868 #if 0
1869
1870 OR
1871 pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
1872
1873 set context:
1874 nil
1875 tree context: null
1876
1877 pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
1878
1879 set context:
1880 nil
1881 tree context: null
1882
1883 #endif
1884 ======================================================================
1885 Example of "-info p" with "-prc on" and "-mrhoist off"
1886 ======================================================================
1887 #if 0
1888
1889 OR
1890 pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
1891
1892 set context:
1893 B
1894 tree context: null
1895
1896 pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
1897
1898 set context:
1899 X
1900 tree context: null
1901
1902 #endif
1903 ======================================================================
1904
1905 #60. (Changed in 1.33MR7) Major changes to exception handling
1906
1907 There were significant problems in the handling of exceptions
1908 in 1.33 vanilla. The general problem is that it can only
1909 process one level of exception handler. For example, a named
1910 exception handler, an exception handler for an alternative, or
1911 an exception for a subrule always went to the rule's exception
1912 handler if there was no "catch" which matched the exception.
1913
1914 In 1.33MR7 the exception handlers properly "nest". If an
1915 exception handler does not have a matching "catch" then the
1916 nextmost outer exception handler is checked for an appropriate
1917 "catch" clause, and so on until an exception handler with an
1918 appropriate "catch" is found.
1919
1920 There are still undesirable features in the way exception
1921 handlers are implemented, but I do not have time to fix them
1922 at the moment:
1923
1924 The exception handlers for alternatives are outside the
1925 block containing the alternative. This makes it impossible
1926 to access variables declared in a block or to resume the
1927 parse by "falling through". The parse can still be easily
1928 resumed in other ways, but not in the most natural fashion.
1929
1930 This results in an inconsistentcy between named exception
1931 handlers and exception handlers for alternatives. When
1932 an exception handler for an alternative "falls through"
1933 it goes to the nextmost outer handler - not the "normal
1934 action".
1935
1936 A major difference between 1.33MR7 and 1.33 vanilla is
1937 the default action after an exception is caught:
1938
1939 1.33 Vanilla
1940 ------------
1941 In 1.33 vanilla the signal value is set to zero ("NoSignal")
1942 and the code drops through to the code following the exception.
1943 For named exception handlers this is the "normal action".
1944 For alternative exception handlers this is the rule's handler.
1945
1946 1.33MR7
1947 -------
1948 In 1.33MR7 the signal value is NOT automatically set to zero.
1949
1950 There are two cases:
1951
1952 For named exception handlers: if the signal value has been
1953 set to zero the code drops through to the "normal action".
1954
1955 For all other cases the code branches to the nextmost outer
1956 exception handler until it reaches the handler for the rule.
1957
1958 The following macros have been defined for convenience:
1959
1960 C/C++ Mode Name
1961 --------------------
1962 (zz)suppressSignal
1963 set signal & return signal arg to 0 ("NoSignal")
1964 (zz)setSignal(intValue)
1965 set signal & return signal arg to some value
1966 (zz)exportSignal
1967 copy the signal value to the return signal arg
1968
1969 I'm not sure why PCCTS make a distinction between the local
1970 signal value and the return signal argument, but I'm loathe
1971 to change the code. The burden of copying the local signal
1972 value to the return signal argument can be given to the
1973 default signal handler, I suppose.
1974
1975 #53. (Explanation for 1.33MR6) What happens after an exception is caught ?
1976
1977 The Book is silent about what happens after an exception
1978 is caught.
1979
1980 The following code fragment prints "Error Action" followed
1981 by "Normal Action".
1982
1983 test : Word ex:Number <<printf("Normal Action\n");>>
1984 exception[ex]
1985 catch NoViableAlt:
1986 <<printf("Error Action\n");>>
1987 ;
1988
1989 The reason for "Normal Action" is that the normal flow of the
1990 program after a user-written exception handler is to "drop through".
1991 In the case of an exception handler for a rule this results in
1992 the exection of a "return" statement. In the case of an
1993 exception handler attached to an alternative, rule, or token
1994 this is the code that would have executed had there been no
1995 exception.
1996
1997 The user can achieve the desired result by using a "return"
1998 statement.
1999
2000 test : Word ex:Number <<printf("Normal Action\n");>>
2001 exception[ex]
2002 catch NoViableAlt:
2003 <<printf("Error Action\n"); return;>>
2004 ;
2005
2006 The most powerful mechanism for recovery from parse errors
2007 in pccts is syntactic predicates because they provide
2008 backtracking. Exceptions allow "return", "break",
2009 "consumeUntil(...)", "goto _handler", "goto _fail", and
2010 changing the _signal value.
2011
2012 #41. (Added in 1.33MR6) antlr -stdout
2013
2014 Using "antlr -stdout ..." forces the text that would
2015 normally go to the grammar.c or grammar.cpp file to
2016 stdout.
2017
2018 #40. (Added in 1.33MR6) antlr -tab to change tab stops
2019
2020 Using "antlr -tab number ..." changes the tab stops
2021 for the grammar.c or grammar.cpp file. The number
2022 must be between 0 and 8. Using 0 gives tab characters,
2023 values between 1 and 8 give the appropriate number of
2024 space characters.
2025
2026 #34. (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)
2027
2028 Previously there was no public function for changing the line
2029 number maintained by the lexer.
2030
2031 #28. (Added to 1.33MR1) More control over DLG header
2032
2033 Version 1.33MR1 adds the following directives to PCCTS
2034 for C++ mode:
2035
2036 #lexprefix <<source code>>
2037
2038 Adds source code to the DLGLexer.h file
2039 after the #include "DLexerBase.h" but
2040 before the start of the class definition.
2041
2042 #lexmember <<source code>>
2043
2044 Adds source code to the DLGLexer.h file
2045 as part of the DLGLexer class body. It
2046 appears immediately after the start of
2047 the class and a "public: statement.
2048
+0
-5
contrib/pccts/IBM_VISUAL_AGE_PROJECTS/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 EXTRA_DIST= antlr.icc dlg.icc sorcerer.icc
4
+0
-456
contrib/pccts/IBM_VISUAL_AGE_PROJECTS/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/IBM_VISUAL_AGE_PROJECTS
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 am__can_run_installinfo = \
102 case $$AM_UPDATE_INFO_DIR in \
103 n|no|NO) false;; \
104 *) (install-info --version) >/dev/null 2>&1;; \
105 esac
106 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
107 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
108 ACLOCAL = @ACLOCAL@
109 AET2_CFLAGS = @AET2_CFLAGS@
110 AET2_LDADD = @AET2_LDADD@
111 ALLOCA = @ALLOCA@
112 AMTAR = @AMTAR@
113 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
114 AUTOCONF = @AUTOCONF@
115 AUTOHEADER = @AUTOHEADER@
116 AUTOMAKE = @AUTOMAKE@
117 AWK = @AWK@
118 CC = @CC@
119 CCDEPMODE = @CCDEPMODE@
120 CFLAGS = @CFLAGS@
121 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
122 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
123 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
124 CPP = @CPP@
125 CPPFLAGS = @CPPFLAGS@
126 CXX = @CXX@
127 CXXDEPMODE = @CXXDEPMODE@
128 CXXFLAGS = @CXXFLAGS@
129 CYGPATH_W = @CYGPATH_W@
130 DEFS = @DEFS@
131 DEPDIR = @DEPDIR@
132 ECHO_C = @ECHO_C@
133 ECHO_N = @ECHO_N@
134 ECHO_T = @ECHO_T@
135 EGREP = @EGREP@
136 EXEEXT = @EXEEXT@
137 EXTDEBUG = @EXTDEBUG@
138 EXTDEBUG2 = @EXTDEBUG2@
139 EXTDEBUG3 = @EXTDEBUG3@
140 EXTDEBUG4 = @EXTDEBUG4@
141 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
142 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
143 FSDB_CFLAGS = @FSDB_CFLAGS@
144 FSDB_LDADD = @FSDB_LDADD@
145 GCONF_CFLAGS = @GCONF_CFLAGS@
146 GCONF_LIBS = @GCONF_LIBS@
147 GEDITTEST = @GEDITTEST@
148 GEDIT_CFLAGS = @GEDIT_CFLAGS@
149 GIO_CFLAGS = @GIO_CFLAGS@
150 GIO_LIBS = @GIO_LIBS@
151 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
152 GPERF = @GPERF@
153 GREP = @GREP@
154 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
155 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
156 GTK_CFLAGS = @GTK_CFLAGS@
157 GTK_CONFIG = @GTK_CONFIG@
158 GTK_LIBS = @GTK_LIBS@
159 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
160 GTK_MAC_LIBS = @GTK_MAC_LIBS@
161 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
162 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
163 INSTALL = @INSTALL@
164 INSTALL_DATA = @INSTALL_DATA@
165 INSTALL_PROGRAM = @INSTALL_PROGRAM@
166 INSTALL_SCRIPT = @INSTALL_SCRIPT@
167 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
168 LDFLAGS = @LDFLAGS@
169 LEX = @LEX@
170 LEXLIB = @LEXLIB@
171 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
172 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
173 LIBBZ2_DIR = @LIBBZ2_DIR@
174 LIBBZ2_LDADD = @LIBBZ2_LDADD@
175 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
176 LIBJUDY_LDADD = @LIBJUDY_LDADD@
177 LIBOBJS = @LIBOBJS@
178 LIBS = @LIBS@
179 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
180 LIBXZ_LDADD = @LIBXZ_LDADD@
181 LIBZ_CFLAGS = @LIBZ_CFLAGS@
182 LIBZ_DIR = @LIBZ_DIR@
183 LIBZ_LDADD = @LIBZ_LDADD@
184 LTLIBOBJS = @LTLIBOBJS@
185 MAINT = @MAINT@
186 MAKEINFO = @MAKEINFO@
187 MINGW_LDADD = @MINGW_LDADD@
188 MKDIR_P = @MKDIR_P@
189 OBJEXT = @OBJEXT@
190 PACKAGE = @PACKAGE@
191 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
192 PACKAGE_NAME = @PACKAGE_NAME@
193 PACKAGE_STRING = @PACKAGE_STRING@
194 PACKAGE_TARNAME = @PACKAGE_TARNAME@
195 PACKAGE_URL = @PACKAGE_URL@
196 PACKAGE_VERSION = @PACKAGE_VERSION@
197 PATH_SEPARATOR = @PATH_SEPARATOR@
198 PKG_CONFIG = @PKG_CONFIG@
199 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
200 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
201 POW_LIB = @POW_LIB@
202 RANLIB = @RANLIB@
203 RPC_CFLAGS = @RPC_CFLAGS@
204 RPC_LDADD = @RPC_LDADD@
205 SET_MAKE = @SET_MAKE@
206 SHELL = @SHELL@
207 STRIP = @STRIP@
208 STRUCT_PACK = @STRUCT_PACK@
209 TCL_DEFADD = @TCL_DEFADD@
210 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
211 TCL_LDADD = @TCL_LDADD@
212 TCL_LIB_SPEC = @TCL_LIB_SPEC@
213 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
214 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
215 TIRPC_CFLAGS = @TIRPC_CFLAGS@
216 TIRPC_LIBS = @TIRPC_LIBS@
217 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
218 TK_LDADD = @TK_LDADD@
219 TK_LIB_SPEC = @TK_LIB_SPEC@
220 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
221 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
222 VERSION = @VERSION@
223 XDGDATADIR = @XDGDATADIR@
224 abs_builddir = @abs_builddir@
225 abs_srcdir = @abs_srcdir@
226 abs_top_builddir = @abs_top_builddir@
227 abs_top_srcdir = @abs_top_srcdir@
228 ac_ct_CC = @ac_ct_CC@
229 ac_ct_CXX = @ac_ct_CXX@
230 am__include = @am__include@
231 am__leading_dot = @am__leading_dot@
232 am__quote = @am__quote@
233 am__tar = @am__tar@
234 am__untar = @am__untar@
235 bindir = @bindir@
236 build_alias = @build_alias@
237 builddir = @builddir@
238 datadir = @datadir@
239 datarootdir = @datarootdir@
240 docdir = @docdir@
241 dvidir = @dvidir@
242 exec_prefix = @exec_prefix@
243 gsettingsschemadir = @gsettingsschemadir@
244 host_alias = @host_alias@
245 htmldir = @htmldir@
246 includedir = @includedir@
247 infodir = @infodir@
248 install_sh = @install_sh@
249 libdir = @libdir@
250 libexecdir = @libexecdir@
251 localedir = @localedir@
252 localstatedir = @localstatedir@
253 mandir = @mandir@
254 mkdir_p = @mkdir_p@
255 oldincludedir = @oldincludedir@
256 pdfdir = @pdfdir@
257 prefix = @prefix@
258 program_transform_name = @program_transform_name@
259 psdir = @psdir@
260 sbindir = @sbindir@
261 sharedstatedir = @sharedstatedir@
262 srcdir = @srcdir@
263 sysconfdir = @sysconfdir@
264 target_alias = @target_alias@
265 top_build_prefix = @top_build_prefix@
266 top_builddir = @top_builddir@
267 top_srcdir = @top_srcdir@
268 EXTRA_DIST = antlr.icc dlg.icc sorcerer.icc
269 all: all-am
270
271 .SUFFIXES:
272 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
273 @for dep in $?; do \
274 case '$(am__configure_deps)' in \
275 *$$dep*) \
276 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
277 && { if test -f $@; then exit 0; else break; fi; }; \
278 exit 1;; \
279 esac; \
280 done; \
281 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/IBM_VISUAL_AGE_PROJECTS/Makefile'; \
282 $(am__cd) $(top_srcdir) && \
283 $(AUTOMAKE) --foreign contrib/pccts/IBM_VISUAL_AGE_PROJECTS/Makefile
284 .PRECIOUS: Makefile
285 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
286 @case '$?' in \
287 *config.status*) \
288 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
289 *) \
290 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
291 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
292 esac;
293
294 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
295 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
296
297 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
298 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
299 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
300 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
301 $(am__aclocal_m4_deps):
302 tags TAGS:
303
304 ctags CTAGS:
305
306 cscope cscopelist:
307
308
309 distdir: $(DISTFILES)
310 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
311 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
312 list='$(DISTFILES)'; \
313 dist_files=`for file in $$list; do echo $$file; done | \
314 sed -e "s|^$$srcdirstrip/||;t" \
315 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
316 case $$dist_files in \
317 */*) $(MKDIR_P) `echo "$$dist_files" | \
318 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
319 sort -u` ;; \
320 esac; \
321 for file in $$dist_files; do \
322 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
323 if test -d $$d/$$file; then \
324 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
325 if test -d "$(distdir)/$$file"; then \
326 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
327 fi; \
328 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
329 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
330 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
331 fi; \
332 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
333 else \
334 test -f "$(distdir)/$$file" \
335 || cp -p $$d/$$file "$(distdir)/$$file" \
336 || exit 1; \
337 fi; \
338 done
339 check-am: all-am
340 check: check-am
341 all-am: Makefile
342 installdirs:
343 install: install-am
344 install-exec: install-exec-am
345 install-data: install-data-am
346 uninstall: uninstall-am
347
348 install-am: all-am
349 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
350
351 installcheck: installcheck-am
352 install-strip:
353 if test -z '$(STRIP)'; then \
354 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
355 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
356 install; \
357 else \
358 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
359 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
360 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
361 fi
362 mostlyclean-generic:
363
364 clean-generic:
365
366 distclean-generic:
367 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
368 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
369
370 maintainer-clean-generic:
371 @echo "This command is intended for maintainers to use"
372 @echo "it deletes files that may require special tools to rebuild."
373 clean: clean-am
374
375 clean-am: clean-generic mostlyclean-am
376
377 distclean: distclean-am
378 -rm -f Makefile
379 distclean-am: clean-am distclean-generic
380
381 dvi: dvi-am
382
383 dvi-am:
384
385 html: html-am
386
387 html-am:
388
389 info: info-am
390
391 info-am:
392
393 install-data-am:
394
395 install-dvi: install-dvi-am
396
397 install-dvi-am:
398
399 install-exec-am:
400
401 install-html: install-html-am
402
403 install-html-am:
404
405 install-info: install-info-am
406
407 install-info-am:
408
409 install-man:
410
411 install-pdf: install-pdf-am
412
413 install-pdf-am:
414
415 install-ps: install-ps-am
416
417 install-ps-am:
418
419 installcheck-am:
420
421 maintainer-clean: maintainer-clean-am
422 -rm -f Makefile
423 maintainer-clean-am: distclean-am maintainer-clean-generic
424
425 mostlyclean: mostlyclean-am
426
427 mostlyclean-am: mostlyclean-generic
428
429 pdf: pdf-am
430
431 pdf-am:
432
433 ps: ps-am
434
435 ps-am:
436
437 uninstall-am:
438
439 .MAKE: install-am install-strip
440
441 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
442 ctags-am distclean distclean-generic distdir dvi dvi-am html \
443 html-am info info-am install install-am install-data \
444 install-data-am install-dvi install-dvi-am install-exec \
445 install-exec-am install-html install-html-am install-info \
446 install-info-am install-man install-pdf install-pdf-am \
447 install-ps install-ps-am install-strip installcheck \
448 installcheck-am installdirs maintainer-clean \
449 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
450 pdf-am ps ps-am tags-am uninstall uninstall-am
451
452
453 # Tell versions [3.59,3.63) of GNU make to not export all variables.
454 # Otherwise a system limit (for SysV at least) may be exceeded.
455 .NOEXPORT:
+0
-20
contrib/pccts/IBM_VISUAL_AGE_PROJECTS/antlr.icc less more
0 option ProjectOptions =
1 define("USER_ZZSYN", ),
2 define("__USE_PROTOS", ),
3 incl(searchpath, "..\\h"),
4 incl(searchpath, "..\\support\\set"),
5 link(pmtype, vio)
6 {
7 target "..\\bin\\antlr.exe"
8 {
9 option incl(searchpath, "..\\antlr") { source type("c")
10 "antlr.c","bits.c","build.c","dumpcycles.c",
11 "dumpnode.c","egman.c","main.c","err.c",
12 "fcache.c","fset.c","fset2.c","gen.c",
13 "globals.c","hash.c","lex.c","main.c",
14 "misc.c","mrhoist.c","pred.c","scan.c"}
15
16 option incl(searchpath, "..\\support\\set") source type("c")
17 "set.c"
18 }
19 }
+0
-22
contrib/pccts/IBM_VISUAL_AGE_PROJECTS/dlg.icc less more
0 option ProjectOptions =
1 define("USER_ZZSYN", ),
2 define("__USE_PROTOS", ),
3 incl(searchpath, "..\\h"),
4 incl(searchpath, "..\\support\\set"),
5 link(pmtype, vio)
6 {
7 target "..\\bin\\dlg.exe"
8 {
9 source type("c")
10 "..\\dlg\\automata.c",
11 "..\\dlg\\dlg_a.c",
12 "..\\dlg\\dlg_p.c",
13 "..\\dlg\\err.c",
14 "..\\dlg\\main.c",
15 "..\\dlg\\output.c",
16 "..\\dlg\\relabel.c",
17 "..\\dlg\\support.c",
18
19 "..\\support\\set\\set.c"
20 }
21 }
+0
-21
contrib/pccts/IBM_VISUAL_AGE_PROJECTS/sorcerer.icc less more
0 0ption ProjectOptions =
1 define("__USE_PROTOS", ),
2 incl(searchpath, "..\\sorcerer\\h"),
3 incl(searchpath, "..\\h"),
4 incl(searchpath, "..\\support\\set"),
5 link(pmtype, vio)
6 {
7 target "..\\bin\\sorcerer.exe"
8 {
9 option incl(searchpath, "..\\sorcerer") {
10 source type("c")
11
12 'sor.c','scan.c','err.c','main.c','globals.c','gen.c','hash.c','look.c','cpp.c'
13 }
14
15 option incl(searchpath, "..\\support\\set") {
16 source type("c")
17 "set.c"
18 }
19 }
20 }
+0
-241
contrib/pccts/KNOWN_PROBLEMS.txt less more
0
1 =======================================================
2 Known Problems In PCCTS - Last revised 14 November 1998
3 =======================================================
4
5 #17. The dlg fix for handling characters up to 255 is incorrect.
6
7 See item #207.
8
9 Reported by Frank Hartmann.
10
11 #16. A note about "&&" predicates (Mike Dimmick)
12
13 Mike Dimmick has pointed out a potential pitfall in the use of the
14 "&&" style predicate. Consider:
15
16 r0: (g)? => <<P>>? r1
17 | ...
18 ;
19 r1: A | B;
20
21 If the context guard g is not a subset of the lookahead context for r1
22 (in other words g is neither A nor B) then the code may execute r1
23 even when the lookahead context is not satisfied. This is an error
24 by the person coding the grammer, and the error should be reported to
25 the user, but it isn't. expect. Some examples I've run seem to
26 indicate that such an error actually results in the rule becoming
27 unreachable.
28
29 When g is properly coded the code is correct, the problem is when g
30 is not properly coded.
31
32 A second problem reported by Mike Dimmick is that the test for a
33 failed validation predicate is equivalent to a test on the predicate
34 along. In other words, if the "&&" has not been hoisted then it may
35 falsely report a validation error.
36
37 #15. (Changed in MR23) Warning for LT(i), LATEXT(i) in token match actions
38
39 An bug (or at least an oddity) is that a reference to LT(1), LA(1),
40 or LATEXT(1) in an action which immediately follows a token match
41 in a rule refers to the token matched, not the token which is in
42 the lookahead buffer. Consider:
43
44 r : abc <<action alpha>> D <<action beta>> E;
45
46 In this case LT(1) in action alpha will refer to the next token in
47 the lookahead buffer ("D"), but LT(1) in action beta will refer to
48 the token matched by D - the preceding token.
49
50 A warning has been added which warns users about this when an action
51 following a token match contains a reference to LT(1), LA(1), or LATEXT(1).
52
53 This behavior should be changed, but it appears in too many programs
54 now. Another problem, perhaps more significant, is that the obvious
55 fix (moving the consume() call to before the action) could change the
56 order in which input is requested and output appears in existing programs.
57
58 This problem was reported, along with a fix by Benjamin Mandel
59 (beny@sd.co.il). However, I felt that changing the behavior was too
60 dangerous for existing code.
61
62 #14. Parsing bug in dlg
63
64 THM: I have been unable to reproduce this problem.
65
66 Reported by Rick Howard Mijenix Corporation (rickh@mijenix.com).
67
68 The regular expression parser (in rexpr.c) fails while
69 trying to parse the following regular expression:
70
71 {[a-zA-Z]:}(\\\\[a-zA-Z0-9]*)+
72
73 See my comment in the following excerpt from rexpr.c:
74
75 /*
76 * <regExpr> ::= <andExpr> ( '|' {<andExpr>} )*
77 *
78 * Return -1 if syntax error
79 * Return 0 if none found
80 * Return 1 if a regExrp was found
81 */
82 static
83 regExpr(g)
84 GraphPtr g;
85 {
86 Graph g1, g2;
87
88 if ( andExpr(&g1) == -1 )
89 {
90 return -1;
91 }
92
93 while ( token == '|' )
94 {
95 int a;
96 next();
97 a = andExpr(&g2);
98 if ( a == -1 ) return -1; /* syntax error below */
99 else if ( !a ) return 1; /* empty alternative */
100 g1 = BuildNFA_AorB(g1, g2);
101 }
102
103 if ( token!='\0' ) return -1;
104 *****
105 ***** It appears to fail here becuause token is 125 - the closing '}'
106 ***** If I change it to:
107 ***** if ( token!='\0' && token!='}' && token!= ')' ) return -1;
108 *****
109 ***** It succeeds, but I'm not sure this is the corrrect approach.
110 *****
111 *g = g1;
112 return 1;
113 }
114
115 #13. dlg reports an invalid range for: [\0x00-\0xff]
116
117 Diagnosed by Piotr Eljasiak (eljasiak@no-spam.zt.gdansk.tpsa.pl):
118
119 Fixed in MR16.
120
121 #12. Strings containing comment actions
122
123 Sequences that looked like C style comments appearing in string
124 literals are improperly parsed by antlr/dlg.
125
126 << fprintf(out," /* obsolete */ ");
127
128 For this case use:
129
130 << fprintf(out," \/\* obsolete \*\/ ");
131
132 Reported by K.J. Cummings (cummings@peritus.com).
133
134 #11. User hook for deallocation of variables on guess fail
135
136 The mechanism outlined in Item #108 works only for
137 heap allocated variables.
138
139 #10. Label re-initialization in ( X {y:Y} )*
140
141 If a label assignment is optional and appears in a
142 (...)* or (...)+ block it will not be reset to NULL
143 when it is skipped by a subsequent iteration.
144
145 Consider the example:
146
147 ( X { y:Y })* Z
148
149 with input:
150
151 X Y X Z
152
153 The first time through the block Y will be matched and
154 y will be set to point to the token. On the second
155 iteration of the (...)* block there is no match for Y.
156 But y will not be reset to NULL, as the user might
157 expect, it will contain a reference to the Y that was
158 matched in the first iteration.
159
160 The work-around is to manually reset y:
161
162 ( X << y = NULL; >> { y:Y } )* Z
163
164 or
165
166 ( X ( y:Y | << y = NULL; >> /* epsilon */ ) )* Z
167
168 Reported by Jeff Vincent (JVincent@novell.com).
169
170 #9. PCCTAST.h PCCTSAST::setType() is a noop
171
172 #8. #tokdefs with ~Token and .
173
174 THM: I have been unable to reproduce this problem.
175
176 When antlr uses #tokdefs to define tokens the fields of
177 #errclass and #tokclass do not get properly defined.
178 When it subsequently attempts to take the complement of
179 the set of tokens (using ~Token or .) it can refer to
180 tokens which don't have names, generating a fatal error.
181
182 #7. DLG crashes on some invalid inputs
183
184 THM: In MR20 have fixed the most common cases.
185
186 The following token defintion will cause DLG to crash.
187
188 #token "()"
189
190 Reported by Mengue Olivier (dolmen@bigfoot.com).
191
192 #6. On MS systems \n\r is treated as two new lines
193
194 Fixed.
195
196 #5. Token expressions in #tokclass
197
198 #errclass does not support TOK1..TOK2 or ~TOK syntax.
199 #tokclass does not support ~TOKEN syntax
200
201 A workaround for #errclass TOK1..TOK2 is to use a
202 #tokclass.
203
204 Reported by Dave Watola (dwatola@amtsun.jpl.nasa.gov)
205
206 #4. A #tokdef must appear "early" in the grammar file.
207
208 The "early" section of the grammar file is the only
209 place where the following directives may appear:
210
211 #header
212 #first
213 #tokdefs
214 #parser
215
216 Any other kind of statement signifiies the end of the
217 "early" section.
218
219 #3. Use of PURIFY macro for C++ mode
220
221 Item #93 of the CHANGES_FROM_1.33 describes the use of
222 the PURIFY macro to zero arguments to be passed by
223 upward inheritance.
224
225 #define PURIFY(r, s) memset((char *) &(r), '\0', (s));
226
227 This may not be the right thing to do for C++ objects that
228 have constructors. Reported by Bonny Rais (bonny@werple.net.au).
229
230 For those cases one should #define PURIFY to be an empty macro
231 in the #header or #first actions.
232
233 #2. Fixed in 1.33MR10 - See CHANGES_FROM_1.33 Item #80.
234
235 #1. The quality of support for systems with 8.3 file names leaves
236 much to be desired. Since the kit is distributed using the
237 long file names and the make file uses long file names it requires
238 some effort to generate. This will probably not be changed due
239 to the large number of systems already written using the long
240 file names.
+0
-21
contrib/pccts/MPW_Read_Me less more
0
1 1. You can control the creator type of generated files by changing a value of
2 #if control statement.
3
4
5 pccts:h:pcctscfg.h
6
7 line 225-231
8
9 #if 0
10 #define MAC_FILE_CREATOR 'MPS ' /* MPW Text files */
11 #endif
12 #if 0
13 #define MAC_FILE_CREATOR 'KAHL' /* THINK C/Symantec C++ Text files */
14 #endif
15 #if 0
16 #define MAC_FILE_CREATOR 'CWIE' /* Metrowerks C/C++ Text files */
17 #endif
18
19 2. If you want to build 68K version. You must convert all source files to Macintosh
20 format before compile.
+0
-13
contrib/pccts/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 SUBDIRS= IBM_VISUAL_AGE_PROJECTS antlr dlg h sorcerer support testcpp
4
5 EXTRA_DIST= \
6 CHANGES_FROM_131.txt CHANGES_FROM_133.txt \
7 CHANGES_FROM_133_BEFORE_MR13.txt CHANGES_SUMMARY.txt \
8 KNOWN_PROBLEMS.txt MPW_Read_Me \
9 NOTES.OS2 NOTES.bcc NOTES.msvc NOTES.watcom README \
10 RIGHTS history.ps history.txt install68K.mpw \
11 installPPC.mpw makefile.vms
12
+0
-644
contrib/pccts/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
102 ctags-recursive dvi-recursive html-recursive info-recursive \
103 install-data-recursive install-dvi-recursive \
104 install-exec-recursive install-html-recursive \
105 install-info-recursive install-pdf-recursive \
106 install-ps-recursive install-recursive installcheck-recursive \
107 installdirs-recursive pdf-recursive ps-recursive \
108 tags-recursive uninstall-recursive
109 am__can_run_installinfo = \
110 case $$AM_UPDATE_INFO_DIR in \
111 n|no|NO) false;; \
112 *) (install-info --version) >/dev/null 2>&1;; \
113 esac
114 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
115 distclean-recursive maintainer-clean-recursive
116 am__recursive_targets = \
117 $(RECURSIVE_TARGETS) \
118 $(RECURSIVE_CLEAN_TARGETS) \
119 $(am__extra_recursive_targets)
120 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
121 distdir
122 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
123 # Read a list of newline-separated strings from the standard input,
124 # and print each of them once, without duplicates. Input order is
125 # *not* preserved.
126 am__uniquify_input = $(AWK) '\
127 BEGIN { nonempty = 0; } \
128 { items[$$0] = 1; nonempty = 1; } \
129 END { if (nonempty) { for (i in items) print i; }; } \
130 '
131 # Make sure the list of sources is unique. This is necessary because,
132 # e.g., the same source file might be shared among _SOURCES variables
133 # for different programs/libraries.
134 am__define_uniq_tagged_files = \
135 list='$(am__tagged_files)'; \
136 unique=`for i in $$list; do \
137 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
138 done | $(am__uniquify_input)`
139 ETAGS = etags
140 CTAGS = ctags
141 DIST_SUBDIRS = $(SUBDIRS)
142 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
143 am__relativize = \
144 dir0=`pwd`; \
145 sed_first='s,^\([^/]*\)/.*$$,\1,'; \
146 sed_rest='s,^[^/]*/*,,'; \
147 sed_last='s,^.*/\([^/]*\)$$,\1,'; \
148 sed_butlast='s,/*[^/]*$$,,'; \
149 while test -n "$$dir1"; do \
150 first=`echo "$$dir1" | sed -e "$$sed_first"`; \
151 if test "$$first" != "."; then \
152 if test "$$first" = ".."; then \
153 dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
154 dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
155 else \
156 first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
157 if test "$$first2" = "$$first"; then \
158 dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
159 else \
160 dir2="../$$dir2"; \
161 fi; \
162 dir0="$$dir0"/"$$first"; \
163 fi; \
164 fi; \
165 dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
166 done; \
167 reldir="$$dir2"
168 ACLOCAL = @ACLOCAL@
169 AET2_CFLAGS = @AET2_CFLAGS@
170 AET2_LDADD = @AET2_LDADD@
171 ALLOCA = @ALLOCA@
172 AMTAR = @AMTAR@
173 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
174 AUTOCONF = @AUTOCONF@
175 AUTOHEADER = @AUTOHEADER@
176 AUTOMAKE = @AUTOMAKE@
177 AWK = @AWK@
178 CC = @CC@
179 CCDEPMODE = @CCDEPMODE@
180 CFLAGS = @CFLAGS@
181 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
182 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
183 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
184 CPP = @CPP@
185 CPPFLAGS = @CPPFLAGS@
186 CXX = @CXX@
187 CXXDEPMODE = @CXXDEPMODE@
188 CXXFLAGS = @CXXFLAGS@
189 CYGPATH_W = @CYGPATH_W@
190 DEFS = @DEFS@
191 DEPDIR = @DEPDIR@
192 ECHO_C = @ECHO_C@
193 ECHO_N = @ECHO_N@
194 ECHO_T = @ECHO_T@
195 EGREP = @EGREP@
196 EXEEXT = @EXEEXT@
197 EXTDEBUG = @EXTDEBUG@
198 EXTDEBUG2 = @EXTDEBUG2@
199 EXTDEBUG3 = @EXTDEBUG3@
200 EXTDEBUG4 = @EXTDEBUG4@
201 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
202 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
203 FSDB_CFLAGS = @FSDB_CFLAGS@
204 FSDB_LDADD = @FSDB_LDADD@
205 GCONF_CFLAGS = @GCONF_CFLAGS@
206 GCONF_LIBS = @GCONF_LIBS@
207 GEDITTEST = @GEDITTEST@
208 GEDIT_CFLAGS = @GEDIT_CFLAGS@
209 GIO_CFLAGS = @GIO_CFLAGS@
210 GIO_LIBS = @GIO_LIBS@
211 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
212 GPERF = @GPERF@
213 GREP = @GREP@
214 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
215 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
216 GTK_CFLAGS = @GTK_CFLAGS@
217 GTK_CONFIG = @GTK_CONFIG@
218 GTK_LIBS = @GTK_LIBS@
219 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
220 GTK_MAC_LIBS = @GTK_MAC_LIBS@
221 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
222 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
223 INSTALL = @INSTALL@
224 INSTALL_DATA = @INSTALL_DATA@
225 INSTALL_PROGRAM = @INSTALL_PROGRAM@
226 INSTALL_SCRIPT = @INSTALL_SCRIPT@
227 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
228 LDFLAGS = @LDFLAGS@
229 LEX = @LEX@
230 LEXLIB = @LEXLIB@
231 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
232 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
233 LIBBZ2_DIR = @LIBBZ2_DIR@
234 LIBBZ2_LDADD = @LIBBZ2_LDADD@
235 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
236 LIBJUDY_LDADD = @LIBJUDY_LDADD@
237 LIBOBJS = @LIBOBJS@
238 LIBS = @LIBS@
239 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
240 LIBXZ_LDADD = @LIBXZ_LDADD@
241 LIBZ_CFLAGS = @LIBZ_CFLAGS@
242 LIBZ_DIR = @LIBZ_DIR@
243 LIBZ_LDADD = @LIBZ_LDADD@
244 LTLIBOBJS = @LTLIBOBJS@
245 MAINT = @MAINT@
246 MAKEINFO = @MAKEINFO@
247 MINGW_LDADD = @MINGW_LDADD@
248 MKDIR_P = @MKDIR_P@
249 OBJEXT = @OBJEXT@
250 PACKAGE = @PACKAGE@
251 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
252 PACKAGE_NAME = @PACKAGE_NAME@
253 PACKAGE_STRING = @PACKAGE_STRING@
254 PACKAGE_TARNAME = @PACKAGE_TARNAME@
255 PACKAGE_URL = @PACKAGE_URL@
256 PACKAGE_VERSION = @PACKAGE_VERSION@
257 PATH_SEPARATOR = @PATH_SEPARATOR@
258 PKG_CONFIG = @PKG_CONFIG@
259 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
260 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
261 POW_LIB = @POW_LIB@
262 RANLIB = @RANLIB@
263 RPC_CFLAGS = @RPC_CFLAGS@
264 RPC_LDADD = @RPC_LDADD@
265 SET_MAKE = @SET_MAKE@
266 SHELL = @SHELL@
267 STRIP = @STRIP@
268 STRUCT_PACK = @STRUCT_PACK@
269 TCL_DEFADD = @TCL_DEFADD@
270 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
271 TCL_LDADD = @TCL_LDADD@
272 TCL_LIB_SPEC = @TCL_LIB_SPEC@
273 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
274 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
275 TIRPC_CFLAGS = @TIRPC_CFLAGS@
276 TIRPC_LIBS = @TIRPC_LIBS@
277 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
278 TK_LDADD = @TK_LDADD@
279 TK_LIB_SPEC = @TK_LIB_SPEC@
280 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
281 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
282 VERSION = @VERSION@
283 XDGDATADIR = @XDGDATADIR@
284 abs_builddir = @abs_builddir@
285 abs_srcdir = @abs_srcdir@
286 abs_top_builddir = @abs_top_builddir@
287 abs_top_srcdir = @abs_top_srcdir@
288 ac_ct_CC = @ac_ct_CC@
289 ac_ct_CXX = @ac_ct_CXX@
290 am__include = @am__include@
291 am__leading_dot = @am__leading_dot@
292 am__quote = @am__quote@
293 am__tar = @am__tar@
294 am__untar = @am__untar@
295 bindir = @bindir@
296 build_alias = @build_alias@
297 builddir = @builddir@
298 datadir = @datadir@
299 datarootdir = @datarootdir@
300 docdir = @docdir@
301 dvidir = @dvidir@
302 exec_prefix = @exec_prefix@
303 gsettingsschemadir = @gsettingsschemadir@
304 host_alias = @host_alias@
305 htmldir = @htmldir@
306 includedir = @includedir@
307 infodir = @infodir@
308 install_sh = @install_sh@
309 libdir = @libdir@
310 libexecdir = @libexecdir@
311 localedir = @localedir@
312 localstatedir = @localstatedir@
313 mandir = @mandir@
314 mkdir_p = @mkdir_p@
315 oldincludedir = @oldincludedir@
316 pdfdir = @pdfdir@
317 prefix = @prefix@
318 program_transform_name = @program_transform_name@
319 psdir = @psdir@
320 sbindir = @sbindir@
321 sharedstatedir = @sharedstatedir@
322 srcdir = @srcdir@
323 sysconfdir = @sysconfdir@
324 target_alias = @target_alias@
325 top_build_prefix = @top_build_prefix@
326 top_builddir = @top_builddir@
327 top_srcdir = @top_srcdir@
328 SUBDIRS = IBM_VISUAL_AGE_PROJECTS antlr dlg h sorcerer support testcpp
329 EXTRA_DIST = \
330 CHANGES_FROM_131.txt CHANGES_FROM_133.txt \
331 CHANGES_FROM_133_BEFORE_MR13.txt CHANGES_SUMMARY.txt \
332 KNOWN_PROBLEMS.txt MPW_Read_Me \
333 NOTES.OS2 NOTES.bcc NOTES.msvc NOTES.watcom README \
334 RIGHTS history.ps history.txt install68K.mpw \
335 installPPC.mpw makefile.vms
336
337 all: all-recursive
338
339 .SUFFIXES:
340 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
341 @for dep in $?; do \
342 case '$(am__configure_deps)' in \
343 *$$dep*) \
344 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
345 && { if test -f $@; then exit 0; else break; fi; }; \
346 exit 1;; \
347 esac; \
348 done; \
349 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/Makefile'; \
350 $(am__cd) $(top_srcdir) && \
351 $(AUTOMAKE) --foreign contrib/pccts/Makefile
352 .PRECIOUS: Makefile
353 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
354 @case '$?' in \
355 *config.status*) \
356 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
357 *) \
358 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
359 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
360 esac;
361
362 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
363 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
364
365 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
366 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
367 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
368 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
369 $(am__aclocal_m4_deps):
370
371 # This directory's subdirectories are mostly independent; you can cd
372 # into them and run 'make' without going through this Makefile.
373 # To change the values of 'make' variables: instead of editing Makefiles,
374 # (1) if the variable is set in 'config.status', edit 'config.status'
375 # (which will cause the Makefiles to be regenerated when you run 'make');
376 # (2) otherwise, pass the desired values on the 'make' command line.
377 $(am__recursive_targets):
378 @fail=; \
379 if $(am__make_keepgoing); then \
380 failcom='fail=yes'; \
381 else \
382 failcom='exit 1'; \
383 fi; \
384 dot_seen=no; \
385 target=`echo $@ | sed s/-recursive//`; \
386 case "$@" in \
387 distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
388 *) list='$(SUBDIRS)' ;; \
389 esac; \
390 for subdir in $$list; do \
391 echo "Making $$target in $$subdir"; \
392 if test "$$subdir" = "."; then \
393 dot_seen=yes; \
394 local_target="$$target-am"; \
395 else \
396 local_target="$$target"; \
397 fi; \
398 ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
399 || eval $$failcom; \
400 done; \
401 if test "$$dot_seen" = "no"; then \
402 $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
403 fi; test -z "$$fail"
404
405 ID: $(am__tagged_files)
406 $(am__define_uniq_tagged_files); mkid -fID $$unique
407 tags: tags-recursive
408 TAGS: tags
409
410 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
411 set x; \
412 here=`pwd`; \
413 if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
414 include_option=--etags-include; \
415 empty_fix=.; \
416 else \
417 include_option=--include; \
418 empty_fix=; \
419 fi; \
420 list='$(SUBDIRS)'; for subdir in $$list; do \
421 if test "$$subdir" = .; then :; else \
422 test ! -f $$subdir/TAGS || \
423 set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
424 fi; \
425 done; \
426 $(am__define_uniq_tagged_files); \
427 shift; \
428 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
429 test -n "$$unique" || unique=$$empty_fix; \
430 if test $$# -gt 0; then \
431 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
432 "$$@" $$unique; \
433 else \
434 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
435 $$unique; \
436 fi; \
437 fi
438 ctags: ctags-recursive
439
440 CTAGS: ctags
441 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
442 $(am__define_uniq_tagged_files); \
443 test -z "$(CTAGS_ARGS)$$unique" \
444 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
445 $$unique
446
447 GTAGS:
448 here=`$(am__cd) $(top_builddir) && pwd` \
449 && $(am__cd) $(top_srcdir) \
450 && gtags -i $(GTAGS_ARGS) "$$here"
451 cscopelist: cscopelist-recursive
452
453 cscopelist-am: $(am__tagged_files)
454 list='$(am__tagged_files)'; \
455 case "$(srcdir)" in \
456 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
457 *) sdir=$(subdir)/$(srcdir) ;; \
458 esac; \
459 for i in $$list; do \
460 if test -f "$$i"; then \
461 echo "$(subdir)/$$i"; \
462 else \
463 echo "$$sdir/$$i"; \
464 fi; \
465 done >> $(top_builddir)/cscope.files
466
467 distclean-tags:
468 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
469
470 distdir: $(DISTFILES)
471 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
472 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
473 list='$(DISTFILES)'; \
474 dist_files=`for file in $$list; do echo $$file; done | \
475 sed -e "s|^$$srcdirstrip/||;t" \
476 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
477 case $$dist_files in \
478 */*) $(MKDIR_P) `echo "$$dist_files" | \
479 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
480 sort -u` ;; \
481 esac; \
482 for file in $$dist_files; do \
483 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
484 if test -d $$d/$$file; then \
485 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
486 if test -d "$(distdir)/$$file"; then \
487 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
488 fi; \
489 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
490 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
491 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
492 fi; \
493 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
494 else \
495 test -f "$(distdir)/$$file" \
496 || cp -p $$d/$$file "$(distdir)/$$file" \
497 || exit 1; \
498 fi; \
499 done
500 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
501 if test "$$subdir" = .; then :; else \
502 $(am__make_dryrun) \
503 || test -d "$(distdir)/$$subdir" \
504 || $(MKDIR_P) "$(distdir)/$$subdir" \
505 || exit 1; \
506 dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
507 $(am__relativize); \
508 new_distdir=$$reldir; \
509 dir1=$$subdir; dir2="$(top_distdir)"; \
510 $(am__relativize); \
511 new_top_distdir=$$reldir; \
512 echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
513 echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
514 ($(am__cd) $$subdir && \
515 $(MAKE) $(AM_MAKEFLAGS) \
516 top_distdir="$$new_top_distdir" \
517 distdir="$$new_distdir" \
518 am__remove_distdir=: \
519 am__skip_length_check=: \
520 am__skip_mode_fix=: \
521 distdir) \
522 || exit 1; \
523 fi; \
524 done
525 check-am: all-am
526 check: check-recursive
527 all-am: Makefile
528 installdirs: installdirs-recursive
529 installdirs-am:
530 install: install-recursive
531 install-exec: install-exec-recursive
532 install-data: install-data-recursive
533 uninstall: uninstall-recursive
534
535 install-am: all-am
536 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
537
538 installcheck: installcheck-recursive
539 install-strip:
540 if test -z '$(STRIP)'; then \
541 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
542 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
543 install; \
544 else \
545 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
546 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
547 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
548 fi
549 mostlyclean-generic:
550
551 clean-generic:
552
553 distclean-generic:
554 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
555 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
556
557 maintainer-clean-generic:
558 @echo "This command is intended for maintainers to use"
559 @echo "it deletes files that may require special tools to rebuild."
560 clean: clean-recursive
561
562 clean-am: clean-generic mostlyclean-am
563
564 distclean: distclean-recursive
565 -rm -f Makefile
566 distclean-am: clean-am distclean-generic distclean-tags
567
568 dvi: dvi-recursive
569
570 dvi-am:
571
572 html: html-recursive
573
574 html-am:
575
576 info: info-recursive
577
578 info-am:
579
580 install-data-am:
581
582 install-dvi: install-dvi-recursive
583
584 install-dvi-am:
585
586 install-exec-am:
587
588 install-html: install-html-recursive
589
590 install-html-am:
591
592 install-info: install-info-recursive
593
594 install-info-am:
595
596 install-man:
597
598 install-pdf: install-pdf-recursive
599
600 install-pdf-am:
601
602 install-ps: install-ps-recursive
603
604 install-ps-am:
605
606 installcheck-am:
607
608 maintainer-clean: maintainer-clean-recursive
609 -rm -f Makefile
610 maintainer-clean-am: distclean-am maintainer-clean-generic
611
612 mostlyclean: mostlyclean-recursive
613
614 mostlyclean-am: mostlyclean-generic
615
616 pdf: pdf-recursive
617
618 pdf-am:
619
620 ps: ps-recursive
621
622 ps-am:
623
624 uninstall-am:
625
626 .MAKE: $(am__recursive_targets) install-am install-strip
627
628 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
629 check-am clean clean-generic cscopelist-am ctags ctags-am \
630 distclean distclean-generic distclean-tags distdir dvi dvi-am \
631 html html-am info info-am install install-am install-data \
632 install-data-am install-dvi install-dvi-am install-exec \
633 install-exec-am install-html install-html-am install-info \
634 install-info-am install-man install-pdf install-pdf-am \
635 install-ps install-ps-am install-strip installcheck \
636 installcheck-am installdirs installdirs-am maintainer-clean \
637 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
638 pdf-am ps ps-am tags tags-am uninstall uninstall-am
639
640
641 # Tell versions [3.59,3.63) of GNU make to not export all variables.
642 # Otherwise a system limit (for SysV at least) may be exceeded.
643 .NOEXPORT:
+0
-296
contrib/pccts/NOTES.OS2 less more
0 14 April 94
1 Version 1.20 of pccts
2
3 At the moment this help file is available via anonymous FTP at
4
5 Node: marvin.ecn.purdue.edu
6 File: pub/pccts/1.20/NOTES.OS2
7
8 Mail corrections or additions to Steve Robenalt <steve@molly.dny.rockwell.com>
9 ===============================================================================
10 Notes on building PCCTS under OS/2 2.X with the C Set compilers.
11
12 The supplied makefiles can be used to build PCCTS under OS/2 with minimal
13 trouble. First you need to edit the makefiles such that the Unix specific
14 defaults are commented out, then uncomment the lines which are specific
15 to OS/2 and C Set/2 compilers as originally set up by Ed Harfmann. Note
16 also that you need to use the target list which reflects the appropriate
17 naming conventions. Some of the lines now need to be changed to reflect
18 differences in conventions between the operating systems: 1) change forward
19 slashes in directories to backslashes, 2) change command line parameters
20 from -option to /option (note that this applies to C Set, not ANTLR and DLG
21 options), and 3) change rm to del for clean and scrub targets.
22
23 To build ANTLR for the first time:
24
25 note: I tried various combinations of "touch"ing files to try to prevent nmake
26 from using ANTLR to rebuild itself, and was unsuccessful.
27
28 In the section labelled "Target list of PC machines", comment out the
29 scan.c and antlr.c dependencies. This prevents nmake from trying to invoke
30 ANTLR to build itself. After you have built ANTLR successfully for the first
31 time, you can uncomment these lines and it will build itself normally. (If you
32 had a working 1.10 installation before, you can also use the older binaries
33 when building the new ones.)
34
35 An example of the resulting makefile, with all the extra baggage for Unix, DOS,
36 and OS/2 1.X is shown here:
37
38 ----- cut here -----
39
40 #
41 # Makefile for ANTLR 1.20
42 #
43 # SOFTWARE RIGHTS
44 #
45 # We reserve no LEGAL rights to the Purdue Compiler Construction Tool
46 # Set (PCCTS) -- PCCTS is in the public domain. An individual or
47 # company may do whatever they wish with source code distributed with
48 # PCCTS or the code generated by PCCTS, including the incorporation of
49 # PCCTS, or its output, into commerical software.
50 #
51 # We encourage users to develop software with PCCTS. However, we do ask
52 # that credit is given to us for developing PCCTS. By "credit",
53 # we mean that if you incorporate our source code into one of your
54 # programs (commercial product, research project, or otherwise) that you
55 # acknowledge this fact somewhere in the documentation, research report,
56 # etc... If you like PCCTS and have developed a nice tool with the
57 # output, please mention that you developed it using PCCTS. In
58 # addition, we ask that this header remain intact in our source code.
59 # As long as these guidelines are kept, we expect to continue enhancing
60 # this system and expect to make other tools available as they are
61 # completed.
62 #
63 # ANTLR 1.20
64 # Terence Parr
65 # Purdue University
66 # With AHPCRC, University of Minnesota
67 # 1989-1994
68 #
69 # Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by
70 # Ed Harfmann
71 # Micro Data Base Systems
72 # Lafayette, Indiana
73 # - With updates by Steve Robenalt 4/94
74 #
75 SET=..\support\set
76 PCCTS_H=..\h
77
78 #
79 # C-Set/2 for OS/2
80 #
81 CC=icc
82 CFLAGS= /I. /I$(SET) /I$(PCCTS_H) /Sa /W3 /DUSER_ZZSYN
83 OUT_OBJ = /Fo
84 LIBS=
85 ANTLR=..\bin\antlr
86 DLG=..\bin\dlg
87 OBJ_EXT = obj
88
89 antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \
90 fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \
91 misc.obj set.obj pred.obj dialog.obj
92 link386 @<<
93 $** /NOI
94 $@ /STACK:32768
95
96 $(LIBS: = +^
97 )
98 $(DEF_FILE) $(LFLAGS) ;
99 <<
100 copy *.exe ..\bin
101
102 #
103 # *********** Target list of PC machines ***********
104 #
105 # Don't worry about the ambiguity messages coming from antlr
106 # for making antlr.c etc... [should be 10 of them, I think]
107 #
108 #antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g
109 # $(ANTLR) antlr.g
110
111 antlr.$(OBJ_EXT): antlr.c mode.h tokens.h
112
113 scan.$(OBJ_EXT): scan.c mode.h tokens.h
114
115 #scan.c mode.h: parser.dlg
116 # $(DLG) -C2 parser.dlg scan.c
117
118 set.$(OBJ_EXT): $(SET)\set.c
119 $(CC) $(CFLAGS) /C $(OUT_OBJ)set.$(OBJ_EXT) $(SET)\set.c
120
121 #
122 # what files does PCCTS generate (both ANTLR and DLG)
123 #
124
125 PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h
126
127 SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \
128 hash.c lex.c main.c misc.c $(SET)\set.c pred.c dialog.c
129
130 #
131 # ****** These next targets are common to UNIX and PC world ********
132 #
133
134 #clean up all the intermediate files
135 clean:
136 del *.$(OBJ_EXT)
137
138 #remove everything in clean plus the PCCTS files generated
139 scrub:
140 del $(PCCTS_GEN) *.$(OBJ_EXT)
141
142 ----- cut here -----
143
144 To build DLG for the first time:
145
146 Follow the same steps as were used to build ANTLR, changing the slashes and
147 commands, targets, and extensions for OS/2. Comment out the dependencies for
148 dlg_p.c and dlg_a.c to prevent nmake from trying to invoke ANTLR and DLG to
149 build DLG (unless you have 1.10 binaries).
150
151 An example of the resulting makefile, with all the extra baggage for Unix, DOS,
152 and OS/2 1.X is shown here:
153
154 ----- cut here -----
155
156 #
157 # Makefile for DLG 1.20
158 # Terence Parr
159 # Purdue University
160 # 1989-1993
161 #
162 # Ported to IBM C-Set/2 and Microsoft 6.0 by
163 # Ed Harfmann
164 # Micro Data Base Systems
165 # Lafayette, Indiana
166 # - With updates by Steve Robenalt 4/94
167 #
168 SET=..\support\set
169 PCCTS_H=..\h
170
171 #
172 # C-Set/2 for OS/2
173 #
174 CC=icc
175 CFLAGS= /I. /I$(SET) /I$(PCCTS_H) /Sa /W3
176 OUT_OBJ = /Fo
177 LIBS=
178 ANTLR=..\bin\antlr
179 DLG=..\bin\dlg
180 OBJ_EXT=obj
181
182 dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \
183 output.obj relabel.obj automata.obj
184 link386 @<<
185 $** /NOI
186 $@ /STACK:32768
187
188 $(LIBS: = +^
189 )
190 $(DEF_FILE) $(LFLAGS) ;
191 <<
192 copy *.exe ..\bin
193
194 SRC = dlg_p.c dlg_a.c main.c err.c $(SET)\set.c support.c output.c \
195 relabel.c automata.c
196
197 #dlg_p.c parser.dlg err.c tokens.h : dlg_p.g
198 # $(ANTLR) dlg_p.g
199
200 #dlg_a.c mode.h : parser.dlg
201 # $(DLG) -C2 parser.dlg dlg_a.c
202
203 dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h
204 $(CC) $(CFLAGS) /c dlg_p.c
205
206 dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h
207 $(CC) $(CFLAGS) /c dlg_a.c
208
209 main.$(OBJ_EXT) : main.c dlg.h
210 $(CC) $(CFLAGS) /c main.c
211
212 set.$(OBJ_EXT) : $(SET)\set.c
213 $(CC) /c $(CFLAGS) $(SET)\set.c
214
215 lint:
216 lint *.c
217
218 #clean up all the intermediate files
219 clean:
220 del *.$(OBJ_EXT)
221
222 ----- cut here -----
223
224 Once you have built ANTLR and DLG successfully, you will also want to build
225 the genmk utility, located at ~\pccts\support\genmk. The makefile in this
226 directory is relatively simple to modify, so I won't repeat it here.
227
228 At this point, you can test the executables by building one of the sample
229 programs, such as the Pascal or C example under ~pccts\lang. The prototype
230 makefile which is in these directories will work fine as a base, with OS/2
231 specific modifications as noted above. Note that the /Sa flag defines the
232 ANSI C mode of the compiler which is not the default. The default mode
233 does not define __STDC__ and will lead to lots of errors.
234
235 A sample pascal makefile is shown below:
236
237 ----- cut here -----
238
239 GRM =pascal.g
240 LEX_FILE =pscan.dlg
241 GSRC=pascal.c err.c pscan.c ttree.c adebug.c
242 GOBJ=pascal.obj err.obj pscan.obj ttree.obj adebug.obj
243
244 PCCTS_GEN= pascal.c err.c $(LEX_FILE) pscan.c mode.h tokens.h
245
246 SRC =$(GSRC) pmain.c sym.c
247 OBJ =$(GOBJ) pmain.obj sym.obj
248 INCL = ..\..\h
249 SYM = ..\..\support\sym
250 ANTLR = ..\..\bin\antlr
251 DLG = ..\..\bin\dlg
252
253 CFLAGS=/I. /I$(INCL) /Sa
254 AFLAGS= -fl $(LEX_FILE) -gh
255
256 pascal.exe : $(OBJ)
257 $(CC) $(CFLAGS) /Fopascal.exe $(OBJ)
258
259 pascal.c $(LEX_FILE) : $(GRM)
260 $(ANTLR) $(AFLAGS) $(GRM)
261
262 mode.h pscan.c : $(LEX_FILE)
263 $(DLG) -C2 $(LEX_FILE) pscan.c
264
265 pmain.obj : pmain.c pascal.h
266
267 pascal.obj : pascal.c mode.h tokens.h
268
269 sym.obj : $(SYM)\sym.c
270 icc /c /Fo sym.obj $(CFLAGS) $(SYM)\sym.c
271
272 err.obj : err.c
273
274 clean:
275 del $(PCCTS_GEN) *.obj
276
277
278 ----- cut here -----
279
280 The C example can be built in much the same way.
281
282 If you have problems compiling anything, I would appreciate hearing about
283 it. I was able to get everything built and working without changing any
284 of the supplied or generated C code, so if you find that you need to make
285 changes to any code, I've probably written something up incorrectly.
286
287 Please post comments to the mailing list for PCCTS at:
288
289 pccts-users@ahpcrc.umn.edu
290
291 since I am most likely to see them there.
292
293 - Steve Robenalt
294
295
+0
-184
contrib/pccts/NOTES.bcc less more
0 March 95
1 Version 1.32 of pccts
2
3 At the moment this file is available via anonymous FTP at
4
5 Node: marvin.ecn.purdue.edu
6 File: pub/pccts/1.32/NOTES.BCC
7
8 Mail corrections or additions to David Seidel <71333.1575@compuserve.com>
9 ===============================================================================
10 Notes on Building PCCTS 1.32 with Borland C++
11
12 David Seidel, Innovative Data Concepts Incorporated
13 CompuServe: 71333,1575
14 Internet: 71333.1575@compuserve.com
15 dseidel@delphi.com
16
17 I have gotten ANTLR and DLG to succesfully build with BCC 4.0, but have found
18 from experience that ANTLR, in particular, is likely to run out of memory
19 with grammars over a certain size, or with larger values for the -k and -ck
20 options. Now that BCC 4.02 and the new Borland Power Pack for DOS is now
21 available, I feel that there is no excuse not to build these tools as
22 32-bit executables, as they ought to be.
23
24 For people without the Power Pack, the makefiles below should be fairly easily
25 modified to build 16-bit real-mode executables, but I don't really recommend
26 it. As an alternative, you might consider the highly regarded DJGPP compiler
27 (a DOS port of the Gnu GCC compiler, with a DOS extender included). Hopefully
28 some other PCCTS who has DJGPP can provode whatever advice is necessary. The
29 Watcom compiler is also an excellent possibility (albeit a commercial one),
30 and I hope to make available Watcom makefiles in the near future.
31
32 Here are the makefiles I am using. Both makefiles use a compiler configuration
33 file that contains compiler switches such as optimization settings. I call
34 this file bor32.cfg and keep a copy in both the ANTLR and DLG subdirectories.
35
36 ==== File: bor32.cfg (cut here) ===============================================
37 -w-
38 -RT-
39 -x-
40 -N-
41 -k-
42 -d
43 -O2-e-l
44 -Z
45 -D__STDC__=1
46 ==== End of file bor32.cfg (cut here) =========================================
47
48 ==== File: antlr\bor32.mak (cut here) =========================================
49 #
50 # ANTLR 1.32 Makefile for Borland C++ 4.02 with DPMI 32-bit DOS extender by
51 # David Seidel
52 # Innovative Data Concepts Incorporated
53 # 71333.1575@compuserve.com (or) dseidel@delphi.com
54 #
55 # Notes: 1. Compiler switches (optimization etc.) are contained in the
56 # file bor32.cfg.
57 # 2. This makefile requires Borland C++ 4.02 or greater with
58 # the DOS Power Pack add-on package.
59 # 3. Change the BCCDIR macro below to the topmost directory in
60 # which BCC is installed on your system.
61 #
62
63 BCCDIR = d:\bc4
64 CC = bcc32
65 SET = ..\support\set
66 PCCTS_H = ..\h
67 ANTLR = ..\bin\antlr
68 DLG = ..\bin\dlg
69 CFLAGS = -I$(BCCDIR)\include -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN \
70 +bor32.cfg
71 LIBS = dpmi32 cw32
72 OBJ_EXT = obj
73 OBJS = antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj fset.obj \
74 gen.obj globals.obj hash.obj lex.obj main.obj misc.obj pred.obj dialog.obj \
75 set.obj
76
77 .c.obj:
78 $(CC) -c $(CFLAGS) {$&.c }
79
80 antlr.exe: $(OBJS)
81 tlink32 @&&|
82 -Tpe -ax -c -s -L$(BCCDIR)\lib +
83 $(BCCDIR)\lib\c0x32 $**
84 $@
85
86 $(LIBS)
87 ;
88 |
89 copy *.exe ..\bin
90
91
92 # *********** Target list of PC machines ***********
93 #
94 # Don't worry about the ambiguity messages coming from antlr
95 # for making antlr.c etc... [should be 10 of them, I think]
96 #
97
98 # leave this commented out for initial build!
99 #antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g
100 # $(ANTLR) antlr.g
101
102 antlr.$(OBJ_EXT): antlr.c mode.h tokens.h
103
104 scan.$(OBJ_EXT): scan.c mode.h tokens.h
105
106 # leave this commented out for initial build!
107 #scan.c mode.h: parser.dlg
108 # $(DLG) -C2 parser.dlg scan.c
109
110 set.$(OBJ_EXT): $(SET)\set.c
111 $(CC) -c $(CFLAGS) $(SET)\set.c
112
113 ==== End of file antlr\bor32.mak (cut here) ===================================
114
115 ==== File: dlg\bor32.mak (cut here) ===========================================
116 #
117 # DLG 1.32 Makefile for Borland C++ 4.02 with DPMI 32-bit DOS extender by
118 # David Seidel
119 # Innovative Data Concepts Incorporated
120 # 71333.1575@compuserve.com (or) dseidel@delphi.com
121 #
122 # Notes: 1. Compiler switches (optimization etc.) are contained in the
123 # file bor32.cfg.
124 # 2. This makefile requires Borland C++ 4.02 or greater with
125 # the DOS Power Pack add-on package.
126 # 3. Change the BCCDIR macro below to the topmost directory in
127 # which BCC is installed on your system.
128 #
129
130
131 BCCDIR = d:\bc4
132 CC = bcc32
133 SET = ..\support\set
134 PCCTS_H = ..\h
135 ANTLR = ..\bin\antlr
136 DLG = ..\bin\dlg
137 CFLAGS = -I$(BCCDIR)\include -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN \
138 +bor32.cfg
139 LIBS = dpmi32 cw32
140 OBJ_EXT = obj
141 OBJS = dlg_p.obj dlg_a.obj main.obj err.obj support.obj \
142 output.obj relabel.obj automata.obj set.obj
143
144 .c.obj:
145 $(CC) -c $(CFLAGS) {$&.c }
146
147 dlg.exe : $(OBJS)
148 tlink32 @&&|
149 -Tpe -ax -c -s -L$(BCCDIR)\lib +
150 c0x32 $**
151 $@
152
153 $(LIBS)
154 ;
155 |
156 copy *.exe ..\bin
157
158 dlg_p.obj: dlg_p.c
159
160 dlg_a.obj: dlg_a.c
161
162 main.obj: main.c
163
164 err.obj: err.c
165
166 support.obj: support.c
167
168 output.obj: output.c
169
170 relabel.obj: relabel.c
171
172 automata.obj: automata.c
173
174 set.$(OBJ_EXT): $(SET)\set.c
175 $(CC) -c $(CFLAGS) $(SET)\set.c
176
177 ==== End of file dlg\bor32.mak (cut here) =====================================
178
179
180
181
182
183
+0
-189
contrib/pccts/NOTES.msvc less more
0
1 Microsoft Visual C Stuff
2
3
4 [Tom Moog 2-Oct-98
5
6 Users of Microsoft Visual C++ should download a separate
7 ready-to-run zip file from my web site. It contains
8 binaries, static library, and a sample project.
9 ]
10
11 [
12 Two notes added by Tom Moog 23-Sep-97. I believe the *.dsp and
13 *.mak files that were once at the end of this file are now obsolete.
14
15 The following MSVC .dsp and .mak files for pccts and sorcerer
16 were contributed by Stanislaw Bochnak (S.Bochnak@microtool.com.pl)
17 and Jeff Vincent (jvincent@novell.com)
18
19 PCCTS Distribution Kit
20 ----------------------
21 pccts/antlr/AntlrMSVC50.dsp
22 pccts/antlr/AntlrMSVC50.mak
23
24 pccts/dlg/DlgMSVC50.dsp
25 pccts/dlg/DlgMSVC50.mak
26
27 pccts/support/genmk/watgenmk.mak
28 pccts/support/msvc.dsp
29
30 Sorcerer Distribution Kit
31 -------------------------
32 pccts/sorcerer/SorcererMSVC50.dsp
33 pccts/sorcerer/SorcererMSVC50.mak
34
35 pccts/sorcerer/lib/msvc.dsp
36
37 I do not have an MS based computer. If you discover problems
38 please report them so as to save trouble for others in the future.
39 ]
40
41 [
42 Modified by Terence Parr (September 1995) to change .C to .cpp
43 ]
44
45 [
46 This file contains notes on MSVC for Windows NT console execs by Dave
47 Seidel and an explanation of flags etc.. by John Hall; good luck,
48 Terence
49 ]
50
51 ===============================================================================
52 Date: Sat, 31 Dec 1994 11:40:36 -0500 (EST)
53 From: David Seidel <75342.2034@compuserve.com>
54
55 I've succesfully build 1.31b3 with djgpp for DOS and MSVC 2.0 for Windows
56 NT. The only (minor) problem I had was that GNU make (version 3.71, in the
57 djgpp port) complained about "multiple targets" in both the antlr and dlg
58 makefiles. I got around the error by, in each makefile, commenting out the
59 $(SRC) dependency, for example:
60
61 antlr: $(OBJ) #$(SRC)
62
63 I don't know why this is happenning, since you haven't changed that part of
64 the makefile at all, and I think this used to work ok...
65
66 Here are the makefiles I built from within the MSVC 2.0 environment for antlr
67 and dlg and Windows NT console executables. Please feel free to pass them
68 on. Of course, as soon as 1.31 "goes gold", I will send you nice new
69 binaries. I'm not going to bother to keep doing both Borland and djgpp for
70 DOS however. Instead, I'll just keep the djgpp version up to date and also
71 provide WinNT binaries.
72
73 Dave
74 ===============================================================================
75
76 How to port PCCTS 1.10 (and 1.32 hopefully) to Visual C++
77
78 By
79
80 John Hall <jhall@ivy.wpi.edu>
81
82 Here is how to compile an ANTLR grammar in Visual C++. These steps
83 describe how to have your ANTLR grammar parse the input file the user
84 selects when they choose File Open in your Windows application. (Even
85 if you aren't using Visual C++, the steps should be portable enough to
86 other compilers.)
87
88 * Make sure that ANTLR and DLG generate ANSI code (use the -ga
89 switch).
90
91 * Set the following compiler flags in Visual C++ (these are in the
92 Memory Model category of the compiler options in the Project
93 Options menu):
94
95 FLAG MEANING
96 ==== ==============================================================
97 /AL Large memory model (multiple data segments; data items must be
98 smaller than 64K).
99
100 /Gtn Allocates all items whose size is greater than or equal to n
101 in a new data segment. (I let n be 256: /Gt256.)
102
103 /Gx- All references to data items are done with far addressing in
104 case they are placed in a far segment.
105
106 * Add the following member variable to the attributes section of your
107 derived CDocument class (you will need to make sure you also
108 include stdio.h):
109
110 FILE *fp;
111
112 * Add the following method to your derived CDocument class:
113
114 BOOL CAppDoc::OnOpenDocument(const char* pszPathName)
115 {
116 // Call CDocument's OnOpenDocument to do housekeeping for us
117 // DON'T add anything to the loading section of Serialize
118 if (!CDocument::OnOpenDocument(pszPathName))
119 return FALSE;
120
121 // Open input file
122 if ((fp = fopen(pszPathName, "r")) == NULL)
123 return FALSE;
124
125 // Parse input file
126 ANTLR(start(), fp);
127
128 // Close input file
129 fclose(fp);
130 return TRUE;
131 }
132
133 (Note: additional code may be necessary, depending on your parser.
134 For example, if your parser uses PCCTS's symbol table library, you
135 will need to insert calls to zzs_init and zzs_done.)
136
137 * Compile the generated C files as C++ files. (I renamed the files
138 to have a .CPP extension to fool Visual C++ into thinking they were
139 C++ files. One might also use the /Tp switch, but that switch
140 requires you separately include the filename.) [I used this step
141 as an easy out for all the external linking errors I was getting
142 that I couldn't fix by declaring things extern "C".]
143
144 * Make sure the __STDC__ portion of the generated files gets
145 compiled. (Either define __STDC__ yourself or else change all
146 occurrences of __STDC__ to __cplusplus in the generated files. You
147 can define __STDC__ in the Preprocessor category of the compiler
148 options.)
149
150 ================================================================
151 = Note 23-Sep-97: This is probably not necessary any more. =
152 = With 1.33MRxxx the use of __STDC__ was replaced with the =
153 = macro __USE_PROTOS to control the compilation of prototypes. =
154 ================================================================
155
156 That last step is important for Visual C++, but may not apply to other
157 compilers. For C++ compilers, whether __STDC__ is defined is
158 implementation dependent (ARM, page 379). Apparently, Visual C++ does
159 not to define it; it also does not support "old style" C function
160 definitions (which is okay, according to page 404 of the ARM). Those
161 two things together caused problems when trying to port the code.
162 When it saw this:
163
164 #ifdef __STDC__
165 void
166 globals(AST **_root)
167 #else
168 globals(_root)
169 AST **_root;
170 #endif
171
172 it skipped the __STDC__ section and tried to process the "old style"
173 function definition, where it choked.
174
175 When you finally get your parser to compile and link without error,
176 you may get General Protection Fault errors at run time. The problem
177 I had was that a NULL was passed to a variable argument function
178 without an explicit cast. The function grabbed a pointer (32-bits)
179 off the stack using va_arg, but the NULL was passed silently as the
180 integer 0 (16 bits), making the resulting pointer was invalid. (This
181 was in PCCTS's sample C parser.)
182
183 There is one other thing I might suggest to help you avoid a run-time
184 error. Make sure you redefine the default error reporting function,
185 zzsyn. To do this, put "#define USER_ZZSYN" in your #header section
186 and put your own zzsyn somewhere. You can then pop up a MessageBox or
187 print the error to some output window.
188 ===============================================================================
+0
-114
contrib/pccts/NOTES.watcom less more
0 From Tom Zougas, zougas@civ.utoronto.ca
1
2 These are the changes I had to make to get ANTLR to compile under Watcom C
3 10.0 32-bit mode. I'm including the makefiles for antlr and dlg:
4
5 [Warning from T. Parr: I think that I may have expanded the tabs by
6 mistake in this file. You might have to convert them back to
7 tabs to have this file work correctly.]
8
9 antlr.mak:
10 -----------------------------------------------------------------------
11
12 SET=..\support\set
13 PCCTS_H=..\h
14
15 #
16 # Watcom
17 #
18 CC=wcl386
19 ANTLR=..\bin\antlr
20 DLG=..\bin\dlg
21 CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DPC
22 OUT_OBJ = -o
23 OBJ_EXT = obj
24 LINK = wcl386
25
26 .c.obj :
27 $(CC) -c $[* $(CFLAGS)
28
29 antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj &
30 fset.obj gen.obj globals.obj hash.obj lex.obj main.obj &
31 misc.obj set.obj pred.obj
32 $(LINK) -fe=antlr.exe *.obj -k14336
33 copy *.exe ..\bin
34
35 # *********** Target list of PC machines ***********
36 #
37 # Don't worry about the ambiguity messages coming from antlr
38 # for making antlr.c etc... [should be 10 of them, I think]
39 #
40 antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g
41 $(ANTLR) antlr.g
42
43 antlr.$(OBJ_EXT): antlr.c mode.h tokens.h
44
45 scan.$(OBJ_EXT): scan.c mode.h tokens.h
46
47 scan.c mode.h: parser.dlg
48 $(DLG) -C2 parser.dlg scan.c
49
50 set.$(OBJ_EXT): $(SET)\set.c
51 $(CC) $(CFLAGS) -c set.$(OBJ_EXT) $(SET)\set.c
52
53 #
54 # ****** These next targets are common to UNIX and PC world ********
55 #
56
57 #clean up all the intermediate files
58 clean:
59 del *.obj
60
61 #remove everything in clean plus the PCCTS files generated
62 scrub:
63 del $(PCCTS_GEN)
64 del *.$(OBJ_EXT)
65 ---------------------------------------------------------------------
66 dlg.mak:
67 ---------------------------------------------------------------------
68 SET=..\support\set
69 PCCTS_H=..\h
70
71 #
72 # Watcom
73 #
74 CC=wcl386
75 ANTLR=..\bin\antlr
76 DLG=..\bin\dlg
77 CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DPC
78 LIBS=
79 OBJ_EXT = obj
80 LINK = wcl386
81
82 .c.obj :
83 $(CC) -c $[* $(CFLAGS)
84
85 dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj &
86 output.obj relabel.obj automata.obj
87 $(LINK) -fe=dlg.exe *.obj -k14336
88 copy *.exe ..\bin
89
90 SRC = dlg_p.c dlg_a.c main.c err.c $(SET)\set.c support.c output.c &
91 relabel.c automata.c
92
93 dlg_p.c parser.dlg err.c tokens.h : dlg_p.g
94 $(ANTLR) dlg_p.g
95
96 dlg_a.c mode.h : parser.dlg
97 $(DLG) -C2 parser.dlg dlg_a.c
98
99 dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h
100 $(CC) $(CFLAGS) -c dlg_p.c
101
102 dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h
103 $(CC) $(CFLAGS) -c dlg_a.c
104
105 main.$(OBJ_EXT) : main.c dlg.h
106 $(CC) $(CFLAGS) -c main.c
107
108 set.$(OBJ_EXT) : $(SET)\set.c
109 $(CC) -c $(CFLAGS) $(SET)\set.c
110
111 #clean up all the intermediate files
112 clean:
113 del *.$(OBJ_EXT)
+0
-159
contrib/pccts/README less more
0
1 Parr Research Corporation
2 with
3 Purdue University Electrical Engineering
4 and
5 University of Minnesota, AHPCRC
6
7 Terence Parr
8 Russell Quong
9 Will Cohen
10 Hank Dietz
11
12
13 A central place for information about PCCTS 1.33 is:
14
15 http://www.polhode.com/pccts.html
16
17 The maintenance release is available from:
18
19 http://www.polhode.com/pccts133mr.zip
20
21 There is a ready-to-run version for win32 for Microsoft Visual Studio
22 at the same site. It is available from:
23
24 http://www.polhode.com/win32.zip
25
26 New users should visit http://www.polhode.com/pccts.html in
27 order to get the following document:
28
29 "Notes For New Users of PCCTS"
30
31 This is a Postscript file of about 40 pages which is extremely
32 useful for someone starting out. It is a based on 1.33mr21
33
34 When you have a little more experience, be sure to review the
35 following documents in the distribution kit:
36
37 CHANGES_FROM_133.txt
38 CHANGES_FROM_133_BEFORE_MR13.txt
39 KNOWN_PROBLEMS.txt
40
41 -------------------------------------------------------------------------
42 INSTALLATION (Unix)
43 -------------------------------------------------------------------------
44 0. Download http://www.polhode.com/pccts133mr.zip
45
46 1. Unzip the distribution kit to your preferred location.
47 If there are newline problems try using zip -a ...
48
49 2. cd to the main pccts directory.
50
51 3. make
52
53 This will create:
54
55 antlr
56 dlg
57 sorcerer
58 genmk
59
60 4. Copy to /usr/local/bin or /usr/local/bin if you like. If you
61 don't wish to then add pccts/bin to your path.
62
63 5. To get an up-to-date list of program options execute the
64 program with no command line options. To get up-to-date
65 documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt
66 at:
67
68 http://www.polhode.com/pccts.html
69
70 6. You need not create a library. The makefile created by genmk
71 assumes that the files are not part of a library.
72
73 If you wish to create a library from elements of pccts/h:
74
75 If the first letter of the filename is lowercase (uppercase) it is
76 related to the code generated using the pccts C mode (C++ mode).
77 Some of the .c and .cpp files in the h directory are not meant to
78 be placed in a library and will not compile because they are meant
79 to be #include in pccts generated files which are grammar specific.
80
81 For C++ users place the following elements in the library:
82
83 AParser.cpp
84 ASTBase.cpp
85 ATokenBuffer.cpp
86 BufFileInput.cpp (optional)
87 DLexerBase.cpp
88 PCCTSAST.cpp
89 SList.cpp
90
91 -------------------------------------------------------------------------
92 INSTALLATION (Win32)
93 -------------------------------------------------------------------------
94
95 I've tried to keep the win32 kit to the minimum necessary to get
96 up and running. The complete kit contains additional information
97 (some historical), source code, and DevStudio projects for
98 rebuilding pccts from the source code.
99
100 The kit is now distributed with both MSVC 5 and MSVC6 style projects.
101
102 0. Download http://www.polhode.com/win32.zip.
103
104 You may also wish to download:
105
106 http://www.polhode.com/CHANGES_FROM_133.txt
107 http://www.polhode.com/CHANGES_FROM_133_BEFORE_MR13.txt
108 http://www.polhode.com/KNOWN_PROBLEMS.txt
109
110 1. Unzip the distribution kit to your preferred location.
111
112 This will create:
113
114 a pccts directory tree
115 pccts/bin/*.exe
116 pccts/lib/*.lib
117 pccts/h/*
118 sorcerer/lib/*
119 sorcerer/h/*
120
121 an example directory tree
122 pccts\example\calcAST\*
123 pccts\example\simple\*
124
125 2. Define the environment variable PCCTS to point to the main
126 pccts directory.
127
128 3. Try building the simple project: pccts\example\simple\simple50.dsw
129 or simple60.dsw.
130
131 4. Try building the complex project: pccts\example\calcAST\calcAST50.dsw
132 or calcAST60.dsw.
133
134 -------------------------------------------------------------------------
135 INSTALLATION (DEC/VMS)
136 -------------------------------------------------------------------------
137
138 DEC/VMS support added by Piéronne Jean-François (jfp@altavista.net)
139
140 0. Download http://www.polhode.com/pccts133mr.zip
141
142 1. Unzip the distribution kit to your preferred location.
143
144 2. set default to the main pccts directory.
145
146 3. @makefile.vms
147
148 This will create in directory [.bin]:
149
150 antlr.exe
151 dlg.exe
152 sorcerer.exe
153 genmk.exe
154
155 5. To get an up-to-date list of program options execute the
156 program with no command line options. To get up-to-date
157 documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt
158 at http://www.polhode.com/pccts.html.
+0
-26
contrib/pccts/RIGHTS less more
0
1 SOFTWARE RIGHTS
2
3 We reserve no LEGAL rights to the Purdue Compiler Construction Tool
4 Set (PCCTS) -- PCCTS is in the public domain. An individual or
5 company may do whatever they wish with source code distributed with
6 PCCTS or the code generated by PCCTS, including the incorporation of
7 PCCTS, or its output, into commerical software.
8
9 We encourage users to develop software with PCCTS. However, we do ask
10 that credit is given to us for developing PCCTS. By "credit", we mean
11 that if you incorporate our source code into one of your programs
12 (commercial product, research project, or otherwise) that you
13 acknowledge this fact somewhere in the documentation, research report,
14 etc... If you like PCCTS and have developed a nice tool with the
15 output, please mention that you developed it using PCCTS. In
16 addition, we ask that this header remain intact in our source code.
17 As long as these guidelines are kept, we expect to continue enhancing
18 this system and expect to make other tools available as they are
19 completed.
20
21 ANTLR 1.33
22 Terence Parr
23 Parr Research Corporation
24 with Purdue University and AHPCRC, University of Minnesota
25 1989-1995
+0
-221
contrib/pccts/antlr/AntlrMS.mak less more
0 # PCCTS directory
1
2 PCCTS_HOME=<your PCCTS_HOME>
3 ANTLR_SRC=$(PCCTS_HOME)\antlr
4 PCCTS_H=$(PCCTS_HOME)\h
5
6
7 # Support directories
8 SET=$(PCCTS_HOME)\support\set
9
10
11 # Compiler stuff
12 CC = cl
13 CFLAGS = -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \
14 -D "ZZLEXBUFSIZE=65536" /D "LONGFILENAMES" /Zi /W3
15
16 ANTLR_OBJS = antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \
17 fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \
18 misc.obj pred.obj egman.obj mrhoist.obj fcache.obj
19
20 SUPPORT_OBJS = set.obj
21
22 # Dependencies
23
24 antlr.exe: $(ANTLR_OBJS) $(SUPPORT_OBJS)
25 $(CC) $(CFLAGS) -o antlr.exe $(ANTLR_OBJS) $(SUPPORT_OBJS)
26 del *.obj
27
28
29 antlr.obj: $(ANTLR_SRC)\antlr.c \
30 $(PCCTS_H)\antlr.h \
31 $(PCCTS_H)\config.h \
32 $(PCCTS_H)\dlgdef.h \
33 $(SET)\set.h \
34 $(ANTLR_SRC)\generic.h \
35 $(ANTLR_SRC)\hash.h \
36 $(ANTLR_SRC)\mode.h \
37 $(ANTLR_SRC)\proto.h \
38 $(ANTLR_SRC)\syn.h \
39 $(ANTLR_SRC)\tokens.h \
40
41 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\antlr.c
42
43 scan.obj: $(ANTLR_SRC)\scan.c \
44 $(PCCTS_H)\antlr.h \
45 $(PCCTS_H)\config.h \
46 $(PCCTS_H)\dlgauto.h \
47 $(PCCTS_H)\dlgdef.h \
48 $(SET)\set.h \
49 $(ANTLR_SRC)\generic.h \
50 $(ANTLR_SRC)\hash.h \
51 $(ANTLR_SRC)\mode.h \
52 $(ANTLR_SRC)\proto.h \
53 $(ANTLR_SRC)\syn.h \
54 $(ANTLR_SRC)\tokens.h \
55
56 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\scan.c
57
58 err.obj: $(ANTLR_SRC)\err.c \
59 $(PCCTS_H)\antlr.h \
60 $(PCCTS_H)\config.h \
61 $(PCCTS_H)\dlgdef.h \
62 $(PCCTS_H)\err.h \
63 $(SET)\set.h \
64 $(ANTLR_SRC)\generic.h \
65 $(ANTLR_SRC)\hash.h \
66 $(ANTLR_SRC)\proto.h \
67 $(ANTLR_SRC)\syn.h \
68 $(ANTLR_SRC)\tokens.h \
69
70 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\err.c
71
72 bits.obj: $(ANTLR_SRC)\bits.c \
73 $(PCCTS_H)\config.h \
74 $(PCCTS_H)\dlgdef.h \
75 $(SET)\set.h \
76 $(ANTLR_SRC)\generic.h \
77 $(ANTLR_SRC)\hash.h \
78 $(ANTLR_SRC)\proto.h \
79 $(ANTLR_SRC)\syn.h \
80
81 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\bits.c
82
83 build.obj: $(ANTLR_SRC)\build.c \
84 $(PCCTS_H)\config.h \
85 $(PCCTS_H)\dlgdef.h \
86 $(SET)\set.h \
87 $(ANTLR_SRC)\generic.h \
88 $(ANTLR_SRC)\hash.h \
89 $(ANTLR_SRC)\proto.h \
90 $(ANTLR_SRC)\syn.h \
91
92 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\build.c
93
94 fset2.obj: $(ANTLR_SRC)\fset2.c \
95 $(PCCTS_H)\config.h \
96 $(PCCTS_H)\dlgdef.h \
97 $(SET)\set.h \
98 $(ANTLR_SRC)\generic.h \
99 $(ANTLR_SRC)\hash.h \
100 $(ANTLR_SRC)\proto.h \
101 $(ANTLR_SRC)\syn.h \
102
103 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\fset2.c
104
105 fset.obj: $(ANTLR_SRC)\fset.c \
106 $(PCCTS_H)\config.h \
107 $(PCCTS_H)\dlgdef.h \
108 $(SET)\set.h \
109 $(ANTLR_SRC)\generic.h \
110 $(ANTLR_SRC)\hash.h \
111 $(ANTLR_SRC)\proto.h \
112 $(ANTLR_SRC)\syn.h \
113
114 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\fset.c
115
116 gen.obj: $(ANTLR_SRC)\gen.c \
117 $(PCCTS_H)\config.h \
118 $(PCCTS_H)\dlgdef.h \
119 $(SET)\set.h \
120 $(ANTLR_SRC)\generic.h \
121 $(ANTLR_SRC)\hash.h \
122 $(ANTLR_SRC)\proto.h \
123 $(ANTLR_SRC)\syn.h \
124
125 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\gen.c
126
127 globals.obj: $(ANTLR_SRC)\globals.c \
128 $(PCCTS_H)\config.h \
129 $(SET)\set.h \
130 $(ANTLR_SRC)\generic.h \
131 $(ANTLR_SRC)\hash.h \
132 $(ANTLR_SRC)\proto.h \
133 $(ANTLR_SRC)\syn.h \
134
135 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\globals.c
136
137 hash.obj: $(ANTLR_SRC)\hash.c \
138 $(PCCTS_H)\config.h \
139 $(ANTLR_SRC)\hash.h \
140
141 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\hash.c
142
143 lex.obj: $(ANTLR_SRC)\lex.c \
144 $(PCCTS_H)\config.h \
145 $(SET)\set.h \
146 $(ANTLR_SRC)\generic.h \
147 $(ANTLR_SRC)\hash.h \
148 $(ANTLR_SRC)\proto.h \
149 $(ANTLR_SRC)\syn.h \
150
151 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\lex.c
152
153 main.obj: $(ANTLR_SRC)\main.c \
154 $(PCCTS_H)\antlr.h \
155 $(PCCTS_H)\config.h \
156 $(PCCTS_H)\dlgdef.h \
157 $(SET)\set.h \
158 $(ANTLR_SRC)\generic.h \
159 $(ANTLR_SRC)\hash.h \
160 $(ANTLR_SRC)\mode.h \
161 $(ANTLR_SRC)\proto.h \
162 $(ANTLR_SRC)\stdpccts.h \
163 $(ANTLR_SRC)\syn.h \
164 $(ANTLR_SRC)\tokens.h \
165
166 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\main.c
167
168 misc.obj: $(ANTLR_SRC)\misc.c \
169 $(PCCTS_H)\config.h \
170 $(PCCTS_H)\dlgdef.h \
171 $(SET)\set.h \
172 $(ANTLR_SRC)\generic.h \
173 $(ANTLR_SRC)\hash.h \
174 $(ANTLR_SRC)\proto.h \
175 $(ANTLR_SRC)\syn.h \
176
177 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\misc.c
178
179 pred.obj: $(ANTLR_SRC)\pred.c \
180 $(PCCTS_H)\config.h \
181 $(PCCTS_H)\dlgdef.h \
182 $(SET)\set.h \
183 $(ANTLR_SRC)\generic.h \
184 $(ANTLR_SRC)\hash.h \
185 $(ANTLR_SRC)\proto.h \
186 $(ANTLR_SRC)\syn.h \
187
188 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\pred.c
189
190 egman.obj: $(ANTLR_SRC)\egman.c \
191 $(PCCTS_H)\config.h \
192 $(SET)\set.h \
193 $(ANTLR_SRC)\generic.h \
194 $(ANTLR_SRC)\hash.h \
195 $(ANTLR_SRC)\proto.h \
196 $(ANTLR_SRC)\syn.h \
197
198 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\egman.c
199
200 mrhoist.obj: $(ANTLR_SRC)\mrhoist.c \
201 $(ANTLR_SRC)\generic.h \
202 $(ANTLR_SRC)\hash.h \
203 $(ANTLR_SRC)\proto.h \
204 $(ANTLR_SRC)\syn.h \
205
206 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\mrhoist.c
207
208 fcache.obj: $(ANTLR_SRC)\fcache.c \
209 $(ANTLR_SRC)\generic.h \
210 $(ANTLR_SRC)\hash.h \
211 $(ANTLR_SRC)\proto.h \
212 $(ANTLR_SRC)\syn.h \
213
214 $(CC) -c $(CFLAGS) $(ANTLR_SRC)\fcache.c
215
216 set.obj: $(SET)\set.c \
217 $(PCCTS_H)\config.h \
218 $(SET)\set.h \
219
220 $(CC) -c $(CFLAGS) $(SET)\set.c
+0
-247
contrib/pccts/antlr/AntlrMSVC50.dsp less more
0 # Microsoft Developer Studio Project File - Name="ANTLR" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 5.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Console Application" 0x0103
5
6 CFG=ANTLR - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "AntlrMSVC50.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "AntlrMSVC50.mak" CFG="ANTLR - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "ANTLR - Win32 Release" (based on "Win32 (x86) Console Application")
20 !MESSAGE "ANTLR - Win32 Debug" (based on "Win32 (x86) Console Application")
21 !MESSAGE
22
23 # Begin Project
24 # PROP Scc_ProjName ""
25 # PROP Scc_LocalPath ""
26 CPP=cl.exe
27 RSC=rc.exe
28
29 !IF "$(CFG)" == "ANTLR - Win32 Release"
30
31 # PROP BASE Use_MFC 0
32 # PROP BASE Use_Debug_Libraries 0
33 # PROP BASE Output_Dir "Release"
34 # PROP BASE Intermediate_Dir "Release"
35 # PROP BASE Target_Dir ""
36 # PROP Use_MFC 0
37 # PROP Use_Debug_Libraries 0
38 # PROP Output_Dir "."
39 # PROP Intermediate_Dir "."
40 # PROP Ignore_Export_Lib 0
41 # PROP Target_Dir ""
42 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
43 # ADD CPP /nologo /W3 /O2 /I "." /I "..\h" /I "..\support\set" /D "__STDC__" /D "NDEBUG" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /FD /c
44 # SUBTRACT CPP /YX
45 # ADD BASE RSC /l 0x409 /d "NDEBUG"
46 # ADD RSC /l 0x409 /d "NDEBUG"
47 BSC32=bscmake.exe
48 # ADD BASE BSC32 /nologo
49 # ADD BSC32 /nologo
50 LINK32=link.exe
51 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
52 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"./Antlr.exe"
53 # Begin Special Build Tool
54 SOURCE=$(InputPath)
55 PostBuild_Desc=Copy antlr to ..\bin directory
56 PostBuild_Cmds=mkdir ..\bin copy ..\bin\antlr.exe antlr_old.exe copy antlr.exe\
57 ..\bin\.
58 # End Special Build Tool
59
60 !ELSEIF "$(CFG)" == "ANTLR - Win32 Debug"
61
62 # PROP BASE Use_MFC 0
63 # PROP BASE Use_Debug_Libraries 1
64 # PROP BASE Output_Dir "Debug"
65 # PROP BASE Intermediate_Dir "Debug"
66 # PROP BASE Target_Dir ""
67 # PROP Use_MFC 0
68 # PROP Use_Debug_Libraries 1
69 # PROP Output_Dir "."
70 # PROP Intermediate_Dir "."
71 # PROP Ignore_Export_Lib 0
72 # PROP Target_Dir ""
73 # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
74 # ADD CPP /nologo /W3 /Gm /Zi /Od /I "." /I "..\h" /I "..\support\set" /D "__STDC__" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /FD /c
75 # SUBTRACT CPP /YX
76 # ADD BASE RSC /l 0x409 /d "_DEBUG"
77 # ADD RSC /l 0x409 /d "_DEBUG"
78 BSC32=bscmake.exe
79 # ADD BASE BSC32 /nologo
80 # ADD BSC32 /nologo -DUSER_ZZSYN -D__STDC__
81 LINK32=link.exe
82 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
83 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"./Antlr.exe" /pdbtype:sept
84 # Begin Special Build Tool
85 SOURCE=$(InputPath)
86 PostBuild_Desc=Copy antlr to ..\bin
87 PostBuild_Cmds=mkdir ..\bin copy ..\bin\antlr.exe antlr_old.exe copy antlr.exe\
88 ..\bin\.
89 # End Special Build Tool
90
91 !ENDIF
92
93 # Begin Target
94
95 # Name "ANTLR - Win32 Release"
96 # Name "ANTLR - Win32 Debug"
97 # Begin Source File
98
99 SOURCE=.\antlr.c
100 # End Source File
101 # Begin Source File
102
103 SOURCE=.\antlr.g
104
105 !IF "$(CFG)" == "ANTLR - Win32 Release"
106
107 # Begin Custom Build - Building ANTLR Parser from ANTLR Grammar
108 InputPath=.\antlr.g
109 InputName=antlr
110
111 BuildCmds= \
112 ../bin/antlr -gh $(InputName).g \
113 ../bin/dlg -C2 parser.dlg scan.c \
114
115
116 "antlr.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
117 $(BuildCmds)
118
119 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
120 $(BuildCmds)
121
122 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
123 $(BuildCmds)
124
125 "scan.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
126 $(BuildCmds)
127
128 "tokens.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
129 $(BuildCmds)
130
131 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
132 $(BuildCmds)
133 # End Custom Build
134
135 !ELSEIF "$(CFG)" == "ANTLR - Win32 Debug"
136
137 # Begin Custom Build - Building ANTLR Parser from ANTLR Grammar
138 InputPath=.\antlr.g
139 InputName=antlr
140
141 BuildCmds= \
142 ..\bin\antlr -gh $(InputName).g \
143 ..\bin\dlg -C2 parser.dlg scan.c \
144
145
146 "antlr.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
147 $(BuildCmds)
148
149 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
150 $(BuildCmds)
151
152 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
153 $(BuildCmds)
154
155 "scan.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
156 $(BuildCmds)
157
158 "tokens.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
159 $(BuildCmds)
160
161 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
162 $(BuildCmds)
163 # End Custom Build
164
165 !ENDIF
166
167 # End Source File
168 # Begin Source File
169
170 SOURCE=.\bits.c
171 # End Source File
172 # Begin Source File
173
174 SOURCE=.\build.c
175 # End Source File
176 # Begin Source File
177
178 SOURCE=.\egman.c
179 # End Source File
180 # Begin Source File
181
182 SOURCE=.\err.c
183
184 !IF "$(CFG)" == "ANTLR - Win32 Release"
185
186 !ELSEIF "$(CFG)" == "ANTLR - Win32 Debug"
187
188 # SUBTRACT CPP /YX /Yc /Yu
189
190 !ENDIF
191
192 # End Source File
193 # Begin Source File
194
195 SOURCE=.\fcache.c
196 # End Source File
197 # Begin Source File
198
199 SOURCE=.\fset.c
200 # End Source File
201 # Begin Source File
202
203 SOURCE=.\fset2.c
204 # End Source File
205 # Begin Source File
206
207 SOURCE=.\gen.c
208 # End Source File
209 # Begin Source File
210
211 SOURCE=.\globals.c
212 # End Source File
213 # Begin Source File
214
215 SOURCE=.\hash.c
216 # End Source File
217 # Begin Source File
218
219 SOURCE=.\lex.c
220 # End Source File
221 # Begin Source File
222
223 SOURCE=.\main.c
224 # End Source File
225 # Begin Source File
226
227 SOURCE=.\misc.c
228 # End Source File
229 # Begin Source File
230
231 SOURCE=.\mrhoist.c
232 # End Source File
233 # Begin Source File
234
235 SOURCE=.\pred.c
236 # End Source File
237 # Begin Source File
238
239 SOURCE=.\scan.c
240 # End Source File
241 # Begin Source File
242
243 SOURCE=..\support\set\set.c
244 # End Source File
245 # End Target
246 # End Project
+0
-29
contrib/pccts/antlr/AntlrMSVC50.dsw less more
0 Microsoft Developer Studio Workspace File, Format Version 5.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "ANTLR"=.\AntlrMSVC50.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 }}}
10
11 Package=<4>
12 {{{
13 }}}
14
15 ###############################################################################
16
17 Global:
18
19 Package=<5>
20 {{{
21 }}}
22
23 Package=<3>
24 {{{
25 }}}
26
27 ###############################################################################
28
+0
-782
contrib/pccts/antlr/AntlrMSVC50.mak less more
0 # Microsoft Developer Studio Generated NMAKE File, Based on AntlrMSVC50.dsp
1 !IF "$(CFG)" == ""
2 CFG=ANTLR - Win32 Debug
3 !MESSAGE No configuration specified. Defaulting to ANTLR - Win32 Debug.
4 !ENDIF
5
6 !IF "$(CFG)" != "ANTLR - Win32 Release" && "$(CFG)" != "ANTLR - Win32 Debug"
7 !MESSAGE Invalid configuration "$(CFG)" specified.
8 !MESSAGE You can specify a configuration when running NMAKE
9 !MESSAGE by defining the macro CFG on the command line. For example:
10 !MESSAGE
11 !MESSAGE NMAKE /f "AntlrMSVC50.mak" CFG="ANTLR - Win32 Debug"
12 !MESSAGE
13 !MESSAGE Possible choices for configuration are:
14 !MESSAGE
15 !MESSAGE "ANTLR - Win32 Release" (based on "Win32 (x86) Console Application")
16 !MESSAGE "ANTLR - Win32 Debug" (based on "Win32 (x86) Console Application")
17 !MESSAGE
18 !ERROR An invalid configuration is specified.
19 !ENDIF
20
21 !IF "$(OS)" == "Windows_NT"
22 NULL=
23 !ELSE
24 NULL=nul
25 !ENDIF
26
27 !IF "$(CFG)" == "ANTLR - Win32 Release"
28
29 OUTDIR=.\.
30 INTDIR=.\.
31 # Begin Custom Macros
32 OutDir=.\.
33 # End Custom Macros
34
35 !IF "$(RECURSE)" == "0"
36
37 ALL : "tokens.h" "scan.c" "parser.dlg" "mode.h" "err.c" "antlr.c"\
38 "$(OUTDIR)\Antlr.exe" "$(OUTDIR)\AntlrMSVC50.bsc"
39
40 !ELSE
41
42 ALL : "tokens.h" "scan.c" "parser.dlg" "mode.h" "err.c" "antlr.c"\
43 "$(OUTDIR)\Antlr.exe" "$(OUTDIR)\AntlrMSVC50.bsc"
44
45 !ENDIF
46
47 CLEAN :
48 -@erase "$(INTDIR)\antlr.obj"
49 -@erase "$(INTDIR)\antlr.sbr"
50 -@erase "$(INTDIR)\bits.obj"
51 -@erase "$(INTDIR)\bits.sbr"
52 -@erase "$(INTDIR)\build.obj"
53 -@erase "$(INTDIR)\build.sbr"
54 -@erase "$(INTDIR)\egman.obj"
55 -@erase "$(INTDIR)\egman.sbr"
56 -@erase "$(INTDIR)\err.obj"
57 -@erase "$(INTDIR)\err.sbr"
58 -@erase "$(INTDIR)\fcache.obj"
59 -@erase "$(INTDIR)\fcache.sbr"
60 -@erase "$(INTDIR)\fset.obj"
61 -@erase "$(INTDIR)\fset.sbr"
62 -@erase "$(INTDIR)\fset2.obj"
63 -@erase "$(INTDIR)\fset2.sbr"
64 -@erase "$(INTDIR)\gen.obj"
65 -@erase "$(INTDIR)\gen.sbr"
66 -@erase "$(INTDIR)\globals.obj"
67 -@erase "$(INTDIR)\globals.sbr"
68 -@erase "$(INTDIR)\hash.obj"
69 -@erase "$(INTDIR)\hash.sbr"
70 -@erase "$(INTDIR)\lex.obj"
71 -@erase "$(INTDIR)\lex.sbr"
72 -@erase "$(INTDIR)\main.obj"
73 -@erase "$(INTDIR)\main.sbr"
74 -@erase "$(INTDIR)\misc.obj"
75 -@erase "$(INTDIR)\misc.sbr"
76 -@erase "$(INTDIR)\mrhoist.obj"
77 -@erase "$(INTDIR)\mrhoist.sbr"
78 -@erase "$(INTDIR)\pred.obj"
79 -@erase "$(INTDIR)\pred.sbr"
80 -@erase "$(INTDIR)\scan.obj"
81 -@erase "$(INTDIR)\scan.sbr"
82 -@erase "$(INTDIR)\set.obj"
83 -@erase "$(INTDIR)\set.sbr"
84 -@erase "$(INTDIR)\vc50.idb"
85 -@erase "$(OUTDIR)\Antlr.exe"
86 -@erase "$(OUTDIR)\AntlrMSVC50.bsc"
87 -@erase "antlr.c"
88 -@erase "err.c"
89 -@erase "mode.h"
90 -@erase "parser.dlg"
91 -@erase "scan.c"
92 -@erase "tokens.h"
93
94 "$(OUTDIR)" :
95 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
96
97 CPP=cl.exe
98 CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "." /I "..\h" /I "..\support\set" /D\
99 "NDEBUG" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D\
100 "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\"\
101 /Fd"$(INTDIR)\\" /FD /c
102 CPP_OBJS=./
103 CPP_SBRS=./
104
105 .c{$(CPP_OBJS)}.obj::
106 $(CPP) @<<
107 $(CPP_PROJ) $<
108 <<
109
110 .cpp{$(CPP_OBJS)}.obj::
111 $(CPP) @<<
112 $(CPP_PROJ) $<
113 <<
114
115 .cxx{$(CPP_OBJS)}.obj::
116 $(CPP) @<<
117 $(CPP_PROJ) $<
118 <<
119
120 .c{$(CPP_SBRS)}.sbr::
121 $(CPP) @<<
122 $(CPP_PROJ) $<
123 <<
124
125 .cpp{$(CPP_SBRS)}.sbr::
126 $(CPP) @<<
127 $(CPP_PROJ) $<
128 <<
129
130 .cxx{$(CPP_SBRS)}.sbr::
131 $(CPP) @<<
132 $(CPP_PROJ) $<
133 <<
134
135 RSC=rc.exe
136 BSC32=bscmake.exe
137 BSC32_FLAGS=/nologo /o"$(OUTDIR)\AntlrMSVC50.bsc"
138 BSC32_SBRS= \
139 "$(INTDIR)\antlr.sbr" \
140 "$(INTDIR)\bits.sbr" \
141 "$(INTDIR)\build.sbr" \
142 "$(INTDIR)\egman.sbr" \
143 "$(INTDIR)\err.sbr" \
144 "$(INTDIR)\fcache.sbr" \
145 "$(INTDIR)\fset.sbr" \
146 "$(INTDIR)\fset2.sbr" \
147 "$(INTDIR)\gen.sbr" \
148 "$(INTDIR)\globals.sbr" \
149 "$(INTDIR)\hash.sbr" \
150 "$(INTDIR)\lex.sbr" \
151 "$(INTDIR)\main.sbr" \
152 "$(INTDIR)\misc.sbr" \
153 "$(INTDIR)\mrhoist.sbr" \
154 "$(INTDIR)\pred.sbr" \
155 "$(INTDIR)\scan.sbr" \
156 "$(INTDIR)\set.sbr"
157
158 "$(OUTDIR)\AntlrMSVC50.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
159 $(BSC32) @<<
160 $(BSC32_FLAGS) $(BSC32_SBRS)
161 <<
162
163 LINK32=link.exe
164 LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
165 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
166 odbccp32.lib /nologo /subsystem:console /incremental:no\
167 /pdb:"$(OUTDIR)\Antlr.pdb" /machine:I386 /out:"$(OUTDIR)\Antlr.exe"
168 LINK32_OBJS= \
169 "$(INTDIR)\antlr.obj" \
170 "$(INTDIR)\bits.obj" \
171 "$(INTDIR)\build.obj" \
172 "$(INTDIR)\egman.obj" \
173 "$(INTDIR)\err.obj" \
174 "$(INTDIR)\fcache.obj" \
175 "$(INTDIR)\fset.obj" \
176 "$(INTDIR)\fset2.obj" \
177 "$(INTDIR)\gen.obj" \
178 "$(INTDIR)\globals.obj" \
179 "$(INTDIR)\hash.obj" \
180 "$(INTDIR)\lex.obj" \
181 "$(INTDIR)\main.obj" \
182 "$(INTDIR)\misc.obj" \
183 "$(INTDIR)\mrhoist.obj" \
184 "$(INTDIR)\pred.obj" \
185 "$(INTDIR)\scan.obj" \
186 "$(INTDIR)\set.obj"
187
188 "$(OUTDIR)\Antlr.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
189 $(LINK32) @<<
190 $(LINK32_FLAGS) $(LINK32_OBJS)
191 <<
192
193 SOURCE=$(InputPath)
194 PostBuild_Desc=Copy antlr to ..\bin directory
195 DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
196
197 ALL : $(DS_POSTBUILD_DEP)
198
199 # Begin Custom Macros
200 OutDir=.\.
201 # End Custom Macros
202
203 $(DS_POSTBUILD_DEP) : "tokens.h" "scan.c" "parser.dlg" "mode.h" "err.c"\
204 "antlr.c" "$(OUTDIR)\Antlr.exe" "$(OUTDIR)\AntlrMSVC50.bsc"
205 mkdir ..\bin
206 copy ..\bin\antlr.exe antlr_old.exe
207 copy antlr.exe ..\bin\.
208 echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
209
210 !ELSEIF "$(CFG)" == "ANTLR - Win32 Debug"
211
212 OUTDIR=.\.
213 INTDIR=.\.
214 # Begin Custom Macros
215 OutDir=.\.
216 # End Custom Macros
217
218 !IF "$(RECURSE)" == "0"
219
220 ALL : "tokens.h" "scan.c" "parser.dlg" "mode.h" "err.c" "antlr.c"\
221 "$(OUTDIR)\Antlr.exe" "$(OUTDIR)\AntlrMSVC50.bsc"
222
223 !ELSE
224
225 ALL : "tokens.h" "scan.c" "parser.dlg" "mode.h" "err.c" "antlr.c"\
226 "$(OUTDIR)\Antlr.exe" "$(OUTDIR)\AntlrMSVC50.bsc"
227
228 !ENDIF
229
230 CLEAN :
231 -@erase "$(INTDIR)\antlr.obj"
232 -@erase "$(INTDIR)\antlr.sbr"
233 -@erase "$(INTDIR)\bits.obj"
234 -@erase "$(INTDIR)\bits.sbr"
235 -@erase "$(INTDIR)\build.obj"
236 -@erase "$(INTDIR)\build.sbr"
237 -@erase "$(INTDIR)\egman.obj"
238 -@erase "$(INTDIR)\egman.sbr"
239 -@erase "$(INTDIR)\err.obj"
240 -@erase "$(INTDIR)\err.sbr"
241 -@erase "$(INTDIR)\fcache.obj"
242 -@erase "$(INTDIR)\fcache.sbr"
243 -@erase "$(INTDIR)\fset.obj"
244 -@erase "$(INTDIR)\fset.sbr"
245 -@erase "$(INTDIR)\fset2.obj"
246 -@erase "$(INTDIR)\fset2.sbr"
247 -@erase "$(INTDIR)\gen.obj"
248 -@erase "$(INTDIR)\gen.sbr"
249 -@erase "$(INTDIR)\globals.obj"
250 -@erase "$(INTDIR)\globals.sbr"
251 -@erase "$(INTDIR)\hash.obj"
252 -@erase "$(INTDIR)\hash.sbr"
253 -@erase "$(INTDIR)\lex.obj"
254 -@erase "$(INTDIR)\lex.sbr"
255 -@erase "$(INTDIR)\main.obj"
256 -@erase "$(INTDIR)\main.sbr"
257 -@erase "$(INTDIR)\misc.obj"
258 -@erase "$(INTDIR)\misc.sbr"
259 -@erase "$(INTDIR)\mrhoist.obj"
260 -@erase "$(INTDIR)\mrhoist.sbr"
261 -@erase "$(INTDIR)\pred.obj"
262 -@erase "$(INTDIR)\pred.sbr"
263 -@erase "$(INTDIR)\scan.obj"
264 -@erase "$(INTDIR)\scan.sbr"
265 -@erase "$(INTDIR)\set.obj"
266 -@erase "$(INTDIR)\set.sbr"
267 -@erase "$(INTDIR)\vc50.idb"
268 -@erase "$(INTDIR)\vc50.pdb"
269 -@erase "$(OUTDIR)\Antlr.exe"
270 -@erase "$(OUTDIR)\Antlr.ilk"
271 -@erase "$(OUTDIR)\Antlr.pdb"
272 -@erase "$(OUTDIR)\AntlrMSVC50.bsc"
273 -@erase "antlr.c"
274 -@erase "err.c"
275 -@erase "mode.h"
276 -@erase "parser.dlg"
277 -@erase "scan.c"
278 -@erase "tokens.h"
279
280 "$(OUTDIR)" :
281 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
282
283 CPP=cl.exe
284 CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "." /I "..\h" /I "..\support\set"\
285 /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D\
286 "WIN32" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\"\
287 /Fd"$(INTDIR)\\" /FD /c
288 CPP_OBJS=./
289 CPP_SBRS=./
290
291 .c{$(CPP_OBJS)}.obj::
292 $(CPP) @<<
293 $(CPP_PROJ) $<
294 <<
295
296 .cpp{$(CPP_OBJS)}.obj::
297 $(CPP) @<<
298 $(CPP_PROJ) $<
299 <<
300
301 .cxx{$(CPP_OBJS)}.obj::
302 $(CPP) @<<
303 $(CPP_PROJ) $<
304 <<
305
306 .c{$(CPP_SBRS)}.sbr::
307 $(CPP) @<<
308 $(CPP_PROJ) $<
309 <<
310
311 .cpp{$(CPP_SBRS)}.sbr::
312 $(CPP) @<<
313 $(CPP_PROJ) $<
314 <<
315
316 .cxx{$(CPP_SBRS)}.sbr::
317 $(CPP) @<<
318 $(CPP_PROJ) $<
319 <<
320
321 RSC=rc.exe
322 BSC32=bscmake.exe
323 BSC32_FLAGS=/nologo /o"$(OUTDIR)\AntlrMSVC50.bsc" -DUSER_ZZSYN -D__STDC__
324 BSC32_SBRS= \
325 "$(INTDIR)\antlr.sbr" \
326 "$(INTDIR)\bits.sbr" \
327 "$(INTDIR)\build.sbr" \
328 "$(INTDIR)\egman.sbr" \
329 "$(INTDIR)\err.sbr" \
330 "$(INTDIR)\fcache.sbr" \
331 "$(INTDIR)\fset.sbr" \
332 "$(INTDIR)\fset2.sbr" \
333 "$(INTDIR)\gen.sbr" \
334 "$(INTDIR)\globals.sbr" \
335 "$(INTDIR)\hash.sbr" \
336 "$(INTDIR)\lex.sbr" \
337 "$(INTDIR)\main.sbr" \
338 "$(INTDIR)\misc.sbr" \
339 "$(INTDIR)\mrhoist.sbr" \
340 "$(INTDIR)\pred.sbr" \
341 "$(INTDIR)\scan.sbr" \
342 "$(INTDIR)\set.sbr"
343
344 "$(OUTDIR)\AntlrMSVC50.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
345 $(BSC32) @<<
346 $(BSC32_FLAGS) $(BSC32_SBRS)
347 <<
348
349 LINK32=link.exe
350 LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
351 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
352 odbccp32.lib /nologo /subsystem:console /incremental:yes\
353 /pdb:"$(OUTDIR)\Antlr.pdb" /debug /machine:I386 /out:"$(OUTDIR)\Antlr.exe"\
354 /pdbtype:sept
355 LINK32_OBJS= \
356 "$(INTDIR)\antlr.obj" \
357 "$(INTDIR)\bits.obj" \
358 "$(INTDIR)\build.obj" \
359 "$(INTDIR)\egman.obj" \
360 "$(INTDIR)\err.obj" \
361 "$(INTDIR)\fcache.obj" \
362 "$(INTDIR)\fset.obj" \
363 "$(INTDIR)\fset2.obj" \
364 "$(INTDIR)\gen.obj" \
365 "$(INTDIR)\globals.obj" \
366 "$(INTDIR)\hash.obj" \
367 "$(INTDIR)\lex.obj" \
368 "$(INTDIR)\main.obj" \
369 "$(INTDIR)\misc.obj" \
370 "$(INTDIR)\mrhoist.obj" \
371 "$(INTDIR)\pred.obj" \
372 "$(INTDIR)\scan.obj" \
373 "$(INTDIR)\set.obj"
374
375 "$(OUTDIR)\Antlr.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
376 $(LINK32) @<<
377 $(LINK32_FLAGS) $(LINK32_OBJS)
378 <<
379
380 SOURCE=$(InputPath)
381 PostBuild_Desc=Copy antlr to ..\bin
382 DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
383
384 ALL : $(DS_POSTBUILD_DEP)
385
386 # Begin Custom Macros
387 OutDir=.\.
388 # End Custom Macros
389
390 $(DS_POSTBUILD_DEP) : "tokens.h" "scan.c" "parser.dlg" "mode.h" "err.c"\
391 "antlr.c" "$(OUTDIR)\Antlr.exe" "$(OUTDIR)\AntlrMSVC50.bsc"
392 mkdir ..\bin
393 copy ..\bin\antlr.exe antlr_old.exe
394 copy antlr.exe ..\bin\.
395 echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
396
397 !ENDIF
398
399
400 !IF "$(CFG)" == "ANTLR - Win32 Release" || "$(CFG)" == "ANTLR - Win32 Debug"
401 SOURCE=.\antlr.c
402 DEP_CPP_ANTLR=\
403 "..\h\antlr.h"\
404 "..\h\dlgdef.h"\
405 "..\h\pccts_stdio.h"\
406 "..\h\pccts_stdlib.h"\
407 "..\h\pccts_string.h"\
408 "..\h\pcctscfg.h"\
409 "..\support\set\set.h"\
410 ".\generic.h"\
411 ".\hash.h"\
412 ".\mode.h"\
413 ".\proto.h"\
414 ".\syn.h"\
415 ".\tokens.h"\
416
417
418 "$(INTDIR)\antlr.obj" "$(INTDIR)\antlr.sbr" : $(SOURCE) $(DEP_CPP_ANTLR)\
419 "$(INTDIR)" "$(INTDIR)\tokens.h" "$(INTDIR)\mode.h"
420
421
422 SOURCE=.\antlr.g
423
424 !IF "$(CFG)" == "ANTLR - Win32 Release"
425
426 InputPath=.\antlr.g
427 InputName=antlr
428
429 "antlr.c" "err.c" "mode.h" "scan.c" "tokens.h" "parser.dlg" : $(SOURCE)\
430 "$(INTDIR)" "$(OUTDIR)"
431 ../bin/antlr -gh $(InputName).g
432 ../bin/dlg -C2 parser.dlg scan.c
433
434
435 !ELSEIF "$(CFG)" == "ANTLR - Win32 Debug"
436
437 InputPath=.\antlr.g
438 InputName=antlr
439
440 "antlr.c" "err.c" "mode.h" "scan.c" "tokens.h" "parser.dlg" : $(SOURCE)\
441 "$(INTDIR)" "$(OUTDIR)"
442 ..\bin\antlr -gh $(InputName).g
443 ..\bin\dlg -C2 parser.dlg scan.c
444
445
446 !ENDIF
447
448 SOURCE=.\bits.c
449 DEP_CPP_BITS_=\
450 "..\h\dlgdef.h"\
451 "..\h\pccts_stdio.h"\
452 "..\h\pccts_stdlib.h"\
453 "..\h\pccts_string.h"\
454 "..\h\pcctscfg.h"\
455 "..\support\set\set.h"\
456 ".\generic.h"\
457 ".\hash.h"\
458 ".\proto.h"\
459 ".\syn.h"\
460
461
462 "$(INTDIR)\bits.obj" "$(INTDIR)\bits.sbr" : $(SOURCE) $(DEP_CPP_BITS_)\
463 "$(INTDIR)"
464
465
466 SOURCE=.\build.c
467 DEP_CPP_BUILD=\
468 "..\h\dlgdef.h"\
469 "..\h\pccts_stdio.h"\
470 "..\h\pccts_stdlib.h"\
471 "..\h\pccts_string.h"\
472 "..\h\pcctscfg.h"\
473 "..\support\set\set.h"\
474 ".\generic.h"\
475 ".\hash.h"\
476 ".\proto.h"\
477 ".\syn.h"\
478
479
480 "$(INTDIR)\build.obj" "$(INTDIR)\build.sbr" : $(SOURCE) $(DEP_CPP_BUILD)\
481 "$(INTDIR)"
482
483
484 SOURCE=.\egman.c
485 DEP_CPP_EGMAN=\
486 "..\h\pccts_stdio.h"\
487 "..\h\pccts_stdlib.h"\
488 "..\h\pccts_string.h"\
489 "..\h\pcctscfg.h"\
490 "..\support\set\set.h"\
491 ".\generic.h"\
492 ".\hash.h"\
493 ".\proto.h"\
494 ".\syn.h"\
495
496
497 "$(INTDIR)\egman.obj" "$(INTDIR)\egman.sbr" : $(SOURCE) $(DEP_CPP_EGMAN)\
498 "$(INTDIR)"
499
500
501 SOURCE=.\err.c
502 DEP_CPP_ERR_C=\
503 "..\h\antlr.h"\
504 "..\h\dlgdef.h"\
505 "..\h\err.h"\
506 "..\h\pccts_stdarg.h"\
507 "..\h\pccts_stdio.h"\
508 "..\h\pccts_stdlib.h"\
509 "..\h\pccts_string.h"\
510 "..\h\pcctscfg.h"\
511 "..\support\set\set.h"\
512 ".\generic.h"\
513 ".\hash.h"\
514 ".\proto.h"\
515 ".\syn.h"\
516 ".\tokens.h"\
517
518
519 !IF "$(CFG)" == "ANTLR - Win32 Release"
520
521 CPP_SWITCHES=/nologo /ML /W3 /GX /O2 /I "." /I "..\h" /I "..\support\set" /D\
522 "NDEBUG" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D\
523 "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\"\
524 /Fd"$(INTDIR)\\" /FD /c
525
526 "$(INTDIR)\err.obj" "$(INTDIR)\err.sbr" : $(SOURCE) $(DEP_CPP_ERR_C)\
527 "$(INTDIR)" "$(INTDIR)\tokens.h"
528 $(CPP) @<<
529 $(CPP_SWITCHES) $(SOURCE)
530 <<
531
532
533 !ELSEIF "$(CFG)" == "ANTLR - Win32 Debug"
534
535 CPP_SWITCHES=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "." /I "..\h" /I\
536 "..\support\set" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D\
537 ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS"\
538 /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
539
540 "$(INTDIR)\err.obj" "$(INTDIR)\err.sbr" : $(SOURCE) $(DEP_CPP_ERR_C)\
541 "$(INTDIR)" "$(INTDIR)\tokens.h"
542 $(CPP) @<<
543 $(CPP_SWITCHES) $(SOURCE)
544 <<
545
546
547 !ENDIF
548
549 SOURCE=.\fcache.c
550 DEP_CPP_FCACH=\
551 "..\h\pccts_stdio.h"\
552 "..\h\pccts_stdlib.h"\
553 "..\h\pccts_string.h"\
554 "..\h\pcctscfg.h"\
555 "..\support\set\set.h"\
556 ".\generic.h"\
557 ".\hash.h"\
558 ".\proto.h"\
559 ".\syn.h"\
560
561
562 "$(INTDIR)\fcache.obj" "$(INTDIR)\fcache.sbr" : $(SOURCE) $(DEP_CPP_FCACH)\
563 "$(INTDIR)"
564
565
566 SOURCE=.\fset.c
567 DEP_CPP_FSET_=\
568 "..\h\dlgdef.h"\
569 "..\h\pccts_stdio.h"\
570 "..\h\pccts_stdlib.h"\
571 "..\h\pccts_string.h"\
572 "..\h\pcctscfg.h"\
573 "..\support\set\set.h"\
574 ".\generic.h"\
575 ".\hash.h"\
576 ".\proto.h"\
577 ".\syn.h"\
578
579
580 "$(INTDIR)\fset.obj" "$(INTDIR)\fset.sbr" : $(SOURCE) $(DEP_CPP_FSET_)\
581 "$(INTDIR)"
582
583
584 SOURCE=.\fset2.c
585 DEP_CPP_FSET2=\
586 "..\h\dlgdef.h"\
587 "..\h\pccts_stdio.h"\
588 "..\h\pccts_stdlib.h"\
589 "..\h\pccts_string.h"\
590 "..\h\pcctscfg.h"\
591 "..\support\set\set.h"\
592 ".\generic.h"\
593 ".\hash.h"\
594 ".\proto.h"\
595 ".\syn.h"\
596
597
598 "$(INTDIR)\fset2.obj" "$(INTDIR)\fset2.sbr" : $(SOURCE) $(DEP_CPP_FSET2)\
599 "$(INTDIR)"
600
601
602 SOURCE=.\gen.c
603 DEP_CPP_GEN_C=\
604 "..\h\dlgdef.h"\
605 "..\h\pccts_stdio.h"\
606 "..\h\pccts_stdlib.h"\
607 "..\h\pccts_string.h"\
608 "..\h\pcctscfg.h"\
609 "..\support\set\set.h"\
610 ".\generic.h"\
611 ".\hash.h"\
612 ".\proto.h"\
613 ".\syn.h"\
614
615
616 "$(INTDIR)\gen.obj" "$(INTDIR)\gen.sbr" : $(SOURCE) $(DEP_CPP_GEN_C)\
617 "$(INTDIR)"
618
619
620 SOURCE=.\globals.c
621 DEP_CPP_GLOBA=\
622 "..\h\pccts_stdio.h"\
623 "..\h\pccts_stdlib.h"\
624 "..\h\pccts_string.h"\
625 "..\h\pcctscfg.h"\
626 "..\support\set\set.h"\
627 ".\generic.h"\
628 ".\hash.h"\
629 ".\proto.h"\
630 ".\syn.h"\
631
632
633 "$(INTDIR)\globals.obj" "$(INTDIR)\globals.sbr" : $(SOURCE) $(DEP_CPP_GLOBA)\
634 "$(INTDIR)"
635
636
637 SOURCE=.\hash.c
638 DEP_CPP_HASH_=\
639 "..\h\pccts_stdio.h"\
640 "..\h\pccts_stdlib.h"\
641 "..\h\pccts_string.h"\
642 "..\h\pcctscfg.h"\
643 ".\hash.h"\
644
645
646 "$(INTDIR)\hash.obj" "$(INTDIR)\hash.sbr" : $(SOURCE) $(DEP_CPP_HASH_)\
647 "$(INTDIR)"
648
649
650 SOURCE=.\lex.c
651 DEP_CPP_LEX_C=\
652 "..\h\pccts_stdio.h"\
653 "..\h\pccts_stdlib.h"\
654 "..\h\pccts_string.h"\
655 "..\h\pcctscfg.h"\
656 "..\support\set\set.h"\
657 ".\generic.h"\
658 ".\hash.h"\
659 ".\proto.h"\
660 ".\syn.h"\
661
662
663 "$(INTDIR)\lex.obj" "$(INTDIR)\lex.sbr" : $(SOURCE) $(DEP_CPP_LEX_C)\
664 "$(INTDIR)"
665
666
667 SOURCE=.\main.c
668 DEP_CPP_MAIN_=\
669 "..\h\antlr.h"\
670 "..\h\dlgdef.h"\
671 "..\h\pccts_stdio.h"\
672 "..\h\pccts_stdlib.h"\
673 "..\h\pccts_string.h"\
674 "..\h\pcctscfg.h"\
675 "..\support\set\set.h"\
676 ".\generic.h"\
677 ".\hash.h"\
678 ".\mode.h"\
679 ".\proto.h"\
680 ".\stdpccts.h"\
681 ".\syn.h"\
682 ".\tokens.h"\
683
684
685 "$(INTDIR)\main.obj" "$(INTDIR)\main.sbr" : $(SOURCE) $(DEP_CPP_MAIN_)\
686 "$(INTDIR)" "$(INTDIR)\tokens.h" "$(INTDIR)\mode.h"
687
688
689 SOURCE=.\misc.c
690 DEP_CPP_MISC_=\
691 "..\h\dlgdef.h"\
692 "..\h\pccts_stdio.h"\
693 "..\h\pccts_stdlib.h"\
694 "..\h\pccts_string.h"\
695 "..\h\pcctscfg.h"\
696 "..\support\set\set.h"\
697 ".\generic.h"\
698 ".\hash.h"\
699 ".\proto.h"\
700 ".\syn.h"\
701
702
703 "$(INTDIR)\misc.obj" "$(INTDIR)\misc.sbr" : $(SOURCE) $(DEP_CPP_MISC_)\
704 "$(INTDIR)"
705
706
707 SOURCE=.\mrhoist.c
708 DEP_CPP_MRHOI=\
709 "..\h\dlgdef.h"\
710 "..\h\pccts_stdio.h"\
711 "..\h\pccts_stdlib.h"\
712 "..\h\pccts_string.h"\
713 "..\h\pcctscfg.h"\
714 "..\support\set\set.h"\
715 ".\generic.h"\
716 ".\hash.h"\
717 ".\proto.h"\
718 ".\syn.h"\
719
720
721 "$(INTDIR)\mrhoist.obj" "$(INTDIR)\mrhoist.sbr" : $(SOURCE) $(DEP_CPP_MRHOI)\
722 "$(INTDIR)"
723
724
725 SOURCE=.\pred.c
726 DEP_CPP_PRED_=\
727 "..\h\dlgdef.h"\
728 "..\h\pccts_stdio.h"\
729 "..\h\pccts_stdlib.h"\
730 "..\h\pccts_string.h"\
731 "..\h\pcctscfg.h"\
732 "..\support\set\set.h"\
733 ".\generic.h"\
734 ".\hash.h"\
735 ".\proto.h"\
736 ".\syn.h"\
737
738
739 "$(INTDIR)\pred.obj" "$(INTDIR)\pred.sbr" : $(SOURCE) $(DEP_CPP_PRED_)\
740 "$(INTDIR)"
741
742
743 SOURCE=.\scan.c
744 DEP_CPP_SCAN_=\
745 "..\h\antlr.h"\
746 "..\h\dlgauto.h"\
747 "..\h\dlgdef.h"\
748 "..\h\pccts_stdio.h"\
749 "..\h\pccts_stdlib.h"\
750 "..\h\pccts_string.h"\
751 "..\h\pcctscfg.h"\
752 "..\support\set\set.h"\
753 ".\generic.h"\
754 ".\hash.h"\
755 ".\mode.h"\
756 ".\proto.h"\
757 ".\syn.h"\
758 ".\tokens.h"\
759
760
761 "$(INTDIR)\scan.obj" "$(INTDIR)\scan.sbr" : $(SOURCE) $(DEP_CPP_SCAN_)\
762 "$(INTDIR)" "$(INTDIR)\tokens.h" "$(INTDIR)\mode.h"
763
764
765 SOURCE=..\support\set\set.c
766 DEP_CPP_SET_C=\
767 "..\h\pccts_stdio.h"\
768 "..\h\pccts_stdlib.h"\
769 "..\h\pccts_string.h"\
770 "..\h\pcctscfg.h"\
771 "..\support\set\set.h"\
772
773
774 "$(INTDIR)\set.obj" "$(INTDIR)\set.sbr" : $(SOURCE) $(DEP_CPP_SET_C)\
775 "$(INTDIR)"
776 $(CPP) $(CPP_PROJ) $(SOURCE)
777
778
779
780 !ENDIF
781
+0
-266
contrib/pccts/antlr/AntlrMSVC60.dsp less more
0 # Microsoft Developer Studio Project File - Name="ANTLR" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 6.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Console Application" 0x0103
5
6 CFG=ANTLR - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "AntlrMSVC60.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "AntlrMSVC60.mak" CFG="ANTLR - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "ANTLR - Win32 Release" (based on "Win32 (x86) Console Application")
20 !MESSAGE "ANTLR - Win32 Debug" (based on "Win32 (x86) Console Application")
21 !MESSAGE
22
23 # Begin Project
24 # PROP AllowPerConfigDependencies 0
25 # PROP Scc_ProjName "AntlrMSVC60"
26 # PROP Scc_LocalPath ".."
27 CPP=cl.exe
28 RSC=rc.exe
29
30 !IF "$(CFG)" == "ANTLR - Win32 Release"
31
32 # PROP BASE Use_MFC 0
33 # PROP BASE Use_Debug_Libraries 0
34 # PROP BASE Output_Dir "Release"
35 # PROP BASE Intermediate_Dir "Release"
36 # PROP BASE Target_Dir ""
37 # PROP Use_MFC 0
38 # PROP Use_Debug_Libraries 0
39 # PROP Output_Dir "."
40 # PROP Intermediate_Dir "."
41 # PROP Ignore_Export_Lib 0
42 # PROP Target_Dir ""
43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
44 # ADD CPP /nologo /W3 /O2 /I "." /I "..\h" /I "..\support\set" /D "__STDC__" /D "NDEBUG" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /FD /c
45 # SUBTRACT CPP /YX
46 # ADD BASE RSC /l 0x409 /d "NDEBUG"
47 # ADD RSC /l 0x409 /d "NDEBUG"
48 BSC32=bscmake.exe
49 # ADD BASE BSC32 /nologo
50 # ADD BSC32 /nologo
51 LINK32=link.exe
52 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
53 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"./Antlr.exe"
54 # Begin Special Build Tool
55 SOURCE="$(InputPath)"
56 PostBuild_Desc=Copy antlr to ..\bin directory
57 PostBuild_Cmds=mkdir ..\bin copy ..\bin\antlr.exe antlr_old.exe copy antlr.exe ..\bin\.
58 # End Special Build Tool
59
60 !ELSEIF "$(CFG)" == "ANTLR - Win32 Debug"
61
62 # PROP BASE Use_MFC 0
63 # PROP BASE Use_Debug_Libraries 1
64 # PROP BASE Output_Dir "Debug"
65 # PROP BASE Intermediate_Dir "Debug"
66 # PROP BASE Target_Dir ""
67 # PROP Use_MFC 0
68 # PROP Use_Debug_Libraries 1
69 # PROP Output_Dir "."
70 # PROP Intermediate_Dir "."
71 # PROP Ignore_Export_Lib 0
72 # PROP Target_Dir ""
73 # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
74 # ADD CPP /nologo /W3 /Gm /ZI /Od /I "." /I "..\h" /I "..\support\set" /D "__STDC__" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /FD /c
75 # SUBTRACT CPP /YX
76 # ADD BASE RSC /l 0x409 /d "_DEBUG"
77 # ADD RSC /l 0x409 /d "_DEBUG"
78 BSC32=bscmake.exe
79 # ADD BASE BSC32 /nologo
80 # ADD BSC32 /nologo -DUSER_ZZSYN -D__STDC__
81 LINK32=link.exe
82 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
83 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"./Antlr.exe" /pdbtype:sept
84 # Begin Special Build Tool
85 SOURCE="$(InputPath)"
86 PostBuild_Desc=Copy antlr to ..\bin
87 PostBuild_Cmds=mkdir ..\bin copy ..\bin\antlr.exe antlr_old.exe copy antlr.exe ..\bin\.
88 # End Special Build Tool
89
90 !ENDIF
91
92 # Begin Target
93
94 # Name "ANTLR - Win32 Release"
95 # Name "ANTLR - Win32 Debug"
96 # Begin Source File
97
98 SOURCE=.\antlr.c
99 # End Source File
100 # Begin Source File
101
102 SOURCE=.\antlr.g
103
104 !IF "$(CFG)" == "ANTLR - Win32 Release"
105
106 # Begin Custom Build - Building ANTLR Parser from ANTLR Grammar
107 InputPath=.\antlr.g
108 InputName=antlr
109
110 BuildCmds= \
111 ..\bin\antlr -gh $(InputName).g \
112 ..\bin\dlg -C2 parser.dlg scan.c \
113
114
115 "antlr.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
116 $(BuildCmds)
117
118 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
119 $(BuildCmds)
120
121 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
122 $(BuildCmds)
123
124 "scan.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
125 $(BuildCmds)
126
127 "tokens.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
128 $(BuildCmds)
129
130 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
131 $(BuildCmds)
132 # End Custom Build
133
134 !ELSEIF "$(CFG)" == "ANTLR - Win32 Debug"
135
136 # Begin Custom Build - Building ANTLR Parser from ANTLR Grammar
137 InputPath=.\antlr.g
138 InputName=antlr
139
140 BuildCmds= \
141 ..\bin\antlr -gh $(InputName).g \
142 ..\bin\dlg -C2 parser.dlg scan.c \
143
144
145 "antlr.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
146 $(BuildCmds)
147
148 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
149 $(BuildCmds)
150
151 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
152 $(BuildCmds)
153
154 "scan.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
155 $(BuildCmds)
156
157 "tokens.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
158 $(BuildCmds)
159
160 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
161 $(BuildCmds)
162 # End Custom Build
163
164 !ENDIF
165
166 # End Source File
167 # Begin Source File
168
169 SOURCE=.\bits.c
170 # End Source File
171 # Begin Source File
172
173 SOURCE=.\build.c
174 # End Source File
175 # Begin Source File
176
177 SOURCE=.\dumpnode.c
178 # End Source File
179 # Begin Source File
180
181 SOURCE=.\egman.c
182 # End Source File
183 # Begin Source File
184
185 SOURCE=.\err.c
186
187 !IF "$(CFG)" == "ANTLR - Win32 Release"
188
189 !ELSEIF "$(CFG)" == "ANTLR - Win32 Debug"
190
191 # SUBTRACT CPP /YX /Yc /Yu
192
193 !ENDIF
194
195 # End Source File
196 # Begin Source File
197
198 SOURCE=.\fcache.c
199 # End Source File
200 # Begin Source File
201
202 SOURCE=.\fset.c
203 # End Source File
204 # Begin Source File
205
206 SOURCE=.\fset2.c
207 # End Source File
208 # Begin Source File
209
210 SOURCE=.\gen.c
211 # End Source File
212 # Begin Source File
213
214 SOURCE=.\generic.h
215 # End Source File
216 # Begin Source File
217
218 SOURCE=.\globals.c
219 # End Source File
220 # Begin Source File
221
222 SOURCE=.\hash.c
223 # End Source File
224 # Begin Source File
225
226 SOURCE=.\hash.h
227 # End Source File
228 # Begin Source File
229
230 SOURCE=.\lex.c
231 # End Source File
232 # Begin Source File
233
234 SOURCE=.\main.c
235 # End Source File
236 # Begin Source File
237
238 SOURCE=.\misc.c
239 # End Source File
240 # Begin Source File
241
242 SOURCE=.\mrhoist.c
243 # End Source File
244 # Begin Source File
245
246 SOURCE=.\pred.c
247 # End Source File
248 # Begin Source File
249
250 SOURCE=.\proto.h
251 # End Source File
252 # Begin Source File
253
254 SOURCE=.\scan.c
255 # End Source File
256 # Begin Source File
257
258 SOURCE=..\support\set\set.c
259 # End Source File
260 # Begin Source File
261
262 SOURCE=.\syn.h
263 # End Source File
264 # End Target
265 # End Project
+0
-33
contrib/pccts/antlr/AntlrMSVC60.dsw less more
0 Microsoft Developer Studio Workspace File, Format Version 6.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "ANTLR"=.\AntlrMSVC60.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 begin source code control
10 AntlrMSVC60
11 ..
12 end source code control
13 }}}
14
15 Package=<4>
16 {{{
17 }}}
18
19 ###############################################################################
20
21 Global:
22
23 Package=<5>
24 {{{
25 }}}
26
27 Package=<3>
28 {{{
29 }}}
30
31 ###############################################################################
32
+0
-62
contrib/pccts/antlr/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 noinst_PROGRAMS= antlr
4
5 AM_CFLAGS= -I. -I$(srcdir)/../support/set \
6 -I$(srcdir)/../h -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=32000
7
8 #
9 # SGI Users, use this CFLAGS
10 #
11 # FIXME -- what are -DUSER_ZZSYN and -woff 3262 for? Whats the real
12 # condition we need to detect to corectly turn those on?
13 #
14 # Think feature test, not OS test.
15 #CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262
16
17 antlr_SOURCES= \
18 antlr.c err.c bits.c build.c egman.c fcache.c fset.c fset2.c \
19 gen.c generic.h globals.c hash.c hash.h lex.c main.c misc.c mode.h \
20 mrhoist.c pred.c proto.h scan.c $(srcdir)/../support/set/set.c \
21 stdpccts.h syn.h tokens.h
22
23
24 # what files does PCCTS generate (both ANTLR and DLG)
25 PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h
26
27
28 # hopefully this won't produce some sort of chicken and egg problem
29
30 ANTLR= ./antlr
31 # Don't worry about the ambiguity messages coming from antlr
32 # for making antlr.c etc... [should be 10 of them, I think]
33 antlr.c stdpccts.h parser.dlg tokens.h err.c : $(srcdir)/antlr.g
34 @if test -x ${ANTLR} ; then \
35 echo "${ANTLR} -gh $(srcdir)/antlr.g" ; \
36 ${ANTLR} -gh $(srcdir)/antlr.g ; \
37 else \
38 echo "WARNING: $(srcdir)/antlr.g has changed making antlr.c stdpccts.h parser.dlg tokens.h " ; \
39 echo " and err.c out of date." ; \
40 echo " However you have not finished building $(ANTLR) yet. So you may want to" ; \
41 echo " build again a 2nd time after your build (hopefully) finishes." ; \
42 fi
43
44 DLG= ../dlg/dlg
45 scan.c mode.h: $(srcdir)/parser.dlg
46 @if test -x ${DLG} ; then \
47 echo "${DLG} -C2 $(srcdir)/parser.dlg scan.c" ; \
48 ${DLG} -C2 $(srcdir)/parser.dlg scan.c ; \
49 else \
50 echo "WARNING: $(srcdir)/parser.g has changed making scan.c and mode.h out of date." ; \
51 echo " However you have not finished building $(DLG) yet. So you may want to" ; \
52 echo " build again a 2nd time after your build (hopefully) finishes." ; \
53 fi
54
55
56 EXTRA_DIST= \
57 AntlrMS.mak AntlrMSVC50.dsp AntlrMSVC50.dsw AntlrMSVC50.mak \
58 AntlrMSVC60.dsp AntlrMSVC60.dsw README antlr.1 antlr.g \
59 antlr.r antlr1.txt antlr68K.make antlrPPC.make makefile.VMS \
60 makefile1 parser.dlg watantlr.mak
61
+0
-668
contrib/pccts/antlr/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 noinst_PROGRAMS = antlr$(EXEEXT)
79 subdir = contrib/pccts/antlr
80 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
81 $(top_srcdir)/depcomp README
82 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
83 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
84 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
85 $(ACLOCAL_M4)
86 mkinstalldirs = $(install_sh) -d
87 CONFIG_HEADER = $(top_builddir)/config.h
88 CONFIG_CLEAN_FILES =
89 CONFIG_CLEAN_VPATH_FILES =
90 PROGRAMS = $(noinst_PROGRAMS)
91 am_antlr_OBJECTS = antlr.$(OBJEXT) err.$(OBJEXT) bits.$(OBJEXT) \
92 build.$(OBJEXT) egman.$(OBJEXT) fcache.$(OBJEXT) \
93 fset.$(OBJEXT) fset2.$(OBJEXT) gen.$(OBJEXT) globals.$(OBJEXT) \
94 hash.$(OBJEXT) lex.$(OBJEXT) main.$(OBJEXT) misc.$(OBJEXT) \
95 mrhoist.$(OBJEXT) pred.$(OBJEXT) scan.$(OBJEXT) set.$(OBJEXT)
96 antlr_OBJECTS = $(am_antlr_OBJECTS)
97 antlr_LDADD = $(LDADD)
98 AM_V_P = $(am__v_P_@AM_V@)
99 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
100 am__v_P_0 = false
101 am__v_P_1 = :
102 AM_V_GEN = $(am__v_GEN_@AM_V@)
103 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
104 am__v_GEN_0 = @echo " GEN " $@;
105 am__v_GEN_1 =
106 AM_V_at = $(am__v_at_@AM_V@)
107 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
108 am__v_at_0 = @
109 am__v_at_1 =
110 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
111 depcomp = $(SHELL) $(top_srcdir)/depcomp
112 am__depfiles_maybe = depfiles
113 am__mv = mv -f
114 AM_V_lt = $(am__v_lt_@AM_V@)
115 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
116 am__v_lt_0 = --silent
117 am__v_lt_1 =
118 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
119 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
120 AM_V_CC = $(am__v_CC_@AM_V@)
121 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
122 am__v_CC_0 = @echo " CC " $@;
123 am__v_CC_1 =
124 CCLD = $(CC)
125 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
126 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
127 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
128 am__v_CCLD_0 = @echo " CCLD " $@;
129 am__v_CCLD_1 =
130 SOURCES = $(antlr_SOURCES)
131 DIST_SOURCES = $(antlr_SOURCES)
132 am__can_run_installinfo = \
133 case $$AM_UPDATE_INFO_DIR in \
134 n|no|NO) false;; \
135 *) (install-info --version) >/dev/null 2>&1;; \
136 esac
137 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
138 # Read a list of newline-separated strings from the standard input,
139 # and print each of them once, without duplicates. Input order is
140 # *not* preserved.
141 am__uniquify_input = $(AWK) '\
142 BEGIN { nonempty = 0; } \
143 { items[$$0] = 1; nonempty = 1; } \
144 END { if (nonempty) { for (i in items) print i; }; } \
145 '
146 # Make sure the list of sources is unique. This is necessary because,
147 # e.g., the same source file might be shared among _SOURCES variables
148 # for different programs/libraries.
149 am__define_uniq_tagged_files = \
150 list='$(am__tagged_files)'; \
151 unique=`for i in $$list; do \
152 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
153 done | $(am__uniquify_input)`
154 ETAGS = etags
155 CTAGS = ctags
156 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
157 ACLOCAL = @ACLOCAL@
158 AET2_CFLAGS = @AET2_CFLAGS@
159 AET2_LDADD = @AET2_LDADD@
160 ALLOCA = @ALLOCA@
161 AMTAR = @AMTAR@
162 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
163 AUTOCONF = @AUTOCONF@
164 AUTOHEADER = @AUTOHEADER@
165 AUTOMAKE = @AUTOMAKE@
166 AWK = @AWK@
167 CC = @CC@
168 CCDEPMODE = @CCDEPMODE@
169 CFLAGS = @CFLAGS@
170 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
171 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
172 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
173 CPP = @CPP@
174 CPPFLAGS = @CPPFLAGS@
175 CXX = @CXX@
176 CXXDEPMODE = @CXXDEPMODE@
177 CXXFLAGS = @CXXFLAGS@
178 CYGPATH_W = @CYGPATH_W@
179 DEFS = @DEFS@
180 DEPDIR = @DEPDIR@
181 ECHO_C = @ECHO_C@
182 ECHO_N = @ECHO_N@
183 ECHO_T = @ECHO_T@
184 EGREP = @EGREP@
185 EXEEXT = @EXEEXT@
186 EXTDEBUG = @EXTDEBUG@
187 EXTDEBUG2 = @EXTDEBUG2@
188 EXTDEBUG3 = @EXTDEBUG3@
189 EXTDEBUG4 = @EXTDEBUG4@
190 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
191 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
192 FSDB_CFLAGS = @FSDB_CFLAGS@
193 FSDB_LDADD = @FSDB_LDADD@
194 GCONF_CFLAGS = @GCONF_CFLAGS@
195 GCONF_LIBS = @GCONF_LIBS@
196 GEDITTEST = @GEDITTEST@
197 GEDIT_CFLAGS = @GEDIT_CFLAGS@
198 GIO_CFLAGS = @GIO_CFLAGS@
199 GIO_LIBS = @GIO_LIBS@
200 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
201 GPERF = @GPERF@
202 GREP = @GREP@
203 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
204 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
205 GTK_CFLAGS = @GTK_CFLAGS@
206 GTK_CONFIG = @GTK_CONFIG@
207 GTK_LIBS = @GTK_LIBS@
208 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
209 GTK_MAC_LIBS = @GTK_MAC_LIBS@
210 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
211 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
212 INSTALL = @INSTALL@
213 INSTALL_DATA = @INSTALL_DATA@
214 INSTALL_PROGRAM = @INSTALL_PROGRAM@
215 INSTALL_SCRIPT = @INSTALL_SCRIPT@
216 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
217 LDFLAGS = @LDFLAGS@
218 LEX = @LEX@
219 LEXLIB = @LEXLIB@
220 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
221 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
222 LIBBZ2_DIR = @LIBBZ2_DIR@
223 LIBBZ2_LDADD = @LIBBZ2_LDADD@
224 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
225 LIBJUDY_LDADD = @LIBJUDY_LDADD@
226 LIBOBJS = @LIBOBJS@
227 LIBS = @LIBS@
228 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
229 LIBXZ_LDADD = @LIBXZ_LDADD@
230 LIBZ_CFLAGS = @LIBZ_CFLAGS@
231 LIBZ_DIR = @LIBZ_DIR@
232 LIBZ_LDADD = @LIBZ_LDADD@
233 LTLIBOBJS = @LTLIBOBJS@
234 MAINT = @MAINT@
235 MAKEINFO = @MAKEINFO@
236 MINGW_LDADD = @MINGW_LDADD@
237 MKDIR_P = @MKDIR_P@
238 OBJEXT = @OBJEXT@
239 PACKAGE = @PACKAGE@
240 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
241 PACKAGE_NAME = @PACKAGE_NAME@
242 PACKAGE_STRING = @PACKAGE_STRING@
243 PACKAGE_TARNAME = @PACKAGE_TARNAME@
244 PACKAGE_URL = @PACKAGE_URL@
245 PACKAGE_VERSION = @PACKAGE_VERSION@
246 PATH_SEPARATOR = @PATH_SEPARATOR@
247 PKG_CONFIG = @PKG_CONFIG@
248 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
249 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
250 POW_LIB = @POW_LIB@
251 RANLIB = @RANLIB@
252 RPC_CFLAGS = @RPC_CFLAGS@
253 RPC_LDADD = @RPC_LDADD@
254 SET_MAKE = @SET_MAKE@
255 SHELL = @SHELL@
256 STRIP = @STRIP@
257 STRUCT_PACK = @STRUCT_PACK@
258 TCL_DEFADD = @TCL_DEFADD@
259 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
260 TCL_LDADD = @TCL_LDADD@
261 TCL_LIB_SPEC = @TCL_LIB_SPEC@
262 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
263 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
264 TIRPC_CFLAGS = @TIRPC_CFLAGS@
265 TIRPC_LIBS = @TIRPC_LIBS@
266 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
267 TK_LDADD = @TK_LDADD@
268 TK_LIB_SPEC = @TK_LIB_SPEC@
269 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
270 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
271 VERSION = @VERSION@
272 XDGDATADIR = @XDGDATADIR@
273 abs_builddir = @abs_builddir@
274 abs_srcdir = @abs_srcdir@
275 abs_top_builddir = @abs_top_builddir@
276 abs_top_srcdir = @abs_top_srcdir@
277 ac_ct_CC = @ac_ct_CC@
278 ac_ct_CXX = @ac_ct_CXX@
279 am__include = @am__include@
280 am__leading_dot = @am__leading_dot@
281 am__quote = @am__quote@
282 am__tar = @am__tar@
283 am__untar = @am__untar@
284 bindir = @bindir@
285 build_alias = @build_alias@
286 builddir = @builddir@
287 datadir = @datadir@
288 datarootdir = @datarootdir@
289 docdir = @docdir@
290 dvidir = @dvidir@
291 exec_prefix = @exec_prefix@
292 gsettingsschemadir = @gsettingsschemadir@
293 host_alias = @host_alias@
294 htmldir = @htmldir@
295 includedir = @includedir@
296 infodir = @infodir@
297 install_sh = @install_sh@
298 libdir = @libdir@
299 libexecdir = @libexecdir@
300 localedir = @localedir@
301 localstatedir = @localstatedir@
302 mandir = @mandir@
303 mkdir_p = @mkdir_p@
304 oldincludedir = @oldincludedir@
305 pdfdir = @pdfdir@
306 prefix = @prefix@
307 program_transform_name = @program_transform_name@
308 psdir = @psdir@
309 sbindir = @sbindir@
310 sharedstatedir = @sharedstatedir@
311 srcdir = @srcdir@
312 sysconfdir = @sysconfdir@
313 target_alias = @target_alias@
314 top_build_prefix = @top_build_prefix@
315 top_builddir = @top_builddir@
316 top_srcdir = @top_srcdir@
317 AM_CFLAGS = -I. -I$(srcdir)/../support/set \
318 -I$(srcdir)/../h -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=32000
319
320
321 #
322 # SGI Users, use this CFLAGS
323 #
324 # FIXME -- what are -DUSER_ZZSYN and -woff 3262 for? Whats the real
325 # condition we need to detect to corectly turn those on?
326 #
327 # Think feature test, not OS test.
328 #CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262
329 antlr_SOURCES = \
330 antlr.c err.c bits.c build.c egman.c fcache.c fset.c fset2.c \
331 gen.c generic.h globals.c hash.c hash.h lex.c main.c misc.c mode.h \
332 mrhoist.c pred.c proto.h scan.c $(srcdir)/../support/set/set.c \
333 stdpccts.h syn.h tokens.h
334
335
336 # what files does PCCTS generate (both ANTLR and DLG)
337 PCCTS_GEN = antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h
338
339 # hopefully this won't produce some sort of chicken and egg problem
340 ANTLR = ./antlr
341 DLG = ../dlg/dlg
342 EXTRA_DIST = \
343 AntlrMS.mak AntlrMSVC50.dsp AntlrMSVC50.dsw AntlrMSVC50.mak \
344 AntlrMSVC60.dsp AntlrMSVC60.dsw README antlr.1 antlr.g \
345 antlr.r antlr1.txt antlr68K.make antlrPPC.make makefile.VMS \
346 makefile1 parser.dlg watantlr.mak
347
348 all: all-am
349
350 .SUFFIXES:
351 .SUFFIXES: .c .o .obj
352 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
353 @for dep in $?; do \
354 case '$(am__configure_deps)' in \
355 *$$dep*) \
356 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
357 && { if test -f $@; then exit 0; else break; fi; }; \
358 exit 1;; \
359 esac; \
360 done; \
361 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/antlr/Makefile'; \
362 $(am__cd) $(top_srcdir) && \
363 $(AUTOMAKE) --foreign contrib/pccts/antlr/Makefile
364 .PRECIOUS: Makefile
365 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
366 @case '$?' in \
367 *config.status*) \
368 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
369 *) \
370 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
371 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
372 esac;
373
374 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
375 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
376
377 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
378 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
379 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
380 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
381 $(am__aclocal_m4_deps):
382
383 clean-noinstPROGRAMS:
384 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
385
386 antlr$(EXEEXT): $(antlr_OBJECTS) $(antlr_DEPENDENCIES) $(EXTRA_antlr_DEPENDENCIES)
387 @rm -f antlr$(EXEEXT)
388 $(AM_V_CCLD)$(LINK) $(antlr_OBJECTS) $(antlr_LDADD) $(LIBS)
389
390 mostlyclean-compile:
391 -rm -f *.$(OBJEXT)
392
393 distclean-compile:
394 -rm -f *.tab.c
395
396 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/antlr.Po@am__quote@
397 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bits.Po@am__quote@
398 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/build.Po@am__quote@
399 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/egman.Po@am__quote@
400 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Po@am__quote@
401 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcache.Po@am__quote@
402 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fset.Po@am__quote@
403 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fset2.Po@am__quote@
404 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen.Po@am__quote@
405 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/globals.Po@am__quote@
406 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@
407 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lex.Po@am__quote@
408 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
409 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@
410 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mrhoist.Po@am__quote@
411 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pred.Po@am__quote@
412 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan.Po@am__quote@
413 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set.Po@am__quote@
414
415 .c.o:
416 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
417 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
418 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
419 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
420 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
421
422 .c.obj:
423 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
424 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
425 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
426 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
427 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
428
429 set.o: $(srcdir)/../support/set/set.c
430 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT set.o -MD -MP -MF $(DEPDIR)/set.Tpo -c -o set.o `test -f '$(srcdir)/../support/set/set.c' || echo '$(srcdir)/'`$(srcdir)/../support/set/set.c
431 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/set.Tpo $(DEPDIR)/set.Po
432 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../support/set/set.c' object='set.o' libtool=no @AMDEPBACKSLASH@
433 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
434 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o set.o `test -f '$(srcdir)/../support/set/set.c' || echo '$(srcdir)/'`$(srcdir)/../support/set/set.c
435
436 set.obj: $(srcdir)/../support/set/set.c
437 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT set.obj -MD -MP -MF $(DEPDIR)/set.Tpo -c -o set.obj `if test -f '$(srcdir)/../support/set/set.c'; then $(CYGPATH_W) '$(srcdir)/../support/set/set.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../support/set/set.c'; fi`
438 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/set.Tpo $(DEPDIR)/set.Po
439 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../support/set/set.c' object='set.obj' libtool=no @AMDEPBACKSLASH@
440 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
441 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o set.obj `if test -f '$(srcdir)/../support/set/set.c'; then $(CYGPATH_W) '$(srcdir)/../support/set/set.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../support/set/set.c'; fi`
442
443 ID: $(am__tagged_files)
444 $(am__define_uniq_tagged_files); mkid -fID $$unique
445 tags: tags-am
446 TAGS: tags
447
448 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
449 set x; \
450 here=`pwd`; \
451 $(am__define_uniq_tagged_files); \
452 shift; \
453 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
454 test -n "$$unique" || unique=$$empty_fix; \
455 if test $$# -gt 0; then \
456 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
457 "$$@" $$unique; \
458 else \
459 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
460 $$unique; \
461 fi; \
462 fi
463 ctags: ctags-am
464
465 CTAGS: ctags
466 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
467 $(am__define_uniq_tagged_files); \
468 test -z "$(CTAGS_ARGS)$$unique" \
469 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
470 $$unique
471
472 GTAGS:
473 here=`$(am__cd) $(top_builddir) && pwd` \
474 && $(am__cd) $(top_srcdir) \
475 && gtags -i $(GTAGS_ARGS) "$$here"
476 cscopelist: cscopelist-am
477
478 cscopelist-am: $(am__tagged_files)
479 list='$(am__tagged_files)'; \
480 case "$(srcdir)" in \
481 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
482 *) sdir=$(subdir)/$(srcdir) ;; \
483 esac; \
484 for i in $$list; do \
485 if test -f "$$i"; then \
486 echo "$(subdir)/$$i"; \
487 else \
488 echo "$$sdir/$$i"; \
489 fi; \
490 done >> $(top_builddir)/cscope.files
491
492 distclean-tags:
493 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
494
495 distdir: $(DISTFILES)
496 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
497 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
498 list='$(DISTFILES)'; \
499 dist_files=`for file in $$list; do echo $$file; done | \
500 sed -e "s|^$$srcdirstrip/||;t" \
501 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
502 case $$dist_files in \
503 */*) $(MKDIR_P) `echo "$$dist_files" | \
504 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
505 sort -u` ;; \
506 esac; \
507 for file in $$dist_files; do \
508 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
509 if test -d $$d/$$file; then \
510 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
511 if test -d "$(distdir)/$$file"; then \
512 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
513 fi; \
514 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
515 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
516 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
517 fi; \
518 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
519 else \
520 test -f "$(distdir)/$$file" \
521 || cp -p $$d/$$file "$(distdir)/$$file" \
522 || exit 1; \
523 fi; \
524 done
525 check-am: all-am
526 check: check-am
527 all-am: Makefile $(PROGRAMS)
528 installdirs:
529 install: install-am
530 install-exec: install-exec-am
531 install-data: install-data-am
532 uninstall: uninstall-am
533
534 install-am: all-am
535 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
536
537 installcheck: installcheck-am
538 install-strip:
539 if test -z '$(STRIP)'; then \
540 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
541 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
542 install; \
543 else \
544 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
545 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
546 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
547 fi
548 mostlyclean-generic:
549
550 clean-generic:
551
552 distclean-generic:
553 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
554 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
555
556 maintainer-clean-generic:
557 @echo "This command is intended for maintainers to use"
558 @echo "it deletes files that may require special tools to rebuild."
559 clean: clean-am
560
561 clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am
562
563 distclean: distclean-am
564 -rm -rf ./$(DEPDIR)
565 -rm -f Makefile
566 distclean-am: clean-am distclean-compile distclean-generic \
567 distclean-tags
568
569 dvi: dvi-am
570
571 dvi-am:
572
573 html: html-am
574
575 html-am:
576
577 info: info-am
578
579 info-am:
580
581 install-data-am:
582
583 install-dvi: install-dvi-am
584
585 install-dvi-am:
586
587 install-exec-am:
588
589 install-html: install-html-am
590
591 install-html-am:
592
593 install-info: install-info-am
594
595 install-info-am:
596
597 install-man:
598
599 install-pdf: install-pdf-am
600
601 install-pdf-am:
602
603 install-ps: install-ps-am
604
605 install-ps-am:
606
607 installcheck-am:
608
609 maintainer-clean: maintainer-clean-am
610 -rm -rf ./$(DEPDIR)
611 -rm -f Makefile
612 maintainer-clean-am: distclean-am maintainer-clean-generic
613
614 mostlyclean: mostlyclean-am
615
616 mostlyclean-am: mostlyclean-compile mostlyclean-generic
617
618 pdf: pdf-am
619
620 pdf-am:
621
622 ps: ps-am
623
624 ps-am:
625
626 uninstall-am:
627
628 .MAKE: install-am install-strip
629
630 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
631 clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \
632 distclean-compile distclean-generic distclean-tags distdir dvi \
633 dvi-am html html-am info info-am install install-am \
634 install-data install-data-am install-dvi install-dvi-am \
635 install-exec install-exec-am install-html install-html-am \
636 install-info install-info-am install-man install-pdf \
637 install-pdf-am install-ps install-ps-am install-strip \
638 installcheck installcheck-am installdirs maintainer-clean \
639 maintainer-clean-generic mostlyclean mostlyclean-compile \
640 mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
641 uninstall-am
642
643 # Don't worry about the ambiguity messages coming from antlr
644 # for making antlr.c etc... [should be 10 of them, I think]
645 antlr.c stdpccts.h parser.dlg tokens.h err.c : $(srcdir)/antlr.g
646 @if test -x ${ANTLR} ; then \
647 echo "${ANTLR} -gh $(srcdir)/antlr.g" ; \
648 ${ANTLR} -gh $(srcdir)/antlr.g ; \
649 else \
650 echo "WARNING: $(srcdir)/antlr.g has changed making antlr.c stdpccts.h parser.dlg tokens.h " ; \
651 echo " and err.c out of date." ; \
652 echo " However you have not finished building $(ANTLR) yet. So you may want to" ; \
653 echo " build again a 2nd time after your build (hopefully) finishes." ; \
654 fi
655 scan.c mode.h: $(srcdir)/parser.dlg
656 @if test -x ${DLG} ; then \
657 echo "${DLG} -C2 $(srcdir)/parser.dlg scan.c" ; \
658 ${DLG} -C2 $(srcdir)/parser.dlg scan.c ; \
659 else \
660 echo "WARNING: $(srcdir)/parser.g has changed making scan.c and mode.h out of date." ; \
661 echo " However you have not finished building $(DLG) yet. So you may want to" ; \
662 echo " build again a 2nd time after your build (hopefully) finishes." ; \
663 fi
664
665 # Tell versions [3.59,3.63) of GNU make to not export all variables.
666 # Otherwise a system limit (for SysV at least) may be exceeded.
667 .NOEXPORT:
+0
-19
contrib/pccts/antlr/README less more
0 ANTLR 1.33
1
2 This directory contains the files necessary to build ANTLR.
3
4 If you do a "make scrub", ANTLR will have to run on antlr.g and DLG
5 will have to run on parser.dlg. Either
6
7 (1) ANTLR uses the previous antlr in that directory to rebuild itself
8 (2) Needs to find antlr on the search path
9
10 You will find that running "antlr -gh antlr.g" will result in about
11 10 ambiguity warnings. These are normal. Don't worry.
12
13 If you do a "make clean" right after installation, ANTLR and DLG should
14 not need to run; only the C files will compile.
15
16 Don't forget to go into the makefile to uncomment the appropriate
17 definitions for your OS/architecture/compiler or see the appropriate
18 NOTES.?? file.
+0
-209
contrib/pccts/antlr/antlr.1 less more
0 .TH ANTLR 1 "September 1995" "ANTLR" "PCCTS Manual Pages"
1 .SH NAME
2 antlr \- ANother Tool for Language Recognition
3 .SH SYNTAX
4 .LP
5 \fBantlr\fR [\fIoptions\fR] \fIgrammar_files\fR
6 .SH DESCRIPTION
7 .PP
8 \fIAntlr\fP converts an extended form of context-free grammar into a
9 set of C functions which directly implement an efficient form of
10 deterministic recursive-descent LL(k) parser. Context-free grammars
11 may be augmented with predicates to allow semantics to influence
12 parsing; this allows a form of context-sensitive parsing. Selective
13 backtracking is also available to handle non-LL(k) and even
14 non-LALR(k) constructs. \fIAntlr\fP also produces a definition of a
15 lexer which can be automatically converted into C code for a DFA-based
16 lexer by \fIdlg\fR. Hence, \fIantlr\fR serves a function much like
17 that of \fIyacc\fR, however, it is notably more flexible and is more
18 integrated with a lexer generator (\fIantlr\fR directly generates
19 \fIdlg\fR code, whereas \fIyacc\fR and \fIlex\fR are given independent
20 descriptions). Unlike \fIyacc\fR which accepts LALR(1) grammars,
21 \fIantlr\fR accepts LL(k) grammars in an extended BNF notation \(em
22 which eliminates the need for precedence rules.
23 .PP
24 Like \fIyacc\fR grammars, \fIantlr\fR grammars can use
25 automatically-maintained symbol attribute values referenced as dollar
26 variables. Further, because \fIantlr\fR generates top-down parsers,
27 arbitrary values may be inherited from parent rules (passed like
28 function parameters). \fIAntlr\fP also has a mechanism for creating
29 and manipulating abstract-syntax-trees.
30 .PP
31 There are various other niceties in \fIantlr\fR, including the ability to
32 spread one grammar over multiple files or even multiple grammars in a single
33 file, the ability to generate a version of the grammar with actions stripped
34 out (for documentation purposes), and lots more.
35 .SH OPTIONS
36 .IP "\fB-ck \fIn\fR"
37 Use up to \fIn\fR symbols of lookahead when using compressed (linear
38 approximation) lookahead. This type of lookahead is very cheap to
39 compute and is attempted before full LL(k) lookahead, which is of
40 exponential complexity in the worst case. In general, the compressed
41 lookahead can be much deeper (e.g, \f(CW-ck 10\fP) than the full
42 lookahead (which usually must be less than 4).
43 .IP \fB-CC\fP
44 Generate C++ output from both ANTLR and DLG.
45 .IP \fB-cr\fP
46 Generate a cross-reference for all rules. For each rule, print a list
47 of all other rules that reference it.
48 .IP \fB-e1\fP
49 Ambiguities/errors shown in low detail (default).
50 .IP \fB-e2\fP
51 Ambiguities/errors shown in more detail.
52 .IP \fB-e3\fP
53 Ambiguities/errors shown in excruciating detail.
54 .IP "\fB-fe\fP file"
55 Rename \fBerr.c\fP to file.
56 .IP "\fB-fh\fP file"
57 Rename \fBstdpccts.h\fP header (turns on \fB-gh\fP) to file.
58 .IP "\fB-fl\fP file"
59 Rename lexical output, \fBparser.dlg\fP, to file.
60 .IP "\fB-fm\fP file"
61 Rename file with lexical mode definitions, \fBmode.h\fP, to file.
62 .IP "\fB-fr\fP file"
63 Rename file which remaps globally visible symbols, \fBremap.h\fP, to file.
64 .IP "\fB-ft\fP file"
65 Rename \fBtokens.h\fP to file.
66 .IP \fB-ga\fP
67 Generate ANSI-compatible code (default case). This has not been
68 rigorously tested to be ANSI XJ11 C compliant, but it is close. The
69 normal output of \fIantlr\fP is currently compilable under both K&R,
70 ANSI C, and C++\(emthis option does nothing because \fIantlr\fP
71 generates a bunch of #ifdef's to do the right thing depending on the
72 language.
73 .IP \fB-gc\fP
74 Indicates that \fIantlr\fP should generate no C code, i.e., only
75 perform analysis on the grammar.
76 .IP \fB-gd\fP
77 C code is inserted in each of the \fIantlr\fR generated parsing functions to
78 provide for user-defined handling of a detailed parse trace. The inserted
79 code consists of calls to the user-supplied macros or functions called
80 \fBzzTRACEIN\fR and \fBzzTRACEOUT\fP. The only argument is a
81 \fIchar *\fR pointing to a C-style string which is the grammar rule
82 recognized by the current parsing function. If no definition is given
83 for the trace functions, upon rule entry and exit, a message will be
84 printed indicating that a particular rule as been entered or exited.
85 .IP \fB-ge\fP
86 Generate an error class for each non-terminal.
87 .IP \fB-gh\fP
88 Generate \fBstdpccts.h\fP for non-ANTLR-generated files to include.
89 This file contains all defines needed to describe the type of parser
90 generated by \fIantlr\fP (e.g. how much lookahead is used and whether
91 or not trees are constructed) and contains the \fBheader\fP action
92 specified by the user.
93 .IP \fB-gk\fP
94 Generate parsers that delay lookahead fetches until needed. Without
95 this option, \fIantlr\fP generates parsers which always have \fIk\fP
96 tokens of lookahead available.
97 .IP \fB-gl\fP
98 Generate line info about grammar actions in C parser of the form
99 \fB#\ \fIline\fP\ "\fIfile\fP"\fR which makes error messages from
100 the C/C++ compiler make more sense as they will \*Qpoint\*U into the
101 grammar file not the resulting C file. Debugging is easier as well,
102 because you will step through the grammar not C file.
103 .IP \fB-gs\fR
104 Do not generate sets for token expression lists; instead generate a
105 \fB||\fP-separated sequence of \fBLA(1)==\fItoken_number\fR. The
106 default is to generate sets.
107 .IP \fB-gt\fP
108 Generate code for Abstract-Syntax Trees.
109 .IP \fB-gx\fP
110 Do not create the lexical analyzer files (dlg-related). This option
111 should be given when the user wishes to provide a customized lexical
112 analyzer. It may also be used in \fImake\fR scripts to cause only the
113 parser to be rebuilt when a change not affecting the lexical structure
114 is made to the input grammars.
115 .IP "\fB-k \fIn\fR"
116 Set k of LL(k) to \fIn\fR; i.e. set tokens of look-ahead (default==1).
117 .IP "\fB-o\fP dir
118 Directory where output files should go (default="."). This is very
119 nice for keeping the source directory clear of ANTLR and DLG spawn.
120 .IP \fB-p\fP
121 The complete grammar, collected from all input grammar files and
122 stripped of all comments and embedded actions, is listed to
123 \fBstdout\fP. This is intended to aid in viewing the entire grammar
124 as a whole and to eliminate the need to keep actions concisely stated
125 so that the grammar is easier to read. Hence, it is preferable to
126 embed even complex actions directly in the grammar, rather than to
127 call them as subroutines, since the subroutine call overhead will be
128 saved.
129 .IP \fB-pa\fP
130 This option is the same as \fB-p\fP except that the output is
131 annotated with the first sets determined from grammar analysis.
132 .IP "\fB-prc on\fR
133 Turn on the computation and hoisting of predicate context.
134 .IP "\fB-prc off\fR
135 Turn off the computation and hoisting of predicate context. This
136 option makes 1.10 behave like the 1.06 release with option \fB-pr\fR
137 on. Context computation is off by default.
138 .IP "\fB-rl \fIn\fR
139 Limit the maximum number of tree nodes used by grammar analysis to
140 \fIn\fP. Occasionally, \fIantlr\fP is unable to analyze a grammar
141 submitted by the user. This rare situation can only occur when the
142 grammar is large and the amount of lookahead is greater than one. A
143 nonlinear analysis algorithm is used by PCCTS to handle the general
144 case of LL(k) parsing. The average complexity of analysis, however, is
145 near linear due to some fancy footwork in the implementation which
146 reduces the number of calls to the full LL(k) algorithm. An error
147 message will be displayed, if this limit is reached, which indicates
148 the grammar construct being analyzed when \fIantlr\fP hit a
149 non-linearity. Use this option if \fIantlr\fP seems to go out to
150 lunch and your disk start thrashing; try \fIn\fP=10000 to start. Once
151 the offending construct has been identified, try to remove the
152 ambiguity that \fIantlr\fP was trying to overcome with large lookahead
153 analysis. The introduction of (...)? backtracking blocks eliminates
154 some of these problems\ \(em \fIantlr\fP does not analyze alternatives
155 that begin with (...)? (it simply backtracks, if necessary, at run
156 time).
157 .IP \fB-w1\fR
158 Set low warning level. Do not warn if semantic predicates and/or
159 (...)? blocks are assumed to cover ambiguous alternatives.
160 .IP \fB-w2\fR
161 Ambiguous parsing decisions yield warnings even if semantic predicates
162 or (...)? blocks are used. Warn if predicate context computed and
163 semantic predicates incompletely disambiguate alternative productions.
164 .IP \fB-\fR
165 Read grammar from standard input and generate \fBstdin.c\fP as the
166 parser file.
167 .SH "SPECIAL CONSIDERATIONS"
168 .PP
169 \fIAntlr\fP works... we think. There is no implicit guarantee of
170 anything. We reserve no \fBlegal\fP rights to the software known as
171 the Purdue Compiler Construction Tool Set (PCCTS) \(em PCCTS is in the
172 public domain. An individual or company may do whatever they wish
173 with source code distributed with PCCTS or the code generated by
174 PCCTS, including the incorporation of PCCTS, or its output, into
175 commercial software. We encourage users to develop software with
176 PCCTS. However, we do ask that credit is given to us for developing
177 PCCTS. By "credit", we mean that if you incorporate our source code
178 into one of your programs (commercial product, research project, or
179 otherwise) that you acknowledge this fact somewhere in the
180 documentation, research report, etc... If you like PCCTS and have
181 developed a nice tool with the output, please mention that you
182 developed it using PCCTS. As long as these guidelines are followed,
183 we expect to continue enhancing this system and expect to make other
184 tools available as they are completed.
185 .SH FILES
186 .IP *.c
187 output C parser.
188 .IP *.cpp
189 output C++ parser when C++ mode is used.
190 .IP \fBparser.dlg\fP
191 output \fIdlg\fR lexical analyzer.
192 .IP \fBerr.c\fP
193 token string array, error sets and error support routines. Not used in
194 C++ mode.
195 .IP \fBremap.h\fP
196 file that redefines all globally visible parser symbols. The use of
197 the #parser directive creates this file. Not used in
198 C++ mode.
199 .IP \fBstdpccts.h\fP
200 list of definitions needed by C files, not generated by PCCTS, that
201 reference PCCTS objects. This is not generated by default. Not used in
202 C++ mode.
203 .IP \fBtokens.h\fP
204 output \fI#defines\fR for tokens used and function prototypes for
205 functions generated for rules.
206 .SH "SEE ALSO"
207 .LP
208 dlg(1), pccts(1)
+0
-3564
contrib/pccts/antlr/antlr.c less more
0 /*
1 * A n t l r T r a n s l a t i o n H e a d e r
2 *
3 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
4 * Purdue University Electrical Engineering
5 * With AHPCRC, University of Minnesota
6 * ANTLR Version 1.33MR33
7 *
8 * ./antlr -gh ./antlr.g
9 *
10 */
11
12 #define ANTLR_VERSION 13333
13 #include "pcctscfg.h"
14 #include "pccts_stdio.h"
15
16 #include "pcctscfg.h"
17 #include "set.h"
18 #include <ctype.h>
19 #include "syn.h"
20 #include "hash.h"
21 #include "generic.h"
22 #define zzcr_attr(attr,tok,t)
23 #define zzSET_SIZE 20
24 #include "antlr.h"
25 #include "tokens.h"
26 #include "dlgdef.h"
27 #include "mode.h"
28
29 /* MR23 In order to remove calls to PURIFY use the antlr -nopurify option */
30
31 #ifndef PCCTS_PURIFY
32 #define PCCTS_PURIFY(r,s) memset((char *) &(r),'\0',(s));
33 #endif
34
35 ANTLR_INFO
36
37
38 /* MR20 G. Hobbelt For Borland C++ 4.x & 5.x compiling with ALL warnings enabled */
39 #if defined(__TURBOC__)
40 #pragma warn -aus /* unused assignment of 'xxx' */
41 #endif
42
43
44 #ifdef __USE_PROTOS
45 static void chkToken(char *, char *, char *, int);
46 #else
47 static void chkToken();
48 #endif
49
50 #ifdef __USE_PROTOS
51 static int isDLGmaxToken(char *Token); /* MR3 */
52 #else
53 static int isDLGmaxToken(); /* MR3 */
54 #endif
55
56 static int class_nest_level = 0;
57
58 /* MR20 G. Hobbelt extern definitions moved to antlr.h */
59
60
61
62 void
63 #ifdef __USE_PROTOS
64 grammar(void)
65 #else
66 grammar()
67 #endif
68 {
69 zzRULE;
70 zzBLOCK(zztasp1);
71 zzMake0;
72 {
73 Graph g;
74 {
75 zzBLOCK(zztasp2);
76 zzMake0;
77 {
78 for (;;) {
79 if ( !((setwd1[LA(1)]&0x1))) break;
80 if ( (LA(1)==94) ) {
81 zzmatch(94); zzCONSUME;
82 zzmatch(Action);
83
84 if ( HdrAction==NULL ) {
85 HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
86 require(HdrAction!=NULL, "rule grammar: cannot allocate header action");
87 strcpy(HdrAction, LATEXT(1));
88 }
89 else warn("additional #header statement ignored");
90 zzCONSUME;
91
92 }
93 else {
94 if ( (LA(1)==95) ) {
95 zzmatch(95); zzCONSUME;
96 zzmatch(Action);
97
98 if ( FirstAction==NULL ) {
99 FirstAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
100 require(FirstAction!=NULL, "rule grammar: cannot allocate #first action");
101 strcpy(FirstAction, LATEXT(1));
102 } else {
103 warn("additional #first statement ignored");
104 };
105 zzCONSUME;
106
107 }
108 else {
109 if ( (LA(1)==96) ) {
110 zzmatch(96); zzCONSUME;
111 zzmatch(QuotedTerm);
112
113 if ( GenCC ) {
114 warn("#parser meta-op incompatible with -CC; ignored");
115 }
116 else {
117 if ( strcmp(ParserName,"zzparser")==0 ) {
118 ParserName=StripQuotes(mystrdup(LATEXT(1)));
119 if ( RulePrefix[0]!='\0' )
120 {
121 warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored");
122 RulePrefix[0]='\0';
123 }
124 }
125 else warn("additional #parser statement ignored");
126 }
127 zzCONSUME;
128
129 }
130 else {
131 if ( (LA(1)==97) ) {
132 zzmatch(97); zzCONSUME;
133 zzmatch(QuotedTerm);
134 {
135 char *fname;
136 zzantlr_state st; FILE *f; struct zzdlg_state dst;
137 UserTokenDefsFile = mystrdup(LATEXT(1));
138 zzsave_antlr_state(&st);
139 zzsave_dlg_state(&dst);
140 fname = mystrdup(LATEXT(1));
141 f = fopen(StripQuotes(fname), "r");
142 if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));}
143 else {
144 ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE);
145 UserDefdTokens = 1;
146 }
147 zzrestore_antlr_state(&st);
148 zzrestore_dlg_state(&dst);
149 }
150 zzCONSUME;
151
152 }
153 else break; /* MR6 code for exiting loop "for sure" */
154 }
155 }
156 }
157 zzLOOP(zztasp2);
158 }
159 zzEXIT(zztasp2);
160 }
161 }
162 {
163 zzBLOCK(zztasp2);
164 zzMake0;
165 {
166 for (;;) {
167 if ( !((setwd1[LA(1)]&0x2))) break;
168 if ( (LA(1)==Action) ) {
169 zzmatch(Action);
170 {
171 UserAction *ua = newUserAction(LATEXT(1));
172 ua->file = action_file; ua->line = action_line;
173 if ( class_nest_level>0 ) list_add(&class_before_actions, ua);
174 else list_add(&BeforeActions, ua);
175 }
176 zzCONSUME;
177
178 }
179 else {
180 if ( (LA(1)==108) ) {
181 laction();
182 }
183 else {
184 if ( (LA(1)==109) ) {
185 lmember();
186 }
187 else {
188 if ( (LA(1)==110) ) {
189 lprefix();
190 }
191 else {
192 if ( (LA(1)==116) ) {
193 aLexclass();
194 }
195 else {
196 if ( (LA(1)==120) ) {
197 token();
198 }
199 else {
200 if ( (LA(1)==117) ) {
201 error();
202 }
203 else {
204 if ( (LA(1)==118) ) {
205 tclass();
206 }
207 else {
208 if ( (LA(1)==111) ) {
209 aPred();
210 }
211 else {
212 if ( (LA(1)==133) ) {
213 default_exception_handler();
214 }
215 else {
216 if ( (LA(1)==99) ) {
217 class_def();
218 }
219 else {
220 if ( (LA(1)==98) ) {
221 zzmatch(98);
222
223 if ( class_nest_level==0 )
224 warn("missing class definition for trailing '}'");
225 class_nest_level--;
226 zzCONSUME;
227
228 }
229 else break; /* MR6 code for exiting loop "for sure" */
230 }
231 }
232 }
233 }
234 }
235 }
236 }
237 }
238 }
239 }
240 }
241 zzLOOP(zztasp2);
242 }
243 zzEXIT(zztasp2);
244 }
245 }
246 rule();
247 g=zzaArg(zztasp1,3); SynDiag = (Junction *) zzaArg(zztasp1,3 ).left;
248 {
249 zzBLOCK(zztasp2);
250 zzMake0;
251 {
252 for (;;) {
253 if ( !((setwd1[LA(1)]&0x4))) break;
254 if ( (LA(1)==NonTerminal) ) {
255 rule();
256 if ( zzaArg(zztasp2,1 ).left!=NULL ) {
257 g.right = NULL;
258
259 /* MR21a */ /* Avoid use of a malformed graph when CannotContinue */
260 /* MR21a */ /* is already set */
261 /* MR21a */
262 /* MR21a */ if (! (CannotContinue && g.left == NULL)) {
263 /* MR21a */ g = Or(g, zzaArg(zztasp2,1));
264 /* MR21a */ }
265 /* MR21a */ }
266 }
267 else {
268 if ( (LA(1)==116) ) {
269 aLexclass();
270 }
271 else {
272 if ( (LA(1)==120) ) {
273 token();
274 }
275 else {
276 if ( (LA(1)==117) ) {
277 error();
278 }
279 else {
280 if ( (LA(1)==118) ) {
281 tclass();
282 }
283 else {
284 if ( (LA(1)==111) ) {
285 aPred();
286 }
287 else {
288 if ( (LA(1)==99) ) {
289 class_def();
290 }
291 else {
292 if ( (LA(1)==98) ) {
293 zzmatch(98);
294
295 if ( class_nest_level==0 )
296 warn("missing class definition for trailing '}'");
297 class_nest_level--;
298 zzCONSUME;
299
300 }
301 else break; /* MR6 code for exiting loop "for sure" */
302 }
303 }
304 }
305 }
306 }
307 }
308 }
309 zzLOOP(zztasp2);
310 }
311 zzEXIT(zztasp2);
312 }
313 }
314 {
315 zzBLOCK(zztasp2);
316 zzMake0;
317 {
318 for (;;) {
319 if ( !((setwd1[LA(1)]&0x8))) break;
320 if ( (LA(1)==Action) ) {
321 zzmatch(Action);
322 {
323 UserAction *ua = newUserAction(LATEXT(1));
324 ua->file = action_file; ua->line = action_line;
325 if ( class_nest_level>0 ) list_add(&class_after_actions, ua);
326 else list_add(&AfterActions, ua);
327 }
328 zzCONSUME;
329
330 }
331 else {
332 if ( (LA(1)==108) ) {
333 laction();
334 }
335 else {
336 if ( (LA(1)==109) ) {
337 lmember();
338 }
339 else {
340 if ( (LA(1)==110) ) {
341 lprefix();
342 }
343 else {
344 if ( (LA(1)==117) ) {
345 error();
346 }
347 else {
348 if ( (LA(1)==118) ) {
349 tclass();
350 }
351 else {
352 if ( (LA(1)==99) ) {
353 class_def();
354 }
355 else {
356 if ( (LA(1)==111) ) {
357 aPred();
358 }
359 else {
360 if ( (LA(1)==98) ) {
361 zzmatch(98);
362
363 if ( class_nest_level==0 )
364 warn("missing class definition for trailing '}'");
365 class_nest_level--;
366 zzCONSUME;
367
368 }
369 else break; /* MR6 code for exiting loop "for sure" */
370 }
371 }
372 }
373 }
374 }
375 }
376 }
377 }
378 zzLOOP(zztasp2);
379 }
380 zzEXIT(zztasp2);
381 }
382 }
383 zzmatch(Eof); zzCONSUME;
384 zzEXIT(zztasp1);
385 return;
386 fail:
387 zzEXIT(zztasp1);
388 CannotContinue=TRUE;
389 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
390 zzresynch(setwd1, 0x10);
391 }
392 }
393
394 void
395 #ifdef __USE_PROTOS
396 class_def(void)
397 #else
398 class_def()
399 #endif
400 {
401 zzRULE;
402 zzBLOCK(zztasp1);
403 zzMake0;
404 {
405 int go=1; char name[MaxRuleName+1];
406 zzmatch(99); zzCONSUME;
407 {
408 zzBLOCK(zztasp2);
409 zzMake0;
410 {
411 if ( (LA(1)==NonTerminal) ) {
412 zzmatch(NonTerminal);
413 if(go) strncpy(name,LATEXT(1),MaxRuleName);
414 zzCONSUME;
415
416 }
417 else {
418 if ( (LA(1)==TokenTerm) ) {
419 zzmatch(TokenTerm);
420 if(go) strncpy(name,LATEXT(1),MaxRuleName);
421 zzCONSUME;
422
423 }
424 else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
425 }
426 zzEXIT(zztasp2);
427 }
428 }
429
430 if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0
431 && GenCC ) {
432 err("only one grammar class allowed in this release");
433 go = 0;
434 }
435 else strcpy(CurrentClassName, name);
436 if ( !GenCC ) { err("class meta-op used without C++ option"); }
437 {
438 zzBLOCK(zztasp2);
439 zzMake0;
440 {
441 while ( (setwd1[LA(1)]&0x20) ) {
442 zzsetmatch(zzerr2, zzerr3);
443 if (ClassDeclStuff == NULL) {
444 /* MR10 */ ClassDeclStuff=(char *)calloc(MaxClassDeclStuff+1,sizeof(char));
445 /* MR10 */ };
446 /* MR10 */ strncat(ClassDeclStuff," ",MaxClassDeclStuff);
447 /* MR10 */ strncat(ClassDeclStuff,LATEXT(1),MaxClassDeclStuff);
448 /* MR22 */ do {
449 /* MR22 */ if (0 == strcmp(LATEXT(1),"public")) break;
450 /* MR22 */ if (0 == strcmp(LATEXT(1),"private")) break;
451 /* MR22 */ if (0 == strcmp(LATEXT(1),"protected")) break;
452 /* MR22 */ if (0 == strcmp(LATEXT(1),"virtual")) break;
453 /* MR22 */ if (0 == strcmp(LATEXT(1),",")) break;
454 /* MR22 */ if (0 == strcmp(LATEXT(1),":")) break;
455 /* MR22 */ if (BaseClassName != NULL) break;
456 /* MR22 */ BaseClassName=(char *)calloc(strlen(LATEXT(1))+1,sizeof(char));
457 /* MR22 */ require(BaseClassName!=NULL, "rule grammar: cannot allocate base class name");
458 /* MR22 */ strcpy(BaseClassName,LATEXT(1));
459 /* MR22 */ } while (0);
460 /* MR10 */
461 zzCONSUME;
462
463 zzLOOP(zztasp2);
464 }
465 zzEXIT(zztasp2);
466 }
467 }
468 zzmatch(102);
469
470 no_classes_found = 0;
471 if ( class_nest_level>=1 ) {warn("cannot have nested classes");}
472 else class_nest_level++;
473 zzCONSUME;
474
475 zzEXIT(zztasp1);
476 return;
477 fail:
478 zzEXIT(zztasp1);
479 CannotContinue=TRUE;
480 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
481 zzresynch(setwd1, 0x40);
482 }
483 }
484
485 void
486 #ifdef __USE_PROTOS
487 rule(void)
488 #else
489 rule()
490 #endif
491 {
492 zzRULE;
493 zzBLOCK(zztasp1);
494 zzMake0;
495 {
496
497
498 ExceptionGroup *eg;
499 RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e;
500 set toksrefd, rulesrefd;
501 char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL;
502 CurExGroups = NULL;
503 CurElementLabels = NULL;
504 CurAstLabelsInActions = NULL; /* MR27 */
505 /* We want a new element label hash table for each rule */
506 if ( Elabel!=NULL ) killHashTable(Elabel);
507 Elabel = newHashTable();
508 attribsRefdFromAction = empty;
509 zzmatch(NonTerminal);
510 q=NULL;
511 if ( hash_get(Rname, LATEXT(1))!=NULL ) {
512 err(eMsg1("duplicate rule definition: '%s'",LATEXT(1)));
513 CannotContinue=TRUE;
514 }
515 else
516 {
517 q = (RuleEntry *)hash_add(Rname,
518 LATEXT(1),
519 (Entry *)newRuleEntry(LATEXT(1)));
520 CurRule = q->str;
521 }
522 CurRuleNode = q;
523 f = CurFile; l = zzline;
524 NumRules++;
525 zzCONSUME;
526
527 {
528 zzBLOCK(zztasp2);
529 zzMake0;
530 {
531 if ( (LA(1)==103) ) {
532 zzmatch(103);
533 if ( q!=NULL ) q->noAST = TRUE;
534 zzCONSUME;
535
536 }
537 else {
538 if ( (setwd1[LA(1)]&0x80) ) {
539 }
540 else {zzFAIL(1,zzerr4,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
541 }
542 zzEXIT(zztasp2);
543 }
544 }
545 {
546 zzBLOCK(zztasp2);
547 zzMake0;
548 {
549 ;
550 if ( (setwd2[LA(1)]&0x1) ) {
551 {
552 zzBLOCK(zztasp3);
553 zzMake0;
554 {
555 if ( (LA(1)==104) ) {
556 zzmatch(104); zzCONSUME;
557 }
558 else {
559 if ( (LA(1)==PassAction) ) {
560 }
561 else {zzFAIL(1,zzerr5,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
562 }
563 zzEXIT(zztasp3);
564 }
565 }
566 zzmatch(PassAction);
567 pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
568 require(pdecl!=NULL, "rule rule: cannot allocate param decl");
569 strcpy(pdecl, LATEXT(1));
570 CurParmDef = pdecl;
571 zzCONSUME;
572
573 }
574 else {
575 if ( (setwd2[LA(1)]&0x2) ) {
576 }
577 else {zzFAIL(1,zzerr6,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
578 }
579 zzEXIT(zztasp2);
580 }
581 }
582 {
583 zzBLOCK(zztasp2);
584 zzMake0;
585 {
586 if ( (LA(1)==105) ) {
587 zzmatch(105); zzCONSUME;
588 zzmatch(PassAction);
589 ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
590 require(ret!=NULL, "rule rule: cannot allocate ret type");
591 strcpy(ret, LATEXT(1));
592 CurRetDef = ret;
593 zzCONSUME;
594
595 }
596 else {
597 if ( (setwd2[LA(1)]&0x4) ) {
598 }
599 else {zzFAIL(1,zzerr7,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
600 }
601 zzEXIT(zztasp2);
602 }
603 }
604 {
605 zzBLOCK(zztasp2);
606 zzMake0;
607 {
608 if ( (LA(1)==QuotedTerm) ) {
609 zzmatch(QuotedTerm);
610 if ( q!=NULL ) q->egroup=mystrdup(LATEXT(1));
611 zzCONSUME;
612
613 }
614 else {
615 if ( (LA(1)==106) ) {
616 }
617 else {zzFAIL(1,zzerr8,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
618 }
619 zzEXIT(zztasp2);
620 }
621 }
622
623 if ( GenEClasseForRules && q!=NULL ) {
624 e = newECnode;
625 require(e!=NULL, "cannot allocate error class node");
626 if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);}
627 else a = q->egroup;
628 if ( Tnum( a ) == 0 )
629 {
630 e->tok = addTname( a );
631 list_add(&eclasses, (char *)e);
632 if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
633 /* refers to itself */
634 list_add(&(e->elist), mystrdup(q->str));
635 }
636 else {
637 warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a));
638 if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
639 free((char *)e);
640 }
641 }
642 BlkLevel++;
643 if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");
644 /* MR23 */ CurBlockID_array[BlkLevel] = CurBlockID;
645 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
646 zzmatch(106);
647 inAlt=1;
648 zzCONSUME;
649
650 block( &toksrefd, &rulesrefd );
651 r = makeBlk(zzaArg(zztasp1,7),0, NULL /* pFirstSetSymbol */ );
652 CurRuleBlk = (Junction *)r.left;
653 CurRuleBlk->blockid = CurBlockID;
654 CurRuleBlk->jtype = RuleBlk;
655 if ( q!=NULL ) CurRuleBlk->rname = q->str;
656 CurRuleBlk->file = f;
657 CurRuleBlk->line = l;
658 CurRuleBlk->pdecl = pdecl;
659 CurRuleBlk->ret = ret;
660 CurRuleBlk->lock = makelocks();
661 CurRuleBlk->pred_lock = makelocks();
662 CurRuleBlk->tokrefs = toksrefd;
663 CurRuleBlk->rulerefs = rulesrefd;
664 p = newJunction(); /* add EndRule Node */
665 ((Junction *)r.right)->p1 = (Node *)p;
666 r.right = (Node *) p;
667 p->jtype = EndRule;
668 p->lock = makelocks();
669 p->pred_lock = makelocks();
670 CurRuleBlk->end = p;
671 if ( q!=NULL ) q->rulenum = NumRules;
672 zzaArg(zztasp1,7) = r;
673
674 /* MR23 */ CurBlockID_array[BlkLevel] = (-1);
675 /* MR23 */ CurAltNum_array[BlkLevel] = (-1);
676 --BlkLevel;
677 altFixup();leFixup();egFixup();
678 zzmatch(107);
679 inAlt=0;
680 zzCONSUME;
681
682 {
683 zzBLOCK(zztasp2);
684 zzMake0;
685 {
686 if ( (LA(1)==Action) ) {
687 zzmatch(Action);
688 a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
689 require(a!=NULL, "rule rule: cannot allocate error action");
690 strcpy(a, LATEXT(1));
691 CurRuleBlk->erraction = a;
692 zzCONSUME;
693
694 }
695 else {
696 if ( (setwd2[LA(1)]&0x8) ) {
697 }
698 else {zzFAIL(1,zzerr9,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
699 }
700 zzEXIT(zztasp2);
701 }
702 }
703 {
704 zzBLOCK(zztasp2);
705 zzMake0;
706 {
707 while ( (LA(1)==133) ) {
708 eg = exception_group();
709
710 if ( eg!=NULL ) {
711 list_add(&CurExGroups, (void *)eg);
712 if (eg->label == NULL || *eg->label=='\0' ) q->has_rule_exception = 1;
713 }
714 zzLOOP(zztasp2);
715 }
716 zzEXIT(zztasp2);
717 }
718 }
719 if ( q==NULL ) zzaArg(zztasp1,0 ).left = NULL; else zzaArg(zztasp1,0) = zzaArg(zztasp1,7);
720 CurRuleBlk->exceptions = CurExGroups;
721 CurRuleBlk->el_labels = CurElementLabels;
722 CurRuleNode->ast_labels_in_actions = CurAstLabelsInActions;
723 CurRuleNode = NULL;
724 zzEXIT(zztasp1);
725 return;
726 fail:
727 zzEXIT(zztasp1);
728 CannotContinue=TRUE;
729 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
730 zzresynch(setwd2, 0x10);
731 }
732 }
733
734 void
735 #ifdef __USE_PROTOS
736 laction(void)
737 #else
738 laction()
739 #endif
740 {
741 zzRULE;
742 zzBLOCK(zztasp1);
743 zzMake0;
744 {
745 char *a;
746 zzmatch(108); zzCONSUME;
747 zzmatch(Action);
748
749 a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
750 require(a!=NULL, "rule laction: cannot allocate action");
751 strcpy(a, LATEXT(1));
752 list_add(&LexActions, a);
753 zzCONSUME;
754
755 zzEXIT(zztasp1);
756 return;
757 fail:
758 zzEXIT(zztasp1);
759 CannotContinue=TRUE;
760 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
761 zzresynch(setwd2, 0x20);
762 }
763 }
764
765 void
766 #ifdef __USE_PROTOS
767 lmember(void)
768 #else
769 lmember()
770 #endif
771 {
772 zzRULE;
773 zzBLOCK(zztasp1);
774 zzMake0;
775 {
776 char *a;
777 zzmatch(109); zzCONSUME;
778 zzmatch(Action);
779
780 /* MR1 */ if (! GenCC) {
781 /* MR1 */ err("Use #lexmember only in C++ mode (to insert code in DLG class header");
782 /* MR1 */ } else {
783 /* MR1 */ a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
784 /* MR1 */ require(a!=NULL, "rule lmember: cannot allocate action");
785 /* MR1 */ strcpy(a, LATEXT(1));
786 /* MR1 */ list_add(&LexMemberActions, a);
787 /* MR1 */ };
788 /* MR1 */
789 zzCONSUME;
790
791 zzEXIT(zztasp1);
792 return;
793 fail:
794 zzEXIT(zztasp1);
795 CannotContinue=TRUE;
796 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
797 zzresynch(setwd2, 0x40);
798 }
799 }
800
801 void
802 #ifdef __USE_PROTOS
803 lprefix(void)
804 #else
805 lprefix()
806 #endif
807 {
808 zzRULE;
809 zzBLOCK(zztasp1);
810 zzMake0;
811 {
812 char *a;
813 zzmatch(110); zzCONSUME;
814 zzmatch(Action);
815
816 /* MR1 */ if (! GenCC) {
817 /* MR1 */ err("Use #lexprefix only in C++ mode (to insert code in DLG class header");
818 /* MR1 */ } else {
819 /* MR1 */ a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
820 /* MR1 */ require(a!=NULL, "rule lprefix: cannot allocate action");
821 /* MR1 */ strcpy(a, LATEXT(1));
822 /* MR1 */ list_add(&LexPrefixActions, a);
823 /* MR1 */ };
824 /* MR1 */
825 zzCONSUME;
826
827 zzEXIT(zztasp1);
828 return;
829 fail:
830 zzEXIT(zztasp1);
831 CannotContinue=TRUE;
832 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
833 zzresynch(setwd2, 0x80);
834 }
835 }
836
837 void
838 #ifdef __USE_PROTOS
839 aPred(void)
840 #else
841 aPred()
842 #endif
843 {
844 zzRULE;
845 zzBLOCK(zztasp1);
846 zzMake0;
847 {
848 PredEntry *predEntry=NULL;
849 char *name=NULL;
850 Predicate *predExpr=NULL;
851 char *predLiteral=NULL;
852 int save_file;
853 int save_line;
854 int predExprPresent=0;
855 zzmatch(111);
856
857 MR_usingPredNames=1; /* will need to use -mrhoist version of genPredTree */
858 zzCONSUME;
859
860 zzmatch(TokenTerm);
861 name=mystrdup(LATEXT(1));
862 zzCONSUME;
863
864
865 /* don't free - referenced in predicates */
866
867 CurPredName=(char *)calloc(1,strlen(name) + 10);
868 strcat(CurPredName,"#pred ");
869 strcat(CurPredName,name);
870
871 predEntry=(PredEntry *) hash_get(Pname,name);
872 if (predEntry != NULL) {
873 warnFL(eMsg1("#pred %s previously defined - ignored",name),
874 FileStr[action_file],action_line);
875 name=NULL;
876 };
877 {
878 zzBLOCK(zztasp2);
879 zzMake0;
880 {
881 if ( (LA(1)==Pred) ) {
882 zzmatch(Pred);
883 predLiteral=mystrdup(LATEXT(1));
884 save_line=action_line;
885 save_file=action_file;
886 zzCONSUME;
887
888 {
889 zzBLOCK(zztasp3);
890 zzMake0;
891 {
892 if ( (setwd3[LA(1)]&0x1) ) {
893 predExpr = predOrExpr();
894
895 predExprPresent=1;
896 }
897 else {
898 if ( (setwd3[LA(1)]&0x2) ) {
899 }
900 else {zzFAIL(1,zzerr10,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
901 }
902 zzEXIT(zztasp3);
903 }
904 }
905 if (predLiteral != NULL && name != NULL) {
906
907 /*
908 * predExpr may be NULL due to syntax errors
909 * or simply omitted by the user
910 */
911
912 predEntry=newPredEntry(name);
913 predEntry->file=save_file;
914 predEntry->line=save_line;
915 predExpr=MR_predFlatten(predExpr);
916 predEntry->predLiteral=predLiteral;
917 if (! predExprPresent || predExpr == NULL) {
918 predExpr=new_pred();
919 predExpr->expr=predLiteral;
920 predExpr->source=newActionNode();
921 predExpr->source->action=predExpr->expr;
922 predExpr->source->rname=CurPredName;
923 predExpr->source->line=action_line;
924 predExpr->source->file=action_file;
925 predExpr->source->is_predicate=1;
926 predExpr->k=predicateLookaheadDepth(predExpr->source);
927 };
928 predEntry->pred=predExpr;
929 hash_add(Pname,name,(Entry *)predEntry);
930 predExpr=NULL;
931 };
932 predicate_free(predExpr);
933 }
934 else {
935 if ( (setwd3[LA(1)]&0x4) ) {
936 save_line=zzline; save_file=CurFile;
937 predExpr = predOrExpr();
938
939 if (predExpr != NULL && name != NULL) {
940 predEntry=newPredEntry(name);
941 predEntry->file=CurFile;
942 predEntry->line=zzline;
943 predExpr=MR_predFlatten(predExpr);
944 predEntry->pred=predExpr;
945 hash_add(Pname,name,(Entry *)predEntry);
946 predExpr=NULL;
947 };
948 predicate_free(predExpr);
949 }
950 else {zzFAIL(1,zzerr11,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
951 }
952 zzEXIT(zztasp2);
953 }
954 }
955 {
956 zzBLOCK(zztasp2);
957 zzMake0;
958 {
959 if ( (LA(1)==107) ) {
960 zzmatch(107); zzCONSUME;
961 }
962 else {
963 if ( (setwd3[LA(1)]&0x8) ) {
964 }
965 else {zzFAIL(1,zzerr12,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
966 }
967 zzEXIT(zztasp2);
968 }
969 }
970 zzEXIT(zztasp1);
971 return;
972 fail:
973 zzEXIT(zztasp1);
974 predicate_free(predExpr);
975 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
976 zzresynch(setwd3, 0x10);
977 }
978 }
979
980 Predicate *
981 #ifdef __USE_PROTOS
982 predOrExpr(void)
983 #else
984 predOrExpr()
985 #endif
986 {
987 Predicate * _retv;
988 zzRULE;
989 zzBLOCK(zztasp1);
990 PCCTS_PURIFY(_retv,sizeof(Predicate * ))
991 zzMake0;
992 {
993 Predicate *ORnode;
994 Predicate *predExpr;
995 Predicate **tail=NULL;
996 predExpr = predAndExpr();
997
998
999 ORnode=new_pred();
1000 ORnode->expr=PRED_OR_LIST;
1001 if (predExpr != NULL) {
1002 ORnode->down=predExpr;
1003 tail=&predExpr->right;
1004 };
1005 {
1006 zzBLOCK(zztasp2);
1007 zzMake0;
1008 {
1009 while ( (LA(1)==112) ) {
1010 zzmatch(112); zzCONSUME;
1011 predExpr = predAndExpr();
1012
1013
1014 if (predExpr != NULL) {
1015 *tail=predExpr;
1016 tail=&predExpr->right;
1017 };
1018 zzLOOP(zztasp2);
1019 }
1020 zzEXIT(zztasp2);
1021 }
1022 }
1023
1024 _retv=ORnode;
1025 ORnode=NULL;
1026 zzEXIT(zztasp1);
1027 return _retv;
1028 fail:
1029 zzEXIT(zztasp1);
1030 predicate_free(ORnode);
1031 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1032 zzresynch(setwd3, 0x20);
1033 return _retv;
1034 }
1035 }
1036
1037 Predicate *
1038 #ifdef __USE_PROTOS
1039 predAndExpr(void)
1040 #else
1041 predAndExpr()
1042 #endif
1043 {
1044 Predicate * _retv;
1045 zzRULE;
1046 zzBLOCK(zztasp1);
1047 PCCTS_PURIFY(_retv,sizeof(Predicate * ))
1048 zzMake0;
1049 {
1050 Predicate *ANDnode;
1051 Predicate *predExpr;
1052 Predicate **tail=NULL;
1053 predExpr = predPrimary();
1054
1055
1056 ANDnode=new_pred();
1057 ANDnode->expr=PRED_AND_LIST;
1058 if (predExpr != NULL) {
1059 ANDnode->down=predExpr;
1060 tail=&predExpr->right;
1061 };
1062 {
1063 zzBLOCK(zztasp2);
1064 zzMake0;
1065 {
1066 while ( (LA(1)==113) ) {
1067 zzmatch(113); zzCONSUME;
1068 predExpr = predPrimary();
1069
1070
1071 if (predExpr != NULL) {
1072 *tail=predExpr;
1073 tail=&predExpr->right;
1074 };
1075 zzLOOP(zztasp2);
1076 }
1077 zzEXIT(zztasp2);
1078 }
1079 }
1080
1081 _retv=ANDnode;
1082 ANDnode=NULL;
1083 zzEXIT(zztasp1);
1084 return _retv;
1085 fail:
1086 zzEXIT(zztasp1);
1087 predicate_free(ANDnode);
1088 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1089 zzresynch(setwd3, 0x40);
1090 return _retv;
1091 }
1092 }
1093
1094 Predicate *
1095 #ifdef __USE_PROTOS
1096 predPrimary(void)
1097 #else
1098 predPrimary()
1099 #endif
1100 {
1101 Predicate * _retv;
1102 zzRULE;
1103 zzBLOCK(zztasp1);
1104 PCCTS_PURIFY(_retv,sizeof(Predicate * ))
1105 zzMake0;
1106 {
1107
1108 char *name=NULL;
1109 PredEntry *predEntry=NULL;
1110 Predicate *predExpr=NULL;
1111 if ( (LA(1)==TokenTerm) ) {
1112 zzmatch(TokenTerm);
1113 name=mystrdup(LATEXT(1));
1114 zzCONSUME;
1115
1116
1117 predEntry=(PredEntry *) hash_get(Pname,name);
1118 if (predEntry == NULL) {
1119 warnFL(eMsg1("no previously defined #pred with name \"%s\"",name),
1120 FileStr[CurFile],zzline);
1121 name=NULL;
1122 _retv=NULL;
1123 } else {
1124 predExpr=predicate_dup(predEntry->pred);
1125 predExpr->predEntry=predEntry;
1126 _retv=predExpr;
1127 };
1128 }
1129 else {
1130 if ( (LA(1)==114) ) {
1131 zzmatch(114); zzCONSUME;
1132 predExpr = predOrExpr();
1133
1134 zzmatch(115);
1135
1136 _retv=predExpr;
1137 zzCONSUME;
1138
1139 }
1140 else {
1141 if ( (LA(1)==103) ) {
1142 zzmatch(103); zzCONSUME;
1143 predExpr = predPrimary();
1144
1145
1146 predExpr->inverted=!predExpr->inverted;
1147 _retv=predExpr;
1148 }
1149 else {zzFAIL(1,zzerr13,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1150 }
1151 }
1152 zzEXIT(zztasp1);
1153 return _retv;
1154 fail:
1155 zzEXIT(zztasp1);
1156
1157 predicate_free(predExpr);
1158 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1159 zzresynch(setwd3, 0x80);
1160 return _retv;
1161 }
1162 }
1163
1164 void
1165 #ifdef __USE_PROTOS
1166 aLexclass(void)
1167 #else
1168 aLexclass()
1169 #endif
1170 {
1171 zzRULE;
1172 zzBLOCK(zztasp1);
1173 zzMake0;
1174 {
1175 zzmatch(116); zzCONSUME;
1176 zzmatch(TokenTerm);
1177 lexclass(mystrdup(LATEXT(1)));
1178 zzCONSUME;
1179
1180 zzEXIT(zztasp1);
1181 return;
1182 fail:
1183 zzEXIT(zztasp1);
1184 CannotContinue=TRUE;
1185 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1186 zzresynch(setwd4, 0x1);
1187 }
1188 }
1189
1190 void
1191 #ifdef __USE_PROTOS
1192 error(void)
1193 #else
1194 error()
1195 #endif
1196 {
1197 zzRULE;
1198 zzBLOCK(zztasp1);
1199 zzMake0;
1200 {
1201 char *t=NULL; ECnode *e; int go=1; TermEntry *p;
1202 zzmatch(117); zzCONSUME;
1203 {
1204 zzBLOCK(zztasp2);
1205 zzMake0;
1206 {
1207 ;
1208 if ( (LA(1)==TokenTerm) ) {
1209 zzmatch(TokenTerm);
1210 t=mystrdup(LATEXT(1));
1211 zzCONSUME;
1212
1213 }
1214 else {
1215 if ( (LA(1)==QuotedTerm) ) {
1216 zzmatch(QuotedTerm);
1217 t=mystrdup(LATEXT(1));
1218 zzCONSUME;
1219
1220 }
1221 else {zzFAIL(1,zzerr14,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1222 }
1223 zzEXIT(zztasp2);
1224 }
1225 }
1226 e = newECnode;
1227 require(e!=NULL, "cannot allocate error class node");
1228 e->lexclass = CurrentLexClass;
1229 if ( Tnum( (t=StripQuotes(t)) ) == 0 )
1230 {
1231 if ( hash_get(Texpr, t) != NULL )
1232 warn(eMsg1("errclass name conflicts with regular expression '%s'",t));
1233 e->tok = addTname( t );
1234 set_orel(e->tok, &imag_tokens);
1235 require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
1236 "hash table mechanism is broken");
1237 p->classname = 1; /* entry is errclass name, not token */
1238 list_add(&eclasses, (char *)e);
1239 }
1240 else
1241 {
1242 warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t));
1243 free( (char *)e );
1244 go=0;
1245 }
1246 zzmatch(102); zzCONSUME;
1247 {
1248 zzBLOCK(zztasp2);
1249 zzMake0;
1250 {
1251 if ( (LA(1)==NonTerminal) ) {
1252 zzmatch(NonTerminal);
1253 if ( go ) t=mystrdup(LATEXT(1));
1254 zzCONSUME;
1255
1256 }
1257 else {
1258 if ( (LA(1)==TokenTerm) ) {
1259 zzmatch(TokenTerm);
1260 if ( go ) t=mystrdup(LATEXT(1));
1261 zzCONSUME;
1262
1263 }
1264 else {
1265 if ( (LA(1)==QuotedTerm) ) {
1266 zzmatch(QuotedTerm);
1267 if ( go ) t=mystrdup(LATEXT(1));
1268 zzCONSUME;
1269
1270 }
1271 else {zzFAIL(1,zzerr15,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1272 }
1273 }
1274 zzEXIT(zztasp2);
1275 }
1276 }
1277 if ( go ) list_add(&(e->elist), t);
1278 {
1279 zzBLOCK(zztasp2);
1280 zzMake0;
1281 {
1282 while ( (setwd4[LA(1)]&0x2) ) {
1283 {
1284 zzBLOCK(zztasp3);
1285 zzMake0;
1286 {
1287 if ( (LA(1)==NonTerminal) ) {
1288 zzmatch(NonTerminal);
1289 if ( go ) t=mystrdup(LATEXT(1));
1290 zzCONSUME;
1291
1292 }
1293 else {
1294 if ( (LA(1)==TokenTerm) ) {
1295 zzmatch(TokenTerm);
1296 if ( go ) t=mystrdup(LATEXT(1));
1297 zzCONSUME;
1298
1299 }
1300 else {
1301 if ( (LA(1)==QuotedTerm) ) {
1302 zzmatch(QuotedTerm);
1303 if ( go ) t=mystrdup(LATEXT(1));
1304 zzCONSUME;
1305
1306 }
1307 else {zzFAIL(1,zzerr16,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1308 }
1309 }
1310 zzEXIT(zztasp3);
1311 }
1312 }
1313 if ( go ) list_add(&(e->elist), t);
1314 zzLOOP(zztasp2);
1315 }
1316 zzEXIT(zztasp2);
1317 }
1318 }
1319 zzmatch(98); zzCONSUME;
1320 zzEXIT(zztasp1);
1321 return;
1322 fail:
1323 zzEXIT(zztasp1);
1324 CannotContinue=TRUE;
1325 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1326 zzresynch(setwd4, 0x4);
1327 }
1328 }
1329
1330 void
1331 #ifdef __USE_PROTOS
1332 tclass(void)
1333 #else
1334 tclass()
1335 #endif
1336 {
1337 zzRULE;
1338 zzBLOCK(zztasp1);
1339 zzMake0;
1340 {
1341 char *t=NULL; TCnode *e; int go=1,tok,totok; TermEntry *p, *term, *toterm;
1342 char *akaString=NULL; int save_file; int save_line;
1343 char *totext=NULL;
1344 zzmatch(118); zzCONSUME;
1345 zzmatch(TokenTerm);
1346 t=mystrdup(LATEXT(1));
1347 zzCONSUME;
1348
1349 e = newTCnode;
1350 require(e!=NULL, "cannot allocate token class node");
1351 e->lexclass = CurrentLexClass;
1352 if ( Tnum( t ) == 0 )
1353 {
1354 e->tok = addTname( t );
1355 set_orel(e->tok, &imag_tokens);
1356 set_orel(e->tok, &tokclasses);
1357 require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
1358 "hash table mechanism is broken");
1359 p->classname = 1; /* entry is class name, not token */
1360 p->tclass = e; /* save ptr to this tclass def */
1361 list_add(&tclasses, (char *)e);
1362 }
1363 else
1364 {
1365 warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t));
1366 free( (char *)e );
1367 go=0;
1368 }
1369 {
1370 zzBLOCK(zztasp2);
1371 zzMake0;
1372 {
1373 if ( (LA(1)==114) ) {
1374 zzmatch(114); zzCONSUME;
1375 zzmatch(QuotedTerm);
1376 akaString=mystrdup(StripQuotes(LATEXT(1)));
1377 /* MR11 */ save_file=CurFile;save_line=zzline;
1378 /* MR23 */
1379 zzCONSUME;
1380
1381 zzmatch(115); zzCONSUME;
1382 }
1383 else {
1384 if ( (LA(1)==102) ) {
1385 }
1386 else {zzFAIL(1,zzerr17,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1387 }
1388 zzEXIT(zztasp2);
1389 }
1390 }
1391
1392 /* MR23 */ if (p!= NULL && akaString != NULL) {
1393 /* MR23 */ if (p->akaString != NULL) {
1394 /* MR23 */ if (strcmp(p->akaString,akaString) != 0) {
1395 /* MR23 */ warnFL(eMsg2("this #tokclass statment conflicts with a previous #tokclass %s(\"%s\") statement",
1396 /* MR23 */ t,p->akaString),
1397 /* MR23 */ FileStr[save_file],save_line);
1398 /* MR23 */ };
1399 /* MR23 */ } else {
1400 /* MR23 */ p->akaString=akaString;
1401 /* MR23 */ };
1402 /* MR23 */ };
1403 /* MR23 */
1404 zzmatch(102); zzCONSUME;
1405 {
1406 zzBLOCK(zztasp2);
1407 int zzcnt=1;
1408 zzMake0;
1409 {
1410 do {
1411 {
1412 zzBLOCK(zztasp3);
1413 zzMake0;
1414 {
1415 if ( (LA(1)==TokenTerm) ) {
1416 zzmatch(TokenTerm);
1417 if ( go ) {
1418 term = (TermEntry *) hash_get(Tname, LATEXT(1));
1419 if ( term==NULL && UserDefdTokens ) {
1420 err("implicit token definition not allowed with #tokdefs");
1421 go = 0;
1422 }
1423 else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));}
1424 }
1425 zzCONSUME;
1426
1427 {
1428 zzBLOCK(zztasp4);
1429 zzMake0;
1430 {
1431 if ( (LA(1)==119) ) {
1432 zzmatch(119); zzCONSUME;
1433 zzmatch(TokenTerm);
1434 if ( go ) {
1435 toterm = (TermEntry *) hash_get(Tname, LATEXT(1));
1436 if ( toterm==NULL && UserDefdTokens ) {
1437 err("implicit token definition not allowed with #tokdefs");
1438 go = 0;
1439 } else {
1440 totext=mystrdup(LATEXT(1)); totok=addTname(LATEXT(1));
1441 }
1442 }
1443 zzCONSUME;
1444
1445 }
1446 else {
1447 if ( (setwd4[LA(1)]&0x8) ) {
1448 }
1449 else {zzFAIL(1,zzerr18,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1450 }
1451 zzEXIT(zztasp4);
1452 }
1453 }
1454 }
1455 else {
1456 if ( (LA(1)==QuotedTerm) ) {
1457 zzmatch(QuotedTerm);
1458 if ( go ) {
1459 term = (TermEntry *) hash_get(Texpr, LATEXT(1));
1460 if ( term==NULL && UserDefdTokens ) {
1461 err("implicit token definition not allowed with #tokdefs");
1462 go = 0;
1463 }
1464 else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));}
1465 }
1466 zzCONSUME;
1467
1468 }
1469 else {zzFAIL(1,zzerr19,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1470 }
1471 zzEXIT(zztasp3);
1472 }
1473 }
1474 if ( go ) {
1475 if (totext == NULL) {
1476 list_add(&(e->tlist), t);
1477 } else {
1478 list_add(&(e->tlist),"..");
1479 list_add(&(e->tlist),t);
1480 list_add(&(e->tlist),totext);
1481 }
1482 totext=NULL;
1483 }
1484 zzLOOP(zztasp2);
1485 } while ( (setwd4[LA(1)]&0x10) );
1486 zzEXIT(zztasp2);
1487 }
1488 }
1489 zzmatch(98); zzCONSUME;
1490 zzEXIT(zztasp1);
1491 return;
1492 fail:
1493 zzEXIT(zztasp1);
1494 CannotContinue=TRUE;
1495 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1496 zzresynch(setwd4, 0x20);
1497 }
1498 }
1499
1500 void
1501 #ifdef __USE_PROTOS
1502 token(void)
1503 #else
1504 token()
1505 #endif
1506 {
1507 zzRULE;
1508 zzBLOCK(zztasp1);
1509 zzMake0;
1510 {
1511 char *t=NULL, *e=NULL, *a=NULL; int tnum=0;
1512 char *akaString=NULL; TermEntry *te;int save_file=0,save_line=0;
1513 zzmatch(120);
1514 tokenActionActive=1;
1515 zzCONSUME;
1516
1517 {
1518 zzBLOCK(zztasp2);
1519 zzMake0;
1520 {
1521 if ( (LA(1)==TokenTerm) ) {
1522 zzmatch(TokenTerm);
1523 t=mystrdup(LATEXT(1));
1524 zzCONSUME;
1525
1526 {
1527 zzBLOCK(zztasp3);
1528 zzMake0;
1529 {
1530 if ( (LA(1)==114) ) {
1531 zzmatch(114); zzCONSUME;
1532 zzmatch(QuotedTerm);
1533 akaString=mystrdup(StripQuotes(LATEXT(1)));
1534 /* MR11 */ save_file=CurFile;save_line=zzline;
1535 /* MR11 */
1536 zzCONSUME;
1537
1538 zzmatch(115); zzCONSUME;
1539 }
1540 else {
1541 if ( (setwd4[LA(1)]&0x40) ) {
1542 }
1543 else {zzFAIL(1,zzerr20,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1544 }
1545 zzEXIT(zztasp3);
1546 }
1547 }
1548 {
1549 zzBLOCK(zztasp3);
1550 zzMake0;
1551 {
1552 if ( (LA(1)==121) ) {
1553 zzmatch(121); zzCONSUME;
1554 zzmatch(122);
1555 tnum = atoi(LATEXT(1));
1556 zzCONSUME;
1557
1558 }
1559 else {
1560 if ( (setwd4[LA(1)]&0x80) ) {
1561 }
1562 else {zzFAIL(1,zzerr21,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1563 }
1564 zzEXIT(zztasp3);
1565 }
1566 }
1567 }
1568 else {
1569 if ( (setwd5[LA(1)]&0x1) ) {
1570 }
1571 else {zzFAIL(1,zzerr22,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1572 }
1573 zzEXIT(zztasp2);
1574 }
1575 }
1576 {
1577 zzBLOCK(zztasp2);
1578 zzMake0;
1579 {
1580 if ( (LA(1)==QuotedTerm) ) {
1581 zzmatch(QuotedTerm);
1582 e=mystrdup(LATEXT(1));
1583 zzCONSUME;
1584
1585 }
1586 else {
1587 if ( (setwd5[LA(1)]&0x2) ) {
1588 }
1589 else {zzFAIL(1,zzerr23,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1590 }
1591 zzEXIT(zztasp2);
1592 }
1593 }
1594 {
1595 zzBLOCK(zztasp2);
1596 zzMake0;
1597 {
1598 if ( (LA(1)==Action) ) {
1599 zzmatch(Action);
1600
1601 a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
1602 require(a!=NULL, "rule token: cannot allocate action");
1603 strcpy(a, LATEXT(1));
1604 zzCONSUME;
1605
1606 }
1607 else {
1608 if ( (setwd5[LA(1)]&0x4) ) {
1609 }
1610 else {zzFAIL(1,zzerr24,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1611 }
1612 zzEXIT(zztasp2);
1613 }
1614 }
1615 {
1616 zzBLOCK(zztasp2);
1617 zzMake0;
1618 {
1619 if ( (LA(1)==107) ) {
1620 zzmatch(107); zzCONSUME;
1621 }
1622 else {
1623 if ( (setwd5[LA(1)]&0x8) ) {
1624 }
1625 else {zzFAIL(1,zzerr25,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1626 }
1627 zzEXIT(zztasp2);
1628 }
1629 }
1630 chkToken(t, e, a, tnum);
1631 if (t != NULL) {
1632 te=(TermEntry *)hash_get(Tname,t);
1633 if (te != NULL && akaString != NULL) {
1634 if (te->akaString != NULL) {
1635 if (strcmp(te->akaString,akaString) != 0) {
1636 warnFL(eMsg2("this #token statment conflicts with a previous #token %s(\"%s\") statement",
1637 t,te->akaString),
1638 FileStr[save_file],save_line);
1639 };
1640 } else {
1641 te->akaString=akaString;
1642 };
1643 };
1644 };
1645 zzEXIT(zztasp1);
1646 return;
1647 fail:
1648 zzEXIT(zztasp1);
1649 CannotContinue=TRUE;
1650 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1651 zzresynch(setwd5, 0x10);
1652 }
1653 }
1654
1655 void
1656 #ifdef __USE_PROTOS
1657 block(set * toksrefd,set * rulesrefd)
1658 #else
1659 block(toksrefd,rulesrefd)
1660 set *toksrefd;
1661 set *rulesrefd ;
1662 #endif
1663 {
1664 zzRULE;
1665 zzBLOCK(zztasp1);
1666 zzMake0;
1667 {
1668
1669 Graph g, b;
1670 set saveblah;
1671 int saveinalt = inAlt;
1672 ExceptionGroup *eg;
1673 * toksrefd = empty;
1674 * rulesrefd = empty;
1675 set_clr(AST_nodes_refd_in_actions);
1676 CurBlockID++;
1677 /* MR23 */ CurBlockID_array[BlkLevel] = CurBlockID;
1678 CurAltNum = 1;
1679 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
1680 saveblah = attribsRefdFromAction;
1681 attribsRefdFromAction = empty;
1682 alt( toksrefd,rulesrefd );
1683 b = g = zzaArg(zztasp1,1);
1684
1685 if ( ((Junction *)g.left)->p1->ntype == nAction )
1686 {
1687 ActionNode *actionNode=(ActionNode *)
1688 ( ( (Junction *)g.left) ->p1);
1689 if (!actionNode->is_predicate )
1690 {
1691 actionNode->init_action = TRUE;
1692 /* MR12c */ if (actionNode->noHoist) {
1693 /* MR12c */ errFL("<<nohoist>> appears as init-action - use <<>> <<nohoist>>",
1694 /* MR12c */ FileStr[actionNode->file],actionNode->line);
1695 /* MR12c */ };
1696 }
1697 }
1698 ((Junction *)g.left)->blockid = CurBlockID;
1699 {
1700 zzBLOCK(zztasp2);
1701 zzMake0;
1702 {
1703 while ( (LA(1)==133) ) {
1704 eg = exception_group();
1705
1706
1707 if ( eg!=NULL ) {
1708 /* MR7 ***** eg->altID = makeAltID(CurBlockID,CurAltNum); *****/
1709 /* MR7 ***** CurAltStart->exception_label = eg->altID; *****/
1710 list_add(&CurExGroups, (void *)eg);
1711 }
1712 zzLOOP(zztasp2);
1713 }
1714 zzEXIT(zztasp2);
1715 }
1716 }
1717 CurAltNum++;
1718 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
1719 {
1720 zzBLOCK(zztasp2);
1721 zzMake0;
1722 {
1723 while ( (LA(1)==123) ) {
1724 zzmatch(123);
1725 inAlt=1;
1726 zzCONSUME;
1727
1728 alt( toksrefd,rulesrefd );
1729 g = Or(g, zzaArg(zztasp2,2));
1730
1731 ((Junction *)g.left)->blockid = CurBlockID;
1732 {
1733 zzBLOCK(zztasp3);
1734 zzMake0;
1735 {
1736 while ( (LA(1)==133) ) {
1737 eg = exception_group();
1738
1739
1740 if ( eg!=NULL ) {
1741 /* MR7 ***** eg->altID = makeAltID(CurBlockID,CurAltNum); *****/
1742 /* MR7 ***** CurAltStart->exception_label = eg->altID; *****/
1743 list_add(&CurExGroups, (void *)eg);
1744 }
1745 zzLOOP(zztasp3);
1746 }
1747 zzEXIT(zztasp3);
1748 }
1749 }
1750 CurAltNum++;
1751 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
1752 zzLOOP(zztasp2);
1753 }
1754 zzEXIT(zztasp2);
1755 }
1756 }
1757 zzaArg(zztasp1,0) = b;
1758 attribsRefdFromAction = saveblah; inAlt = saveinalt;
1759 zzEXIT(zztasp1);
1760 return;
1761 fail:
1762 zzEXIT(zztasp1);
1763 CannotContinue=TRUE;
1764 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1765 zzresynch(setwd5, 0x20);
1766 }
1767 }
1768
1769 void
1770 #ifdef __USE_PROTOS
1771 alt(set * toksrefd,set * rulesrefd)
1772 #else
1773 alt(toksrefd,rulesrefd)
1774 set *toksrefd;
1775 set *rulesrefd ;
1776 #endif
1777 {
1778 zzRULE;
1779 zzBLOCK(zztasp1);
1780 zzMake0;
1781 {
1782 int n=0; Graph g; int e_num=0, old_not=0; Node *node; set elems, dif;
1783 int first_on_line = 1, use_def_MT_handler = 0;
1784 g.left=NULL; g.right=NULL;
1785
1786 CurAltStart = NULL;
1787 elems = empty;
1788 inAlt = 1;
1789 {
1790 zzBLOCK(zztasp2);
1791 zzMake0;
1792 {
1793 if ( (LA(1)==88) ) {
1794 zzmatch(88);
1795 use_def_MT_handler = 1;
1796 zzCONSUME;
1797
1798 }
1799 else {
1800 if ( (setwd5[LA(1)]&0x40) ) {
1801 }
1802 else {zzFAIL(1,zzerr26,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1803 }
1804 zzEXIT(zztasp2);
1805 }
1806 }
1807 {
1808 zzBLOCK(zztasp2);
1809 zzMake0;
1810 {
1811 ;
1812 while ( (setwd5[LA(1)]&0x80) ) {
1813 {
1814 zzBLOCK(zztasp3);
1815 zzMake0;
1816 {
1817 old_not=0;
1818 if ( (LA(1)==124) ) {
1819 zzmatch(124);
1820 old_not=1;
1821 zzCONSUME;
1822
1823 }
1824 else {
1825 if ( (setwd6[LA(1)]&0x1) ) {
1826 }
1827 else {zzFAIL(1,zzerr27,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1828 }
1829 zzEXIT(zztasp3);
1830 }
1831 }
1832 node = element( old_not, first_on_line, use_def_MT_handler );
1833
1834 if ( node!=NULL && node->ntype!=nAction ) first_on_line = 0;
1835
1836 if ( zzaArg(zztasp2,2 ).left!=NULL ) {
1837 g = Cat(g, zzaArg(zztasp2,2));
1838 n++;
1839 if ( node!=NULL ) {
1840 if ( node->ntype!=nAction ) e_num++;
1841 /* record record number of all rule and token refs */
1842 if ( node->ntype==nToken ) {
1843 TokNode *tk = (TokNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;
1844 tk->elnum = e_num;
1845 set_orel(e_num, &elems);
1846 }
1847 else if ( node->ntype==nRuleRef ) {
1848 RuleRefNode *rn = (RuleRefNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;
1849 rn->elnum = e_num;
1850 set_orel(e_num, rulesrefd);
1851 }
1852 }
1853 }
1854 zzLOOP(zztasp2);
1855 }
1856 zzEXIT(zztasp2);
1857 }
1858 }
1859 if ( n == 0 ) g = emptyAlt();
1860 zzaArg(zztasp1,0) = g;
1861 /* We want to reduce number of LT(i) calls and the number of
1862 * local attribute variables in C++ mode (for moment, later we'll
1863 * do for C also). However, if trees are being built, they
1864 * require most of the attrib variables to create the tree nodes
1865 * with; therefore, we gen a token ptr for each token ref in C++
1866 */
1867 if ( GenCC && !GenAST )
1868 {
1869 /* This now free's the temp set -ATG 5/6/95 */
1870 set temp;
1871 temp = set_and(elems, attribsRefdFromAction);
1872 set_orin( toksrefd, temp);
1873 set_free(temp);
1874 }
1875 else set_orin( toksrefd, elems);
1876 if ( GenCC ) {
1877 dif = set_dif(attribsRefdFromAction, elems);
1878 if ( set_deg(dif)>0 )
1879 err("one or more $i in action(s) refer to non-token elements");
1880 set_free(dif);
1881 }
1882 set_free(elems);
1883 set_free(attribsRefdFromAction);
1884 inAlt = 0;
1885 zzEXIT(zztasp1);
1886 return;
1887 fail:
1888 zzEXIT(zztasp1);
1889 CannotContinue=TRUE;
1890 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1891 zzresynch(setwd6, 0x2);
1892 }
1893 }
1894
1895 LabelEntry *
1896 #ifdef __USE_PROTOS
1897 element_label(void)
1898 #else
1899 element_label()
1900 #endif
1901 {
1902 LabelEntry * _retv;
1903 zzRULE;
1904 zzBLOCK(zztasp1);
1905 PCCTS_PURIFY(_retv,sizeof(LabelEntry * ))
1906 zzMake0;
1907 {
1908 TermEntry *t=NULL; LabelEntry *l=NULL; RuleEntry *r=NULL; char *lab;
1909 zzmatch(LABEL);
1910 lab = mystrdup(LATEXT(1));
1911 zzCONSUME;
1912
1913
1914 UsedNewStyleLabel = 1;
1915 if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i");
1916 t = (TermEntry *) hash_get(Tname, lab);
1917 if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab);
1918 if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab);
1919 if ( t!=NULL ) {
1920 err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab));
1921 _retv = NULL;
1922 }
1923 else if ( r!=NULL ) {
1924 err(eMsg1("label definition clashes with rule definition: '%s'", lab));
1925 _retv = NULL;
1926 }
1927 else {
1928 /* we don't clash with anybody else */
1929 l = (LabelEntry *) hash_get(Elabel, lab);
1930 if ( l==NULL ) { /* ok to add new element label */
1931 l = (LabelEntry *)hash_add(Elabel,
1932 lab,
1933 (Entry *)newLabelEntry(lab));
1934 /* add to list of element labels for this rule */
1935 list_add(&CurElementLabels, (void *)lab);
1936 /* MR7 */ leAdd(l); /* list of labels waiting for exception group definitions */
1937 _retv = l;
1938 }
1939 else {
1940 err(eMsg1("label definitions must be unique per rule: '%s'", lab));
1941 _retv = NULL;
1942 }
1943 }
1944 zzmatch(106); zzCONSUME;
1945 zzEXIT(zztasp1);
1946 return _retv;
1947 fail:
1948 zzEXIT(zztasp1);
1949 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1950 zzresynch(setwd6, 0x4);
1951 return _retv;
1952 }
1953 }
1954
1955 Node *
1956 #ifdef __USE_PROTOS
1957 element(int old_not,int first_on_line,int use_def_MT_handler)
1958 #else
1959 element(old_not,first_on_line,use_def_MT_handler)
1960 int old_not;
1961 int first_on_line;
1962 int use_def_MT_handler ;
1963 #endif
1964 {
1965 Node * _retv;
1966 zzRULE;
1967 zzBLOCK(zztasp1);
1968 PCCTS_PURIFY(_retv,sizeof(Node * ))
1969 zzMake0;
1970 {
1971
1972 Attrib blk;
1973 Predicate *pred = NULL;
1974 int local_use_def_MT_handler=0;
1975 ActionNode *act;
1976 RuleRefNode *rr;
1977 set toksrefd, rulesrefd;
1978 TermEntry *term;
1979 TokNode *p=NULL; RuleRefNode *q; int approx=0;
1980 LabelEntry *label=NULL;
1981 int predMsgDone=0;
1982 int semDepth=0;
1983 int ampersandStyle;
1984 int height; /* MR11 */
1985 int equal_height; /* MR11 */
1986
1987 char* pFirstSetSymbol = NULL; /* MR21 */
1988
1989 _retv = NULL;
1990 if ( (setwd6[LA(1)]&0x8) ) {
1991 {
1992 zzBLOCK(zztasp2);
1993 zzMake0;
1994 {
1995 if ( (LA(1)==LABEL) ) {
1996 label = element_label();
1997
1998 }
1999 else {
2000 if ( (setwd6[LA(1)]&0x10) ) {
2001 }
2002 else {zzFAIL(1,zzerr28,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2003 }
2004 zzEXIT(zztasp2);
2005 }
2006 }
2007 {
2008 zzBLOCK(zztasp2);
2009 zzMake0;
2010 {
2011 if ( (LA(1)==TokenTerm) ) {
2012 zzmatch(TokenTerm);
2013
2014 term = (TermEntry *) hash_get(Tname, LATEXT(1));
2015 if ( term==NULL && UserDefdTokens ) {
2016 err("implicit token definition not allowed with #tokdefs");
2017 zzaRet.left = zzaRet.right = NULL;
2018 }
2019 else {
2020 zzaRet = buildToken(LATEXT(1));
2021 p=((TokNode *)((Junction *)zzaRet.left)->p1);
2022 term = (TermEntry *) hash_get(Tname, LATEXT(1));
2023 require( term!= NULL, "hash table mechanism is broken");
2024 p->tclass = term->tclass;
2025 p->complement = old_not;
2026 if ( label!=NULL ) {
2027 p->el_label = label->str;
2028 label->elem = (Node *)p;
2029 }
2030 }
2031 zzCONSUME;
2032
2033 {
2034 zzBLOCK(zztasp3);
2035 zzMake0;
2036 {
2037 if ( (LA(1)==119) ) {
2038 zzmatch(119); zzCONSUME;
2039 {
2040 zzBLOCK(zztasp4);
2041 zzMake0;
2042 {
2043 if ( (LA(1)==QuotedTerm) ) {
2044 zzmatch(QuotedTerm);
2045 if ( p!=NULL ) setUpperRange(p, LATEXT(1));
2046 zzCONSUME;
2047
2048 }
2049 else {
2050 if ( (LA(1)==TokenTerm) ) {
2051 zzmatch(TokenTerm);
2052 if ( p!=NULL ) setUpperRange(p, LATEXT(1));
2053 zzCONSUME;
2054
2055 }
2056 else {zzFAIL(1,zzerr29,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2057 }
2058 zzEXIT(zztasp4);
2059 }
2060 }
2061 }
2062 else {
2063 if ( (setwd6[LA(1)]&0x20) ) {
2064 }
2065 else {zzFAIL(1,zzerr30,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2066 }
2067 zzEXIT(zztasp3);
2068 }
2069 }
2070
2071 if ( p!=NULL && (p->upper_range!=0 || p->tclass || old_not) )
2072 list_add(&MetaTokenNodes, (void *)p);
2073 {
2074 zzBLOCK(zztasp3);
2075 zzMake0;
2076 {
2077 if ( (LA(1)==125) ) {
2078 zzmatch(125);
2079 if ( p!=NULL ) p->astnode=ASTroot;
2080 zzCONSUME;
2081
2082 }
2083 else {
2084 if ( (setwd6[LA(1)]&0x40) ) {
2085 if ( p!=NULL ) p->astnode=ASTchild;
2086 }
2087 else {
2088 if ( (LA(1)==103) ) {
2089 zzmatch(103);
2090 if ( p!=NULL ) p->astnode=ASTexclude;
2091 zzCONSUME;
2092
2093 }
2094 else {zzFAIL(1,zzerr31,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2095 }
2096 }
2097 zzEXIT(zztasp3);
2098 }
2099 }
2100 {
2101 zzBLOCK(zztasp3);
2102 zzMake0;
2103 {
2104 if ( (LA(1)==88) ) {
2105 zzmatch(88);
2106 local_use_def_MT_handler = 1;
2107 zzCONSUME;
2108
2109 }
2110 else {
2111 if ( (setwd6[LA(1)]&0x80) ) {
2112 }
2113 else {zzFAIL(1,zzerr32,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2114 }
2115 zzEXIT(zztasp3);
2116 }
2117 }
2118
2119 if ( p!=NULL && first_on_line ) {
2120 CurAltStart = (Junction *)zzaRet.left;
2121 altAdd(CurAltStart); /* MR7 */
2122 p->altstart = CurAltStart;
2123 }
2124 if ( p!=NULL )
2125 p->use_def_MT_handler = use_def_MT_handler || local_use_def_MT_handler;
2126 _retv = (Node *)p;
2127 }
2128 else {
2129 if ( (LA(1)==QuotedTerm) ) {
2130 zzmatch(QuotedTerm);
2131
2132 term = (TermEntry *) hash_get(Texpr, LATEXT(1));
2133 if ( term==NULL && UserDefdTokens ) {
2134 err("implicit token definition not allowed with #tokdefs");
2135 zzaRet.left = zzaRet.right = NULL;
2136 }
2137 else {
2138 zzaRet = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);
2139 p->complement = old_not;
2140 if ( label!=NULL ) {
2141 p->el_label = label->str;
2142 label->elem = (Node *)p;
2143 }
2144 }
2145 zzCONSUME;
2146
2147 {
2148 zzBLOCK(zztasp3);
2149 zzMake0;
2150 {
2151 if ( (LA(1)==119) ) {
2152 zzmatch(119); zzCONSUME;
2153 {
2154 zzBLOCK(zztasp4);
2155 zzMake0;
2156 {
2157 if ( (LA(1)==QuotedTerm) ) {
2158 zzmatch(QuotedTerm);
2159 if ( p!=NULL ) setUpperRange(p, LATEXT(1));
2160 zzCONSUME;
2161
2162 }
2163 else {
2164 if ( (LA(1)==TokenTerm) ) {
2165 zzmatch(TokenTerm);
2166 if ( p!=NULL ) setUpperRange(p, LATEXT(1));
2167 zzCONSUME;
2168
2169 }
2170 else {zzFAIL(1,zzerr33,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2171 }
2172 zzEXIT(zztasp4);
2173 }
2174 }
2175 }
2176 else {
2177 if ( (setwd7[LA(1)]&0x1) ) {
2178 }
2179 else {zzFAIL(1,zzerr34,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2180 }
2181 zzEXIT(zztasp3);
2182 }
2183 }
2184 {
2185 zzBLOCK(zztasp3);
2186 zzMake0;
2187 {
2188 if ( (LA(1)==125) ) {
2189 zzmatch(125);
2190 if ( p!=NULL ) p->astnode=ASTroot;
2191 zzCONSUME;
2192
2193 }
2194 else {
2195 if ( (setwd7[LA(1)]&0x2) ) {
2196 if ( p!=NULL ) p->astnode=ASTchild;
2197 }
2198 else {
2199 if ( (LA(1)==103) ) {
2200 zzmatch(103);
2201 if ( p!=NULL ) p->astnode=ASTexclude;
2202 zzCONSUME;
2203
2204 }
2205 else {zzFAIL(1,zzerr35,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2206 }
2207 }
2208 zzEXIT(zztasp3);
2209 }
2210 }
2211 {
2212 zzBLOCK(zztasp3);
2213 zzMake0;
2214 {
2215 if ( (LA(1)==88) ) {
2216 zzmatch(88);
2217 local_use_def_MT_handler = 1;
2218 zzCONSUME;
2219
2220 }
2221 else {
2222 if ( (setwd7[LA(1)]&0x4) ) {
2223 }
2224 else {zzFAIL(1,zzerr36,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2225 }
2226 zzEXIT(zztasp3);
2227 }
2228 }
2229
2230 if ( p!=NULL && (p->upper_range!=0 || p->tclass || old_not) )
2231 list_add(&MetaTokenNodes, (void *)p);
2232
2233 if ( first_on_line ) {
2234 CurAltStart = (Junction *)zzaRet.left;
2235 altAdd(CurAltStart); /* MR7 */
2236 p->altstart = CurAltStart;
2237 }
2238 if ( p!=NULL )
2239 p->use_def_MT_handler = use_def_MT_handler || local_use_def_MT_handler;
2240 _retv = (Node *)p;
2241 }
2242 else {
2243 if ( (LA(1)==WildCard) ) {
2244 if ( old_not ) warn("~ WILDCARD is an undefined operation (implies 'nothing')");
2245 zzmatch(WildCard);
2246 zzaRet = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);
2247 zzCONSUME;
2248
2249 {
2250 zzBLOCK(zztasp3);
2251 zzMake0;
2252 {
2253 if ( (LA(1)==125) ) {
2254 zzmatch(125);
2255 p->astnode=ASTroot;
2256 zzCONSUME;
2257
2258 }
2259 else {
2260 if ( (setwd7[LA(1)]&0x8) ) {
2261 p->astnode=ASTchild;
2262 }
2263 else {
2264 if ( (LA(1)==103) ) {
2265 zzmatch(103);
2266 p->astnode=ASTexclude;
2267 zzCONSUME;
2268
2269 }
2270 else {zzFAIL(1,zzerr37,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2271 }
2272 }
2273 zzEXIT(zztasp3);
2274 }
2275 }
2276 list_add(&MetaTokenNodes, (void *)p);
2277
2278 if ( first_on_line ) {
2279 CurAltStart = (Junction *)zzaRet.left;
2280 altAdd(CurAltStart); /* MR7 */
2281 p->altstart = CurAltStart;
2282 if ( label!=NULL ) {
2283 p->el_label = label->str;
2284 label->elem = (Node *)p;
2285 }
2286 }
2287 _retv = (Node *)p;
2288 }
2289 else {
2290 if ( (LA(1)==NonTerminal) ) {
2291 if ( old_not ) warn("~ NONTERMINAL is an undefined operation");
2292 zzmatch(NonTerminal);
2293 zzaRet = buildRuleRef(LATEXT(1));
2294 zzCONSUME;
2295
2296 {
2297 zzBLOCK(zztasp3);
2298 zzMake0;
2299 {
2300 if ( (LA(1)==103) ) {
2301 zzmatch(103);
2302 q = (RuleRefNode *) ((Junction *)zzaRet.left)->p1;
2303 q->astnode=ASTexclude;
2304 zzCONSUME;
2305
2306 }
2307 else {
2308 if ( (setwd7[LA(1)]&0x10) ) {
2309 }
2310 else {zzFAIL(1,zzerr38,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2311 }
2312 zzEXIT(zztasp3);
2313 }
2314 }
2315 {
2316 zzBLOCK(zztasp3);
2317 zzMake0;
2318 {
2319 if ( (setwd7[LA(1)]&0x20) ) {
2320 {
2321 zzBLOCK(zztasp4);
2322 zzMake0;
2323 {
2324 if ( (LA(1)==104) ) {
2325 zzmatch(104); zzCONSUME;
2326 }
2327 else {
2328 if ( (LA(1)==PassAction) ) {
2329 }
2330 else {zzFAIL(1,zzerr39,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2331 }
2332 zzEXIT(zztasp4);
2333 }
2334 }
2335 zzmatch(PassAction);
2336 addParm(((Junction *)zzaRet.left)->p1, LATEXT(1));
2337 zzCONSUME;
2338
2339 }
2340 else {
2341 if ( (setwd7[LA(1)]&0x40) ) {
2342 }
2343 else {zzFAIL(1,zzerr40,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2344 }
2345 zzEXIT(zztasp3);
2346 }
2347 }
2348 rr=(RuleRefNode *) ((Junction *)zzaRet.left)->p1;
2349 {
2350 zzBLOCK(zztasp3);
2351 zzMake0;
2352 {
2353 char *a;
2354 if ( (LA(1)==105) ) {
2355 zzmatch(105); zzCONSUME;
2356 zzmatch(PassAction);
2357
2358 a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2359 require(a!=NULL, "rule element: cannot allocate assignment");
2360 strcpy(a, LATEXT(1));
2361 rr->assign = a;
2362 zzCONSUME;
2363
2364 }
2365 else {
2366 if ( (setwd7[LA(1)]&0x80) ) {
2367 }
2368 else {zzFAIL(1,zzerr41,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2369 }
2370 zzEXIT(zztasp3);
2371 }
2372 }
2373
2374 if ( label!=NULL ) {
2375 rr->el_label = label->str;
2376 label->elem = (Node *)rr;
2377 }
2378 if ( first_on_line ) {
2379 CurAltStart = (Junction *)zzaRet.left;
2380 altAdd(CurAltStart); /* MR7 */
2381 ((RuleRefNode *)((Junction *)zzaRet.left)->p1)->altstart = CurAltStart;
2382 }
2383 _retv = (Node *)rr;
2384 }
2385 else {zzFAIL(1,zzerr42,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2386 }
2387 }
2388 }
2389 zzEXIT(zztasp2);
2390 }
2391 }
2392 }
2393 else {
2394 if ( (LA(1)==Action) ) {
2395 if ( old_not ) warn("~ ACTION is an undefined operation");
2396 zzmatch(Action);
2397 zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 0);
2398 zzCONSUME;
2399
2400 if ( first_on_line ) { /* MR7 */
2401 CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left; /* MR7 */
2402 altAdd(CurAltStart); /* MR7 */
2403 };
2404 _retv = (Node *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;
2405 }
2406 else {
2407 if ( (LA(1)==Pred) ) {
2408 if ( old_not ) warn("~ SEMANTIC-PREDICATE is an undefined operation");
2409 zzmatch(Pred);
2410 zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 1);
2411 zzCONSUME;
2412
2413 act = (ActionNode *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;
2414 if (numericActionLabel) { /* MR10 */
2415 list_add(&NumericPredLabels,act); /* MR10 */
2416 numericActionLabel=0; /* MR10 */
2417 }; /* MR10 */
2418 {
2419 zzBLOCK(zztasp2);
2420 zzMake0;
2421 {
2422 char *a;
2423 if ( (LA(1)==PassAction) ) {
2424 zzmatch(PassAction);
2425
2426 a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2427 require(a!=NULL, "rule element: cannot allocate predicate fail action");
2428 strcpy(a, LATEXT(1));
2429 act->pred_fail = a;
2430 zzCONSUME;
2431
2432 }
2433 else {
2434 if ( (setwd8[LA(1)]&0x1) ) {
2435 }
2436 else {zzFAIL(1,zzerr43,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2437 }
2438 zzEXIT(zztasp2);
2439 }
2440 }
2441 if ( first_on_line ) { /* MR7 */
2442 CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left; /* MR7 */
2443 altAdd(CurAltStart); /* MR7 */
2444 };
2445 _retv = (Node *)act;
2446 }
2447 else {
2448 if ( (setwd8[LA(1)]&0x2) ) {
2449 if ( old_not ) warn("~ BLOCK is an undefined operation");
2450 BlkLevel++;
2451 if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");
2452 /* MR23 */ CurBlockID_array[BlkLevel] = CurBlockID;
2453 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
2454 {
2455 zzBLOCK(zztasp2);
2456 zzMake0;
2457 {
2458 if ( (LA(1)==Pragma) ) {
2459 zzmatch(Pragma); zzCONSUME;
2460 {
2461 zzBLOCK(zztasp3);
2462 zzMake0;
2463 {
2464 if ( (LA(1)==126) ) {
2465 zzmatch(126);
2466 approx=LL_k;
2467 zzCONSUME;
2468
2469 }
2470 else {
2471 if ( (LA(1)==127) ) {
2472 zzmatch(127);
2473 approx = 1;
2474 zzCONSUME;
2475
2476 }
2477 else {
2478 if ( (LA(1)==128) ) {
2479 zzmatch(128);
2480 approx = 2;
2481 zzCONSUME;
2482
2483 }
2484 else {zzFAIL(1,zzerr44,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2485 }
2486 }
2487 zzEXIT(zztasp3);
2488 }
2489 }
2490 }
2491 else {
2492 if ( (setwd8[LA(1)]&0x4) ) {
2493 }
2494 else {zzFAIL(1,zzerr45,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2495 }
2496 zzEXIT(zztasp2);
2497 }
2498 }
2499 {
2500 zzBLOCK(zztasp2);
2501 zzMake0;
2502 {
2503 if ( (LA(1)==FirstSetSymbol) ) {
2504 zzmatch(FirstSetSymbol); zzCONSUME;
2505 zzmatch(114); zzCONSUME;
2506 {
2507 zzBLOCK(zztasp3);
2508 zzMake0;
2509 {
2510 if ( (LA(1)==NonTerminal) ) {
2511 zzmatch(NonTerminal);
2512
2513 /* MR21 */ pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,
2514 /* MR21 */ sizeof(char));
2515 /* MR21 */ require(pFirstSetSymbol!=NULL,
2516 /* MR21 */ "cannot allocate first set name");
2517 /* MR21 */ strcpy(pFirstSetSymbol, LATEXT(1));
2518 /* MR21 */
2519 zzCONSUME;
2520
2521 }
2522 else {
2523 if ( (LA(1)==TokenTerm) ) {
2524 zzmatch(TokenTerm);
2525
2526 /* MR21 */ pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,
2527 /* MR21 */ sizeof(char));
2528 /* MR21 */ require(pFirstSetSymbol!=NULL,
2529 /* MR21 */ "cannot allocate first set name");
2530 /* MR21 */ strcpy(pFirstSetSymbol, LATEXT(1));
2531 /* MR21 */
2532 zzCONSUME;
2533
2534 }
2535 else {zzFAIL(1,zzerr46,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2536 }
2537 zzEXIT(zztasp3);
2538 }
2539 }
2540 zzmatch(115); zzCONSUME;
2541 }
2542 else {
2543 if ( (setwd8[LA(1)]&0x8) ) {
2544 }
2545 else {zzFAIL(1,zzerr47,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2546 }
2547 zzEXIT(zztasp2);
2548 }
2549 }
2550 {
2551 zzBLOCK(zztasp2);
2552 zzMake0;
2553 {
2554 if ( (LA(1)==114) ) {
2555 zzmatch(114); zzCONSUME;
2556 block( &toksrefd,&rulesrefd );
2557 zzmatch(115);
2558 blk = zzaRet = zzaArg(zztasp2,2);
2559 /* MR23 */ CurBlockID_array[BlkLevel] = (-1);
2560 /* MR23 */ CurAltNum_array[BlkLevel] = (-1);
2561 --BlkLevel;
2562 zzCONSUME;
2563
2564 {
2565 zzBLOCK(zztasp3);
2566 zzMake0;
2567 {
2568 if ( (LA(1)==129) ) {
2569 zzmatch(129);
2570 zzaRet = makeLoop(zzaRet,approx,pFirstSetSymbol);
2571 zzCONSUME;
2572
2573 }
2574 else {
2575 if ( (LA(1)==130) ) {
2576 zzmatch(130);
2577 zzaRet = makePlus(zzaRet,approx,pFirstSetSymbol);
2578 zzCONSUME;
2579
2580 }
2581 else {
2582 if ( (LA(1)==131) ) {
2583 zzmatch(131); zzCONSUME;
2584 {
2585 zzBLOCK(zztasp4);
2586 zzMake0;
2587 {
2588 if ( (setwd8[LA(1)]&0x10) ) {
2589 {
2590 zzBLOCK(zztasp5);
2591 zzMake0;
2592 {
2593 if ( (LA(1)==132) ) {
2594 zzmatch(132);
2595 ampersandStyle=0;
2596 zzCONSUME;
2597
2598 }
2599 else {
2600 if ( (LA(1)==113) ) {
2601 zzmatch(113);
2602 ampersandStyle=1;
2603 zzCONSUME;
2604
2605 }
2606 else {zzFAIL(1,zzerr48,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2607 }
2608 zzEXIT(zztasp5);
2609 }
2610 }
2611 zzmatch(Pred);
2612 zzaRet = buildAction(LATEXT(1),action_file,action_line,1);
2613 zzCONSUME;
2614
2615 act = (ActionNode *) ((Junction *)zzaRet.left)->p1;
2616 semDepth=predicateLookaheadDepth(act);
2617 if (numericActionLabel) { /* MR10 */
2618 list_add(&NumericPredLabels,act); /* MR10 */
2619 numericActionLabel=0; /* MR10 */
2620 }; /* MR10 */
2621 {
2622 zzBLOCK(zztasp5);
2623 zzMake0;
2624 {
2625 char *a;
2626 if ( (LA(1)==PassAction) ) {
2627 zzmatch(PassAction);
2628
2629 a = (char *)calloc(strlen(LATEXT(1))+1, sizeof(char));
2630 require(a!=NULL, "rule element: cannot allocate predicate fail action");
2631 strcpy(a, LATEXT(1));
2632 act->pred_fail = a;
2633 zzCONSUME;
2634
2635 }
2636 else {
2637 if ( (setwd8[LA(1)]&0x20) ) {
2638 }
2639 else {zzFAIL(1,zzerr49,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2640 }
2641 zzEXIT(zztasp5);
2642 }
2643 }
2644 if ( first_on_line) { /* MR7 */
2645 CurAltStart=(Junction *)zzaRet.left; /* MR7 */
2646 altAdd(CurAltStart); /* MR7 */
2647 };
2648 _retv = (Node *)act;
2649
2650 pred = computePredFromContextGuard(blk,&predMsgDone); /* MR10 */
2651 if ( pred==NULL) { /* MR10 */
2652 if ( !predMsgDone) err("invalid or missing context guard"); /* MR10 */
2653 predMsgDone=1; /* MR10 */
2654 } else { /* MR10 */
2655 act->guardNodes=(Junction *)blk.left; /* MR11 */
2656 pred->expr = act->action;
2657 pred->source = act;
2658 /* MR10 */ pred->ampersandStyle = ampersandStyle; /* 0 means (g)? => ... 1 means (g)? && ... */
2659 /* MR13 */ if (pred->tcontext != NULL) {
2660 /* MR13 */ height=MR_max_height_of_tree(pred->tcontext);
2661 /* MR13 */ equal_height=MR_all_leaves_same_height(pred->tcontext,height);
2662 /* MR13 */ if (! equal_height) {
2663 /* MR13 */ errFL("in guarded predicates all tokens in the guard must be at the same height",
2664 /* MR13 */ FileStr[act->file],act->line);
2665 /* MR13 */ };
2666 /* MR13 */ }
2667 /* MR10 */ if (ampersandStyle) {
2668 /* MR10 */ act->ampersandPred = pred;
2669 /* MR11 */ if (! HoistPredicateContext) {
2670 /* MR11 */ errFL("without \"-prc on\" (guard)? && <<pred>>? ... doesn't make sense",
2671 /* MR11 */ FileStr[act->file],act->line);
2672 /* MR11 */ };
2673 /* MR10 */ } else {
2674 /* MR10 */ act->guardpred = pred;
2675 /* MR10 */ };
2676 /* MR10 */ if (pred->k != semDepth) {
2677 /* MR10 */ warn(eMsgd2("length of guard (%d) does not match the length of semantic predicate (%d)",
2678 /* MR10 */ pred->k,semDepth));
2679 /* MR10 */ };
2680 }
2681 }
2682 else {
2683 if ( (setwd8[LA(1)]&0x40) ) {
2684 zzaRet = makeBlk(zzaRet,approx,pFirstSetSymbol);
2685 FoundGuessBlk = 1;
2686 ((Junction *) ((Junction *)zzaRet.left)->p1)->guess=1;
2687 if ( ! first_on_line ) {
2688 err("(...)? predicate must be first element of production");
2689 }
2690 }
2691 else {zzFAIL(1,zzerr50,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2692 }
2693 zzEXIT(zztasp4);
2694 }
2695 }
2696 }
2697 else {
2698 if ( (setwd8[LA(1)]&0x80) ) {
2699 zzaRet = makeBlk(zzaRet,approx,pFirstSetSymbol);
2700 }
2701 else {zzFAIL(1,zzerr51,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2702 }
2703 }
2704 }
2705 zzEXIT(zztasp3);
2706 }
2707 }
2708
2709 if ( pred==NULL && !predMsgDone) { /* MR10 */
2710 ((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;
2711 ((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;
2712 ((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;
2713 if ( first_on_line ) { /* MR7 */
2714 CurAltStart = (Junction *)((Junction *)((Junction *)zzaRet.left)->p1); /* MR7 */
2715 altAdd(CurAltStart); /* MR7 */
2716 }; /* MR7 */
2717 _retv = (Node *) ((Junction *)zzaRet.left)->p1;
2718 }
2719 }
2720 else {
2721 if ( (LA(1)==102) ) {
2722 zzmatch(102); zzCONSUME;
2723 block( &toksrefd,&rulesrefd );
2724 zzaRet = makeOpt(zzaArg(zztasp2,2),approx,pFirstSetSymbol);
2725 /* MR23 */ CurBlockID_array[BlkLevel] = (-1);
2726 /* MR23 */ CurAltNum_array[BlkLevel] = (-1);
2727 --BlkLevel;
2728 zzmatch(98);
2729
2730 ((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;
2731 ((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;
2732 ((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;
2733 zzCONSUME;
2734
2735 if ( first_on_line ) { /* MR7 */
2736 CurAltStart = (Junction *) ((Junction *)((Junction *)zzaRet.left)->p1); /* MR7 */
2737 altAdd(CurAltStart); /* MR7 */
2738 };
2739 _retv = (Node *) ((Junction *)zzaRet.left)->p1;
2740 }
2741 else {zzFAIL(1,zzerr52,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2742 }
2743 zzEXIT(zztasp2);
2744 }
2745 }
2746 }
2747 else {
2748 if ( (LA(1)==129) ) {
2749 zzmatch(129);
2750 warn("don't you want a ')' with that '*'?"); CannotContinue=TRUE;
2751 zzCONSUME;
2752
2753 }
2754 else {
2755 if ( (LA(1)==130) ) {
2756 zzmatch(130);
2757 warn("don't you want a ')' with that '+'?"); CannotContinue=TRUE;
2758 zzCONSUME;
2759
2760 }
2761 else {
2762 if ( (LA(1)==105) ) {
2763 zzmatch(105);
2764 warn("'>' can only appear after a nonterminal"); CannotContinue=TRUE;
2765 zzCONSUME;
2766
2767 }
2768 else {
2769 if ( (LA(1)==PassAction) ) {
2770 zzmatch(PassAction);
2771 warn("[...] out of context 'rule > [...]'");
2772 CannotContinue=TRUE;
2773 zzCONSUME;
2774
2775 }
2776 else {zzFAIL(1,zzerr53,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2777 }
2778 }
2779 }
2780 }
2781 }
2782 }
2783 }
2784 zzEXIT(zztasp1);
2785 return _retv;
2786 fail:
2787 zzEXIT(zztasp1);
2788 CannotContinue=TRUE;
2789 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
2790 zzresynch(setwd9, 0x1);
2791 return _retv;
2792 }
2793 }
2794
2795 void
2796 #ifdef __USE_PROTOS
2797 default_exception_handler(void)
2798 #else
2799 default_exception_handler()
2800 #endif
2801 {
2802 zzRULE;
2803 zzBLOCK(zztasp1);
2804 zzMake0;
2805 {
2806 DefaultExGroup = exception_group();
2807
2808 zzEXIT(zztasp1);
2809 return;
2810 fail:
2811 zzEXIT(zztasp1);
2812 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
2813 zzresynch(setwd9, 0x2);
2814 }
2815 }
2816
2817 ExceptionGroup *
2818 #ifdef __USE_PROTOS
2819 exception_group(void)
2820 #else
2821 exception_group()
2822 #endif
2823 {
2824 ExceptionGroup * _retv;
2825 zzRULE;
2826 zzBLOCK(zztasp1);
2827 PCCTS_PURIFY(_retv,sizeof(ExceptionGroup * ))
2828 zzMake0;
2829 {
2830 ExceptionHandler *h; LabelEntry *label=NULL; /* MR6 */
2831 FoundException = 1; FoundExceptionGroup = 1;
2832 zzmatch(133);
2833 _retv = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));
2834 zzCONSUME;
2835
2836 {
2837 zzBLOCK(zztasp2);
2838 zzMake0;
2839 {
2840 char *p;
2841 if ( (LA(1)==PassAction) ) {
2842 zzmatch(PassAction);
2843
2844 p = LATEXT(1)+1;
2845 p[strlen(p)-1] = '\0'; /* kill trailing space */
2846 label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1);
2847 if ( label==NULL )
2848 {
2849 err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1));
2850 }
2851 zzCONSUME;
2852
2853 }
2854 else {
2855 if ( (setwd9[LA(1)]&0x4) ) {
2856 }
2857 else {zzFAIL(1,zzerr54,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2858 }
2859 zzEXIT(zztasp2);
2860 }
2861 }
2862 {
2863 zzBLOCK(zztasp2);
2864 zzMake0;
2865 {
2866 while ( (LA(1)==135) ) {
2867 h = exception_handler();
2868
2869 list_add(&(_retv->handlers), (void *)h);
2870 zzLOOP(zztasp2);
2871 }
2872 zzEXIT(zztasp2);
2873 }
2874 }
2875 {
2876 zzBLOCK(zztasp2);
2877 zzMake0;
2878 {
2879 if ( (LA(1)==134) ) {
2880 zzmatch(134); zzCONSUME;
2881 zzmatch(106); zzCONSUME;
2882 zzmatch(Action);
2883 {
2884 ExceptionHandler *eh = (ExceptionHandler *)
2885 calloc(1, sizeof(ExceptionHandler));
2886 char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2887 require(eh!=NULL, "exception: cannot allocate handler");
2888 require(a!=NULL, "exception: cannot allocate action");
2889 strcpy(a, LATEXT(1));
2890 eh->action = a;
2891 eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char));
2892 require(eh->signalname!=NULL, "exception: cannot allocate sig name");
2893 strcpy(eh->signalname, "default");
2894 list_add(&(_retv->handlers), (void *)eh);
2895 }
2896 zzCONSUME;
2897
2898 }
2899 else {
2900 if ( (setwd9[LA(1)]&0x8) ) {
2901 }
2902 else {zzFAIL(1,zzerr55,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2903 }
2904 zzEXIT(zztasp2);
2905 }
2906 }
2907
2908 if ( label!=NULL ) {
2909 /* Record ex group in sym tab for this label */
2910 if ( label->ex_group!=NULL ) {
2911 err(eMsg1("duplicate exception handler for label '%s'",label->str));
2912 } else {
2913 label->ex_group = _retv;
2914 /* Label the exception group itself */
2915 _retv->label = label->str;
2916 /* Make the labelled element pt to the exception also */
2917 /* MR6 */ if (label->elem == NULL) {
2918 /* MR6 */ err(eMsg1("reference in exception handler to undefined label '%s'",label->str));
2919 /* MR6 */ } else {
2920 switch ( label->elem->ntype ) {
2921 case nRuleRef :
2922 {
2923 RuleRefNode *r = (RuleRefNode *)label->elem;
2924 r->ex_group = _retv;
2925 break;
2926 }
2927 case nToken :
2928 {
2929 TokNode *t = (TokNode *)label->elem;
2930 t->ex_group = _retv;
2931 break;
2932 }
2933 } /* end switch */
2934 /* MR6 */ }; /* end test on label->elem */
2935 } /* end test on label->ex_group */
2936
2937 } /* end test on exception label */
2938
2939 /* MR7 */
2940 /* MR7 */ if (BlkLevel == 1 && label == NULL) {
2941 /* MR7 */ _retv->forRule=1;
2942 /* MR7 */ } else if (label == NULL) {
2943 /* MR7 */ _retv->altID = makeAltID(CurBlockID_array[BlkLevel], CurAltNum_array[BlkLevel]);
2944 /* MR7 */ egAdd(_retv);
2945 /* MR7 */ } else {
2946 /* MR7 */ _retv->labelEntry=label;
2947 /* MR7 */ };
2948 /* MR7 */
2949 /* MR7 */ /* You may want to remove this exc from the rule list */
2950 /* MR7 */ /* and handle at the labeled element site. */
2951 /* MR7 */
2952 /* MR7 */ if (label != NULL) {
2953 /* MR7 */ _retv = NULL;
2954 /* MR7 */ };
2955 zzEXIT(zztasp1);
2956 return _retv;
2957 fail:
2958 zzEXIT(zztasp1);
2959 CannotContinue=TRUE;
2960 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
2961 zzresynch(setwd9, 0x10);
2962 return _retv;
2963 }
2964 }
2965
2966 ExceptionHandler *
2967 #ifdef __USE_PROTOS
2968 exception_handler(void)
2969 #else
2970 exception_handler()
2971 #endif
2972 {
2973 ExceptionHandler * _retv;
2974 zzRULE;
2975 zzBLOCK(zztasp1);
2976 PCCTS_PURIFY(_retv,sizeof(ExceptionHandler * ))
2977 zzMake0;
2978 {
2979 ;
2980 zzmatch(135);
2981
2982 _retv = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler));
2983 require(_retv!=NULL, "exception: cannot allocate handler");
2984 zzCONSUME;
2985
2986 {
2987 zzBLOCK(zztasp2);
2988 zzMake0;
2989 {
2990 if ( (LA(1)==NonTerminal) ) {
2991 zzmatch(NonTerminal);
2992
2993 _retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2994 require(_retv->signalname!=NULL, "exception: cannot allocate sig name");
2995 strcpy(_retv->signalname, LATEXT(1));
2996 zzCONSUME;
2997
2998 }
2999 else {
3000 if ( (LA(1)==TokenTerm) ) {
3001 zzmatch(TokenTerm);
3002
3003 _retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
3004 require(_retv->signalname!=NULL, "exception: cannot allocate sig name");
3005 strcpy(_retv->signalname, LATEXT(1));
3006 zzCONSUME;
3007
3008 }
3009 else {zzFAIL(1,zzerr56,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3010 }
3011 zzEXIT(zztasp2);
3012 }
3013 }
3014 zzmatch(106); zzCONSUME;
3015 {
3016 zzBLOCK(zztasp2);
3017 zzMake0;
3018 {
3019 _retv->action = NULL;
3020 if ( (LA(1)==Action) ) {
3021 zzmatch(Action);
3022
3023 _retv->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
3024 require(_retv->action!=NULL, "exception: cannot allocate action");
3025 strcpy(_retv->action, LATEXT(1));
3026 zzCONSUME;
3027
3028 }
3029 else {
3030 if ( (setwd9[LA(1)]&0x20) ) {
3031 }
3032 else {zzFAIL(1,zzerr57,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3033 }
3034 zzEXIT(zztasp2);
3035 }
3036 }
3037 zzEXIT(zztasp1);
3038 return _retv;
3039 fail:
3040 zzEXIT(zztasp1);
3041 CannotContinue=TRUE;
3042 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
3043 zzresynch(setwd9, 0x40);
3044 return _retv;
3045 }
3046 }
3047
3048 void
3049 #ifdef __USE_PROTOS
3050 enum_file(char * fname)
3051 #else
3052 enum_file(fname)
3053 char *fname ;
3054 #endif
3055 {
3056 zzRULE;
3057 zzBLOCK(zztasp1);
3058 zzMake0;
3059 {
3060 if ( (setwd9[LA(1)]&0x80) ) {
3061 {
3062 zzBLOCK(zztasp2);
3063 zzMake0;
3064 {
3065 if ( (LA(1)==143) ) {
3066 zzmatch(143); zzCONSUME;
3067 zzmatch(ID); zzCONSUME;
3068 {
3069 zzBLOCK(zztasp3);
3070 zzMake0;
3071 {
3072 if ( (LA(1)==149) ) {
3073 zzmatch(149); zzCONSUME;
3074 zzmatch(ID); zzCONSUME;
3075 }
3076 else {
3077 if ( (setwd10[LA(1)]&0x1) ) {
3078 }
3079 else {zzFAIL(1,zzerr58,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3080 }
3081 zzEXIT(zztasp3);
3082 }
3083 }
3084 }
3085 else {
3086 if ( (setwd10[LA(1)]&0x2) ) {
3087 }
3088 else {zzFAIL(1,zzerr59,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3089 }
3090 zzEXIT(zztasp2);
3091 }
3092 }
3093 {
3094 zzBLOCK(zztasp2);
3095 zzMake0;
3096 {
3097 if ( (LA(1)==151) ) {
3098 {
3099 zzBLOCK(zztasp3);
3100 int zzcnt=1;
3101 zzMake0;
3102 {
3103 do {
3104 enum_def( fname );
3105 zzLOOP(zztasp3);
3106 } while ( (LA(1)==151) );
3107 zzEXIT(zztasp3);
3108 }
3109 }
3110 }
3111 else {
3112 if ( (LA(1)==149) ) {
3113 defines( fname );
3114 }
3115 else {zzFAIL(1,zzerr60,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3116 }
3117 zzEXIT(zztasp2);
3118 }
3119 }
3120 }
3121 else {
3122 if ( (LA(1)==Eof) ) {
3123 }
3124 else {zzFAIL(1,zzerr61,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3125 }
3126 zzEXIT(zztasp1);
3127 return;
3128 fail:
3129 zzEXIT(zztasp1);
3130 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
3131 zzresynch(setwd10, 0x4);
3132 }
3133 }
3134
3135 void
3136 #ifdef __USE_PROTOS
3137 defines(char * fname)
3138 #else
3139 defines(fname)
3140 char *fname ;
3141 #endif
3142 {
3143 zzRULE;
3144 zzBLOCK(zztasp1);
3145 zzMake0;
3146 {
3147 int v; int maxt=(-1); char *t;
3148 {
3149 zzBLOCK(zztasp2);
3150 int zzcnt=1;
3151 zzMake0;
3152 {
3153 do {
3154 zzmatch(149); zzCONSUME;
3155 zzmatch(ID);
3156 t = mystrdup(LATEXT(1));
3157 zzCONSUME;
3158
3159 zzmatch(INT);
3160
3161 v = atoi(LATEXT(1));
3162 /* fprintf(stderr, "#token %s=%d\n", t, v);*/
3163
3164 /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */
3165 /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs */
3166 /* MR2 Don't let #tokdefs be confused by */
3167 /* MR2 DLGminToken and DLGmaxToken */
3168
3169 if ( ! isDLGmaxToken(t)) { /* MR2 */
3170 TokenNum = v;
3171 if ( v>maxt ) maxt=v;
3172 if ( Tnum( t ) == 0 ) {
3173 addForcedTname( t, v );
3174 } else {
3175 warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);
3176 };
3177 };
3178 zzCONSUME;
3179
3180 zzLOOP(zztasp2);
3181 } while ( (LA(1)==149) );
3182 zzEXIT(zztasp2);
3183 }
3184 }
3185 TokenNum = maxt + 1;
3186 zzEXIT(zztasp1);
3187 return;
3188 fail:
3189 zzEXIT(zztasp1);
3190 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
3191 zzresynch(setwd10, 0x8);
3192 }
3193 }
3194
3195 void
3196 #ifdef __USE_PROTOS
3197 enum_def(char * fname)
3198 #else
3199 enum_def(fname)
3200 char *fname ;
3201 #endif
3202 {
3203 zzRULE;
3204 zzBLOCK(zztasp1);
3205 zzMake0;
3206 {
3207 int v= 0; int maxt=(-1); char *t;
3208 zzmatch(151); zzCONSUME;
3209 zzmatch(ID); zzCONSUME;
3210 zzmatch(152); zzCONSUME;
3211 zzmatch(ID);
3212 t = mystrdup(LATEXT(1));
3213 zzCONSUME;
3214
3215 {
3216 zzBLOCK(zztasp2);
3217 zzMake0;
3218 {
3219 if ( (LA(1)==153) ) {
3220 zzmatch(153); zzCONSUME;
3221 zzmatch(INT);
3222 v=atoi(LATEXT(1));
3223 zzCONSUME;
3224
3225 }
3226 else {
3227 if ( (setwd10[LA(1)]&0x10) ) {
3228 v++;
3229 }
3230 else {zzFAIL(1,zzerr62,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3231 }
3232 zzEXIT(zztasp2);
3233 }
3234 }
3235
3236 /* fprintf(stderr, "#token %s=%d\n", t, v);*/
3237 TokenNum = v;
3238 if ( v>maxt ) maxt=v; /* MR3 */
3239 if ( Tnum( t ) == 0 ) addForcedTname( t, v );
3240 else {
3241 warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);
3242 }
3243 {
3244 zzBLOCK(zztasp2);
3245 zzMake0;
3246 {
3247 while ( (LA(1)==154) ) {
3248 zzmatch(154); zzCONSUME;
3249 {
3250 zzBLOCK(zztasp3);
3251 zzMake0;
3252 {
3253 if ( (LA(1)==ID)&&(isDLGmaxToken(LATEXT(1))) ) {
3254 if (!(isDLGmaxToken(LATEXT(1))) ) {zzfailed_pred(" isDLGmaxToken(LATEXT(1))",0 /* report */, { 0; /* no user action */ } );}
3255 zzmatch(ID); zzCONSUME;
3256 {
3257 zzBLOCK(zztasp4);
3258 zzMake0;
3259 {
3260 if ( (LA(1)==153) ) {
3261 zzmatch(153); zzCONSUME;
3262 zzmatch(INT); zzCONSUME;
3263 }
3264 else {
3265 if ( (setwd10[LA(1)]&0x20) ) {
3266 }
3267 else {zzFAIL(1,zzerr63,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3268 }
3269 zzEXIT(zztasp4);
3270 }
3271 }
3272 }
3273 else {
3274 if ( (LA(1)==ID) ) {
3275 zzmatch(ID);
3276 t = mystrdup(LATEXT(1));
3277 zzCONSUME;
3278
3279 {
3280 zzBLOCK(zztasp4);
3281 zzMake0;
3282 {
3283 if ( (LA(1)==153) ) {
3284 zzmatch(153); zzCONSUME;
3285 zzmatch(INT);
3286 v=atoi(LATEXT(1));
3287 zzCONSUME;
3288
3289 }
3290 else {
3291 if ( (setwd10[LA(1)]&0x40) ) {
3292 v++;
3293 }
3294 else {zzFAIL(1,zzerr64,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3295 }
3296 zzEXIT(zztasp4);
3297 }
3298 }
3299
3300 /* fprintf(stderr, "#token %s=%d\n", t, v);*/
3301 TokenNum = v;
3302 if ( v>maxt ) maxt=v; /* MR3 */
3303 if ( Tnum( t ) == 0 ) addForcedTname( t, v );
3304 else {
3305 warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);
3306 }
3307 }
3308 else {
3309 if ( (setwd10[LA(1)]&0x80) ) {
3310 }
3311 else {zzFAIL(1,zzerr65,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3312 }
3313 }
3314 zzEXIT(zztasp3);
3315 }
3316 }
3317 zzLOOP(zztasp2);
3318 }
3319 zzEXIT(zztasp2);
3320 }
3321 }
3322 zzmatch(155); zzCONSUME;
3323 zzmatch(156);
3324 TokenNum = maxt + 1;
3325 zzCONSUME;
3326
3327 zzEXIT(zztasp1);
3328 return;
3329 fail:
3330 zzEXIT(zztasp1);
3331 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
3332 zzresynch(setwd11, 0x1);
3333 }
3334 }
3335
3336
3337 /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */
3338 /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs */
3339 /* MR2 Don't let #tokdefs be confused by */
3340 /* MR2 DLGminToken and DLGmaxToken */
3341
3342 /* semantic check on DLGminToken and DLGmaxmaxToken in #tokdefs */
3343
3344 #ifdef __USE_PROTOS
3345 static int isDLGmaxToken(char *Token)
3346 #else
3347 static int isDLGmaxToken(Token)
3348 char * Token;
3349 #endif
3350 {
3351 static char checkStr1[] = "DLGmaxToken";
3352 static char checkStr2[] = "DLGminToken";
3353
3354 if (strcmp(Token, checkStr1) == 0)
3355 return 1;
3356 else if (strcmp(Token, checkStr2) == 0)
3357 return 1;
3358 else
3359 return 0;
3360 }
3361
3362 /* semantics of #token */
3363 static void
3364 #ifdef __USE_PROTOS
3365 chkToken(char *t, char *e, char *a, int tnum)
3366 #else
3367 chkToken(t,e,a,tnum)
3368 char *t, *e, *a;
3369 int tnum;
3370 #endif
3371 {
3372 TermEntry *p;
3373
3374 /* check to see that they don't try to redefine a token as a token class */
3375 if ( t!=NULL ) {
3376 p = (TermEntry *) hash_get(Tname, t);
3377 if ( p!=NULL && p->classname ) {
3378 err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t));
3379 if ( a!=NULL ) free((char *)a);
3380 return;
3381 }
3382 }
3383
3384 if ( t==NULL && e==NULL ) { /* none found */
3385 err("#token requires at least token name or rexpr");
3386 }
3387 else if ( t!=NULL && e!=NULL ) { /* both found */
3388 if ( UserDefdTokens ) { /* if #tokdefs, must not define new */
3389 p = (TermEntry *) hash_get(Tname, t);
3390 if ( p == NULL) {
3391 err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));
3392 return;
3393 };
3394 }
3395 Tklink(t, e);
3396 if ( a!=NULL ) {
3397 if ( hasAction(e) ) {
3398 err(eMsg1("redefinition of action for %s; ignored",e));
3399 }
3400 else setHasAction(e, a);
3401 }
3402 }
3403 else if ( t!=NULL ) { /* only one found */
3404 if ( UserDefdTokens ) {
3405 p = (TermEntry *) hash_get(Tname, t);
3406 if (p == NULL) {
3407 err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));
3408 };
3409 return;
3410 }
3411 if ( Tnum( t ) == 0 ) addTname( t );
3412 else {
3413 err(eMsg1("redefinition of token %s; ignored",t));
3414 }
3415 if ( a!=NULL ) {
3416 err(eMsg1("action cannot be attached to a token name (%s); ignored",t));
3417 free((char *)a);
3418 }
3419 }
3420 else if ( e!=NULL ) {
3421 if ( Tnum( e ) == 0 ) addTexpr( e );
3422 else {
3423 if ( hasAction(e) ) {
3424 err(eMsg1("redefinition of action for expr %s; ignored",e));
3425 }
3426 else if ( a==NULL ) {
3427 err(eMsg1("redefinition of expr %s; ignored",e));
3428 }
3429 }
3430 if ( a!=NULL ) setHasAction(e, a);
3431 }
3432
3433 /* if a token type number was specified, then add the token ID and 'tnum'
3434 * pair to the ForcedTokens list. (only applies if an id was given)
3435 */
3436 if ( t!=NULL && tnum>0 )
3437 {
3438 if ( set_el(tnum, reserved_positions) )
3439 {
3440 err(eMsgd("a token has already been forced to token number %d; ignored", tnum));
3441 }
3442 else
3443 {
3444 list_add(&ForcedTokens, newForcedToken(t,tnum));
3445 set_orel(tnum, &reserved_positions);
3446 }
3447 }
3448 }
3449
3450 static int
3451 #ifdef __USE_PROTOS
3452 match_token(char *s, char **nxt)
3453 #else
3454 match_token(s,nxt)
3455 char *s;
3456 char **nxt;
3457 #endif
3458 {
3459 if ( !(*s>='A' && *s<='Z') ) return 0;
3460 s++;
3461 while ( (*s>='a' && *s<='z') ||
3462 (*s>='A' && *s<='Z') ||
3463 (*s>='0' && *s<='9') ||
3464 *s=='_' )
3465 {
3466 s++;
3467 }
3468 if ( *s!=' ' && *s!='}' ) return 0;
3469 *nxt = s;
3470 return 1;
3471 }
3472
3473 static int
3474 #ifdef __USE_PROTOS
3475 match_rexpr(char *s, char **nxt)
3476 #else
3477 match_rexpr(s,nxt)
3478 char *s;
3479 char **nxt;
3480 #endif
3481 {
3482 if ( *s!='"' ) return 0;
3483 s++;
3484 while ( *s!='"' )
3485 {
3486 if ( *s=='\n' || *s=='\r' ) /* MR13 */
3487 warn("eoln found in regular expression");
3488 if ( *s=='\\' ) s++;
3489 s++;
3490 }
3491 *nxt = s+1;
3492 return 1;
3493 }
3494
3495 /*
3496 * Walk a string "{ A .. Z }" where A..Z is a space separated list
3497 * of token references (either labels or reg exprs). Return a
3498 * string "inlineX_set" for some unique integer X. Basically,
3499 * we pretend as if we had seen "#tokclass inlineX { A .. Z }"
3500 * on the input stream outside of an action.
3501 */
3502 char *
3503 #ifdef __USE_PROTOS
3504 inline_set(char *s)
3505 #else
3506 inline_set(s)
3507 char *s;
3508 #endif
3509 {
3510 char *nxt;
3511 fprintf(stderr, "found consumeUntil( {...} )\n");
3512 while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}
3513 if ( *s!='{' )
3514 {
3515 err("malformed consumeUntil( {...} ); missing '{'");
3516 return "bad_set";
3517 }
3518 s++;
3519 while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}
3520 while ( *s!='}' )
3521 {
3522 if ( match_token(s,&nxt) ) fprintf(stderr, "found token %s\n", s);
3523 else if ( match_rexpr(s,&nxt) ) fprintf(stderr, "found rexpr %s\n", s);
3524 else {
3525 err("invalid element in consumeUntil( {...} )");
3526 return "bad_set";
3527 }
3528 s = nxt;
3529 while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}
3530 }
3531 return "inlineX_set";
3532 }
3533
3534 /* ANTLR-specific syntax error message generator
3535 * (define USER_ZZSYN when compiling so don't get 2 definitions)
3536 */
3537 void
3538 #ifdef __USE_PROTOS
3539 zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok,
3540 int k, char *bad_text)
3541 #else
3542 zzsyn(text, tok, egroup, eset, etok, k, bad_text)
3543 char *text, *egroup, *bad_text;
3544 int tok;
3545 int etok;
3546 int k;
3547 SetWordType *eset;
3548 #endif
3549 {
3550 fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);
3551 fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
3552 if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
3553 if ( k==1 ) fprintf(stderr, " missing");
3554 else
3555 {
3556 fprintf(stderr, "; \"%s\" not", bad_text);
3557 if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
3558 }
3559 if ( zzset_deg(eset)>0 ) zzedecode(eset);
3560 else fprintf(stderr, " %s", zztokens[etok]);
3561 if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);
3562 fprintf(stderr, "\n");
3563 }
+0
-2586
contrib/pccts/antlr/antlr.g less more
0 /*
1 * antlr.g -- PCCTS Version 1.xx ANTLR
2 *
3 * Parse an antlr input grammar and build a syntax-diagram.
4 *
5 * Written in itself (needs at least 1.06 to work)
6 *
7 * SOFTWARE RIGHTS
8 *
9 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
10 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
11 * company may do whatever they wish with source code distributed with
12 * PCCTS or the code generated by PCCTS, including the incorporation of
13 * PCCTS, or its output, into commerical software.
14 *
15 * We encourage users to develop software with PCCTS. However, we do ask
16 * that credit is given to us for developing PCCTS. By "credit",
17 * we mean that if you incorporate our source code into one of your
18 * programs (commercial product, research project, or otherwise) that you
19 * acknowledge this fact somewhere in the documentation, research report,
20 * etc... If you like PCCTS and have developed a nice tool with the
21 * output, please mention that you developed it using PCCTS. In
22 * addition, we ask that this header remain intact in our source code.
23 * As long as these guidelines are kept, we expect to continue enhancing
24 * this system and expect to make other tools available as they are
25 * completed.
26 *
27 * ANTLR 1.33
28 * Terence Parr
29 * Parr Research Corporation
30 * with Purdue University and AHPCRC, University of Minnesota
31 * 1989-1995
32 */
33
34 /* MR1 */
35 /* MR1 10-Apr-97 MR1 Replace #if logic with #include "pcctscfg.h" */
36 /* MR1 */
37
38 #header <<
39 #include "pcctscfg.h"
40 #include "set.h"
41 #include <ctype.h>
42 #include "syn.h"
43 #include "hash.h"
44 #include "generic.h"
45 #define zzcr_attr(attr,tok,t)
46 >>
47
48 <<
49
50 /* MR20 G. Hobbelt For Borland C++ 4.x & 5.x compiling with ALL warnings enabled */
51 #if defined(__TURBOC__)
52 #pragma warn -aus /* unused assignment of 'xxx' */
53 #endif
54
55
56 #ifdef __USE_PROTOS
57 static void chkToken(char *, char *, char *, int);
58 #else
59 static void chkToken();
60 #endif
61
62 #ifdef __USE_PROTOS
63 static int isDLGmaxToken(char *Token); /* MR3 */
64 #else
65 static int isDLGmaxToken(); /* MR3 */
66 #endif
67
68 static int class_nest_level = 0;
69
70 /* MR20 G. Hobbelt extern definitions moved to antlr.h */
71
72 >>
73
74 #lexaction <<
75 /* maintained, but not used for now */
76 set AST_nodes_refd_in_actions = set_init;
77 int inAlt = 0;
78 set attribsRefdFromAction = set_init; /* MR20 */
79 int UsedOldStyleAttrib = 0;
80 int UsedNewStyleLabel = 0;
81 #ifdef __USE_PROTOS
82 char *inline_set(char *);
83 #else
84 char *inline_set();
85 #endif
86
87 /* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */
88 /* MR1 in DLG action */
89
90 int tokenActionActive=0; /* MR1 */
91
92 >>
93
94 #lexclass STRINGS
95 #token QuotedTerm "\"" << zzmode(START); >>
96 #token "\n|\r|\r\n" <<
97 zzline++;
98 warn("eoln found in string");
99 zzskip();
100 >>
101 #token "\\(\n|\r|\r\n)" << zzline++; zzmore(); >>
102 #token "\\~[]" << zzmore(); >>
103 #token "~[\n\r\"\\]+" << zzmore(); >>
104
105 #lexclass ACTION_STRINGS
106 #token "\"" << zzmode(ACTIONS); zzmore(); >>
107 #token "\n|\r|\r\n" <<
108 zzline++;
109 warn("eoln found in string (in user action)");
110 zzskip();
111 >>
112 #token "\\(\n|\r|\r\n)" << zzline++; zzmore(); >>
113 #token "\\~[]" << zzmore(); >>
114 #token "~[\n\r\"\\]+" << zzmore(); >>
115
116 #lexclass ACTION_CHARS
117 #token "'" << zzmode(ACTIONS); zzmore(); >>
118 #token "\n|\r|\r\n" <<
119 zzline++;
120 warn("eoln found in char literal (in user action)");
121 zzskip();
122 >>
123 #token "\\~[]" << zzmore(); >>
124 #token "~[\n\r'\\]+" << zzmore(); >>
125
126 #lexclass ACTION_COMMENTS
127 #token "\*/" << zzmode(ACTIONS); zzmore(); >>
128 #token "\*" << zzmore(); >>
129 #token "\n|\r|\r\n" << zzline++; zzmore(); DAWDLE; >>
130 #token "~[\n\r\*]+" << zzmore(); >>
131
132 #lexclass TOK_DEF_COMMENTS
133 #token "\*/" << zzmode(PARSE_ENUM_FILE);
134 zzmore(); >>
135 #token "\*" << zzmore(); >>
136 #token "\n|\r|\r\n" << zzline++; zzmore(); DAWDLE; >>
137 #token "~[\n\r\*]+" << zzmore(); >>
138
139 #lexclass TOK_DEF_CPP_COMMENTS
140 #token "\n|\r|\r\n" << zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE; >>
141 #token "~[\n\r]+" << zzskip(); >>
142
143 #lexclass ACTION_CPP_COMMENTS
144 #token "\n|\r|\r\n" << zzline++; zzmode(ACTIONS); zzmore(); DAWDLE; >>
145 #token "~[\n\r]+" << zzmore(); >>
146
147 #lexclass CPP_COMMENTS
148 #token "\n|\r|\r\n" << zzline++; zzmode(START); zzskip(); DAWDLE; >>
149 #token "~[\n\r]+" << zzskip(); >>
150
151 #lexclass COMMENTS
152 #token "\*/" << zzmode(START); zzskip(); >>
153 #token "\*" << zzskip(); >>
154 #token "\n|\r|\r\n" << zzline++; zzskip(); DAWDLE; >>
155 #token "~[\n\r\*]+" << zzskip(); >>
156
157 /*
158 * This lexical class accepts actions of type [..] and <<..>>
159 *
160 * It translates the following special items for C:
161 *
162 * $j --> "zzaArg(current zztasp, j)"
163 * $i.j --> "zzaArg(zztaspi, j)"
164 * $i.nondigit> "zzaArg(current zztasp, i).nondigit"
165 * $$ --> "zzaRet"
166 * $alnum --> "alnum" (used to ref parameters)
167 * $rule --> "zzaRet"
168 * $retval --> "_retv.retval" if > 1 return values else "_retv"
169 * $[token, text] --> "zzconstr_attr(token, text)"
170 * $[] --> "zzempty_attr()"
171 *
172 * It translates the following special items for C++:
173 * (attributes are now stored with 'Token' and $i's are only
174 * pointers to the Tokens. Rules don't have attributes now.)
175 *
176 * $j --> "_tbj" where b is the block level
177 * $i.j --> "_tij"
178 * $j->nondigit> "_tbj->nondigit"
179 * $$ --> "$$"
180 * $alnum --> "alnum" (used to ref parameters)
181 * $rule --> "$rule"
182 * $retval --> "_retv.retval" if > 1 return values else "_retv"
183 * $[token, text] --> invalid
184 * $[] --> invalid
185 *
186 * And, for trees:
187 *
188 * #0 --> "(*_root)"
189 * #i --> "zzastArg(i)"
190 * #[args] --> "zzmk_ast(zzastnew(), args)"
191 * #[] --> "zzastnew()"
192 * #( root, child1, ..., childn )
193 * --> "zztmake(root, child1, ...., childn, NULL)"
194 * #() --> "NULL"
195 *
196 * For C++, ...
197 *
198 * #0 --> "(*_root)"
199 * #i --> "_astbi" where b is the block level
200 * #alnum --> "alnum_ast" (used to ref #label)
201 * #[args] --> "new AST(args)"
202 * #[] --> "new AST"
203 * #( root, child1, ..., childn )
204 * --> "AST::tmake(root, child1, ...., childn, NULL)"
205 * #() --> "NULL"
206 *
207 * To escape,
208 *
209 * \] --> ]
210 * \) --> )
211 * \$ --> $
212 * \# --> #
213 *
214 * A stack is used to nest action terminators because they can be nested
215 * like crazy: << #[$[..],..] >>
216 */
217 #lexclass ACTIONS
218 #token Action "\>\>" << /* these do not nest */
219 zzmode(START);
220 NLATEXT[0] = ' ';
221 NLATEXT[1] = ' ';
222 zzbegexpr[0] = ' ';
223 zzbegexpr[1] = ' ';
224 if ( zzbufovf ) {
225 err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));
226 }
227
228 /* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */
229 /* MR1 in DLG action */
230 /* MR1 Doesn't matter what kind of action it is - reset*/
231
232 tokenActionActive=0; /* MR1 */
233 >>
234 #token Pred "\>\>?" << /* these do not nest */
235 zzmode(START);
236 NLATEXT[0] = ' ';
237 NLATEXT[1] = ' ';
238 zzbegexpr[0] = '\0';
239 if ( zzbufovf ) {
240 err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));
241 };
242 #ifdef __cplusplus__
243 /* MR10 */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);
244 #else
245 #ifdef __STDC__
246 /* MR10 */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);
247 #else
248 #ifdef __USE_PROTOS
249 /* MRxx */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);
250 #else
251 /* MR10 */ list_apply(CurActionLabels,mark_label_used_in_sem_pred);
252 #endif
253 #endif
254 #endif
255 >>
256 #token PassAction "\]" << if ( topint() == ']' ) {
257 popint();
258 if ( istackempty() ) /* terminate action */
259 {
260 zzmode(START);
261 NLATEXT[0] = ' ';
262 zzbegexpr[0] = ' ';
263 if ( zzbufovf ) {
264 err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));
265 }
266 }
267 else {
268 /* terminate $[..] and #[..] */
269 if ( GenCC ) zzreplstr("))");
270 else zzreplstr(")");
271 zzmore();
272 }
273 }
274 else if ( topint() == '|' ) { /* end of simple [...] */
275 popint();
276 zzmore();
277 }
278 else zzmore();
279 >>
280 #token "consumeUntil\( [\ \t]* \{~[\}]+\} [\ \t]* \)"
281 <<
282 zzmore();
283 zzreplstr(inline_set(zzbegexpr+
284 strlen("consumeUntil(")));
285 >>
286 #token "consumeUntil\( ~[\)]+ \)"
287 << zzmore(); >>
288 #token "\n|\r|\r\n" << zzline++; zzmore(); DAWDLE; >>
289 #token "\>" << zzmore(); >>
290 #token "$" << zzmore(); >>
291 #token "$$" << if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}
292 else err("$$ use invalid in C++ mode"); >>
293
294 #token "$\[\]" << if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}
295 else err("$[] use invalid in C++ mode"); >>
296 #token "$\[" <<
297 pushint(']');
298 if ( !GenCC ) zzreplstr("zzconstr_attr(");
299 else err("$[..] use invalid in C++ mode");
300 zzmore();
301 >>
302 #token "$[0-9]+" <<{
303 static char buf[100];
304 numericActionLabel=1; /* MR10 */
305 if ( strlen(zzbegexpr)>(size_t)85 )
306 fatal("$i attrib ref too big");
307 set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
308 if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",
309 BlkLevel-1,zzbegexpr+1);
310 else sprintf(buf,"_t%d%s",
311 BlkLevel-1,zzbegexpr+1);
312 zzreplstr(buf);
313 zzmore();
314 UsedOldStyleAttrib = 1;
315 if ( UsedNewStyleLabel )
316 err("cannot mix old-style $i with new-style labels");
317 }
318 >>
319 #token "$[0-9]+." <<{
320 static char buf[100];
321 numericActionLabel=1; /* MR10 */
322 if ( strlen(zzbegexpr)>(size_t)85 )
323 fatal("$i.field attrib ref too big");
324 zzbegexpr[strlen(zzbegexpr)-1] = ' ';
325 set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
326 if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",
327 BlkLevel-1,zzbegexpr+1);
328 else sprintf(buf,"_t%d%s.",
329 BlkLevel-1,zzbegexpr+1);
330 zzreplstr(buf);
331 zzmore();
332 UsedOldStyleAttrib = 1;
333 if ( UsedNewStyleLabel )
334 err("cannot mix old-style $i with new-style labels");
335 }
336 >>
337 #token "$[0-9]+.[0-9]+" <<{
338 static char buf[100];
339 static char i[20], j[20];
340 char *p,*q;
341 numericActionLabel=1; /* MR10 */
342 if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big");
343 for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {
344 if ( q == &i[20] )
345 fatalFL("i of $i.j attrib ref too big",
346 FileStr[CurFile], zzline );
347 *q++ = *p;
348 }
349 *q = '\0';
350 for (p++, q= &j[0]; *p!='\0'; p++) {
351 if ( q == &j[20] )
352 fatalFL("j of $i.j attrib ref too big",
353 FileStr[CurFile], zzline );
354 *q++ = *p;
355 }
356 *q = '\0';
357 if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);
358 else sprintf(buf,"_t%s%s",i,j);
359 zzreplstr(buf);
360 zzmore();
361 UsedOldStyleAttrib = 1;
362 if ( UsedNewStyleLabel )
363 err("cannot mix old-style $i with new-style labels");
364 }
365 >>
366 #token "$[_a-zA-Z][_a-zA-Z0-9]*"
367 <<{ static char buf[300]; LabelEntry *el;
368 zzbegexpr[0] = ' ';
369 if ( CurRule != NULL &&
370 strcmp(CurRule, &zzbegexpr[1])==0 ) {
371 if ( !GenCC ) zzreplstr("zzaRet");
372 }
373 else if ( CurRetDef != NULL &&
374 strmember(CurRetDef, &zzbegexpr[1])) {
375 if ( hasMultipleOperands( CurRetDef ) ) {
376 require (strlen(zzbegexpr)<=(size_t)285,
377 "$retval attrib ref too big");
378 sprintf(buf,"_retv.%s",&zzbegexpr[1]);
379 zzreplstr(buf);
380 }
381 else zzreplstr("_retv");
382 }
383 else if ( CurParmDef != NULL &&
384 strmember(CurParmDef, &zzbegexpr[1])) {
385 ;
386 }
387 else if ( Elabel==NULL ) {
388 { err("$-variables in actions outside of rules are not allowed"); }
389 } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) {
390 /* MR10 */
391 /* MR10 */ /* element labels might exist without an elem when */
392 /* MR10 */ /* it is a forward reference (to a rule) */
393 /* MR10 */
394 /* MR10 */ if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) )
395 /* MR10 */ { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); }
396 /* MR10 */
397 /* MR10 */ if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) {
398 /* MR10 */ err("You can no longer use attributes returned by rules when also using ASTs");
399 /* MR10 */ err(" Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...\>\>\")");
400 /* MR10 */ };
401 /* MR10 */
402 /* MR10 */ /* keep track of <<... $label ...>> for semantic predicates in guess mode */
403 /* MR10 */ /* element labels contain pointer to the owners node */
404 /* MR10 */
405 /* MR10 */ if (el->elem != NULL && el->elem->ntype == nToken) {
406 /* MR10 */ list_add(&CurActionLabels,el);
407 /* MR10 */ };
408 }
409 else
410 warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1]));
411 }
412 zzmore();
413 >>
414 #token "#0" << zzreplstr("(*_root)"); zzmore(); chkGTFlag(); >>
415 #token "#\[\]" << if ( GenCC ) {
416 if (NewAST) zzreplstr("(newAST)");
417 else zzreplstr("(new AST)");}
418 else {zzreplstr("zzastnew()");} zzmore();
419 chkGTFlag();
420 >>
421 #token "#\(\)" << zzreplstr("NULL"); zzmore(); chkGTFlag(); >>
422 #token "#[0-9]+" <<{
423 static char buf[100];
424 if ( strlen(zzbegexpr)>(size_t)85 )
425 fatal("#i AST ref too big");
426 if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);
427 else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);
428 zzreplstr(buf);
429 zzmore();
430 set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);
431 chkGTFlag();
432 }
433 >>
434
435 /* MR14 Arpad Beszedes 26-May-98
436 Add support for #line directives when antlr source is pre-processed
437 #lexclass ACTIONS
438 */
439
440 #token "#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)"
441 <<
442 zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();
443 getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);
444 >>
445
446 #token "#line ~[\n\r]* (\n|\r|\r\n)"
447 <<
448 zzline++; zzmore();
449 >>
450
451 /* MR14 end of a block to support #line in antlr source code */
452
453 #token "#[_a-zA-Z][_a-zA-Z0-9]*"
454 <<
455 if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||
456 strcmp(zzbegexpr, "#if")==0 ||
457 strcmp(zzbegexpr, "#else")==0 ||
458 strcmp(zzbegexpr, "#endif")==0 ||
459 strcmp(zzbegexpr, "#ifndef")==0 ||
460 strcmp(zzbegexpr, "#define")==0 ||
461 strcmp(zzbegexpr, "#pragma")==0 ||
462 strcmp(zzbegexpr, "#undef")==0 ||
463 strcmp(zzbegexpr, "#import")==0 ||
464 strcmp(zzbegexpr, "#line")==0 ||
465 strcmp(zzbegexpr, "#include")==0 ||
466 strcmp(zzbegexpr, "#error")==0) )
467 {
468 static char buf[100];
469 sprintf(buf, "%s_ast", zzbegexpr+1);
470 /* MR27 */ list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1));
471 zzreplstr(buf);
472 chkGTFlag();
473 }
474 zzmore();
475 >>
476 #token "#\[" <<
477 pushint(']');
478 if ( GenCC ) {
479 if (NewAST) zzreplstr("(newAST(");
480 else zzreplstr("(new AST("); }
481 else zzreplstr("zzmk_ast(zzastnew(),");
482 zzmore();
483 chkGTFlag();
484 >>
485 #token "#\(" <<
486 pushint('}');
487 if ( GenCC ) {
488 if (tmakeInParser) {
489 zzreplstr("tmake(");
490 }
491 else {
492 zzreplstr("ASTBase::tmake(");
493 }
494 }
495 else {
496 zzreplstr("zztmake(");
497 }
498 zzmore();
499 chkGTFlag();
500 >>
501 #token "#" << zzmore(); >>
502 #token "\)" <<
503 if ( istackempty() )
504 zzmore();
505 else if ( topint()==')' ) {
506 popint();
507 }
508 else if ( topint()=='}' ) {
509 popint();
510 /* terminate #(..) */
511 zzreplstr(", NULL)");
512 }
513 zzmore();
514 >>
515 #token "\[" <<
516 pushint('|'); /* look for '|' to terminate simple [...] */
517 zzmore();
518 >>
519 #token "\(" <<
520 pushint(')');
521 zzmore();
522 >>
523
524 #token "\\\]" << zzreplstr("]"); zzmore(); >>
525 #token "\\\)" << zzreplstr(")"); zzmore(); >>
526
527 /* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */
528 /* MR1 in DLG action */
529
530 #token "\\>" << if (! tokenActionActive) zzreplstr(">"); /* MR1 */
531 zzmore(); /* MR1 */
532 >> /* MR1 */
533
534
535 #token "'" << zzmode(ACTION_CHARS); zzmore();>>
536 #token "\"" << zzmode(ACTION_STRINGS); zzmore();>>
537 #token "\\$" << zzreplstr("$"); zzmore(); >>
538 #token "\\#" << zzreplstr("#"); zzmore(); >>
539 #token "\\(\n|\r|\r\n)" << zzline++; zzmore(); >>
540 #token "\\~[\]\)>$#]" << zzmore(); >> /* escaped char, always ignore */
541 #token "/" << zzmore(); >>
542 #token "/\*" << zzmode(ACTION_COMMENTS); zzmore(); >>
543 #token "\*/" << warn("Missing /*; found dangling */ in action"); zzmore(); >>
544 #token "//" << zzmode(ACTION_CPP_COMMENTS); zzmore(); >>
545 #token "~[\n\r\)\(\\$#\>\]\[\"'/]+" << zzmore(); >>
546
547 #lexclass START
548 #token "[\t\ ]+" << zzskip(); >> /* Ignore White */
549 #token "\n|\r|\r\n" << zzline++; zzskip(); >> /* Track Line # */
550 #token "\[" << zzmode(ACTIONS); zzmore();
551 istackreset();
552 pushint(']'); >>
553 #token "\<\<" << action_file=CurFile; action_line=zzline;
554 zzmode(ACTIONS); zzmore();
555 list_free(&CurActionLabels,0); /* MR10 */
556 numericActionLabel=0; /* MR10 */
557 istackreset();
558 pushint('>'); >>
559 #token "\"" << zzmode(STRINGS); zzmore(); >>
560 #token "/\*" << zzmode(COMMENTS); zzskip(); >>
561 #token "\*/" << warn("Missing /*; found dangling */"); zzskip(); >>
562 #token "//" << zzmode(CPP_COMMENTS); zzskip(); >>
563
564 /* MR14 Arpad Beszedes 26-May-98
565 Add support for #line directives when antlr source is pre-processed
566 #lexclass START
567 */
568
569 #token "#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)"
570 <<
571 zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();
572 getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);
573 >>
574
575 #token "#line ~[\n\r]* (\n|\r|\r\n)"
576 <<
577 zzline++; zzmore();
578 >>
579
580 /* MR14 end of a block to support #line in antlr source code */
581
582 /* */
583 /* 8-Apr-97 Regularize escape sequence for ">>" */
584 /* appearing in string literals */
585 /* */
586
587 #token "\>\>" << warn("Missing <<; found dangling \>\>"); zzskip(); >> /* MR1 */
588 #token WildCard "."
589 #token "\@" <<FoundException = 1; /* MR6 */
590 FoundAtOperator = 1;>> /* MR6 */
591 #token Eof "@"
592 << /* L o o k F o r A n o t h e r F i l e */
593 {
594 FILE *new_input;
595 new_input = NextFile();
596 if ( new_input == NULL ) { NLA=Eof; return; }
597 fclose( input );
598 input = new_input;
599 zzrdstream( input );
600 zzskip(); /* Skip the Eof (@) char i.e continue */
601 }
602 >>
603
604 #token LABEL
605
606 #errclass "grammar-element" { element }
607 #errclass "meta-symbol" { "\}" "!" ";" "\|" "\~" "^" "\)" }
608
609 #token Pragma "{\\}#pragma" /* MR21 */
610 #token FirstSetSymbol "{\\}#FirstSetSymbol" /* MR21 */
611 /*
612 * Get a grammar -- Build a list of rules like:
613 *
614 * o-->Rule1--o
615 * |
616 * o-->Rule2--o
617 * |
618 * ...
619 * |
620 * o-->RuleN--o
621 */
622
623 /* rule grammar */
624
625 grammar : <<Graph g;>>
626 ( "{\\}#header" Action /* MR13 */
627 <<
628 if ( HdrAction==NULL ) {
629 HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
630 require(HdrAction!=NULL, "rule grammar: cannot allocate header action");
631 strcpy(HdrAction, LATEXT(1));
632 }
633 else warn("additional #header statement ignored");
634 >>
635 | "{\\}#first" Action
636 <<
637 if ( FirstAction==NULL ) {
638 FirstAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
639 require(FirstAction!=NULL, "rule grammar: cannot allocate #first action");
640 strcpy(FirstAction, LATEXT(1));
641 } else {
642 warn("additional #first statement ignored");
643 };
644 >>
645
646 | "{\\}#parser" QuotedTerm
647 <<
648 if ( GenCC ) {
649 warn("#parser meta-op incompatible with -CC; ignored");
650 }
651 else {
652 if ( strcmp(ParserName,"zzparser")==0 ) {
653 ParserName=StripQuotes(mystrdup(LATEXT(1)));
654 if ( RulePrefix[0]!='\0' )
655 {
656 warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored");
657 RulePrefix[0]='\0';
658 }
659 }
660 else warn("additional #parser statement ignored");
661 }
662 >>
663 | "{\\}#tokdefs" QuotedTerm
664 <<{
665 char *fname;
666 zzantlr_state st; FILE *f; struct zzdlg_state dst;
667 UserTokenDefsFile = mystrdup(LATEXT(1));
668 zzsave_antlr_state(&st);
669 zzsave_dlg_state(&dst);
670 fname = mystrdup(LATEXT(1));
671 f = fopen(StripQuotes(fname), "r");
672 if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));}
673 else {
674 ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE);
675 UserDefdTokens = 1;
676 }
677 zzrestore_antlr_state(&st);
678 zzrestore_dlg_state(&dst);
679 }>>
680 )*
681 ( Action
682 <<{
683 UserAction *ua = newUserAction(LATEXT(1));
684 ua->file = action_file; ua->line = action_line;
685 if ( class_nest_level>0 ) list_add(&class_before_actions, ua);
686 else list_add(&BeforeActions, ua);
687 }>>
688 | laction
689 | lmember /* MR1 */
690 | lprefix /* MR1 */
691 | aLexclass
692 | token
693 | error
694 | tclass
695 | aPred /* MR11 */
696 | default_exception_handler
697 | class_def
698 | "\}"
699 <<
700 if ( class_nest_level==0 )
701 warn("missing class definition for trailing '}'");
702 class_nest_level--;
703 >>
704 )*
705
706 rule <<g=$3; SynDiag = (Junction *) $3.left;>>
707 ( rule
708
709 <<if ( $1.left!=NULL ) {
710 g.right = NULL;
711
712 /* MR21a */ /* Avoid use of a malformed graph when CannotContinue */
713 /* MR21a */ /* is already set */
714 /* MR21a */
715 /* MR21a */ if (! (CannotContinue && g.left == NULL)) {
716 /* MR21a */ g = Or(g, $1);
717 /* MR21a */ }
718 /* MR21a */ }
719 >>
720
721 | aLexclass
722 | token
723 | error
724 | tclass
725 | aPred /* MR11 */
726 | class_def
727 | "\}"
728 <<
729 if ( class_nest_level==0 )
730 warn("missing class definition for trailing '}'");
731 class_nest_level--;
732 >>
733 )*
734 ( Action
735 <<{
736 UserAction *ua = newUserAction(LATEXT(1));
737 ua->file = action_file; ua->line = action_line;
738 if ( class_nest_level>0 ) list_add(&class_after_actions, ua);
739 else list_add(&AfterActions, ua);
740 }>>
741 | laction
742 | lmember /* MR1 */
743 | lprefix /* MR1 */
744 | error
745 | tclass
746 | class_def
747 | aPred /* MR11 */
748 | "\}"
749 <<
750 if ( class_nest_level==0 )
751 warn("missing class definition for trailing '}'");
752 class_nest_level--;
753 >>
754 )*
755 Eof
756 ;
757 <<CannotContinue=TRUE;>>
758
759 /* rule class_def */
760
761 class_def
762 : <<int go=1; char name[MaxRuleName+1];>>
763 "class"
764 ( NonTerminal <<if(go) strncpy(name,LATEXT(1),MaxRuleName);>>
765 | TokenTerm <<if(go) strncpy(name,LATEXT(1),MaxRuleName);>>
766 )
767 <<
768 if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0
769 && GenCC ) {
770 err("only one grammar class allowed in this release");
771 go = 0;
772 }
773 else strcpy(CurrentClassName, name);
774 >>
775 <<if ( !GenCC ) { err("class meta-op used without C++ option"); }>>
776
777 /* MR10 */ (~ "\{"
778 /* MR10 */ <<if (ClassDeclStuff == NULL) {
779 /* MR10 */ ClassDeclStuff=(char *)calloc(MaxClassDeclStuff+1,sizeof(char));
780 /* MR10 */ };
781 /* MR10 */ strncat(ClassDeclStuff," ",MaxClassDeclStuff);
782 /* MR10 */ strncat(ClassDeclStuff,LATEXT(1),MaxClassDeclStuff);
783 /* MR22 */ do {
784 /* MR22 */ if (0 == strcmp(LATEXT(1),"public")) break;
785 /* MR22 */ if (0 == strcmp(LATEXT(1),"private")) break;
786 /* MR22 */ if (0 == strcmp(LATEXT(1),"protected")) break;
787 /* MR22 */ if (0 == strcmp(LATEXT(1),"virtual")) break;
788 /* MR22 */ if (0 == strcmp(LATEXT(1),",")) break;
789 /* MR22 */ if (0 == strcmp(LATEXT(1),":")) break;
790 /* MR22 */ if (BaseClassName != NULL) break;
791 /* MR22 */ BaseClassName=(char *)calloc(strlen(LATEXT(1))+1,sizeof(char));
792 /* MR22 */ require(BaseClassName!=NULL, "rule grammar: cannot allocate base class name");
793 /* MR22 */ strcpy(BaseClassName,LATEXT(1));
794 /* MR22 */ } while (0);
795 /* MR10 */ >>
796 /* MR10 */ )*
797
798 "\{"
799 <<
800 no_classes_found = 0;
801 if ( class_nest_level>=1 ) {warn("cannot have nested classes");}
802 else class_nest_level++;
803 >>
804 ;
805 <<CannotContinue=TRUE;>>
806
807 /*
808 * Build -o-->o-R-o-->o- where -o-R-o- is the block from rule 'block'.
809 * Construct the RuleBlk front and EndRule node on the end of the
810 * block. This is used to add FOLLOW pointers to the rule end. Add the
811 * new rule name to the Rname hash table and sets its rulenum.
812 * Store the parameter definitions if any are found.
813 *
814 * Note that locks are required on the RuleBlk and EndRule nodes to thwart
815 * infinite recursion.
816 *
817 * Return the left graph pointer == NULL to indicate error/dupl rule def.
818 */
819
820 /* rule rule */
821
822 rule : <<
823
824 ExceptionGroup *eg;
825 RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e;
826 set toksrefd, rulesrefd;
827 char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL;
828 CurExGroups = NULL;
829 CurElementLabels = NULL;
830 CurAstLabelsInActions = NULL; /* MR27 */
831 /* We want a new element label hash table for each rule */
832 if ( Elabel!=NULL ) killHashTable(Elabel);
833 Elabel = newHashTable();
834 attribsRefdFromAction = empty;
835 >>
836 NonTerminal
837 <<q=NULL;
838 if ( hash_get(Rname, LATEXT(1))!=NULL ) {
839 err(eMsg1("duplicate rule definition: '%s'",LATEXT(1)));
840 CannotContinue=TRUE;
841 }
842 else
843 {
844 q = (RuleEntry *)hash_add(Rname,
845 LATEXT(1),
846 (Entry *)newRuleEntry(LATEXT(1)));
847 CurRule = q->str;
848 }
849 CurRuleNode = q;
850 f = CurFile; l = zzline;
851 NumRules++;
852 >>
853 { "!" <<if ( q!=NULL ) q->noAST = TRUE;>> }
854 { <<;>>
855 {"\<"}
856 PassAction
857 << pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
858 require(pdecl!=NULL, "rule rule: cannot allocate param decl");
859 strcpy(pdecl, LATEXT(1));
860 CurParmDef = pdecl;
861 >>
862 }
863 { "\>"
864 PassAction
865 << ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
866 require(ret!=NULL, "rule rule: cannot allocate ret type");
867 strcpy(ret, LATEXT(1));
868 CurRetDef = ret;
869 >>
870 }
871 { QuotedTerm <<if ( q!=NULL ) q->egroup=mystrdup(LATEXT(1));>> }
872 <<
873 if ( GenEClasseForRules && q!=NULL ) {
874 e = newECnode;
875 require(e!=NULL, "cannot allocate error class node");
876 if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);}
877 else a = q->egroup;
878 if ( Tnum( a ) == 0 )
879 {
880 e->tok = addTname( a );
881 list_add(&eclasses, (char *)e);
882 if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
883 /* refers to itself */
884 list_add(&(e->elist), mystrdup(q->str));
885 }
886 else {
887 warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a));
888 if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
889 free((char *)e);
890 }
891 }
892 >>
893 <<BlkLevel++;
894 if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");
895 /* MR23 */ CurBlockID_array[BlkLevel] = CurBlockID;
896 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
897 >>
898
899 ":" <<inAlt=1;>>
900 block[&toksrefd, &rulesrefd]
901 <<r = makeBlk($7,0, NULL /* pFirstSetSymbol */ );
902 CurRuleBlk = (Junction *)r.left;
903 CurRuleBlk->blockid = CurBlockID;
904 CurRuleBlk->jtype = RuleBlk;
905 if ( q!=NULL ) CurRuleBlk->rname = q->str;
906 CurRuleBlk->file = f;
907 CurRuleBlk->line = l;
908 CurRuleBlk->pdecl = pdecl;
909 CurRuleBlk->ret = ret;
910 CurRuleBlk->lock = makelocks();
911 CurRuleBlk->pred_lock = makelocks();
912 CurRuleBlk->tokrefs = toksrefd;
913 CurRuleBlk->rulerefs = rulesrefd;
914 p = newJunction(); /* add EndRule Node */
915 ((Junction *)r.right)->p1 = (Node *)p;
916 r.right = (Node *) p;
917 p->jtype = EndRule;
918 p->lock = makelocks();
919 p->pred_lock = makelocks();
920 CurRuleBlk->end = p;
921 if ( q!=NULL ) q->rulenum = NumRules;
922 $7 = r;
923 >>
924 <<
925 /* MR23 */ CurBlockID_array[BlkLevel] = (-1);
926 /* MR23 */ CurAltNum_array[BlkLevel] = (-1);
927 --BlkLevel;
928 >>
929 <<altFixup();leFixup();egFixup();>> /* MR7 */
930 ";" <<inAlt=0;>>
931 { Action
932 << a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
933 require(a!=NULL, "rule rule: cannot allocate error action");
934 strcpy(a, LATEXT(1));
935 CurRuleBlk->erraction = a;
936 >>
937 }
938 ( exception_group > [eg]
939 <<if ( eg!=NULL ) {
940 list_add(&CurExGroups, (void *)eg);
941 if (eg->label == NULL || *eg->label=='\0' ) q->has_rule_exception = 1;
942 }
943 >>
944 )*
945 <<if ( q==NULL ) $0.left = NULL; else $0 = $7;>>
946 <<CurRuleBlk->exceptions = CurExGroups;>>
947 <<CurRuleBlk->el_labels = CurElementLabels;>>
948 <<CurRuleNode->ast_labels_in_actions = CurAstLabelsInActions;>> /* MR27 */
949 <<CurRuleNode = NULL;>> /* MR27 Moved */
950 ;
951 <<CannotContinue=TRUE;>>
952
953 /*
954 * pragma : "{\\}#pragma" "dup\-labeled\-tokens"
955 * <<Pragma_DupLabeledTokens=1;>>
956 * ;
957 */
958
959 /* rule laction */
960
961 laction : <<char *a;>>
962
963 "{\\}#lexaction"
964 Action
965 <<
966 a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
967 require(a!=NULL, "rule laction: cannot allocate action");
968 strcpy(a, LATEXT(1));
969 list_add(&LexActions, a);
970 >>
971 ;
972 <<CannotContinue=TRUE;>>
973
974 /* MR1 */
975 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
976 /* MR1 via #lexmember <<....>> & #lexprefix <<...>> */
977 /* MR1 */
978
979 /* rule lmember */
980
981 lmember: <<char *a;>> /* MR1 */
982
983 /* MR1 */ "{\\}#lexmember"
984 /* MR1 */ Action
985 /* MR1 */ <<
986 /* MR1 */ if (! GenCC) {
987 /* MR1 */ err("Use #lexmember only in C++ mode (to insert code in DLG class header");
988 /* MR1 */ } else {
989 /* MR1 */ a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
990 /* MR1 */ require(a!=NULL, "rule lmember: cannot allocate action");
991 /* MR1 */ strcpy(a, LATEXT(1));
992 /* MR1 */ list_add(&LexMemberActions, a);
993 /* MR1 */ };
994 /* MR1 */ >>
995 /* MR1 */ ;
996 /* MR1 */ <<CannotContinue=TRUE;>>
997
998 /* rule lprefix */
999
1000 lprefix: <<char *a;>> /* MR1 */
1001
1002 /* MR1 */ "{\\}#lexprefix"
1003 /* MR1 */ Action
1004 /* MR1 */ <<
1005 /* MR1 */ if (! GenCC) {
1006 /* MR1 */ err("Use #lexprefix only in C++ mode (to insert code in DLG class header");
1007 /* MR1 */ } else {
1008 /* MR1 */ a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
1009 /* MR1 */ require(a!=NULL, "rule lprefix: cannot allocate action");
1010 /* MR1 */ strcpy(a, LATEXT(1));
1011 /* MR1 */ list_add(&LexPrefixActions, a);
1012 /* MR1 */ };
1013 /* MR1 */ >>
1014 /* MR1 */ ;
1015 /* MR1 */ <<CannotContinue=TRUE;>>
1016
1017 /*
1018 * #pred upper <<isupper()>>? predicate literal
1019 * #pred lower <<islower()>>? predicate literal
1020 * #pred up_or_low upper || lower predicate expression
1021 * concealed interdependence
1022 * #pred up_or_low_2 <<isletter()>>? A || B predicate literal equals predicate expr
1023 * analyze using lower||upper
1024 * generate using isLetter()
1025 */
1026
1027 /* rule aPref */
1028
1029 aPred: <<PredEntry *predEntry=NULL;
1030 char *name=NULL;
1031 Predicate *predExpr=NULL;
1032 char *predLiteral=NULL;
1033 int save_file;
1034 int save_line;
1035 int predExprPresent=0;
1036 >>
1037
1038 "{\\}#pred"
1039
1040 <<
1041 MR_usingPredNames=1; /* will need to use -mrhoist version of genPredTree */
1042 >>
1043
1044 /* used to allow NonTerminal but it caused problems
1045 when a rule name immediately followed a #pred statement */
1046
1047 TokenTerm <<name=mystrdup(LATEXT(1));>>
1048
1049 <<
1050 /* don't free - referenced in predicates */
1051
1052 CurPredName=(char *)calloc(1,strlen(name) + 10);
1053 strcat(CurPredName,"#pred ");
1054 strcat(CurPredName,name);
1055
1056 predEntry=(PredEntry *) hash_get(Pname,name);
1057 if (predEntry != NULL) {
1058 warnFL(eMsg1("#pred %s previously defined - ignored",name),
1059 FileStr[action_file],action_line);
1060 name=NULL;
1061 };
1062 >>
1063
1064 (
1065
1066 Pred <<predLiteral=mystrdup(LATEXT(1));
1067 save_line=action_line;
1068 save_file=action_file;
1069 >>
1070
1071 {
1072 predOrExpr>[predExpr] <<predExprPresent=1;>>
1073 }
1074
1075 <<if (predLiteral != NULL && name != NULL) {
1076
1077 /*
1078 * predExpr may be NULL due to syntax errors
1079 * or simply omitted by the user
1080 */
1081
1082 predEntry=newPredEntry(name);
1083 predEntry->file=save_file;
1084 predEntry->line=save_line;
1085 predExpr=MR_predFlatten(predExpr);
1086 predEntry->predLiteral=predLiteral;
1087 if (! predExprPresent || predExpr == NULL) {
1088 predExpr=new_pred();
1089 predExpr->expr=predLiteral;
1090 predExpr->source=newActionNode();
1091 predExpr->source->action=predExpr->expr;
1092 predExpr->source->rname=CurPredName;
1093 predExpr->source->line=action_line;
1094 predExpr->source->file=action_file;
1095 predExpr->source->is_predicate=1;
1096 predExpr->k=predicateLookaheadDepth(predExpr->source);
1097 };
1098 predEntry->pred=predExpr;
1099 hash_add(Pname,name,(Entry *)predEntry);
1100 predExpr=NULL;
1101 };
1102 predicate_free(predExpr);
1103 >>
1104
1105 |
1106 <<save_line=zzline; save_file=CurFile;>>
1107
1108 predOrExpr>[predExpr]
1109
1110 <<if (predExpr != NULL && name != NULL) {
1111 predEntry=newPredEntry(name);
1112 predEntry->file=CurFile;
1113 predEntry->line=zzline;
1114 predExpr=MR_predFlatten(predExpr);
1115 predEntry->pred=predExpr;
1116 hash_add(Pname,name,(Entry *)predEntry);
1117 predExpr=NULL;
1118 };
1119 predicate_free(predExpr);
1120 >>
1121 )
1122 {";"}
1123 ;
1124
1125 /* fail */
1126
1127 <<predicate_free(predExpr);
1128 >>
1129
1130 /* rule predOrExpr */
1131
1132 predOrExpr>[Predicate *result] :
1133 <<Predicate *ORnode;
1134 Predicate *predExpr;
1135 Predicate **tail=NULL;
1136 >>
1137 predAndExpr>[predExpr]
1138 <<
1139 ORnode=new_pred();
1140 ORnode->expr=PRED_OR_LIST;
1141 if (predExpr != NULL) {
1142 ORnode->down=predExpr;
1143 tail=&predExpr->right;
1144 };
1145 >>
1146 ( "\|\|" predAndExpr>[predExpr]
1147 <<
1148 if (predExpr != NULL) {
1149 *tail=predExpr;
1150 tail=&predExpr->right;
1151 };
1152 >>
1153 )*
1154 <<
1155 $result=ORnode;
1156 ORnode=NULL;
1157 >>
1158 ;
1159
1160 /* fail */
1161
1162 <<predicate_free(ORnode);>>
1163
1164 /* rule predAndExpr */
1165
1166 predAndExpr>[Predicate *result] :
1167 <<Predicate *ANDnode;
1168 Predicate *predExpr;
1169 Predicate **tail=NULL;
1170 >>
1171 predPrimary>[predExpr]
1172 <<
1173 ANDnode=new_pred();
1174 ANDnode->expr=PRED_AND_LIST;
1175 if (predExpr != NULL) {
1176 ANDnode->down=predExpr;
1177 tail=&predExpr->right;
1178 };
1179 >>
1180 ( "&&" predPrimary>[predExpr]
1181 <<
1182 if (predExpr != NULL) {
1183 *tail=predExpr;
1184 tail=&predExpr->right;
1185 };
1186 >>
1187 )*
1188 <<
1189 $result=ANDnode;
1190 ANDnode=NULL;
1191 >>
1192 ;
1193
1194 /* fail */
1195
1196 <<predicate_free(ANDnode);>>
1197
1198
1199 /* rule predPrimary */
1200
1201 predPrimary>[Predicate *result] :
1202 <<
1203 char *name=NULL;
1204 PredEntry *predEntry=NULL;
1205 Predicate *predExpr=NULL;
1206 >>
1207
1208 TokenTerm <<name=mystrdup(LATEXT(1));>>
1209
1210 <<
1211 predEntry=(PredEntry *) hash_get(Pname,name);
1212 if (predEntry == NULL) {
1213 warnFL(eMsg1("no previously defined #pred with name \"%s\"",name),
1214 FileStr[CurFile],zzline);
1215 name=NULL;
1216 $result=NULL;
1217 } else {
1218 predExpr=predicate_dup(predEntry->pred);
1219 predExpr->predEntry=predEntry;
1220 $result=predExpr;
1221 };
1222 >>
1223
1224 | "\(" predOrExpr>[predExpr] "\)"
1225 <<
1226 $result=predExpr;
1227 >>
1228
1229 | "!" predPrimary>[predExpr]
1230 <<
1231 predExpr->inverted=!predExpr->inverted;
1232 $result=predExpr;
1233 >>
1234 ;
1235
1236 /* fail */ <<
1237 predicate_free(predExpr);
1238 >>
1239
1240 /* rule aLexclass */
1241
1242 aLexclass: "{\\}#lexclass" TokenTerm <<lexclass(mystrdup(LATEXT(1)));>>
1243 ;
1244 <<CannotContinue=TRUE;>>
1245
1246 /* rule error */
1247
1248 error : <<char *t=NULL; ECnode *e; int go=1; TermEntry *p;>>
1249 "{\\}#errclass"
1250 (<<;>> TokenTerm <<t=mystrdup(LATEXT(1));>>
1251 | QuotedTerm <<t=mystrdup(LATEXT(1));>>
1252 )
1253 <<e = newECnode;
1254 require(e!=NULL, "cannot allocate error class node");
1255 e->lexclass = CurrentLexClass;
1256 if ( Tnum( (t=StripQuotes(t)) ) == 0 )
1257 {
1258 if ( hash_get(Texpr, t) != NULL )
1259 warn(eMsg1("errclass name conflicts with regular expression '%s'",t));
1260 e->tok = addTname( t );
1261 set_orel(e->tok, &imag_tokens);
1262 require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
1263 "hash table mechanism is broken");
1264 p->classname = 1; /* entry is errclass name, not token */
1265 list_add(&eclasses, (char *)e);
1266 }
1267 else
1268 {
1269 warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t));
1270 free( (char *)e );
1271 go=0;
1272 }
1273 >>
1274 "\{"
1275 ( NonTerminal <<if ( go ) t=mystrdup(LATEXT(1));>>
1276 | TokenTerm <<if ( go ) t=mystrdup(LATEXT(1));>>
1277 | QuotedTerm <<if ( go ) t=mystrdup(LATEXT(1));>>
1278 )
1279 <<if ( go ) list_add(&(e->elist), t);>>
1280 (
1281 ( NonTerminal <<if ( go ) t=mystrdup(LATEXT(1));>>
1282 | TokenTerm <<if ( go ) t=mystrdup(LATEXT(1));>>
1283 | QuotedTerm <<if ( go ) t=mystrdup(LATEXT(1));>>
1284 )
1285 <<if ( go ) list_add(&(e->elist), t);>>
1286 )*
1287 "\}"
1288 ;
1289 <<CannotContinue=TRUE;>>
1290
1291 /* rule tclass */
1292
1293 tclass : <<char *t=NULL; TCnode *e; int go=1,tok,totok; TermEntry *p, *term, *toterm;>>
1294 <<char *akaString=NULL; int save_file; int save_line;>>
1295 <<char *totext=NULL; >>
1296 "{\\}#tokclass" TokenTerm <<t=mystrdup(LATEXT(1));>>
1297 <<e = newTCnode;
1298 require(e!=NULL, "cannot allocate token class node");
1299 e->lexclass = CurrentLexClass;
1300 if ( Tnum( t ) == 0 )
1301 {
1302 e->tok = addTname( t );
1303 set_orel(e->tok, &imag_tokens);
1304 set_orel(e->tok, &tokclasses);
1305 require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
1306 "hash table mechanism is broken");
1307 p->classname = 1; /* entry is class name, not token */
1308 p->tclass = e; /* save ptr to this tclass def */
1309 list_add(&tclasses, (char *)e);
1310 }
1311 else
1312 {
1313 warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t));
1314 free( (char *)e );
1315 go=0;
1316 }
1317 >>
1318 /* MR23 */ {
1319 /* MR23 */ "\("
1320 /* MR23 */ QuotedTerm
1321 /* MR23 */ <<akaString=mystrdup(StripQuotes(LATEXT(1)));
1322 /* MR11 */ save_file=CurFile;save_line=zzline;
1323 /* MR23 */ >>
1324 /* MR23 */ "\)"
1325 /* MR23 */ }
1326 /* MR23 */
1327 /* MR23 */
1328 /* MR23 */ <<
1329 /* MR23 */ if (p!= NULL && akaString != NULL) {
1330 /* MR23 */ if (p->akaString != NULL) {
1331 /* MR23 */ if (strcmp(p->akaString,akaString) != 0) {
1332 /* MR23 */ warnFL(eMsg2("this #tokclass statment conflicts with a previous #tokclass %s(\"%s\") statement",
1333 /* MR23 */ t,p->akaString),
1334 /* MR23 */ FileStr[save_file],save_line);
1335 /* MR23 */ };
1336 /* MR23 */ } else {
1337 /* MR23 */ p->akaString=akaString;
1338 /* MR23 */ };
1339 /* MR23 */ };
1340 /* MR23 */ >>
1341
1342 "\{"
1343 (
1344 ( TokenTerm
1345 <<if ( go ) {
1346 term = (TermEntry *) hash_get(Tname, LATEXT(1));
1347 if ( term==NULL && UserDefdTokens ) {
1348 err("implicit token definition not allowed with #tokdefs");
1349 go = 0;
1350 }
1351 else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));}
1352 }>>
1353
1354 {
1355 ".."
1356 TokenTerm
1357
1358 <<if ( go ) {
1359 toterm = (TermEntry *) hash_get(Tname, LATEXT(1));
1360 if ( toterm==NULL && UserDefdTokens ) {
1361 err("implicit token definition not allowed with #tokdefs");
1362 go = 0;
1363 } else {
1364 totext=mystrdup(LATEXT(1)); totok=addTname(LATEXT(1));
1365 }
1366 }
1367 >>
1368 }
1369
1370 | QuotedTerm
1371 <<if ( go ) {
1372 term = (TermEntry *) hash_get(Texpr, LATEXT(1));
1373 if ( term==NULL && UserDefdTokens ) {
1374 err("implicit token definition not allowed with #tokdefs");
1375 go = 0;
1376 }
1377 else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));}
1378 }>>
1379 )
1380 <<if ( go ) {
1381 if (totext == NULL) {
1382 list_add(&(e->tlist), t);
1383 } else {
1384 list_add(&(e->tlist),"..");
1385 list_add(&(e->tlist),t);
1386 list_add(&(e->tlist),totext);
1387 }
1388 totext=NULL;
1389 }
1390 >>
1391 )+ // MR15 Manfred Kogler - forbid empty #tokclass sets (was "+")
1392 "\}"
1393 ;
1394 <<CannotContinue=TRUE;>>
1395
1396 /* rule token */
1397
1398 token : <<char *t=NULL, *e=NULL, *a=NULL; int tnum=0;>>
1399 <<char *akaString=NULL; TermEntry *te;int save_file=0,save_line=0;>> /* MR11 */
1400 "{\\}#token"
1401
1402 /* MR1 10-Apr-97 MR1 Allow shift right operator in DLG actions */
1403 /* MR1 Danger when parser feedback to lexer */
1404 /* MR1 */
1405
1406 <<tokenActionActive=1;>> /* MR1 */
1407 { TokenTerm <<t=mystrdup(LATEXT(1));>>
1408
1409 /* MR11 */ {
1410 /* MR11 */ "\("
1411 /* MR11 */ QuotedTerm
1412 /* MR11 */ <<akaString=mystrdup(StripQuotes(LATEXT(1)));
1413 /* MR11 */ save_file=CurFile;save_line=zzline;
1414 /* MR11 */ >>
1415 /* MR11 */ "\)"
1416 /* MR11 */ }
1417
1418 { "=" "[0-9]+" /* define the token type number */
1419 <<tnum = atoi(LATEXT(1));>>
1420 }
1421 }
1422 { QuotedTerm <<e=mystrdup(LATEXT(1));>> }
1423 { Action
1424 <<
1425 a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
1426 require(a!=NULL, "rule token: cannot allocate action");
1427 strcpy(a, LATEXT(1));
1428 >>
1429 }
1430
1431 { ";" } /* MR11 */
1432
1433 <<chkToken(t, e, a, tnum);>>
1434
1435 <<if (t != NULL) {
1436 te=(TermEntry *)hash_get(Tname,t);
1437 if (te != NULL && akaString != NULL) {
1438 if (te->akaString != NULL) {
1439 if (strcmp(te->akaString,akaString) != 0) {
1440 warnFL(eMsg2("this #token statment conflicts with a previous #token %s(\"%s\") statement",
1441 t,te->akaString),
1442 FileStr[save_file],save_line);
1443 };
1444 } else {
1445 te->akaString=akaString;
1446 };
1447 };
1448 };
1449 >>
1450 ;
1451 <<CannotContinue=TRUE;>>
1452
1453 /* rule block */
1454
1455 block[set *toksrefd, set *rulesrefd]
1456 : <<
1457 Graph g, b;
1458 set saveblah;
1459 int saveinalt = inAlt;
1460 ExceptionGroup *eg;
1461 *$toksrefd = empty;
1462 *$rulesrefd = empty;
1463 set_clr(AST_nodes_refd_in_actions);
1464 CurBlockID++;
1465 /* MR23 */ CurBlockID_array[BlkLevel] = CurBlockID;
1466 CurAltNum = 1;
1467 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
1468 saveblah = attribsRefdFromAction;
1469 attribsRefdFromAction = empty;
1470 >>
1471
1472 alt[toksrefd,rulesrefd] <<b = g = $1;>>
1473
1474 <<
1475 if ( ((Junction *)g.left)->p1->ntype == nAction )
1476 {
1477 ActionNode *actionNode=(ActionNode *)
1478 ( ( (Junction *)g.left) ->p1);
1479 if (!actionNode->is_predicate )
1480 {
1481 actionNode->init_action = TRUE;
1482 /* MR12c */ if (actionNode->noHoist) {
1483 /* MR12c */ errFL("<<nohoist>> appears as init-action - use <<>> <<nohoist>>",
1484 /* MR12c */ FileStr[actionNode->file],actionNode->line);
1485 /* MR12c */ };
1486 }
1487 }
1488 ((Junction *)g.left)->blockid = CurBlockID;
1489 >>
1490
1491 ( exception_group > [eg]
1492 <<
1493 if ( eg!=NULL ) {
1494 /* MR7 ***** eg->altID = makeAltID(CurBlockID,CurAltNum); *****/
1495 /* MR7 ***** CurAltStart->exception_label = eg->altID; *****/
1496 list_add(&CurExGroups, (void *)eg);
1497 }
1498 >>
1499 )*
1500 <<CurAltNum++;
1501 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
1502 >>
1503
1504 ( "\|" <<inAlt=1;>>
1505 alt[toksrefd,rulesrefd] <<g = Or(g, $2);>>
1506 <<
1507 ((Junction *)g.left)->blockid = CurBlockID;
1508 >>
1509
1510 ( exception_group > [eg]
1511 <<
1512 if ( eg!=NULL ) {
1513 /* MR7 ***** eg->altID = makeAltID(CurBlockID,CurAltNum); *****/
1514 /* MR7 ***** CurAltStart->exception_label = eg->altID; *****/
1515 list_add(&CurExGroups, (void *)eg);
1516 }
1517 >>
1518 )*
1519
1520 <<CurAltNum++;
1521 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
1522 >>
1523
1524 )*
1525 <<$0 = b;>>
1526 <<attribsRefdFromAction = saveblah; inAlt = saveinalt;>>
1527 ;
1528 <<CannotContinue=TRUE;>>
1529
1530 /* rule alt */
1531
1532 alt[set *toksrefd, set *rulesrefd]
1533 : <<int n=0; Graph g; int e_num=0, old_not=0; Node *node; set elems, dif;
1534 int first_on_line = 1, use_def_MT_handler = 0;
1535 g.left=NULL; g.right=NULL;
1536
1537 CurAltStart = NULL;
1538 elems = empty;
1539 inAlt = 1;
1540 >>
1541 { "\@" /* handle MismatchedToken signals with default handler */
1542 <<use_def_MT_handler = 1;>>
1543 }
1544
1545 ( <<;>> /* MR9 Removed unreferenced variable "tok" */
1546 { <<old_not=0;>> "\~" <<old_not=1;>> }
1547 element[old_not, first_on_line, use_def_MT_handler] > [node]
1548 <<if ( node!=NULL && node->ntype!=nAction ) first_on_line = 0;>>
1549 <<
1550 if ( $2.left!=NULL ) {
1551 g = Cat(g, $2);
1552 n++;
1553 if ( node!=NULL ) {
1554 if ( node->ntype!=nAction ) e_num++;
1555 /* record record number of all rule and token refs */
1556 if ( node->ntype==nToken ) {
1557 TokNode *tk = (TokNode *)((Junction *)$2.left)->p1;
1558 tk->elnum = e_num;
1559 set_orel(e_num, &elems);
1560 }
1561 else if ( node->ntype==nRuleRef ) {
1562 RuleRefNode *rn = (RuleRefNode *)((Junction *)$2.left)->p1;
1563 rn->elnum = e_num;
1564 set_orel(e_num, $rulesrefd);
1565 }
1566 }
1567 }
1568 >>
1569 )*
1570 <<if ( n == 0 ) g = emptyAlt();
1571 $0 = g;
1572 /* We want to reduce number of LT(i) calls and the number of
1573 * local attribute variables in C++ mode (for moment, later we'll
1574 * do for C also). However, if trees are being built, they
1575 * require most of the attrib variables to create the tree nodes
1576 * with; therefore, we gen a token ptr for each token ref in C++
1577 */
1578 if ( GenCC && !GenAST )
1579 {
1580 /* This now free's the temp set -ATG 5/6/95 */
1581 set temp;
1582 temp = set_and(elems, attribsRefdFromAction);
1583 set_orin($toksrefd, temp);
1584 set_free(temp);
1585 }
1586 else set_orin($toksrefd, elems);
1587 if ( GenCC ) {
1588 dif = set_dif(attribsRefdFromAction, elems);
1589 if ( set_deg(dif)>0 )
1590 err("one or more $i in action(s) refer to non-token elements");
1591 set_free(dif);
1592 }
1593 set_free(elems);
1594 set_free(attribsRefdFromAction);
1595 inAlt = 0;
1596 >>
1597 ;
1598 <<CannotContinue=TRUE;>>
1599
1600 /* rule element_label */
1601
1602 element_label > [LabelEntry *label]
1603 : <<TermEntry *t=NULL; LabelEntry *l=NULL; RuleEntry *r=NULL; char *lab;>>
1604 LABEL <<lab = mystrdup(LATEXT(1));>>
1605 <<
1606 UsedNewStyleLabel = 1;
1607 if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i");
1608 t = (TermEntry *) hash_get(Tname, lab);
1609 if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab);
1610 if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab);
1611 if ( t!=NULL ) {
1612 err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab));
1613 $label = NULL;
1614 }
1615 else if ( r!=NULL ) {
1616 err(eMsg1("label definition clashes with rule definition: '%s'", lab));
1617 $label = NULL;
1618 }
1619 else {
1620 /* we don't clash with anybody else */
1621 l = (LabelEntry *) hash_get(Elabel, lab);
1622 if ( l==NULL ) { /* ok to add new element label */
1623 l = (LabelEntry *)hash_add(Elabel,
1624 lab,
1625 (Entry *)newLabelEntry(lab));
1626 /* add to list of element labels for this rule */
1627 list_add(&CurElementLabels, (void *)lab);
1628 /* MR7 */ leAdd(l); /* list of labels waiting for exception group definitions */
1629 $label = l;
1630 }
1631 else {
1632 err(eMsg1("label definitions must be unique per rule: '%s'", lab));
1633 $label = NULL;
1634 }
1635 }
1636 >>
1637 ":"
1638 ;
1639
1640 /* rule element */
1641
1642 element[int old_not, int first_on_line, int use_def_MT_handler] > [Node *node]
1643 : <<
1644 Attrib blk;
1645 Predicate *pred = NULL;
1646 int local_use_def_MT_handler=0;
1647 ActionNode *act;
1648 RuleRefNode *rr;
1649 set toksrefd, rulesrefd;
1650 TermEntry *term;
1651 TokNode *p=NULL; RuleRefNode *q; int approx=0;
1652 LabelEntry *label=NULL;
1653 int predMsgDone=0;
1654 int semDepth=0;
1655 int ampersandStyle;
1656 int height; /* MR11 */
1657 int equal_height; /* MR11 */
1658
1659 char* pFirstSetSymbol = NULL; /* MR21 */
1660
1661 $node = NULL;
1662 >>
1663 {element_label>[label]}
1664 ( TokenTerm
1665 <<
1666 term = (TermEntry *) hash_get(Tname, LATEXT(1));
1667 if ( term==NULL && UserDefdTokens ) {
1668 err("implicit token definition not allowed with #tokdefs");
1669 $$.left = $$.right = NULL;
1670 }
1671 else {
1672 $$ = buildToken(LATEXT(1));
1673 p=((TokNode *)((Junction *)$$.left)->p1);
1674 term = (TermEntry *) hash_get(Tname, LATEXT(1));
1675 require( term!= NULL, "hash table mechanism is broken");
1676 p->tclass = term->tclass;
1677 p->complement = $old_not;
1678 if ( label!=NULL ) {
1679 p->el_label = label->str;
1680 label->elem = (Node *)p;
1681 }
1682 }
1683 >>
1684 { ".."
1685 ( QuotedTerm
1686 <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>
1687 | TokenTerm
1688 <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>
1689 )
1690 }
1691 <<
1692 if ( p!=NULL && (p->upper_range!=0 || p->tclass || $old_not) )
1693 list_add(&MetaTokenNodes, (void *)p);
1694 >>
1695 ( "^" <<if ( p!=NULL ) p->astnode=ASTroot;>>
1696 | <<if ( p!=NULL ) p->astnode=ASTchild;>>
1697 | "!" <<if ( p!=NULL ) p->astnode=ASTexclude;>>
1698 )
1699 { "\@" <<local_use_def_MT_handler = 1;>> }
1700 <<
1701 if ( p!=NULL && $first_on_line ) {
1702 CurAltStart = (Junction *)$$.left;
1703 altAdd(CurAltStart); /* MR7 */
1704 p->altstart = CurAltStart;
1705 }
1706 if ( p!=NULL )
1707 p->use_def_MT_handler = $use_def_MT_handler || local_use_def_MT_handler;
1708 $node = (Node *)p;
1709 >>
1710 | QuotedTerm
1711 <<
1712 term = (TermEntry *) hash_get(Texpr, LATEXT(1));
1713 if ( term==NULL && UserDefdTokens ) {
1714 err("implicit token definition not allowed with #tokdefs");
1715 $$.left = $$.right = NULL;
1716 }
1717 else {
1718 $$ = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1);
1719 p->complement = $old_not;
1720 if ( label!=NULL ) {
1721 p->el_label = label->str;
1722 label->elem = (Node *)p;
1723 }
1724 }
1725 >>
1726 { ".."
1727 ( QuotedTerm
1728 <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>
1729 | TokenTerm
1730 <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>
1731 )
1732 }
1733 ( "^" <<if ( p!=NULL ) p->astnode=ASTroot;>>
1734 | <<if ( p!=NULL ) p->astnode=ASTchild;>>
1735 | "!" <<if ( p!=NULL ) p->astnode=ASTexclude;>>
1736 )
1737 { "\@" <<local_use_def_MT_handler = 1;>> }
1738 <<
1739 if ( p!=NULL && (p->upper_range!=0 || p->tclass || $old_not) )
1740 list_add(&MetaTokenNodes, (void *)p);
1741 >>
1742 <<
1743 if ( $first_on_line ) {
1744 CurAltStart = (Junction *)$$.left;
1745 altAdd(CurAltStart); /* MR7 */
1746 p->altstart = CurAltStart;
1747 }
1748 if ( p!=NULL )
1749 p->use_def_MT_handler = $use_def_MT_handler || local_use_def_MT_handler;
1750 $node = (Node *)p;
1751 >>
1752
1753 | <<if ( $old_not ) warn("~ WILDCARD is an undefined operation (implies 'nothing')");>>
1754 "."
1755 <<$$ = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1);>>
1756 ( "^" <<p->astnode=ASTroot;>>
1757 | <<p->astnode=ASTchild;>>
1758 | "!" <<p->astnode=ASTexclude;>>
1759 )
1760 <<list_add(&MetaTokenNodes, (void *)p);>>
1761 <<
1762 if ( $first_on_line ) {
1763 CurAltStart = (Junction *)$$.left;
1764 altAdd(CurAltStart); /* MR7 */
1765 p->altstart = CurAltStart;
1766 if ( label!=NULL ) {
1767 p->el_label = label->str;
1768 label->elem = (Node *)p;
1769 }
1770 }
1771 $node = (Node *)p;
1772 >>
1773
1774 | <<if ( $old_not ) warn("~ NONTERMINAL is an undefined operation");>>
1775 NonTerminal
1776 <<$$ = buildRuleRef(LATEXT(1));>>
1777 { "!" <<q = (RuleRefNode *) ((Junction *)$$.left)->p1;
1778 q->astnode=ASTexclude;>>
1779 }
1780 { {"\<"}
1781 PassAction <<addParm(((Junction *)$$.left)->p1, LATEXT(1));>>
1782 }
1783 <<rr=(RuleRefNode *) ((Junction *)$$.left)->p1;>>
1784 { <<char *a;>>
1785 "\>"
1786 PassAction
1787 <<
1788 a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
1789 require(a!=NULL, "rule element: cannot allocate assignment");
1790 strcpy(a, LATEXT(1));
1791 rr->assign = a;
1792 >>
1793 }
1794 <<
1795 if ( label!=NULL ) {
1796 rr->el_label = label->str;
1797 label->elem = (Node *)rr;
1798 }
1799 if ( $first_on_line ) {
1800 CurAltStart = (Junction *)$$.left;
1801 altAdd(CurAltStart); /* MR7 */
1802 ((RuleRefNode *)((Junction *)$$.left)->p1)->altstart = CurAltStart;
1803 }
1804 $node = (Node *)rr;
1805 >>
1806 )
1807
1808 | <<if ( $old_not ) warn("~ ACTION is an undefined operation");>>
1809 Action <<$0 = buildAction(LATEXT(1),action_file,action_line, 0);>>
1810 <<if ( $first_on_line ) { /* MR7 */
1811 CurAltStart = (Junction *)$0.left; /* MR7 */
1812 altAdd(CurAltStart); /* MR7 */
1813 };>> /* MR7 */
1814 <<$node = (Node *) ((Junction *)$0.left)->p1;>>
1815
1816 | <<if ( $old_not ) warn("~ SEMANTIC-PREDICATE is an undefined operation");>>
1817 Pred <<$0 = buildAction(LATEXT(1),action_file,action_line, 1);>>
1818 <<act = (ActionNode *) ((Junction *)$0.left)->p1;>>
1819 <<if (numericActionLabel) { /* MR10 */
1820 list_add(&NumericPredLabels,act); /* MR10 */
1821 numericActionLabel=0; /* MR10 */
1822 }; /* MR10 */
1823 >>
1824 { <<char *a;>>
1825 PassAction
1826 <<
1827 a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
1828 require(a!=NULL, "rule element: cannot allocate predicate fail action");
1829 strcpy(a, LATEXT(1));
1830 act->pred_fail = a;
1831 >>
1832 }
1833 <<if ( $first_on_line ) { /* MR7 */
1834 CurAltStart = (Junction *)$0.left; /* MR7 */
1835 altAdd(CurAltStart); /* MR7 */
1836 };>> /* MR7 */
1837 <<$node = (Node *)act;>>
1838
1839 | <<if ( $old_not ) warn("~ BLOCK is an undefined operation");>>
1840 <<BlkLevel++;
1841 if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");
1842 /* MR23 */ CurBlockID_array[BlkLevel] = CurBlockID;
1843 /* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum;
1844 >>
1845 { Pragma
1846 ( "approx" <<approx=LL_k;>>
1847 | "LL\(1\)" <<approx = 1;>> /* MR20 */
1848 | "LL\(2\)" <<approx = 2;>> /* MR20 */
1849 )
1850 }
1851
1852 /* MR21 */ { FirstSetSymbol
1853 /* MR21 */ "\("
1854 /* MR21 */ ( NonTerminal
1855 /* MR21 */ <<
1856 /* MR21 */ pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,
1857 /* MR21 */ sizeof(char));
1858 /* MR21 */ require(pFirstSetSymbol!=NULL,
1859 /* MR21 */ "cannot allocate first set name");
1860 /* MR21 */ strcpy(pFirstSetSymbol, LATEXT(1));
1861 /* MR21 */ >>
1862 /* MR21 */ | TokenTerm
1863 /* MR21 */ <<
1864 /* MR21 */ pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,
1865 /* MR21 */ sizeof(char));
1866 /* MR21 */ require(pFirstSetSymbol!=NULL,
1867 /* MR21 */ "cannot allocate first set name");
1868 /* MR21 */ strcpy(pFirstSetSymbol, LATEXT(1));
1869 /* MR21 */ >>
1870 /* MR21 */ )
1871 /* MR21 */ "\)"
1872 /* MR21 */ }
1873
1874 (
1875
1876 "\(" block[&toksrefd,&rulesrefd] "\)"
1877 <<blk = $$ = $2;
1878 /* MR23 */ CurBlockID_array[BlkLevel] = (-1);
1879 /* MR23 */ CurAltNum_array[BlkLevel] = (-1);
1880 --BlkLevel;
1881 >>
1882
1883 ( "\*" <<$$ = makeLoop($$,approx,pFirstSetSymbol);>>
1884 | "\+" <<$$ = makePlus($$,approx,pFirstSetSymbol);>>
1885 | "?"
1886 (
1887 ( "=>" <<ampersandStyle=0;>>
1888 | "&&" <<ampersandStyle=1;>> /* MR10 (g)? && <<p>>? */
1889 )
1890 Pred /* generalized predicate */
1891 /* first make into a predicate */
1892 <<$$ = buildAction(LATEXT(1),action_file,action_line,1);>>
1893 <<act = (ActionNode *) ((Junction *)$$.left)->p1;>>
1894 <<semDepth=predicateLookaheadDepth(act);>> /* MR10 */
1895 <<if (numericActionLabel) { /* MR10 */
1896 list_add(&NumericPredLabels,act); /* MR10 */
1897 numericActionLabel=0; /* MR10 */
1898 }; /* MR10 */
1899 >>
1900 { <<char *a;>>
1901 PassAction
1902 <<
1903 a = (char *)calloc(strlen(LATEXT(1))+1, sizeof(char));
1904 require(a!=NULL, "rule element: cannot allocate predicate fail action");
1905 strcpy(a, LATEXT(1));
1906 act->pred_fail = a;
1907 >>
1908 }
1909 <<if ($first_on_line) { /* MR7 */
1910 CurAltStart=(Junction *)$$.left; /* MR7 */
1911 altAdd(CurAltStart); /* MR7 */
1912 };>>
1913 <<$node = (Node *)act;>>
1914
1915 /* for now, just snag context */
1916 <<
1917 pred = computePredFromContextGuard(blk,&predMsgDone); /* MR10 */
1918 if ( pred==NULL) { /* MR10 */
1919 if ( !predMsgDone) err("invalid or missing context guard"); /* MR10 */
1920 predMsgDone=1; /* MR10 */
1921 } else { /* MR10 */
1922 act->guardNodes=(Junction *)blk.left; /* MR11 */
1923 pred->expr = act->action;
1924 pred->source = act;
1925 /* MR10 */ pred->ampersandStyle = ampersandStyle; /* 0 means (g)? => ... 1 means (g)? && ... */
1926 /* MR13 */ if (pred->tcontext != NULL) {
1927 /* MR13 */ height=MR_max_height_of_tree(pred->tcontext);
1928 /* MR13 */ equal_height=MR_all_leaves_same_height(pred->tcontext,height);
1929 /* MR13 */ if (! equal_height) {
1930 /* MR13 */ errFL("in guarded predicates all tokens in the guard must be at the same height",
1931 /* MR13 */ FileStr[act->file],act->line);
1932 /* MR13 */ };
1933 /* MR13 */ }
1934 /* MR10 */ if (ampersandStyle) {
1935 /* MR10 */ act->ampersandPred = pred;
1936 /* MR11 */ if (! HoistPredicateContext) {
1937 /* MR11 */ errFL("without \"-prc on\" (guard)? && <<pred>>? ... doesn't make sense",
1938 /* MR11 */ FileStr[act->file],act->line);
1939 /* MR11 */ };
1940 /* MR10 */ } else {
1941 /* MR10 */ act->guardpred = pred;
1942 /* MR10 */ };
1943 /* MR10 */ if (pred->k != semDepth) {
1944 /* MR10 */ warn(eMsgd2("length of guard (%d) does not match the length of semantic predicate (%d)",
1945 /* MR10 */ pred->k,semDepth));
1946 /* MR10 */ };
1947 }
1948 >>
1949 | <<$$ = makeBlk($$,approx,pFirstSetSymbol);
1950 FoundGuessBlk = 1;
1951 ((Junction *) ((Junction *)$$.left)->p1)->guess=1;
1952 if ( !$first_on_line ) {
1953 err("(...)? predicate must be first element of production");
1954 }
1955 >>
1956 )
1957 | <<$$ = makeBlk($$,approx,pFirstSetSymbol);>>
1958 )
1959 <<
1960 if ( pred==NULL && !predMsgDone) { /* MR10 */
1961 ((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID;
1962 ((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd;
1963 ((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd;
1964 if ( $first_on_line ) { /* MR7 */
1965 CurAltStart = (Junction *)((Junction *)((Junction *)$$.left)->p1); /* MR7 */
1966 altAdd(CurAltStart); /* MR7 */
1967 }; /* MR7 */
1968 $node = (Node *) ((Junction *)$$.left)->p1;
1969 }
1970 >>
1971
1972 | "\{" block[&toksrefd,&rulesrefd]
1973 <<$$ = makeOpt($2,approx,pFirstSetSymbol);
1974 /* MR23 */ CurBlockID_array[BlkLevel] = (-1);
1975 /* MR23 */ CurAltNum_array[BlkLevel] = (-1);
1976 --BlkLevel;
1977 >>
1978 "\}"
1979 <<
1980 ((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID;
1981 ((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd;
1982 ((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd;
1983 >>
1984 <<if ( $first_on_line ) { /* MR7 */
1985 CurAltStart = (Junction *) ((Junction *)((Junction *)$$.left)->p1); /* MR7 */
1986 altAdd(CurAltStart); /* MR7 */
1987 };
1988 >>
1989 <<$node = (Node *) ((Junction *)$$.left)->p1;>>
1990
1991 )
1992
1993 /* Error catching alternatives */
1994 | "\*" <<warn("don't you want a ')' with that '*'?"); CannotContinue=TRUE;>>
1995 | "\+" <<warn("don't you want a ')' with that '+'?"); CannotContinue=TRUE;>>
1996 | "\>" <<warn("'>' can only appear after a nonterminal"); CannotContinue=TRUE;>>
1997 | PassAction <<warn("[...] out of context 'rule > [...]'");
1998 CannotContinue=TRUE;>>
1999 ;
2000 <<CannotContinue=TRUE;>>
2001
2002 /* rule default_exception_handler */
2003
2004 default_exception_handler
2005 : exception_group > [DefaultExGroup]
2006 ;
2007
2008 /* rule exception_group */
2009
2010 exception_group > [ExceptionGroup *eg]
2011 : <<ExceptionHandler *h; LabelEntry *label=NULL; /* MR6 */
2012 FoundException = 1; FoundExceptionGroup = 1;>> /* MR6 */
2013
2014 "exception" <<$eg = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));>>
2015 { <<char *p;>>
2016 PassAction /* did they attach a label? */
2017 <<
2018 p = LATEXT(1)+1;
2019 p[strlen(p)-1] = '\0'; /* kill trailing space */
2020 label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1);
2021 if ( label==NULL )
2022 {
2023 err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1));
2024 }
2025 >>
2026 }
2027 ( exception_handler > [h]
2028 <<list_add(&($eg->handlers), (void *)h);>>
2029 )*
2030 { "default" ":" Action
2031 <<{
2032 ExceptionHandler *eh = (ExceptionHandler *)
2033 calloc(1, sizeof(ExceptionHandler));
2034 char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2035 require(eh!=NULL, "exception: cannot allocate handler");
2036 require(a!=NULL, "exception: cannot allocate action");
2037 strcpy(a, LATEXT(1));
2038 eh->action = a;
2039 eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char));
2040 require(eh->signalname!=NULL, "exception: cannot allocate sig name");
2041 strcpy(eh->signalname, "default");
2042 list_add(&($eg->handlers), (void *)eh);
2043 }>>
2044 }
2045
2046 <<
2047 if ( label!=NULL ) {
2048 /* Record ex group in sym tab for this label */
2049 if ( label->ex_group!=NULL ) {
2050 err(eMsg1("duplicate exception handler for label '%s'",label->str));
2051 } else {
2052 label->ex_group = $eg;
2053 /* Label the exception group itself */
2054 $eg->label = label->str;
2055 /* Make the labelled element pt to the exception also */
2056 /* MR6 */ if (label->elem == NULL) {
2057 /* MR6 */ err(eMsg1("reference in exception handler to undefined label '%s'",label->str));
2058 /* MR6 */ } else {
2059 switch ( label->elem->ntype ) {
2060 case nRuleRef :
2061 {
2062 RuleRefNode *r = (RuleRefNode *)label->elem;
2063 r->ex_group = $eg;
2064 break;
2065 }
2066 case nToken :
2067 {
2068 TokNode *t = (TokNode *)label->elem;
2069 t->ex_group = $eg;
2070 break;
2071 }
2072 } /* end switch */
2073 /* MR6 */ }; /* end test on label->elem */
2074 } /* end test on label->ex_group */
2075
2076 } /* end test on exception label */
2077
2078 /* MR7 */
2079 /* MR7 */ if (BlkLevel == 1 && label == NULL) {
2080 /* MR7 */ $eg->forRule=1;
2081 /* MR7 */ } else if (label == NULL) {
2082 /* MR7 */ $eg->altID = makeAltID(CurBlockID_array[BlkLevel], CurAltNum_array[BlkLevel]);
2083 /* MR7 */ egAdd($eg);
2084 /* MR7 */ } else {
2085 /* MR7 */ $eg->labelEntry=label;
2086 /* MR7 */ };
2087 /* MR7 */
2088 /* MR7 */ /* You may want to remove this exc from the rule list */
2089 /* MR7 */ /* and handle at the labeled element site. */
2090 /* MR7 */
2091 /* MR7 */ if (label != NULL) {
2092 /* MR7 */ $eg = NULL;
2093 /* MR7 */ };
2094
2095 >>
2096 ;
2097 <<CannotContinue=TRUE;>>
2098
2099 /* rule exception_handler */
2100
2101 exception_handler > [ExceptionHandler *eh]
2102 : <<;>> /* MR9 Removed unreferenced variable "a" */
2103 "catch"
2104 <<
2105 $eh = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler));
2106 require($eh!=NULL, "exception: cannot allocate handler");
2107 >>
2108 ( NonTerminal
2109 <<
2110 $eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2111 require($eh->signalname!=NULL, "exception: cannot allocate sig name");
2112 strcpy($eh->signalname, LATEXT(1));
2113 >>
2114 | TokenTerm
2115 <<
2116 $eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2117 require($eh->signalname!=NULL, "exception: cannot allocate sig name");
2118 strcpy($eh->signalname, LATEXT(1));
2119 >>
2120 )
2121 ":"
2122 { <<$eh->action = NULL;>>
2123 Action
2124 <<
2125 $eh->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2126 require($eh->action!=NULL, "exception: cannot allocate action");
2127 strcpy($eh->action, LATEXT(1));
2128 >>
2129 }
2130 ;
2131 <<CannotContinue=TRUE;>>
2132
2133 #token NonTerminal "[a-z] [A-Za-z0-9_]*"
2134 <<
2135 while ( zzchar==' ' || zzchar=='\t' ) {
2136 zzadvance();
2137 }
2138 if ( zzchar == ':' && inAlt ) NLA = LABEL;
2139 >>
2140 #token TokenTerm "[A-Z] [A-Za-z0-9_]*"
2141 <<
2142 while ( zzchar==' ' || zzchar=='\t' ) {
2143 zzadvance();
2144 }
2145 if ( zzchar == ':' && inAlt ) NLA = LABEL;
2146 >>
2147 #token "{\\}#[A-Za-z0-9_]*" <<warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip(); >>
2148
2149 #lexclass PARSE_ENUM_FILE
2150
2151 #token "[\t\ ]+" << zzskip(); >> /* Ignore White */
2152 #token "\n|\r|\r\n" << zzline++; zzskip(); >> /* Track Line # */
2153 #token "//" << zzmode(TOK_DEF_CPP_COMMENTS); zzmore(); >>
2154 #token "/\*" << zzmode(TOK_DEF_COMMENTS); zzskip(); >>
2155 #token "#ifdef" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
2156 #token "#if" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
2157 #token "#ifndef" << ; >>
2158 #token "#else" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
2159 #token "#endif" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
2160 #token "#undef" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
2161 #token "#import" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
2162 #token "@" << ; >>
2163
2164 /* rule enum_file */
2165
2166 enum_file[char *fname]
2167 : { "#ifndef" ID
2168 { "#define" ID /* ignore if it smells like a gate */
2169 /* First #define after the first #ifndef (if any) is ignored */
2170 }
2171 }
2172 ( ( enum_def[$fname] )+
2173 | defines[$fname]
2174 )
2175 |
2176 ;
2177
2178 /* rule defines */
2179
2180 defines[char *fname]
2181 : <<int v; int maxt=(-1); char *t;>> /* MR3 */
2182 (
2183 "#define" ID
2184 <<t = mystrdup(LATEXT(1));>>
2185 INT
2186 <<
2187 v = atoi(LATEXT(1));
2188 /* fprintf(stderr, "#token %s=%d\n", t, v);*/
2189
2190 /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */
2191 /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs */
2192 /* MR2 Don't let #tokdefs be confused by */
2193 /* MR2 DLGminToken and DLGmaxToken */
2194
2195 if ( ! isDLGmaxToken(t)) { /* MR2 */
2196 TokenNum = v;
2197 if ( v>maxt ) maxt=v;
2198 if ( Tnum( t ) == 0 ) {
2199 addForcedTname( t, v );
2200 } else {
2201 warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);
2202 };
2203 };
2204 >>
2205 )+
2206 <<TokenNum = maxt + 1;>>
2207 ;
2208
2209 /* rule enum_def */
2210
2211 enum_def[char *fname]
2212 : <<int v= 0; int maxt=(-1); char *t;>> /* MR3 */
2213 "enum" ID
2214 "\{"
2215 ID
2216 <<t = mystrdup(LATEXT(1));>>
2217 ( "=" INT <<v=atoi(LATEXT(1));>>
2218 | <<v++;>>
2219 )
2220 <<
2221 /* fprintf(stderr, "#token %s=%d\n", t, v);*/
2222 TokenNum = v;
2223 if ( v>maxt ) maxt=v; /* MR3 */
2224 if ( Tnum( t ) == 0 ) addForcedTname( t, v );
2225 else {
2226 warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);
2227 }
2228 >>
2229 ( ","
2230
2231 /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */
2232 /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs */
2233 /* MR2 Don't let #tokdefs be confused by */
2234 /* MR2 DLGminToken and DLGmaxToken */
2235
2236 {
2237 <<isDLGmaxToken(LATEXT(1))>>? ID { "=" INT } /* MR2 */
2238 | ID /* MR2 */
2239 <<t = mystrdup(LATEXT(1));>>
2240 ( "=" INT <<v=atoi(LATEXT(1));>>
2241 | <<v++;>>
2242 )
2243 <<
2244 /* fprintf(stderr, "#token %s=%d\n", t, v);*/
2245 TokenNum = v;
2246 if ( v>maxt ) maxt=v; /* MR3 */
2247 if ( Tnum( t ) == 0 ) addForcedTname( t, v );
2248 else {
2249 warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);
2250 }
2251 >>
2252 }
2253 )*
2254 "\}"
2255 ";"
2256 <<TokenNum = maxt + 1;>> /* MR3 */
2257 ;
2258
2259 #token INT "[0-9]+"
2260 #token ID "[a-zA-Z_][_a-zA-Z0-9]*"
2261
2262 #lexclass START
2263
2264 /* MR14 Arpad Beszedes 26-May-98
2265 Add support for #line directives when antlr source is pre-processed
2266 */
2267
2268 #lexaction
2269 <<
2270
2271 static char *
2272 #ifdef __USE_PROTOS
2273 getFileNameFromTheLineInfo(char *toStr, char *fromStr)
2274 #else
2275 getFileNameFromTheLineInfo(toStr, fromStr)
2276 char *toStr, *fromStr;
2277 #endif
2278 {
2279 int i, j, k;
2280
2281 if (!fromStr || !toStr) return toStr;
2282
2283 /* find the first " */
2284
2285 for (i=0;
2286 (i<MaxFileName) &&
2287 (fromStr[i] != '\n') &&
2288 (fromStr[i] != '\r') &&
2289 (fromStr[i] != '\"');
2290 i++) /* nothing */ ;
2291
2292 if ( (i == MaxFileName) ||
2293 (fromStr[i] == '\n') ||
2294 (fromStr[i] == '\r') ) {
2295 return toStr;
2296 }
2297
2298 /* find the second " */
2299
2300 for (j=i+1;
2301 (j<MaxFileName) &&
2302 (fromStr[j] != '\n') &&
2303 (fromStr[j] != '\r') &&
2304 (fromStr[j] != '\"');
2305 j++) /* nothing */ ;
2306
2307 if ((j == MaxFileName) ||
2308 (fromStr[j] == '\n') ||
2309 (fromStr[j] == '\r') ) {
2310 return toStr;
2311 }
2312
2313 /* go back until the last / or \ */
2314
2315 for (k=j-1;
2316 (fromStr[k] != '\"') &&
2317 (fromStr[k] != '/') &&
2318 (fromStr[k] != '\\');
2319 k--) /* nothing */ ;
2320
2321 /* copy the string after " / or \ into toStr */
2322
2323 for (i=k+1; fromStr[i] != '\"'; i++) {
2324 toStr[i-k-1] = fromStr[i];
2325 }
2326
2327 toStr[i-k-1] = '\0';
2328
2329 return toStr;
2330 }
2331
2332 /* MR14 end of a block to support #line in antlr source code */
2333
2334 >>
2335
2336 <<
2337
2338 /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */
2339 /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs */
2340 /* MR2 Don't let #tokdefs be confused by */
2341 /* MR2 DLGminToken and DLGmaxToken */
2342
2343 /* semantic check on DLGminToken and DLGmaxmaxToken in #tokdefs */
2344
2345 #ifdef __USE_PROTOS
2346 static int isDLGmaxToken(char *Token)
2347 #else
2348 static int isDLGmaxToken(Token)
2349 char * Token;
2350 #endif
2351 {
2352 static char checkStr1[] = "DLGmaxToken";
2353 static char checkStr2[] = "DLGminToken";
2354
2355 if (strcmp(Token, checkStr1) == 0)
2356 return 1;
2357 else if (strcmp(Token, checkStr2) == 0)
2358 return 1;
2359 else
2360 return 0;
2361 }
2362
2363 /* semantics of #token */
2364 static void
2365 #ifdef __USE_PROTOS
2366 chkToken(char *t, char *e, char *a, int tnum)
2367 #else
2368 chkToken(t,e,a,tnum)
2369 char *t, *e, *a;
2370 int tnum;
2371 #endif
2372 {
2373 TermEntry *p;
2374
2375 /* check to see that they don't try to redefine a token as a token class */
2376 if ( t!=NULL ) {
2377 p = (TermEntry *) hash_get(Tname, t);
2378 if ( p!=NULL && p->classname ) {
2379 err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t));
2380 if ( a!=NULL ) free((char *)a);
2381 return;
2382 }
2383 }
2384
2385 if ( t==NULL && e==NULL ) { /* none found */
2386 err("#token requires at least token name or rexpr");
2387 }
2388 else if ( t!=NULL && e!=NULL ) { /* both found */
2389 if ( UserDefdTokens ) { /* if #tokdefs, must not define new */
2390 p = (TermEntry *) hash_get(Tname, t);
2391 if ( p == NULL) {
2392 err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));
2393 return;
2394 };
2395 }
2396 Tklink(t, e);
2397 if ( a!=NULL ) {
2398 if ( hasAction(e) ) {
2399 err(eMsg1("redefinition of action for %s; ignored",e));
2400 }
2401 else setHasAction(e, a);
2402 }
2403 }
2404 else if ( t!=NULL ) { /* only one found */
2405 if ( UserDefdTokens ) {
2406 p = (TermEntry *) hash_get(Tname, t);
2407 if (p == NULL) {
2408 err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));
2409 };
2410 return;
2411 }
2412 if ( Tnum( t ) == 0 ) addTname( t );
2413 else {
2414 err(eMsg1("redefinition of token %s; ignored",t));
2415 }
2416 if ( a!=NULL ) {
2417 err(eMsg1("action cannot be attached to a token name (%s); ignored",t));
2418 free((char *)a);
2419 }
2420 }
2421 else if ( e!=NULL ) {
2422 if ( Tnum( e ) == 0 ) addTexpr( e );
2423 else {
2424 if ( hasAction(e) ) {
2425 err(eMsg1("redefinition of action for expr %s; ignored",e));
2426 }
2427 else if ( a==NULL ) {
2428 err(eMsg1("redefinition of expr %s; ignored",e));
2429 }
2430 }
2431 if ( a!=NULL ) setHasAction(e, a);
2432 }
2433
2434 /* if a token type number was specified, then add the token ID and 'tnum'
2435 * pair to the ForcedTokens list. (only applies if an id was given)
2436 */
2437 if ( t!=NULL && tnum>0 )
2438 {
2439 if ( set_el(tnum, reserved_positions) )
2440 {
2441 err(eMsgd("a token has already been forced to token number %d; ignored", tnum));
2442 }
2443 else
2444 {
2445 list_add(&ForcedTokens, newForcedToken(t,tnum));
2446 set_orel(tnum, &reserved_positions);
2447 }
2448 }
2449 }
2450 >>
2451
2452 <<
2453 static int
2454 #ifdef __USE_PROTOS
2455 match_token(char *s, char **nxt)
2456 #else
2457 match_token(s,nxt)
2458 char *s;
2459 char **nxt;
2460 #endif
2461 {
2462 if ( !(*s>='A' && *s<='Z') ) return 0;
2463 s++;
2464 while ( (*s>='a' && *s<='z') ||
2465 (*s>='A' && *s<='Z') ||
2466 (*s>='0' && *s<='9') ||
2467 *s=='_' )
2468 {
2469 s++;
2470 }
2471 if ( *s!=' ' && *s!='}' ) return 0;
2472 *nxt = s;
2473 return 1;
2474 }
2475
2476 static int
2477 #ifdef __USE_PROTOS
2478 match_rexpr(char *s, char **nxt)
2479 #else
2480 match_rexpr(s,nxt)
2481 char *s;
2482 char **nxt;
2483 #endif
2484 {
2485 if ( *s!='"' ) return 0;
2486 s++;
2487 while ( *s!='"' )
2488 {
2489 if ( *s=='\n' || *s=='\r' ) /* MR13 */
2490 warn("eoln found in regular expression");
2491 if ( *s=='\\' ) s++;
2492 s++;
2493 }
2494 *nxt = s+1;
2495 return 1;
2496 }
2497
2498 /*
2499 * Walk a string "{ A .. Z }" where A..Z is a space separated list
2500 * of token references (either labels or reg exprs). Return a
2501 * string "inlineX_set" for some unique integer X. Basically,
2502 * we pretend as if we had seen "#tokclass inlineX { A .. Z }"
2503 * on the input stream outside of an action.
2504 */
2505 char *
2506 #ifdef __USE_PROTOS
2507 inline_set(char *s)
2508 #else
2509 inline_set(s)
2510 char *s;
2511 #endif
2512 {
2513 char *nxt;
2514 fprintf(stderr, "found consumeUntil( {...} )\n");
2515 while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}
2516 if ( *s!='{' )
2517 {
2518 err("malformed consumeUntil( {...} ); missing '{'");
2519 return "bad_set";
2520 }
2521 s++;
2522 while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}
2523 while ( *s!='}' )
2524 {
2525 if ( match_token(s,&nxt) ) fprintf(stderr, "found token %s\n", s);
2526 else if ( match_rexpr(s,&nxt) ) fprintf(stderr, "found rexpr %s\n", s);
2527 else {
2528 err("invalid element in consumeUntil( {...} )");
2529 return "bad_set";
2530 }
2531 s = nxt;
2532 while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}
2533 }
2534 return "inlineX_set";
2535 }
2536 >>
2537
2538 <<
2539 /* ANTLR-specific syntax error message generator
2540 * (define USER_ZZSYN when compiling so don't get 2 definitions)
2541 */
2542 void
2543 #ifdef __USE_PROTOS
2544 zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok,
2545 int k, char *bad_text)
2546 #else
2547 zzsyn(text, tok, egroup, eset, etok, k, bad_text)
2548 char *text, *egroup, *bad_text;
2549 int tok;
2550 int etok;
2551 int k;
2552 SetWordType *eset;
2553 #endif
2554 {
2555 fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);
2556 fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
2557 if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
2558 if ( k==1 ) fprintf(stderr, " missing");
2559 else
2560 {
2561 fprintf(stderr, "; \"%s\" not", bad_text);
2562 if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
2563 }
2564 if ( zzset_deg(eset)>0 ) zzedecode(eset);
2565 else fprintf(stderr, " %s", zztokens[etok]);
2566 if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);
2567 fprintf(stderr, "\n");
2568 }
2569 >>
2570
2571 #lexaction <<
2572 #ifdef __USE_PROTOS
2573 void mark_label_used_in_sem_pred(LabelEntry *le) /* MR10 */
2574 #else
2575 void mark_label_used_in_sem_pred(le) /* MR10 */
2576 LabelEntry *le;
2577 #endif
2578 {
2579 TokNode *tn;
2580 require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken");
2581 tn=(TokNode *)le->elem;
2582 require (tn->label != 0,"mark_label_used... TokNode has no label");
2583 tn->label_used_in_semantic_pred=1;
2584 }
2585 >>
+0
-787
contrib/pccts/antlr/antlr.r less more
0 /*
1 File: antlrMPW.r
2 Target: antlr 133MR
3 Created: Monday, June 15, 1998 4:41:11 AM
4 Author: Kenji Tanaka (kentar@osa.att.ne.jp)
5 */
6
7 #include "cmdo.r"
8
9 resource 'cmdo' (128, "Antlr") {
10 { /* array dialogs: 5 elements */
11 /* [1] */
12 295,
13 "ANTLR -- Purdue Compiler Construction To"
14 "ol Set (PCCTS) LL(k) parser generator.",
15 { /* array itemArray: 12 elements */
16 /* [1] */
17 NotDependent {
18
19 },
20 CheckOption {
21 NotSet,
22 {18, 23, 33, 223},
23 "Read grammar from stdin",
24 "-",
25 "Read grammar from stdin."
26 },
27 /* [2] */
28 NotDependent {
29
30 },
31 CheckOption {
32 NotSet,
33 {38, 23, 53, 310},
34 "Send grammar.c/grammar.cpp to stdout",
35 "-stdout",
36 "Send grammar.c/grammar.cpp to stdout."
37 },
38 /* [3] */
39 NotDependent {
40
41 },
42 MultiFiles {
43 "Grammar File(s)É",
44 "Choose the grammar specification files y"
45 "ou wish to have ANTLR process.",
46 {79, 22, 98, 152},
47 "Grammar specification:",
48 "",
49 MultiInputFiles {
50 { /* array MultiTypesArray: 1 elements */
51 /* [1] */
52 text
53 },
54 ".g",
55 "Files ending in .g",
56 "All text files"
57 }
58 },
59 /* [4] */
60 NotDependent {
61
62 },
63 Files {
64 DirOnly,
65 OptionalFile {
66 {58, 168, 74, 298},
67 {79, 169, 98, 299},
68 "Output Directory",
69 ":",
70 "-o",
71 "",
72 "Choose the directory where ANTLR will pu"
73 "t its output.",
74 dim,
75 "Output Directory…",
76 "",
77 ""
78 },
79 NoMore {
80
81 }
82 },
83 /* [5] */
84 NotDependent {
85
86 },
87 Redirection {
88 StandardOutput,
89 {126, 27}
90 },
91 /* [6] */
92 NotDependent {
93
94 },
95 Redirection {
96 DiagnosticOutput,
97 {126, 178}
98 },
99 /* [7] */
100 NotDependent {
101
102 },
103 TextBox {
104 gray,
105 {117, 20, 167, 300},
106 "Redirection"
107 },
108 /* [8] */
109 NotDependent {
110
111 },
112 NestedDialog {
113 5,
114 {20, 324, 40, 460},
115 "Parse Options…",
116 "Parse control options may be set with th"
117 "is button."
118 },
119 /* [9] */
120 NotDependent {
121
122 },
123 NestedDialog {
124 2,
125 {50, 324, 70, 460},
126 "Generate Options…",
127 "Various command line options may be set "
128 "with this button."
129 },
130 /* [10] */
131 NotDependent {
132
133 },
134 NestedDialog {
135 3,
136 {78, 324, 98, 460},
137 "More Options…",
138 "Antlr has ALOT of options. There are eve"
139 "n more to be found with this button."
140 },
141 /* [11] */
142 NotDependent {
143
144 },
145 NestedDialog {
146 4,
147 {106, 324, 126, 460},
148 "Rename Options…",
149 "Options for renaming output files may be"
150 " set with this button."
151 },
152 /* [12] */
153 NotDependent {
154
155 },
156 VersionDialog {
157 VersionString {
158 "1.33MR"
159 },
160 "PCCTS was written by Terence Parr, Russe"
161 "ll Quong, Will Cohen, and Hank Dietz: 19"
162 "89-1998. MPW port by Scott Haney.",
163 noDialog
164 }
165 },
166 /* [2] */
167 295,
168 "Use this dialog to specify command line "
169 "Generate Options.",
170 { /* array itemArray: 15 elements */
171 /* [1] */
172 NotDependent {
173
174 },
175 CheckOption {
176 NotSet,
177 {18, 25, 33, 225},
178 "Generate C++ code",
179 "-CC",
180 "Generate C++ output from both ANTLR and "
181 "DLG."
182 },
183 /* [2] */
184 NotDependent {
185
186 },
187 CheckOption {
188 NotSet,
189 {38, 25, 53, 225},
190 "Generate ASTs",
191 "-gt",
192 "Generate code for Abstract-Syntax-Trees "
193 "(ASTs)."
194 },
195 /* [3] */
196 NotDependent {
197
198 },
199 CheckOption {
200 NotSet,
201 {58, 25, 73, 225},
202 "Generate line info",
203 "-gl",
204 "If this option is checked, ANTLR will ge"
205 "nerate line info about grammaractions, t"
206 "hereby making debugging easier since com"
207 "pile errors will point to the grammar fi"
208 "le."
209 },
210 /* [4] */
211 NotDependent {
212
213 },
214 CheckOption {
215 NotSet,
216 {78, 25, 93, 225},
217 "Generate error classes",
218 "-ge",
219 "If this option is checked, ANTLR will ge"
220 "nerate an error class foreach non-termin"
221 "al."
222 },
223 /* [5] */
224 NotDependent {
225
226 },
227 CheckOption {
228 NotSet,
229 {98, 25, 113, 225},
230 "Don't generate Code",
231 "-gc",
232 "If this option is checked, ANTLR will ge"
233 "nerate no code, i.e. it will only perfor"
234 "m analysis on the grammar."
235 },
236 /* [6] */
237 NotDependent {
238
239 },
240 CheckOption {
241 NotSet,
242 {118, 25, 133, 225},
243 "Delay lookahead fetches",
244 "-gk",
245 "If this option is checked, ANTLR will ge"
246 "nerate a parser that delays lookahead fe"
247 "tches until needed."
248 },
249 /* [7] */
250 NotDependent {
251
252 },
253 CheckOption {
254 NotSet,
255 {138, 25, 153, 225},
256 "Use newAST(...)",
257 "-newAST",
258 "In C++ mode use \"newAST(...)\" rather tha"
259 "n \"new AST(...)\""
260 },
261 /* [8] */
262 NotDependent {
263
264 },
265 CheckOption {
266 NotSet,
267 {18, 235, 33, 435},
268 "Support parse traces",
269 "-gd",
270 "If this option is checked, ANTLR inserts"
271 " code in each parsing function to provid"
272 "e for user-defined handling of a detaile"
273 "d parse trace. The code consists of call"
274 "s to zzTRACEIN and zzTRACEOUT."
275 },
276 /* [9] */
277 NotDependent {
278
279 },
280 CheckOption {
281 NotSet,
282 {38, 235, 53, 435},
283 "Generate cross-references",
284 "-cr",
285 "If this option is checked, ANTLR will ge"
286 "nerate a cross reference for all rules. "
287 "For each rule it will print a list of al"
288 "l other rules that refrence it."
289 },
290 /* [10] */
291 NotDependent {
292
293 },
294 CheckOption {
295 NotSet,
296 {58, 235, 73, 435},
297 "Don't create Lexer files",
298 "-gx",
299 "If this option is checked, ANTLR will no"
300 "t generate DLG-related output files. Thi"
301 "s option should be used if one wants a c"
302 "ustom lexical analyzer or if one has mad"
303 "e changes to the grammar not affecting t"
304 "he lexical structure."
305 },
306 /* [11] */
307 NotDependent {
308
309 },
310 CheckOption {
311 NotSet,
312 {78, 235, 93, 460},
313 "Don't generate token expr sets",
314 "-gs",
315 "If this option is checked, ANTLR will no"
316 "t generate sets for token expression set"
317 "s; instead, it will generate a || separa"
318 "ted sequence of LA(1)==token #. "
319 },
320 /* [12] */
321 NotDependent {
322
323 },
324 CheckOption {
325 NotSet,
326 {98, 235, 113, 460},
327 "Generate ANSI-compatible",
328 "-ga",
329 "Generate ANSI-compatible code (default=F"
330 "ALSE)"
331 },
332 /* [13] */
333 NotDependent {
334
335 },
336 CheckOption {
337 NotSet,
338 {118, 235, 133, 460},
339 "Don't generate tokens.h",
340 "-gxt",
341 "Do not generate tokens.h (default=FALSE)"
342 },
343 /* [13] */
344 NotDependent {
345
346 },
347 CheckOption {
348 NotSet,
349 {138, 235, 153, 460},
350 "Provide \"(alpha)? beta\" info",
351 "-alpha",
352 "Provide additional information for \"(alpha)? beta\" error messages"
353 },
354 /* [14] */
355 NotDependent {
356
357 },
358 RegularEntry {
359 "Tabs(1 to 8):",
360 {162, 23, 177, 117},
361 {163, 125, 179, 196},
362 "",
363 keepCase,
364 "-tab",
365 "Width of tabs (1 to 8) for grammar.c/gra"
366 "mmar.cpp files."
367 },
368 /* [15] */
369 NotDependent {
370
371 },
372 RegularEntry {
373 "Function Prefix:",
374 {161, 236, 177, 342},
375 {162, 345, 177, 454},
376 "",
377 keepCase,
378 "-gp",
379 "Prefix all generated rule functions with"
380 " a string."
381 }
382 },
383 /* [3] */
384 295,
385 "Use this dialog to specify still more co"
386 "mmand line options.",
387 { /* array itemArray: 12 elements */
388 /* [1] */
389 NotDependent {
390
391 },
392 RadioButtons {
393 { /* array radioArray: 3 elements */
394 /* [1] */
395 {38, 25, 53, 85}, "None", "", Set, "When this option is selected, ANTLR will"
396 " not print the grammar to stdout.",
397 /* [2] */
398 {38, 100, 53, 160}, "Yes", "-p", NotSet, "When this option is selected, ANTLR will"
399 " print the grammar, stripped of all acti"
400 "ons and comments, to stdout.",
401 /* [3] */
402 {38, 175, 53, 235}, "More", "-pa", NotSet, "When this option is selected, ANTLR will"
403 " print the grammar, stripped of all acti"
404 "ons and comments, to stdout. It will als"
405 "o annotate the output with the first set"
406 "s determined from grammar analysis."
407 }
408 },
409 /* [2] */
410 NotDependent {
411
412 },
413 TextBox {
414 gray,
415 {28, 15, 60, 250},
416 "Grammar Printing"
417 },
418 /* [3] */
419 NotDependent {
420
421 },
422 RadioButtons {
423 { /* array radioArray: 3 elements */
424 /* [1] */
425 {88, 25, 103, 85}, "Low", "", Set, "When this option is selected, ANTLR will"
426 " show ambiguities/errors in low detail.",
427 /* [2] */
428 {88, 100, 103, 160}, "Medium", "-e2", NotSet, "When this option is selected, ANTLR will"
429 " show ambiguities/errors in more detail.",
430 /* [3] */
431 {88, 175, 103, 235}, "High", "-e3", NotSet, "When this option is selected, ANTLR will"
432 " show ambiguities/errors in excruciating"
433 " detail."
434 }
435 },
436 /* [4] */
437 NotDependent {
438
439 },
440 TextBox {
441 gray,
442 {78, 15, 110, 250},
443 "Error reporting"
444 },
445 /* [5] */
446 NotDependent {
447
448 },
449 CheckOption {
450 NotSet,
451 {130, 22, 145, 222},
452 "More warnings",
453 "-w2",
454 "If this option is checked, ANTLR will wa"
455 "rn if semantic predicates and/or (É)? bl"
456 "ocks are assumed to cover ambiguous alte"
457 "rnatives."
458 },
459 /* [6] */
460 NotDependent {
461
462 },
463 RegularEntry {
464 "Report when tnode usage exceeds:",
465 {162, 23, 180, 253},
466 {162, 255, 178, 326},
467 "",
468 keepCase,
469 "-treport",
470 "Report when tnode usage exceeds value du"
471 "ring ambiguity resolution."
472 },
473 /* [7] */
474 NotDependent {
475
476 },
477 CheckOption {
478 NotSet,
479 {40, 292, 55, 431},
480 "Predicate",
481 "-info p",
482 "With the antlr \"-info p\" switch the user"
483 " will receive information about the pred"
484 "icate suppression in the generated file."
485 },
486 /* [8] */
487 NotDependent {
488
489 },
490 CheckOption {
491 NotSet,
492 {60, 292, 75, 430},
493 "Tree Nodes",
494 "-info t",
495 "Using \"-info t\" gives information about "
496 "the total number of tnodes created and t"
497 "he peak number of tnodes."
498 },
499 /* [9] */
500 NotDependent {
501
502 },
503 CheckOption {
504 NotSet,
505 {80, 292, 95, 425},
506 "First/follow",
507 "-info f",
508 "first/follow set information."
509 },
510 /* [10] */
511 NotDependent {
512
513 },
514 CheckOption {
515 NotSet,
516 {100, 292, 115, 425},
517 "Monitor progress",
518 "-info m",
519 "prints name of each rule as it is starte"
520 "d and flushes output at start of each rule."
521 },
522 /* [11] */
523 NotDependent {
524
525 },
526 CheckOption {
527 NotSet,
528 {120, 292, 135, 416},
529 "Orphan rules",
530 "-info o",
531 "If there is more than one rule which is "
532 "not referenced by any other rule then al"
533 "l such rules are listed."
534 },
535 /* [12] */
536 NotDependent {
537
538 },
539 TextBox {
540 gray,
541 {28, 279, 147, 451},
542 "Extra info"
543 }
544 },
545 /* [4] */
546 295,
547 "Use this dialog to specify command line "
548 "options relating to renaming output file"
549 "s.",
550 { /* array itemArray: 7 elements */
551 /* [1] */
552 NotDependent {
553
554 },
555 RegularEntry {
556 "Errors file name:",
557 {35, 25, 50, 205},
558 {35, 205, 51, 300},
559 "err.c",
560 keepCase,
561 "-fe",
562 "This entry specifies the name ANTLR uses"
563 " for the errors file."
564 },
565 /* [2] */
566 NotDependent {
567
568 },
569 RegularEntry {
570 "Lexical output name:",
571 {60, 25, 75, 205},
572 {60, 205, 76, 300},
573 "parser.dlg",
574 keepCase,
575 "-fl",
576 "This entry specifies the name ANTLR uses"
577 " for the lexical output file."
578 },
579 /* [3] */
580 NotDependent {
581
582 },
583 RegularEntry {
584 "Lexical modes name:",
585 {85, 25, 100, 205},
586 {85, 205, 101, 300},
587 "mode.h",
588 keepCase,
589 "-fm",
590 "This entry specifies the name ANTLR uses"
591 " for the lexical mode definitions file."
592 },
593 /* [4] */
594 NotDependent {
595
596 },
597 RegularEntry {
598 "Remap file name:",
599 {110, 25, 125, 205},
600 {110, 205, 126, 300},
601 "remap.h",
602 keepCase,
603 "-fr",
604 "This entry specifies the name ANTLR uses"
605 " for the file that remaps globally visib"
606 "le symbols."
607 },
608 /* [5] */
609 NotDependent {
610
611 },
612 RegularEntry {
613 "Tokens file name:",
614 {135, 25, 150, 205},
615 {135, 205, 151, 300},
616 "tokens.h",
617 keepCase,
618 "-ft",
619 "This entry specifies the name ANTLR uses"
620 " for the tokens file."
621 },
622 /* [6] */
623 NotDependent {
624
625 },
626 CheckOption {
627 NotSet,
628 {160, 25, 175, 175},
629 "Create std header",
630 "-gh",
631 "If this option is checked, ANTLR will cr"
632 "eate a standard header file named, by de"
633 "fault 'stdpccts.h'. This name can be alt"
634 "ered using the entry right next door."
635 },
636 /* [7] */
637 Or {
638 { /* array OrArray: 1 elements */
639 /* [1] */
640 6
641 }
642 },
643 RegularEntry {
644 "Std header file name:",
645 {160, 175, 175, 355},
646 {160, 355, 176, 450},
647 "stdpccts.h",
648 keepCase,
649 "-fh",
650 "This entry specifies the name ANTLR uses"
651 " for the standard header file."
652 }
653 },
654 /* [5] */
655 295,
656 "Use this dialog to specify parse options"
657 ".",
658 { /* array itemArray: 9 elements */
659 /* [1] */
660 NotDependent {
661
662 },
663 RegularEntry {
664 "Lookahead:",
665 {23, 27, 38, 152},
666 {46, 29, 62, 154},
667 "1",
668 keepCase,
669 "-k",
670 "This entry specifies the number of token"
671 "s of lookahead."
672 },
673 /* [2] */
674 NotDependent {
675
676 },
677 RegularEntry {
678 "Compr lookahead:",
679 {22, 167, 37, 292},
680 {46, 172, 62, 297},
681 "",
682 keepCase,
683 "-ck",
684 "This entry specifies the number of token"
685 "s of lookahead when using compressed (li"
686 "near approximation) lookahead. In genera"
687 "l, the compressed lookahead is much deep"
688 "er than the full lookahead."
689 },
690 /* [3] */
691 NotDependent {
692
693 },
694 RegularEntry {
695 "Max tree nodes:",
696 {22, 312, 37, 437},
697 {46, 315, 62, 445},
698 "",
699 keepCase,
700 "-rl",
701 "This entry specifies the maximum number "
702 "of tokens of tree nodes used by the gram"
703 "mar analysis."
704 },
705 /* [4] */
706 NotDependent {
707
708 },
709 CheckOption {
710 NotSet,
711 {76, 25, 91, 350},
712 "Maintenance Release style hoisting",
713 "-mrhoist",
714 "Turn on/off k=1 Maintenance Release styl"
715 "e hoisting."
716 },
717 /* [5] */
718 NotDependent {
719
720 },
721 CheckOption {
722 NotSet,
723 {96, 25, 111, 431},
724 "EXPERIMENTAL Maintenance Release style h"
725 "oisting",
726 "-mrhoistk",
727 "Turn on/off k>1 EXPERIMENTAL Maintenance"
728 " Release style hoisting."
729 },
730 /* [6] */
731 NotDependent {
732
733 },
734 CheckOption {
735 NotSet,
736 {116, 25, 131, 363},
737 "Compute context for hoisted predicates",
738 "-prc on",
739 "Turn on/off computation of context for h"
740 "oisted predicates."
741 },
742 /* [7] */
743 NotDependent {
744
745 },
746 RegularEntry {
747 "Ambiguity aid:",
748 {140, 27, 155, 125},
749 {141, 135, 155, 209},
750 "",
751 keepCase,
752 "-aa",
753 "Ambiguity aid for a rule (rule name or l"
754 "ine number)."
755 },
756 /* [8] */
757 NotDependent {
758
759 },
760 RegularEntry {
761 "Limits exp growth:",
762 {140, 236, 155, 361},
763 {139, 372, 155, 452},
764 "",
765 keepCase,
766 "-aad",
767 "Limits exp growth of -aa listing - defau"
768 "lt=1 (max=ck value)."
769 },
770 /* [9] */
771 NotDependent {
772
773 },
774 CheckOption {
775 NotSet,
776 {164, 26, 179, 366},
777 "Lookahead token may appear multiple time"
778 "s",
779 "-aam",
780 "Lookahead token may appear multiple time"
781 "s in -aa listing."
782 }
783 }
784 }
785 };
786
+0
-264
contrib/pccts/antlr/antlr1.txt less more
0
1
2
3 ANTLR(1) PCCTS Manual Pages ANTLR(1)
4
5
6
7 NAME
8 antlr - ANother Tool for Language Recognition
9
10 SYNTAX
11 antlr [_o_p_t_i_o_n_s] _g_r_a_m_m_a_r__f_i_l_e_s
12
13 DESCRIPTION
14 _A_n_t_l_r converts an extended form of context-free grammar into
15 a set of C functions which directly implement an efficient
16 form of deterministic recursive-descent LL(k) parser.
17 Context-free grammars may be augmented with predicates to
18 allow semantics to influence parsing; this allows a form of
19 context-sensitive parsing. Selective backtracking is also
20 available to handle non-LL(k) and even non-LALR(k) con-
21 structs. _A_n_t_l_r also produces a definition of a lexer which
22 can be automatically converted into C code for a DFA-based
23 lexer by _d_l_g. Hence, _a_n_t_l_r serves a function much like that
24 of _y_a_c_c, however, it is notably more flexible and is more
25 integrated with a lexer generator (_a_n_t_l_r directly generates
26 _d_l_g code, whereas _y_a_c_c and _l_e_x are given independent
27 descriptions). Unlike _y_a_c_c which accepts LALR(1) grammars,
28 _a_n_t_l_r accepts LL(k) grammars in an extended BNF notation -
29 which eliminates the need for precedence rules.
30
31 Like _y_a_c_c grammars, _a_n_t_l_r grammars can use automatically-
32 maintained symbol attribute values referenced as dollar
33 variables. Further, because _a_n_t_l_r generates top-down
34 parsers, arbitrary values may be inherited from parent rules
35 (passed like function parameters). _A_n_t_l_r also has a mechan-
36 ism for creating and manipulating abstract-syntax-trees.
37
38 There are various other niceties in _a_n_t_l_r, including the
39 ability to spread one grammar over multiple files or even
40 multiple grammars in a single file, the ability to generate
41 a version of the grammar with actions stripped out (for
42 documentation purposes), and lots more.
43
44 OPTIONS
45 -ck _n
46 Use up to _n symbols of lookahead when using compressed
47 (linear approximation) lookahead. This type of looka-
48 head is very cheap to compute and is attempted before
49 full LL(k) lookahead, which is of exponential complex-
50 ity in the worst case. In general, the compressed loo-
51 kahead can be much deeper (e.g, -ck 10) _t_h_a_n _t_h_e _f_u_l_l
52 _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).
53
54 -CC Generate C++ output from both ANTLR and DLG.
55
56 -cr Generate a cross-reference for all rules. For each
57 rule, print a list of all other rules that reference
58 it.
59
60 -e1 Ambiguities/errors shown in low detail (default).
61
62 -e2 Ambiguities/errors shown in more detail.
63
64 -e3 Ambiguities/errors shown in excruciating detail.
65
66 -fe file
67 Rename err.c to file.
68
69 -fh file
70 Rename stdpccts.h header (turns on -gh) to file.
71
72 -fl file
73 Rename lexical output, parser.dlg, to file.
74
75 -fm file
76 Rename file with lexical mode definitions, mode.h, to
77 file.
78
79 -fr file
80 Rename file which remaps globally visible symbols,
81 remap.h, to file.
82
83 -ft file
84 Rename tokens.h to file.
85
86 -ga Generate ANSI-compatible code (default case). This has
87 not been rigorously tested to be ANSI XJ11 C compliant,
88 but it is close. The normal output of _a_n_t_l_r is
89 currently compilable under both K&R, ANSI C, and C++-
90 this option does nothing because _a_n_t_l_r generates a
91 bunch of #ifdef's to do the right thing depending on
92 the language.
93
94 -gc Indicates that _a_n_t_l_r should generate no C code, i.e.,
95 only perform analysis on the grammar.
96
97 -gd C code is inserted in each of the _a_n_t_l_r generated pars-
98 ing functions to provide for user-defined handling of a
99 detailed parse trace. The inserted code consists of
100 calls to the user-supplied macros or functions called
101 zzTRACEIN and zzTRACEOUT. The only argument is a _c_h_a_r
102 * pointing to a C-style string which is the grammar
103 rule recognized by the current parsing function. If no
104 definition is given for the trace functions, upon rule
105 entry and exit, a message will be printed indicating
106 that a particular rule as been entered or exited.
107
108 -ge Generate an error class for each non-terminal.
109
110 -gh Generate stdpccts.h for non-ANTLR-generated files to
111 include. This file contains all defines needed to
112 describe the type of parser generated by _a_n_t_l_r (e.g.
113 how much lookahead is used and whether or not trees are
114 constructed) and contains the header action specified
115 by the user.
116
117 -gk Generate parsers that delay lookahead fetches until
118 needed. Without this option, _a_n_t_l_r generates parsers
119 which always have _k tokens of lookahead available.
120
121 -gl Generate line info about grammar actions in C parser of
122 the form # _l_i_n_e "_f_i_l_e" which makes error messages from
123 the C/C++ compiler make more sense as they will point
124 into the grammar file not the resulting C file.
125 Debugging is easier as well, because you will step
126 through the grammar not C file.
127
128 -gs Do not generate sets for token expression lists;
129 instead generate a ||-separated sequence of
130 LA(1)==_t_o_k_e_n__n_u_m_b_e_r. The default is to generate sets.
131
132 -gt Generate code for Abstract-Syntax Trees.
133
134 -gx Do not create the lexical analyzer files (dlg-related).
135 This option should be given when the user wishes to
136 provide a customized lexical analyzer. It may also be
137 used in _m_a_k_e scripts to cause only the parser to be
138 rebuilt when a change not affecting the lexical struc-
139 ture is made to the input grammars.
140
141 -k _n Set k of LL(k) to _n; i.e. set tokens of look-ahead
142 (default==1).
143
144 -o dir
145 Directory where output files should go (default=".").
146 This is very nice for keeping the source directory
147 clear of ANTLR and DLG spawn.
148
149 -p The complete grammar, collected from all input grammar
150 files and stripped of all comments and embedded
151 actions, is listed to stdout. This is intended to aid
152 in viewing the entire grammar as a whole and to elim-
153 inate the need to keep actions concisely stated so that
154 the grammar is easier to read. Hence, it is preferable
155 to embed even complex actions directly in the grammar,
156 rather than to call them as subroutines, since the sub-
157 routine call overhead will be saved.
158
159 -pa This option is the same as -p except that the output is
160 annotated with the first sets determined from grammar
161 analysis.
162
163 -prc on
164 Turn on the computation and hoisting of predicate con-
165 text.
166
167 -prc off
168 Turn off the computation and hoisting of predicate con-
169 text. This option makes 1.10 behave like the 1.06
170 release with option -pr on. Context computation is off
171 by default.
172
173 -rl _n
174 Limit the maximum number of tree nodes used by grammar
175 analysis to _n. Occasionally, _a_n_t_l_r is unable to
176 analyze a grammar submitted by the user. This rare
177 situation can only occur when the grammar is large and
178 the amount of lookahead is greater than one. A non-
179 linear analysis algorithm is used by PCCTS to handle
180 the general case of LL(k) parsing. The average com-
181 plexity of analysis, however, is near linear due to
182 some fancy footwork in the implementation which reduces
183 the number of calls to the full LL(k) algorithm. An
184 error message will be displayed, if this limit is
185 reached, which indicates the grammar construct being
186 analyzed when _a_n_t_l_r hit a non-linearity. Use this
187 option if _a_n_t_l_r seems to go out to lunch and your disk
188 start thrashing; try _n=10000 to start. Once the
189 offending construct has been identified, try to remove
190 the ambiguity that _a_n_t_l_r was trying to overcome with
191 large lookahead analysis. The introduction of (...)?
192 backtracking blocks eliminates some of these problems -
193 _a_n_t_l_r does not analyze alternatives that begin with
194 (...)? (it simply backtracks, if necessary, at run
195 time).
196
197 -w1 Set low warning level. Do not warn if semantic
198 predicates and/or (...)? blocks are assumed to cover
199 ambiguous alternatives.
200
201 -w2 Ambiguous parsing decisions yield warnings even if
202 semantic predicates or (...)? blocks are used. Warn if
203 predicate context computed and semantic predicates
204 incompletely disambiguate alternative productions.
205
206 - Read grammar from standard input and generate stdin.c
207 as the parser file.
208
209 SPECIAL CONSIDERATIONS
210 _A_n_t_l_r works... we think. There is no implicit guarantee of
211 anything. We reserve no legal rights to the software known
212 as the Purdue Compiler Construction Tool Set (PCCTS) - PCCTS
213 is in the public domain. An individual or company may do
214 whatever they wish with source code distributed with PCCTS
215 or the code generated by PCCTS, including the incorporation
216 of PCCTS, or its output, into commercial software. We
217 encourage users to develop software with PCCTS. However, we
218 do ask that credit is given to us for developing PCCTS. By
219 "credit", we mean that if you incorporate our source code
220 into one of your programs (commercial product, research pro-
221 ject, or otherwise) that you acknowledge this fact somewhere
222 in the documentation, research report, etc... If you like
223 PCCTS and have developed a nice tool with the output, please
224 mention that you developed it using PCCTS. As long as these
225 guidelines are followed, we expect to continue enhancing
226 this system and expect to make other tools available as they
227 are completed.
228
229 FILES
230 *.c output C parser.
231
232 *.cpp
233 output C++ parser when C++ mode is used.
234
235 parser.dlg
236 output _d_l_g lexical analyzer.
237
238 err.c
239 token string array, error sets and error support rou-
240 tines. Not used in C++ mode.
241
242 remap.h
243 file that redefines all globally visible parser sym-
244 bols. The use of the #parser directive creates this
245 file. Not used in C++ mode.
246
247 stdpccts.h
248 list of definitions needed by C files, not generated by
249 PCCTS, that reference PCCTS objects. This is not gen-
250 erated by default. Not used in C++ mode.
251
252 tokens.h
253 output #_d_e_f_i_n_e_s for tokens used and function prototypes
254 for functions generated for rules.
255
256
257 SEE ALSO
258 dlg(1), pccts(1)
259
260
261
262
263
+0
-135
contrib/pccts/antlr/antlr68K.make less more
0 # File: antlr68K.make
1 # Target: antlr68K
2 # Sources: ::support:set:set.c
3 # antlr.c
4 # bits.c
5 # build.c
6 # egman.c
7 # err.c
8 # fcache.c
9 # fset2.c
10 # fset.c
11 # gen.c
12 # globals.c
13 # hash.c
14 # lex.c
15 # main.c
16 # misc.c
17 # mrhoist.c
18 # pred.c
19 # scan.c
20 # Created: Sunday, May 17, 1998 10:12:02 PM
21 # Author: Kenji Tanaka
22
23
24 MAKEFILE = antlr68K.make
25 ¥MondoBuild¥ = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified
26 Includes = ¶
27 -i "::h:" ¶
28 -i "::support:set:"
29 Sym¥68K =
30 ObjDir¥68K = :Obj:
31
32 COptions = {Includes} {Sym¥68K} -model far -w off -d MPW -d __STDC__=1 -d USER_ZZSYN
33
34 Objects¥68K = ¶
35 "{ObjDir¥68K}set.c.o" ¶
36 "{ObjDir¥68K}antlr.c.o" ¶
37 "{ObjDir¥68K}bits.c.o" ¶
38 "{ObjDir¥68K}build.c.o" ¶
39 "{ObjDir¥68K}egman.c.o" ¶
40 "{ObjDir¥68K}err.c.o" ¶
41 "{ObjDir¥68K}fcache.c.o" ¶
42 "{ObjDir¥68K}fset2.c.o" ¶
43 "{ObjDir¥68K}fset.c.o" ¶
44 "{ObjDir¥68K}gen.c.o" ¶
45 "{ObjDir¥68K}globals.c.o" ¶
46 "{ObjDir¥68K}hash.c.o" ¶
47 "{ObjDir¥68K}lex.c.o" ¶
48 "{ObjDir¥68K}main.c.o" ¶
49 "{ObjDir¥68K}misc.c.o" ¶
50 "{ObjDir¥68K}mrhoist.c.o" ¶
51 "{ObjDir¥68K}pred.c.o" ¶
52 "{ObjDir¥68K}scan.c.o"
53
54
55 antlr68K ÄÄ {¥MondoBuild¥} {Objects¥68K}
56 Link ¶
57 -o {Targ} -d {Sym¥68K} ¶
58 {Objects¥68K} ¶
59 -t 'MPST' ¶
60 -c 'MPS ' ¶
61 -mf ¶
62 -model far ¶
63 -br ON ¶
64 -srtsg ALL ¶
65 "{Libraries}Stubs.o" ¶
66 #"{Libraries}MathLib.o" ¶
67 #"{CLibraries}Complex.o" ¶
68 "{CLibraries}StdCLib.o" ¶
69 "{Libraries}MacRuntime.o" ¶
70 "{Libraries}IntEnv.o" ¶
71 "{Libraries}ToolLibs.o" ¶
72 "{Libraries}Interface.o"
73
74
75 "{ObjDir¥68K}set.c.o" Ä {¥MondoBuild¥} "::support:set:set.c"
76 {C} "::support:set:set.c" -o {Targ} {COptions}
77
78 "{ObjDir¥68K}antlr.c.o" Ä {¥MondoBuild¥} antlr.c
79 {C} antlr.c -o {Targ} {COptions}
80
81 "{ObjDir¥68K}bits.c.o" Ä {¥MondoBuild¥} bits.c
82 {C} bits.c -o {Targ} {COptions}
83
84 "{ObjDir¥68K}build.c.o" Ä {¥MondoBuild¥} build.c
85 {C} build.c -o {Targ} {COptions}
86
87 "{ObjDir¥68K}egman.c.o" Ä {¥MondoBuild¥} egman.c
88 {C} egman.c -o {Targ} {COptions}
89
90 "{ObjDir¥68K}err.c.o" Ä {¥MondoBuild¥} err.c
91 {C} err.c -o {Targ} {COptions}
92
93 "{ObjDir¥68K}fcache.c.o" Ä {¥MondoBuild¥} fcache.c
94 {C} fcache.c -o {Targ} {COptions}
95
96 "{ObjDir¥68K}fset2.c.o" Ä {¥MondoBuild¥} fset2.c
97 {C} fset2.c -o {Targ} {COptions}
98
99 "{ObjDir¥68K}fset.c.o" Ä {¥MondoBuild¥} fset.c
100 {C} fset.c -o {Targ} {COptions}
101
102 "{ObjDir¥68K}gen.c.o" Ä {¥MondoBuild¥} gen.c
103 {C} gen.c -o {Targ} {COptions}
104
105 "{ObjDir¥68K}globals.c.o" Ä {¥MondoBuild¥} globals.c
106 {C} globals.c -o {Targ} {COptions}
107
108 "{ObjDir¥68K}hash.c.o" Ä {¥MondoBuild¥} hash.c
109 {C} hash.c -o {Targ} {COptions}
110
111 "{ObjDir¥68K}lex.c.o" Ä {¥MondoBuild¥} lex.c
112 {C} lex.c -o {Targ} {COptions}
113
114 "{ObjDir¥68K}main.c.o" Ä {¥MondoBuild¥} main.c
115 {C} main.c -o {Targ} {COptions}
116
117 "{ObjDir¥68K}misc.c.o" Ä {¥MondoBuild¥} misc.c
118 {C} misc.c -o {Targ} {COptions}
119
120 "{ObjDir¥68K}mrhoist.c.o" Ä {¥MondoBuild¥} mrhoist.c
121 {C} mrhoist.c -o {Targ} {COptions}
122
123 "{ObjDir¥68K}pred.c.o" Ä {¥MondoBuild¥} pred.c
124 {C} pred.c -o {Targ} {COptions}
125
126 "{ObjDir¥68K}scan.c.o" Ä {¥MondoBuild¥} scan.c
127 {C} scan.c -o {Targ} {COptions}
128
129
130 antlr68K ÄÄ antlr.r
131 Rez antlr.r -o antlr68K -a
132
133 Install Ä antlr68K
134 Duplicate -y antlr68K "{MPW}"Tools:antlr
+0
-101
contrib/pccts/antlr/antlrPPC.make less more
0 # Target: antlrPPC
1 # Sources: ::support:set:set.c
2 # antlr.c
3 # bits.c
4 # build.c
5 # egman.c
6 # err.c
7 # fcache.c
8 # fset2.c
9 # fset.c
10 # gen.c
11 # globals.c
12 # hash.c
13 # lex.c
14 # main.c
15 # misc.c
16 # mrhoist.c
17 # pred.c
18 # scan.c
19 # Created: Sunday, May 17, 1998 10:24:53 PM
20 # Author: Kenji Tanaka
21 MAKEFILE = antlrPPC.make
22 ¥MondoBuild¥ = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified
23 Includes = ¶
24 -i "::h:" ¶
25 -i "::support:set:"
26 Sym¥PPC =
27 ObjDir¥PPC = :Obj:
28 PPCCOptions = {Includes} {Sym¥PPC} -w off -d MPW -d __STDC__=1 -d USER_ZZSYN
29 Objects¥PPC = ¶
30 "{ObjDir¥PPC}set.c.x" ¶
31 "{ObjDir¥PPC}antlr.c.x" ¶
32 "{ObjDir¥PPC}bits.c.x" ¶
33 "{ObjDir¥PPC}build.c.x" ¶
34 "{ObjDir¥PPC}egman.c.x" ¶
35 "{ObjDir¥PPC}err.c.x" ¶
36 "{ObjDir¥PPC}fcache.c.x" ¶
37 "{ObjDir¥PPC}fset2.c.x" ¶
38 "{ObjDir¥PPC}fset.c.x" ¶
39 "{ObjDir¥PPC}gen.c.x" ¶
40 "{ObjDir¥PPC}globals.c.x" ¶
41 "{ObjDir¥PPC}hash.c.x" ¶
42 "{ObjDir¥PPC}lex.c.x" ¶
43 "{ObjDir¥PPC}main.c.x" ¶
44 "{ObjDir¥PPC}misc.c.x" ¶
45 "{ObjDir¥PPC}mrhoist.c.x" ¶
46 "{ObjDir¥PPC}pred.c.x" ¶
47 "{ObjDir¥PPC}scan.c.x"
48 antlrPPC ÄÄ {¥MondoBuild¥} {Objects¥PPC}
49 PPCLink ¶
50 -o {Targ} {Sym¥PPC} ¶
51 {Objects¥PPC} ¶
52 -t 'MPST' ¶
53 -c 'MPS ' ¶
54 "{SharedLibraries}InterfaceLib" ¶
55 "{SharedLibraries}StdCLib" ¶
56 #"{SharedLibraries}MathLib" ¶
57 "{PPCLibraries}StdCRuntime.o" ¶
58 "{PPCLibraries}PPCCRuntime.o" ¶
59 "{PPCLibraries}PPCToolLibs.o"
60 "{ObjDir¥PPC}set.c.x" Ä {¥MondoBuild¥} "::support:set:set.c"
61 {PPCC} "::support:set:set.c" -o {Targ} {PPCCOptions}
62 "{ObjDir¥PPC}antlr.c.x" Ä {¥MondoBuild¥} antlr.c
63 {PPCC} antlr.c -o {Targ} {PPCCOptions}
64 "{ObjDir¥PPC}bits.c.x" Ä {¥MondoBuild¥} bits.c
65 {PPCC} bits.c -o {Targ} {PPCCOptions}
66 "{ObjDir¥PPC}build.c.x" Ä {¥MondoBuild¥} build.c
67 {PPCC} build.c -o {Targ} {PPCCOptions}
68 "{ObjDir¥PPC}egman.c.x" Ä {¥MondoBuild¥} egman.c
69 {PPCC} egman.c -o {Targ} {PPCCOptions}
70 "{ObjDir¥PPC}err.c.x" Ä {¥MondoBuild¥} err.c
71 {PPCC} err.c -o {Targ} {PPCCOptions}
72 "{ObjDir¥PPC}fcache.c.x" Ä {¥MondoBuild¥} fcache.c
73 {PPCC} fcache.c -o {Targ} {PPCCOptions}
74 "{ObjDir¥PPC}fset2.c.x" Ä {¥MondoBuild¥} fset2.c
75 {PPCC} fset2.c -o {Targ} {PPCCOptions}
76 "{ObjDir¥PPC}fset.c.x" Ä {¥MondoBuild¥} fset.c
77 {PPCC} fset.c -o {Targ} {PPCCOptions}
78 "{ObjDir¥PPC}gen.c.x" Ä {¥MondoBuild¥} gen.c
79 {PPCC} gen.c -o {Targ} {PPCCOptions}
80 "{ObjDir¥PPC}globals.c.x" Ä {¥MondoBuild¥} globals.c
81 {PPCC} globals.c -o {Targ} {PPCCOptions}
82 "{ObjDir¥PPC}hash.c.x" Ä {¥MondoBuild¥} hash.c
83 {PPCC} hash.c -o {Targ} {PPCCOptions}
84 "{ObjDir¥PPC}lex.c.x" Ä {¥MondoBuild¥} lex.c
85 {PPCC} lex.c -o {Targ} {PPCCOptions}
86 "{ObjDir¥PPC}main.c.x" Ä {¥MondoBuild¥} main.c
87 {PPCC} main.c -o {Targ} {PPCCOptions}
88 "{ObjDir¥PPC}misc.c.x" Ä {¥MondoBuild¥} misc.c
89 {PPCC} misc.c -o {Targ} {PPCCOptions}
90 "{ObjDir¥PPC}mrhoist.c.x" Ä {¥MondoBuild¥} mrhoist.c
91 {PPCC} mrhoist.c -o {Targ} {PPCCOptions}
92 "{ObjDir¥PPC}pred.c.x" Ä {¥MondoBuild¥} pred.c
93 {PPCC} pred.c -o {Targ} {PPCCOptions}
94 "{ObjDir¥PPC}scan.c.x" Ä {¥MondoBuild¥} scan.c
95 {PPCC} scan.c -o {Targ} {PPCCOptions}
96
97 antlrPPC ÄÄ antlr.r
98 Rez antlr.r -o antlrPPC -a
99 Install Ä antlrPPC
100 Duplicate -y antlrPPC "{MPW}"Tools:antlr
+0
-1033
contrib/pccts/antlr/bits.c less more
0 /* bits.c -- manage creation and output of bit sets used by the parser.
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2001
27 */
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <ctype.h>
32 #include <assert.h>
33 #include "pcctscfg.h"
34 #include "set.h"
35 #include "syn.h"
36 #include "hash.h"
37 #include "generic.h"
38 #include "dlgdef.h"
39
40 /* OSX warning fix */
41 #define GR_INT int
42
43 /* char is only thing that is pretty much always known == 8 bits
44 * This allows output of antlr (set stuff, anyway) to be androgynous (portable)
45 */
46 typedef unsigned char SetWordType;
47 #define BitsPerByte 8
48 #define BitsPerWord BitsPerByte*sizeof(SetWordType)
49
50 static SetWordType *setwd = NULL;
51 int setnum = -1;
52 int wordnum = 0;
53
54 int esetnum = 0;
55
56 /* Used to convert native wordsize, which ANTLR uses (via set.c) to manipulate sets,
57 to bytes that are most portable size-wise.
58 */
59 void
60 #ifdef __USE_PROTOS
61 DumpIntAsChars( FILE *f, char *format, unsigned wd )
62 #else
63 DumpIntAsChars( f, format, wd )
64 FILE *f;
65 char *format;
66 unsigned wd;
67 #endif
68 {
69 int i;
70 /* uses max of 32 bit unsigned integer for the moment */
71 static unsigned long byte_mask[sizeof(unsigned long)] =
72 { 0xFF, 0xFF00UL, 0xFF0000UL, 0xFF000000UL }; /* MR20 G. Hobbelt */
73 /* 0xFF00000000, 0xFF0000000000, 0xFF000000000000, 0xFF00000000000000 };*/
74
75 /* for each byte in the word */
76 assert(sizeof(unsigned) <= 4); /* M20 G. Hobbelt Sanity check */
77 for (i=0; i<sizeof(unsigned); i++)
78 {
79 /* mask out the ith byte and shift down to the first 8 bits */
80 fprintf(f, format, (wd&byte_mask[i])>>(i*BitsPerByte));
81 if ( i<sizeof(unsigned)-1) fprintf(f, ",");
82 }
83 }
84
85 /* Create a new setwd (ignoring [Ep] token on end) */
86 void
87 #ifdef __USE_PROTOS
88 NewSetWd( void )
89 #else
90 NewSetWd( )
91 #endif
92 {
93 SetWordType *p;
94
95 if ( setwd == NULL )
96 {
97 setwd = (SetWordType *) calloc(TokenNum, sizeof(SetWordType));
98 require(setwd!=NULL, "NewSetWd: cannot alloc set wd\n");
99 }
100 for (p = setwd; p<&(setwd[TokenNum]); p++) {*p=0;}
101 wordnum++;
102 }
103
104 void
105 #ifdef __USE_PROTOS
106 DumpSetWd( void )
107 #else
108 DumpSetWd( )
109 #endif
110 {
111 if ( GenCC ) DumpSetWdForCC();
112 else DumpSetWdForC();
113 }
114
115 /* Dump the current setwd to ErrFile. 0..MaxTokenVal */
116 void
117 #ifdef __USE_PROTOS
118 DumpSetWdForC( void )
119 #else
120 DumpSetWdForC( )
121 #endif
122 {
123 int i,c=1;
124
125 if ( setwd==NULL ) return;
126 fprintf(DefFile, "extern SetWordType setwd%d[];\n", wordnum);
127 fprintf(ErrFile,
128 "SetWordType setwd%d[%d] = {", wordnum, TokenNum-1);
129 for (i=0; i<TokenNum-1; i++)
130 {
131 DAWDLE;
132 if ( i!=0 ) fprintf(ErrFile, ",");
133 if ( c == 8 ) {fprintf(ErrFile, "\n\t"); c=1;} else c++;
134 fprintf(ErrFile, "0x%x", setwd[i]);
135 }
136 fprintf(ErrFile, "};\n");
137 }
138
139 /* Dump the current setwd to Parser.C file. 0..MaxTokenVal;
140 * Only used if -CC on.
141 */
142 void
143 #ifdef __USE_PROTOS
144 DumpSetWdForCC( void )
145 #else
146 DumpSetWdForCC( )
147 #endif
148 {
149 int i,c=1;
150
151 if ( setwd==NULL ) return;
152 fprintf(Parser_h, "\tstatic SetWordType setwd%d[%d];\n", wordnum, TokenNum-1);
153 fprintf(Parser_c,
154 "SetWordType %s::setwd%d[%d] = {", CurrentClassName, wordnum,
155 TokenNum-1);
156 for (i=0; i<TokenNum-1; i++)
157 {
158 DAWDLE;
159 if ( i!=0 ) fprintf(Parser_c, ",");
160 if ( c == 8 ) {fprintf(Parser_c, "\n\t"); c=1;} else c++;
161 fprintf(Parser_c, "0x%x", setwd[i]);
162 }
163 fprintf(Parser_c, "};\n");
164 }
165
166 /* Make a new set. Dump old setwd and create new setwd if current setwd is full */
167 void
168 #ifdef __USE_PROTOS
169 NewSet( void )
170 #else
171 NewSet( )
172 #endif
173 {
174 setnum++;
175 if ( setnum==BitsPerWord ) /* is current setwd full? */
176 {
177 DumpSetWd(); NewSetWd(); setnum = 0;
178 }
179 }
180
181 /* s is a set of tokens. Turn on bit at each token position in set 'setnum' */
182 void
183 #ifdef __USE_PROTOS
184 FillSet( set s )
185 #else
186 FillSet( s )
187 set s;
188 #endif
189 {
190 SetWordType mask=(((unsigned)1)<<setnum);
191 unsigned int e;
192
193 while ( !set_nil(s) )
194 {
195 e = set_int(s);
196 set_rm(e, s);
197 setwd[e] |= mask;
198 }
199 }
200
201 /* E r r o r C l a s s S t u f f */
202
203 /* compute the FIRST of a rule for the error class stuff */
204 static set
205 #ifdef __USE_PROTOS
206 Efirst( char *rule, ECnode *eclass )
207 #else
208 Efirst( rule, eclass )
209 char *rule;
210 ECnode *eclass;
211 #endif
212 {
213 set rk, a;
214 Junction *r;
215 RuleEntry *q = (RuleEntry *) hash_get(Rname, rule);
216
217 if ( q == NULL )
218 {
219 warnNoFL(eMsg2("undefined rule '%s' referenced in errclass '%s'; ignored",
220 rule, TokenString(eclass->tok)));
221 return empty;
222 }
223 r = RulePtr[q->rulenum];
224 r->end->halt = TRUE; /* don't let reach fall off end of rule here */
225 rk = empty;
226 REACH(r, 1, &rk, a);
227 r->end->halt = FALSE;
228 return a;
229 }
230
231 /*
232 * scan the list of tokens/eclasses/nonterminals filling the new eclass
233 * with the set described by the list. Note that an eclass can be
234 * quoted to allow spaces etc... However, an eclass must not conflict
235 * with a reg expr found elsewhere. The reg expr will be taken over
236 * the eclass name.
237 */
238 static void
239 #ifdef __USE_PROTOS
240 doEclass( char *eclass )
241 #else
242 doEclass( eclass )
243 char *eclass;
244 #endif
245 {
246 TermEntry *q;
247 ECnode *p;
248 TCnode *tcnode;
249 ListNode *e;
250 unsigned int t;
251 unsigned deg=0;
252 set a;
253 require(eclass!=NULL, "doEclass: NULL eset");
254
255 p = (ECnode *) eclass;
256 lexmode(p->lexclass); /* switch to lexclass where errclass is defined */
257 p->eset = empty;
258 for (e = (p->elist)->next; e!=NULL; e=e->next)
259 {
260 q = NULL; /* MR23 */
261
262 if ( islower( *((char *)e->elem) ) ) /* is it a rule ref? (alias FIRST request) */
263 {
264 a = Efirst((char *)e->elem, p);
265 set_orin(&p->eset, a);
266 deg += set_deg(a);
267 set_free( a );
268 continue;
269 }
270 else if ( *((char *)e->elem)=='"' )
271 {
272 t = 0;
273 q = (TermEntry *) hash_get(Texpr, (char *) e->elem);
274 if ( q == NULL )
275 {
276 /* if quoted and not an expr look for eclass name */
277 /* fix to the following to avoid -fstrict-aliasing problems in compiler: */
278 char *e_ch = StripQuotes((char *)e->elem);
279 e->elem = e_ch;
280 q = (TermEntry *) hash_get(Tname, *((char **)&(e_ch)) );
281 /* above was: q = (TermEntry *) hash_get(Tname, *((char **)&(e->elem))=StripQuotes((char *)e->elem)); */
282
283 if ( q != NULL ) t = q->token;
284 }
285 else t = q->token;
286 }
287 else /* labelled token/eclass/tokclass */
288 {
289 q = (TermEntry *) hash_get(Tname, (char *)e->elem);
290 if ( q != NULL )
291 {
292 if ( strcmp((char *)e->elem, TokenString(p->tok))==0 )
293 {
294 warnNoFL(eMsg1("self-referential error class '%s'; ignored",
295 (char *)e->elem));
296 continue;
297 }
298 else
299 t = q->token;
300 }
301 else t=0;
302 }
303 if ( t!=0 )
304 {
305 if (isTermEntryTokClass(q)) { /* MR23 */
306 tcnode = q->tclass; /* MR23 */
307 set_orin(&p->eset, tcnode->tset); /* MR23 */
308 deg = set_deg(p->eset); /* MR23 */
309 } /* MR23 */
310 else {
311 set_orel(t, &p->eset);
312 deg++;
313 }
314 }
315 else warnNoFL(eMsg2("undefined token '%s' referenced in errclass '%s'; ignored",
316 (char *)e->elem, TokenString(p->tok)));
317 }
318 p->setdeg = deg;
319 }
320
321 void
322 #ifdef __USE_PROTOS
323 ComputeErrorSets( void )
324 #else
325 ComputeErrorSets( )
326 #endif
327 {
328 #ifdef __cplusplus
329 list_apply(eclasses, (void (*)(void *)) doEclass);
330 #else
331 #ifdef __USE_PROTOS
332 list_apply(eclasses, (void (*)(void *)) doEclass);
333 #else
334 list_apply(eclasses, doEclass);
335 #endif
336 #endif
337 }
338
339 void
340 #ifdef __USE_PROTOS
341 ComputeTokSets( void )
342 #else
343 ComputeTokSets( )
344 #endif
345 {
346 ListNode *t, *e = NULL, *e1, *e2;
347 int something_changed;
348 int i;
349 TCnode *p;
350 TermEntry *q, *q1, *q2;
351
352 if ( tclasses == NULL ) return;
353
354 /* turn lists of token/tokclass references into sets */
355 for (t = tclasses->next; t!=NULL; t=t->next)
356 {
357 p = (TCnode *) t->elem;
358
359 /* if wild card, then won't have entries in tclass, assume all_tokens */
360 if ( p->tok == WildCardToken )
361 {
362 p->tset = set_dup(all_tokens);
363 continue;
364 }
365
366 lexmode(p->lexclass); /* switch to lexclass where tokclass is defined */
367 p->tset = empty;
368
369 /* instantiate all tokens/token_classes into the tset */
370 for (e = (p->tlist)->next; e!=NULL; e=e->next)
371 {
372 char *tokstr;
373 tokstr = (char *)e->elem;
374 if ( *tokstr == '"' ) {
375 q = (TermEntry *) hash_get(Texpr, tokstr);
376 require(q!=NULL, "ComputeTokSets: no token def");
377 set_orel(q->token, &p->tset);
378 } else if (tokstr[0] == '.') {
379 e1=e->next;
380 e2=e1->next;
381 e=e2;
382 q1= (TermEntry *) hash_get(Tname, (char *)e1->elem);
383 require(q1!=NULL, "ComputeTokSets: no token def");
384 q2= (TermEntry *) hash_get(Tname, (char *)e2->elem);
385 require(q2!=NULL, "ComputeTokSets: no token def");
386
387 if (set_el(q1->token,imag_tokens)) {
388 errNoFL(eMsg2("can't define #tokclass %s using #tokclass or #errclass %s",
389 TokenString(p->tok),(char *)e1->elem) );
390 }
391 if (set_el(q2->token,imag_tokens)) {
392 errNoFL(eMsg2("can't define #tokclass %s using #tokclass or #errclass %s",
393 TokenString(p->tok),(char *)e2->elem) );
394 }
395 if (q1->token > q2->token) {
396 errNoFL(eMsg3("for #tokclass %s %s..%s - first token number > second token number",
397 TokenString(p->tok),(char *)e1->elem,(char *)e2->elem) );
398 for (i=q2->token; i<=q1->token; i++) { set_orel(i, &p->tset); }
399 } else {
400 for (i=q1->token; i<=q2->token; i++) { set_orel(i, &p->tset); }
401 }
402 } else {
403 q = (TermEntry *) hash_get(Tname, tokstr);
404 require(q!=NULL, "ComputeTokSets: no token def");
405 set_orel(q->token, &p->tset);
406 }
407 }
408 }
409
410 /* Go thru list of tokclasses again looking for tokclasses in sets */
411 again:
412 something_changed = 0;
413 for (t = tclasses->next; t!=NULL; t=t->next)
414 {
415 set tcl;
416 p = (TCnode *) t->elem;
417 tcl = set_and(p->tset, tokclasses);
418 if ( !set_nil(tcl) )
419 {
420 int tk;
421 /* replace refs to tokclasses with the associated set of tokens */
422 something_changed = 1;
423 while ( !set_nil(tcl) )
424 {
425 tk = set_int(tcl); /* grab one of the tok class refs */
426 set_rm(tk, tcl);
427 if ( p->tok != tk ) /* tokclass ref to yourself? */
428 {
429 q = (TermEntry *) hash_get(Tname, TokenString(tk));
430 require(q!=NULL, "#tokclass not in hash table");
431 set_orin(&p->tset, q->tclass->tset);
432 }
433 set_rm(tk, p->tset); /* remove ref that we replaced */
434 }
435 }
436 set_free(tcl);
437 }
438 if ( something_changed ) goto again;
439 }
440
441 void
442 #ifdef __USE_PROTOS
443 DumpRemainingTokSets(void)
444 #else
445 DumpRemainingTokSets()
446 #endif
447 {
448 TCnode *p;
449 ListNode *t;
450
451 /* Go thru tclasses (for the last time) and dump the sets not dumped
452 * during code gen; yes, this is a bogus way to do this, but ComputeTokSets()
453 * can't dump the defs as the error file and tok file has not been created
454 * yet etc...
455 */
456 if ( tclasses==NULL ) return;
457 for (t = tclasses->next; t!=NULL; t=t->next)
458 {
459 unsigned e;
460 p = (TCnode *) t->elem;
461 if ( p->dumped ) continue;
462 e = DefErrSet(&(p->tset), 0, TokenString(p->tok));
463 p->dumped = 1;
464 p->setnum = e;
465 }
466 }
467
468
469 /* replace a subset of an error set with an error class name if a subset is found
470 * repeat process until no replacements made
471 */
472 void
473 #ifdef __USE_PROTOS
474 SubstErrorClass( set *f )
475 #else
476 SubstErrorClass( f )
477 set *f;
478 #endif
479 {
480 int max, done = 0;
481 ListNode *p;
482 ECnode *ec, *maxclass = NULL;
483 set a;
484 require(f!=NULL, "SubstErrorClass: NULL eset");
485
486 if ( eclasses == NULL ) return;
487 while ( !done )
488 {
489 max = 0;
490 maxclass = NULL;
491 for (p=eclasses->next; p!=NULL; p=p->next) /* chk all error classes */
492 {
493 ec = (ECnode *) p->elem;
494 if ( ec->setdeg > max )
495 {
496 if ( set_sub(ec->eset, *f) || set_equ(ec->eset, *f) )
497 {maxclass = ec; max=ec->setdeg;}
498 }
499 }
500 if ( maxclass != NULL ) /* if subset found, replace with token */
501 {
502 a = set_dif(*f, maxclass->eset);
503 set_orel((unsigned)maxclass->tok, &a);
504 set_free(*f);
505 *f = a;
506 }
507 else done = 1;
508 }
509 }
510
511 int
512 #ifdef __USE_PROTOS
513 DefErrSet1(int nilOK, set *f, int subst, char *name )
514 #else
515 DefErrSet1(nilOK, f, subst, name )
516 int nilOK;
517 set *f;
518 int subst; /* should be substitute error classes? */
519 char *name;
520 #endif
521 {
522 if ( GenCC ) return DefErrSetForCC1(nilOK, f, subst, name, "_set");
523 else return DefErrSetForC1(nilOK, f, subst, name, "_set");
524 }
525
526 int
527 #ifdef __USE_PROTOS
528 DefErrSet( set *f, int subst, char *name )
529 #else
530 DefErrSet( f, subst, name )
531 set *f;
532 int subst; /* should be substitute error classes? */
533 char *name;
534 #endif
535 {
536 return DefErrSet1(0,f,subst,name);
537 }
538
539 int
540 #ifdef __USE_PROTOS
541 DefErrSetWithSuffix(int nilOK, set *f, int subst, char *name, const char* suffix)
542 #else
543 DefErrSetWithSuffix(nilOK, f, subst, name, suffix )
544 int nilOK;
545 set *f;
546 int subst; /* should be substitute error classes? */
547 char *name;
548 char *suffix;
549 #endif
550 {
551 if ( GenCC ) return DefErrSetForCC1(nilOK, f, subst, name, suffix );
552 else return DefErrSetForC1(nilOK, f, subst, name, suffix);
553 }
554
555 /* Define a new error set. WARNING...set-implementation dependent.
556 */
557 int
558 #ifdef __USE_PROTOS
559 DefErrSetForC1(int nilOK, set *f, int subst, char * name, const char * suffix)
560 #else
561 DefErrSetForC1(nilOK, f, subst, name, suffix)
562 int nilOK; /* MR13 */
563 set *f;
564 int subst; /* should be substitute error classes? */
565 char *name;
566 const char *suffix;
567 #endif
568 {
569 unsigned *p, *endp;
570 int e=1;
571
572 if (!nilOK) require(!set_nil(*f), "DefErrSetForC1: nil set to dump?");
573
574 if ( subst ) SubstErrorClass(f);
575 p = f->setword;
576 endp = &(f->setword[f->n]);
577 esetnum++;
578 if ( name!=NULL )
579 fprintf(DefFile, "extern SetWordType %s%s[];\n", name, suffix);
580 else
581 fprintf(DefFile, "extern SetWordType zzerr%d[];\n", esetnum);
582 if ( name!=NULL ) {
583 fprintf(ErrFile, "SetWordType %s%s[%d] = {",
584 name,
585 suffix,
586 (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
587 }
588 else {
589 fprintf(ErrFile, "SetWordType zzerr%d[%d] = {",
590 esetnum,
591 (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
592 }
593 while ( p < endp )
594 {
595 if ( e > 1 ) fprintf(ErrFile, ", ");
596 DumpIntAsChars(ErrFile, "0x%x", *p++);
597 if ( e == 3 )
598 {
599 DAWDLE;
600 if ( p < endp ) fprintf(ErrFile, ",");
601 fprintf(ErrFile, "\n\t");
602 e=1;
603 }
604 else e++;
605 }
606 fprintf(ErrFile, "};\n");
607
608 return esetnum;
609 }
610
611 int
612 #ifdef __USE_PROTOS
613 DefErrSetForC( set *f, int subst, char *name )
614 #else
615 DefErrSetForC( f, subst, name )
616 set *f;
617 int subst; /* should be substitute error classes? */
618 char *name;
619 #endif
620 {
621 return DefErrSetForC1(0,f,subst,name, "_set");
622 }
623
624 /* Define a new error set. WARNING...set-implementation dependent;
625 * Only used when -CC on.
626 */
627
628 int
629 #ifdef __USE_PROTOS
630 DefErrSetForCC1(int nilOK, set *f, int subst, char *name, const char *suffix )
631 #else
632 DefErrSetForCC1(nilOK, f, subst, name, suffix )
633 int nilOK; /* MR13 */
634 set *f;
635 int subst; /* should be substitute error classes? */
636 char *name;
637 const char *suffix;
638 #endif
639 {
640 unsigned *p, *endp;
641 int e=1;
642
643 if (!nilOK) require(!set_nil(*f), "DefErrSetForCC1: nil set to dump?");
644
645 if ( subst ) SubstErrorClass(f);
646 p = f->setword;
647 endp = &(f->setword[f->n]);
648 esetnum++;
649
650 if ( name!=NULL ) {
651 fprintf(Parser_h, "\tstatic SetWordType %s%s[%d];\n", name, suffix,
652 (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
653 fprintf(Parser_c, "SetWordType %s::%s%s[%d] = {",
654 CurrentClassName,
655 name,
656 suffix,
657 (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
658 }
659 else {
660 fprintf(Parser_c, "SetWordType %s::err%d[%d] = {",
661 CurrentClassName,
662 esetnum,
663 (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
664 fprintf(Parser_h, "\tstatic SetWordType err%d[%d];\n", esetnum,
665 (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
666 }
667
668 while ( p < endp )
669 {
670 if ( e > 1 ) fprintf(Parser_c, ", ");
671 DumpIntAsChars(Parser_c, "0x%x", *p++);
672 if ( e == 3 )
673 {
674 if ( p < endp ) fprintf(Parser_c, ",");
675 fprintf(Parser_c, "\n\t");
676 e=1;
677 }
678 else e++;
679 }
680 fprintf(Parser_c, "};\n");
681
682 return esetnum;
683 }
684
685 int
686 #ifdef __USE_PROTOS
687 DefErrSetForCC( set *f, int subst, char *name )
688 #else
689 DefErrSetForCC( f, subst, name )
690 set *f;
691 int subst; /* should be substitute error classes? */
692 char *name;
693 #endif
694 {
695 return DefErrSetForCC1(0,f,subst,name, "_set");
696 }
697
698 void
699 #ifdef __USE_PROTOS
700 GenParser_c_Hdr(void)
701 #else
702 GenParser_c_Hdr()
703 #endif
704 {
705 int i,j;
706 TermEntry *te;
707 char * hasAkaName = NULL; /* MR23 */
708
709 hasAkaName = (char *) malloc(TokenNum+1); /* MR23 */
710 require(hasAkaName!=NULL, "Cannot alloc hasAkaName\n"); /* MR23 */
711 for (i = 0; i < TokenNum; i++) hasAkaName[i]='0'; /* MR23 */
712 hasAkaName[TokenNum] = 0; /* MR23 */
713
714 fprintf(Parser_c, "/*\n");
715 fprintf(Parser_c, " * %s: P a r s e r S u p p o r t\n", CurrentClassName);
716 fprintf(Parser_c, " *\n");
717 fprintf(Parser_c, " * Generated from:");
718 for (i=0; i<NumFiles; i++) fprintf(Parser_c, " %s", FileStr[i]);
719 fprintf(Parser_c, "\n");
720 fprintf(Parser_c, " *\n");
721 fprintf(Parser_c, " * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\n");
722 fprintf(Parser_c, " * Parr Research Corporation\n");
723 fprintf(Parser_c, " * with Purdue University Electrical Engineering\n");
724 fprintf(Parser_c, " * with AHPCRC, University of Minnesota\n");
725 fprintf(Parser_c, " * ANTLR Version %s\n", Version);
726 fprintf(Parser_c, " */\n\n");
727
728 if ( FirstAction != NULL ) dumpAction(FirstAction,Parser_c, 0, -1, 0, 1); /* MR11 MR15b */
729
730 fprintf(Parser_c, "#define ANTLR_VERSION %s\n", VersionDef);
731
732 fprintf(Parser_c, "#include \"pcctscfg.h\"\n");
733 fprintf(Parser_c, "#include \"pccts_stdio.h\"\n");
734 fprintf(Parser_c, "#define ANTLR_SUPPORT_CODE\n");
735 if ( UserTokenDefsFile != NULL )
736 fprintf(Parser_c, "#include %s\n", UserTokenDefsFile);
737 else
738 fprintf(Parser_c, "#include \"%s\"\n", DefFileName);
739
740 fprintf(Parser_c, "#include \"%s.h\"\n\n", CurrentClassName);
741
742 fprintf(Parser_c, "const ANTLRChar *%s::tokenName(int tok) ", /* MR1 */
743 CurrentClassName); /* MR1 */
744 fprintf(Parser_c, " { return _token_tbl[tok]; }\n"); /* MR1 */ /* MR10 */
745 /* Dump a Parser::tokens for each automaton */
746 fprintf(Parser_c, "\nconst ANTLRChar *%s::_token_tbl[]={\n",
747 CurrentClassName); /* MR20 */
748 fprintf(Parser_c, "\t/* 00 */\t\"Invalid\"");
749
750 for (i=1; i<TokenNum-1; i++)
751 {
752 DAWDLE;
753 if ( i == EpToken ) continue;
754 /* remapped to invalid token? */
755 if ( TokenInd!=NULL && TokenInd[i]>=LastTokenCounted )
756 {
757 fprintf(Parser_c, ",\n\t/* %02d */\t\"invalid\"", i);
758 continue;
759 }
760 if ( TokenString(i) != NULL ) {
761 te=(TermEntry *) hash_get(Tname,TokenString(i)); /* MR11 */
762 if (te == NULL || te->akaString == NULL) { /* MR11 */
763 fprintf(Parser_c, ",\n\t/* %02d */\t\"%s\"", i, TokenString(i));
764 } else {
765 hasAkaName[i] = '1'; /* MR23 */
766 fprintf(Parser_c, ",\n\t/* %02d */\t\"%s\"", i, te->akaString); /* MR11 */
767 }
768 }
769 else
770 {
771 /* look in all lexclasses for the reg expr */
772 for (j=0; j<NumLexClasses; j++)
773 {
774 lexmode(j);
775 if ( ExprString(i) != NULL )
776 {
777 fprintf(Parser_c, ",\n\t/* %02d */\t", i);
778 dumpExpr(Parser_c, ExprString(i));
779 break;
780 }
781 }
782 if ( j>=NumLexClasses )
783 {
784 if ( UserDefdTokens )
785 {
786 fprintf(Parser_c, ",\n\t/* %02d */\t\"\"", i);
787 }
788 else
789 fatal_internal(eMsgd("No label or expr for token %d",i));
790 }
791 }
792 }
793 fprintf(Parser_c, "\n};\n");
794
795 /* Build constructors */
796 fprintf(Parser_c, "\n%s::", CurrentClassName);
797 fprintf(Parser_c, "%s(ANTLRTokenBuffer *input) : %s(input,%d,%d,%d,%d)\n",
798 CurrentClassName,
799 (BaseClassName == NULL ? "ANTLRParser" : BaseClassName),
800 OutputLL_k,
801 FoundGuessBlk,
802 DemandLookahead,
803 (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
804 fprintf(Parser_c, "{\n");
805 fprintf(Parser_c, "\ttoken_tbl = _token_tbl;\n");
806 if (TraceGen) {
807 fprintf(Parser_c, "\ttraceOptionValueDefault=1;\t\t// MR10 turn trace ON\n");
808 } else {
809 fprintf(Parser_c, "\ttraceOptionValueDefault=0;\t\t// MR10 turn trace OFF\n");
810 };
811 fprintf(Parser_c, "}\n\n");
812 free ( (void *) hasAkaName);
813 }
814
815 void
816 #ifdef __USE_PROTOS
817 GenParser_h_Hdr(void)
818 #else
819 GenParser_h_Hdr()
820 #endif
821 {
822 int i;
823
824 fprintf(Parser_h, "/*\n");
825 fprintf(Parser_h, " * %s: P a r s e r H e a d e r \n", CurrentClassName);
826 fprintf(Parser_h, " *\n");
827 fprintf(Parser_h, " * Generated from:");
828 for (i=0; i<NumFiles; i++) fprintf(Parser_h, " %s", FileStr[i]);
829 fprintf(Parser_h, "\n");
830 fprintf(Parser_h, " *\n");
831 fprintf(Parser_h, " * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\n");
832 fprintf(Parser_h, " * Parr Research Corporation\n");
833 fprintf(Parser_h, " * with Purdue University Electrical Engineering\n");
834 fprintf(Parser_h, " * with AHPCRC, University of Minnesota\n");
835 fprintf(Parser_h, " * ANTLR Version %s\n", Version);
836 fprintf(Parser_h, " */\n\n");
837
838 if ( FirstAction != NULL ) dumpAction( FirstAction, Parser_h, 0, -1, 0, 1); /* MR11 MR15b */
839
840 fprintf(Parser_h, "#ifndef %s_h\n", CurrentClassName);
841 fprintf(Parser_h, "#define %s_h\n\n", CurrentClassName);
842
843 fprintf(Parser_h, "#ifndef ANTLR_VERSION\n");
844 fprintf(Parser_h, "#define ANTLR_VERSION %s\n",VersionDef);
845 fprintf(Parser_h, "#endif\n\n");
846
847 if ( GenAST ) fprintf(Parser_h, "class ASTBase;\n");
848 if (TraceGen) {
849 fprintf(Parser_h,"#ifndef zzTRACE_RULES\n"); /* MR20 */
850 fprintf(Parser_h,"#define zzTRACE_RULES\n"); /* MR20 */
851 fprintf(Parser_h,"#endif\n"); /* MR22 */
852 };
853 fprintf(Parser_h, "#include \"%s\"\n\n", APARSER_H);
854
855 if ( HdrAction != NULL ) dumpAction( HdrAction, Parser_h, 0, -1, 0, 1);
856
857 /* MR10 */ if (ClassDeclStuff == NULL) {
858 /* MR10 */ fprintf(Parser_h, "class %s : public ANTLRParser {\n", CurrentClassName);
859 /* MR10 */ } else {
860 /* MR10 */ fprintf(Parser_h, "class %s %s {\n",CurrentClassName,ClassDeclStuff);
861 /* MR10 */ };
862
863 fprintf(Parser_h, "public:\n"); /* MR1 */
864 fprintf(Parser_h, "\tstatic const ANTLRChar *tokenName(int tk);\n");/* MR1 */
865 fprintf(Parser_h, "\tenum { SET_SIZE = %i };\n",TokenNum-1); /* MR21 */
866 fprintf(Parser_h, "protected:\n");
867 fprintf(Parser_h, "\tstatic const ANTLRChar *_token_tbl[];\n"); /* MR20 */
868 fprintf(Parser_h, "private:\n");
869 }
870
871 /* Currently, this is only used in !GenCC mode */
872 void
873 #ifdef __USE_PROTOS
874 GenErrHdr( void )
875 #else
876 GenErrHdr( )
877 #endif
878 {
879 int i, j;
880 TermEntry *te;
881
882 fprintf(ErrFile, "/*\n");
883 fprintf(ErrFile, " * A n t l r S e t s / E r r o r F i l e H e a d e r\n");
884 fprintf(ErrFile, " *\n");
885 fprintf(ErrFile, " * Generated from:");
886 for (i=0; i<NumFiles; i++) fprintf(ErrFile, " %s", FileStr[i]);
887 fprintf(ErrFile, "\n");
888 fprintf(ErrFile, " *\n");
889 fprintf(ErrFile, " * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\n");
890 fprintf(ErrFile, " * Parr Research Corporation\n");
891 fprintf(ErrFile, " * with Purdue University Electrical Engineering\n");
892 fprintf(ErrFile, " * With AHPCRC, University of Minnesota\n");
893 fprintf(ErrFile, " * ANTLR Version %s\n", Version);
894 fprintf(ErrFile, " */\n\n");
895
896 if ( FirstAction != NULL ) dumpAction( FirstAction, ErrFile, 0, -1, 0, 1); /* MR11 MR15b */
897
898 fprintf(ErrFile, "#define ANTLR_VERSION %s\n", VersionDef);
899
900 fprintf(ErrFile, "#include \"pcctscfg.h\"\n");
901 fprintf(ErrFile, "#include \"pccts_stdio.h\"\n");
902 if ( strcmp(ParserName, DefaultParserName)!=0 )
903 fprintf(ErrFile, "#define %s %s\n", DefaultParserName, ParserName);
904 if ( strcmp(ParserName, DefaultParserName)!=0 )
905 fprintf(ErrFile, "#include \"%s\"\n", RemapFileName);
906 if ( HdrAction != NULL ) dumpAction( HdrAction, ErrFile, 0, -1, 0, 1 );
907 if ( FoundGuessBlk )
908 {
909 fprintf(ErrFile, "#define ZZCAN_GUESS\n");
910 fprintf(ErrFile, "#include \"pccts_setjmp.h\"\n");
911 }
912 if (TraceGen) {
913 fprintf(ErrFile,"#ifndef zzTRACE_RULES\n"); /* MR20 */
914 fprintf(ErrFile,"#define zzTRACE_RULES\n"); /* MR20 */
915 fprintf(ErrFile,"#endif\n"); /* MR22 */
916 };
917
918 if ( OutputLL_k > 1 ) fprintf(ErrFile, "#define LL_K %d\n", OutputLL_k);
919 #ifdef DUM
920 if ( LexGen ) fprintf(ErrFile, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));
921 #endif
922 fprintf(ErrFile, "#define zzSET_SIZE %d\n", (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
923 if ( DemandLookahead ) fprintf(ErrFile, "#define DEMAND_LOOK\n");
924 fprintf(ErrFile, "#include \"antlr.h\"\n");
925 if ( GenAST ) fprintf(ErrFile, "#include \"ast.h\"\n");
926
927 if ( UserDefdTokens ) fprintf(ErrFile, "#include %s\n", UserTokenDefsFile);
928 /* still need this one as it has the func prototypes */
929 fprintf(ErrFile, "#include \"%s\"\n", DefFileName);
930 fprintf(ErrFile, "#include \"dlgdef.h\"\n");
931 fprintf(ErrFile, "#include \"err.h\"\n\n");
932
933 /* Dump a zztokens for each automaton */
934 if ( strcmp(ParserName, DefaultParserName)!=0 )
935 {
936 fprintf(ErrFile, "ANTLRChar *%s_zztokens[%d]={\n", ParserName, TokenNum-1);
937 }
938 else
939 {
940 fprintf(ErrFile, "ANTLRChar *zztokens[%d]={\n", TokenNum-1);
941 }
942 fprintf(ErrFile, "\t/* 00 */\t\"Invalid\"");
943 for (i=1; i<TokenNum-1; i++)
944 {
945 DAWDLE;
946 if ( i == EpToken ) continue;
947 /* remapped to invalid token? */
948 if ( TokenInd!=NULL && TokenInd[i]>=LastTokenCounted )
949 {
950 fprintf(ErrFile, ",\n\t/* %02d */\t\"invalid\"", i);
951 continue;
952 }
953 if ( TokenString(i) != NULL ) {
954 te=(TermEntry *) hash_get(Tname,TokenString(i)); /* MR11 */
955 if (te == NULL || te->akaString == NULL) { /* MR11 */
956 fprintf(ErrFile, ",\n\t/* %02d */\t\"%s\"", i, TokenString(i));
957 } else {
958 fprintf(ErrFile, ",\n\t/* %02d */\t\"%s\"", i, te->akaString); /* MR11 */
959 }
960 }
961 else
962 {
963 /* look in all lexclasses for the reg expr */
964 for (j=0; j<NumLexClasses; j++)
965 {
966 lexmode(j);
967 if ( ExprString(i) != NULL )
968 {
969 fprintf(ErrFile, ",\n\t/* %02d */\t", i);
970 dumpExpr(ErrFile, ExprString(i));
971 break;
972 }
973 }
974 if ( j>=NumLexClasses )
975 {
976 if ( UserDefdTokens )
977 {
978 fprintf(ErrFile, ",\n\t/* %02d */\t\"\"", i);
979 }
980 else
981 fatal_internal(eMsgd("No label or expr for token %d",i));
982 }
983 }
984 }
985 fprintf(ErrFile, "\n};\n");
986 }
987
988 void
989 #ifdef __USE_PROTOS
990 dumpExpr( FILE *f, char *e )
991 #else
992 dumpExpr( f, e )
993 FILE *f;
994 char *e;
995 #endif
996 {
997 while ( *e!='\0' )
998 {
999 if ( *e=='\\' && *(e+1)=='\\' )
1000 {putc('\\', f); putc('\\', f); e+=2;}
1001 else if ( *e=='\\' && *(e+1)=='"' )
1002 {putc('\\', f); putc('"', f); e+=2;}
1003 else if ( *e=='\\' ) {putc('\\', f); putc('\\', f); e++;}
1004 else {putc(*e, f); e++;}
1005 }
1006 }
1007
1008 int
1009 #ifdef __USE_PROTOS
1010 isTermEntryTokClass(TermEntry *te)
1011 #else
1012 isTermEntryTokClass(te)
1013 TermEntry *te;
1014 #endif
1015 {
1016 ListNode *t;
1017 TCnode *p;
1018 TermEntry *q;
1019 char *tokstr;
1020
1021 if (tclasses == NULL) return 0;
1022
1023 for (t = tclasses->next; t!=NULL; t=t->next)
1024 {
1025 p = (TCnode *) t->elem;
1026 tokstr = TokenString(p->tok);
1027 lexmode(p->lexclass); /* switch to lexclass where tokclass is defined */
1028 q = (TermEntry *) hash_get(Tname, tokstr);
1029 if (q == te) return 1;
1030 }
1031 return 0;
1032 }
+0
-813
contrib/pccts/antlr/build.c less more
0 /*
1 * build.c -- functions associated with building syntax diagrams.
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1989-2001
28 */
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <ctype.h>
33 #include "pcctscfg.h"
34 #include "set.h"
35 #include "syn.h"
36 #include "hash.h"
37 #include "generic.h"
38 #include "dlgdef.h"
39
40 #define SetBlk(g, t, approx, first_set_symbol) { \
41 ((Junction *)g.left)->jtype = t; \
42 ((Junction *)g.left)->approx = approx; \
43 ((Junction *)g.left)->pFirstSetSymbol = first_set_symbol; \
44 ((Junction *)g.left)->end = (Junction *) g.right; \
45 ((Junction *)g.right)->jtype = EndBlk;}
46
47 /* Add the parameter string 'parm' to the parms field of a block-type junction
48 * g.left points to the sentinel node on a block. i.e. g.left->p1 points to
49 * the actual junction with its jtype == some block-type.
50 */
51 void
52 #ifdef __USE_PROTOS
53 addParm( Node *p, char *parm )
54 #else
55 addParm( p, parm )
56 Node *p;
57 char *parm;
58 #endif
59 {
60 char *q = (char *) malloc( strlen(parm) + 1 );
61 require(p!=NULL, "addParm: NULL object\n");
62 require(q!=NULL, "addParm: unable to alloc parameter\n");
63
64 strcpy(q, parm);
65 if ( p->ntype == nRuleRef )
66 {
67 ((RuleRefNode *)p)->parms = q;
68 }
69 else if ( p->ntype == nJunction )
70 {
71 ((Junction *)p)->parm = q; /* only one parameter allowed on subrules */
72 }
73 else fatal_internal("addParm: invalid node for adding parm");
74 }
75
76 /*
77 * Build an action node for the syntax diagram
78 *
79 * buildAction(ACTION) ::= --o-->ACTION-->o--
80 *
81 * Where o is a junction node.
82 */
83 Graph
84 #ifdef __USE_PROTOS
85 buildAction( char *action, int file, int line, int is_predicate )
86 #else
87 buildAction( action, file, line, is_predicate )
88 char *action;
89 int file;
90 int line;
91 int is_predicate;
92 #endif
93 {
94 Junction *j1, *j2;
95 Graph g;
96 ActionNode *a;
97 require(action!=NULL, "buildAction: invalid action");
98
99 j1 = newJunction();
100 j2 = newJunction();
101 a = newActionNode();
102 a->action = (char *) malloc( strlen(action)+1 );
103 require(a->action!=NULL, "buildAction: cannot alloc space for action\n");
104 strcpy(a->action, action);
105 j1->p1 = (Node *) a;
106 a->next = (Node *) j2;
107 a->is_predicate = is_predicate;
108
109 if (is_predicate) {
110 PredEntry *predEntry;
111 char *t;
112 char *key;
113 char *u;
114 int inverted=0;
115
116 t=key=(char *)calloc(1,strlen(a->action)+1);
117
118 for (u=a->action; *u != '\0' ; u++) {
119 if (*u != ' ') {
120 if (t==key && *u=='!') {
121 inverted=!inverted;
122 } else {
123 *t++=*u;
124 };
125 };
126 };
127
128 *t='\0';
129
130
131 predEntry=(PredEntry *)hash_get(Pname,key);
132 a->predEntry=predEntry;
133 if (predEntry != NULL) a->inverted=inverted;
134 } else {
135 /* MR12c */ char *strStart=a->action;
136 /* MR12c */ char *strEnd;
137 /* MR12c */ strEnd=strStart+strlen(strStart)-1;
138 /* MR12c */ for ( ; strEnd >= strStart && isspace(*strEnd); strEnd--) *strEnd=0;
139 /* MR12c */ while (*strStart != '\0' && isspace(*strStart)) strStart++;
140 /* MR12c */ if (ci_strequ(strStart,"nohoist")) {
141 /* MR12c */ a->noHoist=1;
142 /* MR12c */ }
143 }
144
145 g.left = (Node *) j1; g.right = (Node *) j2;
146 a->file = file;
147 a->line = line;
148 a->rname = CurRule; /* MR10 */
149 return g;
150 }
151
152 /*
153 * Build a token node for the syntax diagram
154 *
155 * buildToken(TOKEN) ::= --o-->TOKEN-->o--
156 *
157 * Where o is a junction node.
158 */
159 Graph
160 #ifdef __USE_PROTOS
161 buildToken( char *text )
162 #else
163 buildToken( text )
164 char *text;
165 #endif
166 {
167 Junction *j1, *j2;
168 Graph g;
169 TokNode *t;
170 require(text!=NULL, "buildToken: invalid token name");
171
172 j1 = newJunction();
173 j2 = newJunction();
174 t = newTokNode();
175 t->altstart = CurAltStart;
176 if ( *text == '"' ) {t->label=FALSE; t->token = addTexpr( text );}
177 else {t->label=TRUE; t->token = addTname( text );}
178 j1->p1 = (Node *) t;
179 t->next = (Node *) j2;
180 g.left = (Node *) j1; g.right = (Node *) j2;
181 return g;
182 }
183
184 /*
185 * Build a wild-card node for the syntax diagram
186 *
187 * buildToken(TOKEN) ::= --o-->'.'-->o--
188 *
189 * Where o is a junction node.
190 */
191 Graph
192 #ifdef __USE_PROTOS
193 buildWildCard( char *text )
194 #else
195 buildWildCard( text )
196 char *text;
197 #endif
198 {
199 Junction *j1, *j2;
200 Graph g;
201 TokNode *t;
202 TCnode *w;
203 TermEntry *p;
204 require(text!=NULL, "buildWildCard: invalid token name");
205
206 j1 = newJunction();
207 j2 = newJunction();
208 t = newTokNode();
209
210 /* If the ref a wild card, make a token class for it */
211 if ( Tnum(WildCardString) == 0 )
212 {
213 w = newTCnode;
214 w->tok = addTname( WildCardString );
215 set_orel(w->tok, &imag_tokens);
216 set_orel(w->tok, &tokclasses);
217 WildCardToken = w->tok;
218 require((p=(TermEntry *)hash_get(Tname, WildCardString)) != NULL,
219 "hash table mechanism is broken");
220 p->classname = 1; /* entry is class name, not token */
221 p->tclass = w; /* save ptr to this tclass def */
222 list_add(&tclasses, (char *)w);
223 }
224 else {
225 p=(TermEntry *)hash_get(Tname, WildCardString);
226 require( p!= NULL, "hash table mechanism is broken");
227 w = p->tclass;
228 }
229
230 t->token = w->tok;
231 t->wild_card = 1;
232 t->tclass = w;
233
234 t->altstart = CurAltStart;
235 j1->p1 = (Node *) t;
236 t->next = (Node *) j2;
237 g.left = (Node *) j1; g.right = (Node *) j2;
238 return g;
239 }
240
241 void
242 #ifdef __USE_PROTOS
243 setUpperRange(TokNode *t, char *text)
244 #else
245 setUpperRange(t, text)
246 TokNode *t;
247 char *text;
248 #endif
249 {
250 require(t!=NULL, "setUpperRange: NULL token node");
251 require(text!=NULL, "setUpperRange: NULL token string");
252
253 if ( *text == '"' ) {t->upper_range = addTexpr( text );}
254 else {t->upper_range = addTname( text );}
255 }
256
257 /*
258 * Build a rule reference node of the syntax diagram
259 *
260 * buildRuleRef(RULE) ::= --o-->RULE-->o--
261 *
262 * Where o is a junction node.
263 *
264 * If rule 'text' has been defined already, don't alloc new space to store string.
265 * Set r->text to point to old copy in string table.
266 */
267 Graph
268 #ifdef __USE_PROTOS
269 buildRuleRef( char *text )
270 #else
271 buildRuleRef( text )
272 char *text;
273 #endif
274 {
275 Junction *j1, *j2;
276 Graph g;
277 RuleRefNode *r;
278 RuleEntry *p;
279 require(text!=NULL, "buildRuleRef: invalid rule name");
280
281 j1 = newJunction();
282 j2 = newJunction();
283 r = newRNode();
284 r->altstart = CurAltStart;
285 r->assign = NULL;
286 if ( (p=(RuleEntry *)hash_get(Rname, text)) != NULL ) r->text = p->str;
287 else r->text = mystrdup( text );
288 j1->p1 = (Node *) r;
289 r->next = (Node *) j2;
290 g.left = (Node *) j1; g.right = (Node *) j2;
291 return g;
292 }
293
294 /*
295 * Or two subgraphs into one graph via:
296 *
297 * Or(G1, G2) ::= --o-G1-o--
298 * | ^
299 * v |
300 * o-G2-o
301 *
302 * Set the altnum of junction starting G2 to 1 + altnum of junction starting G1.
303 * If, however, the G1 altnum is 0, make it 1 and then
304 * make G2 altnum = G1 altnum + 1.
305 */
306 Graph
307 #ifdef __USE_PROTOS
308 Or( Graph g1, Graph g2 )
309 #else
310 Or( g1, g2 )
311 Graph g1;
312 Graph g2;
313 #endif
314 {
315 Graph g;
316 require(g1.left != NULL, "Or: invalid graph");
317 require(g2.left != NULL && g2.right != NULL, "Or: invalid graph");
318
319 ((Junction *)g1.left)->p2 = g2.left;
320 ((Junction *)g2.right)->p1 = g1.right;
321 /* set altnums */
322 if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;
323 ((Junction *)g2.left)->altnum = ((Junction *)g1.left)->altnum + 1;
324 g.left = g2.left;
325 g.right = g1.right;
326 return g;
327 }
328
329 /*
330 * Catenate two subgraphs
331 *
332 * Cat(G1, G2) ::= --o-G1-o-->o-G2-o--
333 * Cat(NULL,G2)::= --o-G2-o--
334 * Cat(G1,NULL)::= --o-G1-o--
335 */
336 Graph
337 #ifdef __USE_PROTOS
338 Cat( Graph g1, Graph g2 )
339 #else
340 Cat( g1, g2 )
341 Graph g1;
342 Graph g2;
343 #endif
344 {
345 Graph g;
346
347 if ( g1.left == NULL && g1.right == NULL ) return g2;
348 if ( g2.left == NULL && g2.right == NULL ) return g1;
349 ((Junction *)g1.right)->p1 = g2.left;
350 g.left = g1.left;
351 g.right = g2.right;
352 return g;
353 }
354
355 /*
356 * Make a subgraph an optional block
357 *
358 * makeOpt(G) ::= --o-->o-G-o-->o--
359 * | ^
360 * v |
361 * o-------o
362 *
363 * Note that this constructs {A|B|...|Z} as if (A|B|...|Z|) was found.
364 *
365 * The node on the far right is added so that every block owns its own
366 * EndBlk node.
367 */
368 Graph
369 #ifdef __USE_PROTOS
370 makeOpt( Graph g1, int approx, char * pFirstSetSymbol )
371 #else
372 makeOpt( g1, approx, pFirstSetSymbol )
373 Graph g1;
374 int approx;
375 char * pFirstSetSymbol;
376 #endif
377 {
378 Junction *j1,*j2,*p;
379 Graph g;
380 require(g1.left != NULL && g1.right != NULL, "makeOpt: invalid graph");
381
382 j1 = newJunction();
383 j2 = newJunction();
384 ((Junction *)g1.right)->p1 = (Node *) j2; /* add node to G at end */
385
386 /* MR21
387 *
388 * There is code in genBlk which recognizes the node created
389 * by emptyAlt() as a special case and bypasses it. We don't
390 * want this to happen for the optBlk.
391 */
392
393 g = emptyAlt3(); /* MR21 */
394 if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;
395 ((Junction *)g.left)->altnum = ((Junction *)g1.left)->altnum + 1;
396 for(p=(Junction *)g1.left; p->p2!=NULL; p=(Junction *)p->p2)
397 {;} /* find last alt */
398 p->p2 = g.left; /* add optional alternative */
399 ((Junction *)g.right)->p1 = (Node *)j2; /* opt alt points to EndBlk */
400 g1.right = (Node *)j2;
401 SetBlk(g1, aOptBlk, approx, pFirstSetSymbol);
402 j1->p1 = g1.left; /* add generic node in front */
403 g.left = (Node *) j1;
404 g.right = g1.right;
405 return g;
406 }
407
408 /*
409 * Make a graph into subblock
410 *
411 * makeBlk(G) ::= --o-->o-G-o-->o--
412 *
413 * The node on the far right is added so that every block owns its own
414 * EndBlk node.
415 */
416 Graph
417 #ifdef __USE_PROTOS
418 makeBlk( Graph g1, int approx, char * pFirstSetSymbol )
419 #else
420 makeBlk( g1, approx, pFirstSetSymbol )
421 Graph g1;
422 int approx;
423 char * pFirstSetSymbol;
424 #endif
425 {
426 Junction *j,*j2;
427 Graph g;
428 require(g1.left != NULL && g1.right != NULL, "makeBlk: invalid graph");
429
430 j = newJunction();
431 j2 = newJunction();
432 ((Junction *)g1.right)->p1 = (Node *) j2; /* add node to G at end */
433 g1.right = (Node *)j2;
434 SetBlk(g1, aSubBlk, approx, pFirstSetSymbol);
435 j->p1 = g1.left; /* add node in front */
436 g.left = (Node *) j;
437 g.right = g1.right;
438
439 return g;
440 }
441
442 /*
443 * Make a subgraph into a loop (closure) block -- (...)*
444 *
445 * makeLoop(G) ::= |---|
446 * v |
447 * --o-->o-->o-G-o-->o--
448 * | ^
449 * v |
450 * o-----------o
451 *
452 * After making loop, always place generic node out front. It becomes
453 * the start of enclosing block. The aLoopBlk is the target of the loop.
454 *
455 * Loop blks have TWO EndBlk nodes--the far right and the node that loops back
456 * to the aLoopBlk node. Node with which we can branch past loop == aLoopBegin and
457 * one which is loop target == aLoopBlk.
458 * The branch-past (initial) aLoopBegin node has end
459 * pointing to the last EndBlk node. The loop-target node has end==NULL.
460 *
461 * Loop blocks have a set of locks (from 1..CLL_k) on the aLoopBlk node.
462 */
463 Graph
464 #ifdef __USE_PROTOS
465 makeLoop( Graph g1, int approx, char * pFirstSetSymbol )
466 #else
467 makeLoop( g1, approx, pFirstSetSymbol)
468 Graph g1;
469 int approx;
470 char * pFirstSetSymbol;
471 #endif
472 {
473 Junction *back, *front, *begin;
474 Graph g;
475 require(g1.left != NULL && g1.right != NULL, "makeLoop: invalid graph");
476
477 back = newJunction();
478 front = newJunction();
479 begin = newJunction();
480 g = emptyAlt3();
481 ((Junction *)g1.right)->p2 = g1.left; /* add loop branch to G */
482 ((Junction *)g1.right)->p1 = (Node *) back; /* add node to G at end */
483 ((Junction *)g1.right)->jtype = EndBlk; /* mark 1st EndBlk node */
484 ((Junction *)g1.left)->jtype = aLoopBlk; /* mark 2nd aLoopBlk node */
485 ((Junction *)g1.left)->end = (Junction *) g1.right;
486 ((Junction *)g1.left)->lock = makelocks();
487 ((Junction *)g1.left)->pred_lock = makelocks();
488 g1.right = (Node *) back;
489 begin->p1 = (Node *) g1.left;
490 g1.left = (Node *) begin;
491 begin->p2 = (Node *) g.left; /* make bypass arc */
492 ((Junction *)g.right)->p1 = (Node *) back;
493 SetBlk(g1, aLoopBegin, approx, pFirstSetSymbol);
494 front->p1 = g1.left; /* add node to front */
495 g1.left = (Node *) front;
496
497 return g1;
498 }
499
500 /*
501 * Make a subgraph into a plus block -- (...)+ -- 1 or more times
502 *
503 * makePlus(G) ::= |---|
504 * v |
505 * --o-->o-G-o-->o--
506 *
507 * After making loop, always place generic node out front. It becomes
508 * the start of enclosing block. The aPlusBlk is the target of the loop.
509 *
510 * Plus blks have TWO EndBlk nodes--the far right and the node that loops back
511 * to the aPlusBlk node.
512 *
513 * Plus blocks have a set of locks (from 1..CLL_k) on the aPlusBlk node.
514 */
515 Graph
516 #ifdef __USE_PROTOS
517 makePlus( Graph g1, int approx, char * pFirstSetSymbol)
518 #else
519 makePlus( g1, approx, pFirstSetSymbol)
520 Graph g1;
521 int approx;
522 char * pFirstSetSymbol;
523 #endif
524 {
525 int has_empty_alt_already = 0;
526 Graph g;
527 Junction *j2, *j3, *first_alt;
528 Junction *last_alt=NULL, *p;
529 require(g1.left != NULL && g1.right != NULL, "makePlus: invalid graph");
530
531 first_alt = (Junction *)g1.left;
532 j2 = newJunction();
533 j3 = newJunction();
534 if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;
535 ((Junction *)g1.right)->p2 = g1.left; /* add loop branch to G */
536 ((Junction *)g1.right)->p1 = (Node *) j2; /* add node to G at end */
537 ((Junction *)g1.right)->jtype = EndBlk; /* mark 1st EndBlk node */
538 g1.right = (Node *) j2;
539 SetBlk(g1, aPlusBlk, approx, pFirstSetSymbol);
540 ((Junction *)g1.left)->lock = makelocks();
541 ((Junction *)g1.left)->pred_lock = makelocks();
542 j3->p1 = g1.left; /* add node to front */
543 g1.left = (Node *) j3;
544
545 /* add an optional branch which is the "exit" branch of loop */
546 /* FIRST, check to ensure that there does not already exist
547 * an optional path.
548 */
549 /* find last alt */
550 for(p=first_alt; p!=NULL; p=(Junction *)p->p2)
551 {
552 if ( p->p1->ntype == nJunction &&
553 p->p1!=NULL &&
554 ((Junction *)p->p1)->jtype==Generic &&
555 ((Junction *)p->p1)->p1!=NULL &&
556 ((Junction *)((Junction *)p->p1)->p1)->jtype==EndBlk )
557 {
558 has_empty_alt_already = 1;
559 }
560 last_alt = p;
561 }
562 if ( !has_empty_alt_already )
563 {
564 require(last_alt!=NULL, "last_alt==NULL; bad (..)+");
565 g = emptyAlt();
566 last_alt->p2 = g.left;
567 ((Junction *)g.right)->p1 = (Node *) j2;
568
569 /* make sure lookahead computation ignores this alt for
570 * FIRST("(..)+"); but it's still used for computing the FIRST
571 * of each alternative.
572 */
573 ((Junction *)g.left)->ignore = 1;
574 }
575
576 return g1;
577 }
578
579 /*
580 * Return an optional path: --o-->o--
581 */
582
583 Graph
584 #ifdef __USE_PROTOS
585 emptyAlt( void )
586 #else
587 emptyAlt( )
588 #endif
589 {
590 Junction *j1, *j2;
591 Graph g;
592
593 j1 = newJunction();
594 j2 = newJunction();
595 j1->p1 = (Node *) j2;
596 g.left = (Node *) j1;
597 g.right = (Node *) j2;
598
599 return g;
600 }
601
602 /* MR21
603 *
604 * There is code in genBlk which recognizes the node created
605 * by emptyAlt() as a special case and bypasses it. We don't
606 * want this to happen for the optBlk.
607 */
608
609 Graph
610 #ifdef __USE_PROTOS
611 emptyAlt3( void )
612 #else
613 emptyAlt3( )
614 #endif
615 {
616 Junction *j1, *j2, *j3;
617 Graph g;
618
619 j1 = newJunction();
620 j2 = newJunction();
621 j3 = newJunction();
622 j1->p1 = (Node *) j2;
623 j2->p1 = (Node *) j3;
624 g.left = (Node *) j1;
625 g.right = (Node *) j3;
626
627 return g;
628 }
629
630 /* N o d e A l l o c a t i o n */
631
632 TokNode *
633 #ifdef __USE_PROTOS
634 newTokNode( void )
635 #else
636 newTokNode( )
637 #endif
638 {
639 static TokNode *FreeList = NULL;
640 TokNode *p, *newblk;
641
642 if ( FreeList == NULL )
643 {
644 newblk = (TokNode *)calloc(TokenBlockAllocSize, sizeof(TokNode));
645 if ( newblk == NULL )
646 fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));
647 for (p=newblk; p<&(newblk[TokenBlockAllocSize]); p++)
648 {
649 p->next = (Node *)FreeList; /* add all new token nodes to FreeList */
650 FreeList = p;
651 }
652 }
653 p = FreeList;
654 FreeList = (TokNode *)FreeList->next;/* remove a TokNode node */
655 p->next = NULL; /* NULL the ptr we used */
656 memset( (char *) p, 0, sizeof(TokNode)); /* MR10 */
657 p->ntype = nToken;
658 p->rname = CurRule;
659 p->file = CurFile;
660 p->line = zzline;
661 p->altstart = NULL;
662
663 return p;
664 }
665
666 RuleRefNode *
667 #ifdef __USE_PROTOS
668 newRNode( void )
669 #else
670 newRNode( )
671 #endif
672 {
673 static RuleRefNode *FreeList = NULL;
674 RuleRefNode *p, *newblk;
675
676 if ( FreeList == NULL )
677 {
678 newblk = (RuleRefNode *)calloc(RRefBlockAllocSize, sizeof(RuleRefNode));
679 if ( newblk == NULL )
680 fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));
681 for (p=newblk; p<&(newblk[RRefBlockAllocSize]); p++)
682 {
683 p->next = (Node *)FreeList; /* add all new rref nodes to FreeList */
684 FreeList = p;
685 }
686 }
687 p = FreeList;
688 FreeList = (RuleRefNode *)FreeList->next;/* remove a Junction node */
689 p->next = NULL; /* NULL the ptr we used */
690 memset( (char *) p, 0, sizeof(RuleRefNode)); /* MR10 */
691 p->ntype = nRuleRef;
692 p->rname = CurRule;
693 p->file = CurFile;
694 p->line = zzline;
695 p->astnode = ASTinclude;
696 p->altstart = NULL;
697
698 return p;
699 }
700
701 static int junctionSeqNumber=0; /* MR10 */
702
703 Junction *
704 #ifdef __USE_PROTOS
705 newJunction( void )
706 #else
707 newJunction( )
708 #endif
709 {
710 static Junction *FreeList = NULL;
711 Junction *p, *newblk;
712
713 if ( FreeList == NULL )
714 {
715 newblk = (Junction *)calloc(JunctionBlockAllocSize, sizeof(Junction));
716 if ( newblk == NULL )
717 fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));
718 for (p=newblk; p<&(newblk[JunctionBlockAllocSize]); p++)
719 {
720 p->p1 = (Node *)FreeList; /* add all new Junction nodes to FreeList */
721 FreeList = p;
722 }
723 }
724 p = FreeList;
725 FreeList = (Junction *)FreeList->p1;/* remove a Junction node */
726 p->p1 = NULL; /* NULL the ptr we used */
727 memset( (char *) p, 0, sizeof(Junction)); /* MR10 */
728 p->ntype = nJunction;
729 p->visited = 0;
730 p->jtype = Generic;
731 p->rname = CurRule;
732 p->file = CurFile;
733 p->line = zzline;
734 p->exception_label = NULL;
735 p->fset = (set *) calloc(CLL_k+1, sizeof(set));
736 require(p->fset!=NULL, "cannot allocate fset in newJunction");
737 p->seq=++junctionSeqNumber; /* MR10 */
738
739 return p;
740 }
741
742 ActionNode *
743 #ifdef __USE_PROTOS
744 newActionNode( void )
745 #else
746 newActionNode( )
747 #endif
748 {
749 static ActionNode *FreeList = NULL;
750 ActionNode *p, *newblk;
751
752 if ( FreeList == NULL )
753 {
754 newblk = (ActionNode *)calloc(ActionBlockAllocSize, sizeof(ActionNode));
755 if ( newblk == NULL )
756 fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));
757 for (p=newblk; p<&(newblk[ActionBlockAllocSize]); p++)
758 {
759 p->next = (Node *)FreeList; /* add all new Action nodes to FreeList */
760 FreeList = p;
761 }
762 }
763 p = FreeList;
764 FreeList = (ActionNode *)FreeList->next;/* remove an Action node */
765 memset( (char *) p, 0, sizeof(ActionNode)); /* MR10 */
766 p->ntype = nAction;
767 p->next = NULL; /* NULL the ptr we used */
768 p->done = 0;
769 p->pred_fail = NULL;
770 p->guardpred = NULL;
771 p->ampersandPred = NULL;
772 return p;
773 }
774
775 /*
776 * allocate the array of locks (1..CLL_k) used to inhibit infinite recursion.
777 * Infinite recursion can occur in (..)* blocks, FIRST calcs and FOLLOW calcs.
778 * Therefore, we need locks on aLoopBlk, RuleBlk, EndRule nodes.
779 *
780 * if ( lock[k]==TRUE ) then we have been here before looking for k tokens
781 * of lookahead.
782 */
783 char *
784 #ifdef __USE_PROTOS
785 makelocks( void )
786 #else
787 makelocks( )
788 #endif
789 {
790 char *p = (char *) calloc(CLL_k+1, sizeof(char));
791 require(p!=NULL, "cannot allocate lock array");
792
793 return p;
794 }
795
796 #if 0
797 ** #ifdef __USE_PROTOS
798 ** void my_memset(char *p,char value,int count)
799 ** #else
800 ** void my_memset(p,value,count)
801 ** char *p;
802 ** char value;
803 ** int count;
804 ** #endif
805 ** {
806 ** int i;
807 **
808 ** for (i=0; i<count; i++) {
809 ** p[i]=value;
810 ** };
811 ** }
812 #endif
+0
-328
contrib/pccts/antlr/egman.c less more
0 /*
1 * egman.c
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33MR10
24 * 2001
25 *
26 */
27
28 #include <stdio.h>
29 #include <stdlib.h>
30
31 #include "set.h"
32 #include "syn.h"
33 #include "hash.h"
34 #include "generic.h"
35 #include "proto.h"
36
37 static ExceptionGroup **egArray=NULL; /* ExceptionGroup by BlkLevel */
38 static LabelEntry **leArray=NULL; /* LabelEntry by BlkLevel */
39 static Junction **altArray=NULL; /* start of alternates */
40 static int arraySize=0;
41 static int highWater=0;
42 static ExceptionGroup *lastEG=NULL; /* used in altFixup() */
43 static int lastBlkLevel=0; /* used in altFixup() */
44
45 #ifdef __USE_PROTOS
46 static void arrayCheck(void);
47 #else
48 static void arrayCheck();
49 #endif
50
51 /* Called to add an exception group for an alternative EG */
52
53 #ifdef __USE_PROTOS
54 void egAdd(ExceptionGroup * eg)
55 #else
56 void egAdd(eg)
57 ExceptionGroup *eg;
58 #endif
59 {
60 int i;
61
62 ExceptionGroup *nextEG;
63 ExceptionGroup *innerEG;
64
65 LabelEntry *nextLE;
66 LabelEntry *innerLE;
67
68 Junction *nextAlt;
69 Junction *innerAlt;
70
71 lastEG=eg;
72 lastBlkLevel=BlkLevel;
73
74 arrayCheck();
75 eg->pendingLink=egArray[BlkLevel];
76 egArray[BlkLevel]=eg;
77
78 /* EG for alternates already have their altID filled in */
79
80 for (i=BlkLevel+1; i<=highWater ; i++) {
81 for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {
82 nextEG=innerEG->pendingLink;
83 innerEG->pendingLink=NULL;
84 innerEG->outerEG=eg;
85 };
86 egArray[i]=NULL;
87 };
88
89 /*
90 * for patching up the LabelEntry you might use an EG for the
91 * current alternative - unlike patching up an alternative EG
92 * i.e. start the loop at BlkLevel rather than (BlkLevel+1)
93 * fill it in only if the EG and the LE are for the very
94 * same alternative if they're at the same BlkLevel
95 * it's easier to leave the LE on this list (filled in) rather than
96 * trying to selectively remove it. It will eventually be
97 * removed anyway when the BlkLevel gets small enough.
98 */
99
100 for (i=BlkLevel; i<=highWater ; i++) {
101 for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {
102 nextLE=innerLE->pendingLink;
103 if (BlkLevel != i ||
104 innerLE->curAltNum == CurAltNum_array[BlkLevel]) {
105 if (innerLE->outerEG == NULL) {
106 innerLE->outerEG=eg;
107 };
108 };
109 };
110 if (BlkLevel != i) leArray[i]=NULL;
111 };
112
113 /*
114 * For the start of alternatives it is necessary to make a
115 * distinction between the exception group for the current
116 * alternative and the "fallback" EG for the block which
117 * contains the alternative
118 *
119 * The fallback outerEG is used to handle the case where
120 * no alternative of a block matches. In that case the
121 * signal is "NoViableAlt" (or "NoSemViableAlt" and the
122 * generator needs the EG of the block CONTAINING the
123 * current one.
124 *
125 * rule: ( ( ( a
126 * | b
127 * )
128 * | c
129 * )
130 * | d
131 * );
132 */
133
134 for (i=BlkLevel; i <= highWater ; i++) {
135 for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {
136 nextAlt=innerAlt->pendingLink;
137
138 /* first fill in the EG for the current alternative */
139 /* but leave it on the list in order to get the fallback EG */
140 /* if the EG is at the same LEVEL as the alternative then */
141 /* fill it in only if in the very same alternative */
142 /* */
143 /* rule: ( a */
144 /* | b */
145 /* | c exception ... */
146 /* ) */
147 /* */
148 /* if the EG is outside the alternative (e.g. BlkLevel < i) */
149 /* then it doesn't matter about the alternative */
150 /* */
151 /* rule: ( a */
152 /* | b */
153 /* | c */
154 /* ) exception ... */
155 /* */
156
157 #if 0
158 printf("BlkLevel=%d i=%d altnum=%d CurAltNum=%d altID=%s\n",
159 BlkLevel,i,innerAlt->curAltNum,CurAltNum_array[BlkLevel],eg->altID);
160 #endif
161 if (BlkLevel != i ||
162 innerAlt->curAltNum == CurAltNum_array[BlkLevel]) {
163 if (innerAlt->exception_label == NULL) {
164 innerAlt->exception_label=eg->altID;
165 };
166 };
167
168 /* ocurs at a later pass then for the exception_label */
169 /* if an outerEG has been found then fill in the outer EG */
170 /* remove if from the list when the BlkLevel gets smaller */
171
172 if (BlkLevel != i) {
173 if (innerAlt->outerEG == NULL) {
174 innerAlt->outerEG=eg;
175 };
176 };
177 };
178 if (BlkLevel != i) altArray[i]=NULL;
179 };
180 }
181
182 #ifdef __USE_PROTOS
183 void leAdd(LabelEntry * le)
184 #else
185 void leAdd(le)
186 LabelEntry *le;
187 #endif
188
189 {
190 arrayCheck();
191 le->pendingLink=leArray[BlkLevel];
192 le->curAltNum=CurAltNum_array[BlkLevel];
193 leArray[BlkLevel]=le;
194 }
195
196 #ifdef __USE_PROTOS
197 void altAdd(Junction *alt)
198 #else
199 void altAdd(alt)
200 Junction *alt;
201 #endif
202
203 {
204 arrayCheck();
205 #if 0
206 printf("BlkLevel=%d CurAltNum=%d\n",
207 BlkLevel,CurAltNum_array[BlkLevel]);
208 #endif
209 alt->curAltNum=CurAltNum_array[BlkLevel];
210 alt->pendingLink=altArray[BlkLevel];
211 altArray[BlkLevel]=alt;
212 }
213
214 static void
215 #ifdef __USE_PROTOS
216 arrayCheck(void)
217 #else
218 arrayCheck()
219 #endif
220 {
221 ExceptionGroup **egArrayNew;
222 LabelEntry **leArrayNew;
223 Junction **altArrayNew;
224 int arraySizeNew;
225 int i;
226
227 if (BlkLevel > highWater) highWater=BlkLevel;
228
229 if (BlkLevel >= arraySize) {
230 arraySizeNew=BlkLevel+5; /* MR20 */
231 egArrayNew=(ExceptionGroup **)
232 calloc(arraySizeNew,sizeof(ExceptionGroup *));
233 leArrayNew=(LabelEntry **)
234 calloc(arraySizeNew,sizeof(LabelEntry *));
235 altArrayNew=(Junction **)
236 calloc(arraySizeNew,sizeof(Junction *));
237 for (i=0; i<arraySize ; i++) {
238 egArrayNew[i]=egArray[i];
239 leArrayNew[i]=leArray[i];
240 altArrayNew[i]=altArray[i];
241 };
242 arraySize=arraySizeNew;
243 if (egArray != NULL) free( (char *) egArray);
244 if (leArray != NULL) free( (char *) leArray);
245 if (altArray != NULL) free( (char *) altArray);
246 egArray=egArrayNew;
247 leArray=leArrayNew;
248 altArray=altArrayNew;
249 };
250 }
251
252 /* always call leFixup() BEFORE egFixup() */
253
254 void
255 #ifdef __USE_PROTOS
256 egFixup(void)
257 #else
258 egFixup()
259 #endif
260 {
261 int i;
262 ExceptionGroup *nextEG;
263 ExceptionGroup *innerEG;
264
265 for (i=1; i<=highWater ; i++) {
266 for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {
267 nextEG=innerEG->pendingLink;
268 innerEG->pendingLink=NULL;
269 };
270 egArray[i]=NULL;
271 };
272 lastEG=NULL;
273 lastBlkLevel=0;
274 }
275
276 /* always call leFixup() BEFORE egFixup() */
277
278 #ifdef __USE_PROTOS
279 void leFixup(void)
280 #else
281 void leFixup()
282 #endif
283 {
284
285 int i;
286 LabelEntry *nextLE;
287 LabelEntry *innerLE;
288
289 for (i=BlkLevel; i<=highWater ; i++) {
290 for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {
291 nextLE=innerLE->pendingLink;
292 innerLE->pendingLink=NULL;
293 };
294 leArray[i]=NULL;
295 };
296 }
297
298 /* always call altFixup() BEFORE egFixup() */
299
300 #ifdef __USE_PROTOS
301 void altFixup(void)
302 #else
303 void altFixup()
304 #endif
305 {
306
307 int i;
308 Junction *nextAlt;
309 Junction *innerAlt;
310
311 for (i=BlkLevel; i<=highWater ; i++) {
312 for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {
313
314 /* if an outerEG has been found then fill in the outer EG */
315
316 if (lastBlkLevel <= i) {
317 if (innerAlt->outerEG == NULL) {
318 innerAlt->outerEG=lastEG;
319 };
320 };
321 nextAlt=innerAlt->pendingLink;
322 innerAlt->pendingLink=NULL;
323 };
324 altArray[i]=NULL;
325 };
326 }
327
+0
-538
contrib/pccts/antlr/err.c less more
0 /*
1 * A n t l r S e t s / E r r o r F i l e H e a d e r
2 *
3 * Generated from: ./antlr.g
4 *
5 * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001
6 * Parr Research Corporation
7 * with Purdue University Electrical Engineering
8 * With AHPCRC, University of Minnesota
9 * ANTLR Version 1.33MR33
10 */
11
12 #define ANTLR_VERSION 13333
13 #include "pcctscfg.h"
14 #include "pccts_stdio.h"
15
16 #include "pcctscfg.h"
17 #include "set.h"
18 #include <ctype.h>
19 #include "syn.h"
20 #include "hash.h"
21 #include "generic.h"
22 #define zzcr_attr(attr,tok,t)
23 #define zzSET_SIZE 20
24 #include "antlr.h"
25 #include "tokens.h"
26 #include "dlgdef.h"
27 #include "err.h"
28
29 ANTLRChar *zztokens[157]={
30 /* 00 */ "Invalid",
31 /* 01 */ "Eof",
32 /* 02 */ "QuotedTerm",
33 /* 03 */ "\\n|\\r|\\r\\n",
34 /* 04 */ "\\(\\n|\\r|\\r\\n)",
35 /* 05 */ "\\~[]",
36 /* 06 */ "~[\\n\\r\"\\]+",
37 /* 07 */ "\"",
38 /* 08 */ "\\n|\\r|\\r\\n",
39 /* 09 */ "\\(\\n|\\r|\\r\\n)",
40 /* 10 */ "\\~[]",
41 /* 11 */ "~[\\n\\r\"\\]+",
42 /* 12 */ "'",
43 /* 13 */ "\\n|\\r|\\r\\n",
44 /* 14 */ "\\~[]",
45 /* 15 */ "~[\\n\\r'\\]+",
46 /* 16 */ "\\*/",
47 /* 17 */ "\\*",
48 /* 18 */ "\\n|\\r|\\r\\n",
49 /* 19 */ "~[\\n\\r\\*]+",
50 /* 20 */ "\\*/",
51 /* 21 */ "\\*",
52 /* 22 */ "\\n|\\r|\\r\\n",
53 /* 23 */ "~[\\n\\r\\*]+",
54 /* 24 */ "\\n|\\r|\\r\\n",
55 /* 25 */ "~[\\n\\r]+",
56 /* 26 */ "\\n|\\r|\\r\\n",
57 /* 27 */ "~[\\n\\r]+",
58 /* 28 */ "\\n|\\r|\\r\\n",
59 /* 29 */ "~[\\n\\r]+",
60 /* 30 */ "\\*/",
61 /* 31 */ "\\*",
62 /* 32 */ "\\n|\\r|\\r\\n",
63 /* 33 */ "~[\\n\\r\\*]+",
64 /* 34 */ "Action",
65 /* 35 */ "Pred",
66 /* 36 */ "PassAction",
67 /* 37 */ "consumeUntil\\( [\\ \\t]* \\{~[\\}]+\\} [\\ \\t]* \\)",
68 /* 38 */ "consumeUntil\\( ~[\\)]+ \\)",
69 /* 39 */ "\\n|\\r|\\r\\n",
70 /* 40 */ "\\>",
71 /* 41 */ "$",
72 /* 42 */ "$$",
73 /* 43 */ "$\\[\\]",
74 /* 44 */ "$\\[",
75 /* 45 */ "$[0-9]+",
76 /* 46 */ "$[0-9]+.",
77 /* 47 */ "$[0-9]+.[0-9]+",
78 /* 48 */ "$[_a-zA-Z][_a-zA-Z0-9]*",
79 /* 49 */ "#0",
80 /* 50 */ "#\\[\\]",
81 /* 51 */ "#\\(\\)",
82 /* 52 */ "#[0-9]+",
83 /* 53 */ "#line[\\ \\t]* [0-9]+ {[\\ \\t]* \"~[\"]+\" ([\\ \\t]* [0-9]*)* } (\\n|\\r|\\r\\n)",
84 /* 54 */ "#line ~[\\n\\r]* (\\n|\\r|\\r\\n)",
85 /* 55 */ "#[_a-zA-Z][_a-zA-Z0-9]*",
86 /* 56 */ "#\\[",
87 /* 57 */ "#\\(",
88 /* 58 */ "#",
89 /* 59 */ "\\)",
90 /* 60 */ "\\[",
91 /* 61 */ "\\(",
92 /* 62 */ "\\\\]",
93 /* 63 */ "\\\\)",
94 /* 64 */ "\\>",
95 /* 65 */ "'",
96 /* 66 */ "\"",
97 /* 67 */ "\\$",
98 /* 68 */ "\\#",
99 /* 69 */ "\\(\\n|\\r|\\r\\n)",
100 /* 70 */ "\\~[\\]\\)>$#]",
101 /* 71 */ "/",
102 /* 72 */ "/\\*",
103 /* 73 */ "\\*/",
104 /* 74 */ "//",
105 /* 75 */ "~[\\n\\r\\)\\(\\$#\\>\\]\\[\"'/]+",
106 /* 76 */ "[\\t\\ ]+",
107 /* 77 */ "\\n|\\r|\\r\\n",
108 /* 78 */ "\\[",
109 /* 79 */ "\\<\\<",
110 /* 80 */ "\"",
111 /* 81 */ "/\\*",
112 /* 82 */ "\\*/",
113 /* 83 */ "//",
114 /* 84 */ "#line[\\ \\t]* [0-9]+ {[\\ \\t]* \"~[\"]+\" ([\\ \\t]* [0-9]*)* } (\\n|\\r|\\r\\n)",
115 /* 85 */ "#line ~[\\n\\r]* (\\n|\\r|\\r\\n)",
116 /* 86 */ "\\>\\>",
117 /* 87 */ "WildCard",
118 /* 88 */ "\\@",
119 /* 89 */ "LABEL",
120 /* 90 */ "grammar-element",
121 /* 91 */ "meta-symbol",
122 /* 92 */ "Pragma",
123 /* 93 */ "FirstSetSymbol",
124 /* 94 */ "{\\}#header",
125 /* 95 */ "{\\}#first",
126 /* 96 */ "{\\}#parser",
127 /* 97 */ "{\\}#tokdefs",
128 /* 98 */ "\\}",
129 /* 99 */ "class",
130 /* 100 */ "NonTerminal",
131 /* 101 */ "TokenTerm",
132 /* 102 */ "\\{",
133 /* 103 */ "!",
134 /* 104 */ "\\<",
135 /* 105 */ "\\>",
136 /* 106 */ ":",
137 /* 107 */ ";",
138 /* 108 */ "{\\}#lexaction",
139 /* 109 */ "{\\}#lexmember",
140 /* 110 */ "{\\}#lexprefix",
141 /* 111 */ "{\\}#pred",
142 /* 112 */ "\\|\\|",
143 /* 113 */ "&&",
144 /* 114 */ "\\(",
145 /* 115 */ "\\)",
146 /* 116 */ "{\\}#lexclass",
147 /* 117 */ "{\\}#errclass",
148 /* 118 */ "{\\}#tokclass",
149 /* 119 */ "..",
150 /* 120 */ "{\\}#token",
151 /* 121 */ "=",
152 /* 122 */ "[0-9]+",
153 /* 123 */ "\\|",
154 /* 124 */ "\\~",
155 /* 125 */ "^",
156 /* 126 */ "approx",
157 /* 127 */ "LL\\(1\\)",
158 /* 128 */ "LL\\(2\\)",
159 /* 129 */ "\\*",
160 /* 130 */ "\\+",
161 /* 131 */ "?",
162 /* 132 */ "=>",
163 /* 133 */ "exception",
164 /* 134 */ "default",
165 /* 135 */ "catch",
166 /* 136 */ "{\\}#[A-Za-z0-9_]*",
167 /* 137 */ "[\\t\\ ]+",
168 /* 138 */ "\\n|\\r|\\r\\n",
169 /* 139 */ "//",
170 /* 140 */ "/\\*",
171 /* 141 */ "#ifdef",
172 /* 142 */ "#if",
173 /* 143 */ "#ifndef",
174 /* 144 */ "#else",
175 /* 145 */ "#endif",
176 /* 146 */ "#undef",
177 /* 147 */ "#import",
178 /* 148 */ "ID",
179 /* 149 */ "#define",
180 /* 150 */ "INT",
181 /* 151 */ "enum",
182 /* 152 */ "\\{",
183 /* 153 */ "=",
184 /* 154 */ ",",
185 /* 155 */ "\\}",
186 /* 156 */ ";"
187 };
188 SetWordType zzerr1[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
189 0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
190 SetWordType zzerr2[20] = {0xfc,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xf3,
191 0xbf,0xff,0xff,0xff, 0xff,0xff,0xff,0x1f};
192 SetWordType zzerr3[20] = {0xfc,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xfb,
193 0x3b,0xf7,0xf7,0xc7, 0xff,0xff,0xff,0x1f};
194 SetWordType zzerr4[20] = {0x4,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
195 0x80,0x7,0x0,0x0, 0x0,0x0,0x0,0x0};
196 SetWordType setwd1[157] = {0x0,0x50,0xa0,0x20,0x20,0x20,0x20,
197 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
198 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
199 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
200 0x20,0x20,0x20,0x6a,0x20,0xa0,0x20,0x20,
201 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
202 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
203 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
204 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
205 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
206 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
207 0x20,0x20,0x20,0x0,0x0,0x20,0x20,0x21,
208 0x21,0x21,0x21,0x6e,0x6e,0x64,0x20,0x0,
209 0x20,0xa0,0xa0,0xa0,0x20,0x6a,0x6a,0x6a,
210 0x6e,0x20,0x20,0x20,0x20,0x66,0x6e,0x6e,
211 0x20,0x66,0x20,0x20,0x20,0x20,0x20,0x20,
212 0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x20,
213 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
214 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
215 0x20,0x20,0x20,0x20,0x20,0x20};
216 SetWordType zzerr5[20] = {0x0,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
217 0x0,0x1,0x0,0x0, 0x0,0x0,0x0,0x0};
218 SetWordType zzerr6[20] = {0x4,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
219 0x0,0x7,0x0,0x0, 0x0,0x0,0x0,0x0};
220 SetWordType zzerr7[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
221 0x0,0x6,0x0,0x0, 0x0,0x0,0x0,0x0};
222 SetWordType zzerr8[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
223 0x0,0x4,0x0,0x0, 0x0,0x0,0x0,0x0};
224 SetWordType zzerr9[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
225 0x1c,0xf0,0x70,0x1, 0x20,0x0,0x0,0x0};
226 SetWordType setwd2[157] = {0x0,0xf8,0x6,0x0,0x0,0x0,0x0,
227 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
228 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
229 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
230 0x0,0x0,0x0,0xf8,0x0,0x1,0x0,0x0,
231 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
232 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
233 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
234 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
235 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
236 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
237 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
238 0x0,0x0,0x0,0xf8,0xf8,0xf8,0x0,0x0,
239 0x0,0x1,0x2,0x6,0x0,0xf8,0xf8,0xf8,
240 0xf8,0x0,0x0,0x0,0x0,0xf8,0xf8,0xf8,
241 0x0,0xf8,0x0,0x0,0x0,0x0,0x0,0x0,
242 0x0,0x0,0x0,0x0,0x0,0x0,0xe8,0x0,
243 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
244 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
245 0x0,0x0,0x0,0x0,0x0,0x0};
246 SetWordType zzerr10[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
247 0xbc,0xf8,0x74,0x1, 0x20,0x0,0x0,0x0};
248 SetWordType zzerr11[20] = {0x0,0x0,0x0,0x0, 0x8,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
249 0xa0,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
250 SetWordType zzerr12[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
251 0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
252 SetWordType zzerr13[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
253 0xa0,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
254 SetWordType setwd3[157] = {0x0,0xfa,0x0,0x0,0x0,0x0,0x0,
255 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
256 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
257 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
258 0x0,0x0,0x0,0xfa,0x0,0x0,0x0,0x0,
259 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
260 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
261 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
262 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
263 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
264 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
265 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
266 0x0,0x0,0x0,0xfa,0xfa,0xfa,0x5,0x0,
267 0x5,0x0,0x0,0x0,0xe2,0xfa,0xfa,0xfa,
268 0xfa,0xc0,0x80,0x5,0xe0,0xfa,0xfa,0xfa,
269 0x0,0xfa,0x0,0x0,0x0,0x0,0x0,0x0,
270 0x0,0x0,0x0,0x0,0x0,0x0,0xfa,0x0,
271 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
272 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
273 0x0,0x0,0x0,0x0,0x0,0x0};
274 SetWordType zzerr14[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
275 0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
276 SetWordType zzerr15[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
277 0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
278 SetWordType zzerr16[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
279 0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
280 SetWordType zzerr17[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
281 0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
282 SetWordType zzerr18[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
283 0x24,0x0,0x80,0x0, 0x0,0x0,0x0,0x0};
284 SetWordType zzerr19[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
285 0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
286 SetWordType zzerr20[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
287 0x1c,0xf8,0x74,0x3, 0x20,0x0,0x0,0x0};
288 SetWordType zzerr21[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
289 0x1c,0xf8,0x70,0x3, 0x20,0x0,0x0,0x0};
290 SetWordType setwd4[157] = {0x0,0xe5,0xda,0x0,0x0,0x0,0x0,
291 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
292 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
293 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
294 0x0,0x0,0x0,0xe5,0x0,0x0,0x0,0x0,
295 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
296 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
297 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
298 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
299 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
300 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
301 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
302 0x0,0x0,0x0,0xed,0xe5,0xe7,0x1a,0x0,
303 0x0,0x0,0x0,0x0,0xc0,0xe5,0xe5,0xe5,
304 0xe5,0x0,0x0,0x0,0x0,0xe5,0xe5,0xe5,
305 0x0,0xe5,0x40,0x0,0x0,0x0,0x0,0x0,
306 0x0,0x0,0x0,0x0,0x0,0x0,0xe5,0x0,
307 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
308 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
309 0x0,0x0,0x0,0x0,0x0,0x0};
310 SetWordType zzerr22[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
311 0x3c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
312 SetWordType zzerr23[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
313 0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
314 SetWordType zzerr24[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
315 0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
316 SetWordType zzerr25[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
317 0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};
318 SetWordType zzerr26[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,
319 0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
320 SetWordType setwd5[157] = {0x0,0x1f,0xc1,0x0,0x0,0x0,0x0,
321 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
322 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
323 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
324 0x0,0x0,0x0,0xdf,0xc0,0xc0,0x0,0x0,
325 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
326 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
327 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
328 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
329 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
330 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
331 0xc0,0x0,0xc0,0x0,0x0,0xc0,0xc0,0x0,
332 0x0,0x0,0x0,0x7f,0x1f,0xdf,0xc0,0xc0,
333 0x0,0x0,0xc0,0x0,0x67,0x1f,0x1f,0x1f,
334 0x1f,0x0,0x0,0xc0,0x60,0x1f,0x1f,0x1f,
335 0x0,0x1f,0x0,0x0,0x40,0xc0,0x0,0x0,
336 0x0,0x0,0xc0,0xc0,0x0,0x0,0x5f,0x0,
337 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
338 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
339 0x0,0x0,0x0,0x0,0x0,0x0};
340 SetWordType zzerr27[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
341 0x0,0x0,0x0,0x10, 0x0,0x0,0x0,0x0};
342 SetWordType zzerr28[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x80,0x2,
343 0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
344 SetWordType zzerr29[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
345 0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
346 SetWordType zzerr30[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,
347 0x0,0x0,0x80,0x0, 0x20,0x0,0x0,0x0};
348 SetWordType zzerr31[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,
349 0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};
350 SetWordType zzerr32[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,
351 0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
352 SetWordType zzerr33[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
353 0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
354 SetWordType setwd6[157] = {0x0,0x0,0xfd,0x0,0x0,0x0,0x0,
355 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
356 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
357 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
358 0x0,0x0,0x0,0xe1,0xe1,0xe1,0x0,0x0,
359 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
360 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
361 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
362 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
363 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
364 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
365 0xfd,0x60,0xe9,0x0,0x0,0xe1,0xe1,0x0,
366 0x0,0x0,0x0,0xe2,0x0,0xfd,0xfd,0xe1,
367 0x20,0x0,0xe1,0x0,0xe2,0x0,0x0,0x0,
368 0x0,0x0,0x0,0xe1,0xe2,0x0,0x0,0x0,
369 0x0,0x0,0x0,0x0,0xe2,0xe0,0x20,0x0,
370 0x0,0x0,0xe1,0xe1,0x0,0x0,0xe2,0x0,
371 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
372 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
373 0x0,0x0,0x0,0x0,0x0,0x0};
374 SetWordType zzerr34[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,
375 0x0,0x0,0x80,0x0, 0x20,0x0,0x0,0x0};
376 SetWordType zzerr35[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,
377 0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};
378 SetWordType zzerr36[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,
379 0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
380 SetWordType zzerr37[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xc,
381 0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};
382 SetWordType zzerr38[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
383 0x84,0x9,0x8,0x18, 0x20,0x0,0x0,0x0};
384 SetWordType zzerr39[20] = {0x0,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
385 0x0,0x1,0x0,0x0, 0x0,0x0,0x0,0x0};
386 SetWordType zzerr40[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
387 0x4,0x9,0x8,0x18, 0x20,0x0,0x0,0x0};
388 SetWordType zzerr41[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
389 0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
390 SetWordType zzerr42[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x80,0x0,
391 0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
392 SetWordType setwd7[157] = {0x0,0x0,0xdf,0x0,0x0,0x0,0x0,
393 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
394 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
395 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
396 0x0,0x0,0x0,0xdf,0xdf,0xff,0x0,0x0,
397 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
398 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
399 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
400 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
401 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
402 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
403 0xdf,0x3,0xdf,0x0,0x0,0xdf,0xdf,0x0,
404 0x0,0x0,0x0,0xdf,0x0,0xdf,0xdf,0xdf,
405 0x1,0x30,0xdf,0x0,0xdf,0x0,0x0,0x0,
406 0x0,0x0,0x0,0xdf,0xdf,0x0,0x0,0x0,
407 0x0,0x0,0x0,0x0,0xdf,0xdf,0x1,0x0,
408 0x0,0x0,0xdf,0xdf,0x0,0x0,0xdf,0x0,
409 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
410 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
411 0x0,0x0,0x0,0x0,0x0,0x0};
412 SetWordType zzerr43[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
413 0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
414 SetWordType zzerr44[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
415 0x0,0x0,0x0,0xc0, 0x1,0x0,0x0,0x0};
416 SetWordType zzerr45[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x30,
417 0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
418 SetWordType zzerr46[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
419 0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
420 SetWordType zzerr47[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x20,
421 0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
422 SetWordType zzerr48[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
423 0x0,0x0,0x2,0x0, 0x10,0x0,0x0,0x0};
424 SetWordType zzerr49[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
425 0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};
426 SetWordType zzerr50[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
427 0x4,0x8,0xa,0x18, 0x30,0x0,0x0,0x0};
428 SetWordType zzerr51[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
429 0x4,0x8,0x8,0x18, 0x28,0x0,0x0,0x0};
430 SetWordType zzerr52[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
431 0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};
432 SetWordType zzerr53[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,
433 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
434 SetWordType setwd8[157] = {0x0,0x0,0xe1,0x0,0x0,0x0,0x0,
435 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
436 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
437 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
438 0x0,0x0,0x0,0xe1,0xe1,0xe1,0x0,0x0,
439 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
440 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
441 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
442 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
443 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
444 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
445 0xe1,0x0,0xe1,0x0,0x0,0xe3,0xe7,0x0,
446 0x0,0x0,0x0,0xe1,0x0,0xe1,0xe1,0xef,
447 0x0,0x0,0xe1,0x0,0xe1,0x0,0x0,0x0,
448 0x0,0x0,0x10,0xef,0xe1,0x0,0x0,0x0,
449 0x0,0x0,0x0,0x0,0xe1,0xe1,0x0,0x0,
450 0x0,0x0,0xe1,0xe1,0x0,0x10,0xe1,0x0,
451 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
452 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
453 0x0,0x0,0x0,0x0,0x0,0x0};
454 SetWordType zzerr54[20] = {0x2,0x0,0x0,0x0, 0x14,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
455 0x1c,0xf8,0x78,0x9, 0xe0,0x0,0x0,0x0};
456 SetWordType zzerr55[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
457 0x1c,0xf8,0x78,0x9, 0x60,0x0,0x0,0x0};
458 SetWordType zzerr56[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
459 0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
460 SetWordType zzerr57[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
461 0x1c,0xf8,0x78,0x9, 0xe0,0x0,0x0,0x0};
462 SetWordType setwd9[157] = {0x0,0x7c,0x1,0x0,0x0,0x0,0x0,
463 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
464 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
465 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
466 0x0,0x0,0x0,0x7f,0x1,0x1,0x0,0x0,
467 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
468 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
469 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
470 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
471 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
472 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
473 0x1,0x0,0x1,0x0,0x0,0x1,0x1,0x0,
474 0x0,0x0,0x0,0x7f,0x7e,0x7f,0x1,0x1,
475 0x0,0x0,0x1,0x0,0x7d,0x7e,0x7e,0x7e,
476 0x7e,0x0,0x0,0x1,0x7d,0x7e,0x7e,0x7e,
477 0x0,0x7e,0x0,0x0,0x7d,0x1,0x0,0x0,
478 0x0,0x0,0x1,0x1,0x0,0x0,0x7f,0x64,
479 0x64,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
480 0x80,0x0,0x0,0x0,0x0,0x0,0x80,0x0,
481 0x80,0x0,0x0,0x0,0x0,0x0};
482 SetWordType zzerr58[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
483 0x0,0x0,0x0,0x0, 0x0,0x0,0xa0,0x0};
484 SetWordType zzerr59[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
485 0x0,0x0,0x0,0x0, 0x0,0x80,0xa0,0x0};
486 SetWordType zzerr60[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
487 0x0,0x0,0x0,0x0, 0x0,0x0,0xa0,0x0};
488 SetWordType zzerr61[20] = {0x2,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
489 0x0,0x0,0x0,0x0, 0x0,0x80,0xa0,0x0};
490 SetWordType zzerr62[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
491 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};
492 SetWordType zzerr63[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
493 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};
494 SetWordType zzerr64[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
495 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};
496 SetWordType zzerr65[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
497 0x0,0x0,0x0,0x0, 0x0,0x0,0x10,0xc};
498 SetWordType setwd10[157] = {0x0,0xc,0x0,0x0,0x0,0x0,0x0,
499 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
500 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
501 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
502 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
503 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
504 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
505 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
506 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
507 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
508 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
509 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
510 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
511 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
512 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
513 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
514 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
515 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
516 0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,
517 0x3,0x0,0x0,0xf0,0xf0,0x0};
518 SetWordType setwd11[157] = {0x0,0x1,0x0,0x0,0x0,0x0,0x0,
519 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
520 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
521 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
522 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
523 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
524 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
525 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
526 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
527 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
528 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
529 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
530 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
531 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
532 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
533 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
534 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
535 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
536 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
537 0x1,0x0,0x0,0x0,0x0,0x0};
+0
-123
contrib/pccts/antlr/fcache.c less more
0 /*
1 * fcache.c
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33MR10
24 *
25 */
26
27 #include <stdio.h>
28 #include <ctype.h>
29
30 #include "pcctscfg.h"
31
32 #include "set.h"
33 #include "syn.h"
34 #include "hash.h"
35 #include "generic.h"
36
37 #ifdef __USE_PROTOS
38 CacheEntry *dumpFcache1(char *prev)
39 #else
40 CacheEntry *dumpFcache1(prev)
41 char *prev;
42 #endif
43 {
44 Entry **table=Fcache;
45
46 int low=0;
47 int hi=0;
48
49 CacheEntry *least=NULL;
50
51 Entry **p;
52
53 for (p=table; p<&(table[HashTableSize]); p++) {
54
55 CacheEntry *q =(CacheEntry *) *p;
56
57 if ( q != NULL && low==0 ) low = p-table;
58 while ( q != NULL ) {
59 if (strcmp(q->str,prev) > 0) {
60 if (least == NULL) {
61 least=q;
62 } else {
63 if (strcmp(q->str,least->str) < 0) {
64 least=q;
65 };
66 };
67 };
68 q = q->next;
69 };
70
71 if ( *p != NULL ) hi = p-table;
72 }
73 return least;
74 }
75
76 #ifdef __USE_PROTOS
77 void reportFcache(CacheEntry *q)
78 #else
79 void reportFcache(q)
80 CacheEntry *q;
81 #endif
82 {
83 char *qstr;
84
85 fprintf(stdout,"\nrule ");
86 for (qstr=q->str; *qstr != '*' ; qstr++) {
87 fprintf(stdout,"%c",*qstr);
88 };
89
90 qstr++;
91 if (*qstr == 'i') fprintf(stdout," First[");
92 if (*qstr == 'o') fprintf(stdout," Follow[");
93 qstr++;
94 fprintf(stdout,"%s]",qstr);
95 if (q->incomplete) fprintf(stdout," *** incomplete ***");
96 fprintf(stdout,"\n");
97 MR_dumpTokenSet(stdout,1,q->fset);
98 }
99
100 void
101 #ifdef __USE_PROTOS
102 DumpFcache(void)
103 #else
104 DumpFcache()
105 #endif
106 {
107
108 char *prev="";
109 int n=0;
110 CacheEntry *next;
111
112 fprintf(stdout,"\n\nDump of First/Follow Cache\n");
113
114 for(;;) {
115 next=dumpFcache1(prev);
116 if (next == NULL) break;
117 reportFcache(next);
118 ++n;
119 prev=next->str;
120 };
121 fprintf(stdout,"\nEnd dump of First/Follow Cache\n");
122 }
+0
-1555
contrib/pccts/antlr/fset.c less more
0 /*
1 * fset.c
2 *
3 * Compute FIRST and FOLLOW sets.
4 *
5 * SOFTWARE RIGHTS
6 *
7 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
8 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
9 * company may do whatever they wish with source code distributed with
10 * PCCTS or the code generated by PCCTS, including the incorporation of
11 * PCCTS, or its output, into commerical software.
12 *
13 * We encourage users to develop software with PCCTS. However, we do ask
14 * that credit is given to us for developing PCCTS. By "credit",
15 * we mean that if you incorporate our source code into one of your
16 * programs (commercial product, research project, or otherwise) that you
17 * acknowledge this fact somewhere in the documentation, research report,
18 * etc... If you like PCCTS and have developed a nice tool with the
19 * output, please mention that you developed it using PCCTS. In
20 * addition, we ask that this header remain intact in our source code.
21 * As long as these guidelines are kept, we expect to continue enhancing
22 * this system and expect to make other tools available as they are
23 * completed.
24 *
25 * ANTLR 1.33
26 * Terence Parr
27 * Parr Research Corporation
28 * with Purdue University and AHPCRC, University of Minnesota
29 * 1989-2001
30 */
31
32 #include <stdio.h>
33 #include <stdlib.h>
34
35 #include "pcctscfg.h"
36
37 #include "set.h"
38 #include "syn.h"
39 #include "hash.h"
40 #include "generic.h"
41 #include "dlgdef.h"
42 #include "limits.h"
43
44 #ifdef __USE_PROTOS
45 static void ensure_predicates_cover_ambiguous_lookahead_sequences
46 (Junction *, Junction *, char *, Tree *);
47 #else
48 static void ensure_predicates_cover_ambiguous_lookahead_sequences();
49 #endif
50
51 /*
52 * What tokens are k tokens away from junction q?
53 *
54 * Follow both p1 and p2 paths (unless RuleBlk) to collect the tokens k away from this
55 * node.
56 * We lock the junction according to k--the lookahead. If we have been at this
57 * junction before looking for the same, k, number of lookahead tokens, we will
58 * do it again and again...until we blow up the stack. Locks are only used on aLoopBlk,
59 * RuleBlk, aPlusBlk and EndRule junctions to remove/detect infinite recursion from
60 * FIRST and FOLLOW calcs.
61 *
62 * If p->jtype == EndRule we are going to attempt a FOLLOW. (FOLLOWs are really defined
63 * in terms of FIRST's, however). To proceed with the FOLLOW, p->halt cannot be
64 * set. p->halt is set to indicate that a reference to the current rule is in progress
65 * and the FOLLOW is not desirable.
66 *
67 * If we attempt a FOLLOW and find that there is no FOLLOW or REACHing beyond the EndRule
68 * junction yields an empty set, replace the empty set with EOF. No FOLLOW means that
69 * only EOF can follow the current rule. This normally occurs only on the start symbol
70 * since all other rules are referenced by another rule somewhere.
71 *
72 * Normally, both p1 and p2 are followed. However, checking p2 on a RuleBlk node is
73 * the same as checking the next rule which is clearly incorrect.
74 *
75 * Cycles in the FOLLOW sense are possible. e.g. Fo(c) requires Fo(b) which requires
76 * Fo(c). Both Fo(b) and Fo(c) are defined to be Fo(b) union Fo(c). Let's say
77 * Fo(c) is attempted first. It finds all of the FOLLOW symbols and then attempts
78 * to do Fo(b) which finds of its FOLLOW symbols. So, we have:
79 *
80 * Fo(c)
81 * / \
82 * a set Fo(b)
83 * / \
84 * a set Fo(c) .....Hmmmm..... Infinite recursion!
85 *
86 * The 2nd Fo(c) is not attempted and Fo(b) is left deficient, but Fo(c) is now
87 * correctly Fo(c) union Fo(b). We wish to pick up where we left off, so the fact
88 * that Fo(b) terminated early means that we lack Fo(c) in the Fo(b) set already
89 * laying around. SOOOOoooo, we track FOLLOW cycles. All FOLLOW computations are
90 * cached in a hash table. After the sequence of FOLLOWs finish, we reconcile all
91 * cycles --> correct all Fo(rule) sets in the cache.
92 *
93 * Confused? Good! Read my MS thesis [Purdue Technical Report TR90-30].
94 * TJP 8/93 -- can now read PhD thesis from Purdue.
95 *
96 * Also, FIRST sets are cached in the hash table. Keys are (rulename,Fi/Fo,k).
97 * Only FIRST sets, for which the FOLLOW is not included, are stored.
98 *
99 * SPECIAL CASE of (...)+ blocks:
100 * I added an optional alt so that the alts could see what
101 * was behind the (...)+ block--thus using enough lookahead
102 * to branch out rather than just enough to distinguish
103 * between alts in the (...)+. However, when the FIRST("(...)+") is
104 * is needed, must not use this last "optional" alt. This routine
105 * turns off this path by setting a new 'ignore' flag for
106 * the alt and then resetting it afterwards.
107 */
108
109 set
110 #ifdef __USE_PROTOS
111 rJunc( Junction *p, int k, set *rk )
112 #else
113 rJunc( p, k, rk )
114 Junction *p;
115 int k;
116 set *rk;
117 #endif
118 {
119 set a, b;
120
121 require(p!=NULL, "rJunc: NULL node");
122 require(p->ntype==nJunction, "rJunc: not junction");
123
124 #ifdef DBG_LL1
125 if ( p->jtype == RuleBlk ) fprintf(stderr, "FIRST(%s,%d) \n",((Junction *)p)->rname,k);
126 else fprintf(stderr, "rJunc: %s in rule %s\n",
127 decodeJType[p->jtype], ((Junction *)p)->rname);
128 #endif
129 /* if this is one of the added optional alts for (...)+ then return */
130
131 /* no need to pop backtrace - hasn't been pushed */
132
133 if ( p->ignore ) return empty;
134
135 if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);
136
137 /* MR14 */ if (AlphaBetaTrace && p->alpha_beta_guess_end) {
138 /* MR14 */ warnFL(
139 /* MR14 */ "not possible to compute follow set for alpha in an \"(alpha)? beta\" block. ",
140 /* MR14 */ FileStr[p->file],p->line);
141 /* MR14 */ MR_alphaBetaTraceReport();
142 /* MR14 */ };
143
144 /* MR14 */ if (p->alpha_beta_guess_end) {
145 /* MR14 */ if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
146 /* MR14 */ return empty;
147 /* MR14 */ }
148
149 /* locks are valid for aLoopBlk,aPlusBlk,RuleBlk,EndRule junctions only */
150 if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||
151 p->jtype==aPlusBlk || p->jtype==EndRule )
152 {
153 require(p->lock!=NULL, "rJunc: lock array is NULL");
154 if ( p->lock[k] )
155 {
156 if ( p->jtype == EndRule ) /* FOLLOW cycle? */
157 {
158 #ifdef DBG_LL1
159 fprintf(stderr, "FOLLOW cycle to %s: panic!\n", p->rname);
160 #endif
161 if (! MR_AmbSourceSearch) RegisterCycle(p->rname, k);
162 }
163 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
164 return empty;
165 }
166 if ( p->jtype == RuleBlk &&
167 p->end->halt &&
168 ! MR_AmbSourceSearch) /* check for FIRST cache */
169 {
170 CacheEntry *q = (CacheEntry *) hash_get(Fcache, Fkey(p->rname,'i',k));
171 if ( q != NULL )
172 {
173 set_orin(rk, q->rk);
174 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
175 return set_dup( q->fset );
176 }
177 }
178 if ( p->jtype == EndRule &&
179 !p->halt && /* MR11 was using cache even when halt set */
180 ! MR_AmbSourceSearch) /* FOLLOW set cached already? */
181 {
182 CacheEntry *q = (CacheEntry *) hash_get(Fcache, Fkey(p->rname,'o',k));
183 if ( q != NULL )
184 {
185 #ifdef DBG_LL1
186 fprintf(stderr, "cache for FOLLOW(%s,%d):", p->rname,k);
187 s_fprT(stderr, q->fset);
188 if ( q->incomplete ) fprintf(stderr, " (incomplete)");
189 fprintf(stderr, "\n");
190 #endif
191 if ( !q->incomplete )
192 {
193 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
194 return set_dup( q->fset );
195 }
196 }
197 }
198 p->lock[k] = TRUE; /* This rule is busy */
199 }
200
201 a = b = empty;
202
203 if ( p->jtype == EndRule )
204 {
205 if (p->halt ) /* don't want FOLLOW here? */ /* unless MR10 hoisting */
206 {
207 p->lock[k] = FALSE;
208 set_orel(k, rk); /* indicate this k value needed */
209 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
210 return empty;
211 }
212 if (! MR_AmbSourceSearch) FoPush(p->rname, k); /* Attempting FOLLOW */
213 if ( p->p1 == NULL ) set_orel((TokenInd!=NULL?TokenInd[EofToken]:EofToken), &a);/* if no FOLLOW assume EOF */
214 #ifdef DBG_LL1
215 fprintf(stderr, "-->FOLLOW(%s,%d)\n", p->rname,k);
216 #endif
217 }
218
219 if ( p->p1 != NULL ) {
220 /* MR14 */ if (p->guess) {
221 /* MR14 */ if (p->guess_analysis_point == NULL) {
222 /* MR14 */ Node * guess_point;
223 /* MR14 */ guess_point=(Node *)analysis_point(p);
224 /* MR14 */ if (guess_point == (Node *)p) {
225 /* MR14 */ guess_point=p->p1;
226 /* MR14 */ }
227 /* MR14 */ p->guess_analysis_point=guess_point;
228 /* MR14 */ }
229 /* MR14 */ REACH(p->guess_analysis_point, k, rk, a);
230 } else {
231 REACH(p->p1, k, rk, a);
232 }
233 }
234
235 /* C a c h e R e s u l t s */
236
237 if ( p->jtype == RuleBlk && p->end->halt && ! MR_AmbSourceSearch) /* can save FIRST set? */
238 {
239 CacheEntry *q = newCacheEntry( Fkey(p->rname,'i',k) );
240 /*fprintf(stderr, "Caching %s FIRST %d\n", p->rname, k);*/
241 hash_add(Fcache, Fkey(p->rname,'i',k), (Entry *)q);
242 q->fset = set_dup( a );
243 q->rk = set_dup( *rk );
244 }
245
246 if ( p->jtype == EndRule &&
247 !p->halt && /* MR11 was using cache even with halt set */
248 ! MR_AmbSourceSearch) /* just completed FOLLOW? */
249 {
250 /* Cache Follow set */
251 CacheEntry *q = (CacheEntry *) hash_get(Fcache, Fkey(p->rname,'o',k));
252 if ( q==NULL )
253 {
254 q = newCacheEntry( Fkey(p->rname,'o',k) );
255 hash_add(Fcache, Fkey(p->rname,'o',k), (Entry *)q);
256 }
257 /*fprintf(stderr, "Caching %s FOLLOW %d\n", p->rname, k);*/
258 if ( set_nil(a) && !q->incomplete )
259 {
260 /* Don't ever save a nil set as complete.
261 * Turn it into an eof set.
262 */
263 set_orel(EofToken, &a);
264 }
265 set_orin(&(q->fset), a);
266 FoPop( k );
267 if ( FoTOS[k] == NULL && Cycles[k] != NULL ) ResolveFoCycles(k);
268 #ifdef DBG_LL1
269 fprintf(stderr, "saving FOLLOW(%s,%d):", p->rname, k);
270 s_fprT(stderr, q->fset);
271 if ( q->incomplete ) fprintf(stderr, " (incomplete)");
272 fprintf(stderr, "\n");
273 #endif
274 }
275
276 if (p->jtype != RuleBlk && p->p2 != NULL && /* MR14 */ ! p->guess) {
277 REACH(p->p2, k, rk, b);
278 }
279
280 if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||
281 p->jtype==aPlusBlk || p->jtype==EndRule )
282 p->lock[k] = FALSE; /* unlock node */
283
284 set_orin(&a, b);
285 set_free(b);
286 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
287 return a;
288 }
289
290 set
291 #ifdef __USE_PROTOS
292 rRuleRef( RuleRefNode *p, int k, set *rk_out )
293 #else
294 rRuleRef( p, k, rk_out )
295 RuleRefNode *p;
296 int k;
297 set *rk_out;
298 #endif
299 {
300 set rk;
301 Junction *r;
302 int k2;
303 set a, rk2, b;
304 int save_halt;
305 RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);
306 require(p!=NULL, "rRuleRef: NULL node");
307 require(p->ntype==nRuleRef, "rRuleRef: not rule ref");
308
309 #ifdef DBG_LL1
310 fprintf(stderr, "rRuleRef: %s\n", p->text);
311 #endif
312
313 if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);
314
315 if ( q == NULL )
316 {
317 warnFL( eMsg1("rule %s not defined",p->text), FileStr[p->file], p->line );
318 REACH(p->next, k, rk_out, a);
319 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
320 return a;
321 }
322 rk2 = empty;
323
324 /* MR9 Problems with rule references in guarded predicates */
325 /* MR9 Perhaps can use hash table to find rule ? */
326
327 /* MR9 */ if (RulePtr == NULL) {
328 /* MR9 */ fatalFL(eMsg2("Rule %s uses rule %s via RulePtr before it has been initialized",
329 /* MR9 */ p->rname,q->str),FileStr[p->file],p->line);
330 /* MR9 */ };
331
332 r = RulePtr[q->rulenum];
333 if ( r->lock[k] )
334 {
335 errNoFL( eMsg2("infinite left-recursion to rule %s from rule %s",
336 r->rname, p->rname) );
337
338 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
339
340 return empty;
341 }
342
343 save_halt = r->end->halt;
344 r->end->halt = TRUE; /* don't let reach fall off end of rule here */
345 rk = empty;
346 REACH(r, k, &rk, a);
347 r->end->halt = save_halt;
348 while ( !set_nil(rk) ) {
349 k2 = set_int(rk); /* MR11 this messes up the ambiguity search routine */
350 set_rm(k2, rk);
351 REACH(p->next, k2, &rk2, b); /* MR11 by changing the value of k */
352 set_orin(&a, b);
353 set_free(b);
354 }
355 set_free(rk); /* this has no members, but free it's memory */
356 set_orin(rk_out, rk2); /* remember what we couldn't do */
357 set_free(rk2);
358 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
359 return a;
360 }
361
362 /*
363 * Return FIRST sub k ( token_node )
364 *
365 * TJP 10/11/93 modified this so that token nodes that are actually
366 * ranges (T1..T2) work.
367 */
368 set
369 #ifdef __USE_PROTOS
370 rToken( TokNode *p, int k, set *rk )
371 #else
372 rToken( p, k, rk )
373 TokNode *p;
374 int k;
375 set *rk;
376 #endif
377 {
378 set a;
379
380 require(p!=NULL, "rToken: NULL node");
381 require(p->ntype==nToken, "rToken: not token node");
382
383 #ifdef DBG_LL1
384 fprintf(stderr, "rToken: %s\n", (TokenString(p->token)!=NULL)?TokenString(p->token):
385 ExprString(p->token));
386 #endif
387
388
389 if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);
390
391 if (MR_AmbSourceSearch && (k-1) == 0) {
392
393 set localConstrain;
394 set intersection;
395
396 localConstrain=fset[maxk-k+1];
397
398 if (! set_nil(p->tset)) {
399 intersection=set_and(localConstrain,p->tset);
400 if (! set_nil(intersection)) {
401 MR_backTraceReport();
402 };
403 set_free(intersection);
404 } else {
405 if (set_el( (unsigned) p->token,localConstrain)) {
406 MR_backTraceReport();
407 }
408 };
409 };
410
411 if ( k-1 == 0 ) {
412
413 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
414
415 if ( !set_nil(p->tset) ) {
416 return set_dup(p->tset);
417 } else {
418 return set_of(p->token);
419 };
420 }
421
422 REACH(p->next, k-1, rk, a);
423
424 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
425
426 return a;
427 }
428
429 set
430 #ifdef __USE_PROTOS
431 rAction( ActionNode *p, int k, set *rk )
432 #else
433 rAction( p, k, rk )
434 ActionNode *p;
435 int k;
436 set *rk;
437 #endif
438 {
439 set a;
440
441 require(p!=NULL, "rJunc: NULL node");
442 require(p->ntype==nAction, "rJunc: not action");
443
444 /* MR11 */ if (p->is_predicate && p->ampersandPred != NULL) {
445 /* MR11 */ Predicate *pred=p->ampersandPred;
446 /* MR11 */ if (k <= pred->k) {
447 /* MR11 */ REACH(p->guardNodes,k,rk,a);
448 /* MR11 */ return a;
449 /* MR11 */ };
450 /* MR11 */ };
451
452 /* it might be a good idea when doing an MR_AmbSourceSearch
453 to *not* look behind predicates under some circumstances
454 we'll look into that later
455 */
456
457 REACH(p->next, k, rk, a); /* ignore actions */
458 return a;
459 }
460
461 /* A m b i g u i t y R e s o l u t i o n */
462
463
464 void
465 #ifdef __USE_PROTOS
466 dumpAmbigMsg( set *fset, FILE *f, int want_nls )
467 #else
468 dumpAmbigMsg( fset, f, want_nls )
469 set *fset;
470 FILE *f;
471 int want_nls;
472 #endif
473 {
474 int i;
475
476 set copy; /* MR11 */
477
478 if ( want_nls ) fprintf(f, "\n\t");
479 else fprintf(f, " ");
480
481 for (i=1; i<=CLL_k; i++)
482 {
483 copy=set_dup(fset[i]); /* MR11 */
484
485 if ( i>1 )
486 {
487 if ( !want_nls ) fprintf(f, ", ");
488 }
489 if ( set_deg(copy) > 3 && elevel == 1 )
490 {
491 int e,m;
492 fprintf(f, "{");
493 for (m=1; m<=3; m++)
494 {
495 e=set_int(copy);
496 fprintf(f, " %s", TerminalString(e));
497 set_rm(e, copy);
498 }
499 fprintf(f, " ... }");
500 }
501 else s_fprT(f, copy);
502 if ( want_nls ) fprintf(f, "\n\t");
503 set_free(copy);
504 }
505 fprintf(f, "\n");
506
507 }
508
509 static void
510 #ifdef __USE_PROTOS
511 verify_context(Predicate *predicate)
512 #else
513 verify_context(predicate)
514 Predicate *predicate;
515 #endif
516 {
517 if ( predicate == NULL ) return;
518
519 if ( predicate->expr == PRED_OR_LIST ||
520 predicate->expr == PRED_AND_LIST )
521 {
522 verify_context(predicate->down);
523 verify_context(predicate->right); /* MR10 */
524 return;
525 }
526
527 if ( !predicate->source->ctxwarned && predicate->source->guardpred==NULL &&
528 ((predicate->k > 1 &&
529 !is_single_tuple(predicate->tcontext)) ||
530 ( predicate->k == 1 &&
531 set_deg(predicate->scontext[1])>1 )) )
532 {
533
534 /* MR9 Suppress annoying messages caused by our own clever(?) fix */
535
536 fprintf(stderr, ErrHdr, FileStr[predicate->source->file],
537 predicate->source->line);
538 fprintf(stderr, " warning: predicate applied for >1 lookahead %d-sequences\n", predicate->k);
539 fprintf(stderr, ErrHdr, FileStr[predicate->source->file],
540 predicate->source->line);
541 fprintf(stderr, " predicate text: \"%s\"\n",
542 (predicate->expr == NULL ? "(null)" : predicate->expr) );
543 fprintf(stderr, ErrHdr, FileStr[predicate->source->file],
544 predicate->source->line);
545 fprintf(stderr, " You may only want one lookahead %d-sequence to apply\n", predicate->k);
546 fprintf(stderr, ErrHdr, FileStr[predicate->source->file],
547 predicate->source->line);
548 fprintf(stderr, " Try using a context guard '(...)? =>'\n");
549 predicate->source->ctxwarned = 1;
550 }
551 verify_context(predicate->right); /* MR10 */
552 }
553
554 /*
555 * If delta is the set of ambiguous lookahead sequences, then make sure that
556 * the predicate(s) for productions alt1,alt2 cover the sequences in delta.
557 *
558 * For example,
559 * a : <<PRED1>>? (A B|A C)
560 * | b
561 * ;
562 * b : <<PRED2>>? A B
563 * | A C
564 * ;
565 *
566 * This should give a warning that (A C) predicts both productions and alt2
567 * does not have a predicate in the production that generates (A C).
568 *
569 * The warning detection is simple. Let delta = LOOK(alt1) intersection LOOK(alt2).
570 * Now, if ( delta set-difference context(predicates-for-alt1) != empty then
571 * alt1 does not "cover" all ambiguous sequences.
572 *
573 * If ambig is nonempty, then ambig in LL(k) sense -> use tree info; else use fset
574 * info. Actually, sets are used only if k=1 for this grammar.
575 */
576 static void
577 #ifdef __USE_PROTOS
578 ensure_predicates_cover_ambiguous_lookahead_sequences
579 ( Junction *alt1, Junction *alt2, char *sub, Tree *ambig )
580 #else
581 ensure_predicates_cover_ambiguous_lookahead_sequences( alt1, alt2, sub, ambig )
582 Junction *alt1;
583 Junction *alt2;
584 char *sub;
585 Tree *ambig;
586 #endif
587 {
588 if ( !ParseWithPredicates ) return;
589
590 if ( ambig!=NULL )
591 {
592 Tree *non_covered = NULL;
593 if ( alt1->predicate!=NULL )
594 non_covered = tdif(ambig, alt1->predicate, alt1->fset, alt2->fset);
595 if ( (non_covered!=NULL || alt1->predicate==NULL) && WarningLevel>1 )
596 {
597 fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);
598 fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",
599 alt1->altnum, sub);
600 if ( alt1->predicate!=NULL && non_covered!=NULL )
601 {
602 fprintf(stderr, " upon");
603 preorder(non_covered);
604 }
605 else if ( alt1->predicate==NULL )
606 {
607 fprintf(stderr, " upon");
608 preorder(ambig->down);
609 }
610 fprintf(stderr, "\n");
611 }
612 Tfree(non_covered);
613 non_covered = NULL;
614 if ( alt2->predicate!=NULL )
615 non_covered = tdif(ambig, alt2->predicate, alt1->fset, alt2->fset);
616 if ( (non_covered!=NULL || alt2->predicate==NULL) && WarningLevel>1 )
617 {
618 fprintf(stderr, ErrHdr, FileStr[alt2->file], alt2->line);
619 fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",
620 alt2->altnum, sub);
621 if ( alt2->predicate!=NULL && non_covered!=NULL )
622 {
623 fprintf(stderr, " upon");
624 preorder(non_covered);
625 }
626 else if ( alt2->predicate==NULL )
627 {
628 fprintf(stderr, " upon");
629 preorder(ambig->down);
630 }
631 fprintf(stderr, "\n");
632 }
633 Tfree(non_covered);
634 }
635 else if ( !set_nil(alt1->fset[1]) )
636 {
637 set delta, non_covered;
638 delta = set_and(alt1->fset[1], alt2->fset[1]);
639 non_covered = set_dif(delta, covered_set(alt1->predicate));
640 if ( set_deg(non_covered)>0 && WarningLevel>1 )
641 {
642 fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);
643 fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",
644 alt1->altnum, sub);
645 if ( alt1->predicate!=NULL )
646 {
647 fprintf(stderr, " upon ");
648 s_fprT(stderr, non_covered);
649 }
650 fprintf(stderr, "\n");
651 }
652 set_free( non_covered );
653 non_covered = set_dif(delta, covered_set(alt2->predicate));
654 if ( set_deg(non_covered)>0 && WarningLevel>1 )
655 {
656 fprintf(stderr, ErrHdr, FileStr[alt2->file], alt2->line);
657 fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",
658 alt2->altnum, sub);
659 if ( alt2->predicate!=NULL )
660 {
661 fprintf(stderr, " upon ");
662 s_fprT(stderr, non_covered);
663 }
664 fprintf(stderr, "\n");
665 }
666 set_free( non_covered );
667 set_free( delta );
668 }
669 else fatal_internal("productions have no lookahead in predicate checking routine");
670 }
671
672 #ifdef __USE_PROTOS
673 void MR_doPredicatesHelp(int inGuessBlock,Junction *alt1,Junction *alt2,int jtype,char *sub)
674 #else
675 void MR_doPredicatesHelp(inGuessBlock,alt1,alt2,jtype,sub)
676 int inGuessBlock;
677 Junction *alt1;
678 Junction *alt2;
679 int jtype;
680 char *sub;
681 #endif
682 {
683 Predicate *p1;
684 Predicate *p2;
685
686 Junction *parentRule=MR_nameToRuleBlk(alt1->rname);
687
688 if (inGuessBlock && WarningLevel <= 1) return;
689
690 /* let antlr give the usual error message */
691
692 if (alt1->predicate == NULL && alt2->predicate == NULL) return;
693
694 if ( (jtype == RuleBlk || jtype == aSubBlk)
695 && (alt1->predicate == NULL && alt2->predicate != NULL)) {
696 fprintf(stderr, ErrHdr, FileStr[parentRule->file],parentRule->line);
697 fprintf(stderr," warning: alt %d line %d and alt %d line %d of %s\n%s%s%s",
698 alt1->altnum,
699 alt1->line,
700 alt2->altnum,
701 alt2->line,
702 sub,
703 " These alts have ambig lookahead sequences resolved by a predicate for\n",
704 " the second choice. The second choice may not be reachable.\n",
705 " You may want to use a complementary predicate or rearrange the alts\n"
706 );
707 return;
708 };
709
710 /* first do the easy comparison. then do the hard one */
711
712 if (MR_comparePredicates(alt1->predicate,alt2->predicate)) {
713
714 if (jtype == aLoopBegin || jtype == aPlusBlk ) {
715
716 /* I'm not sure this code is reachable.
717 Predicates following a (...)+ or (...)* block are probably
718 considered validation predicates and therefore not
719 participate in the predication expression
720 */
721
722 fprintf(stderr, ErrHdr,FileStr[parentRule->file],parentRule->line);
723 fprintf(stderr," warning: %s of %s in rule %s\n (file %s alt %d line %d and alt %d line %d)\n%s",
724 "the predicates used to disambiguate optional/exit paths of ",
725 sub,
726 CurRule,
727 FileStr[alt1->file],
728 alt1->altnum,
729 alt1->line,
730 alt2->altnum,
731 alt2->line,
732 " are identical and have no resolving power\n");
733 } else {
734 fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);
735 fprintf(stderr," warning: %s rule %s\n (file %s alt %d line %d and alt %d line %d)\n%s",
736 "the predicates used to disambiguate",
737 CurRule,
738 FileStr[alt1->file],
739 alt1->altnum,
740 alt1->line,
741 alt2->altnum,
742 alt2->line,
743 " are identical and have no resolving power\n");
744 };
745 } else {
746 p1=predicate_dup_without_context(alt1->predicate);
747 p1=MR_unfold(p1);
748 MR_clearPredEntry(p1);
749 MR_simplifyInverted(p1,0);
750 p1=MR_predSimplifyALL(p1);
751 p2=predicate_dup_without_context(alt2->predicate);
752 p2=MR_unfold(p2);
753 MR_clearPredEntry(p2);
754 MR_simplifyInverted(p2,0);
755 p2=MR_predSimplifyALL(p2);
756 if (MR_comparePredicates(p1,p2)) {
757 if (jtype == aLoopBegin || jtype == aPlusBlk ) {
758 fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);
759 fprintf(stderr," warning: %s of %s in rule %s\n (file %s alt %d line %d and alt %d line %d)\n%s%s",
760 "the predicates used to disambiguate optional/exit paths of ",
761 sub,
762 CurRule,
763 FileStr[alt1->file],
764 alt1->altnum,
765 alt1->line,
766 alt2->altnum,
767 alt2->line,
768 " are identical when compared without context and may have no\n",
769 " resolving power for some lookahead sequences.\n");
770 } else {
771 fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);
772 fprintf(stderr," warning: %s rule %s\n (file %s alt %d line %d and alt %d line %d)\n%s%s",
773 "the predicates used to disambiguate",
774 CurRule,
775 FileStr[alt1->file],
776 alt1->altnum,
777 alt1->line,
778 alt2->altnum,
779 alt2->line,
780 " are identical when compared without context and may have no\n",
781 " resolving power for some lookahead sequences.\n");
782 };
783 if (InfoP) {
784 fprintf(output,"\n#if 0\n\n");
785 fprintf(output,"The following predicates are identical when compared without\n");
786 fprintf(output," lookahead context information. For some ambiguous lookahead\n");
787 fprintf(output," sequences they may not have any power to resolve the ambiguity.\n");
788 fprintf(output,"\n");
789
790 fprintf(output,"Choice 1: %s alt %d line %d file %s\n\n",
791 MR_ruleNamePlusOffset( (Node *) alt1),
792 alt1->altnum,
793 alt1->line,
794 FileStr[alt1->file]);
795 fprintf(output," The original predicate for choice 1 with available context information:\n\n");
796 MR_dumpPred1(2,alt1->predicate,1);
797 fprintf(output," The predicate for choice 1 after expansion (but without context information):\n\n");
798 MR_dumpPred1(2,p1,0);
799 if (p1 == NULL) {
800 Predicate *phelp;
801 fprintf(output," The predicate for choice 1 after expansion (but before simplification)\n\n");
802 phelp=predicate_dup_without_context(alt1->predicate);
803 phelp=MR_unfold(phelp);
804 MR_clearPredEntry(phelp);
805 MR_simplifyInverted(phelp,0);
806 phelp=MR_predSimplifyALLX(phelp,1);
807 MR_dumpPred1(2,phelp,0);
808 predicate_free(phelp);
809 };
810 fprintf(output,"\n");
811
812 fprintf(output,"Choice 2: %s alt %d line %d file %s\n\n",
813 MR_ruleNamePlusOffset( (Node *) alt2),
814 alt2->altnum,
815 alt2->line,
816 FileStr[alt2->file]);
817 fprintf(output," The original predicate for choice 2 with available context information:\n\n");
818 MR_dumpPred1(1,alt2->predicate,1);
819 fprintf(output," The predicate for choice 2 after expansion (but without context information):\n\n");
820 MR_dumpPred1(1,p2,0);
821 if (p2 == NULL) {
822 Predicate *phelp;
823 fprintf(output," The predicate for choice 2 after expansion (but before simplification)\n\n");
824 phelp=predicate_dup_without_context(alt2->predicate);
825 phelp=MR_unfold(phelp);
826 MR_clearPredEntry(phelp);
827 MR_simplifyInverted(phelp,0);
828 phelp=MR_predSimplifyALLX(phelp,1);
829 MR_dumpPred1(2,phelp,0);
830 predicate_free(phelp);
831 };
832 fprintf(output,"\n#endif\n");
833 };
834 } else if (MR_secondPredicateUnreachable(p1,p2)) {
835 if (jtype == aLoopBegin || jtype == aPlusBlk ) {
836 fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);
837 fprintf(stderr," warning: %s of %s in rule %s\n (file %s alt %d line %d and alt %d line %d)\n%s%s",
838 "the predicate used to disambiguate the first choice of the optional/exit paths of ",
839 sub,
840 CurRule,
841 FileStr[alt1->file],
842 alt1->altnum,
843 alt1->line,
844 alt2->altnum,
845 alt2->line,
846 " appears to \"cover\" the second predicate when compared without context.\n",
847 " The second predicate may have no resolving power for some lookahead sequences.\n");
848 } else {
849 fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);
850 fprintf(stderr," warning: %s rule %s\n (file %s alt %d line %d and alt %d line %d)\n%s%s",
851 "the predicate used to disambiguate the first choice of",
852 CurRule,
853 FileStr[alt1->file],
854 alt1->altnum,
855 alt1->line,
856 alt2->altnum,
857 alt2->line,
858 " appears to \"cover\" the second predicate when compared without context.\n",
859 " The second predicate may have no resolving power for some lookahead sequences.\n");
860 };
861 if (InfoP) {
862 fprintf(output,"\n#if 0\n\n");
863 fprintf(output,"The first predicate appears to \"cover\" the second predicate when they\n");
864 fprintf(output," are compared without lookahead context information. For some ambiguous\n");
865 fprintf(output," lookahead sequences the second predicate may not have any power to\n");
866 fprintf(output," resolve the ambiguity.\n");
867 fprintf(output,"\n");
868 fprintf(output,"Choice 1: %s alt %d line %d file %s\n\n",
869 MR_ruleNamePlusOffset( (Node *) alt1),
870 alt1->altnum,
871 alt1->line,
872 FileStr[alt1->file]);
873 fprintf(output," The original predicate for choice 1 with available context information:\n\n");
874 MR_dumpPred1(2,alt1->predicate,1);
875 fprintf(output," The predicate for choice 1 after expansion (but without context information):\n\n");
876 MR_dumpPred1(2,p1,0);
877 if (p1 == NULL) {
878 Predicate *phelp;
879 fprintf(output," The predicate for choice 1 after expansion (but before simplification)\n\n");
880 phelp=predicate_dup_without_context(alt1->predicate);
881 phelp=MR_unfold(phelp);
882 MR_clearPredEntry(phelp);
883 MR_simplifyInverted(phelp,0);
884 phelp=MR_predSimplifyALLX(phelp,1);
885 MR_dumpPred1(2,phelp,0);
886 predicate_free(phelp);
887 };
888 fprintf(output,"\n");
889
890 fprintf(output,"Choice 2: %s alt %d line %d file %s\n\n",
891 MR_ruleNamePlusOffset( (Node *) alt2),
892 alt2->altnum,
893 alt2->line,
894 FileStr[alt2->file]);
895 fprintf(output," The original predicate for choice 2 with available context information:\n\n");
896 MR_dumpPred1(1,alt2->predicate,1);
897 fprintf(output," The predicate for choice 2 after expansion (but without context information):\n\n");
898 MR_dumpPred1(1,p2,0);
899 if (p2 == NULL) {
900 Predicate *phelp;
901 fprintf(output," The predicate for choice 2 after expansion (but before simplification)\n\n");
902 phelp=predicate_dup_without_context(alt2->predicate);
903 phelp=MR_unfold(phelp);
904 MR_clearPredEntry(phelp);
905 MR_simplifyInverted(phelp,0);
906 phelp=MR_predSimplifyALLX(phelp,1);
907 MR_dumpPred1(2,phelp,0);
908 predicate_free(phelp);
909 };
910 fprintf(output,"\n#endif\n");
911 };
912 };
913 predicate_free(p1);
914 predicate_free(p2);
915 };
916 }
917
918 static int totalOverflow=0; /* MR9 */
919
920 void
921 #ifdef __USE_PROTOS
922 HandleAmbiguity( Junction *block, Junction *alt1, Junction *alt2, int jtype )
923 #else
924 HandleAmbiguity( block, alt1, alt2, jtype )
925 Junction *block;
926 Junction *alt1;
927 Junction *alt2;
928 int jtype;
929 #endif
930 {
931 unsigned **ftbl;
932 set *fset, b;
933 int i, numAmbig,n2;
934 Tree *ambig=NULL, *t, *u;
935 char *sub = "";
936 long n;
937 int thisOverflow=0; /* MR9 */
938 long set_deg_value; /* MR10 */
939 long threshhold; /* MR10 */
940
941 require(block!=NULL, "NULL block");
942 require(block->ntype==nJunction, "invalid block");
943
944 /* These sets are used to constrain LL_k set, but are made CLL_k long anyway */
945 fset = (set *) calloc(CLL_k+1, sizeof(set));
946 require(fset!=NULL, "cannot allocate fset");
947 ftbl = (unsigned **) calloc(CLL_k+1, sizeof(unsigned *));
948 require(ftbl!=NULL, "cannot allocate ftbl");
949
950 /* create constraint table and count number of possible ambiguities (use<=LL_k) */
951 for (n=1,i=1; i<=CLL_k; i++)
952 {
953 b = set_and(alt1->fset[i], alt2->fset[i]);
954 /* MR9 */ set_deg_value = set_deg(b);
955 /* MR10 */ if (n > 0) {
956 /* MR10 */ threshhold = LONG_MAX / n;
957 /* MR10 */ if (set_deg_value <= threshhold) {
958 /* MR10 */ n *= set_deg_value;
959 /* MR10 */ } else {
960 /* MR10 */ n=LONG_MAX;
961 /* MR9 */ if (totalOverflow == 0) {
962 #if 0
963 /* MR10 comment this out because it just makes users worry */
964
965 /* MR9 */ warnNoFL("Overflow in computing number of possible ambiguities in HandleAmbiguity\n");
966 #endif
967 /* MR9 */ };
968 /* MR9 */ thisOverflow++;
969 /* MR9 */ totalOverflow++;
970 /* MR9 */ };
971 /* MR10 */ } else {
972 /* MR10 */ n *= set_deg_value;
973 /* MR9 */ };
974 fset[i] = set_dup(b);
975 ftbl[i] = set_pdq(b);
976 set_free(b);
977 }
978
979 switch ( jtype )
980 {
981 case aSubBlk: sub = "of (..) "; break;
982 case aOptBlk: sub = "of {..} "; break;
983 case aLoopBegin: sub = "of (..)* "; break;
984 case aLoopBlk: sub = "of (..)* "; break;
985 case aPlusBlk: sub = "of (..)+ "; break;
986 case RuleBlk: sub = "of the rule itself "; break;
987 default : sub = ""; break;
988 }
989
990 /* If the block is marked as a compressed lookahead only block, then
991 * simply return; ambiguity warning is given only at warning level 2.
992 */
993 if ( block->approx>0 )
994 {
995 if ( ParseWithPredicates )
996 {
997 if (alt1->predicate != NULL) predicate_free(alt1->predicate); /* MR12 */
998 if (alt2->predicate != NULL) predicate_free(alt2->predicate); /* MR12 */
999
1000 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1001 alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);
1002 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1003 require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");
1004 alt1->predicate=MR_predSimplifyALL(alt1->predicate);
1005
1006 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1007 alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);
1008 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1009 require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");
1010 alt2->predicate=MR_predSimplifyALL(alt2->predicate);
1011
1012 MR_doPredicatesHelp(0,alt1,alt2,jtype,sub);
1013
1014 if ( HoistPredicateContext
1015 && (alt1->predicate!=NULL||alt2->predicate!=NULL) )
1016 {
1017 verify_context(alt1->predicate);
1018 verify_context(alt2->predicate);
1019 }
1020
1021 if ( HoistPredicateContext
1022 && (alt1->predicate!=NULL||alt2->predicate!=NULL)
1023 && WarningLevel>1 )
1024 ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);
1025 }
1026
1027 if ( WarningLevel>1 )
1028 {
1029 fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);
1030 if ( jtype == aLoopBegin || jtype == aPlusBlk )
1031 fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);
1032 else
1033 fprintf(stderr, " warning(approx): alts %d and %d %sambiguous upon",
1034 alt1->altnum, alt2->altnum, sub);
1035 dumpAmbigMsg(fset, stderr, 0);
1036 MR_traceAmbSource(fset,alt1,alt2);
1037 }
1038 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1039 free((char *)fset);
1040 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1041 free((char *)ftbl);
1042 return;
1043 }
1044
1045 /* if all sets have degree 1 for k<LL_k, then must be ambig upon >=1 permutation;
1046 * don't bother doing full LL(k) analysis.
1047 * (This "if" block handles the LL(1) case)
1048 */
1049
1050 n2 = 0;
1051 for (i=1; i<LL_k; i++) n2 += set_deg(alt1->fset[i])+set_deg(alt2->fset[i]);
1052
1053 /* here STARTS the special case in which the lookahead sets for alt1 and alt2
1054 all have degree 1 for k<LL_k (including LL_k=1)
1055 */
1056
1057 if ( n2==2*(LL_k-1) )
1058 {
1059
1060 /* TJP: added to fix the case where LL(1) and syntactic predicates didn't
1061 * work. It now recognizes syntactic predicates, but does not like combo:
1062 * LL(1)/syn/sem predicates. (10/24/93)
1063 */
1064
1065 if ( first_item_is_guess_block_extra((Junction *)alt1->p1)!=NULL )
1066 {
1067 if ( WarningLevel==1 )
1068 {
1069 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1070 free((char *)fset);
1071 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1072 free((char *)ftbl);
1073 return;
1074 }
1075
1076 fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);
1077 if ( jtype == aLoopBegin || jtype == aPlusBlk )
1078 fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);
1079 else
1080 fprintf(stderr, " warning: alts %d and %d %sambiguous upon",
1081 alt1->altnum, alt2->altnum, sub);
1082 dumpAmbigMsg(fset, stderr, 0);
1083 MR_traceAmbSource(fset,alt1,alt2);
1084 }
1085
1086 ambig = NULL;
1087 if ( LL_k>1 ) ambig = make_tree_from_sets(alt1->fset, alt2->fset);
1088 if ( ParseWithPredicates )
1089 {
1090 if (alt1->predicate != NULL) predicate_free(alt1->predicate); /* MR12 */
1091 if (alt2->predicate != NULL) predicate_free(alt2->predicate); /* MR12 */
1092
1093 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1094 alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);
1095 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1096 require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");
1097 alt1->predicate=MR_predSimplifyALL(alt1->predicate);
1098
1099 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1100 alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);
1101 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1102 require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");
1103 alt2->predicate=MR_predSimplifyALL(alt2->predicate);
1104
1105 MR_doPredicatesHelp(0,alt1,alt2,jtype,sub);
1106
1107 if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) )
1108 {
1109 verify_context(alt1->predicate);
1110 verify_context(alt2->predicate);
1111 }
1112 if (HoistPredicateContext&&(alt1->predicate!=NULL||alt2->predicate!=NULL) && WarningLevel>1)
1113 ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);
1114 if ( WarningLevel == 1 &&
1115 (alt1->predicate!=NULL||alt2->predicate!=NULL))
1116 {
1117 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1118 free((char *)fset);
1119 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1120 free((char *)ftbl);
1121 Tfree(ambig);
1122 return;
1123 }
1124 }
1125 /* end TJP (10/24/93) */
1126
1127 fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);
1128 if ( jtype == aLoopBegin || jtype == aPlusBlk )
1129 fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);
1130 else
1131 fprintf(stderr, " warning: alts %d and %d %sambiguous upon",
1132 alt1->altnum, alt2->altnum, sub);
1133 if ( elevel == 3 && LL_k>1 )
1134 {
1135 preorder(ambig);
1136 fprintf(stderr, "\n");
1137 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1138 free((char *)fset);
1139 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1140 free((char *)ftbl);
1141 Tfree(ambig);
1142 return;
1143 };
1144
1145 Tfree(ambig);
1146 dumpAmbigMsg(fset, stderr, 0);
1147
1148 /* because this is a special case in which both alt1 and alt2 have
1149 lookahead sets of degree 1 for k<LL_k (including k=1) the linear
1150 lookahead style search is adequate
1151 */
1152
1153 MR_traceAmbSource(fset,alt1,alt2);
1154
1155 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1156 free((char *)fset);
1157 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1158 free((char *)ftbl);
1159 return;
1160 }
1161
1162 /* here ENDS the special case in which the lookahead sets for alt1 and alt2
1163 all have degree 1 for k<LL_k (including LL_k=1)
1164 */
1165
1166 /* in case tree construction runs out of memory, set info to make good err msg */
1167
1168 CurAmbigAlt1 = alt1->altnum;
1169 CurAmbigAlt2 = alt2->altnum;
1170 CurAmbigbtype = sub;
1171 CurAmbigfile = alt1->file;
1172 CurAmbigline = alt1->line;
1173
1174 /* Don't do full LL(n) analysis if (...)? block because the block,
1175 by definition, defies LL(n) analysis.
1176 If guess (...)? block and ambiguous then don't remove anything from
1177 2nd alt to resolve ambig.
1178 Want to predict with LL sup 1 ( n ) decision not LL(n) if guess block
1179 since it is much cheaper than LL(n). LL sup 1 ( n ) "covers" the LL(n)
1180 lookahead information.
1181
1182 Note: LL(n) context cannot be computed for semantic predicates when
1183 followed by (..)?.
1184
1185 If (..)? then we scream "AAAHHHH! No LL(n) analysis will help"
1186
1187 Is 'ambig' always defined if we enter this if? I hope so
1188 because the 'ensure...()' func references it. TJP Nov 1993.
1189 */
1190
1191 /* THM MR30: Instead of using first_item_is_guss_block we use
1192 first_item_is_guess_block_extra which will look inside a
1193 loop block for a guess block. In other words ( (...)? )*.
1194 It there is an ambiguity in this circumstance then we suppress
1195 the normal methods of resolving ambiguities.
1196 */
1197
1198 if ( first_item_is_guess_block_extra((Junction *)alt1->p1)!=NULL )
1199 {
1200 if ( ParseWithPredicates )
1201 {
1202 if (alt1->predicate != NULL) predicate_free(alt1->predicate); /* MR12 */
1203 if (alt2->predicate != NULL) predicate_free(alt2->predicate); /* MR12 */
1204 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1205 alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);
1206 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1207 require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");
1208 alt1->predicate=MR_predSimplifyALL(alt1->predicate);
1209
1210 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1211 alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);
1212 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1213 require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");
1214 alt2->predicate=MR_predSimplifyALL(alt2->predicate);
1215
1216 MR_doPredicatesHelp(1,alt1,alt2,jtype,sub);
1217
1218 if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) )
1219 {
1220 verify_context(alt1->predicate);
1221 verify_context(alt2->predicate);
1222 }
1223 if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) && WarningLevel>1 )
1224 ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);
1225 if ( WarningLevel==1 &&
1226 (alt1->predicate!=NULL||alt2->predicate!=NULL))
1227 {
1228 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1229 free((char *)fset);
1230 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1231 free((char *)ftbl);
1232 return;
1233 }
1234 }
1235
1236 if ( WarningLevel>1 )
1237 {
1238 fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);
1239 if ( jtype == aLoopBegin || jtype == aPlusBlk )
1240 fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);
1241 else
1242 fprintf(stderr, " warning: alts %d and %d %sambiguous upon",
1243 alt1->altnum, alt2->altnum, sub);
1244 dumpAmbigMsg(fset, stderr, 0);
1245 MR_traceAmbSource(fset,alt1,alt2);
1246 }
1247
1248 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1249 free((char *)fset);
1250 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1251 free((char *)ftbl);
1252 return;
1253 }
1254
1255 /* Not resolved with (..)? block. Do full LL(n) analysis */
1256
1257 /* ambig is the set of k-tuples truly in common between alt 1 and alt 2 */
1258 /* MR11 VerifyAmbig once used fset destructively */
1259
1260 ambig = VerifyAmbig(alt1, alt2, ftbl, fset, &t, &u, &numAmbig);
1261
1262 /* are all things in intersection really ambigs? */
1263
1264 if (thisOverflow || numAmbig < n ) /* MR9 */
1265 {
1266 Tree *v;
1267
1268 /* remove ambig permutation from 2nd alternative to resolve ambig;
1269 * We want to compute the set of artificial tuples, arising from
1270 * LL sup 1 (n) compression, that collide with real tuples from the
1271 * 2nd alternative. This is the set of "special case" tuples that
1272 * the LL sup 1 (n) decision template maps incorrectly.
1273 */
1274
1275 /* when generating code in genExpr() it does
1276 *
1277 * if ( genExprSets(j->fset) && !genExprTree(j->ftree)) {...
1278 *
1279 * Sooooo the j->ftree is the tree of alt2
1280 * after removal of conflicts, not alt1 !
1281 */
1282
1283 if ( ambig!=NULL )
1284 {
1285 /* at the top of ambig is an ALT node */
1286
1287 for (v=ambig->down; v!=NULL; v=v->right)
1288 {
1289 u = trm_perm(u, v); /* remove v FROM u */
1290 }
1291 /* fprintf(stderr, "after rm alt2:"); preorder(u); fprintf(stderr, "\n");*/
1292 }
1293 Tfree( t );
1294 alt1->ftree = tappend(alt1->ftree, u);
1295 alt1->ftree = tleft_factor(alt1->ftree);
1296 }
1297
1298 if ( ambig==NULL )
1299 {
1300 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1301 free((char *)fset);
1302 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1303 free((char *)ftbl);
1304 return;
1305 }
1306
1307 ambig = tleft_factor(ambig);
1308
1309 /* TJP:
1310 * At this point, we surely have an LL(k) ambiguity. Check for predicates
1311 */
1312 if ( ParseWithPredicates )
1313 {
1314 if (alt1->predicate != NULL) predicate_free(alt1->predicate); /* MR12 */
1315 if (alt2->predicate != NULL) predicate_free(alt2->predicate); /* MR12 */
1316 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1317 alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);
1318 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1319 require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");
1320 alt1->predicate=MR_predSimplifyALL(alt1->predicate);
1321
1322 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1323 alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);
1324 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
1325 require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");
1326 alt2->predicate=MR_predSimplifyALL(alt2->predicate);
1327
1328 MR_doPredicatesHelp(0,alt1,alt2,jtype,sub);
1329
1330 if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) )
1331 {
1332 verify_context(alt1->predicate);
1333 verify_context(alt2->predicate);
1334 }
1335 if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) && WarningLevel>1 )
1336 ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);
1337 if ( WarningLevel==1 &&
1338 (alt1->predicate!=NULL||alt2->predicate!=NULL))
1339 {
1340
1341 /* We found at least one pred for at least one of the alts;
1342 * If warnings are low, just return.
1343 */
1344
1345 Tfree(ambig);
1346 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1347 free((char *)fset);
1348 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1349 free((char *)ftbl);
1350 return;
1351 }
1352 /* else we're gonna give a warning */
1353 }
1354 /* end TJP addition */
1355
1356 fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);
1357 if ( jtype == aLoopBegin || jtype == aPlusBlk )
1358 fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);
1359 else
1360 fprintf(stderr, " warning: alts %d and %d %sambiguous upon",
1361 alt1->altnum, alt2->altnum, sub);
1362 if ( elevel == 3 )
1363 {
1364 preorder(ambig->down); /* <===== k>1 ambiguity message data */
1365 fprintf(stderr, "\n");
1366 } else {
1367 MR_skipped_e3_report=1;
1368 dumpAmbigMsg(fset, stderr, 0);
1369 };
1370
1371 MR_traceAmbSourceK(ambig,alt1,alt2); /* <====== k>1 ambiguity aid */
1372
1373 Tfree(ambig);
1374
1375 for (i=1; i<=CLL_k; i++) set_free( fset[i] );
1376 free((char *)fset);
1377 for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );
1378 free((char *)ftbl);
1379 }
1380
1381 /* Don't analyze alpha block of (alpha)?beta; if (alpha)? then analyze
1382 * Return the 1st node of the beta block if present else return j.
1383 */
1384 Junction *
1385 #ifdef __USE_PROTOS
1386 analysis_point( Junction *j )
1387 #else
1388 analysis_point( j )
1389 Junction *j;
1390 #endif
1391 {
1392 Junction *gblock;
1393
1394 /* MR13b When there was an action/predicate preceding a guess block
1395 the guess block became invisible at the analysis_point.
1396
1397 first_item_is_guess_block accepts any kind of node,
1398 despite the fact that the formal is a junction. But
1399 I don't want to have to change it all over the place
1400 until I know it works.
1401 */
1402
1403 if ( j->ntype != nJunction && j->ntype != nAction) return j;
1404
1405 gblock = first_item_is_guess_block((Junction *)j);
1406
1407 if ( gblock!=NULL )
1408 {
1409 Junction *past = gblock->end;
1410 Junction *p;
1411 require(past!=NULL, "analysis_point: no end block on (...)? block");
1412
1413 for (p=(Junction *)past->p1; p!=NULL; )
1414 {
1415 if ( p->ntype==nAction )
1416 {
1417 p=(Junction *)((ActionNode *)p)->next;
1418 continue;
1419 }
1420 if ( p->ntype!=nJunction )
1421 {
1422 past->alpha_beta_guess_end=1; /* MR14 */
1423 return (Junction *)past->p1;
1424 }
1425 if ( p->jtype==EndBlk || p->jtype==EndRule )
1426 {
1427 return j;
1428 }
1429 /* MR6 */
1430 /* MR6 A guess block is of the form "(alpha)? beta" or "(alpha)?". */
1431 /* MR6 When beta is omitted (second form) this means "(alpha)? alpha". */
1432 /* MR6 The program does not store another copy of alpha in this case. */
1433 /* MR6 During analysis when the program needs to know what follows the */
1434 /* MR6 guess clause. It calls this routine. */
1435 /* MR6 */
1436 /* MR6 If it is of the form "(alpha)? beta" it returns a pointer to beta.*/
1437 /* MR6 */
1438 /* MR6 If it is of the form "(alpha)?" it returns a pointer to the guess */
1439 /* MR6 block itself thereby reusing the junction tree. */
1440 /* MR6 */
1441 /* MR6 It works by searching the "next in sequence" chain (skipping actions) */
1442 /* MR6 searching for a RuleRef or Token node. (Those are the only 4 kinds */
1443 /* MR6 of nodes: Junctions, RuleRef, Token, and Action.) */
1444 /* MR6 */
1445 /* MR6 This won't work for the special case "(alpha)? ()" because it has no */
1446 /* MR6 rule references or token nodes. It eventually encounters a */
1447 /* MR6 junction of type EndBlk or EndRule and says to its caller: nothing */
1448 /* MR6 more here to analyze - must be of the form "(alpha)?". */
1449 /* MR6 */
1450 /* MR6 In the case of "(alpha)? ()" it should return a pointer to "()" */
1451 /* MR6 */
1452 /* MR6 I think. */
1453 /* MR6 */
1454 if ( p->jtype!=Generic) { /* MR6 */
1455 past->alpha_beta_guess_end=1; /* MR14 */
1456 return (Junction *)past->p1; /* MR6 */
1457 }; /* MR6 */
1458 p=(Junction *)p->p1;
1459 }
1460 }
1461 return j;
1462 }
1463
1464 set
1465 #ifdef __USE_PROTOS
1466 First( Junction *j, int k, int jtype, int *max_k )
1467 #else
1468 First( j, k, jtype, max_k )
1469 Junction *j;
1470 int k;
1471 int jtype;
1472 int *max_k;
1473 #endif
1474 {
1475 Junction *alt1, *alt2;
1476 set a, rk, fCurBlk;
1477 int savek;
1478 int p1, p2;
1479
1480 int save_maintainBackTrace;
1481
1482 require(j->ntype==nJunction, "First: non junction passed");
1483
1484 /* C o m p u t e F I R S T s e t w i t h k l o o k a h e a d */
1485 fCurBlk = rk = empty;
1486 for (alt1=j; alt1!=NULL; alt1 = (Junction *)alt1->p2 )
1487 {
1488 Junction * p = NULL;
1489 Junction * p1junction = NULL;
1490 p = analysis_point((Junction *)alt1->p1);
1491 p1junction = (Junction *) (alt1->p1);
1492 #if 0
1493 if (p != p1junction) {
1494 fprintf(stdout,"Analysis point for #%d is #%d", p1junction->seq, p->seq); /* debug */
1495 }
1496 #endif
1497 REACH(p, k, &rk, alt1->fset[k]);
1498 require(set_nil(rk), "rk != nil");
1499 set_free(rk);
1500 set_orin(&fCurBlk, alt1->fset[k]);
1501 }
1502
1503 /* D e t e c t A m b i g u i t i e s */
1504 *max_k = 1;
1505 for (p1=1,alt1=j; alt1!=NULL; alt1 = (Junction *)alt1->p2, p1++)
1506 {
1507 for (p2=1,alt2=(Junction *)alt1->p2; alt2!=NULL; alt2 = (Junction *)alt2->p2, p2++)
1508 {
1509 savek = k;
1510 a = set_and(alt1->fset[k], alt2->fset[k]);
1511 while ( !set_nil(a) )
1512 {
1513 /* if we have hit the max k requested, just give warning */
1514 if ( j->approx==k ) {
1515 }
1516
1517 if ( k==CLL_k )
1518 {
1519 #ifdef NOT_USED
1520 *** int save_LL_k = LL_k;
1521 *** int save_CLL_k = CLL_k;
1522 *** /* Get new LL_k from interactive feature if enabled */
1523 *** if ( AImode )
1524 *** AmbiguityDialog(j, jtype, alt1, alt2, &CLL_k, &LL_k);
1525 #endif
1526 *max_k = CLL_k;
1527 save_maintainBackTrace=MR_MaintainBackTrace;
1528 if (AlphaBetaTrace) MR_MaintainBackTrace=0;
1529 HandleAmbiguity(j, alt1, alt2, jtype);
1530 MR_MaintainBackTrace=save_maintainBackTrace;
1531 break;
1532 }
1533 else
1534 {
1535 Junction *p = analysis_point((Junction *)alt1->p1);
1536 Junction *q = analysis_point((Junction *)alt2->p1);
1537 k++; /* attempt ambig alts again with more lookahead */
1538
1539 REACH(p, k, &rk, alt1->fset[k]);
1540 require(set_nil(rk), "rk != nil");
1541 REACH(q, k, &rk, alt2->fset[k]);
1542 require(set_nil(rk), "rk != nil");
1543 set_free(a);
1544 a = set_and(alt1->fset[k], alt2->fset[k]);
1545 if ( k > *max_k ) *max_k = k;
1546 }
1547 }
1548 set_free(a);
1549 k = savek;
1550 }
1551 }
1552
1553 return fCurBlk;
1554 }
+0
-2250
contrib/pccts/antlr/fset2.c less more
0 /*
1 * fset2.c
2 *
3 * Compute FIRST sets for full LL(k)
4 *
5 * SOFTWARE RIGHTS
6 *
7 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
8 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
9 * company may do whatever they wish with source code distributed with
10 * PCCTS or the code generated by PCCTS, including the incorporation of
11 * PCCTS, or its output, into commerical software.
12 *
13 * We encourage users to develop software with PCCTS. However, we do ask
14 * that credit is given to us for developing PCCTS. By "credit",
15 * we mean that if you incorporate our source code into one of your
16 * programs (commercial product, research project, or otherwise) that you
17 * acknowledge this fact somewhere in the documentation, research report,
18 * etc... If you like PCCTS and have developed a nice tool with the
19 * output, please mention that you developed it using PCCTS. In
20 * addition, we ask that this header remain intact in our source code.
21 * As long as these guidelines are kept, we expect to continue enhancing
22 * this system and expect to make other tools available as they are
23 * completed.
24 *
25 * ANTLR 1.33
26 * Terence Parr
27 * Parr Research Corporation
28 * with Purdue University and AHPCRC, University of Minnesota
29 * 1989-2001
30 */
31
32 #include <stdio.h>
33 #include "pcctscfg.h"
34 #include <stdlib.h>
35
36 #ifdef PCCTS_USE_STDARG
37 #include <stdarg.h>
38 #else
39 #include <varargs.h>
40 #endif
41
42 #include "set.h"
43 #include "syn.h"
44 #include "hash.h"
45 #include "generic.h"
46 #include "dlgdef.h"
47
48 /* ick! globals. Used by permute() to track which elements of a set have been used */
49
50 static int *findex;
51 set *fset; /* MR11 make global */
52 static unsigned **ftbl;
53 static set *constrain; /* pts into fset. constrains tToken() to 'constrain' */
54 int ConstrainSearch;
55 int maxk; /* set to initial k upon tree construction request */
56 /* MR11 make global */
57 static Tree *FreeList = NULL;
58
59 #ifdef __USE_PROTOS
60 static int tmember_of_context(Tree *, Predicate *);
61 #else
62 static int tmember_of_context();
63 #endif
64
65 #if TREE_DEBUG
66 set set_of_tnodes_in_use;
67 int stop_on_tnode_seq_number=(-1); /* (-1) to disable */
68 #endif
69
70 /* Do root
71 * Then each sibling
72 */
73
74 void
75 #ifdef __USE_PROTOS
76 preorder( Tree *tree )
77 #else
78 preorder( tree )
79 Tree *tree;
80 #endif
81 {
82 if ( tree == NULL ) return;
83 if ( tree->down != NULL ) fprintf(stderr, " (");
84 if ( tree->token == ALT ) fprintf(stderr, " ALT");
85 else fprintf(stderr, " %s", TerminalString(tree->token));
86 if ( tree->token==EpToken ) fprintf(stderr, "(%d)", tree->v.rk);
87 preorder(tree->down);
88 if ( tree->down != NULL ) fprintf(stderr, " )");
89 preorder(tree->right);
90 }
91
92 #ifdef __USE_PROTOS
93 int MR_tree_matches_constraints(int k,set * constrain,Tree *t)
94 #else
95 int MR_tree_matches_constraints(k,constrain,t)
96 int k;
97 set * constrain;
98 Tree * t;
99 #endif
100 {
101 int i;
102 Tree *u;
103
104 if (k == 0) return 1;
105
106 /* for testing guard predicates: if the guard tree is shorter
107 than the constraint then it is a match. The reason is that
108 a guard of (A B) should be equivalent to a guard of (A B . . .)
109 where "." matches every token. Thus a match which runs out
110 of tree before constraint is a match.
111 */
112
113 if (t == NULL) return 1;
114 require (set_deg(constrain[0]) == 1,
115 "MR_tree_matches_constraints: set_deg != 1");
116 i=set_int(constrain[0]);
117 if (t->token != i) return 0;
118 if (k-1 == 0) return 1;
119 for (u=t->down; u != NULL; u=u->right) {
120 if (MR_tree_matches_constraints(k-1,&constrain[1],u)) {
121 return 1;
122 };
123 };
124 return 0;
125 }
126
127 /* check the depth of each primary sibling to see that it is exactly
128 * k deep. e.g.;
129 *
130 * ALT
131 * |
132 * A ------- B
133 * | |
134 * C -- D E
135 *
136 * Remove all branches <= k deep.
137 *
138 * Added by TJP 9-23-92 to make the LL(k) constraint mechanism to work.
139 */
140
141 static int pruneCount=0;
142 static int prunePeak=200;
143
144 Tree *
145 #ifdef __USE_PROTOS
146 prune( Tree *t, int k )
147 #else
148 prune( t, k )
149 Tree *t;
150 int k;
151 #endif
152 {
153 pruneCount++;
154 if (pruneCount > prunePeak+100) {
155 prunePeak=pruneCount;
156 #if 0
157 *** fprintf(stderr,"pruneCount=%d\n",pruneCount);
158 /*** preorder(t); ***/
159 *** fprintf(stderr,"\n",pruneCount);
160 #endif
161 };
162 if ( t == NULL ) {
163 pruneCount--;
164 return NULL;
165 };
166 if ( t->token == ALT ) fatal_internal("prune: ALT node in FIRST tree");
167 if ( t->right!=NULL ) t->right = prune(t->right, k);
168 if ( k>1 )
169 {
170 if ( t->down!=NULL ) t->down = prune(t->down, k-1);
171 if ( t->down == NULL )
172 {
173 Tree *r = t->right;
174 t->right = NULL;
175 Tfree(t);
176 pruneCount--;
177 return r;
178 }
179 }
180 pruneCount--;
181 return t;
182 }
183
184 /* build a tree (root child1 child2 ... NULL) */
185 #ifdef PCCTS_USE_STDARG
186 Tree *tmake(Tree *root, ...)
187 #else
188 Tree *tmake(va_alist)
189 va_dcl
190 #endif
191 {
192 Tree *w;
193 va_list ap;
194 Tree *child, *sibling=NULL, *tail=NULL;
195 #ifndef PCCTS_USE_STDARG
196 Tree *root;
197 #endif
198
199 #ifdef PCCTS_USE_STDARG
200 va_start(ap, root);
201 #else
202 va_start(ap);
203 root = va_arg(ap, Tree *);
204 #endif
205 child = va_arg(ap, Tree *);
206 while ( child != NULL )
207 {
208 #ifdef DUM
209 /* added "find end of child" thing TJP March 1994 */
210 for (w=child; w->right!=NULL; w=w->right) {;} /* find end of child */
211 #else
212 w = child;
213 #endif
214
215 if ( sibling == NULL ) {sibling = child; tail = w;}
216 else {tail->right = child; tail = w;}
217 child = va_arg(ap, Tree *);
218 }
219
220 /* was "root->down = sibling;" */
221 if ( root==NULL ) root = sibling;
222 else root->down = sibling;
223
224 va_end(ap);
225 return root;
226 }
227
228 Tree *
229 #ifdef __USE_PROTOS
230 tnode( int tok )
231 #else
232 tnode( tok )
233 int tok;
234 #endif
235 {
236 Tree *p, *newblk;
237 static int n=0;
238
239 if ( FreeList == NULL )
240 {
241 /*fprintf(stderr, "tnode: %d more nodes\n", TreeBlockAllocSize);*/
242 if ( TreeResourceLimit > 0 )
243 {
244 if ( (n+TreeBlockAllocSize) >= TreeResourceLimit )
245 {
246 fprintf(stderr, ErrHdr, FileStr[CurAmbigfile], CurAmbigline);
247 fprintf(stderr, " hit analysis resource limit while analyzing alts %d and %d %s\n",
248 CurAmbigAlt1,
249 CurAmbigAlt2,
250 CurAmbigbtype);
251 exit(PCCTS_EXIT_FAILURE);
252 }
253 }
254 newblk = (Tree *)calloc(TreeBlockAllocSize, sizeof(Tree));
255 if ( newblk == NULL )
256 {
257 fprintf(stderr, ErrHdr, FileStr[CurAmbigfile], CurAmbigline);
258 fprintf(stderr, " out of memory while analyzing alts %d and %d %s\n",
259 CurAmbigAlt1,
260 CurAmbigAlt2,
261 CurAmbigbtype);
262 exit(PCCTS_EXIT_FAILURE);
263 }
264 n += TreeBlockAllocSize;
265 for (p=newblk; p<&(newblk[TreeBlockAllocSize]); p++)
266 {
267 p->right = FreeList; /* add all new Tree nodes to Free List */
268 FreeList = p;
269 }
270 }
271 p = FreeList;
272 FreeList = FreeList->right; /* remove a tree node */
273 p->right = NULL; /* zero out ptrs */
274 p->down = NULL;
275 p->token = tok;
276
277 TnodesAllocated++; /* MR10 */
278 TnodesInUse++; /* MR10 */
279 if (TnodesInUse > TnodesPeak) TnodesPeak=TnodesInUse; /* MR10 */
280
281 #ifdef TREE_DEBUG
282 require(!p->in_use, "tnode: node in use!");
283 p->in_use = 1;
284 p->seq=TnodesAllocated;
285 set_orel( (unsigned) TnodesAllocated,&set_of_tnodes_in_use);
286 if (stop_on_tnode_seq_number == p->seq) {
287 fprintf(stderr,"\n*** just allocated tnode #%d ***\n",
288 stop_on_tnode_seq_number);
289 };
290 #endif
291 return p;
292 }
293
294 static Tree *
295 #ifdef __USE_PROTOS
296 eofnode( int k )
297 #else
298 eofnode( k )
299 int k;
300 #endif
301 {
302 Tree *t=NULL;
303 int i;
304
305 for (i=1; i<=k; i++)
306 {
307 t = tmake(tnode((TokenInd!=NULL?TokenInd[EofToken]:EofToken)), t, NULL);
308 }
309 return t;
310 }
311
312
313
314 void
315 #ifdef __USE_PROTOS
316 _Tfree( Tree *t )
317 #else
318 _Tfree( t )
319 Tree *t;
320 #endif
321 {
322 if ( t!=NULL )
323 {
324 #ifdef TREE_DEBUG
325 if (t->seq == stop_on_tnode_seq_number) {
326 fprintf(stderr,"\n*** just freed tnode #%d ***\n",t->seq);
327 };
328 require(t->in_use, "_Tfree: node not in use!");
329 t->in_use = 0;
330 set_rm( (unsigned) t->seq,set_of_tnodes_in_use);
331 #endif
332 t->right = FreeList;
333 FreeList = t;
334 TnodesInUse--; /* MR10 */
335 }
336 }
337
338 /* tree duplicate */
339 Tree *
340 #ifdef __USE_PROTOS
341 tdup( Tree *t )
342 #else
343 tdup( t )
344 Tree *t;
345 #endif
346 {
347 Tree *u;
348
349 if ( t == NULL ) return NULL;
350 u = tnode(t->token);
351 u->v.rk = t->v.rk;
352 u->right = tdup(t->right);
353 u->down = tdup(t->down);
354 return u;
355 }
356
357 /* tree duplicate (assume tree is a chain downwards) */
358 Tree *
359 #ifdef __USE_PROTOS
360 tdup_chain( Tree *t )
361 #else
362 tdup_chain( t )
363 Tree *t;
364 #endif
365 {
366 Tree *u;
367
368 if ( t == NULL ) return NULL;
369 u = tnode(t->token);
370 u->v.rk = t->v.rk;
371 u->down = tdup(t->down);
372 return u;
373 }
374
375 Tree *
376 #ifdef __USE_PROTOS
377 tappend( Tree *t, Tree *u )
378 #else
379 tappend( t, u )
380 Tree *t;
381 Tree *u;
382 #endif
383 {
384 Tree *w;
385
386 /*** fprintf(stderr, "tappend(");
387 *** preorder(t); fprintf(stderr, ",");
388 *** preorder(u); fprintf(stderr, " )\n");
389 */
390 if ( t == NULL ) return u;
391 if ( t->token == ALT && t->right == NULL ) return tappend(t->down, u);
392 for (w=t; w->right!=NULL; w=w->right) {;}
393 w->right = u;
394 return t;
395 }
396
397 /* dealloc all nodes in a tree */
398 void
399 #ifdef __USE_PROTOS
400 Tfree( Tree *t )
401 #else
402 Tfree( t )
403 Tree *t;
404 #endif
405 {
406 if ( t == NULL ) return;
407 Tfree( t->down );
408 Tfree( t->right );
409 _Tfree( t );
410 }
411
412 /* find all children (alts) of t that require remaining_k nodes to be LL_k
413 * tokens long.
414 *
415 * t-->o
416 * |
417 * a1--a2--...--an <-- LL(1) tokens
418 * | | |
419 * b1 b2 ... bn <-- LL(2) tokens
420 * | | |
421 * . . .
422 * . . .
423 * z1 z2 ... zn <-- LL(LL_k) tokens
424 *
425 * We look for all [Ep] needing remaining_k nodes and replace with u.
426 * u is not destroyed or actually used by the tree (a copy is made).
427 */
428 Tree *
429 #ifdef __USE_PROTOS
430 tlink( Tree *t, Tree *u, int remaining_k )
431 #else
432 tlink( t, u, remaining_k )
433 Tree *t;
434 Tree *u;
435 int remaining_k;
436 #endif
437 {
438 Tree *p;
439 require(remaining_k!=0, "tlink: bad tree");
440
441 if ( t==NULL ) return NULL;
442 /*fprintf(stderr, "tlink: u is:"); preorder(u); fprintf(stderr, "\n");*/
443 if ( t->token == EpToken && t->v.rk == remaining_k )
444 {
445 require(t->down==NULL, "tlink: invalid tree");
446 if ( u == NULL ) {
447 /* MR10 */ Tree *tt=t->right;
448 /* MR10 */ _Tfree(t);
449 /* MR10 */ return tt;
450 };
451 p = tdup( u );
452 p->right = t->right;
453 _Tfree( t );
454 return p;
455 }
456 t->down = tlink(t->down, u, remaining_k);
457 t->right = tlink(t->right, u, remaining_k);
458 return t;
459 }
460
461 /* remove as many ALT nodes as possible while still maintaining semantics */
462 Tree *
463 #ifdef __USE_PROTOS
464 tshrink( Tree *t )
465 #else
466 tshrink( t )
467 Tree *t;
468 #endif
469 {
470 if ( t == NULL ) return NULL;
471 t->down = tshrink( t->down );
472 t->right = tshrink( t->right );
473 if ( t->down == NULL )
474 {
475 if ( t->token == ALT )
476 {
477 Tree *u = t->right;
478 _Tfree(t);
479 return u; /* remove useless alts */
480 }
481 return t;
482 }
483
484 /* (? (ALT (? ...)) s) ==> (? (? ...) s) where s = sibling, ? = match any */
485 if ( t->token == ALT && t->down->right == NULL)
486 {
487 Tree *u = t->down;
488 u->right = t->right;
489 _Tfree( t );
490 return u;
491 }
492 /* (? (A (ALT t)) s) ==> (? (A t) s) where A is a token; s,t siblings */
493 if ( t->token != ALT && t->down->token == ALT && t->down->right == NULL )
494 {
495 Tree *u = t->down->down;
496 _Tfree( t->down );
497 t->down = u;
498 return t;
499 }
500 return t;
501 }
502
503 Tree *
504 #ifdef __USE_PROTOS
505 tflatten( Tree *t )
506 #else
507 tflatten( t )
508 Tree *t;
509 #endif
510 {
511 if ( t == NULL ) return NULL;
512 t->down = tflatten( t->down );
513 t->right = tflatten( t->right );
514 if ( t->down == NULL ) return t;
515
516 if ( t->token == ALT )
517 {
518 Tree *u;
519 /* find tail of children */
520 for (u=t->down; u->right!=NULL; u=u->right) {;}
521 u->right = t->right;
522 u = t->down;
523 _Tfree( t );
524 return u;
525 }
526 return t;
527 }
528
529 Tree *
530 #ifdef __USE_PROTOS
531 tJunc( Junction *p, int k, set *rk )
532 #else
533 tJunc( p, k, rk )
534 Junction *p;
535 int k;
536 set *rk;
537 #endif
538 {
539 Tree *t=NULL, *u=NULL;
540 Junction *alt;
541 Tree *tail=NULL, *r;
542
543 #ifdef DBG_TRAV
544 fprintf(stderr, "tJunc(%d): %s in rule %s\n", k,
545 decodeJType[p->jtype], ((Junction *)p)->rname);
546 #endif
547
548 /* MR14 */ if (AlphaBetaTrace && p->alpha_beta_guess_end) {
549 /* MR14 */ warnFL(
550 /* MR14 */ "not possible to compute follow set for alpha in an \"(alpha)? beta\" block. ",
551 /* MR14 */ FileStr[p->file],p->line);
552 /* MR14 */ MR_alphaBetaTraceReport();
553 /* MR14 */ };
554
555 /* MR14 */ if (p->alpha_beta_guess_end) {
556 /* MR14 */ return NULL;
557 /* MR14 */ }
558
559 if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||
560 p->jtype==aPlusBlk || p->jtype==aSubBlk || p->jtype==aOptBlk )
561 {
562 if ( p->jtype!=aSubBlk && p->jtype!=aOptBlk ) {
563 require(p->lock!=NULL, "rJunc: lock array is NULL");
564 if ( p->lock[k] ) return NULL;
565 p->lock[k] = TRUE;
566 }
567
568 /* MR10 */ if (MR_MaintainBackTrace) {
569 /* MR10 */ if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);
570 /* MR10 */ };
571
572 TRAV(p->p1, k, rk, tail);
573
574 /* MR10 */ if (MR_MaintainBackTrace) {
575 /* MR10 */ if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);
576 /* MR10 */ };
577
578 if ( p->jtype==RuleBlk ) {p->lock[k] = FALSE; return tail;}
579 r = tmake(tnode(ALT), tail, NULL);
580 for (alt=(Junction *)p->p2; alt!=NULL; alt = (Junction *)alt->p2)
581 {
582 /* if this is one of the added optional alts for (...)+ then break */
583 if ( alt->ignore ) break;
584
585 if ( tail==NULL ) {TRAV(alt->p1, k, rk, tail); r->down = tail;}
586 else
587 {
588 /* MR10 */ if (MR_MaintainBackTrace) {
589 /* MR10 */ if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);
590 /* MR10 */ };
591
592 TRAV(alt->p1, k, rk, tail->right);
593
594 /* MR10 */ if (MR_MaintainBackTrace) {
595 /* MR10 */ if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);
596 /* MR10 */ };
597 if ( tail->right != NULL ) tail = tail->right;
598 }
599 }
600 if ( p->jtype!=aSubBlk && p->jtype!=aOptBlk ) p->lock[k] = FALSE;
601 #ifdef DBG_TREES
602 fprintf(stderr, "blk(%s) returns:",((Junction *)p)->rname); preorder(r); fprintf(stderr, "\n");
603 #endif
604 if ( r->down == NULL ) {_Tfree(r); return NULL;}
605 return r;
606 }
607
608 if ( p->jtype==EndRule )
609 {
610 if ( p->halt ) /* don't want FOLLOW here? */
611 {
612 /**** if ( ContextGuardTRAV ) return NULL; ****/
613 set_orel( (unsigned) k, rk); /* indicate this k value needed */ /* MR10 cast */
614 t = tnode(EpToken);
615 t->v.rk = k;
616 return t;
617 }
618 require(p->lock!=NULL, "rJunc: lock array is NULL");
619 if ( p->lock[k] ) return NULL;
620 /* if no FOLLOW assume k EOF's */
621 if ( p->p1 == NULL ) return eofnode(k);
622 p->lock[k] = TRUE;
623 }
624
625 /* MR14 */ if (p->p1 != NULL && p->guess && p->guess_analysis_point == NULL) {
626 /* MR14 */ Node * guess_point;
627 /* MR14 */ guess_point=(Node *)analysis_point(p);
628 /* MR14 */ if (guess_point == (Node *)p) {
629 /* MR14 */ guess_point=p->p1;
630 /* MR14 */ }
631 /* MR14 */ p->guess_analysis_point=guess_point;
632 /* MR14 */ }
633
634 if ( p->p2 == NULL )
635 {
636
637 /* MR10 */ if (MR_MaintainBackTrace) {
638 /* MR10 */ if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);
639 /* MR10 */ };
640
641 /* M14 */ if (p->guess_analysis_point != NULL) {
642 /* M14 */ TRAV(p->guess_analysis_point, k, rk,t);
643 /* M14 */ } else {
644 TRAV(p->p1, k, rk,t);
645 /* M14 */ }
646
647 /* MR10 */ if (MR_MaintainBackTrace) {
648 /* MR10 */ if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);
649 /* MR10 */ };
650
651 if ( p->jtype==EndRule ) p->lock[k]=FALSE;
652 return t;
653 }
654
655 /* MR10 */ if (MR_MaintainBackTrace) {
656 /* MR10 */ if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);
657 /* MR10 */ };
658
659 /* M14 */ if (p->guess_analysis_point != NULL) {
660 /* M14 */ TRAV(p->guess_analysis_point, k, rk,t);
661 /* M14 */ } else {
662 TRAV(p->p1, k, rk,t);
663 /* M14 */ }
664
665 /* MR10 */ if (MR_MaintainBackTrace) {
666 /* MR10 */ if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);
667 /* MR10 */ };
668
669 if ( p->jtype!=RuleBlk && /* MR14 */ !p->guess) TRAV(p->p2, k, rk, u);
670
671 if ( p->jtype==EndRule ) p->lock[k] = FALSE;/* unlock node */
672
673 if ( t==NULL ) return tmake(tnode(ALT), u, NULL);
674 return tmake(tnode(ALT), t, u, NULL);
675 }
676
677 Tree *
678 #ifdef __USE_PROTOS
679 tRuleRef( RuleRefNode *p, int k, set *rk_out )
680 #else
681 tRuleRef( p, k, rk_out )
682 RuleRefNode *p;
683 int k;
684 set *rk_out;
685 #endif
686 {
687 int k2;
688 Tree *t=NULL, *u=NULL;
689 Junction *r;
690 set rk, rk2;
691 int save_halt;
692 RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);
693
694 #ifdef DBG_TRAV
695 fprintf(stderr, "tRuleRef: %s\n", p->text);
696 #endif
697 if ( q == NULL )
698 {
699 TRAV(p->next, k, rk_out, t);/* ignore undefined rules */
700 return t;
701 }
702 rk = rk2 = empty;
703 if (RulePtr == NULL) fatal("RulePtr==NULL");
704 r = RulePtr[q->rulenum];
705 if ( r->lock[k] ) return NULL;
706 save_halt = r->end->halt;
707 r->end->halt = TRUE; /* don't let reach fall off end of rule here */
708
709 /* MR10 */ if (MR_MaintainBackTrace) {
710 /* MR10 */ MR_pointerStackPush(&MR_BackTraceStack,p);
711 /* MR10 */ };
712
713 TRAV(r, k, &rk, t);
714
715 /* MR10 */ if (MR_MaintainBackTrace) {
716 /* MR10 */ MR_pointerStackPop(&MR_BackTraceStack);
717 /* MR10 */ };
718
719 r->end->halt = save_halt;
720 #ifdef DBG_TREES
721 fprintf(stderr, "after ruleref, t is:"); preorder(t); fprintf(stderr, "\n");
722 #endif
723 t = tshrink( t );
724 while ( !set_nil(rk) ) { /* any k left to do? if so, link onto tree */
725 k2 = set_int(rk);
726 set_rm(k2, rk);
727
728 /* MR10 */ if (MR_MaintainBackTrace) {
729 /* MR10 */ MR_pointerStackPush(&MR_BackTraceStack,p);
730 /* MR10 */ };
731
732 TRAV(p->next, k2, &rk2, u);
733
734 /* MR10 */ if (MR_MaintainBackTrace) {
735 /* MR10 */ MR_pointerStackPop(&MR_BackTraceStack);
736 /* MR10 */ };
737
738 t = tlink(t, u, k2); /* any alts missing k2 toks, add u onto end */
739 Tfree(u); /* MR10 */
740 }
741 set_free(rk); /* rk is empty, but free it's memory */
742 set_orin(rk_out, rk2); /* remember what we couldn't do */
743 set_free(rk2);
744 return t;
745 }
746
747 Tree *
748 #ifdef __USE_PROTOS
749 tToken( TokNode *p, int k, set *rk )
750 #else
751 tToken( p, k, rk )
752 TokNode *p;
753 int k;
754 set *rk;
755 #endif
756 {
757 Tree *t=NULL, *tset=NULL, *u;
758
759 if (ConstrainSearch) {
760 if (MR_AmbSourceSearch) {
761 require(constrain>=fset&&constrain<=&(fset[CLL_k]),"tToken: constrain is not a valid set");
762 } else {
763 require(constrain>=fset&&constrain<=&(fset[LL_k]),"tToken: constrain is not a valid set");
764 };
765 constrain = &fset[maxk-k+1];
766 }
767
768 #ifdef DBG_TRAV
769 fprintf(stderr, "tToken(%d): %s\n", k, TerminalString(p->token));
770 if ( ConstrainSearch ) {
771 fprintf(stderr, "constrain is:"); s_fprT(stderr, *constrain); fprintf(stderr, "\n");
772 }
773 #endif
774
775 /* is it a meta token (set of tokens)? */
776
777 if ( !set_nil(p->tset) )
778 {
779 unsigned e=0;
780 set a;
781 Tree *n, *tail = NULL;
782
783 if ( ConstrainSearch ) {
784 a = set_and(p->tset, *constrain);
785 if (set_nil(a)) { /* MR10 */
786 set_free(a); /* MR11 */
787 return NULL; /* MR10 */
788 }; /* MR10 */
789 } else {
790 a = set_dup(p->tset);
791 };
792
793 for (; !set_nil(a); set_rm(e, a))
794 {
795 e = set_int(a);
796 n = tnode(e);
797 if ( tset==NULL ) { tset = n; tail = n; }
798 else { tail->right = n; tail = n; }
799 }
800 set_free( a );
801 }
802 else if ( ConstrainSearch && !set_el(p->token, *constrain) )
803 {
804 /* fprintf(stderr, "ignoring token %s(%d)\n", TerminalString(p->token),
805 k);*/
806 return NULL;
807 }
808 else {
809 tset = tnode( p->token );
810 };
811
812 /* MR10 */ if (MR_MaintainBackTrace) {
813 /* MR10 */ if (k == 1) {
814 /* MR10 */ MR_pointerStackPush(&MR_BackTraceStack,p);
815 /* MR13 */ if (MR_SuppressSearch) {
816 /* MR13 */ MR_suppressSearchReport();
817 /* MR13 */ } else {
818 /* MR10 */ MR_backTraceReport();
819 /* MR13 */ };
820 /* MR10 */ MR_pointerStackPop(&MR_BackTraceStack);
821 /* MR11 */ Tfree(tset);
822 /* MR11 */ return NULL;
823 /* MR10 */ };
824 /* MR10 */ };
825
826 if ( k == 1 ) return tset;
827
828 if (MR_MaintainBackTrace) {
829 MR_pointerStackPush(&MR_BackTraceStack,p);
830 };
831
832 TRAV(p->next, k-1, rk, t);
833
834 if (MR_MaintainBackTrace) {
835 Tfree(t);
836 Tfree(tset);
837 MR_pointerStackPop(&MR_BackTraceStack);
838 return NULL;
839 };
840
841 /* here, we are positive that, at least, this tree will not contribute
842 * to the LL(2) tree since it will be too shallow, IF t==NULL.
843 * If doing a context guard walk, then don't prune.
844 */
845 if ( t == NULL && !ContextGuardTRAV ) /* tree will be too shallow */
846 {
847 if ( tset!=NULL ) Tfree( tset );
848 return NULL;
849 }
850 #ifdef DBG_TREES
851 fprintf(stderr, "tToken(%d)->next:",k); preorder(t); fprintf(stderr, "\n");
852 #endif
853
854 /* if single token root, then just make new tree and return */
855 /* MR10 - set_nil(p->tset) isn't a good test because of ConstraintSearch */
856
857 if (tset->right == NULL) return tmake(tset, t, NULL); /* MR10 */
858
859 /* here we must make a copy of t as a child of each element of the tset;
860 * e.g., "T1..T3 A" would yield ( nil ( T1 A ) ( T2 A ) ( T3 A ) )
861 */
862 for (u=tset; u!=NULL; u=u->right)
863 {
864 /* make a copy of t and hook it onto bottom of u */
865 u->down = tdup(t);
866 }
867 Tfree( t );
868 #ifdef DBG_TREES
869 fprintf(stderr, "range is:"); preorder(tset); fprintf(stderr, "\n");
870 #endif
871 return tset;
872 }
873
874 Tree *
875 #ifdef __USE_PROTOS
876 tAction( ActionNode *p, int k, set *rk )
877 #else
878 tAction( p, k, rk )
879 ActionNode *p;
880 int k;
881 set *rk;
882 #endif
883 {
884 Tree *t=NULL;
885 set *save_fset=NULL;
886 int i;
887
888 /* fprintf(stderr, "tAction\n"); */
889
890 /* An MR_SuppressSearch is looking for things that can be
891 reached even when the predicate is false.
892
893 There are three kinds of predicates:
894 plain: r1: <<p>>? r2
895 guarded: r1: (A)? => <<p>>? r2
896 ampersand style: r1: (A)? && <<p>>? r2
897
898 Of the three kinds of predicates, only a guard predicate
899 has things which are reachable even when the predicate
900 is false. To be reachable the constraint must *not*
901 match the guard.
902
903 */
904
905 if (p->is_predicate && MR_SuppressSearch) {
906
907 Predicate *pred=p->guardpred;
908
909 if (pred == NULL) {
910 t=NULL;
911 goto EXIT;
912 };
913 constrain = &fset[maxk-k+1];
914 if (pred->k == 1) {
915 set dif;
916 dif=set_dif(*constrain,pred->scontext[1]);
917 if (set_nil(dif)) {
918 set_free(dif);
919 t=NULL;
920 goto EXIT;
921 };
922 set_free(dif);
923 } else {
924 if (MR_tree_matches_constraints(k,constrain,pred->tcontext)) {
925 t=NULL;
926 goto EXIT;
927 };
928 }
929 };
930
931 /* The ampersand predicate differs from the
932 other predicates because its first set
933 is a subset of the first set behind the predicate
934
935 r1: (A)? && <<p>>? r2 ;
936 r2: A | B;
937
938 In this case first[1] of r1 is A, even
939 though first[1] of r2 is {A B}.
940 */
941
942 if (p->is_predicate && p->ampersandPred != NULL) {
943
944 Predicate *pred=p->ampersandPred;
945 Tree *tAND;
946 Tree *tset;
947
948 if (k <= pred->k) {
949 if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);
950 TRAV(p->guardNodes,k,rk,t);
951 if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);
952 return t;
953 } else {
954 require (k>1,"tAction for ampersandpred: k <= 1");
955 if (ConstrainSearch) {
956 if (MR_AmbSourceSearch) {
957 require(constrain>=fset&&constrain<=&(fset[CLL_k]),
958 "tToken: constrain is not a valid set");
959 } else {
960 require(constrain>=fset&&constrain<=&(fset[LL_k]),
961 "tToken: constrain is not a valid set");
962 };
963 save_fset=(set *) calloc (CLL_k+1,sizeof(set));
964 require (save_fset != NULL,"tAction save_fset alloc");
965 for (i=1; i <= CLL_k ; i++) {
966 save_fset[i]=set_dup(fset[i]);
967 };
968 if (pred->k == 1) {
969 constrain = &fset[maxk-k+1];
970 set_andin(constrain,pred->scontext[1]);
971 if (set_nil(*constrain)) {
972 t=NULL;
973 goto EXIT;
974 };
975 } else {
976 constrain = &fset[maxk-k+1];
977 if (! MR_tree_matches_constraints(pred->k,constrain,pred->tcontext)) {
978 t=NULL;
979 goto EXIT;
980 }; /* end loop on i */
981 }; /* end loop on pred scontext/tcontext */
982 }; /* end if on k > pred->k */
983 }; /* end if on constrain search */
984
985 TRAV(p->next,k,rk,t);
986
987 if (t != NULL) {
988 t=tshrink(t);
989 t=tflatten(t);
990 t=tleft_factor(t);
991 if (pred->tcontext != NULL) {
992 tAND=MR_computeTreeAND(t,pred->tcontext);
993 } else {
994 tset=MR_make_tree_from_set(pred->scontext[1]);
995 tAND=MR_computeTreeAND(t,tset);
996 Tfree(tset);
997 };
998 Tfree(t);
999 t=tAND;
1000 };
1001 goto EXIT;
1002
1003 }; /* end if on ampersand predicate */
1004
1005 TRAV(p->next,k,rk,t);
1006
1007 EXIT:
1008 if (save_fset != NULL) {
1009 for (i=1 ; i <= CLL_k ; i++) {
1010 set_free(fset[i]);
1011 fset[i]=save_fset[i];
1012 };
1013 free ( (char *) save_fset);
1014 };
1015 return t;
1016 }
1017
1018 /* see if e exists in s as a possible input permutation (e is always a chain) */
1019
1020 int
1021 #ifdef __USE_PROTOS
1022 tmember( Tree *e, Tree *s )
1023 #else
1024 tmember( e, s )
1025 Tree *e;
1026 Tree *s;
1027 #endif
1028 {
1029 if ( e==NULL||s==NULL ) return 0;
1030 /** fprintf(stderr, "tmember(");
1031 *** preorder(e); fprintf(stderr, ",");
1032 *** preorder(s); fprintf(stderr, " )\n");
1033 */
1034 if ( s->token == ALT && s->right == NULL ) return tmember(e, s->down);
1035 if ( e->token!=s->token )
1036 {
1037 if ( s->right==NULL ) return 0;
1038 return tmember(e, s->right);
1039 }
1040 if ( e->down==NULL && s->down == NULL ) return 1;
1041 if ( tmember(e->down, s->down) ) return 1;
1042 if ( s->right==NULL ) return 0;
1043 return tmember(e, s->right);
1044 }
1045
1046 /* see if e exists in s as a possible input permutation (e is always a chain);
1047 * Only check s to the depth of e. In other words, 'e' can be a shorter
1048 * sequence than s.
1049 */
1050 int
1051 #ifdef __USE_PROTOS
1052 tmember_constrained( Tree *e, Tree *s)
1053 #else
1054 tmember_constrained( e, s )
1055 Tree *e;
1056 Tree *s;
1057 #endif
1058 {
1059 if ( e==NULL||s==NULL ) return 0;
1060 /** fprintf(stderr, "tmember_constrained(");
1061 *** preorder(e); fprintf(stderr, ",");
1062 *** preorder(s); fprintf(stderr, " )\n");
1063 **/
1064 if ( s->token == ALT && s->right == NULL )
1065 return tmember_constrained(e, s->down);
1066 if ( e->token!=s->token )
1067 {
1068 if ( s->right==NULL ) return 0;
1069 return tmember_constrained(e, s->right);
1070 }
1071 if ( e->down == NULL ) return 1; /* if s is matched to depth of e return */
1072 if ( tmember_constrained(e->down, s->down) ) return 1;
1073 if ( s->right==NULL ) return 0;
1074 return tmember_constrained(e, s->right);
1075 }
1076
1077 /* combine (? (A t) ... (A u) ...) into (? (A t u)) */
1078 Tree *
1079 #ifdef __USE_PROTOS
1080 tleft_factor( Tree *t )
1081 #else
1082 tleft_factor( t )
1083 Tree *t;
1084 #endif
1085 {
1086 Tree *u, *v, *trail, *w;
1087
1088 /* left-factor what is at this level */
1089 if ( t == NULL ) return NULL;
1090 for (u=t; u!=NULL; u=u->right)
1091 {
1092 trail = u;
1093 v=u->right;
1094 while ( v!=NULL )
1095 {
1096 if ( u->token == v->token )
1097 {
1098 if ( u->down!=NULL )
1099 {
1100 for (w=u->down; w->right!=NULL; w=w->right) {;}
1101 w->right = v->down; /* link children together */
1102 }
1103 else u->down = v->down;
1104 trail->right = v->right; /* unlink factored node */
1105 _Tfree( v );
1106 v = trail->right;
1107 }
1108 else {trail = v; v=v->right;}
1109 }
1110 }
1111 /* left-factor what is below */
1112 for (u=t; u!=NULL; u=u->right) u->down = tleft_factor( u->down );
1113 return t;
1114 }
1115
1116 /* remove the permutation p from t if present */
1117 Tree *
1118 #ifdef __USE_PROTOS
1119 trm_perm( Tree *t, Tree *p )
1120 #else
1121 trm_perm( t, p )
1122 Tree *t;
1123 Tree *p;
1124 #endif
1125 {
1126 /*
1127 fprintf(stderr, "trm_perm(");
1128 preorder(t); fprintf(stderr, ",");
1129 preorder(p); fprintf(stderr, " )\n");
1130 */
1131 if ( t == NULL || p == NULL ) return NULL;
1132 if ( t->token == ALT )
1133 {
1134 t->down = trm_perm(t->down, p);
1135 if ( t->down == NULL ) /* nothing left below, rm cur node */
1136 {
1137 Tree *u = t->right;
1138 _Tfree( t );
1139 return trm_perm(u, p);
1140 }
1141 t->right = trm_perm(t->right, p); /* look for more instances of p */
1142 return t;
1143 }
1144 if ( p->token != t->token ) /* not found, try a sibling */
1145 {
1146 t->right = trm_perm(t->right, p);
1147 return t;
1148 }
1149 t->down = trm_perm(t->down, p->down);
1150 if ( t->down == NULL ) /* nothing left below, rm cur node */
1151 {
1152 Tree *u = t->right;
1153 _Tfree( t );
1154 return trm_perm(u, p);
1155 }
1156 t->right = trm_perm(t->right, p); /* look for more instances of p */
1157 return t;
1158 }
1159
1160 /* add the permutation 'perm' to the LL_k sets in 'fset' */
1161 void
1162 #ifdef __USE_PROTOS
1163 tcvt( set *fset, Tree *perm )
1164 #else
1165 tcvt( fset, perm )
1166 set *fset;
1167 Tree *perm;
1168 #endif
1169 {
1170 if ( perm==NULL ) return;
1171 set_orel(perm->token, fset);
1172 tcvt(fset+1, perm->down);
1173 }
1174
1175 /* for each element of ftbl[k], make it the root of a tree with permute(ftbl[k+1])
1176 * as a child.
1177 */
1178 Tree *
1179 #ifdef __USE_PROTOS
1180 permute( int k, int max_k )
1181 #else
1182 permute( k, max_k )
1183 int k, max_k;
1184 #endif
1185 {
1186 Tree *t, *u;
1187
1188 if ( k>max_k ) return NULL;
1189 if ( ftbl[k][findex[k]] == nil ) return NULL;
1190 t = permute(k+1, max_k);
1191 if ( t==NULL&&k<max_k ) /* no permutation left below for k+1 tokens? */
1192 {
1193 findex[k+1] = 0;
1194 (findex[k])++; /* try next token at this k */
1195 return permute(k, max_k);
1196 }
1197
1198 u = tmake(tnode(ftbl[k][findex[k]]), t, NULL);
1199 if ( k == max_k ) (findex[k])++;
1200 return u;
1201 }
1202
1203 /* Compute LL(k) trees for alts alt1 and alt2 of p.
1204 * function result is tree of ambiguous input permutations
1205 *
1206 * ALGORITHM may change to look for something other than LL_k size
1207 * trees ==> maxk will have to change.
1208 */
1209 Tree *
1210 #ifdef __USE_PROTOS
1211 VerifyAmbig( Junction *alt1, Junction *alt2, unsigned **ft, set *fs, Tree **t, Tree **u, int *numAmbig )
1212 #else
1213 VerifyAmbig( alt1, alt2, ft, fs, t, u, numAmbig )
1214 Junction *alt1;
1215 Junction *alt2;
1216 unsigned **ft;
1217 set *fs;
1218 Tree **t;
1219 Tree **u;
1220 int *numAmbig;
1221 #endif
1222 {
1223 set rk;
1224 Tree *perm, *ambig=NULL;
1225 Junction *p;
1226 int k;
1227 int tnodes_at_start=TnodesAllocated;
1228 int tnodes_at_end;
1229 int tnodes_used;
1230 set *save_fs;
1231 int j;
1232
1233 save_fs=(set *) calloc(CLL_k+1,sizeof(set));
1234 require(save_fs != NULL,"save_fs calloc");
1235
1236 for (j=0; j <= CLL_k ; j++) save_fs[j]=set_dup(fs[j]);
1237
1238 maxk = LL_k; /* NOTE: for now, we look for LL_k */
1239 ftbl = ft;
1240 fset = fs;
1241 constrain = &(fset[1]);
1242 findex = (int *) calloc(LL_k+1, sizeof(int));
1243 if ( findex == NULL )
1244 {
1245 fprintf(stderr, ErrHdr, FileStr[CurAmbigfile], CurAmbigline);
1246 fprintf(stderr, " out of memory while analyzing alts %d and %d of %s\n",
1247 CurAmbigAlt1,
1248 CurAmbigAlt2,
1249 CurAmbigbtype);
1250 exit(PCCTS_EXIT_FAILURE);
1251 }
1252 for (k=1; k<=LL_k; k++) findex[k] = 0;
1253
1254 rk = empty;
1255 ConstrainSearch = 1; /* consider only tokens in ambig sets */
1256
1257 p = analysis_point((Junction *)alt1->p1);
1258 TRAV(p, LL_k, &rk, *t);
1259 *t = tshrink( *t );
1260 *t = tflatten( *t );
1261 *t = tleft_factor( *t ); /* MR10 */
1262 *t = prune(*t, LL_k);
1263 *t = tleft_factor( *t );
1264
1265 /*** fprintf(stderr, "after shrink&flatten&prune&left_factor:"); preorder(*t); fprintf(stderr, "\n");*/
1266 if ( *t == NULL )
1267 {
1268 /*** fprintf(stderr, "TreeIncomplete --> no LL(%d) ambiguity\n", LL_k);*/
1269 Tfree( *t ); /* kill if impossible to have ambig */
1270 *t = NULL;
1271 }
1272
1273 p = analysis_point((Junction *)alt2->p1);
1274
1275 TRAV(p, LL_k, &rk, *u);
1276 *u = tshrink( *u );
1277 *u = tflatten( *u );
1278 *t = tleft_factor( *t ); /* MR10 */
1279 *u = prune(*u, LL_k);
1280 *u = tleft_factor( *u );
1281 /* fprintf(stderr, "after shrink&flatten&prune&lfactor:"); preorder(*u); fprintf(stderr, "\n");*/
1282 if ( *u == NULL )
1283 {
1284 /* fprintf(stderr, "TreeIncomplete --> no LL(%d) ambiguity\n", LL_k);*/
1285 Tfree( *u );
1286 *u = NULL;
1287 }
1288
1289 for (k=1; k<=LL_k; k++) set_clr( fs[k] );
1290
1291 ambig = tnode(ALT);
1292 k = 0;
1293 if ( *t!=NULL && *u!=NULL )
1294 {
1295 while ( (perm=permute(1,LL_k))!=NULL )
1296 {
1297 /* fprintf(stderr, "chk perm:"); preorder(perm); fprintf(stderr, "\n");*/
1298 if ( tmember(perm, *t) && tmember(perm, *u) )
1299 {
1300 /* fprintf(stderr, "ambig upon"); preorder(perm); fprintf(stderr, "\n");*/
1301
1302 k++;
1303 perm->right = ambig->down;
1304 ambig->down = perm;
1305 tcvt(&(fs[1]), perm);
1306 }
1307 else Tfree( perm );
1308 }
1309 }
1310
1311 for (j=0; j <= CLL_k ; j++) fs[j]=save_fs[j];
1312 free( (char *) save_fs);
1313
1314 tnodes_at_end=TnodesAllocated;
1315 tnodes_used=tnodes_at_end - tnodes_at_start;
1316
1317 if (TnodesReportThreshold > 0 && tnodes_used > TnodesReportThreshold) {
1318 fprintf(stdout,"There were %d tuples whose ambiguity could not be resolved by full lookahead\n",k);
1319 fprintf(stdout,"There were %d tnodes created to resolve ambiguity between:\n\n",tnodes_used);
1320 fprintf(stdout," Choice 1: %s line %d file %s\n",
1321 MR_ruleNamePlusOffset( (Node *) alt1),alt1->line,FileStr[alt1->file]);
1322 fprintf(stdout," Choice 2: %s line %d file %s\n",
1323 MR_ruleNamePlusOffset( (Node *) alt2),alt2->line,FileStr[alt2->file]);
1324 for (j=1; j <= CLL_k ; j++) {
1325 fprintf(stdout,"\n Intersection of lookahead[%d] sets:\n",j);
1326 MR_dumpTokenSet(stdout,2,fs[j]);
1327 };
1328 fprintf(stdout,"\n");
1329 };
1330
1331 *numAmbig = k;
1332 if ( ambig->down == NULL ) {_Tfree(ambig); ambig = NULL;}
1333 free( (char *)findex );
1334 /* fprintf(stderr, "final ambig:"); preorder(ambig); fprintf(stderr, "\n");*/
1335 return ambig;
1336 }
1337
1338 static Tree *
1339 #ifdef __USE_PROTOS
1340 bottom_of_chain( Tree *t )
1341 #else
1342 bottom_of_chain( t )
1343 Tree *t;
1344 #endif
1345 {
1346 if ( t==NULL ) return NULL;
1347 for (; t->down != NULL; t=t->down) {;}
1348 return t;
1349 }
1350
1351 /*
1352 * Make a tree from k sets where the degree of the first k-1 sets is 1.
1353 */
1354 Tree *
1355 #ifdef __USE_PROTOS
1356 make_tree_from_sets( set *fset1, set *fset2 )
1357 #else
1358 make_tree_from_sets( fset1, fset2 )
1359 set *fset1;
1360 set *fset2;
1361 #endif
1362 {
1363 set inter;
1364 int i;
1365 Tree *t=NULL, *n, *u;
1366 unsigned *p,*q;
1367 require(LL_k>1, "make_tree_from_sets: LL_k must be > 1");
1368
1369 /* do the degree 1 sets first */
1370 for (i=1; i<=LL_k-1; i++)
1371 {
1372 inter = set_and(fset1[i], fset2[i]);
1373 require(set_deg(inter)==1, "invalid set to tree conversion");
1374 n = tnode(set_int(inter));
1375 if (t==NULL) t=n; else tmake(t, n, NULL);
1376 set_free(inter);
1377 }
1378
1379 /* now add the chain of tokens at depth k */
1380 u = bottom_of_chain(t);
1381 inter = set_and(fset1[LL_k], fset2[LL_k]);
1382 if ( (q=p=set_pdq(inter)) == NULL ) fatal_internal("Can't alloc space for set_pdq");
1383 /* first one is linked to bottom, then others are sibling linked */
1384 n = tnode(*p++);
1385 u->down = n;
1386 u = u->down;
1387 while ( *p != nil )
1388 {
1389 n = tnode(*p);
1390 u->right = n;
1391 u = u->right;
1392 p++;
1393 }
1394 free((char *)q);
1395
1396 return t;
1397 }
1398
1399 /* create and return the tree of lookahead k-sequences that are in t, but not
1400 * in the context of predicates in predicate list p.
1401 */
1402 Tree *
1403 #ifdef __USE_PROTOS
1404 tdif( Tree *ambig_tuples, Predicate *p, set *fset1, set *fset2 )
1405 #else
1406 tdif( ambig_tuples, p, fset1, fset2 )
1407 Tree *ambig_tuples;
1408 Predicate *p;
1409 set *fset1;
1410 set *fset2;
1411 #endif
1412 {
1413 unsigned **ft;
1414 Tree *dif=NULL;
1415 Tree *perm;
1416 set b;
1417 int i,k;
1418
1419 if ( p == NULL ) return tdup(ambig_tuples);
1420
1421 ft = (unsigned **) calloc(CLL_k+1, sizeof(unsigned *));
1422 require(ft!=NULL, "cannot allocate ft");
1423 for (i=1; i<=CLL_k; i++)
1424 {
1425 b = set_and(fset1[i], fset2[i]);
1426 ft[i] = set_pdq(b);
1427 set_free(b);
1428 }
1429 findex = (int *) calloc(LL_k+1, sizeof(int));
1430 if ( findex == NULL )
1431 {
1432 fatal_internal("out of memory in tdif while checking predicates");
1433 }
1434 for (k=1; k<=LL_k; k++) findex[k] = 0;
1435
1436 #ifdef DBG_TRAV
1437 fprintf(stderr, "tdif_%d[", p->k);
1438 preorder(ambig_tuples);
1439 fprintf(stderr, ",");
1440 preorder(p->tcontext);
1441 fprintf(stderr, "] =");
1442 #endif
1443
1444 ftbl = ft;
1445 while ( (perm=permute(1,p->k))!=NULL )
1446 {
1447 #ifdef DBG_TRAV
1448 fprintf(stderr, "test perm:"); preorder(perm); fprintf(stderr, "\n");
1449 #endif
1450 if ( tmember_constrained(perm, ambig_tuples) &&
1451 !tmember_of_context(perm, p) )
1452 {
1453 #ifdef DBG_TRAV
1454 fprintf(stderr, "satisfied upon"); preorder(perm); fprintf(stderr, "\n");
1455 #endif
1456 k++;
1457 if ( dif==NULL ) dif = perm;
1458 else
1459 {
1460 perm->right = dif;
1461 dif = perm;
1462 }
1463 }
1464 else Tfree( perm );
1465 }
1466
1467 #ifdef DBG_TRAV
1468 preorder(dif);
1469 fprintf(stderr, "\n");
1470 #endif
1471
1472 for (i=1; i<=CLL_k; i++) free( (char *)ft[i] );
1473 free((char *)ft);
1474 free((char *)findex);
1475
1476 return dif;
1477 }
1478
1479 /* is lookahead sequence t a member of any context tree for any
1480 * predicate in p?
1481 */
1482 static int
1483 #ifdef __USE_PROTOS
1484 tmember_of_context( Tree *t, Predicate *p )
1485 #else
1486 tmember_of_context( t, p )
1487 Tree *t;
1488 Predicate *p;
1489 #endif
1490 {
1491 for (; p!=NULL; p=p->right)
1492 {
1493 if ( p->expr==PRED_AND_LIST || p->expr==PRED_OR_LIST )
1494 return tmember_of_context(t, p->down);
1495 if ( tmember_constrained(t, p->tcontext) ) return 1;
1496 if ( tmember_of_context(t, p->down) ) return 1;
1497 }
1498 return 0;
1499 }
1500
1501 int
1502 #ifdef __USE_PROTOS
1503 is_single_tuple( Tree *t )
1504 #else
1505 is_single_tuple( t )
1506 Tree *t;
1507 #endif
1508 {
1509 if ( t == NULL ) return 0;
1510 if ( t->right != NULL ) return 0;
1511 if ( t->down == NULL ) return 1;
1512 return is_single_tuple(t->down);
1513 }
1514
1515
1516 /* MR10 Check that a context guard contains only allowed things */
1517 /* MR10 (mainly token references). */
1518
1519 #ifdef __USE_PROTOS
1520 int contextGuardOK(Node *p,int h,int *hmax)
1521 #else
1522 int contextGuardOK(p,h,hmax)
1523 Node *p;
1524 int h;
1525 int *hmax;
1526 #endif
1527 {
1528 Junction *j;
1529 TokNode *tn;
1530
1531 if (p == NULL) return 1;
1532 if (p->ntype == nToken) {
1533 h++;
1534 if (h > *hmax) *hmax=h;
1535 tn=(TokNode *)p;
1536 if (tn->el_label != NULL) {
1537 warnFL(eMsg1("a label (\"%s\") for a context guard element is meaningless",tn->el_label),
1538 FileStr[p->file],p->line);
1539 };
1540 return contextGuardOK( ( (TokNode *) p)->next,h,hmax);
1541 } else if (p->ntype == nAction) {
1542 goto Fail;
1543 } else if (p->ntype == nRuleRef) {
1544 goto Fail;
1545 } else {
1546 require (p->ntype == nJunction,"Unexpected ntype");
1547 j=(Junction *) p;
1548 if (j->jtype != Generic &&
1549 j->jtype != aSubBlk && /* pretty sure this one is allowed */
1550 /**** j->jtype != aOptBlk && ****/ /* pretty sure this one is allowed */ /* MR11 not any more ! */
1551 j->jtype != EndBlk) {
1552 errFL("A context guard may not contain an option block: {...} or looping block: (...)* or (...)+",
1553 FileStr[p->file],p->line);
1554 contextGuardOK(j->p1,h,hmax);
1555 return 0;
1556 };
1557 /* do both p1 and p2 so use | rather than || */
1558 return contextGuardOK(j->p2,h,hmax) | contextGuardOK(j->p1,h,hmax);
1559 };
1560 Fail:
1561 errFL("A context guard may contain only Token references - guard will be ignored",
1562 FileStr[p->file],p->line);
1563 contextGuardOK( ( (ActionNode *) p)->next,h,hmax);
1564 return 0;
1565 }
1566
1567 /*
1568 * Look at a (...)? generalized-predicate context-guard and compute
1569 * either a lookahead set (k==1) or a lookahead tree for k>1. The
1570 * k level is determined by the guard itself rather than the LL_k
1571 * variable. For example, ( A B )? is an LL(2) guard and ( ID )?
1572 * is an LL(1) guard. For the moment, you can only have a single
1573 * tuple in the guard. Physically, the block must look like this
1574 * --o-->TOKEN-->o-->o-->TOKEN-->o-- ... -->o-->TOKEN-->o--
1575 * An error is printed for any other type.
1576 */
1577 Predicate *
1578 #ifdef __USE_PROTOS
1579 computePredFromContextGuard(Graph blk,int *msgDone) /* MR10 */
1580 #else
1581 computePredFromContextGuard(blk,msgDone) /* MR10 */
1582 Graph blk;
1583 int *msgDone; /* MR10 */
1584 #endif
1585 {
1586 Junction *junc = (Junction *)blk.left, *p;
1587 Tree *t=NULL;
1588 Predicate *pred = NULL;
1589 set scontext, rk;
1590 int ok;
1591 int hmax=0;
1592
1593 require(junc!=NULL && junc->ntype == nJunction, "bad context guard");
1594
1595 /* MR10 Check for anything other than Tokens and generic junctions */
1596
1597 *msgDone=0; /* MR10 */
1598 ok=contextGuardOK( (Node *)junc,0,&hmax); /* MR10 */
1599 if (! ok) { /* MR10 */
1600 *msgDone=1; /* MR10 */
1601 return NULL; /* MR10 */
1602 }; /* MR10 */
1603 if (hmax == 0) {
1604 errFL("guard is 0 tokens long",FileStr[junc->file],junc->line); /* MR11 */
1605 *msgDone=1;
1606 return NULL;
1607 };
1608 if (hmax > CLL_k) { /* MR10 */
1609 errFL(eMsgd2("guard is %d tokens long - lookahead is limited to max(k,ck)==%d", /* MR10 */
1610 hmax,CLL_k), /* MR10 */
1611 FileStr[junc->file],junc->line); /* MR10 */
1612 *msgDone=1; /* MR10 */
1613 return NULL; /* MR10 */
1614 }; /* MR10 */
1615
1616 rk = empty;
1617 p = junc;
1618 pred = new_pred();
1619 pred->k = hmax; /* MR10 should be CLL_k, not LLK ? */
1620 if (hmax > 1 ) /* MR10 was LL_k */
1621 {
1622 ConstrainSearch = 0;
1623 ContextGuardTRAV = 1;
1624 TRAV(p, hmax, &rk, t); /* MR10 was LL_k */
1625 ContextGuardTRAV = 0;
1626 set_free(rk);
1627 t = tshrink( t );
1628 t = tflatten( t );
1629 t = tleft_factor( t );
1630 /*
1631 fprintf(stderr, "ctx guard:");
1632 preorder(t);
1633 fprintf(stderr, "\n");
1634 */
1635 pred->tcontext = t;
1636 }
1637 else
1638 {
1639 REACH(p, 1, &rk, scontext);
1640 require(set_nil(rk), "rk != nil");
1641 set_free(rk);
1642 /*
1643 fprintf(stderr, "LL(1) ctx guard is:");
1644 s_fprT(stderr, scontext);
1645 fprintf(stderr, "\n");
1646 */
1647 pred->scontext[1] = scontext;
1648 }
1649
1650 list_add(&ContextGuardPredicateList,pred); /* MR13 */
1651
1652 return pred;
1653 }
1654
1655 /* MR13
1656 When the context guard is originally computed the
1657 meta-tokens are not known.
1658 */
1659
1660 #ifdef __USE_PROTOS
1661 void recomputeContextGuard(Predicate *pred)
1662 #else
1663 void recomputeContextGuard(pred)
1664 Predicate *pred;
1665 #endif
1666 {
1667 Tree * t=NULL;
1668 set scontext;
1669 set rk;
1670 ActionNode * actionNode;
1671 Junction * p;
1672
1673 actionNode=pred->source;
1674 require (actionNode != NULL,"context predicate's source == NULL");
1675
1676 p=actionNode->guardNodes;
1677 require (p != NULL,"context predicate's guardNodes == NULL");
1678
1679 rk = empty;
1680 if (pred->k > 1 )
1681 {
1682 ConstrainSearch = 0;
1683 ContextGuardTRAV = 1;
1684 TRAV(p, pred->k, &rk, t);
1685 ContextGuardTRAV = 0;
1686 set_free(rk);
1687 t = tshrink( t );
1688 t = tflatten( t );
1689 t = tleft_factor( t );
1690 Tfree(pred->tcontext);
1691 pred->tcontext = t;
1692 }
1693 else
1694 {
1695 REACH(p, 1, &rk, scontext);
1696 require(set_nil(rk), "rk != nil");
1697 set_free(rk);
1698 set_free(pred->scontext[1]);
1699 pred->scontext[1] = scontext;
1700 }
1701 }
1702
1703 /* MR11 - had enough of flags yet ? */
1704
1705 int MR_AmbSourceSearch=0;
1706 int MR_AmbSourceSearchGroup=0;
1707 int MR_AmbSourceSearchChoice=0;
1708 int MR_AmbSourceSearchLimit=0;
1709 int MR_matched_AmbAidRule=0;
1710
1711 static set *matchSets[2]={NULL,NULL};
1712 static int *tokensInChain=NULL;
1713 static Junction *MR_AmbSourceSearchJ[2];
1714
1715 void MR_traceAmbSourceKclient()
1716 {
1717 int i;
1718 set *save_fset;
1719 int save_ConstrainSearch;
1720 set incomplete;
1721 Tree *t;
1722
1723 if (matchSets[0] == NULL) {
1724 matchSets[0]=(set *) calloc (CLL_k+1,sizeof(set));
1725 require (matchSets[0] != NULL,"matchSets[0] alloc");
1726 matchSets[1]=(set *) calloc (CLL_k+1,sizeof(set));
1727 require (matchSets[1] != NULL,"matchSets[1] alloc");
1728 };
1729
1730 for (i=1 ; i <= MR_AmbSourceSearchLimit ; i++) {
1731 set_clr(matchSets[0][i]);
1732 set_orel( (unsigned) tokensInChain[i],
1733 &matchSets[0][i]);
1734 set_clr(matchSets[1][i]);
1735 set_orel( (unsigned) tokensInChain[i],
1736 &matchSets[1][i]);
1737 };
1738
1739 save_fset=fset;
1740 save_ConstrainSearch=ConstrainSearch;
1741
1742
1743
1744 for (i=0 ; i < 2 ; i++) {
1745
1746 #if 0
1747 ** fprintf(stdout," Choice:%d Depth:%d ",i+1,MR_AmbSourceSearchLimit);
1748 ** fprintf(stdout,"(");
1749 ** for (j=1 ; j <= MR_AmbSourceSearchLimit ; j++) {
1750 ** if (j != 1) fprintf(stdout," ");
1751 ** fprintf(stdout,"%s",TerminalString(tokensInChain[j]));
1752 ** };
1753 ** fprintf(stdout,")\n\n");
1754 #endif
1755
1756 fset=matchSets[i];
1757
1758 MR_AmbSourceSearch=1;
1759 MR_MaintainBackTrace=1;
1760 MR_AmbSourceSearchChoice=i;
1761 ConstrainSearch=1;
1762
1763 maxk = MR_AmbSourceSearchLimit;
1764
1765 incomplete=empty;
1766 t=NULL;
1767
1768 constrain = &(fset[1]);
1769 MR_pointerStackReset(&MR_BackTraceStack);
1770
1771 TRAV(MR_AmbSourceSearchJ[i],maxk,&incomplete,t);
1772
1773 Tfree(t);
1774
1775 require (set_nil(incomplete),"MR_traceAmbSourceK TRAV incomplete");
1776 require (MR_BackTraceStack.count == 0,"K: MR_BackTraceStack.count != 0");
1777
1778 set_free(incomplete);
1779 };
1780
1781 ConstrainSearch=save_ConstrainSearch;
1782 fset=save_fset;
1783 MR_AmbSourceSearch=0;
1784 MR_MaintainBackTrace=0;
1785 MR_AmbSourceSearchChoice=0;
1786 }
1787
1788 #ifdef __USE_PROTOS
1789 Tree *tTrunc(Tree *t,int depth)
1790 #else
1791 Tree *tTrunc(t,depth)
1792 Tree *t;
1793 #endif
1794 {
1795 Tree *u;
1796
1797 require ( ! (t == NULL && depth > 0),"tree too short");
1798
1799 if (depth == 0) return NULL;
1800
1801 if (t->token == ALT) {
1802 u=tTrunc(t->down,depth);
1803 } else {
1804 u=tnode(t->token);
1805 u->down=tTrunc(t->down,depth-1);
1806 };
1807 if (t->right != NULL) u->right=tTrunc(t->right,depth);
1808 return u;
1809 }
1810
1811 #ifdef __USE_PROTOS
1812 void MR_iterateOverTree(Tree *t,int chain[])
1813 #else
1814 void MR_iterateOverTree(t,chain)
1815 Tree *t;
1816 int chain[];
1817 #endif
1818 {
1819 if (t == NULL) return;
1820 chain[0]=t->token;
1821 if (t->down != NULL) {
1822 MR_iterateOverTree(t->down,&chain[1]);
1823 } else {
1824 MR_traceAmbSourceKclient();
1825 };
1826 MR_iterateOverTree(t->right,&chain[0]);
1827 chain[0]=0;
1828 }
1829
1830 #ifdef __USE_PROTOS
1831 void MR_traceAmbSourceK(Tree *t,Junction *alt1,Junction *alt2)
1832 #else
1833 void MR_traceAmbSourceK(t,alt1,alt2)
1834 Tree *t;
1835 Junction *alt1;
1836 Junction *alt2;
1837 #endif
1838 {
1839 int i;
1840 int depth;
1841 int maxDepth;
1842 Tree *truncatedTree;
1843
1844 if (MR_AmbAidRule == NULL) return;
1845
1846 if ( ! (
1847 strcmp(MR_AmbAidRule,alt1->rname) == 0 ||
1848 strcmp(MR_AmbAidRule,alt2->rname) == 0 ||
1849 MR_AmbAidLine==alt1->line ||
1850 MR_AmbAidLine==alt2->line
1851 )
1852 ) return;
1853
1854 MR_matched_AmbAidRule++;
1855
1856 /* there are no token sets in trees, only in TokNodes */
1857
1858 MR_AmbSourceSearchJ[0]=analysis_point( (Junction *) alt1->p1);
1859 MR_AmbSourceSearchJ[1]=analysis_point( (Junction *) alt2->p1);
1860
1861 if (tokensInChain == NULL) {
1862 tokensInChain=(int *) calloc (CLL_k+1,sizeof(int));
1863 require (tokensInChain != NULL,"tokensInChain alloc");
1864 };
1865
1866 MR_AmbSourceSearchGroup=0;
1867
1868 fprintf(stdout,"\n");
1869 fprintf(stdout," Ambiguity Aid ");
1870 fprintf(stdout,
1871 (MR_AmbAidDepth <= LL_k ?
1872 "(-k %d -aa %s %s -aad %d)\n\n" :
1873 "(-k %d -aa %s %s [-k value limits -aad %d])\n\n"),
1874 LL_k,
1875 MR_AmbAidRule,
1876 (MR_AmbAidMultiple ? "-aam" : ""),
1877 MR_AmbAidDepth);
1878
1879 for (i=0 ; i < 2 ; i++) {
1880 fprintf(stdout," Choice %d: %-25s line %d file %s\n",
1881 (i+1),
1882 MR_ruleNamePlusOffset( (Node *) MR_AmbSourceSearchJ[i]),
1883 MR_AmbSourceSearchJ[i]->line,
1884 FileStr[MR_AmbSourceSearchJ[i]->file]);
1885 };
1886
1887 fprintf(stdout,"\n");
1888
1889 if (MR_AmbAidDepth < LL_k) {
1890 maxDepth=MR_AmbAidDepth;
1891 } else {
1892 maxDepth=LL_k;
1893 };
1894
1895 for (depth=1 ; depth <= maxDepth; depth++) {
1896 MR_AmbSourceSearchLimit=depth;
1897 if (depth < LL_k) {
1898 truncatedTree=tTrunc(t,depth);
1899 truncatedTree=tleft_factor(truncatedTree);
1900 MR_iterateOverTree(truncatedTree,&tokensInChain[1]); /* <===== */
1901 Tfree(truncatedTree);
1902 } else {
1903 MR_iterateOverTree(t,tokensInChain); /* <===== */
1904 };
1905 fflush(stdout);
1906 fflush(stderr);
1907 };
1908
1909 fprintf(stdout,"\n");
1910 MR_AmbSourceSearch=0;
1911 MR_MaintainBackTrace=0;
1912 MR_AmbSourceSearchGroup=0;
1913 MR_AmbSourceSearchChoice=0;
1914 MR_AmbSourceSearchLimit=0;
1915
1916 }
1917
1918
1919 /* this if for k=1 grammars only
1920
1921 this is approximate only because of the limitations of linear
1922 approximation lookahead. Don't want to do a k=3 search when
1923 the user only specified a ck=3 grammar
1924 */
1925
1926 #ifdef __USE_PROTOS
1927 void MR_traceAmbSource(set *matchSets,Junction *alt1, Junction *alt2)
1928 #else
1929 void MR_traceAmbSource(matchSets,alt1,alt2)
1930 set *matchSets;
1931 Junction *alt1;
1932 Junction *alt2;
1933 #endif
1934 {
1935 set *save_fset;
1936 Junction *p[2];
1937 int i;
1938 int j;
1939 set *dup_matchSets;
1940 set intersection;
1941 set incomplete;
1942 set tokensUsed;
1943 int depth;
1944
1945 if (MR_AmbAidRule == NULL) return;
1946 if ( ! (
1947 strcmp(MR_AmbAidRule,alt1->rname) == 0 ||
1948 strcmp(MR_AmbAidRule,alt2->rname) == 0 ||
1949 MR_AmbAidLine==alt1->line ||
1950 MR_AmbAidLine==alt2->line
1951 )
1952 ) return;
1953
1954 MR_matched_AmbAidRule++;
1955
1956 save_fset=fset;
1957
1958 dup_matchSets=(set *) calloc(CLL_k+1,sizeof(set));
1959 require (dup_matchSets != NULL,"Can't allocate dup_matchSets");
1960
1961 p[0]=analysis_point( (Junction *) alt1->p1);
1962 p[1]=analysis_point( (Junction *) alt2->p1);
1963
1964 fprintf(stdout,"\n");
1965
1966 fprintf(stdout," Ambiguity Aid ");
1967 fprintf(stdout,
1968 (MR_AmbAidDepth <= CLL_k ?
1969 "(-ck %d -aa %s %s -aad %d)\n\n" :
1970 "(-ck %d -aa %s %s [-ck value limits -aad %d])\n\n"),
1971 CLL_k,
1972 MR_AmbAidRule,
1973 (MR_AmbAidMultiple ? "-aam" : ""),
1974 MR_AmbAidDepth);
1975
1976 for (i=0 ; i < 2 ; i++) {
1977 fprintf(stdout," Choice %d: %-25s line %d file %s\n",
1978 (i+1),
1979 MR_ruleNamePlusOffset( (Node *) p[i]),
1980 p[i]->line,FileStr[p[i]->file]);
1981 };
1982
1983 for (j=1; j <= CLL_k ; j++) {
1984 fprintf(stdout,"\n Intersection of lookahead[%d] sets:\n",j);
1985 intersection=set_and(alt1->fset[j],alt2->fset[j]);
1986 MR_dumpTokenSet(stdout,2,intersection);
1987 set_free(intersection);
1988 };
1989
1990 fprintf(stdout,"\n");
1991
1992 require (1 <= MR_AmbAidDepth && MR_AmbAidDepth <= CLL_k,
1993 "illegal MR_AmbAidDepth");
1994
1995 MR_AmbSourceSearchGroup=0;
1996 for (depth=1; depth <= MR_AmbAidDepth; depth++) {
1997 MR_AmbSourceSearchLimit=depth;
1998 for (i=0 ; i < 2 ; i++) {
1999
2000 /*** fprintf(stdout," Choice:%d Depth:%d\n\n",i+1,depth); ***/
2001
2002 for (j=0 ; j <= CLL_k ; j++) { dup_matchSets[j]=set_dup(matchSets[j]); };
2003 fset=dup_matchSets;
2004
2005 fflush(output);
2006 fflush(stdout);
2007
2008 MR_AmbSourceSearch=1;
2009 MR_MaintainBackTrace=1;
2010 MR_AmbSourceSearchChoice=i;
2011
2012 maxk = depth;
2013 tokensUsed=empty;
2014 incomplete=empty;
2015
2016 constrain = &(fset[1]);
2017 MR_pointerStackReset(&MR_BackTraceStack);
2018
2019 REACH(p[i],depth,&incomplete,tokensUsed);
2020
2021 fflush(output);
2022 fflush(stdout);
2023
2024 require (set_nil(incomplete),"MR_traceAmbSource REACH incomplete");
2025 require (MR_BackTraceStack.count == 0,"1: MR_BackTraceStack.count != 0");
2026
2027 set_free(incomplete);
2028 set_free(tokensUsed);
2029
2030 for (j=0 ; j <= CLL_k ; j++) { set_free(dup_matchSets[j]); };
2031 };
2032 };
2033
2034 fprintf(stdout,"\n");
2035
2036 MR_AmbSourceSearch=0;
2037 MR_MaintainBackTrace=0;
2038 MR_AmbSourceSearchGroup=0;
2039 MR_AmbSourceSearchChoice=0;
2040 MR_AmbSourceSearchLimit=0;
2041
2042 fset=save_fset;
2043 free ( (char *) dup_matchSets);
2044 }
2045
2046 static int itemCount;
2047
2048 void MR_backTraceDumpItemReset() {
2049 itemCount=0;
2050 }
2051
2052 #ifdef __USE_PROTOS
2053 void MR_backTraceDumpItem(FILE *f,int skip,Node *n)
2054 #else
2055 void MR_backTraceDumpItem(f,skip,n)
2056 FILE *f;
2057 int skip;
2058 Node *n;
2059 #endif
2060 {
2061 TokNode *tn;
2062 RuleRefNode *rrn;
2063 Junction *j;
2064 ActionNode *a;
2065
2066 switch (n->ntype) {
2067 case nToken:
2068 itemCount++; if (skip) goto EXIT;
2069 tn=(TokNode *)n;
2070 if (set_nil(tn->tset)) {
2071 fprintf(f," %2d #token %-23s",itemCount,TerminalString(tn->token));
2072 } else {
2073 fprintf(f," %2d #tokclass %-20s",itemCount,TerminalString(tn->token));
2074 };
2075 break;
2076 case nRuleRef:
2077 itemCount++; if (skip) goto EXIT;
2078 rrn=(RuleRefNode *)n;
2079 fprintf(f," %2d to %-27s",itemCount,rrn->text);
2080 break;
2081 case nAction:
2082 a=(ActionNode *)n;
2083 goto EXIT;
2084 case nJunction:
2085
2086 j=(Junction *)n;
2087
2088 switch (j->jtype) {
2089 case aSubBlk:
2090 if (j->guess) {
2091 itemCount++; if (skip) goto EXIT;
2092 fprintf(f," %2d %-30s",itemCount,"in (...)? block at");
2093 break;
2094 };
2095 /****** fprintf(f," %2d %-32s",itemCount,"in (...) block at"); *******/
2096 /****** break; *******/
2097 goto EXIT;
2098 case aOptBlk:
2099 itemCount++; if (skip) goto EXIT;
2100 fprintf(f," %2d %-30s",itemCount,"in {...} block");
2101 break;
2102 case aLoopBlk:
2103 itemCount++; if (skip) goto EXIT;
2104 fprintf(f," %2d %-30s",itemCount,"in (...)* block");
2105 break;
2106 case EndBlk:
2107 if (j->alpha_beta_guess_end) {
2108 itemCount++; if (skip) goto EXIT;
2109 fprintf(f," %2d %-30s",itemCount,"end (...)? block at");
2110 break;
2111 };
2112 goto EXIT;
2113 /****** fprintf(f," %2d %-32s",itemCount,"end of a block at"); *****/
2114 /****** break; *****/
2115 case RuleBlk:
2116 itemCount++; if (skip) goto EXIT;
2117 fprintf(f," %2d %-30s",itemCount,j->rname);
2118 break;
2119 case Generic:
2120 goto EXIT;
2121 case EndRule:
2122 itemCount++; if (skip) goto EXIT;
2123 fprintf (f," %2d end %-26s",itemCount,j->rname);
2124 break;
2125 case aPlusBlk:
2126 itemCount++; if (skip) goto EXIT;
2127 fprintf(f," %2d %-30s",itemCount,"in (...)+ block");
2128 break;
2129 case aLoopBegin:
2130 goto EXIT;
2131 };
2132 break;
2133 };
2134 fprintf(f," %-23s line %-4d %s\n",MR_ruleNamePlusOffset(n),n->line,FileStr[n->file]);
2135 EXIT:
2136 return;
2137 }
2138
2139
2140 static PointerStack previousBackTrace={0,0,NULL};
2141
2142 #ifdef __USE_PROTOS
2143 void MR_backTraceReport(void)
2144 #else
2145 void MR_backTraceReport()
2146 #endif
2147 {
2148 int i;
2149 int match = 0;
2150 int limitMatch;
2151
2152 Node *p;
2153 TokNode *tn;
2154 set remainder;
2155 int depth;
2156
2157 /* Even when doing a k=2 search this routine can get
2158 called when there is only 1 token on the stack.
2159 This is because something like rRuleRef can change
2160 the search value of k from 2 to 1 temporarily.
2161 It does this because the it wants to know the k=1
2162 first set before it does a k=2 search
2163 */
2164
2165 depth=0;
2166 for (i=0; i < MR_BackTraceStack.count ; i++) {
2167 p=(Node *) MR_BackTraceStack.data[i];
2168 if (p->ntype == nToken) depth++;
2169 };
2170
2171 /* MR14 */ if (MR_AmbSourceSearch) {
2172 /* MR14 */ require (depth <= MR_AmbSourceSearchLimit,"depth > MR_AmbSourceSearchLimit");
2173 /* MR14 */ }
2174
2175 /* MR23 THM - Traceback report was being called at the wrong time for -alpha reports */
2176 /* Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu) */
2177
2178 if (MR_AmbSourceSearchLimit == 0 || depth < MR_AmbSourceSearchLimit) {
2179 return;
2180 };
2181
2182 MR_backTraceDumpItemReset();
2183
2184 limitMatch=MR_BackTraceStack.count;
2185 if (limitMatch > previousBackTrace.count) {
2186 limitMatch=previousBackTrace.count;
2187 };
2188
2189 for (match=0; match < limitMatch; match++) {
2190 if (MR_BackTraceStack.data[match] !=
2191 previousBackTrace.data[match]) {
2192 break;
2193 };
2194 };
2195
2196 /* not sure at the moment why there would be duplicates */
2197
2198 if (match != MR_BackTraceStack.count) {
2199
2200 fprintf(stdout," Choice:%d Depth:%d Group:%d",
2201 (MR_AmbSourceSearchChoice+1),
2202 MR_AmbSourceSearchLimit,
2203 ++MR_AmbSourceSearchGroup);
2204
2205 depth=0;
2206 fprintf(stdout," (");
2207 for (i=0; i < MR_BackTraceStack.count ; i++) {
2208 p=(Node *) MR_BackTraceStack.data[i];
2209 if (p->ntype != nToken) continue;
2210 tn=(TokNode *)p;
2211 if (depth != 0) fprintf(stdout," ");
2212 fprintf(stdout,"%s",TerminalString(tn->token));
2213 depth++;
2214 if (! MR_AmbAidMultiple) {
2215 if (set_nil(tn->tset)) {
2216 set_rm( (unsigned) tn->token,fset[depth]);
2217 } else {
2218 remainder=set_dif(fset[depth],tn->tset);
2219 set_free(fset[depth]);
2220 fset[depth]=remainder;
2221 };
2222 };
2223 };
2224 fprintf(stdout,")\n");
2225
2226 for (i=0; i < MR_BackTraceStack.count ; i++) {
2227 MR_backTraceDumpItem(stdout, (i<match) ,(Node *) MR_BackTraceStack.data[i]);
2228 };
2229 fprintf(stdout,"\n");
2230 fflush(stdout);
2231
2232 MR_pointerStackReset(&previousBackTrace);
2233
2234 for (i=0; i < MR_BackTraceStack.count ; i++) {
2235 MR_pointerStackPush(&previousBackTrace,MR_BackTraceStack.data[i]);
2236 };
2237
2238 };
2239 }
2240
2241 #ifdef __USE_PROTOS
2242 void MR_setConstrainPointer(set * newConstrainValue)
2243 #else
2244 void MR_setConstrainPointer(newConstrainValue)
2245 set * newConstrainValue;
2246 #endif
2247 {
2248 constrain=newConstrainValue;
2249 }
+0
-4800
contrib/pccts/antlr/gen.c less more
0 /*
1 * gen.c
2 *
3 * Generate C code (ANSI, K&R, C++)
4 *
5 * SOFTWARE RIGHTS
6 *
7 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
8 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
9 * company may do whatever they wish with source code distributed with
10 * PCCTS or the code generated by PCCTS, including the incorporation of
11 * PCCTS, or its output, into commerical software.
12 *
13 * We encourage users to develop software with PCCTS. However, we do ask
14 * that credit is given to us for developing PCCTS. By "credit",
15 * we mean that if you incorporate our source code into one of your
16 * programs (commercial product, research project, or otherwise) that you
17 * acknowledge this fact somewhere in the documentation, research report,
18 * etc... If you like PCCTS and have developed a nice tool with the
19 * output, please mention that you developed it using PCCTS. In
20 * addition, we ask that this header remain intact in our source code.
21 * As long as these guidelines are kept, we expect to continue enhancing
22 * this system and expect to make other tools available as they are
23 * completed.
24 *
25 * ANTLR 1.33
26 * Terence Parr
27 * Parr Research Corporation
28 * with Purdue University and AHPCRC, University of Minnesota
29 * 1989-2001
30 */
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <ctype.h>
35 #include "pcctscfg.h"
36 #include "set.h"
37 #include "syn.h"
38 #include "hash.h"
39 #include "generic.h"
40 #include "dlgdef.h"
41
42 /* OSX warning fix */
43 #define GR_INT int
44
45 #define NumExprPerLine 4
46 static int on1line=0;
47 static set tokensRefdInBlock;
48
49 /* T r a n s l a t i o n T a b l e s */
50
51 /* C_Trans[node type] == pointer to function that knows how to translate that node. */
52 #ifdef __cplusplus
53 void (*C_Trans[NumNodeTypes+1])(...) = {
54 NULL,
55 NULL, /* See next table.
56 Junctions have many types */
57 (void (*)(...)) genRuleRef,
58 (void (*)(...)) genToken,
59 (void (*)(...)) genAction
60 };
61 #else
62 void (*C_Trans[NumNodeTypes+1])() = {
63 NULL,
64 NULL, /* See next table.
65 Junctions have many types */
66 genRuleRef,
67 genToken,
68 genAction
69 };
70 #endif
71
72 /* C_JTrans[Junction type] == pointer to function that knows how to translate that
73 * kind of junction node.
74 */
75 #ifdef __cplusplus
76 void (*C_JTrans[NumJuncTypes+1])(...) = {
77 NULL,
78 (void (*)(...)) genSubBlk,
79 (void (*)(...)) genOptBlk,
80 (void (*)(...)) genLoopBlk,
81 (void (*)(...)) genEndBlk,
82 (void (*)(...)) genRule,
83 (void (*)(...)) genJunction,
84 (void (*)(...)) genEndRule,
85 (void (*)(...)) genPlusBlk,
86 (void (*)(...)) genLoopBegin
87 };
88 #else
89 void (*C_JTrans[NumJuncTypes+1])() = {
90 NULL,
91 genSubBlk,
92 genOptBlk,
93 genLoopBlk,
94 genEndBlk,
95 genRule,
96 genJunction,
97 genEndRule,
98 genPlusBlk,
99 genLoopBegin
100 };
101 #endif
102
103 #define PastWhiteSpace(s) while (*(s) == ' ' || *(s) == '\t') {s++;}
104
105 static int tabs = 0;
106
107 /* MR6 Got tired of text running off page when using standard tab stops */
108
109 #define TAB { int i; \
110 if (TabWidth==0) { \
111 for (i=0; i<tabs; i++) fputc('\t', output); \
112 } else { \
113 for (i=0; i<tabs*TabWidth; i++) fputc(' ',output); \
114 }; \
115 }
116
117 static void
118 #ifdef __USE_PROTOS
119 tab( void )
120 #else
121 tab( )
122 #endif
123 TAB
124
125 #ifdef __USE_PROTOS
126 static char *tokenFollowSet(TokNode *);
127 static ActionNode *findImmedAction( Node * );
128 static void dumpRetValAssign(char *, char *, RuleRefNode *); /* MR30 */
129 static void dumpAfterActions(FILE *output);
130 static set ComputeErrorSet(Junction *, int, int);
131 static void makeErrorClause(Junction *, set, int, int);
132 static void DumpFuncHeader( Junction *, RuleEntry * );
133 static int has_guess_block_as_first_item(Junction *);
134 static int genExprSets(set *, int);
135 static void genExprTree( Tree *t, int k );
136 static void genExprTreeOriginal( Tree *t, int k ); /* MR10 */
137 static char * findOuterHandlerLabel(ExceptionGroup *eg); /* MR7 */
138 static void OutLineInfo(FILE *file,int line,char *fileName); /* MR14 */
139 #else
140 static char *tokenFollowSet();
141 static ActionNode *findImmedAction();
142 static void dumpRetValAssign();
143 static void dumpAfterActions();
144 static set ComputeErrorSet();
145 static void makeErrorClause();
146 static void DumpFuncHeader();
147 static int has_guess_block_as_first_item();
148 static int genExprSets();
149 static void genExprTree();
150 static void genExprTreeOriginal(); /* MR10 */
151 static char * findOuterHandlerLabel(); /* MR7 */
152 static void OutLineInfo(); /* MR14 */
153 #endif
154
155 #define gen(s) {tab(); fprintf(output, s);}
156 #define gen1(s,a) {tab(); fprintf(output, s,a);}
157 #define gen2(s,a,b) {tab(); fprintf(output, s,a,b);}
158 #define gen3(s,a,b,c) {tab(); fprintf(output, s,a,b,c);}
159 #define gen4(s,a,b,c,d) {tab(); fprintf(output, s,a,b,c,d);}
160 #define gen5(s,a,b,c,d,e) {tab(); fprintf(output, s,a,b,c,d,e);}
161 #define gen6(s,a,b,c,d,e,f) {tab(); fprintf(output, s,a,b,c,d,e,f);}
162 #define gen7(s,a,b,c,d,e,f,g) {tab(); fprintf(output, s,a,b,c,d,e,f,g);}
163
164 #define _gen(s) {fprintf(output, s);}
165 #define _gen1(s,a) {fprintf(output, s,a);}
166 #define _gen2(s,a,b) {fprintf(output, s,a,b);}
167 #define _gen3(s,a,b,c) {fprintf(output, s,a,b,c);}
168 #define _gen4(s,a,b,c,d){fprintf(output, s,a,b,c,d);}
169 #define _gen5(s,a,b,c,d,e){fprintf(output, s,a,b,c,d,e);}
170 #define _gen6(s,a,b,c,d,e,f){fprintf(output, s,a,b,c,d,e,f);}
171 #define _gen7(s,a,b,c,d,e,f,g){fprintf(output, s,a,b,c,d,e,f,g);}
172
173
174 /* MR11 a convenient place to set a break point */
175
176 #ifdef __USE_PROTOS
177 void MR_break(void)
178 #else
179 void MR_break()
180 #endif
181 {
182 return;
183 }
184
185 /* MR10 genTraceOut(Junction *) */
186
187 #ifdef __USE_PROTOS
188 static void genTraceOut(Junction *q)
189 #else
190 static void genTraceOut(q)
191 Junction *q;
192 #endif
193 {
194 if ( TraceGen ) {
195 if ( GenCC ) {gen1("zzTRACEOUT(\"%s\");\n", q->rname);}
196 else gen1("zzTRACEOUT((ANTLRChar *)\"%s\");\n", q->rname);
197 }
198 }
199
200 static void
201 #ifdef __USE_PROTOS
202 warn_about_using_gk_option(void)
203 #else
204 warn_about_using_gk_option()
205 #endif
206 {
207 static int warned_already=0;
208
209 if ( !DemandLookahead || warned_already ) return;
210 warned_already = 1;
211 warnNoFL("-gk option could cause trouble for <<...>>? predicates");
212 }
213
214 void
215 #ifdef __USE_PROTOS
216 freeBlkFsets( Junction *q )
217 #else
218 freeBlkFsets( q )
219 Junction *q;
220 #endif
221 {
222 int i;
223 Junction *alt;
224 require(q!=NULL, "freeBlkFsets: invalid node");
225
226 for (alt=q; alt != NULL; alt= (Junction *) alt->p2 )
227 {
228 for (i=1; i<=CLL_k; i++) set_free(alt->fset[i]);
229 }
230 }
231
232 /*
233 * Generate a local variable allocation for each token references
234 * in this block.
235 */
236 static void
237 #ifdef __USE_PROTOS
238 genTokenPointers( Junction *q )
239 #else
240 genTokenPointers( q )
241 Junction *q;
242 #endif
243 {
244 /* Rule refs are counted and can be referenced, but their
245 * value is not set to anything useful ever.
246 *
247 * The ptrs are to be named _tij where i is the current level
248 * and j is the element number within an alternative.
249 */
250 int first=1, t=0;
251 set a;
252 tokensRefdInBlock = q->tokrefs;
253
254 if ( set_deg(q->tokrefs) == 0 ) return;
255 a = set_dup(q->tokrefs);
256 gen("ANTLRTokenPtr ");
257 for (; !set_nil(a); set_rm(t, a))
258 {
259 t = set_int(a);
260 if ( first ) first = 0;
261 else _gen(",");
262 if ( !DontCopyTokens ) _gen2("_tv%d%d,", BlkLevel, t);
263 _gen2("_t%d%d", BlkLevel, t);
264 if ( !DontCopyTokens ) {_gen2("= &_tv%d%d", BlkLevel, t);}
265 else _gen("=NULL");
266 }
267 _gen(";\n");
268 set_free(a);
269 }
270
271 static int
272 #ifdef __USE_PROTOS
273 hasDefaultException(ExceptionGroup *eg)
274 #else
275 hasDefaultException(eg)
276 ExceptionGroup *eg;
277 #endif
278 {
279 ListNode *q;
280
281 for (q = eg->handlers->next; q!=NULL; q=q->next)
282 {
283 ExceptionHandler *eh = (ExceptionHandler *)q->elem;
284 if ( strcmp("default", eh->signalname)==0 ) {
285 return 1;
286 }
287 }
288 return 0;
289 }
290 static void
291 #ifdef __USE_PROTOS
292 dumpException(ExceptionGroup *eg, int no_default_case)
293 #else
294 dumpException(eg, no_default_case)
295 ExceptionGroup *eg;
296 int no_default_case;
297 #endif
298 {
299 char *outerLabel; /* MR7 */
300 int altHandler=0; /* MR7 */
301 int namedHandler=0; /* MR7 */
302
303 outerLabel=findOuterHandlerLabel(eg); /* MR7 */
304
305 if (eg->label != NULL) { /* MR7 */
306 namedHandler=1; /* MR7 */
307 } else if (eg->forRule) { /* MR7 */
308 /* nothing */ /* MR20 */
309 } else { /* MR7 */
310 altHandler=1; /* MR7 */
311 }; /* MR7 */
312
313 #if 0
314 ** if (! eg->used) { /* MR7 */
315 ** warnFL("exception group never used", /* MR7 */
316 ** FileStr[eg->altstart->file],eg->altstart->line); /* MR7 */
317 ** }; /* MR7 */
318 #endif
319
320 if (namedHandler) { /* MR7 */
321 gen1("switch ( _signal ) { /* [%s] */\n",eg->label); /* MR7 */
322 } else { /* MR7 */
323 gen("switch ( _signal ) {\n"); /* MR7 */
324 gen("case NoSignal: break; /* MR7 */\n"); /* MR7 */
325 }; /* MR7 */
326 {
327 ListNode *q;
328 for (q = eg->handlers->next; q!=NULL; q=q->next)
329 {
330 ExceptionHandler *eh = (ExceptionHandler *)q->elem;
331 if ( strcmp("default", eh->signalname)==0 ) {
332 gen("default :\n");
333 tabs++;
334 dumpAction(eh->action, output, tabs, -1, 1, 1);
335 gen("_signal=NoSignal; /* MR7 */\n"); /* MR7 */
336 gen("break; /* MR7 */\n"); /* MR7 */
337 tabs--;
338 gen("}\n");
339
340 /* copied from later code in dumpException */ /* MR7 */
341
342 if (namedHandler) { /* MR7 */
343 gen("if (_signal != NoSignal)"); /* MR7 */
344 _gen1(" goto %s_handler; /* MR7 */\n",outerLabel);/* MR7 */
345 } else if (altHandler) { /* MR7 */
346 gen1("goto %s_handler; /* MR7 */\n",outerLabel); /* MR7 */
347 };
348 return;
349 }
350 gen1("case %s :\n", eh->signalname);
351 tabs++;
352 if ( eh->action != NULL )
353 {
354 dumpAction(eh->action, output, tabs, -1, 1, 1);
355 gen("break; /* MR7 */\n"); /* MR7 */
356 }
357 tabs--;
358 }
359 }
360 if ( no_default_case ) return;
361
362 gen("default :\n");
363 tabs++; /* MR7 */
364 gen("break; /* MR7 */\n"); /* MR7 */
365 tabs--; /* MR7 */
366
367 tabs++;
368 /***** gen("*_retsignal = _signal;\n"); *****/
369
370 tabs--;
371 gen("}\n");
372
373 if (namedHandler) { /* MR7 */
374 gen("if (_signal != NoSignal)"); /* MR7 */
375 _gen1(" goto %s_handler; /* MR7 */\n",outerLabel); /* MR7 */
376 } else if (altHandler) { /* MR7 */
377 gen1("goto %s_handler; /* MR7 */\n",outerLabel); /* MR7 */
378 };
379
380 }
381
382 static void
383 #ifdef __USE_PROTOS
384 dumpExceptions(ListNode *list)
385 #else
386 dumpExceptions(list)
387 ListNode *list;
388 #endif
389 {
390 ListNode *p;
391
392 for (p = list->next; p!=NULL; p=p->next)
393 {
394 ExceptionGroup *eg = (ExceptionGroup *) p->elem;
395 _gen2("%s%s_handler:\n",
396 eg->label==NULL?"":eg->label,
397 eg->altID==NULL?"":eg->altID);
398 if ( eg->altID!=NULL ) dumpException(eg, 0);
399 else {
400 /* This must be the rule exception handler */
401 dumpException(eg, 1);
402 if ( !hasDefaultException(eg) )
403 {
404 gen("default :\n");
405 tabs++;
406 gen("zzdflthandlers(_signal,_retsignal);\n");
407 tabs--;
408 gen("}\n");
409 }
410 }
411 }
412 }
413
414 /* For each element label that is found in a rule, generate a unique
415 * Attribute (and AST pointer if GenAST) variable.
416 */
417 void
418 #ifdef __USE_PROTOS
419 genElementLabels(ListNode *list)
420 #else
421 genElementLabels(list)
422 ListNode *list;
423 #endif
424 {
425 int first=1;
426 ListNode *p;
427
428 if ( GenCC ) {gen("ANTLRTokenPtr");}
429 else {gen("Attrib");}
430 for (p = list->next; p!=NULL; p=p->next)
431 {
432 char *ep = (char *)p->elem;
433 if ( first ) first = 0;
434 else _gen(",");
435 if ( GenCC ) {_gen1(" %s=NULL",ep);}
436 else {_gen1(" %s",ep);}
437 }
438 _gen(";\n");
439
440 if ( !GenAST ) return;
441
442 first = 1;
443 gen("AST");
444 for (p = list->next; p!=NULL; p=p->next)
445 {
446 char *ep = (char *)p->elem;
447 if ( first ) first = 0;
448 else _gen(",");
449 _gen1(" *%s_ast=NULL",ep);
450 }
451 _gen(";\n");
452 }
453
454 /*
455 * Generate a local variable allocation for each token or rule reference
456 * in this block.
457 */
458 static void
459 #ifdef __USE_PROTOS
460 genASTPointers( Junction *q )
461 #else
462 genASTPointers( q )
463 Junction *q;
464 #endif
465 {
466 int first=1, t;
467 set a;
468
469 a = set_or(q->tokrefs, q->rulerefs);
470 if ( set_deg(a) > 0 )
471 {
472 gen("AST ");
473 for (; !set_nil(a); set_rm(t, a))
474 {
475 t = set_int(a);
476 if ( first ) first = 0;
477 else _gen(",");
478 _gen2("*_ast%d%d=NULL", BlkLevel, t);
479 }
480 set_free(a);
481 }
482 _gen(";\n");
483 }
484
485 static void
486 #ifdef __USE_PROTOS
487 BLOCK_Head( void )
488 #else
489 BLOCK_Head( )
490 #endif
491 {
492 gen("{\n");
493 tabs++;
494 if ( !GenCC ) gen1("zzBLOCK(zztasp%d);\n", BlkLevel);
495 }
496
497 static void
498 #ifdef __USE_PROTOS
499 BLOCK_Tail( void )
500 #else
501 BLOCK_Tail( )
502 #endif
503 {
504 if ( !GenCC ) gen1("zzEXIT(zztasp%d);\n", BlkLevel);
505 if ( !GenCC ) gen("}\n");
506 tabs--;
507 gen("}\n");
508 }
509
510 static void
511 #ifdef __USE_PROTOS
512 BLOCK_Preamble( Junction *q )
513 #else
514 BLOCK_Preamble( q )
515 Junction *q;
516 #endif
517 {
518 ActionNode *a;
519 Junction *begin;
520
521 BLOCK_Head();
522 if ( GenCC ) genTokenPointers(q);
523 if ( GenCC&&GenAST ) genASTPointers(q);
524 if ( q->jtype == aPlusBlk ) gen("int zzcnt=1;\n");
525 if ( q->parm != NULL && !q->predparm ) gen1("zzaPush(%s);\n", q->parm)
526 else if ( !GenCC ) gen("zzMake0;\n");
527 if ( !GenCC ) gen("{\n");
528 if ( q->jtype == aLoopBegin ) begin = (Junction *) ((Junction *)q->p1);
529 else begin = q;
530 if ( has_guess_block_as_first_item(begin) )
531 {
532 gen("zzGUESS_BLOCK\n");
533 }
534 if ( q->jtype == aLoopBegin )
535 a = findImmedAction( ((Junction *)q->p1)->p1 ); /* look at aLoopBlk */
536 else
537 a = findImmedAction( q->p1 );
538 if ( a!=NULL && !a->is_predicate) {
539 /* MR21 */ if (!a->noHoist) dumpActionPlus(a, a->action, output, tabs, a->file, a->line, 1);
540 a->done = 1; /* remove action. We have already handled it */
541 }
542 }
543
544 void
545 #ifdef __USE_PROTOS
546 genCombinedPredTreeContextOrig( Predicate *p )
547 #else
548 genCombinedPredTreeContextOrig( p )
549 Predicate *p;
550 #endif
551 {
552 static set *ctx=NULL; /* genExprSets() is destructive, make copy*/
553 require(p!=NULL, "can't make context tree for NULL pred tree");
554
555 #ifdef DBG_PRED
556 fprintf(stderr, "enter genCombinedPredTreeContextOrig(%s,0x%x) with sets:\n", p->expr, p);
557 s_fprT(stderr, p->scontext[1]);
558 fprintf(stderr, "\n");
559 #endif
560 if ( p->down == NULL )
561 {
562 /*** if ( p->k>1 && p->tcontext!=NULL ) ***/
563 if ( p->tcontext!=NULL )
564 {
565 _gen("(");
566 genExprTree(p->tcontext, 1);
567 _gen(")");
568 }
569 /*** else if ( p->k==1 && set_deg(p->scontext[1])>0 ) ***/
570 else if ( set_deg(p->scontext[1])>0 )
571 {
572 if ( ctx==NULL ) ctx = (set *)calloc(CLL_k+1, sizeof(set));
573 require(ctx!=NULL, "ctx cannot allocate");
574 ctx[0]=empty;
575 ctx[1]=set_dup(p->scontext[1]);
576 _gen("(");
577 genExprSets(&(ctx[0]), p->k);
578 _gen(")");
579 set_free(ctx[1]);
580 }
581 else if ( p->expr==PRED_AND_LIST || p->expr==PRED_OR_LIST ) {
582 fatal_internal("pred tree is orphan OR or AND list");
583 }
584 else {
585 if (! HoistPredicateContext) {
586 _gen(" 1 /* no context: prc is off */ ");
587 } else {
588 fatal_internal("pred tree context is empty");
589 };
590 }
591 return;
592 }
593
594 /* MR10 - make AND just like OR */
595
596 if ( p->expr == PRED_AND_LIST )
597 {
598 Predicate *list = p->down;
599 for (; list!=NULL; list=list->right)
600 {
601 genCombinedPredTreeContextOrig(list);
602 if ( list->right!=NULL ) _gen("|| /* MR10 was wrong */ ");
603 };
604 return;
605 }
606
607 if ( p->expr == PRED_OR_LIST )
608 {
609 Predicate *list = p->down;
610 for (; list!=NULL; list=list->right)
611 {
612 genCombinedPredTreeContextOrig(list);
613 if ( list->right!=NULL ) _gen("||");
614 };
615 return;
616 };
617
618 fatal("pred tree is really wacked");
619 }
620
621 /* [genCombinedPredTreeContext] */
622
623 void
624 #ifdef __USE_PROTOS
625 genCombinedPredTreeContext( Predicate *p )
626 #else
627 genCombinedPredTreeContext( p )
628 Predicate *p;
629 #endif
630 {
631 Tree *t;
632 int predDepth=0;
633
634 if (0 && ! MR_usingPredNames && ! MRhoisting) {
635 genCombinedPredTreeContextOrig(p);
636 } else {
637 /* MR13 */ MR_pred_depth(p,&predDepth);
638 /* MR13 */ if (predDepth == 1) {
639 /* MR13 */
640 /* MR13 */ set scontext[2];
641 /* MR13 */ scontext[0]=empty;
642 /* MR13 */ scontext[1]=MR_compute_pred_set(p);
643 /* MR13 */ if (set_nil(scontext[1])) {
644 /* MR13 */ _gen(" 1 /* MR12 no context (-prc off) */ ");
645 /* MR13 */ } else {
646 /* MR13 */ _gen("(");
647 /* MR13 */ genExprSets(&scontext[0], 1);
648 /* MR13 */ set_free(scontext[1]);
649 /* MR13 */ _gen(")");
650 /* MR13 */ };
651
652 } else {
653 t=MR_compute_pred_tree_context(p);
654 if (t == NULL) {
655 _gen(" 1 /* MR12 no context (-prc off) */ ");
656 } else {
657 _gen("(");
658 genExprTree(t, 1);
659 Tfree(t); /* MR10 */
660 _gen(")");
661 };
662 };
663 };
664 }
665
666 /* [genPredTreeGate] */
667
668 void
669 #ifdef __USE_PROTOS
670 genPredTreeGate( Predicate *p, int in_and_expr )
671 #else
672 genPredTreeGate( p, in_and_expr )
673 Predicate *p;
674 int in_and_expr;
675 #endif
676 {
677 if ( in_and_expr )
678 {
679 _gen("!(");
680 genCombinedPredTreeContext(p);
681 _gen(")||");
682 if ( p->down!=NULL ) _gen("\n");
683 }
684 else
685 {
686 _gen("(");
687 genCombinedPredTreeContext(p);
688 _gen(")&&");
689 if ( p->down!=NULL ) _gen("\n");
690 }
691 }
692
693 #ifdef __USE_PROTOS
694 void genPredEntry(Predicate *p,int outer)
695 #else
696 void genPredEntry(p,outer)
697 Predicate *p;
698 int outer;
699 #endif
700 {
701 int inverted=0;
702 Predicate *q;
703 int localOuter=outer;
704 int needRP=0;
705
706 if (p == NULL) return;
707
708 if (p->predEntry != NULL && p->predEntry->predLiteral != NULL) {
709 if (p->inverted != p->predEntry->pred->inverted) {
710 _gen("! /* inverted pred */ (");
711 needRP=1;
712 } else {
713 if (!localOuter) _gen("(");
714 needRP=1;
715 };
716 dumpAction(p->predEntry->predLiteral,output,0,p->source->file,p->source->line,0);
717 if (needRP) _gen(")");
718 return;
719 };
720
721 inverted=p->inverted;
722
723 if (inverted) {
724 _gen(" ! /* inverted pred */ (");
725 localOuter=1;
726 };
727
728 if (p->expr == PRED_OR_LIST) {
729 if (!localOuter) _gen("(");
730 for (q=p->down; q != NULL ; q=q->right) {
731 genPredEntry(q,0);
732 if (q->right != NULL) _gen(" || ");
733 };
734 if (!localOuter) _gen(")");
735 } else if (p->expr == PRED_AND_LIST) {
736 if (!localOuter) _gen("(");
737 for (q=p->down; q != NULL ; q=q->right) {
738 genPredEntry(q,0);
739 if (q->right != NULL) _gen(" && ");
740 };
741 if (!localOuter) _gen(")");
742 } else {
743 if (!localOuter) _gen("(");
744 require (p->source != NULL,"predEntry->source == NULL");
745 require (p->source->inverted == 0,"dumpPredEntry p->source->inverted != 0");
746 dumpAction(p->source->action,output,0,p->source->file,p->source->line,0);
747 if (!localOuter) _gen(")");
748 };
749
750 if (inverted) {
751 _gen(")");
752 }
753 }
754
755 void
756 #ifdef __USE_PROTOS
757 dumpPredAction(ActionNode *anode,
758 char *s,FILE *output,int tabs,int file,int line,int final_newline)
759 #else
760 dumpPredAction(anode,
761 s,output,tabs,file,line,final_newline)
762
763 ActionNode *anode;
764 char *s;
765 FILE *output;
766 int tabs;
767 int file;
768 int line;
769 int final_newline;
770 #endif
771 {
772 PredEntry *predEntry=anode->predEntry;
773 int inverted=anode->inverted;
774 Predicate *workPred;
775
776 if (predEntry == NULL) {
777
778 /* inline predicate literal */
779
780 require(inverted == 0,"dumpPredAction action->inverted");
781 dumpAction(s,output,tabs,file,line,final_newline);
782
783 } else {
784
785 /* a reference to a predicate - possibly with an inverted source */
786
787 if (predEntry->predLiteral != NULL) {
788 if (inverted) _gen("! /* inverted pred */ (");
789 dumpAction(predEntry->predLiteral,output,0,anode->file,anode->line,0);
790 if (inverted) _gen(")");
791 } else {
792 workPred=predicate_dup(predEntry->pred);
793 if (inverted) workPred->inverted=!workPred->inverted;
794 genPredEntry(workPred,1);
795 predicate_free(workPred);
796 };
797 };
798 }
799
800 /* [genPred] */
801
802 void
803 #ifdef __USE_PROTOS
804 genPred(Predicate *p, Node *j,int suppress_sva)
805 #else
806 genPred(p,j,suppress_sva)
807 Predicate *p;
808 Node *j;
809 int suppress_sva;
810 #endif
811 {
812 if ( FoundException && !suppress_sva) {_gen("(_sva=(");} /* MR11 suppress_sva */
813 else {_gen("(");}
814 if ( GenLineInfo && j->file != -1 ) _gen("\n");
815 if (p->source != NULL && p->source->ampersandPred != NULL) {
816 if (p->source->ampersandPred->k == 1) {
817
818 set ctx[2];
819
820 ctx[0]=empty;
821 ctx[1]=set_dup(p->source->ampersandPred->scontext[1]);
822
823 _gen("(");
824 genExprSets(&(ctx[0]), p->k);
825 _gen(") && ");
826 set_free(ctx[1]);
827 } else {
828 _gen("( ");
829 genExprTree(p->source->ampersandPred->tcontext,1);
830 _gen(" ) && ");
831 };
832 };
833
834 dumpPredAction((ActionNode *)p->source,
835 p->expr, output, 0, -1 /*indicates no line info*/, j->line, 0);
836
837 if ( FoundException && !suppress_sva) /* MR11 suppress_sva */
838 {_gen("),_sva)");} /* MR10 - get red of "meant ==" messages */
839 else {_gen(")");}
840 }
841
842 void
843 #ifdef __USE_PROTOS
844 MR_distinctORcontextOpt(Predicate *p,Node *j,int in_and_expr)
845 #else
846 MR_distinctORcontextOpt(p,j,in_and_expr)
847 Predicate *p;
848 Node *j;
849 int in_and_expr;
850 #endif
851 {
852 Predicate *q;
853
854 _gen(" /* MR10 Distinct OR context optimization */ \n");
855
856 if (in_and_expr) {
857 gen("zzpf=0,\n");
858 for (q=p->down; q != NULL; q=q->right) {
859 gen("( ");
860 genCombinedPredTreeContext(q);
861 _gen(" && (zzpf=1, ");
862 genPred(q,j,0);
863 _gen(" )) ||\n");
864 };
865 gen("!zzpf)");
866 } else {
867 require (0,
868 "MR_distinctORcontextOpt: can't get here when using MR_predSimplify");
869 #if 0
870 ** for (q=p->down; q != NULL; q=q->right) {
871 ** gen("( ");
872 ** genCombinedPredTreeContext(q);
873 ** _gen(" && ");
874 ** genPred(q,j);
875 ** if (q->right != NULL) {
876 ** _gen(" ) ||\n");
877 ** };
878 ** };
879 ** gen(")");
880 #endif
881 };
882 }
883
884 void
885 #ifdef __USE_PROTOS
886 genPredTreeOrig( Predicate *p, Node *j, int in_and_expr )
887 #else
888 genPredTreeOrig( p, j, in_and_expr )
889 Predicate *p;
890 Node *j;
891 int in_and_expr;
892 #endif
893 {
894
895 /* MR10 */ int allHaveContext=1;
896 /* MR10 */ int noneHaveContext=1;
897
898 /* MR10 */ MR_predContextPresent(p,&allHaveContext,&noneHaveContext);
899
900 if ( ! noneHaveContext ) /* MR10 context guards ignored when -prc off */
901 {
902 _gen("(");
903 genPredTreeGate(p, in_and_expr);
904 }
905
906 /* if leaf node, just gen predicate */
907
908 if ( p->down==NULL )
909 {
910 genPred(p,j,0);
911 if ( ! noneHaveContext ) _gen(")"); /* MR10 context guards ignored when -prc off */
912 return;
913 }
914
915 /* if AND list, do both preds (only two possible) */
916 if ( p->expr == PRED_AND_LIST )
917 {
918 #if 0
919 ** _gen("(");
920 ** genPredTreeOrig(p->down, j, 1);
921 ** _gen("&&");
922 ** genPredTreeOrig(p->down->right, j, 1);
923 ** _gen(")");
924 ** if ( ! noneHaveContext ) _gen(")"); /* MR10 context guards ignored when -prc off */
925 ** return;
926 #endif
927 /* MR11 - make it work with AND with more than two children - like OR */
928
929 Predicate *list;
930 _gen("(");
931 list = p->down;
932 for (; list!=NULL; list=list->right)
933 {
934 genPredTreeOrig(list, j, 1);
935 if ( list->right!=NULL ) _gen("&&");
936 }
937 _gen(")");
938 if ( ! noneHaveContext ) _gen(")"); /* MR10 context guards ignored when -prc off */
939 return;
940 };
941
942 if ( p->expr == PRED_OR_LIST )
943 {
944 Predicate *list;
945 _gen("(");
946 list = p->down;
947 for (; list!=NULL; list=list->right)
948 {
949 genPredTreeOrig(list, j, 0);
950 if ( list->right!=NULL ) _gen("||");
951 }
952 _gen(")");
953 if ( ! noneHaveContext ) _gen(")"); /* MR10 context guards ignored when -prc off */
954 return;
955 }
956
957 fatal_internal("genPredTreeOrig: predicate tree is wacked");
958 }
959
960 #if 0
961 ** Predicate member dummyPredDepth is no longer used in MR10
962 ** but we might need it again in the future
963 **
964 ** if (MRhoisting) {
965 ** if ( !noneHaveContext &&
966 ** ! in_and_expr &&
967 ** p->source != NULL &&
968 ** p->source->dummyPredicateDepth > 0 &&
969 ** p->down == NULL) {
970 ** _gen("(");
971 ** genCombinedPredTreeContext(p);
972 ** _gen(" )\n");
973 ** return;
974 ** };
975 ** };
976 #endif
977
978 /* [genPredTree] */
979
980 /* in_and_expr
981
982 what to do if the context is wrong
983 what to do if the context is correct but the predicate is false
984
985 remember: if the context is wrong it's the same as if the
986 predicate is true as far as enabling an alternative
987
988 Consider (AND p q r)
989
990 if in an ... && ... expression then you don't want
991 the entire predicate chain to fail just because the
992 context for one component is wrong: so return true
993
994 Consider (OR p q r)
995
996 if in an ... || ... expression then you don't want
997 the entire predicate chain to succeed just because
998 the context for one component is correct when the
999 corresponding test is false: so return false when
1000 the context is correct but the test is false.
1001 */
1002
1003 void
1004 #ifdef __USE_PROTOS
1005 genPredTree( Predicate *p, Node *j, int in_and_expr, int suppress_sva )
1006 #else
1007 genPredTree( p, j, in_and_expr, suppress_sva)
1008 Predicate *p;
1009 Node *j;
1010 int in_and_expr;
1011 int suppress_sva;
1012 #endif
1013 {
1014
1015 int allHaveContext=1;
1016 int noneHaveContext=1;
1017 Tree *groupTree;
1018 Tree *oneTree;
1019 Predicate *q;
1020 int identicalORcontextOptimization=0;
1021 int identicalANDcontextOptimization=0;
1022
1023 if (0 && !MR_usingPredNames && !MRhoisting) {
1024 genPredTreeOrig(p,j,in_and_expr);
1025 return;
1026 };
1027
1028 MR_predContextPresent(p,&allHaveContext,&noneHaveContext);
1029
1030 if ( ! noneHaveContext ) { /* MR10 context guards ignored when -prc off */
1031
1032 _gen("(");
1033
1034 /* MR10 optimize OR predicates which are all leaves */
1035
1036 if (p->expr == PRED_OR_LIST && MR_allPredLeaves(p->down)) {
1037 groupTree=MR_compute_pred_tree_context(p);
1038 for (q=p->down ; q != NULL ; q=q->right) {
1039 oneTree=MR_compute_pred_tree_context(q);
1040 if (! MR_tree_equ(groupTree,oneTree)) {
1041 Tfree(oneTree);
1042 break;
1043 };
1044 Tfree(oneTree);
1045 };
1046 Tfree(groupTree);
1047 if (q == NULL) {
1048 _gen("/* MR10 individual OR gates suppressed when all predicates are leaves");
1049 _gen(" with identical context */\n");
1050 genPredTreeGate(p,in_and_expr); /* use the parent's in_and_expr for this gate */
1051 identicalORcontextOptimization=1;
1052 } else {
1053 MR_distinctORcontextOpt(p,j,in_and_expr);
1054 return;
1055 };
1056 } else if (p->expr == PRED_AND_LIST && MR_allPredLeaves(p->down)) {
1057
1058 /* MR12 optimize AND predicates which are all leaves */
1059
1060 groupTree=MR_compute_pred_tree_context(p);
1061 for (q=p->down ; q != NULL ; q=q->right) {
1062 oneTree=MR_compute_pred_tree_context(q);
1063 if (! MR_tree_equ(groupTree,oneTree)) {
1064 Tfree(oneTree);
1065 break;
1066 };
1067 Tfree(oneTree);
1068 };
1069 Tfree(groupTree);
1070 if (q == NULL) {
1071 _gen("/* MR12 individual AND gates suppressed when all predicates are leaves");
1072 _gen(" with identical context */\n");
1073 genPredTreeGate(p,in_and_expr); /* use the parent's in_and_expr for this gate */
1074 identicalANDcontextOptimization=1;
1075 } else {
1076 genPredTreeGate(p, in_and_expr);
1077 };
1078 } else {
1079 genPredTreeGate(p, in_and_expr);
1080 };
1081 }
1082
1083 /* if leaf node, just gen predicate */
1084
1085 if ( p->down==NULL )
1086 {
1087 genPred(p,j,suppress_sva);
1088 if ( ! noneHaveContext ) _gen(")"); /* MR10 context guards ignored when -prc off */
1089 return;
1090 }
1091
1092 /* if AND list, do both preds (only two possible) */
1093 /* MR10 not any more ! */
1094
1095 if ( p->expr == PRED_AND_LIST )
1096 {
1097 Predicate *list;
1098 _gen("(");
1099 list = p->down;
1100 for (; list != NULL; list=list->right) {
1101 if (identicalANDcontextOptimization) {
1102 genPred(list, j,suppress_sva);
1103 } else {
1104 genPredTree(list, j, 1, suppress_sva); /* in and context */
1105 };
1106 if ( list->right!=NULL ) _gen("&&");
1107 };
1108 _gen(")");
1109 if ( ! noneHaveContext ) _gen(")"); /* MR10 context guards ignored when -prc off */
1110 return;
1111 }
1112
1113 if ( p->expr == PRED_OR_LIST )
1114 {
1115 Predicate *list;
1116 _gen("(");
1117 list = p->down;
1118 for (; list!=NULL; list=list->right)
1119 {
1120 if (identicalORcontextOptimization) {
1121 genPred(list, j,suppress_sva);
1122 } else {
1123 genPredTree(list, j, 0, suppress_sva);
1124 };
1125 if ( list->right!=NULL ) _gen("||");
1126 }
1127 _gen(")");
1128 if ( ! noneHaveContext ) _gen(")"); /* MR10 context guards ignored when -prc off */
1129 return;
1130 }
1131
1132 fatal_internal("predicate tree is wacked");
1133 }
1134
1135 /* [genPredTreeMainXX] */
1136
1137 Predicate * /* MR10 */
1138 #ifdef __USE_PROTOS
1139 genPredTreeMainXX( Predicate *p, Node *j ,int in_and_expr)
1140 #else
1141 genPredTreeMainXX( p, j ,in_and_expr)
1142 Predicate *p;
1143 Node *j;
1144 int in_and_expr;
1145 #endif
1146 {
1147
1148 int allHaveContext=1;
1149 int noneHaveContext=1;
1150
1151 #if 0
1152 fprintf(stderr,"Pred before\n");
1153 dumppred(p);
1154 fprintf(stderr,"\n");
1155 fprintf(stderr,"Pred after\n");
1156 dumppred(p);
1157 fprintf(stderr,"\n");
1158 #endif
1159
1160 p=MR_predSimplifyALL(p); /* MR10 */
1161
1162 require (MR_predicate_context_completed(p),"predicate context is not complete");
1163
1164 MR_cleanup_pred_trees(p); /* MR10 */
1165
1166 MR_predContextPresent(p,&allHaveContext,&noneHaveContext);
1167 if (!noneHaveContext & !allHaveContext) {
1168 warnFL("predicate contains elements both with and without context",
1169 FileStr[j->file],j->line);
1170 };
1171
1172 if (InfoP) {
1173 _gen("\n#if 0\n\n");
1174 MR_dumpPred(p,1);
1175 _gen("#endif\n");
1176 };
1177 genPredTree(p,j,in_and_expr,0);
1178 return p;
1179 }
1180
1181 Predicate * /* MR10 */
1182 #ifdef __USE_PROTOS
1183 genPredTreeMain( Predicate *p, Node *j)
1184 #else
1185 genPredTreeMain( p, j)
1186 Predicate *p;
1187 Node *j;
1188 #endif
1189 {
1190 return genPredTreeMainXX(p,j,1);
1191 }
1192
1193 static void
1194 #ifdef __USE_PROTOS
1195 genExprTreeOriginal( Tree *t, int k )
1196 #else
1197 genExprTreeOriginal( t, k )
1198 Tree *t;
1199 int k;
1200 #endif
1201 {
1202 require(t!=NULL, "genExprTreeOriginal: NULL tree");
1203
1204 if ( t->token == ALT )
1205 {
1206 _gen("("); genExprTreeOriginal(t->down, k); _gen(")");
1207 if ( t->right!=NULL )
1208 {
1209 _gen("||");
1210 on1line++;
1211 if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }
1212 _gen("("); genExprTreeOriginal(t->right, k); _gen(")");
1213 }
1214 return;
1215 }
1216 if ( t->down!=NULL ) _gen("(");
1217 _gen1("LA(%d)==",k);
1218 if ( TokenString(t->token) == NULL ) _gen1("%d", t->token)
1219 else _gen1("%s", TokenString(t->token));
1220 if ( t->down!=NULL )
1221 {
1222 _gen("&&");
1223 on1line++;
1224 if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }
1225 _gen("("); genExprTreeOriginal(t->down, k+1); _gen(")");
1226 }
1227 if ( t->down!=NULL ) _gen(")");
1228 if ( t->right!=NULL )
1229 {
1230 _gen("||");
1231 on1line++;
1232 if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }
1233 _gen("("); genExprTreeOriginal(t->right, k); _gen(")");
1234 }
1235 }
1236
1237 #ifdef __USE_PROTOS
1238 static void MR_LAtokenString(int k,int token)
1239 #else
1240 static void MR_LAtokenString(k,token)
1241 int k;
1242 int token;
1243 #endif
1244 {
1245 char *ts;
1246
1247 ts=TokenString(token);
1248 if (ts == NULL) {
1249 _gen2(" LA(%d)==%d",k,token);
1250 } else {
1251 _gen2(" LA(%d)==%s",k,ts);
1252 };
1253 }
1254
1255
1256 #ifdef __USE_PROTOS
1257 static int MR_countLeaves(Tree *t)
1258 #else
1259 static int MR_countLeaves(t)
1260 Tree *t;
1261 #endif
1262 {
1263 if (t == NULL) return 0;
1264 if (t->token == ALT) {
1265 return MR_countLeaves(t->down)+MR_countLeaves(t->right);
1266 } else {
1267 return 1+MR_countLeaves(t->down)+MR_countLeaves(t->right);
1268 };
1269 }
1270
1271 #ifdef __USE_PROTOS
1272 static void MR_genOneLine(Tree *tree,int k)
1273 #else
1274 static void MR_genOneLine(tree,k)
1275 Tree *tree;
1276 int k;
1277 #endif
1278 {
1279 if (tree == NULL) return;
1280 if (tree->token == ALT) {
1281 MR_genOneLine(tree->down,k);
1282 } else {
1283 MR_LAtokenString(k,tree->token);
1284 if (tree->down != NULL &&
1285 tree->down->right == NULL) {
1286 _gen(" &&");
1287 MR_genOneLine(tree->down,k+1);
1288 } else if (tree->down != NULL) {
1289 _gen(" && (");
1290 MR_genOneLine(tree->down,k+1);
1291 _gen(")");
1292 };
1293 };
1294 if (tree->right != NULL) {
1295 _gen(" ||");
1296 MR_genOneLine(tree->right,k);
1297 };
1298 }
1299
1300 static int across;
1301 static int depth;
1302 static int lastkonline;
1303
1304 #ifdef __USE_PROTOS
1305 static void MR_genMultiLine(Tree *tree,int k)
1306 #else
1307 static void MR_genMultiLine(tree,k)
1308 Tree *tree;
1309 int k;
1310 #endif
1311 {
1312 int i;
1313
1314 if (tree == NULL) return;
1315 if (tree->token == ALT) {
1316 MR_genMultiLine(tree,k);
1317 } else {
1318 MR_LAtokenString(k,tree->token);
1319 lastkonline=k;
1320 across++;
1321 if (tree->down != NULL && tree->down->right == NULL) {
1322 if (across > 3) {
1323 _gen("\n");
1324 across=0;
1325 lastkonline=0;
1326 for (i=0 ; i < depth+k ; i++) _gen(" ");
1327 _gen("&&");
1328 } else {
1329 _gen(" &&");
1330 };
1331 MR_genMultiLine(tree->down,k+1);
1332 } else if (tree->down != NULL) {
1333 _gen("\n");
1334 lastkonline=0;
1335 across=0;
1336 for (i=0 ; i < depth+k ; i++) _gen(" ");
1337 _gen("&& (");
1338 MR_genMultiLine(tree->down,k+1);
1339 _gen(")");
1340 };
1341 };
1342 if (tree->right != NULL) {
1343 if (k < lastkonline) {
1344 _gen("\n");
1345 across=0;
1346 lastkonline=0;
1347 for (i=0; i < depth+k-1 ; i++) _gen(" ");
1348 _gen("||");
1349 } else if (across > 3 ) {
1350 _gen("\n");
1351 across=0;
1352 lastkonline=0;
1353 for (i=0; i < depth+k ; i++) _gen(" ");
1354 _gen("||");
1355 } else {
1356 _gen(" ||");
1357 };
1358 MR_genMultiLine(tree->right,k);
1359 };
1360 }
1361
1362 #ifdef __USE_PROTOS
1363 static void genExprTree(Tree *tree,int k)
1364 #else
1365 static void genExprTree(tree,k)
1366 Tree *tree;
1367 int k;
1368 #endif
1369 {
1370 int count;
1371
1372 #if 0
1373 /* MR20 THM This was probably an error.
1374 The routine should probably reference that static
1375 "across" and this declaration hides it.
1376 */
1377
1378 int across;
1379 #endif
1380
1381 require (tree != NULL,"genExprTree: tree is NULL");
1382 require (k > 0,"genExprTree: k <= 0");
1383
1384 if (0 && !MRhoisting) { /* MR11 make new version standard */
1385 genExprTreeOriginal(tree,k);
1386 } else {
1387 count=MR_countLeaves(tree);
1388 if (count < 5) {
1389 MR_genOneLine(tree,k);
1390 } else {
1391 _gen("\n");
1392 across=0;
1393 depth=0;
1394 lastkonline=0;
1395 MR_genMultiLine(tree,k);
1396 _gen("\n");
1397 };
1398 };
1399 }
1400
1401
1402 /*
1403 * Generate LL(k) type expressions of the form:
1404 *
1405 * (LA(1) == T1 || LA(1) == T2 || ... || LA(1) == Tn) &&
1406 * (LA(2) == T1 || LA(2) == T2 || ... || LA(2) == Tn) &&
1407 * .....
1408 * (LA(k) == T1 || LA(k) == T2 || ... || LA(k) == Tn)
1409 *
1410 * If GenExprSetsOpt generate:
1411 *
1412 * (setwdi[LA(1)]&(1<<j)) && (setwdi[LA(2)]&(1<<j)) ...
1413 *
1414 * where n is set_deg(expr) and Ti is some random token and k is the last nonempty
1415 * set in fset <=CLL_k.
1416 * k=1..CLL_k where CLL_k >= 1.
1417 *
1418 * This routine is visible only to this file and cannot answer a TRANS message.
1419 *
1420 */
1421
1422 /* [genExpr] */
1423
1424 static int
1425 #ifdef __USE_PROTOS
1426 genExpr( Junction *j )
1427 #else
1428 genExpr( j )
1429 Junction *j;
1430 #endif
1431 {
1432 int max_k;
1433
1434 /* if full LL(k) is sufficient, then don't use approximate (-ck) lookahead
1435 * from CLL_k..LL_k
1436 */
1437 {
1438 int limit;
1439 if ( j->ftree!=NULL ) limit = LL_k;
1440 else limit = CLL_k;
1441 max_k = genExprSets(j->fset, limit);
1442 }
1443
1444 /* Do tests for real tuples from other productions that conflict with
1445 * artificial tuples generated by compression (using sets of tokens
1446 * rather than k-trees).
1447 */
1448 if ( j->ftree != NULL )
1449 {
1450 _gen(" && !("); genExprTree(j->ftree, 1); _gen(")");
1451 }
1452
1453 if ( ParseWithPredicates && j->predicate!=NULL )
1454 {
1455 Predicate *p = j->predicate;
1456 warn_about_using_gk_option();
1457 _gen("&&");
1458 j->predicate=genPredTreeMain(p, (Node *)j); /* MR10 */
1459 }
1460
1461 return max_k;
1462 }
1463
1464 static int
1465 #ifdef __USE_PROTOS
1466 genExprSets( set *fset, int limit )
1467 #else
1468 genExprSets( fset, limit )
1469 set *fset;
1470 int limit;
1471 #endif
1472 {
1473 int k = 1;
1474 int max_k = 0;
1475 unsigned *e, *g, firstTime=1;
1476
1477 if (set_nil(fset[1])) {
1478 _gen(" 0 /* MR13 empty set expression - undefined rule ? infinite left recursion ? */ ");
1479 MR_BadExprSets++;
1480 };
1481
1482 if ( GenExprSetsOpt )
1483 {
1484 while ( k <= limit && !set_nil(fset[k]) ) /* MR11 */
1485 {
1486 if ( set_deg(fset[k])==1 ) /* too simple for a set? */
1487 {
1488 int e;
1489 _gen1("(LA(%d)==",k);
1490 e = set_int(fset[k]);
1491 if ( TokenString(e) == NULL ) _gen1("%d)", e)
1492 else _gen1("%s)", TokenString(e));
1493 }
1494 else
1495 {
1496 NewSet();
1497 FillSet( fset[k] );
1498 _gen3("(setwd%d[LA(%d)]&0x%x)", wordnum, k, 1<<setnum);
1499 }
1500 if ( k>max_k ) max_k = k;
1501 if ( k == CLL_k ) break;
1502 k++;
1503 if ( k<=limit && !set_nil(fset[k]) ) _gen(" && "); /* MR11 */
1504 on1line++;
1505 if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }
1506 }
1507 return max_k;
1508 }
1509
1510 while ( k<= limit && !set_nil(fset[k]) ) /* MR11 */
1511 {
1512 if ( (e=g=set_pdq(fset[k])) == NULL ) fatal_internal("genExpr: cannot allocate IF expr pdq set");
1513 for (; *e!=nil; e++)
1514 {
1515 if ( !firstTime ) _gen(" || ") else { _gen("("); firstTime = 0; }
1516 on1line++;
1517 if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }
1518 _gen1("LA(%d)==",k);
1519 if ( TokenString(*e) == NULL ) _gen1("%d", *e)
1520 else _gen1("%s", TokenString(*e));
1521 }
1522 free( (char *)g );
1523 _gen(")");
1524 if ( k>max_k ) max_k = k;
1525 if ( k == CLL_k ) break;
1526 k++;
1527 if ( k <= limit && !set_nil(fset[k]) ) { firstTime=1; _gen(" && "); } /* MR11 */
1528 on1line++;
1529 if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }
1530 }
1531 return max_k;
1532 }
1533
1534 /*
1535 * Generate code for any type of block. If the last alternative in the block is
1536 * empty (not even an action) don't bother doing it. This permits us to handle
1537 * optional and loop blocks as well.
1538 *
1539 * Only do this block, return after completing the block.
1540 * This routine is visible only to this file and cannot answer a TRANS message.
1541 */
1542 static set
1543 #ifdef __USE_PROTOS
1544 genBlk( Junction *q, int jtype, int *max_k, int *need_right_curly, int * lastAltEmpty /* MR23 */)
1545 #else
1546 genBlk( q, jtype, max_k, need_right_curly, lastAltEmpty /* MR23 */)
1547 Junction *q;
1548 int jtype;
1549 int *max_k;
1550 int *need_right_curly;
1551 int *lastAltEmpty; /* MR23 */
1552 #endif
1553 {
1554 set f;
1555 Junction *alt;
1556 int a_guess_in_block = 0;
1557 require(q!=NULL, "genBlk: invalid node");
1558 require(q->ntype == nJunction, "genBlk: not junction");
1559 *need_right_curly=0;
1560 *lastAltEmpty = 0; /* MR23 */
1561 if ( q->p2 == NULL ) /* only one alternative? Then don't need if */
1562 {
1563 if (first_item_is_guess_block((Junction *)q->p1)!=NULL )
1564 {
1565 if (jtype != aLoopBlk && jtype != aOptBlk && jtype != aPlusBlk) {
1566 warnFL("(...)? as only alternative of block is unnecessary", FileStr[q->file], q->line);
1567 };
1568 gen("zzGUESS\n"); /* guess anyway to make output code consistent */
1569 /* MR10 disable */ /**** gen("if ( !zzrv )\n"); ****/
1570 /* MR10 */ gen("if ( !zzrv ) {\n"); tabs++; (*need_right_curly)++;
1571 };
1572 TRANS(q->p1);
1573 return empty; /* no decision to be made-->no error set */
1574 }
1575
1576 f = First(q, 1, jtype, max_k);
1577 for (alt=q; alt != NULL; alt= (Junction *) alt->p2 )
1578 {
1579 if ( alt->p2 == NULL ) /* chk for empty alt */
1580 {
1581 Node *p = alt->p1;
1582 if ( p->ntype == nJunction )
1583 {
1584 /* we have empty alt */
1585 /* MR23
1586 There is a conflict between giving good error information for non-exceptions
1587 and making life easy for those using parser exception handling. Consider:
1588
1589 r: { A } b;
1590 b: B;
1591
1592 with input "C"
1593
1594 Before MR21 the error message would be "expecting B - found C". After MR21
1595 the error message would be "expcect A, B - found C". This was good, but it
1596 caused problems for those using parser exceptions because the reference to
1597 B was generated inside the {...} where B really wasn't part of the block.
1598
1599 In MR23 this has been changed for the case where exceptions are in use to
1600 not generate the extra check in the tail of the {A} block.
1601 */
1602
1603
1604 /* MR23 */ if (isEmptyAlt( ((Junction *)p)->p1, (Node *)q->end)) {
1605 /* MR23 */ *lastAltEmpty = 1;
1606 /* MR23 */ if (FoundException) {
1607 /* MR23 */ /* code to restore state if a prev alt didn't follow guess */
1608 /* MR23 */ if ( a_guess_in_block && jtype != aPlusBlk) {
1609 /* MR23 */ gen("if ( !zzrv ) zzGUESS_DONE; /* MR28 */\n");
1610 /* MR23 */ }
1611 /* MR23 */ break;
1612 /* MR23 */ };
1613 /* MR28 */ if (jtype == aPlusBlk) {
1614 /* MR28 */ break;
1615 /* MR28 */ }
1616 /* MR23 */ }
1617 }
1618 } /* end of for loop on alt */
1619
1620 /* MR10 */ if (alt->p2 == NULL &&
1621 /* MR10 */ ( q->jtype == aSubBlk || q->jtype == RuleBlk) ) {
1622 /* MR10 */ if (first_item_is_guess_block(alt)) {
1623 /* MR10 */ warnFL("(...)? as last alternative of block is unnecessary",
1624 /* MR10 */ FileStr[alt->file],alt->line);
1625 /* MR10 */ };
1626 /* MR10 */ };
1627
1628 if ( alt != q ) gen("else ")
1629 else
1630 {
1631 if ( DemandLookahead ) {
1632 if ( !GenCC ) {gen1("LOOK(%d);\n", *max_k);}
1633 else gen1("look(%d);\n", *max_k);
1634 }
1635 }
1636
1637 if ( alt!=q )
1638 {
1639 _gen("{\n");
1640 tabs++;
1641 (*need_right_curly)++;
1642 /* code to restore state if a prev alt didn't follow guess */
1643 if ( a_guess_in_block )
1644 gen("if ( !zzrv ) zzGUESS_DONE;\n");
1645 }
1646 if ( first_item_is_guess_block((Junction *)alt->p1)!=NULL )
1647 {
1648 a_guess_in_block = 1;
1649 gen("zzGUESS\n");
1650 }
1651 gen("if ( ");
1652 if ( first_item_is_guess_block((Junction *)alt->p1)!=NULL ) _gen("!zzrv && ");
1653 genExpr(alt);
1654 _gen(" ) ");
1655 _gen("{\n");
1656 tabs++;
1657 TRANS(alt->p1);
1658 --tabs;
1659 gen("}\n");
1660 /* MR10 */ if (alt->p2 == NULL) {
1661 /* MR10 */ if (first_item_is_guess_block(alt)) {
1662 /* MR10 */ gen("/* MR10 */ else {\n");
1663 /* MR10 */ tabs++;
1664 /* MR10 */ (*need_right_curly)++;
1665 /* MR10 */ /* code to restore state if a prev alt didn't follow guess */
1666 /* MR10 */ gen("/* MR10 */ if ( !zzrv ) zzGUESS_DONE;\n");
1667 /* MR10 */ gen("/* MR10 */ if (0) {} /* last alternative of block is guess block */\n");
1668 /* MR10 */ };
1669 /* MR10 */ };
1670 }
1671 return f;
1672 }
1673
1674 static int
1675 #ifdef __USE_PROTOS
1676 has_guess_block_as_first_item( Junction *q )
1677 #else
1678 has_guess_block_as_first_item( q )
1679 Junction *q;
1680 #endif
1681 {
1682 Junction *alt;
1683
1684 for (alt=q; alt != NULL; alt= (Junction *) alt->p2 )
1685 {
1686 if ( first_item_is_guess_block((Junction *)alt->p1)!=NULL ) return 1;
1687 }
1688 return 0;
1689 }
1690
1691 static int
1692 #ifdef __USE_PROTOS
1693 has_guess_block_as_last_item( Junction *q )
1694 #else
1695 has_guess_block_as_last_item( q )
1696 Junction *q;
1697 #endif
1698 {
1699 Junction *alt;
1700
1701 if (q == NULL) return 0;
1702 for (alt=q; alt->p2 != NULL && !( (Junction *) alt->p2)->ignore; alt= (Junction *) alt->p2 ) {};
1703 return first_item_is_guess_block( (Junction *) alt->p1) != NULL;
1704 }
1705
1706 /* MR30 See description of first_item_is_guess_block for background */
1707
1708 Junction *
1709 #ifdef __USE_PROTOS
1710 first_item_is_guess_block_extra(Junction *q )
1711 #else
1712 first_item_is_guess_block_extra(q)
1713 Junction *q;
1714 #endif
1715 {
1716 while ( q!=NULL &&
1717 ( ( q->ntype==nAction ) ||
1718 ( q->ntype==nJunction &&
1719 (q->jtype==Generic || q->jtype == aLoopBlk)
1720 )
1721 )
1722 )
1723 {
1724 if ( q->ntype==nJunction ) q = (Junction *)q->p1;
1725 else q = (Junction *) ((ActionNode *)q)->next;
1726 }
1727
1728 if ( q==NULL ) return NULL;
1729 if ( q->ntype!=nJunction ) return NULL;
1730 if ( q->jtype!=aSubBlk ) return NULL;
1731 if ( !q->guess ) return NULL;
1732
1733 return q;
1734 }
1735
1736 /* return NULL if 1st item of alt is NOT (...)? block; else return ptr to aSubBlk node
1737 * of (...)?; This function ignores actions and predicates.
1738 */
1739
1740 Junction *
1741 #ifdef __USE_PROTOS
1742 first_item_is_guess_block( Junction *q )
1743 #else
1744 first_item_is_guess_block( q )
1745 Junction *q;
1746 #endif
1747 {
1748 Junction * qOriginal = q; /* DEBUG */
1749
1750 /* MR14 Couldn't find aSubBlock which was a guess block when it lay
1751 behind aLoopBlk. The aLoopBlk only appear in conjunction with
1752 aLoopBegin, but the routine didn't know that. I think.
1753
1754 MR14a Added extra parentheses to clarify precedence
1755
1756 MR30 This appears to have been a mistake. The First set was then
1757 computed incorrectly for:
1758
1759 r : ( (A)? B
1760 | C
1761 )*
1762
1763 The routine analysis_point was seeing the guess block when
1764 it was still analyzing the loopBegin block. As a consequence,
1765 when it looked for the analysis_point it was processing the B, but
1766 skipping over the C alternative altogether because it thought
1767 it was looking at a guess block, not realizing there was a loop
1768 block in front of the loopBegin.
1769
1770 loopBegin loopBlk subBlk/guess A G EB G B EB EB EB ER
1771 | | | ^ ^
1772 | | | |
1773 | +-> G C G ----------------------+ |
1774 | |
1775 +--- G G G -------------------------------------+
1776
1777 Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu).
1778
1779 MR30 This is still more complicated. This fix caused ambiguity messages
1780 to be reported for "( (A B)? )* A B" but not for "( (A B)? )+". Why is
1781 there a difference when these are outwardly identical ? It is because the
1782 start of a (...)* block is represented by two nodes: a loopBegin block
1783 followed by a loopBlock whereas the start of a (...)+ block is
1784 represented as a single node: a plusBlock. So if first_item_is_guess_block
1785 is called when the current node is a loopBegin it starts with the
1786 loop block rather than the the sub block which follows the loop block.
1787 However, we can't just skip past the loop block because some routines
1788 depend on the old implementation. So, we provide a new implementation
1789 which does skip the loopBlock. However, which should be called when ?
1790 I'm not sure, but my guess is that first_item_is_guess_block_extra (the
1791 new one) should only be called for the ambiguity routines.
1792
1793 */
1794
1795 while ( q!=NULL &&
1796 ( ( q->ntype==nAction ) ||
1797 ( q->ntype==nJunction &&
1798 (q->jtype==Generic /*** || q->jtype == aLoopBlk ***/ ) /*** MR30 Undo MR14 change ***/
1799 )
1800 )
1801 )
1802 {
1803 if ( q->ntype==nJunction ) q = (Junction *)q->p1;
1804 else q = (Junction *) ((ActionNode *)q)->next;
1805 }
1806
1807 if ( q==NULL ) return NULL;
1808 if ( q->ntype!=nJunction ) return NULL;
1809 if ( q->jtype!=aSubBlk ) return NULL;
1810 if ( !q->guess ) return NULL;
1811
1812 return q;
1813 }
1814
1815 /* MR1 */
1816 /* MR1 10-Apr-97 MR1 Routine to stringize failed semantic predicates msgs */
1817 /* MR1 */
1818
1819 #define STRINGIZEBUFSIZE 1024
1820
1821 static char stringizeBuf[STRINGIZEBUFSIZE];
1822 char *
1823 #ifdef __USE_PROTOS
1824 stringize(char * s)
1825 #else
1826 stringize(s)
1827 char *s;
1828 #endif
1829
1830 {
1831 char *p;
1832 char *stop;
1833
1834 p=stringizeBuf;
1835 stop=&stringizeBuf[1015];
1836
1837 if (s != 0) {
1838 while (*s != 0) {
1839 if (p >= stop) {
1840 goto stringizeStop;
1841 } else if (*s == '\n') {
1842 *p++='\\';
1843 *p++='n';
1844 *p++='\\';
1845 *p++=*s++;
1846 } else if (*s == '\\') {
1847 *p++=*s;
1848 *p++=*s++;
1849 } else if (*s == '\"') {
1850 *p++='\\';
1851 *p++=*s++;
1852 while (*s != 0) {
1853 if (p >= stop) {
1854 goto stringizeStop;
1855 } else if (*s == '\n') {
1856 *p++='\\';
1857 *p++=*s++;
1858 } else if (*s == '\\') {
1859 *p++=*s++;
1860 *p++=*s++;
1861 } else if (*s == '\"') {
1862 *p++='\\';
1863 *p++=*s++;
1864 break;
1865 } else {
1866 *p++=*s++;
1867 };
1868 };
1869 } else if (*s == '\'') {
1870 *p++=*s++;
1871 while (*s != 0) {
1872 if (p >= stop) {
1873 goto stringizeStop;
1874 } else if (*s == '\'') {
1875 *p++=*s++;
1876 break;
1877 } else if (*s == '\\') {
1878 *p++=*s++;
1879 *p++=*s++;
1880 } else if (*s == '\"') {
1881 *p++='\\';
1882 *p++=*s++;
1883 break;
1884 } else {
1885 *p++=*s++;
1886 };
1887 };
1888 } else {
1889 *p++=*s++;
1890 };
1891 };
1892 };
1893 goto stringizeExit;
1894 stringizeStop:
1895 *p++='.';
1896 *p++='.';
1897 *p++='.';
1898 stringizeExit:
1899 *p=0;
1900 return stringizeBuf;
1901 }
1902
1903 #ifdef __USE_PROTOS
1904 int isNullAction(char *s)
1905 #else
1906 int isNullAction(s)
1907 char *s;
1908 #endif
1909 {
1910 char *p;
1911 for (p=s; *p != '\0' ; p++) {
1912 if (*p != ';' && *p !=' ') return 0;
1913 };
1914 return 1;
1915 }
1916 /* MR1 */
1917 /* MR1 End of Routine to stringize code for failed predicates msgs */
1918 /* MR1 */
1919
1920 /* Generate an action. Don't if action is NULL which means that it was already
1921 * handled as an init action.
1922 */
1923 void
1924 #ifdef __USE_PROTOS
1925 genAction( ActionNode *p )
1926 #else
1927 genAction( p )
1928 ActionNode *p;
1929 #endif
1930 {
1931 require(p!=NULL, "genAction: invalid node and/or rule");
1932 require(p->ntype==nAction, "genAction: not action");
1933
1934 if ( !p->done ) /* MR10 */ /* MR11 */
1935 {
1936 if ( p->is_predicate)
1937 {
1938 if ( p->guardpred != NULL )
1939 {
1940 Predicate *guardDup=predicate_dup(p->guardpred); /* MR10 */
1941 gen("if (!");
1942 guardDup=genPredTreeMain(guardDup, (Node *)p);
1943 predicate_free(guardDup);
1944 }
1945 /* MR10 */ else if (p->ampersandPred != NULL) {
1946 /* MR10 */ gen("if (!");
1947 /* MR10 */ p->ampersandPred=genPredTreeMain(p->ampersandPred, (Node *)p);
1948 /* MR10 */ }
1949 else
1950 {
1951 gen("if (!(");
1952 /* make sure that '#line n' is on front of line */
1953 if ( GenLineInfo && p->file != -1 ) _gen("\n");
1954 dumpPredAction(p,p->action, output, 0, p->file, p->line, 0);
1955 _gen(")");
1956 }
1957
1958 /* MR23 Change failed predicate macro to have three arguments:
1959
1960 macro arg 1: The stringized predicate itself
1961 macro arg 2: 0 => no user-defined error action
1962 1 => user-defined error action
1963 macro arg 3: The user-defined error action
1964
1965 This gives the user more control of the error action.
1966 */
1967 tabs++;
1968 gen3(") {zzfailed_pred(\"%s\",%s, { %s } );}\n", /* MR23 */
1969 stringize(p->action), /* MR23 */
1970 (p->pred_fail == NULL ? /* MR23/MR27 */
1971 "0 /* report */" : "1 /* user action */"), /* MR23/MR27 */
1972 (p->pred_fail == NULL ? /* MR23 */
1973 "0; /* no user action */" : p->pred_fail)); /* MR23 */
1974 tabs--;
1975 }
1976 else /* not a predicate */
1977 {
1978 if (! isNullAction(p->action) && !p->noHoist) {
1979 if ( FoundGuessBlk ) {
1980 if ( GenCC ) {
1981 gen("if ( !guessing ) {\n");
1982 } else {
1983 gen("zzNON_GUESS_MODE {\n");
1984 };
1985 };
1986 dumpActionPlus(p, p->action, output, tabs, p->file, p->line, 1); /* MR21 */
1987 if ( FoundGuessBlk ) gen("}\n");
1988 };
1989 }
1990 }
1991 TRANS(p->next)
1992 }
1993
1994 /*
1995 * if invoking rule has !noAST pass zzSTR to rule ref and zzlink it in
1996 * else pass addr of temp root ptr (&_ast) (don't zzlink it in).
1997 *
1998 * if ! modifies rule-ref, then never link it in and never pass zzSTR.
1999 * Always pass address of temp root ptr.
2000 */
2001 void
2002 #ifdef __USE_PROTOS
2003 genRuleRef( RuleRefNode *p )
2004 #else
2005 genRuleRef( p )
2006 RuleRefNode *p;
2007 #endif
2008 {
2009 Junction *q;
2010 char *handler_id = "";
2011 RuleEntry *r, *r2;
2012 char *parm = "", *exsig = "";
2013
2014 int genRuleRef_emittedGuessGuard=0; /* MR10 */
2015
2016 require(p!=NULL, "genRuleRef: invalid node and/or rule");
2017 require(p->ntype==nRuleRef, "genRuleRef: not rule reference");
2018
2019 if ( p->altstart!=NULL && p->altstart->exception_label!=NULL )
2020 handler_id = p->altstart->exception_label;
2021
2022 r = (RuleEntry *) hash_get(Rname, p->text);
2023 if ( r == NULL )
2024 {
2025 warnFL( eMsg1("rule %s not defined",
2026 p->text), FileStr[p->file], p->line );
2027 return;
2028 }
2029
2030 /* MR8 5-Aug-97 Reported by S.Bochnak@microtool.com.pl */
2031 /* Don't do assign when no return values declared */
2032 /* Move definition of q up and use it to guard p->assign */
2033
2034 q = RulePtr[r->rulenum]; /* find definition of ref'd rule */ /* MR8 */
2035
2036 r2 = (RuleEntry *) hash_get(Rname, p->rname);
2037 if ( r2 == NULL ) {warnNoFL("Rule hash table is screwed up beyond belief"); return;}
2038
2039 OutLineInfo(output,p->line,FileStr[p->file]);
2040
2041 if ( GenCC && GenAST ) {
2042 gen("_ast = NULL;\n");
2043 }
2044
2045 if ( FoundGuessBlk && p->assign!=NULL && q->ret != NULL ) { /* MR8 */
2046 if ( GenCC ) {
2047 gen("if ( !guessing ) {\n");
2048 } else {
2049 gen("zzNON_GUESS_MODE {\n");
2050 };
2051 tabs++; /* MR11 */
2052 genRuleRef_emittedGuessGuard=1; /* MR11 */
2053 };
2054
2055 if ( FoundException ) exsig = "&_signal";
2056
2057 tab();
2058 if ( GenAST )
2059 {
2060 if ( GenCC ) {
2061 /**** if ( r2->noAST || p->astnode==ASTexclude )
2062 ****/
2063 {
2064 /**** _gen("_ast = NULL;\n");
2065 ****/
2066 parm = "&_ast";
2067 }
2068 /*** we always want to set just a pointer now, then set correct
2069 pointer after
2070
2071 else {
2072 _gen("_astp =
2073 (_tail==NULL)?(&_sibling):(&(_tail->_right));\n");
2074 parm = "_astp";
2075 }
2076 ****/
2077 }
2078 else {
2079 if ( r2->noAST || p->astnode==ASTexclude )
2080 {
2081 _gen("_ast = NULL; ");
2082 parm = "&_ast";
2083 }
2084 else parm = "zzSTR";
2085 }
2086 if ( p->assign!=NULL && q->ret!=NULL ) /* MR8 */
2087 {
2088 if ( !hasMultipleOperands(p->assign) ) {_gen1("%s = ",p->assign);} /* MR23 */
2089 else _gen1("{ struct _rv%d _trv; _trv = ", r->rulenum);
2090 }
2091 if ( FoundException ) {
2092 _gen5("%s%s(%s,&_signal%s%s); ",
2093 RulePrefix,
2094 p->text,
2095 parm,
2096 (p->parms!=NULL)?",":"",
2097 (p->parms!=NULL)?p->parms:"");
2098 if ( p->ex_group!=NULL ) {
2099 _gen("\n");
2100 gen("if (_signal) {\n");
2101 tabs++;
2102 dumpException(p->ex_group, 0);
2103 tabs--;
2104 gen("}");
2105 }
2106 else {
2107 _gen1("if (_signal) goto %s_handler;", handler_id);
2108 }
2109 }
2110 else {
2111 _gen5("%s%s(%s%s%s);",
2112 RulePrefix,
2113 p->text,
2114 parm,
2115 (p->parms!=NULL)?",":"",
2116 (p->parms!=NULL)?p->parms:"");
2117 }
2118 if ( GenCC && (r2->noAST || p->astnode==ASTexclude) )
2119 {
2120 /* rule has a ! or element does */
2121 /* still need to assign to #i so we can play with it */
2122 _gen("\n");
2123 gen2("_ast%d%d = (AST *)_ast;", BlkLevel-1, p->elnum);
2124 }
2125 else if ( !r2->noAST && p->astnode == ASTinclude )
2126 {
2127 /* rule doesn't have a ! and neither does element */
2128 /* MR10 */ if (FoundGuessBlk && !genRuleRef_emittedGuessGuard) {
2129 /* MR10 */ _gen("\n");
2130 /* MR10 */ if (GenCC) gen ("if (!guessing) { /* MR10 */")
2131 /* MR10 */ else gen ("if (!zzguessing) { /* MR10 */\n");
2132 /* MR10 */ tabs++;
2133 /* MR10 */ };
2134 if ( GenCC ) {
2135 _gen("\n");
2136 gen("if ( _tail==NULL ) _sibling = _ast; else _tail->setRight(_ast);\n");
2137 gen2("_ast%d%d = (AST *)_ast;\n", BlkLevel-1, p->elnum);
2138 tab();
2139 }
2140 else _gen(" ");
2141 if ( GenCC ) {
2142 _gen("ASTBase::"); }
2143 else _gen("zz");
2144 _gen("link(_root, &_sibling, &_tail);");
2145
2146 /* MR10 */ if (FoundGuessBlk && !genRuleRef_emittedGuessGuard) { /* MR10 */
2147 /* MR10 */ _gen("\n");
2148 /* MR10 */ tabs--;
2149 /* MR10 */ if (GenCC) gen ("}; /* MR10 */")
2150 /* MR10 */ else gen ("}; /* MR10 */");
2151 /* MR10 */ };
2152 }
2153 }
2154 else
2155 {
2156 if ( p->assign!=NULL && q->ret!=NULL ) /* MR8 */
2157 {
2158 if ( !hasMultipleOperands(p->assign) ) {_gen1("%s = ",p->assign);} /* MR23 */
2159 else _gen1("{ struct _rv%d _trv; _trv = ", r->rulenum);
2160 }
2161 if ( FoundException ) {
2162 _gen4("%s%s(&_signal%s%s); ",
2163 RulePrefix,
2164 p->text,
2165 (p->parms!=NULL)?",":"",
2166 (p->parms!=NULL)?p->parms:"");
2167 if ( p->ex_group!=NULL ) {
2168 _gen("\n");
2169 gen("if (_signal) {\n");
2170 tabs++;
2171 dumpException(p->ex_group, 0);
2172 tabs--;
2173 gen("}");
2174 }
2175 else {
2176 _gen1("if (_signal) goto %s_handler;", handler_id);
2177 }
2178 }
2179 else {
2180 _gen3("%s%s(%s);",
2181 RulePrefix,
2182 p->text,
2183 (p->parms!=NULL)?p->parms:"");
2184 }
2185 if ( p->assign!=NULL && q->ret!=NULL ) _gen("\n"); /* MR8 */
2186 }
2187
2188 if ( p->assign!=NULL && q->ret!=NULL) { /* MR8 */
2189 if ( hasMultipleOperands(p->assign) ) /* MR23 */
2190 {
2191 _gen("\n");
2192 dumpRetValAssign(p->assign, q->ret, p); /* MR30 */
2193 _gen("}");
2194 }
2195 }
2196 _gen("\n");
2197
2198 /* Handle element labels now */
2199 if ( p->el_label!=NULL )
2200 {
2201 if ( GenAST )
2202 {
2203 if ( GenCC ) {
2204 gen3("%s_ast = _ast%d%d;\n", p->el_label, BlkLevel-1, p->elnum);
2205 }
2206 else {gen1("%s_ast = zzastCur;\n", p->el_label);}
2207 }
2208 else if (!GenCC ) {
2209 gen1("%s = zzaCur;\n", p->el_label);
2210 }
2211 }
2212
2213 if ( FoundGuessBlk && p->assign!=NULL && q->ret!=NULL ) { /* MR8 */
2214 /* in guessing mode, don't branch to handler upon error */
2215 tabs--; /* MR11 */
2216 gen("} else {\n");
2217 tabs++; /* MR11 */
2218 if ( FoundException ) {
2219 gen6("%s%s(%s%s&_signal%s%s);\n",
2220 RulePrefix,
2221 p->text,
2222 parm,
2223 (*parm!='\0')?",":"",
2224 (p->parms!=NULL)?",":"",
2225 (p->parms!=NULL)?p->parms:"");
2226 }
2227 else {
2228 gen5("%s%s(%s%s%s);\n",
2229 RulePrefix,
2230 p->text,
2231 parm,
2232 (p->parms!=NULL && *parm!='\0')?",":"",
2233 (p->parms!=NULL)?p->parms:"");
2234 }
2235 tabs--; /* MR11 */
2236 gen("}\n");
2237 }
2238 TRANS(p->next)
2239 }
2240
2241 /*
2242 * Generate code to match a token.
2243 *
2244 * Getting the next token is tricky. We want to ensure that any action
2245 * following a token is executed before the next GetToken();
2246 */
2247 void
2248 #ifdef __USE_PROTOS
2249 genToken( TokNode *p )
2250 #else
2251 genToken( p )
2252 TokNode *p;
2253 #endif
2254 {
2255 RuleEntry *r;
2256 char *handler_id = "";
2257 ActionNode *a;
2258 char *set_name;
2259 char *set_nameErrSet;
2260 int complement;
2261 int ast_label_in_action = 0; /* MR27 */
2262 int pushedCmodeAST = 0; /* MR27 */
2263
2264 require(p!=NULL, "genToken: invalid node and/or rule");
2265 require(p->ntype==nToken, "genToken: not token");
2266 if ( p->altstart!=NULL && p->altstart->exception_label!=NULL )
2267 handler_id = p->altstart->exception_label;
2268
2269 r = (RuleEntry *) hash_get(Rname, p->rname);
2270 if ( r == NULL ) {warnNoFL("Rule hash table is screwed up beyond belief"); return;}
2271
2272 /*
2273 * MR27 Has the element label been referenced as an AST (with the # operator) ?
2274 * If so, then we'll want to build the AST even though the user has used
2275 * the ! operator.
2276 */
2277 /* MR27 */ if (GenAST && p->el_label != NULL) {
2278 /* MR27 */ ast_label_in_action = list_search_cstring(r->ast_labels_in_actions,
2279 /* MR27 */ p->el_label);
2280 /* MR27 */ }
2281
2282 OutLineInfo(output,p->line,FileStr[p->file]);
2283
2284 if ( !set_nil(p->tset) ) /* implies '.', ~Tok, or tokenclass */
2285 {
2286 unsigned e;
2287 unsigned eErrSet = 0;
2288 set b;
2289 set bErrSet; /* MR23 */
2290 b = set_dup(p->tset);
2291 bErrSet = set_dup(p->tset); /* MR23 */
2292 complement = p->complement; /* MR23 */
2293 if ( p->tclass!=NULL && complement == 0 /* MR23 */) { /* token class not complemented*/
2294 static char buf[MaxRuleName+20]; /* MR23 */
2295 static char bufErrSet[MaxRuleName+20]; /* MR23 */
2296 if ( p->tclass->dumped ) {
2297 e = p->tclass->setnum;
2298 eErrSet = p->tclass->setnumErrSet;
2299 }
2300 else {
2301 e = DefErrSet(&b, 0, TokenString(p->token));
2302 eErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, TokenString(p->token), "_errset");
2303 p->tclass->dumped = 1; /* indicate set has been created */
2304 p->tclass->setnum = e;
2305 p->tclass->setnumErrSet = eErrSet; /* MR23 */
2306 }
2307 sprintf(buf, "%s_set", TokenString(p->token));
2308 sprintf(bufErrSet, "%s_errset", TokenString(p->token)); /* MR23 */
2309 set_name = buf;
2310 set_nameErrSet = bufErrSet; /* MR23 */
2311 }
2312
2313 /* MR23 - Forgot about the case of ~TOKCLASS. */
2314
2315 else if ( p->tclass!=NULL && complement != 0 /* MR23 */)
2316 {
2317 static char buf[MaxRuleName+20]; /* MR23 */
2318 static char bufErrSet[MaxRuleName+20]; /* MR23 */
2319 if ( p->tclass->dumpedComplement ) {
2320 e = p->tclass->setnumComplement;
2321 eErrSet = p->tclass->setnumErrSetComplement;
2322 }
2323 else {
2324 e = DefErrSetWithSuffix(0, &b, 0, TokenString(p->token), "_setbar");
2325 eErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, TokenString(p->token), "_errsetbar");
2326 p->tclass->dumpedComplement = 1; /* indicate set has been created */
2327 p->tclass->setnumComplement = e;
2328 p->tclass->setnumErrSetComplement = eErrSet; /* MR23 */
2329 }
2330 sprintf(buf, "%s_setbar", TokenString(p->token));
2331 sprintf(bufErrSet, "%s_errsetbar", TokenString(p->token)); /* MR23 */
2332 set_name = buf;
2333 set_nameErrSet = bufErrSet; /* MR23 */
2334 }
2335 else { /* wild card */
2336 static char buf[sizeof("zzerr")+10];
2337 static char bufErrSet[sizeof("zzerr")+10];
2338 int n = DefErrSet( &b, 0, NULL );
2339 int nErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, NULL, "_set");
2340 if ( GenCC ) sprintf(buf, "err%d", n);
2341 else sprintf(buf, "zzerr%d", n);
2342 if ( GenCC ) sprintf(bufErrSet, "err%d", nErrSet);
2343 else sprintf(bufErrSet, "zzerr%d", nErrSet);
2344 set_name = buf;
2345 set_nameErrSet = bufErrSet;
2346 }
2347
2348 if ( !FoundException ) {
2349 /* MR23 */ gen2("zzsetmatch(%s, %s);", set_name, set_nameErrSet);
2350 }
2351 else if ( p->ex_group==NULL ) {
2352 if ( p->use_def_MT_handler )
2353 gen3("zzsetmatch_wdfltsig(%s,(ANTLRTokenType)%d,%s);",
2354 set_name,
2355 p->token,
2356 tokenFollowSet(p))
2357 else
2358 gen2("zzsetmatch_wsig(%s, %s_handler);",
2359 set_name,
2360 handler_id);
2361 }
2362 else
2363 {
2364 gen1("if ( !_setmatch_wsig(%s) ) {\n", set_name);
2365 tabs++;
2366 /* MR6 */ if (FoundGuessBlk) {
2367 /* MR6 */ if ( GenCC ) {gen("if ( guessing ) goto fail;\n");}
2368 /* MR6 */ else gen("if ( zzguessing ) goto fail;\n");
2369 /* MR6 */ };
2370 gen("_signal=MismatchedToken;\n");
2371 dumpException(p->ex_group, 0);
2372 tabs--;
2373 gen("}\n");
2374 }
2375 set_free(b);
2376 set_free(bErrSet);
2377 }
2378 else if ( TokenString(p->token)!=NULL )
2379 {
2380 if ( FoundException ) {
2381 if ( p->use_def_MT_handler )
2382 gen2("zzmatch_wdfltsig(%s,%s);",TokenString(p->token),tokenFollowSet(p))
2383 else if ( p->ex_group==NULL )
2384 {
2385 gen2("zzmatch_wsig(%s, %s_handler);",
2386 TokenString(p->token),
2387 handler_id);
2388 }
2389 else
2390 {
2391 /* MR6 */ if (GenCC) {
2392 /* MR6 */ gen1("if ( !_match_wsig(%s) ) {\n", TokenString(p->token));
2393 /* MR6 */ } else {
2394 /* MR6 */ gen1("if ( !_zzmatch_wsig(%s) ) {\n", TokenString(p->token));
2395 /* MR6 */ };
2396 tabs++;
2397 /* MR6 */ if (FoundGuessBlk) {
2398 /* MR6 */ if ( GenCC ) {gen("if ( guessing ) goto fail;\n");}
2399 /* MR6 */ else gen("if ( zzguessing ) goto fail;\n");
2400 /* MR6 */ };
2401 gen("_signal=MismatchedToken;\n");
2402 dumpException(p->ex_group, 0);
2403 tabs--;
2404 gen("}\n");
2405 }
2406 }
2407 else gen1("zzmatch(%s);", TokenString(p->token));
2408 }
2409 else {
2410 if ( FoundException ) {
2411 if ( p->use_def_MT_handler )
2412 gen2("zzmatch_wdfltsig((ANTLRTokenType)%d,%s);",
2413 p->token,tokenFollowSet(p))
2414 else
2415 gen2("zzmatch_wsig(%d,%s_handler);",p->token,handler_id);
2416 }
2417 else {gen1("zzmatch(%d);", p->token);}
2418 }
2419
2420 a = findImmedAction( p->next );
2421 /* generate the token labels */
2422 if ( GenCC && p->elnum>0 )
2423 {
2424 /* If building trees in C++, always gen the LT() assigns */
2425 if ( set_el(p->elnum, tokensRefdInBlock) || GenAST )
2426 {
2427 /* MR10 */ if ( FoundGuessBlk ) {
2428 /* MR10 */ gen("\n");
2429 /* MR10 */ if (p->label_used_in_semantic_pred) {
2430 /* MR10 */ gen2(" _t%d%d = (ANTLRTokenPtr)LT(1); /* MR10 */\n", BlkLevel-1, p->elnum);
2431 /* MR10 */ } else {
2432 /* MR10 */ gen("if ( !guessing ) {\n"); tab();
2433 /* MR10 */ _gen2(" _t%d%d = (ANTLRTokenPtr)LT(1);\n", BlkLevel-1, p->elnum);
2434 /* MR10 */ gen("}\n");
2435 /* MR10 */ };
2436 /* MR10 */ } else {
2437 /* MR10 */ _gen2(" _t%d%d = (ANTLRTokenPtr)LT(1);", BlkLevel-1, p->elnum);
2438 /* MR10 */ };
2439 /* MR10 */
2440 }
2441
2442 /*
2443 * MR23 labase is never used in the C++ runtime library.
2444 * and this code is generated only in C++ mode
2445 */
2446
2447 /*** if ( LL_k>1 ) / * MR23 disabled */
2448 /*** if ( !DemandLookahead ) _gen(" labase++;"); / * MR23 disabled */
2449 /*** _gen("\n"); / * MR23 disabled */
2450 /*** tab(); / * MR23 disabled */
2451 }
2452 if ( GenAST )
2453 {
2454 if ( FoundGuessBlk &&
2455 (ast_label_in_action || !(p->astnode == ASTexclude || r->noAST)) )
2456 {
2457 if ( GenCC ) {_gen("if ( !guessing ) {\n"); tab();}
2458 else {_gen("zzNON_GUESS_MODE {\n"); tab();}
2459 }
2460
2461 /* MR27 addition when labels referenced when operator ! used */
2462
2463 pushedCmodeAST = 0; /* MR27 */
2464 if (ast_label_in_action && (p->astnode == ASTexclude || r->noAST)) {
2465 _gen("\n");
2466 if (GenCC) {
2467 /* MR13 */ if (NewAST) {
2468 /* MR13 */ gen4("_ast%d%d = newAST(_t%d%d); /* MR27 */\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);
2469 /* MR13 */ } else {
2470 /* MR13 */ gen4("_ast%d%d = new AST(_t%d%d); /* MR27 */\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);
2471 /* MR13 */ }
2472 }
2473 else {
2474 pushedCmodeAST = 1;
2475 gen("zzastPush(zzmk_ast(zzastnew(),zzaCur)); /* MR27 */");
2476 }
2477 }
2478
2479 /* end MR27 addition for labels referenced when operator ! used */
2480
2481 if (!r->noAST )
2482 {
2483 if (GenCC && !(p->astnode == ASTexclude) ) {
2484 _gen("\n");
2485 /* MR13 */ if (NewAST) {
2486 /* MR13 */ gen4("_ast%d%d = newAST(_t%d%d);\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);
2487 /* MR13 */ } else {
2488 /* MR13 */ gen4("_ast%d%d = new AST(_t%d%d);\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);
2489 /* MR13 */ }
2490 tab();
2491 }
2492 if ( GenCC && !(p->astnode == ASTexclude) )
2493 {_gen2("_ast%d%d->", BlkLevel-1, p->elnum);}
2494 else _gen(" ");
2495 if ( p->astnode==ASTchild ) {
2496 if ( !GenCC ) _gen("zz");
2497 _gen("subchild(_root, &_sibling, &_tail);");
2498 }
2499 else if ( p->astnode==ASTroot ) {
2500 if ( !GenCC ) _gen("zz");
2501 _gen("subroot(_root, &_sibling, &_tail);");
2502 }
2503 if ( GenCC && !(p->astnode == ASTexclude) ) {
2504 _gen("\n");
2505 tab();
2506 }
2507 }
2508 else if ( !GenCC ) {
2509 if (! pushedCmodeAST) _gen(" zzastDPush;");
2510 }
2511 if ( FoundGuessBlk &&
2512 (ast_label_in_action || !(p->astnode == ASTexclude || r->noAST)) )
2513 {gen("}\n"); tab();}
2514 }
2515
2516 /* Handle element labels now */
2517 if ( p->el_label!=NULL )
2518 {
2519 int done_NON_GUESSMODE=0;
2520
2521 _gen("\n");
2522
2523 /* MR10 */ /* do Attrib / Token ptr for token label used in semantic pred */
2524 /* MR10 */ /* for these cases do assign even in guess mode */
2525 /* MR10 */
2526 /* MR10 */ if (p->label_used_in_semantic_pred) {
2527 /* MR10 */ if ( GenCC ) {
2528 /* MR10 */ if ( set_el(p->elnum, tokensRefdInBlock) || GenAST ) {
2529 /* MR10 */ gen3("%s = _t%d%d;", p->el_label, BlkLevel-1, p->elnum);
2530 /* MR10 */ } else {
2531 /* MR10 */ gen1("%s = (ANTLRTokenPtr)LT(1);\n", p->el_label);
2532 /* MR10 */ };
2533 /* MR10 */ } else {
2534 /* MR10 */ gen1("%s = zzaCur;", p->el_label);
2535 /* MR10 */ };
2536 /* MR10 */ if (FoundGuessBlk) _gen(" /* MR10 */");
2537 /* MR10 */ _gen("\n");
2538 /* MR10 */ };
2539
2540 /* Do Attrib / Token ptr */
2541
2542 /* MR10 */ if (! p->label_used_in_semantic_pred) {
2543 /* MR10 */
2544 /* MR10 */ if ( FoundGuessBlk ) {
2545 /* MR10 */ if (! done_NON_GUESSMODE) {
2546 /* MR10 */ done_NON_GUESSMODE=1;
2547 /* MR10 */ if ( GenCC ) {gen("if ( !guessing ) {\n"); tab();}
2548 /* MR10 */ else {gen("zzNON_GUESS_MODE {\n"); tab();}
2549 /* MR10 */ };
2550 /* MR10 */ };
2551 /* MR10 */
2552 /* MR10 */ if ( GenCC ) {
2553 /* MR10 */ if ( set_el(p->elnum, tokensRefdInBlock) || GenAST ) {
2554 /* MR10 */ gen3("%s = _t%d%d;\n", p->el_label, BlkLevel-1, p->elnum);
2555 /* MR10 */ } else {
2556 /* MR10 */ gen1("%s = (ANTLRTokenPtr)LT(1);\n", p->el_label);
2557 /* MR10 */ };
2558 /* MR10 */ } else {
2559 /* MR10 */ gen1("%s = zzaCur;\n", p->el_label);
2560 /* MR10 */ };
2561 /* MR10 */ };
2562
2563 /* Do AST ptr */
2564
2565 if (GenAST && (ast_label_in_action || !(p->astnode == ASTexclude || r->noAST) )) /* MR27 */
2566 {
2567
2568 /* MR10 */ if ( FoundGuessBlk ) {
2569 /* MR10 */ if (! done_NON_GUESSMODE) {
2570 /* MR10 */ done_NON_GUESSMODE=1;
2571 /* MR10 */ if ( GenCC ) {gen("if ( !guessing ) {\n"); tab();}
2572 /* MR10 */ else {gen("zzNON_GUESS_MODE {\n"); tab();}
2573 /* MR10 */ };
2574 /* MR10 */ };
2575
2576 if ( GenCC ) {
2577 gen3("%s_ast = _ast%d%d;\n", p->el_label, BlkLevel-1, p->elnum);
2578 }
2579 else {gen1("%s_ast = zzastCur;\n", p->el_label);}
2580 }
2581
2582 /* MR10 */ if (done_NON_GUESSMODE) {
2583 /* MR10 */ gen("}\n"); tab();
2584 /* MR10 */ };
2585
2586 }
2587
2588 /* Handle any actions immediately following action */
2589 if ( a != NULL ) /* MR10 */ /* MR11 */
2590 {
2591 /* delay next token fetch until after action */
2592 _gen("\n");
2593 if ( a->is_predicate)
2594 {
2595 #if 0
2596 /* Disabled in MR30 ************************************************************
2597 And moved into genAction
2598 *****************************************************************************
2599 */
2600
2601 gen("if (!(");
2602
2603 /* make sure that '#line n' is on front of line */ /* MR14 */
2604 if ( GenLineInfo && p->file != -1 ) _gen("\n"); /* MR14 */
2605 dumpPredAction(a,a->action, output, 0, a->file, a->line, 0);
2606
2607 /* MR23 Change failed predicate macro to have three arguments:
2608
2609 macro arg 1: The stringized predicate itself
2610 macro arg 2: 0 => no user-defined error action
2611 1 => user-defined error action
2612 macro arg 3: The user-defined error action
2613
2614 This gives the user more control of the error action.
2615 */
2616 _gen(")) \n");
2617 tabs++;
2618 gen3(" {zzfailed_pred(\"%s\",%s,{ %s } );}\n", /* MR23 */
2619 stringize(a->action), /* MR23 */
2620 (a->pred_fail == NULL ? /* MR23/MR27 */
2621 "0 /* report */" : "1 /* user action */"), /* MR23/MR27 */
2622 (a->pred_fail == NULL ? /* MR23 */
2623 "0; /* no user action */" : a->pred_fail)); /* MR23 */
2624 tabs--;
2625 /* Disabled in MR30 ************************************************************
2626 And moved into genAction
2627 *****************************************************************************
2628 */
2629 #endif
2630 }
2631 else /* MR9 a regular action - not a predicate action */
2632 {
2633
2634 /* MR23: Search an action which is not a predicate for LT(i),
2635 LA(i), or LATEXT(i) in order to warn novice users that
2636 it refers to the previous matched token, not the next
2637 one. This is different than the case for semantic
2638 predicates.
2639 */
2640
2641 /* MR23 */ if (GenCC) {
2642 /* MR23 */ if (strstr(a->action, "LT(") != NULL) LTinTokenAction = 1;
2643 /* MR23 */ }
2644 /* MR23 */ else {
2645 /* MR23 */ if (strstr(a->action, "LA(") != NULL) LTinTokenAction = 1;
2646 /* MR23 */ if (strstr(a->action, "LATEXT(") != NULL) LTinTokenAction = 1;
2647 /* MR23 */ }
2648
2649 if ( FoundGuessBlk ) {
2650 if ( GenCC ) {gen("if ( !guessing ) {\n");}
2651 else gen("zzNON_GUESS_MODE {\n");
2652 }
2653 dumpActionPlus(a, a->action, output, tabs, a->file, a->line, 1); /* MR21 */
2654 if ( FoundGuessBlk ) gen("}\n");
2655 a->done = 1; /* MR30 */
2656 }
2657 /*** a->done = 1; MR30 Moved up into then branch for true actions, but not predicates ***/
2658 if ( !DemandLookahead ) {
2659 if ( GenCC ) {
2660 if ( FoundException && p->use_def_MT_handler ) gen("if (!_signal)");
2661 _gen(" consume();")
2662 if ( FoundException && p->use_def_MT_handler )
2663 _gen(" _signal=NoSignal;");
2664 _gen("\n");
2665 }
2666 else
2667 {
2668 if ( FoundException && p->use_def_MT_handler ) _gen("if (!_signal)");
2669 _gen(" zzCONSUME;\n");
2670 if ( FoundException && p->use_def_MT_handler ) _gen(" _signal=NoSignal;");
2671 _gen("\n");
2672 }
2673 }
2674 else gen("\n");
2675 if (a->done) { /* MR30 */
2676 TRANS( a->next ); /* MR30 */
2677 } /* MR30 */
2678 else { /* MR30 */
2679 TRANS( p->next ); /* MR30 */
2680 } /* MR30 */
2681 }
2682 else
2683 {
2684 if ( !DemandLookahead ) {
2685 if ( GenCC ) {
2686 if (FoundException && p->use_def_MT_handler) _gen("if (!_signal)");
2687 _gen(" consume();")
2688 if (FoundException&&p->use_def_MT_handler) _gen(" _signal=NoSignal;");
2689 _gen("\n");
2690 }
2691 else {
2692 if (FoundException && p->use_def_MT_handler) _gen("if (!_signal)");
2693 _gen(" zzCONSUME;");
2694 if ( FoundException && p->use_def_MT_handler ) _gen(" _signal=NoSignal;");
2695 _gen("\n");
2696 }
2697 }
2698 else _gen("\n");
2699 TRANS(p->next);
2700 }
2701 }
2702
2703 /* MR21
2704 *
2705 * There was a bug in the code generation for {...} which causes it
2706 * to omit the optional tokens from the error messages. The easiest
2707 * way to fix this was to make the opt block look like a sub block:
2708 *
2709 * { a | b | c }
2710 *
2711 * becomes (internally):
2712 *
2713 * ( a | b | c | )
2714 *
2715 * The code for genOptBlk is now identical to genSubBlk except for
2716 * cosmetic changes.
2717 */
2718
2719 void
2720 #ifdef __USE_PROTOS
2721 genOptBlk( Junction *q )
2722 #else
2723 genOptBlk( q )
2724 Junction *q;
2725 #endif
2726 {
2727 int max_k;
2728 set f;
2729 int need_right_curly;
2730 set savetkref;
2731 int lastAltEmpty; /* MR23 */
2732 savetkref = tokensRefdInBlock;
2733 require(q->ntype == nJunction, "genOptBlk: not junction");
2734 require(q->jtype == aOptBlk, "genOptBlk: not opt block");
2735
2736 OutLineInfo(output,q->line,FileStr[q->file]);
2737 BLOCK_Preamble(q);
2738 BlkLevel++;
2739 BlockPreambleOption(q,q->pFirstSetSymbol); /* MR21 */
2740 f = genBlk(q, aOptBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);
2741 /* MR23
2742 Bypass error clause generation when exceptions are used in {...} block
2743 See multi-line note in genBlk near call to isEmptyAlt.
2744 */
2745 if (! FoundException) {
2746 if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */ );}
2747 }
2748 else {
2749 gen("/* MR23 skip error clause for {...} when exceptions in use */\n");
2750 }
2751 { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }
2752 freeBlkFsets(q);
2753 --BlkLevel;
2754 BLOCK_Tail();
2755
2756 if ( q->guess )
2757 {
2758 gen("zzGUESS_DONE\n");
2759 }
2760
2761 /* must duplicate if (alpha)?; one guesses (validates), the
2762 * second pass matches */
2763 if ( q->guess && analysis_point(q)==q )
2764 {
2765 OutLineInfo(output,q->line,FileStr[q->file]);
2766 BLOCK_Preamble(q);
2767 BlkLevel++;
2768 f = genBlk(q, aSubBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);
2769 if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */ );}
2770 { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }
2771 freeBlkFsets(q);
2772 --BlkLevel;
2773 BLOCK_Tail();
2774 }
2775
2776 tokensRefdInBlock = savetkref;
2777 if (q->end->p1 != NULL) TRANS(q->end->p1);
2778 }
2779
2780 /*
2781 * Generate code for a loop blk of form:
2782 *
2783 * |---|
2784 * v |
2785 * --o-G-o-->o--
2786 */
2787 void
2788 #ifdef __USE_PROTOS
2789 genLoopBlk( Junction *begin, Junction *q, Junction *start, int max_k )
2790 #else
2791 genLoopBlk( begin, q, start, max_k )
2792 Junction *begin;
2793 Junction *q;
2794 Junction *start; /* where to start generating code from */
2795 int max_k;
2796 #endif
2797 {
2798 set f;
2799 int need_right_curly;
2800 set savetkref;
2801 Junction *guessBlock; /* MR10 */
2802 int singleAlt; /* MR10 */
2803 int lastAltEmpty; /* MR23 */
2804
2805 savetkref = tokensRefdInBlock;
2806 require(q->ntype == nJunction, "genLoopBlk: not junction");
2807 require(q->jtype == aLoopBlk, "genLoopBlk: not loop block");
2808
2809 if ( q->visited ) return;
2810 q->visited = TRUE;
2811
2812 /* first_item_is_guess_block doesn't care what kind of node it is */
2813
2814 guessBlock=first_item_is_guess_block( (Junction *) q->p1); /* MR10 */
2815 singleAlt=q->p2==NULL; /* MR10 */
2816
2817 if (singleAlt && !guessBlock) /* MR10 */ /* only one alternative? */
2818 {
2819 if ( DemandLookahead ) {
2820 if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}
2821 else gen1("look(%d);\n", max_k);
2822 }
2823 gen("while ( ");
2824 if ( begin!=NULL ) genExpr(begin);
2825 else genExpr(q);
2826 /* if no predicates have been hoisted for this single alt (..)*
2827 * do so now
2828 */
2829 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
2830 if ( ParseWithPredicates && begin->predicate==NULL )
2831 {
2832 Predicate *a = MR_find_predicates_and_supp((Node *)q->p1);
2833 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
2834
2835 if ( a!=NULL )
2836 {
2837 _gen("&&");
2838 a=genPredTreeMain(a, (Node *)q); /* MR10 */
2839 }
2840 /* MR10 */ if (MRhoisting) {
2841 /* MR10 */ predicate_free(a);
2842 /* MR10 */ };
2843 }
2844 _gen(" ) {\n");
2845 tabs++;
2846 TRANS(q->p1);
2847 if ( !GenCC ) gen1("zzLOOP(zztasp%d);\n", BlkLevel-1);
2848 if ( DemandLookahead ) {
2849 if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}
2850 else gen1("look(%d);\n", max_k);
2851 }
2852 --tabs;
2853 gen("}\n");
2854 freeBlkFsets(q);
2855 q->visited = FALSE;
2856 tokensRefdInBlock = savetkref;
2857 return;
2858 }
2859 gen("for (;;) {\n"); /* MR20 G. Hobbelt */
2860 tabs++;
2861 /* MR6 */
2862 /* MR6 "begin" can never be null when called from genLoopBegin */
2863 /* MR6 because q==(Junction *)begin->p1 and we know q is valid */
2864 /* MR6 */
2865 /* MR6 from genLoopBegin: */
2866 /* MR6 */
2867 /* MR6 if ( LL_k>1 && !set_nil(q->fset[2]) ) */
2868 /* MR6 genLoopBlk( q, (Junction *)q->p1, q, max_k ); */
2869 /* MR6 else genLoopBlk( q, (Junction *)q->p1, NULL, max_k ); */
2870 /* MR6 */
2871 if ( begin!=NULL )
2872 {
2873 if ( DemandLookahead )
2874 {
2875 if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}
2876 else gen1("look(%d);\n", max_k);
2877 }
2878 /* The bypass arc of the (...)* predicts what to do when you fail, but
2879 * ONLY after having tested the loop start expression. To avoid this,
2880 * we simply break out of the (...)* loop when we find something that
2881 * is not in the prediction of the loop (all alts thereof).
2882 */
2883 gen("if ( !(");
2884
2885 /*** TJP says: It used to use the prediction expression for the bypass arc
2886 of the (...)*. HOWEVER, if a non LL^1(k) decision was found, this
2887 thing would miss the ftree stored in the aLoopBegin node and generate
2888 an LL^1(k) decision anyway.
2889
2890 *** genExpr((Junction *)begin->p2);
2891 ***/
2892
2893 genExpr((Junction *)begin);
2894 _gen(")) break;\n");
2895
2896 }
2897
2898 /* generate code for terminating loop (this is optional branch) */
2899
2900 f = genBlk(q, aLoopBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);
2901 set_free(f);
2902 freeBlkFsets(q);
2903
2904 /* generate code for terminating loop (this is optional branch) */
2905
2906 /* MR6 */
2907 /* MR6 30-May-97 Bug reported by Manuel Ornato */
2908 /* MR6 A definite bug involving the exit from a loop block */
2909 /* MR6 In 1.23 and later versions (including 1.33) Instead */
2910 /* MR6 exiting the block and reporting a syntax error the */
2911 /* MR6 code loops forever. */
2912 /* MR6 Looking at 1.20 which generates proper code it is not */
2913 /* MR6 clear which of two changes should be undone. */
2914 /* MR6 This is my best guess. */
2915 /* MR6 From earlier MR6 note we know that begin can never be */
2916 /* MR6 null when genLoopBlk called from genLoopBegin */
2917 /* MR6 */
2918 /* MR6 */ if ( begin==NULL) {
2919 /* MR6 */ /* code for exiting loop "for sure" */
2920 /* MR6 */ gen("/* Suppressed by MR6 */ /*** else break; ***/\n");
2921 /* MR6 */ };
2922
2923 /* MR10 */if (singleAlt && guessBlock) {
2924 /* MR10 */ tabs--;
2925 /* MR6 */ gen("} else break; /* MR6 code for exiting loop \"for sure\" */\n");
2926 /* MR10 */ need_right_curly--;
2927 /* MR10 */ } else {
2928 /* MR6 */ gen("else break; /* MR6 code for exiting loop \"for sure\" */\n");
2929 /* MR10 */ };
2930
2931 { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }
2932 if ( !GenCC ) gen1("zzLOOP(zztasp%d);\n", BlkLevel-1);
2933 --tabs;
2934 gen("}\n");
2935 q->visited = FALSE;
2936 tokensRefdInBlock = savetkref;
2937 }
2938
2939 /*
2940 * Generate code for a loop blk of form:
2941 *
2942 * |---|
2943 * v |
2944 * --o-->o-->o-G-o-->o--
2945 * | ^
2946 * v |
2947 * o-----------o
2948 *
2949 * q->end points to the last node (far right) in the blk.
2950 *
2951 * Note that q->end->jtype must be 'EndBlk'.
2952 *
2953 * Generate code roughly of the following form:
2954 *
2955 * do {
2956 * ... code for alternatives ...
2957 * } while ( First Set of aLoopBlk );
2958 *
2959 * OR if > 1 alternative
2960 *
2961 * do {
2962 * ... code for alternatives ...
2963 * else break;
2964 * } while ( 1 );
2965 */
2966 void
2967 #ifdef __USE_PROTOS
2968 genLoopBegin( Junction *q )
2969 #else
2970 genLoopBegin( q )
2971 Junction *q;
2972 #endif
2973 {
2974 set f;
2975 int i;
2976 int max_k;
2977 set savetkref;
2978 savetkref = tokensRefdInBlock;
2979 require(q!=NULL, "genLoopBegin: invalid node and/or rule");
2980 require(q->ntype == nJunction, "genLoopBegin: not junction");
2981 require(q->jtype == aLoopBegin, "genLoopBegin: not loop block");
2982 require(q->p2!=NULL, "genLoopBegin: invalid Loop Graph");
2983
2984 OutLineInfo(output,q->line,FileStr[q->file]);
2985
2986 BLOCK_Preamble(q);
2987 BlkLevel++;
2988 BlockPreambleOption(q,q->pFirstSetSymbol); /* MR21 */
2989 f = First(q, 1, aLoopBegin, &max_k);
2990 /* If not simple LL(1), must specify to start at LoopBegin, not LoopBlk */
2991 if ( LL_k>1 && !set_nil(q->fset[2]) )
2992 genLoopBlk( q, (Junction *)q->p1, q, max_k );
2993 else genLoopBlk( q, (Junction *)q->p1, NULL, max_k );
2994
2995 for (i=1; i<=CLL_k; i++) set_free(q->fset[i]);
2996 for (i=1; i<=CLL_k; i++) set_free(((Junction *)q->p2)->fset[i]);
2997 --BlkLevel;
2998 BLOCK_Tail();
2999 set_free(f);
3000 tokensRefdInBlock = savetkref;
3001 /* MR21 */ if (MR_BlkErr) {
3002 /* MR21 */ set f, fArray[2];
3003 /* MR21 */ f = ComputeErrorSet(q,1,0 /* use plus block bypass ? */ );
3004 /* MR21 */ fArray[0]= empty;
3005 /* MR21 */ fArray[1]= set_dup(f);
3006 /* MR21 */ gen("if (");
3007 /* MR21 */ genExprSets(fArray,1); /* note: destroys set arguments */
3008 /* MR21 */ _gen(") { /* MR21 option -mrblksynerr */\n");
3009 /* MR21 */ tabs++;
3010 /* MR21 */ tab();
3011 /* MR21 */ _gen("/* nothing */ }\n");
3012 /* MR21 */ tab();
3013 /* MR21 */ makeErrorClause(q,f,1,0 /* use plus block bypass ? */ ); /* frees set */
3014 /* MR21 */ tabs--;
3015 /* MR21 */ };
3016 if (q->end->p1 != NULL) TRANS(q->end->p1);
3017 }
3018
3019 /*
3020 * Generate code for a loop blk of form:
3021 *
3022 * |---|
3023 * v |
3024 * --o-G-o-->o--
3025 *
3026 * q->end points to the last node (far right) in the blk.
3027 * Note that q->end->jtype must be 'EndBlk'.
3028 *
3029 * Generate code roughly of the following form:
3030 *
3031 * do {
3032 * ... code for alternatives ...
3033 * } while ( First Set of aPlusBlk );
3034 *
3035 * OR if > 1 alternative
3036 *
3037 * do {
3038 * ... code for alternatives ...
3039 * else if not 1st time through, break;
3040 * } while ( 1 );
3041 */
3042 void
3043 #ifdef __USE_PROTOS
3044 genPlusBlk( Junction *q )
3045 #else
3046 genPlusBlk( q )
3047 Junction *q;
3048 #endif
3049 {
3050 int max_k;
3051 set f;
3052 int need_right_curly;
3053 int lastAltEmpty; /* MR23 */
3054 set savetkref;
3055 Junction *guessBlock; /* MR10 */
3056 int singleAlt; /* MR10 */
3057
3058 savetkref = tokensRefdInBlock;
3059 require(q!=NULL, "genPlusBlk: invalid node and/or rule");
3060 require(q->ntype == nJunction, "genPlusBlk: not junction");
3061 require(q->jtype == aPlusBlk, "genPlusBlk: not Plus block");
3062 require(q->p2 != NULL, "genPlusBlk: not a valid Plus block");
3063
3064 if ( q->visited ) return;
3065 q->visited = TRUE;
3066 OutLineInfo(output,q->line,FileStr[q->file]);
3067 BLOCK_Preamble(q);
3068 BlkLevel++;
3069
3070 BlockPreambleOption((Junction *)q, q->pFirstSetSymbol); /* MR21 */
3071
3072 /* first_item_is_guess_block doesn't care what kind of node it is */
3073
3074 guessBlock=first_item_is_guess_block( (Junction *)q->p1); /* MR10 */
3075
3076 /* if the ignore flag is set on the 2nd alt and that alt is empty,
3077 * then it is the implied optional alternative that we added for (...)+
3078 * and, hence, only 1 alt.
3079 */
3080
3081 /* MR10 Reported by Pulkkinen Esa (esap@cs.tut.fi)
3082 * Outer code for guess blocks ignored when there is only one alt
3083 * for a (...)+ block.
3084 * Force use of regular code rather than "optimized" code for that case
3085 */
3086
3087 singleAlt=( ( (Junction *) q->p2)->p2 == NULL) &&
3088 ( ( (Junction *) q->p2)->ignore ); /* only one alternative? */
3089
3090 if (singleAlt && !guessBlock) /* MR10 */
3091 {
3092
3093 Predicate *a=NULL;
3094 /* if the only alt has a semantic predicate, hoist it; must test before
3095 * entering loop.
3096 */
3097 if ( ParseWithPredicates )
3098 {
3099 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
3100 a = MR_find_predicates_and_supp((Node *)q);
3101 require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");
3102
3103 if ( a!=NULL ) {
3104 gen("if (");
3105 a=genPredTreeMain(a, (Node *)q); /* MR10 */
3106 _gen(") {\n");
3107 }
3108 }
3109 gen("do {\n");
3110 tabs++;
3111 TRANS(q->p1);
3112 if ( !GenCC ) gen1("zzLOOP(zztasp%d);\n", BlkLevel-1);
3113 f = First(q, 1, aPlusBlk, &max_k);
3114 if ( DemandLookahead ) {
3115 if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}
3116 else gen1("look(%d);\n", max_k);
3117 }
3118 --tabs;
3119 gen("} while ( ");
3120 if ( q->parm!=NULL && q->predparm ) _gen1("(%s) && ", q->parm);
3121 genExpr(q);
3122 if ( ParseWithPredicates && a!=NULL )
3123 {
3124 if (! MR_comparePredicates(q->predicate,a)) {
3125 _gen("&&");
3126 a=genPredTreeMain(a, (Node *)q); /* MR10 */
3127 };
3128 }
3129 _gen(" );\n");
3130 if ( ParseWithPredicates && a!=NULL ) gen("}\n");
3131 --BlkLevel;
3132 BLOCK_Tail();
3133 q->visited = FALSE;
3134 freeBlkFsets(q);
3135 set_free(f);
3136 tokensRefdInBlock = savetkref;
3137 /* MR21 */ if (MR_BlkErr) {
3138 /* MR21 */ set f, fArray[2];
3139 /* MR21 */ f = ComputeErrorSet(q,1,1 /* use plus block bypass ? */ );
3140 /* MR21 */ fArray[0]= empty;
3141 /* MR21 */ fArray[1]= set_dup(f);
3142 /* MR21 */ gen("if (");
3143 /* MR21 */ genExprSets(fArray,1); /* note: destroys set arguments */
3144 /* MR21 */ _gen(") { /* MR21 option -mrblksynerr */\n");
3145 /* MR21 */ tabs++;
3146 /* MR21 */ tab();
3147 /* MR21 */ _gen("/* nothing */ }\n");
3148 /* MR21 */ tab();
3149 /* MR21 */ makeErrorClause(q,f,1,1 /* use plus block bypass ? */ ); /* frees set */
3150 /* MR21 */ tabs--;
3151 /* MR21 */ };
3152 if (q->end->p1 != NULL) TRANS(q->end->p1);
3153 /* MR10 */ if (MRhoisting) {
3154 /* MR10 */ predicate_free(a);
3155 /* MR10 */ };
3156 return;
3157 }
3158 gen("do {\n");
3159 tabs++;
3160 f = genBlk(q, aPlusBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);
3161 /* MR6 */
3162 /* MR6 Sinan Karasu (sinan@tardis.ds.boeing.com) */
3163 /* MR6 Failed to turn off guess mode when leaving block */
3164 /* MR6 */
3165 /* MR6 */ if ( has_guess_block_as_last_item(q) ) {
3166 /* MR10 */ gen("/* MR10 ()+ */ else {\n");
3167 /* MR10 */ tabs++;
3168 /* MR10 */ need_right_curly++;
3169 /* MR10 */ gen("/* MR10 ()+ */ if ( !zzrv ) zzGUESS_DONE;\n");
3170 /* MR6 */ gen("/* MR10 ()+ */ if ( zzcnt > 1 ) break;\n");
3171 /* MR10 */ } else {
3172 /* MR10 */ gen("/* MR10 ()+ */ else {\n");
3173 /* MR10 */ tabs++;
3174 /* MR10 */ need_right_curly++;
3175 /* MR10 */ gen("if ( zzcnt > 1 ) break;\n");
3176 /* MR10 */ };
3177
3178 /* MR21 */ if (MR_BlkErr && 1 >= max_k) {
3179 /* MR21 */ set f;
3180 /* MR21 */ f = ComputeErrorSet(q,1,0 /* use plus block bypass ? */ );
3181 /* MR21 */ tabs++;
3182 /* MR21 */ tab();
3183 /* MR21 */ makeErrorClause(q,f,1,0 /* use plus block bypass ? */ ); /* frees set */
3184 /* MR21 */ tabs--;
3185 /* MR21 */ }
3186 /* MR21 */ else {
3187 tab();
3188 makeErrorClause(q,f,max_k,1 /* use plus block bypass ? */);
3189 /* MR21 I think this generates the wrong set ? */
3190 /* MR21 because it includes the plus block bypass ? */
3191 /* MR21 but I'm afraid to change it without additional checking */
3192 }
3193
3194 { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }
3195 freeBlkFsets(q);
3196 gen("zzcnt++;");
3197 if ( !GenCC ) _gen1(" zzLOOP(zztasp%d);", BlkLevel-1);
3198 _gen("\n");
3199 if ( DemandLookahead ) {
3200 if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}
3201 else gen1("look(%d);\n", max_k);
3202 }
3203 --tabs;
3204 if ( q->parm!=NULL && q->predparm ) {gen1("} while (%s);\n", q->parm);}
3205 else gen("} while ( 1 );\n");
3206 --BlkLevel;
3207 BLOCK_Tail();
3208 q->visited = FALSE;
3209 tokensRefdInBlock = savetkref;
3210 /* MR21 */ if (MR_BlkErr) {
3211 /* MR21 */ set f, fArray[2];
3212 /* MR21 */ f = ComputeErrorSet(q,1,1 /* use plus block bypass ? */ );
3213 /* MR21 */ fArray[0]= empty;
3214 /* MR21 */ fArray[1]= set_dup(f);
3215 /* MR21 */ gen("if (");
3216 /* MR21 */ genExprSets(fArray,1); /* note: destroys set arguments */
3217 /* MR21 */ _gen(") { /* MR21 option -mrblksynerr */\n");
3218 /* MR21 */ tabs++;
3219 /* MR21 */ tab();
3220 /* MR21 */ _gen("/* nothing */ }\n");
3221 /* MR21 */ tab();
3222 /* MR21 */ makeErrorClause(q,f,1,1 /* use plus block bypass ? */ ); /* frees set */
3223 /* MR21 */ tabs--;
3224 /* MR21 */ };
3225 if (q->end->p1 != NULL) TRANS(q->end->p1);
3226 }
3227
3228 /*
3229 * Generate code for a sub blk of alternatives of form:
3230 *
3231 * --o-G1--o--
3232 * | ^
3233 * v /|
3234 * o-G2-o|
3235 * | ^
3236 * v |
3237 * ..........
3238 * | ^
3239 * v /
3240 * o-Gn-o
3241 *
3242 * q points to the 1st junction of blk (upper-left).
3243 * q->end points to the last node (far right) in the blk.
3244 * Note that q->end->jtype must be 'EndBlk'.
3245 * The last node in every alt points to q->end.
3246 *
3247 * Generate code of the following form:
3248 * if ( First(G1) ) {
3249 * ...code for G1...
3250 * }
3251 * else if ( First(G2) ) {
3252 * ...code for G2...
3253 * }
3254 * ...
3255 * else {
3256 * ...code for Gn...
3257 * }
3258 */
3259
3260 void
3261 #ifdef __USE_PROTOS
3262 genSubBlk( Junction *q )
3263 #else
3264 genSubBlk( q )
3265 Junction *q;
3266 #endif
3267 {
3268 int max_k;
3269 set f;
3270 int need_right_curly;
3271 int lastAltEmpty; /* MR23 */
3272 set savetkref;
3273 savetkref = tokensRefdInBlock;
3274 require(q->ntype == nJunction, "genSubBlk: not junction");
3275 require(q->jtype == aSubBlk, "genSubBlk: not subblock");
3276
3277 OutLineInfo(output,q->line,FileStr[q->file]);
3278 BLOCK_Preamble(q);
3279 BlkLevel++;
3280 BlockPreambleOption(q,q->pFirstSetSymbol); /* MR21 */
3281 f = genBlk(q, aSubBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);
3282
3283 /* MR23
3284 Bypass error clause generation when exceptions are used in a sub block
3285 in which the last alternative is epsilon. Example: "(A | B | )".
3286 See multi-line note in genBlk near call to isEmptyAlt.
3287 */
3288 if (FoundException && lastAltEmpty) {
3289 gen("/* MR23 skip error clause for (...| epsilon) when exceptions in use */\n");
3290 }
3291 else {
3292 if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */ );}
3293 }
3294
3295 { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }
3296 freeBlkFsets(q);
3297 --BlkLevel;
3298 BLOCK_Tail();
3299
3300 if ( q->guess )
3301 {
3302 gen("zzGUESS_DONE\n");
3303 }
3304
3305 /* must duplicate if (alpha)?; one guesses (validates), the
3306 * second pass matches */
3307 if ( q->guess && analysis_point(q)==q )
3308 {
3309 OutLineInfo(output,q->line,FileStr[q->file]);
3310 BLOCK_Preamble(q);
3311 BlkLevel++;
3312 f = genBlk(q, aSubBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);
3313 if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */);}
3314 { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }
3315 freeBlkFsets(q);
3316 --BlkLevel;
3317 BLOCK_Tail();
3318 }
3319
3320 tokensRefdInBlock = savetkref;
3321 if (q->end->p1 != NULL) TRANS(q->end->p1);
3322 }
3323
3324 static int TnodesAllocatedPrevRule=0;
3325
3326 /*
3327 * Generate code for a rule.
3328 *
3329 * rule--> o-->o-Alternatives-o-->o
3330 * Or,
3331 * rule--> o-->o-Alternative-o-->o
3332 *
3333 * The 1st junction is a RuleBlk. The second can be a SubBlk or just a junction
3334 * (one alternative--no block), the last is EndRule.
3335 * The second to last is EndBlk if more than one alternative exists in the rule.
3336 *
3337 * To get to the init-action for a rule, we must bypass the RuleBlk,
3338 * and possible SubBlk.
3339 * Mark any init-action as generated so genBlk() does not regenerate it.
3340 */
3341 void
3342 #ifdef __USE_PROTOS
3343 genRule( Junction *q )
3344 #else
3345 genRule( q )
3346 Junction *q;
3347 #endif
3348 {
3349
3350 const char * returnValueInitializer;
3351
3352 do { /* MR10 Change recursion into iteration */
3353
3354 int max_k;
3355 set follow, rk, f;
3356 ActionNode *a;
3357 RuleEntry *r;
3358 int lastAltEmpty; /* MR23 */
3359 static int file = -1;
3360 int need_right_curly;
3361 require(q->ntype == nJunction, "genRule: not junction");
3362 require(q->jtype == RuleBlk, "genRule: not rule");
3363
3364 /* MR14 */ require (MR_BackTraceStack.count == 0,"-alpha MR_BackTraceStack.count != 0");
3365 /* MR14 */ MR_pointerStackReset(&MR_BackTraceStack);
3366 /* MR14 */ if (AlphaBetaTrace) MR_MaintainBackTrace=1;
3367
3368 CurRule=q->rname; /* MR11 */
3369
3370 r = (RuleEntry *) hash_get(Rname, q->rname);
3371 if ( r == NULL ) warnNoFL("Rule hash table is screwed up beyond belief");
3372 if ( q->file != file ) /* open new output file if need to */
3373 {
3374 /* MR6 */
3375 /* MR6 Simpler to debug when output goes to stdout rather than a file */
3376 /* MR6 */
3377 /* MR6 */ if (UseStdout) {
3378 /* MR6 */ output = stdout;
3379 /* MR6 */ } else {
3380 /* MR6 */ if ( output != NULL) fclose( output );
3381 /* MR6 */ output = fopen(OutMetaName(outname(FileStr[q->file])), "w");
3382 /* MR6 */ };
3383 require(output != NULL, "genRule: can't open output file");
3384
3385 #ifdef SPECIAL_FOPEN
3386 special_fopen_actions(OutMetaName(outname(FileStr[q->file]))); /* MR1 */
3387 #endif
3388 if ( file == -1 ) genHdr1(q->file);
3389 else genHdr(q->file);
3390 file = q->file;
3391 }
3392
3393 if (InfoM) {
3394 fprintf(stderr," rule %s\n",q->rname);
3395 fflush(output);
3396 };
3397
3398 #if 0
3399 if (strcmp(q->rname,"***debug***") == 0) {
3400 fprintf(stderr,"***debug*** %s reached\n",q->rname);
3401 MR_break();
3402 };
3403 #endif
3404
3405 DumpFuncHeader(q,r);
3406 tabs++;
3407
3408 /* MR23
3409
3410 If there is a single return value then it can be initialized in
3411 the declaration using assignment syntax. If there are multiple
3412 return values then antlr creates a struct and initialization takes
3413 place element by element for each element of the struct. For
3414 multiple elements the initialization is by assignment so we have
3415 to wait until all declarations are done before emitting that code -
3416 because of restrictions in C which don't exist in C++.
3417
3418 In the past (before MR23) the only kind of initialization was
3419 the PURIFY macro which was just a memset() of 0. Now we allow
3420 the user to specify an initial value. PURIFY is still used in C
3421 mode because C does not have constructors. However, PURIFY is
3422 not used in C++ mode because it might overwrite information created
3423 by elements which have their own ctor.
3424
3425 */
3426
3427 if ( q->ret!=NULL )
3428 {
3429 if ( hasMultipleOperands(q->ret) ) /* MR23 */
3430 {
3431
3432 /* Emit initialization code later. */
3433
3434 gen1("struct _rv%d _retv;\n",r->rulenum);
3435 }
3436 else
3437 {
3438 /* Emit initialization code now. */
3439
3440 tab();
3441 DumpType(q->ret, output);
3442 returnValueInitializer = getInitializer(q->ret);
3443 if (returnValueInitializer == NULL) { /* MR23 */
3444 gen(" _retv;\n"); /* MR1 MR3 */
3445 } /* MR23 */
3446 else { /* MR23 */
3447 gen1(" _retv = %s;\n", returnValueInitializer); /* MR23 */
3448 } /* MR23 */
3449 }
3450 }
3451
3452 OutLineInfo(output,q->line,FileStr[q->file]);
3453
3454 if (InfoM) {
3455 fflush(output);
3456 };
3457
3458 gen("zzRULE;\n");
3459 if ( FoundException )
3460 {
3461 gen("int _sva=1;\n");
3462 }
3463 if ( GenCC && GenAST )
3464 gen("ASTBase *_ast = NULL, *_sibling = NULL, *_tail = NULL;\n");
3465 if ( GenCC ) genTokenPointers(q);
3466 if ( GenCC&&GenAST ) genASTPointers(q);
3467 if ( q->el_labels!=NULL ) genElementLabels(q->el_labels);
3468 if ( FoundException ) gen("int _signal=NoSignal;\n");
3469
3470 if ( !GenCC ) gen1("zzBLOCK(zztasp%d);\n", BlkLevel);
3471
3472 /* MR10 */ /* move zzTRACEIN to before init action */
3473
3474 /* MR10 */ if ( TraceGen ) {
3475 /* MR10 */ if ( GenCC ) {gen1("zzTRACEIN(\"%s\");\n", q->rname);}
3476 /* MR10 */ else gen1("zzTRACEIN((ANTLRChar *)\"%s\");\n", q->rname);
3477 /* MR10 */ }
3478
3479 /* MR7 Moved PURIFY() to after all local variables have been declared */
3480 /* MR7 so that the generated code is valid C as well as C++ */
3481 /* MR7 Jan Mikkelsen 10-June-1997 */
3482
3483
3484 /*
3485 MR23 Do the PURIFY macro only for C mode.
3486 C++ users should use constructors or initialization expressions.
3487 */
3488
3489 if ( q->ret != NULL ) /* MR7 */
3490 { /* MR7 */
3491 if (hasMultipleOperands(q->ret)) { /* MR23 */
3492 if (PURIFY == TRUE) {
3493 gen1("PCCTS_PURIFY(_retv,sizeof(struct _rv%d))\n",r->rulenum); /* MR23 */
3494 }
3495 } /* MR7 */
3496 else { /* MR7 */
3497
3498 /* MR23
3499 If there were only one return value operand and
3500 it had an initializer then it would have been
3501 initiailized in the declaration.
3502 */
3503
3504 returnValueInitializer = getInitializer(q->ret); /* MR23 */
3505 if (returnValueInitializer == NULL) { /* MR23 */
3506 if (PURIFY == TRUE) {
3507 gen("PCCTS_PURIFY(_retv,sizeof("); /* MR23 */
3508 DumpType(q->ret, output); /* MR7 */
3509 gen("))\n"); /* MR7 */
3510 }
3511 } /* MR23 */
3512 } /* MR7 */
3513
3514 if (hasMultipleOperands(q->ret)) { /* MR23 */
3515 DumpInitializers(output, r, q->ret); /* MR23 */
3516 }
3517
3518 }
3519 if ( !GenCC ) gen("zzMake0;\n");
3520 if ( FoundException ) gen("*_retsignal = NoSignal;\n");
3521
3522 if ( !GenCC ) gen("{\n");
3523
3524 if ( has_guess_block_as_first_item((Junction *)q->p1) )
3525 {
3526 gen("zzGUESS_BLOCK\n");
3527 }
3528
3529 /* L o o k F o r I n i t A c t i o n */
3530 if ( ((Junction *)q->p1)->jtype == aSubBlk )
3531 a = findImmedAction( ((Junction *)q->p1)->p1 );
3532 else
3533 a = findImmedAction( q->p1 ); /* only one alternative in rule */
3534 if ( a!=NULL && !a->is_predicate)
3535 {
3536 /* MR21 */ if (!a->noHoist) dumpActionPlus(a, a->action, output, tabs, a->file, a->line, 1);
3537 a->done = 1; /* ignore action. We have already handled it */
3538 }
3539
3540 BlkLevel++;
3541 q->visited = TRUE; /* mark RULE as visited for FIRST/FOLLOW */
3542 BlockPreambleOption((Junction *)q->p1, NULL); /* MR21 */
3543 f = genBlk((Junction *)q->p1, RuleBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);
3544 if ( q->p1 != NULL )
3545 if ( ((Junction *)q->p1)->p2 != NULL )
3546 {tab(); makeErrorClause((Junction *)q->p1,f,max_k,0 /* use plus block bypass ? */);}
3547 { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }
3548 freeBlkFsets((Junction *)q->p1);
3549 q->visited = FALSE;
3550 --BlkLevel;
3551 if ( !GenCC ) gen1("zzEXIT(zztasp%d);\n", BlkLevel);
3552
3553 genTraceOut(q);
3554
3555 if ( q->ret!=NULL ) gen("return _retv;\n") else gen("return;\n");
3556 /* E r r o r R e c o v e r y */
3557 NewSet();
3558 rk = empty;
3559
3560 /* MR14 */ if (r->dontComputeErrorSet) {
3561 /* MR14 */ follow=empty;
3562 } else {
3563 MR_pointerStackReset(&MR_BackTraceStack); /* MR14 */
3564 MR_ErrorSetComputationActive=1;
3565 REACH(q->end, 1, &rk, follow);
3566 MR_ErrorSetComputationActive=0;
3567 require (MR_BackTraceStack.count == 0,"K: MR_BackTraceStack.count != 0");
3568 }
3569
3570 FillSet( follow );
3571 set_free( follow );
3572
3573 /* MR20 G. Hobbelt
3574 Isn't it so that "fail:" is ONLY referenced when:
3575
3576 !FoundException || FoundGuessBlk ?
3577
3578 Therefore add the "if" around this piece of code generation...
3579
3580 Should guessing mode also use _handler label instead of "fail"
3581 when exception handling is active? gen can automatically put
3582 "if (guessing)" there so as to skip all kinds of user code.
3583
3584 */
3585
3586 if ( !FoundException || FoundGuessBlk ) /* MR20 G. Hobbelt */
3587 { /* MR20 G. Hobbelt */
3588 _gen("fail:\n");
3589 if ( !GenCC ) gen("zzEXIT(zztasp1);\n");
3590 if ( FoundGuessBlk ) {
3591 if ( !GenCC ) {gen("if ( zzguessing ) zzGUESS_FAIL;\n");}
3592 else gen("if ( guessing ) zzGUESS_FAIL;\n");
3593 }
3594 if ( q->erraction!=NULL )
3595 dumpAction(q->erraction, output, tabs, q->file, q->line, 1);
3596 if ( GenCC )
3597 {
3598 gen1("syn(zzBadTok, %s, zzMissSet, zzMissTok, zzErrk);\n",
3599 r->egroup==NULL?"(ANTLRChar *)\"\"":r->egroup);
3600 }
3601 else
3602 {
3603 gen1("zzsyn(zzMissText, zzBadTok, %s, zzMissSet, zzMissTok, zzErrk, zzBadText);\n",
3604 r->egroup==NULL?"(ANTLRChar *)\"\"":r->egroup);
3605 }
3606 gen3("%sresynch(setwd%d, 0x%x);\n", GenCC?"":"zz", wordnum, 1<<setnum);
3607
3608 if ( q->ret!=NULL ) {
3609 genTraceOut(q);
3610 gen("return _retv;\n");
3611 } else if ( q->exceptions!=NULL ) {
3612 genTraceOut(q);
3613 gen("return;\n");
3614 } else if (!FoundException) { /* MR10 */
3615 genTraceOut(q); /* MR10 */
3616 };
3617
3618 } /* MR20 G. Hobbelt */
3619
3620 if ( !GenCC ) gen("}\n");
3621
3622 /* Gen code for exception handlers */
3623 /* make sure each path out contains genTraceOut() */
3624
3625 if ( q->exceptions!=NULL )
3626 {
3627
3628 gen("/* exception handlers */\n");
3629
3630 dumpExceptions(q->exceptions);
3631
3632 if ( !r->has_rule_exception )
3633 {
3634 _gen("_handler:\n");
3635 gen("zzdflthandlers(_signal,_retsignal);\n");
3636 }
3637 /* MR20 G. Gobbelt The label "adios" is never referenced */
3638
3639 #if 0
3640 _gen("_adios:\n");
3641 #endif
3642 if ( q->ret!=NULL ) {
3643 genTraceOut(q);
3644 gen("return _retv;\n");
3645 }
3646 else {
3647 genTraceOut(q);
3648 gen("return;\n");
3649 }
3650 }
3651 else if ( FoundException )
3652 {
3653 _gen("_handler:\n");
3654 gen("zzdflthandlers(_signal,_retsignal);\n");
3655
3656 /* MR1 */
3657 /* MR1 7-Apr-97 Fix suggested by: John Bair (jbair@iftime.com) */
3658 /* MR1 */
3659
3660 if ( q->ret != NULL) { /* MR1 */
3661 genTraceOut(q); /* MR10 */
3662 gen("return _retv;\n"); /* MR1 */
3663 } else { /* MR1 */
3664 genTraceOut(q); /* MR10 */
3665 gen("return;\n") ; /* MR1 */
3666 }; /* MR1 */
3667 }
3668
3669 tabs--;
3670 gen("}\n");
3671
3672 /* MR10 Tired of looking at stacks that are as deep as the number of */
3673 /* MR10 rules. Changes recursion to iteration. */
3674
3675 MR_releaseResourcesUsedInRule( (Node *) q ); /* MR10 */
3676
3677 if (InfoT) {
3678 fprintf(output,"\n/* tnodes created for rule %s: %d */\n",
3679 q->rname, (TnodesAllocated-TnodesAllocatedPrevRule) );
3680 };
3681
3682 TnodesAllocatedPrevRule=TnodesAllocated;
3683
3684 if (q->p2 == NULL) dumpAfterActions( output );
3685 q=(Junction *)q->p2;
3686 require(q==NULL || q->jtype==RuleBlk,"RuleBlk p2 does not point to another RuleBlk");
3687
3688 } while (q != NULL);
3689
3690 /**** The old code ****/
3691 /**** if ( q->p2 != NULL ) {TRANS(q->p2);} ****/ /* generate code for next rule too */
3692 /**** else dumpAfterActions( output ); ****/
3693
3694 }
3695
3696
3697 /* This is for the function definition, not the declaration. */
3698
3699 static void
3700 #ifdef __USE_PROTOS
3701 DumpFuncHeader( Junction *q, RuleEntry *r )
3702 #else
3703 DumpFuncHeader( q, r )
3704 Junction *q;
3705 RuleEntry *r;
3706 #endif
3707 {
3708 /* */
3709 /* MR1 10-Apr-97 MR1 Simplify insertion of commas in function header */
3710 /* */
3711 int needComma; /* MR1 */
3712
3713
3714 /* A N S I */
3715 _gen("\n");
3716 if ( q->ret!=NULL )
3717 {
3718 if ( hasMultipleOperands(q->ret) ) /* MR23 */
3719 {
3720 if (GenCC) gen2("%s::_rv%d\n", CurrentClassName, r->rulenum)
3721 else gen1("struct _rv%d\n",r->rulenum);
3722 }
3723 else
3724 {
3725 DumpType(q->ret, output);
3726 gen("\n");
3727 }
3728 }
3729 else
3730 {
3731 _gen("void\n");
3732 }
3733 /* MR1 */
3734 /* MR1 10-Apr-97 133MR1 Replace __STDC__ with __USE_PROTOS */
3735 /* MR1 */
3736 if ( !GenCC ) _gen("#ifdef __USE_PROTOS\n"); /* MR1 */
3737 if ( !GenCC ) gen2("%s%s(", RulePrefix, q->rname)
3738 else gen3("%s::%s%s(", CurrentClassName, RulePrefix,q->rname);
3739
3740 /* If we generate C++ method names, we must hide default arguments */
3741 /* which can appear in the parameter declaration list. */
3742 /* NOTICE: this is done only here, for the method definition, but */
3743 /* not for the method declaration inside the class */
3744 /* definition. This is exactly the behaviour defined in */
3745 /* C++ standard for default paramters. */
3746
3747 DumpANSIFunctionArgDef(output,q, 0 /* emit initializers ? */);
3748 _gen("\n");
3749
3750 if ( GenCC ) {
3751 gen("{\n");
3752 return;
3753 }
3754
3755 /* K & R */
3756 gen("#else\n");
3757 gen2("%s%s(", RulePrefix, q->rname);
3758 needComma=0; /* MR1 */
3759 if ( GenAST ) /* MR1 */
3760 { /* MR1 */
3761 _gen("_root"); /* MR1 */
3762 needComma=1; /* MR1 */
3763 } /* MR1 */
3764 if ( FoundException ) /* MR1 */
3765 { /* MR1 */
3766 if (needComma) {_gen(",");needComma=0;}; /* MR1 */
3767 _gen("_retsignal"); /* MR1 */
3768 needComma=1; /* MR1 */
3769 } /* MR1 */
3770 /* MR5 Change below by Jan Mikkelsen (janm@zeta.org.au) 26-May-97 MR5 */
3771 DumpListOfParmNames( q->pdecl, output, needComma ); /* MR5 */
3772 gen(")\n");
3773 if ( GenAST ) gen("AST **_root;\n");
3774 if ( FoundException ) gen("int *_retsignal;\n");
3775 DumpOldStyleParms( q->pdecl, output );
3776 gen("#endif\n");
3777 gen("{\n");
3778 }
3779
3780 void
3781 #ifdef __USE_PROTOS
3782 DumpANSIFunctionArgDef(FILE *f, Junction *q, int bInitializer)
3783 #else
3784 DumpANSIFunctionArgDef(f,q,bInitializer)
3785 FILE *f;
3786 Junction *q;
3787 int bInitializer;
3788 #endif
3789 {
3790 if ( GenAST )
3791 {
3792 if ( GenCC ) {fprintf(f,"ASTBase **_root");}
3793 else fprintf(f,"AST**_root");
3794 if ( !FoundException && q->pdecl!=NULL ) fprintf(f,",");
3795 }
3796 if ( FoundException )
3797 {
3798 if ( GenAST ) fprintf(f,",");
3799 fprintf(f,"int *_retsignal");
3800 if ( q->pdecl!=NULL ) {
3801 fprintf(f,",");
3802 }
3803 }
3804 if ( q->pdecl!=NULL ) {
3805 DumpFormals(f, q->pdecl, bInitializer); /* MR23 */
3806 }
3807 else {
3808 if ( !GenAST && !FoundException ) {
3809 fprintf(f,"void");
3810 }
3811 }
3812 fprintf(f,")");
3813 }
3814
3815 void
3816 #ifdef __USE_PROTOS
3817 genJunction( Junction *q )
3818 #else
3819 genJunction( q )
3820 Junction *q;
3821 #endif
3822 {
3823 require(q->ntype == nJunction, "genJunction: not junction");
3824 require(q->jtype == Generic, "genJunction: not generic junction");
3825
3826 if ( q->p1 != NULL ) TRANS(q->p1);
3827 if ( q->p2 != NULL ) TRANS(q->p2);
3828 }
3829
3830 void
3831 #ifdef __USE_PROTOS
3832 genEndBlk( Junction *q )
3833 #else
3834 genEndBlk( q )
3835 Junction *q;
3836 #endif
3837 {
3838 }
3839
3840 void
3841 #ifdef __USE_PROTOS
3842 genEndRule( Junction *q )
3843 #else
3844 genEndRule( q )
3845 Junction *q;
3846 #endif
3847 {
3848 }
3849
3850 void
3851 #ifdef __USE_PROTOS
3852 genHdr( int file )
3853 #else
3854 genHdr( file )
3855 int file;
3856 #endif
3857 {
3858 int i;
3859
3860 _gen("/*\n");
3861 _gen(" * A n t l r T r a n s l a t i o n H e a d e r\n");
3862 _gen(" *\n");
3863 _gen(" * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");
3864 _gen(" * Purdue University Electrical Engineering\n");
3865 _gen(" * With AHPCRC, University of Minnesota\n");
3866 _gen1(" * ANTLR Version %s\n", Version);
3867 _gen(" *\n");
3868 /* MR10 */ _gen(" * ");
3869 /* MR10 */ for (i=0 ; i < Save_argc ; i++) {
3870 /* MR10 */ _gen(" ");
3871 /* MR10 */ _gen1("%s",Save_argv[i]);
3872 /* MR10 */ };
3873 _gen("\n");
3874 _gen(" *\n");
3875 _gen(" */\n\n");
3876 if (FirstAction != NULL ) dumpAction( FirstAction, output, 0, -1, 0, 1); /* MR11 MR15b */
3877 _gen1("#define ANTLR_VERSION %s\n", VersionDef);
3878 _gen("#include \"pcctscfg.h\"\n");
3879 _gen("#include \"pccts_stdio.h\"\n");
3880 if ( strcmp(ParserName, DefaultParserName)!=0 )
3881 _gen2("#define %s %s\n", DefaultParserName, ParserName);
3882 if ( strcmp(ParserName, DefaultParserName)!=0 )
3883 {_gen1("#include \"%s\"\n", RemapFileName);}
3884 OutLineInfo(output,1,FileStr[file]);
3885 if ( GenCC ) {
3886 if ( UserTokenDefsFile != NULL )
3887 fprintf(output, "#include %s\n", UserTokenDefsFile);
3888 else
3889 fprintf(output, "#include \"%s\"\n", DefFileName);
3890 }
3891
3892 if ( HdrAction != NULL ) dumpAction( HdrAction, output, 0, -1, 0, 1);
3893 if ( !GenCC && FoundGuessBlk )
3894 {
3895 _gen("#define ZZCAN_GUESS\n");
3896 _gen("#include \"pccts_setjmp.h\"\n"); /* MR15 K.J. Cummings (cummings@peritus.com) */
3897 }
3898 if ( FoundException )
3899 {
3900 _gen("#define EXCEPTION_HANDLING\n");
3901 _gen1("#define NUM_SIGNALS %d\n", NumSignals);
3902 }
3903 if ( !GenCC && OutputLL_k > 1 ) _gen1("#define LL_K %d\n", OutputLL_k);
3904 if ( GenAST&&!GenCC ) _gen("#define GENAST\n\n");
3905 if ( GenAST ) {
3906 if ( GenCC ) {_gen1("#include \"%s\"\n\n", ASTBASE_H);}
3907 else _gen("#include \"ast.h\"\n\n");
3908 }
3909 if ( !GenCC && DemandLookahead ) _gen("#define DEMAND_LOOK\n\n");
3910 #ifdef DUM
3911 if ( !GenCC && LexGen ) {
3912 _gen1("#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));
3913 }
3914 #endif
3915 /* ###WARNING: This will have to change when SetWordSize changes */
3916 if ( !GenCC ) _gen1("#define zzSET_SIZE %d\n", (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
3917 if (TraceGen) {
3918 _gen("#ifndef zzTRACE_RULES\n"); /* MR20 */
3919 _gen("#define zzTRACE_RULES\n"); /* MR20 */
3920 _gen("#endif\n"); /* MR22 */
3921 };
3922 if ( !GenCC ) {_gen("#include \"antlr.h\"\n");}
3923 else {
3924 _gen1("#include \"%s\"\n", APARSER_H);
3925 _gen1("#include \"%s.h\"\n", CurrentClassName);
3926 }
3927 if ( !GenCC ) {
3928 if ( UserDefdTokens )
3929 {_gen1("#include %s\n", UserTokenDefsFile);}
3930 /* still need this one as it has the func prototypes */
3931 _gen1("#include \"%s\"\n", DefFileName);
3932 }
3933 /* still need this one as it defines the DLG interface */
3934 if ( !GenCC ) _gen("#include \"dlgdef.h\"\n");
3935 if ( LexGen && GenCC ) _gen1("#include \"%s\"\n", DLEXERBASE_H);
3936 if ( GenCC ) _gen1("#include \"%s\"\n", ATOKPTR_H);
3937 if ( !GenCC && LexGen ) _gen1("#include \"%s\"\n", ModeFileName);
3938
3939 /* MR10 Ofer Ben-Ami (gremlin@cs.huji.ac.il) */
3940 /* MR10 Finally, a definition of the Purify macro */
3941
3942 if (PURIFY == TRUE) { /* MR23 */
3943 _gen("\n/* MR23 In order to remove calls to PURIFY use the antlr"); /* MR23 */
3944 _gen(" -nopurify option */\n\n"); /* MR23 */
3945 _gen("#ifndef PCCTS_PURIFY\n");
3946 _gen("#define PCCTS_PURIFY(r,s) memset((char *) &(r),'\\0',(s));\n");
3947 _gen("#endif\n\n");
3948 } /* MR23 */
3949 }
3950
3951 void
3952 #ifdef __USE_PROTOS
3953 genHdr1( int file )
3954 #else
3955 genHdr1( file )
3956 int file;
3957 #endif
3958 {
3959 ListNode *p;
3960
3961 genHdr(file);
3962 if ( GenAST )
3963 {
3964 if ( !GenCC ) {
3965 _gen("#include \"ast.c\"\n");
3966 _gen("zzASTgvars\n\n");
3967 }
3968 }
3969 if ( !GenCC ) _gen("ANTLR_INFO\n");
3970 if ( BeforeActions != NULL )
3971 {
3972 for (p = BeforeActions->next; p!=NULL; p=p->next)
3973 {
3974 UserAction *ua = (UserAction *)p->elem;
3975 dumpAction( ua->action, output, 0, ua->file, ua->line, 1);
3976 }
3977 }
3978
3979 if ( !FoundException ) return;
3980
3981 if ( GenCC )
3982 {
3983 _gen1("\nvoid %s::\n", CurrentClassName);
3984 _gen("zzdflthandlers( int _signal, int *_retsignal )\n");
3985 _gen("{\n");
3986 }
3987 else
3988 {
3989 _gen("\nvoid\n");
3990 /* MR1 */
3991 /* MR1 10-Apr-97 133MR1 Replace __STDC__ with __USE_PROTOS */
3992 /* MR1 */
3993 _gen("#ifdef __USE_PROTOS\n"); /* MR1 */
3994 _gen("zzdflthandlers( int _signal, int *_retsignal )\n");
3995 _gen("#else\n");
3996 _gen("zzdflthandlers( _signal, _retsignal )\n");
3997 _gen("int _signal;\n");
3998 _gen("int *_retsignal;\n");
3999 _gen("#endif\n");
4000 _gen("{\n");
4001 }
4002 tabs++;
4003 if ( DefaultExGroup!=NULL )
4004 {
4005 dumpException(DefaultExGroup, 1);
4006 if ( !hasDefaultException(DefaultExGroup) )
4007 {
4008 gen("default :\n");
4009 tabs++;
4010 gen("*_retsignal = _signal;\n");
4011 tabs--;
4012 gen("}\n");
4013 }
4014 }
4015 else {
4016 gen("*_retsignal = _signal;\n");
4017 }
4018
4019 tabs--;
4020 _gen("}\n\n");
4021 }
4022
4023 void
4024 #ifdef __USE_PROTOS
4025 genStdPCCTSIncludeFile( FILE *f,char *gate ) /* MR10 */
4026 #else
4027 genStdPCCTSIncludeFile( f , gate) /* MR10 */
4028 FILE *f;
4029 char * gate; /* MR10 */
4030 #endif
4031 {
4032 /* MR10 Ramanathan Santhanam (ps@kumaran.com) */
4033 /* MR10 Same preprocessor symbol use to gate stdpccts.h */
4034 /* MR10 even when two grammars are in use. */
4035 /* MR10 Derive gate symbol from -fh filename */
4036
4037 if (gate == NULL) {
4038 fprintf(f,"#ifndef STDPCCTS_H\n"); /* MR10 */
4039 fprintf(f,"#define STDPCCTS_H\n"); /* MR10 */
4040 } else {
4041 fprintf(f,"#ifndef STDPCCTS_%s_H\n",gate); /* MR10 */
4042 fprintf(f,"#define STDPCCTS_%s_H\n",gate); /* MR10 */
4043 };
4044 fprintf(f,"/*\n");
4045 if (gate == NULL) {
4046 fprintf(f," * %s -- P C C T S I n c l u d e\n", stdpccts);
4047 } else {
4048 fprintf(f," * Standard PCCTS include file with -fh %s -- P C C T S I n c l u d e\n", stdpccts);
4049 }
4050 fprintf(f," *\n");
4051 fprintf(f," * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");
4052 fprintf(f," * Purdue University Electrical Engineering\n");
4053 fprintf(f," * With AHPCRC, University of Minnesota\n");
4054 fprintf(f," * ANTLR Version %s\n", Version);
4055 fprintf(f," */\n\n");
4056
4057 fprintf(f,"#ifndef ANTLR_VERSION\n");
4058 fprintf(f,"#define ANTLR_VERSION %s\n", VersionDef);
4059 fprintf(f,"#endif\n\n");
4060
4061 if (FirstAction != NULL ) dumpAction(FirstAction, f, 0, -1, 0, 1); /* MR11 */
4062
4063 fprintf(f,"#include \"pcctscfg.h\"\n");
4064 fprintf(f,"#include \"pccts_stdio.h\"\n");
4065 if ( GenCC )
4066 {
4067 if ( UserDefdTokens )
4068 fprintf(f, "#include %s\n", UserTokenDefsFile);
4069 else {
4070 fprintf(f, "#include \"%s\"\n", DefFileName);
4071 }
4072
4073 fprintf(f, "#include \"%s\"\n", ATOKEN_H);
4074
4075 if ( HdrAction != NULL ) dumpAction( HdrAction, f, 0, -1, 0, 1);
4076
4077 fprintf(f, "#include \"%s\"\n", ATOKENBUFFER_H);
4078
4079 if ( OutputLL_k > 1 ) fprintf(f,"static const unsigned LL_K=%d;\n", OutputLL_k);
4080 if ( GenAST ) {
4081 fprintf(f, "#include \"%s\"\n", ASTBASE_H);
4082 }
4083
4084 if (TraceGen) {
4085 fprintf(f,"#ifndef zzTRACE_RULES\n"); /* MR20 */
4086 fprintf(f,"#define zzTRACE_RULES\n"); /* MR20 */
4087 fprintf(f,"#endif\n"); /* MR22 */
4088 };
4089
4090 fprintf(f,"#include \"%s\"\n", APARSER_H);
4091 fprintf(f,"#include \"%s.h\"\n", CurrentClassName);
4092 if ( LexGen ) fprintf(f,"#include \"%s\"\n", DLEXERBASE_H);
4093 fprintf(f, "#endif\n");
4094 return;
4095 }
4096
4097 if ( strcmp(ParserName, DefaultParserName)!=0 )
4098 fprintf(f, "#define %s %s\n", DefaultParserName, ParserName);
4099 if ( strcmp(ParserName, DefaultParserName)!=0 )
4100 fprintf(f, "#include \"%s\"\n", RemapFileName);
4101 if ( UserTokenDefsFile != NULL )
4102 fprintf(f, "#include %s\n", UserTokenDefsFile);
4103 if ( HdrAction != NULL ) dumpAction( HdrAction, f, 0, -1, 0, 1);
4104 if ( FoundGuessBlk )
4105 {
4106 fprintf(f,"#define ZZCAN_GUESS\n");
4107 fprintf(f,"#include \"pccts_setjmp.h\"\n");
4108 }
4109 if (TraceGen) {
4110 fprintf(f,"#ifndef zzTRACE_RULES\n"); /* MR20 */
4111 fprintf(f,"#define zzTRACE_RULES\n"); /* MR20 */
4112 fprintf(f,"#endif\n"); /* MR22 */
4113 };
4114 if ( OutputLL_k > 1 ) fprintf(f,"#define LL_K %d\n", OutputLL_k);
4115 if ( GenAST ) fprintf(f,"#define GENAST\n");
4116 if ( FoundException )
4117 {
4118 /* MR1 7-Apr-97 1.33MR1 */
4119 /* MR1 Fix suggested by: */
4120 /* MR1 Francois-Xavier Fontaine (fontaine_f@istvax.ist.lu) */
4121
4122 fprintf(f,"#define EXCEPTION_HANDLING\n"); /* MR1 */
4123 fprintf(f,"#define NUM_SIGNALS %d\n", NumSignals); /* MR1 */
4124 }
4125 if ( DemandLookahead ) fprintf(f,"#define DEMAND_LOOK\n");
4126 #ifdef DUM
4127 if ( LexGen ) fprintf(f, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));
4128 #endif
4129 /* ###WARNING: This will have to change when SetWordSize changes */
4130 fprintf(f, "#define zzSET_SIZE %d\n", (GR_INT)(NumWords(TokenNum-1)*sizeof(unsigned)));
4131 if (TraceGen) {
4132 fprintf(f,"#ifndef zzTRACE_RULES\n"); /* MR20 */
4133 fprintf(f,"#define zzTRACE_RULES\n"); /* MR20 */
4134 fprintf(f,"#endif\n"); /* MR22 */
4135 };
4136 fprintf(f,"#include \"antlr.h\"\n");
4137 if ( GenAST ) fprintf(f,"#include \"ast.h\"\n");
4138 if ( UserDefdTokens )
4139 fprintf(f, "#include %s\n", UserTokenDefsFile);
4140 /* still need this one as it has the func prototypes */
4141 fprintf(f, "#include \"%s\"\n", DefFileName);
4142 /* still need this one as it defines the DLG interface */
4143 fprintf(f,"#include \"dlgdef.h\"\n");
4144 /* don't need this one unless DLG is used */
4145 if ( LexGen ) fprintf(f,"#include \"%s\"\n", ModeFileName);
4146 fprintf(f,"#endif\n");
4147 }
4148
4149 /* dump action 's' to file 'output' starting at "local" tab 'tabs'
4150 Dump line information in front of action if GenLineInfo is set
4151 If file == -1 then GenLineInfo is ignored.
4152 The user may redefine the LineInfoFormatStr to his/her liking
4153 most compilers will like the default, however.
4154
4155 June '93; changed so that empty lines are left alone so that
4156 line information is correct for the compiler/debuggers.
4157 */
4158 void
4159 #ifdef __USE_PROTOS
4160 dumpAction( char *s, FILE *output, int tabs, int file, int line,
4161 int final_newline )
4162 #else
4163 dumpAction( s, output, tabs, file, line, final_newline )
4164 char *s;
4165 FILE *output;
4166 int tabs;
4167 int file;
4168 int line;
4169 int final_newline;
4170 #endif
4171 {
4172 int inDQuote, inSQuote;
4173 require(s!=NULL, "dumpAction: NULL action");
4174 require(output!=NULL, eMsg1("dumpAction: output FILE is NULL for %s",s));
4175
4176 if ( GenLineInfo && file != -1 )
4177 {
4178 OutLineInfo(output,line,FileStr[file]);
4179 }
4180 PastWhiteSpace( s );
4181 /* don't print a tab if first non-white char is a # (preprocessor command) */
4182 if ( *s!='#' ) {TAB;}
4183 inDQuote = inSQuote = FALSE;
4184 while ( *s != '\0' )
4185 {
4186 if ( *s == '\\' )
4187 {
4188 fputc( *s++, output ); /* Avoid '"' Case */
4189 if ( *s == '\0' ) return;
4190 if ( *s == '\'' ) fputc( *s++, output );
4191 if ( *s == '\"' ) fputc( *s++, output );
4192 }
4193 if ( *s == '\'' )
4194 {
4195 if ( !inDQuote ) inSQuote = !inSQuote;
4196 }
4197 if ( *s == '"' )
4198 {
4199 if ( !inSQuote ) inDQuote = !inDQuote;
4200 }
4201 if ( *s == '\n' )
4202 {
4203 fputc('\n', output);
4204 s++;
4205 PastWhiteSpace( s );
4206 if ( *s == '}' )
4207 {
4208 --tabs;
4209 TAB;
4210 fputc( *s++, output );
4211 continue;
4212 }
4213 if ( *s == '\0' ) return;
4214 if ( *s != '#' ) /* #define, #endif etc.. start at col 1 */
4215 {
4216 TAB;
4217 }
4218 }
4219 if ( *s == '}' && !(inSQuote || inDQuote) )
4220 {
4221 --tabs; /* Indent one fewer */
4222 }
4223 if ( *s == '{' && !(inSQuote || inDQuote) )
4224 {
4225 tabs++; /* Indent one more */
4226 }
4227 fputc( *s, output );
4228 s++;
4229 }
4230 if ( final_newline ) fputc('\n', output);
4231 }
4232
4233 static void
4234 #ifdef __USE_PROTOS
4235 dumpAfterActions( FILE *output )
4236 #else
4237 dumpAfterActions( output )
4238 FILE *output;
4239 #endif
4240 {
4241 ListNode *p;
4242 require(output!=NULL, "dumpAfterActions: output file was NULL for some reason");
4243 if ( AfterActions != NULL )
4244 {
4245 for (p = AfterActions->next; p!=NULL; p=p->next)
4246 {
4247 UserAction *ua = (UserAction *)p->elem;
4248 dumpAction( ua->action, output, 0, ua->file, ua->line, 1);
4249 }
4250 }
4251 fclose( output );
4252 }
4253
4254 /*
4255 * Find the next action in the stream of execution. Do not pass
4256 * junctions with more than one path leaving them.
4257 * Only pass generic junctions.
4258 *
4259 * Scan forward while (generic junction with p2==NULL)
4260 * If we stop on an action, return ptr to the action
4261 * else return NULL;
4262 */
4263 static ActionNode *
4264 #ifdef __USE_PROTOS
4265 findImmedAction( Node *q )
4266 #else
4267 findImmedAction( q )
4268 Node *q;
4269 #endif
4270 {
4271 Junction *j;
4272 require(q!=NULL, "findImmedAction: NULL node");
4273 require(q->ntype>=1 && q->ntype<=NumNodeTypes, "findImmedAction: invalid node");
4274
4275 while ( q->ntype == nJunction )
4276 {
4277 j = (Junction *)q;
4278 if ( j->jtype != Generic || j->p2 != NULL ) return NULL;
4279 q = j->p1;
4280 if ( q == NULL ) return NULL;
4281 }
4282 if ( q->ntype == nAction ) return (ActionNode *)q;
4283 return NULL;
4284 }
4285
4286 static void
4287 #ifdef __USE_PROTOS
4288 dumpRetValAssign( char *retval, char *ret_def, RuleRefNode * ruleRef /* MR30 */)
4289 #else
4290 dumpRetValAssign( retval, ret_def, ruleRef /* MR30 */)
4291 char *retval;
4292 char *ret_def;
4293 RuleRefNode *ruleRefNode;
4294 #endif
4295 {
4296 char *q = ret_def;
4297
4298 tab();
4299 while ( *retval != '\0' && *q != '\0')
4300 {
4301 while ( isspace((*retval)) ) retval++;
4302 while ( *retval!=',' && *retval!='\0' ) fputc(*retval++, output);
4303 fprintf(output, " = _trv.");
4304
4305 DumpNextNameInDef(&q, output);
4306 while ( isspace(*q) ) q++;
4307 fputc(';', output); fputc(' ', output);
4308 if ( *retval == ',' ) retval++;
4309 }
4310 if (*retval == '\0' && *q != '\0') {
4311 /* MR30 */ errFL("Fewer output values than output formals for rule reference",
4312 /* MR30 */ FileStr[ruleRef->file],ruleRef->line);
4313 }
4314 if (*retval != '\0' && *q == '\0') {
4315 /* MR30 */ errFL("More output actuals than output formals for rule reference",
4316 /* MR30 */ FileStr[ruleRef->file],ruleRef->line);
4317 }
4318 }
4319
4320 /* This function computes the set of tokens that can possibly be seen k
4321 * tokens in the future from point j
4322 */
4323
4324 static set
4325 #ifdef __USE_PROTOS
4326 ComputeErrorSet( Junction *j, int k, int usePlusBlockBypass)
4327 #else
4328 ComputeErrorSet( j, k, usePlusBlockBypass )
4329 Junction *j;
4330 int k;
4331 int usePlusBlockBypass;
4332 #endif
4333 {
4334 Junction *alt1;
4335 set a, rk, f;
4336 require(j->ntype==nJunction, "ComputeErrorSet: non junction passed");
4337
4338 f = rk = empty;
4339 for (alt1=j; alt1!=NULL; alt1 = (Junction *)alt1->p2)
4340 {
4341 if (alt1->ignore && ! usePlusBlockBypass) continue; /* MR21 - Ignore aPlusBlk forward p2 */
4342 REACH(alt1->p1, k, &rk, a);
4343 require(set_nil(rk), "ComputeErrorSet: rk != nil");
4344 set_free(rk);
4345 set_orin(&f, a);
4346 set_free(a);
4347 }
4348 return f;
4349 }
4350
4351 static char *
4352 #ifdef __USE_PROTOS
4353 tokenFollowSet(TokNode *p)
4354 #else
4355 tokenFollowSet(p)
4356 TokNode *p;
4357 #endif
4358 {
4359 static char buf[100];
4360 set rk, a;
4361 int n;
4362 rk = empty;
4363
4364 REACH(p->next, 1, &rk, a);
4365 require(set_nil(rk), "rk != nil");
4366 set_free(rk);
4367 n = DefErrSet( &a, 0, NULL );
4368 set_free(a);
4369 if ( GenCC )
4370 sprintf(buf, "err%d", n);
4371 else
4372 sprintf(buf, "zzerr%d", n);
4373 return buf;
4374 }
4375
4376 static void
4377 #ifdef __USE_PROTOS
4378 makeErrorClause( Junction *q, set f, int max_k, int usePlusBlockBypass )
4379 #else
4380 makeErrorClause( q, f, max_k, usePlusBlockBypass )
4381 Junction *q;
4382 set f;
4383 int max_k;
4384 int usePlusBlockBypass;
4385 #endif
4386 {
4387 char * handler_id=""; /* MR7 */
4388 int nilf=0; /* MR13 */
4389 RuleEntry *ruleEntry; /* MR14 */
4390
4391 if ( FoundException )
4392 {
4393 _gen("else {\n");
4394 tabs++;
4395 if ( FoundGuessBlk )
4396 {
4397 if ( GenCC ) {gen("if ( guessing ) goto fail;\n");}
4398 else gen("if ( zzguessing ) goto fail;\n");
4399 }
4400 gen("if (_sva) _signal=NoViableAlt;\n");
4401 gen("else _signal=NoSemViableAlt;\n");
4402 if (q->outerEG != NULL) {
4403 handler_id=q->outerEG->altID;
4404 #if 0
4405 } else {
4406 printf("q->curAltNum=%d q->exception_label=%s\n",q->curAltNum,q->exception_label);
4407 gen("*** DEBUG *** outerEG==NULL\n");
4408 #endif
4409 };
4410 gen1("goto %s_handler; /* MR7 */\n",handler_id); /* MR7 */
4411 tabs--;
4412 gen("}\n");
4413 return;
4414 }
4415
4416 if ( max_k == 1 )
4417 {
4418 /* MR13 */ nilf=set_nil(f);
4419 if ( GenCC ) {
4420 _gen1("else {FAIL(1,err%d", DefErrSet1(1,&f,1,NULL));
4421 } else {
4422 _gen1("else {zzFAIL(1,zzerr%d", DefErrSet1(1,&f,1,NULL));
4423 };
4424 set_free(f);
4425 }
4426 else
4427 {
4428 int i;
4429 set_free(f);
4430 if ( GenCC ) {_gen1("else {FAIL(%d", max_k);}
4431 else _gen1("else {zzFAIL(%d", max_k);
4432
4433 ruleEntry = (RuleEntry *) hash_get(Rname,q->rname);
4434
4435 for (i=1; i<=max_k; i++)
4436 {
4437 /* MR14 */ if (ruleEntry->dontComputeErrorSet) {
4438 /* MR14 */ f=empty;
4439 } else {
4440 f = ComputeErrorSet(q, i, usePlusBlockBypass /* use plus block bypass ? */ );
4441 }
4442
4443 if ( GenCC ) {_gen1(",err%d", DefErrSet( &f, 1, NULL ));}
4444 else _gen1(",zzerr%d", DefErrSet( &f, 1, NULL ));
4445
4446 set_free(f);
4447 }
4448 }
4449 _gen(",&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\n");
4450 /* MR13 */ if (nilf) {
4451 /* MR13 */ errFL("empty error set for alt - probably because of undefined rule or infinite left recursion",
4452 /* MR13 */ FileStr[q->file],q->line);
4453 /* MR13 */ gen(" /* MR13 empty error set for this alt - undef rule ? infinite left recursion ? */");
4454 /* MR13 */ };
4455 }
4456
4457 static /* MR7 */
4458 #ifdef __USE_PROTOS
4459 char * findOuterHandlerLabel(ExceptionGroup *eg) /* MR7 */
4460 #else
4461 char * findOuterHandlerLabel(eg) /* MR7 */
4462 ExceptionGroup *eg; /* MR7 */
4463 #endif
4464 {
4465 char *label=NULL; /* MR7 */
4466 ExceptionGroup *outerEG; /* MR7 */
4467
4468 if (eg->forRule == 0) { /* MR7 */
4469 if (eg->labelEntry != NULL) { /* MR7 */
4470 outerEG=eg->labelEntry->outerEG; /* MR7 */
4471 if (outerEG != NULL) { /* MR7 */
4472 label=outerEG->altID; /* MR7 */
4473 outerEG->used=1; /* MR7 */
4474 }; /* MR7 */
4475 } else if (eg->outerEG != NULL) { /* MR7 */
4476 outerEG=eg->outerEG; /* MR7 */
4477 label=outerEG->altID; /* MR7 */
4478 outerEG->used=1; /* MR7 */
4479 }; /* MR7 */
4480 }; /* MR7 */
4481 return (label==NULL ? "" : label); /* MR7 */
4482 } /* MR7 */
4483
4484 /*** debug ***/
4485 #if 0
4486 ** static /* MR7 */
4487 ** #ifdef __USE_PROTOS
4488 ** char * findOuterAltHandlerLabel(Junction *startJ) /* MR7 */
4489 ** #else
4490 ** char * findOuterAltHandlerLabel(startJ) /* MR7 */
4491 ** Junction *startJ; /* MR7 */
4492 ** #endif
4493 ** { /* MR7 */
4494 ** char *label=NULL; /* MR7 */
4495 ** Junction *alt; /* MR7 */
4496 ** /* MR7 */
4497 ** for (alt=startJ; alt != NULL; alt=alt->outerAltstart) { /* MR7 */
4498 ** label=alt->exception_label; /* MR7 */
4499 ** if (label != NULL) break; /* MR7 */
4500 ** }; /* MR7 */
4501 ** return (label==NULL ? "" : label); /* MR7 */
4502 ** } /* MR7 */
4503 #endif
4504
4505 #ifdef __USE_PROTOS
4506 static void OutLineInfo(FILE *file,int line,char *fileName)
4507 #else
4508 static void OutLineInfo(file,line,fileName)
4509 FILE * file;
4510 int line;
4511 char * fileName;
4512 #endif
4513 {
4514 static char * prevFileName=NULL;
4515 static char * prevFileNameMS=NULL;
4516
4517 char * p;
4518 char * q;
4519
4520 if (! GenLineInfo) return;
4521
4522 if (!GenLineInfoMS) {
4523 fprintf(file, LineInfoFormatStr,line,fileName);
4524 } else {
4525 if (fileName == prevFileName) {
4526 fprintf(file, LineInfoFormatStr,line,prevFileNameMS);
4527 } else {
4528 if (prevFileNameMS != NULL) free (prevFileNameMS);
4529 prevFileNameMS=(char *)calloc(1,strlen(fileName)+1);
4530 require(prevFileNameMS != NULL,"why not do this in calloc wrapper");
4531 q=prevFileNameMS;
4532 for (p=fileName; *p != 0; p++) {
4533 *q=*p;
4534 if (*q == '\\') *q='/';
4535 q++;
4536 }
4537 }
4538 prevFileName=fileName;
4539 };
4540 }
4541
4542 #if 0
4543
4544 /* MR21 */
4545
4546 #ifdef __USE_PROTOS
4547 void OutFirstSetSymbol(Junction *q, char * pSymbol)
4548 #else
4549 void OutFirstSetSymbol(q, pSymbol)
4550 Junction* q;
4551 char * pSymbol
4552 #endif
4553 {
4554
4555 set f;
4556 if (pSymbol == NULL) return;
4557 gen1("/** #FirstSetSymbol(%s) **/\n",pSymbol);
4558 f = ComputeErrorSet(q, 1, 0 /* use plus block bypass ? */);
4559 DefErrSetWithSuffix (0 /* nil ok */, &f,0 /* no substitute */, pSymbol, "");
4560 set_free(f);
4561 }
4562 #endif
4563
4564 /* MR21 */
4565
4566 #ifdef __USE_PROTOS
4567 void BlockPreambleOption(Junction *q, char * pSymbol)
4568 #else
4569 void BlockPreambleOption(q, pSymbol)
4570 Junction* q;
4571 char * pSymbol;
4572 #endif
4573 {
4574 set f = empty;
4575 if (pSymbol != NULL) {
4576 f = ComputeErrorSet(q, 1, 0 /* use plus block bypass ? */);
4577 gen1("/** #FirstSetSymbol(%s) **/\n",pSymbol);
4578 DefErrSetWithSuffix (0 /* nil ok */, &f,0 /* no substitute */, pSymbol, "");
4579 }
4580 set_free(f);
4581 }
4582
4583 /* MR21 */
4584
4585 void
4586 #ifdef __USE_PROTOS
4587 dumpActionPlus(ActionNode *a, char *s, FILE *output, int tabs, int file, int line,
4588 int final_newline )
4589 #else
4590 dumpActionPlus(a, s, output, tabs, file, line, final_newline )
4591 ActionNode *a;
4592 char *s;
4593 FILE *output;
4594 int tabs;
4595 int file;
4596 int line;
4597 int final_newline;
4598 #endif
4599 {
4600 dumpAction(s,output,tabs,file,line,final_newline);
4601 }
4602
4603
4604 #if 0
4605 ** #ifdef __USE_PROTOS
4606 ** void MR_ErrorSets(Junction *q, int max_k, int usePlusBlockBypass)
4607 ** #else
4608 ** void MR_ErrorSets(q, max_k, usePlusBlockBypass)
4609 ** Junction *q;
4610 ** int max_k;
4611 ** int usePlusBlockBypass;
4612 ** #endif
4613 ** {
4614 ** int k;
4615 ** set setResult;
4616 ** Junction* alt1;
4617 ** Junction* p;
4618 ** set rk;
4619 **
4620 ** require (max_k <= CLL_k, "k > CLL_k");
4621 **
4622 **
4623 ** for (k = 1; k <= CLL_k; k++) {set_clr(q->fset[k]); }
4624 **
4625 ** for (k = 1; k <= max_k; k++) {
4626 ** for (alt1=q; alt1 != NULL; alt1 = (Junction *)alt1->p2)
4627 ** {
4628 ** if (alt1->ignore && ! usePlusBlockBypass) continue;
4629 ** p = analysis_point((Junction *)alt1->p1);
4630 ** REACH(p, k, &rk, setResult);
4631 ** require(set_nil(rk), "rk != nil");
4632 ** set_orin(&q->fset[k], setResult);
4633 ** }
4634 ** }
4635 ** }
4636 #endif
4637
4638
4639 #ifdef __USE_PROTOS
4640 void DumpInitializers(FILE* output, RuleEntry *r, char * pReturn)
4641 #else
4642 void DumpInitializers(output, r, pReturn)
4643 FILE* output;
4644 RuleEntry *r;
4645 char * pReturn;
4646 #endif
4647 {
4648 char *p = pReturn;
4649 char *pDataType;
4650 char *pSymbol;
4651 char *pEqualSign;
4652 char *pValue;
4653 char *pSeparator;
4654 int nest = 0;
4655 char *q;
4656
4657 require(pReturn!=NULL, "DumpInitializer: invalid string");
4658
4659 while (*p != 0) {
4660 p = endFormal(p,
4661 &pDataType,
4662 &pSymbol,
4663 &pEqualSign,
4664 &pValue,
4665 &pSeparator,
4666 &nest);
4667 if (nest != 0) return;
4668 if (pValue != NULL) {
4669 tab();
4670 q = strBetween(pSymbol, pEqualSign, pSeparator);
4671 fprintf(output, "_retv.%s", q);
4672 q = strBetween(pValue, NULL, pSeparator);
4673 fprintf(output, " = %s;\n", q);
4674 }
4675 }
4676 }
4677
4678 #ifdef __USE_PROTOS
4679 void DumpFormals(FILE* output, char * pReturn, int bInitializer)
4680 #else
4681 void DumpFormals(output, pReturn, bInitializer)
4682 FILE* output;
4683 char * pReturn;
4684 int bInitializer;
4685 #endif
4686 {
4687 char *p = pReturn;
4688 char *pDataType;
4689 char *pSymbol;
4690 char *pEqualSign;
4691 char *pValue;
4692 char *pSeparator;
4693 int nest = 0;
4694 char *q;
4695 int count = 0;
4696
4697 require(pReturn!=NULL, "DumpFormals: invalid string");
4698
4699 while (*p != 0) {
4700 p = endFormal(p,
4701 &pDataType,
4702 &pSymbol,
4703 &pEqualSign,
4704 &pValue,
4705 &pSeparator,
4706 &nest);
4707 if (nest != 0) return;
4708 if (count > 0) fprintf(output,",");
4709 if (pDataType != NULL && pSymbol != NULL) {
4710 q = strBetween(pDataType, pSymbol, pSeparator);
4711 fprintf(output, "%s", q);
4712 q = strBetween(pSymbol, pEqualSign, pSeparator);
4713 fprintf(output," %s",q);
4714 if (pValue != NULL) {
4715 q = strBetween(pValue, NULL, pSeparator);
4716 if (bInitializer != 0) {
4717 fprintf(output, " = %s", q);
4718 }
4719 }
4720 }
4721 count++;
4722 }
4723 }
4724
4725 /* MR23 Check for empty alt in a more intelligent way.
4726 Previously, an empty alt for genBlk had to point directly
4727 to the endBlock. This did not work once I changed {...}
4728 blocks to look like (...|...| epsilon) since there were
4729 intervening generics. This fixes the problem for this
4730 particular case. Things like actions or empty blocks of
4731 various kinds will still cause problems, but I wasnt't
4732 prepared to handle pathological cases like (A|()*). It
4733 does handle (A | ()), which is a recommended idiom for
4734 epsilon.
4735
4736 Actually, this isn't quite correct since it doesn't handle
4737 the case of the ignore bit in the plus block bypass, but
4738 I'm too tired to figure out the correct fix, and will just
4739 work around it.
4740 */
4741
4742 #ifdef __USE_PROTOS
4743 int isEmptyAlt(Node * alt, Node * endBlock)
4744 #else
4745 int isEmptyAlt(alt, endBlock)
4746 Node * alt;
4747 Node * endBlock;
4748 #endif
4749 {
4750 Node * n = alt;
4751 Junction * j;
4752 while (n != endBlock) {
4753 switch (n->ntype) {
4754
4755 case nRuleRef:
4756 return 0;
4757
4758 case nToken:
4759 return 0;
4760
4761 case nAction:
4762 return 0;
4763
4764 case nJunction:
4765 goto JUNCTION;
4766
4767 default:
4768 fatal_internal("Invalid node type");
4769 return 0;
4770 }
4771 JUNCTION:
4772 j = (Junction *) n;
4773
4774 switch (j->jtype) {
4775 case Generic:
4776 {
4777 n = j->p1;
4778 goto NEXT;
4779 }
4780
4781 case aSubBlk:
4782 {
4783 n = j->p1; /* MR26 */
4784 goto NEXT; /* MR26 */
4785 }
4786
4787 case EndBlk:
4788 return 0;
4789
4790 case EndRule:
4791 return 1;
4792
4793 default:
4794 return 0;
4795 }
4796 NEXT: continue;
4797 }
4798 return 1;
4799 }
+0
-286
contrib/pccts/antlr/generic.h less more
0 /*
1 * generic.h -- generic include stuff for new PCCTS ANTLR.
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1989-2001
28 */
29
30 #define StrSame 0
31
32 #define DefaultParserName "zzparser"
33
34 /* MR9 JVincent@novell.com Allow user to override default ZZLEXBUFSIZE */
35 /* MR11 thm Raise antlr's own default ZZLEXBUFSIZE to 8k */
36 /* MR22 thm Raise antlr's own default ZZLEXBUFSIZE to 32k */
37
38 #ifndef ZZLEXBUFSIZE
39 #define ZZLEXBUFSIZE 32000
40 #endif
41
42 /* Tree/FIRST/FOLLOW defines -- valid only after all grammar has been read */
43 #define ALT TokenNum+1
44 #define SET TokenNum+2
45 #define TREE_REF TokenNum+3
46
47 /* E r r o r M a c r o s */
48
49 #define fatal(err) fatalFL(err, __FILE__, __LINE__)
50 #define fatal_internal(err) fatal_intern(err, __FILE__, __LINE__)
51
52
53 #define eMsg1(s,a) eMsg3(s,a,NULL,NULL)
54 #define eMsg2(s,a,b) eMsg3(s,a,b,NULL)
55
56 /* S a n i t y C h e c k i n g */
57
58 #ifndef require
59 #define require(expr, err) {if ( !(expr) ) fatal_internal(err);}
60 #endif
61
62 /* L i s t N o d e s */
63
64 typedef struct _ListNode {
65 void *elem; /* pointer to any kind of element */
66 struct _ListNode *next;
67 } ListNode;
68
69 /* Define a Cycle node which is used to track lists of cycles for later
70 * reconciliation by ResolveFoCycles().
71 */
72 typedef struct _c {
73 int croot; /* cycle root */
74 set cyclicDep; /* cyclic dependents */
75 unsigned deg; /* degree of FOLLOW set of croot */
76 } Cycle;
77
78 typedef struct _e {
79 int tok; /* error class name == TokenStr[tok] */
80 ListNode *elist; /* linked list of elements in error set */
81 set eset;
82 int setdeg; /* how big is the set */
83 int lexclass; /* which lex class is it in? */
84 } ECnode;
85
86 typedef struct _TCnode {
87 int tok; /* token class name */
88 ListNode *tlist; /* linked list of elements in token set */
89 set tset;
90 int lexclass; /* which lex class is it in? */
91 unsigned char dumped; /* this def has been been dumped */
92 unsigned char dumpedComplement; /* this def has been been dumped */
93 unsigned setnum; /* which set number is this guy? (if dumped) */
94 unsigned setnumComplement; /* MR23 */
95 unsigned setnumErrSet; /* MR23 which set is this #tokclass error set (if dumped) */
96 unsigned setnumErrSetComplement; /* MR23 */
97 } TCnode;
98
99 typedef struct _ft {
100 char *token; /* id of token type to remap */
101 int tnum; /* move token type to which token position */
102 } ForcedToken;
103
104 typedef struct _ContextGuardPredicates { /* MR13 */
105 Predicate *pred; /* MR13 */
106 } ContextGuardPredicates; /* MR13 */
107
108 #define newListNode (ListNode *) calloc(1, sizeof(ListNode));
109 #define newCycle (Cycle *) calloc(1, sizeof(Cycle));
110 #define newECnode (ECnode *) calloc(1, sizeof(ECnode));
111 #define newTCnode (TCnode *) calloc(1, sizeof(TCnode));
112
113
114 /* H a s h T a b l e E n t r i e s */
115
116 typedef struct _t { /* Token name or expression */
117 char *str;
118 struct _t *next;
119 int token; /* token number */
120 unsigned char classname; /* is it a err/tok class name or token */
121 TCnode *tclass; /* ptr to token class */
122 char *action;
123 char *akaString;
124 } TermEntry;
125
126 typedef struct _r { /* Rule name and ptr to start of rule */
127 char *str;
128 struct _t *next;
129 int rulenum; /* RulePtr[rulenum]== ptr to RuleBlk junction */
130 unsigned char noAST;/* gen AST construction code? (def==gen code) */
131 char *egroup; /* which error group (err reporting stuff) */
132 #if 0
133 /* MR27 This appears to never be used. Delete this code later. */
134
135 ListNode *el_labels;/* list of element labels ref in all of rule */
136 #endif
137 ListNode *ast_labels_in_actions; /* MR27 */
138 unsigned char has_rule_exception;
139 char dontComputeErrorSet; /* MR14 - don't compute error set
140 special for rule in alpha part of
141 (alpha)? beta block */
142 } RuleEntry;
143
144 typedef struct _f { /* cache Fi/Fo set */
145 char *str; /* key == (rulename, computation, k) */
146 struct _f *next;
147 set fset; /* First/Follow of rule */
148 set rk; /* set of k's remaining to be done after ruleref */
149 int incomplete; /* only w/FOLLOW sets. Use only if complete */
150 } CacheEntry;
151
152 typedef struct _LabelEntry { /* element labels */
153 char *str;
154 struct _f *next;
155 Node *elem; /* which element does it point to? */
156 ExceptionGroup *ex_group;
157 /* Is there an exception attached to label? */
158 ExceptionGroup *outerEG; /* MR7 */
159 /* next EG if ex_group doesn't catch it MR7 */
160 struct _LabelEntry *pendingLink; /* MR7 */
161 /* too lazy to use ListNode ? MR7 */
162 int curAltNum; /* MR7 */
163 } LabelEntry;
164
165 typedef struct _SignalEntry {
166 char *str;
167 struct _f *next;
168 int signum; /* unique signal number */
169 } SignalEntry;
170
171 typedef struct _PredEntry { /* MR11 predicate name and ptr to string */
172 char *str;
173 struct _PredEntry *next;
174 int file;
175 int line;
176 Predicate *pred;
177 char *predLiteral;
178 } PredEntry;
179
180 typedef struct _PointerStack { /* MR10 */
181 int count;
182 int size;
183 void **data;
184 } PointerStack;
185
186 #define newTermEntry(s) (TermEntry *) newEntry(s, sizeof(TermEntry))
187 #define newRuleEntry(s) (RuleEntry *) newEntry(s, sizeof(RuleEntry))
188 #define newCacheEntry(s) (CacheEntry *) newEntry(s, sizeof(CacheEntry))
189 #define newLabelEntry(s) (LabelEntry *) newEntry(s, sizeof(LabelEntry))
190 #define newSignalEntry(s) (SignalEntry *) newEntry(s, sizeof(SignalEntry))
191 #define newPredEntry(s) (PredEntry *) newEntry(s,sizeof(PredEntry))
192
193 typedef struct _UserAction {
194 char *action;
195 int file, line;
196 } UserAction;
197
198
199 /* L e x i c a l C l a s s */
200
201 /* to switch lex classes, switch ExprStr and Texpr (hash table) */
202 typedef struct _lc {
203 char *classnum, **exprs;
204 Entry **htable;
205 } LClass;
206
207 typedef struct _exprOrder {
208 char *expr;
209 int lclass;
210 } Expr;
211
212
213 typedef Graph Attrib;
214
215 /* M a x i m u m s */
216
217 /* MR20 Note G. Hobbelt These values are superceded by values in hash.h */
218
219 #ifndef HashTableSize
220 #define HashTableSize 253
221 #endif
222 #ifndef StrTableSize
223 #define StrTableSize 15000 /* all tokens, nonterminals, rexprs stored here */
224 #endif
225 #define MaxLexClasses 50 /* how many automatons */
226 /* TokenStart and EofToken are ignored if #tokdefs meta-op is used */
227 #define TokenStart 2 /* MUST be in 1 + EofToken */
228 #define EofToken 1 /* Always predefined to be 1 */
229
230 #ifndef MaxNumFiles
231 #define MaxNumFiles 99
232 #endif
233
234 /**** MR9 JVincent@novell.com Move to pcctscfg.h */
235 /**** #define MaxFileName 300 ****/ /* MR9 Move to pcctscfg.h */ /* largest file name size */
236
237 #define MaxRuleName 100 /* largest rule name size */
238 #define TSChunk 100 /* how much to expand TokenStr/ExprStr each time */
239 #define TIChunk TSChunk /* expand TokenInd by same as TokenStr to mirror them */
240 #define FoStackSize 100 /* deepest FOLLOW recursion possible */
241
242 #define MaxClassDeclStuff 256 /* MR10 */
243
244 #define NumPredefinedSignals 3
245
246 /* S t a n d a r d S i g n a l s */
247
248 #define sigNoSignal 0
249 #define sigMismatchedToken 1
250 #define sigNoViableAlt 2
251 #define sigNoSemViableAlt 3
252
253
254
255 /* AST token types */
256 #define ASTexclude 0
257 #define ASTchild 1
258 #define ASTroot 2
259 #define ASTinclude 3 /* include subtree made by rule ref */
260
261
262 #define PredictionVariable "zzpr_expr"
263 #define PredictionLexClassSuffix "_zzpred"
264
265 #define WildCardString "WildCard"
266
267 #if 0
268 /* Removed in version 1.33MR19
269 Don't understand why this never caused problems before
270 */
271
272 /*********************************************************
273 #ifndef ANTLRm
274 #define ANTLRm(st, f, _m) zzbufsize = ZZLEXBUFSIZE;\
275 zzmode(_m); \
276 zzenterANTLR(f); \
277 st; ++zzasp; \
278 zzleaveANTLR(f);
279 #endif
280 *********************************************************/
281 #endif
282
283 #include "proto.h"
284 #include "pcctscfg.h" /* MR14 */
285 #include <string.h>
+0
-484
contrib/pccts/antlr/globals.c less more
0 /*
1 * globals.c -- File containing all variables/tables visible to all files.
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1989-2001
28 */
29
30 #include <stdio.h>
31
32 #include "pcctscfg.h"
33
34 #include "set.h"
35 #include "syn.h"
36 #include "hash.h"
37 #include "generic.h"
38
39 char Version[] = "1.33MR33" ; /* PCCTS version number */ /* MRXXX */
40 char VersionDef[] = "13333"; /* same (except int equiv for preproc symbol) */ /* MRXXX */
41
42 char LexStartSymbol[] = "START";/* Name of starting lexical class/automaton */
43 char *RemapFileName = "remap.h";
44 char *DlgFileName = "parser.dlg";
45 char *DefFileName = "tokens.h";
46 char *ErrFileName = "err.c";
47 char *ModeFileName = "mode.h";
48 char *StdMsgName = NULL;
49
50 char *ParserName = DefaultParserName;
51
52 /* list of PCCTS supplied support symbols; these are renamed when more than
53 * one ANTLR-generated parsers are linked together to avoid name conflicts.
54 * Can't use '##' ANSIC preprocessor concat operator with K&R and:
55 * #define zzskip zzparser ## skip
56 * will not work for ANSI/C++ as 'zzparserskip' is created w/o zzparser
57 * being substituted--ack!!!
58 */
59 char *StandardSymbols[] = {
60 /* ANTLR stuff */
61 "zzStackOvfMsg",
62 "zzasp",
63 "zzaStack",
64 "inf_tokens",
65 "inf_text",
66 "inf_text_buffer",
67 "inf_text_buffer_ptr",
68 "inf_text_buffer_size",
69 "inf_labase",
70 "inf_last",
71 "inf_lap",
72 "zztokenLA",
73 "zztextLA",
74 "zzlap",
75 "zzlabase",
76 "zztoktext",
77 "zztoken",
78 "zzdirty",
79 "zzguessing",
80 "zzguess_start",
81 "zzresynch",
82 "zzinf_tokens",
83 "zzinf_text",
84 "zzinf_text_buffer",
85 "zzinf_labase",
86 "zzinf_last",
87 "zzfill_inf_look",
88 "zzFAIL",
89 "zzsave_antlr_state",
90 "zzrestore_antlr_state",
91 "zzsyn",
92 "zzset_el",
93 "zzset_deg",
94 "zzedecode",
95 "_zzsetmatch",
96 "_zzmatch",
97 "_inf_zzgettok",
98 "zzconsumeUntil",
99 "zzconsumeUntilToken",
100 "_zzmatch_wsig",
101 "_zzsetmatch_wsig",
102 "_zzmatch_wdfltsig",
103 "_zzsetmatch_wdfltsig",
104 "zzdflthandlers",
105 /* DLG stuff */
106 "zzreal_line",
107 "zzcharfull",
108 "zzerr",
109 "zzlextext",
110 "zzbegexpr",
111 "zzendexpr",
112 "zzbufsize",
113 "zzbegcol",
114 "zzendcol",
115 "zzline",
116 "zzchar",
117 "zzbufovf",
118 "zzrdstream",
119 "zzrdfunc",
120 "zzrdstr",
121 "zzclose_stream",
122 "zzsave_dlg_state",
123 "zzrestore_dlg_state",
124 "zzmode",
125 "zzskip",
126 "zzmore",
127 "zzreplchar",
128 "zzreplstr",
129 "zzgettok",
130 "zzadvance",
131 "zzerrstd",
132 "zzerr_in",
133 "zzconstr_attr",
134 "zzempty_attr",
135 "zzerraction",
136 "zztokens", /* list of token regular expressions */
137 "dfa",
138 "accepts",
139 "actions",
140 "zzTraceOptionValue", /* MR10 */
141 "zzTraceGuessOptionValue", /* MR10 */
142 "zzTraceCurrentRuleName", /* MR10 */
143 "zzTraceDepth", /* MR10 */
144 "zzGuessSeq", /* MR10 */
145 "zzSyntaxErrCount", /* MR11 */
146 "zzLexErrCount", /* MR11 */
147 "zzTraceGuessDone", /* MR13 - BJS */
148 "zzTraceGuessFail", /* MR13 - BJS */
149 "zzTraceGuessOption", /* MR13 - BJS */
150 "zzTraceIn", /* MR13 - BJS */
151 "zzTraceOption", /* MR13 - BJS */
152 "zzTraceOut", /* MR13 - BJS */
153 "zzTraceReset", /* MR13 - BJS */
154 NULL /* must be present */
155 };
156
157 /* list of PCCTS supplied support functions; these are renamed when more than
158 * one ANTLR-generated parsers are linked together to avoid name conflicts.
159 */
160 char *ASTSymbols[] = {
161 "AST",
162 "zzast_sp",
163 "zzastStack",
164 "zzlink",
165 "zzastnew",
166 "zzsubchild",
167 "zzsubroot",
168 "zzpre_ast",
169 "zzfree_ast",
170 "zztmake",
171 "zzdup_ast",
172 "zztfree",
173 "zzdouble_link",
174 NULL /* must be present */
175 };
176
177 /* Current ambiguity examination information */
178 int CurAmbigAlt1, CurAmbigAlt2, CurAmbigline, CurAmbigfile;
179 char *CurAmbigbtype;
180
181
182 /* M e t h o d T a b l e s */
183 /*
184 * The following tables are used to fill syntax diagram nodes with the correct
185 * function pointers for computing FIRST sets and printing themselves.
186 */
187
188 /* fpTraverse[node type] == pointer to function that calculates trees
189 * representing the FIRST sets for that node (maintains spatial info).
190 * We use 'struct _tree' not 'tree' due to a g++ 2.4.3 bug.
191 */
192 #ifdef __cplusplus
193 struct _tree *(*fpTraverse[NumNodeTypes+1])(... /* Node *, int, set * */) = {
194 NULL,
195 (struct _tree *(*)(...)) tJunc,
196 (struct _tree *(*)(...)) tRuleRef,
197 (struct _tree *(*)(...)) tToken,
198 (struct _tree *(*)(...)) tAction
199 };
200 #else
201 Tree *(*fpTraverse[NumNodeTypes+1])() = {
202 NULL,
203 tJunc,
204 tRuleRef,
205 tToken,
206 tAction
207 };
208 #endif
209
210 /* fpReach[node type] == pointer to function that calculates FIRST set for
211 * that node. (r stands for reach). We use 'struct _set' not 'set'
212 * due to a g++ 2.4.3 bug.
213 */
214 #ifdef __cplusplus
215 struct _set (*fpReach[NumNodeTypes+1])(... /* Node *, int, set * */) = {
216 NULL,
217 (struct _set (*)(...)) rJunc,
218 (struct _set (*)(...)) rRuleRef,
219 (struct _set (*)(...)) rToken,
220 (struct _set (*)(...)) rAction
221 };
222 #else
223 set (*fpReach[NumNodeTypes+1])() = {
224 NULL,
225 rJunc,
226 rRuleRef,
227 rToken,
228 rAction
229 };
230 #endif
231
232 /* fpPrint[node type] == pointer to function that knows how to print that node. */
233 #ifdef __cplusplus
234 void (*fpPrint[NumNodeTypes+1])(... /* Node * */) = {
235 NULL,
236 (void (*)(...)) pJunc,
237 (void (*)(...)) pRuleRef,
238 (void (*)(...)) pToken,
239 (void (*)(...)) pAction
240 };
241 #else
242 void (*fpPrint[NumNodeTypes+1])() = {
243 NULL,
244 pJunc,
245 pRuleRef,
246 pToken,
247 pAction
248 };
249 #endif
250
251 char *decodeJType[] = {
252 "invalid",
253 "aSubBlk",
254 "aOptBlk",
255 "aLoopBlk",
256 "EndBlk",
257 "RuleBlk",
258 "Generic",
259 "EndRule",
260 "aPlusBlk",
261 "aLoopBegin"
262 };
263
264
265 /* H a s h T a b l e s */
266
267 Entry **Tname, /* Table of all token names (maps name to tok num)*/
268 **Texpr, /* Table of all token expressions
269 (maps expr to tok num) */
270 **Rname, /* Table of all Rules (has ptr to start of rule) */
271 **Fcache, /* Cache of First/Follow Computations */
272 **Tcache; /* Tree cache; First/Follow for permute trees */
273 Entry **Elabel; /* Table of all element label names */
274 Entry **Sname; /* Signal names */
275 Entry **Pname; /* symbolic predicate names MR11 */
276
277
278 /* V a r i a b l e s */
279
280 int Save_argc; /* MR10 */
281 char **Save_argv; /* MR10 */
282 int EpToken=0; /* Imaginary Epsilon token number */
283 int WildCardToken=0;
284 int CurFile= -1; /* Index into FileStr table */
285 char *CurPredName=NULL; /* MR11 */
286 char *CurRule=NULL; /* Pointer to current rule name */
287 int CurRuleDebug=0; /* MR13 debug flag */
288 RuleEntry *CurRuleNode=NULL;/* Pointer to current rule node in syntax tree */
289 char *CurRetDef=NULL; /* Pointer to current return type definition */
290 char *CurParmDef=NULL; /* Pointer to current parameter definition */
291 Junction *CurRuleBlk=NULL; /* Pointer to current block node for enclosing block */
292 ListNode *CurExGroups=NULL; /* Current list of exception groups for rule/alts */
293 ListNode *CurElementLabels=NULL;
294 ListNode *CurAstLabelsInActions=NULL; /* MR27 */
295
296 /* MR10 used by <<>>? to set "label_used_in_semantic_pred" */
297 /* MR10 this will force LT(i) assignment even in guess mode */
298
299 ListNode *CurActionLabels=NULL; /* MR10 Element Labels appearing in last action */
300 int numericActionLabel=0 ; /* MR10 << ... $1 ... >> or << ... $1 ... >>? */
301 ListNode *NumericPredLabels=NULL; /* MR10 << ... $1 ... >>? ONLY */
302 ListNode *ContextGuardPredicateList=NULL; /* MR13 for re-evaluating predicates
303 after meta tokens are defined */
304
305 int CurBlockID=0; /* Unique int for each block */
306 int CurAltNum=0;
307 Junction *CurAltStart = NULL; /* Junction node that starts the alt */
308 Junction *OuterAltStart = NULL; /* For chaining exception groups MR7 */
309 int NumRules=0; /* Rules are from 1 to n */
310 FILE *output=NULL; /* current parser output file */
311 FILE *input=NULL; /* current grammar input file */
312 char *FileStr[MaxNumFiles];/* Ptr to array of file names on command-line */
313 int NumFiles=0; /* current grammar file number */
314 #ifdef __cplusplus
315 void (**fpTrans)(...), /* array of ptrs to funcs that translate nodes */
316 (**fpJTrans)(...); /* ... that translate junctions */
317 #else
318 void (**fpTrans)(), /* array of ptrs to funcs that translate nodes */
319 (**fpJTrans)(); /* ... that translate junctions */
320 #endif
321 int **FoStack; /* Array of LL_k ptrs to stacks of rule numbers */
322 int **FoTOS; /* FOLLOW stack top-of-stack pointers */
323 Junction *SynDiag = NULL; /* Pointer to start of syntax diagram */
324 int BlkLevel=1; /* Current block level. Set by antlr.g, used by
325 * scanner to translate $i.j attributes */
326 set reserved_positions; /* set of token positions reserved by '#token T=i' cmds */
327 set all_tokens; /* set of all token types */
328 set imag_tokens; /* set of all imaginary token types (EpToken, errclasses...) */
329 set tokclasses; /* set of all token class token types */
330 ListNode *ForcedTokens = 0; /* list of token_id/token_num pairs to remap */
331 ListNode *MetaTokenNodes=NULL; /* list of meta token refs such as token classes etc... */
332 int *TokenInd=NULL; /* an indirection level between token num and position
333 * of that token def in TokenStr and ExprStr */
334 int LastTokenCounted=0; /* ==TokenNum if no token renumbering (same as old TokenNum) */
335 int TokenNum=TokenStart;
336 char **TokenStr=NULL; /* map token # to token name */
337 char **ExprStr=NULL; /* map token # to expr */
338 Junction **RulePtr=NULL; /* map rule # to RuleBlk node of rule */
339 ListNode *ExprOrder=NULL; /* list of exprs as they are found in grammar */
340 ListNode *BeforeActions=NULL;/* list of grammar actions before rules */
341 ListNode *AfterActions=NULL;/* list of grammar actions after rules */
342 ListNode *LexActions=NULL; /* list of lexical actions */
343
344 /* MR1 */
345 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
346 /* MR1 via #lexmember <<....>> */
347 /* MR1 via #lexprefix <<....>> */
348 /* MR1 */
349
350 ListNode *LexMemberActions=NULL;/* list of lexical header member decl MR1 */
351 ListNode *LexPrefixActions=NULL;/* list of lexical header #include decl MR1 */
352 ListNode **Cycles=NULL; /* list of cycles (for each k) found when
353 doing FOLLOWs */
354 ListNode *eclasses=NULL; /* list of error classes */
355 ListNode *tclasses=NULL; /* list of token classes */
356 LClass lclass[MaxLexClasses]; /* array of lex class definitions */
357 int CurrentLexClass; /* index into lclass */
358 int NumLexClasses=0; /* in range 1..MaxLexClasses (init 0) */
359
360 char *HdrAction=NULL; /* action defined with #header */
361 char *FirstAction=NULL; /* action defined with #first MR11 */
362 FILE *ErrFile; /* sets and error recovery stuff */
363 FILE *DefFile=NULL; /* list of tokens, return value structs, setwd defs */
364 FILE *MRinfoFile=NULL; /* MR10 information file */
365 int MRinfo=0; /* MR10 */
366 int MRinfoSeq=0; /* MR10 */
367 int InfoP=0; /* MR10 predicates */
368 int InfoT=0; /* MR10 tnodes */
369 int InfoF=0; /* MR10 first/follow sets */
370 int InfoM=0; /* MR10 monitor progress */
371 int InfoO=0; /* MR12 orphan rules */
372 int TnodesInUse=0; /* MR10 */
373 int TnodesPeak=0; /* MR10 */
374 int TnodesAllocated=0; /* MR10 */
375 int TnodesReportThreshold=0; /* MR11 */
376 int PotentialSuppression=0; /* MR10 */
377 int PotentialDummy=0; /* MR10 */
378 int CannotContinue=FALSE;
379 int OutputLL_k = 1; /* LL_k for parsing must be power of 2 */
380 int action_file; /* used to track start of action */
381 int action_line;
382 int FoundGuessBlk=0; /* there is a (...)? block somewhere in grammar */
383 int FoundException=0; /* there is an exception somewhere in grammar */
384 /* MR6 Distinguish between @ operator and real exception */
385 /* MR6 by keeping separate flags for @ operator and real exceptions */
386 int FoundAtOperator=0; /* MR6 */
387 int FoundExceptionGroup=0; /* MR6 */
388 int pLevel=0; /* print Level */
389 int pAlt1,pAlt2; /* print "==>" in front of these alts */
390
391 /* C++ output stuff */
392 FILE *Parser_h, /* where subclass of ANTLRParser goes */
393 *Parser_c; /* where code for subclass of ANTLRParser goes */
394 char Parser_h_Name[MaxFileName+1] = "";
395 char Parser_c_Name[MaxFileName+1] = "";
396 char MRinfoFile_Name[MaxFileName+1] = ""; /* MR10 */
397 char *ClassDeclStuff=NULL; /* MR10 */
398 char *BaseClassName=NULL; /* MR22 */
399 /* list of actions inside the #class {...} defs */
400 ListNode *class_before_actions=NULL;
401 ListNode *class_after_actions=NULL;
402
403 char CurrentClassName[MaxRuleName]="";
404 int no_classes_found=1;
405 char *UserTokenDefsFile;
406 int UserDefdTokens=0; /* found #tokdefs? */
407 char *OutputDirectory=TopDirectory;
408 ExceptionGroup *DefaultExGroup = NULL;
409 int NumSignals = NumPredefinedSignals;
410 int ContextGuardTRAV=0;
411
412 char *MR_AmbAidRule=NULL; /* MR11 */
413 int MR_AmbAidLine=0; /* MR11 */
414 int MR_AmbAidDepth=0; /* MR11 */
415 int MR_AmbAidMultiple=0; /* MR11 */
416 int MR_skipped_e3_report=0; /* MR11 */
417 int MR_usingPredNames=0; /* MR11 */
418 int MR_BadExprSets=0; /* MR13 */
419 int MR_Inhibit_Tokens_h_Gen=0; /* MR13 */
420 int NewAST=0; /* MR13 */
421 int tmakeInParser=0; /* MR23 */
422 int AlphaBetaTrace=0; /* MR14 */
423 int MR_BlkErr=0; /* MR21 */
424 int MR_AlphaBetaMessageCount=0; /* MR14 */
425 int MR_AlphaBetaWarning=0; /* MR14 */
426 int MR_ErrorSetComputationActive=0; /* MR14 */
427 int MR_MaintainBackTrace=0; /* MR14 */
428 set MR_CompromisedRules; /* MR14 */
429
430 Junction *MR_RuleBlkWithHalt; /* MR10 */
431
432 /* C m d - L i n e O p t i o n s */
433
434 int LL_k=1; /* how many tokens of full lookahead */
435 int CLL_k= -1; /* how many tokens of compressed lookahead */
436 int PrintOut = FALSE; /* print out the grammar */
437 int PrintAnnotate = FALSE;/* annotate printout with FIRST sets */
438 int CodeGen=TRUE; /* Generate output code? */
439 int LexGen=TRUE; /* Generate lexical files? (tokens.h, parser.dlg) */
440 int GenAST=FALSE; /* Generate AST's? */
441 int GenANSI=FALSE; /* Generate ANSI code where necessary */
442 int GenExprSetsOpt=TRUE;/* use sets not (LA(1)==tok) expression lists */
443 int GenCR=FALSE; /* Generate cross reference? */
444 int GenLineInfo=FALSE; /* Generate # line "file" stuff? */
445 int GenLineInfoMS=FALSE;/* Like -gl but replace "\" with "/" for MS C/C++ systems */
446 int TraceGen=FALSE; /* Generate code to trace rule invocation */
447 int elevel=1; /* error level for ambiguity messages */
448 int GenEClasseForRules=0;/* don't generate eclass for each rule */
449 int TreeResourceLimit= -1;/* don't limit tree resource */
450 int DemandLookahead = 0;/* demand/delayed lookahead or not */
451 char *RulePrefix = ""; /* prefix each generated rule with this */
452 char *stdpccts = "stdpccts.h";/* where to generate std pccts include file */
453 int GenStdPccts = 0; /* don't gen stdpccts.h? */
454 int ParseWithPredicates = 1;
455 int WarningLevel = 1;
456 int UseStdout = 0; /* MR6 */
457 int TabWidth = 2; /* MR6 */ /* MR27 */
458 int HoistPredicateContext = 0;
459 int MRhoisting = 0; /* MR9 */
460 int MRhoistingk = 0; /* MR13 */
461 int MR_debugGenRule=0; /* MR11 */
462
463 int GenCC = 0; /* Generate C++ output */
464
465 PointerStack MR_BackTraceStack={0,0,NULL}; /* MR10 */
466 PointerStack MR_PredRuleRefStack={0,0,NULL}; /* MR10 */
467 PointerStack MR_RuleBlkWithHaltStack={0,0,NULL}; /* MR10 */
468
469 /* DontCopyTokens and Pragma_DupLabeledTokens were a bad idea. I've just
470 turned them off rather than backpatching the code. Who knows? We
471 may need them in the future.
472 */
473 int DontCopyTokens = 1; /* in C++, don't copy ANTLRToken passed to ANTLR */
474
475 /* Remember if LT(i), LA(i), or LATEXT(i) used in an action which is not
476 a predicate. If so, give a warning for novice users.
477 */
478
479 int LTinTokenAction = 0; /* MR23 */
480 int PURIFY = 1; /* MR23 */
481
482 int CurBlockID_array[MAX_BLK_LEVEL]; /* MR23 */
483 int CurAltNum_array[MAX_BLK_LEVEL]; /* MR23 */
+0
-221
contrib/pccts/antlr/hash.c less more
0 /*
1 * hash.c
2 *
3 * Manage hash tables.
4 *
5 * The following functions are visible:
6 *
7 * char *mystrdup(char *); Make space and copy string
8 * Entry **newHashTable(); Create and return initialized hash table
9 * Entry *hash_add(Entry **, char *, Entry *)
10 * Entry *hash_get(Entry **, char *)
11 *
12 * SOFTWARE RIGHTS
13 *
14 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
15 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
16 * company may do whatever they wish with source code distributed with
17 * PCCTS or the code generated by PCCTS, including the incorporation of
18 * PCCTS, or its output, into commerical software.
19 *
20 * We encourage users to develop software with PCCTS. However, we do ask
21 * that credit is given to us for developing PCCTS. By "credit",
22 * we mean that if you incorporate our source code into one of your
23 * programs (commercial product, research project, or otherwise) that you
24 * acknowledge this fact somewhere in the documentation, research report,
25 * etc... If you like PCCTS and have developed a nice tool with the
26 * output, please mention that you developed it using PCCTS. In
27 * addition, we ask that this header remain intact in our source code.
28 * As long as these guidelines are kept, we expect to continue enhancing
29 * this system and expect to make other tools available as they are
30 * completed.
31 *
32 * ANTLR 1.33
33 * Terence Parr
34 * Parr Research Corporation
35 * with Purdue University and AHPCRC, University of Minnesota
36 * 1989-2001
37 */
38
39 #include <stdio.h>
40 #include "pcctscfg.h"
41 #include "hash.h"
42
43 #ifdef __USE_PROTOS
44 #include <stdlib.h>
45 #else
46 #ifdef VAXC
47 #include <stdlib.h>
48 #else
49 #include <malloc.h>
50 #endif
51 #endif
52 #include <string.h>
53
54 #define StrSame 0
55
56 #define fatal(err) \
57 {fprintf(stderr, "%s(%d):", __FILE__, __LINE__); \
58 fprintf(stderr, " %s\n", err); exit(PCCTS_EXIT_FAILURE);}
59 #define require(expr, err) {if ( !(expr) ) fatal(err);}
60
61 static unsigned size = HashTableSize;
62 static char *strings = NULL;
63 static char *strp;
64 static unsigned strsize = StrTableSize;
65
66 /* create the hash table and string table for terminals (string table only once) */
67 Entry **
68 #ifdef __USE_PROTOS
69 newHashTable( void )
70 #else
71 newHashTable( )
72 #endif
73 {
74 Entry **table;
75
76 table = (Entry **) calloc(size, sizeof(Entry *));
77 require( table != NULL, "cannot allocate hash table");
78 if ( strings == NULL )
79 {
80 strings = (char *) calloc(strsize, sizeof(char));
81 require( strings != NULL, "cannot allocate string table");
82 strp = strings;
83 }
84 return table;
85 }
86
87 void
88 #ifdef __USE_PROTOS
89 killHashTable( Entry **table )
90 #else
91 killHashTable( table )
92 Entry **table;
93 #endif
94 {
95 /* for now, just free table, forget entries */
96 free( (char *) table ); /* MR10 cast */
97 }
98
99 /* Given a table, add 'rec' with key 'key' (add to front of list). return ptr to entry */
100 Entry *
101 #ifdef __USE_PROTOS
102 hash_add( Entry **table, char *key, Entry *rec )
103 #else
104 hash_add( table, key, rec )
105 Entry **table;
106 char *key;
107 Entry *rec;
108 #endif
109 {
110 unsigned h=0;
111 char *p=key;
112 require(table!=NULL && key!=NULL && rec!=NULL, "add: invalid addition");
113
114 Hash(p,h,size);
115 rec->next = table[h]; /* Add to singly-linked list */
116 table[h] = rec;
117 return rec;
118 }
119
120 /* Return ptr to 1st entry found in table under key (return NULL if none found) */
121 Entry *
122 #ifdef __USE_PROTOS
123 hash_get( Entry **table, char *key )
124 #else
125 hash_get( table, key )
126 Entry **table;
127 char *key;
128 #endif
129 {
130 unsigned h=0;
131 char *p=key;
132 Entry *q;
133 /* require(table!=NULL && key!=NULL, "get: invalid table and/or key");*/
134 if ( !(table!=NULL && key!=NULL) ) *((char *) 34) = 3;
135
136 Hash(p,h,size);
137 for (q = table[h]; q != NULL; q = q->next)
138 {
139 if ( strcmp(key, q->str) == StrSame ) return( q );
140 }
141 return( NULL );
142 }
143
144 #ifdef DEBUG_HASH
145 void
146 #ifdef __USE_PROTOS
147 hashStat( Entry **table )
148 #else
149 hashStat( table )
150 Entry **table;
151 #endif
152 {
153 static unsigned short count[20];
154 int i,n=0,low=0, hi=0;
155 Entry **p;
156 float avg=0.0;
157
158 for (i=0; i<20; i++) count[i] = 0;
159 for (p=table; p<&(table[size]); p++)
160 {
161 Entry *q = *p;
162 int len;
163
164 if ( q != NULL && low==0 ) low = p-table;
165 len = 0;
166 if ( q != NULL ) fprintf(stderr, "[%d]", p-table);
167 while ( q != NULL )
168 {
169 len++;
170 n++;
171 fprintf(stderr, " %s", q->str);
172 q = q->next;
173 if ( q == NULL ) fprintf(stderr, "\n");
174 }
175 count[len]++;
176 if ( *p != NULL ) hi = p-table;
177 }
178
179 fprintf(stderr, "Storing %d recs used %d hash positions out of %d\n",
180 n, size-count[0], size);
181 fprintf(stderr, "%f %% utilization\n",
182 ((float)(size-count[0]))/((float)size));
183 for (i=0; i<20; i++)
184 {
185 if ( count[i] != 0 )
186 {
187 avg += (((float)(i*count[i]))/((float)n)) * i;
188 fprintf(stderr, "Bucket len %d == %d (%f %% of recs)\n",
189 i, count[i], ((float)(i*count[i]))/((float)n));
190 }
191 }
192 fprintf(stderr, "Avg bucket length %f\n", avg);
193 fprintf(stderr, "Range of hash function: %d..%d\n", low, hi);
194 }
195 #endif
196
197 /* Add a string to the string table and return a pointer to it.
198 * Bump the pointer into the string table to next avail position.
199 */
200 char *
201 #ifdef __USE_PROTOS
202 mystrdup( char *s )
203 #else
204 mystrdup( s )
205 char *s;
206 #endif
207 {
208 char *start=strp;
209 require(s!=NULL, "mystrdup: NULL string");
210
211 while ( *s != '\0' )
212 {
213 require( strp <= &(strings[strsize-2]),
214 "string table overflow\nIncrease StrTableSize in hash.h and recompile hash.c\n");
215 *strp++ = *s++;
216 }
217 *strp++ = '\0';
218
219 return( start );
220 }
+0
-73
contrib/pccts/antlr/hash.h less more
0 /*
1 * hash.h -- define hash table entries, sizes, hash function...
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1989-2001
28 */
29
30 /* H a s h T a b l e S t u f f */
31
32 #ifndef HashTableSize
33 #define HashTableSize 553
34 #endif
35
36 #ifndef StrTableSize
37 #ifdef PC32
38 #define StrTableSize 1000000
39 #endif
40 #endif
41
42 #ifndef StrTableSize
43 #ifdef PC
44 #define StrTableSize 655200
45 #endif
46 #endif
47
48 #ifndef StrTableSize
49 #define StrTableSize 1000000
50 #endif
51
52 typedef struct _entry { /* Minimum hash table entry -- superclass */
53 char *str;
54 struct _entry *next;
55 } Entry;
56
57 /* Hash 's' using 'size', place into h (s is modified) */
58 #define Hash(s,h,size) \
59 {while ( *s != '\0' ) h = (h<<1) + *s++; \
60 h %= size;}
61
62 #ifdef __USE_PROTOS
63 Entry *hash_get(Entry **, char *),
64 **newHashTable(void),
65 *hash_add(Entry **, char *, Entry *);
66
67 void killHashTable(Entry **);
68
69 #else
70 Entry *hash_get(), **newHashTable(), *hash_add();
71 void killHashTable(); /* MR9 23-Sep-97 */
72 #endif
+0
-878
contrib/pccts/antlr/lex.c less more
0 /*
1 * lex.c -- Generate all of the lexical type files: parser.dlg tokens.h
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1989-2001
28 */
29
30 #include <stdio.h>
31 #include <ctype.h>
32 /* MR1 */
33 /* MR1 10-Apr-97 MR1 Replace use of __STDC__ with __USE_PROTOS */
34 /* MR1 */
35 #include "pcctscfg.h"
36 #include "set.h"
37 #include "syn.h"
38 #include "hash.h"
39 #include "generic.h"
40
41 #define DLGErrorString "invalid token"
42
43 /* Generate a complete lexical description of the lexemes found in the grammar */
44 void
45 #ifdef __USE_PROTOS
46 genLexDescr( void )
47 #else
48 genLexDescr( )
49 #endif
50 {
51 ListNode *p;
52 FILE *dlgFile = fopen(OutMetaName(DlgFileName), "w");
53 require(dlgFile!=NULL, eMsg1("genLexFile: cannot open %s", OutMetaName(DlgFileName)) );
54 #ifdef SPECIAL_FOPEN
55 special_fopen_actions(OutMetaName(DlgFileName)); /* MR1 */
56 #endif
57 fprintf(dlgFile, "<<\n");
58 fprintf(dlgFile, "/* %s -- DLG Description of scanner\n", DlgFileName);
59 fprintf(dlgFile, " *\n");
60 fprintf(dlgFile, " * Generated from:");
61 {int i; for (i=0; i<NumFiles; i++) fprintf(dlgFile, " %s", FileStr[i]);}
62 fprintf(dlgFile, "\n");
63 fprintf(dlgFile, " *\n");
64 fprintf(dlgFile, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");
65 fprintf(dlgFile, " * Purdue University Electrical Engineering\n");
66 fprintf(dlgFile, " * With AHPCRC, University of Minnesota\n");
67 fprintf(dlgFile, " * ANTLR Version %s\n", Version);
68 fprintf(dlgFile, " */\n\n");
69 if (FirstAction != NULL ) dumpAction( FirstAction, dlgFile, 0, -1, 0, 1 ); /* MR11 MR15b */
70 fprintf(dlgFile, "#define ANTLR_VERSION %s\n", VersionDef);
71 if ( GenCC )
72 {
73 if ( !UserDefdTokens ) fprintf(dlgFile, "#include \"%s\"\n", DefFileName);
74 else fprintf(dlgFile, "#include %s\n", UserTokenDefsFile);
75 fprintf(dlgFile, "#include \"%s\"\n", ATOKEN_H);
76 if ( GenAST ) fprintf(dlgFile, "#include \"%s\"\n", ASTBASE_H);
77 if ( HdrAction != NULL ) dumpAction( HdrAction, dlgFile, 0, -1, 0, 1 );
78 }
79 else
80 {
81 fprintf(dlgFile, "#include \"pcctscfg.h\"\n");
82 fprintf(dlgFile, "#include \"pccts_stdio.h\"\n");
83 if ( strcmp(ParserName, DefaultParserName)!=0 )
84 fprintf(dlgFile, "#define %s %s\n", DefaultParserName, ParserName);
85 if ( strcmp(ParserName, DefaultParserName)!=0 )
86 fprintf(dlgFile, "#include \"%s\"\n", RemapFileName);
87 if ( HdrAction != NULL ) dumpAction( HdrAction, dlgFile, 0, -1, 0, 1 );
88 if ( FoundGuessBlk )
89 {
90 fprintf(dlgFile, "#define ZZCAN_GUESS\n");
91 fprintf(dlgFile, "#include \"pccts_setjmp.h\"\n");
92 }
93 if ( OutputLL_k > 1 ) fprintf(dlgFile, "#define LL_K %d\n", OutputLL_k);
94 if ( DemandLookahead ) fprintf(dlgFile, "#define DEMAND_LOOK\n");
95 if (TraceGen) {
96 fprintf(dlgFile,"#ifndef zzTRACE_RULES\n"); /* MR20 */
97 fprintf(dlgFile,"#define zzTRACE_RULES\n"); /* MR20 */
98 fprintf(dlgFile,"#endif\n"); /* MR22 */
99 };
100 fprintf(dlgFile, "#include \"antlr.h\"\n");
101 if ( GenAST ) {
102 fprintf(dlgFile, "#include \"ast.h\"\n");
103 }
104 if ( UserDefdTokens )
105 fprintf(dlgFile, "#include %s\n", UserTokenDefsFile);
106 /* still need this one as it has the func prototypes */
107 fprintf(dlgFile, "#include \"%s\"\n", DefFileName);
108 fprintf(dlgFile, "#include \"dlgdef.h\"\n");
109 fprintf(dlgFile, "LOOKAHEAD\n");
110 fprintf(dlgFile, "\n");
111 fprintf(dlgFile, "void\n");
112 fprintf(dlgFile, "#ifdef __USE_PROTOS\n");
113 fprintf(dlgFile, "zzerraction(void)\n");
114 fprintf(dlgFile, "#else\n");
115 fprintf(dlgFile, "zzerraction()\n");
116 fprintf(dlgFile, "#endif\n");
117 fprintf(dlgFile, "{\n");
118 fprintf(dlgFile, "\t(*zzerr)(\"%s\");\n", DLGErrorString);
119 fprintf(dlgFile, "\tzzadvance();\n");
120 fprintf(dlgFile, "\tzzskip();\n");
121 fprintf(dlgFile, "}\n");
122 }
123 fprintf(dlgFile, ">>\n\n");
124
125 /* dump all actions */
126
127 /* MR1 */
128 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
129 /* MR1 via <<%%lexmember ....>> & <<%%lexprefix ...>> */
130 /* MR1 */
131 if (LexActions != NULL) {
132 for (p = LexActions->next; p!=NULL; p=p->next)
133 {
134 /* MR1 */ fprintf(dlgFile, "<<%%%%lexaction\n");
135 dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );
136 fprintf(dlgFile, ">>\n\n");
137 }
138 };
139
140 /* MR1 */ if (GenCC) {
141 /* MR1 */ fprintf(dlgFile,"<<%%%%parserclass %s>>\n\n",CurrentClassName);
142 /* MR1 */ };
143
144 /* MR1 */ if (LexPrefixActions != NULL) {
145 /* MR1 */ for (p = LexPrefixActions->next; p!=NULL; p=p->next)
146 /* MR1 */ {
147 /* MR1 */ fprintf(dlgFile, "<<%%%%lexprefix\n");
148 /* MR1 */ dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );
149 /* MR1 */ fprintf(dlgFile, ">>\n\n");
150 /* MR1 */ }
151 /* MR1 */ };
152
153 /* MR1 */ if (LexMemberActions != NULL) {
154 /* MR1 */ for (p = LexMemberActions->next; p!=NULL; p=p->next)
155 /* MR1 */ {
156 /* MR1 */ fprintf(dlgFile, "<<%%%%lexmember\n");
157 /* MR1 */ dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );
158 /* MR1 */ fprintf(dlgFile, ">>\n\n");
159 /* MR1 */ }
160 /* MR1 */ };
161
162 /* dump all regular expression rules/actions (skip sentinel node) */
163 if ( ExprOrder == NULL ) {
164 warnNoFL("no regular expressions found in grammar");
165 }
166 else dumpLexClasses(dlgFile);
167 fprintf(dlgFile, "%%%%\n");
168 fclose( dlgFile );
169 }
170
171 /* For each lexical class, scan ExprOrder looking for expressions
172 * in that lexical class. Print out only those that match.
173 * Each element of the ExprOrder list has both an expr and an lclass
174 * field.
175 */
176 void
177 #ifdef __USE_PROTOS
178 dumpLexClasses( FILE *dlgFile )
179 #else
180 dumpLexClasses( dlgFile )
181 FILE *dlgFile;
182 #endif
183 {
184 int i;
185 TermEntry *t;
186 ListNode *p;
187 Expr *q;
188
189 for (i=0; i<NumLexClasses; i++)
190 {
191 fprintf(dlgFile, "\n%%%%%s\n\n", lclass[i].classnum);
192 for (p=ExprOrder->next; p!=NULL; p=p->next)
193 {
194 q = (Expr *) p->elem;
195 if ( q->lclass != i ) continue;
196 lexmode(i);
197 t = (TermEntry *) hash_get(Texpr, q->expr);
198 require(t!=NULL, eMsg1("genLexDescr: rexpr %s not in hash table",q->expr) );
199 if ( t->token == EpToken ) continue;
200 fprintf(dlgFile, "%s\n\t<<\n", StripQuotes(q->expr));
201 /* replace " killed by StripQuotes() */
202 q->expr[ strlen(q->expr) ] = '"';
203 if ( !GenCC ) {
204 if ( TokenString(t->token) != NULL )
205 fprintf(dlgFile, "\t\tNLA = %s;\n", TokenString(t->token));
206 else
207 fprintf(dlgFile, "\t\tNLA = %d;\n", t->token);
208 }
209 if ( t->action != NULL ) dumpAction( t->action, dlgFile, 2,-1,0,1 );
210 if ( GenCC ) {
211 if ( TokenString(t->token) != NULL )
212 fprintf(dlgFile, "\t\treturn %s;\n", TokenString(t->token));
213 else
214 fprintf(dlgFile, "\t\treturn (ANTLRTokenType)%d;\n", t->token);
215 }
216 fprintf(dlgFile, "\t>>\n\n");
217 }
218 }
219 }
220
221 /* Strip the leading path (if any) from a filename */
222 char *
223 #ifdef __USE_PROTOS
224 StripPath( char *fileName )
225 #else
226 StripPath( fileName )
227 char *fileName;
228 #endif
229 {
230 char *p;
231 static char dirSym[2] = DirectorySymbol;
232
233 if(NULL != (p = strrchr(fileName, dirSym[0])))
234 p++;
235 else
236 p = fileName;
237
238 return(p);
239 }
240
241 /* Generate a list of #defines && list of struct definitions for
242 * aggregate retv's */
243 void
244 #ifdef __USE_PROTOS
245 genDefFile( void )
246 #else
247 genDefFile( )
248 #endif
249 {
250 int i;
251
252 /* If C++ mode and #tokdef used, then don't need anything in here since
253 * C++ puts all definitions in the class file name.
254 */
255 if ( GenCC && UserTokenDefsFile ) return;
256 if ( MR_Inhibit_Tokens_h_Gen) return;
257
258 DefFile = fopen(OutMetaName(DefFileName), "w");
259 require(DefFile!=NULL, eMsg1("genDefFile: cannot open %s", OutMetaName(DefFileName)) );
260 #ifdef SPECIAL_FOPEN
261 special_fopen_actions(OutMetaName(DefFileName)); /* MR1 */
262 #endif
263 fprintf(DefFile, "#ifndef %s\n", StripPath(gate_symbol(DefFileName)));
264 fprintf(DefFile, "#define %s\n", StripPath(gate_symbol(DefFileName)));
265
266 fprintf(DefFile, "/* %s -- List of labelled tokens and stuff\n", DefFileName);
267 fprintf(DefFile, " *\n");
268 fprintf(DefFile, " * Generated from:");
269 for (i=0; i<NumFiles; i++) fprintf(DefFile, " %s", FileStr[i]);
270 fprintf(DefFile, "\n");
271 fprintf(DefFile, " *\n");
272 fprintf(DefFile, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");
273 fprintf(DefFile, " * Purdue University Electrical Engineering\n");
274 fprintf(DefFile, " * ANTLR Version %s\n", Version);
275 fprintf(DefFile, " */\n");
276
277 if ( !GenCC && LexGen ) {
278 fprintf(DefFile,"#define zzEOF_TOKEN %d\n",
279 TokenInd!=NULL?TokenInd[EofToken]:EofToken);
280 }
281
282 if ( !UserDefdTokens )
283 {
284 int first=1;
285
286 if ( GenCC ) fprintf(DefFile, "enum ANTLRTokenType {\n");
287 for (i=1; i<TokenNum; i++)
288 {
289 /* Don't do EpToken or expr w/o labels */
290 if ( TokenString(i)!=NULL && i != EpToken )
291 {
292 TermEntry *p;
293
294 if ( WarningLevel>1 )
295 {
296 int j;
297 /* look in all lexclasses for the reg expr */
298
299 /* MR10 Derek Pappas */
300 /* MR10 A #tokclass doesn't have associated regular expressiones */
301 /* MR10 so don't warn user about it's omission */
302
303 p = (TermEntry *) hash_get(Tname, TokenString(i));
304
305 if (p != NULL && ! p->classname) {
306 for (j=0; j<NumLexClasses; j++)
307 {
308 lexmode(j);
309 if ( ExprString(i)!=NULL ) break;
310 }
311 if ( j>=NumLexClasses )
312 {
313 warnNoFL(eMsg1("token label has no associated rexpr: %s",TokenString(i)));
314 }
315 };
316 }
317 require((p=(TermEntry *)hash_get(Tname, TokenString(i))) != NULL,
318 "token not in sym tab when it should be");
319 if ( !p->classname )
320 {
321 if ( GenCC ) {
322 if ( !first ) fprintf(DefFile, ",\n");
323 first = 0;
324 fprintf(DefFile, "\t%s=%d", TokenString(i), i);
325 }
326 else
327 fprintf(DefFile, "#define %s %d\n", TokenString(i), i);
328 }
329 }
330 }
331 /* MR1 */
332 /* MR1 10-Apr-97 133MR1 Prevent use of varying sizes of integer */
333 /* MR1 for the enum ANTLRTokenType */
334 /* MR1 */
335 if ( GenCC ) { /* MR1 */
336 if ( !first ) fprintf(DefFile, ",\n"); /* MR14 */
337 fprintf(DefFile, "\tDLGminToken=0"); /* MR1 */
338 fprintf(DefFile, ",\n\tDLGmaxToken=9999};\n"); /* MR1 */
339 }; /* MR1 */
340 }
341
342 if ( !GenCC ) GenRulePrototypes(DefFile, SynDiag);
343
344 fprintf(DefFile, "\n#endif\n");
345 }
346
347 void
348 #ifdef __USE_PROTOS
349 GenRemapFile( void )
350 #else
351 GenRemapFile( )
352 #endif
353 {
354 if ( strcmp(ParserName, DefaultParserName)!=0 )
355 {
356 FILE *f;
357 int i;
358
359 f = fopen(OutMetaName(RemapFileName), "w");
360 require(f!=NULL, eMsg1("GenRemapFile: cannot open %s", OutMetaName(RemapFileName)) );
361 #ifdef SPECIAL_FOPEN
362 special_fopen_actions(OutMetaName(RemapFileName)); /* MR1 */
363 #endif
364 fprintf(f, "/* %s -- List of symbols to remap\n", RemapFileName);
365 fprintf(f, " *\n");
366 fprintf(f, " * Generated from:");
367 for (i=0; i<NumFiles; i++) fprintf(f, " %s", FileStr[i]);
368 fprintf(f, "\n");
369 fprintf(f, " *\n");
370 fprintf(f, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");
371 fprintf(f, " * Purdue University Electrical Engineering\n");
372 fprintf(f, " * ANTLR Version %s\n", Version);
373 fprintf(f, " */\n");
374
375 GenRuleFuncRedefs(f, SynDiag);
376 GenPredefinedSymbolRedefs(f);
377 if ( GenAST ) GenASTSymbolRedefs(f);
378 GenSetRedefs(f);
379
380 fclose(f);
381 }
382 }
383
384 /* Generate a bunch of #defines that rename all functions to be "ParserName_func" */
385 void
386 #ifdef __USE_PROTOS
387 GenRuleFuncRedefs( FILE *f, Junction *p )
388 #else
389 GenRuleFuncRedefs( f, p )
390 FILE *f;
391 Junction *p;
392 #endif
393 {
394 fprintf(f, "\n/* rename rule functions to be 'ParserName_func' */\n");
395 while ( p!=NULL )
396 {
397 fprintf(f, "#define %s %s_%s\n", p->rname, ParserName, p->rname);
398 p = (Junction *)p->p2;
399 }
400 }
401
402 /* Generate a bunch of #defines that rename all standard symbols to be
403 * "ParserName_symbol". The list of standard symbols to change is in
404 * globals.c.
405 */
406 void
407 #ifdef __USE_PROTOS
408 GenPredefinedSymbolRedefs( FILE *f )
409 #else
410 GenPredefinedSymbolRedefs( f )
411 FILE *f;
412 #endif
413 {
414 char **p;
415
416 fprintf(f, "\n/* rename PCCTS-supplied symbols to be 'ParserName_symbol' */\n");
417 for (p = &StandardSymbols[0]; *p!=NULL; p++)
418 {
419 fprintf(f, "#define %s %s_%s\n", *p, ParserName, *p);
420 }
421 }
422
423 /* Generate a bunch of #defines that rename all AST symbols to be
424 * "ParserName_symbol". The list of AST symbols to change is in
425 * globals.c.
426 */
427 void
428 #ifdef __USE_PROTOS
429 GenASTSymbolRedefs( FILE *f )
430 #else
431 GenASTSymbolRedefs( f )
432 FILE *f;
433 #endif
434 {
435 char **p;
436
437 fprintf(f, "\n/* rename PCCTS-supplied AST symbols to be 'ParserName_symbol' */\n");
438 for (p = &ASTSymbols[0]; *p!=NULL; p++)
439 {
440 fprintf(f, "#define %s %s_%s\n", *p, ParserName, *p);
441 }
442 }
443
444 /* redefine all sets generated by ANTLR; WARNING: 'zzerr', 'setwd' must match
445 * use in bits.c (DumpSetWd() etc...)
446 */
447 void
448 #ifdef __USE_PROTOS
449 GenSetRedefs( FILE *f )
450 #else
451 GenSetRedefs( f )
452 FILE *f;
453 #endif
454 {
455 int i;
456
457 for (i=1; i<=wordnum; i++)
458 {
459 fprintf(f, "#define setwd%d %s_setwd%d\n", i, ParserName, i);
460 }
461 for (i=1; i<=esetnum; i++)
462 {
463 fprintf(f, "#define zzerr%d %s_err%d\n", i, ParserName, i);
464 }
465 }
466
467 /* Find all return types/parameters that require structs and def
468 * all rules with ret types.
469 *
470 * This is for the declaration, not the definition.
471 */
472 void
473 #ifdef __USE_PROTOS
474 GenRulePrototypes( FILE *f, Junction *p )
475 #else
476 GenRulePrototypes( f, p )
477 FILE *f;
478 Junction *p;
479 #endif
480 {
481 int i;
482
483 i = 1;
484 while ( p!=NULL )
485 {
486 if ( p->ret != NULL )
487 {
488 /* MR23 */ if ( hasMultipleOperands(p->ret) )
489 {
490 DumpRetValStruct(f, p->ret, i);
491 }
492 fprintf(f, "\n#ifdef __USE_PROTOS\n");
493 /* MR23 */ if ( hasMultipleOperands(p->ret) )
494 {
495 fprintf(f, "extern struct _rv%d", i);
496 }
497 else
498 {
499 fprintf(f, "extern ");
500 DumpType(p->ret, f);
501 }
502 fprintf(f, " %s%s(", RulePrefix, p->rname);
503 DumpANSIFunctionArgDef(f,p,1 /* emit initializers ? */);
504 fprintf(f, ";\n");
505 fprintf(f, "#else\n");
506 /* MR23 */ if ( hasMultipleOperands(p->ret) )
507 {
508 fprintf(f, "extern struct _rv%d", i);
509 }
510 else
511 {
512 fprintf(f, "extern ");
513 DumpType(p->ret, f);
514 }
515 fprintf(f, " %s%s();\n", RulePrefix, p->rname);
516 fprintf(f, "#endif\n");
517 }
518 else
519 {
520 fprintf(f, "\n#ifdef __USE_PROTOS\n");
521 fprintf(f, "void %s%s(", RulePrefix, p->rname);
522 DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */ );
523 fprintf(f, ";\n");
524 #ifdef OLD
525 if ( p->pdecl != NULL || GenAST )
526 {
527 if ( GenAST ) {
528 fprintf(f, "AST **%s",(p->pdecl!=NULL)?",":"");
529 }
530 if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);
531 }
532 else fprintf(f, "void");
533 fprintf(f, ");\n");
534 #endif
535 fprintf(f, "#else\n");
536 fprintf(f, "extern void %s%s();\n", RulePrefix, p->rname);
537 fprintf(f, "#endif\n");
538 }
539 i++;
540 p = (Junction *)p->p2;
541 }
542 }
543
544 /* Define all rules in the class.h file; generate any required
545 * struct definitions first, however.
546 */
547 void
548 #ifdef __USE_PROTOS
549 GenRuleMemberDeclarationsForCC( FILE *f, Junction *q )
550 #else
551 GenRuleMemberDeclarationsForCC( f, q )
552 FILE *f;
553 Junction *q;
554 #endif
555 {
556 Junction *p = q;
557 int i;
558
559 fprintf(f, "private:\n");
560
561 /* Dump dflt handler declaration */
562 fprintf(f, "\tvoid zzdflthandlers( int _signal, int *_retsignal );\n\n");
563
564 fprintf(f, "public:\n");
565
566 /* Dump return value structs */
567 i = 1;
568 while ( p!=NULL )
569 {
570 if ( p->ret != NULL )
571 {
572 /* MR23 */ if ( hasMultipleOperands(p->ret) )
573 {
574 DumpRetValStruct(f, p->ret, i);
575 }
576 }
577 i++;
578 p = (Junction *)p->p2;
579 }
580
581 /* Dump member func defs && CONSTRUCTOR */
582 fprintf(f, "\t%s(ANTLRTokenBuffer *input);\n", CurrentClassName);
583 /*
584 fprintf(f, "\t%s(ANTLRTokenBuffer *input, ANTLRTokenType eof);\n",
585 CurrentClassName);
586 */
587
588 i = 1;
589 p = q;
590 while ( p!=NULL )
591 {
592 if ( p->ret != NULL )
593 {
594 /* MR23 */ if ( hasMultipleOperands(p->ret) )
595 {
596 fprintf(f, "\tstruct _rv%d", i);
597 }
598 else
599 {
600 fprintf(f, "\t");
601 DumpType(p->ret, f);
602 }
603 fprintf(f, " %s%s(",RulePrefix,p->rname);
604 DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */ );
605 fprintf(f, ";\n");
606 #ifdef OLD
607 if ( p->pdecl != NULL || GenAST )
608 {
609 if ( GenAST ) fprintf(f, "ASTBase **%s",(p->pdecl!=NULL)?",":"");
610 if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);
611 }
612 fprintf(f, ");\n");
613 #endif
614 }
615 else
616 {
617 fprintf(f, "\tvoid %s%s(",RulePrefix,p->rname);
618 DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */);
619 fprintf(f, ";\n");
620 #ifdef OLD
621 if ( p->pdecl != NULL || GenAST )
622 {
623 if ( GenAST ) fprintf(f, "ASTBase **%s",(p->pdecl!=NULL)?",":"");
624 if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);
625 }
626 fprintf(f, ");\n");
627 #endif
628 }
629 i++;
630 p = (Junction *)p->p2;
631 }
632 }
633
634 /* Given a list of ANSI-style parameter declarations, print out a
635 * comma-separated list of the symbols (w/o types).
636 * Basically, we look for a comma, then work backwards until start of
637 * the symbol name. Then print it out until 1st non-alnum char. Now,
638 * move on to next parameter.
639 *
640 */
641
642 /* MR5 Jan Mikkelsen 26-May-97 - added initalComma parameter */
643
644 void
645 #ifdef __USE_PROTOS
646 DumpListOfParmNames(char *pdecl, FILE *output, int initialComma) /* MR5 */
647 #else
648 DumpListOfParmNames(pdecl, output, initialComma) /* MR5 */
649 char *pdecl; /* MR5 */
650 FILE *output; /* MR5 */
651 int initialComma; /* MR5 */
652 #endif
653 {
654 int firstTime = 1, done = 0;
655 require(output!=NULL, "DumpListOfParmNames: NULL parm");
656
657 if ( pdecl == NULL ) return;
658 while ( !done )
659 {
660 if ( !firstTime || initialComma ) putc(',', output); /* MR5 */
661 done = DumpNextNameInDef(&pdecl, output);
662 firstTime = 0;
663 }
664 }
665
666 /* given a list of parameters or return values, dump the next
667 * name to output. Return 1 if last one just printed, 0 if more to go.
668 */
669
670 /* MR23 Total rewrite */
671
672 int
673 #ifdef __USE_PROTOS
674 DumpNextNameInDef( char **q, FILE *output )
675 #else
676 DumpNextNameInDef( q, output )
677 char **q;
678 FILE *output;
679 #endif
680 {
681 char *p;
682 char *t;
683 char *pDataType;
684 char *pSymbol;
685 char *pEqualSign;
686 char *pValue;
687 char *pSeparator;
688 int nest = 0;
689
690 p = endFormal(*q,
691 &pDataType,
692 &pSymbol,
693 &pEqualSign,
694 &pValue,
695 &pSeparator,
696 &nest);
697
698 /* MR26 Handle rule arguments such as: IIR_Bool (IIR_Decl::*contstraint)()
699 For this we need to strip off anything which follows the symbol.
700 */
701
702 /* MR26 */ t = pSymbol;
703 /* MR26 */ if (t != NULL) {
704 /* MR26 */ for (t = pSymbol; *t != 0; t++) {
705 /* MR26 */ if (! (isalpha(*t) || isdigit(*t) || *t == '_' || *t == '$')) break;
706 /* MR26 */ }
707 /* MR26 */ }
708 /* MR26 */ fprintf(output,"%s",strBetween(pSymbol, t, pSeparator));
709
710 *q = p;
711 return (*pSeparator == 0);
712 }
713
714 /* Given a list of ANSI-style parameter declarations, dump K&R-style
715 * declarations, one per line for each parameter. Basically, convert
716 * comma to semi-colon, newline.
717 */
718 void
719 #ifdef __USE_PROTOS
720 DumpOldStyleParms( char *pdecl, FILE *output )
721 #else
722 DumpOldStyleParms( pdecl, output )
723 char *pdecl;
724 FILE *output;
725 #endif
726 {
727 require(output!=NULL, "DumpOldStyleParms: NULL parm");
728
729 if ( pdecl == NULL ) return;
730 while ( *pdecl != '\0' )
731 {
732 if ( *pdecl == ',' )
733 {
734 pdecl++;
735 putc(';', output); putc('\n', output);
736 while ( *pdecl==' ' || *pdecl=='\t' || *pdecl=='\n' ) pdecl++;
737 }
738 else {putc(*pdecl, output); pdecl++;}
739 }
740 putc(';', output);
741 putc('\n', output);
742 }
743
744 /* Take in a type definition (type + symbol) and print out type only */
745 /* MR23 Total rewrite */
746
747 void
748 #ifdef __USE_PROTOS
749 DumpType( char *s, FILE *f )
750 #else
751 DumpType( s, f )
752 char *s;
753 FILE *f;
754 #endif
755 {
756 char *p;
757 char *pDataType;
758 char *pSymbol;
759 char *pEqualSign;
760 char *pValue;
761 char *pSeparator;
762 int nest = 0;
763
764 require(s!=NULL, "DumpType: invalid type string");
765
766 p = endFormal(s,
767 &pDataType,
768 &pSymbol,
769 &pEqualSign,
770 &pValue,
771 &pSeparator,
772 &nest);
773 fprintf(f,"%s",strBetween(pDataType, pSymbol, pSeparator));
774 }
775
776 /* check to see if string e is a word in string s */
777 int
778 #ifdef __USE_PROTOS
779 strmember( char *s, char *e )
780 #else
781 strmember( s, e )
782 char *s;
783 char *e;
784 #endif
785 {
786 register char *p;
787 require(s!=NULL&&e!=NULL, "strmember: NULL string");
788
789 if ( *e=='\0' ) return 1; /* empty string is always member */
790 do {
791 while ( *s!='\0' && !isalnum(*s) && *s!='_' )
792 ++s;
793 p = e;
794 while ( *p!='\0' && *p==*s ) {p++; s++;}
795 if ( *p=='\0' ) {
796 if ( *s=='\0' ) return 1;
797 if ( !isalnum (*s) && *s != '_' ) return 1;
798 }
799 while ( isalnum(*s) || *s == '_' )
800 ++s;
801 } while ( *s!='\0' );
802 return 0;
803 }
804
805 #if 0
806
807 /* MR23 Replaced by hasMultipleOperands() */
808
809 int
810 #ifdef __USE_PROTOS
811 HasComma( char *s )
812 #else
813 HasComma( s )
814 char *s;
815 #endif
816 {
817 while (*s!='\0')
818 if ( *s++ == ',' ) return 1;
819 return 0;
820 }
821 #endif
822
823
824 /* MR23 Total rewrite */
825
826 void
827 #ifdef __USE_PROTOS
828 DumpRetValStruct( FILE *f, char *ret, int i )
829 #else
830 DumpRetValStruct( f, ret, i )
831 FILE *f;
832 char *ret;
833 int i;
834 #endif
835 {
836 char *p = ret;
837 char *pDataType;
838 char *pSymbol;
839 char *pEqualSign;
840 char *pValue;
841 char *pSeparator;
842 int nest = 0;
843
844 fprintf(f, "\nstruct _rv%d {\n", i);
845 while (*p != 0 && nest == 0) {
846 p = endFormal(p,
847 &pDataType,
848 &pSymbol,
849 &pEqualSign,
850 &pValue,
851 &pSeparator,
852 &nest);
853 fprintf(f,"\t");
854 fprintf(f,"%s",strBetween(pDataType, pSymbol, pSeparator));
855 fprintf(f," ");
856 fprintf(f,"%s",strBetween(pSymbol, pEqualSign, pSeparator));
857 fprintf(f,";\n");
858 }
859 fprintf(f,"};\n");
860 }
861
862 /* given "s" yield s -- DESTRUCTIVE (we modify s if starts with " else return s) */
863 char *
864 #ifdef __USE_PROTOS
865 StripQuotes( char *s )
866 #else
867 StripQuotes( s )
868 char *s;
869 #endif
870 {
871 if ( *s == '"' )
872 {
873 s[ strlen(s)-1 ] = '\0'; /* remove last quote */
874 return( s+1 ); /* return address past initial quote */
875 }
876 return( s );
877 }
+0
-1747
contrib/pccts/antlr/main.c less more
0 /*
1 * main.c -- main program for PCCTS ANTLR.
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1989-2001
28 */
29
30 /* To set a breakpoint just before exit look for "cleanUp". */
31 /* To set a breakpoint for fatal error look for "fatal_intern" */
32
33 #include <stdio.h>
34
35 #include "pcctscfg.h"
36 #include "stdpccts.h"
37
38 #define MAX_INT_STACK 50
39 static int istack[MAX_INT_STACK]; /* Int stack */
40 static int isp = MAX_INT_STACK;
41
42 static int DontAcceptFiles = 0; /* if stdin, don't read files */
43 static int DontAcceptStdin = 0; /* if files seen first, don't accept stdin */
44
45 static int tnodes_used_in_guard_predicates_etc; /* MR10 */
46
47 /* C m d - L i n e O p t i o n S t r u c t & F u n c s */
48
49 typedef struct _Opt {
50 char *option;
51 int arg;
52 #ifdef __cplusplus
53 void (*process)(...);
54 #else
55 void (*process)();
56 #endif
57 char *descr;
58 } Opt;
59
60 #ifdef __USE_PROTOS
61 extern void ProcessArgs(int, char **, Opt *);
62 #else
63 extern void ProcessArgs();
64 #endif
65
66 #ifdef __USE_PROTOS
67 int ci_strequ(char *a,char *b)
68 #else
69 int ci_strequ(a,b)
70 char *a;
71 char *b;
72 #endif
73 {
74 for ( ;*a != 0 && *b != 0; a++, b++) {
75 if (toupper(*a) != toupper(*b)) return 0;
76 }
77 return (*a == *b);
78 }
79
80 static void
81 #ifdef __USE_PROTOS
82 pStdin( void )
83 #else
84 pStdin( )
85 #endif
86 {
87 if ( DontAcceptStdin )
88 {
89 warnNoFL("'-' (stdin) ignored as files were specified first");
90 return;
91 }
92
93 require(NumFiles<MaxNumFiles,"exceeded max # of input files");
94 FileStr[NumFiles++] = "stdin";
95 DontAcceptFiles = 1;
96 }
97
98 static void
99 #ifdef __USE_PROTOS
100 pFile( char *s )
101 #else
102 pFile( s )
103 char *s;
104 #endif
105 {
106 if ( *s=='-' ) { warnNoFL( eMsg1("invalid option: '%s'",s) ); return; }
107 if ( DontAcceptFiles )
108 {
109 warnNoFL(eMsg1("file '%s' ignored as '-' (stdin option) was specified first",s));
110 return;
111 }
112
113 require(NumFiles<MaxNumFiles,"exceeded max # of input files");
114 FileStr[NumFiles++] = s;
115 DontAcceptStdin = 1;
116 }
117
118 /* MR14
119 Allow input to be a file containing a list of files
120 Bernard Giroud (b_giroud@decus.ch)
121 */
122
123 static void
124 #ifdef __USE_PROTOS
125 pFileList( char *s, char *t )
126 #else
127 pFileList( s, t )
128 char *s;
129 char *t;
130 #endif
131 {
132 #define MaxFLArea 1024
133 FILE *fl;
134 static char Fn_in_Fl[MaxFLArea] = "";
135 char one_fn[MaxFileName];
136 char *flp = &Fn_in_Fl[0];
137 int fnl, left = MaxFLArea, i;
138
139 if ( *t=='-' ) { warnNoFL( eMsg1("invalid option: '%s'",t) ); return; }
140 if ( DontAcceptFiles )
141 {
142 warnNoFL(eMsg1("file '%s' ignored as '-' (stdin option) was specified first",t));
143 return;
144 }
145
146 if ((fl = fopen(t, "r")) == NULL)
147 {
148 warnNoFL(eMsg1("file '%s' can't be opened", t));
149 return;
150 }
151 for (;;)
152 {
153 if (fgets(one_fn, 128 - 1, fl) == NULL)
154 break;
155 fnl = strlen(one_fn);
156 require(fnl<=left, "no more room in File List Area");
157 /* drop the trailing LF */
158 if (one_fn[fnl - 1] == 0x0a) one_fn[fnl - 1] = ' ';
159 strcat(Fn_in_Fl, one_fn);
160 left = left - fnl;
161 require(NumFiles<MaxNumFiles,"exceeded max # of input files");
162 FileStr[NumFiles++] = flp;
163 flp = flp + fnl;
164 }
165 fclose(fl);
166 for (i=0;i < MaxFLArea;i++) if (Fn_in_Fl[i] == ' ') Fn_in_Fl[i] = '\0';
167 DontAcceptStdin = 1;
168 }
169
170 static void
171 #ifdef __USE_PROTOS
172 pLLK( char *s, char *t )
173 #else
174 pLLK( s, t )
175 char *s;
176 char *t;
177 #endif
178 {
179 LL_k = atoi(t);
180 if ( LL_k <= 0 ) {
181 warnNoFL("must have at least one token of lookahead (setting to 1)");
182 LL_k = 1;
183 }
184 }
185
186 static void
187 #ifdef __USE_PROTOS
188 pCk( char *s, char *t )
189 #else
190 pCk( s, t )
191 char *s;
192 char *t;
193 #endif
194 {
195 CLL_k = atoi(t);
196 if ( CLL_k <= 0 ) {
197 warnNoFL("must have at least one token of look-ahead (setting to 1)");
198 CLL_k = 1;
199 }
200 }
201
202 static void /* MR6 */
203 #ifdef __USE_PROTOS
204 pTab( char *s, char *t ) /* MR6 */
205 #else
206 pTab( s, t ) /* MR6 */
207 char *s; /* MR6 */
208 char *t; /* MR6 */
209 #endif
210 { /* MR6 */
211 TabWidth = atoi(t); /* MR6 */
212 if ( TabWidth < 0 || TabWidth > 8 ) { /* MR6 */
213 warnNoFL("tab width must be between 1 and 8"); /* MR6 */
214 TabWidth=0; /* MR6 */
215 } /* MR6 */
216 } /* MR6 */
217
218 static int ambAidDepthSpecified=0; /* MR11 */
219
220 static void /* MR11 */
221 #ifdef __USE_PROTOS
222 pAAd( char *s, char *t ) /* MR11 */
223 #else
224 pAAd( s, t ) /* MR11 */
225 char *s; /* MR11 */
226 char *t; /* MR11 */
227 #endif
228 { /* MR11 */
229 ambAidDepthSpecified=1; /* MR11 */
230 MR_AmbAidDepth = atoi(t); /* MR11 */
231 } /* MR11 */
232
233 static void /* MR11 */
234 #ifdef __USE_PROTOS
235 pTreport( char *s, char *t ) /* MR11 */
236 #else
237 pTreport( s, t ) /* MR11 */
238 char *s; /* MR11 */
239 char *t; /* MR11 */
240 #endif
241 { /* MR11 */
242 TnodesReportThreshold = atoi(t); /* MR11 */
243 } /* MR11 */
244
245 #ifdef __USE_PROTOS
246 void chkGTFlag(void) /* 7-Apr-97 MR1 */
247 #else
248 void chkGTFlag() /* 7-Apr-97 MR1 */
249 #endif
250 {
251 if ( !GenAST )
252 warn("#-variable or other AST item referenced w/o -gt option");
253 }
254
255
256 #ifdef __USE_PROTOS
257 static void pInfo(char *s, char *t) /* MR10 */
258 #else
259 static void pInfo(s,t) /* MR10 */
260 char *s;
261 char *t;
262 #endif
263 {
264 char *p;
265 int q;
266 for (p=t; *p != 0; p++) {
267 q=tolower(*p);
268 if (q=='t') {
269 InfoT=1;
270 } else if (q=='p') {
271 InfoP=1;
272 } else if (q=='m') {
273 InfoM=1;
274 } else if (q=='o') {
275 InfoO=1;
276 } else if (q=='0') {
277 ; /* nothing */
278 } else if (q=='f') {
279 InfoF=1;
280 } else {
281 warnNoFL(eMsgd("unrecognized -info option \"%c\"",(int)*p));
282 };
283 };
284 }
285
286 #ifdef __USE_PROTOS
287 static void pCGen(void) { CodeGen = FALSE; LexGen = FALSE; }
288 static void pLGen(void) { LexGen = FALSE; }
289 static void pXTGen(void){ MR_Inhibit_Tokens_h_Gen = TRUE; }
290 static void pTGen(void) { TraceGen = TRUE; }
291 static void pSGen(void) { GenExprSetsOpt = FALSE; }
292 static void pPrt(void) { PrintOut = TRUE; pCGen(); pLGen(); }
293 static void pPrtA(void) { PrintOut = TRUE; PrintAnnotate = TRUE; pCGen(); pLGen(); }
294 static void pAst(void) { GenAST = TRUE; }
295 static void pANSI(void) { GenANSI = TRUE; }
296 static void pCr(void) { GenCR = TRUE; }
297 static void pNOPURIFY(void) { PURIFY = FALSE; }
298 /*static void pCt(void) { warnNoFL("-ct option is now the default"); }*/
299 static void pLI(void) { GenLineInfo = TRUE; GenLineInfoMS = FALSE; } /* MR14 */
300 static void pLIms(void) { GenLineInfo = TRUE; GenLineInfoMS = TRUE; } /* MR14 */
301 static void pFr(char *s, char *t) {RemapFileName = t;}
302 static void pFe(char *s, char *t) {ErrFileName = t;}
303 static void pFl(char *s, char *t) {DlgFileName = t;}
304 static void pFm(char *s, char *t) {ModeFileName = t;}
305 static void pFt(char *s, char *t) {DefFileName = t;}
306
307 static void pE1(void) { elevel = 1; }
308 static void pE2(void) { elevel = 2; }
309 static void pE3(void) { elevel = 3; }
310 static void pEGen(void) { GenEClasseForRules = 1; }
311 static void pDL(void)
312 {
313 DemandLookahead = 1;
314 if ( GenCC ) {
315 warnNoFL("-gk does not work currently in C++ mode; -gk turned off");
316 DemandLookahead = 0;
317 }
318 }
319
320 static void pAA(char *s,char *t) {MR_AmbAidRule = t;} /* MR11 */
321 static void pAAm(char *s){MR_AmbAidMultiple = 1;} /* MR11 */
322 static void pGHdr(void) { GenStdPccts = 1; }
323 static void pFHdr(char *s, char *t) { stdpccts = t; pGHdr(); }
324 static void pW1(void) { WarningLevel = 1; }
325 static void pNewAST(void) { NewAST = 1; } /* MR13 */
326 static void ptmakeInParser(void) { tmakeInParser = 1; } /* MR23 */
327 static void pAlpha(void) { AlphaBetaTrace = 1; } /* MR14 */
328 static void pMR_BlkErr(void) { MR_BlkErr = 1; } /* MR21 */
329 static void pStdout(void) {UseStdout = 1; } /* MR6 */
330 static void pW2(void) { WarningLevel = 2; }
331 static void pCC(void) { GenCC = TRUE; }
332 #else
333 static void pCGen() { CodeGen = FALSE; LexGen = FALSE; }
334 static void pLGen() { LexGen = FALSE; }
335 static void pXTGen(){ MR_Inhibit_Tokens_h_Gen = TRUE; } /* MR14 */
336 static void pTGen() { TraceGen = TRUE; }
337 static void pSGen() { GenExprSetsOpt = FALSE; }
338 static void pPrt() { PrintOut = TRUE; pCGen(); pLGen(); }
339 static void pPrtA() { PrintOut = TRUE; PrintAnnotate = TRUE; pCGen(); pLGen(); }
340 static void pAst() { GenAST = TRUE; }
341 static void pANSI() { GenANSI = TRUE; }
342 static void pCr() { GenCR = TRUE; }
343 static void pNOPURIFY() { PURIFY = FALSE; }
344
345 /*static void pCt() { warnNoFL("-ct option is now the default"); }*/
346 static void pLI() { GenLineInfo = TRUE; GenLineInfoMS = FALSE; } /* MR14 */
347 static void pLIms() { GenLineInfo = TRUE; GenLineInfoMS = TRUE; } /* MR14 */
348 static void pFr(s,t) char *s, *t; {RemapFileName = t;}
349 static void pFe(s,t) char *s, *t; {ErrFileName = t;}
350 static void pFl(s,t) char *s, *t; {DlgFileName = t;}
351 static void pFm(s,t) char *s, *t; {ModeFileName = t;}
352 static void pFt(s,t) char *s, *t; {DefFileName = t;}
353
354 static void pE1() { elevel = 1; }
355 static void pE2() { elevel = 2; }
356 static void pE3() { elevel = 3; }
357 static void pEGen() { GenEClasseForRules = 1; }
358 static void pDL()
359 {
360 DemandLookahead = 1;
361 if ( GenCC ) {
362 warnNoFL("-gk does not work currently in C++ mode; -gk turned off");
363 DemandLookahead = 0;
364 }
365 }
366
367 static void pAA(s,t) char *s; char *t; {MR_AmbAidRule = t;} /* MR11 BJS 20-Mar-98 */
368 static void pAAm(s) char *s; {MR_AmbAidMultiple = 1;} /* MR11 BJS 20-Mar-98 */
369 static void pGHdr() { GenStdPccts = 1; }
370 static void pFHdr(s,t) char *s, *t; { stdpccts = t; pGHdr(); }
371 static void pW1() { WarningLevel = 1; }
372 static void pNewAST() { NewAST = 1; } /* MR13 */
373 static void ptmakeInParser() { tmakeInParser = 1; } /* MR23 */
374 static void pAlpha() { AlphaBetaTrace = 1; } /* MR14 */
375 static void pMR_BlkErr() { MR_BlkErr = 1; } /* MR21 */
376 static void pStdout() {UseStdout = 1; } /* MR6 */
377 static void pW2() { WarningLevel = 2; }
378 static void pCC() { GenCC = TRUE; }
379 #endif
380
381 static void
382 #ifdef __USE_PROTOS
383 pPre( char *s, char *t )
384 #else
385 pPre( s, t )
386 char *s;
387 char *t;
388 #endif
389 {
390 RulePrefix = t;
391 }
392
393 static void
394 #ifdef __USE_PROTOS
395 pOut( char *s, char *t )
396 #else
397 pOut( s, t )
398 char *s;
399 char *t;
400 #endif
401 {
402 OutputDirectory = t;
403 }
404
405 static void
406 #ifdef __USE_PROTOS
407 pPred( void )
408 #else
409 pPred( )
410 #endif
411 {
412 warnNoFL("-pr is no longer used (predicates employed if present); see -prc, -mrhoist, -mrhoistk");
413 /*
414 ** if ( DemandLookahead )
415 ** warnNoFL("-gk conflicts with -pr; -gk turned off");
416 ** DemandLookahead = 0;
417 ** HoistPredicateContext = 0;
418 */
419 }
420
421 static void
422 #ifdef __USE_PROTOS
423 pPredCtx( char *s, char *t )
424 #else
425 pPredCtx(s,t)
426 char *s;
427 char *t;
428 #endif
429 {
430 if ( ci_strequ(t,"on")) HoistPredicateContext = 1;
431 else if ( ci_strequ(t,"off")) HoistPredicateContext = 0;
432 if ( DemandLookahead )
433 {
434 warnNoFL("-gk incompatible with semantic predicate usage; -gk turned off");
435 DemandLookahead = 0;
436 }
437 }
438
439 static void
440 #ifdef __USE_PROTOS
441 pMRhoist( char *s, char *t )
442 #else
443 pMRhoist(s,t)
444 char *s;
445 char *t;
446 #endif
447 {
448 if ( ci_strequ(t,"on")) MRhoisting = 1;
449 else if ( ci_strequ(t,"off")==0 ) MRhoisting = 0;
450 if (MRhoisting) {
451 fprintf(stderr,"Maintenance Release style hoisting enabled for predicates with lookahead depth = 1\n");
452 fprintf(stderr," No longer considered experimental\n");
453 fprintf(stderr," Can't consider suppression for predicates with lookahead depth > 1\n");
454 fprintf(stderr," Implies -prc on but does *not* imply -mrhoistk for k>1 predicates\n");
455 fprintf(stderr," This is a reminder, not a warning or error.\n");
456 };
457 }
458
459 static void
460 #ifdef __USE_PROTOS
461 pMRhoistk( char *s, char *t )
462 #else
463 pMRhoistk(s,t)
464 char *s;
465 char *t;
466 #endif
467 {
468 if ( ci_strequ(t,"on")) MRhoistingk = 1;
469 else if ( ci_strequ(t,"off")==0 ) MRhoistingk = 0;
470 if (MRhoistingk) {
471 fprintf(stderr,"EXPERIMENTAL Maintenance Release style hoisting enabled\n");
472 fprintf(stderr," Applies to predicates with lookahead depth > 1\n");
473 fprintf(stderr," Implies -prc on and -mrhoist on\n");
474 };
475 }
476
477 static void
478 #ifdef __USE_PROTOS
479 pTRes( char *s, char *t )
480 #else
481 pTRes( s, t )
482 char *s;
483 char *t;
484 #endif
485 {
486 TreeResourceLimit = atoi(t);
487 if ( TreeResourceLimit <= 0 )
488 {
489 warnNoFL("analysis resource limit (# of tree nodes) must be greater than 0");
490 TreeResourceLimit = -1; /* set to no limit */
491 }
492 }
493
494 Opt options[] = {
495 #ifdef __cplusplus
496 { "-CC", 0, (void (*)(...)) pCC, "Generate C++ output (default=FALSE)"},
497 { "-ck", 1, (void (*)(...)) pCk, "Set compressed lookahead depth; fast approximate lookahead"},
498 { "-cr", 0, (void (*)(...)) pCr, "Generate cross reference (default=FALSE)"},
499 { "-e1", 0, (void (*)(...)) pE1, "Ambiguities/errors shown in low detail (default)"},
500 { "-e2", 0, (void (*)(...)) pE2, "Ambiguities/errors shown in more detail"},
501 { "-e3", 0, (void (*)(...)) pE3,
502 "Ambiguities for k>1 grammars shown with exact tuples (not lookahead sets)"},
503 { "-f", 1, (void (*)(...)) pFileList,"Read names of grammar files from specified file"}, /* MR14 */
504 { "-fe", 1, (void (*)(...)) pFe, "Rename err.c"},
505 { "-fh", 1, (void (*)(...)) pFHdr, "Rename stdpccts.h header (turns on -gh)"},
506 { "-fl", 1, (void (*)(...)) pFl, "Rename lexical output--parser.dlg"},
507 { "-fm", 1, (void (*)(...)) pFm, "Rename mode.h"},
508 { "-fr", 1, (void (*)(...)) pFr, "Rename remap.h"},
509 { "-ft", 1, (void (*)(...)) pFt, "Rename tokens.h"},
510 { "-ga", 0, (void (*)(...)) pANSI, "Generate ANSI-compatible code (default=FALSE)"},
511 { "-gc", 0, (void (*)(...)) pCGen, "Do not generate output parser code (default=FALSE)"},
512 { "-gd", 0, (void (*)(...)) pTGen, "Generate code to trace rule invocation (default=FALSE)"},
513 { "-ge", 0, (void (*)(...)) pEGen, "Generate an error class for each non-terminal (default=FALSE)"},
514 { "-gh", 0, (void (*)(...)) pGHdr, "Generate stdpccts.h for non-ANTLR-generated-files to include"},
515 { "-gk", 0, (void (*)(...)) pDL, "Generate parsers that delay lookahead fetches until needed"},
516 { "-gl", 0, (void (*)(...)) pLI, "Generate line info about grammar actions in parser"},
517 { "-glms", 0, (void (*)(...)) pLIms,"Like -gl but replace '\\' with '/' in #line filenames for MS C/C++ systems"},
518 { "-gp", 1, (void (*)(...)) pPre, "Prefix all generated rule functions with a string"},
519 { "-gs", 0, (void (*)(...)) pSGen, "Do not generate sets for token expression lists (default=FALSE)"},
520 { "-gt", 0, (void (*)(...)) pAst, "Generate code for Abstract-Syntax-Trees (default=FALSE)"},
521 { "-gx", 0, (void (*)(...)) pLGen, "Do not generate lexical (dlg-related) files (default=FALSE)"},
522 { "-gxt",0, (void (*)(...)) pXTGen, "Do not generate tokens.h (default=FALSE)"},
523 { "-k", 1, (void (*)(...)) pLLK, "Set full LL(k) lookahead depth (default==1)"},
524 { "-o", 1, (void (*)(...)) pOut, OutputDirectoryOption},
525 { "-p", 0, (void (*)(...)) pPrt, "Print out the grammar w/o actions (default=no)"},
526 { "-pa", 0, (void (*)(...)) pPrtA, "Print out the grammar w/o actions & w/FIRST sets (default=no)"},
527 { "-pr",0, (void (*)(...)) pPred, "no longer used; predicates employed if present"},
528 { "-prc", 1, (void (*)(...)) pPredCtx,"Turn on/off computation of context for hoisted predicates"},
529 { "-rl", 1, (void (*)(...)) pTRes, "Limit max # of tree nodes used by grammar analysis"},
530 { "-stdout",0, (void (*)(...)) pStdout,"Send grammar.c/grammar.cpp to stdout"}, /* MR6 */
531 { "-tab", 1, (void (*)(...)) pTab, "Width of tabs (1 to 8) for grammar.c/grammar.cpp files"}, /* MR6 */
532 { "-w1", 0, (void (*)(...)) pW1, "Set the warning level to 1 (default)"},
533 { "-w2", 0, (void (*)(...)) pW2, "Ambiguities yield warnings even if predicates or (...)? block"},
534 { "-", 0, (void (*)(...)) pStdin, "Read grammar from stdin" },
535 { "-mrhoist",1, (void (*)(...)) pMRhoist, /* MR9 */
536 "Turn on/off k=1 Maintenance Release style hoisting"}, /* MR9 */
537 { "-mrhoistk",1, (void (*)(...)) pMRhoistk, /* MR9 */
538 "Turn on/off EXPERIMENTAL k>1 Maintenance Release style hoisting"}, /* MR13 */
539 { "-aa" , 1, (void (*)(...)) pAA, "Ambiguity aid for a rule (rule name or line number)"}, /* MR11 */
540 { "-aam" , 0, (void (*)(...)) pAAm,
541 "Lookahead token may appear multiple times in -aa listing"}, /* MR11 */
542 { "-aad" , 1, (void (*)(...)) pAAd,
543 "Limits exp growth of -aa listing - default=1 (max=ck value)"}, /* MR11 */
544 { "-info", 1, (void (*)(...)) pInfo,
545 "Extra info: p=pred t=tnodes f=first/follow m=monitor o=orphans 0=noop"}, /* MR12 */
546 { "-treport",1,(void (*)(...)) pTreport,
547 "Report when tnode usage exceeds value during ambiguity resolution"}, /* MR11 */
548 { "-newAST", 0, (void (*)(...)) pNewAST,
549 "In C++ mode use \"newAST(...)\" rather than \"new AST(...)\""}, /* MR13 */
550 { "-tmake", 0, (void (*)(...)) ptmakeInParser,
551 "In C++ mode use parser's tmake method rather than \"ASTBase::tmake(...)\""}, /* MR23 */
552 { "-alpha",0,(void (*)(...)) pAlpha,
553 "Provide additional information for \"(alpha)? beta\" error messages"}, /* MR14 */
554 { "-mrblkerr",0,(void (*)(...)) pMR_BlkErr, /* MR21 */
555 "EXPERIMENTAL change to (...)* and (...)+ syntax error sets"}, /* MR21 */
556 { "-nopurify",0,(void (*)(...)) pNOPURIFY,
557 "Don't use the notorious PURIFY macro (replaced by MR23 initial value syntax) to zero return arguments of rules"}, /* MR23 */
558 { "*", 0, (void (*)(...)) pFile, "" }, /* anything else is a file */
559 #else
560 { "-CC", 0, pCC, "Generate C++ output (default=FALSE)"},
561 { "-cr", 0, pCr, "Generate cross reference (default=FALSE)"},
562 { "-ck", 1, pCk, "Set compressed lookahead depth; fast approximate lookahead"},
563 { "-e1", 0, pE1, "Ambiguities/errors shown in low detail (default)"},
564 { "-e2", 0, pE2, "Ambiguities/errors shown in more detail"},
565 { "-e3", 0, pE3, "Ambiguities for k>1 grammars shown with exact tuples (not lookahead sets)"},
566 { "-f", 1, pFileList,"Read names of grammar files from specified file"}, /* MR14 */
567 { "-fe", 1, pFe, "Rename err.c"},
568 { "-fh", 1, pFHdr, "Rename stdpccts.h header (turns on -gh)"},
569 { "-fl", 1, pFl, "Rename lexical output--parser.dlg"},
570 { "-fm", 1, pFm, "Rename mode.h"},
571 { "-fr", 1, pFr, "Rename remap.h"},
572 { "-ft", 1, pFt, "Rename tokens.h"},
573 { "-ga", 0, pANSI, "Generate ANSI-compatible code (default=FALSE)"},
574 { "-gc", 0, pCGen, "Do not generate output parser code (default=FALSE)"},
575 { "-gd", 0, pTGen, "Generate code to trace rule invocation (default=FALSE)"},
576 { "-ge", 0, pEGen, "Generate an error class for each non-terminal (default=FALSE)"},
577 { "-gh", 0, pGHdr, "Generate stdpccts.h for non-ANTLR-generated-files to include"},
578 { "-gk", 0, pDL, "Generate parsers that delay lookahead fetches until needed"},
579 { "-gl", 0, pLI, "Generate line info about grammar actions in C parser"},
580 { "-glms", 0, pLIms,"Like -gl but replace '\\' with '/' in #line filenames for MS C/C++ systems"},
581 { "-gp", 1, pPre, "Prefix all generated rule functions with a string"},
582 { "-gs", 0, pSGen, "Do not generate sets for token expression lists (default=FALSE)"},
583 { "-gt", 0, pAst, "Generate code for Abstract-Syntax-Trees (default=FALSE)"},
584 { "-gx", 0, pLGen, "Do not generate lexical (dlg-related) files (default=FALSE)"},
585 { "-gxt",0, pXTGen, "Do not generate tokens.h (default=FALSE)"},
586 { "-k", 1, pLLK, "Set full LL(k) lookahead depth (default==1)"},
587 { "-o", 1, pOut, OutputDirectoryOption},
588 { "-p", 0, pPrt, "Print out the grammar w/o actions (default=no)"},
589 { "-pa", 0, pPrtA, "Print out the grammar w/o actions & w/FIRST sets (default=no)"},
590 { "-pr",0, pPred, "no longer used; predicates employed if present"},
591 { "-prc", 1, pPredCtx,"Turn on/off computation of context for hoisted predicates"},
592 { "-rl", 1, pTRes, "Limit max # of tree nodes used by grammar analysis"},
593 { "-stdout",0, pStdout, "Send grammar.c/grammar.cpp to stdout"}, /* MR6 */
594 { "-tab", 1, pTab, "Width of tabs (1 to 8) for grammar.c/grammar.cpp files"}, /* MR6 */
595 { "-w1", 0, pW1, "Set the warning level to 1 (default)"},
596 { "-w2", 0, pW2, "Ambiguities yield warnings even if predicates or (...)? block"},
597 { "-mrhoist",1,pMRhoist, /* MR9 */
598 "Turn on/off k=1 Maintenance Release style hoisting"}, /* MR9 */
599 { "-mrhoistk",1,pMRhoistk, /* MR13 */
600 "Turn on/off k>1 EXPERIMENTAL Maintenance Release style hoisting"}, /* MR13 */
601 { "-aa" ,1,pAA, "Ambiguity aid for a rule (rule name or line number)"}, /* MR11 */
602 { "-aam" ,0,pAAm,
603 "Lookahead token may appear multiple times in -aa listing"}, /* MR11 */
604 { "-aad" ,1,pAAd,
605 "Limits exp growth of -aa listing - default=1 (max=ck value)"}, /* MR11 */
606 { "-info",1,pInfo,
607 "Extra info: p=pred t=tnodes f=first/follow m=monitor o=orphans 0=noop"}, /* MR11 */
608 { "-treport",1,pTreport,
609 "Report when tnode usage exceeds value during ambiguity resolution"}, /* MR11 */
610 { "-newAST", 0, pNewAST,
611 "In C++ mode use \"newAST(...)\" rather than \"new AST(...)\""}, /* MR13 */
612 { "-tmake", 0, ptmakeInParser,
613 "In C++ mode use parser's tmake method rather than \"ASTBase::tmake(...)\""}, /* MR23 */
614 { "-alpha",0, pAlpha,
615 "Provide additional information for \"(alpha)? beta\" error messages"}, /* MR14 */
616 { "-mrblkerr",0,pMR_BlkErr, /* MR21 */
617 "EXPERIMENTAL change to (...)* and (...)+ syntax error sets"}, /* MR21 */
618 { "-nopurify",0,pNOPURIFY,
619 "Don't use the notorious PURIFY macro (replaced by MR23 initial value syntax) to zero return arguments of rules"}, /* MR23 */
620 { "-", 0, pStdin, "Read grammar from stdin" },
621 { "*", 0, pFile, "" }, /* anything else is a file */
622 #endif
623 { NULL, 0, NULL }
624 };
625
626 void readDescr();
627 void cleanUp();
628
629 #ifdef __USE_PROTOS
630 static void buildRulePtr( void );
631 static void help( void );
632 static void init( void );
633 static void CompleteTokenSetRefs( void );
634 static void ensure_no_C_file_collisions(char *);
635 static void CompleteContextGuards(void);
636 #else
637 static void buildRulePtr( );
638 static void help( );
639 static void init( );
640 static void CompleteTokenSetRefs( );
641 static void ensure_no_C_file_collisions();
642 static void CompleteContextGuards();
643 #endif
644
645 static void
646 #ifdef __USE_PROTOS /* <BJS> */
647 report_numericPredLabels(ActionNode *a)
648 #else
649 report_numericPredLabels(a)
650 ActionNode *a;
651 #endif
652 { /* MR10 */
653 warnFL("numeric references to attributes (e.g. $i or $i.j) in semantic pred will be null during guess mode", /* MR10 */
654 FileStr[a->file],a->line); /* MR10 */
655 } /* MR10 */
656
657 /* M a i n */
658
659 int
660 #ifdef __USE_PROTOS
661 main( int argc, char *argv[] )
662 #else
663 main( argc, argv )
664 int argc;
665 char *argv[];
666 #endif
667 {
668 int i;
669 static char EPSTR[] = "[Ep]";
670
671 Save_argc=argc; /* MR10 */
672 Save_argv=argv; /* MR10 */
673
674 /* malloc_debug(8);*/
675
676 #ifdef SPECIAL_INITS
677 special_inits(); /* MR1 */
678 #endif
679 fprintf(stderr, "Antlr parser generator Version %s 1989-2001\n", Version);
680 if ( argc == 1 ) { help(); zzDIE; }
681 ProcessArgs(argc-1, &(argv[1]), options);
682
683 /* MR14 */ if (MR_AmbAidRule && AlphaBetaTrace) {
684 /* MR14 */ fatal("Can't specify both -aa (ambiguity aid) and -alpha (\"(alpha)? beta\" aid)");
685 /* MR14 */ }
686
687 if (MRhoistingk) { /* MR13 */
688 HoistPredicateContext=1; /* MR13 */
689 MRhoisting=1; /* MR13 */
690 }; /* MR13 */
691 if (MRhoisting && ! HoistPredicateContext) {
692 /*** warnNoFL("Using \"-mrhoist\" forces \"-prc on\""); ***/
693 HoistPredicateContext=1;
694 };
695 if (HoistPredicateContext && ! MRhoisting) {
696 warnNoFL("When using predicate context (-prc on) -mrhoist on is recommended");
697 }
698 /* Fix lookahead depth */
699 /* Compressed lookahead must always be larger than or equal to full lookahead */
700 if ( CLL_k < LL_k && CLL_k>0 )
701 {
702 warnNoFL("must have compressed lookahead >= full LL(k) lookahead (setting -ck to -k)");
703 CLL_k = LL_k;
704 }
705 if ( CLL_k == -1 ) CLL_k = LL_k;
706 OutputLL_k = CLL_k;
707 if ( ((CLL_k-1)&CLL_k)!=0 ) { /* output ll(k) must be power of 2 */
708 int n;
709 for(n=1; n<CLL_k; n<<=1) {;}
710 OutputLL_k = n;
711 };
712
713 if (MR_BlkErr) {
714 warnNoFL("The -mrblkerr option is EXPERIMENTAL");
715 if (LL_k > 1) {
716 warnNoFL("The -mrblkerr option is designed only for k=1 ck=1 grammars");
717 }
718 };
719
720 if ( ! ambAidDepthSpecified) {
721 MR_AmbAidDepth=1;
722 } else {
723 if (MR_AmbAidDepth > CLL_k || MR_AmbAidDepth <= 0) {
724 warnNoFL(eMsgd(
725 "Ambiguity aid depth (\"-aad ...\") must be a number between 1 and max(k,ck)=%d",CLL_k));
726 MR_AmbAidDepth=1;
727 };
728 if (MR_AmbAidDepth == 0) {
729 MR_AmbAidDepth=2;
730 };
731 };
732
733 if (MR_AmbAidRule != NULL) MR_AmbAidLine=atoi(MR_AmbAidRule);
734
735 fpTrans = &(C_Trans[0]); /* Translate to C Language */
736 fpJTrans = &(C_JTrans[0]);
737 init();
738 lexclass(LexStartSymbol);
739
740 readDescr();
741 LastTokenCounted = TokenNum;
742 RemapForcedTokens();
743 if ( CannotContinue ) {cleanUp(); zzDIE;}
744 if ( GenCC && no_classes_found ) fatal("required grammar class not found (exiting...)");
745 if ( WarningLevel>1 && HdrAction == NULL )
746 warnNoFL("no #header action was found");
747 if ( FoundAtOperator && ! FoundExceptionGroup) {
748 warnNoFL("found the exception operator '@' - but no exception group was found");
749 };
750 EpToken = addTname(EPSTR); /* add imaginary token epsilon */
751 set_orel(EpToken, &imag_tokens);
752
753 /* this won't work for hand-built scanners since EofToken is not
754 * known. Forces EOF to be token type 1.
755 */
756 set_orel(EofToken, &imag_tokens);
757
758 set_size(NumWords(TokenNum-1));
759
760 /* compute the set of all known token types
761 * It represents the set of tokens from 1 to last_token_num + the
762 * reserved positions above that (if any). Don't include the set of
763 * imaginary tokens such as the token/error classes or EOF.
764 */
765 {
766 set a;
767 a = set_dup(reserved_positions);
768 for (i=1; i<TokenNum; i++) { set_orel(i, &a); }
769 all_tokens = set_dif(a, imag_tokens);
770 set_free(a);
771 }
772
773 ComputeTokSets(); /* Compute #tokclass sets */
774 CompleteTokenSetRefs(); /* Change complex nodes in syn diag */
775 CompleteContextGuards(); /* MR13 */
776
777 if ( CodeGen ) genDefFile(); /* create tokens.h */
778 if ( LexGen ) genLexDescr(); /* create parser.dlg */
779
780 if ( GenStdPccts )
781 {
782 FILE *f = fopen(OutMetaName(stdpccts), "w");
783 if ( f==NULL ) {warnNoFL( eMsg1("can't create %s",OutMetaName(stdpccts)) );}
784 else
785 {
786 #ifdef SPECIAL_FOPEN
787 special_fopen_actions(OutMetaName(stdpccts)); /* MR1 */
788 #endif
789 if (strcmp(stdpccts,"stdpccts.h") == 0) { /* MR10 */
790 genStdPCCTSIncludeFile(f,NULL); /* MR10 */
791 } else { /* MR10 */
792 genStdPCCTSIncludeFile(f,pcctsBaseName(stdpccts)); /* MR32 */
793 };
794 fclose(f);
795 }
796 }
797
798 buildRulePtr(); /* create mapping from rule # to RuleBlk junction */
799 ComputeErrorSets();
800 FoLink( (Node *)SynDiag ); /* add follow links to end of all rules */
801
802 if ( GenCR ) GenCrossRef( SynDiag );
803
804 if ( CodeGen )
805 {
806 if ( SynDiag == NULL )
807 {
808 warnNoFL("no grammar description recognized");
809 cleanUp();
810 zzDIE;
811 }
812 else if ( !GenCC ) {
813 ErrFile = fopen(OutMetaName(ErrFileName), "w");
814 require(ErrFile != NULL, "main: can't open err file");
815 #ifdef SPECIAL_FOPEN
816 special_fopen_actions(OutMetaName(ErrFileName)); /* MR1 */
817 #endif
818 NewSetWd();
819 GenErrHdr();
820 TRANS(SynDiag); /* Translate to the target language */
821 DumpSetWd();
822 DumpRemainingTokSets();
823 fclose( ErrFile );
824 }
825 else {
826 strcpy(Parser_h_Name, CurrentClassName);
827 strcat(Parser_h_Name, ".h");
828 strcpy(Parser_c_Name, CurrentClassName);
829 strcat(Parser_c_Name, CPP_FILE_SUFFIX);
830 ensure_no_C_file_collisions(Parser_c_Name);
831 Parser_h = fopen(OutMetaName(Parser_h_Name), "w");
832 require(Parser_h != NULL, "main: can't open class Parserx.h file");
833 #ifdef SPECIAL_FOPEN
834 special_fopen_actions(OutMetaName(Parser_h_Name)); /* MR1 */
835 #endif
836 Parser_c = fopen(OutMetaName(Parser_c_Name), "w");
837 require(Parser_c != NULL, "main: can't open class Parserx.c file");
838 #ifdef SPECIAL_FOPEN
839 special_fopen_actions(OutMetaName(Parser_c_Name)); /* MR1 */
840 #endif
841 GenParser_h_Hdr();
842 if ( class_before_actions != NULL )
843 {
844 ListNode *p;
845 for (p = class_before_actions->next; p!=NULL; p=p->next)
846 {
847 UserAction *ua = (UserAction *)p->elem;
848 dumpAction( ua->action, Parser_h, 0, ua->file, ua->line, 1);
849 }
850 }
851 GenParser_c_Hdr();
852 fprintf(Parser_h, "protected:\n"); /* MR20 */
853 NewSetWd();
854 TRANS(SynDiag); /* Translate to the target language */
855 DumpSetWd();
856 GenRuleMemberDeclarationsForCC(Parser_h, SynDiag);
857 if ( class_after_actions != NULL )
858 {
859 ListNode *p;
860 for (p = class_after_actions->next; p!=NULL; p=p->next)
861 {
862 UserAction *ua = (UserAction *)p->elem;
863 dumpAction( ua->action, Parser_h, 0, ua->file, ua->line, 1);
864 }
865 }
866 DumpRemainingTokSets();
867 fprintf(Parser_h, "};\n");
868 fprintf(Parser_h, "\n#endif /* %s_h */\n", CurrentClassName);
869 fclose( Parser_h );
870 fclose( Parser_c );
871 }
872 }
873
874 MR_orphanRules(stderr);
875 if (LTinTokenAction && WarningLevel >= 2) {
876 if (GenCC) {
877 warnNoFL("At least one <<action>> following a token match contains a reference to LT(...)\n this will reference the immediately preceding token,\n not the one which follows as is the case with semantic predicates.");
878 }
879 warnNoFL("At least one <<action>> following a token match contains a reference to LA(...) or LATEXT(...)\n this will reference the immediately preceding token,\n not the one which follows as is the case with semantic predicates.");
880 }
881
882 if ( PrintOut )
883 {
884 if ( SynDiag == NULL ) {warnNoFL("no grammar description recognized");}
885 else PRINT(SynDiag);
886 }
887
888 #ifdef DBG_LL1
889 #endif
890 GenRemapFile(); /* create remap.h */
891 /* MR10 */ if (FoundGuessBlk) {
892 #ifdef __cplusplus__
893 /* MR10 */ list_apply(NumericPredLabels, (void (*)(void *))report_numericPredLabels);
894 #else
895 #ifdef __USE_PROTOS
896 /* MR10 */ list_apply(NumericPredLabels, (void (*)(void *))report_numericPredLabels);
897 #else
898 /* MR10 */ list_apply(NumericPredLabels,report_numericPredLabels);
899 #endif
900 #endif
901 /* MR10 */ };
902
903 if (InfoT && TnodesAllocated > 0) {
904 if (TnodesPeak > 10000) {
905 fprintf(stdout,"\nTree Nodes: peak %dk created %dk lost %d\n",
906 (TnodesPeak/1000),
907 (TnodesAllocated/1000),
908 TnodesInUse-tnodes_used_in_guard_predicates_etc);
909 } else {
910 fprintf(stdout,"\nTree Nodes: peak %d created %d lost %d\n",
911 TnodesPeak,
912 TnodesAllocated,
913 TnodesInUse-tnodes_used_in_guard_predicates_etc);
914 };
915 };
916 if (InfoF) {
917 DumpFcache();
918 };
919 if (MR_skipped_e3_report) {
920 fprintf(stderr,"note: use -e3 to get exact information on ambiguous tuples\n");
921 };
922 if (MR_BadExprSets != 0) {
923 fprintf(stderr,"note: Unreachable C or C++ code was generated for empty expression sets,\n");
924 fprintf(stderr," probably due to undefined rules or infinite left recursion.\n");
925 fprintf(stderr," To locate: search the generated code for \"empty set expression\"\n");
926 };
927 if (MR_AmbAidRule != NULL && MR_matched_AmbAidRule==0) {
928 RuleEntry *q = (RuleEntry *) hash_get(Rname,MR_AmbAidRule);
929 if (MR_AmbAidLine == 0 && q == NULL) {
930 warnNoFL(eMsg2("there is no rule \"%s\" so \"-aa %s\" will never match",
931 MR_AmbAidRule,MR_AmbAidRule));
932 } else {
933 warnNoFL(eMsg1("there was no ambiguity that matched \"-aa %s\"",MR_AmbAidRule));
934 };
935 };
936 if (AlphaBetaTrace) {
937
938 if (MR_AlphaBetaMessageCount == 0) {
939 fprintf(stderr,"note: there were no messages about \"(alpha)? beta\" blocks added to the generated code\n");
940 } else {
941 fprintf(stderr,"note: there were %d messages about \"(alpha)? beta\" blocks added to the generated code\n",
942 MR_AlphaBetaMessageCount);
943 }
944
945 if (set_null(MR_CompromisedRules)) {
946 fprintf(stderr,"note: the list of rules with compromised follow sets is empty\n");
947 } else {
948 fprintf(stderr,"note: the following is a list of rules which *may* have incorrect\n");
949 fprintf(stderr," follow sets computed as a result of an \"(alpha)? beta\" block\n");
950 fprintf(stderr,"\n");
951 MR_dumpRuleSet(MR_CompromisedRules);
952 fprintf(stderr,"\n");
953 }
954 }
955 cleanUp();
956 exit(PCCTS_EXIT_SUCCESS);
957 return 0; /* MR11 make compilers happy */
958 }
959
960 static void
961 #ifdef __USE_PROTOS
962 init( void )
963 #else
964 init( )
965 #endif
966 {
967 SignalEntry *q;
968
969 Tname = newHashTable();
970 Rname = newHashTable();
971 Fcache = newHashTable();
972 Tcache = newHashTable();
973 Sname = newHashTable();
974 Pname = newHashTable(); /* MR11 */
975
976 /* Add default signal names */
977 q = (SignalEntry *)hash_add(Sname,
978 "NoViableAlt",
979 (Entry *)newSignalEntry("NoViableAlt"));
980 require(q!=NULL, "cannot alloc signal entry");
981 q->signum = sigNoViableAlt;
982 q = (SignalEntry *)hash_add(Sname,
983 "MismatchedToken",
984 (Entry *)newSignalEntry("MismatchedToken"));
985 require(q!=NULL, "cannot alloc signal entry");
986 q->signum = sigMismatchedToken;
987 q = (SignalEntry *)hash_add(Sname,
988 "NoSemViableAlt",
989 (Entry *)newSignalEntry("NoSemViableAlt"));
990 require(q!=NULL, "cannot alloc signal entry");
991 q->signum = sigNoSemViableAlt;
992
993 reserved_positions = empty;
994 all_tokens = empty;
995 imag_tokens = empty;
996 tokclasses = empty;
997 TokenStr = (char **) calloc(TSChunk, sizeof(char *));
998 require(TokenStr!=NULL, "main: cannot allocate TokenStr");
999 FoStack = (int **) calloc(CLL_k+1, sizeof(int *));
1000 require(FoStack!=NULL, "main: cannot allocate FoStack");
1001 FoTOS = (int **) calloc(CLL_k+1, sizeof(int *));
1002 require(FoTOS!=NULL, "main: cannot allocate FoTOS");
1003 Cycles = (ListNode **) calloc(CLL_k+1, sizeof(ListNode *));
1004 require(Cycles!=NULL, "main: cannot allocate Cycles List");
1005 MR_CompromisedRules=empty; /* MR14 */
1006 }
1007
1008 static void
1009 #ifdef __USE_PROTOS
1010 help( void )
1011 #else
1012 help( )
1013 #endif
1014 {
1015 Opt *p = options;
1016 fprintf(stderr, "antlr [options] f1 f2 ... fn\n");
1017 while ( *(p->option) != '*' )
1018 {
1019 fprintf(stderr, " %-9s%s %s\n",
1020 p->option,
1021 (p->arg)?"___":" ",
1022 p->descr);
1023 p++;
1024 }
1025 }
1026
1027 /* The RulePtr array is filled in here. RulePtr exists primarily
1028 * so that sets of rules can be maintained for the FOLLOW caching
1029 * mechanism found in rJunc(). RulePtr maps a rule num from 1 to n
1030 * to a pointer to its RuleBlk junction where n is the number of rules.
1031 */
1032 static void
1033 #ifdef __USE_PROTOS
1034 buildRulePtr( void )
1035 #else
1036 buildRulePtr( )
1037 #endif
1038 {
1039 int r=1;
1040 Junction *p = SynDiag;
1041 RulePtr = (Junction **) calloc(NumRules+1, sizeof(Junction *));
1042 require(RulePtr!=NULL, "cannot allocate RulePtr array");
1043
1044 while ( p!=NULL )
1045 {
1046 require(r<=NumRules, "too many rules???");
1047 RulePtr[r++] = p;
1048 p = (Junction *)p->p2;
1049 }
1050 }
1051
1052 void
1053 #ifdef __USE_PROTOS
1054 dlgerror(const char *s)
1055 #else
1056 dlgerror(s)
1057 char *s;
1058 #endif
1059 {
1060 fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);
1061 fprintf(stderr, " lexical error: %s (text was '%s')\n",
1062 ((s == NULL) ? "Lexical error" : s), zzlextext);
1063 }
1064
1065 void
1066 #ifdef __USE_PROTOS
1067 readDescr( void )
1068 #else
1069 readDescr( )
1070 #endif
1071 {
1072 zzerr = dlgerror;
1073 input = NextFile();
1074 if ( input==NULL ) fatal("No grammar description found (exiting...)");
1075 ANTLR(grammar(), input);
1076 tnodes_used_in_guard_predicates_etc=TnodesInUse; /* MR10 */
1077 }
1078
1079 FILE *
1080 #ifdef __USE_PROTOS
1081 NextFile( void )
1082 #else
1083 NextFile( )
1084 #endif
1085 {
1086 FILE *f;
1087
1088 for (;;)
1089 {
1090 CurFile++;
1091 if ( CurFile >= NumFiles ) return(NULL);
1092 if ( ci_strequ(FileStr[CurFile],"stdin")) return stdin;
1093 f = fopen(FileStr[CurFile], "r");
1094 if ( f == NULL )
1095 {
1096 warnNoFL( eMsg1("file %s doesn't exist; ignored", FileStr[CurFile]) );
1097 }
1098 else
1099 {
1100 return(f);
1101 }
1102 }
1103 }
1104
1105 /*
1106 * Return a string corresponding to the output file name associated
1107 * with the input file name passed in.
1108 *
1109 * Observe the following rules:
1110 *
1111 * f.e --> f".c"
1112 * f --> f".c"
1113 * f. --> f".c"
1114 * f.e.g --> f.e".c"
1115 *
1116 * Where f,e,g are arbitrarily long sequences of characters in a file
1117 * name.
1118 *
1119 * In other words, if a ".x" appears on the end of a file name, make it
1120 * ".c". If no ".x" appears, append ".c" to the end of the file name.
1121 *
1122 * C++ mode using .cpp not .c.
1123 *
1124 * Use malloc() for new string.
1125 */
1126
1127 char *
1128 #ifdef __USE_PROTOS
1129 outname( char *fs )
1130 #else
1131 outname( fs )
1132 char *fs;
1133 #endif
1134 {
1135 if ( GenCC) {
1136 return outnameX(fs,CPP_FILE_SUFFIX);
1137 } else {
1138 return outnameX(fs,".c");
1139 };
1140 }
1141
1142 char *
1143 #ifdef __USE_PROTOS
1144 outnameX( char *fs ,char *suffix)
1145 #else
1146 outnameX( fs , suffix )
1147 char *fs;
1148 char *suffix;
1149 #endif
1150 {
1151 static char buf[MaxFileName+1];
1152 char *p;
1153 require(fs!=NULL&&*fs!='\0', "outname: NULL filename");
1154
1155 p = buf;
1156 strcpy(buf, fs);
1157 while ( *p != '\0' ) {p++;} /* Stop on '\0' */
1158 while ( *p != '.' && p != buf ) {--p;} /* Find '.' */
1159 if ( p != buf ) *p = '\0'; /* Found '.' */
1160 require(strlen(buf) + 2 < (size_t)MaxFileName, "outname: filename too big");
1161 strcat(buf,suffix);
1162 return( buf );
1163 }
1164
1165 void
1166 #ifdef __USE_PROTOS
1167 fatalFL( char *err_, char *f, int l )
1168 #else
1169 fatalFL( err_, f, l )
1170 char *err_;
1171 char *f;
1172 int l;
1173 #endif
1174 {
1175 fprintf(stderr, ErrHdr, f, l);
1176 fprintf(stderr, " %s\n", err_);
1177 cleanUp();
1178 exit(PCCTS_EXIT_FAILURE);
1179 }
1180
1181 void
1182 #ifdef __USE_PROTOS
1183 fatal_intern( char *err_, char *f, int l )
1184 #else
1185 fatal_intern( err_, f, l )
1186 char *err_;
1187 char *f;
1188 int l;
1189 #endif
1190 {
1191 fprintf(stderr, ErrHdr, f, l);
1192 fprintf(stderr, " #$%%*&@# internal error: %s\n", err_);
1193 fprintf(stderr, ErrHdr, f, l);
1194 fprintf(stderr, " [complain to nearest government official\n");
1195 fprintf(stderr, ErrHdr, f, l);
1196 fprintf(stderr, " or send hate-mail to parrt@parr-research.com;\n");
1197 fprintf(stderr, ErrHdr, f, l);
1198 fprintf(stderr, " please pray to the ``bug'' gods that there is a trival fix.]\n");
1199 cleanUp();
1200 exit(PCCTS_EXIT_FAILURE);
1201 }
1202
1203 void
1204 #ifdef __USE_PROTOS
1205 cleanUp( void )
1206 #else
1207 cleanUp( )
1208 #endif
1209 {
1210 if ( DefFile != NULL) fclose( DefFile );
1211 }
1212
1213 /* sprintf up to 3 strings */
1214 char *
1215 #ifdef __USE_PROTOS
1216 eMsg3( char *s, char *a1, char *a2, char *a3 )
1217 #else
1218 eMsg3( s, a1, a2, a3 )
1219 char *s;
1220 char *a1;
1221 char *a2;
1222 char *a3;
1223 #endif
1224 {
1225 static char buf[250]; /* DANGEROUS as hell !!!!!! */
1226
1227 sprintf(buf, s, a1, a2, a3);
1228 return( buf );
1229 }
1230
1231 /* sprintf a decimal */
1232 char *
1233 #ifdef __USE_PROTOS
1234 eMsgd( char *s, int d )
1235 #else
1236 eMsgd( s, d )
1237 char *s;
1238 int d;
1239 #endif
1240 {
1241 static char buf[250]; /* DANGEROUS as hell !!!!!! */
1242
1243 sprintf(buf, s, d);
1244 return( buf );
1245 }
1246
1247 char *
1248 #ifdef __USE_PROTOS
1249 eMsgd2( char *s, int d1,int d2)
1250 #else
1251 eMsgd2( s, d1, d2 )
1252 char *s;
1253 int d1;
1254 int d2;
1255 #endif
1256 {
1257 static char buf[250]; /* DANGEROUS as hell !!!!!! */
1258
1259 sprintf(buf, s, d1, d2);
1260 return( buf );
1261 }
1262
1263 void
1264 #ifdef __USE_PROTOS
1265 s_fprT( FILE *f, set e )
1266 #else
1267 s_fprT( f, e )
1268 FILE *f;
1269 set e;
1270 #endif
1271 {
1272 register unsigned *p;
1273 unsigned *q;
1274
1275 if ( set_nil(e) ) return;
1276 if ( (q=p=set_pdq(e)) == NULL ) fatal_internal("Can't alloc space for set_pdq");
1277 fprintf(f, "{");
1278 while ( *p != nil )
1279 {
1280 fprintf(f, " %s", TerminalString(*p));
1281 p++;
1282 }
1283 fprintf(f, " }");
1284 free((char *)q);
1285 }
1286
1287 /* Return the token name or regular expression for a token number. */
1288 char *
1289 #ifdef __USE_PROTOS
1290 TerminalString( int token )
1291 #else
1292 TerminalString( token )
1293 int token;
1294 #endif
1295 {
1296 int j;
1297 static char imag_name[20];
1298
1299 /* look in all lexclasses for the token */
1300 if ( TokenString(token) != NULL ) return TokenString(token);
1301 for (j=0; j<NumLexClasses; j++)
1302 {
1303 lexmode(j);
1304 if ( ExprString(token) != NULL ) return ExprString(token);
1305 }
1306
1307 if (1) {
1308 sprintf(imag_name,"UnknownToken#%d",token); /* MR13 */
1309 return imag_name; /* MR13 */
1310 }
1311
1312 require(j<NumLexClasses, eMsgd("No label or expr for token %d",token));
1313 return "invalid";
1314 }
1315
1316 /* S i m p l e I n t S t a c k */
1317
1318 void
1319 #ifdef __USE_PROTOS
1320 pushint( int i )
1321 #else
1322 pushint( i )
1323 int i;
1324 #endif
1325 {
1326 require(isp>0, "pushint: stack overflow");
1327 istack[--isp] = i;
1328 }
1329
1330 int
1331 #ifdef __USE_PROTOS
1332 popint( void )
1333 #else
1334 popint( )
1335 #endif
1336 {
1337 require(isp<MAX_INT_STACK, "popint: stack underflow");
1338 return istack[isp++];
1339 }
1340
1341 int
1342 #ifdef __USE_PROTOS
1343 istacksize( void )
1344 #else
1345 istacksize( )
1346 #endif
1347 {
1348 return MAX_INT_STACK-isp;
1349 }
1350
1351 void
1352 #ifdef __USE_PROTOS
1353 istackreset( void )
1354 #else
1355 istackreset( )
1356 #endif
1357 {
1358 isp = MAX_INT_STACK;
1359 }
1360
1361 int
1362 #ifdef __USE_PROTOS
1363 istackempty( void )
1364 #else
1365 istackempty( )
1366 #endif
1367 {
1368 return isp==MAX_INT_STACK;
1369 }
1370
1371 int
1372 #ifdef __USE_PROTOS
1373 topint( void )
1374 #else
1375 topint( )
1376 #endif
1377 {
1378 require(isp<MAX_INT_STACK, "topint: stack underflow");
1379 return istack[isp];
1380 }
1381
1382 void
1383 #ifdef __USE_PROTOS
1384 ProcessArgs( int argc, char **argv, Opt *options )
1385 #else
1386 ProcessArgs( argc, argv, options )
1387 int argc;
1388 char **argv;
1389 Opt *options;
1390 #endif
1391 {
1392 Opt *p;
1393 require(argv!=NULL, "ProcessArgs: command line NULL");
1394
1395 while ( argc-- > 0 )
1396 {
1397 p = options;
1398 while ( p->option != NULL )
1399 {
1400 if ( strcmp(p->option, "*") == 0 ||
1401 ci_strequ(p->option, *argv) == 1 )
1402 {
1403 if ( p->arg )
1404 {
1405 /* MR9 26-Sep-97 Check for argv valid */
1406 if (argc-- > 0) {
1407 (*p->process)( *argv, *(argv+1) );
1408 argv++;
1409 } else {
1410 fprintf(stderr,"error: required argument for option %s omitted\n",*argv);
1411 exit(PCCTS_EXIT_FAILURE);
1412 };
1413 }
1414 else
1415 (*p->process)( *argv );
1416 break;
1417 }
1418 p++;
1419 }
1420 argv++;
1421 }
1422 }
1423
1424 static void
1425 #ifdef __USE_PROTOS
1426 CompleteContextGuards(void)
1427 #else
1428 CompleteContextGuards()
1429 #endif
1430 {
1431 ListNode * p;
1432 Predicate * pred;
1433
1434 if (ContextGuardPredicateList == NULL) return;
1435
1436 for (p=ContextGuardPredicateList->next; p != NULL; p=p->next) {
1437 pred=(Predicate *)p->elem;
1438 recomputeContextGuard(pred);
1439 }
1440 }
1441
1442 /* Go back into the syntax diagram and compute all meta tokens; i.e.
1443 * turn all '.', ranges, token class refs etc... into actual token sets
1444 */
1445 static void
1446 #ifdef __USE_PROTOS
1447 CompleteTokenSetRefs(void)
1448 #else
1449 CompleteTokenSetRefs()
1450 #endif
1451 {
1452 ListNode *p;
1453
1454 if ( MetaTokenNodes==NULL ) return;
1455 for (p = MetaTokenNodes->next; p!=NULL; p=p->next)
1456 {
1457 set a,b;
1458
1459 TokNode *q = (TokNode *)p->elem;
1460 if ( q->wild_card )
1461 {
1462 q->tset = all_tokens;
1463 }
1464 else if ( q->tclass!=NULL )
1465 {
1466 if ( q->complement ) q->tset = set_dif(all_tokens, q->tclass->tset);
1467 else q->tset = q->tclass->tset;
1468 }
1469 else if ( q->upper_range!=0 )
1470 {
1471 /* we have a range on our hands: make a set from q->token .. q->upper_range */
1472 int i;
1473 a = empty;
1474 for (i=q->token; i<=q->upper_range; i++) { set_orel(i, &a); } /* MR13 */
1475
1476 /* MR13 */ if (q->complement) {
1477 /* MR13 */ q->tset = set_dif(all_tokens, a);
1478 /* MR13 */ set_free(a);
1479 /* MR13 */ } else {
1480 /* MR13 */ q->tset = a;
1481 /* MR13 */ }
1482
1483 }
1484
1485 /* at this point, it can only be a complemented single token */
1486 else if ( q->complement )
1487 {
1488 a = set_of(q->token);
1489 b = set_dif(all_tokens, a);
1490 set_free(a);
1491 q->tset=b;
1492 }
1493 else fatal("invalid meta token");
1494 }
1495 }
1496
1497 /* MR10: Jeff Vincent
1498 MR10: Changed to remove directory information from n only if
1499 MR10: if OutputDirectory was changed by user (-o option)
1500 */
1501
1502 char *
1503 #ifdef __USE_PROTOS
1504 OutMetaName(char *n)
1505 #else
1506 OutMetaName(n)
1507 char *n;
1508 #endif
1509 {
1510 static char *dir_sym = DirectorySymbol;
1511 static char newname[MaxFileName+1];
1512 char *p;
1513
1514 /* If OutputDirectory is same as TopDirectory (platform default) then leave n alone. */
1515 if (strcmp(OutputDirectory, TopDirectory) == 0) /* TopDirectory is "." on Unix. */
1516 return n;
1517
1518 /* p will point to filename without path information */
1519 if ((p = strrchr(n, *dir_sym)) != NULL) /* Directory symbol is "/" on Unix. */
1520 p++;
1521 else
1522 p = n;
1523
1524 /* Copy new output directory into newname[] */
1525 strcpy(newname, OutputDirectory);
1526
1527 /* if new output directory does not have trailing dir_sym, add it! */
1528 if (newname[strlen(newname)-1] != *dir_sym) {
1529 strcat(newname, dir_sym);
1530 }
1531 strcat(newname, p);
1532 return newname;
1533 }
1534
1535 char *
1536 #ifdef __USE_PROTOS
1537 pcctsBaseName(char *n) /* MR32 */
1538 #else
1539 pcctsBaseName(n)
1540 char *n;
1541 #endif
1542 {
1543 static char newname[MaxFileName+1];
1544 static char* dir_sym = DirectorySymbol;
1545 int count = 0;
1546 char *p;
1547
1548 p = n;
1549
1550 while ( *p != '\0' ) {p++;} /* go to end of string */
1551 while ( (*p != *dir_sym) && (p != n) ) {--p;} /* Find last DirectorySymbol */
1552 while ( *p == *dir_sym) p++; /* step forward if we're on a dir symbol */
1553 while ( *p != '\0' && *p != '.')
1554 {
1555 newname[count++] = *p;
1556 p++;
1557 } /* create a new name */
1558 newname[count] = '\0';
1559 return newname;
1560 }
1561
1562 static void
1563 #ifdef __USE_PROTOS
1564 ensure_no_C_file_collisions(char *class_c_file)
1565 #else
1566 ensure_no_C_file_collisions(class_c_file)
1567 char *class_c_file;
1568 #endif
1569 {
1570 int i;
1571
1572 for (i=0; i<NumFiles; i++)
1573 {
1574
1575 #ifdef PCCTS_CASE_INSENSITIVE_FILE_NAME
1576 /* assume that file names are case insensitive */
1577 if ( STRICMP(outname(FileStr[i]), class_c_file)==0 )
1578 #else
1579 if ( strcmp(outname(FileStr[i]), class_c_file)==0 )
1580 #endif
1581 {
1582 fatal(eMsg1("class def output file conflicts with parser output file: %s",
1583 outname(FileStr[i])));
1584 }
1585 }
1586 }
1587
1588 void
1589 #ifdef __USE_PROTOS
1590 warnNoFL(char *err)
1591 #else
1592 warnNoFL(err)
1593 char *err;
1594 #endif
1595 {
1596 fprintf(stderr, "warning: %s\n", err);
1597 }
1598
1599 void
1600 #ifdef __USE_PROTOS
1601 warnFL(char *err,char *f,int l)
1602 #else
1603 warnFL(err,f,l)
1604 char *f;
1605 int l;
1606 char *err;
1607 #endif
1608 {
1609 fprintf(stderr, ErrHdr, f, l);
1610 fprintf(stderr, " warning: %s\n", err);
1611 }
1612
1613 void
1614 #ifdef __USE_PROTOS
1615 warn(char *err)
1616 #else
1617 warn(err)
1618 char *err;
1619 #endif
1620 {
1621 /* back up the file number if we hit an error at the end of the last file */
1622 if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;
1623 fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);
1624 fprintf(stderr, " warning: %s\n", err);
1625 }
1626
1627 void
1628 #ifdef __USE_PROTOS
1629 warnNoCR( char *err )
1630 #else
1631 warnNoCR( err )
1632 char *err;
1633 #endif
1634 {
1635 /* back up the file number if we hit an error at the end of the last file */
1636 if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;
1637 fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);
1638 fprintf(stderr, " warning: %s", err);
1639 }
1640
1641 void
1642 #ifdef __USE_PROTOS
1643 errNoFL(char *err)
1644 #else
1645 errNoFL(err)
1646 char *err;
1647 #endif
1648 {
1649 fprintf(stderr, "error: %s\n", err);
1650 }
1651
1652 void
1653 #ifdef __USE_PROTOS
1654 errFL(char *err,char *f,int l)
1655 #else
1656 errFL(err,f,l)
1657 char *err;
1658 char *f;
1659 int l;
1660 #endif
1661 {
1662 fprintf(stderr, ErrHdr, f, l);
1663 fprintf(stderr, " error: %s\n", err);
1664 }
1665
1666 void
1667 #ifdef __USE_PROTOS
1668 err(char *err)
1669 #else
1670 err(err)
1671 char *err;
1672 #endif
1673 {
1674 /* back up the file number if we hit an error at the end of the last file */
1675 if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;
1676 fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);
1677 fprintf(stderr, " error: %s\n", err);
1678 }
1679
1680 void
1681 #ifdef __USE_PROTOS
1682 errNoCR( char *err )
1683 #else
1684 errNoCR( err )
1685 char *err;
1686 #endif
1687 {
1688 /* back up the file number if we hit an error at the end of the last file */
1689 if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;
1690 fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);
1691 fprintf(stderr, " error: %s", err);
1692 }
1693
1694 UserAction *
1695 #ifdef __USE_PROTOS
1696 newUserAction(char *s)
1697 #else
1698 newUserAction(s)
1699 char *s;
1700 #endif
1701 {
1702 UserAction *ua = (UserAction *) calloc(1, sizeof(UserAction));
1703 require(ua!=NULL, "cannot allocate UserAction");
1704
1705 ua->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
1706 strcpy(ua->action, s);
1707 return ua;
1708 }
1709
1710 /* Added by TJP September 1994 */
1711 /* Take in file.h and return file_h; names w/o '.'s are left alone */
1712 char *
1713 #ifdef __USE_PROTOS
1714 gate_symbol(char *name)
1715 #else
1716 gate_symbol(name)
1717 char *name;
1718 #endif
1719 {
1720 static char buf[100];
1721 char *p;
1722 sprintf(buf, "%s", name);
1723
1724 for (p=buf; *p!='\0'; p++)
1725 {
1726 if ( *p=='.' ) *p = '_';
1727 }
1728 return buf;
1729 }
1730
1731 char *
1732 #ifdef __USE_PROTOS
1733 makeAltID(int blockid, int altnum)
1734 #else
1735 makeAltID(blockid, altnum)
1736 int blockid;
1737 int altnum;
1738 #endif
1739 {
1740 static char buf[100];
1741 char *p;
1742 sprintf(buf, "_blk%d_alt%d", blockid, altnum);
1743 p = (char *)malloc(strlen(buf)+1);
1744 strcpy(p, buf);
1745 return p;
1746 }
+0
-45
contrib/pccts/antlr/makefile.VMS less more
0 $! File: MAKE.COM - Makefile for ANTLR 1.33 on OpenVMS, DECC
1 $!
2 $! History:
3 $! ---------
4 $! 20-Mar-1992 Fred Scholldorf Hacked together for VAX/VMS.
5 $! 24-Mar-1992 Fred Scholldorf LINK against VAXCRTL sharable library.
6 $! 24-Aug-1993 Fred Scholldorf Upgrade for ANTLR V1.10.
7 $! 27-Jan-1998 J.F. Pieronne Upgrade for ANTLR V1.33, DECC
8 $!
9 $ set noon !Don't stop on errors.
10 $!
11 $ if P1 .eqs. "LINK" then goto relink
12 $!
13 $ define/nolog pccts_h "[-.h]"
14 $ define/nolog support_set "[-.support.set]"
15 $!
16 $ delete/nolog *.obj;* !Get rid of existing .OBJ files.
17 $!
18 $ options = "/INCLUDE=(pccts_h,support_set)/define=(USER_ZZSYN)"
19 $ CC 'options' antlr
20 $ CC 'options' scan
21 $ CC 'options' err
22 $ CC 'options' bits
23 $ CC 'options' build
24 $ CC 'options' fset2
25 $ CC 'options' fset
26 $ CC 'options' gen
27 $ CC 'options' globals
28 $ CC 'options' hash
29 $ CC 'options' lex
30 $ CC 'options' main
31 $ CC 'options' misc
32 $ CC 'options' pred
33 $ CC 'options' egman
34 $ CC 'options' mrhoist
35 $ CC 'options' fcache
36 $ CC 'options' [-.support.set]set
37 $!
38 $relink:
39 $ LINK antlr,scan,err,bits,build, -
40 fset2,fset,gen,globals,hash, -
41 lex,main,misc,pred,egman,mrhoist,fcache,set, -
42 sys$input:/options
43 ! sys$share:vaxcrtl.exe/share
44 $ EXIT
+0
-96
contrib/pccts/antlr/makefile1 less more
0 #
1 # Makefile for ANTLR 1.33
2 #
3 # SOFTWARE RIGHTS
4 #
5 # We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 # Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 # company may do whatever they wish with source code distributed with
8 # PCCTS or the code generated by PCCTS, including the incorporation of
9 # PCCTS, or its output, into commerical software.
10 #
11 # We encourage users to develop software with PCCTS. However, we do ask
12 # that credit is given to us for developing PCCTS. By "credit",
13 # we mean that if you incorporate our source code into one of your
14 # programs (commercial product, research project, or otherwise) that you
15 # acknowledge this fact somewhere in the documentation, research report,
16 # etc... If you like PCCTS and have developed a nice tool with the
17 # output, please mention that you developed it using PCCTS. In
18 # addition, we ask that this header remain intact in our source code.
19 # As long as these guidelines are kept, we expect to continue enhancing
20 # this system and expect to make other tools available as they are
21 # completed.
22 #
23 # ANTLR 1.33
24 # Terence Parr
25 # Parr Research Corporation
26 # with Purdue University
27 # and AHPCRC, University of Minnesota
28 # 1989-1995
29 #
30 # Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by
31 # Ed Harfmann
32 # Micro Data Base Systems
33 # Lafayette, Indiana
34 #
35 SET=../support/set
36 PCCTS_H=../h
37
38 #
39 # UNIX (default)
40 #
41 CC=cc
42 ANTLR=../bin/antlr
43 DLG=../bin/dlg
44 OBJ_EXT=o
45 OUT_OBJ = -o
46 ANSI=-ansi
47 AOTHER=
48 CFLAGS= -O0 -g -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) $(ANSI) -DZZLEXBUFSIZE=32000
49 #
50 # SGI Users, use this CFLAGS
51 #
52 #CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262
53
54 OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o \
55 globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o $(OBJOTHER)
56
57 antlr : $(OBJ) $(SRC)
58 $(CC) $(CFLAGS) -o antlr $(OBJ)
59 mv antlr ../bin
60
61 # what files does PCCTS generate (both ANTLR and DLG)
62 PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h
63
64 SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \
65 hash.c lex.c main.c misc.c $(SET)/set.c pred.c egman.c mrhoist.c fcache.c
66
67 #
68 # Don't worry about the ambiguity messages coming from antlr
69 # for making antlr.c etc... [should be 10 of them, I think]
70 #
71 antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g
72 $(ANTLR) -gh antlr.g $(AOTHER)
73
74 antlr.o : antlr.c mode.h tokens.h
75
76 scan.o : scan.c mode.h tokens.h
77
78 scan.c mode.h: parser.dlg
79 $(DLG) -C2 parser.dlg scan.c
80
81 set.o : $(SET)/set.c
82 $(CC) $(CFLAGS) -c -o set.o $(SET)/set.c
83
84
85 #
86 # ****** These next targets are common to UNIX and PC world ********
87 #
88
89 #clean up all the intermediate files
90 clean:
91 rm -f *.$(OBJ_EXT) core
92
93 #remove everything in clean plus the PCCTS files generated
94 scrub:
95 rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core
+0
-1864
contrib/pccts/antlr/misc.c less more
0 /*
1 * misc.c
2 *
3 * Manage tokens, regular expressions.
4 * Print methods for debugging
5 * Compute follow lists onto tail ends of rules.
6 *
7 * The following functions are visible:
8 *
9 * int addTname(char *); Add token name
10 * int addTexpr(char *); Add token expression
11 * int Tnum(char *); Get number of expr/token
12 * void Tklink(char *, char *); Link a name with an expression
13 * int hasAction(expr); Does expr already have action assigned?
14 * void setHasAction(expr); Indicate that expr now has an action
15 * Entry *newEntry(char *,int); Create new table entry with certain size
16 * void list_add(ListNode **list, char *e)
17 * void list_free(ListNode **list, int freeData); *** MR10 ***
18 * void list_apply(ListNode *list, void (*f)())
19 * void lexclass(char *m); switch to new/old lexical class
20 * void lexmode(int i); switch to old lexical class i
21 *
22 * SOFTWARE RIGHTS
23 *
24 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
25 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
26 * company may do whatever they wish with source code distributed with
27 * PCCTS or the code generated by PCCTS, including the incorporation of
28 * PCCTS, or its output, into commerical software.
29 *
30 * We encourage users to develop software with PCCTS. However, we do ask
31 * that credit is given to us for developing PCCTS. By "credit",
32 * we mean that if you incorporate our source code into one of your
33 * programs (commercial product, research project, or otherwise) that you
34 * acknowledge this fact somewhere in the documentation, research report,
35 * etc... If you like PCCTS and have developed a nice tool with the
36 * output, please mention that you developed it using PCCTS. In
37 * addition, we ask that this header remain intact in our source code.
38 * As long as these guidelines are kept, we expect to continue enhancing
39 * this system and expect to make other tools available as they are
40 * completed.
41 *
42 * ANTLR 1.33
43 * Terence Parr
44 * Parr Research Corporation
45 * with Purdue University and AHPCRC, University of Minnesota
46 * 1989-2001
47 */
48
49 #include <stdio.h>
50 #include "pcctscfg.h"
51 #include "set.h"
52 #include "syn.h"
53 #include "hash.h"
54 #include "generic.h"
55 #include "dlgdef.h"
56 #include <ctype.h>
57
58 static int tsize=TSChunk; /* size of token str arrays */
59
60 static void
61 #ifdef __USE_PROTOS
62 RemapForcedTokensInSyntaxDiagram(Node *);
63 #else
64 RemapForcedTokensInSyntaxDiagram();
65 #endif
66
67 /* T o k e n M a n i p u l a t i o n */
68
69 /*
70 * add token 't' to the TokenStr/Expr array. Make more room if necessary.
71 * 't' is either an expression or a token name.
72 *
73 * There is only one TokenStr array, but multiple ExprStr's. Therefore,
74 * for each lex class (element of lclass) we must extend the ExprStr array.
75 * ExprStr's and TokenStr are always all the same size.
76 *
77 * Also, there is a Texpr hash table for each automaton.
78 */
79 static void
80 #ifdef __USE_PROTOS
81 Ttrack( char *t )
82 #else
83 Ttrack( t )
84 char *t;
85 #endif
86 {
87 if ( TokenNum >= tsize ) /* terminal table overflow? */
88 {
89 char **p;
90 int i, more, j;
91
92 more = TSChunk * (1 + ((TokenNum-tsize) / TSChunk));
93 tsize += more;
94 TokenStr = (char **) realloc((char *)TokenStr, tsize*sizeof(char *));
95 require(TokenStr != NULL, "Ttrack: can't extend TokenStr");
96 for (i=0; i<NumLexClasses; i++)
97 {
98 lclass[i].exprs = (char **)
99 realloc((char *)lclass[i].exprs, tsize*sizeof(char *));
100 require(lclass[i].exprs != NULL, "Ttrack: can't extend ExprStr");
101 for (p= &lclass[i].exprs[tsize-more],j=1; j<=more; j++) *p++ = NULL;
102 }
103 for (p= &TokenStr[tsize-more],i=1; i<=more; i++) *p++ = NULL;
104 lexmode( CurrentLexClass ); /* reset ExprStr in case table moved */
105 }
106 /* note: we use the actual ExprStr/TokenStr array
107 * here as TokenInd doesn't exist yet
108 */
109 if ( *t == '"' ) ExprStr[TokenNum] = t;
110 else TokenStr[TokenNum] = t;
111 }
112
113 static Expr *
114 #ifdef __USE_PROTOS
115 newExpr( char *e )
116 #else
117 newExpr( e )
118 char *e;
119 #endif
120 {
121 Expr *p = (Expr *) calloc(1, sizeof(Expr));
122 require(p!=NULL, "newExpr: cannot alloc Expr node");
123
124 p->expr = e;
125 p->lclass = CurrentLexClass;
126 return p;
127 }
128
129 /* switch to lexical class/mode m. This amounts to creating a new
130 * lex mode if one does not already exist and making ExprStr point
131 * to the correct char string array. We must also switch Texpr tables.
132 *
133 * BTW, we need multiple ExprStr arrays because more than one automaton
134 * may have the same label for a token, but with different expressions.
135 * We need to track an expr for each automaton. If we disallowed this
136 * feature, only one ExprStr would be required.
137 */
138 void
139 #ifdef __USE_PROTOS
140 lexclass( char *m )
141 #else
142 lexclass( m )
143 char *m;
144 #endif
145 {
146 int i;
147 TermEntry *p;
148 static char EOFSTR[] = "\"@\"";
149
150 if ( hash_get(Tname, m) != NULL )
151 {
152 warn(eMsg1("lexclass name conflicts with token/errclass label '%s'",m));
153 }
154 /* does m already exist? */
155 i = LexClassIndex(m);
156 if ( i != -1 ) {lexmode(i); return;}
157 /* must make new one */
158 NumLexClasses++;
159 CurrentLexClass = NumLexClasses-1;
160 require(NumLexClasses<=MaxLexClasses, "number of allowable lexclasses exceeded\nIncrease MaxLexClasses in generic.h and recompile all C files");
161 lclass[CurrentLexClass].classnum = m;
162 lclass[CurrentLexClass].exprs = (char **) calloc(tsize, sizeof(char *));
163 require(lclass[CurrentLexClass].exprs!=NULL,
164 "lexclass: cannot allocate ExprStr");
165 lclass[CurrentLexClass].htable = newHashTable();
166 ExprStr = lclass[CurrentLexClass].exprs;
167 Texpr = lclass[CurrentLexClass].htable;
168 /* define EOF for each automaton */
169 p = newTermEntry( EOFSTR );
170 p->token = EofToken; /* couldn't have remapped tokens yet, use EofToken */
171 hash_add(Texpr, EOFSTR, (Entry *)p);
172 list_add(&ExprOrder, (void *)newExpr(EOFSTR));
173 /* note: we use the actual ExprStr array
174 * here as TokenInd doesn't exist yet
175 */
176 ExprStr[EofToken] = EOFSTR;
177 }
178
179 void
180 #ifdef __USE_PROTOS
181 lexmode( int i )
182 #else
183 lexmode( i )
184 int i;
185 #endif
186 {
187 require(i<NumLexClasses, "lexmode: invalid mode");
188 ExprStr = lclass[i].exprs;
189 Texpr = lclass[i].htable;
190 CurrentLexClass = i;
191 }
192
193 /* return index into lclass array of lexical class. return -1 if nonexistent */
194 int
195 #ifdef __USE_PROTOS
196 LexClassIndex( char *cl )
197 #else
198 LexClassIndex( cl )
199 char *cl;
200 #endif
201 {
202 int i;
203
204 for (i=0; i<NumLexClasses; i++)
205 {
206 if ( strcmp(lclass[i].classnum, cl) == 0 ) return i;
207 }
208 return -1;
209 }
210
211 int
212 #ifdef __USE_PROTOS
213 hasAction( char *expr )
214 #else
215 hasAction( expr )
216 char *expr;
217 #endif
218 {
219 TermEntry *p;
220 require(expr!=NULL, "hasAction: invalid expr");
221
222 p = (TermEntry *) hash_get(Texpr, expr);
223 require(p!=NULL, eMsg1("hasAction: expr '%s' doesn't exist",expr));
224 return (p->action!=NULL);
225 }
226
227 void
228 #ifdef __USE_PROTOS
229 setHasAction( char *expr, char *action )
230 #else
231 setHasAction( expr, action )
232 char *expr;
233 char *action;
234 #endif
235 {
236 TermEntry *p;
237 require(expr!=NULL, "setHasAction: invalid expr");
238
239 p = (TermEntry *) hash_get(Texpr, expr);
240 require(p!=NULL, eMsg1("setHasAction: expr '%s' doesn't exist",expr));
241 p->action = action;
242 }
243
244 ForcedToken *
245 #ifdef __USE_PROTOS
246 newForcedToken(char *token, int tnum)
247 #else
248 newForcedToken(token, tnum)
249 char *token;
250 int tnum;
251 #endif
252 {
253 ForcedToken *ft = (ForcedToken *) calloc(1, sizeof(ForcedToken));
254 require(ft!=NULL, "out of memory");
255 ft->token = token;
256 ft->tnum = tnum;
257 return ft;
258 }
259
260 /*
261 * Make a token indirection array that remaps token numbers and then walk
262 * the appropriate symbol tables and SynDiag to change token numbers
263 */
264 void
265 #ifdef __USE_PROTOS
266 RemapForcedTokens(void)
267 #else
268 RemapForcedTokens()
269 #endif
270 {
271 ListNode *p;
272 ForcedToken *q;
273 int max_token_number=0; /* MR9 23-Sep-97 Removed "unsigned" */
274 int i;
275
276 if ( ForcedTokens == NULL ) return;
277
278 /* find max token num */
279 for (p = ForcedTokens->next; p!=NULL; p=p->next)
280 {
281 q = (ForcedToken *) p->elem;
282 if ( q->tnum > max_token_number ) max_token_number = q->tnum;
283 }
284 fprintf(stderr, "max token number is %d\n", max_token_number);
285
286 /* make token indirection array */
287 TokenInd = (int *) calloc(max_token_number+1, sizeof(int));
288 LastTokenCounted = TokenNum;
289 TokenNum = max_token_number+1;
290 require(TokenInd!=NULL, "RemapForcedTokens: cannot allocate TokenInd");
291
292 /* fill token indirection array and change token id htable ; swap token indices */
293 for (i=1; i<TokenNum; i++) TokenInd[i] = i;
294 for (p = ForcedTokens->next; p!=NULL; p=p->next)
295 {
296 TermEntry *te;
297 int old_pos, t;
298
299 q = (ForcedToken *) p->elem;
300 fprintf(stderr, "%s forced to %d\n", q->token, q->tnum);
301 te = (TermEntry *) hash_get(Tname, q->token);
302 require(te!=NULL, "RemapForcedTokens: token not in hash table");
303 old_pos = te->token;
304 fprintf(stderr, "Before: TokenInd[old_pos==%d] is %d\n", old_pos, TokenInd[old_pos]);
305 fprintf(stderr, "Before: TokenInd[target==%d] is %d\n", q->tnum, TokenInd[q->tnum]);
306 q = (ForcedToken *) p->elem;
307 t = TokenInd[old_pos];
308 TokenInd[old_pos] = q->tnum;
309 TokenInd[q->tnum] = t;
310 te->token = q->tnum; /* update token type id symbol table */
311 fprintf(stderr, "After: TokenInd[old_pos==%d] is %d\n", old_pos, TokenInd[old_pos]);
312 fprintf(stderr, "After: TokenInd[target==%d] is %d\n", q->tnum, TokenInd[q->tnum]);
313
314 /* Change the token number in the sym tab entry for the exprs
315 * at the old position of the token id and the target position
316 */
317 /* update expr at target (if any) of forced token id */
318 if ( q->tnum < TokenNum ) /* is it a valid position? */
319 {
320 for (i=0; i<NumLexClasses; i++)
321 {
322 if ( lclass[i].exprs[q->tnum]!=NULL )
323 {
324 /* update the symbol table for this expr */
325 TermEntry *e = (TermEntry *) hash_get(lclass[i].htable, lclass[i].exprs[q->tnum]);
326 require(e!=NULL, "RemapForcedTokens: expr not in hash table");
327 e->token = old_pos;
328 fprintf(stderr, "found expr '%s' at target %d in lclass[%d]; changed to %d\n",
329 lclass[i].exprs[q->tnum], q->tnum, i, old_pos);
330 }
331 }
332 }
333 /* update expr at old position (if any) of forced token id */
334 for (i=0; i<NumLexClasses; i++)
335 {
336 if ( lclass[i].exprs[old_pos]!=NULL )
337 {
338 /* update the symbol table for this expr */
339 TermEntry *e = (TermEntry *) hash_get(lclass[i].htable, lclass[i].exprs[old_pos]);
340 require(e!=NULL, "RemapForcedTokens: expr not in hash table");
341 e->token = q->tnum;
342 fprintf(stderr, "found expr '%s' for id %s in lclass[%d]; changed to %d\n",
343 lclass[i].exprs[old_pos], q->token, i, q->tnum);
344 }
345 }
346 }
347
348 /* Update SynDiag */
349 RemapForcedTokensInSyntaxDiagram((Node *)SynDiag);
350 }
351
352 static void
353 #ifdef __USE_PROTOS
354 RemapForcedTokensInSyntaxDiagram(Node *p)
355 #else
356 RemapForcedTokensInSyntaxDiagram(p)
357 Node *p;
358 #endif
359 {
360 Junction *j = (Junction *) p;
361 RuleRefNode *r = (RuleRefNode *) p;
362 TokNode *t = (TokNode *)p;
363
364 if ( p==NULL ) return;
365 require(p->ntype>=1 && p->ntype<=NumNodeTypes, "Remap...: invalid diagram node");
366 switch ( p->ntype )
367 {
368 case nJunction :
369 if ( j->visited ) return;
370 if ( j->jtype == EndRule ) return;
371 j->visited = TRUE;
372 RemapForcedTokensInSyntaxDiagram( j->p1 );
373 RemapForcedTokensInSyntaxDiagram( j->p2 );
374 j->visited = FALSE;
375 return;
376 case nRuleRef :
377 RemapForcedTokensInSyntaxDiagram( r->next );
378 return;
379 case nToken :
380 if ( t->remapped ) return; /* we've been here before */
381 t->remapped = 1;
382 fprintf(stderr, "remapping %d to %d\n", t->token, TokenInd[t->token]);
383 t->token = TokenInd[t->token];
384 RemapForcedTokensInSyntaxDiagram( t->next );
385 return;
386 case nAction :
387 RemapForcedTokensInSyntaxDiagram( ((ActionNode *)p)->next );
388 return;
389 default :
390 fatal_internal("invalid node type");
391 }
392 }
393
394 /*
395 * Add a token name. Return the token number associated with it. If it already
396 * exists, then return the token number assigned to it.
397 *
398 * Track the order in which tokens are found so that the DLG output maintains
399 * that order. It also lets us map token numbers to strings.
400 */
401 int
402 #ifdef __USE_PROTOS
403 addTname( char *token )
404 #else
405 addTname( token )
406 char *token;
407 #endif
408 {
409 TermEntry *p;
410 require(token!=NULL, "addTname: invalid token name");
411
412 if ( (p=(TermEntry *)hash_get(Tname, token)) != NULL ) return p->token;
413 p = newTermEntry( token );
414 Ttrack( p->str );
415 p->token = TokenNum++;
416 hash_add(Tname, token, (Entry *)p);
417 return p->token;
418 }
419
420 /* This is the same as addTname except we force the TokenNum to be tnum.
421 * We don't have to use the Forced token stuff as no tokens will have
422 * been defined with #tokens when this is called. This is only called
423 * when a #tokdefs meta-op is used.
424 */
425 int
426 #ifdef __USE_PROTOS
427 addForcedTname( char *token, int tnum )
428 #else
429 addForcedTname( token, tnum )
430 char *token;
431 int tnum;
432 #endif
433 {
434 TermEntry *p;
435 require(token!=NULL, "addTname: invalid token name");
436
437 if ( (p=(TermEntry *)hash_get(Tname, token)) != NULL ) return p->token;
438 p = newTermEntry( token );
439 Ttrack( p->str );
440 p->token = tnum;
441 hash_add(Tname, token, (Entry *)p);
442 return p->token;
443 }
444
445 /*
446 * Add a token expr. Return the token number associated with it. If it already
447 * exists, then return the token number assigned to it.
448 */
449 int
450 #ifdef __USE_PROTOS
451 addTexpr( char *expr )
452 #else
453 addTexpr( expr )
454 char *expr;
455 #endif
456 {
457 TermEntry *p;
458 require(expr!=NULL, "addTexpr: invalid regular expression");
459
460 if ( (p=(TermEntry *)hash_get(Texpr, expr)) != NULL ) return p->token;
461 p = newTermEntry( expr );
462 Ttrack( p->str );
463 /* track the order in which they occur */
464 list_add(&ExprOrder, (void *)newExpr(p->str));
465 p->token = TokenNum++;
466 hash_add(Texpr, expr, (Entry *)p);
467 return p->token;
468 }
469
470 /* return the token number of 'term'. Return 0 if no 'term' exists */
471 int
472 #ifdef __USE_PROTOS
473 Tnum( char *term )
474 #else
475 Tnum( term )
476 char *term;
477 #endif
478 {
479 TermEntry *p;
480 require(term!=NULL, "Tnum: invalid terminal");
481
482 if ( *term=='"' ) p = (TermEntry *) hash_get(Texpr, term);
483 else p = (TermEntry *) hash_get(Tname, term);
484 if ( p == NULL ) return 0;
485 else return p->token;
486 }
487
488 /* associate a Name with an expr. If both have been already assigned
489 * token numbers, then an error is reported. Add the token or expr
490 * that has not been added if no error. This 'represents' the #token
491 * ANTLR pseudo-op. If both have not been defined, define them both
492 * linked to same token number.
493 */
494 void
495 #ifdef __USE_PROTOS
496 Tklink( char *token, char *expr )
497 #else
498 Tklink( token, expr )
499 char *token;
500 char *expr;
501 #endif
502 {
503 TermEntry *p, *q;
504 require(token!=NULL && expr!=NULL, "Tklink: invalid token name and/or expr");
505
506 p = (TermEntry *) hash_get(Tname, token);
507 q = (TermEntry *) hash_get(Texpr, expr);
508 if ( p != NULL && q != NULL ) /* both defined */
509 {
510 warn( eMsg2("token name %s and rexpr %s already defined; ignored",
511 token, expr) );
512 return;
513 }
514 if ( p==NULL && q==NULL ) /* both not defined */
515 {
516 int t = addTname( token );
517 q = newTermEntry( expr );
518 hash_add(Texpr, expr, (Entry *)q);
519 q->token = t;
520 /* note: we use the actual ExprStr array
521 * here as TokenInd doesn't exist yet
522 */
523 ExprStr[t] = q->str;
524 /* track the order in which they occur */
525 list_add(&ExprOrder, (void *)newExpr(q->str));
526 return;
527 }
528 if ( p != NULL ) /* one is defined, one is not */
529 {
530 q = newTermEntry( expr );
531 hash_add(Texpr, expr, (Entry *)q);
532 q->token = p->token;
533 ExprStr[p->token] = q->str; /* both expr and token str defined now */
534 list_add(&ExprOrder, (void *)newExpr(q->str));
535 }
536 else /* trying to associate name with expr here*/
537 {
538 p = newTermEntry( token );
539 hash_add(Tname, token, (Entry *)p);
540 p->token = q->token;
541 TokenStr[p->token] = p->str;/* both expr and token str defined now */
542 }
543 }
544
545 /*
546 * Given a string, this function allocates and returns a pointer to a
547 * hash table record of size 'sz' whose "str" pointer is reset to a position
548 * in the string table.
549 */
550 Entry *
551 #ifdef __USE_PROTOS
552 newEntry( char *text, int sz )
553 #else
554 newEntry( text, sz )
555 char *text;
556 int sz;
557 #endif
558 {
559 Entry *p;
560 require(text!=NULL, "new: NULL terminal");
561
562 if ( (p = (Entry *) calloc(1,sz)) == 0 )
563 {
564 fatal_internal("newEntry: out of memory for terminals\n");
565 exit(PCCTS_EXIT_FAILURE);
566 }
567 p->str = mystrdup(text);
568
569 return(p);
570 }
571
572 /*
573 * add an element to a list.
574 *
575 * Any non-empty list has a sentinel node whose 'elem' pointer is really
576 * a pointer to the last element. (i.e. length(list) = #elemIn(list)+1).
577 * Elements are appended to the list.
578 */
579 void
580 #ifdef __USE_PROTOS
581 list_add( ListNode **list, void *e )
582 #else
583 list_add( list, e )
584 ListNode **list;
585 void *e;
586 #endif
587 {
588 ListNode *p, *tail;
589 require(e!=NULL, "list_add: attempting to add NULL list element");
590
591 p = newListNode;
592 require(p!=NULL, "list_add: cannot alloc new list node");
593 p->elem = e;
594 if ( *list == NULL )
595 {
596 ListNode *sentinel = newListNode;
597 require(sentinel!=NULL, "list_add: cannot alloc sentinel node");
598 *list=sentinel;
599 sentinel->next = p;
600 sentinel->elem = (char *)p; /* set tail pointer */
601 }
602 else /* find end of list */
603 {
604 tail = (ListNode *) (*list)->elem; /* get tail pointer */
605 tail->next = p;
606 (*list)->elem = (char *) p; /* reset tail */
607 }
608 }
609
610 /* MR10 list_free() frees the ListNode elements in the list */
611 /* MR10 if freeData then free the data elements of the list too */
612
613 void
614 #ifdef __USE_PROTOS
615 list_free(ListNode **list,int freeData)
616 #else
617 list_free(list,freeData)
618 ListNode **list;
619 int freeData;
620 #endif
621 {
622 ListNode *p;
623 ListNode *next;
624
625 if (list == NULL) return;
626 if (*list == NULL) return;
627 for (p=*list; p != NULL; p=next) {
628 next=p->next;
629 if (freeData && p->elem != NULL) {
630 free( (char *) p->elem);
631 };
632 free( (char *) p);
633 };
634 *list=NULL;
635 }
636
637 void
638 #ifdef __USE_PROTOS
639 list_apply( ListNode *list, void (*f)(void *) )
640 #else
641 list_apply( list, f )
642 ListNode *list;
643 void (*f)();
644 #endif
645 {
646 ListNode *p;
647 require(f!=NULL, "list_apply: NULL function to apply");
648
649 if ( list == NULL ) return;
650 for (p = list->next; p!=NULL; p=p->next) (*f)( p->elem );
651 }
652
653 /* MR27 */
654
655 #ifdef __USE_PROTOS
656 int list_search_cstring(ListNode *list, char * cstring)
657 #else
658 int list_search_cstring(list, cstring)
659 ListNode * list;
660 char * cstring;
661 #endif
662 {
663 ListNode *p;
664 if (list == NULL ) return 0;
665 for (p = list->next; p!=NULL; p=p->next) {
666 if (p->elem == NULL) continue;
667 if (0 == strcmp((char *) p->elem , cstring)) return 1;
668 }
669 return 0;
670 }
671
672 /* F O L L O W C y c l e S t u f f */
673
674 /* make a key based upon (rulename, computation, k value).
675 * Computation values are 'i'==FIRST, 'o'==FOLLOW.
676 */
677
678 /* MR10 Make the key all characters so it can be read easily */
679 /* MR10 by a simple dump program. Also, separates */
680 /* MR10 'o' and 'i' from rule name */
681
682 char *
683 #ifdef __USE_PROTOS
684 Fkey( char *rule, int computation, int k )
685 #else
686 Fkey( rule, computation, k )
687 char *rule;
688 int computation;
689 int k;
690 #endif
691 {
692 static char key[MaxRuleName+2+2+1]; /* MR10 */
693 int i;
694
695 if ( k > 99 ) /* MR10 */
696 fatal("k>99 is too big for this implementation of ANTLR!\n"); /* MR10 */
697 if ( (i=strlen(rule)) > MaxRuleName ) /* MR10 */
698 fatal( eMsgd("rule name > max of %d\n", MaxRuleName) ); /* MR10 */
699 strcpy(key,rule);
700
701 /* MR10 */ key[i]='*';
702 /* MR10 */ key[i+1] = (char) computation; /* MR20 G. Hobbelt */
703 /* MR10 */ if (k < 10) {
704 /* MR10 */ key[i+2] = (char) ( '0' + k);
705 /* MR10 */ key[i+3] = '\0';
706 /* MR10 */ } else {
707 /* MR10 */ key[i+2] = (char) ( '0' + k/10);
708 /* MR10 */ key[i+3] = (char) ( '0' + k % 10);
709 /* MR10 */ key[i+4] = '\0';
710 /* MR10 */ };
711
712 return key;
713 }
714
715 /* Push a rule onto the kth FOLLOW stack */
716 void
717 #ifdef __USE_PROTOS
718 FoPush( char *rule, int k )
719 #else
720 FoPush( rule, k )
721 char *rule;
722 int k;
723 #endif
724 {
725 RuleEntry *r;
726 require(rule!=NULL, "FoPush: tried to push NULL rule");
727 require(k<=CLL_k, "FoPush: tried to access non-existent stack");
728
729 /*fprintf(stderr, "FoPush(%s)\n", rule);*/
730 r = (RuleEntry *) hash_get(Rname, rule);
731 if ( r == NULL ) {fatal_internal( eMsg1("rule %s must be defined but isn't", rule) );}
732 if ( FoStack[k] == NULL ) /* Does the kth stack exist yet? */
733 {
734 /*fprintf(stderr, "allocating FoStack\n");*/
735 FoStack[k] = (int *) calloc(FoStackSize, sizeof(int));
736 require(FoStack[k]!=NULL, "FoPush: cannot allocate FOLLOW stack\n");
737 }
738 if ( FoTOS[k] == NULL )
739 {
740 FoTOS[k]=FoStack[k];
741 *(FoTOS[k]) = r->rulenum;
742 }
743 else
744 {
745 #ifdef MEMCHK
746 require(valid(FoStack[k]), "FoPush: invalid FoStack");
747 #endif
748 if ( FoTOS[k] >= &(FoStack[k][FoStackSize-1]) )
749 fatal( eMsgd("exceeded max depth of FOLLOW recursion (%d)\n",
750 FoStackSize) );
751 require(FoTOS[k]>=FoStack[k],
752 eMsg1("FoPush: FoStack stack-ptr is playing out of its sandbox",
753 rule));
754 ++(FoTOS[k]);
755 *(FoTOS[k]) = r->rulenum;
756 }
757 {
758 /*
759 **** int *p;
760 **** fprintf(stderr, "FoStack[k=%d]:\n", k);
761 **** for (p=FoStack[k]; p<=FoTOS[k]; p++)
762 **** {
763 **** fprintf(stderr, "\t%s\n", RulePtr[*p]->rname);
764 **** }
765 */
766 }
767 }
768
769 /* Pop one rule off of the FOLLOW stack. TOS ptr is NULL if empty. */
770 void
771 #ifdef __USE_PROTOS
772 FoPop( int k )
773 #else
774 FoPop( k )
775 int k;
776 #endif
777 {
778 require(k<=CLL_k, "FoPop: tried to access non-existent stack");
779 /*fprintf(stderr, "FoPop\n");*/
780 require(FoTOS[k]>=FoStack[k]&&FoTOS[k]<=&(FoStack[k][FoStackSize-1]),
781 "FoPop: FoStack stack-ptr is playing out of its sandbox");
782 if ( FoTOS[k] == FoStack[k] ) FoTOS[k] = NULL;
783 else (FoTOS[k])--;
784 }
785
786 /* Compute FOLLOW cycle.
787 * Mark all FOLLOW sets for rules in cycle as incomplete.
788 * Then, save cycle on the cycle list (Cycles) for later resolution.
789 * The Cycle is stored in the form:
790 * (head of cycle==croot, rest of rules in cycle==cyclicDep)
791 *
792 * e.g. (Fo means "FOLLOW of", "-->" means requires or depends on)
793 *
794 * Fo(x)-->Fo(a)-->Fo(b)-->Fo(c)-->Fo(x)
795 * ^----Infinite recursion (cycle)
796 *
797 * the cycle would be: x -> {a,b,c} or stored as (x,{a,b,c}). Fo(x) depends
798 * on the FOLLOW of a,b, and c. The root of a cycle is always complete after
799 * Fo(x) finishes. Fo(a,b,c) however are not. It turns out that all rules
800 * in a FOLLOW cycle have the same FOLLOW set.
801 */
802 void
803 #ifdef __USE_PROTOS
804 RegisterCycle( char *rule, int k )
805 #else
806 RegisterCycle( rule, k )
807 char *rule;
808 int k;
809 #endif
810 {
811 CacheEntry *f;
812 Cycle *c;
813 int *p;
814 RuleEntry *r;
815 require(rule!=NULL, "RegisterCycle: tried to register NULL rule");
816 require(k<=CLL_k, "RegisterCycle: tried to access non-existent stack");
817
818 /*fprintf(stderr, "RegisterCycle(%s)\n", rule);*/
819 /* Find cycle start */
820 r = (RuleEntry *) hash_get(Rname, rule);
821 require(r!=NULL,eMsg1("rule %s must be defined but isn't", rule));
822 require(FoTOS[k]>=FoStack[k]&&FoTOS[k]<=&(FoStack[k][FoStackSize-1]),
823 eMsg1("RegisterCycle(%s): FoStack stack-ptr is playing out of its sandbox",
824 rule));
825 /*** if ( FoTOS[k]<FoStack[k]||FoTOS[k]>&(FoStack[k][FoStackSize-1]) )
826 **** {
827 **** fprintf(stderr, "RegisterCycle(%s): FoStack stack-ptr is playing out of its sandbox\n",
828 **** rule);
829 **** fprintf(stderr, "RegisterCycle: sp==0x%x out of bounds 0x%x...0x%x\n",
830 **** FoTOS[k], FoStack[k], &(FoStack[k][FoStackSize-1]));
831 **** exit(PCCTS_EXIT_FAILURE);
832 **** }
833 ****/
834
835 #ifdef MEMCHK
836 require(valid(FoStack[k]), "RegisterCycle: invalid FoStack");
837 #endif
838 for (p=FoTOS[k]; *p != r->rulenum && p >= FoStack[k]; --p) {;}
839 require(p>=FoStack[k], "RegisterCycle: FoStack is screwed up beyond belief");
840 if ( p == FoTOS[k] ) return; /* don't worry about cycles to oneself */
841
842 /* compute cyclic dependents (rules in cycle except head) */
843 c = newCycle;
844 require(c!=NULL, "RegisterCycle: couldn't alloc new cycle");
845 c->cyclicDep = empty;
846 c->croot = *p++; /* record root of cycle */
847 for (; p<=FoTOS[k]; p++)
848 {
849 /* Mark all dependent rules as incomplete */
850 f = (CacheEntry *) hash_get(Fcache, Fkey(RulePtr[*p]->rname,'o',k));
851 if ( f==NULL )
852 {
853 f = newCacheEntry( Fkey(RulePtr[*p]->rname,'o',k) );
854 hash_add(Fcache, Fkey(RulePtr[*p]->rname,'o',k), (Entry *)f);
855 }
856 f->incomplete = TRUE;
857
858 set_orel(*p, &(c->cyclicDep)); /* mark rule as dependent of croot */
859 }
860 list_add(&(Cycles[k]), (void *)c);
861 }
862
863 /* make all rules in cycle complete
864 *
865 * while ( some set has changed ) do
866 * for each cycle do
867 * if degree of FOLLOW set for croot > old degree then
868 * update all FOLLOW sets for rules in cyclic dependency
869 * change = TRUE
870 * endif
871 * endfor
872 * endwhile
873 */
874 void
875 #ifdef __USE_PROTOS
876 ResolveFoCycles( int k )
877 #else
878 ResolveFoCycles( k )
879 int k;
880 #endif
881 {
882 ListNode *p, *q;
883 Cycle *c;
884 int changed = 1;
885 CacheEntry *f,*g;
886 int r;
887 /* int i; */ /* MR10 not useful */
888 unsigned d;
889
890 unsigned *cursor; /* MR10 */
891 unsigned *origin; /* MR10 */
892
893 /*fprintf(stderr, "Resolving following cycles for %d\n", k);*/
894 while ( changed )
895 {
896 changed = 0;
897 /* MR10 i = 0; */
898 for (p = Cycles[k]->next; p!=NULL; p=p->next)
899 {
900 c = (Cycle *) p->elem;
901 /*fprintf(stderr, "cycle %d: %s -->", i++, RulePtr[c->croot]->rname);*/
902 /*s_fprT(stderr, c->cyclicDep);*/
903 /*fprintf(stderr, "\n");*/
904 f = (CacheEntry *)
905 hash_get(Fcache, Fkey(RulePtr[c->croot]->rname,'o',k));
906 require(f!=NULL, eMsg1("FOLLOW(%s) must be in cache but isn't", RulePtr[c->croot]->rname) );
907 if ( (d=set_deg(f->fset)) > c->deg )
908 {
909 /*fprintf(stderr, "Fo(%s) has changed\n", RulePtr[c->croot]->rname);*/
910 changed = 1;
911 c->deg = d; /* update cycle FOLLOW set degree */
912
913 /* MR10 */ origin=set_pdq(c->cyclicDep);
914 /* MR10 */ for (cursor=origin; *cursor != nil; cursor++) {
915 /* MR10 */ r=*cursor;
916
917 /******** while ( !set_nil(c->cyclicDep) ) { *****/
918 /******** r = set_int(c->cyclicDep); *****/
919 /******** set_rm(r, c->cyclicDep); *****/
920
921 /*fprintf(stderr, "updating Fo(%s)\n", RulePtr[r]->rname);*/
922 g = (CacheEntry *)
923 hash_get(Fcache, Fkey(RulePtr[r]->rname,'o',k));
924 require(g!=NULL, eMsg1("FOLLOW(%s) must be in cache but isn't", RulePtr[r]->rname) );
925 set_orin(&(g->fset), f->fset);
926 g->incomplete = FALSE;
927 }
928 /* MR10 */ free( (char *) origin);
929 /* MR10 */ origin=NULL;
930 }
931 }
932 /* MR10 - this if statement appears to be meaningless since i is always 0 */
933 /* MR10 if ( i == 1 ) changed = 0; */ /* if only 1 cycle, no need to repeat */
934 }
935 /* kill Cycle list */
936 for (q = Cycles[k]->next; q != NULL; q=p)
937 {
938 p = q->next;
939 set_free( ((Cycle *)q->elem)->cyclicDep );
940 free((char *)q);
941 }
942 free( (char *)Cycles[k] );
943 Cycles[k] = NULL;
944 }
945
946
947 /* P r i n t i n g S y n t a x D i a g r a m s */
948
949 static void
950 #ifdef __USE_PROTOS
951 pBlk( Junction *q, int btype )
952 #else
953 pBlk( q, btype )
954 Junction *q;
955 int btype;
956 #endif
957 {
958 int k,a;
959 Junction *alt, *p;
960
961 q->end->pvisited = TRUE;
962 if ( btype == aLoopBegin )
963 {
964 require(q->p2!=NULL, "pBlk: invalid ()* block");
965 PRINT(q->p1);
966 alt = (Junction *)q->p2;
967 PRINT(alt->p1);
968 if ( PrintAnnotate )
969 {
970 printf(" /* Opt ");
971 k = 1;
972 while ( !set_nil(alt->fset[k]) )
973 {
974 s_fprT(stdout, alt->fset[k]);
975 if ( k++ == CLL_k ) break;
976 if ( !set_nil(alt->fset[k]) ) printf(", ");
977 }
978 printf(" */\n");
979 }
980 return;
981 }
982 for (a=1,alt=q; alt != NULL; alt= (Junction *) alt->p2, a++)
983 {
984 if ( alt->p1 != NULL ) PRINT(alt->p1);
985 if ( PrintAnnotate )
986 {
987 printf( " /* [%d] ", alt->altnum);
988 k = 1;
989 while ( !set_nil(alt->fset[k]) )
990 {
991 s_fprT(stdout, alt->fset[k]);
992 if ( k++ == CLL_k ) break;
993 if ( !set_nil(alt->fset[k]) ) printf(", ");
994 }
995 if ( alt->p2 == NULL && btype == aOptBlk )
996 printf( " (optional branch) */\n");
997 else printf( " */\n");
998 }
999
1000 /* ignore implied empty alt of Plus blocks */
1001 if ( alt->p2 != NULL && ((Junction *)alt->p2)->ignore ) break;
1002
1003 if ( alt->p2 != NULL && !(((Junction *)alt->p2)->p2==NULL && btype == aOptBlk) )
1004 {
1005 if ( pLevel == 1 )
1006 {
1007 printf("\n");
1008 if ( a+1==pAlt1 || a+1==pAlt2 ) printf("=>");
1009 printf("\t");
1010 }
1011 else printf(" ");
1012 printf("|");
1013 if ( pLevel == 1 )
1014 {
1015 p = (Junction *) ((Junction *)alt->p2)->p1;
1016 while ( p!=NULL )
1017 {
1018 if ( p->ntype==nAction )
1019 {
1020 p=(Junction *)((ActionNode *)p)->next;
1021 continue;
1022 }
1023 if ( p->ntype!=nJunction )
1024 {
1025 break;
1026 }
1027 if ( p->jtype==EndBlk || p->jtype==EndRule )
1028 {
1029 p = NULL;
1030 break;
1031 }
1032 p = (Junction *)p->p1;
1033 }
1034 if ( p==NULL ) printf("\n\t"); /* Empty alt? */
1035 }
1036 }
1037 }
1038 q->end->pvisited = FALSE;
1039 }
1040
1041 /* How to print out a junction */
1042 void
1043 #ifdef __USE_PROTOS
1044 pJunc( Junction *q )
1045 #else
1046 pJunc( q )
1047 Junction *q;
1048 #endif
1049 {
1050 int dum_k;
1051 int doing_rule;
1052 require(q!=NULL, "pJunc: NULL node");
1053 require(q->ntype==nJunction, "pJunc: not junction");
1054
1055 if ( q->pvisited == TRUE ) return;
1056 q->pvisited = TRUE;
1057 switch ( q->jtype )
1058 {
1059 case aSubBlk :
1060 if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);
1061 if ( q->end->p1 != NULL && ((Junction *)q->end->p1)->ntype==nJunction &&
1062 ((Junction *)q->end->p1)->jtype == EndRule ) doing_rule = 1;
1063 else doing_rule = 0;
1064 pLevel++;
1065 if ( pLevel==1 )
1066 {
1067 if ( pAlt1==1 ) printf("=>");
1068 printf("\t");
1069 }
1070 else printf(" ");
1071 if ( doing_rule )
1072 {
1073 if ( pLevel==1 ) printf(" ");
1074 pBlk(q,q->jtype);
1075 }
1076 else {
1077 printf("(");
1078 if ( pLevel==1 ) printf(" ");
1079 pBlk(q,q->jtype);
1080 if ( pLevel>1 ) printf(" ");
1081 printf(")");
1082 }
1083 if ( q->guess ) printf("?");
1084 pLevel--;
1085 if ( PrintAnnotate ) freeBlkFsets(q);
1086 if ( q->end->p1 != NULL ) PRINT(q->end->p1);
1087 break;
1088 case aOptBlk :
1089 if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);
1090 pLevel++;
1091 if ( pLevel==1 )
1092 {
1093 if ( pAlt1==1 ) printf("=>");
1094 printf("\t");
1095 }
1096 else printf(" ");
1097 printf("{");
1098 if ( pLevel==1 ) printf(" ");
1099 pBlk(q,q->jtype);
1100 if ( pLevel>1 ) printf(" ");
1101 else printf("\n\t");
1102 printf("}");
1103 pLevel--;
1104 if ( PrintAnnotate ) freeBlkFsets(q);
1105 if ( q->end->p1 != NULL ) PRINT(q->end->p1);
1106 break;
1107 case aLoopBegin :
1108 if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);
1109 pLevel++;
1110 if ( pLevel==1 )
1111 {
1112 if ( pAlt1==1 ) printf("=>");
1113 printf("\t");
1114 }
1115 else printf(" ");
1116 printf("(");
1117 if ( pLevel==1 ) printf(" ");
1118 pBlk(q,q->jtype);
1119 if ( pLevel>1 ) printf(" ");
1120 else printf("\n\t");
1121 printf(")*");
1122 pLevel--;
1123 if ( PrintAnnotate ) freeBlkFsets(q);
1124 if ( q->end->p1 != NULL ) PRINT(q->end->p1);
1125 break;
1126 case aLoopBlk :
1127 if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);
1128 pBlk(q,q->jtype);
1129 if ( PrintAnnotate ) freeBlkFsets(q);
1130 break;
1131 case aPlusBlk :
1132 if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);
1133 pLevel++;
1134 if ( pLevel==1 )
1135 {
1136 if ( pAlt1==1 ) printf("=>");
1137 printf("\t");
1138 }
1139 else printf(" ");
1140 printf("(");
1141 if ( pLevel==1 ) printf(" ");
1142 pBlk(q,q->jtype);
1143 if ( pLevel>1 ) printf(" ");
1144 printf(")+");
1145 pLevel--;
1146 if ( PrintAnnotate ) freeBlkFsets(q);
1147 if ( q->end->p1 != NULL ) PRINT(q->end->p1);
1148 break;
1149 case EndBlk :
1150 break;
1151 case RuleBlk :
1152 printf( "\n%s :\n", q->rname);
1153 PRINT(q->p1);
1154 if ( q->p2 != NULL ) PRINT(q->p2);
1155 break;
1156 case Generic :
1157 if ( q->p1 != NULL ) PRINT(q->p1);
1158 q->pvisited = FALSE;
1159 if ( q->p2 != NULL ) PRINT(q->p2);
1160 break;
1161 case EndRule :
1162 printf( "\n\t;\n");
1163 break;
1164 }
1165 q->pvisited = FALSE;
1166 }
1167
1168 /* How to print out a rule reference node */
1169 void
1170 #ifdef __USE_PROTOS
1171 pRuleRef( RuleRefNode *p )
1172 #else
1173 pRuleRef( p )
1174 RuleRefNode *p;
1175 #endif
1176 {
1177 require(p!=NULL, "pRuleRef: NULL node");
1178 require(p->ntype==nRuleRef, "pRuleRef: not rule ref node");
1179
1180 printf( " %s", p->text);
1181 PRINT(p->next);
1182 }
1183
1184 /* How to print out a terminal node */
1185 void
1186 #ifdef __USE_PROTOS
1187 pToken( TokNode *p )
1188 #else
1189 pToken( p )
1190 TokNode *p;
1191 #endif
1192 {
1193 require(p!=NULL, "pToken: NULL node");
1194 require(p->ntype==nToken, "pToken: not token node");
1195
1196 if ( p->wild_card ) printf(" .");
1197 printf( " %s", TerminalString(p->token));
1198 PRINT(p->next);
1199 }
1200
1201 /* How to print out a terminal node */
1202 void
1203 #ifdef __USE_PROTOS
1204 pAction( ActionNode *p )
1205 #else
1206 pAction( p )
1207 ActionNode *p;
1208 #endif
1209 {
1210 require(p!=NULL, "pAction: NULL node");
1211 require(p->ntype==nAction, "pAction: not action node");
1212
1213 PRINT(p->next);
1214 }
1215
1216 /* F i l l F o l l o w L i s t s */
1217
1218 /*
1219 * Search all rules for all rule reference nodes, q to rule, r.
1220 * Add q->next to follow list dangling off of rule r.
1221 * i.e.
1222 *
1223 * r: -o-R-o-->o--> Ptr to node following rule r in another rule
1224 * |
1225 * o--> Ptr to node following another reference to r.
1226 *
1227 * This is the data structure employed to avoid FOLLOW set computation. We
1228 * simply compute the FIRST (reach) of the EndRule Node which follows the
1229 * list found at the end of all rules which are referenced elsewhere. Rules
1230 * not invoked by other rules have no follow list (r->end->p1==NULL).
1231 * Generally, only start symbols are not invoked by another rule.
1232 *
1233 * Note that this mechanism also gives a free cross-reference mechanism.
1234 *
1235 * The entire syntax diagram is layed out like this:
1236 *
1237 * SynDiag
1238 * |
1239 * v
1240 * o-->R1--o
1241 * |
1242 * o-->R2--o
1243 * |
1244 * ...
1245 * |
1246 * o-->Rn--o
1247 *
1248 */
1249 void
1250 #ifdef __USE_PROTOS
1251 FoLink( Node *p )
1252 #else
1253 FoLink( p )
1254 Node *p;
1255 #endif
1256 {
1257 RuleEntry *q;
1258 Junction *j = (Junction *) p;
1259 RuleRefNode *r = (RuleRefNode *) p;
1260
1261 if ( p==NULL ) return;
1262 require(p->ntype>=1 && p->ntype<=NumNodeTypes,
1263 eMsgd("FoLink: invalid diagram node: ntype==%d",p->ntype));
1264 switch ( p->ntype )
1265 {
1266 case nJunction :
1267 if ( j->fvisited ) return;
1268 if ( j->jtype == EndRule ) return;
1269 j->fvisited = TRUE;
1270 FoLink( j->p1 );
1271 FoLink( j->p2 );
1272 /* MR14 */
1273 /* MR14 */ /* Need to determine whether the guess block is an */
1274 /* MR14 */ /* of the form (alpha)? beta before follow sets are */
1275 /* MR14 */ /* computed. This is necessary to solve problem */
1276 /* MR14 */ /* of doing follow on the alpha of an (alpha)? beta block. */
1277 /* MR14 */
1278 /* MR14 */ /* This is performed by analysis_point as a side-effect. */
1279 /* MR14 */
1280 /* MR14 */
1281 /* MR14 */ if (j->jtype == aSubBlk && j->guess) {
1282 /* MR14 */ Junction *ignore;
1283 /* MR14 */ ignore=analysis_point(j);
1284 /* MR14 */ }
1285 /* MR14 */
1286 return;
1287 case nRuleRef :
1288 if ( r->linked ) return;
1289 q = (RuleEntry *) hash_get(Rname, r->text);
1290 if ( q == NULL )
1291 {
1292 warnFL( eMsg1("rule %s not defined",r->text), FileStr[r->file], r->line );
1293 }
1294 else
1295 {
1296 if ( r->parms!=NULL && RulePtr[q->rulenum]->pdecl==NULL )
1297 {
1298 warnFL( eMsg1("rule %s accepts no parameter(s)", r->text),
1299 FileStr[r->file], r->line );
1300 }
1301 if ( r->parms==NULL && RulePtr[q->rulenum]->pdecl!=NULL )
1302 {
1303 warnFL( eMsg1("rule %s requires parameter(s)", r->text),
1304 FileStr[r->file], r->line );
1305 }
1306 if ( r->assign!=NULL && RulePtr[q->rulenum]->ret==NULL )
1307 {
1308 warnFL( eMsg1("rule %s yields no return value(s)", r->text),
1309 FileStr[r->file], r->line );
1310 }
1311 if ( r->assign==NULL && RulePtr[q->rulenum]->ret!=NULL )
1312 {
1313 warnFL( eMsg1("rule %s returns a value(s)", r->text),
1314 FileStr[r->file], r->line );
1315 }
1316 if ( !r->linked )
1317 {
1318 addFoLink( r->next, r->rname, RulePtr[q->rulenum] );
1319 r->linked = TRUE;
1320 }
1321 }
1322 FoLink( r->next );
1323 return;
1324 case nToken :
1325 FoLink( ((TokNode *)p)->next );
1326 return;
1327 case nAction :
1328 FoLink( ((ActionNode *)p)->next );
1329 return;
1330 default :
1331 fatal_internal("invalid node type");
1332 }
1333 }
1334
1335 /*
1336 * Add a reference to the end of a rule.
1337 *
1338 * 'r' points to the RuleBlk node in a rule. r->end points to the last node
1339 * (EndRule jtype) in a rule.
1340 *
1341 * Initial:
1342 * r->end --> o
1343 *
1344 * After:
1345 * r->end --> o-->o--> Ptr to node following rule r in another rule
1346 * |
1347 * o--> Ptr to node following another reference to r.
1348 *
1349 * Note that the links are added to the head of the list so that r->end->p1
1350 * always points to the most recently added follow-link. At the end, it should
1351 * point to the last reference found in the grammar (starting from the 1st rule).
1352 */
1353 void
1354 #ifdef __USE_PROTOS
1355 addFoLink( Node *p, char *rname, Junction *r )
1356 #else
1357 addFoLink( p, rname, r )
1358 Node *p;
1359 char *rname;
1360 Junction *r;
1361 #endif
1362 {
1363 Junction *j;
1364 require(r!=NULL, "addFoLink: incorrect rule graph");
1365 require(r->end!=NULL, "addFoLink: incorrect rule graph");
1366 require(r->end->jtype==EndRule, "addFoLink: incorrect rule graph");
1367 require(p!=NULL, "addFoLink: NULL FOLLOW link");
1368
1369 j = newJunction();
1370 j->rname = rname; /* rname on follow links point to target rule */
1371 j->p1 = p; /* link to other rule */
1372 j->p2 = (Node *) r->end->p1;/* point to head of list */
1373 r->end->p1 = (Node *) j; /* reset head to point to new node */
1374 }
1375
1376 void
1377 #ifdef __USE_PROTOS
1378 GenCrossRef( Junction *p )
1379 #else
1380 GenCrossRef( p )
1381 Junction *p;
1382 #endif
1383 {
1384 set a;
1385 Junction *j;
1386 RuleEntry *q;
1387 unsigned e;
1388 require(p!=NULL, "GenCrossRef: why are you passing me a null grammar?");
1389
1390 printf("Cross Reference:\n\n");
1391 a = empty;
1392 for (; p!=NULL; p = (Junction *)p->p2)
1393 {
1394 printf("Rule %20s referenced by {", p->rname);
1395 /* make a set of rules for uniqueness */
1396 for (j = (Junction *)(p->end)->p1; j!=NULL; j = (Junction *)j->p2)
1397 {
1398 q = (RuleEntry *) hash_get(Rname, j->rname);
1399 require(q!=NULL, "GenCrossRef: FoLinks are screwed up");
1400 set_orel(q->rulenum, &a);
1401 }
1402 for (; !set_nil(a); set_rm(e, a))
1403 {
1404 e = set_int(a);
1405 printf(" %s", RulePtr[e]->rname);
1406 }
1407 printf(" }\n");
1408 }
1409 set_free( a );
1410 }
1411
1412 /*
1413 The single argument is a pointer to the start of an element of a
1414 C++ style function prototypet list. Given a pointer to the start of
1415 an formal we must locate the comma (or the end of the string)
1416 and locate the datatype, formal name, and initial value expression.
1417
1418 The function returns a pointer to the character following the comma
1419 which terminates the formal declaration, or a pointer to the end of
1420 the string if none was found.
1421
1422 I thought we were parsing specialists, how come I'm doing this by
1423 hand written code ?
1424
1425 Examples of input:
1426
1427 Foo f,
1428 Foo f = Foo(1),
1429 Foo f = Foo(1,2),
1430 Foo f = &farray[1,2],
1431 Foo f = ",",
1432 Foo f = ',',
1433 TFoo<int,char> f = TFoo<int,char>(1,2),
1434
1435 A non-zero value for nesting indicates a problem matching '(' and ')',
1436 '[' and ']', '<' and '>', '{' and '}', or improperly terminated string
1437 or character literal.
1438
1439 */
1440
1441
1442 /*
1443 * Don't care if it is a valid string literal or not, just find the end
1444 * Start with pointer to leading "\""
1445 */
1446
1447 #ifdef __USE_PROTOS
1448 char * skipStringLiteral(char *pCurrent)
1449 #else
1450 char * skipStringLiteral(pCurrent)
1451 char *pCurrent;
1452 #endif
1453 {
1454 char *p = pCurrent;
1455 if (*p == 0) return p;
1456 require (*p == '\"', "skipStringLiteral")
1457 p++;
1458 for (p = p; *p != 0; p++) {
1459 if (*p == '\\') {
1460 p++;
1461 if (*p == 0) break;
1462 p++;
1463 }
1464 if (*p == '\"') {
1465 p++;
1466 break;
1467 }
1468 }
1469 return p;
1470 }
1471
1472 /*
1473 * Don't care if it is a valid character literal or not, just find the end
1474 * Start with pointer to leading "'"
1475 */
1476
1477 #ifdef __USE_PROTOS
1478 char * skipCharLiteral(char *pStart)
1479 #else
1480 char * skipCharLiteral(pStart)
1481 char *pStart;
1482 #endif
1483 {
1484 char *p = pStart;
1485 if (*p == 0) return p;
1486 require (*p == '\'', "skipCharLiteral")
1487 p++;
1488 for (p = p; *p != 0; p++) {
1489 if (*p == '\\') {
1490 p++;
1491 if (*p == 0) break;
1492 p++;
1493 }
1494 if (*p == '\'') {
1495 p++;
1496 break;
1497 }
1498 }
1499 return p;
1500 }
1501
1502 #ifdef __USE_PROTOS
1503 char * skipSpaces(char *pStart)
1504 #else
1505 char * skipSpaces(pStart)
1506 char * pStart;
1507 #endif
1508 {
1509 char *p = pStart;
1510 while (*p != 0 && isspace(*p)) p++;
1511 return p;
1512 }
1513
1514 #ifdef __USE_PROTOS
1515 char * skipToSeparatorOrEqualSign(char *pStart, int *pNest)
1516 #else
1517 char * skipToSeparatorOrEqualSign(pStart, pNest)
1518 char *pStart;
1519 int *pNest;
1520 #endif
1521 {
1522 char *p = pStart;
1523
1524 int nest = 0;
1525
1526 *pNest = (-1);
1527
1528 while (*p != 0) {
1529 switch (*p) {
1530
1531 case '(' :
1532 case '[' :
1533 case '<' :
1534 case '{' :
1535 nest++;
1536 p++;
1537 break;
1538
1539 case ')' :
1540 case ']' :
1541 case '>' :
1542 case '}' :
1543 nest--;
1544 p++;
1545 break;
1546
1547 case '"' :
1548 p = skipStringLiteral(p);
1549 break;
1550
1551 case '\'' :
1552 p = skipCharLiteral(p);
1553 break;
1554
1555 case '\\':
1556 p++;
1557 if (*p == 0) goto EXIT;
1558 p++;
1559 break;
1560
1561 case ',':
1562 case '=':
1563 if (nest == 0) goto EXIT;
1564 p++;
1565 break;
1566
1567 default:
1568 p++;
1569 }
1570 }
1571 EXIT:
1572 *pNest = nest;
1573 return p;
1574 }
1575
1576 #ifdef __USE_PROTOS
1577 char * skipToSeparator(char *pStart, int *pNest)
1578 #else
1579 char * skipToSeparator(pStart, pNest)
1580 char *pStart;
1581 int *pNest;
1582 #endif
1583 {
1584 char * p = pStart;
1585 for ( ; ; ) {
1586 p = skipToSeparatorOrEqualSign(p, pNest);
1587 if (*pNest != 0) return p;
1588 if (*p == ',') return p;
1589 if (*p == 0) return p;
1590 p++;
1591 }
1592 }
1593
1594 /* skip to just past the "=" separating the declaration from the initialization value */
1595
1596 #ifdef __USE_PROTOS
1597 char * getInitializer(char *pStart)
1598 #else
1599 char * getInitializer(pStart)
1600 char * pStart;
1601 #endif
1602 {
1603 char *p;
1604 char *pDataType;
1605 char *pSymbol;
1606 char *pEqualSign;
1607 char *pValue;
1608 char *pSeparator;
1609 int nest = 0;
1610
1611 require(pStart!=NULL, "getInitializer: invalid string");
1612
1613 p = endFormal(pStart,
1614 &pDataType,
1615 &pSymbol,
1616 &pEqualSign,
1617 &pValue,
1618 &pSeparator,
1619 &nest);
1620 if (nest != 0) return NULL;
1621 if (pEqualSign == NULL) return NULL;
1622 if (pValue == NULL) return NULL;
1623 return strBetween(pValue, NULL, pSeparator);
1624 }
1625
1626 /*
1627 Examines the string from pStart to pEnd-1.
1628 If the string has 0 length or is entirely white space
1629 returns 1. Otherwise 0.
1630 */
1631
1632 #ifdef __USE_PROTOS
1633 int isWhiteString(const char *pStart, const char *pEnd)
1634 #else
1635 int isWhiteString(pStart, pEnd)
1636 const char *pStart;
1637 const char *pEnd;
1638 #endif
1639 {
1640 const char *p;
1641 for (p = pStart; p < pEnd; p++) {
1642 if (! isspace(*p)) return 0;
1643 }
1644 return 1;
1645 }
1646
1647 /*
1648 This replaces HasComma() which couldn't distinguish
1649
1650 foo ["a,b"]
1651
1652 from:
1653
1654 foo[a,b]
1655
1656 */
1657
1658 #ifdef __USE_PROTOS
1659 int hasMultipleOperands(char *pStart)
1660 #else
1661 int hasMultipleOperands(pStart)
1662 char *pStart;
1663 #endif
1664 {
1665 char *p = pStart;
1666 int nest = 0;
1667
1668 p = skipSpaces(p);
1669 if (*p == 0) return 0;
1670 p = skipToSeparator(p, &nest);
1671 if (nest == 0 && *p == ',') return 1;
1672 return 0;
1673 }
1674
1675
1676 #define MAX_STR_BETWEEN_WORK_AREA 1000
1677
1678 static char strBetweenWorkArea[MAX_STR_BETWEEN_WORK_AREA];
1679
1680
1681 /*
1682 strBetween(pStart, pNext, pStop)
1683
1684 Creates a null terminated string by copying the text between two pointers
1685 to a work area. The start of the string is pStart. The end of the string
1686 is the character before pNext, or if pNext is null then the character before
1687 pStop. Trailing spaces are not included in the copy operation.
1688
1689 This is used when a string contains several parts. The pNext part may be
1690 optional. The pStop will stop the scan when the optional part is not present
1691 (is a null pointer).
1692 */
1693
1694 #ifdef __USE_PROTOS
1695 char *strBetween(char *pStart, char *pNext, char *pStop)
1696 #else
1697 char *strBetween(pStart, pNext, pStop)
1698 char *pStart;
1699 char *pNext;
1700 char *pStop;
1701 #endif
1702 {
1703 char *p;
1704 char *q = strBetweenWorkArea;
1705 const char *pEnd;
1706
1707 pEnd = (pNext != NULL) ? pNext : pStop;
1708
1709 require (pEnd != NULL, "pEnd == NULL");
1710 require (pEnd >= pStart, "pEnd < pStart");
1711 for (pEnd--; pEnd >= pStart; pEnd--) { /* MR31 */
1712 if (! isspace(*pEnd)) break;
1713 }
1714 for (p = pStart;
1715 p <= pEnd && q < &strBetweenWorkArea[MAX_STR_BETWEEN_WORK_AREA-2];
1716 p++, q++) {
1717 *q = *p;
1718 }
1719 *q = 0;
1720 return strBetweenWorkArea;
1721 }
1722
1723 /*
1724 function Returns pointer to character following separator at
1725 value which to continue search for next formal. If at the
1726 end of the string a pointer to the null byte at the
1727 end of the string is returned.
1728
1729 pStart Pointer to the starting position of the formal list
1730
1731 This may be the middle of a longer string, for example
1732 when looking for the end of formal #3 starting from
1733 the middle of the complete formal list.
1734
1735 ppDataType Returns a pointer to the start of the data type in the
1736 formal. Example: pointer to "Foo".
1737
1738 ppSymbol Returns a pointer to the start of the formal symbol.
1739 Example: pointer to "f".
1740
1741 ppEqualSign Returns a pointer to the equal sign separating the
1742 formal symbol from the initial value. If there is
1743 no "=" then this will be NULL.
1744
1745 ppValue Returns a pointer to the initial value part of the
1746 formal declaration. Example: pointer to "&farray[1,2]"
1747
1748 ppSeparator Returns a pointer to the character which terminated the
1749 scan. This should be a pointer to a comma or a null
1750 byte which terminates the string.
1751
1752 pNest Returns the nesting level when a separator was found.
1753 This is non-zero for any kind of error. This is zero
1754 for a successful parse of this portion of the formal
1755 list.
1756
1757 */
1758
1759 #ifdef __USE_PROTOS
1760 char * endFormal(char *pStart,
1761 char **ppDataType,
1762 char **ppSymbol,
1763 char **ppEqualSign,
1764 char **ppValue,
1765 char **ppSeparator,
1766 int *pNest)
1767 #else
1768 char * endFormal(pStart,
1769 ppDataType,
1770 ppSymbol,
1771 ppEqualSign,
1772 ppValue,
1773 ppSeparator,
1774 pNest)
1775 char *pStart;
1776 char **ppDataType;
1777 char **ppSymbol;
1778 char **ppEqualSign;
1779 char **ppValue;
1780 char **ppSeparator;
1781 int *pNest;
1782
1783 #endif
1784 {
1785 char *p = pStart;
1786 char *q;
1787
1788 *ppDataType = NULL;
1789 *ppSymbol = NULL;
1790 *ppEqualSign = NULL;
1791 *ppValue = NULL;
1792 *ppSeparator = NULL;
1793
1794 *pNest = 0;
1795
1796 /* The first non-blank is the start of the datatype */
1797
1798 p = skipSpaces(p);
1799 if (*p == 0) goto EXIT;
1800 *ppDataType = p;
1801
1802 /* We are not looking for the symbol, we are looking
1803 for the separator that follows the symbol. Then
1804 we'll back up.
1805
1806 Search for the ',' or '=" or null terminator.
1807 */
1808
1809 p = skipToSeparatorOrEqualSign(p, pNest);
1810
1811 if (*pNest != 0) goto EXIT;
1812
1813 /*
1814 Work backwards to find start of symbol
1815 Skip spaces between the end of symbol and separator
1816 Assume that there are no spaces in the formal, but
1817 there is a space preceding the formal
1818 */
1819
1820 for (q = &p[-1]; q >= *ppDataType; q--) {
1821 if (! isspace(*q)) break;
1822 }
1823 if (q < *ppDataType) goto EXIT;
1824
1825 /*
1826 MR26 Handle things like: IIR_Bool (IIR_Decl::*constraint)()
1827 Backup until we hit the end of a symbol string, then find the
1828 start of the symbol string. This wont' work for functions
1829 with prototypes, but works for the most common cases. For
1830 others, use typedef names.
1831 */
1832
1833 /* MR26 */ for (q = q; q >= *ppDataType; q--) {
1834 /* MR26 */ if (isalpha(*q) || isdigit(*q) || *q == '_' || *q == '$') break;
1835 /* MR26 */ }
1836 /* MR26 */ if (q < *ppDataType) goto EXIT;
1837
1838 for (q = q; q >= *ppDataType; q--) {
1839 if ( ! (isalpha(*q) || isdigit(*q) || *q == '_' || *q == '$')) break;
1840 }
1841
1842 *ppSymbol = &q[1];
1843
1844 if (*p == ',' || *p == 0) {
1845 *ppSeparator = p;
1846 goto EXIT;
1847 }
1848
1849 *ppEqualSign = p;
1850 p = skipSpaces(++p);
1851 *ppValue = p;
1852 if (*p == 0) goto EXIT;
1853
1854
1855 while (*p != 0 && *pNest == 0 && *p != ',') {
1856 p = skipToSeparator(p, pNest);
1857 }
1858 if (*pNest == 0) *ppSeparator = p;
1859
1860 EXIT:
1861 if (*p == ',') p++;
1862 return p;
1863 }
+0
-12
contrib/pccts/antlr/mode.h less more
0 #define START 0
1 #define STRINGS 1
2 #define ACTION_STRINGS 2
3 #define ACTION_CHARS 3
4 #define ACTION_COMMENTS 4
5 #define TOK_DEF_COMMENTS 5
6 #define TOK_DEF_CPP_COMMENTS 6
7 #define ACTION_CPP_COMMENTS 7
8 #define CPP_COMMENTS 8
9 #define COMMENTS 9
10 #define ACTIONS 10
11 #define PARSE_ENUM_FILE 11
+0
-3030
contrib/pccts/antlr/mrhoist.c less more
0 /*
1 * mrhoist.c
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33MR10
24 *
25 */
26
27 #include <stdio.h>
28
29 #include "pcctscfg.h"
30
31 #include "set.h"
32 #include "syn.h"
33 #include "hash.h"
34 #include "generic.h"
35 #include "dlgdef.h"
36 #include <ctype.h>
37
38 #ifdef __USE_PROTOS
39 void dumppred(Predicate *);
40 #else
41 void dumppred();
42 #endif
43
44 /*
45 Try to determine whether predicate "first" is true for
46 all cases where "second" is true. Comparison takes place
47 without regard to context.
48 Assumes that predicate symbols have been expanded.
49 Assumes that there are no NAND or NOR nodes
50
51 */
52
53 #ifdef __USE_PROTOS
54 int MR_secondPredicateUnreachable(Predicate *first,Predicate *second)
55 #else
56 int MR_secondPredicateUnreachable(first,second)
57 Predicate *first;
58 Predicate *second;
59 #endif
60 {
61 Predicate *f;
62 Predicate *s;
63
64 if (first == NULL) {
65 return 1;
66 } else if (second == NULL) {
67 return 0;
68 } else if (first->down == NULL && second->down == NULL) {
69 if (first->source == second->source &&
70 first->inverted == second->inverted) {
71 return 1; /* look identical - will never reach alt2 */
72 } else {
73 return 0; /* look different */
74 };
75 } else if (first->down == NULL && second->down != NULL) {
76
77 if (second->expr == PRED_AND_LIST) {
78
79 /* unreachable if first covers any child of second */
80
81 for (s=second->down; s != NULL; s=s->right) {
82 if (MR_secondPredicateUnreachable(first,s)) {
83 return 1;
84 };
85 };
86 return 0;
87 } else if (second->expr == PRED_OR_LIST) {
88
89 /* unreachable if first covers every child of second */
90
91 for (s=second->down; s != NULL; s=s->right) {
92 if (!MR_secondPredicateUnreachable(first,s)) {
93 return 0;
94 };
95 };
96 return 1;
97 } else {
98 require (0,"Illegal pred->expr");
99 return 0; /* MR20 Make compiler happy */
100 };
101 } else if (first->down != NULL && second->down == NULL) {
102 if (first->expr == PRED_AND_LIST) {
103
104 /* unreachable if every child of first covers second */
105
106 for (f=first->down; f != NULL; f=f->right) {
107 if (!MR_secondPredicateUnreachable(f,second)) {
108 return 0;
109 };
110 };
111 return 1;
112 } else if (first->expr == PRED_OR_LIST) {
113
114 /* unreachable if any child of first covers second */
115
116 for (f=first->down; f != NULL; f=f->right) {
117 if (MR_secondPredicateUnreachable(f,second)) {
118 return 1;
119 };
120 };
121 return 0;
122 } else {
123 require (0,"Illegal predicate->expr");
124 return 0; /* MR20 Make compiler happy */
125 };
126 } else {
127
128 if (first->expr == PRED_AND_LIST && second->expr == PRED_AND_LIST) {
129
130 /* unreachable if each child of first covers at least one child of second */
131
132 for (f=first->down; f != NULL ; f=f->right) {
133 for (s=second->down; s != NULL ; s=s->right) {
134 if (MR_secondPredicateUnreachable(f,s)) goto A_next_f;
135 };
136 return 0;
137 A_next_f:
138 continue;
139 };
140 return 1;
141
142 } else if (first->expr == PRED_AND_LIST && second->expr == PRED_OR_LIST) {
143
144 /* unreachable if each child of first covers ALL of second's children */
145
146 for (f=first->down; f != NULL ; f=f->right) {
147 for (s=second->down; s != NULL ; s=s->right) {
148 if (!MR_secondPredicateUnreachable(f,s)) return 0;
149 };
150 };
151 return 1;
152
153 } else if (first->expr == PRED_OR_LIST && second->expr == PRED_AND_LIST) {
154
155 /* unreachable if any child of second is covered by any child of first */
156
157 for (f=first->down; f != NULL ; f=f->right) {
158 for (s=second->down; s != NULL ; s=s->right) {
159 if (MR_secondPredicateUnreachable(f,s)) return 1;
160 };
161 };
162 return 0;
163
164 } else if (first->expr == PRED_OR_LIST && second->expr == PRED_OR_LIST) {
165
166 /* unreachable if every child of second is covered by some child of first */
167
168 for (f=first->down; f != NULL ; f=f->right) {
169 for (s=second->down; s != NULL ; s=s->right) {
170 if (MR_secondPredicateUnreachable(f,s)) goto B_next_f;
171 };
172 return 0;
173 B_next_f:
174 continue;
175 };
176 return 1;
177
178 } else {
179 require (0,"Illegal predicate->expr");
180 return 0; /* MR20 Make compiler happy */
181 };
182 };
183 return 0; /* MR20 MSVC 5.0 complains about missing return statement */
184 }
185
186 #ifdef __USE_PROTOS
187 void MR_xxxIndent(FILE *f,int depth)
188 #else
189 void MR_xxxIndent(f,depth)
190 FILE *f;
191 int depth;
192 #endif
193 {
194 int i;
195
196 for (i=0; i<depth ; i++) {
197 fprintf(f," ");
198 };
199 }
200
201 #ifdef __USE_PROTOS
202 void MR_stderrIndent(int depth)
203 #else
204 void MR_stderrIndent(depth)
205 int depth;
206 #endif
207 {
208 MR_xxxIndent(stderr,depth);
209 }
210
211 #ifdef __USE_PROTOS
212 void MR_outputIndent(int depth)
213 #else
214 void MR_outputIndent(depth)
215 int depth;
216 #endif
217 {
218 MR_xxxIndent(output,depth);
219 }
220
221 #ifdef __USE_PROTOS
222 void MR_set_reuse(set *s)
223 #else
224 void MR_set_reuse(s)
225 set *s;
226 #endif
227 {
228 set_free(*s);
229 *s=empty;
230 }
231
232 #ifdef __USE_PROTOS
233 void MR_dumpPredRuleRefStack(FILE *iounit,int indent)
234 #else
235 void MR_dumpPredRuleRefStack(iounit,indent)
236 FILE *iounit;
237 int indent;
238 #endif
239 {
240 int i;
241 int j;
242 int count=MR_PredRuleRefStack.count;
243 RuleRefNode *rrn=NULL;
244 Junction *lastOne;
245
246 if (count == 0) {
247 fprintf(iounit,"empty\n");
248 return;
249 };
250 for (i=0; i < count; i++) {
251 rrn=(RuleRefNode *) MR_PredRuleRefStack.data[i];
252 for (j=0; j<indent; j++) fprintf(iounit," ");
253 fprintf(iounit,"#%-2d in rule %s (line %d %s) to rule %s\n",
254 i,rrn->rname,rrn->line,FileStr[rrn->file],rrn->text);
255 };
256 lastOne=MR_ruleReferenced(rrn);
257 if (lastOne != NULL) {
258 for (j=0; j<indent; j++) fprintf(iounit," ");
259 fprintf(iounit,"#%-2d in rule %s (line %d %s)\n",
260 count,lastOne->rname,lastOne->line,FileStr[lastOne->file]);
261 };
262 }
263
264 #ifdef __USE_PROTOS
265 void MR_dumpTreeF(FILE *f,int depth,Tree *tree,int across)
266 #else
267 void MR_dumpTreeF(f,depth,tree,across)
268 FILE *f;
269 Tree *tree;
270 int depth;
271 int across;
272 #endif
273 {
274 int newAcross=across;
275
276 if (tree == NULL ) return;
277 if (tree->down != NULL ) {
278 fprintf(output,"\n");
279 MR_outputIndent(depth);
280 fprintf(output, "(root =");
281 };
282 if (tree->token == ALT ) {
283 fprintf(output," %-16s","Alt");
284 } else if (tree->token==EpToken ) {
285 fprintf(output,"(%d)%13s",tree->v.rk," ");
286 } else {
287 fprintf(output," %-16s",TerminalString(tree->token));
288 };
289 if (tree->down != NULL) {
290 fprintf(output,"\n");
291 MR_outputIndent(depth+1);
292 MR_dumpTreeF(f,depth+1,tree->down,1);
293 newAcross=0;
294 fprintf(output,"\n");
295 MR_outputIndent(depth);
296 fprintf(output,")");
297 };
298 if (newAcross > 3) {
299 fprintf(output,"\n");
300 MR_outputIndent(depth);
301 newAcross=0;
302 };
303 MR_dumpTreeF(f,depth,tree->right,newAcross+1);
304 }
305
306 #ifdef __USE_PROTOS
307 void MR_dumpTreeX(int depth,Tree *tree,int across)
308 #else
309 void MR_dumpTreeX(depth,tree,across)
310 Tree *tree;
311 int depth;
312 int across;
313 #endif
314 {
315 MR_dumpTreeF(output,depth,tree,across);
316 }
317
318 #ifdef __USE_PROTOS
319 void MR_dumpTokenSet(FILE *f,int depth,set s)
320 #else
321 void MR_dumpTokenSet(f,depth,s)
322 FILE *f;
323 int depth;
324 set s;
325 #endif
326 {
327 int i;
328 int j;
329
330 unsigned *pdq;
331
332 if (set_nil(s)) {
333 fprintf(f,"\n");
334 MR_xxxIndent(f,depth+1);
335 fprintf(f,"nil\n");
336 return;
337 };
338
339 pdq=set_pdq(s);
340 require(pdq != NULL,"set_pdq failed");
341 i=0;
342 for (i=0 ; ; i=i+4) {
343 fprintf(f,"\n");
344 MR_xxxIndent(f,depth+1);
345 for (j=0; j < 4 ; j++) {
346 if (pdq[i+j] == nil) break;
347 fprintf(f," %-16s",TerminalString(pdq[i+j]));
348 };
349 if (pdq[i+j] == nil) break;
350 };
351 fprintf(f,"\n");
352 free( (char *) pdq);
353 }
354
355 #ifdef __USE_PROTOS
356 void MR_dumpPred1(int depth,Predicate *p,int withContext)
357 #else
358 void MR_dumpPred1(depth,p,withContext)
359 int depth;
360 Predicate *p;
361 int withContext;
362 #endif
363 {
364 unsigned k;
365
366 if (p == NULL) {
367 MR_outputIndent(depth);
368 fprintf(output,"The predicate is empty (or always true)\n\n");
369 return;
370 };
371 if (p->down != NULL) {
372 MR_outputIndent(depth);
373 if (p->inverted) {
374
375 /* MR14a Left out print expression in fprintf
376 Reported by Manuel Kessler (mlkessle@cip.physik.uni-wuerzburg.de)
377 */
378
379 if (p->expr == PRED_AND_LIST) fprintf(output,"%s NAND (not AND) expr\n\n",p->expr);
380 if (p->expr == PRED_OR_LIST) fprintf(output,"%s NOR (not OR) expr\n\n",p->expr);
381 } else {
382 fprintf(output,"%s expr\n\n",p->expr);
383 };
384 } else {
385 MR_outputIndent(depth);
386 fprintf(output,"pred %s <<%s>>?\n",
387 (p->inverted ? " *not*" : ""),
388 (p->expr == NULL ? "null expr" : p->expr));
389 MR_outputIndent(depth+1);
390 fprintf(output," ");
391 fprintf(output," depth=k=%d",p->k);
392 if (p->source != NULL && p->source->guardpred) {
393 fprintf(output," (\"=>\" guard)");
394 }
395 if (p->source != NULL && p->source->ampersandPred != NULL) {
396 fprintf(output," (\"&&\" guard)");
397 };
398 k=set_int(p->completionSet);
399 if (k != nil) {
400 fprintf(output," Incomplete Set at k=%d !",k);
401 };
402 k=set_int(p->completionTree);
403 if (k != nil) {
404 fprintf(output," Incomplete Tree at k=%d !",k);
405 };
406 if (p->source != NULL) {
407 fprintf(output," rule %s line %d %s",
408 p->source->rname,p->source->line,FileStr[p->source->file]);
409 };
410 fprintf(output,"\n");
411 if (withContext &&
412 (HoistPredicateContext ||
413 ! set_nil(p->scontext[1]) ||
414 p->tcontext != NULL)) {
415 if (p->k == 1) {
416 MR_outputIndent(depth+1);
417 fprintf(output,"set context: ");
418 MR_dumpTokenSet(output,depth+1,p->scontext[1]);
419 }
420 if (p->k != 1) {
421 MR_outputIndent(depth+1);
422 fprintf(output,"tree context:");
423 if (p->tcontext == NULL) {
424 fprintf(output," null");
425 } else {
426 MR_dumpTreeX(depth+2,p->tcontext,0);
427 };
428 fprintf(output,"\n");
429 };
430 };
431 fprintf(output,"\n");
432 };
433 if (p->down != NULL) {
434 MR_dumpPred1(depth+1,p->down,withContext);
435 };
436 if (p->right != NULL) {
437 MR_dumpPred1(depth,p->right,withContext);
438 };
439 }
440
441 #ifdef __USE_PROTOS
442 void MR_dumpPred(Predicate *p,int withContext)
443 #else
444 void MR_dumpPred(p,withContext)
445 Predicate *p;
446 int withContext;
447 #endif
448 {
449 MR_dumpPred1(0,p,withContext);
450 }
451
452 #ifdef __USE_PROTOS
453 Tree * MR_make_tree_from_set(set s)
454 #else
455 Tree * MR_make_tree_from_set(s)
456 set s;
457 #endif
458 {
459 Tree *t=NULL;
460 Tree *node;
461 Tree **tp=&t;
462 int i;
463
464 unsigned *pdq=set_pdq(s);
465
466 if (pdq != NULL) {
467 for (i=0 ; pdq[i] != nil ; i++) {
468 node=tnode( (int) pdq[i]);
469 *tp=node;
470 tp=&(node->right);
471 };
472 *tp=NULL;
473 free ( (char *) pdq);
474 };
475 return t;
476 }
477
478 #ifdef __USE_PROTOS
479 void MR_check_pred_too_long(Predicate *p,set completion)
480 #else
481 void MR_check_pred_too_long(p,completion)
482 Predicate *p;
483 set completion;
484 #endif
485 {
486 if (p != NULL &&
487 p->source != NULL &&
488 ! p->source->predTooLong) {
489 if ( !set_nil(completion)) {
490 p->source->predTooLong=1;
491 warnFL("It is unusual (but ok) for a semantic predicate to test context past the end of its own rule",
492 FileStr[p->source->file],p->source->line);
493 };
494 };
495 }
496
497 #ifdef __USE_PROTOS
498 int MR_predicate_context_completed(Predicate *p)
499 #else
500 int MR_predicate_context_completed(p)
501 Predicate *p;
502 #endif
503 {
504 if (p == NULL) return 1;
505 if (p->expr != PRED_AND_LIST &&
506 p->expr != PRED_OR_LIST) {
507 if ( ! set_nil(p->completionSet)) return 0;
508 if ( ! set_nil(p->completionTree)) return 0;
509 };
510 return MR_predicate_context_completed(p->down) &
511 MR_predicate_context_completed(p->right);
512 }
513
514 #ifdef __USE_PROTOS
515 Node * MR_advance(Node *n)
516 #else
517 Node * MR_advance(n)
518 Node *n;
519 #endif
520 {
521 if (n == NULL) return NULL;
522 switch (n->ntype) {
523 case nJunction: return ((Junction *)n)->p1;
524 case nToken: return ((TokNode *)n)->next;
525 case nRuleRef: return ((RuleRefNode *)n)->next;
526 case nAction: return ((ActionNode *)n)->next;
527 default: return NULL;
528 };
529 return NULL; /* MSVC 5.0 complains about missing return statement */
530 }
531
532 #ifdef __USE_PROTOS
533 Junction * MR_find_endRule(Node *n)
534 #else
535 Junction * MR_find_endRule(n)
536 Node *n;
537 #endif
538 {
539 Node *next;
540 if (n == NULL) return NULL;
541 for (next=n; next != NULL; next=MR_advance(next)) {
542 if (next->ntype == nJunction &&
543 ( (Junction *) next)->jtype == EndRule) {
544 break;
545 };
546 };
547 return (Junction *)next;
548 }
549
550 /*
551 Intersection: a branch which is shorter is chosen
552 over one which is longer: (A B C) intersect (A B) yields (A B).
553
554 AND: a branch which is longer is chosen over the one
555 which is shorter: (A B C) AND (A B) yields (A B C)
556
557 */
558
559 #ifdef __USE_PROTOS
560 Tree *MR_computeTreeIntersection(Tree *l,Tree *r)
561 #else
562 Tree *MR_computeTreeIntersection(l,r)
563 Tree *l;
564 Tree *r;
565 #endif
566 {
567 Tree *result=NULL;
568 Tree **tail;
569 Tree *p;
570 Tree *q;
571 Tree *match;
572
573 if (l == NULL || r == NULL) return NULL;
574 for (p=l; p != NULL; p=p->right) {
575 require(p->token != EpToken,"MR_computeTreeIntersection: p->EpToken unexpected\n");
576 require (p->token != ALT,"MR_computeTreeIntersection: p->ALT unexpected\n");
577 };
578 for (q=r; q != NULL; q=q->right) {
579 require(q->token != EpToken,"MR_computeTreeIntersection: q->EpToken unexpected\n");
580 require(q->token != ALT,"MR_computeTreeIntersection: q->ALT unexpected\n");
581 };
582
583 result=tnode(ALT);
584 tail=&(result->down);
585
586 for (p=l; p != NULL ; p=p->right) {
587 for (q=r; q != NULL ; q=q->right) {
588 if (p->token == q->token) {
589 match=tnode(p->token);
590 match->down=MR_computeTreeIntersection(p->down,q->down);
591 *tail=match;
592 tail=&(match->right);
593 };
594 };
595 };
596
597 *tail=NULL;
598 result=tshrink(result);
599 result=tflatten( result );
600 result=tleft_factor( result );
601 return result;
602 }
603
604 /* the predicates which are ANDed together have a common
605 context: they must all have common roots. Thus the
606 AND operation is more like an OR operation because
607 branches which are longer are grafted onto shorter
608 branches of the AND tree. For instance combining
609 (A B C) with (A B C D) gives (A B C D). There
610 should never be a case of (A B C) and (A B D) because
611 they have the same context.
612
613 Actually, this may not be true once one throws in
614 guard predicates which are defined by the user, not
615 the context.
616 */
617
618 /* requires input trees to be in "canonical" format */
619
620 #ifdef __USE_PROTOS
621 Tree *MR_computeTreeAND(Tree *l,Tree *r)
622 #else
623 Tree *MR_computeTreeAND(l,r)
624 Tree *l;
625 Tree *r;
626 #endif
627 {
628 Tree *result=NULL;
629 Tree **tail;
630 Tree *p;
631 Tree *q;
632 Tree *match;
633
634 if (l == NULL) return tdup(r);
635 if (r == NULL) return tdup(l);
636
637 for (p=l; p != NULL; p=p->right) {
638 /**** require(p->token != EpToken,"MR_computeTreeAND: p->EpToken unexpected\n"); ****/
639 require (p->token != ALT,"MR_computeTreeAND: p->ALT unexpected\n");
640 };
641 for (q=r; q != NULL; q=q->right) {
642 /**** require(q->token != EpToken,"MR_computeTreeAND: q->EpToken unexpected\n"); ****/
643 require(q->token != ALT,"MR_computeTreeAND: q->ALT unexpected\n");
644 };
645
646 result=tnode(ALT);
647 tail=&(result->down);
648
649 for (p=l; p != NULL ; p=p->right) {
650 for (q=r; q != NULL ; q=q->right) {
651 if (p->token == q->token) {
652 match=tnode(p->token);
653 match->down=MR_computeTreeAND(p->down,q->down);
654 *tail=match;
655 tail=&(match->right);
656 };
657 };
658 };
659
660 *tail=NULL;
661 result=tshrink(result);
662 result=tflatten( result );
663 result=tleft_factor( result );
664 return result;
665 }
666
667 #ifdef __USE_PROTOS
668 void MR_union_plain_sets1(Predicate *p,set *theUnion)
669 #else
670 void MR_union_plain_sets1(p,theUnion)
671 Predicate *p;
672 set *theUnion;
673 #endif
674 {
675 if (p == NULL) return;
676 MR_union_plain_sets1(p->down,theUnion);
677 MR_union_plain_sets1(p->right,theUnion);
678 set_orin(theUnion,p->plainSet);
679 return;
680 }
681
682 #ifdef __USE_PROTOS
683 set MR_union_plain_sets(Predicate *p)
684 #else
685 set MR_union_plain_sets(p)
686 Predicate *p;
687 #endif
688 {
689 set theUnion;
690
691 theUnion=empty;
692
693 MR_union_plain_sets1(p,&theUnion);
694 return theUnion;
695 }
696
697 /* does NOT left factor: do not want to merge
698 (A B) with (A) to get (A B)
699 in fact the opposite: (A B) with (A) gives (A)
700 */
701
702 #ifdef __USE_PROTOS
703 Tree *MR_compute_pred_tree_ctxXX(Predicate *p)
704 #else
705 Tree *MR_compute_pred_tree_ctxXX(p)
706 Predicate *p;
707 #endif
708 {
709 Tree *result=NULL;
710 Predicate *q;
711 Tree *t;
712
713 if (p == NULL) return NULL;
714
715 /* this appears strange: why do we OR the context
716 of and AND predicate ? It is because of the way
717 that predicates are evaluated: if the context is
718 wrong then it's the same as if the predicate was
719 true. That means that even when one leg of an
720 AND has unmatched context, if the other leg has
721 matched context and is true then the predicate
722 succeeds. It's only when all the legs have unmatched
723 context that this one can skip evaluation of the
724 predicates.
725 */
726 if (p->expr == PRED_OR_LIST ||
727 p->expr == PRED_AND_LIST) {
728 for (q=p->down; q != NULL ; q=q->right) {
729 t=MR_compute_pred_tree_ctxXX(q);
730 result=tappend(result,t);
731 t=NULL;
732 };
733
734 result=tshrink(result);
735 result=tflatten( result );
736
737 /* does NOT left factor: do not want to merge
738 (A B) with (A) to get (A B)
739 in fact the opposite: (A B) with (A) gives (A)
740 */
741
742 /**** result=tleft_factor( result ); ****/
743 return result;
744 };
745
746 #if 0
747 ** if (p->expr == PRED_AND_LIST) {
748 **
749 ** Predicate *l;
750 ** Predicate *r;
751 ** Tree *l1;
752 ** Tree *r1;
753 ** Tree *prevl1;
754 **
755 ** l=p->down;
756 ** require (l->right != NULL,"MR_compute_pred_tree - AND has only one child");
757 **
758 **/* l1 and r1 should already be in "canonical" format */
759 **
760 ** l1=MR_compute_pred_tree(l);
761 ** for (r=l->right; r != NULL; r=r->right) {
762 ** r1=MR_compute_pred_tree(r);
763 ** prevl1=l1;
764 ** l1=MR_computeTreeAND(l1,r1);
765 ** Tfree(r1);
766 ** Tfree(prevl1);
767 ** };
768 **
769 **/* result from computeTreeAND should be in "canonical" format */
770 **
771 ** result=l1;
772 **
773 **/* result of MR_computeTreeAND should be in "canonical" format */
774 **
775 ** return result;
776 ** };
777 #endif
778
779 if (p->k == 1) {
780 result=MR_make_tree_from_set(p->scontext[1]);
781 } else {
782 result=tdup(p->tcontext);
783 result=MR_remove_epsilon_from_tree(result);
784 result=tshrink(result);
785 result=tflatten(result);
786 result=tleft_factor(result);
787 };
788 return result;
789 }
790
791 #ifdef __USE_PROTOS
792 void MR_pred_depth(Predicate *p,int *maxDepth)
793 #else
794 void MR_pred_depth(p,maxDepth)
795 Predicate *p;
796 int *maxDepth;
797 #endif
798 {
799 if (p == NULL) return;
800 if (p->expr != PRED_OR_LIST &&
801 p->expr != PRED_AND_LIST) {
802 if (p->k > *maxDepth) *maxDepth=p->k;
803 };
804 MR_pred_depth(p->down,maxDepth);
805 MR_pred_depth(p->right,maxDepth);
806 }
807
808 /* this computes the OR of all the contexts */
809
810 #ifdef __USE_PROTOS
811 set MR_compute_pred_set(Predicate *p)
812 #else
813 set MR_compute_pred_set(p)
814 Predicate *p;
815 #endif
816 {
817 set result;
818 Predicate *q;
819
820 result=empty;
821
822 if (p == NULL) return empty;
823
824 if (p->expr == PRED_OR_LIST ||
825 p->expr == PRED_AND_LIST) { /* yes, I do mean PRED_AND_LIST ! */
826 /* remember: r1: (A)? => <<p>>? r2; */
827 /* r2: (B)? => <<q>>? r3; */
828 set t;
829
830 t=empty;
831 result=empty;
832
833 for (q=p->down; q != NULL; q=q->right) {
834 t=MR_compute_pred_set(q);
835 set_orin(&result,t);
836 set_free(t);
837 };
838 return result;
839 } else if (p->k > 1) {
840 return empty;
841 } else {
842 return set_dup(p->scontext[1]);
843 };
844 }
845
846 #ifdef __USE_PROTOS
847 set MR_First(int ck,Junction *j,set *incomplete)
848 #else
849 set MR_First(ck,j,incomplete)
850 int ck;
851 Junction *j;
852 set *incomplete;
853 #endif
854 {
855 Junction *p;
856 set tokensUsed;
857
858 tokensUsed=empty;
859
860 require(j->ntype==nJunction, "MR_First: non junction passed");
861
862 p = analysis_point((Junction *)j->p1);
863
864 REACH(p,ck,incomplete,tokensUsed);
865
866 return tokensUsed;
867 }
868
869 #ifdef __USE_PROTOS
870 void MR_cleanup_pred_trees(Predicate *p)
871 #else
872 void MR_cleanup_pred_trees(p)
873 Predicate *p;
874 #endif
875 {
876 Tree *t;
877
878 if (p == NULL) return;
879 if (p->expr != PRED_OR_LIST &&
880 p->expr != PRED_AND_LIST) {
881 t=p->tcontext;
882 t=tshrink(t);
883 t=tflatten(t);
884 t=tleft_factor(t);
885 p->tcontext=t;
886 };
887 MR_cleanup_pred_trees(p->down);
888 MR_cleanup_pred_trees(p->right);
889 }
890
891 /* does NOT return canonical tree */
892
893 #ifdef __USE_PROTOS
894 Tree * MR_remove_epsilon_from_tree(Tree *t)
895 #else
896 Tree * MR_remove_epsilon_from_tree(t)
897 Tree *t;
898 #endif
899 {
900 if (t == NULL) return NULL;
901
902 /* I think ALT can be ignored as a special case */
903
904 if (t->token != EpToken) {
905 t->down=MR_remove_epsilon_from_tree(t->down);
906 t->right=MR_remove_epsilon_from_tree(t->right);
907 return t;
908 } else {
909 Tree *u;
910 u=MR_remove_epsilon_from_tree(t->right);
911 t->right=NULL;
912 Tfree(t);
913 return u;
914 };
915 }
916
917 #ifdef __USE_PROTOS
918 void MR_complete_set(int predDepth,set *tokensUsed,set *incomplete)
919 #else
920 void MR_complete_set(predDepth,tokensUsed,incomplete)
921 int predDepth;
922 set *tokensUsed;
923 set *incomplete;
924 #endif
925 {
926 int i;
927 RuleRefNode *ruleRef;
928 set rk2;
929 set b;
930 int k2;
931 Junction *save_MR_RuleBlkWithHalt;
932
933 if (set_int(*incomplete) > (unsigned) predDepth) {
934 return;
935 };
936
937 require(MR_PredRuleRefStack.count == MR_RuleBlkWithHaltStack.count,
938 "RuleRefStack and RuleBlkWithHaltStack not same size");
939
940 require(MR_RuleBlkWithHalt == NULL ||
941 (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),
942 "RuleBlkWithHalt has no halt set");
943
944 save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;
945
946 if (MR_RuleBlkWithHalt != NULL) {
947 MR_RuleBlkWithHalt->end->halt=FALSE;
948 };
949
950 for (i=MR_PredRuleRefStack.count-1; i >= 0 ; i--) {
951 ruleRef=(RuleRefNode *)MR_PredRuleRefStack.data[i];
952 if (ruleRef == NULL) continue;
953
954 MR_RuleBlkWithHalt=(Junction *)MR_RuleBlkWithHaltStack.data[i];
955 if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=TRUE;
956
957 rk2=empty;
958 b=empty;
959
960 while ( !set_nil(*incomplete) ) {
961 k2=set_int(*incomplete);
962 if (k2 > predDepth) break; /* <=== another exit from loop */
963 set_rm(k2,*incomplete);
964 REACH(ruleRef->next,k2,&rk2,b);
965 set_orin(tokensUsed,b);
966 set_free(b);
967 };
968
969 if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=FALSE;
970
971 set_orin(incomplete,rk2); /* remember what we couldn't do */
972 set_free(rk2);
973 if (set_int(*incomplete) > (unsigned) predDepth) break; /* <=== another exit from loop */
974 };
975
976 MR_RuleBlkWithHalt=save_MR_RuleBlkWithHalt;
977 if (MR_RuleBlkWithHalt != NULL) {
978 MR_RuleBlkWithHalt->end->halt=TRUE;
979 };
980 }
981
982 #ifdef __USE_PROTOS
983 void MR_complete_tree(int predDepth,Tree **t,set *incomplete)
984 #else
985 void MR_complete_tree(predDepth,t,incomplete)
986 int predDepth;
987 Tree **t;
988 set *incomplete;
989 #endif
990 {
991 int i;
992 RuleRefNode *ruleRef;
993 set rk2;
994 Tree *u;
995 unsigned k2;
996 Junction *save_MR_RuleBlkWithHalt;
997 int saveConstrainSearch;
998
999 if (set_int(*incomplete) > (unsigned) predDepth) {
1000 return;
1001 };
1002
1003 require(MR_PredRuleRefStack.count == MR_RuleBlkWithHaltStack.count,
1004 "RuleRefStack and RuleBlkWithHaltStack not same size");
1005
1006 require(MR_RuleBlkWithHalt == NULL ||
1007 (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),
1008 "RuleBlkWithHalt has no halt set");
1009
1010 save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;
1011 saveConstrainSearch=ConstrainSearch;
1012 ConstrainSearch=0;
1013
1014 if (MR_RuleBlkWithHalt != NULL) {
1015 MR_RuleBlkWithHalt->end->halt=FALSE;
1016 };
1017
1018 for (i=MR_PredRuleRefStack.count-1; i >= 0 ; i--) {
1019 ruleRef=(RuleRefNode *)MR_PredRuleRefStack.data[i];
1020 if (ruleRef == NULL) continue;
1021
1022 MR_RuleBlkWithHalt=(Junction *)MR_RuleBlkWithHaltStack.data[i];
1023
1024 if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=TRUE;
1025
1026 rk2=empty;
1027
1028 while ( !set_nil(*incomplete) ) {
1029 k2 = set_int(*incomplete);
1030 if (k2 > (unsigned) predDepth) break; /* <=== another exit from loop */
1031 set_rm(k2,*incomplete);
1032 u = NULL;
1033
1034 TRAV(ruleRef->next,k2,&rk2,u);
1035
1036 /* any subtrees missing k2 tokens, add u onto end */
1037
1038 *t=tlink(*t,u,k2);
1039 Tfree(u);
1040 }
1041
1042 set_orin(incomplete,rk2); /* remember what we couldn't do */
1043 set_free(rk2);
1044
1045 if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=FALSE;
1046
1047 if (set_int(*incomplete) > (unsigned) predDepth) break; /* <=== another exit from loop */
1048 };
1049
1050 MR_RuleBlkWithHalt=save_MR_RuleBlkWithHalt;
1051
1052 if (MR_RuleBlkWithHalt != NULL) {
1053 MR_RuleBlkWithHalt->end->halt=TRUE;
1054 };
1055 ConstrainSearch=saveConstrainSearch;
1056 }
1057
1058 #ifdef __USE_PROTOS
1059 void MR_complete_predicates(int predDepth,Predicate *pred)
1060 #else
1061 void MR_complete_predicates(predDepth,pred)
1062 int predDepth;
1063 Predicate *pred;
1064 #endif
1065 {
1066 if (pred == NULL) return;
1067 if (pred->expr != PRED_AND_LIST &&
1068 pred->expr != PRED_OR_LIST) {
1069 MR_complete_set(predDepth,&(pred->scontext[1]),&(pred->completionSet));
1070 MR_complete_tree(predDepth,&(pred->tcontext),&(pred->completionTree));
1071 };
1072 MR_complete_predicates(predDepth,pred->down);
1073 MR_complete_predicates(predDepth,pred->right);
1074 }
1075
1076 #ifdef __USE_PROTOS
1077 Junction * MR_junctionWithoutP2(Junction *j)
1078 #else
1079 Junction * MR_junctionWithoutP2(j)
1080 Junction *j;
1081 #endif
1082 {
1083 Junction *thisAlt;
1084
1085 /* don't want to follow p2 to the next alternative of this rule */
1086 /* insert a generic node with null p2 if necessary */
1087 /* however FIRST requires a junction */
1088
1089 thisAlt=j;
1090 if (thisAlt->p2 != NULL) {
1091 if (thisAlt->p1->ntype == nJunction) {
1092 thisAlt=(Junction *) thisAlt->p1;
1093 } else {
1094 thisAlt=newJunction();
1095 thisAlt->p1=j->p1;
1096 thisAlt->rname=j->rname;
1097 thisAlt->file=j->file;
1098 thisAlt->line=j->line;
1099 j->p1=(Node *)thisAlt;
1100 };
1101 };
1102 return thisAlt;
1103 }
1104
1105 #ifdef __USE_PROTOS
1106 int MR_tree_equ(Tree *big, Tree *small) {
1107 #else
1108 int MR_tree_equ(big,small)
1109 Tree *big;
1110 Tree *small;
1111 {
1112 #endif
1113
1114 Tree *b;
1115 Tree *s;
1116 int bcount=0;
1117 int scount=0;
1118
1119 if (small == NULL && big == NULL) return 1;
1120 if (small == NULL) return 0;
1121 if (big == NULL) return 0;
1122
1123 if (small->token == ALT) {
1124 require(small->right == NULL,
1125 "MR_tree_equ: small: ALT node has siblings");
1126 return MR_tree_equ(big,small->down);
1127 };
1128 if (big->token == ALT) {
1129 require(big->right == NULL,
1130 "MR_tree_equ: big: ALT node has siblings");
1131 return MR_tree_equ(big->down,small);
1132 };
1133 for (s=small; s != NULL; s=s->right) {
1134 scount++;
1135 require(s->token != EpToken,"MR_tree_equ: s->EpToken unexpected\n");
1136 };
1137 for (b=big; b != NULL; b=b->right) {
1138 bcount++;
1139 require(b->token != EpToken,"MR_tree_equ: b->EpToken unexpected\n");
1140 };
1141
1142 if (bcount != scount) return 0;
1143
1144 for (s=small; s != NULL; s=s->right) {
1145 for (b=big; b!= NULL; b=b->right) {
1146 if (s->token == b->token) {
1147 if (MR_tree_equ(b->down,s->down)) goto next_s;
1148 };
1149 };
1150 return 0;
1151 next_s:
1152 continue;
1153 };
1154 return 1;
1155 }
1156
1157 /* this does not compare sources - only contexts ! */
1158
1159 #ifdef __USE_PROTOS
1160 int MR_identicalContext(Predicate *p,Predicate *q)
1161 #else
1162 int MR_identicalContext(p,q)
1163 Predicate *p;
1164 Predicate *q;
1165 #endif
1166 {
1167 if (p->k != q->k) return 0;
1168 require ( (p->tcontext == NULL) == (q->tcontext == NULL),
1169 "tcontext inconsistent");
1170 if (p->k == 1) {
1171 return set_equ(p->scontext[1],q->scontext[1]);
1172 } else {
1173 return MR_tree_equ(p->tcontext,q->tcontext);
1174 };
1175 }
1176
1177 #ifdef __USE_PROTOS
1178 void MR_reportSetSuppression(int predDepth,
1179 set predSet,set plainSet,Junction *jPred,Junction *jPlain,Predicate *p)
1180 #else
1181 void MR_reportSetSuppression(predDepth,predSet,plainSet,jPred,jPlain,p)
1182 int predDepth;
1183 set predSet;
1184 set plainSet;
1185 Junction *jPred;
1186 Junction *jPlain;
1187 Predicate *p;
1188 #endif
1189 {
1190 if (InfoP) {
1191 fprintf(output,"\n#if 0\n\n");
1192 fprintf(output,"Hoisting of predicate suppressed by alternative without predicate.\n");
1193 fprintf(output,"The alt without the predicate includes all cases where the predicate is false.\n\n");
1194 fprintf(output," WITH predicate: line %d %s\n",jPred->line,FileStr[jPred->file]);
1195 if (jPlain != NULL) {
1196 fprintf(output," WITHOUT predicate: line %d %s\n",jPlain->line,FileStr[jPlain->file]);
1197 } else {
1198 fprintf(output," WITHOUT predicate: all alternatives without predicates (combined)\n");
1199 };
1200 if (predDepth == 1) {
1201 fprintf(output,"\nThe context set for the predicate:\n");
1202 MR_dumpTokenSet(output,1,predSet);
1203 };
1204 fprintf(output,"\nThe lookahead set for the alt WITHOUT the semantic predicate:\n");
1205 MR_dumpTokenSet(output,1,plainSet);
1206 fprintf(output,"\nThe predicate:\n\n");
1207 MR_dumpPred1(1,p,1);
1208 fprintf(output,"Chain of referenced rules:\n\n");
1209 MR_dumpPredRuleRefStack(output,4);
1210 fprintf(output,"\n#endif\n");
1211 };
1212 }
1213
1214 #ifdef __USE_PROTOS
1215 void MR_reportSetRestriction(int predDepth,set predSet,set plainSet,
1216 Junction *jPred,Junction *jPlain,Predicate *origPred,Predicate *newPred)
1217 #else
1218 void MR_reportSetRestriction(predDepth,predSet,plainSet,jPred,jPlain,origPred,newPred)
1219 int predDepth;
1220 set predSet;
1221 set plainSet;
1222 Junction *jPred;
1223 Junction *jPlain;
1224 Predicate *origPred;
1225 Predicate *newPred;
1226 #endif
1227 {
1228 set intersect;
1229
1230 intersect=empty;
1231
1232 if (! InfoP) return;
1233 fprintf(output,"\n#if 0\n\n");
1234 fprintf(output,"Restricting the context of a predicate because of overlap in the lookahead set\n");
1235 fprintf(output," between the alternative with the semantic predicate and one without\n");
1236 fprintf(output,"Without this restriction the alternative without the predicate could not\n");
1237 fprintf(output," be reached when input matched the context of the predicate and the predicate\n");
1238 fprintf(output," was false.\n\n");
1239
1240 fprintf(output," WITH predicate: line %d %s\n",jPred->line,FileStr[jPred->file]);
1241 if (jPlain != NULL) {
1242 fprintf(output," WITHOUT predicate: line %d %s\n",jPlain->line,FileStr[jPlain->file]);
1243 } else {
1244 fprintf(output," WITHOUT predicate: all alternatives without predicates (combined)\n");
1245 };
1246 if (predDepth == 1) {
1247 fprintf(output,"\nThe original context set for the predicate:\n");
1248 MR_dumpTokenSet(output,1,predSet);
1249 };
1250 fprintf(output,"\nThe lookahead set for the alt WITHOUT the semantic predicate:\n");
1251 MR_dumpTokenSet(output,1,plainSet);
1252 if (predDepth == 1) {
1253 fprintf(output,"\nThe intersection of the two sets\n");
1254 intersect=set_and(predSet,plainSet);
1255 MR_dumpTokenSet(output,1,intersect);
1256 set_free(intersect);
1257 };
1258 fprintf(output,"\nThe original predicate:\n\n");
1259 MR_dumpPred1(1,origPred,1);
1260 fprintf(output,"The new (modified) form of the predicate:\n\n");
1261 MR_dumpPred1(1,newPred,1);
1262 fprintf(output,"#endif\n");
1263 }
1264
1265 /* don't use Pass3 by itself unless you know that inverted is not important */
1266
1267 #ifdef __USE_PROTOS
1268 Predicate * MR_removeRedundantPredPass3(Predicate *p)
1269 #else
1270 Predicate * MR_removeRedundantPredPass3(p)
1271 Predicate *p;
1272 #endif
1273 {
1274 Predicate *q;
1275
1276 if (p == NULL) return NULL;
1277 p->right=MR_removeRedundantPredPass3(p->right);
1278 p->down=MR_removeRedundantPredPass3(p->down);
1279 if (p->redundant) {
1280 q=p->right;
1281 p->right=NULL;
1282 predicate_free(p);
1283 return q;
1284 };
1285 if (p->expr == PRED_AND_LIST ||
1286 p->expr == PRED_OR_LIST) {
1287 if (p->down == NULL) {
1288 q=p->right;
1289 p->right=NULL;
1290 predicate_free(p);
1291 return q;
1292 };
1293 if (p->down != NULL && p->down->right == NULL) {
1294 q=p->down;
1295 q->right=p->right;
1296 p->right=NULL;
1297 p->down=NULL;
1298 return q;
1299 };
1300 };
1301 return p;
1302 }
1303
1304 #ifdef __USE_PROTOS
1305 void MR_removeRedundantPredPass2(Predicate *p)
1306 #else
1307 void MR_removeRedundantPredPass2(p)
1308 Predicate *p;
1309 #endif
1310 {
1311 Predicate *q;
1312
1313 if (p == NULL) return;
1314
1315 if (p->expr == PRED_AND_LIST) {
1316 for (q=p->down ; q != NULL ; q=q->right) {
1317 MR_removeRedundantPredPass2(q);
1318 if (q->isConst) {
1319 if (q->constValue == 0) {
1320 p->isConst=1;
1321 p->constValue=0;
1322 return;
1323 } else {
1324 q->redundant=1;
1325 };
1326 };
1327 };
1328 };
1329
1330 if (p->expr == PRED_OR_LIST) {
1331 for (q=p->down ; q != NULL ; q=q->right) {
1332 MR_removeRedundantPredPass2(q);
1333 if (q->isConst) {
1334 if (q->constValue == 0) {
1335 q->redundant=1;
1336 } else {
1337 p->isConst=1;
1338 p->constValue=1;
1339 return;
1340 };
1341 };
1342 };
1343 };
1344
1345 return;
1346 }
1347
1348 #if 0
1349 this totally ignores the implications of guarded predicates
1350 in which the part after the guard could possibly cover a predicate.
1351 that would be much harder:
1352
1353 rule : (A)? => <<p>>? sub1; /* 1 */
1354 | (B)? => <<r>>? sub2 /* 2 */
1355 sub1 : (A)? => <<q>>? A B /* 3 */
1356 | B /* 4 - suppresses line 2 */
1357 ;
1358 #endif
1359
1360 #ifdef __USE_PROTOS
1361 void MR_apply_restriction1(Predicate *pred,set *plainSet,int *changed)
1362 #else
1363 void MR_apply_restriction1(pred,plainSet,changed)
1364 Predicate *pred;
1365 set *plainSet;
1366 int *changed;
1367 #endif
1368 {
1369 if (pred == NULL) return;
1370 MR_apply_restriction1(pred->right,plainSet,changed);
1371 if (pred->down != NULL) {
1372 MR_apply_restriction1(pred->down,plainSet,changed);
1373 } else {
1374 set t;
1375 if (pred->k == 1) {
1376 t=set_dif(pred->scontext[1],*plainSet);
1377 if (*changed == 0 &&
1378 !set_equ(t,pred->scontext[1])) {
1379 *changed=1;
1380 };
1381 if (set_nil(t)) {
1382 pred->redundant=1;
1383 };
1384 set_free(pred->scontext[1]);
1385 pred->scontext[1]=t;
1386 };
1387 };
1388 }
1389
1390 #ifdef __USE_PROTOS
1391 void MR_orin_plainSet(Predicate *p,set plainSet)
1392 #else
1393 void MR_orin_plainSet(p,plainSet)
1394 Predicate *p;
1395 set plainSet;
1396 #endif
1397 {
1398 if (p == NULL) return;
1399 MR_orin_plainSet(p->down,plainSet);
1400 MR_orin_plainSet(p->right,plainSet);
1401 set_orin(&p->plainSet,plainSet);
1402 }
1403
1404 Predicate *PRED_SUPPRESS;
1405
1406 #ifdef __USE_PROTOS
1407 Predicate * MR_find_in_aSubBlk(Junction *alt)
1408 #else
1409 Predicate * MR_find_in_aSubBlk(alt)
1410 Junction *alt;
1411 #endif
1412 {
1413 Predicate *root=NULL;
1414 Predicate **tail=NULL;
1415
1416 Junction *p;
1417
1418 int nAlts=0;
1419 Junction **jList;
1420 Predicate **predList;
1421 int *matchList;
1422 set predSet;
1423 int i;
1424 int j;
1425 int m;
1426 int predDepth;
1427 set incomplete;
1428 set union_plainSet;
1429 set setChange;
1430 int changed;
1431 Predicate *newPred;
1432 set setDif;
1433 Predicate *origPred;
1434 int depth1=1; /* const int */
1435 set *plainContext;
1436 set plainSet;
1437
1438 predSet=empty;
1439 incomplete=empty;
1440 union_plainSet=empty;
1441 setChange=empty;
1442 setDif=empty;
1443 plainSet=empty;
1444
1445 if (PRED_SUPPRESS == NULL) {
1446 PRED_SUPPRESS=new_pred();
1447 PRED_SUPPRESS->expr="Predicate Suppressed";
1448 };
1449
1450 /* this section just counts the number of "interesting" alternatives */
1451 /* in order to allocate arrays */
1452
1453 for (p=alt; p!=NULL; p=(Junction *)p->p2) {
1454 /* ignore empty alts */
1455 if ( p->p1->ntype != nJunction ||
1456 ((Junction *)p->p1)->jtype != EndBlk ) {
1457 nAlts++;
1458 };
1459 };
1460
1461 /* if this is a (...)+ block then don't count the last alt because
1462 it can't be taken until at least one time through the block.
1463 In other words it isn't a real choice until the (...)+ is entered
1464 at which point the hoisting issue is moot.
1465 Maybe look at "ignore" instead ?
1466 */
1467
1468 if (alt->jtype == aPlusBlk) {
1469 nAlts--;
1470 };
1471
1472 jList=(Junction **)calloc(nAlts,sizeof(Junction *));
1473 require(jList!=NULL,"cannot allocate MR_find_in_aSubBlk jList");
1474
1475 plainContext=(set *)calloc(nAlts,sizeof(set));
1476 require(plainContext!=NULL,"cannot allocate MR_find_in_aSubBlk plainContext");
1477 for (m=0; m < nAlts; m++) plainContext[m]=empty;
1478
1479 predList=(Predicate **)calloc(nAlts,sizeof(Predicate *));
1480 require(predList!=NULL,"cannot allocate MR_find_in_aSubBlk predList");
1481
1482 matchList=(int *)calloc(nAlts,sizeof(int));
1483 require(matchList!=NULL,"cannot allocate MR_find_in_aSubBlk matchList");
1484
1485 /* this section just fills in the arrays previously allocated */
1486 /* the most interesting one is matchList[] */
1487 /* */
1488 /* bit 0 => this alt has a semantic pred which is "covered" */
1489 /* by an alt without a semantic pred. Don't hoist. */
1490
1491 for (i=0,p=alt;
1492 p!=NULL && i<nAlts;
1493 i++,p=(Junction *)p->p2) {
1494
1495 /* ignore empty alts */
1496
1497 if ( p->p1->ntype != nJunction ||
1498 ((Junction *)p->p1)->jtype != EndBlk ) {
1499 jList[i]=MR_junctionWithoutP2(p);
1500 predList[i]=find_predicates(p->p1); /* should be jList ????? */
1501 if (predList[i] != NULL) {
1502 MR_cleanup_pred_trees(predList[i]); /* flatten & left factor */
1503 plainContext[i]=MR_union_plain_sets(predList[i]);
1504 } else {
1505 MR_set_reuse(&plainSet);
1506 MR_set_reuse(&incomplete);
1507 plainSet=MR_First(depth1,jList[i],&incomplete);
1508 MR_complete_set(depth1,&plainSet,&incomplete);
1509 require(set_nil(incomplete),"couldn't complete k=1");
1510 plainContext[i]=plainSet;
1511 plainSet=empty;
1512 };
1513 set_orin(&union_plainSet,plainContext[i]);
1514 };
1515 };
1516
1517 if (nAlts == 1) {
1518 goto EXIT_SIMPLE;
1519 };
1520
1521 /*
1522 * Looking for cases where alt i has a semantic pred and alt j does not.
1523 * Don't care about cases where lookahead for semantic predicates overlap
1524 * because normal predicate hoisting does the correct thing automatically.
1525 * Don't care about cases where lookahead for alts without semantic predicates
1526 * overlap because normal prediction does the correct thing automatically.
1527 *
1528 * When we find such a case check for one of three subcases:
1529 *
1530 * 1. if lookahead for alt i is contained in the lookahead for any
1531 * alt j then ignore semantic predicate of alt i
1532 * 2. if lookahead for alt i is not contained in the lookahead for
1533 * any alt j then add add predicate i to the OR list to be hoisted
1534 * 3. if lookahead for alt i overlaps the lookahead for some alt j then
1535 * add a dummy semantic predicate for alt j
1536 *
1537 * There is an implicit assumption that the context of all alternatives following
1538 * the rule being processed here are identical (but may vary from hoist to
1539 * hoist depending on the place where the rule was invoked that led to hoisting
1540 * these predicates. In othere words in the fragment:
1541 *
1542 * ( <<a>>? a1 a2 a3 | <<b>>? b1 b2 b3 )
1543 *
1544 * both a3 and b3 have the same follow sets because they are both at the end of
1545 * alternatives in the same block.
1546 */
1547
1548 for (i=0; i < nAlts; i++) {
1549 if (jList[i] == NULL) continue;
1550 if (predList[i] == NULL) continue;
1551
1552 /* if the predicate depth turns out to be one token only */
1553 /* then it is can be easily represented as a set and */
1554 /* compared to the junction set create by MR_First() */
1555
1556 predDepth=0;
1557 MR_pred_depth(predList[i],&predDepth);
1558 require (predDepth >= 1,"MR_find_in_aSubBlk: pred depth < 1");
1559 require (predDepth <= CLL_k,"MR_find_in_aSubBlk: predDepth > CLL_k");
1560
1561 /* complete predicates to predDepth
1562 If completed to depth=1 then the context would be incomplete.
1563 The context would be truncated and the predicate simplify routine
1564 would have incomplete information. It would lead to
1565 either false matches of failure to find true matches.
1566 */
1567
1568 MR_complete_predicates(predDepth,predList[i]);
1569
1570 if (predList[i] != NULL) {
1571 MR_cleanup_pred_trees(predList[i]); /* flatten & left factor */
1572 };
1573
1574 /* If the predicate depth is 1 then it is possible to suppress
1575 a predicate completely using a single plain alt. Check for suppression
1576 by a single plain alt first because it gives better messages. If that
1577 fails try the union of all the plain alts.
1578 */
1579
1580 if (predDepth == 1) {
1581
1582 MR_set_reuse(&predSet);
1583 predSet=MR_compute_pred_set(predList[i]); /* ignores k>1 predicates */
1584
1585 for (j=0; j < nAlts; j++) {
1586 if (jList[j] == NULL) continue;
1587 if (j == i) continue;
1588
1589 MR_set_reuse(&setDif);
1590 setDif=set_dif(predSet,plainContext[j]);
1591 if (set_nil(setDif)) {
1592 matchList[i] |= 1;
1593 MR_reportSetSuppression(predDepth,predSet,plainContext[j],jList[i],jList[j],predList[i]);
1594 predicate_free(predList[i]);
1595 predList[i]=PRED_SUPPRESS;
1596 goto next_i;
1597 };
1598
1599 }; /* end loop on j */
1600
1601 changed=0;
1602
1603 /* predicate_dup is only to give good error messages */
1604 /* remember to do a predicate_free() */
1605
1606 origPred=predicate_dup(predList[i]);
1607 MR_apply_restriction1(predList[i],&union_plainSet,&changed);
1608 if (changed) {
1609
1610 /* don't use Pass3 by itself unless you know that inverted is not important */
1611
1612 newPred=MR_removeRedundantPredPass3(predList[i]);
1613 newPred=MR_predSimplifyALL(newPred);
1614 if (newPred == NULL) {
1615 matchList[i] |= 1;
1616 MR_reportSetSuppression(predDepth,predSet,union_plainSet,jList[i],
1617 NULL,origPred);
1618 predList[i]=PRED_SUPPRESS;
1619 } else {
1620 MR_reportSetRestriction(predDepth,predSet,union_plainSet,jList[i],
1621 NULL,origPred,newPred);
1622 predList[i]=newPred;
1623 };
1624 };
1625 predicate_free(origPred);
1626 origPred=NULL;
1627 };
1628
1629 /*
1630 If the predicate depth is > 1 then it can't be suppressed completely
1631 because the code doesn't support inspection of such things. They're
1632 much messier than k=1 sets.
1633 */
1634
1635 if (predDepth > 1 ) {
1636
1637 changed=0;
1638
1639 /* predicate_dup is only to give good error messages */
1640 /* remember to do a predicate_free() */
1641
1642 origPred=predicate_dup(predList[i]);
1643 MR_apply_restriction1(predList[i],&union_plainSet,&changed);
1644 if (changed) {
1645 newPred=MR_removeRedundantPredPass3(predList[i]);
1646 newPred=MR_predSimplifyALL(newPred);
1647 if (newPred == NULL) {
1648 matchList[i] |= 1;
1649 MR_reportSetSuppression(predDepth,predSet,union_plainSet,jList[i],
1650 NULL,origPred);
1651 predList[i]=PRED_SUPPRESS;
1652 } else {
1653 MR_reportSetRestriction(predDepth,predSet,union_plainSet,jList[i],
1654 NULL,origPred,newPred);
1655 predList[i]=newPred;
1656 };
1657 };
1658 predicate_free(origPred);
1659 origPred=NULL;
1660 };
1661 next_i:
1662 continue;
1663 };
1664
1665 EXIT_SIMPLE:
1666
1667 root = new_pred();
1668 root->expr=PRED_OR_LIST;
1669 tail = &(root->down);
1670
1671 for (i=0 ; i< nAlts ; i++) {
1672 if (jList[i] == NULL) continue;
1673
1674 if (predList[i] == NULL) {
1675 continue;
1676 } else if ( (matchList[i] & 1) != 0) {
1677 if (predList[i] != PRED_SUPPRESS) {
1678 predicate_free(predList[i]);
1679 };
1680 continue;
1681 };
1682
1683 /* make an OR list of predicates */
1684
1685 *tail=predList[i];
1686 tail=&(predList[i]->right);
1687 };
1688
1689 /* if just one pred, remove OR root */
1690
1691 if (root->down == NULL) {
1692 predicate_free(root);
1693 root=NULL;
1694 } else if (root->down->right == NULL) {
1695 Predicate *p=root->down;
1696 root->down=NULL;
1697 predicate_free(root);
1698 root=p;
1699 }
1700
1701 root=MR_predSimplifyALL(root);
1702
1703 MR_orin_plainSet(root,union_plainSet);
1704
1705 set_free(predSet);
1706 set_free(union_plainSet);
1707 set_free(incomplete);
1708 set_free(setChange);
1709 set_free(setDif);
1710
1711 for (m=0; m < nAlts; m++) set_free(plainContext[m]);
1712
1713 free ( (char *) jList);
1714 free ( (char *) predList);
1715 free ( (char *) matchList);
1716 free ( (char *) plainContext);
1717
1718 return root;
1719 }
1720
1721 #ifdef __USE_PROTOS
1722 void MR_predContextPresent(Predicate *p,int *allHaveContext,int *noneHaveContext)
1723 #else
1724 void MR_predContextPresent(p,allHaveContext,noneHaveContext)
1725 Predicate *p;
1726 int *allHaveContext;
1727 int *noneHaveContext;
1728 #endif
1729 {
1730 if (p == NULL) return;
1731 MR_predContextPresent(p->right,allHaveContext,noneHaveContext);
1732 if (p->expr != PRED_AND_LIST &&
1733 p->expr != PRED_OR_LIST) {
1734 if (set_nil(p->scontext[1]) == 0 ||
1735 (p->tcontext != NULL)) {
1736 *noneHaveContext=0;
1737 } else {
1738 *allHaveContext=0;
1739 };
1740 };
1741 MR_predContextPresent(p->down,allHaveContext,noneHaveContext);
1742 }
1743
1744 #ifdef __USE_PROTOS
1745 int MR_pointerStackPush(PointerStack *ps,void *dataPointer)
1746 #else
1747 int MR_pointerStackPush(ps,dataPointer)
1748 PointerStack *ps;
1749 void *dataPointer;
1750 #endif
1751 {
1752 void **newStack;
1753 int newSize;
1754 int i;
1755
1756 if (ps->count == ps->size) {
1757 newSize=20+ps->size*2;
1758 newStack=(void **)calloc(newSize,sizeof(void *));
1759 require (newStack != NULL,"cannot allocate PointerStack");
1760 for (i=0; i < ps->size; i++) {
1761 newStack[i]=ps->data[i];
1762 };
1763 if (ps->data != NULL) free( (char *) ps->data);
1764 ps->data=newStack;
1765 ps->size=newSize;
1766 };
1767 ps->data[ps->count]=dataPointer;
1768 ps->count++;
1769 return ps->count-1;
1770 }
1771
1772 #ifdef __USE_PROTOS
1773 void * MR_pointerStackPop(PointerStack *ps)
1774 #else
1775 void * MR_pointerStackPop(ps)
1776 PointerStack *ps;
1777 #endif
1778 {
1779 void *dataPointer;
1780
1781 require(ps->count > 0,"MR_pointerStackPop underflow");
1782
1783 dataPointer=ps->data[ps->count-1];
1784 ps->data[ps->count-1]=NULL;
1785 (ps->count)--;
1786 return dataPointer;
1787 }
1788
1789 #ifdef __USE_PROTOS
1790 void * MR_pointerStackTop(PointerStack *ps)
1791 #else
1792 void * MR_pointerStackTop(ps)
1793 PointerStack *ps;
1794 #endif
1795 {
1796 require(ps->count > 0,"MR_pointerStackTop underflow");
1797 return ps->data[ps->count-1];
1798 }
1799
1800 #ifdef __USE_PROTOS
1801 void MR_pointerStackReset(PointerStack *ps)
1802 #else
1803 void MR_pointerStackReset(ps)
1804 PointerStack *ps;
1805 #endif
1806 {
1807 int i;
1808 if (ps->data != NULL) {
1809 for (i=0; i < ps->count ; i++) {
1810 ps->data[i]=NULL;
1811 };
1812 };
1813 ps->count=0;
1814 }
1815
1816 #ifdef __USE_PROTOS
1817 Junction *MR_nameToRuleBlk(char *name)
1818 #else
1819 Junction *MR_nameToRuleBlk(name)
1820 char *name;
1821 #endif
1822 {
1823 RuleEntry *q;
1824
1825 require (RulePtr != NULL,"MR_nameToRule: RulePtr not initialized");
1826
1827 if (name == NULL) return NULL;
1828
1829 q = (RuleEntry *) hash_get(Rname,name);
1830
1831 if ( q == NULL ) {
1832 return NULL;
1833 } else {
1834 return RulePtr[q->rulenum];
1835 };
1836 }
1837
1838 #ifdef __USE_PROTOS
1839 Junction * MR_ruleReferenced(RuleRefNode *rrn)
1840 #else
1841 Junction * MR_ruleReferenced(rrn)
1842 RuleRefNode *rrn;
1843 #endif
1844 {
1845 return MR_nameToRuleBlk(rrn->text);
1846 }
1847
1848 #ifdef __USE_PROTOS
1849 void MR_comparePredLeaves(Predicate *me,Predicate *myParent,Predicate *him,Predicate *hisParent)
1850 #else
1851 void MR_comparePredLeaves(me,myParent,him,hisParent)
1852 Predicate *me;
1853 Predicate *myParent;
1854 Predicate *him;
1855 Predicate *hisParent;
1856 #endif
1857 {
1858 if (me == NULL) return;
1859 if (me == him) {
1860 MR_comparePredLeaves(me->right,myParent,him,hisParent);
1861 return;
1862 } else if (me->expr == PRED_AND_LIST ||
1863 me->expr == PRED_OR_LIST) {
1864 MR_comparePredLeaves(me->down,me,him,hisParent);
1865 MR_comparePredLeaves(me->right,myParent,him,hisParent);
1866 return;
1867 } else {
1868 if (me->source != NULL) {
1869
1870 /* predicate->invert can be set only in the predEntry predicates */
1871 /* thus they are only visible after the predEntry predicates have been "unfolded" */
1872
1873 int sameSource=(me->source == him->source);
1874 int sameInvert=1 &
1875 (1 + me->inverted + him->inverted + me->source->inverted + him->source->inverted);
1876 int samePredEntry=(me->source->predEntry != NULL
1877 && him->source->predEntry != NULL
1878 && me->source->predEntry == him->source->predEntry);
1879 if (sameInvert && (sameSource || samePredEntry)) {
1880 if (MR_identicalContext(me,him)) {
1881
1882 /* identical predicates */
1883
1884 if (hisParent->expr == PRED_OR_LIST &&
1885 myParent->expr == PRED_OR_LIST) {
1886 me->redundant=1;
1887 } else if (hisParent->expr == PRED_AND_LIST &&
1888 myParent->expr == PRED_AND_LIST) {
1889 me->redundant=1;
1890 } else if ( (hisParent->expr == PRED_OR_LIST &&
1891 myParent->expr == PRED_AND_LIST)
1892 ||
1893 (hisParent->expr == PRED_AND_LIST &&
1894 myParent->expr == PRED_OR_LIST)
1895 ) {
1896 myParent->redundant=1;
1897 } else {
1898 require (0,"MR_comparePredLeaves: not both PRED_LIST");
1899 };
1900 };
1901 }; /* end same source or same predEntrr with same invert sense */
1902
1903 /* same predEntry but opposite invert sense */
1904
1905 if (!sameInvert && (sameSource || samePredEntry)) {
1906 if (MR_identicalContext(me,him)) {
1907 if (hisParent->expr == PRED_OR_LIST &&
1908 myParent->expr == PRED_OR_LIST) {
1909 myParent->isConst=1;
1910 myParent->constValue=1;
1911 } else if (hisParent->expr == PRED_AND_LIST &&
1912 myParent->expr == PRED_AND_LIST) {
1913 myParent->isConst=1;
1914 myParent->constValue=0;
1915 } else if ( (hisParent->expr == PRED_OR_LIST &&
1916 myParent->expr == PRED_AND_LIST)
1917 ||
1918 (hisParent->expr == PRED_AND_LIST &&
1919 myParent->expr == PRED_OR_LIST)
1920 ) {
1921 me->redundant=1;
1922 } else {
1923 require (0,"MR_comparePredLeaves: not both PRED_LIST");
1924 };
1925 };
1926 }; /* end same predEntry with opposite invert sense */
1927 };
1928
1929 MR_comparePredLeaves(me->right,myParent,him,hisParent);
1930 return;
1931 };
1932 }
1933
1934 #ifdef __USE_PROTOS
1935 void MR_removeRedundantPredPass1(Predicate *me,Predicate *myParent)
1936 #else
1937 void MR_removeRedundantPredPass1(me,myParent)
1938 Predicate *me;
1939 Predicate *myParent;
1940 #endif
1941 {
1942 if (me == NULL) return;
1943 if (me->redundant) {
1944 MR_removeRedundantPredPass1(me->right,myParent);
1945 return;
1946 };
1947 if (me->expr == PRED_AND_LIST ||
1948 me->expr == PRED_OR_LIST) {
1949 MR_removeRedundantPredPass1(me->down,me);
1950 MR_removeRedundantPredPass1(me->right,myParent);
1951 } else {
1952 require (me->source != NULL,"me->source == NULL");
1953 if (myParent != NULL) {
1954 MR_comparePredLeaves(myParent->down,myParent,me,myParent);
1955 };
1956 MR_removeRedundantPredPass1(me->right,myParent);
1957 };
1958 }
1959
1960 /* pretty much ignores things with the inverted bit set */
1961
1962 #ifdef __USE_PROTOS
1963 Predicate *MR_predFlatten(Predicate *p)
1964 #else
1965 Predicate *MR_predFlatten(p)
1966 Predicate *p;
1967 #endif
1968 {
1969 if (p == NULL) return NULL;
1970 if (p->expr == PRED_OR_LIST
1971 || p->expr == PRED_AND_LIST) {
1972
1973 Predicate *child;
1974 Predicate *gchild;
1975 Predicate **tail;
1976 Predicate *next;
1977 char *PRED_XXX_LIST=p->expr;
1978
1979 require (p->down != NULL,"MR_predFlatten AND/OR no child");
1980
1981
1982 p->down=MR_predFlatten(p->down);
1983 p->right=MR_predFlatten(p->right);
1984 child=p->down;
1985 if (child->right == NULL) {
1986 child->right=p->right;
1987 p->right=NULL;
1988 p->down=NULL;
1989 if (p->inverted) child->inverted=!child->inverted;
1990 predicate_free(p);
1991 return child;
1992 };
1993
1994 /* make a single list of all children and grandchildren */
1995
1996 tail=&(p->down);
1997 for (child=p->down; child != NULL; child=next) {
1998 if (child->expr != PRED_XXX_LIST
1999 || child->inverted
2000 || child->predEntry != NULL) {
2001 *tail=child;
2002 tail=&(child->right);
2003 next=child->right;
2004 } else {
2005 for (gchild=child->down;
2006 gchild != NULL;
2007 gchild=gchild->right) {
2008 *tail=gchild;
2009 tail=&(gchild->right);
2010 };
2011 next=child->right;
2012 child->right=NULL;
2013 child->down=NULL;
2014 predicate_free(child);
2015 };
2016 };
2017 *tail=NULL;
2018 return p;
2019 } else {
2020 p->right=MR_predFlatten(p->right);
2021 return p;
2022 };
2023 }
2024
2025 static char *alwaysFalseWarning=NULL;
2026
2027 #ifdef __USE_PROTOS
2028 Predicate *checkPredicateConflict(Predicate *p)
2029 #else
2030 Predicate *checkPredicateConflict(p)
2031 Predicate *p;
2032 #endif
2033 {
2034 if (p->isConst) {
2035 if (p->constValue == 1) {
2036 predicate_free(p);
2037 return NULL;
2038 } else {
2039 if (InfoP && !p->conflictReported) {
2040 p->conflictReported=1;
2041 fprintf(output,"\n#if 0\n\n");
2042 fprintf(output,"The following predicate expression will always be false:\n\n");
2043 MR_dumpPred1(1,p,1);
2044 fprintf(output,"\n#endif\n");
2045 };
2046
2047 if (alwaysFalseWarning != CurRule) {
2048 alwaysFalseWarning=CurRule;
2049 if (InfoP) {
2050 warnNoFL(eMsg1("one (or more) predicate expression hoisted into rule \"%s\" are always false \
2051 - see output file for more information",CurRule));
2052 } else {
2053 warnNoFL(eMsg1("one (or more) predicate expressions hoisted into rule \"%s\" are always false \
2054 - use \"-info p\" for more information",CurRule));
2055 };
2056 };
2057 };
2058 };
2059 return p;
2060 }
2061
2062
2063 #ifdef __USE_PROTOS
2064 int MR_countPredNodes(Predicate *p)
2065 #else
2066 int MR_countPredNodes(p)
2067 Predicate *p;
2068 #endif
2069 {
2070 if (p == NULL) return 0;
2071 return 1 + MR_countPredNodes(p->down) + MR_countPredNodes(p->right);
2072 }
2073
2074 #ifdef __USE_PROTOS
2075 Predicate *MR_predSimplifyALLX(Predicate *p,int skipPass3)
2076 #else
2077 Predicate *MR_predSimplifyALLX(p,skipPass3)
2078 Predicate *p;
2079 int skipPass3;
2080 #endif
2081 {
2082 int countBefore;
2083 int countAfter;
2084
2085 countAfter=MR_countPredNodes(p);
2086
2087 do {
2088 if (p == NULL) return NULL;
2089 if (p->right == NULL && p->down == NULL) return p;
2090 countBefore=countAfter;
2091 MR_simplifyInverted(p,0);
2092 p=MR_predFlatten(p);
2093 MR_removeRedundantPredPass1(p,NULL);
2094 MR_removeRedundantPredPass2(p);
2095 if (! skipPass3) {
2096 p=checkPredicateConflict(p);
2097 p=MR_removeRedundantPredPass3(p);
2098 };
2099 countAfter=MR_countPredNodes(p);
2100 } while (countBefore != countAfter);
2101
2102 return p;
2103 }
2104
2105 #ifdef __USE_PROTOS
2106 Predicate *MR_predSimplifyALL(Predicate *p)
2107 #else
2108 Predicate *MR_predSimplifyALL(p)
2109 Predicate *p;
2110 #endif
2111 {
2112 return MR_predSimplifyALLX(p,0);
2113 }
2114
2115 #ifdef __USE_PROTOS
2116 void MR_releaseResourcesUsedInRule(Node *n)
2117 #else
2118 void MR_releaseResourcesUsedInRule(n)
2119 Node *n;
2120 #endif
2121 {
2122 Node *next;
2123 Junction *j;
2124 int i;
2125
2126 if (n == NULL) return;
2127 if (n->ntype == nJunction) {
2128 j=(Junction *) n;
2129
2130 if (j->predicate != NULL) {
2131 predicate_free(j->predicate);
2132 j->predicate=NULL;
2133 };
2134 for (i=0; i< CLL_k; i++) {
2135 set_free(j->fset[i]);
2136 j->fset[i]=empty;
2137 };
2138 if (j->ftree != NULL) {
2139 Tfree(j->ftree);
2140 j->ftree=NULL;
2141 };
2142 if (j->jtype == EndRule) return;
2143 if (j->jtype != RuleBlk && j->jtype != EndBlk) {
2144 if (j->p2 != NULL && !j->ignore) { /* MR11 */
2145 MR_releaseResourcesUsedInRule(j->p2);
2146 };
2147 };
2148 };
2149 next=MR_advance(n);
2150 MR_releaseResourcesUsedInRule(next);
2151 }
2152
2153 #ifdef __USE_PROTOS
2154 int MR_allPredLeaves(Predicate *p)
2155 #else
2156 int MR_allPredLeaves(p)
2157 Predicate *p;
2158 #endif
2159 {
2160 Predicate *q;
2161
2162 if (p == NULL) return 1;
2163
2164 for (q=p; q != NULL; q=q->right) {
2165 if (q->down != NULL) return 0;
2166 };
2167 return 1;
2168 }
2169
2170 /* make sure it works for the last rule in a file */
2171
2172 #ifdef __USE_PROTOS
2173 int MR_offsetFromRule(Node *n)
2174 #else
2175 int MR_offsetFromRule(n)
2176 Node *n;
2177 #endif
2178 {
2179 Junction *j;
2180 int offset=(-1);
2181
2182 for (j=SynDiag; j != NULL; j=(Junction *)j->p2) {
2183
2184 require (j->ntype == nJunction && j->jtype == RuleBlk,"Not a rule block");
2185
2186 if (n->file < j->file) {
2187 return offset;
2188 };
2189 if (n->file == j->file) {
2190 if (n->line < j->line) {
2191 return (offset < 0) ? 0 : offset;
2192 } else {
2193 offset=n->line - j->line;
2194 if (offset == 0) return 0;
2195 };
2196 };
2197 };
2198 return offset;
2199 }
2200
2201 #define ruleNameMax 50
2202
2203 static char ruleNameStatic1[ruleNameMax];
2204 static char ruleNameStatic2[ruleNameMax+10];
2205
2206 #ifdef __USE_PROTOS
2207 char * MR_ruleNamePlusOffset(Node *n)
2208 #else
2209 char * MR_ruleNamePlusOffset(n)
2210 Node *n;
2211 #endif
2212 {
2213 int offset=MR_offsetFromRule(n);
2214
2215 strncpy(ruleNameStatic1,n->rname,ruleNameMax);
2216 if (offset < 0) {
2217 sprintf(ruleNameStatic2,"%s/?",ruleNameStatic1);
2218 } else {
2219 sprintf(ruleNameStatic2,"%s/%d",ruleNameStatic1,offset+1);
2220 };
2221 return ruleNameStatic2;
2222 }
2223
2224 #ifdef __USE_PROTOS
2225 int MR_max_height_of_tree(Tree *t)
2226 #else
2227 int MR_max_height_of_tree(t)
2228 Tree *t;
2229 #endif
2230 {
2231 int h;
2232 int height=0;
2233 Tree *u;
2234
2235 if (t == NULL) return 0;
2236
2237 require (t->token != ALT && t->token != EpToken,"MR_max_height_of_tree ALT or EpToken");
2238
2239 for (u=t; u != NULL; u=u->right) {
2240 h=MR_max_height_of_tree(u->down)+1;
2241 if (h > height) height=h;
2242 };
2243 return height;
2244 }
2245
2246 #ifdef __USE_PROTOS
2247 int MR_all_leaves_same_height(Tree *t,int depth)
2248 #else
2249 int MR_all_leaves_same_height(t,depth)
2250 Tree *t;
2251 int depth;
2252 #endif
2253 {
2254 if (t == NULL) {
2255 return (depth==0);
2256 };
2257
2258 require (t->token != ALT && t->token != EpToken,"MR_all_leaves_same_height ALT or EpToken");
2259
2260 if (depth == 0) {
2261 return 0;
2262 } else {
2263 if ( ! MR_all_leaves_same_height(t->down,depth-1)) {
2264 return 0;
2265 };
2266 if (t->right == NULL) {
2267 return 1;
2268 } else {
2269 return MR_all_leaves_same_height(t->right,depth);
2270 };
2271 };
2272 }
2273
2274 #ifdef __USE_PROTOS
2275 void MR_projectTreeOntoSet(Tree *tree,int ck,set *ckset)
2276 #else
2277 void MR_projectTreeOntoSet(tree,ck,ckset)
2278 Tree *tree;
2279 int ck;
2280 set *ckset;
2281 #endif
2282 {
2283 if (tree == NULL) return;
2284
2285 require(tree->token != EpToken,"MR_projectTreeOntoSet: EpToken unexpected\n");
2286
2287 MR_projectTreeOntoSet(tree->right,ck,ckset);
2288 if (tree->token == ALT) {
2289 MR_projectTreeOntoSet(tree->down,ck,ckset);
2290 } else {
2291 if (ck > 1) {
2292 MR_projectTreeOntoSet(tree->down,ck-1,ckset);
2293 } else {
2294 set_orel(tree->token,ckset);
2295 };
2296 };
2297 }
2298
2299 #ifdef __USE_PROTOS
2300 int MR_comparePredicates(Predicate *a,Predicate *b)
2301 #else
2302 int MR_comparePredicates(a,b)
2303 Predicate *a;
2304 Predicate *b;
2305 #endif
2306 {
2307 Predicate *p;
2308 Predicate *q;
2309
2310 if (a == b) return 1;
2311 if (a == NULL || b == NULL ) return 0;
2312 if (a->down == NULL && b->down == NULL) {
2313
2314 /* predicate->invert can be set only in the predEntry predicates */
2315 /* thus they are only visible after the predEntry predicates have been "unfolded" */
2316
2317 int sameSource=(a->source == b->source);
2318 int sameInvert= 1 & (1 +a->inverted + b->inverted +
2319 a->source->inverted + b->source->inverted);
2320 int samePredEntry=(a->source->predEntry != NULL
2321 && b->source->predEntry != NULL
2322 && a->source->predEntry == b->source->predEntry);
2323 if (sameInvert && (sameSource || samePredEntry)) {
2324 if (MR_identicalContext(a,b)) {
2325 return 1;
2326 };
2327 };
2328 return 0;
2329 };
2330 if (a->down == NULL || b->down == NULL) return 0;
2331 if (a->expr != b->expr) return 0;
2332
2333 for (p=a->down; p != NULL; p=p->right) {
2334 for (q=b->down; q != NULL; q=q->right) {
2335 if (MR_comparePredicates(p,q)) goto NEXT_P;
2336 };
2337 return 0;
2338 NEXT_P:
2339 continue;
2340 };
2341 return 1;
2342 }
2343
2344 /*
2345 * action->inverted can be set only when a predicate symbol appears in
2346 * a rule: "rule : <<!XXX>>? X". It cannot be set under any
2347 * other circumstances. In particular it cannot be set by
2348 * "#pred NotA !A" or by "#pred Nota <<!A>>?". The first case
2349 * creates a predEntry and the predicate expression of that predEntry
2350 * has inverted set. In the second case, the code for handling "!"
2351 * is only present in buildAction, which is not called by the #pred
2352 * semantic routines, only when a <<...>>? is recognized as part of
2353 * a rule definition.
2354 *
2355 * predicate->inverted can only be set by a predicate created by a #pred
2356 * expression, such as "#pred NotA !A" or "#pred NotXY ! (X && Y) or
2357 * "#pred XbarY !(X && Y)". In particular, it cannot be set by any
2358 * predicate expression occurring under any other circumstances.
2359 * The #pred predicate expresssions are stored with in predEntry->pred
2360 * and do not normally appear anywhere else until the predicates are
2361 * "unfolded" in order to recognize redundancies, conflicts, and
2362 * tautologies.
2363 *
2364 * The unfold routine expands all references to #pred expressions.
2365 *
2366 * The simplifyInvert goes through and propagates the invert bit so that
2367 * all OR and AND nodes are un-inverted.
2368 *
2369 * Note that !(A and B) => (!A or !B)
2370 * !(A or B) => (!A and !B)
2371 *
2372 * MR_unfold() is called to expand predicate symbols by replacing predicates
2373 * that reference predicate entries with the copies of the predicate entries.
2374 * Each reference receives a duplicate of the original. This is necessary
2375 * because the next phase involves simplification and removal of redundant
2376 * predicate nodes. Anyway, the point I'm making is that predicate->invert
2377 * should not be set in any predicate until it has been expanded.
2378 *
2379 * This is a recursive structure, but there is no need for "recursive expansion"
2380 * by which I mean a predicate symbol refers to other predicate symbols which
2381 * must also be expanded.
2382 *
2383 * Recursive expansion is *not* performed by this routine because it is not
2384 * necessary. Expansion of references is performed by predPrimary when
2385 * a new predicate symbol is created by referring to others in the pred expr.
2386 */
2387
2388 #ifdef __USE_PROTOS
2389 Predicate *MR_unfold(Predicate *pred)
2390 #else
2391 Predicate *MR_unfold(pred)
2392 Predicate *pred;
2393 #endif
2394 {
2395 Predicate *result;
2396
2397 if (pred == NULL) return NULL;
2398
2399 pred->right=MR_unfold(pred->right);
2400
2401 if (pred->down == NULL) {
2402 if (pred->source->predEntry != NULL) {
2403 if (pred->source->predEntry->pred == NULL) {
2404 ; /* do nothing */ /* a reference to a literal #pred (perhaps with "!" */
2405 } else {
2406 result=predicate_dup_without_context(pred->source->predEntry->pred);
2407 if (pred->inverted) {
2408 result->inverted=!result->inverted;
2409 };
2410 if (pred->source->inverted) {
2411 result->inverted=!result->inverted;
2412 };
2413 result->right=pred->right;
2414 pred->right=NULL;
2415 predicate_free(pred);
2416 /*** result=MR_unfold(result); *** not necessary */ /* recursive expansion */
2417 return result;
2418 };
2419 } else {
2420 ; /* do nothing */ /* an inline literal predicate */
2421 };
2422 } else {
2423 pred->down=MR_unfold(pred->down);
2424 };
2425 return pred;
2426 }
2427
2428 /* this should be called immediately after MR_unfold() and
2429 at no other times
2430 */
2431
2432 #ifdef __USE_PROTOS
2433 void MR_simplifyInverted(Predicate *pred,int inverted)
2434 #else
2435 void MR_simplifyInverted(pred,inverted)
2436 Predicate *pred;
2437 int inverted;
2438 #endif
2439 {
2440 int newInverted;
2441
2442 if (pred == NULL) return;
2443
2444 MR_simplifyInverted(pred->right,inverted);
2445
2446 newInverted= 1 & (inverted + pred->inverted);
2447
2448 if (pred->down == NULL) {
2449 pred->inverted=newInverted;
2450 } else {
2451 if (newInverted != 0) {
2452 if (pred->expr == PRED_AND_LIST) {
2453 pred->expr=PRED_OR_LIST;
2454 } else {
2455 pred->expr=PRED_AND_LIST;
2456 };
2457 };
2458 pred->inverted=0;
2459 MR_simplifyInverted(pred->down,newInverted);
2460 };
2461 }
2462
2463 /* only remove it from AND and OR nodes, not leaves */
2464
2465 #ifdef __USE_PROTOS
2466 void MR_clearPredEntry(Predicate *p)
2467 #else
2468 void MR_clearPredEntry(p)
2469 Predicate *p;
2470 #endif
2471 {
2472 if (p == NULL) return;
2473 MR_clearPredEntry(p->down);
2474 MR_clearPredEntry(p->right);
2475 if (p->down != NULL) p->predEntry=NULL;
2476 }
2477
2478
2479 #ifdef __USE_PROTOS
2480 void MR_orphanRules(FILE *f)
2481 #else
2482 void MR_orphanRules(f)
2483 FILE *f;
2484 #endif
2485 {
2486 set a;
2487 Junction *p;
2488 unsigned e;
2489 RuleEntry *re;
2490
2491 a=empty;
2492
2493 if (! InfoO) return;
2494
2495 for (p=SynDiag; p!=NULL; p = (Junction *)p->p2) {
2496 if ( (Junction *) (p->end)->p1 == NULL) {
2497 re=(RuleEntry *) hash_get(Rname,p->rname);
2498 require (re != NULL,"RuleEntry == NULL");
2499 set_orel(re->rulenum, &a);
2500 }
2501 }
2502
2503 if (set_deg(a) > 1) {
2504 fprintf(f,"note: Start rules: {");
2505 for (; !set_nil(a); set_rm(e,a)) {
2506 e=set_int(a);
2507 fprintf(f," %s",RulePtr[e]->rname);
2508 };
2509 fprintf(f," }\n");
2510 };
2511 set_free( a );
2512 }
2513
2514 /* merge (X Y) and (X) to create (X) */
2515
2516 static int *mergeChain;
2517 static Tree *mergeTree;
2518
2519 #ifdef __USE_PROTOS
2520 Tree *MR_merge_tree_contexts_client(Tree *t,int chain[])
2521 #else
2522 Tree *MR_merge_tree_contexts_client(t,chain)
2523 Tree *t;
2524 int chain[];
2525 #endif
2526 {
2527 if (t == NULL) return NULL;
2528 if (chain[0] == 0) {
2529 Tree *u=t->right;
2530 t->right=NULL;
2531 Tfree(t);
2532 return MR_merge_tree_contexts_client(u,&chain[0]);
2533 }
2534 if (chain[0] == t->token) {
2535 t->down=MR_merge_tree_contexts_client(t->down,&chain[1]);
2536 };
2537 t->right=MR_merge_tree_contexts_client(t->right,&chain[0]);
2538 return t;
2539 }
2540
2541 #ifdef __USE_PROTOS
2542 void MR_iterateOverTreeContexts(Tree *t,int chain[])
2543 #else
2544 void MR_iterateOverTreeContexts(t,chain)
2545 Tree *t;
2546 int chain[];
2547 #endif
2548 {
2549 if (t == NULL) return;
2550 chain[0]=t->token;
2551 if (t->down != NULL) {
2552 MR_iterateOverTreeContexts(t->down,&chain[1]);
2553 } else {
2554 MR_merge_tree_contexts_client(mergeTree,mergeChain);
2555 };
2556 MR_iterateOverTreeContexts(t->right,&chain[0]);
2557 chain[0]=0;
2558 }
2559
2560 #ifdef __USE_PROTOS
2561 Tree *MR_merge_tree_contexts(Tree *t)
2562 #else
2563 Tree *MR_merge_tree_contexts(t)
2564 Tree *t;
2565 #endif
2566 {
2567 int h=MR_max_height_of_tree(t);
2568
2569 mergeTree=t;
2570 mergeChain=(int *) calloc(h+1,sizeof(int));
2571 require (mergeChain != NULL,"MR_merge_tree_contexts: can't alloc chain");
2572 MR_iterateOverTreeContexts(t,mergeChain);
2573 t=tshrink(t);
2574 t=tflatten(t);
2575 t=tleft_factor(t);
2576 free ( (char *) mergeChain);
2577 mergeChain=NULL;
2578 return t;
2579 }
2580
2581 #ifdef __USE_PROTOS
2582 Tree *MR_compute_pred_tree_context(Predicate *p)
2583 #else
2584 Tree *MR_compute_pred_tree_context(p)
2585 Predicate *p;
2586 #endif
2587 {
2588 Tree *t;
2589
2590 t=MR_compute_pred_tree_ctxXX(p);
2591 MR_merge_tree_contexts(t);
2592 return t;
2593 }
2594
2595 #ifdef __USE_PROTOS
2596 void MR_guardPred_plainSet(ActionNode *anode,Predicate *pred)
2597 #else
2598 void MR_guardPred_plainSet(anode,pred)
2599 ActionNode *anode;
2600 Predicate *pred;
2601 #endif
2602 {
2603 Junction *j;
2604 Predicate *workPred;
2605 set maskSet;
2606
2607 maskSet=empty;
2608
2609 if (!MRhoisting) return;
2610
2611 /* it doesn't really matter whether the predicate has
2612 depth k=1 or k>1 because we're not really looking
2613 at the predicate itself, just the stuff "behind"
2614 the predicate.
2615 */
2616
2617 /* shouldn't have to worry about REACHing off the end
2618 of the rule containing the predicate because the
2619 Rule->end->halt should have been set already by the
2620 the code which handles RuleRef nodes.
2621
2622 We don't want to REACH off the end of the rule because
2623 this would give the "global" follow context rather than
2624 the "local" context.
2625
2626 r1a : (A)? => <<p>>? r2 (A|B)
2627 r1b : (A)? => <<p>>? r2 (A|C)
2628 r2 : ();
2629
2630 For r1a we want follow of predicate = {A B}
2631 we want plainSet = {B}
2632 For r1b we want follow of predicate = {A C}
2633 we want plainSet = {C}
2634 */
2635
2636 require (anode->next->ntype == nJunction,"MR_guardpred_plainSet not Junction");
2637 j=(Junction *)(anode->next);
2638
2639 workPred=predicate_dup_without_context(pred);
2640 workPred->k=1;
2641 workPred->scontext[1]=MR_First(1,j, &(workPred->completionSet) );
2642 MR_complete_predicates(1,workPred);
2643 if (pred->k == 1) {
2644 maskSet=pred->scontext[1];
2645 } else {
2646 MR_projectTreeOntoSet(pred->tcontext,1,&maskSet);
2647 }
2648 pred->plainSet=set_dif(workPred->scontext[1],maskSet);
2649 predicate_free(workPred);
2650 }
2651
2652 /*******************************************************************************/
2653
2654 static Tree * suppressTree;
2655 static int * suppressChain; /* element 0 not used */
2656 static set * suppressSets;
2657 static Node * suppressNode;
2658 static int suppressChainLength;
2659 int MR_SuppressSearch=0;
2660 static int suppressSucceeded;
2661 static Predicate * suppressPredicate;
2662
2663 #ifdef __USE_PROTOS
2664 int MR_isChain(Tree *t)
2665 #else
2666 int MR_isChain(t)
2667 Tree *t;
2668 #endif
2669 {
2670 Tree *u;
2671
2672 for (u=t; u != NULL; u=u->down) {
2673 if (u->right != NULL) return 0;
2674 }
2675 return 1;
2676 }
2677
2678 #ifdef __USE_PROTOS
2679 int MR_suppressK_client(Tree *tree,int tokensInChain[])
2680 #else
2681 int MR_suppressK_client(tree,tokensInChain)
2682 Tree *tree;
2683 int tokensInChain[];
2684 #endif
2685 {
2686 int i;
2687 set *save_fset;
2688 int save_ConstrainSearch;
2689 set incomplete;
2690 Tree *t;
2691
2692 suppressSucceeded=0; /* volatile */
2693
2694 if (suppressSets == NULL) {
2695 suppressSets=(set *) calloc (CLL_k+1,sizeof(set));
2696 require (suppressSets != NULL,"MR_suppressK_client: suppressSets alloc");
2697 };
2698
2699 for (suppressChainLength=1;
2700 tokensInChain[suppressChainLength+1] != 0;
2701 suppressChainLength++) {};
2702
2703 require (suppressChainLength != 0,"MR_suppressK_client: chain empty");
2704
2705 for (i=1 ; i <= suppressChainLength ; i++) {
2706 set_clr(suppressSets[i]);
2707 set_orel( (unsigned) tokensInChain[i],
2708 &suppressSets[i]);
2709 };
2710
2711 save_fset=fset;
2712 save_ConstrainSearch=ConstrainSearch;
2713
2714 fset=suppressSets;
2715
2716 MR_SuppressSearch=1;
2717 MR_AmbSourceSearch=1;
2718 MR_MaintainBackTrace=1;
2719 ConstrainSearch=1;
2720
2721 maxk = suppressChainLength;
2722
2723 incomplete=empty;
2724 t=NULL;
2725
2726 /*** constrain = &(fset[1]); ***/
2727
2728 MR_setConstrainPointer(&(fset[1])); /* MR18 */
2729
2730 MR_pointerStackReset(&MR_BackTraceStack);
2731
2732 TRAV(suppressNode,maxk,&incomplete,t);
2733
2734 Tfree(t);
2735
2736 require (set_nil(incomplete),"MR_suppressK_client TRAV incomplete");
2737 require (MR_BackTraceStack.count == 0,
2738 "MR_suppressK_client: MR_BackTraceStack.count != 0");
2739 set_free(incomplete);
2740
2741 ConstrainSearch=save_ConstrainSearch;
2742 fset=save_fset;
2743
2744 MR_AmbSourceSearch=0;
2745 MR_MaintainBackTrace=0;
2746 MR_SuppressSearch=0;
2747 return suppressSucceeded;
2748 }
2749
2750 #ifdef __USE_PROTOS
2751 Tree * MR_iterateOverTreeSuppressK(Tree *t,int chain[])
2752 #else
2753 Tree * MR_iterateOverTreeSuppressK(t,chain)
2754 Tree *t;
2755 int chain[];
2756 #endif
2757 {
2758 if (t == NULL) return NULL;
2759 t->right=MR_iterateOverTreeSuppressK(t->right,&chain[0]);
2760 chain[0]=t->token;
2761 if (t->down != NULL) {
2762 t->down=MR_iterateOverTreeSuppressK(t->down,&chain[1]);
2763 if (t->down == NULL) {
2764 Tree *u=t->right;
2765 t->right=NULL;
2766 Tfree(t);
2767 chain[0]=0;
2768 return u;
2769 };
2770 } else {
2771 MR_suppressK_client(suppressTree,suppressChain);
2772 if (suppressSucceeded) {
2773 Tree *u=t->right;
2774 t->right=NULL;
2775 Tfree(t);
2776 chain[0]=0;
2777 return u;
2778 };
2779 };
2780 chain[0]=0;
2781 return t;
2782 }
2783
2784 /* @@@ */
2785
2786 #ifdef __USE_PROTOS
2787 Predicate * MR_suppressK(Node *j,Predicate *p)
2788 #else
2789 Predicate * MR_suppressK(j,p)
2790 Node *j;
2791 Predicate *p;
2792 #endif
2793 {
2794 Predicate *result;
2795 int guardPred=0;
2796 int ampersandPred=0;
2797 Node *nodePrime;
2798
2799 if (! MRhoistingk) {
2800 return p;
2801 }
2802
2803 if (! MRhoisting) return p;
2804 if (CLL_k == 1) return p;
2805
2806 if (suppressChain == NULL) {
2807 suppressChain=(int *) calloc(CLL_k+2,sizeof(int));
2808 require (suppressChain != NULL,"MR_suppressK: can't allocate chain");
2809 }
2810
2811 if (p == NULL) return NULL;
2812
2813 if (j->ntype == nJunction) {
2814 nodePrime=(Node *) MR_junctionWithoutP2( (Junction *) j);
2815 } else {
2816 nodePrime=j;
2817 };
2818
2819 p->down=MR_suppressK(j,p->down);
2820 p->right=MR_suppressK(j,p->right);
2821 if (p->down != NULL) {
2822 result=p;
2823 goto EXIT;
2824 };
2825 if (p->k == 1) {
2826 result=p;
2827 goto EXIT;
2828 };
2829
2830 if (p->source != NULL) {
2831 if (p->source->guardpred != NULL) guardPred=1;
2832 if (p->source->ampersandPred != NULL) ampersandPred=1;
2833 }
2834
2835 suppressPredicate=p;
2836 suppressNode=nodePrime; /* was j*/
2837
2838 suppressTree=p->tcontext;
2839
2840 if (guardPred || ampersandPred) {
2841 p->tcontext=MR_iterateOverTreeSuppressK(suppressTree,&suppressChain[1]);
2842 if (p->tcontext == NULL) {
2843 predicate_free(p);
2844 result=NULL;
2845 goto EXIT;
2846 };
2847 } else {
2848 if (MR_isChain(p->tcontext)) {
2849 p->tcontext=MR_iterateOverTreeSuppressK(suppressTree,&suppressChain[1]);
2850 if (p->tcontext == NULL) {
2851 predicate_free(p);
2852 result=NULL;
2853 goto EXIT;
2854 };
2855 }
2856 }
2857 result=p;
2858 EXIT:
2859 return result;
2860 }
2861
2862 #ifdef __USE_PROTOS
2863 void MR_suppressSearchReport(void)
2864 #else
2865 void MR_suppressSearchReport()
2866 #endif
2867 {
2868 int i;
2869 Node *p;
2870 TokNode *tn;
2871 int depth;
2872 set setAnd;
2873
2874 /* number of tokens in back trace stack matches length of chain */
2875
2876 depth=0;
2877 for (i=0; i < MR_BackTraceStack.count ; i++) {
2878 p=(Node *) MR_BackTraceStack.data[i];
2879 if (p->ntype == nToken) depth++;
2880 };
2881
2882 require (depth == suppressChainLength,"depth > suppressChainLength");
2883
2884 /* token codes match chain */
2885
2886 depth=0;
2887 for (i=0; i < MR_BackTraceStack.count ; i++) {
2888 p=(Node *) MR_BackTraceStack.data[i];
2889 if (p->ntype != nToken) continue;
2890 tn=(TokNode *) p;
2891 depth++;
2892 if (set_nil(tn->tset)) {
2893 require(set_el( (unsigned) tn->token,fset[depth]),
2894 "MR_suppressSearchReport: no match to #token in chain");
2895 } else {
2896 setAnd=set_and(fset[depth],tn->tset);
2897 require(!set_nil(setAnd),
2898 "MR_suppressSearchReport: no match to #token set in chain");
2899 set_free(setAnd);
2900 };
2901 };
2902
2903 /* have a match - now remove it from the predicate */
2904
2905 suppressSucceeded=1;
2906
2907 if (suppressSucceeded) {
2908 fprintf(output,"\n");
2909 fprintf(output,"#if 0\n");
2910 fprintf(output,"\n");
2911 fprintf(output,"Part (or all) of predicate with depth > 1 suppressed by ");
2912 fprintf(output,"alternative without predicate\n\n");
2913 MR_dumpPred(suppressPredicate,1);
2914 fprintf(output,"The token sequence which is suppressed:");
2915 fprintf(output," (");
2916 for (i=1; i <= suppressChainLength; i++) {
2917 fprintf(output," %s",TerminalString(suppressChain[i]));
2918 };
2919 fprintf(output," )\n");
2920 fprintf(output,"The sequence of references which generate that sequence of tokens:\n\n");
2921
2922 MR_backTraceDumpItemReset();
2923
2924 for (i=0; i < MR_BackTraceStack.count ; i++) {
2925 MR_backTraceDumpItem(output,0,(Node *) MR_BackTraceStack.data[i]);
2926 };
2927 fprintf(output,"\n");
2928 fprintf(output,"#endif\n");
2929 }
2930 }
2931
2932 #ifdef __USE_PROTOS
2933 void MR_markCompromisedRule(Node *n)
2934 #else
2935 void MR_markCompromisedRule(n)
2936 Node *n;
2937 #endif
2938 {
2939 RuleEntry *q;
2940 Node *mark=NULL;
2941 Junction *j;
2942
2943 if (n->ntype == nRuleRef) {
2944 mark=(Node *) MR_ruleReferenced( (RuleRefNode *) n);
2945 } else if (n->ntype == nToken) {
2946 mark=n;
2947 } else if (n->ntype == nJunction) {
2948 j=(Junction *)n;
2949 switch (j->jtype) {
2950 case aOptBlk:
2951 case aLoopBlk:
2952 case RuleBlk:
2953 case EndRule:
2954 case aPlusBlk:
2955 case aLoopBegin:
2956 mark=n;
2957 break;
2958 default:
2959 break;
2960 };
2961 }
2962
2963 if (mark == NULL) return;
2964
2965 require (RulePtr != NULL,"RulePtr not initialized");
2966
2967 q = (RuleEntry *) hash_get(Rname,mark->rname);
2968 require (q != NULL,"RuleEntry not found");
2969 set_orel(q->rulenum,&MR_CompromisedRules);
2970 }
2971
2972 #ifdef __USE_PROTOS
2973 void MR_alphaBetaTraceReport(void)
2974 #else
2975 void MR_alphaBetaTraceReport()
2976 #endif
2977 {
2978 int i;
2979
2980 if (! AlphaBetaTrace) return;
2981
2982 MR_AlphaBetaMessageCount++;
2983
2984 fprintf(output,"\n");
2985 fprintf(output,"#if 0\n");
2986 fprintf(output,"\n");
2987 fprintf(output,"Trace of references leading to attempt to compute the follow set of\n");
2988 fprintf(output,"alpha in an \"(alpha)? beta\" block. It is not possible for antlr to\n");
2989 fprintf(output,"compute this follow set because it is not known what part of beta has\n");
2990 fprintf(output,"already been matched by alpha and what part remains to be matched.\n");
2991 fprintf(output,"\n");
2992 fprintf(output,"Rules which make use of the incorrect follow set will also be incorrect\n");
2993 fprintf(output,"\n");
2994
2995 MR_backTraceDumpItemReset();
2996
2997 for (i=0; i < MR_BackTraceStack.count ; i++) {
2998 MR_backTraceDumpItem(output,0,(Node *) MR_BackTraceStack.data[i]);
2999 if (i < MR_BackTraceStack.count-1) {
3000 MR_markCompromisedRule( (Node *) MR_BackTraceStack.data[i]);
3001 };
3002 };
3003 fprintf(output,"\n");
3004 fprintf(output,"#endif\n");
3005 }
3006
3007 #ifdef __USE_PROTOS
3008 void MR_dumpRuleSet(set s)
3009 #else
3010 void MR_dumpRuleSet(s)
3011 set s;
3012 #endif
3013 {
3014 unsigned *cursor;
3015 unsigned *origin=set_pdq(s);
3016
3017 require(origin != NULL,"set_pdq failed");
3018
3019 if (RulePtr == NULL) {
3020 fprintf(stderr,"RulePtr[] not yet initialized");
3021 } else {
3022 for (cursor=origin; *cursor != nil ; cursor++) {
3023 /**** if (cursor != origin) fprintf(stderr,","); ****/
3024 fprintf(stderr," %s",RulePtr[*cursor]->rname);
3025 fprintf(stderr,"\n");
3026 };
3027 free( (char *) origin);
3028 };
3029 }
+0
-1387
contrib/pccts/antlr/parser.dlg less more
0 <<
1 /* parser.dlg -- DLG Description of scanner
2 *
3 * Generated from: ./antlr.g
4 *
5 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
6 * Purdue University Electrical Engineering
7 * With AHPCRC, University of Minnesota
8 * ANTLR Version 1.33MR33
9 */
10
11 #define ANTLR_VERSION 13333
12 #include "pcctscfg.h"
13 #include "pccts_stdio.h"
14
15 #include "pcctscfg.h"
16 #include "set.h"
17 #include <ctype.h>
18 #include "syn.h"
19 #include "hash.h"
20 #include "generic.h"
21 #define zzcr_attr(attr,tok,t)
22 #include "antlr.h"
23 #include "tokens.h"
24 #include "dlgdef.h"
25 LOOKAHEAD
26
27 void
28 #ifdef __USE_PROTOS
29 zzerraction(void)
30 #else
31 zzerraction()
32 #endif
33 {
34 (*zzerr)("invalid token");
35 zzadvance();
36 zzskip();
37 }
38 >>
39
40 <<%%lexaction
41
42 /* maintained, but not used for now */
43 set AST_nodes_refd_in_actions = set_init;
44 int inAlt = 0;
45 set attribsRefdFromAction = set_init; /* MR20 */
46 int UsedOldStyleAttrib = 0;
47 int UsedNewStyleLabel = 0;
48 #ifdef __USE_PROTOS
49 char *inline_set(char *);
50 #else
51 char *inline_set();
52 #endif
53
54 /* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */
55 /* MR1 in DLG action */
56
57 int tokenActionActive=0; /* MR1 */
58
59
60 >>
61
62 <<%%lexaction
63
64
65 static char *
66 #ifdef __USE_PROTOS
67 getFileNameFromTheLineInfo(char *toStr, char *fromStr)
68 #else
69 getFileNameFromTheLineInfo(toStr, fromStr)
70 char *toStr, *fromStr;
71 #endif
72 {
73 int i, j, k;
74
75 if (!fromStr || !toStr) return toStr;
76
77 /* find the first " */
78
79 for (i=0;
80 (i<MaxFileName) &&
81 (fromStr[i] != '\n') &&
82 (fromStr[i] != '\r') &&
83 (fromStr[i] != '\"');
84 i++) /* nothing */ ;
85
86 if ( (i == MaxFileName) ||
87 (fromStr[i] == '\n') ||
88 (fromStr[i] == '\r') ) {
89 return toStr;
90 }
91
92 /* find the second " */
93
94 for (j=i+1;
95 (j<MaxFileName) &&
96 (fromStr[j] != '\n') &&
97 (fromStr[j] != '\r') &&
98 (fromStr[j] != '\"');
99 j++) /* nothing */ ;
100
101 if ((j == MaxFileName) ||
102 (fromStr[j] == '\n') ||
103 (fromStr[j] == '\r') ) {
104 return toStr;
105 }
106
107 /* go back until the last / or \ */
108
109 for (k=j-1;
110 (fromStr[k] != '\"') &&
111 (fromStr[k] != '/') &&
112 (fromStr[k] != '\\');
113 k--) /* nothing */ ;
114
115 /* copy the string after " / or \ into toStr */
116
117 for (i=k+1; fromStr[i] != '\"'; i++) {
118 toStr[i-k-1] = fromStr[i];
119 }
120
121 toStr[i-k-1] = '\0';
122
123 return toStr;
124 }
125
126 /* MR14 end of a block to support #line in antlr source code */
127
128
129 >>
130
131 <<%%lexaction
132
133 #ifdef __USE_PROTOS
134 void mark_label_used_in_sem_pred(LabelEntry *le) /* MR10 */
135 #else
136 void mark_label_used_in_sem_pred(le) /* MR10 */
137 LabelEntry *le;
138 #endif
139 {
140 TokNode *tn;
141 require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken");
142 tn=(TokNode *)le->elem;
143 require (tn->label != 0,"mark_label_used... TokNode has no label");
144 tn->label_used_in_semantic_pred=1;
145 }
146 >>
147
148
149 %%START
150
151 @
152 <<
153 NLA = Eof;
154 /* L o o k F o r A n o t h e r F i l e */
155 {
156 FILE *new_input;
157 new_input = NextFile();
158 if ( new_input == NULL ) { NLA=Eof; return; }
159 fclose( input );
160 input = new_input;
161 zzrdstream( input );
162 zzskip(); /* Skip the Eof (@) char i.e continue */
163 }
164 >>
165
166 [\t\ ]+
167 <<
168 NLA = 76;
169 zzskip();
170 >>
171
172 \n|\r|\r\n
173 <<
174 NLA = 77;
175 zzline++; zzskip();
176 >>
177
178 \[
179 <<
180 NLA = 78;
181 zzmode(ACTIONS); zzmore();
182 istackreset();
183 pushint(']');
184 >>
185
186 \<\<
187 <<
188 NLA = 79;
189 action_file=CurFile; action_line=zzline;
190 zzmode(ACTIONS); zzmore();
191 list_free(&CurActionLabels,0); /* MR10 */
192 numericActionLabel=0; /* MR10 */
193 istackreset();
194 pushint('>');
195 >>
196
197 \"
198 <<
199 NLA = 80;
200 zzmode(STRINGS); zzmore();
201 >>
202
203 /\*
204 <<
205 NLA = 81;
206 zzmode(COMMENTS); zzskip();
207 >>
208
209 \*/
210 <<
211 NLA = 82;
212 warn("Missing /*; found dangling */"); zzskip();
213 >>
214
215 //
216 <<
217 NLA = 83;
218 zzmode(CPP_COMMENTS); zzskip();
219 >>
220
221 #line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)
222 <<
223 NLA = 84;
224
225 zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();
226 getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);
227 >>
228
229 #line ~[\n\r]* (\n|\r|\r\n)
230 <<
231 NLA = 85;
232
233 zzline++; zzmore();
234 >>
235
236 \>\>
237 <<
238 NLA = 86;
239 warn("Missing <<; found dangling \>\>"); zzskip();
240 >>
241
242 .
243 <<
244 NLA = WildCard;
245 >>
246
247 \@
248 <<
249 NLA = 88;
250 FoundException = 1; /* MR6 */
251 FoundAtOperator = 1;
252 >>
253
254 {\\}#pragma
255 <<
256 NLA = Pragma;
257 >>
258
259 {\\}#FirstSetSymbol
260 <<
261 NLA = FirstSetSymbol;
262 >>
263
264 {\\}#header
265 <<
266 NLA = 94;
267 >>
268
269 {\\}#first
270 <<
271 NLA = 95;
272 >>
273
274 {\\}#parser
275 <<
276 NLA = 96;
277 >>
278
279 {\\}#tokdefs
280 <<
281 NLA = 97;
282 >>
283
284 \}
285 <<
286 NLA = 98;
287 >>
288
289 class
290 <<
291 NLA = 99;
292 >>
293
294 \{
295 <<
296 NLA = 102;
297 >>
298
299 !
300 <<
301 NLA = 103;
302 >>
303
304 \<
305 <<
306 NLA = 104;
307 >>
308
309 \>
310 <<
311 NLA = 105;
312 >>
313
314 :
315 <<
316 NLA = 106;
317 >>
318
319 ;
320 <<
321 NLA = 107;
322 >>
323
324 {\\}#lexaction
325 <<
326 NLA = 108;
327 >>
328
329 {\\}#lexmember
330 <<
331 NLA = 109;
332 >>
333
334 {\\}#lexprefix
335 <<
336 NLA = 110;
337 >>
338
339 {\\}#pred
340 <<
341 NLA = 111;
342 >>
343
344 \|\|
345 <<
346 NLA = 112;
347 >>
348
349 &&
350 <<
351 NLA = 113;
352 >>
353
354 \(
355 <<
356 NLA = 114;
357 >>
358
359 \)
360 <<
361 NLA = 115;
362 >>
363
364 {\\}#lexclass
365 <<
366 NLA = 116;
367 >>
368
369 {\\}#errclass
370 <<
371 NLA = 117;
372 >>
373
374 {\\}#tokclass
375 <<
376 NLA = 118;
377 >>
378
379 ..
380 <<
381 NLA = 119;
382 >>
383
384 {\\}#token
385 <<
386 NLA = 120;
387 >>
388
389 =
390 <<
391 NLA = 121;
392 >>
393
394 [0-9]+
395 <<
396 NLA = 122;
397 >>
398
399 \|
400 <<
401 NLA = 123;
402 >>
403
404 \~
405 <<
406 NLA = 124;
407 >>
408
409 ^
410 <<
411 NLA = 125;
412 >>
413
414 approx
415 <<
416 NLA = 126;
417 >>
418
419 LL\(1\)
420 <<
421 NLA = 127;
422 >>
423
424 LL\(2\)
425 <<
426 NLA = 128;
427 >>
428
429 \*
430 <<
431 NLA = 129;
432 >>
433
434 \+
435 <<
436 NLA = 130;
437 >>
438
439 ?
440 <<
441 NLA = 131;
442 >>
443
444 =>
445 <<
446 NLA = 132;
447 >>
448
449 exception
450 <<
451 NLA = 133;
452 >>
453
454 default
455 <<
456 NLA = 134;
457 >>
458
459 catch
460 <<
461 NLA = 135;
462 >>
463
464 [a-z] [A-Za-z0-9_]*
465 <<
466 NLA = NonTerminal;
467
468 while ( zzchar==' ' || zzchar=='\t' ) {
469 zzadvance();
470 }
471 if ( zzchar == ':' && inAlt ) NLA = LABEL;
472 >>
473
474 [A-Z] [A-Za-z0-9_]*
475 <<
476 NLA = TokenTerm;
477
478 while ( zzchar==' ' || zzchar=='\t' ) {
479 zzadvance();
480 }
481 if ( zzchar == ':' && inAlt ) NLA = LABEL;
482 >>
483
484 {\\}#[A-Za-z0-9_]*
485 <<
486 NLA = 136;
487 warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip();
488 >>
489
490
491 %%STRINGS
492
493 @
494 <<
495 NLA = Eof;
496 >>
497
498 \"
499 <<
500 NLA = QuotedTerm;
501 zzmode(START);
502 >>
503
504 \n|\r|\r\n
505 <<
506 NLA = 3;
507
508 zzline++;
509 warn("eoln found in string");
510 zzskip();
511 >>
512
513 \\(\n|\r|\r\n)
514 <<
515 NLA = 4;
516 zzline++; zzmore();
517 >>
518
519 \\~[]
520 <<
521 NLA = 5;
522 zzmore();
523 >>
524
525 ~[\n\r\"\\]+
526 <<
527 NLA = 6;
528 zzmore();
529 >>
530
531
532 %%ACTION_STRINGS
533
534 @
535 <<
536 NLA = Eof;
537 >>
538
539 \"
540 <<
541 NLA = 7;
542 zzmode(ACTIONS); zzmore();
543 >>
544
545 \n|\r|\r\n
546 <<
547 NLA = 8;
548
549 zzline++;
550 warn("eoln found in string (in user action)");
551 zzskip();
552 >>
553
554 \\(\n|\r|\r\n)
555 <<
556 NLA = 9;
557 zzline++; zzmore();
558 >>
559
560 \\~[]
561 <<
562 NLA = 10;
563 zzmore();
564 >>
565
566 ~[\n\r\"\\]+
567 <<
568 NLA = 11;
569 zzmore();
570 >>
571
572
573 %%ACTION_CHARS
574
575 @
576 <<
577 NLA = Eof;
578 >>
579
580 '
581 <<
582 NLA = 12;
583 zzmode(ACTIONS); zzmore();
584 >>
585
586 \n|\r|\r\n
587 <<
588 NLA = 13;
589
590 zzline++;
591 warn("eoln found in char literal (in user action)");
592 zzskip();
593 >>
594
595 \\~[]
596 <<
597 NLA = 14;
598 zzmore();
599 >>
600
601 ~[\n\r'\\]+
602 <<
603 NLA = 15;
604 zzmore();
605 >>
606
607
608 %%ACTION_COMMENTS
609
610 @
611 <<
612 NLA = Eof;
613 >>
614
615 \*/
616 <<
617 NLA = 16;
618 zzmode(ACTIONS); zzmore();
619 >>
620
621 \*
622 <<
623 NLA = 17;
624 zzmore();
625 >>
626
627 \n|\r|\r\n
628 <<
629 NLA = 18;
630 zzline++; zzmore(); DAWDLE;
631 >>
632
633 ~[\n\r\*]+
634 <<
635 NLA = 19;
636 zzmore();
637 >>
638
639
640 %%TOK_DEF_COMMENTS
641
642 @
643 <<
644 NLA = Eof;
645 >>
646
647 \*/
648 <<
649 NLA = 20;
650 zzmode(PARSE_ENUM_FILE);
651 zzmore();
652 >>
653
654 \*
655 <<
656 NLA = 21;
657 zzmore();
658 >>
659
660 \n|\r|\r\n
661 <<
662 NLA = 22;
663 zzline++; zzmore(); DAWDLE;
664 >>
665
666 ~[\n\r\*]+
667 <<
668 NLA = 23;
669 zzmore();
670 >>
671
672
673 %%TOK_DEF_CPP_COMMENTS
674
675 @
676 <<
677 NLA = Eof;
678 >>
679
680 \n|\r|\r\n
681 <<
682 NLA = 24;
683 zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE;
684 >>
685
686 ~[\n\r]+
687 <<
688 NLA = 25;
689 zzskip();
690 >>
691
692
693 %%ACTION_CPP_COMMENTS
694
695 @
696 <<
697 NLA = Eof;
698 >>
699
700 \n|\r|\r\n
701 <<
702 NLA = 26;
703 zzline++; zzmode(ACTIONS); zzmore(); DAWDLE;
704 >>
705
706 ~[\n\r]+
707 <<
708 NLA = 27;
709 zzmore();
710 >>
711
712
713 %%CPP_COMMENTS
714
715 @
716 <<
717 NLA = Eof;
718 >>
719
720 \n|\r|\r\n
721 <<
722 NLA = 28;
723 zzline++; zzmode(START); zzskip(); DAWDLE;
724 >>
725
726 ~[\n\r]+
727 <<
728 NLA = 29;
729 zzskip();
730 >>
731
732
733 %%COMMENTS
734
735 @
736 <<
737 NLA = Eof;
738 >>
739
740 \*/
741 <<
742 NLA = 30;
743 zzmode(START); zzskip();
744 >>
745
746 \*
747 <<
748 NLA = 31;
749 zzskip();
750 >>
751
752 \n|\r|\r\n
753 <<
754 NLA = 32;
755 zzline++; zzskip(); DAWDLE;
756 >>
757
758 ~[\n\r\*]+
759 <<
760 NLA = 33;
761 zzskip();
762 >>
763
764
765 %%ACTIONS
766
767 @
768 <<
769 NLA = Eof;
770 >>
771
772 \>\>
773 <<
774 NLA = Action;
775 /* these do not nest */
776 zzmode(START);
777 NLATEXT[0] = ' ';
778 NLATEXT[1] = ' ';
779 zzbegexpr[0] = ' ';
780 zzbegexpr[1] = ' ';
781 if ( zzbufovf ) {
782 err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));
783 }
784
785 /* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */
786 /* MR1 in DLG action */
787 /* MR1 Doesn't matter what kind of action it is - reset*/
788
789 tokenActionActive=0; /* MR1 */
790 >>
791
792 \>\>?
793 <<
794 NLA = Pred;
795 /* these do not nest */
796 zzmode(START);
797 NLATEXT[0] = ' ';
798 NLATEXT[1] = ' ';
799 zzbegexpr[0] = '\0';
800 if ( zzbufovf ) {
801 err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));
802 };
803 #ifdef __cplusplus__
804 /* MR10 */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);
805 #else
806 #ifdef __STDC__
807 /* MR10 */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);
808 #else
809 #ifdef __USE_PROTOS
810 /* MRxx */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);
811 #else
812 /* MR10 */ list_apply(CurActionLabels,mark_label_used_in_sem_pred);
813 #endif
814 #endif
815 #endif
816 >>
817
818 \]
819 <<
820 NLA = PassAction;
821 if ( topint() == ']' ) {
822 popint();
823 if ( istackempty() ) /* terminate action */
824 {
825 zzmode(START);
826 NLATEXT[0] = ' ';
827 zzbegexpr[0] = ' ';
828 if ( zzbufovf ) {
829 err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));
830 }
831 }
832 else {
833 /* terminate $[..] and #[..] */
834 if ( GenCC ) zzreplstr("))");
835 else zzreplstr(")");
836 zzmore();
837 }
838 }
839 else if ( topint() == '|' ) { /* end of simple [...] */
840 popint();
841 zzmore();
842 }
843 else zzmore();
844 >>
845
846 consumeUntil\( [\ \t]* \{~[\}]+\} [\ \t]* \)
847 <<
848 NLA = 37;
849
850 zzmore();
851 zzreplstr(inline_set(zzbegexpr+
852 strlen("consumeUntil(")));
853 >>
854
855 consumeUntil\( ~[\)]+ \)
856 <<
857 NLA = 38;
858 zzmore();
859 >>
860
861 \n|\r|\r\n
862 <<
863 NLA = 39;
864 zzline++; zzmore(); DAWDLE;
865 >>
866
867 \>
868 <<
869 NLA = 40;
870 zzmore();
871 >>
872
873 $
874 <<
875 NLA = 41;
876 zzmore();
877 >>
878
879 $$
880 <<
881 NLA = 42;
882 if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}
883 else err("$$ use invalid in C++ mode");
884 >>
885
886 $\[\]
887 <<
888 NLA = 43;
889 if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}
890 else err("$[] use invalid in C++ mode");
891 >>
892
893 $\[
894 <<
895 NLA = 44;
896
897 pushint(']');
898 if ( !GenCC ) zzreplstr("zzconstr_attr(");
899 else err("$[..] use invalid in C++ mode");
900 zzmore();
901 >>
902
903 $[0-9]+
904 <<
905 NLA = 45;
906 {
907 static char buf[100];
908 numericActionLabel=1; /* MR10 */
909 if ( strlen(zzbegexpr)>(size_t)85 )
910 fatal("$i attrib ref too big");
911 set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
912 if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",
913 BlkLevel-1,zzbegexpr+1);
914 else sprintf(buf,"_t%d%s",
915 BlkLevel-1,zzbegexpr+1);
916 zzreplstr(buf);
917 zzmore();
918 UsedOldStyleAttrib = 1;
919 if ( UsedNewStyleLabel )
920 err("cannot mix old-style $i with new-style labels");
921 }
922 >>
923
924 $[0-9]+.
925 <<
926 NLA = 46;
927 {
928 static char buf[100];
929 numericActionLabel=1; /* MR10 */
930 if ( strlen(zzbegexpr)>(size_t)85 )
931 fatal("$i.field attrib ref too big");
932 zzbegexpr[strlen(zzbegexpr)-1] = ' ';
933 set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
934 if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",
935 BlkLevel-1,zzbegexpr+1);
936 else sprintf(buf,"_t%d%s.",
937 BlkLevel-1,zzbegexpr+1);
938 zzreplstr(buf);
939 zzmore();
940 UsedOldStyleAttrib = 1;
941 if ( UsedNewStyleLabel )
942 err("cannot mix old-style $i with new-style labels");
943 }
944 >>
945
946 $[0-9]+.[0-9]+
947 <<
948 NLA = 47;
949 {
950 static char buf[100];
951 static char i[20], j[20];
952 char *p,*q;
953 numericActionLabel=1; /* MR10 */
954 if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big");
955 for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {
956 if ( q == &i[20] )
957 fatalFL("i of $i.j attrib ref too big",
958 FileStr[CurFile], zzline );
959 *q++ = *p;
960 }
961 *q = '\0';
962 for (p++, q= &j[0]; *p!='\0'; p++) {
963 if ( q == &j[20] )
964 fatalFL("j of $i.j attrib ref too big",
965 FileStr[CurFile], zzline );
966 *q++ = *p;
967 }
968 *q = '\0';
969 if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);
970 else sprintf(buf,"_t%s%s",i,j);
971 zzreplstr(buf);
972 zzmore();
973 UsedOldStyleAttrib = 1;
974 if ( UsedNewStyleLabel )
975 err("cannot mix old-style $i with new-style labels");
976 }
977 >>
978
979 $[_a-zA-Z][_a-zA-Z0-9]*
980 <<
981 NLA = 48;
982 { static char buf[300]; LabelEntry *el;
983 zzbegexpr[0] = ' ';
984 if ( CurRule != NULL &&
985 strcmp(CurRule, &zzbegexpr[1])==0 ) {
986 if ( !GenCC ) zzreplstr("zzaRet");
987 }
988 else if ( CurRetDef != NULL &&
989 strmember(CurRetDef, &zzbegexpr[1])) {
990 if ( hasMultipleOperands( CurRetDef ) ) {
991 require (strlen(zzbegexpr)<=(size_t)285,
992 "$retval attrib ref too big");
993 sprintf(buf,"_retv.%s",&zzbegexpr[1]);
994 zzreplstr(buf);
995 }
996 else zzreplstr("_retv");
997 }
998 else if ( CurParmDef != NULL &&
999 strmember(CurParmDef, &zzbegexpr[1])) {
1000 ;
1001 }
1002 else if ( Elabel==NULL ) {
1003 { err("$-variables in actions outside of rules are not allowed"); }
1004 } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) {
1005 /* MR10 */
1006 /* MR10 */ /* element labels might exist without an elem when */
1007 /* MR10 */ /* it is a forward reference (to a rule) */
1008 /* MR10 */
1009 /* MR10 */ if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) )
1010 /* MR10 */ { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); }
1011 /* MR10 */
1012 /* MR10 */ if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) {
1013 /* MR10 */ err("You can no longer use attributes returned by rules when also using ASTs");
1014 /* MR10 */ err(" Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...\>\>\")");
1015 /* MR10 */ };
1016 /* MR10 */
1017 /* MR10 */ /* keep track of <<... $label ...>> for semantic predicates in guess mode */
1018 /* MR10 */ /* element labels contain pointer to the owners node */
1019 /* MR10 */
1020 /* MR10 */ if (el->elem != NULL && el->elem->ntype == nToken) {
1021 /* MR10 */ list_add(&CurActionLabels,el);
1022 /* MR10 */ };
1023 }
1024 else
1025 warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1]));
1026 }
1027 zzmore();
1028 >>
1029
1030 #0
1031 <<
1032 NLA = 49;
1033 zzreplstr("(*_root)"); zzmore(); chkGTFlag();
1034 >>
1035
1036 #\[\]
1037 <<
1038 NLA = 50;
1039 if ( GenCC ) {
1040 if (NewAST) zzreplstr("(newAST)");
1041 else zzreplstr("(new AST)");}
1042 else {zzreplstr("zzastnew()");} zzmore();
1043 chkGTFlag();
1044 >>
1045
1046 #\(\)
1047 <<
1048 NLA = 51;
1049 zzreplstr("NULL"); zzmore(); chkGTFlag();
1050 >>
1051
1052 #[0-9]+
1053 <<
1054 NLA = 52;
1055 {
1056 static char buf[100];
1057 if ( strlen(zzbegexpr)>(size_t)85 )
1058 fatal("#i AST ref too big");
1059 if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);
1060 else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);
1061 zzreplstr(buf);
1062 zzmore();
1063 set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);
1064 chkGTFlag();
1065 }
1066 >>
1067
1068 #line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)
1069 <<
1070 NLA = 53;
1071
1072 zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();
1073 getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);
1074 >>
1075
1076 #line ~[\n\r]* (\n|\r|\r\n)
1077 <<
1078 NLA = 54;
1079
1080 zzline++; zzmore();
1081 >>
1082
1083 #[_a-zA-Z][_a-zA-Z0-9]*
1084 <<
1085 NLA = 55;
1086
1087 if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||
1088 strcmp(zzbegexpr, "#if")==0 ||
1089 strcmp(zzbegexpr, "#else")==0 ||
1090 strcmp(zzbegexpr, "#endif")==0 ||
1091 strcmp(zzbegexpr, "#ifndef")==0 ||
1092 strcmp(zzbegexpr, "#define")==0 ||
1093 strcmp(zzbegexpr, "#pragma")==0 ||
1094 strcmp(zzbegexpr, "#undef")==0 ||
1095 strcmp(zzbegexpr, "#import")==0 ||
1096 strcmp(zzbegexpr, "#line")==0 ||
1097 strcmp(zzbegexpr, "#include")==0 ||
1098 strcmp(zzbegexpr, "#error")==0) )
1099 {
1100 static char buf[100];
1101 sprintf(buf, "%s_ast", zzbegexpr+1);
1102 /* MR27 */ list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1));
1103 zzreplstr(buf);
1104 chkGTFlag();
1105 }
1106 zzmore();
1107 >>
1108
1109 #\[
1110 <<
1111 NLA = 56;
1112
1113 pushint(']');
1114 if ( GenCC ) {
1115 if (NewAST) zzreplstr("(newAST(");
1116 else zzreplstr("(new AST("); }
1117 else zzreplstr("zzmk_ast(zzastnew(),");
1118 zzmore();
1119 chkGTFlag();
1120 >>
1121
1122 #\(
1123 <<
1124 NLA = 57;
1125
1126 pushint('}');
1127 if ( GenCC ) {
1128 if (tmakeInParser) {
1129 zzreplstr("tmake(");
1130 }
1131 else {
1132 zzreplstr("ASTBase::tmake(");
1133 }
1134 }
1135 else {
1136 zzreplstr("zztmake(");
1137 }
1138 zzmore();
1139 chkGTFlag();
1140 >>
1141
1142 #
1143 <<
1144 NLA = 58;
1145 zzmore();
1146 >>
1147
1148 \)
1149 <<
1150 NLA = 59;
1151
1152 if ( istackempty() )
1153 zzmore();
1154 else if ( topint()==')' ) {
1155 popint();
1156 }
1157 else if ( topint()=='}' ) {
1158 popint();
1159 /* terminate #(..) */
1160 zzreplstr(", NULL)");
1161 }
1162 zzmore();
1163 >>
1164
1165 \[
1166 <<
1167 NLA = 60;
1168
1169 pushint('|'); /* look for '|' to terminate simple [...] */
1170 zzmore();
1171 >>
1172
1173 \(
1174 <<
1175 NLA = 61;
1176
1177 pushint(')');
1178 zzmore();
1179 >>
1180
1181 \\\]
1182 <<
1183 NLA = 62;
1184 zzreplstr("]"); zzmore();
1185 >>
1186
1187 \\\)
1188 <<
1189 NLA = 63;
1190 zzreplstr(")"); zzmore();
1191 >>
1192
1193 \\>
1194 <<
1195 NLA = 64;
1196 if (! tokenActionActive) zzreplstr(">"); /* MR1 */
1197 zzmore(); /* MR1 */
1198 >>
1199
1200 '
1201 <<
1202 NLA = 65;
1203 zzmode(ACTION_CHARS); zzmore();
1204 >>
1205
1206 \"
1207 <<
1208 NLA = 66;
1209 zzmode(ACTION_STRINGS); zzmore();
1210 >>
1211
1212 \\$
1213 <<
1214 NLA = 67;
1215 zzreplstr("$"); zzmore();
1216 >>
1217
1218 \\#
1219 <<
1220 NLA = 68;
1221 zzreplstr("#"); zzmore();
1222 >>
1223
1224 \\(\n|\r|\r\n)
1225 <<
1226 NLA = 69;
1227 zzline++; zzmore();
1228 >>
1229
1230 \\~[\]\)>$#]
1231 <<
1232 NLA = 70;
1233 zzmore();
1234 >>
1235
1236 /
1237 <<
1238 NLA = 71;
1239 zzmore();
1240 >>
1241
1242 /\*
1243 <<
1244 NLA = 72;
1245 zzmode(ACTION_COMMENTS); zzmore();
1246 >>
1247
1248 \*/
1249 <<
1250 NLA = 73;
1251 warn("Missing /*; found dangling */ in action"); zzmore();
1252 >>
1253
1254 //
1255 <<
1256 NLA = 74;
1257 zzmode(ACTION_CPP_COMMENTS); zzmore();
1258 >>
1259
1260 ~[\n\r\)\(\\$#\>\]\[\"'/]+
1261 <<
1262 NLA = 75;
1263 zzmore();
1264 >>
1265
1266
1267 %%PARSE_ENUM_FILE
1268
1269 @
1270 <<
1271 NLA = Eof;
1272 ;
1273 >>
1274
1275 [\t\ ]+
1276 <<
1277 NLA = 137;
1278 zzskip();
1279 >>
1280
1281 \n|\r|\r\n
1282 <<
1283 NLA = 138;
1284 zzline++; zzskip();
1285 >>
1286
1287 //
1288 <<
1289 NLA = 139;
1290 zzmode(TOK_DEF_CPP_COMMENTS); zzmore();
1291 >>
1292
1293 /\*
1294 <<
1295 NLA = 140;
1296 zzmode(TOK_DEF_COMMENTS); zzskip();
1297 >>
1298
1299 #ifdef
1300 <<
1301 NLA = 141;
1302 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1303 >>
1304
1305 #if
1306 <<
1307 NLA = 142;
1308 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1309 >>
1310
1311 #ifndef
1312 <<
1313 NLA = 143;
1314 ;
1315 >>
1316
1317 #else
1318 <<
1319 NLA = 144;
1320 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1321 >>
1322
1323 #endif
1324 <<
1325 NLA = 145;
1326 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1327 >>
1328
1329 #undef
1330 <<
1331 NLA = 146;
1332 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1333 >>
1334
1335 #import
1336 <<
1337 NLA = 147;
1338 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1339 >>
1340
1341 #define
1342 <<
1343 NLA = 149;
1344 >>
1345
1346 enum
1347 <<
1348 NLA = 151;
1349 >>
1350
1351 \{
1352 <<
1353 NLA = 152;
1354 >>
1355
1356 =
1357 <<
1358 NLA = 153;
1359 >>
1360
1361 ,
1362 <<
1363 NLA = 154;
1364 >>
1365
1366 \}
1367 <<
1368 NLA = 155;
1369 >>
1370
1371 ;
1372 <<
1373 NLA = 156;
1374 >>
1375
1376 [0-9]+
1377 <<
1378 NLA = INT;
1379 >>
1380
1381 [a-zA-Z_][_a-zA-Z0-9]*
1382 <<
1383 NLA = ID;
1384 >>
1385
1386 %%
+0
-821
contrib/pccts/antlr/pred.c less more
0 /*
1 * pred.c -- source for predicate detection, manipulation
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1989-2001
28 */
29
30 #include <stdio.h>
31 #include "pcctscfg.h"
32 #include "set.h"
33 #include "syn.h"
34 #include "hash.h"
35 #include "generic.h"
36 #include "dlgdef.h"
37 #include <ctype.h>
38
39 #ifdef __USE_PROTOS
40 static void complete_context_sets(RuleRefNode *, Predicate *);
41 static void complete_context_trees(RuleRefNode *, Predicate *);
42 #else
43 static void complete_context_sets();
44 static void complete_context_trees();
45 #endif
46
47 char *PRED_AND_LIST = "AND";
48 char *PRED_OR_LIST = "OR";
49
50 /*
51 * In C mode, return the largest constant integer found as the
52 * sole argument to LATEXT(i).
53 *
54 * In C++ mode, return the largest constant integer found as the
55 * sole argument to LT(i) given that the char before is nonalpha.
56 */
57
58 int
59 #ifdef __USE_PROTOS
60 predicateLookaheadDepth(ActionNode *a)
61 #else
62 predicateLookaheadDepth(a)
63 ActionNode *a;
64 #endif
65 {
66 int max_k=0;
67
68 if (a->predEntry != NULL) {
69 MR_pred_depth(a->predEntry->pred,&max_k);
70 goto PREDENTRY_EXIT;
71 }
72
73 if ( GenCC )
74 {
75 /* scan for LT(i) */
76 int k = 0;
77 char *p = a->action;
78 while ( p!=NULL )
79 {
80 p = strstr(p, "LT(");
81 if ( p!=NULL )
82 {
83 if ( p>=a->action && !isalpha(*(p-1)) )
84 {
85 k = atoi(p+strlen("LT("));
86 if ( k>max_k ) max_k=k;
87 }
88 p += strlen("LT(");
89 }
90 }
91 }
92 else {
93 /* scan for LATEXT(i) */
94 int k = 0;
95 char *p = a->action;
96 while ( p!=NULL )
97 {
98 p = strstr(p, "LATEXT(");
99 if ( p!=NULL )
100 {
101 p += strlen("LATEXT(");
102 k = atoi(p);
103 if ( k>max_k ) max_k=k;
104 }
105 }
106 }
107
108 if (max_k==0) {
109 max_k = 1; /* MR33 Badly designed if didn't set max_k when CLL_k = 1 */
110 if (CLL_k > 1) /* MR27 Don't warn if max(k,ck) == 1 */
111 {
112 if ( !a->frmwarned )
113 {
114 a->frmwarned = 1;
115 warnFL(eMsg1("predicate: %s missing, bad, or with i=0; assuming i=1",
116 GenCC?"LT(i)":"LATEXT(i)"),
117 FileStr[a->file], a->line);
118 }
119 }
120 }
121
122 /* MR10 */ if ( max_k > CLL_k) {
123 /* MR10 */ if ( !a->frmwarned )
124 /* MR10 */ {
125 /* MR10 */ a->frmwarned = 1;
126 /* MR11 */ errFL(eMsgd2("predicate refers to lookahead token %d. Semantic lookahead is limited to max(k,ck)==%d",
127 /* MR10 */ max_k,CLL_k),
128 /* MR10 */ FileStr[a->file],a->line);
129 /* MR10 */ if (max_k >= OutputLL_k) {
130 /* MR10 */ if (!GenCC) {
131 /* MR10 */ errFL(eMsgd(" the lookahead buffer size in C mode is %d token(s) (including the one just recognized)",
132 /* MR10 */ OutputLL_k),
133 /* MR10 */ FileStr[a->file],a->line);
134 /* MR10 */ };
135 /* MR10 */ };
136 /* MR10 */ };
137 /* MR10 */ max_k= CLL_k;
138 /* MR10 */ };
139
140 PREDENTRY_EXIT:
141 return max_k;
142 }
143
144 /* Find all predicates in a block of alternatives. DO NOT find predicates
145 * behind the block because that predicate could depend on things set in
146 * one of the nonoptional blocks
147 */
148
149 Predicate *
150 #ifdef __USE_PROTOS
151 find_in_aSubBlk( Junction *alt )
152 #else
153 find_in_aSubBlk( alt )
154 Junction *alt;
155 #endif
156 {
157 Predicate *a, *head=NULL, *tail=NULL, *root=NULL;
158 Junction *p = alt;
159
160 if (MRhoisting) {
161 return MR_find_in_aSubBlk(alt);
162 };
163 for (; p!=NULL; p=(Junction *)p->p2)
164 {
165 /* ignore empty alts */
166 if ( p->p1->ntype != nJunction ||
167 ((Junction *)p->p1)->jtype != EndBlk )
168 {
169 a = find_predicates(p->p1); /* get preds for this alt */
170 if ( a==NULL ) continue;
171
172 /* make an OR list of predicates */
173 if ( head==NULL )
174 {
175 root = new_pred();
176 root->expr = PRED_OR_LIST;
177 head = tail = a;
178 root->down = head;
179 }
180 else {
181 tail->right = a;
182 a->left = tail;
183 a->up = tail->up;
184 tail = a;
185 }
186 }
187 }
188
189 /* if just one pred, remove OR root */
190 if ( root!=NULL && root->down->right == NULL )
191 {
192 Predicate *d = root->down;
193 free( (char *) root);
194 return d;
195 }
196
197 return root;
198 }
199
200 Predicate *
201 #ifdef __USE_PROTOS
202 find_in_aOptBlk( Junction *alt )
203 #else
204 find_in_aOptBlk( alt )
205 Junction *alt;
206 #endif
207 {
208 return find_in_aSubBlk( alt );
209 }
210
211 Predicate *
212 #ifdef __USE_PROTOS
213 find_in_aLoopBegin( Junction *alt )
214 #else
215 find_in_aLoopBegin( alt )
216 Junction *alt;
217 #endif
218 {
219 return find_in_aSubBlk( (Junction *) alt->p1 ); /* get preds in alts */
220 }
221
222 Predicate *
223 #ifdef __USE_PROTOS
224 find_in_aPlusBlk( Junction *alt )
225 #else
226 find_in_aPlusBlk( alt )
227 Junction *alt;
228 #endif
229 {
230 require(alt!=NULL&&alt->p2!=NULL, "invalid aPlusBlk");
231 return find_in_aSubBlk( alt );
232 }
233
234 /* Look for a predicate;
235 *
236 * Do not pass anything but Junction nodes; no Actions, Tokens, RuleRefs.
237 * This means that a "hoisting distance" of zero is the only distance
238 * allowable. Init actions are ignored.
239 *
240 * WARNING:
241 * Assumes no (..)? block after predicate for the moment.
242 * Does not check to see if pred is in production that can generate
243 * a sequence contained in the set of ambiguous tuples.
244 *
245 * Return the predicate found if any.
246 */
247
248
249 Predicate *
250 #ifdef __USE_PROTOS
251 find_predicates( Node *alt )
252 #else
253 find_predicates( alt )
254 Node *alt;
255 #endif
256 {
257 #ifdef DBG_PRED
258 Junction *j;
259 RuleRefNode *r;
260 TokNode *t;
261 #endif
262 Predicate *pred;
263
264 if ( alt==NULL ) return NULL;
265
266 #ifdef DBG_PRED
267 switch ( alt->ntype )
268 {
269 case nJunction :
270 j = (Junction *) alt;
271 fprintf(stderr, "Junction(in %s)", j->rname);
272 switch ( j->jtype )
273 {
274 case aSubBlk :
275 fprintf(stderr,"aSubBlk\n");
276 break;
277 case aOptBlk :
278 fprintf(stderr,"aOptBlk\n");
279 break;
280 case aLoopBegin :
281 fprintf(stderr,"aLoopBeginBlk\n");
282 break;
283 case aLoopBlk :
284 fprintf(stderr,"aLoopBlk\n");
285 break;
286 case aPlusBlk :
287 fprintf(stderr,"aPlusBlk\n");
288 break;
289 case EndBlk :
290 fprintf(stderr,"EndBlk\n");
291 break;
292 case RuleBlk :
293 fprintf(stderr,"RuleBlk\n");
294 break;
295 case Generic :
296 fprintf(stderr,"Generic\n");
297 break;
298 case EndRule :
299 fprintf(stderr,"EndRule\n");
300 break;
301 }
302 break;
303 case nRuleRef :
304 r = (RuleRefNode *) alt;
305 fprintf(stderr, "RuleRef(in %s)\n", r->rname);
306 break;
307 case nToken :
308 t = (TokNode *) alt;
309 fprintf(stderr, "TokenNode(in %s)%s\n", t->rname, TokenString(t->token));
310 break;
311 case nAction :
312 fprintf(stderr, "Action\n");
313 break;
314 }
315 #endif
316
317 switch ( alt->ntype )
318 {
319 case nJunction :
320 {
321 Predicate *a, *b;
322 Junction *p = (Junction *) alt;
323
324 /* lock nodes */
325 if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||
326 p->jtype==aPlusBlk || p->jtype==EndRule )
327 {
328 require(p->pred_lock!=NULL, "rJunc: lock array is NULL");
329 if ( p->pred_lock[1] )
330 {
331 return NULL;
332 }
333 p->pred_lock[1] = TRUE;
334 }
335
336 switch ( p->jtype )
337 {
338 case aSubBlk :
339 a = find_in_aSubBlk(p);
340 return a; /* nothing is visible past this guy */
341 case aOptBlk :
342 a = find_in_aOptBlk(p);
343 return a;
344 case aLoopBegin :
345 a = find_in_aLoopBegin(p);
346 return a;
347 case aLoopBlk :
348 a = find_in_aSubBlk(p);
349 p->pred_lock[1] = FALSE;
350 return a;
351 case aPlusBlk :
352 a = find_in_aPlusBlk(p);
353 p->pred_lock[1] = FALSE;
354 return a; /* nothing is visible past this guy */
355 case RuleBlk :
356 a = find_predicates(p->p1);
357 p->pred_lock[1] = FALSE;
358 return a;
359 case Generic :
360 a = find_predicates(p->p1);
361 b = find_predicates(p->p2);
362 if ( p->pred_lock!=NULL ) p->pred_lock[1] = FALSE;
363 if ( a==NULL ) return b;
364 if ( b==NULL ) return a;
365 /* otherwise OR the two preds together */
366 {
367 fatal_internal("hit unknown situation during predicate hoisting");
368 }
369 case EndBlk :
370 case EndRule : /* Find no predicates after a rule ref */
371 return NULL;
372 default:
373 fatal_internal("this cannot be printed\n");
374 break;
375 }
376 }
377 case nAction :
378 {
379 ActionNode *p = (ActionNode *) alt;
380 if ( p->noHoist) return NULL; /* MR12c */
381 if ( p->init_action ) return find_predicates(p->next);
382 if ( p->is_predicate )
383 {
384 Tree *t=NULL;
385 #ifdef DBG_PRED
386 fprintf(stderr, "predicate: <<%s>>?\n", p->action);
387 #endif
388 if ( p->guardpred!=NULL )
389 {
390 pred = predicate_dup(p->guardpred);
391 MR_guardPred_plainSet(p,pred); /* MR12c */
392 }
393 else
394 {
395 pred = new_pred();
396 pred->k = predicateLookaheadDepth(p);
397 pred->source = p;
398 pred->expr = p->action;
399 if ( HoistPredicateContext && pred->k > 1 )
400 {
401 /* MR30 No need to use first_item_is_guess_block_extra
402 since we know this is an action, not a (...)* or
403 (...)+ block.
404 */
405
406 if ( first_item_is_guess_block((Junction *)p->next) )
407 {
408 warnFL("cannot compute context of predicate in front of (..)? block",
409 FileStr[p->file], p->line);
410 }
411 else
412 {
413 ConstrainSearch = 0;
414 /* MR11 */ if (p->ampersandPred != NULL) {
415 /* MR11 */ TRAV(p,
416 /* MR11 */ pred->k,
417 /* MR11 */ &(pred->completionTree), t);
418 /* MR11 */ } else {
419 TRAV(p->next,
420 pred->k,
421 &(pred->completionTree), t);
422 };
423 pred->tcontext = t;
424 MR_check_pred_too_long(pred,pred->completionTree);
425 #ifdef DBG_PRED
426 fprintf(stderr, "LL(%d) context:", pred->k);
427 preorder(t);
428 fprintf(stderr, "\n");
429 #endif
430 }
431 }
432 else if ( HoistPredicateContext && pred->k == 1 )
433 {
434 pred->scontext[1] = empty;
435 /* MR30 No need to use first_item_is_guess_block_extra
436 since we know this is an action.
437 */
438 if ( first_item_is_guess_block((Junction *)p->next) )
439 {
440 warnFL("cannot compute context of predicate in front of (..)? block",
441 FileStr[p->file], p->line);
442 }
443 else
444 {
445 REACH((Junction *)p->next,
446 1,
447 &(pred->completionSet),
448 pred->scontext[1]);
449 MR_check_pred_too_long(pred,pred->completionSet);
450 #ifdef DBG_PRED
451 fprintf(stderr, "LL(1) context:");
452 s_fprT(stderr, pred->scontext[1]);
453 fprintf(stderr, "\n");
454 #endif
455 }
456 }
457 }
458 {
459 Predicate *d = find_predicates(p->next);
460 Predicate *root;
461
462 /* Warning: Doesn't seem like the up pointers will all be set correctly;
463 * TJP: that's ok, we're not using them now.
464 */
465 if ( d!=NULL )
466 {
467 root = new_pred();
468 root->expr = PRED_AND_LIST;
469 root->down = pred;
470 pred->right = d;
471 pred->up = root;
472 d->left = pred;
473 d->up = pred->up;
474 return root;
475 }
476 }
477 return pred;
478 }
479 return NULL;
480 }
481 case nRuleRef :
482 {
483 Predicate *a;
484 RuleRefNode *p = (RuleRefNode *) alt;
485 Junction *r;
486 Junction *save_MR_RuleBlkWithHalt;
487
488 RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);
489 if ( q == NULL )
490 {
491 warnFL( eMsg1("rule %s not defined",p->text), FileStr[p->file], p->line );
492 return NULL;
493 }
494 r = RulePtr[q->rulenum];
495 if ( r->pred_lock[1] )
496 {
497 /* infinite left-recursion; ignore 'cause LL sup 1 (k) analysis
498 * must have seen it earlier.
499 */
500 return NULL;
501 }
502
503 /* MR10 There should only be one halt set at a time. */
504 /* MR10 Life would have been easier with a global variable */
505 /* MR10 (at least for this particular need) */
506 /* MR10 Unset the old one and set the new one, later undo. */
507
508 require(r->end->halt == FALSE,"should only have one halt at a time");
509
510 /* MR10 */ require(MR_RuleBlkWithHalt == NULL ||
511 /* MR10 */ (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),
512 /* MR10 */ "RuleBlkWithHalt->end not RuleBlk or does not have halt set");
513 /* MR10 */ if (MR_RuleBlkWithHalt != NULL) {
514 /* MR10 */ MR_RuleBlkWithHalt->end->halt=FALSE;
515 /* MR10 */ };
516
517 /*** fprintf(stderr,"\nSetting halt on junction #%d\n",r->end->seq); ***/
518
519 require(r->end->halt == FALSE,"rule->end->halt already set");
520
521 save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;
522
523 /* MR10 */ MR_pointerStackPush(&MR_RuleBlkWithHaltStack,MR_RuleBlkWithHalt);
524 /* MR10 */ MR_pointerStackPush(&MR_PredRuleRefStack,p);
525
526 r->end->halt = TRUE;
527 /* MR10 */ MR_RuleBlkWithHalt=r;
528
529 a = find_predicates((Node *)r);
530
531 require(r->end->halt == TRUE,"rule->end->halt not set");
532 r->end->halt = FALSE;
533
534 /* MR10 */ MR_pointerStackPop(&MR_PredRuleRefStack);
535 /* MR10 */ MR_RuleBlkWithHalt=(Junction *) MR_pointerStackPop(&MR_RuleBlkWithHaltStack);
536
537 require (MR_RuleBlkWithHalt==save_MR_RuleBlkWithHalt,
538 "RuleBlkWithHaltStack not consistent");
539
540 /* MR10 */ require(MR_RuleBlkWithHalt == NULL ||
541 /* MR10 */ (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == FALSE),
542 /* MR10 */ "RuleBlkWithHalt->end not RuleBlk or has no halt set");
543 /* MR10 */ if (MR_RuleBlkWithHalt != NULL) {
544 /* MR10 */ MR_RuleBlkWithHalt->end->halt=TRUE;
545 /* MR10 */ };
546
547 /*** fprintf(stderr,"\nRestoring halt on junction #%d\n",r->end->seq); ***/
548
549 if ( a==NULL ) return NULL;
550
551 /* attempt to compute the "local" FOLLOW just like in normal lookahead
552 * computation if needed
553 */
554
555 complete_context_sets(p,a);
556 complete_context_trees(p,a);
557
558 /* MR10 */ MR_cleanup_pred_trees(a);
559
560 return a;
561 }
562 case nToken :
563 break;
564 }
565
566 return NULL;
567 }
568
569 #ifdef __USE_PROTOS
570 Predicate *MR_find_predicates_and_supp(Node *alt)
571 #else
572 Predicate *MR_find_predicates_and_supp(alt)
573 Node *alt;
574 #endif
575 {
576 Predicate *p;
577
578 p=find_predicates(alt);
579 p=MR_suppressK(alt,p);
580 return p;
581 }
582
583 Predicate *
584 #ifdef __USE_PROTOS
585 new_pred( void )
586 #else
587 new_pred( )
588 #endif
589 {
590 Predicate *p = (Predicate *) calloc(1,sizeof(Predicate)); /* MR10 */
591 require(p!=NULL, "new_pred: cannot alloc predicate");
592 p->scontext[0]=empty;
593 p->scontext[1]=empty;
594 p->completionTree=empty;
595 p->completionSet=empty;
596 p->plainSet=empty;
597 return p;
598 }
599
600 static void
601 #ifdef __USE_PROTOS
602 complete_context_sets( RuleRefNode *p, Predicate *a )
603 #else
604 complete_context_sets( p, a )
605 RuleRefNode *p;
606 Predicate *a;
607 #endif
608 {
609 set rk2, b;
610 int k2;
611
612 #ifdef DBG_PRED
613 fprintf(stderr, "enter complete_context_sets\n");
614 #endif
615 for (; a!=NULL; a=a->right)
616 {
617 if ( a->expr == PRED_AND_LIST || a->expr == PRED_OR_LIST )
618 {
619 complete_context_sets(p,a->down);
620 continue;
621 }
622 rk2 = b = empty;
623 while ( !set_nil(a->completionSet) )
624 {
625 k2 = set_int(a->completionSet);
626 set_rm(k2, a->completionSet);
627
628 REACH(p->next, k2, &rk2, b);
629 set_orin(&(a->scontext[1]), b);
630 set_free(b);
631 }
632
633 set_orin(&(a->completionSet), rk2);/* remember what we couldn't do */
634 set_free(rk2);
635 #ifdef DBG_PRED
636 fprintf(stderr, "LL(1) context for %s(addr 0x%x) after ruleref:", a->expr, a);
637 s_fprT(stderr, a->scontext[1]);
638 fprintf(stderr, "\n");
639 #endif
640 /* complete_context_sets(p, a->down);*/
641 }
642 #ifdef DBG_PRED
643 fprintf(stderr, "exit complete_context_sets\n");
644 #endif
645 }
646
647 static void
648 #ifdef __USE_PROTOS
649 complete_context_trees( RuleRefNode *p, Predicate *a )
650 #else
651 complete_context_trees( p, a )
652 RuleRefNode *p;
653 Predicate *a;
654 #endif
655 {
656 set rk2;
657 int k2;
658 Tree *u;
659
660 #ifdef DBG_PRED
661 fprintf(stderr, "enter complete_context_trees\n");
662 #endif
663 for (; a!=NULL; a=a->right)
664 {
665 if ( a->expr == PRED_AND_LIST || a->expr == PRED_OR_LIST )
666 {
667 complete_context_trees(p, a->down);
668 continue;
669 }
670 rk2 = empty;
671
672 /* any k left to do? if so, link onto tree */
673 while ( !set_nil(a->completionTree) )
674 {
675 k2 = set_int(a->completionTree);
676 set_rm(k2, a->completionTree);
677 u = NULL;
678
679 TRAV(p->next, k2, &rk2, u);
680
681 /* any subtrees missing k2 tokens, add u onto end */
682 a->tcontext = tlink(a->tcontext, u, k2);
683 Tfree(u); /* MR10 */
684 }
685 set_orin(&(a->completionTree), rk2);/* remember what we couldn't do */
686 set_free(rk2);
687 #ifdef DBG_PRED
688 fprintf(stderr, "LL(i<%d) context after ruleref:", LL_k);
689 preorder(a->tcontext);
690 fprintf(stderr, "\n");
691 #endif
692 /* complete_context_trees(p, a->down);*/
693 }
694 #ifdef DBG_PRED
695 fprintf(stderr, "exit complete_context_trees\n");
696 #endif
697 }
698
699 /* Walk a list of predicates and return the set of all tokens in scontext[1]'s */
700 set
701 #ifdef __USE_PROTOS
702 covered_set( Predicate *p )
703 #else
704 covered_set( p )
705 Predicate *p;
706 #endif
707 {
708 set a;
709
710 a = empty;
711 for (; p!=NULL; p=p->right)
712 {
713 if ( p->expr == PRED_AND_LIST || p->expr == PRED_OR_LIST )
714 {
715 set_orin(&a, covered_set(p->down));
716 continue;
717 }
718 set_orin(&a, p->scontext[1]);
719 set_orin(&a, covered_set(p->down));
720 }
721 return a;
722 }
723
724 /* MR10 predicate_free()
725 MR10 Don't free the leaf nodes since they are part of the action node
726 */
727
728 #ifdef __USE_PROTOS
729 void predicate_free(Predicate *p)
730 #else
731 void predicate_free(p)
732 Predicate *p;
733 #endif
734 {
735 if (p == NULL) return;
736 predicate_free(p->right);
737 predicate_free(p->down);
738 if (p->cloned ||
739 p->source == NULL ||
740 p->source->guardpred == NULL ||
741 p->expr == PRED_AND_LIST ||
742 p->expr == PRED_OR_LIST) {
743 set_free(p->scontext[1]);
744 set_free(p->completionSet);
745 set_free(p->completionTree);
746 set_free(p->plainSet);
747 Tfree(p->tcontext);
748 free( (char *) p);
749 } else {
750 p->right=NULL;
751 p->down=NULL; /* MR13 *** debug */
752 };
753 }
754
755 /* MR10 predicate_dup() */
756
757 #ifdef __USE_PROTOS
758 Predicate * predicate_dup_xxx(Predicate *p,int contextToo)
759 #else
760 Predicate * predicate_dup_xxx(p,contextToo)
761 Predicate *p;
762 int contextToo;
763 #endif
764 {
765 Predicate *q;
766
767 if (p == NULL) return NULL;
768 q=new_pred();
769 q->down=predicate_dup(p->down);
770 q->right=predicate_dup(p->right);
771
772 /*
773 don't replicate expr - it is read-only
774 and address comparison is used to look
775 for identical predicates.
776 */
777
778 q->expr=p->expr;
779 q->k=p->k;
780 q->source=p->source;
781 q->cloned=1;
782 q->ampersandStyle=p->ampersandStyle;
783 q->inverted=p->inverted;
784 q->predEntry=p->predEntry;
785 q->plainSet=set_dup(p->plainSet);
786
787 if (contextToo) {
788 q->tcontext=tdup(p->tcontext);
789 q->scontext[0]=set_dup(p->scontext[0]);
790 q->scontext[1]=set_dup(p->scontext[1]);
791 q->completionTree=set_dup(p->completionTree);
792 q->completionSet=set_dup(p->completionSet);
793 };
794
795 /* don't need to dup "redundant" */
796
797 return q;
798
799 }
800
801 #ifdef __USE_PROTOS
802 Predicate * predicate_dup_without_context(Predicate *p)
803 #else
804 Predicate * predicate_dup_without_context(p)
805 Predicate *p;
806 #endif
807 {
808 return predicate_dup_xxx(p,0);
809 }
810
811 #ifdef __USE_PROTOS
812 Predicate * predicate_dup(Predicate *p)
813 #else
814 Predicate * predicate_dup(p)
815 Predicate *p;
816 #endif
817 {
818 return predicate_dup_xxx(p,1);
819 }
820
+0
-852
contrib/pccts/antlr/proto.h less more
0 /*
1 * proto.h -- function prototypes
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * ANTLR 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1989-2001
28 */
29
30 /* V a r i a b l e s */
31
32 extern int tp;
33 extern Junction *SynDiag;
34 extern char Version[];
35 extern char VersionDef[];
36 #ifdef __cplusplus
37 extern void (*fpPrint[])(...);
38 #else
39 extern void (*fpPrint[])();
40 #endif
41 #ifdef __cplusplus
42 extern struct _set (*fpReach[])(...);
43 #else
44 extern struct _set (*fpReach[])();
45 #endif
46 #ifdef __cplusplus
47 extern struct _tree *(*fpTraverse[])(...);
48 #else
49 extern struct _tree *(*fpTraverse[])();
50 #endif
51 #ifdef __cplusplus
52 extern void (**fpTrans)(...);
53 #else
54 extern void (**fpTrans)();
55 #endif
56 #ifdef __cplusplus
57 extern void (**fpJTrans)(...);
58 #else
59 extern void (**fpJTrans)();
60 #endif
61 #ifdef __cplusplus
62 extern void (*C_Trans[NumNodeTypes+1])(...);
63 #else
64 extern void (*C_Trans[])();
65 #endif
66 #ifdef __cplusplus
67 extern void (*C_JTrans[NumJuncTypes+1])(...);
68 #else
69 extern void (*C_JTrans[])();
70 #endif
71 extern int BlkLevel;
72 extern int CurFile;
73 extern char *CurPredName;
74 extern char *CurRule;
75 extern int CurRuleDebug; /* MR13 */
76 extern Junction *CurRuleBlk;
77 extern RuleEntry *CurRuleNode;
78 extern ListNode *CurElementLabels;
79 extern ListNode *CurAstLabelsInActions; /* MR27 */
80 extern ListNode *ContextGuardPredicateList; /* MR13 */
81 extern ListNode *CurActionLabels;
82 extern int numericActionLabel; /* MR10 << ... $1 ... >> or << ... $1 ... >>? */
83 extern ListNode *NumericPredLabels; /* MR10 << ... $1 ... >>? ONLY */
84 extern char *FileStr[];
85 extern int NumFiles;
86 extern int EpToken;
87 extern int WildCardToken;
88 extern Entry **Tname,
89 **Texpr,
90 **Rname,
91 **Fcache,
92 **Tcache,
93 **Elabel,
94 **Sname,
95 **Pname; /* MR11 */
96 extern ListNode *ExprOrder;
97 extern ListNode **Cycles;
98 extern int TokenNum;
99 extern int LastTokenCounted;
100 extern ListNode *BeforeActions, *AfterActions, *LexActions;
101
102 /* MR1 */
103 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
104 /* MR1 via #lexmember <<....>> & #lexprefix <<...>> */
105 /* MR1 */
106
107 extern ListNode *LexMemberActions; /* MR1 */
108 extern ListNode *LexPrefixActions; /* MR1 */
109
110 extern set *fset; /* for constrained search */ /* MR11 */
111 extern int maxk; /* for constrained search */ /* MR11 */
112 extern int Save_argc; /* MR10 */
113 extern char **Save_argv; /* MR10 */
114 extern ListNode *eclasses, *tclasses;
115 extern char *HdrAction;
116 extern char *FirstAction; /* MR11 */
117 extern FILE *ErrFile;
118 extern char *RemapFileName;
119 extern char *ErrFileName;
120 extern char *DlgFileName;
121 extern char *DefFileName;
122 extern char *ModeFileName;
123 extern char *StdMsgName;
124 extern int NumRules;
125 extern Junction **RulePtr;
126 extern int LL_k;
127 extern int CLL_k;
128 extern char *decodeJType[];
129 extern int PrintOut;
130 extern int PrintAnnotate;
131 extern int CodeGen;
132 extern int LexGen;
133 extern int esetnum;
134 extern int setnum;
135 extern int wordnum;
136 extern int GenAST;
137 extern int GenANSI;
138 extern int **FoStack;
139 extern int **FoTOS;
140 extern int GenExprSetsOpt;
141 extern FILE *DefFile;
142 extern int CannotContinue;
143 extern int GenCR;
144 extern int GenLineInfo;
145 extern int GenLineInfoMS;
146 extern int action_file, action_line;
147 extern int TraceGen;
148 extern int CurAmbigAlt1, CurAmbigAlt2, CurAmbigline, CurAmbigfile;
149 extern char *CurAmbigbtype;
150 extern int elevel;
151 extern int GenEClasseForRules;
152 extern FILE *input, *output;
153 extern char **TokenStr, **ExprStr;
154 extern int CurrentLexClass, NumLexClasses;
155 extern LClass lclass[];
156 extern char LexStartSymbol[];
157 extern char *CurRetDef;
158 extern char *CurParmDef;
159 extern int OutputLL_k;
160 extern int TreeResourceLimit;
161 extern int DemandLookahead;
162 extern char *RulePrefix;
163 extern int GenStdPccts;
164 extern char *stdpccts;
165 extern int ParseWithPredicates;
166 extern int ConstrainSearch;
167 extern int PURIFY; /* MR23 */
168
169 extern set MR_CompromisedRules; /* MR14 */
170 extern int MR_AmbSourceSearch; /* MR11 */
171 extern int MR_SuppressSearch; /* MR13 */
172 extern int MR_AmbSourceSearchGroup; /* MR11 */
173 extern int MR_AmbSourceSearchChoice; /* MR11 */
174 extern int MR_AmbSourceSearchLimit; /* MR11 */
175 extern int MR_usingPredNames; /* MR11 */
176 extern int MR_ErrorSetComputationActive; /* MR14 */
177 extern char *MR_AmbAidRule; /* MR11 */
178 extern int MR_AmbAidLine; /* MR11 */
179 extern int MR_AmbAidMultiple; /* MR11 */
180 extern int MR_AmbAidDepth; /* MR11 */
181 extern int MR_skipped_e3_report; /* MR11 */
182 extern int MR_matched_AmbAidRule; /* MR11 */
183 extern int MR_Inhibit_Tokens_h_Gen; /* MR13 */
184 extern int NewAST; /* MR13 */
185 extern int tmakeInParser; /* MR23 */
186 extern int AlphaBetaTrace; /* MR14 */
187 extern int MR_BlkErr; /* MR21 */
188 extern int MR_AlphaBetaWarning; /* MR14 */
189 extern int MR_AlphaBetaMessageCount; /* MR14 */
190 extern int MR_MaintainBackTrace; /* MR14 */
191 extern int MR_BadExprSets; /* MR13 */
192 extern int FoundGuessBlk;
193 extern int FoundException;
194 extern int FoundAtOperator; /* MR6 */
195 extern int FoundExceptionGroup; /* MR6 */
196 extern int WarningLevel;
197 extern int UseStdout; /* MR6 */
198 extern int TabWidth; /* MR6 */
199 extern int pLevel;
200 extern int pAlt1;
201 extern int pAlt2;
202 extern int AImode;
203 extern int HoistPredicateContext;
204 extern int MRhoisting; /* MR9 */
205 extern int MRhoistingk; /* MR13 */
206 extern int MR_debugGenRule; /* MR11 */
207 extern int GenCC;
208 extern char *ParserName;
209 extern char *StandardSymbols[];
210 extern char *ASTSymbols[];
211 extern set reserved_positions;
212 extern set all_tokens;
213 extern set imag_tokens;
214 extern set tokclasses;
215 extern ListNode *ForcedTokens;
216 extern int *TokenInd;
217 extern FILE *Parser_h, *Parser_c;
218 extern char CurrentClassName[];
219 extern int no_classes_found;
220 extern char Parser_h_Name[];
221 extern char Parser_c_Name[];
222 extern char MRinfoFile_Name[]; /* MR10 */
223 extern FILE *MRinfoFile; /* MR10 */
224 extern int MRinfo; /* MR10 */
225 extern int MRinfoSeq; /* MR10 */
226 extern int InfoP; /* MR10 */
227 extern int InfoT; /* MR10 */
228 extern int InfoF; /* MR10 */
229 extern int InfoM; /* MR10 */
230 extern int InfoO; /* MR12 */
231 extern int PotentialSuppression; /* MR10 */
232 extern int PotentialDummy; /* MR10 */
233 extern int TnodesInUse; /* MR10 */
234 extern int TnodesPeak; /* MR10 */
235 extern int TnodesReportThreshold; /* MR11 */
236 extern int TnodesAllocated; /* MR10 */
237 extern char *ClassDeclStuff; /* MR10 */
238 extern char *BaseClassName; /* MR22 */
239 extern ListNode *class_before_actions, *class_after_actions;
240 extern char *UserTokenDefsFile;
241 extern int UserDefdTokens;
242 extern ListNode *MetaTokenNodes;
243 extern char *OutputDirectory;
244 extern int DontCopyTokens;
245 extern int LTinTokenAction; /* MR23 */
246 extern set AST_nodes_refd_in_actions;
247 extern ListNode *CurExGroups;
248 extern int CurBlockID;
249 extern int CurAltNum;
250 extern Junction *CurAltStart;
251 extern Junction *OuterAltStart; /* chain exception groups MR7 */
252 extern ExceptionGroup *DefaultExGroup;
253 extern int NumSignals;
254 extern int ContextGuardTRAV;
255 extern Junction *MR_RuleBlkWithHalt; /* MR10 */
256 extern PointerStack MR_BackTraceStack; /* MR10 */
257 extern PointerStack MR_PredRuleRefStack; /* MR10 */
258 extern PointerStack MR_RuleBlkWithHaltStack; /* MR10 */
259
260 /* */
261 /* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */
262 /* MR1 in DLG action */
263 /* */
264 extern int tokenActionActive; /* MR1 */
265
266 extern char *PRED_OR_LIST; /* MR10 */
267 extern char *PRED_AND_LIST; /* MR10 */
268
269 #ifdef __VMS
270 #define STRICMP strcasecmp /* MR21 */
271 #else
272 #define STRICMP stricmp /* MR21 */
273 #endif
274
275 /* MR26 */
276 #ifdef PCCTS_USE_STDARG
277 extern Tree *tmake(Tree *root, ...);
278 #else
279 extern Tree *tmake();
280 #endif
281
282 #ifdef __USE_PROTOS
283 extern int STRICMP(const char*, const char*);
284 extern void istackreset(void);
285 extern int istacksize(void);
286 extern void pushint(int);
287 extern int popint( void );
288 extern int istackempty( void );
289 extern int topint( void );
290 extern void NewSetWd( void );
291 extern void DumpSetWd( void );
292 extern void DumpSetWdForC( void );
293 extern void DumpSetWdForCC( void );
294 extern void NewSet( void );
295 extern void FillSet( set );
296 extern void ComputeErrorSets( void );
297 extern void ComputeTokSets( void );
298 extern void SubstErrorClass( set * );
299 extern int DefErrSet( set *, int, char * );
300 extern int DefErrSetForC( set *, int, char * );
301 extern int DefErrSetForCC( set *, int, char * );
302 extern int DefErrSet1(int, set *, int, char *); /* MR21 */
303 extern int DefErrSetForC1(int, set *, int, char *, const char* ); /* MR21 */
304 extern int DefErrSetForCC1(int, set *, int, char *, const char* ); /* MR21 */
305 extern int DefErrSetWithSuffix(int, set *, int, char *, const char *); /* MR21 */
306 extern void GenErrHdr( void );
307 extern void dumpExpr( FILE *, char * );
308 extern void addParm( Node *, char * );
309 extern Graph buildAction( char *, int, int, int );
310 extern Graph buildToken( char * );
311 extern Graph buildWildCard( char * );
312 extern Graph buildRuleRef( char * );
313 extern Graph Or( Graph, Graph );
314 extern Graph Cat( Graph, Graph );
315 extern Graph makeOpt( Graph, int, char *);
316 extern Graph makeBlk( Graph, int, char *);
317 extern Graph makeLoop( Graph, int, char *);
318 extern Graph makePlus( Graph, int, char *);
319 extern Graph emptyAlt( void );
320 extern Graph emptyAlt3( void );
321 extern TokNode * newTokNode( void );
322 extern RuleRefNode * newRNode( void );
323 extern Junction * newJunction( void );
324 extern ActionNode * newActionNode( void );
325 extern char * makelocks( void );
326 extern void preorder( Tree * );
327 extern Tree * tnode( int );
328 extern void _Tfree( Tree * );
329 extern Tree * tdup( Tree * );
330 extern int is_single_tuple( Tree * );
331 extern Tree * tappend( Tree *, Tree * );
332 extern void Tfree( Tree * );
333 extern Tree * tlink( Tree *, Tree *, int );
334 extern Tree * tshrink( Tree * );
335 extern Tree * tflatten( Tree * );
336 extern Tree * tJunc( Junction *, int, set * );
337 extern Tree * tRuleRef( RuleRefNode *, int, set * );
338 extern Tree * tToken( TokNode *, int, set * );
339 extern Tree * tAction( ActionNode *, int, set * );
340 extern int tmember( Tree *, Tree * );
341 extern int tmember_constrained( Tree *, Tree * );
342 extern Tree * tleft_factor( Tree * );
343 extern Tree * trm_perm( Tree *, Tree * );
344 extern void tcvt( set *, Tree * );
345 extern Tree * permute( int, int );
346 extern Tree * VerifyAmbig( Junction *, Junction *, unsigned **, set *, Tree **, Tree **, int * );
347 extern set rJunc( Junction *, int, set * );
348 extern set rRuleRef( RuleRefNode *, int, set * );
349 extern set rToken( TokNode *, int, set * );
350 extern set rAction( ActionNode *, int, set * );
351 extern void HandleAmbiguity( Junction *, Junction *, Junction *, int );
352 extern set First( Junction *, int, int, int * );
353 extern void freeBlkFsets( Junction * );
354 extern void genAction( ActionNode * );
355 extern void genRuleRef( RuleRefNode * );
356 extern void genToken( TokNode * );
357 extern void genOptBlk( Junction * );
358 extern void genLoopBlk( Junction *, Junction *, Junction *, int );
359 extern void genLoopBegin( Junction * );
360 extern void genPlusBlk( Junction * );
361 extern void genSubBlk( Junction * );
362 extern void genRule( Junction * );
363 extern void genJunction( Junction * );
364 extern void genEndBlk( Junction * );
365 extern void genEndRule( Junction * );
366 extern void genHdr( int );
367 extern void genHdr1( int );
368 extern void dumpAction( char *, FILE *, int, int, int, int );
369 extern void dumpActionPlus(ActionNode*, char *, FILE *, int, int, int, int ); /* MR21 */
370 extern Entry ** newHashTable( void );
371 extern Entry * hash_add( Entry **, char *, Entry * );
372 extern Entry * hash_get( Entry **, char * );
373 extern void hashStat( Entry ** );
374 extern char * mystrdup( char * );
375 extern void genLexDescr( void );
376 extern void dumpLexClasses( FILE * );
377 extern void genDefFile( void );
378 extern void DumpListOfParmNames( char *, FILE *, int ); /* MR5 janm 26-May-97 */
379 extern int DumpNextNameInDef( char **, FILE * );
380 extern void DumpOldStyleParms( char *, FILE * );
381 extern void DumpType( char *, FILE * );
382 extern int strmember( char *, char * );
383 /* extern int HasComma( char * ); MR23 Replaced by hasMultipleOperands() */
384 extern void DumpRetValStruct( FILE *, char *, int );
385 extern char * StripQuotes( char * );
386 extern int main( int, char *[] );
387 extern void readDescr( void );
388 extern FILE * NextFile( void );
389 extern char * outnameX( char *, char *);
390 extern char * outname( char * );
391 extern void fatalFL( char *, char *, int );
392 extern void fatal_intern( char *, char *, int );
393 extern void cleanUp( void );
394 extern char * eMsg3( char *, char *, char *, char * );
395 extern char * eMsgd( char *, int );
396 extern char * eMsgd2( char *, int, int );
397 extern void s_fprT( FILE *, set );
398 extern char * TerminalString( int );
399 extern void lexclass( char * );
400 extern void lexmode( int );
401 extern int LexClassIndex( char * );
402 extern int hasAction( char * );
403 extern void setHasAction( char *, char * );
404 extern int addTname( char * );
405 extern int addTexpr( char * );
406 extern int Tnum( char * );
407 extern void Tklink( char *, char * );
408 extern Entry * newEntry( char *, int );
409 extern void list_add( ListNode **, void * );
410 extern void list_free( ListNode **, int freeData ); /* MR10 */
411 extern void list_apply( ListNode *, void (*)(void *) );
412 extern int list_search_cstring (ListNode *, char *); /* MR27 */
413 extern char * Fkey( char *, int, int );
414 extern void FoPush( char *, int );
415 extern void FoPop( int );
416 extern void RegisterCycle( char *, int );
417 extern void ResolveFoCycles( int );
418 extern void pJunc( Junction * );
419 extern void pRuleRef( RuleRefNode * );
420 extern void pToken( TokNode * );
421 extern void pAction( ActionNode * );
422 extern void FoLink( Node * );
423 extern void addFoLink( Node *, char *, Junction * );
424 extern void GenCrossRef( Junction * );
425 extern void defErr( char *, long, long, long, long, long, long );
426 extern void genStdPCCTSIncludeFile(FILE *,char *); /* MR10 */
427 extern char * pcctsBaseName(char *); /* MR32 */
428 extern Predicate *find_predicates(Node *); /* MR10 */
429 extern Predicate *MR_find_predicates_and_supp(Node *); /* MR13 */
430 extern int predicateLookaheadDepth(ActionNode *); /* MR10 */
431 extern void predicate_free(Predicate *); /* MR10 */
432 extern Predicate * predicate_dup(Predicate *); /* MR10 */
433 extern Predicate * predicate_dup_without_context(Predicate *); /* MR11 */
434 extern void GenRulePrototypes(FILE *, Junction *);
435 extern Junction *first_item_is_guess_block(Junction *);
436 extern Junction *first_item_is_guess_block_extra(Junction * q); /* MR30 */
437 extern Junction *analysis_point(Junction *);
438 extern Tree *make_tree_from_sets(set *, set *);
439 extern Tree *tdup_chain(Tree *);
440 extern Tree *tdif(Tree *, Predicate *, set *, set *);
441 extern set covered_set(Predicate *);
442 extern void AmbiguityDialog(Junction *, int, Junction *, Junction *, int *, int *);
443 extern void dumpAmbigMsg(set *, FILE *, int);
444 extern void GenRuleFuncRedefs(FILE *, Junction *);
445 extern void GenPredefinedSymbolRedefs(FILE *);
446 extern void GenASTSymbolRedefs(FILE *);
447 extern void GenRemapFile(void);
448 extern void GenSetRedefs(FILE *);
449 extern ForcedToken *newForcedToken(char *, int);
450 extern void RemapForcedTokens(void);
451 extern char *TokenOrExpr(int);
452 extern void setUpperRange(TokNode *, char *);
453 extern void GenParser_c_Hdr(void);
454 extern void GenParser_h_Hdr(void);
455 extern void GenRuleMemberDeclarationsForCC(FILE *, Junction *);
456 extern int addForcedTname( char *, int );
457 extern char *OutMetaName(char *);
458 extern void OutFirstSetSymbol(Junction *q, char *); /* MR21 */
459 extern void warnNoFL(char *err);
460 extern void warnFL(char *err,char *f,int l);
461 extern void warn(char *err);
462 extern void warnNoCR( char *err );
463 extern void errNoFL(char *err);
464 extern void errFL(char *err,char *f,int l);
465 extern void err(char *err);
466 extern void errNoCR( char *err );
467 extern void genPredTree( Predicate *p, Node *j, int ,int);
468 extern UserAction *newUserAction(char *);
469 extern char *gate_symbol(char *name);
470 extern char *makeAltID(int blockid, int altnum);
471 extern void DumpRemainingTokSets(void);
472 extern void DumpANSIFunctionArgDef(FILE *f, Junction *q, int bInit); /* MR23 */
473 extern void DumpFormals(FILE *, char *, int bInit); /* MR23 */
474 extern char* hideDefaultArgs(const char* pdecl); /* MR22 VHS */
475 extern Predicate *computePredFromContextGuard(Graph,int *msgDone); /* MR21 */
476 extern void recomputeContextGuard(Predicate *); /* MR13 */
477 extern Predicate *new_pred(void);
478 extern void chkGTFlag(void);
479 extern void leAdd(LabelEntry *); /* MR7 */
480 extern void leFixup(void); /* MR7 */
481 extern void egAdd(ExceptionGroup *); /* MR7 */
482 extern void egFixup(void); /* MR7 */
483 extern void altAdd(Junction *); /* MR7 */
484 extern void altFixup(void); /* MR7 */
485 extern Predicate * MR_find_in_aSubBlk(Junction *alt); /* MR10 */
486 extern Predicate * MR_predFlatten(Predicate *p); /* MR10 */
487 extern Predicate * MR_predSimplifyALL(Predicate *p); /* MR10 */
488 extern Predicate * MR_predSimplifyALLX(Predicate *p,int skipPass3); /* MR10 */
489 extern int MR_allPredLeaves(Predicate *p); /* MR10 */
490 extern void MR_cleanup_pred_trees(Predicate *p); /* MR10 */
491 extern int MR_predicate_context_completed(Predicate *p); /* MR10 */
492 extern void MR_check_pred_too_long(Predicate *p,set completion); /* MR10 */
493 extern Tree * MR_remove_epsilon_from_tree(Tree *t); /* MR10 */
494 extern Tree * MR_computeTreeAND(Tree *l,Tree *r); /* MR10 */
495 extern int MR_tree_equ(Tree *big, Tree *small); /* MR10 */
496 extern set MR_First(int ck,Junction *j,set *incomplete); /* MR10 */
497 extern set MR_compute_pred_set(Predicate *p); /* MR10 */
498 extern Tree * MR_compute_pred_tree_context(Predicate *p); /* MR10 */
499 extern int MR_pointerStackPush(PointerStack *,void *); /* MR10 */
500 extern void * MR_pointerStackPop(PointerStack *); /* MR10 */
501 extern void * MR_pointerStackTop(PointerStack *); /* MR10 */
502 extern void MR_pointerStackReset(PointerStack *); /* MR10 */
503 extern void MR_backTraceReport(void); /* MR10 */
504 extern void MR_alphaBetaTraceReport(void); /* MR14 */
505 extern void MR_dumpRuleSet(set); /* MR14 */
506 extern void MR_predContextPresent(Predicate *p,int *,int *); /* MR10 */
507 extern void MR_dumpPred(Predicate *p,int withContext); /* MR10 */
508 extern void MR_dumpPred1(int,Predicate *p,int withContext); /* MR10 */
509 extern void MR_xxxIndent(FILE *f,int depth); /* MR11 */
510 extern void MR_outputIndent(int depth); /* MR11 */
511 extern void MR_stderrIndent(int depth); /* MR11 */
512 extern Junction * MR_ruleReferenced(RuleRefNode *rrn); /* MR10 */
513 extern Junction * MR_nameToRuleBlk(char *); /* MR10 */
514 extern void MR_releaseResourcesUsedInRule(Node *); /* MR10 */
515 extern void MR_dumpTreeX(int depth,Tree *t,int across); /* MR10 */
516 extern void MR_dumpTreeF(FILE *f,int depth,Tree *t,int across); /* MR10 */
517 extern void DumpFcache(void); /* MR10 */
518 extern void MR_dumpTokenSet(FILE *f,int depth,set s); /* MR10 */
519 extern void MR_traceAmbSource(set *,Junction *,Junction *); /* MR11 */
520 extern void MR_traceAmbSourceK(Tree *,Junction *a1,Junction *a2); /* MR11 */
521 extern void MR_traceAmbSourceKclient(void); /* MR20 */
522 extern Node *MR_advance(Node *); /* MR11 */
523 extern int MR_offsetFromRule(Node *); /* MR11 */
524 extern char *MR_ruleNamePlusOffset(Node *); /* MR11 */
525 extern int MR_max_height_of_tree(Tree *); /* MR11 */
526 extern int MR_all_leaves_same_height(Tree *,int); /* MR11 */
527 extern void MR_projectTreeOntoSet(Tree *t,int k,set *); /* MR11 */
528 extern Tree *MR_make_tree_from_set(set); /* MR11 */
529 extern Predicate *MR_removeRedundantPredPass3(Predicate *); /* MR11 */
530 extern void MR_pred_depth(Predicate *,int *); /* MR11 */
531 extern int MR_comparePredicates(Predicate *,Predicate *); /* MR11 */
532 extern Predicate * MR_unfold(Predicate *); /* MR11 */
533 extern void MR_simplifyInverted(Predicate *,int); /* MR11 */
534 extern int MR_secondPredicateUnreachable /* MR11 */
535 (Predicate *first,Predicate *second); /* MR11 */
536 extern void MR_clearPredEntry(Predicate *); /* MR11 */
537 extern void MR_orphanRules(FILE *); /* MR12 */
538 extern void MR_merge_contexts(Tree *); /* MR12 */
539 extern int ci_strequ(char *,char *); /* MR12 */
540 extern void MR_guardPred_plainSet(ActionNode *anode,Predicate *); /* MR12c */
541 extern void MR_suppressSearchReport(void); /* MR12c */
542 extern Predicate * MR_suppressK(Node *,Predicate *); /* MR13 */
543 extern void MR_backTraceDumpItem(FILE *,int skip,Node *n); /* MR13 */
544 extern void MR_backTraceDumpItemReset(void); /* MR13 */
545 extern Junction * MR_junctionWithoutP2(Junction *); /* MR13 */
546 extern void MR_setConstrainPointer(set *); /* MR18 */
547 extern void BlockPreambleOption(Junction *q, char * pSymbol); /* MR23 */
548 extern char* getInitializer(char *); /* MR23 */
549 extern char *endFormal(char *pStart, /* MR23 */
550 char **ppDataType, /* MR23 */
551 char **ppSymbol, /* MR23 */
552 char **ppEqualSign, /* MR23 */
553 char **ppValue, /* MR23 */
554 char **ppSeparator, /* MR23 */
555 int *pNext); /* MR23 */
556 extern char *strBetween(char *pStart, /* MR23 */
557 char *pNext, /* MR23 */
558 char *pStop); /* MR23 */
559 extern int hasMultipleOperands(char *); /* MR23 */
560 extern void DumpInitializers(FILE*, RuleEntry*, char*); /* MR23 */
561 extern int isTermEntryTokClass(TermEntry *); /* MR23 */
562 extern int isEmptyAlt(Node *, Node *); /* MR23 */
563 #else
564 extern int STRICMP();
565 extern void istackreset();
566 extern int istacksize();
567 extern void pushint();
568 extern int popint();
569 extern int istackempty();
570 extern int topint();
571 extern void NewSetWd();
572 extern void DumpSetWd();
573 extern void DumpSetWdForC();
574 extern void DumpSetWdForCC();
575 extern void NewSet();
576 extern void FillSet();
577 extern void ComputeErrorSets();
578 extern void ComputeTokSets();
579 extern void SubstErrorClass();
580 extern int DefErrSet();
581 extern int DefErrSetForC();
582 extern int DefErrSetForCC();
583 extern int DefErrSet1();
584 extern int DefErrSetForC1();
585 extern int DefErrSetForCC1();
586 extern int DefErrSetWithSuffix(); /* MR21 */
587 extern void GenErrHdr();
588 extern void dumpExpr();
589 extern void addParm();
590 extern Graph buildAction();
591 extern Graph buildToken();
592 extern Graph buildWildCard();
593 extern Graph buildRuleRef();
594 extern Graph Or();
595 extern Graph Cat();
596 extern Graph makeOpt();
597 extern Graph makeBlk();
598 extern Graph makeLoop();
599 extern Graph makePlus();
600 extern Graph emptyAlt();
601 extern Graph emptyAlt3();
602 extern TokNode * newTokNode();
603 extern RuleRefNode * newRNode();
604 extern Junction * newJunction();
605 extern ActionNode * newActionNode();
606 extern char * makelocks();
607 extern void preorder();
608 extern Tree * tnode();
609 extern void _Tfree();
610 extern Tree * tdup();
611 extern int is_single_tuple();
612 extern Tree * tappend();
613 extern void Tfree();
614 extern Tree * tlink();
615 extern Tree * tshrink();
616 extern Tree * tflatten();
617 extern Tree * tJunc();
618 extern Tree * tRuleRef();
619 extern Tree * tToken();
620 extern Tree * tAction();
621 extern int tmember();
622 extern int tmember_constrained();
623 extern Tree * tleft_factor();
624 extern Tree * trm_perm();
625 extern void tcvt();
626 extern Tree * permute();
627 extern Tree * VerifyAmbig();
628 extern set rJunc();
629 extern set rRuleRef();
630 extern set rToken();
631 extern set rAction();
632 extern void HandleAmbiguity();
633 extern set First();
634 extern void freeBlkFsets();
635 extern void genAction();
636 extern void genRuleRef();
637 extern void genToken();
638 extern void genOptBlk();
639 extern void genLoopBlk();
640 extern void genLoopBegin();
641 extern void genPlusBlk();
642 extern void genSubBlk();
643 extern void genRule();
644 extern void genJunction();
645 extern void genEndBlk();
646 extern void genEndRule();
647 extern void genHdr();
648 extern void genHdr1();
649 extern void dumpAction();
650 extern void dumpActionPlus(); /* MR21 */
651 extern Entry ** newHashTable();
652 extern Entry * hash_add();
653 extern Entry * hash_get();
654 extern void hashStat();
655 extern char * mystrdup();
656 extern void genLexDescr();
657 extern void dumpLexClasses();
658 extern void genDefFile();
659 extern void DumpListOfParmNames(); /* MR5 janm 26-May-97 */
660 extern int DumpNextNameInDef();
661 extern void DumpOldStyleParms();
662 extern void DumpType();
663 extern int strmember();
664 /* extern int HasComma(); MR23 Replaced by hasMultipleOperands() */
665 extern void DumpRetValStruct();
666 extern char * StripQuotes();
667 extern int main();
668 extern void readDescr();
669 extern FILE * NextFile();
670 extern char * outnameX();
671 extern char * outname();
672 extern void fatalFL();
673 extern void fatal_intern();
674 extern void cleanUp();
675 extern char * eMsg3();
676 extern char * eMsgd();
677 extern char * eMsgd2();
678 extern void s_fprT();
679 extern char * TerminalString();
680 extern void lexclass();
681 extern void lexmode();
682 extern int LexClassIndex();
683 extern int hasAction();
684 extern void setHasAction();
685 extern int addTname();
686 extern int addTexpr();
687 extern int Tnum();
688 extern void Tklink();
689 extern Entry * newEntry();
690 extern void list_add();
691 extern void list_free(); /* MR10 */
692 extern void list_apply();
693 extern int list_search_cstring (); /* MR27 */
694 extern char * Fkey();
695 extern void FoPush();
696 extern void FoPop();
697 extern void RegisterCycle();
698 extern void ResolveFoCycles();
699 extern void pJunc();
700 extern void pRuleRef();
701 extern void pToken();
702 extern void pAction();
703 extern void FoLink();
704 extern void addFoLink();
705 extern void GenCrossRef();
706 extern void defErr();
707 extern void genStdPCCTSIncludeFile();
708 extern char * pcctsBaseName(); /* MR32 */
709 extern Predicate *find_predicates();
710 extern Predicate *MR_find_predicates_and_supp(); /* MR13 */
711 extern int predicateLookaheadDepth(); /* MR10 */
712 extern void predicate_free(); /* MR10 */
713 extern Predicate * predicate_dup(); /* MR10 */
714 extern Predicate * predicate_dup_without_context(); /* MR11 */
715 extern void GenRulePrototypes();
716 extern Junction *first_item_is_guess_block();
717 extern Junction *first_item_is_guess_block_extra(); /* MR30 */
718 extern Junction *analysis_point();
719 extern Tree *make_tree_from_sets();
720 extern Tree *tdup_chain();
721 extern Tree *tdif();
722 extern set covered_set();
723 extern void AmbiguityDialog();
724 extern void dumpAmbigMsg();
725 extern void GenRuleFuncRedefs();
726 extern void GenPredefinedSymbolRedefs();
727 extern void GenASTSymbolRedefs();
728 extern void GenRemapFile();
729 extern void GenSetRedefs();
730 extern ForcedToken *newForcedToken();
731 extern void RemapForcedTokens();
732 extern char *TokenOrExpr();
733 extern void setUpperRange();
734 extern void GenParser_c_Hdr();
735 extern void GenParser_h_Hdr();
736 extern void GenRuleMemberDeclarationsForCC();
737 extern int addForcedTname();
738 extern char *OutMetaName();
739 extern void OutFirstSetSymbol(); /* MR21 */
740 extern void warnNoFL();
741 extern void warnFL();
742 extern void warn();
743 extern void warnNoCR();
744 extern void errNoFL();
745 extern void errFL();
746 extern void err();
747 extern void errNoCR();
748 extern void genPredTree();
749 extern UserAction *newUserAction();
750 extern char *gate_symbol();
751 extern char *makeAltID();
752 extern void DumpRemainingTokSets();
753 extern void DumpANSIFunctionArgDef();
754 extern void DumpFormals(); /* MR23 */
755 extern char* hideDefaultArgs(); /* MR22 VHS */
756 extern Predicate *computePredFromContextGuard();
757 extern void recomputeContextGuard(); /* MR13 */
758 extern Predicate *new_pred();
759 extern void chkGTFlag();
760 extern void leAdd(); /* MR7 */
761 extern void leFixup(); /* MR7 */
762 extern void egAdd(); /* MR7 */
763 extern void egFixup(); /* MR7 */
764 extern void altAdd(); /* MR7 */
765 extern void altFixup(); /* MR7 */
766 extern Predicate * MR_find_in_aSubBlk(); /* MR10 */
767 extern Predicate * MR_predFlatten(); /* MR10 */
768 extern Predicate * MR_predSimplifyALL(); /* MR10 */
769 extern Predicate * MR_predSimplifyALLX(); /* MR10 */
770 extern void MR_cleanup_pred_trees(); /* MR10 */
771 extern int MR_allPredLeaves(); /* MR10 */
772 extern int MR_predicate_context_completed(); /* MR10 */
773 extern void MR_check_pred_too_long(); /* MR10 */
774 extern Tree * MR_remove_epsilon_from_tree(); /* MR10 */
775 extern Tree * MR_computeTreeAND(); /* MR10 */
776 extern int MR_tree_equ(); /* MR10 */
777 extern set MR_First(); /* MR10 */
778 extern set MR_compute_pred_set(); /* MR10 */
779 extern Tree * MR_compute_pred_tree_context(); /* MR10 */
780 extern int MR_pointerStackPush(); /* MR10 */
781 extern void * MR_pointerStackPop(); /* MR10 */
782 extern void * MR_pointerStackTop(); /* MR10 */
783 extern void MR_pointerStackReset(); /* MR10 */
784 extern void MR_backTraceReport(); /* MR10 */
785 extern void MR_alphaBetaTraceReport(); /* MR14 */
786 extern void MR_dumpRuleSet(); /* MR14 */
787 extern void MR_predContextPresent(); /* MR10 */
788 extern void MR_dumpPred(); /* MR10 */
789 extern void MR_dumpPred1(); /* MR10 */
790 extern void MR_xxxIndent(); /* MR11 */
791 extern void MR_stderrIndent(); /* MR11 */
792 extern void MR_outputIndent(); /* MR11 */
793 extern Junction * MR_ruleReferenced(); /* MR10 */
794 extern void MR_releaseResourcesUsedInRule(); /* MR10 */
795 extern void MR_dumpTreeX(); /* MR10 */
796 extern void MR_dumpTreeF(); /* MR10 */
797 extern void DumpFcache(); /* MR10 */
798 extern void MR_dumpTokenSet(); /* MR10 */
799 extern void MR_traceAmbSource(); /* MR11 */
800 extern Node *MR_advance(); /* MR11 */
801 extern int MR_offsetFromRule(); /* MR11 */
802 extern char *MR_ruleNamePlusOffset(); /* MR11 */
803 extern void MR_traceAmbSourceK(); /* MR11 */
804 extern void MR_traceAmbSourceKclient(); /* [i_a] added */
805 extern int MR_max_height_of_tree(); /* MR11 */
806 extern int MR_all_leaves_same_height(); /* MR11 */
807 extern void MR_projectTreeOntoSet(); /* MR11 */
808 extern Tree *MR_make_tree_from_set(); /* MR11 */
809 extern Predicate *MR_removeRedundantPredPass3(); /* MR11 */
810 extern void MR_pred_depth(); /* MR11 */
811 extern int MR_comparePredicates(); /* MR11 */
812 extern Predicate * MR_unfold(); /* MR11 */
813 extern void MR_simplifyInverted(); /* MR11 */
814 extern int MR_secondPredicateUnreachable(); /* MR11 */
815 extern Junction * MR_nameToRuleBlk(); /* MR10 */
816 extern void MR_clearPredEntry(); /* MR11 */
817 extern void MR_orphanRules(); /* MR12 */
818 extern void MR_merge_contexts(); /* MR12 */
819 extern int ci_strequ(); /* MR12 */
820 extern void MR_guardPred_plainSet(); /* MR12c */
821 extern void MR_suppressSearchReport(); /* MR12c */
822 extern Predicate * MR_suppressK(); /* MR13 */
823 extern void MR_backTraceDumpItem(); /* MR13 */
824 extern void MR_backTraceDumpItemReset(); /* MR13 */
825 extern Junction * MR_junctionWithoutP2(); /* MR13 */
826 extern void MR_setConstrainPointer(); /* MR18 */
827 extern void BlockPreambleOption(); /* MR23 */
828 extern char* getInitializer(); /* MR23 */
829 extern int hasMultipleOperands(); /* MR23 */
830 extern char *endFormal(); /* MR23 */
831 extern char *strBetween(); /* MR23 */
832 extern void DumpInitializers(); /* MR23 */
833 extern int isTermEntryTokClass(); /* MR23 */
834 extern int isEmptyAlt();
835
836 #endif
837
838 #ifdef __USE_PROTOS
839 #include <stdlib.h>
840 #endif
841
842 /* MR20 G. Hobbelt Create proper externs for dlg variables */
843
844 extern set attribsRefdFromAction;
845 extern int inAlt;
846 extern int UsedOldStyleAttrib;
847 extern int UsedNewStyleLabel;
848
849 #define MAX_BLK_LEVEL 100 /* MR23 */
850 extern int CurBlockID_array[MAX_BLK_LEVEL]; /* MR23 */
851 extern int CurAltNum_array[MAX_BLK_LEVEL]; /* MR23 */
+0
-5735
contrib/pccts/antlr/scan.c less more
0
1 /* parser.dlg -- DLG Description of scanner
2 *
3 * Generated from: ./antlr.g
4 *
5 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
6 * Purdue University Electrical Engineering
7 * With AHPCRC, University of Minnesota
8 * ANTLR Version 1.33MR33
9 */
10
11 #define ANTLR_VERSION 13333
12 #include "pcctscfg.h"
13 #include "pccts_stdio.h"
14
15 #include "pcctscfg.h"
16 #include "set.h"
17 #include <ctype.h>
18 #include "syn.h"
19 #include "hash.h"
20 #include "generic.h"
21 #define zzcr_attr(attr,tok,t)
22 #include "antlr.h"
23 #include "tokens.h"
24 #include "dlgdef.h"
25 LOOKAHEAD
26
27 void
28 #ifdef __USE_PROTOS
29 zzerraction(void)
30 #else
31 zzerraction()
32 #endif
33 {
34 (*zzerr)("invalid token");
35 zzadvance();
36 zzskip();
37 }
38 /*
39 * D L G tables
40 *
41 * Generated from: ./parser.dlg
42 *
43 * 1989-2001 by Will Cohen, Terence Parr, and Hank Dietz
44 * Purdue University Electrical Engineering
45 * DLG Version 1.33MR33
46 */
47
48 #include "mode.h"
49
50
51
52
53 /* maintained, but not used for now */
54 set AST_nodes_refd_in_actions = set_init;
55 int inAlt = 0;
56 set attribsRefdFromAction = set_init; /* MR20 */
57 int UsedOldStyleAttrib = 0;
58 int UsedNewStyleLabel = 0;
59 #ifdef __USE_PROTOS
60 char *inline_set(char *);
61 #else
62 char *inline_set();
63 #endif
64
65 /* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */
66 /* MR1 in DLG action */
67
68 int tokenActionActive=0; /* MR1 */
69
70
71
72
73
74 static char *
75 #ifdef __USE_PROTOS
76 getFileNameFromTheLineInfo(char *toStr, char *fromStr)
77 #else
78 getFileNameFromTheLineInfo(toStr, fromStr)
79 char *toStr, *fromStr;
80 #endif
81 {
82 int i, j, k;
83
84 if (!fromStr || !toStr) return toStr;
85
86 /* find the first " */
87
88 for (i=0;
89 (i<MaxFileName) &&
90 (fromStr[i] != '\n') &&
91 (fromStr[i] != '\r') &&
92 (fromStr[i] != '\"');
93 i++) /* nothing */ ;
94
95 if ( (i == MaxFileName) ||
96 (fromStr[i] == '\n') ||
97 (fromStr[i] == '\r') ) {
98 return toStr;
99 }
100
101 /* find the second " */
102
103 for (j=i+1;
104 (j<MaxFileName) &&
105 (fromStr[j] != '\n') &&
106 (fromStr[j] != '\r') &&
107 (fromStr[j] != '\"');
108 j++) /* nothing */ ;
109
110 if ((j == MaxFileName) ||
111 (fromStr[j] == '\n') ||
112 (fromStr[j] == '\r') ) {
113 return toStr;
114 }
115
116 /* go back until the last / or \ */
117
118 for (k=j-1;
119 (fromStr[k] != '\"') &&
120 (fromStr[k] != '/') &&
121 (fromStr[k] != '\\');
122 k--) /* nothing */ ;
123
124 /* copy the string after " / or \ into toStr */
125
126 for (i=k+1; fromStr[i] != '\"'; i++) {
127 toStr[i-k-1] = fromStr[i];
128 }
129
130 toStr[i-k-1] = '\0';
131
132 return toStr;
133 }
134
135 /* MR14 end of a block to support #line in antlr source code */
136
137
138
139
140 #ifdef __USE_PROTOS
141 void mark_label_used_in_sem_pred(LabelEntry *le) /* MR10 */
142 #else
143 void mark_label_used_in_sem_pred(le) /* MR10 */
144 LabelEntry *le;
145 #endif
146 {
147 TokNode *tn;
148 require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken");
149 tn=(TokNode *)le->elem;
150 require (tn->label != 0,"mark_label_used... TokNode has no label");
151 tn->label_used_in_semantic_pred=1;
152 }
153
154 static void act1()
155 {
156 NLA = Eof;
157 /* L o o k F o r A n o t h e r F i l e */
158 {
159 FILE *new_input;
160 new_input = NextFile();
161 if ( new_input == NULL ) { NLA=Eof; return; }
162 fclose( input );
163 input = new_input;
164 zzrdstream( input );
165 zzskip(); /* Skip the Eof (@) char i.e continue */
166 }
167 }
168
169
170 static void act2()
171 {
172 NLA = 76;
173 zzskip();
174 }
175
176
177 static void act3()
178 {
179 NLA = 77;
180 zzline++; zzskip();
181 }
182
183
184 static void act4()
185 {
186 NLA = 78;
187 zzmode(ACTIONS); zzmore();
188 istackreset();
189 pushint(']');
190 }
191
192
193 static void act5()
194 {
195 NLA = 79;
196 action_file=CurFile; action_line=zzline;
197 zzmode(ACTIONS); zzmore();
198 list_free(&CurActionLabels,0); /* MR10 */
199 numericActionLabel=0; /* MR10 */
200 istackreset();
201 pushint('>');
202 }
203
204
205 static void act6()
206 {
207 NLA = 80;
208 zzmode(STRINGS); zzmore();
209 }
210
211
212 static void act7()
213 {
214 NLA = 81;
215 zzmode(COMMENTS); zzskip();
216 }
217
218
219 static void act8()
220 {
221 NLA = 82;
222 warn("Missing /*; found dangling */"); zzskip();
223 }
224
225
226 static void act9()
227 {
228 NLA = 83;
229 zzmode(CPP_COMMENTS); zzskip();
230 }
231
232
233 static void act10()
234 {
235 NLA = 84;
236
237 zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();
238 getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);
239 }
240
241
242 static void act11()
243 {
244 NLA = 85;
245
246 zzline++; zzmore();
247 }
248
249
250 static void act12()
251 {
252 NLA = 86;
253 warn("Missing <<; found dangling >>"); zzskip();
254 }
255
256
257 static void act13()
258 {
259 NLA = WildCard;
260 }
261
262
263 static void act14()
264 {
265 NLA = 88;
266 FoundException = 1; /* MR6 */
267 FoundAtOperator = 1;
268 }
269
270
271 static void act15()
272 {
273 NLA = Pragma;
274 }
275
276
277 static void act16()
278 {
279 NLA = FirstSetSymbol;
280 }
281
282
283 static void act17()
284 {
285 NLA = 94;
286 }
287
288
289 static void act18()
290 {
291 NLA = 95;
292 }
293
294
295 static void act19()
296 {
297 NLA = 96;
298 }
299
300
301 static void act20()
302 {
303 NLA = 97;
304 }
305
306
307 static void act21()
308 {
309 NLA = 98;
310 }
311
312
313 static void act22()
314 {
315 NLA = 99;
316 }
317
318
319 static void act23()
320 {
321 NLA = 102;
322 }
323
324
325 static void act24()
326 {
327 NLA = 103;
328 }
329
330
331 static void act25()
332 {
333 NLA = 104;
334 }
335
336
337 static void act26()
338 {
339 NLA = 105;
340 }
341
342
343 static void act27()
344 {
345 NLA = 106;
346 }
347
348
349 static void act28()
350 {
351 NLA = 107;
352 }
353
354
355 static void act29()
356 {
357 NLA = 108;
358 }
359
360
361 static void act30()
362 {
363 NLA = 109;
364 }
365
366
367 static void act31()
368 {
369 NLA = 110;
370 }
371
372
373 static void act32()
374 {
375 NLA = 111;
376 }
377
378
379 static void act33()
380 {
381 NLA = 112;
382 }
383
384
385 static void act34()
386 {
387 NLA = 113;
388 }
389
390
391 static void act35()
392 {
393 NLA = 114;
394 }
395
396
397 static void act36()
398 {
399 NLA = 115;
400 }
401
402
403 static void act37()
404 {
405 NLA = 116;
406 }
407
408
409 static void act38()
410 {
411 NLA = 117;
412 }
413
414
415 static void act39()
416 {
417 NLA = 118;
418 }
419
420
421 static void act40()
422 {
423 NLA = 119;
424 }
425
426
427 static void act41()
428 {
429 NLA = 120;
430 }
431
432
433 static void act42()
434 {
435 NLA = 121;
436 }
437
438
439 static void act43()
440 {
441 NLA = 122;
442 }
443
444
445 static void act44()
446 {
447 NLA = 123;
448 }
449
450
451 static void act45()
452 {
453 NLA = 124;
454 }
455
456
457 static void act46()
458 {
459 NLA = 125;
460 }
461
462
463 static void act47()
464 {
465 NLA = 126;
466 }
467
468
469 static void act48()
470 {
471 NLA = 127;
472 }
473
474
475 static void act49()
476 {
477 NLA = 128;
478 }
479
480
481 static void act50()
482 {
483 NLA = 129;
484 }
485
486
487 static void act51()
488 {
489 NLA = 130;
490 }
491
492
493 static void act52()
494 {
495 NLA = 131;
496 }
497
498
499 static void act53()
500 {
501 NLA = 132;
502 }
503
504
505 static void act54()
506 {
507 NLA = 133;
508 }
509
510
511 static void act55()
512 {
513 NLA = 134;
514 }
515
516
517 static void act56()
518 {
519 NLA = 135;
520 }
521
522
523 static void act57()
524 {
525 NLA = NonTerminal;
526
527 while ( zzchar==' ' || zzchar=='\t' ) {
528 zzadvance();
529 }
530 if ( zzchar == ':' && inAlt ) NLA = LABEL;
531 }
532
533
534 static void act58()
535 {
536 NLA = TokenTerm;
537
538 while ( zzchar==' ' || zzchar=='\t' ) {
539 zzadvance();
540 }
541 if ( zzchar == ':' && inAlt ) NLA = LABEL;
542 }
543
544
545 static void act59()
546 {
547 NLA = 136;
548 warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip();
549 }
550
551 static unsigned char shift0[257] = {
552 0, 58, 58, 58, 58, 58, 58, 58, 58, 58,
553 1, 2, 58, 58, 3, 58, 58, 58, 58, 58,
554 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
555 58, 58, 58, 1, 40, 6, 9, 58, 58, 45,
556 58, 46, 47, 8, 52, 58, 58, 18, 7, 16,
557 14, 15, 16, 16, 16, 16, 16, 16, 16, 41,
558 42, 5, 48, 17, 53, 19, 56, 56, 56, 56,
559 56, 26, 56, 56, 56, 56, 56, 51, 56, 56,
560 56, 56, 56, 56, 29, 56, 56, 56, 56, 56,
561 56, 56, 4, 20, 58, 50, 57, 58, 23, 31,
562 38, 34, 13, 35, 24, 33, 11, 55, 36, 10,
563 25, 12, 32, 21, 55, 22, 27, 28, 54, 55,
564 55, 43, 30, 55, 39, 44, 37, 49, 58, 58,
565 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
566 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
567 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
568 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
569 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
570 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
571 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
572 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
573 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
574 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
575 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
576 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
577 58, 58, 58, 58, 58, 58, 58
578 };
579
580
581 static void act60()
582 {
583 NLA = Eof;
584 }
585
586
587 static void act61()
588 {
589 NLA = QuotedTerm;
590 zzmode(START);
591 }
592
593
594 static void act62()
595 {
596 NLA = 3;
597
598 zzline++;
599 warn("eoln found in string");
600 zzskip();
601 }
602
603
604 static void act63()
605 {
606 NLA = 4;
607 zzline++; zzmore();
608 }
609
610
611 static void act64()
612 {
613 NLA = 5;
614 zzmore();
615 }
616
617
618 static void act65()
619 {
620 NLA = 6;
621 zzmore();
622 }
623
624 static unsigned char shift1[257] = {
625 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
626 5, 2, 5, 5, 3, 5, 5, 5, 5, 5,
627 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
628 5, 5, 5, 5, 5, 1, 5, 5, 5, 5,
629 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
630 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
631 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
632 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
633 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
634 5, 5, 5, 4, 5, 5, 5, 5, 5, 5,
635 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
636 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
637 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
638 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
639 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
640 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
641 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
642 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
643 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
644 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
645 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
646 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
647 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
648 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
649 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
650 5, 5, 5, 5, 5, 5, 5
651 };
652
653
654 static void act66()
655 {
656 NLA = Eof;
657 }
658
659
660 static void act67()
661 {
662 NLA = 7;
663 zzmode(ACTIONS); zzmore();
664 }
665
666
667 static void act68()
668 {
669 NLA = 8;
670
671 zzline++;
672 warn("eoln found in string (in user action)");
673 zzskip();
674 }
675
676
677 static void act69()
678 {
679 NLA = 9;
680 zzline++; zzmore();
681 }
682
683
684 static void act70()
685 {
686 NLA = 10;
687 zzmore();
688 }
689
690
691 static void act71()
692 {
693 NLA = 11;
694 zzmore();
695 }
696
697 static unsigned char shift2[257] = {
698 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
699 5, 2, 5, 5, 3, 5, 5, 5, 5, 5,
700 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
701 5, 5, 5, 5, 5, 1, 5, 5, 5, 5,
702 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
703 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
704 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
705 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
706 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
707 5, 5, 5, 4, 5, 5, 5, 5, 5, 5,
708 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
709 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
710 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
711 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
712 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
713 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
714 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
715 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
716 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
717 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
718 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
719 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
720 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
721 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
722 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
723 5, 5, 5, 5, 5, 5, 5
724 };
725
726
727 static void act72()
728 {
729 NLA = Eof;
730 }
731
732
733 static void act73()
734 {
735 NLA = 12;
736 zzmode(ACTIONS); zzmore();
737 }
738
739
740 static void act74()
741 {
742 NLA = 13;
743
744 zzline++;
745 warn("eoln found in char literal (in user action)");
746 zzskip();
747 }
748
749
750 static void act75()
751 {
752 NLA = 14;
753 zzmore();
754 }
755
756
757 static void act76()
758 {
759 NLA = 15;
760 zzmore();
761 }
762
763 static unsigned char shift3[257] = {
764 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
765 5, 2, 5, 5, 3, 5, 5, 5, 5, 5,
766 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
767 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
768 1, 5, 5, 5, 5, 5, 5, 5, 5, 5,
769 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
770 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
771 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
772 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
773 5, 5, 5, 4, 5, 5, 5, 5, 5, 5,
774 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
775 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
776 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
777 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
778 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
779 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
780 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
781 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
782 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
783 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
784 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
785 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
786 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
787 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
788 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
789 5, 5, 5, 5, 5, 5, 5
790 };
791
792
793 static void act77()
794 {
795 NLA = Eof;
796 }
797
798
799 static void act78()
800 {
801 NLA = 16;
802 zzmode(ACTIONS); zzmore();
803 }
804
805
806 static void act79()
807 {
808 NLA = 17;
809 zzmore();
810 }
811
812
813 static void act80()
814 {
815 NLA = 18;
816 zzline++; zzmore(); DAWDLE;
817 }
818
819
820 static void act81()
821 {
822 NLA = 19;
823 zzmore();
824 }
825
826 static unsigned char shift4[257] = {
827 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
828 5, 3, 5, 5, 4, 5, 5, 5, 5, 5,
829 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
830 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
831 5, 5, 5, 1, 5, 5, 5, 5, 2, 5,
832 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
833 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
834 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
835 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
836 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
837 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
838 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
839 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
840 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
841 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
842 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
843 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
844 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
845 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
846 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
847 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
848 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
849 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
850 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
851 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
852 5, 5, 5, 5, 5, 5, 5
853 };
854
855
856 static void act82()
857 {
858 NLA = Eof;
859 }
860
861
862 static void act83()
863 {
864 NLA = 20;
865 zzmode(PARSE_ENUM_FILE);
866 zzmore();
867 }
868
869
870 static void act84()
871 {
872 NLA = 21;
873 zzmore();
874 }
875
876
877 static void act85()
878 {
879 NLA = 22;
880 zzline++; zzmore(); DAWDLE;
881 }
882
883
884 static void act86()
885 {
886 NLA = 23;
887 zzmore();
888 }
889
890 static unsigned char shift5[257] = {
891 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
892 5, 3, 5, 5, 4, 5, 5, 5, 5, 5,
893 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
894 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
895 5, 5, 5, 1, 5, 5, 5, 5, 2, 5,
896 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
897 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
898 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
899 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
900 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
901 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
902 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
903 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
904 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
905 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
906 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
907 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
908 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
909 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
910 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
911 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
912 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
913 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
914 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
915 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
916 5, 5, 5, 5, 5, 5, 5
917 };
918
919
920 static void act87()
921 {
922 NLA = Eof;
923 }
924
925
926 static void act88()
927 {
928 NLA = 24;
929 zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE;
930 }
931
932
933 static void act89()
934 {
935 NLA = 25;
936 zzskip();
937 }
938
939 static unsigned char shift6[257] = {
940 0, 3, 3, 3, 3, 3, 3, 3, 3, 3,
941 3, 1, 3, 3, 2, 3, 3, 3, 3, 3,
942 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
943 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
944 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
945 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
946 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
947 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
948 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
949 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
950 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
951 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
952 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
953 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
954 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
955 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
956 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
957 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
958 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
959 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
960 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
961 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
962 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
963 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
964 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
965 3, 3, 3, 3, 3, 3, 3
966 };
967
968
969 static void act90()
970 {
971 NLA = Eof;
972 }
973
974
975 static void act91()
976 {
977 NLA = 26;
978 zzline++; zzmode(ACTIONS); zzmore(); DAWDLE;
979 }
980
981
982 static void act92()
983 {
984 NLA = 27;
985 zzmore();
986 }
987
988 static unsigned char shift7[257] = {
989 0, 3, 3, 3, 3, 3, 3, 3, 3, 3,
990 3, 1, 3, 3, 2, 3, 3, 3, 3, 3,
991 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
992 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
993 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
994 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
995 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
996 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
997 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
998 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
999 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1000 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1001 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1002 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1003 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1004 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1005 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1006 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1007 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1008 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1009 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1010 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1011 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1012 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1013 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1014 3, 3, 3, 3, 3, 3, 3
1015 };
1016
1017
1018 static void act93()
1019 {
1020 NLA = Eof;
1021 }
1022
1023
1024 static void act94()
1025 {
1026 NLA = 28;
1027 zzline++; zzmode(START); zzskip(); DAWDLE;
1028 }
1029
1030
1031 static void act95()
1032 {
1033 NLA = 29;
1034 zzskip();
1035 }
1036
1037 static unsigned char shift8[257] = {
1038 0, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1039 3, 1, 3, 3, 2, 3, 3, 3, 3, 3,
1040 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1041 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1042 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1043 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1044 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1045 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1046 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1047 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1048 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1049 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1050 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1051 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1052 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1053 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1054 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1055 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1056 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1057 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1058 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1059 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1060 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1061 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1062 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1063 3, 3, 3, 3, 3, 3, 3
1064 };
1065
1066
1067 static void act96()
1068 {
1069 NLA = Eof;
1070 }
1071
1072
1073 static void act97()
1074 {
1075 NLA = 30;
1076 zzmode(START); zzskip();
1077 }
1078
1079
1080 static void act98()
1081 {
1082 NLA = 31;
1083 zzskip();
1084 }
1085
1086
1087 static void act99()
1088 {
1089 NLA = 32;
1090 zzline++; zzskip(); DAWDLE;
1091 }
1092
1093
1094 static void act100()
1095 {
1096 NLA = 33;
1097 zzskip();
1098 }
1099
1100 static unsigned char shift9[257] = {
1101 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1102 5, 3, 5, 5, 4, 5, 5, 5, 5, 5,
1103 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1104 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1105 5, 5, 5, 1, 5, 5, 5, 5, 2, 5,
1106 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1107 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1108 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1109 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1110 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1111 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1112 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1113 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1114 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1115 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1116 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1117 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1118 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1119 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1120 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1121 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1122 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1123 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1124 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1125 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1126 5, 5, 5, 5, 5, 5, 5
1127 };
1128
1129
1130 static void act101()
1131 {
1132 NLA = Eof;
1133 }
1134
1135
1136 static void act102()
1137 {
1138 NLA = Action;
1139 /* these do not nest */
1140 zzmode(START);
1141 NLATEXT[0] = ' ';
1142 NLATEXT[1] = ' ';
1143 zzbegexpr[0] = ' ';
1144 zzbegexpr[1] = ' ';
1145 if ( zzbufovf ) {
1146 err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));
1147 }
1148
1149 /* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */
1150 /* MR1 in DLG action */
1151 /* MR1 Doesn't matter what kind of action it is - reset*/
1152
1153 tokenActionActive=0; /* MR1 */
1154 }
1155
1156
1157 static void act103()
1158 {
1159 NLA = Pred;
1160 /* these do not nest */
1161 zzmode(START);
1162 NLATEXT[0] = ' ';
1163 NLATEXT[1] = ' ';
1164 zzbegexpr[0] = '\0';
1165 if ( zzbufovf ) {
1166 err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));
1167 };
1168 #ifdef __cplusplus__
1169 /* MR10 */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);
1170 #else
1171 #ifdef __STDC__
1172 /* MR10 */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);
1173 #else
1174 #ifdef __USE_PROTOS
1175 /* MRxx */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);
1176 #else
1177 /* MR10 */ list_apply(CurActionLabels,mark_label_used_in_sem_pred);
1178 #endif
1179 #endif
1180 #endif
1181 }
1182
1183
1184 static void act104()
1185 {
1186 NLA = PassAction;
1187 if ( topint() == ']' ) {
1188 popint();
1189 if ( istackempty() ) /* terminate action */
1190 {
1191 zzmode(START);
1192 NLATEXT[0] = ' ';
1193 zzbegexpr[0] = ' ';
1194 if ( zzbufovf ) {
1195 err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));
1196 }
1197 }
1198 else {
1199 /* terminate $[..] and #[..] */
1200 if ( GenCC ) zzreplstr("))");
1201 else zzreplstr(")");
1202 zzmore();
1203 }
1204 }
1205 else if ( topint() == '|' ) { /* end of simple [...] */
1206 popint();
1207 zzmore();
1208 }
1209 else zzmore();
1210 }
1211
1212
1213 static void act105()
1214 {
1215 NLA = 37;
1216
1217 zzmore();
1218 zzreplstr(inline_set(zzbegexpr+
1219 strlen("consumeUntil(")));
1220 }
1221
1222
1223 static void act106()
1224 {
1225 NLA = 38;
1226 zzmore();
1227 }
1228
1229
1230 static void act107()
1231 {
1232 NLA = 39;
1233 zzline++; zzmore(); DAWDLE;
1234 }
1235
1236
1237 static void act108()
1238 {
1239 NLA = 40;
1240 zzmore();
1241 }
1242
1243
1244 static void act109()
1245 {
1246 NLA = 41;
1247 zzmore();
1248 }
1249
1250
1251 static void act110()
1252 {
1253 NLA = 42;
1254 if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}
1255 else err("$$ use invalid in C++ mode");
1256 }
1257
1258
1259 static void act111()
1260 {
1261 NLA = 43;
1262 if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}
1263 else err("$[] use invalid in C++ mode");
1264 }
1265
1266
1267 static void act112()
1268 {
1269 NLA = 44;
1270
1271 pushint(']');
1272 if ( !GenCC ) zzreplstr("zzconstr_attr(");
1273 else err("$[..] use invalid in C++ mode");
1274 zzmore();
1275 }
1276
1277
1278 static void act113()
1279 {
1280 NLA = 45;
1281 {
1282 static char buf[100];
1283 numericActionLabel=1; /* MR10 */
1284 if ( strlen(zzbegexpr)>(size_t)85 )
1285 fatal("$i attrib ref too big");
1286 set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
1287 if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",
1288 BlkLevel-1,zzbegexpr+1);
1289 else sprintf(buf,"_t%d%s",
1290 BlkLevel-1,zzbegexpr+1);
1291 zzreplstr(buf);
1292 zzmore();
1293 UsedOldStyleAttrib = 1;
1294 if ( UsedNewStyleLabel )
1295 err("cannot mix old-style $i with new-style labels");
1296 }
1297 }
1298
1299
1300 static void act114()
1301 {
1302 NLA = 46;
1303 {
1304 static char buf[100];
1305 numericActionLabel=1; /* MR10 */
1306 if ( strlen(zzbegexpr)>(size_t)85 )
1307 fatal("$i.field attrib ref too big");
1308 zzbegexpr[strlen(zzbegexpr)-1] = ' ';
1309 set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);
1310 if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",
1311 BlkLevel-1,zzbegexpr+1);
1312 else sprintf(buf,"_t%d%s.",
1313 BlkLevel-1,zzbegexpr+1);
1314 zzreplstr(buf);
1315 zzmore();
1316 UsedOldStyleAttrib = 1;
1317 if ( UsedNewStyleLabel )
1318 err("cannot mix old-style $i with new-style labels");
1319 }
1320 }
1321
1322
1323 static void act115()
1324 {
1325 NLA = 47;
1326 {
1327 static char buf[100];
1328 static char i[20], j[20];
1329 char *p,*q;
1330 numericActionLabel=1; /* MR10 */
1331 if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big");
1332 for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {
1333 if ( q == &i[20] )
1334 fatalFL("i of $i.j attrib ref too big",
1335 FileStr[CurFile], zzline );
1336 *q++ = *p;
1337 }
1338 *q = '\0';
1339 for (p++, q= &j[0]; *p!='\0'; p++) {
1340 if ( q == &j[20] )
1341 fatalFL("j of $i.j attrib ref too big",
1342 FileStr[CurFile], zzline );
1343 *q++ = *p;
1344 }
1345 *q = '\0';
1346 if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);
1347 else sprintf(buf,"_t%s%s",i,j);
1348 zzreplstr(buf);
1349 zzmore();
1350 UsedOldStyleAttrib = 1;
1351 if ( UsedNewStyleLabel )
1352 err("cannot mix old-style $i with new-style labels");
1353 }
1354 }
1355
1356
1357 static void act116()
1358 {
1359 NLA = 48;
1360 { static char buf[300]; LabelEntry *el;
1361 zzbegexpr[0] = ' ';
1362 if ( CurRule != NULL &&
1363 strcmp(CurRule, &zzbegexpr[1])==0 ) {
1364 if ( !GenCC ) zzreplstr("zzaRet");
1365 }
1366 else if ( CurRetDef != NULL &&
1367 strmember(CurRetDef, &zzbegexpr[1])) {
1368 if ( hasMultipleOperands( CurRetDef ) ) {
1369 require (strlen(zzbegexpr)<=(size_t)285,
1370 "$retval attrib ref too big");
1371 sprintf(buf,"_retv.%s",&zzbegexpr[1]);
1372 zzreplstr(buf);
1373 }
1374 else zzreplstr("_retv");
1375 }
1376 else if ( CurParmDef != NULL &&
1377 strmember(CurParmDef, &zzbegexpr[1])) {
1378 ;
1379 }
1380 else if ( Elabel==NULL ) {
1381 { err("$-variables in actions outside of rules are not allowed"); }
1382 } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) {
1383 /* MR10 */
1384 /* MR10 */ /* element labels might exist without an elem when */
1385 /* MR10 */ /* it is a forward reference (to a rule) */
1386 /* MR10 */
1387 /* MR10 */ if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) )
1388 /* MR10 */ { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); }
1389 /* MR10 */
1390 /* MR10 */ if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) {
1391 /* MR10 */ err("You can no longer use attributes returned by rules when also using ASTs");
1392 /* MR10 */ err(" Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...>>\")");
1393 /* MR10 */ };
1394 /* MR10 */
1395 /* MR10 */ /* keep track of <<... $label ...>> for semantic predicates in guess mode */
1396 /* MR10 */ /* element labels contain pointer to the owners node */
1397 /* MR10 */
1398 /* MR10 */ if (el->elem != NULL && el->elem->ntype == nToken) {
1399 /* MR10 */ list_add(&CurActionLabels,el);
1400 /* MR10 */ };
1401 }
1402 else
1403 warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1]));
1404 }
1405 zzmore();
1406 }
1407
1408
1409 static void act117()
1410 {
1411 NLA = 49;
1412 zzreplstr("(*_root)"); zzmore(); chkGTFlag();
1413 }
1414
1415
1416 static void act118()
1417 {
1418 NLA = 50;
1419 if ( GenCC ) {
1420 if (NewAST) zzreplstr("(newAST)");
1421 else zzreplstr("(new AST)");}
1422 else {zzreplstr("zzastnew()");} zzmore();
1423 chkGTFlag();
1424 }
1425
1426
1427 static void act119()
1428 {
1429 NLA = 51;
1430 zzreplstr("NULL"); zzmore(); chkGTFlag();
1431 }
1432
1433
1434 static void act120()
1435 {
1436 NLA = 52;
1437 {
1438 static char buf[100];
1439 if ( strlen(zzbegexpr)>(size_t)85 )
1440 fatal("#i AST ref too big");
1441 if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);
1442 else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);
1443 zzreplstr(buf);
1444 zzmore();
1445 set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);
1446 chkGTFlag();
1447 }
1448 }
1449
1450
1451 static void act121()
1452 {
1453 NLA = 53;
1454
1455 zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();
1456 getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);
1457 }
1458
1459
1460 static void act122()
1461 {
1462 NLA = 54;
1463
1464 zzline++; zzmore();
1465 }
1466
1467
1468 static void act123()
1469 {
1470 NLA = 55;
1471
1472 if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||
1473 strcmp(zzbegexpr, "#if")==0 ||
1474 strcmp(zzbegexpr, "#else")==0 ||
1475 strcmp(zzbegexpr, "#endif")==0 ||
1476 strcmp(zzbegexpr, "#ifndef")==0 ||
1477 strcmp(zzbegexpr, "#define")==0 ||
1478 strcmp(zzbegexpr, "#pragma")==0 ||
1479 strcmp(zzbegexpr, "#undef")==0 ||
1480 strcmp(zzbegexpr, "#import")==0 ||
1481 strcmp(zzbegexpr, "#line")==0 ||
1482 strcmp(zzbegexpr, "#include")==0 ||
1483 strcmp(zzbegexpr, "#error")==0) )
1484 {
1485 static char buf[100];
1486 sprintf(buf, "%s_ast", zzbegexpr+1);
1487 /* MR27 */ list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1));
1488 zzreplstr(buf);
1489 chkGTFlag();
1490 }
1491 zzmore();
1492 }
1493
1494
1495 static void act124()
1496 {
1497 NLA = 56;
1498
1499 pushint(']');
1500 if ( GenCC ) {
1501 if (NewAST) zzreplstr("(newAST(");
1502 else zzreplstr("(new AST("); }
1503 else zzreplstr("zzmk_ast(zzastnew(),");
1504 zzmore();
1505 chkGTFlag();
1506 }
1507
1508
1509 static void act125()
1510 {
1511 NLA = 57;
1512
1513 pushint('}');
1514 if ( GenCC ) {
1515 if (tmakeInParser) {
1516 zzreplstr("tmake(");
1517 }
1518 else {
1519 zzreplstr("ASTBase::tmake(");
1520 }
1521 }
1522 else {
1523 zzreplstr("zztmake(");
1524 }
1525 zzmore();
1526 chkGTFlag();
1527 }
1528
1529
1530 static void act126()
1531 {
1532 NLA = 58;
1533 zzmore();
1534 }
1535
1536
1537 static void act127()
1538 {
1539 NLA = 59;
1540
1541 if ( istackempty() )
1542 zzmore();
1543 else if ( topint()==')' ) {
1544 popint();
1545 }
1546 else if ( topint()=='}' ) {
1547 popint();
1548 /* terminate #(..) */
1549 zzreplstr(", NULL)");
1550 }
1551 zzmore();
1552 }
1553
1554
1555 static void act128()
1556 {
1557 NLA = 60;
1558
1559 pushint('|'); /* look for '|' to terminate simple [...] */
1560 zzmore();
1561 }
1562
1563
1564 static void act129()
1565 {
1566 NLA = 61;
1567
1568 pushint(')');
1569 zzmore();
1570 }
1571
1572
1573 static void act130()
1574 {
1575 NLA = 62;
1576 zzreplstr("]"); zzmore();
1577 }
1578
1579
1580 static void act131()
1581 {
1582 NLA = 63;
1583 zzreplstr(")"); zzmore();
1584 }
1585
1586
1587 static void act132()
1588 {
1589 NLA = 64;
1590 if (! tokenActionActive) zzreplstr(">"); /* MR1 */
1591 zzmore(); /* MR1 */
1592 }
1593
1594
1595 static void act133()
1596 {
1597 NLA = 65;
1598 zzmode(ACTION_CHARS); zzmore();
1599 }
1600
1601
1602 static void act134()
1603 {
1604 NLA = 66;
1605 zzmode(ACTION_STRINGS); zzmore();
1606 }
1607
1608
1609 static void act135()
1610 {
1611 NLA = 67;
1612 zzreplstr("$"); zzmore();
1613 }
1614
1615
1616 static void act136()
1617 {
1618 NLA = 68;
1619 zzreplstr("#"); zzmore();
1620 }
1621
1622
1623 static void act137()
1624 {
1625 NLA = 69;
1626 zzline++; zzmore();
1627 }
1628
1629
1630 static void act138()
1631 {
1632 NLA = 70;
1633 zzmore();
1634 }
1635
1636
1637 static void act139()
1638 {
1639 NLA = 71;
1640 zzmore();
1641 }
1642
1643
1644 static void act140()
1645 {
1646 NLA = 72;
1647 zzmode(ACTION_COMMENTS); zzmore();
1648 }
1649
1650
1651 static void act141()
1652 {
1653 NLA = 73;
1654 warn("Missing /*; found dangling */ in action"); zzmore();
1655 }
1656
1657
1658 static void act142()
1659 {
1660 NLA = 74;
1661 zzmode(ACTION_CPP_COMMENTS); zzmore();
1662 }
1663
1664
1665 static void act143()
1666 {
1667 NLA = 75;
1668 zzmore();
1669 }
1670
1671 static unsigned char shift10[257] = {
1672 0, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1673 16, 19, 33, 33, 20, 33, 33, 33, 33, 33,
1674 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1675 33, 33, 33, 16, 33, 28, 27, 21, 33, 33,
1676 30, 15, 18, 32, 33, 33, 33, 25, 31, 23,
1677 24, 24, 24, 24, 24, 24, 24, 24, 24, 33,
1678 33, 33, 33, 1, 2, 33, 26, 26, 26, 26,
1679 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
1680 26, 26, 26, 26, 26, 26, 11, 26, 26, 26,
1681 26, 26, 22, 29, 3, 33, 26, 33, 26, 26,
1682 4, 26, 10, 26, 26, 26, 13, 26, 26, 14,
1683 9, 6, 5, 26, 26, 26, 7, 12, 8, 26,
1684 26, 26, 26, 26, 17, 33, 34, 33, 33, 33,
1685 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1686 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1687 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1688 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1689 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1690 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1691 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1692 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1693 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1694 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1695 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1696 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1697 33, 33, 33, 33, 33, 33, 33
1698 };
1699
1700
1701 static void act144()
1702 {
1703 NLA = Eof;
1704 ;
1705 }
1706
1707
1708 static void act145()
1709 {
1710 NLA = 137;
1711 zzskip();
1712 }
1713
1714
1715 static void act146()
1716 {
1717 NLA = 138;
1718 zzline++; zzskip();
1719 }
1720
1721
1722 static void act147()
1723 {
1724 NLA = 139;
1725 zzmode(TOK_DEF_CPP_COMMENTS); zzmore();
1726 }
1727
1728
1729 static void act148()
1730 {
1731 NLA = 140;
1732 zzmode(TOK_DEF_COMMENTS); zzskip();
1733 }
1734
1735
1736 static void act149()
1737 {
1738 NLA = 141;
1739 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1740 }
1741
1742
1743 static void act150()
1744 {
1745 NLA = 142;
1746 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1747 }
1748
1749
1750 static void act151()
1751 {
1752 NLA = 143;
1753 ;
1754 }
1755
1756
1757 static void act152()
1758 {
1759 NLA = 144;
1760 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1761 }
1762
1763
1764 static void act153()
1765 {
1766 NLA = 145;
1767 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1768 }
1769
1770
1771 static void act154()
1772 {
1773 NLA = 146;
1774 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1775 }
1776
1777
1778 static void act155()
1779 {
1780 NLA = 147;
1781 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1782 }
1783
1784
1785 static void act156()
1786 {
1787 NLA = 149;
1788 }
1789
1790
1791 static void act157()
1792 {
1793 NLA = 151;
1794 }
1795
1796
1797 static void act158()
1798 {
1799 NLA = 152;
1800 }
1801
1802
1803 static void act159()
1804 {
1805 NLA = 153;
1806 }
1807
1808
1809 static void act160()
1810 {
1811 NLA = 154;
1812 }
1813
1814
1815 static void act161()
1816 {
1817 NLA = 155;
1818 }
1819
1820
1821 static void act162()
1822 {
1823 NLA = 156;
1824 }
1825
1826
1827 static void act163()
1828 {
1829 NLA = INT;
1830 }
1831
1832
1833 static void act164()
1834 {
1835 NLA = ID;
1836 }
1837
1838 static unsigned char shift11[257] = {
1839 0, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1840 1, 2, 27, 27, 3, 27, 27, 27, 27, 27,
1841 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1842 27, 27, 27, 1, 27, 27, 6, 27, 27, 27,
1843 27, 27, 27, 5, 27, 22, 27, 27, 4, 25,
1844 25, 25, 25, 25, 25, 25, 25, 25, 25, 27,
1845 24, 27, 21, 27, 27, 27, 26, 26, 26, 26,
1846 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
1847 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
1848 26, 26, 27, 27, 27, 27, 26, 27, 26, 26,
1849 26, 9, 10, 8, 26, 26, 7, 26, 26, 12,
1850 15, 11, 17, 16, 26, 18, 13, 19, 14, 26,
1851 26, 26, 26, 26, 20, 27, 23, 27, 27, 27,
1852 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1853 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1854 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1855 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1856 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1857 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1858 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1859 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1860 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1861 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1862 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1863 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1864 27, 27, 27, 27, 27, 27, 27
1865 };
1866
1867 #define DfaStates 436
1868 typedef unsigned short DfaState;
1869
1870 static DfaState st0[60] = {
1871 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1872 11, 11, 11, 12, 13, 13, 13, 14, 15, 16,
1873 17, 11, 11, 18, 11, 11, 19, 11, 11, 19,
1874 11, 11, 11, 11, 20, 11, 11, 21, 22, 23,
1875 24, 25, 26, 11, 27, 28, 29, 30, 31, 32,
1876 33, 34, 35, 36, 11, 11, 19, 436, 436, 436
1877 };
1878
1879 static DfaState st1[60] = {
1880 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1881 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1882 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1883 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1884 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1885 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1886 };
1887
1888 static DfaState st2[60] = {
1889 436, 2, 436, 436, 436, 436, 436, 436, 436, 436,
1890 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1891 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1892 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1893 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1894 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1895 };
1896
1897 static DfaState st3[60] = {
1898 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1899 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1900 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1901 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1902 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1903 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1904 };
1905
1906 static DfaState st4[60] = {
1907 436, 436, 37, 436, 436, 436, 436, 436, 436, 436,
1908 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1909 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1910 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1911 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1912 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1913 };
1914
1915 static DfaState st5[60] = {
1916 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1917 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1918 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1919 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1920 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1921 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1922 };
1923
1924 static DfaState st6[60] = {
1925 436, 436, 436, 436, 436, 38, 436, 436, 436, 436,
1926 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1927 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1928 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1929 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1930 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1931 };
1932
1933 static DfaState st7[60] = {
1934 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1935 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1936 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1937 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1938 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1939 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1940 };
1941
1942 static DfaState st8[60] = {
1943 436, 436, 436, 436, 436, 436, 436, 39, 40, 436,
1944 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1945 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1946 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1947 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1948 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1949 };
1950
1951 static DfaState st9[60] = {
1952 436, 436, 436, 436, 436, 436, 436, 41, 436, 436,
1953 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1954 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1955 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1956 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1957 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1958 };
1959
1960 static DfaState st10[60] = {
1961 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1962 42, 43, 43, 44, 43, 43, 43, 436, 436, 436,
1963 436, 45, 43, 43, 43, 43, 46, 43, 47, 43,
1964 43, 43, 43, 48, 43, 49, 43, 436, 43, 436,
1965 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
1966 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
1967 };
1968
1969 static DfaState st11[60] = {
1970 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1971 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
1972 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
1973 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
1974 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
1975 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
1976 };
1977
1978 static DfaState st12[60] = {
1979 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1980 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
1981 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
1982 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
1983 436, 436, 436, 51, 436, 436, 436, 436, 436, 436,
1984 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
1985 };
1986
1987 static DfaState st13[60] = {
1988 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1989 436, 436, 436, 436, 13, 13, 13, 436, 436, 436,
1990 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1991 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1992 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1993 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
1994 };
1995
1996 static DfaState st14[60] = {
1997 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
1998 436, 436, 436, 436, 436, 436, 436, 52, 436, 436,
1999 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2000 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2001 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2002 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2003 };
2004
2005 static DfaState st15[60] = {
2006 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2007 436, 436, 436, 436, 436, 436, 436, 436, 53, 436,
2008 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2009 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2010 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2011 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2012 };
2013
2014 static DfaState st16[60] = {
2015 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2016 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2017 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2018 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2019 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2020 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2021 };
2022
2023 static DfaState st17[60] = {
2024 436, 436, 436, 436, 436, 436, 436, 436, 436, 54,
2025 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2026 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2027 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2028 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2029 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2030 };
2031
2032 static DfaState st18[60] = {
2033 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2034 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2035 436, 55, 50, 50, 50, 50, 50, 50, 50, 50,
2036 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2037 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2038 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2039 };
2040
2041 static DfaState st19[60] = {
2042 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2043 56, 56, 56, 56, 56, 56, 56, 436, 436, 436,
2044 436, 56, 56, 56, 56, 56, 56, 56, 56, 56,
2045 56, 56, 56, 56, 56, 56, 56, 436, 56, 436,
2046 436, 436, 436, 56, 436, 436, 436, 436, 436, 436,
2047 436, 56, 436, 436, 56, 56, 56, 56, 436, 436
2048 };
2049
2050 static DfaState st20[60] = {
2051 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2052 50, 50, 50, 57, 50, 50, 50, 436, 436, 436,
2053 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2054 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2055 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2056 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2057 };
2058
2059 static DfaState st21[60] = {
2060 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2061 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2062 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2063 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2064 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2065 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2066 };
2067
2068 static DfaState st22[60] = {
2069 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2070 58, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2071 436, 50, 50, 59, 50, 50, 50, 50, 50, 50,
2072 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2073 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2074 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2075 };
2076
2077 static DfaState st23[60] = {
2078 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2079 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2080 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2081 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2082 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2083 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2084 };
2085
2086 static DfaState st24[60] = {
2087 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2088 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2089 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2090 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2091 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2092 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2093 };
2094
2095 static DfaState st25[60] = {
2096 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2097 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2098 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2099 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2100 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2101 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2102 };
2103
2104 static DfaState st26[60] = {
2105 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2106 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2107 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2108 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2109 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2110 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2111 };
2112
2113 static DfaState st27[60] = {
2114 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2115 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2116 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2117 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2118 436, 436, 436, 436, 60, 436, 436, 436, 436, 436,
2119 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2120 };
2121
2122 static DfaState st28[60] = {
2123 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2124 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2125 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2126 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2127 436, 436, 436, 436, 436, 61, 436, 436, 436, 436,
2128 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2129 };
2130
2131 static DfaState st29[60] = {
2132 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2133 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2134 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2135 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2136 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2137 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2138 };
2139
2140 static DfaState st30[60] = {
2141 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2142 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2143 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2144 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2145 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2146 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2147 };
2148
2149 static DfaState st31[60] = {
2150 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2151 436, 436, 436, 436, 436, 436, 436, 62, 436, 436,
2152 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2153 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2154 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2155 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2156 };
2157
2158 static DfaState st32[60] = {
2159 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2160 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2161 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2162 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2163 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2164 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2165 };
2166
2167 static DfaState st33[60] = {
2168 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2169 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2170 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2171 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2172 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2173 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2174 };
2175
2176 static DfaState st34[60] = {
2177 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2178 56, 56, 56, 56, 56, 56, 56, 436, 436, 436,
2179 436, 56, 56, 56, 56, 56, 56, 56, 56, 56,
2180 56, 56, 56, 56, 56, 56, 56, 436, 56, 436,
2181 436, 436, 436, 56, 436, 436, 436, 436, 436, 436,
2182 436, 63, 436, 436, 56, 56, 56, 56, 436, 436
2183 };
2184
2185 static DfaState st35[60] = {
2186 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2187 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2188 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2189 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2190 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2191 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2192 };
2193
2194 static DfaState st36[60] = {
2195 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2196 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2197 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2198 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2199 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2200 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2201 };
2202
2203 static DfaState st37[60] = {
2204 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2205 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2206 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2207 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2208 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2209 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2210 };
2211
2212 static DfaState st38[60] = {
2213 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2214 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2215 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2216 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2217 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2218 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2219 };
2220
2221 static DfaState st39[60] = {
2222 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2223 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2224 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2225 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2226 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2227 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2228 };
2229
2230 static DfaState st40[60] = {
2231 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2232 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2233 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2234 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2235 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2236 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2237 };
2238
2239 static DfaState st41[60] = {
2240 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2241 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2242 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2243 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2244 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2245 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2246 };
2247
2248 static DfaState st42[60] = {
2249 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2250 43, 64, 43, 65, 43, 43, 43, 436, 436, 436,
2251 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2252 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2253 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2254 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2255 };
2256
2257 static DfaState st43[60] = {
2258 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2259 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2260 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2261 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2262 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2263 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2264 };
2265
2266 static DfaState st44[60] = {
2267 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2268 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2269 436, 43, 66, 43, 43, 43, 43, 43, 43, 43,
2270 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2271 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2272 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2273 };
2274
2275 static DfaState st45[60] = {
2276 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2277 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2278 436, 43, 67, 68, 43, 43, 43, 43, 43, 43,
2279 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2280 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2281 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2282 };
2283
2284 static DfaState st46[60] = {
2285 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2286 43, 69, 43, 43, 43, 43, 43, 436, 436, 436,
2287 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2288 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2289 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2290 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2291 };
2292
2293 static DfaState st47[60] = {
2294 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2295 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2296 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2297 43, 43, 70, 43, 43, 43, 43, 436, 43, 436,
2298 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2299 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2300 };
2301
2302 static DfaState st48[60] = {
2303 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2304 43, 43, 43, 71, 43, 43, 43, 436, 436, 436,
2305 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2306 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2307 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2308 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2309 };
2310
2311 static DfaState st49[60] = {
2312 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2313 43, 72, 43, 43, 43, 43, 43, 436, 436, 436,
2314 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2315 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2316 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2317 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2318 };
2319
2320 static DfaState st50[60] = {
2321 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2322 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2323 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2324 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2325 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2326 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2327 };
2328
2329 static DfaState st51[60] = {
2330 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2331 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2332 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2333 50, 50, 50, 50, 50, 50, 50, 436, 73, 436,
2334 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2335 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2336 };
2337
2338 static DfaState st52[60] = {
2339 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2340 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2341 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2342 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2343 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2344 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2345 };
2346
2347 static DfaState st53[60] = {
2348 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2349 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2350 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2351 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2352 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2353 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2354 };
2355
2356 static DfaState st54[60] = {
2357 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2358 74, 43, 43, 44, 43, 43, 43, 436, 436, 436,
2359 436, 45, 43, 43, 43, 43, 46, 43, 47, 43,
2360 43, 43, 43, 48, 43, 49, 43, 436, 43, 436,
2361 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2362 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2363 };
2364
2365 static DfaState st55[60] = {
2366 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2367 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2368 436, 75, 50, 50, 50, 50, 50, 50, 50, 50,
2369 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2370 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2371 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2372 };
2373
2374 static DfaState st56[60] = {
2375 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2376 56, 56, 56, 56, 56, 56, 56, 436, 436, 436,
2377 436, 56, 56, 56, 56, 56, 56, 56, 56, 56,
2378 56, 56, 56, 56, 56, 56, 56, 436, 56, 436,
2379 436, 436, 436, 56, 436, 436, 436, 436, 436, 436,
2380 436, 56, 436, 436, 56, 56, 56, 56, 436, 436
2381 };
2382
2383 static DfaState st57[60] = {
2384 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2385 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2386 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2387 50, 50, 50, 50, 50, 76, 50, 436, 50, 436,
2388 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2389 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2390 };
2391
2392 static DfaState st58[60] = {
2393 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2394 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2395 436, 50, 50, 77, 50, 50, 50, 50, 50, 50,
2396 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2397 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2398 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2399 };
2400
2401 static DfaState st59[60] = {
2402 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2403 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2404 436, 50, 50, 50, 50, 50, 50, 50, 78, 50,
2405 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2406 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2407 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2408 };
2409
2410 static DfaState st60[60] = {
2411 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2412 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2413 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2414 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2415 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2416 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2417 };
2418
2419 static DfaState st61[60] = {
2420 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2421 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2422 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2423 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2424 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2425 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2426 };
2427
2428 static DfaState st62[60] = {
2429 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2430 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2431 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2432 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2433 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2434 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2435 };
2436
2437 static DfaState st63[60] = {
2438 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2439 56, 56, 56, 56, 56, 56, 56, 436, 436, 436,
2440 436, 56, 56, 56, 56, 56, 56, 56, 56, 56,
2441 56, 56, 56, 56, 56, 56, 56, 436, 56, 436,
2442 436, 436, 436, 56, 436, 436, 79, 436, 436, 436,
2443 436, 56, 436, 436, 56, 56, 56, 56, 436, 436
2444 };
2445
2446 static DfaState st64[60] = {
2447 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2448 43, 43, 80, 43, 43, 43, 43, 436, 436, 436,
2449 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2450 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2451 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2452 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2453 };
2454
2455 static DfaState st65[60] = {
2456 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2457 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2458 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2459 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2460 436, 436, 436, 81, 436, 436, 436, 436, 436, 436,
2461 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2462 };
2463
2464 static DfaState st66[60] = {
2465 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2466 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2467 436, 43, 82, 43, 43, 43, 43, 43, 43, 43,
2468 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2469 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2470 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2471 };
2472
2473 static DfaState st67[60] = {
2474 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2475 43, 43, 43, 83, 43, 43, 43, 436, 436, 436,
2476 436, 43, 43, 84, 43, 43, 43, 43, 43, 43,
2477 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2478 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2479 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2480 };
2481
2482 static DfaState st68[60] = {
2483 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2484 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2485 436, 43, 85, 43, 43, 43, 43, 43, 43, 43,
2486 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2487 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2488 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2489 };
2490
2491 static DfaState st69[60] = {
2492 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2493 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2494 436, 43, 86, 43, 43, 43, 43, 43, 43, 43,
2495 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2496 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2497 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2498 };
2499
2500 static DfaState st70[60] = {
2501 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2502 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2503 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2504 43, 43, 43, 43, 43, 43, 87, 436, 43, 436,
2505 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2506 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2507 };
2508
2509 static DfaState st71[60] = {
2510 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2511 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2512 436, 43, 43, 88, 43, 43, 43, 43, 43, 43,
2513 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2514 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2515 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2516 };
2517
2518 static DfaState st72[60] = {
2519 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2520 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2521 436, 43, 89, 43, 43, 43, 43, 43, 43, 43,
2522 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2523 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2524 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2525 };
2526
2527 static DfaState st73[60] = {
2528 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2529 50, 50, 50, 90, 50, 50, 50, 436, 436, 436,
2530 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2531 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2532 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2533 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2534 };
2535
2536 static DfaState st74[60] = {
2537 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2538 43, 43, 43, 65, 43, 43, 43, 436, 436, 436,
2539 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2540 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2541 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2542 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2543 };
2544
2545 static DfaState st75[60] = {
2546 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2547 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2548 436, 50, 91, 50, 50, 50, 50, 50, 50, 50,
2549 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2550 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2551 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2552 };
2553
2554 static DfaState st76[60] = {
2555 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2556 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2557 436, 50, 50, 92, 50, 50, 50, 50, 50, 50,
2558 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2559 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2560 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2561 };
2562
2563 static DfaState st77[60] = {
2564 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2565 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2566 436, 50, 50, 50, 50, 50, 50, 93, 50, 50,
2567 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2568 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2569 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2570 };
2571
2572 static DfaState st78[60] = {
2573 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2574 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2575 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2576 50, 50, 50, 50, 50, 50, 50, 436, 94, 436,
2577 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2578 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2579 };
2580
2581 static DfaState st79[60] = {
2582 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2583 436, 436, 436, 436, 95, 96, 436, 436, 436, 436,
2584 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2585 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2586 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2587 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2588 };
2589
2590 static DfaState st80[60] = {
2591 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2592 43, 43, 43, 97, 43, 43, 43, 436, 436, 436,
2593 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2594 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2595 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2596 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2597 };
2598
2599 static DfaState st81[60] = {
2600 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2601 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2602 436, 98, 43, 99, 43, 100, 43, 43, 43, 43,
2603 43, 43, 43, 43, 43, 43, 43, 436, 101, 436,
2604 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2605 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2606 };
2607
2608 static DfaState st82[60] = {
2609 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2610 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2611 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2612 43, 43, 43, 43, 43, 43, 43, 436, 102, 436,
2613 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2614 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2615 };
2616
2617 static DfaState st83[60] = {
2618 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2619 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2620 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2621 43, 43, 43, 43, 103, 43, 43, 436, 43, 436,
2622 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2623 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2624 };
2625
2626 static DfaState st84[60] = {
2627 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2628 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2629 436, 43, 43, 43, 104, 43, 43, 43, 43, 43,
2630 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2631 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2632 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2633 };
2634
2635 static DfaState st85[60] = {
2636 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2637 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2638 436, 43, 43, 43, 43, 43, 43, 105, 43, 43,
2639 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2640 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2641 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2642 };
2643
2644 static DfaState st86[60] = {
2645 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2646 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2647 436, 43, 43, 43, 43, 43, 43, 106, 43, 43,
2648 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2649 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2650 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2651 };
2652
2653 static DfaState st87[60] = {
2654 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2655 43, 43, 43, 107, 43, 43, 43, 436, 436, 436,
2656 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2657 43, 43, 43, 43, 108, 43, 43, 436, 109, 436,
2658 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2659 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2660 };
2661
2662 static DfaState st88[60] = {
2663 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2664 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2665 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2666 43, 43, 43, 43, 110, 43, 43, 436, 43, 436,
2667 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2668 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2669 };
2670
2671 static DfaState st89[60] = {
2672 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2673 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2674 436, 43, 43, 43, 43, 43, 43, 111, 43, 43,
2675 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2676 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2677 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2678 };
2679
2680 static DfaState st90[60] = {
2681 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2682 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2683 436, 112, 50, 50, 50, 50, 50, 50, 50, 50,
2684 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2685 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2686 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2687 };
2688
2689 static DfaState st91[60] = {
2690 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2691 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2692 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2693 50, 50, 113, 50, 50, 50, 50, 436, 50, 436,
2694 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2695 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2696 };
2697
2698 static DfaState st92[60] = {
2699 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2700 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2701 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2702 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2703 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2704 436, 50, 436, 436, 114, 50, 50, 50, 436, 436
2705 };
2706
2707 static DfaState st93[60] = {
2708 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2709 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2710 436, 50, 50, 50, 50, 50, 50, 115, 50, 50,
2711 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2712 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2713 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2714 };
2715
2716 static DfaState st94[60] = {
2717 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2718 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2719 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2720 50, 50, 50, 116, 50, 50, 50, 436, 50, 436,
2721 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2722 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2723 };
2724
2725 static DfaState st95[60] = {
2726 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2727 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2728 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2729 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2730 436, 436, 436, 436, 436, 436, 436, 117, 436, 436,
2731 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2732 };
2733
2734 static DfaState st96[60] = {
2735 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2736 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2737 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2738 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2739 436, 436, 436, 436, 436, 436, 436, 118, 436, 436,
2740 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2741 };
2742
2743 static DfaState st97[60] = {
2744 436, 119, 120, 121, 122, 122, 122, 122, 122, 122,
2745 123, 123, 123, 123, 124, 124, 124, 122, 122, 122,
2746 122, 123, 123, 123, 123, 123, 123, 123, 123, 123,
2747 123, 123, 123, 123, 123, 123, 123, 122, 123, 122,
2748 122, 122, 122, 123, 122, 122, 122, 122, 122, 122,
2749 122, 123, 122, 122, 123, 123, 123, 123, 122, 436
2750 };
2751
2752 static DfaState st98[60] = {
2753 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2754 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2755 436, 43, 125, 43, 43, 43, 43, 43, 43, 43,
2756 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2757 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2758 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2759 };
2760
2761 static DfaState st99[60] = {
2762 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2763 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2764 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2765 43, 43, 43, 43, 43, 43, 43, 436, 126, 436,
2766 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2767 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2768 };
2769
2770 static DfaState st100[60] = {
2771 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2772 43, 43, 43, 127, 43, 43, 43, 436, 436, 436,
2773 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2774 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2775 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2776 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2777 };
2778
2779 static DfaState st101[60] = {
2780 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2781 128, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2782 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2783 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2784 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2785 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2786 };
2787
2788 static DfaState st102[60] = {
2789 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2790 129, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2791 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2792 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2793 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2794 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2795 };
2796
2797 static DfaState st103[60] = {
2798 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2799 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2800 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2801 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2802 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2803 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2804 };
2805
2806 static DfaState st104[60] = {
2807 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2808 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2809 436, 43, 43, 43, 43, 130, 43, 43, 43, 43,
2810 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2811 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2812 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2813 };
2814
2815 static DfaState st105[60] = {
2816 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2817 43, 43, 43, 131, 43, 43, 43, 436, 436, 436,
2818 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2819 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2820 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2821 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2822 };
2823
2824 static DfaState st106[60] = {
2825 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2826 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2827 436, 43, 43, 43, 43, 43, 43, 43, 132, 43,
2828 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2829 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2830 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2831 };
2832
2833 static DfaState st107[60] = {
2834 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2835 43, 43, 133, 43, 43, 43, 43, 436, 436, 436,
2836 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2837 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2838 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2839 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2840 };
2841
2842 static DfaState st108[60] = {
2843 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2844 43, 43, 43, 134, 43, 43, 43, 436, 436, 436,
2845 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2846 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2847 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2848 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2849 };
2850
2851 static DfaState st109[60] = {
2852 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2853 135, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2854 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2855 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2856 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2857 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2858 };
2859
2860 static DfaState st110[60] = {
2861 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2862 43, 43, 43, 136, 43, 43, 43, 436, 436, 436,
2863 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2864 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2865 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2866 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2867 };
2868
2869 static DfaState st111[60] = {
2870 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2871 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
2872 436, 43, 43, 43, 43, 43, 43, 43, 137, 43,
2873 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
2874 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
2875 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
2876 };
2877
2878 static DfaState st112[60] = {
2879 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2880 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2881 436, 50, 50, 50, 50, 50, 50, 50, 138, 50,
2882 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2883 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2884 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2885 };
2886
2887 static DfaState st113[60] = {
2888 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2889 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2890 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2891 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2892 436, 436, 436, 139, 436, 436, 436, 436, 436, 436,
2893 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2894 };
2895
2896 static DfaState st114[60] = {
2897 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2898 140, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2899 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2900 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2901 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2902 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2903 };
2904
2905 static DfaState st115[60] = {
2906 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2907 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2908 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2909 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2910 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2911 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2912 };
2913
2914 static DfaState st116[60] = {
2915 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2916 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
2917 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
2918 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
2919 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
2920 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
2921 };
2922
2923 static DfaState st117[60] = {
2924 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2925 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2926 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2927 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2928 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2929 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2930 };
2931
2932 static DfaState st118[60] = {
2933 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2934 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2935 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2936 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2937 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2938 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2939 };
2940
2941 static DfaState st119[60] = {
2942 436, 119, 120, 121, 122, 122, 122, 122, 122, 122,
2943 122, 122, 122, 122, 141, 141, 141, 122, 122, 122,
2944 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
2945 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
2946 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
2947 122, 122, 122, 122, 122, 122, 122, 122, 122, 436
2948 };
2949
2950 static DfaState st120[60] = {
2951 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2952 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2953 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2954 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2955 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2956 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2957 };
2958
2959 static DfaState st121[60] = {
2960 436, 436, 142, 436, 436, 436, 436, 436, 436, 436,
2961 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2962 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2963 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2964 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2965 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
2966 };
2967
2968 static DfaState st122[60] = {
2969 436, 122, 120, 121, 122, 122, 122, 122, 122, 122,
2970 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
2971 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
2972 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
2973 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
2974 122, 122, 122, 122, 122, 122, 122, 122, 122, 436
2975 };
2976
2977 static DfaState st123[60] = {
2978 436, 122, 120, 121, 122, 122, 122, 122, 122, 122,
2979 123, 123, 123, 123, 123, 123, 123, 122, 122, 122,
2980 122, 123, 123, 123, 123, 123, 123, 123, 123, 123,
2981 123, 123, 123, 123, 123, 123, 123, 122, 123, 122,
2982 122, 122, 122, 123, 122, 122, 122, 122, 122, 122,
2983 122, 123, 122, 122, 123, 123, 123, 123, 122, 436
2984 };
2985
2986 static DfaState st124[60] = {
2987 436, 143, 144, 145, 122, 122, 146, 122, 122, 122,
2988 123, 123, 123, 123, 124, 124, 124, 122, 122, 122,
2989 122, 123, 123, 123, 123, 123, 123, 123, 123, 123,
2990 123, 123, 123, 123, 123, 123, 123, 122, 123, 122,
2991 122, 122, 122, 123, 122, 122, 122, 122, 122, 122,
2992 122, 123, 122, 122, 123, 123, 123, 123, 122, 436
2993 };
2994
2995 static DfaState st125[60] = {
2996 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
2997 43, 43, 43, 147, 43, 43, 43, 436, 436, 436,
2998 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
2999 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3000 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3001 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3002 };
3003
3004 static DfaState st126[60] = {
3005 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3006 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3007 436, 43, 43, 43, 43, 43, 43, 43, 148, 43,
3008 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3009 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3010 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3011 };
3012
3013 static DfaState st127[60] = {
3014 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3015 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3016 436, 43, 43, 43, 43, 149, 43, 43, 43, 43,
3017 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3018 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3019 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3020 };
3021
3022 static DfaState st128[60] = {
3023 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3024 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3025 436, 43, 43, 150, 43, 43, 43, 43, 43, 43,
3026 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3027 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3028 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3029 };
3030
3031 static DfaState st129[60] = {
3032 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3033 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3034 436, 43, 43, 151, 43, 43, 43, 43, 43, 43,
3035 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3036 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3037 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3038 };
3039
3040 static DfaState st130[60] = {
3041 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3042 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3043 436, 43, 43, 152, 43, 43, 43, 43, 43, 43,
3044 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3045 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3046 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3047 };
3048
3049 static DfaState st131[60] = {
3050 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3051 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3052 436, 43, 153, 43, 43, 43, 43, 43, 43, 43,
3053 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3054 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3055 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3056 };
3057
3058 static DfaState st132[60] = {
3059 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3060 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3061 436, 43, 43, 43, 43, 43, 43, 43, 43, 154,
3062 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3063 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3064 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3065 };
3066
3067 static DfaState st133[60] = {
3068 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3069 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3070 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3071 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3072 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3073 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3074 };
3075
3076 static DfaState st134[60] = {
3077 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3078 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3079 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3080 43, 43, 43, 43, 43, 155, 43, 436, 43, 436,
3081 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3082 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3083 };
3084
3085 static DfaState st135[60] = {
3086 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3087 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3088 436, 43, 43, 156, 43, 43, 43, 43, 43, 43,
3089 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3090 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3091 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3092 };
3093
3094 static DfaState st136[60] = {
3095 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3096 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3097 436, 43, 157, 43, 43, 43, 43, 43, 43, 43,
3098 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3099 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3100 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3101 };
3102
3103 static DfaState st137[60] = {
3104 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3105 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3106 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3107 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3108 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3109 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3110 };
3111
3112 static DfaState st138[60] = {
3113 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3114 50, 158, 50, 50, 50, 50, 50, 436, 436, 436,
3115 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
3116 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
3117 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
3118 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
3119 };
3120
3121 static DfaState st139[60] = {
3122 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3123 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
3124 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
3125 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
3126 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
3127 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
3128 };
3129
3130 static DfaState st140[60] = {
3131 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3132 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
3133 436, 50, 50, 50, 50, 50, 50, 50, 159, 50,
3134 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
3135 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
3136 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
3137 };
3138
3139 static DfaState st141[60] = {
3140 436, 143, 144, 145, 122, 122, 146, 122, 122, 122,
3141 122, 122, 122, 122, 141, 141, 141, 122, 122, 122,
3142 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3143 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3144 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3145 122, 122, 122, 122, 122, 122, 122, 122, 122, 436
3146 };
3147
3148 static DfaState st142[60] = {
3149 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3150 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3151 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3152 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3153 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3154 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3155 };
3156
3157 static DfaState st143[60] = {
3158 436, 143, 120, 121, 122, 122, 146, 122, 122, 122,
3159 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3160 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3161 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3162 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3163 122, 122, 122, 122, 122, 122, 122, 122, 122, 436
3164 };
3165
3166 static DfaState st144[60] = {
3167 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3168 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3169 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3170 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3171 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3172 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3173 };
3174
3175 static DfaState st145[60] = {
3176 436, 436, 160, 436, 436, 436, 436, 436, 436, 436,
3177 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3178 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3179 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3180 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3181 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3182 };
3183
3184 static DfaState st146[60] = {
3185 436, 161, 162, 163, 161, 161, 122, 161, 161, 161,
3186 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
3187 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
3188 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
3189 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
3190 161, 161, 161, 161, 161, 161, 161, 161, 161, 436
3191 };
3192
3193 static DfaState st147[60] = {
3194 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3195 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3196 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3197 43, 43, 43, 43, 43, 164, 43, 436, 43, 436,
3198 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3199 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3200 };
3201
3202 static DfaState st148[60] = {
3203 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3204 43, 165, 43, 43, 43, 43, 43, 436, 436, 436,
3205 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3206 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3207 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3208 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3209 };
3210
3211 static DfaState st149[60] = {
3212 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3213 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3214 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3215 43, 166, 43, 43, 43, 43, 43, 436, 43, 436,
3216 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3217 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3218 };
3219
3220 static DfaState st150[60] = {
3221 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3222 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3223 436, 43, 43, 43, 43, 43, 43, 167, 43, 43,
3224 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3225 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3226 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3227 };
3228
3229 static DfaState st151[60] = {
3230 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3231 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3232 436, 43, 43, 43, 43, 43, 43, 168, 43, 43,
3233 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3234 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3235 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3236 };
3237
3238 static DfaState st152[60] = {
3239 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3240 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3241 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3242 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3243 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3244 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3245 };
3246
3247 static DfaState st153[60] = {
3248 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3249 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3250 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3251 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3252 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3253 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3254 };
3255
3256 static DfaState st154[60] = {
3257 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3258 43, 43, 43, 169, 43, 43, 43, 436, 436, 436,
3259 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3260 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3261 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3262 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3263 };
3264
3265 static DfaState st155[60] = {
3266 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3267 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3268 436, 43, 43, 43, 43, 43, 43, 170, 43, 43,
3269 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3270 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3271 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3272 };
3273
3274 static DfaState st156[60] = {
3275 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3276 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3277 436, 43, 43, 43, 43, 43, 43, 171, 43, 43,
3278 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3279 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3280 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3281 };
3282
3283 static DfaState st157[60] = {
3284 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3285 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3286 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3287 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3288 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3289 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3290 };
3291
3292 static DfaState st158[60] = {
3293 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3294 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
3295 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
3296 50, 50, 172, 50, 50, 50, 50, 436, 50, 436,
3297 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
3298 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
3299 };
3300
3301 static DfaState st159[60] = {
3302 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3303 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
3304 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
3305 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
3306 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
3307 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
3308 };
3309
3310 static DfaState st160[60] = {
3311 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3312 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3313 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3314 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3315 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3316 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3317 };
3318
3319 static DfaState st161[60] = {
3320 436, 161, 162, 163, 161, 161, 173, 161, 161, 161,
3321 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
3322 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
3323 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
3324 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
3325 161, 161, 161, 161, 161, 161, 161, 161, 161, 436
3326 };
3327
3328 static DfaState st162[60] = {
3329 436, 174, 174, 174, 174, 174, 175, 174, 174, 174,
3330 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3331 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3332 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3333 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3334 174, 174, 174, 174, 174, 174, 174, 174, 174, 436
3335 };
3336
3337 static DfaState st163[60] = {
3338 436, 174, 176, 174, 174, 174, 175, 174, 174, 174,
3339 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3340 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3341 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3342 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3343 174, 174, 174, 174, 174, 174, 174, 174, 174, 436
3344 };
3345
3346 static DfaState st164[60] = {
3347 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3348 43, 177, 43, 43, 43, 43, 43, 436, 436, 436,
3349 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3350 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3351 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3352 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3353 };
3354
3355 static DfaState st165[60] = {
3356 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3357 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3358 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3359 43, 43, 178, 43, 43, 43, 43, 436, 43, 436,
3360 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3361 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3362 };
3363
3364 static DfaState st166[60] = {
3365 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3366 43, 43, 43, 179, 43, 43, 43, 436, 436, 436,
3367 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3368 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3369 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3370 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3371 };
3372
3373 static DfaState st167[60] = {
3374 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3375 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3376 436, 43, 43, 43, 43, 43, 43, 180, 43, 43,
3377 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3378 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3379 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3380 };
3381
3382 static DfaState st168[60] = {
3383 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3384 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3385 436, 43, 43, 43, 43, 43, 43, 181, 43, 43,
3386 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3387 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3388 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3389 };
3390
3391 static DfaState st169[60] = {
3392 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3393 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3394 436, 43, 43, 43, 43, 43, 43, 43, 182, 43,
3395 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3396 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3397 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3398 };
3399
3400 static DfaState st170[60] = {
3401 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3402 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3403 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3404 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3405 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3406 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3407 };
3408
3409 static DfaState st171[60] = {
3410 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3411 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3412 436, 43, 43, 43, 43, 43, 43, 183, 43, 43,
3413 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3414 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3415 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3416 };
3417
3418 static DfaState st172[60] = {
3419 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3420 50, 50, 184, 50, 50, 50, 50, 436, 436, 436,
3421 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
3422 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
3423 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
3424 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
3425 };
3426
3427 static DfaState st173[60] = {
3428 436, 185, 144, 145, 122, 122, 122, 122, 122, 122,
3429 122, 122, 122, 122, 186, 186, 186, 122, 122, 122,
3430 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3431 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3432 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3433 122, 122, 122, 122, 122, 122, 122, 122, 122, 436
3434 };
3435
3436 static DfaState st174[60] = {
3437 436, 174, 174, 174, 174, 174, 175, 174, 174, 174,
3438 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3439 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3440 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3441 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3442 174, 174, 174, 174, 174, 174, 174, 174, 174, 436
3443 };
3444
3445 static DfaState st175[60] = {
3446 436, 187, 188, 189, 436, 436, 436, 436, 436, 436,
3447 436, 436, 436, 436, 190, 190, 190, 436, 436, 436,
3448 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3449 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3450 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3451 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3452 };
3453
3454 static DfaState st176[60] = {
3455 436, 174, 174, 174, 174, 174, 175, 174, 174, 174,
3456 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3457 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3458 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3459 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
3460 174, 174, 174, 174, 174, 174, 174, 174, 174, 436
3461 };
3462
3463 static DfaState st177[60] = {
3464 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3465 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3466 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3467 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3468 436, 436, 436, 191, 436, 436, 436, 436, 436, 436,
3469 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3470 };
3471
3472 static DfaState st178[60] = {
3473 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3474 43, 43, 192, 43, 43, 43, 43, 436, 436, 436,
3475 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3476 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3477 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3478 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3479 };
3480
3481 static DfaState st179[60] = {
3482 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3483 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3484 436, 43, 193, 43, 43, 43, 43, 43, 43, 43,
3485 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3486 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3487 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3488 };
3489
3490 static DfaState st180[60] = {
3491 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3492 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3493 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3494 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3495 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3496 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3497 };
3498
3499 static DfaState st181[60] = {
3500 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3501 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3502 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3503 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3504 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3505 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3506 };
3507
3508 static DfaState st182[60] = {
3509 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3510 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3511 436, 43, 43, 43, 43, 43, 43, 43, 43, 194,
3512 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3513 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3514 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3515 };
3516
3517 static DfaState st183[60] = {
3518 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3519 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3520 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3521 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3522 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3523 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3524 };
3525
3526 static DfaState st184[60] = {
3527 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3528 50, 50, 50, 50, 50, 50, 50, 436, 436, 436,
3529 436, 50, 50, 50, 50, 50, 50, 50, 50, 50,
3530 50, 50, 50, 50, 50, 50, 50, 436, 50, 436,
3531 436, 436, 436, 50, 436, 436, 436, 436, 436, 436,
3532 436, 50, 436, 436, 50, 50, 50, 50, 436, 436
3533 };
3534
3535 static DfaState st185[60] = {
3536 436, 185, 144, 145, 122, 122, 122, 122, 122, 122,
3537 122, 122, 122, 122, 186, 186, 186, 122, 122, 122,
3538 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3539 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3540 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3541 122, 122, 122, 122, 122, 122, 122, 122, 122, 436
3542 };
3543
3544 static DfaState st186[60] = {
3545 436, 185, 144, 145, 122, 122, 122, 122, 122, 122,
3546 122, 122, 122, 122, 186, 186, 186, 122, 122, 122,
3547 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3548 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3549 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
3550 122, 122, 122, 122, 122, 122, 122, 122, 122, 436
3551 };
3552
3553 static DfaState st187[60] = {
3554 436, 187, 188, 189, 436, 436, 436, 436, 436, 436,
3555 436, 436, 436, 436, 190, 190, 190, 436, 436, 436,
3556 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3557 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3558 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3559 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3560 };
3561
3562 static DfaState st188[60] = {
3563 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3564 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3565 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3566 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3567 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3568 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3569 };
3570
3571 static DfaState st189[60] = {
3572 436, 436, 195, 436, 436, 436, 436, 436, 436, 436,
3573 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3574 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3575 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3576 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3577 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3578 };
3579
3580 static DfaState st190[60] = {
3581 436, 187, 188, 189, 436, 436, 436, 436, 436, 436,
3582 436, 436, 436, 436, 190, 190, 190, 436, 436, 436,
3583 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3584 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3585 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3586 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3587 };
3588
3589 static DfaState st191[60] = {
3590 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3591 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3592 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3593 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3594 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3595 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3596 };
3597
3598 static DfaState st192[60] = {
3599 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3600 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3601 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3602 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3603 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3604 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3605 };
3606
3607 static DfaState st193[60] = {
3608 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3609 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3610 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3611 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3612 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3613 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3614 };
3615
3616 static DfaState st194[60] = {
3617 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3618 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3619 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3620 196, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3621 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3622 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3623 };
3624
3625 static DfaState st195[60] = {
3626 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3627 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3628 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3629 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3630 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3631 436, 436, 436, 436, 436, 436, 436, 436, 436, 436
3632 };
3633
3634 static DfaState st196[60] = {
3635 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3636 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3637 436, 43, 43, 43, 43, 197, 43, 43, 43, 43,
3638 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3639 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3640 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3641 };
3642
3643 static DfaState st197[60] = {
3644 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3645 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3646 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3647 43, 198, 43, 43, 43, 43, 43, 436, 43, 436,
3648 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3649 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3650 };
3651
3652 static DfaState st198[60] = {
3653 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3654 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3655 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3656 43, 43, 199, 43, 43, 43, 43, 436, 43, 436,
3657 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3658 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3659 };
3660
3661 static DfaState st199[60] = {
3662 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3663 200, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3664 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3665 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3666 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3667 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3668 };
3669
3670 static DfaState st200[60] = {
3671 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3672 43, 43, 43, 43, 43, 43, 43, 436, 436, 436,
3673 436, 43, 43, 43, 43, 43, 43, 43, 43, 43,
3674 43, 43, 43, 43, 43, 43, 43, 436, 43, 436,
3675 436, 436, 436, 43, 436, 436, 436, 436, 436, 436,
3676 436, 43, 436, 436, 43, 43, 43, 43, 436, 436
3677 };
3678
3679 static DfaState st201[7] = {
3680 202, 203, 204, 205, 206, 207, 436
3681 };
3682
3683 static DfaState st202[7] = {
3684 436, 436, 436, 436, 436, 436, 436
3685 };
3686
3687 static DfaState st203[7] = {
3688 436, 436, 436, 436, 436, 436, 436
3689 };
3690
3691 static DfaState st204[7] = {
3692 436, 436, 436, 436, 436, 436, 436
3693 };
3694
3695 static DfaState st205[7] = {
3696 436, 436, 208, 436, 436, 436, 436
3697 };
3698
3699 static DfaState st206[7] = {
3700 436, 209, 210, 211, 209, 209, 436
3701 };
3702
3703 static DfaState st207[7] = {
3704 436, 436, 436, 436, 436, 207, 436
3705 };
3706
3707 static DfaState st208[7] = {
3708 436, 436, 436, 436, 436, 436, 436
3709 };
3710
3711 static DfaState st209[7] = {
3712 436, 436, 436, 436, 436, 436, 436
3713 };
3714
3715 static DfaState st210[7] = {
3716 436, 436, 436, 436, 436, 436, 436
3717 };
3718
3719 static DfaState st211[7] = {
3720 436, 436, 212, 436, 436, 436, 436
3721 };
3722
3723 static DfaState st212[7] = {
3724 436, 436, 436, 436, 436, 436, 436
3725 };
3726
3727 static DfaState st213[7] = {
3728 214, 215, 216, 217, 218, 219, 436
3729 };
3730
3731 static DfaState st214[7] = {
3732 436, 436, 436, 436, 436, 436, 436
3733 };
3734
3735 static DfaState st215[7] = {
3736 436, 436, 436, 436, 436, 436, 436
3737 };
3738
3739 static DfaState st216[7] = {
3740 436, 436, 436, 436, 436, 436, 436
3741 };
3742
3743 static DfaState st217[7] = {
3744 436, 436, 220, 436, 436, 436, 436
3745 };
3746
3747 static DfaState st218[7] = {
3748 436, 221, 222, 223, 221, 221, 436
3749 };
3750
3751 static DfaState st219[7] = {
3752 436, 436, 436, 436, 436, 219, 436
3753 };
3754
3755 static DfaState st220[7] = {
3756 436, 436, 436, 436, 436, 436, 436
3757 };
3758
3759 static DfaState st221[7] = {
3760 436, 436, 436, 436, 436, 436, 436
3761 };
3762
3763 static DfaState st222[7] = {
3764 436, 436, 436, 436, 436, 436, 436
3765 };
3766
3767 static DfaState st223[7] = {
3768 436, 436, 224, 436, 436, 436, 436
3769 };
3770
3771 static DfaState st224[7] = {
3772 436, 436, 436, 436, 436, 436, 436
3773 };
3774
3775 static DfaState st225[7] = {
3776 226, 227, 228, 229, 230, 231, 436
3777 };
3778
3779 static DfaState st226[7] = {
3780 436, 436, 436, 436, 436, 436, 436
3781 };
3782
3783 static DfaState st227[7] = {
3784 436, 436, 436, 436, 436, 436, 436
3785 };
3786
3787 static DfaState st228[7] = {
3788 436, 436, 436, 436, 436, 436, 436
3789 };
3790
3791 static DfaState st229[7] = {
3792 436, 436, 232, 436, 436, 436, 436
3793 };
3794
3795 static DfaState st230[7] = {
3796 436, 233, 233, 233, 233, 233, 436
3797 };
3798
3799 static DfaState st231[7] = {
3800 436, 436, 436, 436, 436, 231, 436
3801 };
3802
3803 static DfaState st232[7] = {
3804 436, 436, 436, 436, 436, 436, 436
3805 };
3806
3807 static DfaState st233[7] = {
3808 436, 436, 436, 436, 436, 436, 436
3809 };
3810
3811 static DfaState st234[7] = {
3812 235, 236, 237, 238, 239, 237, 436
3813 };
3814
3815 static DfaState st235[7] = {
3816 436, 436, 436, 436, 436, 436, 436
3817 };
3818
3819 static DfaState st236[7] = {
3820 436, 436, 240, 436, 436, 436, 436
3821 };
3822
3823 static DfaState st237[7] = {
3824 436, 436, 237, 436, 436, 237, 436
3825 };
3826
3827 static DfaState st238[7] = {
3828 436, 436, 436, 436, 436, 436, 436
3829 };
3830
3831 static DfaState st239[7] = {
3832 436, 436, 436, 241, 436, 436, 436
3833 };
3834
3835 static DfaState st240[7] = {
3836 436, 436, 436, 436, 436, 436, 436
3837 };
3838
3839 static DfaState st241[7] = {
3840 436, 436, 436, 436, 436, 436, 436
3841 };
3842
3843 static DfaState st242[7] = {
3844 243, 244, 245, 246, 247, 245, 436
3845 };
3846
3847 static DfaState st243[7] = {
3848 436, 436, 436, 436, 436, 436, 436
3849 };
3850
3851 static DfaState st244[7] = {
3852 436, 436, 248, 436, 436, 436, 436
3853 };
3854
3855 static DfaState st245[7] = {
3856 436, 436, 245, 436, 436, 245, 436
3857 };
3858
3859 static DfaState st246[7] = {
3860 436, 436, 436, 436, 436, 436, 436
3861 };
3862
3863 static DfaState st247[7] = {
3864 436, 436, 436, 249, 436, 436, 436
3865 };
3866
3867 static DfaState st248[7] = {
3868 436, 436, 436, 436, 436, 436, 436
3869 };
3870
3871 static DfaState st249[7] = {
3872 436, 436, 436, 436, 436, 436, 436
3873 };
3874
3875 static DfaState st250[5] = {
3876 251, 252, 253, 254, 436
3877 };
3878
3879 static DfaState st251[5] = {
3880 436, 436, 436, 436, 436
3881 };
3882
3883 static DfaState st252[5] = {
3884 436, 436, 436, 436, 436
3885 };
3886
3887 static DfaState st253[5] = {
3888 436, 255, 436, 436, 436
3889 };
3890
3891 static DfaState st254[5] = {
3892 436, 436, 436, 254, 436
3893 };
3894
3895 static DfaState st255[5] = {
3896 436, 436, 436, 436, 436
3897 };
3898
3899 static DfaState st256[5] = {
3900 257, 258, 259, 260, 436
3901 };
3902
3903 static DfaState st257[5] = {
3904 436, 436, 436, 436, 436
3905 };
3906
3907 static DfaState st258[5] = {
3908 436, 436, 436, 436, 436
3909 };
3910
3911 static DfaState st259[5] = {
3912 436, 261, 436, 436, 436
3913 };
3914
3915 static DfaState st260[5] = {
3916 436, 436, 436, 260, 436
3917 };
3918
3919 static DfaState st261[5] = {
3920 436, 436, 436, 436, 436
3921 };
3922
3923 static DfaState st262[5] = {
3924 263, 264, 265, 266, 436
3925 };
3926
3927 static DfaState st263[5] = {
3928 436, 436, 436, 436, 436
3929 };
3930
3931 static DfaState st264[5] = {
3932 436, 436, 436, 436, 436
3933 };
3934
3935 static DfaState st265[5] = {
3936 436, 267, 436, 436, 436
3937 };
3938
3939 static DfaState st266[5] = {
3940 436, 436, 436, 266, 436
3941 };
3942
3943 static DfaState st267[5] = {
3944 436, 436, 436, 436, 436
3945 };
3946
3947 static DfaState st268[7] = {
3948 269, 270, 271, 272, 273, 271, 436
3949 };
3950
3951 static DfaState st269[7] = {
3952 436, 436, 436, 436, 436, 436, 436
3953 };
3954
3955 static DfaState st270[7] = {
3956 436, 436, 274, 436, 436, 436, 436
3957 };
3958
3959 static DfaState st271[7] = {
3960 436, 436, 271, 436, 436, 271, 436
3961 };
3962
3963 static DfaState st272[7] = {
3964 436, 436, 436, 436, 436, 436, 436
3965 };
3966
3967 static DfaState st273[7] = {
3968 436, 436, 436, 275, 436, 436, 436
3969 };
3970
3971 static DfaState st274[7] = {
3972 436, 436, 436, 436, 436, 436, 436
3973 };
3974
3975 static DfaState st275[7] = {
3976 436, 436, 436, 436, 436, 436, 436
3977 };
3978
3979 static DfaState st276[36] = {
3980 277, 278, 279, 280, 281, 279, 279, 279, 279, 279,
3981 279, 279, 279, 279, 279, 282, 279, 279, 283, 284,
3982 285, 286, 287, 279, 279, 279, 279, 288, 289, 290,
3983 291, 292, 293, 279, 279, 436
3984 };
3985
3986 static DfaState st277[36] = {
3987 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3988 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3989 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3990 436, 436, 436, 436, 436, 436
3991 };
3992
3993 static DfaState st278[36] = {
3994 436, 294, 436, 436, 436, 436, 436, 436, 436, 436,
3995 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3996 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
3997 436, 436, 436, 436, 436, 436
3998 };
3999
4000 static DfaState st279[36] = {
4001 436, 436, 279, 436, 279, 279, 279, 279, 279, 279,
4002 279, 279, 279, 279, 279, 436, 279, 279, 436, 436,
4003 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4004 436, 436, 279, 279, 279, 436
4005 };
4006
4007 static DfaState st280[36] = {
4008 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4009 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4010 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4011 436, 436, 436, 436, 436, 436
4012 };
4013
4014 static DfaState st281[36] = {
4015 436, 436, 279, 436, 279, 295, 279, 279, 279, 279,
4016 279, 279, 279, 279, 279, 436, 279, 279, 436, 436,
4017 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4018 436, 436, 279, 279, 279, 436
4019 };
4020
4021 static DfaState st282[36] = {
4022 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4023 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4024 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4025 436, 436, 436, 436, 436, 436
4026 };
4027
4028 static DfaState st283[36] = {
4029 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4030 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4031 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4032 436, 436, 436, 436, 436, 436
4033 };
4034
4035 static DfaState st284[36] = {
4036 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4037 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4038 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4039 436, 436, 436, 436, 436, 436
4040 };
4041
4042 static DfaState st285[36] = {
4043 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4044 436, 436, 436, 436, 436, 436, 436, 436, 436, 296,
4045 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4046 436, 436, 436, 436, 436, 436
4047 };
4048
4049 static DfaState st286[36] = {
4050 436, 436, 436, 436, 297, 297, 297, 297, 297, 297,
4051 297, 297, 297, 297, 297, 436, 436, 436, 436, 436,
4052 436, 298, 299, 300, 300, 436, 297, 436, 436, 436,
4053 436, 436, 436, 436, 436, 436
4054 };
4055
4056 static DfaState st287[36] = {
4057 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4058 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4059 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4060 436, 436, 436, 436, 436, 436
4061 };
4062
4063 static DfaState st288[36] = {
4064 436, 436, 436, 436, 301, 301, 301, 301, 301, 301,
4065 301, 301, 301, 301, 302, 303, 436, 436, 436, 436,
4066 436, 436, 304, 305, 306, 436, 301, 436, 436, 436,
4067 436, 436, 436, 436, 436, 436
4068 };
4069
4070 static DfaState st289[36] = {
4071 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4072 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4073 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4074 436, 436, 436, 436, 436, 436
4075 };
4076
4077 static DfaState st290[36] = {
4078 436, 307, 308, 309, 308, 308, 308, 308, 308, 308,
4079 308, 308, 308, 308, 308, 308, 308, 308, 310, 311,
4080 312, 313, 308, 308, 308, 308, 308, 314, 308, 308,
4081 308, 308, 308, 308, 308, 436
4082 };
4083
4084 static DfaState st291[36] = {
4085 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4086 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4087 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4088 436, 436, 436, 436, 436, 436
4089 };
4090
4091 static DfaState st292[36] = {
4092 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4093 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4094 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4095 436, 315, 316, 436, 436, 436
4096 };
4097
4098 static DfaState st293[36] = {
4099 436, 436, 279, 436, 279, 279, 279, 279, 279, 279,
4100 279, 279, 279, 279, 279, 436, 279, 279, 436, 436,
4101 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4102 436, 317, 279, 279, 279, 436
4103 };
4104
4105 static DfaState st294[36] = {
4106 436, 436, 318, 436, 436, 436, 436, 436, 436, 436,
4107 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4108 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4109 436, 436, 436, 436, 436, 436
4110 };
4111
4112 static DfaState st295[36] = {
4113 436, 436, 279, 436, 279, 279, 319, 279, 279, 279,
4114 279, 279, 279, 279, 279, 436, 279, 279, 436, 436,
4115 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4116 436, 436, 279, 279, 279, 436
4117 };
4118
4119 static DfaState st296[36] = {
4120 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4121 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4122 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4123 436, 436, 436, 436, 436, 436
4124 };
4125
4126 static DfaState st297[36] = {
4127 436, 436, 436, 436, 320, 320, 320, 320, 320, 320,
4128 320, 320, 320, 320, 320, 436, 436, 436, 436, 436,
4129 436, 436, 436, 320, 320, 436, 320, 436, 436, 436,
4130 436, 436, 436, 436, 436, 436
4131 };
4132
4133 static DfaState st298[36] = {
4134 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4135 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4136 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4137 436, 436, 436, 436, 436, 436
4138 };
4139
4140 static DfaState st299[36] = {
4141 436, 436, 436, 321, 436, 436, 436, 436, 436, 436,
4142 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4143 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4144 436, 436, 436, 436, 436, 436
4145 };
4146
4147 static DfaState st300[36] = {
4148 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4149 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4150 436, 436, 436, 300, 300, 322, 436, 436, 436, 436,
4151 436, 436, 436, 436, 436, 436
4152 };
4153
4154 static DfaState st301[36] = {
4155 436, 436, 436, 436, 323, 323, 323, 323, 323, 323,
4156 323, 323, 323, 323, 323, 436, 436, 436, 436, 436,
4157 436, 436, 436, 323, 323, 436, 323, 436, 436, 436,
4158 436, 436, 436, 436, 436, 436
4159 };
4160
4161 static DfaState st302[36] = {
4162 436, 436, 436, 436, 323, 323, 323, 323, 323, 323,
4163 323, 323, 323, 324, 323, 436, 436, 436, 436, 436,
4164 436, 436, 436, 323, 323, 436, 323, 436, 436, 436,
4165 436, 436, 436, 436, 436, 436
4166 };
4167
4168 static DfaState st303[36] = {
4169 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4170 436, 436, 436, 436, 436, 436, 436, 436, 325, 436,
4171 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4172 436, 436, 436, 436, 436, 436
4173 };
4174
4175 static DfaState st304[36] = {
4176 436, 436, 436, 326, 436, 436, 436, 436, 436, 436,
4177 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4178 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4179 436, 436, 436, 436, 436, 436
4180 };
4181
4182 static DfaState st305[36] = {
4183 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4184 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4185 436, 436, 436, 306, 306, 436, 436, 436, 436, 436,
4186 436, 436, 436, 436, 436, 436
4187 };
4188
4189 static DfaState st306[36] = {
4190 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4191 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4192 436, 436, 436, 306, 306, 436, 436, 436, 436, 436,
4193 436, 436, 436, 436, 436, 436
4194 };
4195
4196 static DfaState st307[36] = {
4197 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4198 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4199 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4200 436, 436, 436, 436, 436, 436
4201 };
4202
4203 static DfaState st308[36] = {
4204 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4205 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4206 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4207 436, 436, 436, 436, 436, 436
4208 };
4209
4210 static DfaState st309[36] = {
4211 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4212 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4213 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4214 436, 436, 436, 436, 436, 436
4215 };
4216
4217 static DfaState st310[36] = {
4218 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4219 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4220 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4221 436, 436, 436, 436, 436, 436
4222 };
4223
4224 static DfaState st311[36] = {
4225 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4226 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4227 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4228 436, 436, 436, 436, 436, 436
4229 };
4230
4231 static DfaState st312[36] = {
4232 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4233 436, 436, 436, 436, 436, 436, 436, 436, 436, 327,
4234 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4235 436, 436, 436, 436, 436, 436
4236 };
4237
4238 static DfaState st313[36] = {
4239 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4240 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4241 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4242 436, 436, 436, 436, 436, 436
4243 };
4244
4245 static DfaState st314[36] = {
4246 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4247 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4248 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4249 436, 436, 436, 436, 436, 436
4250 };
4251
4252 static DfaState st315[36] = {
4253 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4254 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4255 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4256 436, 436, 436, 436, 436, 436
4257 };
4258
4259 static DfaState st316[36] = {
4260 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4261 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4262 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4263 436, 436, 436, 436, 436, 436
4264 };
4265
4266 static DfaState st317[36] = {
4267 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4268 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4269 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4270 436, 436, 436, 436, 436, 436
4271 };
4272
4273 static DfaState st318[36] = {
4274 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4275 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4276 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4277 436, 436, 436, 436, 436, 436
4278 };
4279
4280 static DfaState st319[36] = {
4281 436, 436, 279, 436, 279, 279, 279, 328, 279, 279,
4282 279, 279, 279, 279, 279, 436, 279, 279, 436, 436,
4283 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4284 436, 436, 279, 279, 279, 436
4285 };
4286
4287 static DfaState st320[36] = {
4288 436, 436, 436, 436, 320, 320, 320, 320, 320, 320,
4289 320, 320, 320, 320, 320, 436, 436, 436, 436, 436,
4290 436, 436, 436, 320, 320, 436, 320, 436, 436, 436,
4291 436, 436, 436, 436, 436, 436
4292 };
4293
4294 static DfaState st321[36] = {
4295 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4296 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4297 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4298 436, 436, 436, 436, 436, 436
4299 };
4300
4301 static DfaState st322[36] = {
4302 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4303 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4304 436, 436, 436, 329, 329, 436, 436, 436, 436, 436,
4305 436, 436, 436, 436, 436, 436
4306 };
4307
4308 static DfaState st323[36] = {
4309 436, 436, 436, 436, 323, 323, 323, 323, 323, 323,
4310 323, 323, 323, 323, 323, 436, 436, 436, 436, 436,
4311 436, 436, 436, 323, 323, 436, 323, 436, 436, 436,
4312 436, 436, 436, 436, 436, 436
4313 };
4314
4315 static DfaState st324[36] = {
4316 436, 436, 436, 436, 323, 323, 330, 323, 323, 323,
4317 323, 323, 323, 323, 323, 436, 436, 436, 436, 436,
4318 436, 436, 436, 323, 323, 436, 323, 436, 436, 436,
4319 436, 436, 436, 436, 436, 436
4320 };
4321
4322 static DfaState st325[36] = {
4323 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4324 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4325 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4326 436, 436, 436, 436, 436, 436
4327 };
4328
4329 static DfaState st326[36] = {
4330 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4331 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4332 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4333 436, 436, 436, 436, 436, 436
4334 };
4335
4336 static DfaState st327[36] = {
4337 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4338 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4339 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4340 436, 436, 436, 436, 436, 436
4341 };
4342
4343 static DfaState st328[36] = {
4344 436, 436, 279, 436, 279, 279, 279, 279, 331, 279,
4345 279, 279, 279, 279, 279, 436, 279, 279, 436, 436,
4346 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4347 436, 436, 279, 279, 279, 436
4348 };
4349
4350 static DfaState st329[36] = {
4351 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4352 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4353 436, 436, 436, 329, 329, 436, 436, 436, 436, 436,
4354 436, 436, 436, 436, 436, 436
4355 };
4356
4357 static DfaState st330[36] = {
4358 436, 436, 436, 436, 323, 323, 323, 323, 323, 323,
4359 332, 323, 323, 323, 323, 436, 436, 436, 436, 436,
4360 436, 436, 436, 323, 323, 436, 323, 436, 436, 436,
4361 436, 436, 436, 436, 436, 436
4362 };
4363
4364 static DfaState st331[36] = {
4365 436, 436, 279, 436, 279, 279, 279, 279, 279, 333,
4366 279, 279, 279, 279, 279, 436, 279, 279, 436, 436,
4367 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4368 436, 436, 279, 279, 279, 436
4369 };
4370
4371 static DfaState st332[36] = {
4372 436, 334, 334, 334, 335, 335, 335, 335, 335, 335,
4373 335, 335, 335, 335, 335, 334, 336, 334, 334, 337,
4374 338, 334, 334, 339, 339, 334, 335, 334, 334, 334,
4375 334, 334, 334, 334, 334, 436
4376 };
4377
4378 static DfaState st333[36] = {
4379 436, 436, 279, 436, 279, 279, 279, 279, 279, 279,
4380 340, 279, 279, 279, 279, 436, 279, 279, 436, 436,
4381 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4382 436, 436, 279, 279, 279, 436
4383 };
4384
4385 static DfaState st334[36] = {
4386 436, 334, 334, 334, 334, 334, 334, 334, 334, 334,
4387 334, 334, 334, 334, 334, 334, 334, 334, 334, 337,
4388 338, 334, 334, 334, 334, 334, 334, 334, 334, 334,
4389 334, 334, 334, 334, 334, 436
4390 };
4391
4392 static DfaState st335[36] = {
4393 436, 334, 334, 334, 335, 335, 335, 335, 335, 335,
4394 335, 335, 335, 335, 335, 334, 334, 334, 334, 337,
4395 338, 334, 334, 335, 335, 334, 335, 334, 334, 334,
4396 334, 334, 334, 334, 334, 436
4397 };
4398
4399 static DfaState st336[36] = {
4400 436, 334, 334, 334, 334, 334, 334, 334, 334, 334,
4401 334, 334, 334, 334, 334, 334, 336, 334, 334, 337,
4402 338, 334, 334, 341, 341, 334, 334, 334, 334, 334,
4403 334, 334, 334, 334, 334, 436
4404 };
4405
4406 static DfaState st337[36] = {
4407 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4408 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4409 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4410 436, 436, 436, 436, 436, 436
4411 };
4412
4413 static DfaState st338[36] = {
4414 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4415 436, 436, 436, 436, 436, 436, 436, 436, 436, 342,
4416 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4417 436, 436, 436, 436, 436, 436
4418 };
4419
4420 static DfaState st339[36] = {
4421 436, 334, 334, 334, 335, 335, 335, 335, 335, 335,
4422 335, 335, 335, 335, 335, 334, 343, 334, 334, 344,
4423 345, 334, 334, 339, 339, 334, 335, 334, 346, 334,
4424 334, 334, 334, 334, 334, 436
4425 };
4426
4427 static DfaState st340[36] = {
4428 436, 436, 279, 436, 279, 279, 279, 279, 279, 279,
4429 279, 347, 279, 279, 279, 436, 279, 279, 436, 436,
4430 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4431 436, 436, 279, 279, 279, 436
4432 };
4433
4434 static DfaState st341[36] = {
4435 436, 334, 334, 334, 334, 334, 334, 334, 334, 334,
4436 334, 334, 334, 334, 334, 334, 343, 334, 334, 344,
4437 345, 334, 334, 341, 341, 334, 334, 334, 346, 334,
4438 334, 334, 334, 334, 334, 436
4439 };
4440
4441 static DfaState st342[36] = {
4442 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4443 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4444 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4445 436, 436, 436, 436, 436, 436
4446 };
4447
4448 static DfaState st343[36] = {
4449 436, 334, 334, 334, 334, 334, 334, 334, 334, 334,
4450 334, 334, 334, 334, 334, 334, 343, 334, 334, 337,
4451 338, 334, 334, 334, 334, 334, 334, 334, 346, 334,
4452 334, 334, 334, 334, 334, 436
4453 };
4454
4455 static DfaState st344[36] = {
4456 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4457 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4458 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4459 436, 436, 436, 436, 436, 436
4460 };
4461
4462 static DfaState st345[36] = {
4463 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4464 436, 436, 436, 436, 436, 436, 436, 436, 436, 348,
4465 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4466 436, 436, 436, 436, 436, 436
4467 };
4468
4469 static DfaState st346[36] = {
4470 436, 349, 349, 349, 349, 349, 349, 349, 349, 349,
4471 349, 349, 349, 349, 349, 349, 349, 349, 349, 350,
4472 351, 349, 349, 349, 349, 349, 349, 349, 334, 349,
4473 349, 349, 349, 349, 349, 436
4474 };
4475
4476 static DfaState st347[36] = {
4477 436, 436, 279, 436, 279, 279, 352, 279, 279, 279,
4478 279, 279, 279, 279, 279, 436, 279, 279, 436, 436,
4479 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4480 436, 436, 279, 279, 279, 436
4481 };
4482
4483 static DfaState st348[36] = {
4484 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4485 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4486 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4487 436, 436, 436, 436, 436, 436
4488 };
4489
4490 static DfaState st349[36] = {
4491 436, 349, 349, 349, 349, 349, 349, 349, 349, 349,
4492 349, 349, 349, 349, 349, 349, 349, 349, 349, 350,
4493 351, 349, 349, 349, 349, 349, 349, 349, 353, 349,
4494 349, 349, 349, 349, 349, 436
4495 };
4496
4497 static DfaState st350[36] = {
4498 436, 354, 354, 354, 354, 354, 354, 354, 354, 354,
4499 354, 354, 354, 354, 354, 354, 354, 354, 354, 354,
4500 354, 354, 354, 354, 354, 354, 354, 354, 355, 354,
4501 354, 354, 354, 354, 354, 436
4502 };
4503
4504 static DfaState st351[36] = {
4505 436, 354, 354, 354, 354, 354, 354, 354, 354, 354,
4506 354, 354, 354, 354, 354, 354, 354, 354, 354, 356,
4507 354, 354, 354, 354, 354, 354, 354, 354, 355, 354,
4508 354, 354, 354, 354, 354, 436
4509 };
4510
4511 static DfaState st352[36] = {
4512 436, 436, 279, 436, 279, 279, 279, 279, 279, 279,
4513 279, 279, 357, 279, 279, 436, 279, 279, 436, 436,
4514 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4515 436, 436, 279, 279, 279, 436
4516 };
4517
4518 static DfaState st353[36] = {
4519 436, 334, 334, 334, 334, 334, 334, 334, 334, 334,
4520 334, 334, 334, 334, 334, 334, 358, 334, 334, 344,
4521 345, 334, 334, 359, 359, 334, 334, 334, 334, 334,
4522 334, 334, 334, 334, 334, 436
4523 };
4524
4525 static DfaState st354[36] = {
4526 436, 354, 354, 354, 354, 354, 354, 354, 354, 354,
4527 354, 354, 354, 354, 354, 354, 354, 354, 354, 354,
4528 354, 354, 354, 354, 354, 354, 354, 354, 355, 354,
4529 354, 354, 354, 354, 354, 436
4530 };
4531
4532 static DfaState st355[36] = {
4533 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4534 436, 436, 436, 436, 436, 436, 360, 436, 436, 361,
4535 362, 436, 436, 363, 363, 436, 436, 436, 436, 436,
4536 436, 436, 436, 436, 436, 436
4537 };
4538
4539 static DfaState st356[36] = {
4540 436, 354, 354, 354, 354, 354, 354, 354, 354, 354,
4541 354, 354, 354, 354, 354, 354, 354, 354, 354, 354,
4542 354, 354, 354, 354, 354, 354, 354, 354, 355, 354,
4543 354, 354, 354, 354, 354, 436
4544 };
4545
4546 static DfaState st357[36] = {
4547 436, 436, 279, 436, 279, 279, 279, 279, 279, 279,
4548 279, 279, 279, 364, 279, 436, 279, 279, 436, 436,
4549 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4550 436, 436, 279, 279, 279, 436
4551 };
4552
4553 static DfaState st358[36] = {
4554 436, 334, 334, 334, 334, 334, 334, 334, 334, 334,
4555 334, 334, 334, 334, 334, 334, 358, 334, 334, 344,
4556 345, 334, 334, 359, 359, 334, 334, 334, 334, 334,
4557 334, 334, 334, 334, 334, 436
4558 };
4559
4560 static DfaState st359[36] = {
4561 436, 334, 334, 334, 334, 334, 334, 334, 334, 334,
4562 334, 334, 334, 334, 334, 334, 358, 334, 334, 344,
4563 345, 334, 334, 359, 359, 334, 334, 334, 334, 334,
4564 334, 334, 334, 334, 334, 436
4565 };
4566
4567 static DfaState st360[36] = {
4568 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4569 436, 436, 436, 436, 436, 436, 360, 436, 436, 361,
4570 362, 436, 436, 363, 363, 436, 436, 436, 436, 436,
4571 436, 436, 436, 436, 436, 436
4572 };
4573
4574 static DfaState st361[36] = {
4575 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4576 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4577 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4578 436, 436, 436, 436, 436, 436
4579 };
4580
4581 static DfaState st362[36] = {
4582 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4583 436, 436, 436, 436, 436, 436, 436, 436, 436, 365,
4584 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4585 436, 436, 436, 436, 436, 436
4586 };
4587
4588 static DfaState st363[36] = {
4589 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4590 436, 436, 436, 436, 436, 436, 360, 436, 436, 361,
4591 362, 436, 436, 363, 363, 436, 436, 436, 436, 436,
4592 436, 436, 436, 436, 436, 436
4593 };
4594
4595 static DfaState st364[36] = {
4596 436, 436, 279, 436, 279, 279, 279, 279, 279, 279,
4597 279, 279, 279, 279, 366, 436, 279, 279, 436, 436,
4598 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4599 436, 436, 279, 279, 279, 436
4600 };
4601
4602 static DfaState st365[36] = {
4603 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4604 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4605 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4606 436, 436, 436, 436, 436, 436
4607 };
4608
4609 static DfaState st366[36] = {
4610 436, 436, 279, 436, 279, 279, 279, 279, 279, 279,
4611 279, 279, 279, 279, 279, 367, 279, 279, 436, 436,
4612 436, 436, 436, 279, 279, 279, 279, 436, 436, 436,
4613 436, 436, 279, 279, 279, 436
4614 };
4615
4616 static DfaState st367[36] = {
4617 436, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4618 368, 368, 368, 368, 368, 368, 369, 370, 436, 368,
4619 368, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4620 368, 368, 368, 368, 368, 436
4621 };
4622
4623 static DfaState st368[36] = {
4624 436, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4625 368, 368, 368, 368, 368, 368, 368, 368, 371, 368,
4626 368, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4627 368, 368, 368, 368, 368, 436
4628 };
4629
4630 static DfaState st369[36] = {
4631 436, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4632 368, 368, 368, 368, 368, 368, 369, 370, 371, 368,
4633 368, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4634 368, 368, 368, 368, 368, 436
4635 };
4636
4637 static DfaState st370[36] = {
4638 436, 372, 372, 372, 372, 372, 372, 372, 372, 372,
4639 372, 372, 372, 372, 372, 372, 372, 372, 373, 372,
4640 372, 372, 372, 372, 372, 372, 372, 372, 372, 372,
4641 372, 372, 372, 372, 368, 436
4642 };
4643
4644 static DfaState st371[36] = {
4645 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4646 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4647 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4648 436, 436, 436, 436, 436, 436
4649 };
4650
4651 static DfaState st372[36] = {
4652 436, 372, 372, 372, 372, 372, 372, 372, 372, 372,
4653 372, 372, 372, 372, 372, 372, 372, 372, 373, 372,
4654 372, 372, 372, 372, 372, 372, 372, 372, 372, 372,
4655 372, 372, 372, 372, 374, 436
4656 };
4657
4658 static DfaState st373[36] = {
4659 436, 375, 375, 375, 375, 375, 375, 375, 375, 375,
4660 375, 375, 375, 375, 375, 375, 375, 375, 375, 375,
4661 375, 375, 375, 375, 375, 375, 375, 375, 375, 375,
4662 375, 375, 375, 375, 376, 436
4663 };
4664
4665 static DfaState st374[36] = {
4666 436, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4667 368, 368, 368, 368, 368, 368, 377, 368, 378, 368,
4668 368, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4669 368, 368, 368, 368, 368, 436
4670 };
4671
4672 static DfaState st375[36] = {
4673 436, 375, 375, 375, 375, 375, 375, 375, 375, 375,
4674 375, 375, 375, 375, 375, 375, 375, 375, 375, 375,
4675 375, 375, 375, 375, 375, 375, 375, 375, 375, 375,
4676 375, 375, 375, 375, 376, 436
4677 };
4678
4679 static DfaState st376[36] = {
4680 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4681 436, 436, 436, 436, 436, 436, 379, 436, 380, 436,
4682 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4683 436, 436, 436, 436, 436, 436
4684 };
4685
4686 static DfaState st377[36] = {
4687 436, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4688 368, 368, 368, 368, 368, 368, 377, 368, 378, 368,
4689 368, 368, 368, 368, 368, 368, 368, 368, 368, 368,
4690 368, 368, 368, 368, 368, 436
4691 };
4692
4693 static DfaState st378[36] = {
4694 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4695 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4696 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4697 436, 436, 436, 436, 436, 436
4698 };
4699
4700 static DfaState st379[36] = {
4701 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4702 436, 436, 436, 436, 436, 436, 379, 436, 380, 436,
4703 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4704 436, 436, 436, 436, 436, 436
4705 };
4706
4707 static DfaState st380[36] = {
4708 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4709 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4710 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4711 436, 436, 436, 436, 436, 436
4712 };
4713
4714 static DfaState st381[28] = {
4715 382, 383, 384, 385, 386, 436, 387, 388, 388, 388,
4716 389, 388, 388, 388, 388, 388, 388, 388, 388, 388,
4717 390, 391, 392, 393, 394, 395, 388, 436
4718 };
4719
4720 static DfaState st382[28] = {
4721 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4722 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4723 436, 436, 436, 436, 436, 436, 436, 436
4724 };
4725
4726 static DfaState st383[28] = {
4727 436, 383, 436, 436, 436, 436, 436, 436, 436, 436,
4728 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4729 436, 436, 436, 436, 436, 436, 436, 436
4730 };
4731
4732 static DfaState st384[28] = {
4733 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4734 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4735 436, 436, 436, 436, 436, 436, 436, 436
4736 };
4737
4738 static DfaState st385[28] = {
4739 436, 436, 396, 436, 436, 436, 436, 436, 436, 436,
4740 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4741 436, 436, 436, 436, 436, 436, 436, 436
4742 };
4743
4744 static DfaState st386[28] = {
4745 436, 436, 436, 436, 397, 398, 436, 436, 436, 436,
4746 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4747 436, 436, 436, 436, 436, 436, 436, 436
4748 };
4749
4750 static DfaState st387[28] = {
4751 436, 436, 436, 436, 436, 436, 436, 399, 436, 400,
4752 401, 436, 436, 436, 402, 436, 436, 436, 436, 436,
4753 436, 436, 436, 436, 436, 436, 436, 436
4754 };
4755
4756 static DfaState st388[28] = {
4757 436, 436, 436, 436, 436, 436, 436, 403, 403, 403,
4758 403, 403, 403, 403, 403, 403, 403, 403, 403, 403,
4759 436, 436, 436, 436, 436, 403, 403, 436
4760 };
4761
4762 static DfaState st389[28] = {
4763 436, 436, 436, 436, 436, 436, 436, 403, 403, 403,
4764 403, 404, 403, 403, 403, 403, 403, 403, 403, 403,
4765 436, 436, 436, 436, 436, 403, 403, 436
4766 };
4767
4768 static DfaState st390[28] = {
4769 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4770 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4771 436, 436, 436, 436, 436, 436, 436, 436
4772 };
4773
4774 static DfaState st391[28] = {
4775 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4776 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4777 436, 436, 436, 436, 436, 436, 436, 436
4778 };
4779
4780 static DfaState st392[28] = {
4781 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4782 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4783 436, 436, 436, 436, 436, 436, 436, 436
4784 };
4785
4786 static DfaState st393[28] = {
4787 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4788 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4789 436, 436, 436, 436, 436, 436, 436, 436
4790 };
4791
4792 static DfaState st394[28] = {
4793 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4794 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4795 436, 436, 436, 436, 436, 436, 436, 436
4796 };
4797
4798 static DfaState st395[28] = {
4799 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4800 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4801 436, 436, 436, 436, 436, 395, 436, 436
4802 };
4803
4804 static DfaState st396[28] = {
4805 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4806 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4807 436, 436, 436, 436, 436, 436, 436, 436
4808 };
4809
4810 static DfaState st397[28] = {
4811 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4812 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4813 436, 436, 436, 436, 436, 436, 436, 436
4814 };
4815
4816 static DfaState st398[28] = {
4817 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4818 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4819 436, 436, 436, 436, 436, 436, 436, 436
4820 };
4821
4822 static DfaState st399[28] = {
4823 436, 436, 436, 436, 436, 436, 436, 436, 405, 436,
4824 436, 436, 436, 436, 436, 406, 436, 436, 436, 436,
4825 436, 436, 436, 436, 436, 436, 436, 436
4826 };
4827
4828 static DfaState st400[28] = {
4829 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4830 407, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4831 436, 436, 436, 436, 436, 436, 436, 436
4832 };
4833
4834 static DfaState st401[28] = {
4835 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4836 436, 408, 409, 436, 436, 436, 436, 436, 436, 436,
4837 436, 436, 436, 436, 436, 436, 436, 436
4838 };
4839
4840 static DfaState st402[28] = {
4841 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4842 436, 410, 436, 436, 436, 436, 436, 436, 436, 436,
4843 436, 436, 436, 436, 436, 436, 436, 436
4844 };
4845
4846 static DfaState st403[28] = {
4847 436, 436, 436, 436, 436, 436, 436, 403, 403, 403,
4848 403, 403, 403, 403, 403, 403, 403, 403, 403, 403,
4849 436, 436, 436, 436, 436, 403, 403, 436
4850 };
4851
4852 static DfaState st404[28] = {
4853 436, 436, 436, 436, 436, 436, 436, 403, 403, 403,
4854 403, 403, 403, 403, 411, 403, 403, 403, 403, 403,
4855 436, 436, 436, 436, 436, 403, 403, 436
4856 };
4857
4858 static DfaState st405[28] = {
4859 436, 436, 436, 436, 436, 436, 436, 436, 436, 412,
4860 436, 413, 436, 436, 436, 436, 436, 436, 436, 436,
4861 436, 436, 436, 436, 436, 436, 436, 436
4862 };
4863
4864 static DfaState st406[28] = {
4865 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4866 436, 436, 436, 436, 436, 436, 414, 436, 436, 436,
4867 436, 436, 436, 436, 436, 436, 436, 436
4868 };
4869
4870 static DfaState st407[28] = {
4871 436, 436, 436, 436, 436, 436, 436, 436, 415, 436,
4872 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4873 436, 436, 436, 436, 436, 436, 436, 436
4874 };
4875
4876 static DfaState st408[28] = {
4877 436, 436, 436, 436, 436, 436, 436, 436, 436, 416,
4878 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4879 436, 436, 436, 436, 436, 436, 436, 436
4880 };
4881
4882 static DfaState st409[28] = {
4883 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4884 436, 436, 436, 417, 436, 436, 436, 436, 436, 436,
4885 436, 436, 436, 436, 436, 436, 436, 436
4886 };
4887
4888 static DfaState st410[28] = {
4889 436, 436, 436, 436, 436, 436, 436, 436, 436, 418,
4890 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4891 436, 436, 436, 436, 436, 436, 436, 436
4892 };
4893
4894 static DfaState st411[28] = {
4895 436, 436, 436, 436, 436, 436, 436, 403, 403, 403,
4896 403, 403, 403, 403, 403, 419, 403, 403, 403, 403,
4897 436, 436, 436, 436, 436, 403, 403, 436
4898 };
4899
4900 static DfaState st412[28] = {
4901 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4902 420, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4903 436, 436, 436, 436, 436, 436, 436, 436
4904 };
4905
4906 static DfaState st413[28] = {
4907 436, 436, 436, 436, 436, 436, 436, 436, 436, 421,
4908 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4909 436, 436, 436, 436, 436, 436, 436, 436
4910 };
4911
4912 static DfaState st414[28] = {
4913 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4914 436, 436, 436, 436, 436, 436, 436, 422, 436, 436,
4915 436, 436, 436, 436, 436, 436, 436, 436
4916 };
4917
4918 static DfaState st415[28] = {
4919 436, 436, 436, 436, 436, 436, 436, 423, 436, 436,
4920 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4921 436, 436, 436, 436, 436, 436, 436, 436
4922 };
4923
4924 static DfaState st416[28] = {
4925 436, 436, 436, 436, 436, 436, 436, 424, 436, 436,
4926 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4927 436, 436, 436, 436, 436, 436, 436, 436
4928 };
4929
4930 static DfaState st417[28] = {
4931 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4932 425, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4933 436, 436, 436, 436, 436, 436, 436, 436
4934 };
4935
4936 static DfaState st418[28] = {
4937 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4938 426, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4939 436, 436, 436, 436, 436, 436, 436, 436
4940 };
4941
4942 static DfaState st419[28] = {
4943 436, 436, 436, 436, 436, 436, 436, 403, 403, 403,
4944 403, 403, 403, 403, 403, 403, 403, 403, 403, 403,
4945 436, 436, 436, 436, 436, 403, 403, 436
4946 };
4947
4948 static DfaState st420[28] = {
4949 436, 436, 436, 436, 436, 436, 436, 436, 427, 436,
4950 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4951 436, 436, 436, 436, 436, 436, 436, 436
4952 };
4953
4954 static DfaState st421[28] = {
4955 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4956 428, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4957 436, 436, 436, 436, 436, 436, 436, 436
4958 };
4959
4960 static DfaState st422[28] = {
4961 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4962 436, 436, 436, 436, 436, 436, 436, 436, 429, 436,
4963 436, 436, 436, 436, 436, 436, 436, 436
4964 };
4965
4966 static DfaState st423[28] = {
4967 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4968 436, 430, 436, 436, 436, 436, 436, 436, 436, 436,
4969 436, 436, 436, 436, 436, 436, 436, 436
4970 };
4971
4972 static DfaState st424[28] = {
4973 436, 436, 436, 436, 436, 436, 436, 436, 431, 436,
4974 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4975 436, 436, 436, 436, 436, 436, 436, 436
4976 };
4977
4978 static DfaState st425[28] = {
4979 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4980 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4981 436, 436, 436, 436, 436, 436, 436, 436
4982 };
4983
4984 static DfaState st426[28] = {
4985 436, 436, 436, 436, 436, 436, 436, 436, 432, 436,
4986 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4987 436, 436, 436, 436, 436, 436, 436, 436
4988 };
4989
4990 static DfaState st427[28] = {
4991 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4992 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4993 436, 436, 436, 436, 436, 436, 436, 436
4994 };
4995
4996 static DfaState st428[28] = {
4997 436, 436, 436, 436, 436, 436, 436, 436, 433, 436,
4998 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
4999 436, 436, 436, 436, 436, 436, 436, 436
5000 };
5001
5002 static DfaState st429[28] = {
5003 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5004 436, 436, 436, 436, 436, 436, 436, 436, 436, 434,
5005 436, 436, 436, 436, 436, 436, 436, 436
5006 };
5007
5008 static DfaState st430[28] = {
5009 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5010 435, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5011 436, 436, 436, 436, 436, 436, 436, 436
5012 };
5013
5014 static DfaState st431[28] = {
5015 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5016 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5017 436, 436, 436, 436, 436, 436, 436, 436
5018 };
5019
5020 static DfaState st432[28] = {
5021 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5022 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5023 436, 436, 436, 436, 436, 436, 436, 436
5024 };
5025
5026 static DfaState st433[28] = {
5027 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5028 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5029 436, 436, 436, 436, 436, 436, 436, 436
5030 };
5031
5032 static DfaState st434[28] = {
5033 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5034 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5035 436, 436, 436, 436, 436, 436, 436, 436
5036 };
5037
5038 static DfaState st435[28] = {
5039 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5040 436, 436, 436, 436, 436, 436, 436, 436, 436, 436,
5041 436, 436, 436, 436, 436, 436, 436, 436
5042 };
5043
5044
5045 DfaState *dfa[436] = {
5046 st0,
5047 st1,
5048 st2,
5049 st3,
5050 st4,
5051 st5,
5052 st6,
5053 st7,
5054 st8,
5055 st9,
5056 st10,
5057 st11,
5058 st12,
5059 st13,
5060 st14,
5061 st15,
5062 st16,
5063 st17,
5064 st18,
5065 st19,
5066 st20,
5067 st21,
5068 st22,
5069 st23,
5070 st24,
5071 st25,
5072 st26,
5073 st27,
5074 st28,
5075 st29,
5076 st30,
5077 st31,
5078 st32,
5079 st33,
5080 st34,
5081 st35,
5082 st36,
5083 st37,
5084 st38,
5085 st39,
5086 st40,
5087 st41,
5088 st42,
5089 st43,
5090 st44,
5091 st45,
5092 st46,
5093 st47,
5094 st48,
5095 st49,
5096 st50,
5097 st51,
5098 st52,
5099 st53,
5100 st54,
5101 st55,
5102 st56,
5103 st57,
5104 st58,
5105 st59,
5106 st60,
5107 st61,
5108 st62,
5109 st63,
5110 st64,
5111 st65,
5112 st66,
5113 st67,
5114 st68,
5115 st69,
5116 st70,
5117 st71,
5118 st72,
5119 st73,
5120 st74,
5121 st75,
5122 st76,
5123 st77,
5124 st78,
5125 st79,
5126 st80,
5127 st81,
5128 st82,
5129 st83,
5130 st84,
5131 st85,
5132 st86,
5133 st87,
5134 st88,
5135 st89,
5136 st90,
5137 st91,
5138 st92,
5139 st93,
5140 st94,
5141 st95,
5142 st96,
5143 st97,
5144 st98,
5145 st99,
5146 st100,
5147 st101,
5148 st102,
5149 st103,
5150 st104,
5151 st105,
5152 st106,
5153 st107,
5154 st108,
5155 st109,
5156 st110,
5157 st111,
5158 st112,
5159 st113,
5160 st114,
5161 st115,
5162 st116,
5163 st117,
5164 st118,
5165 st119,
5166 st120,
5167 st121,
5168 st122,
5169 st123,
5170 st124,
5171 st125,
5172 st126,
5173 st127,
5174 st128,
5175 st129,
5176 st130,
5177 st131,
5178 st132,
5179 st133,
5180 st134,
5181 st135,
5182 st136,
5183 st137,
5184 st138,
5185 st139,
5186 st140,
5187 st141,
5188 st142,
5189 st143,
5190 st144,
5191 st145,
5192 st146,
5193 st147,
5194 st148,
5195 st149,
5196 st150,
5197 st151,
5198 st152,
5199 st153,
5200 st154,
5201 st155,
5202 st156,
5203 st157,
5204 st158,
5205 st159,
5206 st160,
5207 st161,
5208 st162,
5209 st163,
5210 st164,
5211 st165,
5212 st166,
5213 st167,
5214 st168,
5215 st169,
5216 st170,
5217 st171,
5218 st172,
5219 st173,
5220 st174,
5221 st175,
5222 st176,
5223 st177,
5224 st178,
5225 st179,
5226 st180,
5227 st181,
5228 st182,
5229 st183,
5230 st184,
5231 st185,
5232 st186,
5233 st187,
5234 st188,
5235 st189,
5236 st190,
5237 st191,
5238 st192,
5239 st193,
5240 st194,
5241 st195,
5242 st196,
5243 st197,
5244 st198,
5245 st199,
5246 st200,
5247 st201,
5248 st202,
5249 st203,
5250 st204,
5251 st205,
5252 st206,
5253 st207,
5254 st208,
5255 st209,
5256 st210,
5257 st211,
5258 st212,
5259 st213,
5260 st214,
5261 st215,
5262 st216,
5263 st217,
5264 st218,
5265 st219,
5266 st220,
5267 st221,
5268 st222,
5269 st223,
5270 st224,
5271 st225,
5272 st226,
5273 st227,
5274 st228,
5275 st229,
5276 st230,
5277 st231,
5278 st232,
5279 st233,
5280 st234,
5281 st235,
5282 st236,
5283 st237,
5284 st238,
5285 st239,
5286 st240,
5287 st241,
5288 st242,
5289 st243,
5290 st244,
5291 st245,
5292 st246,
5293 st247,
5294 st248,
5295 st249,
5296 st250,
5297 st251,
5298 st252,
5299 st253,
5300 st254,
5301 st255,
5302 st256,
5303 st257,
5304 st258,
5305 st259,
5306 st260,
5307 st261,
5308 st262,
5309 st263,
5310 st264,
5311 st265,
5312 st266,
5313 st267,
5314 st268,
5315 st269,
5316 st270,
5317 st271,
5318 st272,
5319 st273,
5320 st274,
5321 st275,
5322 st276,
5323 st277,
5324 st278,
5325 st279,
5326 st280,
5327 st281,
5328 st282,
5329 st283,
5330 st284,
5331 st285,
5332 st286,
5333 st287,
5334 st288,
5335 st289,
5336 st290,
5337 st291,
5338 st292,
5339 st293,
5340 st294,
5341 st295,
5342 st296,
5343 st297,
5344 st298,
5345 st299,
5346 st300,
5347 st301,
5348 st302,
5349 st303,
5350 st304,
5351 st305,
5352 st306,
5353 st307,
5354 st308,
5355 st309,
5356 st310,
5357 st311,
5358 st312,
5359 st313,
5360 st314,
5361 st315,
5362 st316,
5363 st317,
5364 st318,
5365 st319,
5366 st320,
5367 st321,
5368 st322,
5369 st323,
5370 st324,
5371 st325,
5372 st326,
5373 st327,
5374 st328,
5375 st329,
5376 st330,
5377 st331,
5378 st332,
5379 st333,
5380 st334,
5381 st335,
5382 st336,
5383 st337,
5384 st338,
5385 st339,
5386 st340,
5387 st341,
5388 st342,
5389 st343,
5390 st344,
5391 st345,
5392 st346,
5393 st347,
5394 st348,
5395 st349,
5396 st350,
5397 st351,
5398 st352,
5399 st353,
5400 st354,
5401 st355,
5402 st356,
5403 st357,
5404 st358,
5405 st359,
5406 st360,
5407 st361,
5408 st362,
5409 st363,
5410 st364,
5411 st365,
5412 st366,
5413 st367,
5414 st368,
5415 st369,
5416 st370,
5417 st371,
5418 st372,
5419 st373,
5420 st374,
5421 st375,
5422 st376,
5423 st377,
5424 st378,
5425 st379,
5426 st380,
5427 st381,
5428 st382,
5429 st383,
5430 st384,
5431 st385,
5432 st386,
5433 st387,
5434 st388,
5435 st389,
5436 st390,
5437 st391,
5438 st392,
5439 st393,
5440 st394,
5441 st395,
5442 st396,
5443 st397,
5444 st398,
5445 st399,
5446 st400,
5447 st401,
5448 st402,
5449 st403,
5450 st404,
5451 st405,
5452 st406,
5453 st407,
5454 st408,
5455 st409,
5456 st410,
5457 st411,
5458 st412,
5459 st413,
5460 st414,
5461 st415,
5462 st416,
5463 st417,
5464 st418,
5465 st419,
5466 st420,
5467 st421,
5468 st422,
5469 st423,
5470 st424,
5471 st425,
5472 st426,
5473 st427,
5474 st428,
5475 st429,
5476 st430,
5477 st431,
5478 st432,
5479 st433,
5480 st434,
5481 st435
5482 };
5483
5484
5485 DfaState accepts[437] = {
5486 0, 1, 2, 3, 3, 4, 25, 6, 0, 50,
5487 59, 57, 57, 43, 26, 13, 14, 0, 57, 58,
5488 57, 21, 57, 23, 24, 27, 28, 44, 0, 35,
5489 36, 42, 45, 46, 58, 51, 52, 3, 5, 9,
5490 7, 8, 59, 59, 59, 59, 59, 59, 59, 59,
5491 57, 57, 12, 40, 59, 57, 58, 57, 57, 57,
5492 33, 34, 53, 58, 59, 59, 59, 59, 59, 59,
5493 59, 59, 59, 57, 59, 57, 57, 57, 57, 0,
5494 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
5495 57, 57, 57, 57, 57, 0, 0, 59, 59, 59,
5496 59, 59, 59, 32, 59, 59, 59, 59, 59, 59,
5497 59, 59, 57, 57, 57, 22, 56, 48, 49, 0,
5498 11, 11, 0, 59, 59, 59, 59, 59, 59, 59,
5499 59, 59, 59, 41, 59, 59, 59, 18, 57, 47,
5500 57, 0, 11, 0, 10, 10, 0, 59, 59, 59,
5501 59, 59, 15, 19, 59, 59, 59, 17, 57, 55,
5502 10, 0, 11, 11, 59, 59, 59, 59, 59, 59,
5503 20, 59, 57, 0, 0, 0, 11, 59, 59, 59,
5504 37, 38, 59, 39, 54, 0, 0, 0, 10, 10,
5505 0, 31, 29, 30, 59, 10, 59, 59, 59, 59,
5506 16, 0, 60, 61, 62, 62, 0, 65, 62, 64,
5507 63, 63, 63, 0, 66, 67, 68, 68, 0, 71,
5508 68, 70, 69, 69, 69, 0, 72, 73, 74, 74,
5509 0, 76, 74, 75, 0, 77, 79, 81, 80, 80,
5510 78, 80, 0, 82, 84, 86, 85, 85, 83, 85,
5511 0, 87, 88, 88, 89, 88, 0, 90, 91, 91,
5512 92, 91, 0, 93, 94, 94, 95, 94, 0, 96,
5513 98, 100, 99, 99, 97, 99, 0, 101, 108, 143,
5514 104, 143, 129, 127, 107, 107, 109, 128, 126, 134,
5515 0, 133, 139, 143, 102, 143, 107, 116, 110, 112,
5516 113, 123, 123, 125, 124, 117, 120, 132, 138, 130,
5517 131, 137, 137, 135, 136, 142, 140, 141, 103, 143,
5518 116, 111, 114, 123, 123, 119, 118, 137, 143, 115,
5519 123, 143, 123, 143, 0, 123, 0, 122, 122, 123,
5520 143, 0, 122, 0, 121, 121, 0, 143, 121, 0,
5521 122, 122, 143, 0, 0, 0, 122, 143, 0, 0,
5522 0, 121, 121, 0, 143, 121, 143, 0, 0, 0,
5523 0, 106, 0, 106, 0, 0, 0, 0, 105, 0,
5524 105, 0, 144, 145, 146, 146, 0, 0, 164, 164,
5525 158, 159, 160, 161, 162, 163, 146, 147, 148, 0,
5526 0, 0, 0, 164, 164, 150, 0, 0, 0, 0,
5527 0, 164, 0, 0, 0, 0, 0, 0, 0, 157,
5528 0, 0, 0, 0, 0, 152, 0, 149, 0, 0,
5529 0, 153, 154, 151, 155, 156, 0
5530 };
5531
5532 void (*actions[165])() = {
5533 zzerraction,
5534 act1,
5535 act2,
5536 act3,
5537 act4,
5538 act5,
5539 act6,
5540 act7,
5541 act8,
5542 act9,
5543 act10,
5544 act11,
5545 act12,
5546 act13,
5547 act14,
5548 act15,
5549 act16,
5550 act17,
5551 act18,
5552 act19,
5553 act20,
5554 act21,
5555 act22,
5556 act23,
5557 act24,
5558 act25,
5559 act26,
5560 act27,
5561 act28,
5562 act29,
5563 act30,
5564 act31,
5565 act32,
5566 act33,
5567 act34,
5568 act35,
5569 act36,
5570 act37,
5571 act38,
5572 act39,
5573 act40,
5574 act41,
5575 act42,
5576 act43,
5577 act44,
5578 act45,
5579 act46,
5580 act47,
5581 act48,
5582 act49,
5583 act50,
5584 act51,
5585 act52,
5586 act53,
5587 act54,
5588 act55,
5589 act56,
5590 act57,
5591 act58,
5592 act59,
5593 act60,
5594 act61,
5595 act62,
5596 act63,
5597 act64,
5598 act65,
5599 act66,
5600 act67,
5601 act68,
5602 act69,
5603 act70,
5604 act71,
5605 act72,
5606 act73,
5607 act74,
5608 act75,
5609 act76,
5610 act77,
5611 act78,
5612 act79,
5613 act80,
5614 act81,
5615 act82,
5616 act83,
5617 act84,
5618 act85,
5619 act86,
5620 act87,
5621 act88,
5622 act89,
5623 act90,
5624 act91,
5625 act92,
5626 act93,
5627 act94,
5628 act95,
5629 act96,
5630 act97,
5631 act98,
5632 act99,
5633 act100,
5634 act101,
5635 act102,
5636 act103,
5637 act104,
5638 act105,
5639 act106,
5640 act107,
5641 act108,
5642 act109,
5643 act110,
5644 act111,
5645 act112,
5646 act113,
5647 act114,
5648 act115,
5649 act116,
5650 act117,
5651 act118,
5652 act119,
5653 act120,
5654 act121,
5655 act122,
5656 act123,
5657 act124,
5658 act125,
5659 act126,
5660 act127,
5661 act128,
5662 act129,
5663 act130,
5664 act131,
5665 act132,
5666 act133,
5667 act134,
5668 act135,
5669 act136,
5670 act137,
5671 act138,
5672 act139,
5673 act140,
5674 act141,
5675 act142,
5676 act143,
5677 act144,
5678 act145,
5679 act146,
5680 act147,
5681 act148,
5682 act149,
5683 act150,
5684 act151,
5685 act152,
5686 act153,
5687 act154,
5688 act155,
5689 act156,
5690 act157,
5691 act158,
5692 act159,
5693 act160,
5694 act161,
5695 act162,
5696 act163,
5697 act164
5698 };
5699
5700 static DfaState dfa_base[] = {
5701 0,
5702 201,
5703 213,
5704 225,
5705 234,
5706 242,
5707 250,
5708 256,
5709 262,
5710 268,
5711 276,
5712 381
5713 };
5714
5715 static unsigned char *b_class_no[] = {
5716 shift0,
5717 shift1,
5718 shift2,
5719 shift3,
5720 shift4,
5721 shift5,
5722 shift6,
5723 shift7,
5724 shift8,
5725 shift9,
5726 shift10,
5727 shift11
5728 };
5729
5730
5731
5732 #define ZZSHIFT(c) (b_class_no[zzauto][1+c])
5733 #define MAX_MODE 12
5734 #include "dlgauto.h"
+0
-31
contrib/pccts/antlr/stdpccts.h less more
0 #ifndef STDPCCTS_H
1 #define STDPCCTS_H
2 /*
3 * stdpccts.h -- P C C T S I n c l u d e
4 *
5 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
6 * Purdue University Electrical Engineering
7 * With AHPCRC, University of Minnesota
8 * ANTLR Version 1.33MR33
9 */
10
11 #ifndef ANTLR_VERSION
12 #define ANTLR_VERSION 13333
13 #endif
14
15 #include "pcctscfg.h"
16 #include "pccts_stdio.h"
17
18 #include "pcctscfg.h"
19 #include "set.h"
20 #include <ctype.h>
21 #include "syn.h"
22 #include "hash.h"
23 #include "generic.h"
24 #define zzcr_attr(attr,tok,t)
25 #define zzSET_SIZE 20
26 #include "antlr.h"
27 #include "tokens.h"
28 #include "dlgdef.h"
29 #include "mode.h"
30 #endif
+0
-390
contrib/pccts/antlr/syn.h less more
0 /*
1 * syn.h
2 *
3 * This file includes definitions and macros associated with syntax diagrams
4 *
5 * SOFTWARE RIGHTS
6 *
7 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
8 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
9 * company may do whatever they wish with source code distributed with
10 * PCCTS or the code generated by PCCTS, including the incorporation of
11 * PCCTS, or its output, into commerical software.
12 *
13 * We encourage users to develop software with PCCTS. However, we do ask
14 * that credit is given to us for developing PCCTS. By "credit",
15 * we mean that if you incorporate our source code into one of your
16 * programs (commercial product, research project, or otherwise) that you
17 * acknowledge this fact somewhere in the documentation, research report,
18 * etc... If you like PCCTS and have developed a nice tool with the
19 * output, please mention that you developed it using PCCTS. In
20 * addition, we ask that this header remain intact in our source code.
21 * As long as these guidelines are kept, we expect to continue enhancing
22 * this system and expect to make other tools available as they are
23 * completed.
24 *
25 * ANTLR 1.33
26 * Terence Parr
27 * Parr Research Corporation
28 * with Purdue University and AHPCRC, University of Minnesota
29 * 1989-2001
30 */
31
32 #include "set.h"
33
34 #define NumNodeTypes 4
35 #define NumJuncTypes 9
36
37 /* List the different node types */
38 #define nJunction 1
39 #define nRuleRef 2
40 #define nToken 3
41 #define nAction 4
42
43 /* Different types of junctions */
44 #define aSubBlk 1
45 #define aOptBlk 2
46 #define aLoopBlk 3
47 #define EndBlk 4
48 #define RuleBlk 5
49 #define Generic 6 /* just a junction--no unusual characteristics */
50 #define EndRule 7
51 #define aPlusBlk 8
52 #define aLoopBegin 9
53
54 typedef int NodeType;
55
56 #define TreeBlockAllocSize 500
57 #define JunctionBlockAllocSize 200
58 #define ActionBlockAllocSize 50
59 #define RRefBlockAllocSize 100
60 #define TokenBlockAllocSize 100
61
62 #ifdef __cplusplus
63 class ActionNode;
64 class Junction;
65 #endif
66
67 /* note that 'right' is used by the tree node allocator as a ptr for linked list */
68 typedef struct _tree {
69 struct _tree *down, *right;
70 int token;
71 union {
72 int rk; /* if token==EpToken, => how many more tokens req'd */
73 struct _tree *tref; /* if token==TREE_REF */
74 set sref; /* if token==SET */
75 } v;
76 #ifdef TREE_DEBUG
77 int in_use;
78 int seq;
79 #endif
80 } Tree;
81
82
83 /* a predicate is defined to be a predicate action and a token tree with
84 * context info (if used); later, this struct may include the
85 * "hoisting distance" when we hoist past tokens.
86 *
87 * A tree is used to indicate && vs ||
88 *
89 * p
90 * |
91 * q--r
92 *
93 * indicates p && (q||r).
94 *
95 * If expr is PRED_AND_LIST or PRED_OR_LIST, then it's an operation node
96 * and indicates the start of an && or || list.
97 */
98
99 typedef struct _Predicate {
100 struct _Predicate *down, *right; /* these have to be first */
101 struct _Predicate *up, *left; /* doubly-link me */
102 char *expr;
103 Tree *tcontext; /* used if lookahead depth of > one is needed (tree) */
104 int k; /* lookahead depth for this tcontext */
105 set scontext[2];/* used if lookahead depth of one is needed (set) */
106 /* scontext[0] is not used; only needed so genExprSets()
107 routine works (it expects an array)
108 */
109 set completionTree; /* which lookahead depths are required to complete tcontext? */
110 set completionSet; /* MR10 separate completion set for sets and trees */
111 struct _PredEntry *predEntry; /* MR11 */
112
113 #ifdef __cplusplus
114 ActionNode *source; /* where did this predicate come from? */
115 #else
116 struct _anode *source; /* where did this predicate come from? */
117 #endif
118
119 char cloned; /* MR10 don't want to free original guard pred */
120 char redundant; /* MR10 predicate tree simplification */
121 char ampersandStyle; /* MR10 (g)? && <<p>>? */
122 char inverted; /* MR11 ! predName */
123 char isConst; /* MR11 */
124 char constValue; /* MR11 */
125 char conflictReported; /* MR11 */
126
127 set plainSet; /* MR12b */
128
129 /*** remember to change new_predicate() and predicate_dup() when changing this ***/
130
131 } Predicate;
132
133 typedef struct _ExceptionHandler {
134 char *signalname;
135 char *action;
136 } ExceptionHandler;
137
138 typedef struct _ExceptionGroup {
139 struct _ListNode *handlers; /* list of ExceptionHandler's */
140 char *label; /* label==""; implies not attached to any
141 * particular rule ref.
142 */
143 char *altID; /* which alt did it come from (blk#:alt#) */
144
145 struct _ExceptionGroup *pendingLink; /* for alternative EG MR7 */
146 struct _ExceptionGroup *outerEG; /* for alternative EG MR7 */
147 struct _LabelEntry *labelEntry; /* for alternative EG MR7 */
148 int forRule; /* MR7 */
149 int used; /* MR7 */
150 } ExceptionGroup ;
151
152
153 #define TokenString(_i) ((TokenInd!=NULL)?TokenStr[TokenInd[_i]]:TokenStr[_i])
154 #define ExprString(_i) ((TokenInd!=NULL)?ExprStr[TokenInd[_i]]:ExprStr[_i])
155
156
157 /* M e s s a g e P a s s i n g T o N o d e s */
158
159 /*
160 * assumes a 'Junction *r' exists. This macro calls a function with
161 * the pointer to the node to operate on and a pointer to the rule
162 * in which it is enclosed.
163 */
164 #define TRANS(p) {if ( (p)==NULL ) fatal("TRANS: NULL object"); \
165 if ( (p)->ntype == nJunction ) (*(fpJTrans[((Junction *)(p))->jtype]))( p );\
166 else (*(fpTrans[(p)->ntype]))( p );}
167
168 #define PRINT(p) {if ( (p)==NULL ) fatal("PRINT: NULL object");\
169 (*(fpPrint[(p)->ntype]))( p );}
170
171 #define REACH(p,k,rk,a) {if ( (p)==NULL ) fatal("REACH: NULL object");\
172 (a) = (*(fpReach[(p)->ntype]))( p, k, rk );}
173
174 #define TRAV(p,k,rk,a) {if ( (p)==NULL ) {\
175 if ( ContextGuardTRAV ) (a)=NULL; \
176 else fatal("TRAV: NULL object");\
177 } \
178 else (a) = (*(fpTraverse[(p)->ntype]))( p, k, rk );}
179
180 /**
181 *** #define TRAV(p,k,rk,a) {if ( (p)==NULL ) fatal("TRAV: NULL object");\
182 *** (a) = (*(fpTraverse[(p)->ntype]))( p, k, rk );}
183 **/
184
185 /* All syntax diagram nodes derive from Node -- superclass
186 */
187 #ifdef __cplusplus
188 class Node {
189 public:
190 NodeType ntype;
191 char *rname; /* what rule does this element live in? */
192 int file; /* index in FileStr */
193 int line; /* line number that element occurs on */
194 };
195 #else
196 typedef struct _node {
197 NodeType ntype;
198 char *rname; /* what rule does this element live in? */
199 int file; /* index in FileStr */
200 int line; /* line number that element occurs on */
201 } Node;
202 #endif
203
204 #ifdef __cplusplus
205 class ActionNode : public Node {
206 public:
207 #else
208 typedef struct _anode {
209 NodeType ntype;
210 char *rname; /* what rule does this action live in? */
211 int file; /* index in FileStr (name of file with action) */
212 int line; /* line number that action occurs on */
213 #endif
214 Node *next;
215 char *action;
216 int is_predicate; /* true if action is a <<...>>? predicate action */
217 int done; /* don't dump if action dumped (used for predicates) */
218 int init_action; /* is this the 1st action of 1st prod of block? */
219 char *pred_fail; /* what to do/print when predicate fails */
220 Predicate *guardpred; /* if '(context)? =>' was present, already done */
221 unsigned char frmwarned;/* have we dumped a warning for pred yet? */
222 unsigned char ctxwarned;/* have we dumped a warning for pred yet? */
223 unsigned char predTooLong; /* MR10 have we dumped warning for pred yet */
224 unsigned char noHoist; /* MR12 literally "noHoist" */
225 Predicate *ampersandPred; /* MR10 (g)? && <<p>>? expr */
226 #ifdef __cplusplus
227 Junction *guardNodes; /* MR11 */
228 #else
229 struct _junct *guardNodes; /* MR11 */
230 #endif
231 struct _PredEntry *predEntry; /* MR11 */
232 int inverted; /* MR11 <<!predSymbol>>? */
233 #ifdef __cplusplus
234 };
235 #else
236 } ActionNode;
237 #endif
238
239 #ifdef __cplusplus
240 class TokNode : public Node {
241 public:
242 #else
243 typedef struct _toknode {
244 NodeType ntype;
245 char *rname; /* name of rule it's in */
246 int file; /* index in FileStr (name of file with rule) */
247 int line; /* line number that token occurs on */
248 #endif
249 Node *next;
250 int token;
251 int astnode; /* leaf/root/excluded (used to build AST's) */
252 unsigned char label;/* token label or expression ? */
253 unsigned char remapped;
254 /* used if token id's are forced to certain positions;
255 * a function walks the tree reassigning token numbers */
256 int upper_range; /* MR13 - was char */
257 /* used only if Token is of type T1..T2; in this case,
258 * use token..upper_range as the range; else
259 * upper_range must be 0 */
260 unsigned char wild_card;
261 /* indicates that the token is the "." wild-card;
262 * field token is ignored if wild_card is set
263 */
264 unsigned int elnum; /* element number within the alternative */
265 #ifdef __cplusplus
266 Junction *altstart; /* pointer to node that starts alt */
267 #else
268 struct _junct *altstart; /* pointer to node that starts alt */
269 #endif
270 struct _TCnode *tclass; /* token class if tokclass ref */
271 set tset; /* set of tokens represented by meta token */
272 char *el_label; /* el_label:toknode */
273 unsigned char complement; /* complement the set? */
274 ExceptionGroup *ex_group; /* any exception[el_label] attached? */
275 unsigned char use_def_MT_handler;
276 unsigned char label_used_in_semantic_pred; /* MR10 */
277 #ifdef __cplusplus
278 };
279 #else
280 } TokNode;
281 #endif
282
283 #ifdef __cplusplus
284 class RuleRefNode : public Node {
285 public:
286 #else
287 typedef struct _rrnode {
288 NodeType ntype;
289 char *rname; /* name of rule it's in */
290 int file; /* index in FileStr (name of file with rule)
291 it's in */
292 int line; /* line number that rule ref occurs on */
293 #endif
294 Node *next;
295 char *text; /* reference to which rule */
296 char *parms; /* point to parameters of rule invocation
297 (if present) */
298 char *assign; /* point to left-hand-side of assignment
299 (if any) */
300 int linked; /* Has a FoLink already been established? */
301 int astnode; /* excluded? (used to build AST's) */
302 unsigned int elnum; /* element number within the alternative */
303 #ifdef __cplusplus
304 Junction *altstart;
305 #else
306 struct _junct *altstart;
307 #endif
308 char *el_label; /* el_label:rrnode */
309 ExceptionGroup *ex_group; /* any exception[el_label] attached? */
310 #ifdef __cplusplus
311 };
312 #else
313 } RuleRefNode;
314 #endif
315
316 #ifdef __cplusplus
317 class Junction : public Node {
318 public:
319 #else
320 typedef struct _junct {
321 NodeType ntype;
322 char *rname; /* name of rule junction is in */
323 int file; /* index in FileStr (name of file with rule)
324 if blk == RuleBlk */
325 int line; /* line number that rule occurs on */
326 #endif
327 int seq; /* MR10 sequence number */
328 char ignore; /* used by FIRST computation to ignore
329 empty alt added for the (...)+ blks */
330 char visited; /* used by recursive routines to avoid
331 infinite recursion */
332 char pvisited; /* used by print routines to avoid
333 infinite recursion */
334 char fvisited; /* used by FoLink() to avoid
335 infinite recursion */
336 char *lock; /* used by REACH to track infinite recursion */
337 char *pred_lock; /* used by find_predicates to track infinite recursion */
338 int altnum; /* used in subblocks. altnum==0 means not an
339 alt of subrule */
340 int jtype; /* annotation for code-gen/FIRST/FOLLOW.
341 Junction type */
342 #ifdef __cplusplus
343 Junction *end; /* pointer to node with EndBlk in it
344 if blk == a block type */
345 #else
346 struct _junct *end; /* pointer to node with EndBlk in it
347 if blk == a block type */
348 #endif
349 Node *p1, *p2;
350 char halt; /* never move past a junction with halt==TRUE */ /* MR10 was int */
351 char *pdecl; /* point to declaration of parameters on rule
352 (if present) */
353 char *parm; /* point to parameter of block invocation
354 (if present) */
355 char predparm; /* indicates that the 'parm' is a predicate
356 * to be used in the while loop generated
357 * for blocks */ /* MR10 was int */
358 char *ret; /* point to return type of rule (if present) */
359 char *erraction; /* point to error action (if present) */
360 int blockid; /* this is a unique ID */
361 char *exception_label; /* goto label for this alt */
362 set *fset; /* used for code generation */
363 Tree *ftree; /* used for code generation */
364 Predicate *predicate;/* predicate that can be used to disambiguate */
365 char guess; /* true if (...)? block */
366 char alpha_beta_guess_end; /* MR14 1 => end block of guess sub block */
367 Node *guess_analysis_point; /* MR14 */
368 char approx; /* limit block to use linear approx lookahead? */
369 set tokrefs; /* if ith element of alt is tokref then i is member */
370 set rulerefs; /* if ith element of alt is rule ref then i is member */
371 struct _ListNode *exceptions; /* list of exceptions groups for rule */
372 struct _ListNode *el_labels; /* list of element labels for rule */
373 ExceptionGroup *outerEG; /* MR7 */
374 int curAltNum; /* MR7 */
375 char* pFirstSetSymbol; /* #pragma FirstSetSymbol(Foo) MR21 */
376 #ifdef __cplusplus
377 Junction *pendingLink; /* MR7 */
378 #else
379 struct _junct *pendingLink; /* MR7 */
380 #endif
381 char overlap_warning; /* MR10 */
382 #ifdef __cplusplus
383 };
384 #else
385 } Junction;
386 #endif
387
388 typedef struct { Node *left, *right;} Graph;
389
+0
-246
contrib/pccts/antlr/tokens.h less more
0 #ifndef tokens_h
1 #define tokens_h
2 /* tokens.h -- List of labelled tokens and stuff
3 *
4 * Generated from: ./antlr.g
5 *
6 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
7 * Purdue University Electrical Engineering
8 * ANTLR Version 1.33MR33
9 */
10 #define zzEOF_TOKEN 1
11 #define Eof 1
12 #define QuotedTerm 2
13 #define Action 34
14 #define Pred 35
15 #define PassAction 36
16 #define WildCard 87
17 #define LABEL 89
18 #define Pragma 92
19 #define FirstSetSymbol 93
20 #define NonTerminal 100
21 #define TokenTerm 101
22 #define ID 148
23 #define INT 150
24
25 #ifdef __USE_PROTOS
26 void grammar(void);
27 #else
28 extern void grammar();
29 #endif
30
31 #ifdef __USE_PROTOS
32 void class_def(void);
33 #else
34 extern void class_def();
35 #endif
36
37 #ifdef __USE_PROTOS
38 void rule(void);
39 #else
40 extern void rule();
41 #endif
42
43 #ifdef __USE_PROTOS
44 void laction(void);
45 #else
46 extern void laction();
47 #endif
48
49 #ifdef __USE_PROTOS
50 void lmember(void);
51 #else
52 extern void lmember();
53 #endif
54
55 #ifdef __USE_PROTOS
56 void lprefix(void);
57 #else
58 extern void lprefix();
59 #endif
60
61 #ifdef __USE_PROTOS
62 void aPred(void);
63 #else
64 extern void aPred();
65 #endif
66
67 #ifdef __USE_PROTOS
68 extern Predicate * predOrExpr(void);
69 #else
70 extern Predicate * predOrExpr();
71 #endif
72
73 #ifdef __USE_PROTOS
74 extern Predicate * predAndExpr(void);
75 #else
76 extern Predicate * predAndExpr();
77 #endif
78
79 #ifdef __USE_PROTOS
80 extern Predicate * predPrimary(void);
81 #else
82 extern Predicate * predPrimary();
83 #endif
84
85 #ifdef __USE_PROTOS
86 void aLexclass(void);
87 #else
88 extern void aLexclass();
89 #endif
90
91 #ifdef __USE_PROTOS
92 void error(void);
93 #else
94 extern void error();
95 #endif
96
97 #ifdef __USE_PROTOS
98 void tclass(void);
99 #else
100 extern void tclass();
101 #endif
102
103 #ifdef __USE_PROTOS
104 void token(void);
105 #else
106 extern void token();
107 #endif
108
109 #ifdef __USE_PROTOS
110 void block(set * toksrefd,set * rulesrefd);
111 #else
112 extern void block();
113 #endif
114
115 #ifdef __USE_PROTOS
116 void alt(set * toksrefd,set * rulesrefd);
117 #else
118 extern void alt();
119 #endif
120
121 #ifdef __USE_PROTOS
122 extern LabelEntry * element_label(void);
123 #else
124 extern LabelEntry * element_label();
125 #endif
126
127 #ifdef __USE_PROTOS
128 extern Node * element(int old_not,int first_on_line,int use_def_MT_handler);
129 #else
130 extern Node * element();
131 #endif
132
133 #ifdef __USE_PROTOS
134 void default_exception_handler(void);
135 #else
136 extern void default_exception_handler();
137 #endif
138
139 #ifdef __USE_PROTOS
140 extern ExceptionGroup * exception_group(void);
141 #else
142 extern ExceptionGroup * exception_group();
143 #endif
144
145 #ifdef __USE_PROTOS
146 extern ExceptionHandler * exception_handler(void);
147 #else
148 extern ExceptionHandler * exception_handler();
149 #endif
150
151 #ifdef __USE_PROTOS
152 void enum_file(char * fname);
153 #else
154 extern void enum_file();
155 #endif
156
157 #ifdef __USE_PROTOS
158 void defines(char * fname);
159 #else
160 extern void defines();
161 #endif
162
163 #ifdef __USE_PROTOS
164 void enum_def(char * fname);
165 #else
166 extern void enum_def();
167 #endif
168
169 #endif
170 extern SetWordType zzerr1[];
171 extern SetWordType zzerr2[];
172 extern SetWordType zzerr3[];
173 extern SetWordType zzerr4[];
174 extern SetWordType setwd1[];
175 extern SetWordType zzerr5[];
176 extern SetWordType zzerr6[];
177 extern SetWordType zzerr7[];
178 extern SetWordType zzerr8[];
179 extern SetWordType zzerr9[];
180 extern SetWordType setwd2[];
181 extern SetWordType zzerr10[];
182 extern SetWordType zzerr11[];
183 extern SetWordType zzerr12[];
184 extern SetWordType zzerr13[];
185 extern SetWordType setwd3[];
186 extern SetWordType zzerr14[];
187 extern SetWordType zzerr15[];
188 extern SetWordType zzerr16[];
189 extern SetWordType zzerr17[];
190 extern SetWordType zzerr18[];
191 extern SetWordType zzerr19[];
192 extern SetWordType zzerr20[];
193 extern SetWordType zzerr21[];
194 extern SetWordType setwd4[];
195 extern SetWordType zzerr22[];
196 extern SetWordType zzerr23[];
197 extern SetWordType zzerr24[];
198 extern SetWordType zzerr25[];
199 extern SetWordType zzerr26[];
200 extern SetWordType setwd5[];
201 extern SetWordType zzerr27[];
202 extern SetWordType zzerr28[];
203 extern SetWordType zzerr29[];
204 extern SetWordType zzerr30[];
205 extern SetWordType zzerr31[];
206 extern SetWordType zzerr32[];
207 extern SetWordType zzerr33[];
208 extern SetWordType setwd6[];
209 extern SetWordType zzerr34[];
210 extern SetWordType zzerr35[];
211 extern SetWordType zzerr36[];
212 extern SetWordType zzerr37[];
213 extern SetWordType zzerr38[];
214 extern SetWordType zzerr39[];
215 extern SetWordType zzerr40[];
216 extern SetWordType zzerr41[];
217 extern SetWordType zzerr42[];
218 extern SetWordType setwd7[];
219 extern SetWordType zzerr43[];
220 extern SetWordType zzerr44[];
221 extern SetWordType zzerr45[];
222 extern SetWordType zzerr46[];
223 extern SetWordType zzerr47[];
224 extern SetWordType zzerr48[];
225 extern SetWordType zzerr49[];
226 extern SetWordType zzerr50[];
227 extern SetWordType zzerr51[];
228 extern SetWordType zzerr52[];
229 extern SetWordType zzerr53[];
230 extern SetWordType setwd8[];
231 extern SetWordType zzerr54[];
232 extern SetWordType zzerr55[];
233 extern SetWordType zzerr56[];
234 extern SetWordType zzerr57[];
235 extern SetWordType setwd9[];
236 extern SetWordType zzerr58[];
237 extern SetWordType zzerr59[];
238 extern SetWordType zzerr60[];
239 extern SetWordType zzerr61[];
240 extern SetWordType zzerr62[];
241 extern SetWordType zzerr63[];
242 extern SetWordType zzerr64[];
243 extern SetWordType zzerr65[];
244 extern SetWordType setwd10[];
245 extern SetWordType setwd11[];
+0
-54
contrib/pccts/antlr/watantlr.mak less more
0 SET=..\support\set
1 PCCTS_H=..\h
2
3 #
4 # Watcom
5 #
6 CC=wcl386
7 ANTLR=..\bin\antlr
8 DLG=..\bin\dlg
9 CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DPC
10 OUT_OBJ = -o
11 OBJ_EXT = obj
12 LINK = wcl386
13
14 .c.obj :
15 $(CC) -c $[* $(CFLAGS)
16
17 antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj &
18 fset.obj gen.obj globals.obj hash.obj lex.obj main.obj &
19 misc.obj set.obj pred.obj
20 $(LINK) -fe=antlr.exe *.obj -k14336
21 copy *.exe ..\bin
22
23 # *********** Target list of PC machines ***********
24 #
25 # Don't worry about the ambiguity messages coming from antlr
26 # for making antlr.c etc... [should be 10 of them, I think]
27 #
28 antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g
29 $(ANTLR) antlr.g
30
31 antlr.$(OBJ_EXT): antlr.c mode.h tokens.h
32
33 scan.$(OBJ_EXT): scan.c mode.h tokens.h
34
35 scan.c mode.h: parser.dlg
36 $(DLG) -C2 parser.dlg scan.c
37
38 set.$(OBJ_EXT): $(SET)\set.c
39 $(CC) $(CFLAGS) -c set.$(OBJ_EXT) $(SET)\set.c
40
41 #
42 # ****** These next targets are common to UNIX and PC world ********
43 #
44
45 #clean up all the intermediate files
46 clean:
47 del *.obj
48
49 #remove everything in clean plus the PCCTS files generated
50 scrub:
51 del $(PCCTS_GEN)
52 del *.$(OBJ_EXT)
53 EOF_watantlr.mak
+0
-106
contrib/pccts/dlg/DlgMS.mak less more
0 # PCCTS directory
1 PCCTS_HOME=<your PCCTS_HOME>
2 DLG_SRC=$(PCCTS_HOME)\dlg
3 PCCTS_H=$(PCCTS_HOME)\h
4
5
6 # Support directories
7 SET=$(PCCTS_HOME)\support\set
8
9
10 # Compiler stuff
11 CC = cl
12 CFLAGS = -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \
13 -D "ZZLEXBUFSIZE=65536" /D "LONGFILENAMES" /W3 /Zi
14
15 DLG_OBJS = dlg_p.obj dlg_a.obj main.obj err.obj support.obj \
16 output.obj relabel.obj automata.obj
17
18 SUPPORT_OBJS = set.obj
19
20 # Dependencies
21
22 dlg.exe: $(DLG_OBJS) $(SUPPORT_OBJS)
23 $(CC) $(CFLAGS) -o dlg.exe $(DLG_OBJS) $(SUPPORT_OBJS)
24 del *.obj
25
26 dlg_p.obj: $(DLG_SRC)\dlg_p.c \
27 $(PCCTS_H)\antlr.h \
28 $(PCCTS_H)\config.h \
29 $(PCCTS_H)\dlgdef.h \
30 $(SET)\set.h \
31 $(DLG_SRC)\dlg.h \
32 $(DLG_SRC)\mode.h \
33 $(DLG_SRC)\tokens.h \
34
35 $(CC) -c $(CFLAGS) $(DLG_SRC)\dlg_p.c
36
37 dlg_a.obj: $(DLG_SRC)\dlg_a.c \
38 $(PCCTS_H)\antlr.h \
39 $(PCCTS_H)\config.h \
40 $(PCCTS_H)\dlgauto.h \
41 $(PCCTS_H)\dlgdef.h \
42 $(SET)\set.h \
43 $(DLG_SRC)\dlg.h \
44 $(DLG_SRC)\mode.h \
45 $(DLG_SRC)\tokens.h \
46
47 $(CC) -c $(CFLAGS) $(DLG_SRC)\dlg_a.c
48
49 main.obj: $(DLG_SRC)\main.c \
50 $(PCCTS_H)\antlr.h \
51 $(PCCTS_H)\config.h \
52 $(PCCTS_H)\dlgdef.h \
53 $(SET)\set.h \
54 $(DLG_SRC)\dlg.h \
55 $(DLG_SRC)\mode.h \
56 $(DLG_SRC)\stdpccts.h \
57 $(DLG_SRC)\tokens.h \
58
59 $(CC) -c $(CFLAGS) $(DLG_SRC)\main.c
60
61 err.obj: $(DLG_SRC)\err.c \
62 $(PCCTS_H)\antlr.h \
63 $(PCCTS_H)\config.h \
64 $(PCCTS_H)\dlgdef.h \
65 $(PCCTS_H)\err.h \
66 $(SET)\set.h \
67 $(DLG_SRC)\dlg.h \
68 $(DLG_SRC)\tokens.h \
69
70 $(CC) -c $(CFLAGS) $(DLG_SRC)\err.c
71
72 support.obj: $(DLG_SRC)\support.c \
73 $(PCCTS_H)\config.h \
74 $(SET)\set.h \
75 $(DLG_SRC)\dlg.h \
76
77 $(CC) -c $(CFLAGS) $(DLG_SRC)\support.c
78
79 output.obj: $(DLG_SRC)\output.c \
80 $(PCCTS_H)\config.h \
81 $(SET)\set.h \
82 $(DLG_SRC)\dlg.h \
83
84 $(CC) -c $(CFLAGS) $(DLG_SRC)\output.c
85
86 relabel.obj: $(DLG_SRC)\relabel.c \
87 $(PCCTS_H)\config.h \
88 $(SET)\set.h \
89 $(DLG_SRC)\dlg.h \
90
91 $(CC) -c $(CFLAGS) $(DLG_SRC)\relabel.c
92
93 automata.obj: $(DLG_SRC)\automata.c \
94 $(PCCTS_H)\config.h \
95 $(SET)\set.h \
96 $(DLG_SRC)\dlg.h \
97
98 $(CC) -c $(CFLAGS) $(DLG_SRC)\automata.c
99
100
101 set.obj: $(SET)\set.c \
102 $(PCCTS_H)\config.h \
103 $(SET)\set.h \
104
105 $(CC) -c $(CFLAGS) $(SET)\set.c
+0
-217
contrib/pccts/dlg/DlgMSVC50.dsp less more
0 # Microsoft Developer Studio Project File - Name="DLG" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 5.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Console Application" 0x0103
5
6 CFG=DLG - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "DlgMSVC50.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "DlgMSVC50.mak" CFG="DLG - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "DLG - Win32 Release" (based on "Win32 (x86) Console Application")
20 !MESSAGE "DLG - Win32 Debug" (based on "Win32 (x86) Console Application")
21 !MESSAGE
22
23 # Begin Project
24 # PROP Scc_ProjName ""
25 # PROP Scc_LocalPath ""
26 CPP=cl.exe
27 RSC=rc.exe
28
29 !IF "$(CFG)" == "DLG - Win32 Release"
30
31 # PROP BASE Use_MFC 0
32 # PROP BASE Use_Debug_Libraries 0
33 # PROP BASE Output_Dir "Release"
34 # PROP BASE Intermediate_Dir "Release"
35 # PROP BASE Target_Dir ""
36 # PROP Use_MFC 0
37 # PROP Use_Debug_Libraries 0
38 # PROP Output_Dir "."
39 # PROP Intermediate_Dir "."
40 # PROP Ignore_Export_Lib 0
41 # PROP Target_Dir ""
42 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
43 # ADD CPP /nologo /W3 /O2 /I "..\h" /I "..\support\set" /D "__STDC__" /D "NDEBUG" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c
44 # SUBTRACT CPP /YX
45 # ADD BASE RSC /l 0x409 /d "NDEBUG"
46 # ADD RSC /l 0x409 /d "NDEBUG"
47 BSC32=bscmake.exe
48 # ADD BASE BSC32 /nologo
49 # ADD BSC32 /nologo
50 LINK32=link.exe
51 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
52 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"./Dlg.exe"
53 # Begin Special Build Tool
54 SOURCE=$(InputPath)
55 PostBuild_Desc=Copy to ..\bin directory
56 PostBuild_Cmds=mkdir ..\bin copy ..\bin\dlg.exe dlg_old.exe copy dlg.exe\
57 ..\bin\.
58 # End Special Build Tool
59
60 !ELSEIF "$(CFG)" == "DLG - Win32 Debug"
61
62 # PROP BASE Use_MFC 0
63 # PROP BASE Use_Debug_Libraries 1
64 # PROP BASE Output_Dir "Debug"
65 # PROP BASE Intermediate_Dir "Debug"
66 # PROP BASE Target_Dir ""
67 # PROP Use_MFC 0
68 # PROP Use_Debug_Libraries 1
69 # PROP Output_Dir "."
70 # PROP Intermediate_Dir "."
71 # PROP Ignore_Export_Lib 0
72 # PROP Target_Dir ""
73 # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
74 # ADD CPP /nologo /W3 /Gm /Zi /Od /I "..\h" /I "..\support\set" /D "__STDC__" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c
75 # SUBTRACT CPP /YX
76 # ADD BASE RSC /l 0x409 /d "_DEBUG"
77 # ADD RSC /l 0x409 /d "_DEBUG"
78 BSC32=bscmake.exe
79 # ADD BASE BSC32 /nologo
80 # ADD BSC32 /nologo
81 LINK32=link.exe
82 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
83 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"./Dlg.exe" /pdbtype:sept
84 # Begin Special Build Tool
85 SOURCE=$(InputPath)
86 PostBuild_Desc=Copy to ..\bin directory
87 PostBuild_Cmds=mkdir ..\bin copy ..\bin\dlg.exe dlg_old.exe copy dlg.exe\
88 ..\bin\.
89 # End Special Build Tool
90
91 !ENDIF
92
93 # Begin Target
94
95 # Name "DLG - Win32 Release"
96 # Name "DLG - Win32 Debug"
97 # Begin Source File
98
99 SOURCE=.\automata.c
100 # End Source File
101 # Begin Source File
102
103 SOURCE=.\dlg_a.c
104 # End Source File
105 # Begin Source File
106
107 SOURCE=.\dlg_p.c
108
109 !IF "$(CFG)" == "DLG - Win32 Release"
110
111 !ELSEIF "$(CFG)" == "DLG - Win32 Debug"
112
113 # SUBTRACT CPP /YX
114
115 !ENDIF
116
117 # End Source File
118 # Begin Source File
119
120 SOURCE=.\dlg_p.g
121
122 !IF "$(CFG)" == "DLG - Win32 Release"
123
124 # Begin Custom Build - Building DLG Parser from ANTLR Grammar
125 InputPath=.\dlg_p.g
126 InputName=dlg_p
127
128 BuildCmds= \
129 ..\bin\antlr $(InputName).g -gh \
130 ..\bin\dlg -C2 parser.dlg dlg_a.c \
131
132
133 "dlg_a.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
134 $(BuildCmds)
135
136 "dlg_p.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
137 $(BuildCmds)
138
139 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
140 $(BuildCmds)
141
142 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
143 $(BuildCmds)
144
145 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
146 $(BuildCmds)
147
148 "tokens.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
149 $(BuildCmds)
150
151 "stdpccts.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
152 $(BuildCmds)
153 # End Custom Build
154
155 !ELSEIF "$(CFG)" == "DLG - Win32 Debug"
156
157 # Begin Custom Build - Building DLG Parser from ANTLR Grammar
158 InputPath=.\dlg_p.g
159 InputName=dlg_p
160
161 BuildCmds= \
162 ..\bin\antlr $(InputName).g -gh \
163 ..\bin\dlg -C2 parser.dlg dlg_a.c \
164
165
166 "dlg_a.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
167 $(BuildCmds)
168
169 "dlg_p.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
170 $(BuildCmds)
171
172 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
173 $(BuildCmds)
174
175 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
176 $(BuildCmds)
177
178 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
179 $(BuildCmds)
180
181 "tokens.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
182 $(BuildCmds)
183
184 "stdpccts.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
185 $(BuildCmds)
186 # End Custom Build
187
188 !ENDIF
189
190 # End Source File
191 # Begin Source File
192
193 SOURCE=.\err.c
194 # End Source File
195 # Begin Source File
196
197 SOURCE=.\main.c
198 # End Source File
199 # Begin Source File
200
201 SOURCE=.\output.c
202 # End Source File
203 # Begin Source File
204
205 SOURCE=.\relabel.c
206 # End Source File
207 # Begin Source File
208
209 SOURCE=..\support\set\set.c
210 # End Source File
211 # Begin Source File
212
213 SOURCE=.\support.c
214 # End Source File
215 # End Target
216 # End Project
+0
-29
contrib/pccts/dlg/DlgMSVC50.dsw less more
0 Microsoft Developer Studio Workspace File, Format Version 5.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "DLG"=.\DlgMSVC50.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 }}}
10
11 Package=<4>
12 {{{
13 }}}
14
15 ###############################################################################
16
17 Global:
18
19 Package=<5>
20 {{{
21 }}}
22
23 Package=<3>
24 {{{
25 }}}
26
27 ###############################################################################
28
+0
-216
contrib/pccts/dlg/DlgMSVC60.dsp less more
0 # Microsoft Developer Studio Project File - Name="DLG" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 6.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Console Application" 0x0103
5
6 CFG=DLG - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "DlgMSVC60.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "DlgMSVC60.mak" CFG="DLG - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "DLG - Win32 Release" (based on "Win32 (x86) Console Application")
20 !MESSAGE "DLG - Win32 Debug" (based on "Win32 (x86) Console Application")
21 !MESSAGE
22
23 # Begin Project
24 # PROP AllowPerConfigDependencies 0
25 # PROP Scc_ProjName "DlgMSVC60"
26 # PROP Scc_LocalPath ".."
27 CPP=cl.exe
28 RSC=rc.exe
29
30 !IF "$(CFG)" == "DLG - Win32 Release"
31
32 # PROP BASE Use_MFC 0
33 # PROP BASE Use_Debug_Libraries 0
34 # PROP BASE Output_Dir "Release"
35 # PROP BASE Intermediate_Dir "Release"
36 # PROP BASE Target_Dir ""
37 # PROP Use_MFC 0
38 # PROP Use_Debug_Libraries 0
39 # PROP Output_Dir "."
40 # PROP Intermediate_Dir "."
41 # PROP Ignore_Export_Lib 0
42 # PROP Target_Dir ""
43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
44 # ADD CPP /nologo /W3 /O2 /I "..\h" /I "..\support\set" /D "__STDC__" /D "NDEBUG" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c
45 # SUBTRACT CPP /YX
46 # ADD BASE RSC /l 0x409 /d "NDEBUG"
47 # ADD RSC /l 0x409 /d "NDEBUG"
48 BSC32=bscmake.exe
49 # ADD BASE BSC32 /nologo
50 # ADD BSC32 /nologo
51 LINK32=link.exe
52 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
53 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"./Dlg.exe"
54 # Begin Special Build Tool
55 SOURCE="$(InputPath)"
56 PostBuild_Desc=Copy to ..\bin directory
57 PostBuild_Cmds=mkdir ..\bin copy ..\bin\dlg.exe dlg_old.exe copy dlg.exe ..\bin\.
58 # End Special Build Tool
59
60 !ELSEIF "$(CFG)" == "DLG - Win32 Debug"
61
62 # PROP BASE Use_MFC 0
63 # PROP BASE Use_Debug_Libraries 1
64 # PROP BASE Output_Dir "Debug"
65 # PROP BASE Intermediate_Dir "Debug"
66 # PROP BASE Target_Dir ""
67 # PROP Use_MFC 0
68 # PROP Use_Debug_Libraries 1
69 # PROP Output_Dir "."
70 # PROP Intermediate_Dir "."
71 # PROP Ignore_Export_Lib 0
72 # PROP Target_Dir ""
73 # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
74 # ADD CPP /nologo /W3 /Gm /ZI /Od /I "..\h" /I "..\support\set" /D "__STDC__" /D "LONGFILENAMES" /D "PC" /D "USER_ZZSYN" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /FD /c
75 # SUBTRACT CPP /YX
76 # ADD BASE RSC /l 0x409 /d "_DEBUG"
77 # ADD RSC /l 0x409 /d "_DEBUG"
78 BSC32=bscmake.exe
79 # ADD BASE BSC32 /nologo
80 # ADD BSC32 /nologo
81 LINK32=link.exe
82 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
83 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"./Dlg.exe" /pdbtype:sept
84 # Begin Special Build Tool
85 SOURCE="$(InputPath)"
86 PostBuild_Desc=Copy to ..\bin directory
87 PostBuild_Cmds=mkdir ..\bin copy ..\bin\dlg.exe dlg_old.exe copy dlg.exe ..\bin\.
88 # End Special Build Tool
89
90 !ENDIF
91
92 # Begin Target
93
94 # Name "DLG - Win32 Release"
95 # Name "DLG - Win32 Debug"
96 # Begin Source File
97
98 SOURCE=.\automata.c
99 # End Source File
100 # Begin Source File
101
102 SOURCE=.\dlg_a.c
103 # End Source File
104 # Begin Source File
105
106 SOURCE=.\dlg_p.c
107
108 !IF "$(CFG)" == "DLG - Win32 Release"
109
110 !ELSEIF "$(CFG)" == "DLG - Win32 Debug"
111
112 # SUBTRACT CPP /YX
113
114 !ENDIF
115
116 # End Source File
117 # Begin Source File
118
119 SOURCE=.\dlg_p.g
120
121 !IF "$(CFG)" == "DLG - Win32 Release"
122
123 # Begin Custom Build - Building DLG Parser from ANTLR Grammar
124 InputPath=.\dlg_p.g
125 InputName=dlg_p
126
127 BuildCmds= \
128 ..\bin\antlr $(InputName).g -gh \
129 ..\bin\dlg -C2 parser.dlg dlg_a.c \
130
131
132 "dlg_a.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
133 $(BuildCmds)
134
135 "dlg_p.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
136 $(BuildCmds)
137
138 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
139 $(BuildCmds)
140
141 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
142 $(BuildCmds)
143
144 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
145 $(BuildCmds)
146
147 "tokens.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
148 $(BuildCmds)
149
150 "stdpccts.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
151 $(BuildCmds)
152 # End Custom Build
153
154 !ELSEIF "$(CFG)" == "DLG - Win32 Debug"
155
156 # Begin Custom Build - Building DLG Parser from ANTLR Grammar
157 InputPath=.\dlg_p.g
158 InputName=dlg_p
159
160 BuildCmds= \
161 ..\bin\antlr $(InputName).g -gh \
162 ..\bin\dlg -C2 parser.dlg dlg_a.c \
163
164
165 "dlg_a.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
166 $(BuildCmds)
167
168 "dlg_p.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
169 $(BuildCmds)
170
171 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
172 $(BuildCmds)
173
174 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
175 $(BuildCmds)
176
177 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
178 $(BuildCmds)
179
180 "tokens.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
181 $(BuildCmds)
182
183 "stdpccts.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
184 $(BuildCmds)
185 # End Custom Build
186
187 !ENDIF
188
189 # End Source File
190 # Begin Source File
191
192 SOURCE=.\err.c
193 # End Source File
194 # Begin Source File
195
196 SOURCE=.\main.c
197 # End Source File
198 # Begin Source File
199
200 SOURCE=.\output.c
201 # End Source File
202 # Begin Source File
203
204 SOURCE=.\relabel.c
205 # End Source File
206 # Begin Source File
207
208 SOURCE=..\support\set\set.c
209 # End Source File
210 # Begin Source File
211
212 SOURCE=.\support.c
213 # End Source File
214 # End Target
215 # End Project
+0
-33
contrib/pccts/dlg/DlgMSVC60.dsw less more
0 Microsoft Developer Studio Workspace File, Format Version 6.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "DLG"=.\DlgMSVC60.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 begin source code control
10 DlgMSVC60
11 ..
12 end source code control
13 }}}
14
15 Package=<4>
16 {{{
17 }}}
18
19 ###############################################################################
20
21 Global:
22
23 Package=<5>
24 {{{
25 }}}
26
27 Package=<3>
28 {{{
29 }}}
30
31 ###############################################################################
32
+0
-48
contrib/pccts/dlg/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 noinst_PROGRAMS= dlg
4
5 AM_CFLAGS= -I. -I$(srcdir)/../support/set \
6 -I$(srcdir)/../h -DUSER_ZZSYN -DZZLEXBUFSIZE=32000
7
8 dlg_SOURCES= \
9 automata.c dlg.h dlg_p.c dlg_a.c err.c main.c mode.h \
10 output.c relabel.c $(srcdir)/../support/set/set.c \
11 stdpccts.h support.c tokens.h
12
13
14 # hopefully this won't produce some sort of chicken and egg problem
15
16 ANTLR= ../antlr/antlr
17 # Don't worry about the ambiguity messages coming from antlr
18 # for making antlr.c etc... [should be 10 of them, I think]
19 dlg_p.c parser.dlg err.c tokens.h : $(srcdir)/dlg_p.g
20 @if test -x ${ANTLR} ; then \
21 echo "${ANTLR} $(srcdir)/dlg_p.g" ; \
22 ${ANTLR} $(srcdir)/dlg_p.g ; \
23 else \
24 echo "WARNING: $(srcdir)/dlg_p.g has changed making dlg_p.c parser.dlg err.c tokens.h" ; \
25 echo " out of date." ; \
26 echo " However you have not finished building $(ANTLR) yet. So you may want to" ; \
27 echo " build again a 2nd time after your build (hopefully) finishes." ; \
28 fi
29
30 DLG= ./dlg
31 dlg_a.c mode.h: $(srcdir)/parser.dlg
32 @if test -x ${DLG} ; then \
33 echo "${DLG} -C2 $(srcdir)/parser.dlg scan.c" ; \
34 ${DLG} -C2 $(srcdir)/parser.dlg dlg_a.c ; \
35 else \
36 echo "WARNING: $(srcdir)/parser.g has changed making dlg_a.c and mode.h out of date." ; \
37 echo " However you have not finished building $(DLG) yet. So you may want to" ; \
38 echo " build again a 2nd time after your build (hopefully) finishes." ; \
39 fi
40
41
42 EXTRA_DIST= \
43 DlgMS.mak DlgMSVC50.dsp DlgMSVC50.dsw DlgMSVC60.dsp \
44 DlgMSVC60.dsw dlg.1 dlg.r dlg1.txt dlg68K.make \
45 dlgPPC.make dlg_p.g makefile.VMS makefile1 parser.dlg \
46 watdlg.mak
47
+0
-644
contrib/pccts/dlg/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 noinst_PROGRAMS = dlg$(EXEEXT)
79 subdir = contrib/pccts/dlg
80 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
81 $(top_srcdir)/depcomp
82 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
83 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
84 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
85 $(ACLOCAL_M4)
86 mkinstalldirs = $(install_sh) -d
87 CONFIG_HEADER = $(top_builddir)/config.h
88 CONFIG_CLEAN_FILES =
89 CONFIG_CLEAN_VPATH_FILES =
90 PROGRAMS = $(noinst_PROGRAMS)
91 am_dlg_OBJECTS = automata.$(OBJEXT) dlg_p.$(OBJEXT) dlg_a.$(OBJEXT) \
92 err.$(OBJEXT) main.$(OBJEXT) output.$(OBJEXT) \
93 relabel.$(OBJEXT) set.$(OBJEXT) support.$(OBJEXT)
94 dlg_OBJECTS = $(am_dlg_OBJECTS)
95 dlg_LDADD = $(LDADD)
96 AM_V_P = $(am__v_P_@AM_V@)
97 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
98 am__v_P_0 = false
99 am__v_P_1 = :
100 AM_V_GEN = $(am__v_GEN_@AM_V@)
101 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
102 am__v_GEN_0 = @echo " GEN " $@;
103 am__v_GEN_1 =
104 AM_V_at = $(am__v_at_@AM_V@)
105 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
106 am__v_at_0 = @
107 am__v_at_1 =
108 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
109 depcomp = $(SHELL) $(top_srcdir)/depcomp
110 am__depfiles_maybe = depfiles
111 am__mv = mv -f
112 AM_V_lt = $(am__v_lt_@AM_V@)
113 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
114 am__v_lt_0 = --silent
115 am__v_lt_1 =
116 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
117 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
118 AM_V_CC = $(am__v_CC_@AM_V@)
119 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
120 am__v_CC_0 = @echo " CC " $@;
121 am__v_CC_1 =
122 CCLD = $(CC)
123 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
124 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
125 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
126 am__v_CCLD_0 = @echo " CCLD " $@;
127 am__v_CCLD_1 =
128 SOURCES = $(dlg_SOURCES)
129 DIST_SOURCES = $(dlg_SOURCES)
130 am__can_run_installinfo = \
131 case $$AM_UPDATE_INFO_DIR in \
132 n|no|NO) false;; \
133 *) (install-info --version) >/dev/null 2>&1;; \
134 esac
135 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
136 # Read a list of newline-separated strings from the standard input,
137 # and print each of them once, without duplicates. Input order is
138 # *not* preserved.
139 am__uniquify_input = $(AWK) '\
140 BEGIN { nonempty = 0; } \
141 { items[$$0] = 1; nonempty = 1; } \
142 END { if (nonempty) { for (i in items) print i; }; } \
143 '
144 # Make sure the list of sources is unique. This is necessary because,
145 # e.g., the same source file might be shared among _SOURCES variables
146 # for different programs/libraries.
147 am__define_uniq_tagged_files = \
148 list='$(am__tagged_files)'; \
149 unique=`for i in $$list; do \
150 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
151 done | $(am__uniquify_input)`
152 ETAGS = etags
153 CTAGS = ctags
154 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
155 ACLOCAL = @ACLOCAL@
156 AET2_CFLAGS = @AET2_CFLAGS@
157 AET2_LDADD = @AET2_LDADD@
158 ALLOCA = @ALLOCA@
159 AMTAR = @AMTAR@
160 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
161 AUTOCONF = @AUTOCONF@
162 AUTOHEADER = @AUTOHEADER@
163 AUTOMAKE = @AUTOMAKE@
164 AWK = @AWK@
165 CC = @CC@
166 CCDEPMODE = @CCDEPMODE@
167 CFLAGS = @CFLAGS@
168 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
169 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
170 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
171 CPP = @CPP@
172 CPPFLAGS = @CPPFLAGS@
173 CXX = @CXX@
174 CXXDEPMODE = @CXXDEPMODE@
175 CXXFLAGS = @CXXFLAGS@
176 CYGPATH_W = @CYGPATH_W@
177 DEFS = @DEFS@
178 DEPDIR = @DEPDIR@
179 ECHO_C = @ECHO_C@
180 ECHO_N = @ECHO_N@
181 ECHO_T = @ECHO_T@
182 EGREP = @EGREP@
183 EXEEXT = @EXEEXT@
184 EXTDEBUG = @EXTDEBUG@
185 EXTDEBUG2 = @EXTDEBUG2@
186 EXTDEBUG3 = @EXTDEBUG3@
187 EXTDEBUG4 = @EXTDEBUG4@
188 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
189 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
190 FSDB_CFLAGS = @FSDB_CFLAGS@
191 FSDB_LDADD = @FSDB_LDADD@
192 GCONF_CFLAGS = @GCONF_CFLAGS@
193 GCONF_LIBS = @GCONF_LIBS@
194 GEDITTEST = @GEDITTEST@
195 GEDIT_CFLAGS = @GEDIT_CFLAGS@
196 GIO_CFLAGS = @GIO_CFLAGS@
197 GIO_LIBS = @GIO_LIBS@
198 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
199 GPERF = @GPERF@
200 GREP = @GREP@
201 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
202 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
203 GTK_CFLAGS = @GTK_CFLAGS@
204 GTK_CONFIG = @GTK_CONFIG@
205 GTK_LIBS = @GTK_LIBS@
206 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
207 GTK_MAC_LIBS = @GTK_MAC_LIBS@
208 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
209 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
210 INSTALL = @INSTALL@
211 INSTALL_DATA = @INSTALL_DATA@
212 INSTALL_PROGRAM = @INSTALL_PROGRAM@
213 INSTALL_SCRIPT = @INSTALL_SCRIPT@
214 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
215 LDFLAGS = @LDFLAGS@
216 LEX = @LEX@
217 LEXLIB = @LEXLIB@
218 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
219 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
220 LIBBZ2_DIR = @LIBBZ2_DIR@
221 LIBBZ2_LDADD = @LIBBZ2_LDADD@
222 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
223 LIBJUDY_LDADD = @LIBJUDY_LDADD@
224 LIBOBJS = @LIBOBJS@
225 LIBS = @LIBS@
226 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
227 LIBXZ_LDADD = @LIBXZ_LDADD@
228 LIBZ_CFLAGS = @LIBZ_CFLAGS@
229 LIBZ_DIR = @LIBZ_DIR@
230 LIBZ_LDADD = @LIBZ_LDADD@
231 LTLIBOBJS = @LTLIBOBJS@
232 MAINT = @MAINT@
233 MAKEINFO = @MAKEINFO@
234 MINGW_LDADD = @MINGW_LDADD@
235 MKDIR_P = @MKDIR_P@
236 OBJEXT = @OBJEXT@
237 PACKAGE = @PACKAGE@
238 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
239 PACKAGE_NAME = @PACKAGE_NAME@
240 PACKAGE_STRING = @PACKAGE_STRING@
241 PACKAGE_TARNAME = @PACKAGE_TARNAME@
242 PACKAGE_URL = @PACKAGE_URL@
243 PACKAGE_VERSION = @PACKAGE_VERSION@
244 PATH_SEPARATOR = @PATH_SEPARATOR@
245 PKG_CONFIG = @PKG_CONFIG@
246 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
247 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
248 POW_LIB = @POW_LIB@
249 RANLIB = @RANLIB@
250 RPC_CFLAGS = @RPC_CFLAGS@
251 RPC_LDADD = @RPC_LDADD@
252 SET_MAKE = @SET_MAKE@
253 SHELL = @SHELL@
254 STRIP = @STRIP@
255 STRUCT_PACK = @STRUCT_PACK@
256 TCL_DEFADD = @TCL_DEFADD@
257 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
258 TCL_LDADD = @TCL_LDADD@
259 TCL_LIB_SPEC = @TCL_LIB_SPEC@
260 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
261 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
262 TIRPC_CFLAGS = @TIRPC_CFLAGS@
263 TIRPC_LIBS = @TIRPC_LIBS@
264 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
265 TK_LDADD = @TK_LDADD@
266 TK_LIB_SPEC = @TK_LIB_SPEC@
267 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
268 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
269 VERSION = @VERSION@
270 XDGDATADIR = @XDGDATADIR@
271 abs_builddir = @abs_builddir@
272 abs_srcdir = @abs_srcdir@
273 abs_top_builddir = @abs_top_builddir@
274 abs_top_srcdir = @abs_top_srcdir@
275 ac_ct_CC = @ac_ct_CC@
276 ac_ct_CXX = @ac_ct_CXX@
277 am__include = @am__include@
278 am__leading_dot = @am__leading_dot@
279 am__quote = @am__quote@
280 am__tar = @am__tar@
281 am__untar = @am__untar@
282 bindir = @bindir@
283 build_alias = @build_alias@
284 builddir = @builddir@
285 datadir = @datadir@
286 datarootdir = @datarootdir@
287 docdir = @docdir@
288 dvidir = @dvidir@
289 exec_prefix = @exec_prefix@
290 gsettingsschemadir = @gsettingsschemadir@
291 host_alias = @host_alias@
292 htmldir = @htmldir@
293 includedir = @includedir@
294 infodir = @infodir@
295 install_sh = @install_sh@
296 libdir = @libdir@
297 libexecdir = @libexecdir@
298 localedir = @localedir@
299 localstatedir = @localstatedir@
300 mandir = @mandir@
301 mkdir_p = @mkdir_p@
302 oldincludedir = @oldincludedir@
303 pdfdir = @pdfdir@
304 prefix = @prefix@
305 program_transform_name = @program_transform_name@
306 psdir = @psdir@
307 sbindir = @sbindir@
308 sharedstatedir = @sharedstatedir@
309 srcdir = @srcdir@
310 sysconfdir = @sysconfdir@
311 target_alias = @target_alias@
312 top_build_prefix = @top_build_prefix@
313 top_builddir = @top_builddir@
314 top_srcdir = @top_srcdir@
315 AM_CFLAGS = -I. -I$(srcdir)/../support/set \
316 -I$(srcdir)/../h -DUSER_ZZSYN -DZZLEXBUFSIZE=32000
317
318 dlg_SOURCES = \
319 automata.c dlg.h dlg_p.c dlg_a.c err.c main.c mode.h \
320 output.c relabel.c $(srcdir)/../support/set/set.c \
321 stdpccts.h support.c tokens.h
322
323
324 # hopefully this won't produce some sort of chicken and egg problem
325 ANTLR = ../antlr/antlr
326 DLG = ./dlg
327 EXTRA_DIST = \
328 DlgMS.mak DlgMSVC50.dsp DlgMSVC50.dsw DlgMSVC60.dsp \
329 DlgMSVC60.dsw dlg.1 dlg.r dlg1.txt dlg68K.make \
330 dlgPPC.make dlg_p.g makefile.VMS makefile1 parser.dlg \
331 watdlg.mak
332
333 all: all-am
334
335 .SUFFIXES:
336 .SUFFIXES: .c .o .obj
337 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
338 @for dep in $?; do \
339 case '$(am__configure_deps)' in \
340 *$$dep*) \
341 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
342 && { if test -f $@; then exit 0; else break; fi; }; \
343 exit 1;; \
344 esac; \
345 done; \
346 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/dlg/Makefile'; \
347 $(am__cd) $(top_srcdir) && \
348 $(AUTOMAKE) --foreign contrib/pccts/dlg/Makefile
349 .PRECIOUS: Makefile
350 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
351 @case '$?' in \
352 *config.status*) \
353 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
354 *) \
355 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
356 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
357 esac;
358
359 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
360 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
361
362 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
363 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
364 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
365 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
366 $(am__aclocal_m4_deps):
367
368 clean-noinstPROGRAMS:
369 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
370
371 dlg$(EXEEXT): $(dlg_OBJECTS) $(dlg_DEPENDENCIES) $(EXTRA_dlg_DEPENDENCIES)
372 @rm -f dlg$(EXEEXT)
373 $(AM_V_CCLD)$(LINK) $(dlg_OBJECTS) $(dlg_LDADD) $(LIBS)
374
375 mostlyclean-compile:
376 -rm -f *.$(OBJEXT)
377
378 distclean-compile:
379 -rm -f *.tab.c
380
381 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/automata.Po@am__quote@
382 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlg_a.Po@am__quote@
383 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlg_p.Po@am__quote@
384 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Po@am__quote@
385 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
386 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@
387 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relabel.Po@am__quote@
388 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set.Po@am__quote@
389 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/support.Po@am__quote@
390
391 .c.o:
392 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
393 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
394 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
395 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
396 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
397
398 .c.obj:
399 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
400 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
401 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
402 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
403 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
404
405 set.o: $(srcdir)/../support/set/set.c
406 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT set.o -MD -MP -MF $(DEPDIR)/set.Tpo -c -o set.o `test -f '$(srcdir)/../support/set/set.c' || echo '$(srcdir)/'`$(srcdir)/../support/set/set.c
407 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/set.Tpo $(DEPDIR)/set.Po
408 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../support/set/set.c' object='set.o' libtool=no @AMDEPBACKSLASH@
409 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
410 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o set.o `test -f '$(srcdir)/../support/set/set.c' || echo '$(srcdir)/'`$(srcdir)/../support/set/set.c
411
412 set.obj: $(srcdir)/../support/set/set.c
413 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT set.obj -MD -MP -MF $(DEPDIR)/set.Tpo -c -o set.obj `if test -f '$(srcdir)/../support/set/set.c'; then $(CYGPATH_W) '$(srcdir)/../support/set/set.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../support/set/set.c'; fi`
414 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/set.Tpo $(DEPDIR)/set.Po
415 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../support/set/set.c' object='set.obj' libtool=no @AMDEPBACKSLASH@
416 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
417 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o set.obj `if test -f '$(srcdir)/../support/set/set.c'; then $(CYGPATH_W) '$(srcdir)/../support/set/set.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../support/set/set.c'; fi`
418
419 ID: $(am__tagged_files)
420 $(am__define_uniq_tagged_files); mkid -fID $$unique
421 tags: tags-am
422 TAGS: tags
423
424 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
425 set x; \
426 here=`pwd`; \
427 $(am__define_uniq_tagged_files); \
428 shift; \
429 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
430 test -n "$$unique" || unique=$$empty_fix; \
431 if test $$# -gt 0; then \
432 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
433 "$$@" $$unique; \
434 else \
435 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
436 $$unique; \
437 fi; \
438 fi
439 ctags: ctags-am
440
441 CTAGS: ctags
442 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
443 $(am__define_uniq_tagged_files); \
444 test -z "$(CTAGS_ARGS)$$unique" \
445 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
446 $$unique
447
448 GTAGS:
449 here=`$(am__cd) $(top_builddir) && pwd` \
450 && $(am__cd) $(top_srcdir) \
451 && gtags -i $(GTAGS_ARGS) "$$here"
452 cscopelist: cscopelist-am
453
454 cscopelist-am: $(am__tagged_files)
455 list='$(am__tagged_files)'; \
456 case "$(srcdir)" in \
457 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
458 *) sdir=$(subdir)/$(srcdir) ;; \
459 esac; \
460 for i in $$list; do \
461 if test -f "$$i"; then \
462 echo "$(subdir)/$$i"; \
463 else \
464 echo "$$sdir/$$i"; \
465 fi; \
466 done >> $(top_builddir)/cscope.files
467
468 distclean-tags:
469 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
470
471 distdir: $(DISTFILES)
472 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
473 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
474 list='$(DISTFILES)'; \
475 dist_files=`for file in $$list; do echo $$file; done | \
476 sed -e "s|^$$srcdirstrip/||;t" \
477 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
478 case $$dist_files in \
479 */*) $(MKDIR_P) `echo "$$dist_files" | \
480 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
481 sort -u` ;; \
482 esac; \
483 for file in $$dist_files; do \
484 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
485 if test -d $$d/$$file; then \
486 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
487 if test -d "$(distdir)/$$file"; then \
488 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
489 fi; \
490 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
491 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
492 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
493 fi; \
494 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
495 else \
496 test -f "$(distdir)/$$file" \
497 || cp -p $$d/$$file "$(distdir)/$$file" \
498 || exit 1; \
499 fi; \
500 done
501 check-am: all-am
502 check: check-am
503 all-am: Makefile $(PROGRAMS)
504 installdirs:
505 install: install-am
506 install-exec: install-exec-am
507 install-data: install-data-am
508 uninstall: uninstall-am
509
510 install-am: all-am
511 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
512
513 installcheck: installcheck-am
514 install-strip:
515 if test -z '$(STRIP)'; then \
516 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
517 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
518 install; \
519 else \
520 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
521 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
522 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
523 fi
524 mostlyclean-generic:
525
526 clean-generic:
527
528 distclean-generic:
529 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
530 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
531
532 maintainer-clean-generic:
533 @echo "This command is intended for maintainers to use"
534 @echo "it deletes files that may require special tools to rebuild."
535 clean: clean-am
536
537 clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am
538
539 distclean: distclean-am
540 -rm -rf ./$(DEPDIR)
541 -rm -f Makefile
542 distclean-am: clean-am distclean-compile distclean-generic \
543 distclean-tags
544
545 dvi: dvi-am
546
547 dvi-am:
548
549 html: html-am
550
551 html-am:
552
553 info: info-am
554
555 info-am:
556
557 install-data-am:
558
559 install-dvi: install-dvi-am
560
561 install-dvi-am:
562
563 install-exec-am:
564
565 install-html: install-html-am
566
567 install-html-am:
568
569 install-info: install-info-am
570
571 install-info-am:
572
573 install-man:
574
575 install-pdf: install-pdf-am
576
577 install-pdf-am:
578
579 install-ps: install-ps-am
580
581 install-ps-am:
582
583 installcheck-am:
584
585 maintainer-clean: maintainer-clean-am
586 -rm -rf ./$(DEPDIR)
587 -rm -f Makefile
588 maintainer-clean-am: distclean-am maintainer-clean-generic
589
590 mostlyclean: mostlyclean-am
591
592 mostlyclean-am: mostlyclean-compile mostlyclean-generic
593
594 pdf: pdf-am
595
596 pdf-am:
597
598 ps: ps-am
599
600 ps-am:
601
602 uninstall-am:
603
604 .MAKE: install-am install-strip
605
606 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
607 clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \
608 distclean-compile distclean-generic distclean-tags distdir dvi \
609 dvi-am html html-am info info-am install install-am \
610 install-data install-data-am install-dvi install-dvi-am \
611 install-exec install-exec-am install-html install-html-am \
612 install-info install-info-am install-man install-pdf \
613 install-pdf-am install-ps install-ps-am install-strip \
614 installcheck installcheck-am installdirs maintainer-clean \
615 maintainer-clean-generic mostlyclean mostlyclean-compile \
616 mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
617 uninstall-am
618
619 # Don't worry about the ambiguity messages coming from antlr
620 # for making antlr.c etc... [should be 10 of them, I think]
621 dlg_p.c parser.dlg err.c tokens.h : $(srcdir)/dlg_p.g
622 @if test -x ${ANTLR} ; then \
623 echo "${ANTLR} $(srcdir)/dlg_p.g" ; \
624 ${ANTLR} $(srcdir)/dlg_p.g ; \
625 else \
626 echo "WARNING: $(srcdir)/dlg_p.g has changed making dlg_p.c parser.dlg err.c tokens.h" ; \
627 echo " out of date." ; \
628 echo " However you have not finished building $(ANTLR) yet. So you may want to" ; \
629 echo " build again a 2nd time after your build (hopefully) finishes." ; \
630 fi
631 dlg_a.c mode.h: $(srcdir)/parser.dlg
632 @if test -x ${DLG} ; then \
633 echo "${DLG} -C2 $(srcdir)/parser.dlg scan.c" ; \
634 ${DLG} -C2 $(srcdir)/parser.dlg dlg_a.c ; \
635 else \
636 echo "WARNING: $(srcdir)/parser.g has changed making dlg_a.c and mode.h out of date." ; \
637 echo " However you have not finished building $(DLG) yet. So you may want to" ; \
638 echo " build again a 2nd time after your build (hopefully) finishes." ; \
639 fi
640
641 # Tell versions [3.59,3.63) of GNU make to not export all variables.
642 # Otherwise a system limit (for SysV at least) may be exceeded.
643 .NOEXPORT:
+0
-353
contrib/pccts/dlg/automata.c less more
0 /* Automata conversion functions for DLG
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * DLG 1.33
23 * Will Cohen
24 * With mods by Terence Parr; AHPCRC, University of Minnesota
25 * 1989-2001
26 */
27
28 #include <stdio.h>
29 #include "pcctscfg.h"
30 #include "dlg.h"
31 #ifdef MEMCHK
32 #include "trax.h"
33 #else
34 #ifdef __STDC__
35 #include <stdlib.h>
36 #else
37 #include <malloc.h>
38 #endif /* __STDC__ */
39 #endif
40
41 #define hash_list struct _hash_list_
42 hash_list{
43 hash_list *next; /* next thing in list */
44 dfa_node *node;
45 };
46
47 int dfa_allocated = 0; /* keeps track of number of dfa nodes */
48 dfa_node **dfa_array; /* root of binary tree that stores dfa array */
49 dfa_node *dfa_model_node;
50 hash_list *dfa_hash[HASH_SIZE]; /* used to quickly find */
51 /* desired dfa node */
52
53 void
54 #ifdef __USE_PROTOS
55 make_dfa_model_node(int width)
56 #else
57 make_dfa_model_node(width)
58 int width;
59 #endif
60 {
61 register int i;
62 dfa_model_node = (dfa_node*) malloc(sizeof(dfa_node)
63 + sizeof(int)*width);
64 dfa_model_node->node_no = -1; /* impossible value for real dfa node */
65 dfa_model_node->dfa_set = 0;
66 dfa_model_node->alternatives = FALSE;
67 dfa_model_node->done = FALSE;
68 dfa_model_node->nfa_states = empty;
69 for(i = 0; i<width; i++){
70 dfa_model_node->trans[i] = NIL_INDEX;
71 }
72 }
73
74
75 /* adds a new nfa to the binary tree and returns a pointer to it */
76 dfa_node *
77 #ifdef __USE_PROTOS
78 new_dfa_node(set nfa_states)
79 #else
80 new_dfa_node(nfa_states)
81 set nfa_states;
82 #endif
83 {
84 register int j;
85 register dfa_node *t;
86 static int dfa_size=0; /* elements dfa_array[] can hold */
87
88 ++dfa_allocated;
89 if (dfa_size<=dfa_allocated){
90 /* need to redo array */
91 if (!dfa_array){
92 /* need some to do inital allocation */
93 dfa_size=dfa_allocated+DFA_MIN;
94 dfa_array=(dfa_node **) malloc(sizeof(dfa_node*)*
95 dfa_size);
96 }else{
97 /* need more space */
98 dfa_size=2*(dfa_allocated+1);
99 dfa_array=(dfa_node **) realloc(dfa_array,
100 sizeof(dfa_node*)*dfa_size);
101 }
102 }
103 /* fill out entry in array */
104 t = (dfa_node*) malloc(sizeof(nfa_node)+sizeof(int)*class_no);
105 *t = *dfa_model_node;
106 for (j=0; j<class_no; ++j)
107 t->trans[j] = NIL_INDEX;
108 t->node_no = dfa_allocated;
109 t->nfa_states = set_dup(nfa_states);
110 dfa_array[dfa_allocated] = t;
111 return t;
112 }
113
114
115 /* past a pointer to the start start of the nfa graph
116 * nfa_to_dfa convers this graph to dfa. The function returns
117 * a pointer to the first dfa state.
118 * NOTE: The function that prints out the table will have to figure out how
119 * to find the other dfa states given the first dfa_state and the number of dfa
120 * nodes allocated
121 */
122 dfa_node **
123 #ifdef __USE_PROTOS
124 nfa_to_dfa(nfa_node *start)
125 #else
126 nfa_to_dfa(start)
127 nfa_node *start;
128 #endif
129 {
130 register dfa_node *d_state, *trans_d_state;
131 register int a;
132 set t;
133 int last_done;
134 unsigned *nfa_list;
135 unsigned *reach_list;
136
137 reach_list = (unsigned *) malloc((2+nfa_allocated)*sizeof(unsigned));
138 if (!start) return NULL;
139 t = set_of(NFA_NO(start));
140 _set_pdq(t,reach_list);
141 closure(&t,reach_list);
142 /* Make t a dfa state */
143 d_state = dfastate(t);
144 last_done = DFA_NO(d_state);
145
146 do {
147 /* Mark dfa state x as "done" */
148 d_state->done = TRUE;
149 nfa_list = set_pdq(d_state->nfa_states);
150 for (a = 0; a<class_no; ++a) {
151 /* Add NFA states reached by a from d_state */
152 reach(nfa_list,a,reach_list);
153 /* Were any states found? */
154 if ((*reach_list)!=nil) {
155 /* was t=empty; */
156 set_free(t);
157 /* yes, compute closure */
158 closure(&t,reach_list);
159 /* Make DFA state of it ... */
160 trans_d_state = dfastate(t);
161 /* And make transition x->t, labeled with a */
162 d_state->trans[a] = DFA_NO(trans_d_state);
163 d_state->alternatives = TRUE;
164 }
165 }
166 free(nfa_list);
167 ++last_done; /* move forward in queue */
168 /* And so forth until nothing isn't done */
169 d_state = DFA(last_done);
170 } while (last_done<=dfa_allocated);
171
172 free(reach_list);
173 set_free(t);
174
175 /* returns pointer to the array that holds the automaton */
176 return dfa_array;
177 }
178
179 void
180 #ifdef __USE_PROTOS
181 clear_hash(void)
182 #else
183 clear_hash()
184 #endif
185 {
186 register int i;
187
188 for(i=0; i<HASH_SIZE; ++i)
189 dfa_hash[i] = 0;
190 }
191
192 #if HASH_STAT
193 void
194 #ifdef __USE_PROTOS
195 fprint_hash_stats(FILE *f)
196 #else
197 fprint_hash_stats(f)
198 FILE *f;
199 #endif
200 {
201 register hash_list *p;
202 register int i,j;
203 register total;
204
205 total=0;
206 for(i=0; i<HASH_SIZE; ++i){
207 j=0;
208 p = dfa_hash[i];
209 while(p){
210 ++j;
211 p = p->next;
212 }
213 total+=j;
214 fprintf(f,"bin[%d] has %d\n",i,j);
215 }
216 fprintf(f,"total = %d\n",total);
217 }
218 #endif
219
220 /* Returns a pointer to a dfa node that has the same nfa nodes in it.
221 * This may or maynot be a newly created node.
222 */
223 dfa_node *
224 #ifdef __USE_PROTOS
225 dfastate(set nfa_states)
226 #else
227 dfastate(nfa_states)
228 set nfa_states;
229 #endif
230 {
231 register hash_list *p;
232 int bin;
233
234 /* hash using set and see if it exists */
235 bin = set_hash(nfa_states,HASH_SIZE);
236 p = dfa_hash[bin];
237 while(p && !set_equ(nfa_states,(p->node)->nfa_states)){
238 p = p->next;
239 }
240 if(!p){
241 /* next state to add to hash table */
242 p = (hash_list*)malloc(sizeof(hash_list));
243 p->node = new_dfa_node(nfa_states);
244 p->next = dfa_hash[bin];
245 dfa_hash[bin] = p;
246 }
247 return (p->node);
248 }
249
250
251 /* this reach assumes the closure has been done already on set */
252 int
253 #ifdef __USE_PROTOS
254 reach(unsigned *nfa_list, register int a, unsigned *reach_list)
255 #else
256 reach(nfa_list, a, reach_list)
257 unsigned *nfa_list;
258 register int a;
259 unsigned *reach_list;
260 #endif
261 {
262 register unsigned *e;
263 register nfa_node *node;
264 int t=0;
265
266 e = nfa_list;
267 if (e){
268 while (*e != nil){
269 node = NFA(*e);
270 if (set_el(a,node->label)){
271 t=1;
272 *reach_list=NFA_NO(node->trans[0]);
273 ++reach_list;
274 }
275 ++e;
276 }
277 }
278 *reach_list=nil;
279 return t;
280 }
281
282 /* finds all the nodes that can be reached by epsilon transitions
283 from the set of a nodes and returns puts them back in set b */
284 set
285 #ifdef __USE_PROTOS
286 closure(set *b, unsigned *reach_list)
287 #else
288 closure(b, reach_list)
289 set *b;
290 unsigned *reach_list;
291 #endif
292 {
293 register nfa_node *node,*n; /* current node being examined */
294 register unsigned *e;
295
296 ++operation_no;
297 #if 0
298 t = e = set_pdq(*b);
299 #else
300 e=reach_list;
301 #endif
302 while (*e != nil){
303 node = NFA(*e);
304 set_orel(NFA_NO(node),b);
305 /* mark it done */
306 node->nfa_set = operation_no;
307 if ((n=node->trans[0]) != NIL_INDEX && set_nil(node->label) &&
308 (n->nfa_set != operation_no)){
309 /* put in b */
310 set_orel(NFA_NO(n),b);
311 close1(n,operation_no,b);
312 }
313 if ((n=node->trans[1]) != NIL_INDEX &&
314 (n->nfa_set != operation_no)){
315 /* put in b */
316 set_orel(NFA_NO(node->trans[1]),b);
317 close1(n,operation_no,b);
318 }
319 ++e;
320 }
321 #if 0
322 free(t);
323 #endif
324 return *b;
325 }
326
327 #ifdef __USE_PROTOS
328 void close1(nfa_node *node, int o, set *b)
329 #else
330 void close1(node,o,b)
331 nfa_node *node;
332 int o; /* marker to avoid cycles */
333 set *b;
334 #endif
335 {
336 register nfa_node *n; /* current node being examined */
337
338 /* mark it done */
339 node->nfa_set = o;
340 if ((n=node->trans[0]) != NIL_INDEX && set_nil(node->label) &&
341 (n->nfa_set != o)){
342 /* put in b */
343 set_orel(NFA_NO(n),b);
344 close1(n,o,b);
345 }
346 if ((n=node->trans[1]) != NIL_INDEX &&
347 (n->nfa_set != o)){
348 /* put in b */
349 set_orel(NFA_NO(node->trans[1]),b);
350 close1(n,o,b);
351 }
352 }
+0
-79
contrib/pccts/dlg/dlg.1 less more
0 .TH dlg 1 "April 1994" "DLG" "PCCTS Manual Pages"
1 .SH NAME
2 dlg \- DFA Lexical Analyzer Generator
3 .SH SYNTAX
4 .LP
5 \fBdlg\fR [\fIoptions\fR] \fIlexical_spec\fR [\fIoutput_file\fR]
6 .SH DESCRIPTION
7 .B dlg
8 is a tool that produces fast deterministic finite automata for recognizing
9 regular expressions in input.
10 .SH OPTIONS
11 .IP "\fB-CC\fR"
12 Generate C++ output. The \fIoutput_file\fP is not specified in this
13 case.
14 .IP "\fB-C\fR[\fP level\fR]
15 Where \fPlevel\fR is the compression level used. 0 indications no
16 compression, 1 removes all unused characters from the transition from table,
17 and 2 maps equivalent characters into the same character classes. It is
18 suggested that level -C2 is used, since it will significantly reduce the size
19 of the dfa produced for lexical analyzer.
20 .IP "\fB-m\fP
21 Produces the header file for the lexical mode with a name other than
22 the default name of "mode.h".
23 .IP \fB-i\fP
24 An interactive, or as interactive as possible, parser is produced. A character
25 is only obtained when required to decide which state to go to. Some care
26 must be taken to obtain accept states that do not require look ahead at the
27 next character to determine if that is the stop state. Any regular expression
28 with a Kleene closure at the end is guaranteed to require another character
29 of look ahead.
30 .IP "\fB-cl\fP class
31 Specify a class name for DLG to generate. The default is DLGLexer.
32 'class' will be a subclass of DLGLexerBase; only used for -CC.
33 .IP \fB-ci\fP
34 The automaton will treat upper and lower case characters identically.
35 This is accomplished in the automaton; the characters in the lexical
36 buffer are unmodified.
37 .IP \fB-cs\fP
38 Upper and lower case characters are treated as distinct. This is the
39 default.
40 .IP "\fB-o\fP dir
41 Directory where output files should go (default="."). This is very
42 nice for keeping the source directory clear of ANTLR and DLG spawn.
43 .IP \fB-Wambiguity\fP
44 Warns if more than one regular expression could match the same character
45 sequence. The warnings give the numbers of the expressions in the dlg
46 lexical specification file. The numbering of the expressions starts at one.
47 Multiple warnings may be print for the same expressions.
48 .IP \-
49 Used in place of file names to get input from standard in or send output
50 to standard out.
51 .SH "SPECIAL CONSIDERATIONS"
52 .PP
53 \fIDlg\fP works... we think. There is no implicit guarantee of
54 anything. We reserve no \fBlegal\fP rights to the software known as
55 the Purdue Compiler Construction Tool Set (PCCTS) \(em PCCTS is in the
56 public domain. An individual or company may do whatever they wish
57 with source code distributed with PCCTS or the code generated by
58 PCCTS, including the incorporation of PCCTS, or its output, into
59 commercial software. We encourage users to develop software with
60 PCCTS. However, we do ask that credit is given to us for developing
61 PCCTS. By "credit", we mean that if you incorporate our source code
62 into one of your programs (commercial product, research project, or
63 otherwise) that you acknowledge this fact somewhere in the
64 documentation, research report, etc... If you like PCCTS and have
65 developed a nice tool with the output, please mention that you
66 developed it using PCCTS. As long as these guidelines are followed, we
67 expect to continue enhancing this system and expect to make other
68 tools available as they are completed.
69 .SH FILES
70 .B mode.h
71 ,
72 .B dlgauto.h
73 ,
74 .B dlgdef.h
75 .SH SEE ALSO
76 .BR antlr (1),
77 .BR pccts (1)
78 .SH BUGS
+0
-250
contrib/pccts/dlg/dlg.h less more
0 /* dlg header file
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * DLG 1.33
23 * Will Cohen
24 * With mods by Terence Parr; AHPCRC, University of Minnesota
25 * 1989-2001
26 */
27
28 /* MR1 Move pcctscfg.h to top of file */
29
30 #include "pcctscfg.h"
31
32 /* turn off warnings for unreferenced labels */
33
34 #ifdef _MSC_VER
35 #pragma warning(disable:4102)
36 #endif
37
38 #include "set.h"
39
40 #define TRUE 1
41 #define FALSE 0
42
43 /***** output related stuff *******************/
44 #define IN input_stream
45 #define OUT output_stream
46
47 #define MAX_MODES 50 /* number of %%names allowed */
48 #define MAX_ON_LINE 10
49
50 #define NFA_MIN 64 /* minimum nfa_array size */
51 #define DFA_MIN 64 /* minimum dfa_array size */
52
53 #define DEFAULT_CLASSNAME "DLGLexer"
54
55 /* these macros allow the size of the character set to be easily changed */
56 /* NOTE: do NOT change MIN_CHAR since EOF is the lowest char, -1 */
57 #define MIN_CHAR (-1) /* lowest possible character possible on input */
58 #define MAX_CHAR 255 /* highest possible character possible on input */
59 #define CHAR_RANGE (1+(MAX_CHAR) - (MIN_CHAR))
60
61 /* indicates that the not an "array" reference */
62 #define NIL_INDEX 0
63
64 /* size of hash table used to find dfa_states quickly */
65 #define HASH_SIZE 211
66
67 #define nfa_node struct _nfa_node
68 nfa_node {
69 int node_no;
70 int nfa_set;
71 int accept; /* what case to use */
72 nfa_node *trans[2];
73 set label; /* one arc always labelled with epsilon */
74 };
75
76 #define dfa_node struct _dfa_node
77 dfa_node {
78 int node_no;
79 int dfa_set;
80 int alternatives; /* used for interactive mode */
81 /* are more characters needed */
82 int done;
83 set nfa_states;
84 int trans[1];/* size of transition table depends on
85 * number of classes required for automata.
86 */
87
88
89 };
90
91 /******** macros for accessing the NFA and DFA nodes ****/
92 #define NFA(x) (nfa_array[x])
93 #define DFA(x) (dfa_array[x])
94 #define DFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)
95 #define NFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)
96
97 /******** wrapper for memory checking ***/
98 /*#define malloc(x) dlg_malloc((x),__FILE__,__LINE__)*/
99
100 /*#define calloc(x,y) dlg_calloc((x),(y),__FILE__,__LINE__)*/
101
102 /******** antlr attributes *************/
103 typedef struct {
104 unsigned char letter;
105 nfa_node *l,*r;
106 set label;
107 } Attrib;
108
109 #define zzcr_attr(attr, token, text) { \
110 (attr)->letter = text[0]; (attr)->l = NULL; \
111 (attr)->r = NULL; (attr)->label = empty; \
112 }
113 #define zzd_attr(a) set_free((a)->label);
114
115 /******************** Variable ******************************/
116 extern char program[]; /* tells what program this is */
117 extern char version[]; /* tells what version this is */
118 extern char *file_str[]; /* file names being used */
119 extern int err_found; /* flag to indicate error occured */
120 extern int action_no; /* last action function printed */
121 extern int func_action; /* should actions be turned into functions?*/
122 extern set used_chars; /* used to label trans. arcs */
123 extern set used_classes; /* classes or chars used to label trans. arcs */
124 extern int class_no; /* number of classes used */
125 extern set class_sets[]; /* shows char. in each class */
126 extern set normal_chars; /* mask off unused portion of set */
127 extern int comp_level; /* what compression level to use */
128 extern int interactive; /* interactive scanner (avoid lookahead)*/
129 extern int mode_counter; /* keeps track of the number of %%name */
130 extern int dfa_basep[]; /* start of each group of dfa */
131 extern int dfa_class_nop[];/* number of transistion arcs in */
132 /* each dfa in each mode */
133 extern int nfa_allocated;
134 extern int dfa_allocated;
135 extern nfa_node **nfa_array; /* start of nfa "array" */
136 extern dfa_node **dfa_array; /* start of dfa "array" */
137 extern int operation_no; /* unique number for each operation */
138 extern FILE *input_stream; /* where description read from */
139 extern FILE *output_stream; /* where to put the output */
140 extern FILE *mode_stream; /* where to put the mode output */
141 extern FILE *class_stream;
142 extern char *mode_file; /* name of file for mode output */
143 extern int gen_ansi; /* produce ansi compatible code */
144 extern int case_insensitive;/* ignore case of input spec. */
145 extern int warn_ambig; /* show if regular expressions ambiguous */
146 extern int gen_cpp;
147 extern char *cl_file_str;
148 extern int firstLexMember; /* MR1 */
149 extern char *OutputDirectory;
150 extern char *class_name;
151
152 /******************** Functions ******************************/
153 #ifdef __USE_PROTOS
154 extern char *dlg_malloc(int, char *, int); /* wrapper malloc */
155 extern char *dlg_calloc(int, int, char *, int); /* wrapper calloc */
156 extern int reach(unsigned *, register int, unsigned *);
157 extern set closure(set *, unsigned *);
158 extern dfa_node *new_dfa_node(set);
159 extern nfa_node *new_nfa_node(void);
160 extern dfa_node *dfastate(set);
161 extern dfa_node **nfa_to_dfa(nfa_node *);
162 extern void internal_error(char *, char *, int); /* MR9 23-Sep-97 */
163 extern FILE *read_stream(char *); /* opens file for reading */
164 extern FILE *write_stream(char *); /* opens file for writing */
165 extern void make_nfa_model_node(void);
166 extern void make_dfa_model_node(int);
167 extern char *ClassName(char *);
168 extern char *OutMetaName(char *);
169 extern void error(char*, int);
170 extern void warning(char*, int);
171 extern void p_head(void);
172 extern void p_class_hdr(void);
173 extern void p_includes(void);
174 extern void p_tables(void);
175 extern void p_tail(void); /* MR1 */
176 extern void p_class_def1(void); /* MR1 */
177 extern void new_automaton_mode(void); /* MR1 */
178 extern int relabel(nfa_node *,int); /* MR1 */
179 extern void p_shift_table(int); /* MR1 */
180 extern void p_bshift_table(void); /* MR1 */
181 extern void p_class_table(void); /* MR1 */
182 extern void p_mode_def(char *,int); /* MR1 */
183 extern void init(void); /* MR1 */
184 extern void p_class_def2(void); /* MR1 */
185 extern void clear_hash(void); /* MR1 */
186 extern void p_alternative_table(void); /* MR1 */
187 extern void p_node_table(void); /* MR1 */
188 extern void p_dfa_table(void); /* MR1 */
189 extern void p_accept_table(void); /* MR1 */
190 extern void p_action_table(void); /* MR1 */
191 extern void p_base_table(void); /* MR1 */
192 extern void p_single_node(int,int); /* MR1 */
193 extern char * minsize(int); /* MR1 */
194 extern void close1(nfa_node *,int,set *); /* MR1 */
195 extern void partition(nfa_node *,int); /* MR1 */
196 extern void intersect_nfa_labels(nfa_node *,set *); /* MR1 */
197 extern void r_intersect(nfa_node *,set *); /* MR1 */
198 extern void label_node(nfa_node *); /* MR1 */
199 extern void label_with_classes(nfa_node *); /* MR1 */
200
201 #else
202 extern char *dlg_malloc(); /* wrapper malloc */
203 extern char *dlg_calloc(); /* wrapper calloc */
204 extern int reach();
205 extern set closure();
206 extern dfa_node *new_dfa_node();
207 extern nfa_node *new_nfa_node();
208 extern dfa_node *dfastate();
209 extern dfa_node **nfa_to_dfa();
210 extern void internal_error(); /* MR9 23-Sep-97 */
211 extern FILE *read_stream(); /* opens file for reading */
212 extern FILE *write_stream(); /* opens file for writing */
213 extern void make_nfa_model_node();
214 extern void make_dfa_model_node();
215 extern char *ClassName();
216 extern char *OutMetaName();
217 extern void error();
218 extern void warning();
219 extern void p_head(); /* MR9 */
220 extern void p_class_hdr(); /* MR9 */
221 extern void p_includes(); /* MR9 */
222 extern void p_tables(); /* MR9 */
223 extern void p_tail(); /* MR1 */
224 extern void p_class_def1(); /* MR1 */
225 extern void new_automaton_mode(); /* MR1 */
226 extern int relabel(); /* MR1 */
227 extern void p_shift_table(); /* MR1 */
228 extern void p_bshift_table(); /* MR1 */
229 extern void p_class_table(); /* MR1 */
230 extern void p_mode_def(); /* MR1 */
231 extern void init(); /* MR1 */
232 extern void p_class_def2(); /* MR1 */
233 extern void clear_hash(); /* MR1 */
234 extern void p_alternative_table(); /* MR1 */
235 extern void p_node_table(); /* MR1 */
236 extern void p_dfa_table(); /* MR1 */
237 extern void p_accept_table(); /* MR1 */
238 extern void p_action_table(); /* MR1 */
239 extern void p_base_table(); /* MR1 */
240 extern void p_single_node(); /* MR1 */
241 extern char * minsize(); /* MR1 */
242 extern void close1(); /* MR1 */
243 extern void partition(); /* MR1 */
244 extern void intersect_nfa_labels(); /* MR1 */
245 extern void r_intersect(); /* MR1 */
246 extern void label_node(); /* MR1 */
247 extern void label_with_classes(); /* MR1 */
248
249 #endif
+0
-275
contrib/pccts/dlg/dlg.r less more
0 /*
1 File: dlgMPW.r
2 Target: dlg 133MR
3 Created: Monday, June 15, 1998 4:44:11 AM
4 Author: Kenji Tanaka (kentar@osa.att.ne.jp)
5 */
6
7 #include "cmdo.r"
8
9 resource 'cmdo' (128, "Dlg") {
10 { /* array dialogs: 1 elements */
11 /* [1] */
12 295,
13 "DLG -- Purdue Compiler Construction Tool"
14 " Set (PCCTS) lexical analyzer generator.",
15 { /* array itemArray: 18 elements */
16 /* [1] */
17 NotDependent {
18
19 },
20 CheckOption {
21 NotSet,
22 {35, 175, 50, 225},
23 "On",
24 "-CC",
25 "When this control is checked, DLG genera"
26 "tes a scanner using C++ classes rather t"
27 "han C functions."
28 },
29 /* [2] */
30 Or {
31 { /* array OrArray: 1 elements */
32 /* [1] */
33 1
34 }
35 },
36 RegularEntry {
37 "Lexer Class Name:",
38 {35, 225, 50, 355},
39 {35, 355, 51, 450},
40 "DLGLexer",
41 keepCase,
42 "-cl",
43 "This entry specifies the name DLG uses f"
44 "or the C++ lexer class."
45 },
46 /* [3] */
47 NotDependent {
48
49 },
50 TextBox {
51 gray,
52 {25, 165, 60, 460},
53 "C++ Code Generation"
54 },
55 /* [4] */
56 NotDependent {
57
58 },
59 Files {
60 InputFile,
61 RequiredFile {
62 {37, 25, 56, 135},
63 "Input File",
64 "",
65 "Choose the lexical description file for "
66 "DLG to process."
67 },
68 Additional {
69 "",
70 "",
71 "",
72 "",
73 { /* array TypesArray: 1 elements */
74 /* [1] */
75 text
76 }
77 }
78 },
79 /* [5] */
80 Or {
81 { /* array OrArray: 1 elements */
82 /* [1] */
83 -1
84 }
85 },
86 Files {
87 OutputFile,
88 RequiredFile {
89 {66, 25, 85, 135},
90 "Output File",
91 "",
92 "Choose the name of the file that will ho"
93 "ld the DLG-produced scanner."
94 },
95 NoMore {
96
97 }
98 },
99 /* [6] */
100 Or {
101 { /* array OrArray: 2 elements */
102 /* [1] */
103 1,
104 /* [2] */
105 5
106 }
107 },
108 Dummy {
109
110 },
111 /* [7] */
112 NotDependent {
113
114 },
115 Redirection {
116 DiagnosticOutput,
117 {90, 25}
118 },
119 /* [8] */
120 NotDependent {
121
122 },
123 TextBox {
124 gray,
125 {25, 20, 132, 145},
126 "Files"
127 },
128 /* [9] */
129 NotDependent {
130
131 },
132 Files {
133 DirOnly,
134 OptionalFile {
135 {68, 175, 84, 305},
136 {88, 175, 107, 305},
137 "Output Directory",
138 ":",
139 "-o",
140 "",
141 "Choose the directory where DLG will put "
142 "its output.",
143 dim,
144 "Output DirectoryI",
145 "",
146 ""
147 },
148 NoMore {
149
150 }
151 },
152 /* [10] */
153 NotDependent {
154
155 },
156 RegularEntry {
157 "Mode File Name:",
158 {68, 315, 83, 450},
159 {88, 315, 104, 450},
160 "mode.h",
161 keepCase,
162 "-m",
163 "This entry specifies the name DLG uses f"
164 "or its lexical mode output file."
165 },
166 /* [11] */
167 NotDependent {
168
169 },
170 RadioButtons {
171 { /* array radioArray: 3 elements */
172 /* [1] */
173 {134, 175, 149, 255}, "None", "", Set, "When this option is selected, DLG will n"
174 "ot compress its tables.",
175 /* [2] */
176 {134, 265, 149, 345}, "Level 1", "-C1", NotSet, "When this option is selected, DLG will r"
177 "emove all unused characters from the tra"
178 "nsition-from table.",
179 /* [3] */
180 {134, 360, 149, 450}, "Level 2", "-C2", NotSet, "When this option is selected, DLG will p"
181 "erform level 1 compression plus it will "
182 "map equivalent characters into the same "
183 "character classes."
184 }
185 },
186 /* [12] */
187 NotDependent {
188
189 },
190 TextBox {
191 gray,
192 {124, 165, 156, 460},
193 "Table Compression"
194 },
195 /* [13] */
196 NotDependent {
197
198 },
199 CheckOption {
200 Set,
201 {165, 20, 180, 145},
202 "Case Sensitive",
203 "-ci",
204 "When this control is checked, the DLG au"
205 "tomaton will treat upper and lower case "
206 "characters identically."
207 },
208 /* [14] */
209 NotDependent {
210
211 },
212 CheckOption {
213 NotSet,
214 {165, 150, 180, 300},
215 "Interactive Scanner",
216 "-i",
217 "When this control is checked, DLG will g"
218 "enerate as interactive a scanner as poss"
219 "ible."
220 },
221 /* [15] */
222 NotDependent {
223
224 },
225 CheckOption {
226 NotSet,
227 {165, 310, 180, 460},
228 "Ambiguity Warnings",
229 "-Wambiguity",
230 "When this control is checked, DLG warns "
231 "if more than one regular expression coul"
232 "d match the same character sequence."
233 },
234 /* [16] */
235 NotDependent {
236
237 },
238 VersionDialog {
239 VersionString {
240 "1.33MR"
241 },
242 "PCCTS was written by Terence Parr, Russe"
243 "ll Quong, Will Cohen, and Hank Dietz: 19"
244 "89-1998. MPW port by Scott Haney.",
245 noDialog
246 },
247 /* [17] */
248 And {
249 { /* array AndArray: 2 elements */
250 /* [1] */
251 4,
252 /* [2] */
253 6
254 }
255 },
256 DoItButton {
257
258 },
259 /* [18] */
260 NotDependent {
261
262 },
263 CheckOption {
264 NotSet,
265 {142, 20, 157, 148},
266 "Generate ANSI C",
267 "-ga",
268 "When this control is checked, DLG genera"
269 "tes ANSI C compatible code."
270 }
271 }
272 }
273 };
274
+0
-132
contrib/pccts/dlg/dlg1.txt less more
0
1
2
3 dlg(1) PCCTS Manual Pages dlg(1)
4
5
6
7 NAME
8 dlg - DFA Lexical Analyzer Generator
9
10 SYNTAX
11 dlg [_o_p_t_i_o_n_s] _l_e_x_i_c_a_l__s_p_e_c [_o_u_t_p_u_t__f_i_l_e]
12
13 DESCRIPTION
14 dlg is a tool that produces fast deterministic finite auto-
15 mata for recognizing regular expressions in input.
16
17 OPTIONS
18 -CC Generate C++ output. The _o_u_t_p_u_t__f_i_l_e is not specified
19 in this case.
20
21 -C[ level]
22 Where level is the compression level used. 0 indica-
23 tions no compression, 1 removes all unused characters
24 from the transition from table, and 2 maps equivalent
25 characters into the same character classes. It is sug-
26 gested that level -C2 is used, since it will signifi-
27 cantly reduce the size of the dfa produced for lexical
28 analyzer.
29
30 -m Produces the header file for the lexical mode with a
31 name other than the default name of "mode.h".
32
33 -i An interactive, or as interactive as possible, parser
34 is produced. A character is only obtained when
35 required to decide which state to go to. Some care
36 must be taken to obtain accept states that do not
37 require look ahead at the next character to determine
38 if that is the stop state. Any regular expression with
39 a Kleene closure at the end is guaranteed to require
40 another character of look ahead.
41
42 -cl class
43 Specify a class name for DLG to generate. The default
44 is DLGLexer.
45
46 -ci The automaton will treat upper and lower case charac-
47 ters identically. This is accomplished in the automa-
48 ton; the characters in the lexical buffer are unmodi-
49 fied.
50
51 -cs Upper and lower case characters are treated as dis-
52 tinct. This is the default.
53
54 -o dir
55 Directory where output files should go (default=".").
56 This is very nice for keeping the source directory
57 clear of ANTLR and DLG spawn.
58
59 -Wambiguity
60 Warns if more than one regular expression could match
61 the same character sequence. The warnings give the
62 numbers of the expressions in the dlg lexical specifi-
63 cation file. The numbering of the expressions starts
64 at one. Multiple warnings may be print for the same
65 expressions.
66
67 - Used in place of file names to get input from standard
68 in or send output to standard out.
69
70 SPECIAL CONSIDERATIONS
71 _D_l_g works... we think. There is no implicit guarantee of
72 anything. We reserve no legal rights to the software known
73 as the Purdue Compiler Construction Tool Set (PCCTS) - PCCTS
74 is in the public domain. An individual or company may do
75 whatever they wish with source code distributed with PCCTS
76 or the code generated by PCCTS, including the incorporation
77 of PCCTS, or its output, into commercial software. We
78 encourage users to develop software with PCCTS. However, we
79 do ask that credit is given to us for developing PCCTS. By
80 "credit", we mean that if you incorporate our source code
81 into one of your programs (commercial product, research pro-
82 ject, or otherwise) that you acknowledge this fact somewhere
83 in the documentation, research report, etc... If you like
84 PCCTS and have developed a nice tool with the output, please
85 mention that you developed it using PCCTS. As long as these
86 guidelines are followed, we expect to continue enhancing
87 this system and expect to make other tools available as they
88 are completed.
89
90 FILES
91 mode.h , dlgauto.h , dlgdef.h
92
93 SEE ALSO
94 antlr(1), pccts(1)
95
96 BUGS
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
+0
-90
contrib/pccts/dlg/dlg68K.make less more
0 # File: dlg68K.make
1 # Target: dlg68K
2 # Sources: automata.c
3 # dlg_a.c
4 # dlg_p.c
5 # err.c
6 # main.c
7 # output.c
8 # relabel.c
9 # support.c
10 # ::support:set:set.c
11 # Created: Sunday, May 17, 1998 10:58:10 PM
12 # Author: Kenji Tanaka
13
14
15 MAKEFILE = dlg68K.make
16 ¥MondoBuild¥ = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified
17 Includes = ¶
18 -i "::h:" ¶
19 -i "::support:set:"
20 Sym¥68K =
21 ObjDir¥68K = ":Obj:"
22
23 COptions = {Includes} {Sym¥68K} -model far -mc68020 -w off -d MPW -d __STDC__=1 -d USER_ZZSYN
24
25 Objects¥68K = ¶
26 "{ObjDir¥68K}automata.c.o" ¶
27 "{ObjDir¥68K}dlg_a.c.o" ¶
28 "{ObjDir¥68K}dlg_p.c.o" ¶
29 "{ObjDir¥68K}err.c.o" ¶
30 "{ObjDir¥68K}main.c.o" ¶
31 "{ObjDir¥68K}output.c.o" ¶
32 "{ObjDir¥68K}relabel.c.o" ¶
33 "{ObjDir¥68K}support.c.o" ¶
34 "{ObjDir¥68K}set.c.o"
35
36
37 dlg68K ÄÄ {¥MondoBuild¥} {Objects¥68K}
38 Link ¶
39 -o {Targ} -d {Sym¥68K} ¶
40 {Objects¥68K} ¶
41 -t 'MPST' ¶
42 -c 'MPS ' ¶
43 -model far ¶
44 -mf ¶
45 -br ON ¶
46 -srtsg ALL ¶
47 "{Libraries}Stubs.o" ¶
48 "{Libraries}MathLib.o" ¶
49 #"{CLibraries}Complex.o" ¶
50 "{CLibraries}StdCLib.o" ¶
51 "{Libraries}MacRuntime.o" ¶
52 "{Libraries}IntEnv.o" ¶
53 "{Libraries}ToolLibs.o" ¶
54 "{Libraries}Interface.o"
55
56
57 "{ObjDir¥68K}automata.c.o" Ä {¥MondoBuild¥} automata.c
58 {C} automata.c -o {Targ} {COptions}
59
60 "{ObjDir¥68K}dlg_a.c.o" Ä {¥MondoBuild¥} dlg_a.c
61 {C} dlg_a.c -o {Targ} {COptions}
62
63 "{ObjDir¥68K}dlg_p.c.o" Ä {¥MondoBuild¥} dlg_p.c
64 {C} dlg_p.c -o {Targ} {COptions}
65
66 "{ObjDir¥68K}err.c.o" Ä {¥MondoBuild¥} err.c
67 {C} err.c -o {Targ} {COptions}
68
69 "{ObjDir¥68K}main.c.o" Ä {¥MondoBuild¥} main.c
70 {C} main.c -o {Targ} {COptions}
71
72 "{ObjDir¥68K}output.c.o" Ä {¥MondoBuild¥} output.c
73 {C} output.c -o {Targ} {COptions}
74
75 "{ObjDir¥68K}relabel.c.o" Ä {¥MondoBuild¥} relabel.c
76 {C} relabel.c -o {Targ} {COptions}
77
78 "{ObjDir¥68K}support.c.o" Ä {¥MondoBuild¥} support.c
79 {C} support.c -o {Targ} {COptions}
80
81 "{ObjDir¥68K}set.c.o" Ä {¥MondoBuild¥} "::support:set:set.c"
82 {C} "::support:set:set.c" -o {Targ} {COptions}
83
84
85 dlg68K ÄÄ dlg.r
86 Rez dlg.r -o dlg68K -a
87
88 Install Ä dlg68K
89 Duplicate -y dlg68K "{MPW}"Tools:dlg
+0
-84
contrib/pccts/dlg/dlgPPC.make less more
0 # File: dlgPPC.make
1 # Target: dlgPPC
2 # Sources: automata.c
3 # dlg_a.c
4 # dlg_p.c
5 # err.c
6 # main.c
7 # output.c
8 # relabel.c
9 # support.c
10 # ::support:set:set.c
11 # Created: Sunday, May 17, 1998 11:34:20 PM
12 # Author: Kenji Tanaka
13
14
15 MAKEFILE = dlgPPC.make
16 ¥MondoBuild¥ = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified
17 Includes = ¶
18 -i "::h:" ¶
19 -i "::support:set:"
20 Sym¥PPC =
21 ObjDir¥PPC = ":Obj:"
22
23 PPCCOptions = {Includes} {Sym¥PPC} -w off -d MPW -d __STDC__=1 -d USER_ZZSYN
24
25 Objects¥PPC = ¶
26 "{ObjDir¥PPC}automata.c.x" ¶
27 "{ObjDir¥PPC}dlg_a.c.x" ¶
28 "{ObjDir¥PPC}dlg_p.c.x" ¶
29 "{ObjDir¥PPC}err.c.x" ¶
30 "{ObjDir¥PPC}main.c.x" ¶
31 "{ObjDir¥PPC}output.c.x" ¶
32 "{ObjDir¥PPC}relabel.c.x" ¶
33 "{ObjDir¥PPC}support.c.x" ¶
34 "{ObjDir¥PPC}set.c.x"
35
36
37 dlgPPC ÄÄ {¥MondoBuild¥} {Objects¥PPC}
38 PPCLink ¶
39 -o {Targ} {Sym¥PPC} ¶
40 {Objects¥PPC} ¶
41 -t 'MPST' ¶
42 -c 'MPS ' ¶
43 "{SharedLibraries}InterfaceLib" ¶
44 "{SharedLibraries}StdCLib" ¶
45 "{SharedLibraries}MathLib" ¶
46 "{PPCLibraries}StdCRuntime.o" ¶
47 "{PPCLibraries}PPCCRuntime.o" ¶
48 "{PPCLibraries}PPCToolLibs.o"
49
50
51 "{ObjDir¥PPC}automata.c.x" Ä {¥MondoBuild¥} automata.c
52 {PPCC} automata.c -o {Targ} {PPCCOptions}
53
54 "{ObjDir¥PPC}dlg_a.c.x" Ä {¥MondoBuild¥} dlg_a.c
55 {PPCC} dlg_a.c -o {Targ} {PPCCOptions}
56
57 "{ObjDir¥PPC}dlg_p.c.x" Ä {¥MondoBuild¥} dlg_p.c
58 {PPCC} dlg_p.c -o {Targ} {PPCCOptions}
59
60 "{ObjDir¥PPC}err.c.x" Ä {¥MondoBuild¥} err.c
61 {PPCC} err.c -o {Targ} {PPCCOptions}
62
63 "{ObjDir¥PPC}main.c.x" Ä {¥MondoBuild¥} main.c
64 {PPCC} main.c -o {Targ} {PPCCOptions}
65
66 "{ObjDir¥PPC}output.c.x" Ä {¥MondoBuild¥} output.c
67 {PPCC} output.c -o {Targ} {PPCCOptions}
68
69 "{ObjDir¥PPC}relabel.c.x" Ä {¥MondoBuild¥} relabel.c
70 {PPCC} relabel.c -o {Targ} {PPCCOptions}
71
72 "{ObjDir¥PPC}support.c.x" Ä {¥MondoBuild¥} support.c
73 {PPCC} support.c -o {Targ} {PPCCOptions}
74
75 "{ObjDir¥PPC}set.c.x" Ä {¥MondoBuild¥} "::support:set:set.c"
76 {PPCC} "::support:set:set.c" -o {Targ} {PPCCOptions}
77
78
79 dlgPPC ÄÄ dlg.r
80 Rez dlg.r -o dlgPPC -a
81
82 Install Ä dlgPPC
83 Duplicate -y dlgPPC "{MPW}"Tools:dlg
+0
-1414
contrib/pccts/dlg/dlg_a.c less more
0
1 /* parser.dlg -- DLG Description of scanner
2 *
3 * Generated from: ./dlg_p.g
4 *
5 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
6 * Purdue University Electrical Engineering
7 * With AHPCRC, University of Minnesota
8 * ANTLR Version 1.33MR33
9 */
10
11 #define ANTLR_VERSION 13333
12 #include "pcctscfg.h"
13 #include "pccts_stdio.h"
14
15 #include <ctype.h>
16 #include "dlg.h"
17 #include "antlr.h"
18 #include "tokens.h"
19 #include "dlgdef.h"
20 LOOKAHEAD
21
22 void
23 #ifdef __USE_PROTOS
24 zzerraction(void)
25 #else
26 zzerraction()
27 #endif
28 {
29 (*zzerr)("invalid token");
30 zzadvance();
31 zzskip();
32 }
33 /*
34 * D L G tables
35 *
36 * Generated from: ./parser.dlg
37 *
38 * 1989-2001 by Will Cohen, Terence Parr, and Hank Dietz
39 * Purdue University Electrical Engineering
40 * DLG Version 1.33MR33
41 */
42
43 #include "mode.h"
44
45
46
47
48 int func_action; /* should actions be turned into functions?*/
49 int lex_mode_counter = 0; /* keeps track of the number of %%names */
50 /* MR1 */
51 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
52 /* MR1 via <<%%lexmember...>> */
53 /* MR1 */
54 int lexMember = 0; /* <<%%lexmemeber ...>> MR1 */
55 int lexAction = 0; /* <<%%lexaction ...>> MR1 */
56 int parserClass = 0; /* <<%%parserclass ...>> MR1 */
57 int lexPrefix = 0; /* <<%%lexprefix ...>> MR1 */
58 char theClassName[100]; /* MR11 */
59 char *pClassName=theClassName; /* MR11 */
60 int firstLexMember=1; /* MR1 */
61
62 #ifdef __USE_PROTOS
63 void xxputc(int c) { /* MR1 */
64 #else
65 void xxputc(c) /* MR1 */
66 int c; /* MR1 */
67 { /* MR1 */
68 #endif
69 if (parserClass) { /* MR1 */
70 *pClassName++=c; /* MR1 */
71 *pClassName=0; /* MR1 */
72 } else if (lexMember || lexPrefix) { /* MR1 */
73 if (class_stream != NULL) fputc(c,class_stream); /* MR1 */
74 } else { /* MR1 */
75 fputc(c,OUT); /* MR1 */
76 }; /* MR1 */
77 } /* MR1 */
78
79 #ifdef __USE_PROTOS
80 void xxprintf(char *format,char *string) { /* MR1 */
81 #else
82 void xxprintf(format,string) /* MR1 */
83 char *format; /* MR1 */
84 char *string; /* MR1 */
85 { /* MR1 */
86 #endif
87 if (lexMember || lexPrefix || parserClass) { /* MR1 */
88 if (class_stream != NULL) /* MR1 */
89 fprintf(class_stream,format,string); /* MR1 */
90 } else { /* MR1 */
91 fprintf(OUT,format,string); /* MR1 */
92 }; /* MR1 */
93 } /* MR1 */
94
95 static void act1()
96 {
97 NLA = 1;
98 }
99
100
101 static void act2()
102 {
103 NLA = 2;
104 zzskip();
105 }
106
107
108 static void act3()
109 {
110 NLA = 3;
111 zzline++; zzskip(); DAWDLE;
112 }
113
114
115 static void act4()
116 {
117 NLA = L_EOF;
118 }
119
120
121 static void act5()
122 {
123 NLA = PER_PER;
124 }
125
126
127 static void act6()
128 {
129 NLA = NAME_PER_PER;
130 p_mode_def(&zzlextext[2],lex_mode_counter++);
131 }
132
133
134 static void act7()
135 {
136 NLA = LEXMEMBER;
137 lexMember=1; /* MR1 */
138 if (firstLexMember != 0) { /* MR1 */
139 firstLexMember=0; /* MR1 */
140 p_class_def1(); /* MR1 */
141 }; /* MR1 */
142 zzmode(ACT); /* MR1 */
143 }
144
145
146 static void act8()
147 {
148 NLA = LEXACTION;
149 lexAction=1;zzmode(ACT);
150 }
151
152
153 static void act9()
154 {
155 NLA = PARSERCLASS;
156 parserClass=1; /* MR1 */
157 zzmode(ACT); /* MR1 */
158 }
159
160
161 static void act10()
162 {
163 NLA = LEXPREFIX;
164 lexPrefix=1;zzmode(ACT);
165 }
166
167
168 static void act11()
169 {
170 NLA = ACTION;
171 if (func_action)
172 fprintf(OUT,"\n%s %sact%d()\n{ ",
173 gen_cpp?"ANTLRTokenType":"static void",
174 gen_cpp?ClassName("::"):"", ++action_no);
175 zzmode(ACT); zzskip();
176 }
177
178
179 static void act12()
180 {
181 NLA = GREAT_GREAT;
182 }
183
184
185 static void act13()
186 {
187 NLA = L_BRACE;
188 }
189
190
191 static void act14()
192 {
193 NLA = R_BRACE;
194 }
195
196
197 static void act15()
198 {
199 NLA = L_PAR;
200 }
201
202
203 static void act16()
204 {
205 NLA = R_PAR;
206 }
207
208
209 static void act17()
210 {
211 NLA = L_BRACK;
212 }
213
214
215 static void act18()
216 {
217 NLA = R_BRACK;
218 }
219
220
221 static void act19()
222 {
223 NLA = ZERO_MORE;
224 }
225
226
227 static void act20()
228 {
229 NLA = ONE_MORE;
230 }
231
232
233 static void act21()
234 {
235 NLA = OR;
236 }
237
238
239 static void act22()
240 {
241 NLA = RANGE;
242 }
243
244
245 static void act23()
246 {
247 NLA = NOT;
248 }
249
250
251 static void act24()
252 {
253 NLA = OCTAL_VALUE;
254 {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}
255 }
256
257
258 static void act25()
259 {
260 NLA = HEX_VALUE;
261 {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}
262 }
263
264
265 static void act26()
266 {
267 NLA = DEC_VALUE;
268 {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}
269 }
270
271
272 static void act27()
273 {
274 NLA = TAB;
275 zzlextext[0] = '\t';
276 }
277
278
279 static void act28()
280 {
281 NLA = NL;
282 zzlextext[0] = '\n';
283 }
284
285
286 static void act29()
287 {
288 NLA = CR;
289 zzlextext[0] = '\r';
290 }
291
292
293 static void act30()
294 {
295 NLA = BS;
296 zzlextext[0] = '\b';
297 }
298
299
300 static void act31()
301 {
302 NLA = CONTINUATION;
303 zzline++; zzskip();
304 }
305
306
307 static void act32()
308 {
309 NLA = LIT;
310 zzlextext[0] = zzlextext[1];
311 }
312
313
314 static void act33()
315 {
316 NLA = REGCHAR;
317 }
318
319 static unsigned char shift0[257] = {
320 0, 40, 40, 40, 40, 40, 40, 40, 40, 40,
321 1, 2, 40, 40, 1, 40, 40, 40, 40, 40,
322 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
323 40, 40, 40, 1, 40, 40, 40, 40, 4, 40,
324 40, 30, 31, 34, 35, 40, 37, 40, 40, 23,
325 24, 24, 24, 24, 24, 24, 24, 25, 25, 40,
326 40, 26, 40, 27, 40, 3, 21, 21, 21, 21,
327 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
328 22, 22, 22, 22, 22, 22, 22, 22, 22, 20,
329 22, 22, 32, 39, 33, 40, 22, 40, 11, 9,
330 12, 21, 6, 19, 22, 22, 14, 22, 22, 5,
331 8, 16, 15, 17, 22, 10, 18, 13, 22, 22,
332 22, 7, 22, 22, 28, 36, 29, 38, 40, 40,
333 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
334 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
335 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
336 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
337 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
338 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
339 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
340 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
341 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
342 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
343 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
344 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
345 40, 40, 40, 40, 40, 40, 40
346 };
347
348
349 static void act34()
350 {
351 NLA = 1;
352 error("unterminated action", zzline); zzmode(START);
353 }
354
355
356 static void act35()
357 {
358 NLA = ACTION;
359 if (func_action) fprintf(OUT,"}\n\n");
360 zzmode(START);
361 /* MR1 */
362 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
363 /* MR1 via <<%%lexmember ...>> */
364 /* MR1 This is a consequence of not saving actions */
365 /* MR1 */
366 /* MR1 */ parserClass=0;
367 /* MR1 */ lexPrefix=0;
368 /* MR1 */ lexAction=0;
369 /* MR1 */ lexMember=0;
370 }
371
372
373 static void act36()
374 {
375 NLA = 34;
376 xxputc(zzlextext[0]); zzskip();
377 }
378
379
380 static void act37()
381 {
382 NLA = 35;
383 xxputc('>'); zzskip();
384 }
385
386
387 static void act38()
388 {
389 NLA = 36;
390 xxputc('\\'); zzskip();
391 }
392
393
394 static void act39()
395 {
396 NLA = 37;
397 xxputc(zzlextext[0]); ++zzline; zzskip();
398 }
399
400
401 static void act40()
402 {
403 NLA = 38;
404 zzmode(ACTION_COMMENTS); /* MR1 */
405 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
406 }
407
408
409 static void act41()
410 {
411 NLA = 39;
412 zzmode(ACTION_CPP_COMMENTS); /* MR1 */
413 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
414 }
415
416
417 static void act42()
418 {
419 NLA = 40;
420 xxputc(zzlextext[0]); zzskip();
421 }
422
423 static unsigned char shift1[257] = {
424 0, 6, 6, 6, 6, 6, 6, 6, 6, 6,
425 6, 3, 6, 6, 6, 6, 6, 6, 6, 6,
426 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
427 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
428 6, 6, 6, 5, 6, 6, 6, 6, 4, 6,
429 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
430 6, 6, 6, 1, 6, 6, 6, 6, 6, 6,
431 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
432 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
433 6, 6, 6, 2, 6, 6, 6, 6, 6, 6,
434 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
435 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
436 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
437 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
438 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
439 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
440 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
441 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
442 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
443 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
444 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
445 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
446 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
447 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
448 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
449 6, 6, 6, 6, 6, 6, 6
450 };
451
452
453 static void act43()
454 {
455 NLA = 1;
456 }
457
458
459 static void act44()
460 {
461 NLA = 41;
462 zzmode(ACT); /* MR1 */
463 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
464 }
465
466
467 static void act45()
468 {
469 NLA = 42;
470 zzline++; xxputc(zzlextext[0]); zzskip();
471 }
472
473
474 static void act46()
475 {
476 NLA = 43;
477 xxputc(zzlextext[0]); zzskip();
478 }
479
480 static unsigned char shift2[257] = {
481 0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
482 4, 3, 4, 4, 3, 4, 4, 4, 4, 4,
483 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
484 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
485 4, 4, 4, 1, 4, 4, 4, 4, 2, 4,
486 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
487 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
488 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
489 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
490 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
491 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
492 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
493 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
494 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
495 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
496 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
497 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
498 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
499 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
500 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
501 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
502 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
503 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
504 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
505 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
506 4, 4, 4, 4, 4, 4, 4
507 };
508
509
510 static void act47()
511 {
512 NLA = 1;
513 }
514
515
516 static void act48()
517 {
518 NLA = 44;
519 zzmode(ACT); zzline++; /* MR1 */
520 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
521 }
522
523
524 static void act49()
525 {
526 NLA = 45;
527 xxputc(zzlextext[0]); zzskip();
528 }
529
530 static unsigned char shift3[257] = {
531 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 1, 2, 2, 1, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2
557 };
558
559 #define DfaStates 94
560 typedef unsigned char DfaState;
561
562 static DfaState st0[42] = {
563 1, 2, 3, 4, 5, 6, 6, 6, 6, 6,
564 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
565 6, 6, 6, 6, 6, 6, 7, 8, 9, 10,
566 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
567 6, 94
568 };
569
570 static DfaState st1[42] = {
571 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
572 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
573 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
574 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
575 94, 94
576 };
577
578 static DfaState st2[42] = {
579 94, 21, 94, 94, 94, 94, 94, 94, 94, 94,
580 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
581 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
582 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
583 94, 94
584 };
585
586 static DfaState st3[42] = {
587 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
588 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
589 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
590 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
591 94, 94
592 };
593
594 static DfaState st4[42] = {
595 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
596 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
597 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
598 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
599 94, 94
600 };
601
602 static DfaState st5[42] = {
603 94, 94, 94, 94, 22, 94, 94, 94, 94, 94,
604 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
605 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
606 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
607 94, 94
608 };
609
610 static DfaState st6[42] = {
611 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
612 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
613 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
614 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
615 94, 94
616 };
617
618 static DfaState st7[42] = {
619 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
620 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
621 94, 94, 94, 94, 94, 94, 23, 94, 94, 94,
622 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
623 94, 94
624 };
625
626 static DfaState st8[42] = {
627 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
628 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
629 94, 94, 94, 94, 94, 94, 94, 24, 94, 94,
630 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
631 94, 94
632 };
633
634 static DfaState st9[42] = {
635 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
636 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
637 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
638 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
639 94, 94
640 };
641
642 static DfaState st10[42] = {
643 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
644 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
645 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
646 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
647 94, 94
648 };
649
650 static DfaState st11[42] = {
651 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
652 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
653 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
654 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
655 94, 94
656 };
657
658 static DfaState st12[42] = {
659 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
660 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
661 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
662 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
663 94, 94
664 };
665
666 static DfaState st13[42] = {
667 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
668 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
669 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
670 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
671 94, 94
672 };
673
674 static DfaState st14[42] = {
675 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
676 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
677 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
678 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
679 94, 94
680 };
681
682 static DfaState st15[42] = {
683 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
684 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
685 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
686 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
687 94, 94
688 };
689
690 static DfaState st16[42] = {
691 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
692 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
693 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
694 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
695 94, 94
696 };
697
698 static DfaState st17[42] = {
699 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
700 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
701 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
702 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
703 94, 94
704 };
705
706 static DfaState st18[42] = {
707 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
708 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
709 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
710 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
711 94, 94
712 };
713
714 static DfaState st19[42] = {
715 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
716 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
717 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
718 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
719 94, 94
720 };
721
722 static DfaState st20[42] = {
723 94, 25, 26, 25, 25, 25, 25, 25, 25, 27,
724 28, 25, 25, 29, 25, 25, 30, 25, 25, 25,
725 25, 25, 25, 31, 32, 32, 25, 25, 25, 25,
726 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
727 25, 94
728 };
729
730 static DfaState st21[42] = {
731 94, 21, 94, 94, 94, 94, 94, 94, 94, 94,
732 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
733 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
734 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
735 94, 94
736 };
737
738 static DfaState st22[42] = {
739 94, 94, 94, 94, 94, 33, 33, 33, 33, 33,
740 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
741 33, 33, 33, 94, 94, 94, 94, 94, 94, 94,
742 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
743 94, 94
744 };
745
746 static DfaState st23[42] = {
747 94, 94, 94, 94, 34, 94, 94, 94, 94, 94,
748 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
749 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
750 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
751 94, 94
752 };
753
754 static DfaState st24[42] = {
755 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
756 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
757 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
758 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
759 94, 94
760 };
761
762 static DfaState st25[42] = {
763 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
764 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
765 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
766 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
767 94, 94
768 };
769
770 static DfaState st26[42] = {
771 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
772 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
773 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
774 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
775 94, 94
776 };
777
778 static DfaState st27[42] = {
779 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
780 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
781 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
782 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
783 94, 94
784 };
785
786 static DfaState st28[42] = {
787 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
788 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
789 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
790 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
791 94, 94
792 };
793
794 static DfaState st29[42] = {
795 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
796 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
797 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
798 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
799 94, 94
800 };
801
802 static DfaState st30[42] = {
803 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
804 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
805 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
806 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
807 94, 94
808 };
809
810 static DfaState st31[42] = {
811 94, 94, 94, 94, 94, 94, 94, 35, 94, 94,
812 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
813 35, 94, 94, 36, 36, 94, 94, 94, 94, 94,
814 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
815 94, 94
816 };
817
818 static DfaState st32[42] = {
819 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
820 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
821 94, 94, 94, 37, 37, 37, 94, 94, 94, 94,
822 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
823 94, 94
824 };
825
826 static DfaState st33[42] = {
827 94, 94, 94, 94, 94, 38, 38, 38, 38, 38,
828 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
829 38, 38, 38, 38, 38, 38, 94, 94, 94, 94,
830 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
831 94, 94
832 };
833
834 static DfaState st34[42] = {
835 94, 94, 94, 94, 39, 94, 94, 94, 94, 94,
836 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
837 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
838 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
839 94, 94
840 };
841
842 static DfaState st35[42] = {
843 94, 94, 94, 94, 94, 94, 40, 94, 94, 40,
844 94, 40, 40, 94, 94, 94, 94, 94, 94, 40,
845 94, 40, 94, 40, 40, 40, 94, 94, 94, 94,
846 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
847 94, 94
848 };
849
850 static DfaState st36[42] = {
851 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
852 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
853 94, 94, 94, 36, 36, 94, 94, 94, 94, 94,
854 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
855 94, 94
856 };
857
858 static DfaState st37[42] = {
859 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
860 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
861 94, 94, 94, 37, 37, 37, 94, 94, 94, 94,
862 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
863 94, 94
864 };
865
866 static DfaState st38[42] = {
867 94, 94, 94, 94, 94, 38, 38, 38, 38, 38,
868 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
869 38, 38, 38, 38, 38, 38, 94, 94, 94, 94,
870 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
871 94, 94
872 };
873
874 static DfaState st39[42] = {
875 94, 94, 94, 94, 94, 41, 94, 94, 94, 94,
876 94, 94, 94, 94, 94, 94, 94, 42, 94, 94,
877 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
878 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
879 94, 94
880 };
881
882 static DfaState st40[42] = {
883 94, 94, 94, 94, 94, 94, 40, 94, 94, 40,
884 94, 40, 40, 94, 94, 94, 94, 94, 94, 40,
885 94, 40, 94, 40, 40, 40, 94, 94, 94, 94,
886 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
887 94, 94
888 };
889
890 static DfaState st41[42] = {
891 94, 94, 94, 94, 94, 94, 43, 94, 94, 94,
892 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
893 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
894 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
895 94, 94
896 };
897
898 static DfaState st42[42] = {
899 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
900 94, 44, 94, 94, 94, 94, 94, 94, 94, 94,
901 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
902 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
903 94, 94
904 };
905
906 static DfaState st43[42] = {
907 94, 94, 94, 94, 94, 94, 94, 45, 94, 94,
908 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
909 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
910 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
911 94, 94
912 };
913
914 static DfaState st44[42] = {
915 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
916 46, 94, 94, 94, 94, 94, 94, 94, 94, 94,
917 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
918 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
919 94, 94
920 };
921
922 static DfaState st45[42] = {
923 94, 94, 94, 94, 94, 94, 94, 94, 47, 94,
924 94, 48, 94, 94, 94, 94, 94, 49, 94, 94,
925 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
926 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
927 94, 94
928 };
929
930 static DfaState st46[42] = {
931 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
932 94, 94, 94, 94, 94, 94, 94, 94, 50, 94,
933 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
934 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
935 94, 94
936 };
937
938 static DfaState st47[42] = {
939 94, 94, 94, 94, 94, 94, 51, 94, 94, 94,
940 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
941 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
942 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
943 94, 94
944 };
945
946 static DfaState st48[42] = {
947 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
948 94, 94, 52, 94, 94, 94, 94, 94, 94, 94,
949 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
950 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
951 94, 94
952 };
953
954 static DfaState st49[42] = {
955 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
956 53, 94, 94, 94, 94, 94, 94, 94, 94, 94,
957 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
958 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
959 94, 94
960 };
961
962 static DfaState st50[42] = {
963 94, 94, 94, 94, 94, 94, 54, 94, 94, 94,
964 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
965 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
966 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
967 94, 94
968 };
969
970 static DfaState st51[42] = {
971 94, 94, 94, 94, 94, 94, 94, 94, 55, 94,
972 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
973 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
974 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
975 94, 94
976 };
977
978 static DfaState st52[42] = {
979 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
980 94, 94, 94, 56, 94, 94, 94, 94, 94, 94,
981 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
982 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
983 94, 94
984 };
985
986 static DfaState st53[42] = {
987 94, 94, 94, 94, 94, 94, 57, 94, 94, 94,
988 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
989 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
990 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
991 94, 94
992 };
993
994 static DfaState st54[42] = {
995 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
996 58, 94, 94, 94, 94, 94, 94, 94, 94, 94,
997 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
998 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
999 94, 94
1000 };
1001
1002 static DfaState st55[42] = {
1003 94, 94, 94, 94, 94, 94, 94, 94, 94, 59,
1004 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1005 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1006 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1007 94, 94
1008 };
1009
1010 static DfaState st56[42] = {
1011 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1012 94, 94, 94, 94, 60, 94, 94, 94, 94, 94,
1013 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1014 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1015 94, 94
1016 };
1017
1018 static DfaState st57[42] = {
1019 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1020 94, 94, 94, 94, 94, 94, 94, 94, 94, 61,
1021 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1022 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1023 94, 94
1024 };
1025
1026 static DfaState st58[42] = {
1027 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1028 94, 94, 62, 94, 94, 94, 94, 94, 94, 94,
1029 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1030 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1031 94, 94
1032 };
1033
1034 static DfaState st59[42] = {
1035 94, 94, 94, 94, 94, 94, 63, 94, 94, 94,
1036 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1037 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1038 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1039 94, 94
1040 };
1041
1042 static DfaState st60[42] = {
1043 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1044 94, 94, 94, 94, 94, 64, 94, 94, 94, 94,
1045 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1046 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1047 94, 94
1048 };
1049
1050 static DfaState st61[42] = {
1051 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1052 94, 94, 94, 94, 65, 94, 94, 94, 94, 94,
1053 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1054 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1055 94, 94
1056 };
1057
1058 static DfaState st62[42] = {
1059 94, 94, 94, 94, 94, 66, 94, 94, 94, 94,
1060 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1061 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1062 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1063 94, 94
1064 };
1065
1066 static DfaState st63[42] = {
1067 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1068 67, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1069 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1070 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1071 94, 94
1072 };
1073
1074 static DfaState st64[42] = {
1075 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1076 94, 94, 94, 94, 94, 94, 68, 94, 94, 94,
1077 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1078 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1079 94, 94
1080 };
1081
1082 static DfaState st65[42] = {
1083 94, 94, 94, 94, 94, 94, 94, 69, 94, 94,
1084 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1085 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1086 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1087 94, 94
1088 };
1089
1090 static DfaState st66[42] = {
1091 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1092 94, 70, 94, 94, 94, 94, 94, 94, 94, 94,
1093 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1094 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1095 94, 94
1096 };
1097
1098 static DfaState st67[42] = {
1099 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1100 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1101 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1102 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1103 94, 94
1104 };
1105
1106 static DfaState st68[42] = {
1107 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1108 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1109 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1110 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1111 94, 94
1112 };
1113
1114 static DfaState st69[42] = {
1115 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1116 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1117 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1118 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1119 94, 94
1120 };
1121
1122 static DfaState st70[42] = {
1123 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1124 94, 94, 94, 94, 94, 94, 94, 94, 71, 94,
1125 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1126 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1127 94, 94
1128 };
1129
1130 static DfaState st71[42] = {
1131 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1132 94, 94, 94, 94, 94, 94, 94, 94, 72, 94,
1133 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1134 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1135 94, 94
1136 };
1137
1138 static DfaState st72[42] = {
1139 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1140 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1141 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1142 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
1143 94, 94
1144 };
1145
1146 static DfaState st73[8] = {
1147 74, 75, 76, 77, 78, 79, 79, 94
1148 };
1149
1150 static DfaState st74[8] = {
1151 94, 94, 94, 94, 94, 94, 94, 94
1152 };
1153
1154 static DfaState st75[8] = {
1155 94, 80, 94, 94, 94, 94, 94, 94
1156 };
1157
1158 static DfaState st76[8] = {
1159 94, 81, 94, 94, 94, 94, 94, 94
1160 };
1161
1162 static DfaState st77[8] = {
1163 94, 94, 94, 94, 94, 94, 94, 94
1164 };
1165
1166 static DfaState st78[8] = {
1167 94, 94, 94, 94, 82, 83, 94, 94
1168 };
1169
1170 static DfaState st79[8] = {
1171 94, 94, 94, 94, 94, 94, 94, 94
1172 };
1173
1174 static DfaState st80[8] = {
1175 94, 94, 94, 94, 94, 94, 94, 94
1176 };
1177
1178 static DfaState st81[8] = {
1179 94, 94, 94, 94, 94, 94, 94, 94
1180 };
1181
1182 static DfaState st82[8] = {
1183 94, 94, 94, 94, 94, 94, 94, 94
1184 };
1185
1186 static DfaState st83[8] = {
1187 94, 94, 94, 94, 94, 94, 94, 94
1188 };
1189
1190 static DfaState st84[6] = {
1191 85, 86, 87, 88, 87, 94
1192 };
1193
1194 static DfaState st85[6] = {
1195 94, 94, 94, 94, 94, 94
1196 };
1197
1198 static DfaState st86[6] = {
1199 94, 94, 89, 94, 94, 94
1200 };
1201
1202 static DfaState st87[6] = {
1203 94, 94, 94, 94, 94, 94
1204 };
1205
1206 static DfaState st88[6] = {
1207 94, 94, 94, 94, 94, 94
1208 };
1209
1210 static DfaState st89[6] = {
1211 94, 94, 94, 94, 94, 94
1212 };
1213
1214 static DfaState st90[4] = {
1215 91, 92, 93, 94
1216 };
1217
1218 static DfaState st91[4] = {
1219 94, 94, 94, 94
1220 };
1221
1222 static DfaState st92[4] = {
1223 94, 94, 94, 94
1224 };
1225
1226 static DfaState st93[4] = {
1227 94, 94, 94, 94
1228 };
1229
1230
1231 DfaState *dfa[94] = {
1232 st0,
1233 st1,
1234 st2,
1235 st3,
1236 st4,
1237 st5,
1238 st6,
1239 st7,
1240 st8,
1241 st9,
1242 st10,
1243 st11,
1244 st12,
1245 st13,
1246 st14,
1247 st15,
1248 st16,
1249 st17,
1250 st18,
1251 st19,
1252 st20,
1253 st21,
1254 st22,
1255 st23,
1256 st24,
1257 st25,
1258 st26,
1259 st27,
1260 st28,
1261 st29,
1262 st30,
1263 st31,
1264 st32,
1265 st33,
1266 st34,
1267 st35,
1268 st36,
1269 st37,
1270 st38,
1271 st39,
1272 st40,
1273 st41,
1274 st42,
1275 st43,
1276 st44,
1277 st45,
1278 st46,
1279 st47,
1280 st48,
1281 st49,
1282 st50,
1283 st51,
1284 st52,
1285 st53,
1286 st54,
1287 st55,
1288 st56,
1289 st57,
1290 st58,
1291 st59,
1292 st60,
1293 st61,
1294 st62,
1295 st63,
1296 st64,
1297 st65,
1298 st66,
1299 st67,
1300 st68,
1301 st69,
1302 st70,
1303 st71,
1304 st72,
1305 st73,
1306 st74,
1307 st75,
1308 st76,
1309 st77,
1310 st78,
1311 st79,
1312 st80,
1313 st81,
1314 st82,
1315 st83,
1316 st84,
1317 st85,
1318 st86,
1319 st87,
1320 st88,
1321 st89,
1322 st90,
1323 st91,
1324 st92,
1325 st93
1326 };
1327
1328
1329 DfaState accepts[95] = {
1330 0, 1, 2, 3, 4, 33, 33, 33, 33, 13,
1331 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
1332 0, 2, 5, 11, 12, 32, 31, 30, 29, 27,
1333 28, 24, 26, 6, 0, 0, 24, 26, 6, 0,
1334 25, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1335 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1336 0, 0, 0, 0, 0, 0, 0, 7, 8, 10,
1337 0, 0, 9, 0, 34, 36, 38, 39, 42, 42,
1338 35, 37, 41, 40, 0, 43, 46, 46, 45, 44,
1339 0, 47, 48, 49, 0
1340 };
1341
1342 void (*actions[50])() = {
1343 zzerraction,
1344 act1,
1345 act2,
1346 act3,
1347 act4,
1348 act5,
1349 act6,
1350 act7,
1351 act8,
1352 act9,
1353 act10,
1354 act11,
1355 act12,
1356 act13,
1357 act14,
1358 act15,
1359 act16,
1360 act17,
1361 act18,
1362 act19,
1363 act20,
1364 act21,
1365 act22,
1366 act23,
1367 act24,
1368 act25,
1369 act26,
1370 act27,
1371 act28,
1372 act29,
1373 act30,
1374 act31,
1375 act32,
1376 act33,
1377 act34,
1378 act35,
1379 act36,
1380 act37,
1381 act38,
1382 act39,
1383 act40,
1384 act41,
1385 act42,
1386 act43,
1387 act44,
1388 act45,
1389 act46,
1390 act47,
1391 act48,
1392 act49
1393 };
1394
1395 static DfaState dfa_base[] = {
1396 0,
1397 73,
1398 84,
1399 90
1400 };
1401
1402 static unsigned char *b_class_no[] = {
1403 shift0,
1404 shift1,
1405 shift2,
1406 shift3
1407 };
1408
1409
1410
1411 #define ZZSHIFT(c) (b_class_no[zzauto][1+c])
1412 #define MAX_MODE 4
1413 #include "dlgauto.h"
+0
-959
contrib/pccts/dlg/dlg_p.c less more
0 /*
1 * A n t l r T r a n s l a t i o n H e a d e r
2 *
3 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
4 * Purdue University Electrical Engineering
5 * With AHPCRC, University of Minnesota
6 * ANTLR Version 1.33MR33
7 *
8 * ../antlr/antlr ./dlg_p.g
9 *
10 */
11
12 #define ANTLR_VERSION 13333
13 #include "pcctscfg.h"
14 #include "pccts_stdio.h"
15
16 #include <ctype.h>
17 #include "dlg.h"
18 #define zzSET_SIZE 8
19 #include "antlr.h"
20 #include "tokens.h"
21 #include "dlgdef.h"
22 #include "mode.h"
23
24 /* MR23 In order to remove calls to PURIFY use the antlr -nopurify option */
25
26 #ifndef PCCTS_PURIFY
27 #define PCCTS_PURIFY(r,s) memset((char *) &(r),'\0',(s));
28 #endif
29
30 ANTLR_INFO
31
32
33 /* MR20 G. Hobbelt
34 Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled
35 */
36
37 #ifdef __TURBOC__
38 #pragma warn -aus /* unused assignment of 'xxx' */
39 #endif
40
41 int action_no = 0; /* keep track of actions outputed */
42 int nfa_allocated = 0; /* keeps track of number of nfa nodes */
43 nfa_node **nfa_array = NULL;/* root of binary tree that stores nfa array */
44 nfa_node nfa_model_node; /* model to initialize new nodes */
45 set used_chars; /* used to label trans. arcs */
46 set used_classes; /* classes or chars used to label trans. arcs */
47 set normal_chars; /* mask to get rid elements that aren't used
48 in set */
49 int flag_paren = FALSE;
50 int flag_brace = FALSE;
51 int mode_counter = 0; /* keep track of number of %%names */
52
53
54
55 void
56 #ifdef __USE_PROTOS
57 grammar(void)
58 #else
59 grammar()
60 #endif
61 {
62 zzRULE;
63 zzBLOCK(zztasp1);
64 zzMake0;
65 {
66 p_head(); p_class_hdr(); func_action = FALSE;
67 {
68 zzBLOCK(zztasp2);
69 zzMake0;
70 {
71 while ( (setwd1[LA(1)]&0x1) ) {
72 {
73 zzBLOCK(zztasp3);
74 zzMake0;
75 {
76 if ( (LA(1)==LEXACTION) ) {
77 zzmatch(LEXACTION); zzCONSUME;
78 }
79 else {
80 if ( (LA(1)==LEXMEMBER) ) {
81 zzmatch(LEXMEMBER); zzCONSUME;
82 }
83 else {
84 if ( (LA(1)==LEXPREFIX) ) {
85 zzmatch(LEXPREFIX); zzCONSUME;
86 }
87 else {
88 if ( (LA(1)==PARSERCLASS) ) {
89 zzmatch(PARSERCLASS); zzCONSUME;
90 }
91 else {
92 if ( (LA(1)==ACTION) ) {
93 }
94 else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
95 }
96 }
97 }
98 }
99 zzEXIT(zztasp3);
100 }
101 }
102 zzmatch(ACTION); zzCONSUME;
103 zzLOOP(zztasp2);
104 }
105 zzEXIT(zztasp2);
106 }
107 }
108 if ( gen_cpp ) p_includes();
109 start_states();
110 func_action = FALSE; p_tables(); p_tail();
111 {
112 zzBLOCK(zztasp2);
113 zzMake0;
114 {
115 while ( (LA(1)==ACTION) ) {
116 zzmatch(ACTION); zzCONSUME;
117 zzLOOP(zztasp2);
118 }
119 zzEXIT(zztasp2);
120 }
121 }
122 zzmatch(1);
123 if (firstLexMember != 0) p_class_def1();
124 zzCONSUME;
125
126 zzEXIT(zztasp1);
127 return;
128 fail:
129 zzEXIT(zztasp1);
130 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
131 zzresynch(setwd1, 0x2);
132 }
133 }
134
135 void
136 #ifdef __USE_PROTOS
137 start_states(void)
138 #else
139 start_states()
140 #endif
141 {
142 zzRULE;
143 zzBLOCK(zztasp1);
144 zzMake0;
145 {
146 {
147 zzBLOCK(zztasp2);
148 zzMake0;
149 {
150 if ( (LA(1)==PER_PER) ) {
151 zzmatch(PER_PER); zzCONSUME;
152 do_conversion();
153 }
154 else {
155 if ( (LA(1)==NAME_PER_PER) ) {
156 zzmatch(NAME_PER_PER); zzCONSUME;
157 do_conversion();
158 {
159 zzBLOCK(zztasp3);
160 zzMake0;
161 {
162 while ( (LA(1)==NAME_PER_PER) ) {
163 zzmatch(NAME_PER_PER); zzCONSUME;
164 do_conversion();
165 zzLOOP(zztasp3);
166 }
167 zzEXIT(zztasp3);
168 }
169 }
170 }
171 else {zzFAIL(1,zzerr2,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
172 }
173 zzEXIT(zztasp2);
174 }
175 }
176 zzmatch(PER_PER); zzCONSUME;
177 zzEXIT(zztasp1);
178 return;
179 fail:
180 zzEXIT(zztasp1);
181 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
182 zzresynch(setwd1, 0x4);
183 }
184 }
185
186 void
187 #ifdef __USE_PROTOS
188 do_conversion(void)
189 #else
190 do_conversion()
191 #endif
192 {
193 zzRULE;
194 zzBLOCK(zztasp1);
195 zzMake0;
196 {
197 new_automaton_mode(); func_action = TRUE;
198 rule_list();
199
200 dfa_class_nop[mode_counter] =
201 relabel(zzaArg(zztasp1,1 ).l,comp_level);
202 if (comp_level)
203 p_shift_table(mode_counter);
204 dfa_basep[mode_counter] = dfa_allocated+1;
205 make_dfa_model_node(dfa_class_nop[mode_counter]);
206 nfa_to_dfa(zzaArg(zztasp1,1 ).l);
207 ++mode_counter;
208 func_action = FALSE;
209 #ifdef HASH_STAT
210 fprint_hash_stats(stderr);
211 #endif
212 zzEXIT(zztasp1);
213 return;
214 fail:
215 zzEXIT(zztasp1);
216 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
217 zzresynch(setwd1, 0x8);
218 }
219 }
220
221 void
222 #ifdef __USE_PROTOS
223 rule_list(void)
224 #else
225 rule_list()
226 #endif
227 {
228 zzRULE;
229 zzBLOCK(zztasp1);
230 zzMake0;
231 {
232 if ( (setwd1[LA(1)]&0x10) ) {
233 rule();
234 zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;
235 {
236 zzBLOCK(zztasp2);
237 zzMake0;
238 {
239 while ( (setwd1[LA(1)]&0x20) ) {
240 rule();
241 {nfa_node *t1;
242 t1 = new_nfa_node();
243 (t1)->trans[0]=zzaRet.l;
244 (t1)->trans[1]=zzaArg(zztasp2,1 ).l;
245 /* all accept nodes "dead ends" */
246 zzaRet.l=t1; zzaRet.r=NULL;
247 }
248 zzLOOP(zztasp2);
249 }
250 zzEXIT(zztasp2);
251 }
252 }
253 }
254 else {
255 if ( (setwd1[LA(1)]&0x40) ) {
256 zzaRet.l = new_nfa_node(); zzaRet.r = NULL;
257 warning("no regular expressions", zzline);
258 }
259 else {zzFAIL(1,zzerr3,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
260 }
261 zzEXIT(zztasp1);
262 return;
263 fail:
264 zzEXIT(zztasp1);
265 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
266 zzresynch(setwd1, 0x80);
267 }
268 }
269
270 void
271 #ifdef __USE_PROTOS
272 rule(void)
273 #else
274 rule()
275 #endif
276 {
277 zzRULE;
278 zzBLOCK(zztasp1);
279 zzMake0;
280 {
281 if ( (setwd2[LA(1)]&0x1) ) {
282 reg_expr();
283 zzmatch(ACTION);
284 if (zzaArg(zztasp1,1 ).r != NULL) {
285 zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r; (zzaArg(zztasp1,1 ).r)->accept=action_no;
286 }
287 zzCONSUME;
288
289 }
290 else {
291 if ( (LA(1)==ACTION) ) {
292 zzmatch(ACTION);
293 zzaRet.l = NULL; zzaRet.r = NULL;
294 error("no expression for action ", zzline);
295 zzCONSUME;
296
297 }
298 else {zzFAIL(1,zzerr4,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
299 }
300 zzEXIT(zztasp1);
301 return;
302 fail:
303 zzEXIT(zztasp1);
304 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
305 zzresynch(setwd2, 0x2);
306 }
307 }
308
309 void
310 #ifdef __USE_PROTOS
311 reg_expr(void)
312 #else
313 reg_expr()
314 #endif
315 {
316 zzRULE;
317 zzBLOCK(zztasp1);
318 zzMake0;
319 {
320 and_expr();
321 zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;
322 {
323 zzBLOCK(zztasp2);
324 zzMake0;
325 {
326 while ( (LA(1)==OR) ) {
327 zzmatch(OR); zzCONSUME;
328 and_expr();
329 {nfa_node *t1, *t2;
330 t1 = new_nfa_node(); t2 = new_nfa_node();
331 (t1)->trans[0]=zzaRet.l;
332 (t1)->trans[1]=zzaArg(zztasp2,2 ).l;
333 /* MR23 */ if (zzaRet.r != NULL) (zzaRet.r)->trans[1]=t2;
334 if (zzaArg(zztasp2,2 ).r) {
335 (zzaArg(zztasp2,2 ).r)->trans[1]=t2; /* MR20 */
336 }
337 zzaRet.l=t1; zzaRet.r=t2;
338 }
339 zzLOOP(zztasp2);
340 }
341 zzEXIT(zztasp2);
342 }
343 }
344 zzEXIT(zztasp1);
345 return;
346 fail:
347 zzEXIT(zztasp1);
348 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
349 zzresynch(setwd2, 0x4);
350 }
351 }
352
353 void
354 #ifdef __USE_PROTOS
355 and_expr(void)
356 #else
357 and_expr()
358 #endif
359 {
360 zzRULE;
361 zzBLOCK(zztasp1);
362 zzMake0;
363 {
364 repeat_expr();
365
366 zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;
367 {
368 zzBLOCK(zztasp2);
369 zzMake0;
370 {
371 while ( (setwd2[LA(1)]&0x8) ) {
372 repeat_expr();
373 if (zzaRet.r != NULL) {
374 (zzaRet.r)->trans[1]=zzaArg(zztasp2,1 ).l;
375 zzaRet.r=zzaArg(zztasp2,1 ).r;
376 }
377 zzLOOP(zztasp2);
378 }
379 zzEXIT(zztasp2);
380 }
381 }
382 zzEXIT(zztasp1);
383 return;
384 fail:
385 zzEXIT(zztasp1);
386 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
387 zzresynch(setwd2, 0x10);
388 }
389 }
390
391 void
392 #ifdef __USE_PROTOS
393 repeat_expr(void)
394 #else
395 repeat_expr()
396 #endif
397 {
398 zzRULE;
399 zzBLOCK(zztasp1);
400 zzMake0;
401 {
402 if ( (setwd2[LA(1)]&0x20) ) {
403 expr();
404 zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;
405 {
406 zzBLOCK(zztasp2);
407 zzMake0;
408 {
409 if ( (LA(1)==ZERO_MORE) ) {
410 zzmatch(ZERO_MORE);
411 { nfa_node *t1,*t2;
412 /* MR23 */ if (zzaRet.r != NULL) (zzaRet.r)->trans[0] = zzaRet.l;
413 t1 = new_nfa_node(); t2 = new_nfa_node();
414 t1->trans[0]=zzaRet.l;
415 t1->trans[1]=t2;
416 /* MR23 */ if (zzaRet.r != NULL) (zzaRet.r)->trans[1]=t2;
417 zzaRet.l=t1;zzaRet.r=t2;
418 }
419 zzCONSUME;
420
421 }
422 else {
423 if ( (LA(1)==ONE_MORE) ) {
424 zzmatch(ONE_MORE);
425 if (zzaRet.r != NULL) (zzaRet.r)->trans[0] = zzaRet.l;
426 zzCONSUME;
427
428 }
429 else {
430 if ( (setwd2[LA(1)]&0x40) ) {
431 }
432 else {zzFAIL(1,zzerr5,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
433 }
434 }
435 zzEXIT(zztasp2);
436 }
437 }
438 }
439 else {
440 if ( (LA(1)==ZERO_MORE) ) {
441 zzmatch(ZERO_MORE);
442 error("no expression for *", zzline);
443 zzCONSUME;
444
445 }
446 else {
447 if ( (LA(1)==ONE_MORE) ) {
448 zzmatch(ONE_MORE);
449 error("no expression for +", zzline);
450 zzCONSUME;
451
452 }
453 else {zzFAIL(1,zzerr6,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
454 }
455 }
456 zzEXIT(zztasp1);
457 return;
458 fail:
459 zzEXIT(zztasp1);
460 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
461 zzresynch(setwd2, 0x80);
462 }
463 }
464
465 void
466 #ifdef __USE_PROTOS
467 expr(void)
468 #else
469 expr()
470 #endif
471 {
472 zzRULE;
473 zzBLOCK(zztasp1);
474 zzMake0;
475 {
476 zzaRet.l = new_nfa_node();
477 zzaRet.r = new_nfa_node();
478 if ( (LA(1)==L_BRACK) ) {
479 zzmatch(L_BRACK); zzCONSUME;
480 atom_list();
481 zzmatch(R_BRACK);
482
483 /* MR23 */ if (zzaRet.l != NULL) {
484 (zzaRet.l)->trans[0] = zzaRet.r;
485 (zzaRet.l)->label = set_dup(zzaArg(zztasp1,2 ).label);
486 set_orin(&used_chars,(zzaRet.l)->label);
487 }
488 zzCONSUME;
489
490 }
491 else {
492 if ( (LA(1)==NOT) ) {
493 zzmatch(NOT); zzCONSUME;
494 zzmatch(L_BRACK); zzCONSUME;
495 atom_list();
496 zzmatch(R_BRACK);
497
498 /* MR23 */ if (zzaRet.l != NULL) {
499 (zzaRet.l)->trans[0] = zzaRet.r;
500 (zzaRet.l)->label = set_dif(normal_chars,zzaArg(zztasp1,3 ).label);
501 set_orin(&used_chars,(zzaRet.l)->label);
502 }
503 zzCONSUME;
504
505 }
506 else {
507 if ( (LA(1)==L_PAR) ) {
508 zzmatch(L_PAR); zzCONSUME;
509 reg_expr();
510 zzmatch(R_PAR);
511
512 /* MR23 */ if (zzaRet.l != NULL) {
513 (zzaRet.l)->trans[0] = zzaArg(zztasp1,2 ).l;
514 if (zzaArg(zztasp1,2 ).r) {
515 (zzaArg(zztasp1,2 ).r)->trans[1] = zzaRet.r; /* MR20 */
516 }
517 }
518 zzCONSUME;
519
520 }
521 else {
522 if ( (LA(1)==L_BRACE) ) {
523 zzmatch(L_BRACE); zzCONSUME;
524 reg_expr();
525 zzmatch(R_BRACE);
526
527 /* MR23 */ if (zzaRet.l != NULL) {
528 (zzaRet.l)->trans[0] = zzaArg(zztasp1,2 ).l;
529 (zzaRet.l)->trans[1] = zzaRet.r;
530 if (zzaArg(zztasp1,2 ).r) {
531 (zzaArg(zztasp1,2 ).r)->trans[1] = zzaRet.r; /* MR20 */
532 }
533 }
534 zzCONSUME;
535
536 }
537 else {
538 if ( (setwd3[LA(1)]&0x1) ) {
539 atom();
540
541 /* MR23 */ if (zzaRet.l != NULL) {
542 (zzaRet.l)->trans[0] = zzaRet.r;
543 (zzaRet.l)->label = set_dup(zzaArg(zztasp1,1 ).label);
544 set_orin(&used_chars,(zzaRet.l)->label);
545 }
546 }
547 else {zzFAIL(1,zzerr7,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
548 }
549 }
550 }
551 }
552 zzEXIT(zztasp1);
553 return;
554 fail:
555 zzEXIT(zztasp1);
556 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
557 zzresynch(setwd3, 0x2);
558 }
559 }
560
561 void
562 #ifdef __USE_PROTOS
563 atom_list(void)
564 #else
565 atom_list()
566 #endif
567 {
568 zzRULE;
569 zzBLOCK(zztasp1);
570 zzMake0;
571 {
572 set_free(zzaRet.label);
573 {
574 zzBLOCK(zztasp2);
575 zzMake0;
576 {
577 while ( (setwd3[LA(1)]&0x4) ) {
578 near_atom();
579 set_orin(&(zzaRet.label),zzaArg(zztasp2,1 ).label);
580 zzLOOP(zztasp2);
581 }
582 zzEXIT(zztasp2);
583 }
584 }
585 zzEXIT(zztasp1);
586 return;
587 fail:
588 zzEXIT(zztasp1);
589 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
590 zzresynch(setwd3, 0x8);
591 }
592 }
593
594 void
595 #ifdef __USE_PROTOS
596 near_atom(void)
597 #else
598 near_atom()
599 #endif
600 {
601 zzRULE;
602 zzBLOCK(zztasp1);
603 zzMake0;
604 {
605 register int i;
606 register int i_prime;
607 anychar();
608 zzaRet.letter=zzaArg(zztasp1,1 ).letter; zzaRet.label=set_of(zzaArg(zztasp1,1 ).letter);
609 i_prime = zzaArg(zztasp1,1 ).letter + MIN_CHAR;
610 if (case_insensitive && islower(i_prime))
611 set_orel(toupper(i_prime)-MIN_CHAR,
612 &(zzaRet.label));
613 if (case_insensitive && isupper(i_prime))
614 set_orel(tolower(i_prime)-MIN_CHAR,
615 &(zzaRet.label));
616 {
617 zzBLOCK(zztasp2);
618 zzMake0;
619 {
620 if ( (LA(1)==RANGE) ) {
621 zzmatch(RANGE); zzCONSUME;
622 anychar();
623 if (case_insensitive){
624 i_prime = zzaRet.letter+MIN_CHAR;
625 zzaRet.letter = (islower(i_prime) ?
626 toupper(i_prime) : i_prime)-MIN_CHAR;
627 i_prime = zzaArg(zztasp2,2 ).letter+MIN_CHAR;
628 zzaArg(zztasp2,2 ).letter = (islower(i_prime) ?
629 toupper(i_prime) : i_prime)-MIN_CHAR;
630 }
631 /* check to see if range okay */
632 {
633 int debugLetter1 = zzaRet.letter;
634 int debugLetter2 = zzaArg(zztasp2,2 ).letter;
635 }
636 if (zzaRet.letter > zzaArg(zztasp2,2 ).letter
637 && zzaArg(zztasp2,2 ).letter != 0xff){ /* MR16 */
638 error("invalid range ", zzline);
639 }
640 for (i=zzaRet.letter; i<= (int)zzaArg(zztasp2,2 ).letter; ++i){
641 set_orel(i,&(zzaRet.label));
642 i_prime = i+MIN_CHAR;
643 if (case_insensitive && islower(i_prime))
644 set_orel(toupper(i_prime)-MIN_CHAR,
645 &(zzaRet.label));
646 if (case_insensitive && isupper(i_prime))
647 set_orel(tolower(i_prime)-MIN_CHAR,
648 &(zzaRet.label));
649 }
650 }
651 else {
652 if ( (setwd3[LA(1)]&0x10) ) {
653 }
654 else {zzFAIL(1,zzerr8,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
655 }
656 zzEXIT(zztasp2);
657 }
658 }
659 zzEXIT(zztasp1);
660 return;
661 fail:
662 zzEXIT(zztasp1);
663 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
664 zzresynch(setwd3, 0x20);
665 }
666 }
667
668 void
669 #ifdef __USE_PROTOS
670 atom(void)
671 #else
672 atom()
673 #endif
674 {
675 zzRULE;
676 zzBLOCK(zztasp1);
677 zzMake0;
678 {
679 register int i_prime;
680 anychar();
681 zzaRet.label = set_of(zzaArg(zztasp1,1 ).letter);
682 i_prime = zzaArg(zztasp1,1 ).letter + MIN_CHAR;
683 if (case_insensitive && islower(i_prime))
684 set_orel(toupper(i_prime)-MIN_CHAR,
685 &(zzaRet.label));
686 if (case_insensitive && isupper(i_prime))
687 set_orel(tolower(i_prime)-MIN_CHAR,
688 &(zzaRet.label));
689 zzEXIT(zztasp1);
690 return;
691 fail:
692 zzEXIT(zztasp1);
693 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
694 zzresynch(setwd3, 0x40);
695 }
696 }
697
698 void
699 #ifdef __USE_PROTOS
700 anychar(void)
701 #else
702 anychar()
703 #endif
704 {
705 zzRULE;
706 zzBLOCK(zztasp1);
707 zzMake0;
708 {
709 if ( (LA(1)==REGCHAR) ) {
710 zzmatch(REGCHAR);
711 zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;
712 zzCONSUME;
713
714 }
715 else {
716 if ( (LA(1)==OCTAL_VALUE) ) {
717 zzmatch(OCTAL_VALUE);
718 zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;
719 zzCONSUME;
720
721 }
722 else {
723 if ( (LA(1)==HEX_VALUE) ) {
724 zzmatch(HEX_VALUE);
725 zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;
726 zzCONSUME;
727
728 }
729 else {
730 if ( (LA(1)==DEC_VALUE) ) {
731 zzmatch(DEC_VALUE);
732 zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;
733 zzCONSUME;
734
735 }
736 else {
737 if ( (LA(1)==TAB) ) {
738 zzmatch(TAB);
739 zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;
740 zzCONSUME;
741
742 }
743 else {
744 if ( (LA(1)==NL) ) {
745 zzmatch(NL);
746 zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;
747 zzCONSUME;
748
749 }
750 else {
751 if ( (LA(1)==CR) ) {
752 zzmatch(CR);
753 zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;
754 zzCONSUME;
755
756 }
757 else {
758 if ( (LA(1)==BS) ) {
759 zzmatch(BS);
760 zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;
761 zzCONSUME;
762
763 }
764 else {
765 if ( (LA(1)==LIT) ) {
766 zzmatch(LIT);
767 zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;
768 zzCONSUME;
769
770 }
771 else {
772 if ( (LA(1)==L_EOF) ) {
773 zzmatch(L_EOF);
774 zzaRet.letter = 0;
775 zzCONSUME;
776
777 }
778 else {zzFAIL(1,zzerr9,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
779 }
780 }
781 }
782 }
783 }
784 }
785 }
786 }
787 }
788 zzEXIT(zztasp1);
789 return;
790 fail:
791 zzEXIT(zztasp1);
792 /* empty action */
793 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
794 zzresynch(setwd3, 0x80);
795 }
796 }
797
798 /* adds a new nfa to the binary tree and returns a pointer to it */
799 nfa_node *
800 #ifdef __USE_PROTOS
801 new_nfa_node(void)
802 #else
803 new_nfa_node()
804 #endif
805 {
806 register nfa_node *t;
807 static int nfa_size=0; /* elements nfa_array[] can hold */
808
809 ++nfa_allocated;
810 if (nfa_size<=nfa_allocated){
811 /* need to redo array */
812 if (!nfa_array){
813 /* need some to do inital allocation */
814 nfa_size=nfa_allocated+NFA_MIN;
815 nfa_array=(nfa_node **) malloc(sizeof(nfa_node*)*
816 nfa_size);
817 }else{
818 /* need more space */
819 nfa_size=2*(nfa_allocated+1);
820 nfa_array=(nfa_node **) realloc(nfa_array,
821 sizeof(nfa_node*)*nfa_size);
822 }
823 }
824 /* fill out entry in array */
825 t = (nfa_node*) malloc(sizeof(nfa_node));
826 nfa_array[nfa_allocated] = t;
827 *t = nfa_model_node;
828 t->node_no = nfa_allocated;
829 return t;
830 }
831
832
833 /* initialize the model node used to fill in newly made nfa_nodes */
834 void
835 #ifdef __USE_PROTOS
836 make_nfa_model_node(void)
837 #else
838 make_nfa_model_node()
839 #endif
840 {
841 nfa_model_node.node_no = -1; /* impossible value for real nfa node */
842 nfa_model_node.nfa_set = 0;
843 nfa_model_node.accept = 0; /* error state default*/
844 nfa_model_node.trans[0] = NULL;
845 nfa_model_node.trans[1] = NULL;
846 nfa_model_node.label = empty;
847 }
848
849 #if defined(DEBUG) || defined(_DEBUG)
850
851 /* print out the pointer value and the node_number */
852 void
853 #ifdef __USE_PROTOS
854 fprint_dfa_pair(FILE *f, nfa_node *p)
855 #else
856 fprint_dfa_pair(f, p)
857 FILE *f;
858 nfa_node *p;
859 #endif
860 {
861 if (p){
862 fprintf(f, "%x (%d)", p, p->node_no);
863 }else{
864 fprintf(f, "(nil)");
865 }
866 }
867
868 /* print out interest information on a set */
869 void
870 #ifdef __USE_PROTOS
871 fprint_set(FILE *f, set s)
872 #else
873 fprint_set(f,s)
874 FILE *f;
875 set s;
876 #endif
877 {
878 unsigned int *x;
879
880 fprintf(f, "n = %d,", s.n);
881 if (s.setword){
882 fprintf(f, "setword = %x, ", s.setword);
883 /* print out all the elements in the set */
884 x = set_pdq(s);
885 while (*x!=nil){
886 fprintf(f, "%d ", *x);
887 ++x;
888 }
889 }else{
890 fprintf(f, "setword = (nil)");
891 }
892 }
893
894 /* code to be able to dump out the nfas
895 return 0 if okay dump
896 return 1 if screwed up
897 */
898 int
899 #ifdef __USE_PROTOS
900 dump_nfas(int first_node, int last_node)
901 #else
902 dump_nfas(first_node, last_node)
903 int first_node;
904 int last_node;
905 #endif
906 {
907 register int i;
908 nfa_node *t;
909
910 for (i=first_node; i<=last_node; ++i){
911 t = NFA(i);
912 if (!t) break;
913 fprintf(stderr, "nfa_node %d {\n", t->node_no);
914 fprintf(stderr, "\n\tnfa_set = %d\n", t->nfa_set);
915 fprintf(stderr, "\taccept\t=\t%d\n", t->accept);
916 fprintf(stderr, "\ttrans\t=\t(");
917 fprint_dfa_pair(stderr, t->trans[0]);
918 fprintf(stderr, ",");
919 fprint_dfa_pair(stderr, t->trans[1]);
920 fprintf(stderr, ")\n");
921 fprintf(stderr, "\tlabel\t=\t{ ");
922 fprint_set(stderr, t->label);
923 fprintf(stderr, "\t}\n");
924 fprintf(stderr, "}\n\n");
925 }
926 return 0;
927 }
928 #endif
929
930 /* DLG-specific syntax error message generator
931 * (define USER_ZZSYN when compiling so don't get 2 definitions)
932 */
933 void
934 #ifdef __USE_PROTOS
935 zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
936 #else
937 zzsyn(text, tok, egroup, eset, etok, k, bad_text)
938 char *text, *egroup, *bad_text;
939 int tok;
940 int etok;
941 int k;
942 SetWordType *eset;
943 #endif
944 {
945 fprintf(stderr, ErrHdr, file_str[0]!=NULL?file_str[0]:"stdin", zzline);
946 fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
947 if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
948 if ( k==1 ) fprintf(stderr, " missing");
949 else
950 {
951 fprintf(stderr, "; \"%s\" not", bad_text);
952 if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
953 }
954 if ( zzset_deg(eset)>0 ) zzedecode(eset);
955 else fprintf(stderr, " %s", zztokens[etok]);
956 if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);
957 fprintf(stderr, "\n");
958 }
+0
-614
contrib/pccts/dlg/dlg_p.g less more
0 /* This is the parser for the dlg
1 * This is a part of the Purdue Compiler Construction Tool Set
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
10 *
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * DLG 1.33
24 * Will Cohen
25 * With mods by Terence Parr; AHPCRC, University of Minnesota
26 * 1989-1995
27 */
28
29 #header <<
30 #include <ctype.h>
31 #include "dlg.h"
32 >>
33
34 <<
35
36 /* MR20 G. Hobbelt
37 Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled
38 */
39
40 #ifdef __TURBOC__
41 #pragma warn -aus /* unused assignment of 'xxx' */
42 #endif
43
44 int action_no = 0; /* keep track of actions outputed */
45 int nfa_allocated = 0; /* keeps track of number of nfa nodes */
46 nfa_node **nfa_array = NULL;/* root of binary tree that stores nfa array */
47 nfa_node nfa_model_node; /* model to initialize new nodes */
48 set used_chars; /* used to label trans. arcs */
49 set used_classes; /* classes or chars used to label trans. arcs */
50 set normal_chars; /* mask to get rid elements that aren't used
51 in set */
52 int flag_paren = FALSE;
53 int flag_brace = FALSE;
54 int mode_counter = 0; /* keep track of number of %%names */
55
56 >>
57
58 #lexaction <<
59 int func_action; /* should actions be turned into functions?*/
60 int lex_mode_counter = 0; /* keeps track of the number of %%names */
61 /* MR1 */
62 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
63 /* MR1 via <<%%lexmember...>> */
64 /* MR1 */
65 int lexMember = 0; /* <<%%lexmemeber ...>> MR1 */
66 int lexAction = 0; /* <<%%lexaction ...>> MR1 */
67 int parserClass = 0; /* <<%%parserclass ...>> MR1 */
68 int lexPrefix = 0; /* <<%%lexprefix ...>> MR1 */
69 char theClassName[100]; /* MR11 */
70 char *pClassName=theClassName; /* MR11 */
71 int firstLexMember=1; /* MR1 */
72
73 #ifdef __USE_PROTOS
74 void xxputc(int c) { /* MR1 */
75 #else
76 void xxputc(c) /* MR1 */
77 int c; /* MR1 */
78 { /* MR1 */
79 #endif
80 if (parserClass) { /* MR1 */
81 *pClassName++=c; /* MR1 */
82 *pClassName=0; /* MR1 */
83 } else if (lexMember || lexPrefix) { /* MR1 */
84 if (class_stream != NULL) fputc(c,class_stream); /* MR1 */
85 } else { /* MR1 */
86 fputc(c,OUT); /* MR1 */
87 }; /* MR1 */
88 } /* MR1 */
89
90 #ifdef __USE_PROTOS
91 void xxprintf(char *format,char *string) { /* MR1 */
92 #else
93 void xxprintf(format,string) /* MR1 */
94 char *format; /* MR1 */
95 char *string; /* MR1 */
96 { /* MR1 */
97 #endif
98 if (lexMember || lexPrefix || parserClass) { /* MR1 */
99 if (class_stream != NULL) /* MR1 */
100 fprintf(class_stream,format,string); /* MR1 */
101 } else { /* MR1 */
102 fprintf(OUT,format,string); /* MR1 */
103 }; /* MR1 */
104 } /* MR1 */
105 >>
106
107 #token "[\r\t\ ]+" << zzskip(); >> /* Ignore white */
108 #token "\n" << zzline++; zzskip(); DAWDLE; >> /* Track Line # */
109 #token L_EOF "\@"
110 #token PER_PER "\%\%"
111 #token NAME_PER_PER "\%\%[a-zA-Z_][a-zA-Z0-9_]*"
112 << p_mode_def(&zzlextext[2],lex_mode_counter++); >>
113
114 #token LEXMEMBER "\<\<\%\%lexmember" /* MR1 */
115 <<lexMember=1; /* MR1 */
116 if (firstLexMember != 0) { /* MR1 */
117 firstLexMember=0; /* MR1 */
118 p_class_def1(); /* MR1 */
119 }; /* MR1 */
120 zzmode(ACT); /* MR1 */
121 >> /* MR1 */
122 #token LEXACTION "\<\<\%\%lexaction" /* MR1 */
123 <<lexAction=1;zzmode(ACT);>> /* MR1 */
124 #token PARSERCLASS "\<\<\%\%parserclass" /* MR1 */
125 <<parserClass=1; /* MR1 */
126 zzmode(ACT); /* MR1 */
127 >> /* MR1 */
128 #token LEXPREFIX "\<\<\%\%lexprefix" /* MR1 */
129 <<lexPrefix=1;zzmode(ACT);>> /* MR1 */
130
131 #token ACTION "\<\<"
132 << if (func_action)
133 fprintf(OUT,"\n%s %sact%d()\n{ ",
134 gen_cpp?"ANTLRTokenType":"static void",
135 gen_cpp?ClassName("::"):"", ++action_no);
136 zzmode(ACT); zzskip();
137 >>
138 #token GREAT_GREAT "\>\>"
139 #token L_BRACE "\{"
140 #token R_BRACE "\}"
141 #token L_PAR "\("
142 #token R_PAR "\)"
143 #token L_BRACK "\["
144 #token R_BRACK "\]"
145 #token ZERO_MORE "\*"
146 #token ONE_MORE "\+"
147 #token OR "\|"
148 #token RANGE "\-"
149 #token NOT "\~"
150 #token OCTAL_VALUE "\\0[0-7]*"
151 << {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}>>
152 #token HEX_VALUE "\\0[Xx][0-9a-fA-F]+"
153 << {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}>>
154 #token DEC_VALUE "\\[1-9][0-9]*"
155 << {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}>>
156 #token TAB "\\t" << zzlextext[0] = '\t';>>
157 #token NL "\\n" << zzlextext[0] = '\n';>>
158 #token CR "\\r" << zzlextext[0] = '\r';>>
159 #token BS "\\b" << zzlextext[0] = '\b';>>
160
161 /* MR1 */
162 /* MR1 10-Apr-97 MR1 Allow #token regular expressions to cross lines */
163 /* MR1 */
164 #token CONTINUATION "\\ \n" << zzline++; zzskip();>> /* MR1 */
165
166 /* NOTE: this takes ANYTHING after the \ */
167 #token LIT "\\~[tnrb]" << zzlextext[0] = zzlextext[1];>>
168
169 /* NOTE: this takes ANYTHING that doesn't match the other tokens */
170 #token REGCHAR "~[\\]"
171
172
173 grammar : << p_head(); p_class_hdr(); func_action = FALSE;>>
174 ( {LEXACTION | LEXMEMBER | LEXPREFIX | PARSERCLASS } ACTION)* /* MR1 */
175 <<if ( gen_cpp ) p_includes();>>
176 start_states
177 << func_action = FALSE; p_tables(); p_tail(); >>
178 (ACTION)* "@"
179 << if (firstLexMember != 0) p_class_def1(); >> /* MR1 */
180 ;
181
182 start_states : ( PER_PER do_conversion
183 | NAME_PER_PER do_conversion (NAME_PER_PER do_conversion)*)
184 PER_PER
185 ;
186
187 do_conversion : <<new_automaton_mode(); func_action = TRUE;>>
188 rule_list
189 <<
190 dfa_class_nop[mode_counter] =
191 relabel($1.l,comp_level);
192 if (comp_level)
193 p_shift_table(mode_counter);
194 dfa_basep[mode_counter] = dfa_allocated+1;
195 make_dfa_model_node(dfa_class_nop[mode_counter]);
196 nfa_to_dfa($1.l);
197 ++mode_counter;
198 func_action = FALSE;
199 #ifdef HASH_STAT
200 fprint_hash_stats(stderr);
201 #endif
202 >>
203 ;
204
205 rule_list : rule <<$$.l=$1.l; $$.r=$1.r;>>
206 (rule
207 <<{nfa_node *t1;
208 t1 = new_nfa_node();
209 (t1)->trans[0]=$$.l;
210 (t1)->trans[1]=$1.l;
211 /* all accept nodes "dead ends" */
212 $$.l=t1; $$.r=NULL;
213 }
214 >>
215 )*
216 | /* empty */
217 <<$$.l = new_nfa_node(); $$.r = NULL;
218 warning("no regular expressions", zzline);
219 >>
220 ;
221
222 rule : reg_expr ACTION
223 /* MR23 */ << if ($1.r != NULL) {
224 $$.l=$1.l; $$.r=$1.r; ($1.r)->accept=action_no;
225 }
226 >>
227 | ACTION
228 <<$$.l = NULL; $$.r = NULL;
229 error("no expression for action ", zzline);
230 >>
231 ;
232
233 reg_expr : and_expr <<$$.l=$1.l; $$.r=$1.r;>>
234 (OR and_expr
235 <<{nfa_node *t1, *t2;
236 t1 = new_nfa_node(); t2 = new_nfa_node();
237 (t1)->trans[0]=$$.l;
238 (t1)->trans[1]=$2.l;
239 /* MR23 */ if ($$.r != NULL) ($$.r)->trans[1]=t2;
240 if ($2.r) {
241 ($2.r)->trans[1]=t2; /* MR20 */
242 }
243 $$.l=t1; $$.r=t2;
244 }
245 >>
246 )*
247 ;
248
249 and_expr : repeat_expr
250 <<
251 $$.l=$1.l; $$.r=$1.r;
252 >>
253 (repeat_expr
254 /* MR23 */ << if ($$.r != NULL) {
255 ($$.r)->trans[1]=$1.l;
256 $$.r=$1.r;
257 }
258 >>
259 )*
260 ;
261
262 repeat_expr : expr <<$$.l=$1.l; $$.r=$1.r;>>
263 { ZERO_MORE
264 <<{ nfa_node *t1,*t2;
265 /* MR23 */ if ($$.r != NULL) ($$.r)->trans[0] = $$.l;
266 t1 = new_nfa_node(); t2 = new_nfa_node();
267 t1->trans[0]=$$.l;
268 t1->trans[1]=t2;
269 /* MR23 */ if ($$.r != NULL) ($$.r)->trans[1]=t2;
270 $$.l=t1;$$.r=t2;
271 }
272 >>
273 | ONE_MORE
274 /* MR23 */ <<if ($$.r != NULL) ($$.r)->trans[0] = $$.l;>>
275 }
276 | ZERO_MORE
277 << error("no expression for *", zzline);>>
278 | ONE_MORE
279 << error("no expression for +", zzline);>>
280 ;
281
282 expr : << $$.l = new_nfa_node();
283 $$.r = new_nfa_node();
284 >>
285 L_BRACK atom_list R_BRACK
286 <<
287 /* MR23 */ if ($$.l != NULL) {
288 ($$.l)->trans[0] = $$.r;
289 ($$.l)->label = set_dup($2.label);
290 set_orin(&used_chars,($$.l)->label);
291 }
292 >>
293 | NOT L_BRACK atom_list R_BRACK
294 <<
295 /* MR23 */ if ($$.l != NULL) {
296 ($$.l)->trans[0] = $$.r;
297 ($$.l)->label = set_dif(normal_chars,$3.label);
298 set_orin(&used_chars,($$.l)->label);
299 }
300 >>
301 | L_PAR reg_expr R_PAR
302 <<
303 /* MR23 */ if ($$.l != NULL) {
304 ($$.l)->trans[0] = $2.l;
305 if ($2.r) {
306 ($2.r)->trans[1] = $$.r; /* MR20 */
307 }
308 }
309 >>
310 | L_BRACE reg_expr R_BRACE
311 <<
312 /* MR23 */ if ($$.l != NULL) {
313 ($$.l)->trans[0] = $2.l;
314 ($$.l)->trans[1] = $$.r;
315 if ($2.r) {
316 ($2.r)->trans[1] = $$.r; /* MR20 */
317 }
318 }
319 >>
320 | atom
321 <<
322 /* MR23 */ if ($$.l != NULL) {
323 ($$.l)->trans[0] = $$.r;
324 ($$.l)->label = set_dup($1.label);
325 set_orin(&used_chars,($$.l)->label);
326 }
327 >>
328 ;
329
330 atom_list : << set_free($$.label); >>
331 (near_atom <<set_orin(&($$.label),$1.label);>>)*
332 ;
333
334 near_atom : << register int i;
335 register int i_prime;
336 >>
337 anychar
338 <<$$.letter=$1.letter; $$.label=set_of($1.letter);
339 i_prime = $1.letter + MIN_CHAR;
340 if (case_insensitive && islower(i_prime))
341 set_orel(toupper(i_prime)-MIN_CHAR,
342 &($$.label));
343 if (case_insensitive && isupper(i_prime))
344 set_orel(tolower(i_prime)-MIN_CHAR,
345 &($$.label));
346 >>
347 { RANGE anychar
348 << if (case_insensitive){
349 i_prime = $$.letter+MIN_CHAR;
350 $$.letter = (islower(i_prime) ?
351 toupper(i_prime) : i_prime)-MIN_CHAR;
352 i_prime = $2.letter+MIN_CHAR;
353 $2.letter = (islower(i_prime) ?
354 toupper(i_prime) : i_prime)-MIN_CHAR;
355 }
356 /* check to see if range okay */
357 {
358 int debugLetter1 = $$.letter;
359 int debugLetter2 = $2.letter;
360 }
361 if ($$.letter > $2.letter
362 && $2.letter != 0xff){ /* MR16 */
363 error("invalid range ", zzline);
364 }
365 for (i=$$.letter; i<= (int)$2.letter; ++i){
366 set_orel(i,&($$.label));
367 i_prime = i+MIN_CHAR;
368 if (case_insensitive && islower(i_prime))
369 set_orel(toupper(i_prime)-MIN_CHAR,
370 &($$.label));
371 if (case_insensitive && isupper(i_prime))
372 set_orel(tolower(i_prime)-MIN_CHAR,
373 &($$.label));
374 }
375 >>
376 }
377 ;
378
379 atom : << register int i_prime;>>
380 anychar
381 <<$$.label = set_of($1.letter);
382 i_prime = $1.letter + MIN_CHAR;
383 if (case_insensitive && islower(i_prime))
384 set_orel(toupper(i_prime)-MIN_CHAR,
385 &($$.label));
386 if (case_insensitive && isupper(i_prime))
387 set_orel(tolower(i_prime)-MIN_CHAR,
388 &($$.label));
389 >>
390 ;
391
392 anychar : REGCHAR <<$$.letter = $1.letter - MIN_CHAR;>>
393 | OCTAL_VALUE <<$$.letter = $1.letter - MIN_CHAR;>>
394 | HEX_VALUE <<$$.letter = $1.letter - MIN_CHAR;>>
395 | DEC_VALUE <<$$.letter = $1.letter - MIN_CHAR;>>
396 | TAB <<$$.letter = $1.letter - MIN_CHAR;>>
397 | NL <<$$.letter = $1.letter - MIN_CHAR;>>
398 | CR <<$$.letter = $1.letter - MIN_CHAR;>>
399 | BS <<$$.letter = $1.letter - MIN_CHAR;>>
400 | LIT <<$$.letter = $1.letter - MIN_CHAR;>>
401 /* NOTE: LEX_EOF is ALWAYS shifted to 0 = MIN_CHAR - MIN_CHAR*/
402 | L_EOF <<$$.letter = 0;>>
403 ;
404
405 <</* empty action */>>
406
407 #lexclass ACT
408 #token "@" << error("unterminated action", zzline); zzmode(START); >>
409 #token ACTION "\>\>"
410 << if (func_action) fprintf(OUT,"}\n\n");
411 zzmode(START);
412 /* MR1 */
413 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
414 /* MR1 via <<%%lexmember ...>> */
415 /* MR1 This is a consequence of not saving actions */
416 /* MR1 */
417 /* MR1 */ parserClass=0;
418 /* MR1 */ lexPrefix=0;
419 /* MR1 */ lexAction=0;
420 /* MR1 */ lexMember=0;
421 >>
422 #token "\>" << xxputc(zzlextext[0]); zzskip(); >> /* MR1 */
423 #token "\\\>" << xxputc('>'); zzskip(); >> /* MR1 */
424 #token "\\" << xxputc('\\'); zzskip(); >> /* MR1 */
425 #token "\n" << xxputc(zzlextext[0]); ++zzline; zzskip(); >> /* MR1 */
426 #token "/\*" << zzmode(ACTION_COMMENTS); /* MR1 */
427 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
428 >> /* MR1 */
429 #token "//" << zzmode(ACTION_CPP_COMMENTS); /* MR1 */
430 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
431 >> /* MR1 */
432 #token "~[]" << xxputc(zzlextext[0]); zzskip(); >> /* MR1 */
433 /* MR1 */
434 #lexclass ACTION_COMMENTS /* MR1 */
435 #token "\*/" << zzmode(ACT); /* MR1 */
436 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
437 >> /* MR1 */
438 #token "[\n\r]" << zzline++; xxputc(zzlextext[0]); zzskip();>> /* MR1 */
439 #token "~[]" << xxputc(zzlextext[0]); zzskip();>> /* MR1 */
440 /* MR1 */
441 #lexclass ACTION_CPP_COMMENTS /* MR1 */
442 #token "[\n\r]" << zzmode(ACT); zzline++; /* MR1 */
443 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
444 >> /* MR1 */
445 #token "~[]" << xxputc(zzlextext[0]); zzskip();>> /* MR1 */
446
447 <<
448 /* adds a new nfa to the binary tree and returns a pointer to it */
449 nfa_node *
450 #ifdef __USE_PROTOS
451 new_nfa_node(void)
452 #else
453 new_nfa_node()
454 #endif
455 {
456 register nfa_node *t;
457 static int nfa_size=0; /* elements nfa_array[] can hold */
458
459 ++nfa_allocated;
460 if (nfa_size<=nfa_allocated){
461 /* need to redo array */
462 if (!nfa_array){
463 /* need some to do inital allocation */
464 nfa_size=nfa_allocated+NFA_MIN;
465 nfa_array=(nfa_node **) malloc(sizeof(nfa_node*)*
466 nfa_size);
467 }else{
468 /* need more space */
469 nfa_size=2*(nfa_allocated+1);
470 nfa_array=(nfa_node **) realloc(nfa_array,
471 sizeof(nfa_node*)*nfa_size);
472 }
473 }
474 /* fill out entry in array */
475 t = (nfa_node*) malloc(sizeof(nfa_node));
476 nfa_array[nfa_allocated] = t;
477 *t = nfa_model_node;
478 t->node_no = nfa_allocated;
479 return t;
480 }
481
482
483 /* initialize the model node used to fill in newly made nfa_nodes */
484 void
485 #ifdef __USE_PROTOS
486 make_nfa_model_node(void)
487 #else
488 make_nfa_model_node()
489 #endif
490 {
491 nfa_model_node.node_no = -1; /* impossible value for real nfa node */
492 nfa_model_node.nfa_set = 0;
493 nfa_model_node.accept = 0; /* error state default*/
494 nfa_model_node.trans[0] = NULL;
495 nfa_model_node.trans[1] = NULL;
496 nfa_model_node.label = empty;
497 }
498 >>
499
500 <<
501 #if defined(DEBUG) || defined(_DEBUG)
502
503 /* print out the pointer value and the node_number */
504 void
505 #ifdef __USE_PROTOS
506 fprint_dfa_pair(FILE *f, nfa_node *p)
507 #else
508 fprint_dfa_pair(f, p)
509 FILE *f;
510 nfa_node *p;
511 #endif
512 {
513 if (p){
514 fprintf(f, "%x (%d)", p, p->node_no);
515 }else{
516 fprintf(f, "(nil)");
517 }
518 }
519
520 /* print out interest information on a set */
521 void
522 #ifdef __USE_PROTOS
523 fprint_set(FILE *f, set s)
524 #else
525 fprint_set(f,s)
526 FILE *f;
527 set s;
528 #endif
529 {
530 unsigned int *x;
531
532 fprintf(f, "n = %d,", s.n);
533 if (s.setword){
534 fprintf(f, "setword = %x, ", s.setword);
535 /* print out all the elements in the set */
536 x = set_pdq(s);
537 while (*x!=nil){
538 fprintf(f, "%d ", *x);
539 ++x;
540 }
541 }else{
542 fprintf(f, "setword = (nil)");
543 }
544 }
545
546 /* code to be able to dump out the nfas
547 return 0 if okay dump
548 return 1 if screwed up
549 */
550 int
551 #ifdef __USE_PROTOS
552 dump_nfas(int first_node, int last_node)
553 #else
554 dump_nfas(first_node, last_node)
555 int first_node;
556 int last_node;
557 #endif
558 {
559 register int i;
560 nfa_node *t;
561
562 for (i=first_node; i<=last_node; ++i){
563 t = NFA(i);
564 if (!t) break;
565 fprintf(stderr, "nfa_node %d {\n", t->node_no);
566 fprintf(stderr, "\n\tnfa_set = %d\n", t->nfa_set);
567 fprintf(stderr, "\taccept\t=\t%d\n", t->accept);
568 fprintf(stderr, "\ttrans\t=\t(");
569 fprint_dfa_pair(stderr, t->trans[0]);
570 fprintf(stderr, ",");
571 fprint_dfa_pair(stderr, t->trans[1]);
572 fprintf(stderr, ")\n");
573 fprintf(stderr, "\tlabel\t=\t{ ");
574 fprint_set(stderr, t->label);
575 fprintf(stderr, "\t}\n");
576 fprintf(stderr, "}\n\n");
577 }
578 return 0;
579 }
580 #endif
581 >>
582
583 <<
584 /* DLG-specific syntax error message generator
585 * (define USER_ZZSYN when compiling so don't get 2 definitions)
586 */
587 void
588 #ifdef __USE_PROTOS
589 zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
590 #else
591 zzsyn(text, tok, egroup, eset, etok, k, bad_text)
592 char *text, *egroup, *bad_text;
593 int tok;
594 int etok;
595 int k;
596 SetWordType *eset;
597 #endif
598 {
599 fprintf(stderr, ErrHdr, file_str[0]!=NULL?file_str[0]:"stdin", zzline);
600 fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
601 if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
602 if ( k==1 ) fprintf(stderr, " missing");
603 else
604 {
605 fprintf(stderr, "; \"%s\" not", bad_text);
606 if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
607 }
608 if ( zzset_deg(eset)>0 ) zzedecode(eset);
609 else fprintf(stderr, " %s", zztokens[etok]);
610 if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);
611 fprintf(stderr, "\n");
612 }
613 >>
+0
-99
contrib/pccts/dlg/err.c less more
0 /*
1 * A n t l r S e t s / E r r o r F i l e H e a d e r
2 *
3 * Generated from: ./dlg_p.g
4 *
5 * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001
6 * Parr Research Corporation
7 * with Purdue University Electrical Engineering
8 * With AHPCRC, University of Minnesota
9 * ANTLR Version 1.33MR33
10 */
11
12 #define ANTLR_VERSION 13333
13 #include "pcctscfg.h"
14 #include "pccts_stdio.h"
15
16 #include <ctype.h>
17 #include "dlg.h"
18 #define zzSET_SIZE 8
19 #include "antlr.h"
20 #include "tokens.h"
21 #include "dlgdef.h"
22 #include "err.h"
23
24 ANTLRChar *zztokens[46]={
25 /* 00 */ "Invalid",
26 /* 01 */ "@",
27 /* 02 */ "[\\r\\t\\ ]+",
28 /* 03 */ "\\n",
29 /* 04 */ "L_EOF",
30 /* 05 */ "PER_PER",
31 /* 06 */ "NAME_PER_PER",
32 /* 07 */ "LEXMEMBER",
33 /* 08 */ "LEXACTION",
34 /* 09 */ "PARSERCLASS",
35 /* 10 */ "LEXPREFIX",
36 /* 11 */ "ACTION",
37 /* 12 */ "GREAT_GREAT",
38 /* 13 */ "L_BRACE",
39 /* 14 */ "R_BRACE",
40 /* 15 */ "L_PAR",
41 /* 16 */ "R_PAR",
42 /* 17 */ "L_BRACK",
43 /* 18 */ "R_BRACK",
44 /* 19 */ "ZERO_MORE",
45 /* 20 */ "ONE_MORE",
46 /* 21 */ "OR",
47 /* 22 */ "RANGE",
48 /* 23 */ "NOT",
49 /* 24 */ "OCTAL_VALUE",
50 /* 25 */ "HEX_VALUE",
51 /* 26 */ "DEC_VALUE",
52 /* 27 */ "TAB",
53 /* 28 */ "NL",
54 /* 29 */ "CR",
55 /* 30 */ "BS",
56 /* 31 */ "CONTINUATION",
57 /* 32 */ "LIT",
58 /* 33 */ "REGCHAR",
59 /* 34 */ "\\>",
60 /* 35 */ "\\\\>",
61 /* 36 */ "\\",
62 /* 37 */ "\\n",
63 /* 38 */ "/\\*",
64 /* 39 */ "//",
65 /* 40 */ "~[]",
66 /* 41 */ "\\*/",
67 /* 42 */ "[\\n\\r]",
68 /* 43 */ "~[]",
69 /* 44 */ "[\\n\\r]",
70 /* 45 */ "~[]"
71 };
72 SetWordType zzerr1[8] = {0x80,0xf,0x0,0x0, 0x0,0x0,0x0,0x0};
73 SetWordType zzerr2[8] = {0x60,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};
74 SetWordType zzerr3[8] = {0x70,0xa8,0x9a,0x7f, 0x3,0x0,0x0,0x0};
75 SetWordType setwd1[46] = {0x0,0x6,0x0,0x0,0x30,0xc8,0xc8,
76 0x1,0x1,0x1,0x1,0x35,0x0,0x30,0x0,
77 0x30,0x0,0x30,0x0,0x30,0x30,0x0,0x0,
78 0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
79 0x0,0x30,0x30,0x0,0x0,0x0,0x0,0x0,
80 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
81 SetWordType zzerr4[8] = {0x10,0xa8,0x9a,0x7f, 0x3,0x0,0x0,0x0};
82 SetWordType zzerr5[8] = {0x10,0xe8,0xbb,0x7f, 0x3,0x0,0x0,0x0};
83 SetWordType zzerr6[8] = {0x10,0xa0,0x9a,0x7f, 0x3,0x0,0x0,0x0};
84 SetWordType setwd2[46] = {0x0,0x0,0x0,0x0,0xeb,0x2,0x2,
85 0x0,0x0,0x0,0x0,0xd6,0x0,0xeb,0xd4,
86 0xeb,0xd4,0xeb,0x0,0xcb,0xcb,0xd0,0x0,
87 0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,
88 0x0,0xeb,0xeb,0x0,0x0,0x0,0x0,0x0,
89 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
90 SetWordType zzerr7[8] = {0x10,0xa0,0x82,0x7f, 0x3,0x0,0x0,0x0};
91 SetWordType zzerr8[8] = {0x10,0x0,0x44,0x7f, 0x3,0x0,0x0,0x0};
92 SetWordType zzerr9[8] = {0x10,0x0,0x0,0x7f, 0x3,0x0,0x0,0x0};
93 SetWordType setwd3[46] = {0x0,0x0,0x0,0x0,0xf7,0x0,0x0,
94 0x0,0x0,0x0,0x0,0xc2,0x0,0xc2,0xc2,
95 0xc2,0xc2,0xc2,0xb8,0xc2,0xc2,0xc2,0x80,
96 0xc2,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,
97 0x0,0xf7,0xf7,0x0,0x0,0x0,0x0,0x0,
98 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
+0
-281
contrib/pccts/dlg/main.c less more
0 /* Main function for dlg version
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * DLG 1.33
23 * Will Cohen
24 * With mods by Terence Parr; AHPCRC, University of Minnesota
25 * 1989-2001
26 */
27
28 #include <stdio.h>
29 #include "stdpccts.h"
30
31 char program[] = "dlg";
32 char version[] = "1.33MR33"; /* MRXXX */
33 int numfiles = 0;
34 char *file_str[2] = {NULL, NULL};
35 char *mode_file = "mode.h";
36 char *class_name = DEFAULT_CLASSNAME;
37 char *OutputDirectory = TopDirectory;
38
39 /* Option variables */
40 int comp_level = 0;
41 int interactive = FALSE;
42 int case_insensitive = FALSE;
43 int warn_ambig = FALSE;
44 int gen_cpp = FALSE;
45
46 #ifdef __USE_PROTOS
47 static int ci_strequ(char *a,char *b)
48 #else
49 static int ci_strequ(a,b)
50 char *a;
51 char *b;
52 #endif
53 {
54 for ( ;*a != 0 && *b != 0; a++, b++) {
55 if (toupper(*a) != toupper(*b)) return 0;
56 }
57 return (*a == *b);
58 }
59
60 /* Option List Stuff */
61 #ifdef __USE_PROTOS
62 void p_comp0(void) {comp_level = 0;}
63 void p_comp1(void) {comp_level = 1;}
64 void p_comp2(void) {comp_level = 2;}
65 void p_stdio(void) { file_str[numfiles++] = NULL;}
66 void p_file(char *s) { file_str[numfiles++] = s;}
67 void p_cl_name(char *s, char *t)
68 {
69 if ( gen_cpp ) {
70 class_name = t;
71 }
72 else {
73 warning("-cl only valid in C++ mode; -cl ignored...",0);
74 }
75 }
76 void p_mode_file(char *s, char *t){mode_file=t;}
77 void p_outdir(char *s,char *t) {OutputDirectory=t;}
78 void p_ansi(void) {gen_ansi = TRUE;}
79 void p_interactive(void) {interactive = TRUE;}
80 void p_case_s(void) { case_insensitive = FALSE; }
81 void p_case_i(void) { case_insensitive = TRUE; }
82 void p_warn_ambig(void) { warn_ambig = TRUE; }
83 void p_cpp(void) { gen_cpp = TRUE; }
84 #else
85 void p_comp0() {comp_level = 0;}
86 void p_comp1() {comp_level = 1;}
87 void p_comp2() {comp_level = 2;}
88 void p_stdio() { file_str[numfiles++] = NULL;}
89 void p_file(s) char *s; { file_str[numfiles++] = s;}
90 void p_cl_name(s,t)
91 char *s, *t;
92 {
93 if ( gen_cpp ) {
94 class_name = t;
95 }
96 else {
97 warning("-cl only valid in C++ mode; -cl ignored...",0);
98 }
99 }
100 void p_mode_file(s,t) char *s,*t;{mode_file=t;}
101 void p_outdir(s,t) char *s,*t;{OutputDirectory=t;}
102 void p_ansi() {gen_ansi = TRUE;}
103 void p_interactive() {interactive = TRUE;}
104 void p_case_s() { case_insensitive = FALSE; }
105 void p_case_i() { case_insensitive = TRUE; }
106 void p_warn_ambig() { warn_ambig = TRUE; }
107 void p_cpp() { gen_cpp = TRUE; }
108 #endif
109
110 #ifdef __cplusplus
111 typedef void (*WildFunc)(...);
112 #else
113 typedef void (*WildFunc)();
114 #endif
115
116 typedef struct {
117 char *option;
118 int arg;
119 WildFunc process;
120 char *descr;
121 } Opt;
122
123 Opt options[] = {
124 { "-CC", 0, (WildFunc)p_cpp, "Generate C++ output" },
125 { "-C0", 0, (WildFunc)p_comp0, "No compression (default)" },
126 { "-C1", 0, (WildFunc)p_comp1, "Compression level 1" },
127 { "-C2", 0, (WildFunc)p_comp2, "Compression level 2" },
128 { "-ga", 0, (WildFunc)p_ansi, "Generate ansi C"},
129 { "-Wambiguity", 0, (WildFunc)p_warn_ambig, "Warn if expressions ambiguous"},
130 { "-m", 1, (WildFunc)p_mode_file, "Rename lexical mode output file"},
131 { "-i", 0, (WildFunc)p_interactive, "Build interactive scanner (not valid for C++ mode)"},
132 { "-ci", 0, (WildFunc)p_case_i, "Make lexical analyzer case insensitive"},
133 { "-cl", 1, (WildFunc)p_cl_name, "Rename lexer class (DLGLexer); only used for -CC"},
134 { "-cs", 0, (WildFunc)p_case_s, "Make lexical analyzer case sensitive (default)"},
135 { "-o", 1, (WildFunc)p_outdir, OutputDirectoryOption},
136 { "-", 0, (WildFunc)p_stdio, "Use standard i/o rather than file"},
137 { "*", 0, (WildFunc)p_file, ""}, /* anything else is a file */
138 { NULL, 0, NULL }
139 };
140
141 #ifdef __USE_PROTOS
142 void ProcessArgs(int argc, char **argv, Opt *options)
143 #else
144 void ProcessArgs(argc, argv, options)
145 int argc;
146 char **argv;
147 Opt *options;
148 #endif
149 {
150 Opt *p;
151
152 while ( argc-- > 0 )
153 {
154 p = options;
155 while ( p->option != NULL )
156 {
157 if ( strcmp(p->option, "*") == 0 ||
158 ci_strequ(p->option,*argv) )
159 {
160 if ( p->arg )
161 {
162 (*p->process)( *argv, *(argv+1) );
163 argv++;
164 argc--;
165 }
166 else
167 (*p->process)( *argv );
168 break;
169 }
170 p++;
171 }
172 argv++;
173 }
174 }
175
176 #ifdef __USE_PROTOS
177 int main(int argc, char *argv[])
178 #else
179 int main(argc, argv)
180 int argc;
181 char *argv[];
182 #endif
183 {
184 init();
185 fprintf(stderr, "%s Version %s 1989-2001\n", &(program[0]),
186 &(version[0]));
187 if ( argc == 1 )
188 {
189 Opt *p = options;
190 fprintf(stderr, "%s [options] f1 f2 ... fn\n",argv[0]);
191 while ( *(p->option) != '*' )
192 {
193 fprintf(stderr, "\t%s %s\t%s\n",
194 p->option,
195 (p->arg)?"___":" ",
196 p->descr);
197 p++;
198 }
199 }else{
200 ProcessArgs(argc-1, &(argv[1]), options);
201 if (interactive && gen_cpp) {
202 fprintf(stderr,"\n");
203 /*** MR21a This statement is wrong ! ***/
204 #if 0
205 *** fprintf(stderr,"Interactive lexer option (\"-i\") has no effect when in C++ mode\n");
206 *** fprintf(stderr,"because of extra buffering provided by ANTLRTokenBuffer class.\n");
207 *** fprintf(stderr,"\n");
208 #endif
209 }
210 input_stream = read_stream(file_str[0]);
211 if (input_stream) {
212 /* don't overwrite unless input okay */
213 if ( gen_cpp ) {
214 output_stream = write_stream(ClassName(CPP_FILE_SUFFIX));
215 if ( file_str[1]!=NULL ) {
216 warning("output file implicit in C++ mode; ignored...",0);
217 }
218 class_stream = write_stream(ClassName(".h"));
219 mode_stream = class_stream;
220 }
221 else {
222 output_stream = write_stream(file_str[1]);
223 mode_stream = write_stream(mode_file);
224 }
225 }
226 /* make sure that error reporting routines in grammar
227 know what the file really is */
228 /* make sure that reading and writing somewhere */
229 if (input_stream && output_stream && mode_stream){
230 ANTLR(grammar(), input_stream);
231 }
232 p_class_def2(); /* MR1 */
233 }
234 if ( output_stream!=NULL ) fclose(output_stream);
235 if ( !gen_cpp && mode_stream!=NULL ) fclose(mode_stream);
236 if ( class_stream!=NULL ) fclose(class_stream);
237 exit(PCCTS_EXIT_SUCCESS);
238 return 0; /* get rid of warning message MR1 */
239 }
240
241 /* initialize all the variables */
242 void
243 #ifdef __USE_PROTOS
244 init(void)
245 #else
246 init()
247 #endif
248 {
249 register int i;
250
251 #ifdef SPECIAL_INITS
252 special_inits(); /* MR1 */
253 #endif
254 used_chars = empty;
255 used_classes = empty;
256 /* make the valid character set */
257 normal_chars = empty;
258 /* NOTE: MIN_CHAR is EOF */
259 /* NOTE: EOF is not quite a valid char, it is special. Skip it*/
260 for (i = 1; i<CHAR_RANGE; ++i){
261 set_orel(i,&normal_chars);
262 }
263 make_nfa_model_node();
264 clear_hash();
265 /* NOTE: need to set this flag before the lexer starts getting */
266 /* tokens */
267 func_action = FALSE;
268 }
269
270 /* stuff that needs to be reset when a new automaton is being built */
271 void
272 #ifdef __USE_PROTOS
273 new_automaton_mode(void) /* MR1 */
274 #else
275 new_automaton_mode() /* MR1 */
276 #endif
277 {
278 set_free(used_chars);
279 clear_hash();
280 }
+0
-37
contrib/pccts/dlg/makefile.VMS less more
0 $! File: MAKE.COM - Makefile for DLG 1.33
1 $!
2 $! History:
3 $! ---------
4 $! 20-Mar-1992 Fred Scholldorf Hacked together for VAX/VMS.
5 $! 24-Mar-1992 Fred Scholldorf LINK against VAXCRTL sharable library.
6 $! 24-Aug-1993 Fred Scholldorf Upgrade for PCCTS V1.10.
7 $! 27-Jan-1998 J.F. Pieronne Upgrade for DECC
8 $!
9 $ set noon !Don't stop on errors.
10 $!
11 $ if P1 .eqs. "LINK" then goto relink
12 $!
13 $ define pccts_h "[-.h]"
14 $ define support_set "[-.support.set]"
15 $!
16 $ delete/nolog *.obj;* !Get rid of existing .OBJ files.
17 $!
18 $ options = "/INCLUDE=(pccts_h,support_set)/define=(USER_ZZSYN)"
19 $ CC 'options' dlg_a
20 $ CC 'options' dlg_p
21 $ CC 'options' err
22 $ CC 'options' main
23 $ CC 'options' [-.support.set]set
24 $ CC 'options' support
25 $ CC 'options' output
26 $ CC 'options' relabel
27 $ CC 'options' automata
28 $!
29 $relink:
30 $ LINK /EXE=dlg.exe -
31 dlg_a,dlg_p,err,main, -
32 set,support,output, -
33 relabel,automata, -
34 sys$input:/options
35 ! sys$share:vaxcrtl.exe/share
36 $ EXIT
+0
-63
contrib/pccts/dlg/makefile1 less more
0 #
1 # Makefile for DLG 1.33
2 # Terence Parr
3 # Purdue University, U of MN, Parr Research Corporation
4 # 1989-1994
5 #
6 # Ported to IBM C-Set/2 and Microsoft 6.0 by
7 # Ed Harfmann
8 # Micro Data Base Systems
9 # Lafayette, Indiana
10 #
11 SET=../support/set
12 PCCTS_H=../h
13
14 ##
15 ## Uncomment the appropriate section to build
16 ##
17
18
19 #
20 # UNIX
21 #
22 CC=cc
23 ANTLR=../bin/antlr
24 DLG=../bin/dlg
25 ANSI=-ansi
26 CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) $(ANSI) -DZZLEXBUFSIZE=32000
27 OBJ_EXT=o
28 OUT_OBJ = -o
29 OBJ = dlg_p.o dlg_a.o main.o err.o set.o support.o output.o \
30 relabel.o automata.o
31
32 dlg : $(OBJ) $(SRC)
33 $(CC) $(CFLAGS) -o dlg $(OBJ)
34 mv dlg ../bin
35
36 SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \
37 relabel.c automata.c
38
39 dlg_p.c parser.dlg err.c tokens.h : dlg_p.g
40 $(ANTLR) dlg_p.g
41
42 dlg_a.c mode.h : parser.dlg
43 $(DLG) -C2 parser.dlg dlg_a.c
44
45 dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h
46 $(CC) $(CFLAGS) -c dlg_p.c
47
48 dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h
49 $(CC) $(CFLAGS) -c dlg_a.c
50
51 main.$(OBJ_EXT) : main.c dlg.h
52 $(CC) $(CFLAGS) -c main.c
53
54 set.$(OBJ_EXT) : $(SET)/set.c
55 $(CC) -c $(CFLAGS) $(SET)/set.c
56
57 lint:
58 lint *.c
59
60 #clean up all the intermediate files
61 clean:
62 rm -f *.$(OBJ_EXT) core
+0
-4
contrib/pccts/dlg/mode.h less more
0 #define START 0
1 #define ACT 1
2 #define ACTION_COMMENTS 2
3 #define ACTION_CPP_COMMENTS 3
+0
-850
contrib/pccts/dlg/output.c less more
0 /* output.c, output generator for dlg
1 *
2 * Output Notes:
3 *
4 * DfaStates == number of dfa nodes in automaton (just a #define)
5 * DfaState == type large enough to index every node in automaton
6 * <256 unsigned char, <65536 unsigned short, etc.
7 *
8 * Thus, the elements in each of the automaton states (st%d) are type DfaState
9 * and are size appropriately, since they must be able to index the next
10 * automaton state.
11 *
12 * dfa[] == a linear array that points to all the automaton states (st%d)
13 * (dfa_base[] should be the same, but isn't right now)
14 *
15 * accepts[] == Taking a closer look at this one, it probably shouldn't be type
16 * DfaState because there is no real requirement that the number of
17 * accepts states is less than the number of dfa state. However, if
18 * the number of accept states was more than the number of DFA states
19 * then the lexical specification would be really ambiguous.
20 *
21 * Another note. Is that is should be possible to fold accepts[] and
22 * actions[] together. If this is done, I would suggest get rid of
23 * accept[] and make actions[] have an entry for each state (st%d) in
24 * the automaton.
25 *
26 * dfa_base[] == starting location for each lexical mode. This should be
27 * Dfastate type (but isn't right now), since it points to the states
28 * in the automaton.
29 *
30 * dfa_class_no[] == indicates the number of columns each lexical mode has.
31 *
32 * b_class_no[] == pointer to the start of the translation array used to
33 * convert from input character to character class. This could cause
34 * problems if there are more than 256 classes
35 *
36 * shift%d[] == the actual translation arrays that convert the input character
37 * into the character class. These will have to change if there are
38 * more than 256 character classes.
39 *
40 * SOFTWARE RIGHTS
41 *
42 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
43 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
44 * company may do whatever they wish with source code distributed with
45 * PCCTS or the code generated by PCCTS, including the incorporation of
46 * PCCTS, or its output, into commerical software.
47 *
48 * We encourage users to develop software with PCCTS. However, we do ask
49 * that credit is given to us for developing PCCTS. By "credit",
50 * we mean that if you incorporate our source code into one of your
51 * programs (commercial product, research project, or otherwise) that you
52 * acknowledge this fact somewhere in the documentation, research report,
53 * etc... If you like PCCTS and have developed a nice tool with the
54 * output, please mention that you developed it using PCCTS. In
55 * addition, we ask that this header remain intact in our source code.
56 * As long as these guidelines are kept, we expect to continue enhancing
57 * this system and expect to make other tools available as they are
58 * completed.
59 *
60 * DLG 1.33
61 * Will Cohen
62 * With mods by Terence Parr; AHPCRC, University of Minnesota
63 * 1989-2001
64 */
65
66 #include <stdio.h>
67 #include <string.h>
68 #include "dlg.h"
69 #ifdef MEMCHK
70 #include "trax.h"
71 #else
72 #ifdef __STDC__
73 #include <stdlib.h>
74 #else
75 #include <malloc.h>
76 #endif /* __STDC__ */
77 #endif
78
79 static char *mode_name[MAX_MODES];
80 static int mode_number[MAX_MODES];
81 static int cur_mode=0;
82
83 int operation_no = 0; /* used to mark nodes so that infinite loops avoided */
84 int dfa_basep[MAX_MODES]; /* start of each group of states */
85 int dfa_class_nop[MAX_MODES]; /* number of elements in each group of states*/
86
87 int gen_ansi = FALSE; /* allows ansi code to be generated */
88
89 FILE *input_stream; /* where to read description from */
90 FILE *output_stream; /* where to put the output */
91 FILE *mode_stream; /* where to put the mode.h stuff */
92 FILE *class_stream; /* where to put the scan.h stuff (if gen_cpp) */
93
94 /* NOTE: This section is MACHINE DEPENDENT */
95 #define DIF_SIZE 4
96 #if defined(PC) && !defined(PC32)
97 unsigned long typesize[DIF_SIZE] = { 0x7f, 0x7fff, 0x7ffful, 0x7ffffffful }; /* MR20 */
98 char t0[] = "unsigned char";
99 char t1[] = "unsigned short";
100 char t2[] = "unsigned int";
101 char t3[] = "unsigned long";
102 char *typevar[DIF_SIZE] = { t0, t1, t2, t3};
103 #else
104 unsigned long typesize[DIF_SIZE] = { 0x7f, 0x7fff, 0x7ffffffful, 0x7ffffffful }; /* MR20 */
105 char t0[] = "unsigned char";
106 char t1[] = "unsigned short";
107 char t2[] = "unsigned int";
108 char t3[] = "unsigned long";
109 char *typevar[DIF_SIZE] = { t0, t1, t2, t3};
110 #endif
111
112 /* Added by TJP August 1994 */
113 /* Take in MyLexer and return MyLexer_h */
114
115 static char *
116 #ifdef __USE_PROTOS
117 gate_symbol(char *name)
118 #else
119 gate_symbol(name)
120 char *name;
121 #endif
122 {
123 static char buf[100];
124 sprintf(buf, "%s_h", name);
125 return buf;
126 }
127
128 /* Added by TJP August 1994 */
129 static char *
130 #ifdef __USE_PROTOS
131 mystrdup(char *s)
132 #else
133 mystrdup(s)
134 char *s;
135 #endif
136 {
137 char *p = (char *)malloc(strlen(s)+1);
138 strcpy(p, s);
139 return p;
140 }
141
142 #ifdef __USE_PROTOS
143 void p_class_hdr(void)
144 #else
145 void p_class_hdr()
146 #endif
147 {
148 if ( class_stream == NULL ) return;
149 fprintf(class_stream, "#ifndef %s\n", gate_symbol(ClassName("")));
150 fprintf(class_stream, "#define %s\n", gate_symbol(ClassName("")));
151 fprintf(class_stream, "/*\n");
152 fprintf(class_stream, " * D L G L e x e r C l a s s D e f i n i t i o n\n");
153 fprintf(class_stream, " *\n");
154 fprintf(class_stream, " * Generated from:");
155 fprintf(class_stream, " %s", file_str[0]);
156 fprintf(class_stream, "\n");
157 fprintf(class_stream, " *\n");
158 fprintf(class_stream, " * 1989-2001 by Will Cohen, Terence Parr, and Hank Dietz\n");
159 fprintf(class_stream, " * Purdue University Electrical Engineering\n");
160 fprintf(class_stream, " * DLG Version %s\n", version);
161 fprintf(class_stream, " */\n\n");
162 fprintf(class_stream, "\n");
163 fprintf(class_stream, "#include \"%s\"\n", DLEXERBASE_H);
164 }
165
166 /* MR1 */
167 /* MR1 16-Apr-97 Split printing of class header up into several parts */
168 /* MR1 so that #lexprefix <<...>>and #lexmember <<...>> */
169 /* MR1 can be inserted in the appropriate spots */
170 /* MR1 */
171
172 #ifdef __USE_PROTOS
173 void p_class_def1(void)
174 #else
175 void p_class_def1()
176 #endif
177 {
178 if ( class_stream == NULL ) return;
179 fprintf(class_stream, "\nclass %s : public DLGLexerBase {\n", ClassName(""));
180 fprintf(class_stream, "public:\n");
181 }
182
183 #ifdef __USE_PROTOS
184 void p_class_def2(void)
185 #else
186 void p_class_def2()
187 #endif
188 {
189 int i, m;
190 if ( class_stream == NULL ) return;
191 fprintf(class_stream, "public:\n");
192 fprintf(class_stream, "\tstatic const int MAX_MODE;\n");
193 fprintf(class_stream, "\tstatic const int DfaStates;\n");
194 for (i=0; i<cur_mode; i++) {
195 fprintf(class_stream, "\tstatic const int %s;\n", mode_name[i]);
196 }
197
198 fprintf(class_stream, "\ttypedef %s DfaState;\n\n", minsize(dfa_allocated));
199 fprintf(class_stream, "\t%s(DLGInputStream *in,\n",ClassName(""));
200 fprintf(class_stream, "\t\tunsigned bufsize=2000)\n");
201 fprintf(class_stream, "\t\t: DLGLexerBase(in, bufsize, %d)\n", interactive);
202 fprintf(class_stream, "\t{\n");
203 fprintf(class_stream, "\t;\n");
204 fprintf(class_stream, "\t}\n");
205 fprintf(class_stream, "\tvoid mode(int);\n");
206 fprintf(class_stream, "\tANTLRTokenType nextTokenType(void);\n");
207 fprintf(class_stream, "\tvoid advance(void);\n");
208 fprintf(class_stream, "protected:\n");
209 for (i=1; i<=action_no; ++i) {
210 fprintf(class_stream, "\tANTLRTokenType act%d();\n", i);
211 }
212
213 for(m=0; m<(mode_counter-1); ++m){
214 for(i=dfa_basep[m]; i<dfa_basep[m+1]; ++i)
215 fprintf(class_stream, "\tstatic DfaState st%d[%d];\n", i-1, dfa_class_nop[m]+1);
216 }
217 for(i=dfa_basep[m]; i<=dfa_allocated; ++i)
218 fprintf(class_stream, "\tstatic DfaState st%d[%d];\n", i-1, dfa_class_nop[m]+1);
219
220 fprintf(class_stream, "\tstatic DfaState *dfa[%d];\n", dfa_allocated);
221 fprintf(class_stream, "\tstatic DfaState dfa_base[];\n");
222 /* fprintf(class_stream, "\tstatic int dfa_base_no[];\n"); */
223 fprintf(class_stream, "\tstatic unsigned char *b_class_no[];\n");
224 fprintf(class_stream, "\tstatic DfaState accepts[%d];\n",dfa_allocated+1);
225 fprintf(class_stream, "\tstatic DLGChar alternatives[%d];\n",dfa_allocated+1);
226 /* WARNING: should be ANTLRTokenType for action table, but g++ 2.5.6 is hosed */
227 fprintf(class_stream, "\tstatic ANTLRTokenType (%s::*actions[%d])();\n", ClassName(""), action_no+1);
228 for(m=0; m<mode_counter; ++m) {
229 fprintf(class_stream, "\tstatic unsigned char shift%d[%d];\n",
230 m, CHAR_RANGE);
231 }
232 if (comp_level)
233 fprintf(class_stream, "\tint ZZSHIFT(int c) { return b_class_no[automaton][1+c]; }\n");
234 else
235 fprintf(class_stream, "\tint ZZSHIFT(int c) { return 1+c; }\n");
236
237 /* MR1 */
238 /* MR1 11-APr-97 Kludge to allow inclusion of user-defined code in */
239 /* MR1 DLGLexer class header */
240 /* MR1 Deprecated in favor of 133MR1 addition #lexmember <<>> */
241 /* MR1 */
242 /* MR1 */ fprintf(class_stream,"//\n");
243 /* MR1 */ fprintf(class_stream,
244 /* MR1 */ "// 133MR1 Deprecated feature to allow inclusion of ");
245 /* MR1 */ fprintf(class_stream,
246 /* MR1 */ "user-defined code in DLG class header\n");
247 /* MR1 */ fprintf(class_stream,"//\n");
248 /* MR1 */
249 /* MR1 */ fprintf(class_stream,"#ifdef DLGLexerIncludeFile\n");
250 /* MR1 */ fprintf(class_stream,"#include DLGLexerIncludeFile\n");
251 /* MR1 */ fprintf(class_stream,"#endif\n");
252
253 fprintf(class_stream, "};\n");
254
255 fprintf(class_stream, "typedef ANTLRTokenType (%s::*Ptr%sMemberFunc)();\n",
256 ClassName(""), ClassName(""));
257
258 fprintf(class_stream, "#endif\n");
259 }
260
261 /* generate required header on output */
262
263 #ifdef __USE_PROTOS
264 void p_head(void)
265 #else
266 void p_head()
267 #endif
268 {
269 fprintf(OUT, "/*\n");
270 fprintf(OUT, " * D L G tables\n");
271 fprintf(OUT, " *\n");
272 fprintf(OUT, " * Generated from:");
273 fprintf(OUT, " %s", file_str[0]);
274 fprintf(OUT, "\n");
275 fprintf(OUT, " *\n");
276 fprintf(OUT, " * 1989-2001 by Will Cohen, Terence Parr, and Hank Dietz\n");
277 fprintf(OUT, " * Purdue University Electrical Engineering\n");
278 fprintf(OUT, " * DLG Version %s\n", version);
279 fprintf(OUT, " */\n\n");
280 if ( gen_cpp) fprintf(OUT, "#include \"pcctscfg.h\"\n");
281 if ( gen_cpp ) fprintf(OUT, "#include \"pccts_stdio.h\"\n");
282 if ( !gen_cpp ) fprintf(OUT, "#include \"%s\"\n\n", mode_file);
283 fprintf(OUT,"\n");
284 }
285
286 #ifdef __USE_PROTOS
287 void p_includes(void)
288 #else
289 void p_includes()
290 #endif
291 {
292 fprintf(OUT, "#include \"%s\"\n", APARSER_H);
293 fprintf(OUT, "#include \"%s\"\n", DLEXERBASE_H);
294 fprintf(OUT, "#include \"%s\"\n", ClassName(".h"));
295 }
296
297 /* generate code to tie up any loose ends */
298
299 #ifdef __USE_PROTOS
300 void p_tail(void) /* MR1 */
301 #else
302 void p_tail() /* MR1 */
303 #endif
304 {
305 if ( gen_cpp ) {
306 if ( strcmp(ClassName(""), DEFAULT_CLASSNAME)!=0 )
307 fprintf(OUT, "#define DLGLexer %s\n", ClassName(""));
308 fprintf(OUT, "#include \"%s\"\n", DLEXER_H); /* MR23 Rename DLexer.cpp to DLexer.h */
309 return;
310 }
311 fprintf(OUT, "\n");
312 fprintf(OUT, "\n");
313 if (comp_level)
314 fprintf(OUT, "#define ZZSHIFT(c) (b_class_no[zzauto][1+c])\n");
315 else
316 fprintf(OUT, "#define ZZSHIFT(c) (1+c)\n");
317 if ( !gen_cpp ) fprintf(OUT, "#define MAX_MODE %d\n",mode_counter);
318 fprintf(OUT, "#include \"dlgauto.h\"\n");
319 }
320
321
322 /* output the table of DFA for general use */
323
324 #ifdef __USE_PROTOS
325 void p_tables()
326 #else
327 void p_tables()
328 #endif
329 {
330 if ( !gen_cpp ) {
331 fprintf(OUT, "#define DfaStates\t%d\n", dfa_allocated);
332 fprintf(OUT, "typedef %s DfaState;\n\n", minsize(dfa_allocated));
333 }
334
335 if ( gen_cpp ) {
336 int i;
337 fprintf(OUT, "\n");
338 fprintf(OUT, "const int %s::MAX_MODE=%d;\n",
339 ClassName(""),
340 mode_counter);
341 fprintf(OUT, "const int %s::DfaStates=%d;\n",
342 ClassName(""),
343 dfa_allocated);
344 for (i=0; i<cur_mode; i++) {
345 fprintf(OUT, "const int %s::%s=%d;\n",
346 ClassName(""), mode_name[i], mode_number[i]);
347 }
348 fprintf(OUT, "\n");
349 }
350
351 p_node_table();
352 p_dfa_table();
353 p_accept_table();
354 p_action_table();
355 p_base_table();
356 p_class_table();
357 if (comp_level)
358 p_bshift_table();
359 if (interactive || gen_cpp )
360 p_alternative_table();
361 }
362
363
364 /* figures out the smallest variable type that will hold the transitions
365 */
366
367 #ifdef __USE_PROTOS
368 char *minsize(int elements)
369 #else
370 char *minsize(elements)
371 int elements;
372 #endif
373 {
374 int i = 0;
375
376 while ((unsigned long) elements > typesize[i]) /* MR20 */
377 ++i;
378 return typevar[i];
379 }
380
381
382 #ifdef __USE_PROTOS
383 void p_node_table(void)
384 #else
385 void p_node_table()
386 #endif
387 {
388 register int i;
389 register int m = 0;
390
391 for(m=0; m<(mode_counter-1); ++m){
392 for(i=dfa_basep[m]; i<dfa_basep[m+1]; ++i)
393 p_single_node(i,dfa_class_nop[m]);
394 }
395 for(i=dfa_basep[m]; i<=dfa_allocated; ++i)
396 p_single_node(i,dfa_class_nop[m]);
397 }
398
399
400 #ifdef __USE_PROTOS
401 void p_single_node(int i,int classes)
402 #else
403 void p_single_node(i,classes)
404 int i,classes;
405 #endif
406 {
407 register int j;
408 register int trans, items_on_line;
409
410 #if 1
411 /* extra state (classes+1) for invalid characters */
412 fprintf(OUT, "%sDfaState %sst%d[%d] = {\n ",
413 gen_cpp?ClassName("::"):"static ",
414 gen_cpp?ClassName("::"):"",(i-1), (classes+1));
415 #else
416 fprintf(OUT, "static DfaState st%d[%d] = {\n ", (i-1), classes);
417 #endif
418 items_on_line = MAX_ON_LINE;
419 for(j=0; j<classes; ++j){
420 DAWDLE;
421 trans = DFA(i)->trans[j];
422 if (trans == NIL_INDEX)
423 trans = dfa_allocated+1;
424 /* all of DFA moved down one in array */
425 fprintf(OUT, "%d", trans-1);
426 fprintf(OUT, ", ");
427 if (!(--items_on_line)){
428 fprintf(OUT, "\n ");
429 items_on_line = MAX_ON_LINE;
430 }
431 }
432 #if 1
433 /* put in jump to error state */
434 fprintf(OUT, "%d\n};\n\n", dfa_allocated);
435 #else
436 fprintf(OUT, "\n};\n\n");
437 #endif
438 }
439
440
441 #ifdef __USE_PROTOS
442 void p_dfa_table(void)
443 #else
444 void p_dfa_table()
445 #endif
446 {
447 register int i;
448
449 fprintf(OUT, "\n%sDfaState *%sdfa[%d] = {\n",
450 gen_cpp?ClassName("::"):"",gen_cpp?ClassName("::"):"", dfa_allocated);
451 for (i=0; i<(dfa_allocated-1); ++i){
452 fprintf(OUT, "\tst%d,\n", i);
453 }
454 fprintf(OUT, "\tst%d\n", i);
455 fprintf(OUT, "};\n\n");
456 }
457
458
459 #ifdef __USE_PROTOS
460 void p_accept_table(void)
461 #else
462 void p_accept_table()
463 #endif
464 {
465 register int i = 1;
466 register int items_on_line = 0;
467 int true_interactive = TRUE;
468
469 /* make sure element for one past (zzerraction) -WEC 12/16/92 */
470 fprintf(OUT,"\n%sDfaState %saccepts[%d] = {\n ",
471 gen_cpp?ClassName("::"):"",
472 gen_cpp?ClassName("::"):"",
473 dfa_allocated+1);
474 /* don't do anything if no dfa nodes */
475 if (i>dfa_allocated) goto skip_accepts;
476 for (;;) {
477 int accept=0; /* MR14a - Manuel Kessler (mlkessle@cip.physik.uni-wuerzburg.de) */
478 set accept_set;
479 set nfa_states;
480 unsigned int *t, *nfa_i;
481 unsigned int *q, *regular_expr;
482
483 accept_set = empty;
484 nfa_states = DFA(i)->nfa_states;
485 t = nfa_i = set_pdq(nfa_states);
486 /* NOTE: picks lowest accept because accepts monotonic */
487 /* with respect to nfa node numbers and set_pdq */
488 /* returns in that order */
489 while((*nfa_i != nil) && (!(accept = NFA(*nfa_i)->accept))){
490 nfa_i++;
491 }
492
493 /* figure out if more than one accept state there */
494 if (warn_ambig ){
495 set_orel(accept, &accept_set);
496 while(*nfa_i != nil){
497 set_orel(NFA(*nfa_i)->accept, &accept_set);
498 nfa_i++;
499 }
500 /* remove error action from consideration */
501 set_rm(0, accept_set);
502
503 if( set_deg(accept_set)>1){
504 fprintf(stderr, "dlg warning: ambiguous regular expression ");
505 q = regular_expr = set_pdq(accept_set);
506 while(*regular_expr != nil){
507 fprintf(stderr," %d ", *regular_expr);
508 ++regular_expr;
509 }
510 fprintf(stderr, "\n");
511 free(q);
512 }
513 }
514
515 if ((DFA(i)->alternatives) && (accept != 0)){
516 true_interactive = FALSE;
517 }
518 fprintf(OUT, "%d, ", accept);
519
520 /* free up memory before we "break" below -ATG 4/6/95 */
521 free(t);
522 set_free(accept_set);
523
524 if ((++i)>dfa_allocated)
525 break;
526 if ((++items_on_line)>=MAX_ON_LINE){
527 fprintf(OUT,"\n ");
528 items_on_line = 0;
529 }
530 /*
531 free(t);
532 set_free(accept_set);
533 */
534 }
535 /* make sure element for one past (zzerraction) -WEC 12/16/92 */
536 skip_accepts:
537 fprintf(OUT, "0\n};\n\n");
538 }
539
540
541 #ifdef __USE_PROTOS
542 void p_action_table(void)
543 #else
544 void p_action_table()
545 #endif
546 {
547 register int i;
548 char* theClassName = ClassName("");
549
550 if ( gen_cpp )
551 fprintf(OUT, "Ptr%sMemberFunc %s::actions[%d] = {\n", theClassName,
552 theClassName, action_no+1);
553 else
554 fprintf(OUT, "void (*actions[%d])() = {\n", action_no+1);
555 if ( gen_cpp )
556 /* fprintf(OUT, "\t(Ptr%sMemberFunc)&%s::erraction,\n", theClassName, theClassName);*/
557 fprintf(OUT, "\t&%s::erraction,\n", theClassName);
558 else
559 fprintf(OUT, "\tzzerraction,\n");
560 for (i=1; i<action_no; ++i) {
561 if ( gen_cpp )
562 /* fprintf(OUT,"\t(Ptr%sMemberFunc)&%s::act%d,\n", theClassName, theClassName, i);*/
563 fprintf(OUT,"\t&%s::act%d,\n", theClassName, i);
564 else
565 fprintf(OUT,"\tact%d,\n", i);
566 DAWDLE;
567 }
568 if ( gen_cpp )
569 /* fprintf(OUT,"\t(Ptr%sMemberFunc)&%s::act%d\n", theClassName, theClassName, i);*/
570 fprintf(OUT,"\t&%s::act%d\n", theClassName, i);
571 else
572 fprintf(OUT,"\tact%d\n", i);
573 fprintf(OUT, "};\n\n");
574 }
575
576
577 #ifdef __USE_PROTOS
578 void p_shift_table(int m) /* MR1 */
579 #else
580 void p_shift_table(m) /* MR1 */
581 int m;
582 #endif
583 {
584 register int i = 0, j;
585 register int items_on_line = 0;
586
587 fprintf(OUT, "%s unsigned char %sshift%d[%d] = {\n ",
588 gen_cpp?"":"static",
589 gen_cpp?ClassName("::"):"", m, CHAR_RANGE);
590 for (;;) {
591 /* find which partition character i is in */
592 for (j=0; j<dfa_class_nop[mode_counter]; ++j){
593 if (set_el(i,class_sets[j]))
594 break;
595 }
596 fprintf(OUT,"%d",j);
597 if ((++i)>=CHAR_RANGE)
598 break;
599 fprintf(OUT,", ");
600 if ((++items_on_line)>=MAX_ON_LINE){
601 fprintf(OUT,"\n ");
602 items_on_line = 0;
603 }
604 }
605 fprintf(OUT, "\n};\n\n");
606 }
607
608
609 #ifdef __USE_PROTOS
610 void p_base_table(void)
611 #else
612 void p_base_table()
613 #endif
614 {
615 register int m;
616
617 fprintf(OUT, "%sDfaState %sdfa_base[] = {\n",
618 gen_cpp?ClassName("::"):"static ",
619 gen_cpp?ClassName("::"):"");
620 for(m=0; m<(mode_counter-1); ++m)
621 fprintf(OUT, "\t%d,\n", dfa_basep[m]-1);
622 fprintf(OUT, "\t%d\n};\n\n", dfa_basep[m]-1);
623 }
624
625
626 #ifdef __USE_PROTOS
627 void p_class_table(void) /* MR1 */
628 #else
629 void p_class_table() /* MR1 */
630 #endif
631 {
632 #if 0
633 register int m;
634
635 fprintf(OUT,"%s int %sdfa_class_no[] = {\n",
636 gen_cpp?"":"static",
637 gen_cpp?ClassName("::"):"");
638 for(m=0; m<(mode_counter-1); ++m)
639 fprintf(OUT,"\t%d,\n", dfa_class_nop[m]);
640 fprintf(OUT,"\t%d\n};\n\n", dfa_class_nop[m]);
641 #endif
642 }
643
644
645 #ifdef __USE_PROTOS
646 void p_bshift_table(void) /* MR1 */
647 #else
648 void p_bshift_table() /* MR1 */
649 #endif
650 {
651 register int m;
652
653 fprintf(OUT,"%s unsigned char *%sb_class_no[] = {\n",
654 gen_cpp?"":"static",
655 gen_cpp?ClassName("::"):"");
656 for(m=0; m<(mode_counter-1); ++m)
657 fprintf(OUT, "\tshift%d,\n", m);
658 fprintf(OUT, "\tshift%d\n};\n\n", m);
659 }
660
661
662 #ifdef __USE_PROTOS
663 void p_alternative_table(void) /* MR1 */
664 #else
665 void p_alternative_table() /* MR1 */
666 #endif
667 {
668 register int i;
669
670 if ( !gen_cpp ) fprintf(OUT, "#define ZZINTERACTIVE\n\n");
671 if ( gen_cpp )
672 fprintf(OUT, "DLGChar %salternatives[%d] = {\n", /* mr23 vhs %sDfaStates+1 */
673 ClassName("::"),
674 dfa_allocated+1); /* vhs ClassName("::")); */
675 else
676 fprintf(OUT, "static %s zzalternatives[DfaStates+1] = {\n",
677 minsize(dfa_allocated));
678
679 for(i=1; i<=dfa_allocated; ++i)
680 fprintf(OUT, "\t%d,\n", DFA(i)->alternatives);
681 fprintf(OUT, "/* must have 0 for zzalternatives[DfaStates] */\n");
682 fprintf(OUT, "\t0\n};\n\n");
683 }
684
685
686 #ifdef __USE_PROTOS
687 void p_mode_def(char *s,int m) /* MR1 */
688 #else
689 void p_mode_def(s,m) /* MR1 */
690 char *s;
691 int m;
692 #endif
693 {
694 if ( gen_cpp )
695 {
696 mode_name[cur_mode] = mystrdup(s);
697 mode_number[cur_mode] = m;
698 cur_mode++;
699 }
700 else
701 fprintf(mode_stream, "#define %s %d\n", s, m);
702 }
703
704 #ifdef __USE_PROTOS
705 char * ClassName(char *suffix)
706 #else
707 char * ClassName(suffix)
708 char *suffix;
709 #endif
710 {
711 static char buf[200];
712 extern char *class_name;
713
714 sprintf(buf, "%s%s", class_name, suffix);
715 return buf;
716 }
717
718 #ifdef DEBUG
719
720 /* print out a particular nfa node that is pointed to by p */
721
722 #ifdef __USE_PROTOS
723 void p_nfa_node(nfa_node *p)
724 #else
725 void p_nfa_node(p)
726 nfa_node *p;
727 #endif
728 {
729 register nfa_node *t;
730
731 if (p != NIL_INDEX){
732 printf("NFA state : %d\naccept state : %d\n",
733 NFA_NO(p),p->accept);
734 if (p->trans[0] != NIL_INDEX){
735 printf("trans[0] => %d on ", NFA_NO(p->trans[0]));
736 p_set(p->label);
737 printf("\n");
738 }
739 else
740 printf("trans[0] => nil\n");
741 if (p->trans[1] != NIL_INDEX)
742 printf("trans[1] => %d on epsilon\n",
743 NFA_NO(p->trans[1]));
744 else
745 printf("trans[1] => nil\n");
746 printf("\n");
747 }
748 }
749 #endif
750
751 #ifdef DEBUG
752
753 /* code to print out special structures when using a debugger */
754
755 #ifdef __USE_PROTOS
756 void p_nfa(p)
757 #else
758 void p_nfa(nfa_node *p)
759 nfa_node *p; /* state number also index into array */
760 #endif
761 {
762 /* each node has a marker on it so it only gets printed once */
763
764 operation_no++; /* get new number */
765 s_p_nfa(p);
766 }
767
768 #ifdef __USE_PROTOS
769 void s_p_nfa(nfa_node *p)
770 #else
771 void s_p_nfa(p)
772 nfa_node *p; /* state number also index into array */
773 #endif
774 {
775 if ((p != NIL_INDEX) && (p->nfa_set != operation_no)){
776 /* so it is only printed once */
777 p->nfa_set = operation_no;
778 p_nfa_node(p);
779 s_p_nfa(p->trans[0]);
780 s_p_nfa(p->trans[1]);
781 }
782 }
783
784 #ifdef __USE_PROTOS
785 void p_dfa_node(dfa_node *p)
786 #else
787 void p_dfa_node(p)
788 dfa_node *p;
789 #endif
790 {
791 int i;
792
793 if (p != NIL_INDEX){
794 printf("DFA state :%d\n",NFA_NO(p));
795 if (p->done)
796 printf("done\n");
797 else
798 printf("undone\n");
799 printf("from nfa states : ");
800 p_set(p->nfa_states);
801 printf("\n");
802 /* NOTE: trans arcs stored as ints rather than pointer*/
803 for (i=0; i<class_no; i++){
804 printf("%d ",p->trans[i]);
805 }
806 printf("\n\n");
807 }
808 }
809
810 #ifdef __USE_PROTOS
811 void p_dfa(void)
812 #else
813 void p_dfa()
814 #endif
815 {
816 /* prints out all the dfa nodes actually allocated */
817
818 int i;
819
820 for (i = 1; i<=dfa_allocated; i++)
821 p_dfa_node(NFA(i));
822 }
823
824
825 /* print out numbers in the set label */
826
827 #ifdef __USE_PROTOS
828 void p_set(set label)
829 #else
830 void p_set(label)
831 set label;
832 #endif
833 {
834 unsigned *t, *e;
835
836 if (set_nil(label)){
837 printf("epsilon\n");
838 }else{
839 t = e = set_pdq(label);
840 while(*e != nil){
841 printf("%d ", (*e+MIN_CHAR));
842 e++;
843 }
844 printf("\n");
845 free(t);
846 }
847
848 }
849 #endif
+0
-398
contrib/pccts/dlg/parser.dlg less more
0 <<
1 /* parser.dlg -- DLG Description of scanner
2 *
3 * Generated from: ./dlg_p.g
4 *
5 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
6 * Purdue University Electrical Engineering
7 * With AHPCRC, University of Minnesota
8 * ANTLR Version 1.33MR33
9 */
10
11 #define ANTLR_VERSION 13333
12 #include "pcctscfg.h"
13 #include "pccts_stdio.h"
14
15 #include <ctype.h>
16 #include "dlg.h"
17 #include "antlr.h"
18 #include "tokens.h"
19 #include "dlgdef.h"
20 LOOKAHEAD
21
22 void
23 #ifdef __USE_PROTOS
24 zzerraction(void)
25 #else
26 zzerraction()
27 #endif
28 {
29 (*zzerr)("invalid token");
30 zzadvance();
31 zzskip();
32 }
33 >>
34
35 <<%%lexaction
36
37 int func_action; /* should actions be turned into functions?*/
38 int lex_mode_counter = 0; /* keeps track of the number of %%names */
39 /* MR1 */
40 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
41 /* MR1 via <<%%lexmember...>> */
42 /* MR1 */
43 int lexMember = 0; /* <<%%lexmemeber ...>> MR1 */
44 int lexAction = 0; /* <<%%lexaction ...>> MR1 */
45 int parserClass = 0; /* <<%%parserclass ...>> MR1 */
46 int lexPrefix = 0; /* <<%%lexprefix ...>> MR1 */
47 char theClassName[100]; /* MR11 */
48 char *pClassName=theClassName; /* MR11 */
49 int firstLexMember=1; /* MR1 */
50
51 #ifdef __USE_PROTOS
52 void xxputc(int c) { /* MR1 */
53 #else
54 void xxputc(c) /* MR1 */
55 int c; /* MR1 */
56 { /* MR1 */
57 #endif
58 if (parserClass) { /* MR1 */
59 *pClassName++=c; /* MR1 */
60 *pClassName=0; /* MR1 */
61 } else if (lexMember || lexPrefix) { /* MR1 */
62 if (class_stream != NULL) fputc(c,class_stream); /* MR1 */
63 } else { /* MR1 */
64 fputc(c,OUT); /* MR1 */
65 }; /* MR1 */
66 } /* MR1 */
67
68 #ifdef __USE_PROTOS
69 void xxprintf(char *format,char *string) { /* MR1 */
70 #else
71 void xxprintf(format,string) /* MR1 */
72 char *format; /* MR1 */
73 char *string; /* MR1 */
74 { /* MR1 */
75 #endif
76 if (lexMember || lexPrefix || parserClass) { /* MR1 */
77 if (class_stream != NULL) /* MR1 */
78 fprintf(class_stream,format,string); /* MR1 */
79 } else { /* MR1 */
80 fprintf(OUT,format,string); /* MR1 */
81 }; /* MR1 */
82 } /* MR1 */
83 >>
84
85
86 %%START
87
88 @
89 <<
90 NLA = 1;
91 >>
92
93 [\r\t\ ]+
94 <<
95 NLA = 2;
96 zzskip();
97 >>
98
99 \n
100 <<
101 NLA = 3;
102 zzline++; zzskip(); DAWDLE;
103 >>
104
105 \@
106 <<
107 NLA = L_EOF;
108 >>
109
110 \%\%
111 <<
112 NLA = PER_PER;
113 >>
114
115 \%\%[a-zA-Z_][a-zA-Z0-9_]*
116 <<
117 NLA = NAME_PER_PER;
118 p_mode_def(&zzlextext[2],lex_mode_counter++);
119 >>
120
121 \<\<\%\%lexmember
122 <<
123 NLA = LEXMEMBER;
124 lexMember=1; /* MR1 */
125 if (firstLexMember != 0) { /* MR1 */
126 firstLexMember=0; /* MR1 */
127 p_class_def1(); /* MR1 */
128 }; /* MR1 */
129 zzmode(ACT); /* MR1 */
130 >>
131
132 \<\<\%\%lexaction
133 <<
134 NLA = LEXACTION;
135 lexAction=1;zzmode(ACT);
136 >>
137
138 \<\<\%\%parserclass
139 <<
140 NLA = PARSERCLASS;
141 parserClass=1; /* MR1 */
142 zzmode(ACT); /* MR1 */
143 >>
144
145 \<\<\%\%lexprefix
146 <<
147 NLA = LEXPREFIX;
148 lexPrefix=1;zzmode(ACT);
149 >>
150
151 \<\<
152 <<
153 NLA = ACTION;
154 if (func_action)
155 fprintf(OUT,"\n%s %sact%d()\n{ ",
156 gen_cpp?"ANTLRTokenType":"static void",
157 gen_cpp?ClassName("::"):"", ++action_no);
158 zzmode(ACT); zzskip();
159 >>
160
161 \>\>
162 <<
163 NLA = GREAT_GREAT;
164 >>
165
166 \{
167 <<
168 NLA = L_BRACE;
169 >>
170
171 \}
172 <<
173 NLA = R_BRACE;
174 >>
175
176 \(
177 <<
178 NLA = L_PAR;
179 >>
180
181 \)
182 <<
183 NLA = R_PAR;
184 >>
185
186 \[
187 <<
188 NLA = L_BRACK;
189 >>
190
191 \]
192 <<
193 NLA = R_BRACK;
194 >>
195
196 \*
197 <<
198 NLA = ZERO_MORE;
199 >>
200
201 \+
202 <<
203 NLA = ONE_MORE;
204 >>
205
206 \|
207 <<
208 NLA = OR;
209 >>
210
211 \-
212 <<
213 NLA = RANGE;
214 >>
215
216 \~
217 <<
218 NLA = NOT;
219 >>
220
221 \\0[0-7]*
222 <<
223 NLA = OCTAL_VALUE;
224 {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}
225 >>
226
227 \\0[Xx][0-9a-fA-F]+
228 <<
229 NLA = HEX_VALUE;
230 {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}
231 >>
232
233 \\[1-9][0-9]*
234 <<
235 NLA = DEC_VALUE;
236 {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}
237 >>
238
239 \\t
240 <<
241 NLA = TAB;
242 zzlextext[0] = '\t';
243 >>
244
245 \\n
246 <<
247 NLA = NL;
248 zzlextext[0] = '\n';
249 >>
250
251 \\r
252 <<
253 NLA = CR;
254 zzlextext[0] = '\r';
255 >>
256
257 \\b
258 <<
259 NLA = BS;
260 zzlextext[0] = '\b';
261 >>
262
263 \\ \n
264 <<
265 NLA = CONTINUATION;
266 zzline++; zzskip();
267 >>
268
269 \\~[tnrb]
270 <<
271 NLA = LIT;
272 zzlextext[0] = zzlextext[1];
273 >>
274
275 ~[\\]
276 <<
277 NLA = REGCHAR;
278 >>
279
280
281 %%ACT
282
283 @
284 <<
285 NLA = 1;
286 error("unterminated action", zzline); zzmode(START);
287 >>
288
289 \>\>
290 <<
291 NLA = ACTION;
292 if (func_action) fprintf(OUT,"}\n\n");
293 zzmode(START);
294 /* MR1 */
295 /* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
296 /* MR1 via <<%%lexmember ...>> */
297 /* MR1 This is a consequence of not saving actions */
298 /* MR1 */
299 /* MR1 */ parserClass=0;
300 /* MR1 */ lexPrefix=0;
301 /* MR1 */ lexAction=0;
302 /* MR1 */ lexMember=0;
303 >>
304
305 \>
306 <<
307 NLA = 34;
308 xxputc(zzlextext[0]); zzskip();
309 >>
310
311 \\\>
312 <<
313 NLA = 35;
314 xxputc('>'); zzskip();
315 >>
316
317 \\
318 <<
319 NLA = 36;
320 xxputc('\\'); zzskip();
321 >>
322
323 \n
324 <<
325 NLA = 37;
326 xxputc(zzlextext[0]); ++zzline; zzskip();
327 >>
328
329 /\*
330 <<
331 NLA = 38;
332 zzmode(ACTION_COMMENTS); /* MR1 */
333 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
334 >>
335
336 //
337 <<
338 NLA = 39;
339 zzmode(ACTION_CPP_COMMENTS); /* MR1 */
340 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
341 >>
342
343 ~[]
344 <<
345 NLA = 40;
346 xxputc(zzlextext[0]); zzskip();
347 >>
348
349
350 %%ACTION_COMMENTS
351
352 @
353 <<
354 NLA = 1;
355 >>
356
357 \*/
358 <<
359 NLA = 41;
360 zzmode(ACT); /* MR1 */
361 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
362 >>
363
364 [\n\r]
365 <<
366 NLA = 42;
367 zzline++; xxputc(zzlextext[0]); zzskip();
368 >>
369
370 ~[]
371 <<
372 NLA = 43;
373 xxputc(zzlextext[0]); zzskip();
374 >>
375
376
377 %%ACTION_CPP_COMMENTS
378
379 @
380 <<
381 NLA = 1;
382 >>
383
384 [\n\r]
385 <<
386 NLA = 44;
387 zzmode(ACT); zzline++; /* MR1 */
388 xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */
389 >>
390
391 ~[]
392 <<
393 NLA = 45;
394 xxputc(zzlextext[0]); zzskip();
395 >>
396
397 %%
+0
-217
contrib/pccts/dlg/relabel.c less more
0 /* This group of functions does the character class compression.
1 It goes over the dfa and relabels the arcs with the partitions
2 of characters in the NFA. The partitions are stored in the
3 array class.
4
5 *
6 * SOFTWARE RIGHTS
7 *
8 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
9 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
10 * company may do whatever they wish with source code distributed with
11 * PCCTS or the code generated by PCCTS, including the incorporation of
12 * PCCTS, or its output, into commerical software.
13 *
14 * We encourage users to develop software with PCCTS. However, we do ask
15 * that credit is given to us for developing PCCTS. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like PCCTS and have developed a nice tool with the
20 * output, please mention that you developed it using PCCTS. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
24 * completed.
25 *
26 * DLG 1.33
27 * Will Cohen
28 * With mods by Terence Parr; AHPCRC, University of Minnesota
29 * 1989-2001
30 */
31
32 #include <stdio.h>
33 #include "dlg.h"
34 #ifdef MEMCHK
35 #include "trax.h"
36 #else
37 #ifdef __STDC__
38 #include <stdlib.h>
39 #else
40 #include <malloc.h>
41 #endif /* __STDC__ */
42 #endif
43
44 int class_no = CHAR_RANGE; /* number of classes for labels */
45 int first_el[CHAR_RANGE]; /* first element in each class partition */
46 set class_sets[CHAR_RANGE]; /* array holds partitions from class */
47 /* compression */
48
49 /* goes through labels on NFA graph and partitions the characters into
50 * character classes. This reduces the amount of space required for each
51 * dfa node, since only one arc is required each class instead of one arc
52 * for each character
53 * level:
54 * 0 no compression done
55 * 1 remove unused characters from classes
56 * 2 compress equivalent characters into same class
57 *
58 * returns the number of character classes required
59 */
60 #ifdef __USE_PROTOS
61 int relabel(nfa_node* start,int level)
62 #else
63 int relabel(start,level)
64 int level;
65 nfa_node *start;
66 #endif
67 {
68 if (level){
69 set_free(used_classes);
70 partition(start,level);
71 label_with_classes(start);
72 }else{
73 /* classes equivalent to all characters in alphabet */
74 class_no = CHAR_RANGE;
75 }
76 return class_no;
77 }
78
79 /* makes character class sets for new labels */
80 #ifdef __USE_PROTOS
81 void partition(nfa_node* start,int level)
82 #else
83 void partition(start,level)
84 nfa_node *start; /* beginning of nfa graph */
85 int level; /* compression level to uses */
86 #endif
87 {
88 set current_class;
89 set unpart_chars;
90 set temp;
91
92 unpart_chars = set_dup(used_chars);
93 #if 0
94 /* EOF (-1+1) alway in class 0 */
95 class_sets[0] = set_of(0);
96 first_el[0] = 0;
97 used_classes = set_of(0);
98 temp = set_dif(unpart_chars, class_sets[0]);
99 set_free(unpart_chars);
100 unpart_chars = temp;
101 class_no = 1;
102 #else
103 class_no = 0;
104 #endif
105 while (!set_nil(unpart_chars)){
106 /* don't look for equivalent labels if c <= 1 */
107 if (level <= 1){
108 current_class = set_of(set_int(unpart_chars));
109 }else{
110 current_class = set_dup(unpart_chars);
111 intersect_nfa_labels(start,&current_class);
112 }
113 set_orel(class_no,&used_classes);
114 first_el[class_no] = set_int(current_class);
115 class_sets[class_no] = current_class;
116 temp = set_dif(unpart_chars,current_class);
117 set_free(unpart_chars);
118 unpart_chars = temp;
119 ++class_no;
120 }
121
122 /* free unpart_chars -ATG 5/6/95 */
123 set_free(unpart_chars);
124
125 #if 0
126 /* group all the other unused characters into a class */
127 set_orel(class_no,&used_classes);
128 first_el[class_no] = set_int(current_class);
129 class_sets[class_no] = set_dif(normal_chars,used_chars);
130 ++class_no;
131 #endif
132 }
133
134
135 /* given pointer to beginning of graph and recursively walks it trying
136 * to find a maximal partition. This partion in returned in maximal_class
137 */
138 #ifdef __USE_PROTOS
139 void intersect_nfa_labels(nfa_node* start,set* maximal_class)
140 #else
141 void intersect_nfa_labels(start,maximal_class)
142 nfa_node *start;
143 set *maximal_class;
144 #endif
145 {
146 /* pick a new operation number */
147 ++operation_no;
148 r_intersect(start,maximal_class);
149 }
150
151 #ifdef __USE_PROTOS
152 void r_intersect(nfa_node* start,set* maximal_class)
153 #else
154 void r_intersect(start,maximal_class)
155 nfa_node *start;
156 set * maximal_class;
157 #endif
158 {
159 set temp;
160
161 if(start && start->nfa_set != operation_no)
162 {
163 start->nfa_set = operation_no;
164 temp = set_and(*maximal_class,start->label);
165 if (!set_nil(temp))
166 {
167 set_free(*maximal_class);
168 *maximal_class = temp;
169 }else{
170 set_free(temp);
171 }
172 r_intersect(start->trans[0],maximal_class);
173 r_intersect(start->trans[1],maximal_class);
174 }
175 }
176
177
178 /* puts class labels in place of old character labels */
179 #ifdef __USE_PROTOS
180 void label_with_classes(nfa_node* start)
181 #else
182 void label_with_classes(start)
183 nfa_node *start;
184 #endif
185 {
186 ++operation_no;
187 label_node(start);
188 }
189
190 #ifdef __USE_PROTOS
191 void label_node(nfa_node *start)
192 #else
193 void label_node(start)
194 nfa_node *start;
195 #endif
196 {
197 set new_label;
198 register int i;
199
200 /* only do node if it hasn't been done before */
201 if (start && start->nfa_set != operation_no){
202 start->nfa_set = operation_no;
203 new_label = empty;
204 for (i = 0; i<class_no; ++i){
205 /* if one element of class in old_label,
206 all elements are. */
207 if (set_el(first_el[i],start->label))
208 set_orel(i,&new_label);
209 }
210 set_free(start->label);
211 start->label = new_label;
212 /* do any nodes that can be reached from this one */
213 label_node(start->trans[0]);
214 label_node(start->trans[1]);
215 }
216 }
+0
-26
contrib/pccts/dlg/stdpccts.h less more
0 #ifndef STDPCCTS_H
1 #define STDPCCTS_H
2 /*
3 * stdpccts.h -- P C C T S I n c l u d e
4 *
5 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
6 * Purdue University Electrical Engineering
7 * With AHPCRC, University of Minnesota
8 * ANTLR Version 1.33MR33
9 */
10
11 #ifndef ANTLR_VERSION
12 #define ANTLR_VERSION 13333
13 #endif
14
15 #include "pcctscfg.h"
16 #include "pccts_stdio.h"
17
18 #include <ctype.h>
19 #include "dlg.h"
20 #define zzSET_SIZE 8
21 #include "antlr.h"
22 #include "tokens.h"
23 #include "dlgdef.h"
24 #include "mode.h"
25 #endif
+0
-240
contrib/pccts/dlg/support.c less more
0 /*
1 * SOFTWARE RIGHTS
2 *
3 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
4 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
5 * company may do whatever they wish with source code distributed with
6 * PCCTS or the code generated by PCCTS, including the incorporation of
7 * PCCTS, or its output, into commerical software.
8 *
9 * We encourage users to develop software with PCCTS. However, we do ask
10 * that credit is given to us for developing PCCTS. By "credit",
11 * we mean that if you incorporate our source code into one of your
12 * programs (commercial product, research project, or otherwise) that you
13 * acknowledge this fact somewhere in the documentation, research report,
14 * etc... If you like PCCTS and have developed a nice tool with the
15 * output, please mention that you developed it using PCCTS. In
16 * addition, we ask that this header remain intact in our source code.
17 * As long as these guidelines are kept, we expect to continue enhancing
18 * this system and expect to make other tools available as they are
19 * completed.
20 *
21 * DLG 1.33
22 * Will Cohen
23 * With mods by Terence Parr; AHPCRC, University of Minnesota
24 * 1989-2001
25 */
26
27 #include <stdio.h>
28 #include <string.h>
29 #include "dlg.h"
30 #ifdef MEMCHK
31 #include "trax.h"
32 #else
33 #ifdef __STDC__
34 #include <stdlib.h>
35 #else
36 #include <malloc.h>
37 #endif /* __STDC__ */
38 #endif
39
40 int err_found = 0; /* indicates whether problem found */
41
42 #ifdef __USE_PROTOS
43 void internal_error(char *s, char *file,int line) /* MR9 23-Sep-97 */
44 #else
45 void internal_error(s,file,line) /* MR9 23-Sep-97 */
46 char *s,*file;
47 int line;
48 #endif
49 {
50 fprintf(stderr,s,file,line);
51 exit(PCCTS_EXIT_FAILURE);
52 }
53
54 #ifdef __USE_PROTOS
55 char *dlg_malloc(int bytes,char *file,int line)
56 #else
57 char *dlg_malloc(bytes,file,line)
58 int bytes;
59 char *file;
60 int line;
61 #endif
62 {
63 char *t;
64
65 t = (char *) malloc(bytes);
66 if (!t){
67 /* error */
68 internal_error("%s(%d): unable to allocate memory\n",
69 file,line);
70 }
71 return t;
72 }
73
74
75 #ifdef __USE_PROTOS
76 char *dlg_calloc(int n,int bytes,char *file,int line)
77 #else
78 char *dlg_calloc(n,bytes,file,line)
79 int n,bytes;
80 char *file;
81 int line;
82 #endif
83 {
84 char *t;
85
86 t = (char *) calloc(n,bytes);
87 if (!t){
88 /* error */
89 internal_error("%s(%d): unable to allocate memory\n",
90 file,line);
91 }
92 return t;
93 }
94
95
96 #ifdef __USE_PROTOS
97 FILE *read_stream(char *name)
98 #else
99 FILE *read_stream(name)
100 char *name;
101 #endif
102 {
103 FILE *f;
104
105 if (name){
106 if (name[0] == '-') {
107 fprintf(stderr, "dlg: invalid option: '%s'\n", name);
108 f = NULL;
109 }else{
110 f = fopen(name, "r");
111 if (f == NULL){
112 /* couldn't open file */
113 fprintf(stderr,
114 "dlg: Warning: Can't read file %s.\n",
115 name);
116 }
117 }
118 }else{
119 /* open stdin if nothing there */
120 f = stdin;
121 }
122 return f;
123 }
124
125 #ifdef __USE_PROTOS
126 FILE *write_stream(char *name)
127 #else
128 FILE *write_stream(name)
129 char *name;
130 #endif
131 {
132 FILE *f;
133
134 if (name){
135 if (name[0] == '-') {
136 fprintf(stderr, "dlg: invalid option: '%s'\n", name);
137 f = NULL;
138 }else{
139 f = fopen(OutMetaName(name), "w");
140 if (f == NULL){
141 /* couldn't open file */
142 fprintf(stderr,
143 "dlg: Warning: Can't write to file %s.\n",
144 name);
145 }
146 else
147 #ifdef SPECIAL_FOPEN
148 special_fopen_actions(OutMetaName(name)); /* MR1 */
149 #else
150 ; /* MR1 */
151 #endif
152 }
153 }else{
154 /* open stdout if nothing there */
155 f = stdout;
156 }
157 return f;
158 }
159
160
161 #ifdef __USE_PROTOS
162 void fatal(char *message,int line_no)
163 #else
164 void fatal(message,line_no)
165 char *message;
166 int line_no;
167 #endif
168 {
169 fprintf(stderr,ErrHdr,
170 (file_str[0] ? file_str[0] : "stdin"), line_no);
171 fprintf(stderr, " Fatal: %s\n", message);
172 exit(PCCTS_EXIT_FAILURE);
173 }
174
175 #ifdef __USE_PROTOS
176 void error(char *message,int line_no)
177 #else
178 void error(message,line_no)
179 char *message;
180 int line_no;
181 #endif
182 {
183 fprintf(stderr,ErrHdr,
184 (file_str[0] ? file_str[0] : "stdin"), line_no);
185 fprintf(stderr, " Error: %s\n", message);
186 err_found = 1;
187 }
188
189 #ifdef __USE_PROTOS
190 void warning(char *message,int line_no)
191 #else
192 void warning(message,line_no)
193 char *message;
194 int line_no;
195 #endif
196 {
197 fprintf(stderr,ErrHdr,
198 (file_str[0] ? file_str[0] : "stdin"), line_no);
199 fprintf(stderr, " Warning: %s\n", message);
200 }
201
202 /* MR10: Jeff Vincent
203 MR10: Changed to remove directory information from n only if
204 MR10: if OutputDirectory was changed by user (-o option)
205 */
206
207 #ifdef __USE_PROTOS
208 char *OutMetaName(char *n)
209 #else
210 char *OutMetaName(n)
211 char *n;
212 #endif
213 {
214 static char *dir_sym = DirectorySymbol;
215 static char newname[MaxFileName+1];
216 char *p;
217
218 /* If OutputDirectory is same as TopDirectory (platform default) then leave n alone. */
219 if (strcmp(OutputDirectory, TopDirectory) == 0)
220 return n;
221
222 /* p will point to filename without path information */
223 if ((p = strrchr(n, *dir_sym)) != NULL)
224 p++;
225 else
226 p = n;
227
228 /* Copy new output directory into newname[] */
229 strcpy(newname, OutputDirectory);
230
231 /* if new output directory does not have trailing dir_sym, add it! */
232 if (newname[strlen(newname)-1] != *dir_sym)
233 strcat(newname, dir_sym);
234
235 /* contatenate FILE NAME ONLY to new output directory */
236 strcat(newname, p);
237
238 return newname;
239 }
+0
-133
contrib/pccts/dlg/tokens.h less more
0 #ifndef tokens_h
1 #define tokens_h
2 /* tokens.h -- List of labelled tokens and stuff
3 *
4 * Generated from: ./dlg_p.g
5 *
6 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
7 * Purdue University Electrical Engineering
8 * ANTLR Version 1.33MR33
9 */
10 #define zzEOF_TOKEN 1
11 #define L_EOF 4
12 #define PER_PER 5
13 #define NAME_PER_PER 6
14 #define LEXMEMBER 7
15 #define LEXACTION 8
16 #define PARSERCLASS 9
17 #define LEXPREFIX 10
18 #define ACTION 11
19 #define GREAT_GREAT 12
20 #define L_BRACE 13
21 #define R_BRACE 14
22 #define L_PAR 15
23 #define R_PAR 16
24 #define L_BRACK 17
25 #define R_BRACK 18
26 #define ZERO_MORE 19
27 #define ONE_MORE 20
28 #define OR 21
29 #define RANGE 22
30 #define NOT 23
31 #define OCTAL_VALUE 24
32 #define HEX_VALUE 25
33 #define DEC_VALUE 26
34 #define TAB 27
35 #define NL 28
36 #define CR 29
37 #define BS 30
38 #define CONTINUATION 31
39 #define LIT 32
40 #define REGCHAR 33
41
42 #ifdef __USE_PROTOS
43 void grammar(void);
44 #else
45 extern void grammar();
46 #endif
47
48 #ifdef __USE_PROTOS
49 void start_states(void);
50 #else
51 extern void start_states();
52 #endif
53
54 #ifdef __USE_PROTOS
55 void do_conversion(void);
56 #else
57 extern void do_conversion();
58 #endif
59
60 #ifdef __USE_PROTOS
61 void rule_list(void);
62 #else
63 extern void rule_list();
64 #endif
65
66 #ifdef __USE_PROTOS
67 void rule(void);
68 #else
69 extern void rule();
70 #endif
71
72 #ifdef __USE_PROTOS
73 void reg_expr(void);
74 #else
75 extern void reg_expr();
76 #endif
77
78 #ifdef __USE_PROTOS
79 void and_expr(void);
80 #else
81 extern void and_expr();
82 #endif
83
84 #ifdef __USE_PROTOS
85 void repeat_expr(void);
86 #else
87 extern void repeat_expr();
88 #endif
89
90 #ifdef __USE_PROTOS
91 void expr(void);
92 #else
93 extern void expr();
94 #endif
95
96 #ifdef __USE_PROTOS
97 void atom_list(void);
98 #else
99 extern void atom_list();
100 #endif
101
102 #ifdef __USE_PROTOS
103 void near_atom(void);
104 #else
105 extern void near_atom();
106 #endif
107
108 #ifdef __USE_PROTOS
109 void atom(void);
110 #else
111 extern void atom();
112 #endif
113
114 #ifdef __USE_PROTOS
115 void anychar(void);
116 #else
117 extern void anychar();
118 #endif
119
120 #endif
121 extern SetWordType zzerr1[];
122 extern SetWordType zzerr2[];
123 extern SetWordType zzerr3[];
124 extern SetWordType setwd1[];
125 extern SetWordType zzerr4[];
126 extern SetWordType zzerr5[];
127 extern SetWordType zzerr6[];
128 extern SetWordType setwd2[];
129 extern SetWordType zzerr7[];
130 extern SetWordType zzerr8[];
131 extern SetWordType zzerr9[];
132 extern SetWordType setwd3[];
+0
-47
contrib/pccts/dlg/watdlg.mak less more
0 SET=..\support\set
1 PCCTS_H=..\h
2
3 #
4 # Watcom
5 #
6 CC=wcl386
7 ANTLR=..\bin\antlr
8 DLG=..\bin\dlg
9 CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DPC
10 LIBS=
11 OBJ_EXT = obj
12 LINK = wcl386
13
14 .c.obj :
15 $(CC) -c $[* $(CFLAGS)
16
17 dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj &
18 output.obj relabel.obj automata.obj
19 $(LINK) -fe=dlg.exe *.obj -k14336
20 copy *.exe ..\bin
21
22 SRC = dlg_p.c dlg_a.c main.c err.c $(SET)\set.c support.c output.c &
23 relabel.c automata.c
24
25 dlg_p.c parser.dlg err.c tokens.h : dlg_p.g
26 $(ANTLR) dlg_p.g
27
28 dlg_a.c mode.h : parser.dlg
29 $(DLG) -C2 parser.dlg dlg_a.c
30
31 dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h
32 $(CC) $(CFLAGS) -c dlg_p.c
33
34 dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h
35 $(CC) $(CFLAGS) -c dlg_a.c
36
37 main.$(OBJ_EXT) : main.c dlg.h
38 $(CC) $(CFLAGS) -c main.c
39
40 set.$(OBJ_EXT) : $(SET)\set.c
41 $(CC) -c $(CFLAGS) $(SET)\set.c
42
43 #clean up all the intermediate files
44 clean:
45 del *.$(OBJ_EXT)
46 EOF_watdlg.mak
+0
-871
contrib/pccts/h/AParser.cpp less more
0 /* ANTLRParser.C
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #include "pcctscfg.h"
30
31 #include "pccts_stdlib.h"
32 #include "pccts_stdarg.h"
33 #include "pccts_string.h"
34 #include "pccts_stdio.h"
35
36 PCCTS_NAMESPACE_STD
37
38 /* I have to put this here due to C++ limitation
39 * that you can't have a 'forward' decl for enums.
40 * I hate C++!!!!!!!!!!!!!!!
41 * Of course, if I could use real templates, this would go away.
42 */
43 // MR1
44 // MR1 10-Apr-97 133MR1 Prevent use of varying sizes for the
45 // MR1 ANTLRTokenType enum
46 // MR1
47
48 enum ANTLRTokenType { TER_HATES_CPP=0, ITS_TOO_COMPLICATED=9999}; // MR1
49
50 #define ANTLR_SUPPORT_CODE
51
52 #include ATOKEN_H
53 #include ATOKENBUFFER_H
54 #include APARSER_H
55
56 static const int zzINF_DEF_TOKEN_BUFFER_SIZE = 2000; /* MR14 */
57 static const int zzINF_BUFFER_TOKEN_CHUNK_SIZE = 1000; /* MR14 */
58
59 /* L o o k a h e a d M a c r o s */
60
61 /* maximum of 32 bits/unsigned int and must be 8 bits/byte;
62 * we only use 8 bits of it.
63 */
64 SetWordType ANTLRParser::bitmask[sizeof(SetWordType)*8] = {
65 0x00000001, 0x00000002, 0x00000004, 0x00000008,
66 0x00000010, 0x00000020, 0x00000040, 0x00000080
67 };
68
69 char ANTLRParser::eMsgBuffer[500] = "";
70
71 ANTLRParser::
72 ~ANTLRParser()
73 {
74 delete [] token_type;
75 delete [] zzFAILtext; // MR16 Manfred Kogler
76 }
77
78 ANTLRParser::
79 ANTLRParser(ANTLRTokenBuffer *_inputTokens,
80 int k,
81 int use_inf_look,
82 int dlook,
83 int ssize)
84 {
85 LLk = k;
86 can_use_inf_look = use_inf_look;
87 /* MR14 */ if (dlook != 0) {
88 /* MR14 */ panic("ANTLRParser::ANTLRParser - Demand lookahead not supported in C++ mode");
89 /* MR14 */
90 /* MR14 */ };
91 demand_look = 0; /* demand_look = dlook; */
92 bsetsize = ssize;
93 guessing = 0;
94 token_tbl = NULL;
95 eofToken = (ANTLRTokenType)1;
96
97 // allocate lookahead buffer
98 token_type = new ANTLRTokenType[LLk];
99 lap = 0;
100 labase = 0;
101 #ifdef ZZDEFER_FETCH
102 stillToFetch = 0; // MR19
103 #endif
104 dirty = 0;
105 inf_labase = 0; // MR7
106 inf_last = 0; // MR7
107 /* prime lookahead buffer, point to inputTokens */
108 this->inputTokens = _inputTokens;
109 this->inputTokens->setMinTokens(k);
110 _inputTokens->setParser(this); // MR1
111 resynchConsumed=1; // MR8
112 zzFAILtext=NULL; // MR9
113 traceOptionValueDefault=0; // MR10
114 traceReset(); // MR10
115 zzGuessSeq=0; // MR10
116 syntaxErrCount=0; // MR11
117 }
118
119 void ANTLRParser::init()
120 {
121 prime_lookahead();
122 resynchConsumed=1; // MR8
123 traceReset(); // MR10
124 }
125
126 void ANTLRParser::traceReset()
127 {
128 traceOptionValue=traceOptionValueDefault;
129 traceGuessOptionValue=1;
130 traceCurrentRuleName=NULL;
131 traceDepth=0;
132 }
133
134
135 #ifdef _MSC_VER // MR23
136 //Turn off warning:
137 //interaction between '_setjmp' and C++ object destruction is non-portable
138 #pragma warning(disable : 4611)
139 #endif
140 int ANTLRParser::
141 guess(ANTLRParserState *st)
142 {
143 saveState(st);
144 guessing = 1;
145 return setjmp(guess_start.state);
146 }
147 #ifdef _MSC_VER // MR23
148 #pragma warning(default: 4611)
149 #endif
150
151 void ANTLRParser::
152 saveState(ANTLRParserState *buf)
153 {
154 buf->guess_start = guess_start;
155 buf->guessing = guessing;
156 buf->inf_labase = inf_labase;
157 buf->inf_last = inf_last;
158 buf->dirty = dirty;
159 buf->traceOptionValue=traceOptionValue; /* MR10 */
160 buf->traceGuessOptionValue=traceGuessOptionValue; /* MR10 */
161 buf->traceCurrentRuleName=traceCurrentRuleName; /* MR10 */
162 buf->traceDepth=traceDepth; /* MR10 */
163 }
164
165 void ANTLRParser::
166 restoreState(ANTLRParserState *buf)
167 {
168 int i;
169 int prevTraceOptionValue;
170
171 guess_start = buf->guess_start;
172 guessing = buf->guessing;
173 inf_labase = buf->inf_labase;
174 inf_last = buf->inf_last;
175 dirty = buf->dirty;
176
177 // restore lookahead buffer from k tokens before restored TokenBuffer position
178 // if demand_look, then I guess we don't look backwards for these tokens.
179 for (i=1; i<=LLk; i++) token_type[i-1] =
180 inputTokens->bufferedToken(i-LLk)->getType();
181 lap = 0;
182 labase = 0;
183
184 /* MR10 */
185
186 prevTraceOptionValue=traceOptionValue;
187 traceOptionValue=buf->traceOptionValue;
188 if ( (prevTraceOptionValue > 0) !=
189 (traceOptionValue > 0)) {
190 if (traceCurrentRuleName != NULL) { /* MR21 */
191 if (traceOptionValue > 0) {
192 /* MR23 */ printMessage(stderr,
193 "trace enable restored in rule %s depth %d\n",
194 traceCurrentRuleName,
195 traceDepth);
196 };
197 if (traceOptionValue <= 0) {
198 /* MR23 */ printMessage(stderr,
199 "trace disable restored in rule %s depth %d\n",
200 traceCurrentRuleName, /* MR21 */
201 traceDepth);
202 };
203 }
204 };
205 traceGuessOptionValue=buf->traceGuessOptionValue;
206 traceCurrentRuleName=buf->traceCurrentRuleName;
207 traceDepth=buf->traceDepth;
208 traceGuessDone(buf);
209 }
210
211 /* Get the next symbol from the input stream; put it into lookahead buffer;
212 * fill token_type[] fast reference cache also. NLA is the next place where
213 * a lookahead ANTLRAbstractToken should go.
214 */
215 void ANTLRParser::
216 consume()
217 {
218
219 #ifdef ZZDEBUG_CONSUME_ACTION
220 zzdebug_consume_action();
221 #endif
222
223 // MR19 V.H. Simonis
224 // Defer Fetch feature
225 // Moves action of consume() into LA() function
226
227 #ifdef ZZDEFER_FETCH
228 stillToFetch++;
229 #else
230 NLA = inputTokens->getToken()->getType();
231 dirty--;
232 lap = (lap+1)&(LLk-1);
233 #endif
234
235 }
236
237 _ANTLRTokenPtr ANTLRParser::
238 LT(int i)
239 {
240
241 // MR19 V.H. Simonis
242 // Defer Fetch feature
243 // Moves action of consume() into LA() function
244
245 #ifdef ZZDEFER_FETCH
246 undeferFetch();
247 #endif
248
249 #ifdef DEBUG_TOKENBUFFER
250 if ( i >= inputTokens->bufferSize() || inputTokens->minTokens() < LLk ) /* MR20 Was "<=" */
251 {
252 char buf[2000]; /* MR20 Was "static" */
253 sprintf(buf, "The minimum number of tokens you requested that the\nANTLRTokenBuffer buffer is not enough to satisfy your\nLT(%d) request; increase 'k' argument to constructor for ANTLRTokenBuffer\n", i);
254 panic(buf);
255 }
256 #endif
257 return inputTokens->bufferedToken(i-LLk);
258 }
259
260 void
261 ANTLRParser::
262 look(int k)
263 {
264 int i, c = k - (LLk-dirty);
265 for (i=1; i<=c; i++) consume();
266 }
267
268 /* fill the lookahead buffer up with k symbols (even if DEMAND_LOOK);
269 */
270 void
271 ANTLRParser::
272 prime_lookahead()
273 {
274 int i;
275 for(i=1;i<=LLk; i++) consume();
276 dirty=0;
277 // lap = 0; // MR14 Sinan Karasu (sinan.karasu@boeing.com)
278 // labase = 0; // MR14
279 labase=lap; // MR14
280 }
281
282 /* check to see if the current input symbol matches '_t'.
283 * During NON demand lookahead mode, dirty will always be 0 and
284 * hence the extra code for consuming tokens in _match is never
285 * executed; the same routine can be used for both modes.
286 */
287 int ANTLRParser::
288 _match(ANTLRTokenType _t, ANTLRChar **MissText,
289 ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,
290 SetWordType **MissSet)
291 {
292 if ( dirty==LLk ) {
293 consume();
294 }
295 if ( LA(1)!=_t ) {
296 *MissText=NULL;
297 *MissTok= _t;
298 *BadTok = LT(1);
299 *MissSet=NULL;
300 return 0;
301 }
302 dirty++;
303 labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
304 return 1;
305 }
306
307 /* check to see if the current input symbol matches '_t'.
308 * Used during exception handling.
309 */
310 int ANTLRParser::
311 _match_wsig(ANTLRTokenType _t)
312 {
313 if ( dirty==LLk ) {
314 consume();
315 }
316 if ( LA(1)!=_t ) return 0;
317 dirty++;
318 labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
319 return 1;
320 }
321
322 /* check to see if the current input symbol matches any token in a set.
323 * During NON demand lookahead mode, dirty will always be 0 and
324 * hence the extra code for consuming tokens in _match is never
325 * executed; the same routine can be used for both modes.
326 */
327 int ANTLRParser::
328 _setmatch(SetWordType *tset, ANTLRChar **MissText,
329 ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,
330 SetWordType **MissSet, SetWordType *tokclassErrset)
331 {
332 if ( dirty==LLk ) {
333 consume();
334 }
335 if ( !set_el(LA(1), tset) ) {
336 *MissText=NULL; /* MR23 */
337 *MissTok=(ANTLRTokenType) 0; /* MR23 */
338 *BadTok=LT(1); /* MR23 */
339 *MissSet=tokclassErrset; /* MR23 */
340 return 0;
341 }
342 dirty++;
343 labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
344 return 1;
345 }
346
347 int ANTLRParser::
348 _setmatch_wsig(SetWordType *tset)
349 {
350 if ( dirty==LLk ) {
351 consume();
352 }
353 if ( !set_el(LA(1), tset) ) return 0;
354 dirty++;
355 labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
356 return 1;
357 }
358
359 /* Exception handling routines */
360 //
361 // 7-Apr-97 133MR1
362 // Change suggested by Eli Sternheim (eli@interhdl.com)
363 //
364 void ANTLRParser::
365 consumeUntil(SetWordType *st)
366 {
367 ANTLRTokenType tmp; // MR1
368 const int Eof=1; // MR1
369 while ( !set_el( (tmp=LA(1)), st) && tmp!=Eof) { consume(); } // MR1
370 }
371
372 //
373 // 7-Apr-97 133MR1
374 // Change suggested by Eli Sternheim (eli@interhdl.com)
375 //
376 void ANTLRParser::
377 consumeUntilToken(int t)
378 {
379 int tmp; // MR1
380 const int Eof=1; // MR1
381 while ( (tmp=LA(1)) !=t && tmp!=Eof) { consume(); } // MR1
382 }
383
384
385 /* Old error stuff */
386
387 void ANTLRParser::
388 resynch(SetWordType *wd,SetWordType mask)
389 {
390
391 /* MR8 S.Bochnak@microtool.com.pl */
392 /* MR8 Change file scope static "consumed" to instance var */
393
394 /* if you enter here without having consumed a token from last resynch
395 * force a token consumption.
396 */
397 /* MR8 */ if ( !resynchConsumed ) {consume(); resynchConsumed=1; return;}
398
399 /* if current token is in resynch set, we've got what we wanted */
400
401 /* MR8 */ if ( wd[LA(1)]&mask || LA(1) == eofToken ) {resynchConsumed=0; return;}
402
403 /* scan until we find something in the resynch set */
404
405 while ( !(wd[LA(1)]&mask) && LA(1) != eofToken ) {consume();}
406
407 /* MR8 */ resynchConsumed=1;
408 }
409
410 /* standard error reporting function that assumes DLG-based scanners;
411 * you should redefine in subclass to change it or if you use your
412 * own scanner.
413 */
414
415 /* MR23 THM There appears to be a parameter "badText" passed to syn()
416 which is not present in the parameter list. This may be
417 because in C mode there is no attribute function which
418 returns the text, so the text representation of the token
419 must be passed explicitly. I think.
420 */
421
422 void ANTLRParser::
423 syn(_ANTLRTokenPtr /*tok MR23*/, ANTLRChar *egroup, SetWordType *eset,
424 ANTLRTokenType etok, int k)
425 {
426 int line;
427
428 line = LT(1)->getLine();
429
430 syntaxErrCount++; /* MR11 */
431
432 /* MR23 If the token is not an EOF token, then use the ->getText() value.
433
434 If the token is the EOF token the text returned by ->getText()
435 may be garbage. If the text from the token table is "@" use
436 "<eof>" instead, because end-users don't know what "@" means.
437 If the text is not "@" then use that text, which must have been
438 supplied by the grammar writer.
439 */
440 const char * errorAt = LT(1)->getText();
441 if (LA(1) == eofToken) {
442 errorAt = parserTokenName(LA(1));
443 if (errorAt[0] == '@') errorAt = "<eof>";
444 }
445 /* MR23 */ printMessage(stderr, "line %d: syntax error at \"%s\"",
446 line, errorAt);
447 if ( !etok && !eset ) {/* MR23 */ printMessage(stderr, "\n"); return;}
448 if ( k==1 ) /* MR23 */ printMessage(stderr, " missing");
449 else
450 {
451 /* MR23 */ printMessage(stderr, "; \"%s\" not", LT(k)->getText()); // MR23 use LT(k) since k>1
452 if ( set_deg(eset)>1 ) /* MR23 */ printMessage(stderr, " in");
453 }
454 if ( set_deg(eset)>0 ) edecode(eset);
455 else /* MR23 */ printMessage(stderr, " %s", token_tbl[etok]);
456 if ( strlen(egroup) > 0 ) /* MR23 */ printMessage(stderr, " in %s", egroup);
457 /* MR23 */ printMessage(stderr, "\n");
458 }
459
460 /* is b an element of set p? */
461 int ANTLRParser::
462 set_el(ANTLRTokenType b, SetWordType *p)
463 {
464 return( p[DIVWORD(b)] & bitmask[MODWORD(b)] );
465 }
466
467 int ANTLRParser::
468 set_deg(SetWordType *a)
469 {
470 /* Fast compute degree of a set... the number
471 of elements present in the set. Assumes
472 that all word bits are used in the set
473 */
474 register SetWordType *p = a;
475 register SetWordType *endp = &(a[bsetsize]);
476 register int degree = 0;
477
478 if ( a == NULL ) return 0;
479 while ( p < endp )
480 {
481 register SetWordType t = *p;
482 register SetWordType *b = &(bitmask[0]);
483 do {
484 if (t & *b) ++degree;
485 } while (++b < &(bitmask[sizeof(SetWordType)*8]));
486 p++;
487 }
488
489 return(degree);
490 }
491
492 void ANTLRParser::
493 edecode(SetWordType *a)
494 {
495 register SetWordType *p = a;
496 register SetWordType *endp = &(p[bsetsize]);
497 register unsigned e = 0;
498
499 if ( set_deg(a)>1 ) /* MR23 */ printMessage(stderr, " {");
500 do {
501 register SetWordType t = *p;
502 register SetWordType *b = &(bitmask[0]);
503 do {
504 if ( t & *b ) /* MR23 */ printMessage(stderr, " %s", token_tbl[e]);
505 e++;
506 } while (++b < &(bitmask[sizeof(SetWordType)*8]));
507 } while (++p < endp);
508 if ( set_deg(a)>1 ) /* MR23 */ printMessage(stderr, " }");
509 }
510
511 /* input looks like:
512 * zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk)
513 * where the zzMiss stuff is set here to the token that did not match
514 * (and which set wasn't it a member of).
515 */
516
517 // MR9 29-Sep-97 Stan Bochnak (S.Bochnak@microTool.com.pl)
518 // MR9 Original fix to static allocated text didn't
519 // MR9 work because a pointer to it was passed back
520 // MR9 to caller. Replace with instance variable.
521
522 const int SETWORDCOUNT=20;
523
524 void
525 ANTLRParser::FAIL(int k, ...)
526 {
527 //
528 // MR1 10-Apr-97
529 //
530
531 if (zzFAILtext == NULL) zzFAILtext=new char [1000]; // MR9
532 SetWordType **f=new SetWordType *[SETWORDCOUNT]; // MR1 // MR9
533 SetWordType **miss_set;
534 ANTLRChar **miss_text;
535 _ANTLRTokenPtr *bad_tok;
536 ANTLRChar **bad_text;
537 //
538 // 7-Apr-97 133MR1
539 // err_k is passed as a "int *", not "unsigned *"
540 //
541 int *err_k; // MR1
542 int i;
543 va_list ap;
544
545 va_start(ap, k);
546
547 zzFAILtext[0] = '\0';
548 if ( k > SETWORDCOUNT ) panic("FAIL: overflowed buffer");
549 for (i=1; i<=k; i++) /* collect all lookahead sets */
550 {
551 f[i-1] = va_arg(ap, SetWordType *);
552 }
553 for (i=1; i<=k; i++) /* look for offending token */
554 {
555 if ( i>1 ) strcat(zzFAILtext, " ");
556 strcat(zzFAILtext, LT(i)->getText());
557 if ( !set_el(LA(i), f[i-1]) ) break;
558 }
559 miss_set = va_arg(ap, SetWordType **);
560 miss_text = va_arg(ap, ANTLRChar **);
561 bad_tok = va_arg(ap, _ANTLRTokenPtr *);
562 bad_text = va_arg(ap, ANTLRChar **);
563 err_k = va_arg(ap, int *); // MR1
564 if ( i>k )
565 {
566 /* bad; lookahead is permutation that cannot be matched,
567 * but, the ith token of lookahead is valid at the ith position
568 * (The old LL sub 1 (k) versus LL(k) parsing technique)
569 */
570 *miss_set = NULL;
571 *miss_text = LT(1)->getText();
572 *bad_tok = LT(1);
573 *bad_text = (*bad_tok)->getText();
574 *err_k = k;
575 //
576 // MR4 20-May-97 erroneously deleted contents of f[]
577 // MR4 reported by Bruce Guenter (bruceg@qcc.sk.ca)
578 // MR1 10-Apr-97 release temporary storage
579 //
580 delete [] f; // MR1
581 return; // MR1
582 }
583 /* MR23 printMessage(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/
584 *miss_set = f[i-1];
585 *miss_text = zzFAILtext;
586 *bad_tok = LT(i);
587 *bad_text = (*bad_tok)->getText();
588 if ( i==1 ) *err_k = 1;
589 else *err_k = k;
590 //
591 // MR4 20-May-97 erroneously deleted contents of f[]
592 // MR4 reported by Bruce Guenter (bruceg@qcc.sk.ca)
593 // MR1 10-Apr-97 release temporary storage
594 //
595 delete [] f; // MR1
596 return; // MR1
597 }
598
599 int ANTLRParser::
600 _match_wdfltsig(ANTLRTokenType tokenWanted, SetWordType *whatFollows)
601 {
602 if ( dirty==LLk ) consume();
603
604 if ( LA(1)!=tokenWanted )
605 {
606 syntaxErrCount++; /* MR11 */
607 /* MR23 */ printMessage(stderr,
608 "line %d: syntax error at \"%s\" missing %s\n",
609 LT(1)->getLine(),
610 (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */
611 token_tbl[tokenWanted]);
612 consumeUntil( whatFollows );
613 return 0;
614 }
615 else {
616 dirty++;
617 labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
618 /* if ( !demand_look ) consume(); */
619 return 1;
620 }
621 }
622
623
624 int ANTLRParser::
625 _setmatch_wdfltsig(SetWordType *tokensWanted,
626 ANTLRTokenType tokenTypeOfSet,
627 SetWordType *whatFollows)
628 {
629 if ( dirty==LLk ) consume();
630 if ( !set_el(LA(1), tokensWanted) )
631 {
632 syntaxErrCount++; /* MR11 */
633 /* MR23 */ printMessage(stderr,
634 "line %d: syntax error at \"%s\" missing %s\n",
635 LT(1)->getLine(),
636 (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */
637 token_tbl[tokenTypeOfSet]);
638 consumeUntil( whatFollows );
639 return 0;
640 }
641 else {
642 dirty++;
643 labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
644 /* if ( !demand_look ) consume(); */
645 return 1;
646 }
647 }
648
649 char *ANTLRParser::
650 eMsgd(char *err,int d)
651 {
652 sprintf(eMsgBuffer, err, d); // dangerous, but I don't care
653 return eMsgBuffer;
654 }
655
656 char *ANTLRParser::
657 eMsg(char *err, char *s)
658 {
659 sprintf(eMsgBuffer, err, s);
660 return eMsgBuffer;
661 }
662
663 char *ANTLRParser::
664 eMsg2(char *err,char *s, char *t)
665 {
666 sprintf(eMsgBuffer, err, s, t);
667 return eMsgBuffer;
668 }
669
670 void ANTLRParser::
671 panic(const char *msg) // MR20 const
672 {
673 /* MR23 */ printMessage(stderr, "ANTLR panic: %s\n", msg);
674 exit(PCCTS_EXIT_FAILURE); // MR1
675 }
676
677 const ANTLRChar *ANTLRParser:: // MR1
678 parserTokenName(int tok) { // MR1
679 return token_tbl[tok]; // MR1
680 } // MR1
681
682 void ANTLRParser::traceGuessDone(const ANTLRParserState *state) {
683
684 int doIt=0;
685
686 if (traceCurrentRuleName == NULL) return;
687
688 if (traceOptionValue <= 0) {
689 doIt=0;
690 } else if (traceGuessOptionValue <= 0) {
691 doIt=0;
692 } else {
693 doIt=1;
694 };
695
696 if (doIt) {
697 /* MR23 */ printMessage(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",
698 state->traceCurrentRuleName,
699 LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),
700 state->traceDepth);
701 if (state->guessing != 0) {
702 /* MR23 */ printMessage(stderr," (guess mode continues - an enclosing guess is still active)");
703 } else {
704 /* MR23 */ printMessage(stderr," (guess mode ends)");
705 };
706 /* MR23 */ printMessage(stderr,"\n");
707 };
708 }
709
710 void ANTLRParser::traceGuessFail() {
711
712 int doIt=0;
713
714 if (traceCurrentRuleName == NULL) return; /* MR21 */
715
716 if (traceOptionValue <= 0) {
717 doIt=0;
718 } else if (guessing && traceGuessOptionValue <= 0) {
719 doIt=0;
720 } else {
721 doIt=1;
722 };
723
724 if (doIt) {
725 /* MR23 */ printMessage(stderr,"guess failed in %s\n",traceCurrentRuleName);
726 };
727 }
728
729 /* traceOption:
730 zero value turns off trace
731 */
732
733 void ANTLRParser::tracein(const ANTLRChar * rule) {
734
735 int doIt=0;
736
737 traceDepth++;
738 traceCurrentRuleName=rule;
739
740 if (traceOptionValue <= 0) {
741 doIt=0;
742 } else if (guessing && traceGuessOptionValue <= 0) {
743 doIt=0;
744 } else {
745 doIt=1;
746 };
747
748 if (doIt) {
749 /* MR23 */ printMessage(stderr,"enter rule %s {\"%s\"} depth %d",
750 rule,
751 LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),
752 traceDepth);
753 if (guessing) /* MR23 */ printMessage(stderr," guessing");
754 /* MR23 */ printMessage(stderr,"\n");
755 };
756 return;
757 }
758
759 void ANTLRParser::traceout(const ANTLRChar * rule) {
760
761 int doIt=0;
762
763 traceDepth--;
764
765 if (traceOptionValue <= 0) {
766 doIt=0;
767 } else if (guessing && traceGuessOptionValue <= 0) {
768 doIt=0;
769 } else {
770 doIt=1;
771 };
772
773 if (doIt) {
774 /* MR23 */ printMessage(stderr,"exit rule %s {\"%s\"} depth %d",
775 rule,
776 LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),
777 traceDepth+1);
778 if (guessing) /* MR23 */ printMessage(stderr," guessing");
779 /* MR23 */ printMessage(stderr,"\n");
780 };
781 }
782
783 int ANTLRParser::traceOption(int delta) {
784
785 int prevValue=traceOptionValue;
786
787 traceOptionValue=traceOptionValue+delta;
788
789 if (traceCurrentRuleName != NULL) {
790 if (prevValue <= 0 && traceOptionValue > 0) {
791 /* MR23 */ printMessage(stderr,"trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
792 };
793 if (prevValue > 0 && traceOptionValue <= 0) {
794 /* MR23 */ printMessage(stderr,"trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
795 };
796 };
797
798 return prevValue;
799 }
800
801 int ANTLRParser::traceGuessOption(int delta) {
802
803 int prevValue=traceGuessOptionValue;
804
805 traceGuessOptionValue=traceGuessOptionValue+delta;
806
807 if (traceCurrentRuleName != NULL) {
808 if (prevValue <= 0 && traceGuessOptionValue > 0) {
809 /* MR23 */ printMessage(stderr,"guess trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
810 };
811 if (prevValue > 0 && traceGuessOptionValue <= 0) {
812 /* MR23 */ printMessage(stderr,"guess trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
813 };
814 };
815 return prevValue;
816 }
817
818 // MR19 V.H. Simonis Defer Fetch feature
819
820 void ANTLRParser::undeferFetch()
821 {
822
823 #ifdef ZZDEFER_FETCH
824 if (stillToFetch) {
825 for (int stillToFetch_x = 0; stillToFetch_x < stillToFetch; ++stillToFetch_x) {
826 NLA = inputTokens->getToken()->getType();
827 dirty--;
828 lap = (lap+1)&(LLk-1);
829 }
830 stillToFetch = 0;
831 }
832 #else
833 return;
834 #endif
835
836 }
837
838 int ANTLRParser::isDeferFetchEnabled()
839 {
840 #ifdef ZZDEFER_FETCH
841 return 1;
842 #else
843 return 0;
844 #endif
845 }
846
847 //MR23
848 int ANTLRParser::printMessage(FILE* pFile, const char* pFormat, ...)
849 {
850 va_list marker;
851 va_start( marker, pFormat );
852 int iRet = printMessageV(pFile, pFormat, marker);
853 va_end( marker );
854 return iRet;
855 }
856
857 int ANTLRParser::printMessageV(FILE* pFile, const char* pFormat, va_list arglist) // MR23
858 {
859 return vfprintf(pFile, pFormat, arglist);
860 }
861
862 // MR23 Move semantic predicate error handling from macro to virtual function
863 //
864 // Called by the zzfailed_pred
865
866 void ANTLRParser::failedSemanticPredicate(const char* predicate)
867 {
868 printMessage(stdout,"line %d: semantic error; failed predicate: '%s'\n",
869 LT(1)->getLine(), predicate);
870 }
+0
-376
contrib/pccts/h/AParser.h less more
0 /* ANTLRParser.h
1 *
2 * Define the generic ANTLRParser superclass, which is subclassed to
3 * define an actual parser.
4 *
5 * Before entry into this file: ANTLRTokenType must be set.
6 *
7 * SOFTWARE RIGHTS
8 *
9 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
10 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
11 * company may do whatever they wish with source code distributed with
12 * PCCTS or the code generated by PCCTS, including the incorporation of
13 * PCCTS, or its output, into commerical software.
14 *
15 * We encourage users to develop software with PCCTS. However, we do ask
16 * that credit is given to us for developing PCCTS. By "credit",
17 * we mean that if you incorporate our source code into one of your
18 * programs (commercial product, research project, or otherwise) that you
19 * acknowledge this fact somewhere in the documentation, research report,
20 * etc... If you like PCCTS and have developed a nice tool with the
21 * output, please mention that you developed it using PCCTS. In
22 * addition, we ask that this header remain intact in our source code.
23 * As long as these guidelines are kept, we expect to continue enhancing
24 * this system and expect to make other tools available as they are
25 * completed.
26 *
27 * ANTLR 1.33
28 * Terence Parr
29 * Parr Research Corporation
30 * with Purdue University and AHPCRC, University of Minnesota
31 * 1989-2000
32 */
33
34 #ifndef APARSER_H_GATE
35 #define APARSER_H_GATE
36
37 #include "pcctscfg.h"
38
39 #include "pccts_stdio.h"
40 #include "pccts_setjmp.h"
41
42 PCCTS_NAMESPACE_STD
43
44 #include ATOKEN_H
45 #include ATOKENBUFFER_H
46
47 #ifdef ZZCAN_GUESS
48 #ifndef ZZINF_LOOK
49 #define ZZINF_LOOK
50 #endif
51 #endif
52
53
54 #define NLA (token_type[lap&(LLk-1)])/* --> next LA */
55
56 typedef unsigned char SetWordType;
57
58 /* Define external bit set stuff (for SetWordType) */
59 #define EXT_WORDSIZE (sizeof(char)*8)
60 #define EXT_LOGWORDSIZE 3
61
62 /* s y n t a c t i c p r e d i c a t e s t u f f */
63
64 #ifndef zzUSER_GUESS_HOOK
65 #define zzUSER_GUESS_HOOK(seqFrozen,zzrv)
66 #endif
67
68 #ifndef zzUSER_GUESS_DONE_HOOK
69 #define zzUSER_GUESS_DONE_HOOK(seqFrozen)
70 #endif
71
72 /* MR14 Add zzUSER_GUESS_FAIL_HOOK and related code */
73
74 #define zzUSER_GUESS_FAIL_HOOK_INTERNAL zzUSER_GUESS_FAIL_HOOK(SeqFrozen)
75 #ifndef zzUSER_GUESS_FAIL_HOOK
76 #define zzUSER_GUESS_FAIL_HOOK(zzGuessSeq)
77 #endif
78
79
80 typedef struct _zzjmp_buf {
81 jmp_buf state;
82 } zzjmp_buf;
83
84 /* these need to be macros not member functions */
85 #define zzGUESS_BLOCK ANTLRParserState zzst; int zzrv; int _marker; int zzGuessSeqFrozen;
86 #define zzNON_GUESS_MODE if ( !guessing )
87 #define zzGUESS_FAIL guess_fail();
88
89 /* Note: zzGUESS_DONE does not execute longjmp() */
90
91 #define zzGUESS_DONE {zzrv=1; inputTokens->rewind(_marker); guess_done(&zzst);zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }
92 #define zzGUESS saveState(&zzst); \
93 guessing = 1; \
94 zzGuessSeqFrozen = ++zzGuessSeq; \
95 _marker = inputTokens->mark(); \
96 zzrv = setjmp(guess_start.state); \
97 zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \
98 if ( zzrv ) zzGUESS_DONE
99
100 #define zzTRACEdata const ANTLRChar *zzTracePrevRuleName = NULL;
101
102 #ifndef zzTRACEIN
103 #define zzTRACEIN(r) zzTracePrevRuleName=traceCurrentRuleName;tracein(r);
104 #endif
105 #ifndef zzTRACEOUT
106 #define zzTRACEOUT(r) traceout(r);traceCurrentRuleName=zzTracePrevRuleName;
107 #endif
108
109 /* a n t l r p a r s e r d e f */
110
111 struct ANTLRParserState {
112 /* class variables */
113 zzjmp_buf guess_start;
114 int guessing;
115
116 int inf_labase;
117 int inf_last;
118
119 int dirty;
120
121 int traceOptionValue; // MR10
122 int traceGuessOptionValue; // MR10
123 const ANTLRChar *traceCurrentRuleName; // MR10
124 int traceDepth; // MR10
125
126 };
127
128 /* notes:
129 *
130 * multiple inheritance is a cool way to include what stuff is needed
131 * in this structure (like guess stuff). however, i'm not convinced that
132 * multiple inheritance works correctly on all platforms. not that
133 * much space is used--just include all possibly useful members.
134 *
135 * the class should also be a template with arguments for the lookahead
136 * depth and so on. that way, more than one parser can be defined (as
137 * each will probably have different lookahead requirements). however,
138 * am i sure that templates work? no, i'm not sure.
139 *
140 * no attributes are maintained and, hence, the 'asp' variable is not
141 * needed. $i can still be referenced, but it refers to the token
142 * associated with that rule element. question: where are the token's
143 * stored if not on the software stack? in local variables created
144 * and assigned to by antlr.
145 */
146 class ANTLRParser {
147 protected:
148 /* class variables */
149 static SetWordType bitmask[sizeof(SetWordType)*8];
150 static char eMsgBuffer[500];
151
152 protected:
153 int LLk; // number of lookahead symbols (old LL_K)
154 int demand_look;
155 ANTLRTokenType eofToken; // when do I stop during resynch()s
156 int bsetsize; // size of bitsets created by ANTLR in
157 // units of SetWordType
158
159 ANTLRTokenBuffer *inputTokens; //place to get input tokens
160
161 zzjmp_buf guess_start; // where to jump back to upon failure
162 int guessing; // if guessing (using (...)? predicate)
163
164 // infinite lookahead stuff
165 int can_use_inf_look; // set by subclass (generated by ANTLR)
166 int inf_lap;
167 int inf_labase;
168 int inf_last;
169 int *_inf_line;
170
171 const ANTLRChar **token_tbl; // pointer to table of token type strings MR20 const
172
173 int dirty; // used during demand lookahead
174
175 ANTLRTokenType *token_type; // fast reference cache of token.getType()
176 // ANTLRLightweightToken **token; // the token with all its attributes
177 int lap;
178 int labase;
179 #ifdef ZZDEFER_FETCH
180 int stillToFetch; // MR19 V.H. Simonis
181 #endif
182
183 private:
184 void fill_inf_look();
185
186 protected:
187 virtual void guess_fail() { // MR9 27-Sep-97 make virtual
188 traceGuessFail(); // MR10
189 longjmp(guess_start.state, 1); } // MR9
190 virtual void guess_done(ANTLRParserState *st) { // MR9 27-Sep-97 make virtual
191 restoreState(st); } // MR9
192 virtual int guess(ANTLRParserState *); // MR9 27-Sep-97 make virtual
193 void look(int);
194 int _match(ANTLRTokenType, ANTLRChar **, ANTLRTokenType *,
195 _ANTLRTokenPtr *, SetWordType **);
196 int _setmatch(SetWordType *, ANTLRChar **, ANTLRTokenType *,
197 _ANTLRTokenPtr *, SetWordType **,
198 SetWordType * tokclassErrset /* MR23 */);
199 int _match_wsig(ANTLRTokenType);
200 int _setmatch_wsig(SetWordType *);
201 virtual void consume();
202 virtual void resynch(SetWordType *wd,SetWordType mask); // MR21
203 void prime_lookahead();
204 virtual void tracein(const ANTLRChar *r); // MR10
205 virtual void traceout(const ANTLRChar *r); // MR10
206 static unsigned MODWORD(unsigned x) {return x & (EXT_WORDSIZE-1);} // x % EXT_WORDSIZE // MR9
207 static unsigned DIVWORD(unsigned x) {return x >> EXT_LOGWORDSIZE;} // x / EXT_WORDSIZE // MR9
208 int set_deg(SetWordType *);
209 int set_el(ANTLRTokenType, SetWordType *);
210 virtual void edecode(SetWordType *); // MR1
211 virtual void FAIL(int k, ...); // MR1
212 int traceOptionValue; // MR10
213 int traceGuessOptionValue; // MR10
214 const ANTLRChar *traceCurrentRuleName; // MR10
215 int traceDepth; // MR10
216 void traceReset(); // MR10
217 virtual void traceGuessFail(); // MR10
218 virtual void traceGuessDone(const ANTLRParserState *); // MR10
219 int zzGuessSeq; // MR10
220
221 public:
222 ANTLRParser(ANTLRTokenBuffer *,
223 int k=1,
224 int use_inf_look=0,
225 int demand_look=0,
226 int bsetsize=1);
227 virtual ~ANTLRParser();
228
229 virtual void init();
230
231 ANTLRTokenType LA(int i)
232 {
233 //
234 // MR14 demand look will always be 0 for C++ mode
235 //
236 //// return demand_look ? token_type[(labase+(i)-1)&(LLk-1)] :
237 //// token_type[(lap+(i)-1)&(LLk-1)];
238
239 // MR19 V.H. Simonis Defer fetch feature
240
241 #ifdef ZZDEFER_FETCH
242 undeferFetch();
243 #endif
244 return token_type[(lap+(i)-1)&(LLk-1)];
245 }
246 _ANTLRTokenPtr LT(int i);
247
248 void setEofToken(ANTLRTokenType t) { eofToken = t; }
249 ANTLRTokenType getEofToken() const { return eofToken; } // MR14
250
251 void noGarbageCollectTokens() { inputTokens->noGarbageCollectTokens(); }
252 void garbageCollectTokens() { inputTokens->garbageCollectTokens(); }
253
254 virtual void syn(_ANTLRTokenPtr tok, ANTLRChar *egroup,
255 SetWordType *eset, ANTLRTokenType etok, int k);
256 virtual void saveState(ANTLRParserState *); // MR9 27-Sep-97 make virtual
257 virtual void restoreState(ANTLRParserState *); // MR9 27-Sep-97 make virtual
258
259 virtual void panic(const char *msg); // MR20 const
260
261 static char *eMsgd(char *,int);
262 static char *eMsg(char *,char *);
263 static char *eMsg2(char *,char *,char *);
264
265 virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
266 virtual int printMessageV(FILE* pFile, const char* pFormat, va_list arglist); // MR23
267
268 void consumeUntil(SetWordType *st);
269 void consumeUntilToken(int t);
270
271 virtual int _setmatch_wdfltsig(SetWordType *tokensWanted,
272 ANTLRTokenType tokenTypeOfSet,
273 SetWordType *whatFollows);
274 virtual int _match_wdfltsig(ANTLRTokenType tokenWanted,
275 SetWordType *whatFollows);
276
277 const ANTLRChar * parserTokenName(int tok); // MR1
278
279 int traceOptionValueDefault; // MR11
280 int traceOption(int delta); // MR11
281 int traceGuessOption(int delta); // MR11
282
283 // MR8 5-Aug-97 S.Bochnak@microtool.com.pl
284 // MR8 Move resynch static local variable
285 // MR8 to class instance
286
287 int syntaxErrCount; // MR12
288 ANTLRTokenStream *getLexer() const { // MR12
289 return inputTokens ? inputTokens->getLexer() : 0; } // MR12
290 protected: // MR8
291 int resynchConsumed; // MR8
292 char *zzFAILtext; // workarea required by zzFAIL // MR9
293 void undeferFetch(); // MR19 V.H. Simonis
294 int isDeferFetchEnabled(); // MR19 V.H. Simonis
295 virtual void failedSemanticPredicate(const char* predicate); /* MR23 */
296 };
297
298 #define zzmatch(_t) \
299 if ( !_match((ANTLRTokenType)_t, &zzMissText, &zzMissTok, \
300 (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail;
301
302 #define zzmatch_wsig(_t,handler) \
303 if ( !_match_wsig((ANTLRTokenType)_t) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}
304
305 #define zzsetmatch(_ts,_tokclassErrset) \
306 if ( !_setmatch(_ts, &zzMissText, &zzMissTok, \
307 (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet, _tokclassErrset) ) goto fail;
308
309 #define zzsetmatch_wsig(_ts, handler) \
310 if ( !_setmatch_wsig(_ts) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}
311
312 /* For the dflt signal matchers, a FALSE indicates that an error occurred
313 * just like the other matchers, but in this case, the routine has already
314 * recovered--we do NOT want to consume another token. However, when
315 * the match was successful, we do want to consume hence _signal=0 so that
316 * a token is consumed by the "if (!_signal) consume(); _signal=NoSignal;"
317 * preamble.
318 */
319 #define zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) \
320 if ( !_setmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) ) \
321 _signal = MismatchedToken;
322
323 #define zzmatch_wdfltsig(tokenWanted, whatFollows) \
324 if ( !_match_wdfltsig(tokenWanted, whatFollows) ) _signal = MismatchedToken;
325
326
327 // MR1 10-Apr-97 zzfailed_pred() macro does not backtrack in guess mode.
328 // MR1 Identification and correction due to J. Lilley
329 //
330 // MR23 Call virtual method to report error.
331 // MR23 Provide more control over failed predicate action
332 // without any need for user to worry about guessing internals.
333
334 #ifndef zzfailed_pred
335 #define zzfailed_pred(_p,_hasuseraction,_useraction) \
336 if (guessing) { \
337 zzGUESS_FAIL; \
338 } else { \
339 zzfailed_pred_action(_p,_hasuseraction,_useraction) \
340 }
341 #endif
342
343 // MR23 Provide more control over failed predicate action
344 // without any need for user to worry about guessing internals.
345 // _hasuseraction == 0 => no user specified error action
346 // _hasuseraction == 1 => user specified error action
347
348 #ifndef zzfailed_pred_action
349 #define zzfailed_pred_action(_p,_hasuseraction,_useraction) \
350 if (_hasuseraction) { _useraction } else { failedSemanticPredicate(_p); }
351 #endif
352
353 #define zzRULE \
354 SetWordType *zzMissSet=NULL; ANTLRTokenType zzMissTok=(ANTLRTokenType)0; \
355 _ANTLRTokenPtr zzBadTok=NULL; ANTLRChar *zzBadText=(ANTLRChar *)""; \
356 int zzErrk=1,zzpf=0; \
357 zzTRACEdata \
358 ANTLRChar *zzMissText=(ANTLRChar *)"";
359
360 #endif
361
362 /* S t a n d a r d E x c e p t i o n S i g n a l s */
363
364 #define NoSignal 0
365 #define MismatchedToken 1
366 #define NoViableAlt 2
367 #define NoSemViableAlt 3
368
369 /* MR7 Allow more control over signalling */
370 /* by adding "Unwind" and "SetSignal" */
371
372 #define Unwind 4
373 #define setSignal(newValue) *_retsignal=_signal=(newValue)
374 #define suppressSignal *_retsignal=_signal=0
375 #define exportSignal *_retsignal=_signal
+0
-256
contrib/pccts/h/ASTBase.cpp less more
0 /* Abstract syntax tree manipulation functions
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #include "pcctscfg.h"
30
31 #include "pccts_stdio.h"
32 #include "pccts_stdarg.h"
33
34 PCCTS_NAMESPACE_STD
35
36 #define ANTLR_SUPPORT_CODE
37
38 #include "ASTBase.h"
39
40 /* ensure that tree manipulation variables are current after a rule
41 * reference
42 */
43 void
44 ASTBase::link(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)
45 {
46 if ( *_sibling == NULL ) return;
47 if ( *_root == NULL ) *_root = *_sibling;
48 else if ( *_root != *_sibling ) (*_root)->_down = *_sibling;
49 if ( *_tail==NULL ) *_tail = *_sibling;
50 while ( (*_tail)->_right != NULL ) *_tail = (*_tail)->_right;
51 }
52
53 /* add a child node to the current sibling list */
54 void
55 ASTBase::subchild(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)
56 {
57 if ( *_tail != NULL ) (*_tail)->_right = this;
58 else {
59 *_sibling = this;
60 if ( *_root != NULL ) (*_root)->_down = *_sibling;
61 }
62 *_tail = this;
63 if ( *_root == NULL ) *_root = *_sibling;
64 }
65
66 /* make a new AST node. Make the newly-created
67 * node the root for the current sibling list. If a root node already
68 * exists, make the newly-created node the root of the current root.
69 */
70 void
71 ASTBase::subroot(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)
72 {
73 if ( *_root != NULL )
74 if ( (*_root)->_down == *_sibling ) *_sibling = *_tail = *_root;
75 *_root = this;
76 (*_root)->_down = *_sibling;
77 }
78
79 /* Apply preorder_action(), etc.. to root then each sibling */
80 //
81 // 7-Apr-97 133MR1
82 // Fix suggested by Ron House (house@helios.usq.edu.au)
83 //
84 void
85 ASTBase::preorder(void* pData /*= NULL*/ /* MR23 */)
86 {
87 ASTBase *tree = this;
88
89 while ( tree!= NULL )
90 {
91 if ( tree->_down != NULL ) {
92 tree->preorder_before_action(pData); // MR1
93 };
94 tree->preorder_action(pData);
95 if ( tree->_down!=NULL )
96 {
97 tree->_down->preorder(pData);
98 tree->preorder_after_action(pData); // MR1
99 }
100 tree = tree->_right;
101 }
102 }
103
104 /* free all AST nodes in tree; apply func to each before freeing */
105 void
106 ASTBase::destroy()
107 {
108 ASTBase* tree = this;
109 while (tree) {
110 if (tree->_down) tree->_down->destroy();
111
112 ASTBase* cur = tree;
113 tree = tree->_right;
114 delete cur;
115 }
116 }
117
118 /* build a tree (root child1 child2 ... NULL)
119 * If root is NULL, simply make the children siblings and return ptr
120 * to 1st sibling (child1). If root is not single node, return NULL.
121 *
122 * Siblings that are actually siblins lists themselves are handled
123 * correctly. For example #( NULL, #( NULL, A, B, C), D) results
124 * in the tree ( NULL A B C D ).
125 *
126 * Requires at least two parameters with the last one being NULL. If
127 * both are NULL, return NULL.
128 */
129 ASTBase *
130 ASTBase::tmake(ASTBase *root, ...)
131 {
132 va_list ap;
133 register ASTBase *child, *sibling=NULL, *tail=NULL /*MR23*/, *w;
134
135 va_start(ap, root);
136
137 if ( root != NULL )
138 if ( root->_down != NULL ) {
139 root->reportOverwriteOfDownPointer(); /* MR21 Report problem which almost always an error */
140 return NULL;
141 }
142 child = va_arg(ap, ASTBase *);
143 while ( child != NULL )
144 {
145 for (w=child; w->_right!=NULL; w=w->_right) {;} /* find end of child */
146 if ( sibling == NULL ) {sibling = child; tail = w;}
147 else {tail->_right = child; tail = w;}
148 child = va_arg(ap, ASTBase *);
149 }
150 if ( root==NULL ) root = sibling;
151 else root->_down = sibling;
152 va_end(ap);
153 return root;
154 }
155
156 #ifndef PCCTS_NOT_USING_SOR
157
158 /* tree duplicate */
159 // forgot to check for NULL this (TJP July 23,1995)
160 ASTBase *
161 ASTBase::dup()
162 {
163 ASTBase *u, *t=this;
164
165 if ( t == NULL ) return NULL;
166 /*
167 u = new ASTBase;
168 *u = *t;
169 */
170 u = (ASTBase *)this->shallowCopy();
171 if ( t->_right!=NULL ) u->_right = t->_right->dup();
172 else u->_right = NULL;
173 if ( t->_down!=NULL ) u->_down = t->_down->dup();
174 else u->_down = NULL;
175 return u;
176 }
177 #endif
178
179 //
180 // 7-Apr-97 133MR1
181 // Fix suggested by Asgeir Olafsson (olafsson@cstar.ac.com)
182 //
183 /* tree duplicate */
184
185 #ifndef PCCTS_NOT_USING_SOR
186
187 ASTBase *
188 ASTDoublyLinkedBase::dup()
189 {
190 ASTDoublyLinkedBase *u, *t=this;
191
192 if ( t == NULL ) return NULL;
193 u = (ASTDoublyLinkedBase *)this->shallowCopy();
194 u->_up = NULL; /* set by calling invocation */
195 u->_left = NULL;
196 if (t->_right!=NULL) { // MR1
197 u->_right=t->_right->dup(); // MR1
198 ((ASTDoublyLinkedBase *)u->_right)->_left = u; // MR1
199 } else { // MR1
200 u->_right = NULL; // MR1
201 }; // MR1
202 if (t->_down!=NULL) { // MR1
203 u->_down = t->_down->dup(); // MR1
204 ((ASTDoublyLinkedBase *)u->_down)->_up = u; // MR1
205 } else { // MR1
206 u->_down = NULL; // MR1
207 }; // MR1
208 return u;
209 }
210
211 #endif
212
213 /*
214 * Set the 'up', and 'left' pointers of all nodes in 't'.
215 * Initial call is double_link(your_tree, NULL, NULL).
216 */
217 void
218 ASTDoublyLinkedBase::double_link(ASTBase *left, ASTBase *up)
219 {
220 ASTDoublyLinkedBase *t = this;
221
222 t->_left = (ASTDoublyLinkedBase *) left;
223 t->_up = (ASTDoublyLinkedBase *) up;
224 if (t->_down != NULL)
225 ((ASTDoublyLinkedBase *)t->_down)->double_link(NULL, t);
226 if (t->_right != NULL)
227 ((ASTDoublyLinkedBase *)t->_right)->double_link(t, up);
228 }
229
230 // MR21 ASTBase::reportOverwriteOfDownPointer
231
232 void ASTBase::reportOverwriteOfDownPointer()
233 {
234 panic("Attempt to overwrite down pointer in ASTBase::tmake");
235 }
236
237 // MR21 ASTBase::panic
238
239 void ASTBase::panic(const char *msg)
240 {
241 /* MR23 */ printMessage(stderr,"ASTBase panic: %s\n", msg);
242 exit(PCCTS_EXIT_FAILURE);
243 }
244
245 #ifdef PCCTS_NOT_USING_SOR
246 //MR23
247 int ASTBase::printMessage(FILE* pFile, const char* pFormat, ...)
248 {
249 va_list marker;
250 va_start( marker, pFormat );
251 int iRet = vfprintf(pFile, pFormat, marker);
252 va_end( marker );
253 return iRet;
254 }
255 #endif
+0
-122
contrib/pccts/h/ASTBase.h less more
0 /* Abstract syntax tree
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef ASTBase_H
30 #define ASTBase_H
31
32 #include "pcctscfg.h"
33
34 #include "pccts_stdio.h"
35 #include "pccts_stdlib.h"
36
37 PCCTS_NAMESPACE_STD
38
39 #ifndef PCCTS_NOT_USING_SOR
40 #include "PCCTSAST.h"
41 #endif
42
43 /*
44 * Notes:
45 *
46 * To specify a copy constructor, subclass one of these classes and
47 * give the copy constructor. To use dup(), you must define shallowCopy().
48 * shallowCopy() can use either a copy constructor or just copy the node
49 * itself.
50 */
51
52 #ifdef PCCTS_NOT_USING_SOR
53 class DllExportPCCTS ASTBase {
54 #else
55 class DllExportPCCTS ASTBase : public PCCTS_AST {
56 #endif
57
58 protected:
59 ASTBase *_right, *_down;
60
61 public:
62
63 #ifdef PCCTS_NOT_USING_SOR
64 ASTBase *right() { return _right; }
65 ASTBase *down() { return _down; }
66 void setRight(ASTBase *t) { _right = (ASTBase *)t; }
67 void setDown(ASTBase *t) { _down = (ASTBase *)t; }
68 #else
69 PCCTS_AST *right() { return _right; } // define the SORCERER interface
70 PCCTS_AST *down() { return _down; }
71 void setRight(PCCTS_AST *t) { _right = (ASTBase *)t; }
72 void setDown(PCCTS_AST *t) { _down = (ASTBase *)t; }
73 #endif
74 ASTBase() { _right = _down = NULL; }
75 virtual ~ASTBase() { ; }
76 #ifndef PCCTS_NOT_USING_SOR
77 virtual ASTBase *dup();
78 #endif
79 void destroy();
80 void preorder(void* pData = NULL /* MR23 */);
81 static ASTBase *tmake(ASTBase *, ...);
82 static void link(ASTBase **, ASTBase **, ASTBase **);
83 void subchild(ASTBase **, ASTBase **, ASTBase **);
84 void subroot(ASTBase **, ASTBase **, ASTBase **);
85 virtual void preorder_action(void* /*pData*/ = NULL /* MR23 */) { ; }
86 virtual void preorder_before_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " ("); }
87 virtual void preorder_after_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " )"); }
88 virtual void panic(const char *msg); /* MR21 */
89 virtual void reportOverwriteOfDownPointer(); /* MR21 */
90 #ifdef PCCTS_NOT_USING_SOR
91 virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
92 #endif
93 };
94
95 class DllExportPCCTS ASTDoublyLinkedBase : public ASTBase {
96 protected:
97 ASTDoublyLinkedBase *_left, *_up;
98
99 public:
100 void double_link(ASTBase *left, ASTBase *up);
101
102 #ifndef PCCTS_NOT_USING_SOR
103 virtual ASTBase *dup();
104 #endif
105
106 #ifdef PCCTS_NOT_USING_SOR
107 ASTBase *left() { return _left; }
108 ASTBase *up() { return _up; }
109 void setLeft(ASTBase *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6
110 void setUp(ASTBase *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6
111 #else
112 PCCTS_AST *left() { return _left; }
113 PCCTS_AST *up() { return _up; }
114 void setLeft(PCCTS_AST *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6
115 void setUp(PCCTS_AST *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6
116 #endif
117
118 };
119
120 class AST; // announce that this class will be coming along shortly
121 #endif
+0
-88
contrib/pccts/h/ATokPtr.h less more
0 /* ATokPtr.h
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Written by Russell Quong June 30, 1995
24 * Adapted by Terence Parr to ANTLR stuff
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1989-2000
28 */
29
30 #ifndef ATokPtr_h
31 #define ATokPtr_h
32
33 #include "pcctscfg.h"
34
35 #include "pccts_stdio.h"
36
37 PCCTS_NAMESPACE_STD
38
39 // pointer to a reference counted object
40 // robust in that an unused ANTLRTokenPtr can point to NULL.
41
42 class ANTLRAbstractToken;
43
44 class DllExportPCCTS ANTLRTokenPtr {
45 public:
46 ANTLRTokenPtr(ANTLRAbstractToken *addr=NULL){ptr_ = addr; ref();}
47 ANTLRTokenPtr(const ANTLRTokenPtr &lhs) {ptr_ = lhs.ptr_; lhs.ref();}
48 ~ANTLRTokenPtr();
49
50 // use ANTLRTokenPtr as a pointer to ANTLRToken
51 //
52 // 8-Apr-97 MR1 Make operator -> a const member function
53 // as well as some other member functions
54 //
55 ANTLRAbstractToken *operator-> () const { return ptr_; } // MR1
56 //
57 // 7-Apr-97 133MR1
58 // Fix suggested by Andreas Magnusson
59 // (Andreas.Magnusson@mailbox.swipnet.se)
60 void operator = (const ANTLRTokenPtr & lhs); // MR1
61 void operator = (ANTLRAbstractToken *addr);
62 int operator != (const ANTLRTokenPtr &q) const // MR1 // MR11 unsigned -> int
63 { return this->ptr_ != q.ptr_; }
64 int operator == (const ANTLRTokenPtr &q) const // MR1 // MR11 unsigned -> int
65 { return this->ptr_ == q.ptr_; }
66 int operator == (const ANTLRAbstractToken *addr) const // MR11
67 { return this->ptr_ == addr; }
68 int operator != (const ANTLRAbstractToken *addr) const // MR11
69 { return this->ptr_ != addr; }
70
71 void ref() const;
72 void deref();
73
74 protected:
75 ANTLRAbstractToken *ptr_;
76 };
77
78 //typedef ANTLRTokenPtr _ANTLRTokenPtr;
79
80 /*
81 * Since you cannot redefine operator->() to return one of the user's
82 * token object types, we must down cast. This is a drag. Here's
83 * a macro that helps. template: "mytoken(a-smart-ptr)->myfield".
84 */
85 #define mytoken(tk) ((ANTLRToken *)(tk.operator->()))
86
87 #endif
+0
-88
contrib/pccts/h/ATokPtrImpl.h less more
0 /*
1 * ATokPtrImpl.h (formerly ATokPtr.cpp)
2 *
3 * This is #included in ATokBuffer.cpp for historical reasons.
4 * It has been renamed because of problems with the .cpp extension
5 * when used with IDE.
6 *
7 *
8 * ANTLRToken MUST be defined before entry to this file.
9 *
10 * SOFTWARE RIGHTS
11 *
12 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
13 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
14 * company may do whatever they wish with source code distributed with
15 * PCCTS or the code generated by PCCTS, including the incorporation of
16 * PCCTS, or its output, into commerical software.
17 *
18 * We encourage users to develop software with PCCTS. However, we do ask
19 * that credit is given to us for developing PCCTS. By "credit",
20 * we mean that if you incorporate our source code into one of your
21 * programs (commercial product, research project, or otherwise) that you
22 * acknowledge this fact somewhere in the documentation, research report,
23 * etc... If you like PCCTS and have developed a nice tool with the
24 * output, please mention that you developed it using PCCTS. In
25 * addition, we ask that this header remain intact in our source code.
26 * As long as these guidelines are kept, we expect to continue enhancing
27 * this system and expect to make other tools available as they are
28 * completed.
29 *
30 * ANTLR 1.33
31 * Written by Russell Quong June 30, 1995
32 * Adapted by Terence Parr to ANTLR stuff
33 * Parr Research Corporation
34 * with Purdue University and AHPCRC, University of Minnesota
35 * 1989-2000
36 */
37
38 #include "pcctscfg.h"
39
40 PCCTS_NAMESPACE_STD
41
42 #include "ATokPtr.h"
43
44 void ANTLRTokenPtr::ref() const
45 {
46 if (ptr_ != NULL) {
47 ptr_->ref();
48 }
49 }
50
51 void ANTLRTokenPtr::deref()
52 {
53 if (ptr_ != NULL)
54 {
55 ptr_->deref();
56 if ( ptr_->nref()==0 )
57 {
58 delete ptr_;
59 ptr_ = NULL;
60 }
61 }
62 }
63
64 ANTLRTokenPtr::~ANTLRTokenPtr()
65 {
66 deref();
67 }
68
69 //
70 // 8-Apr-97 MR1 Make operator -> a const member function
71 // as weall as some other member functions
72 //
73 void ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs) // MR1
74 {
75 lhs.ref(); // protect against "xp = xp"; ie same underlying object
76 deref();
77 ptr_ = lhs.ptr_;
78 }
79
80 void ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)
81 {
82 if (addr != NULL) {
83 addr->ref();
84 }
85 deref();
86 ptr_ = addr;
87 }
+0
-325
contrib/pccts/h/AToken.h less more
0 /* ANTLRToken.h
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef ATOKEN_H_GATE
30 #define ATOKEN_H_GATE
31
32 #include "pcctscfg.h"
33
34 #include "pccts_string.h"
35 #include "pccts_stdio.h"
36 #include "pccts_stdlib.h"
37 #include "pccts_stdarg.h" // MR23
38
39 PCCTS_NAMESPACE_STD
40
41 // MR9 RJV (JVincent@novell.com) Not needed for variable length strings
42
43 //// MR9 #ifndef ANTLRCommonTokenTEXTSIZE
44 //// MR9 #define ANTLRCommonTokenTEXTSIZE 100
45 //// MR9 #endif
46
47
48 /* must define what a char looks like; can make this a class too */
49 typedef char ANTLRChar;
50
51 /* D E F I N E S M A R T P O I N T E R S */
52
53 //#include ATOKPTR_H not tested yet, leave out
54 class ANTLRAbstractToken;
55 typedef ANTLRAbstractToken *_ANTLRTokenPtr;
56
57 class ANTLRAbstractToken {
58 public:
59 virtual ~ANTLRAbstractToken() {;}
60 virtual ANTLRTokenType getType() const = 0;
61 virtual void setType(ANTLRTokenType t) = 0;
62 virtual int getLine() const = 0;
63 virtual void setLine(int line) = 0;
64 virtual ANTLRChar *getText() const = 0;
65 virtual void setText(const ANTLRChar *) = 0;
66
67 /* This function will disappear when I can use templates */
68 virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
69 ANTLRChar *text,
70 int line) = 0;
71
72 /* define to satisfy ANTLRTokenBuffer's need to determine whether or
73 not a token object can be destroyed. If nref()==0, no one has
74 a reference, and the object may be destroyed. This function defaults
75 to 1, hence, if you use deleteTokens() message with a token object
76 not derived from ANTLRCommonRefCountToken, the parser will compile
77 but will not delete objects after they leave the token buffer.
78 */
79
80 virtual unsigned nref() const { return 1; } // MR11
81 virtual void ref() {;}
82 virtual void deref() {;}
83
84 virtual void panic(const char *msg) // MR20 const
85 {
86 /* MR23 */ printMessage(stderr, "ANTLRAbstractToken panic: %s\n", msg);
87 exit(PCCTS_EXIT_FAILURE);
88 }
89
90 virtual int printMessage(FILE* pFile, const char* pFormat, ...) // MR23
91 {
92 va_list marker;
93 va_start( marker, pFormat );
94 int iRet = vfprintf(pFile, pFormat, marker);
95 va_end( marker );
96 return iRet;
97 }
98 };
99
100 /* This class should be subclassed. It cannot store token type or text */
101
102 class ANTLRRefCountToken : public ANTLRAbstractToken {
103 public:
104 #ifdef DBG_REFCOUNTTOKEN
105 static int ctor;
106 static int dtor;
107 #endif
108 protected:
109 unsigned refcnt_;
110 #ifdef DBG_REFCOUNTTOKEN
111 char object[200];
112 #endif
113
114 public:
115
116 // MR23 - No matter what you do, you're hammered.
117 // Don't give names to formals something breaks.
118 // Give names to formals and don't use them it breaks.
119
120 #ifndef DBG_REFCOUNTTOKEN
121 ANTLRRefCountToken(ANTLRTokenType /* t MR23 */, const ANTLRChar * /* s MR23 */)
122 #else
123 ANTLRRefCountToken(ANTLRTokenType t, const ANTLRChar * s)
124 #endif
125
126 #ifndef DBG_REFCOUNTTOKEN
127 {
128 refcnt_ = 0;
129 }
130 #else
131 {
132 ctor++;
133 refcnt_ = 0;
134 if ( t==1 ) sprintf(object,"tok_EOF");
135 else sprintf(object,"tok_%s",s);
136 /* MR23 */ printMessage(stderr, "ctor %s #%d\n",object,ctor);
137 }
138 #endif
139 ANTLRRefCountToken()
140 #ifndef DBG_REFCOUNTTOKEN
141 { refcnt_ = 0; }
142 #else
143 {
144 ctor++;
145 refcnt_ = 0;
146 sprintf(object,"tok_blank");
147 /* MR23 */ printMessage(stderr, "ctor %s #%d\n",object,ctor);
148 }
149 virtual ~ANTLRRefCountToken()
150 {
151 dtor++;
152 if ( dtor>ctor ) /* MR23 */ printMessage(stderr, "WARNING: dtor>ctor\n");
153 /* MR23 */ printMessage(stderr, "dtor %s #%d\n", object, dtor);
154 object[0]='\0';
155 }
156 #endif
157
158 // reference counting stuff needed by ANTLRTokenPtr.
159 // User should not access these; for C++ language reasons, we had
160 // to make these public. Yuck.
161
162 void ref() { refcnt_++; }
163 void deref() { refcnt_--; }
164 unsigned nref() const { return refcnt_; } // MR11
165
166 virtual ANTLRAbstractToken *makeToken(ANTLRTokenType /*tt MR23*/,
167 ANTLRChar * /*txt MR23*/,
168 int /*line MR23*/)
169 {
170 panic("call to ANTLRRefCountToken::makeToken()\n");
171 return NULL;
172 }
173 };
174
175 class ANTLRCommonNoRefCountToken : public ANTLRAbstractToken {
176 protected:
177 ANTLRTokenType _type;
178 int _line;
179 ANTLRChar *_text; // MR9 RJV
180
181 public:
182 ANTLRCommonNoRefCountToken(ANTLRTokenType t, const ANTLRChar *s)
183 { setType(t); _line = 0; _text = NULL; setText(s); }
184 ANTLRCommonNoRefCountToken()
185 { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); }
186
187 ~ANTLRCommonNoRefCountToken() { if (_text) delete [] _text; } // MR9 RJV: Added Destructor to remove string
188
189 ANTLRTokenType getType() const { return _type; }
190 void setType(ANTLRTokenType t) { _type = t; }
191 virtual int getLine() const { return _line; }
192 void setLine(int line) { _line = line; }
193 ANTLRChar *getText() const { return _text; }
194 int getLength() const { return strlen(getText()); } // MR11
195
196 // MR9 RJV: Added code for variable length strings to setText()
197
198 void setText(const ANTLRChar *s)
199 { if (s != _text) {
200 if (_text) delete [] _text;
201 if (s != NULL) {
202 _text = new ANTLRChar[strlen(s)+1];
203 if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");
204 strcpy(_text,s);
205 } else {
206 _text = new ANTLRChar[1];
207 if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");
208 strcpy(_text,"");
209 };
210 };
211 }
212
213 virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
214 ANTLRChar *txt,
215 int line)
216 {
217 ANTLRAbstractToken *t = new ANTLRCommonNoRefCountToken;
218 t->setType(tt); t->setText(txt); t->setLine(line);
219 return t;
220 }
221
222 // MR9 THM Copy constructor required when heap allocated string is used with copy semantics
223
224 ANTLRCommonNoRefCountToken (const ANTLRCommonNoRefCountToken& from) :
225 ANTLRAbstractToken(from) {
226 setType(from._type);
227 setLine(from._line);
228 _text=NULL;
229 setText(from._text);
230 };
231
232 // MR9 THM operator =() required when heap allocated string is used with copy semantics
233
234 virtual ANTLRCommonNoRefCountToken& operator =(const ANTLRCommonNoRefCountToken& rhs) {
235
236 ////// MR15 WatCom can't hack use of operator =()
237 ////// Use this: *( (ANTRLAbstractToken *) this)=rhs;
238
239 *( (ANTLRAbstractToken *) this ) = rhs;
240
241 setType(rhs._type);
242 setLine(rhs._line);
243 setText(rhs._text);
244 return *this;
245 };
246 };
247
248 class ANTLRCommonToken : public ANTLRRefCountToken {
249 protected:
250 ANTLRTokenType _type;
251 int _line;
252 ANTLRChar *_text; // MR9 RJV:Added
253
254 public:
255 ANTLRCommonToken(ANTLRTokenType t, const ANTLRChar *s) : ANTLRRefCountToken(t,s)
256 { setType(t); _line = 0; _text = NULL; setText(s); } // MR9
257 ANTLRCommonToken()
258 { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); } // MR9
259
260 virtual ~ANTLRCommonToken() { if (_text) delete [] _text; } // MR9 RJV: Added Destructor to remove string
261
262 ANTLRTokenType getType() const { return _type; }
263 void setType(ANTLRTokenType t) { _type = t; }
264 virtual int getLine() const { return _line; }
265 void setLine(int line) { _line = line; }
266 ANTLRChar *getText() const { return _text; }
267 int getLength() const { return strlen(getText()); } // MR11
268
269 // MR9 RJV: Added code for variable length strings to setText()
270
271 void setText(const ANTLRChar *s)
272 { if (s != _text) {
273 if (_text) delete [] _text;
274 if (s != NULL) {
275 _text = new ANTLRChar[strlen(s)+1];
276 if (_text == NULL) panic("ANTLRCommonToken::setText new failed");
277 strcpy(_text,s);
278 } else {
279 _text = new ANTLRChar[1];
280 if (_text == NULL) panic("ANTLRCommonToken::setText new failed");
281 strcpy(_text,"");
282 };
283 };
284 }
285
286 virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
287 ANTLRChar *txt,
288 int line)
289 {
290 ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);
291 t->setLine(line);
292 return t;
293 }
294
295 // MR9 THM Copy constructor required when heap allocated string is used with copy semantics
296
297 ANTLRCommonToken (const ANTLRCommonToken& from) :
298 ANTLRRefCountToken(from) {
299 setType(from._type);
300 setLine(from._line);
301 _text=NULL;
302 setText(from._text);
303 };
304
305 // MR9 THM operator =() required when heap allocated string is used with copy semantics
306
307 virtual ANTLRCommonToken& operator =(const ANTLRCommonToken& rhs) {
308
309 ////// MR15 WatCom can't hack use of operator =()
310 ////// Use this instead: *( (ANTRLRRefCountToken *) this)=rhs;
311
312 *( (ANTLRRefCountToken *) this) = rhs;
313
314 setType(rhs._type);
315 setLine(rhs._line);
316 setText(rhs._text);
317 return *this;
318 };
319 };
320
321 // used for backward compatibility
322 typedef ANTLRCommonToken ANTLRCommonBacktrackingToken;
323
324 #endif
+0
-374
contrib/pccts/h/ATokenBuffer.cpp less more
0 /* ANTLRTokenBuffer.cpp
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 typedef int ANTLRTokenType; // fool AToken.h into compiling
30
31 class ANTLRParser; /* MR1 */
32
33 #define ANTLR_SUPPORT_CODE
34
35 #include "pcctscfg.h"
36
37 #include ATOKENBUFFER_H
38 #include APARSER_H // MR23
39
40 typedef ANTLRAbstractToken *_ANTLRTokenPtr;
41
42 #if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)
43 static unsigned char test[1000];
44 #endif
45
46 #ifdef DBG_REFCOUNTTOKEN
47 int ANTLRRefCountToken::ctor = 0; /* MR23 */
48 int ANTLRRefCountToken::dtor = 0; /* MR23 */
49 #endif
50
51 ANTLRTokenBuffer::
52 ANTLRTokenBuffer(ANTLRTokenStream *_input, int _k, int _chunk_size_formal) /* MR14 */
53 {
54 this->input = _input;
55 this->k = _k;
56 buffer_size = chunk_size = _chunk_size_formal;
57 buffer = (_ANTLRTokenPtr *)
58 calloc(chunk_size+1,sizeof(_ANTLRTokenPtr ));
59 if ( buffer == NULL ) {
60 panic("cannot alloc token buffer");
61 }
62 buffer++; // leave the first elem empty so tp-1 is valid ptr
63
64 tp = &buffer[0];
65 last = tp-1;
66 next = &buffer[0];
67 num_markers = 0;
68 end_of_buffer = &buffer[buffer_size-1];
69 threshold = &buffer[(int)(buffer_size/2)]; // MR23 - Used to be 1.0/2.0 !
70 _deleteTokens = 1; // assume we delete tokens
71 parser=NULL; // MR5 - uninitialized reference
72 }
73
74 static void f() {;}
75 ANTLRTokenBuffer::
76 ~ANTLRTokenBuffer()
77 {
78 f();
79 // Delete all remaining tokens (from 0..last inclusive)
80 if ( _deleteTokens )
81 {
82 _ANTLRTokenPtr *z;
83 for (z=buffer; z<=last; z++)
84 {
85 (*z)->deref();
86 // z->deref();
87 #ifdef DBG_REFCOUNTTOKEN
88 /* MR23 */ printMessage(stderr, "##########dtor: deleting token '%s' (ref %d)\n",
89 ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());
90 #endif
91 if ( (*z)->nref()==0 )
92 {
93 delete (*z);
94 }
95 }
96 }
97
98 if ( buffer!=NULL ) free((char *)(buffer-1));
99 }
100
101 #if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)
102 #include "pccts_stdio.h"
103 PCCTS_NAMESPACE_STD
104 #endif
105
106 _ANTLRTokenPtr ANTLRTokenBuffer::
107 getToken()
108 {
109 if ( tp <= last ) // is there any buffered lookahead still to be read?
110 {
111 return *tp++; // read buffered lookahead
112 }
113 // out of buffered lookahead, get some more "real"
114 // input from getANTLRToken()
115 if ( num_markers==0 )
116 {
117 if( next > threshold )
118 {
119 #ifdef DBG_TBUF
120 /* MR23 */ printMessage(stderr,"getToken: next > threshold (high water is %d)\n", threshold-buffer);
121 #endif
122 makeRoom();
123 }
124 }
125 else {
126 if ( next > end_of_buffer )
127 {
128 #ifdef DBG_TBUF
129 /* MR23 */ printMessage(stderr,"getToken: next > end_of_buffer (size is %d)\n", buffer_size);
130 #endif
131 extendBuffer();
132 }
133 }
134 *next = getANTLRToken();
135 (*next)->ref(); // say we have a copy of this pointer in buffer
136 last = next;
137 next++;
138 tp = last;
139 return *tp++;
140 }
141
142 void ANTLRTokenBuffer::
143 rewind(int pos)
144 {
145 #if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)
146 /* MR23 */ printMessage(stderr, "rewind(%d)[nm=%d,from=%d,%d.n=%d]\n", pos, num_markers, tp-buffer,pos,test[pos]);
147 test[pos]--;
148 #endif
149 tp = &buffer[pos];
150 num_markers--;
151 }
152
153 /*
154 * This function is used to specify that the token pointers read
155 * by the ANTLRTokenBuffer should be buffered up (to be reused later).
156 */
157 int ANTLRTokenBuffer::
158 mark()
159 {
160 #if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)
161 test[tp-buffer]++;
162 /* MR23 */ printMessage(stderr,"mark(%d)[nm=%d,%d.n=%d]\n",tp-buffer,num_markers+1,tp-buffer,test[tp-buffer]);
163 #endif
164 num_markers++;
165 return tp - buffer;
166 }
167
168 /*
169 * returns the token pointer n positions ahead.
170 * This implies that bufferedToken(1) gets the NEXT symbol of lookahead.
171 * This is used in conjunction with the ANTLRParser lookahead buffer.
172 *
173 * No markers are set or anything. A bunch of input is buffered--that's all.
174 * The tp pointer is left alone as the lookahead has not been advanced
175 * with getToken(). The next call to getToken() will find a token
176 * in the buffer and won't have to call getANTLRToken().
177 *
178 * If this is called before a consume() is done, how_many_more_i_need is
179 * set to 'n'.
180 */
181 _ANTLRTokenPtr ANTLRTokenBuffer::
182 bufferedToken(int n)
183 {
184 // int how_many_more_i_need = (last-tp < 0) ? n : n-(last-tp)-1;
185 int how_many_more_i_need = (tp > last) ? n : n-(last-tp)-1;
186 // Make sure that at least n tokens are available in the buffer
187 #ifdef DBG_TBUF
188 /* MR23 */ printMessage(stderr, "bufferedToken(%d)\n", n);
189 #endif
190 for (int i=1; i<=how_many_more_i_need; i++)
191 {
192 if ( next > end_of_buffer ) // buffer overflow?
193 {
194 extendBuffer();
195 }
196 *next = getANTLRToken();
197 (*next)->ref(); // say we have a copy of this pointer in buffer
198 last = next;
199 next++;
200 }
201 return tp[n - 1];
202 }
203
204 /* If no markers are set, the none of the input needs to be saved (except
205 * for the lookahead Token pointers). We save only k-1 token pointers as
206 * we are guaranteed to do a getANTLRToken() right after this because otherwise
207 * we wouldn't have needed to extend the buffer.
208 *
209 * If there are markers in the buffer, we need to save things and so
210 * extendBuffer() is called.
211 */
212 void ANTLRTokenBuffer::
213 makeRoom()
214 {
215 #ifdef DBG_TBUF
216 /* MR23 */ printMessage(stderr, "in makeRoom.................\n");
217 /* MR23 */ printMessage(stderr, "num_markers==%d\n", num_markers);
218 #endif
219 /*
220 if ( num_markers == 0 )
221 {
222 */
223 #ifdef DBG_TBUF
224 /* MR23 */ printMessage(stderr, "moving lookahead and resetting next\n");
225
226 _ANTLRTokenPtr *r;
227 /* MR23 */ printMessage(stderr, "tbuf = [");
228 for (r=buffer; r<=last; r++)
229 {
230 if ( *r==NULL ) /* MR23 */ printMessage(stderr, " xxx");
231 else /* MR23 */ printMessage(stderr, " '%s'", ((ANTLRCommonToken *)*r)->getText());
232 }
233 /* MR23 */ printMessage(stderr, " ]\n");
234
235 /* MR23 */ printMessage(stderr,
236 "before: tp=%d, last=%d, next=%d, threshold=%d\n",tp-buffer,last-buffer,next-buffer,threshold-buffer);
237 #endif
238
239 // Delete all tokens from 0..last-(k-1) inclusive
240 if ( _deleteTokens )
241 {
242 _ANTLRTokenPtr *z;
243 for (z=buffer; z<=last-(k-1); z++)
244 {
245 (*z)->deref();
246 // z->deref();
247 #ifdef DBG_REFCOUNTTOKEN
248 /* MR23 */ printMessage(stderr, "##########makeRoom: deleting token '%s' (ref %d)\n",
249 ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());
250 #endif
251 if ( (*z)->nref()==0 )
252 {
253 delete (*z);
254 }
255 }
256 }
257
258 // reset the buffer to initial conditions, but move k-1 symbols
259 // to the beginning of buffer and put new input symbol at k
260 _ANTLRTokenPtr *p = buffer, *q = last-(k-1)+1;
261 // ANTLRAbstractToken **p = buffer, **q = end_of_buffer-(k-1)+1;
262 #ifdef DBG_TBUF
263 /* MR23 */ printMessage(stderr, "lookahead buffer = [");
264 #endif
265 for (int i=1; i<=(k-1); i++)
266 {
267 *p++ = *q++;
268 #ifdef DBG_TBUF
269 /* MR23 */ printMessage(stderr,
270 " '%s'", ((ANTLRCommonToken *)buffer[i-1])->getText());
271 #endif
272 }
273 #ifdef DBG_TBUF
274 /* MR23 */ printMessage(stderr, " ]\n");
275 #endif
276 next = &buffer[k-1];
277 tp = &buffer[k-1]; // tp points to what will be filled in next
278 last = tp-1;
279 #ifdef DBG_TBUF
280 /* MR23 */ printMessage(stderr,
281 "after: tp=%d, last=%d, next=%d\n",
282 tp-buffer, last-buffer, next-buffer);
283 #endif
284 /*
285 }
286 else {
287 extendBuffer();
288 }
289 */
290 }
291
292 /* This function extends 'buffer' by chunk_size and returns with all
293 * pointers at the same relative positions in the buffer (the buffer base
294 * address could have changed in realloc()) except that 'next' comes
295 * back set to where the next token should be stored. All other pointers
296 * are untouched.
297 */
298 void
299 ANTLRTokenBuffer::
300 extendBuffer()
301 {
302 int save_last = last-buffer, save_tp = tp-buffer, save_next = next-buffer;
303 #ifdef DBG_TBUF
304 /* MR23 */ printMessage(stderr, "extending physical buffer\n");
305 #endif
306 buffer_size += chunk_size;
307 buffer = (_ANTLRTokenPtr *)
308 realloc((char *)(buffer-1),
309 (buffer_size+1)*sizeof(_ANTLRTokenPtr ));
310 if ( buffer == NULL ) {
311 panic("cannot alloc token buffer");
312 }
313 buffer++; // leave the first elem empty so tp-1 is valid ptr
314
315 tp = buffer + save_tp; // put the pointers back to same relative position
316 last = buffer + save_last;
317 next = buffer + save_next;
318 end_of_buffer = &buffer[buffer_size-1];
319 threshold = &buffer[(int)(buffer_size*(1.0/2.0))];
320
321 /*
322 // zero out new token ptrs so we'll know if something to delete in buffer
323 ANTLRAbstractToken **p = end_of_buffer-chunk_size+1;
324 for (; p<=end_of_buffer; p++) *p = NULL;
325 */
326 }
327
328 ANTLRParser * ANTLRTokenBuffer:: // MR1
329 setParser(ANTLRParser *p) { // MR1
330 ANTLRParser *old=parser; // MR1
331 parser=p; // MR1
332 input->setParser(p); // MR1
333 return old; // MR1
334 } // MR1
335 // MR1
336 ANTLRParser * ANTLRTokenBuffer:: // MR1
337 getParser() { // MR1
338 return parser; // MR1
339 } // MR1
340
341 void ANTLRTokenBuffer::panic(const char *msg) // MR23
342 {
343 if (parser) //MR23
344 parser->panic(msg); //MR23
345 else //MR23
346 exit(PCCTS_EXIT_FAILURE);
347 }
348
349 //MR23
350 int ANTLRTokenBuffer::printMessage(FILE* pFile, const char* pFormat, ...)
351 {
352 va_list marker;
353 va_start( marker, pFormat );
354
355 int iRet = 0;
356 if (parser)
357 parser->printMessageV(pFile, pFormat, marker);
358 else
359 iRet = vfprintf(pFile, pFormat, marker);
360
361 va_end( marker );
362 return iRet;
363 }
364
365 /* to avoid having to link in another file just for the smart token ptr
366 * stuff, we include it here. Ugh.
367 *
368 * MR23 This causes nothing but problems for IDEs.
369 * Change from .cpp to .h
370 *
371 */
372
373 #include ATOKPTR_IMPL_H
+0
-109
contrib/pccts/h/ATokenBuffer.h less more
0 /* ANTLRTokenBuffer.h
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef ATOKENBUFFER_H_GATE
30 #define ATOKENBUFFER_H_GATE
31
32 #include "pcctscfg.h"
33
34 #include "pccts_stdlib.h"
35
36 PCCTS_NAMESPACE_STD
37
38 #include ATOKEN_H
39 #include ATOKENSTREAM_H
40
41 /*
42 * The parser is "attached" to an ANTLRTokenBuffer via interface
43 * functions: getToken() and bufferedToken(). The object that actually
44 * consumes characters and constructs tokens is connected to the
45 * ANTLRTokenBuffer via interface function ANTLRTokenStream::getToken();
46 * where ANTLRTokenStream is really just a behavior (class with no data).
47 * C++ does not have this abstraction and hence we simply have come up
48 * with a fancy name for "void *". See the note in ANTLRTokenStream.h on
49 * the "behavior" of ANTLRTokenStream.
50 */
51
52 class ANTLRParser; // MR1
53
54 class DllExportPCCTS ANTLRTokenBuffer {
55 protected:
56 ANTLRTokenStream *input; // where do I get tokens
57 int buffer_size;
58 int chunk_size;
59 int num_markers;
60 int k; // Need at least this many tokens in buffer
61 _ANTLRTokenPtr *buffer; // buffer used for arbitrary lookahead
62 _ANTLRTokenPtr *tp; // pts into buffer; current token ptr
63 _ANTLRTokenPtr *last; // pts to last valid token in buffer
64 _ANTLRTokenPtr *next; // place to put token from getANTLRToken()
65 _ANTLRTokenPtr *end_of_buffer;
66 /* when you try to write a token past this and there are no markers
67 set, then move k-1 tokens back to the beginning of the buffer.
68 We want to stay away from the end of the buffer because we have
69 to extend it if a marker is set and we reach the end (we cannot
70 move tokens to the beginning of the buffer in this case).
71 */
72 _ANTLRTokenPtr *threshold;
73 unsigned char _deleteTokens;
74
75 // This function is filled in by the subclass; it initiates fetch of input
76 virtual _ANTLRTokenPtr getANTLRToken() { return input->getToken(); }
77 void makeRoom();
78 void extendBuffer();
79
80 public:
81 ANTLRTokenBuffer(ANTLRTokenStream *in, int k=1, int chksz=50);
82 virtual ~ANTLRTokenBuffer();
83 virtual _ANTLRTokenPtr getToken();
84 virtual void rewind(int pos);
85 virtual int mark();
86 virtual _ANTLRTokenPtr bufferedToken(int i);
87
88 void noGarbageCollectTokens() { _deleteTokens=0; }
89 void garbageCollectTokens() { _deleteTokens=1; }
90
91 virtual int bufferSize() { return buffer_size; }
92 virtual int minTokens() { return k; }
93 virtual void setMinTokens(int k_new) { k = k_new; }
94
95 virtual void panic(const char *msg); /* MR20 const */
96
97 virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
98
99 protected: // MR1
100 ANTLRParser *parser; // MR1
101 public: // MR1
102 ANTLRParser *setParser(ANTLRParser *p); // MR1
103 ANTLRParser *getParser(); // MR1
104 ANTLRTokenStream *getLexer() const { // MR12
105 return input;} // MR12
106 };
107
108 #endif
+0
-51
contrib/pccts/h/ATokenStream.h less more
0 /* ANTLRTokenStream.h
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef ATOKENSTREAM_H_GATE
30 #define ATOKENSTREAM_H_GATE
31
32 #include "pcctscfg.h"
33
34 /* This is really a behavior or protocol; it merely indicates the behavior
35 * required of the input and output of an ANTLRTokenBuffer. You could
36 * subclass it, but you can also just pass any old pointer to ANTLRTokenBuffer
37 * with a type cast (in which case, your getANTLRToken() would have to
38 * explicitly cast the input pointer to your REAL type (typically your lexer)).
39 */
40
41 class ANTLRParser; // MR1
42
43 class DllExportPCCTS ANTLRTokenStream {
44 public:
45 virtual _ANTLRTokenPtr getToken() = 0;
46 virtual ANTLRParser * setParser(ANTLRParser * /*p MR23*/) {return 0; }; // MR12
47 virtual ANTLRParser * getParser() { return 0; }; // MR12
48 };
49
50 #endif
+0
-100
contrib/pccts/h/BufFileInput.cpp less more
0 // FILE: BufFileInput.cpp
1 // AUTHOR: Alexey Demakov (AVD) demakov@kazbek.ispras.ru
2 // CREATION: 26-JAN-1998
3 // DESCRIPTION: File Input Stream with lookahead for Scanner.
4 // See file BufFileInput.h for details
5
6 // Change History:
7 //
8 // 22-Jun-1998 assert.h -> PCCTS_ASSERT_H
9 // string.h -> PCCTS_STRING_H
10 //
11 // 28-May-1998 Add virtual destructor to release buffer.
12 //
13 // Add dummy definition for ANTLRTokenType
14 // to allow compilation without knowing
15 // token type codes.
16 //
17 // Manfred Kogler (km@cast.uni-linz.ac.at)
18 // (1.33MR14)
19 //
20 // 20-Jul-1998 MR14a - Reorder initialization list for ctor.
21 //
22
23 enum ANTLRTokenType {TER_HATES_CPP=0, SO_DO_OTHERS=9999 };
24
25 #include "pcctscfg.h"
26 #include "pccts_assert.h"
27 #include "pccts_string.h"
28
29 PCCTS_NAMESPACE_STD
30
31 #include "BufFileInput.h"
32
33 BufFileInput::BufFileInput( FILE *f, int buf_size )
34 : input( f ),
35 buf( new int[buf_size] ),
36 size( buf_size ),
37 start( 0 ),
38 len( 0 )
39 {
40 }
41
42 BufFileInput::~BufFileInput()
43 {
44 delete [] buf;
45 }
46
47 int BufFileInput::nextChar( void )
48 {
49 if( len > 0 )
50 {
51 // get char from buffer
52 int c = buf[start];
53
54 if( c != EOF )
55 {
56 start++; start %= size;
57 len--;
58 }
59 return c;
60 } else {
61 // get char from file
62 int c = getc( input );
63
64 if( c == EOF )
65 {
66 // if EOF - put it in the buffer as indicator
67 buf[start] = EOF;
68 len++;
69 }
70 return c;
71 }
72 }
73
74 int BufFileInput::lookahead( char* s )
75 {
76 int l = strlen( s );
77
78 assert( 0 < l && l <= size );
79
80 while( len < l )
81 {
82 int c = getc( input );
83
84 buf[ (start+len) % size ] = c;
85
86 len++;
87
88 if( c == EOF ) return 0;
89 }
90
91 for( int i = 0; i < l; i++ )
92 {
93 if( s[i] != buf[ (start+i) % size ] ) return 0;
94 }
95 return 1;
96 }
97
98 // End of file BufFileInput.cpp
99
+0
-53
contrib/pccts/h/BufFileInput.h less more
0 // FILE: BufFileInput.h
1 // AUTHOR: Alexey Demakov (AVD) demakov@kazbek.ispras.ru
2 // CREATION: 26-JAN-1998
3 // DESCRIPTION: File Input Stream with lookahead for Scanner
4 // Tested under Win32 with ANTLR 1.33 MR10 and MSVC 5.0
5
6 // Change History:
7 //
8 // 28-May-1998 Add virtual destructor to release buffer
9 // Manfred Kogler (km@cast.uni-linz.ac.at)
10 // (1.33MR14)
11
12 #ifndef BufFileInput_h
13 #define BufFileInput_h
14
15 #include "pcctscfg.h"
16
17 #include "pccts_stdio.h"
18
19 PCCTS_NAMESPACE_STD
20
21 #include "DLexerBase.h"
22
23 class DllExportPCCTS BufFileInput : public DLGInputStream
24 {
25 public:
26 // constructor
27 // f - input stream
28 // buf_size - size of buffer (maximal length for string in is_in)
29
30 BufFileInput(FILE *f, int buf_size = 8 );
31
32 virtual ~BufFileInput();
33
34 // gets next char from stream
35
36 virtual int nextChar( void );
37
38 // looks in stream and compares next l characters with s
39 // returns the result of comparision
40
41 int lookahead( char* s );
42
43 private:
44 FILE *input; // input stream;
45 int* buf; // buffer
46 int size; // size of buffer
47 int start; // position of the first symbol in buffer
48 int len; // count of characters in buffers
49 };
50
51 #endif
52 // end of file BufFileInput.h
+0
-98
contrib/pccts/h/DLG_stream_input.h less more
0
1 /************************************************************/
2 /* */
3 /* Predefined char stream: Input from (c++) stream. */
4 /* */
5 /* By Hubert Holin (Hubert.Holin@Bigfoot.com), 1998. */
6 /* */
7 /* This is completely free stuff, do whatever you want with */
8 /* it (but then, I will take no responsability for whatever */
9 /* may happen if you do either... caveat emptor!). */
10 /* */
11 /************************************************************/
12
13 #ifndef _DLG_STREAM_INPUT_H
14 #define _DLG_STREAM_INPUT_H
15
16 #include "pccts_istream.h"
17
18 PCCTS_NAMESPACE_STD
19
20 #ifndef DLGX_H
21 #include "DLexerBase.h"
22 #endif
23
24
25 // NOTES: The semantics of the copy constructor
26 // and the affectation operator may be unwaranted...
27 // and the stream may not be reset.
28 //
29 // It would have been so much nicer for nextChar()
30 // to throw (of for the DLGInputStream to change status)
31 // upon hiting EOF than to return an "int"...
32
33 template <
34 class E,
35 class T = ::std::char_traits<E>
36 >
37 class DLG_stream_input : public DLGInputStream
38 {
39 public:
40
41 DLG_stream_input(::std::basic_istream<E,T> * p_input_stream)
42 : input(p_input_stream)
43 {
44 // nothing to do!
45 };
46
47 DLG_stream_input(const DLG_stream_input & a_recopier)
48 : input(a_recopier.input)
49 {
50 // nothing to do!
51 };
52
53 virtual ~DLG_stream_input()
54 {
55 this->purge(); // bloody templarized lookup...
56 };
57
58 DLG_stream_input operator = (const DLG_stream_input & a_affecter)
59 {
60 if (this != &a_affecter)
61 {
62 input = a_affecter.input;
63 }
64
65 return(*this);
66 };
67
68 virtual int nextChar()
69 {
70 E extracted_stuff;
71
72 input->get(extracted_stuff);
73
74 if (*input)
75 {
76 return(int(extracted_stuff));
77 }
78 else
79 {
80 return(EOF);
81 }
82 };
83
84 protected:
85
86 ::std::basic_istream<E,T> * input;
87
88 private:
89
90 void purge()
91 {
92 // nothing to do!
93 };
94 };
95
96 #endif /* _DLG_STREAM_INPUT_H */
97
+0
-191
contrib/pccts/h/DLexer.h less more
0 /* DLexer.h (formerly DLexer.cpp)
1 *
2 * This was renamed because the use of the .cpp extension caused problems
3 * with IDEs.
4 *
5 * SOFTWARE RIGHTS
6 *
7 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
8 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
9 * company may do whatever they wish with source code distributed with
10 * PCCTS or the code generated by PCCTS, including the incorporation of
11 * PCCTS, or its output, into commerical software.
12 *
13 * We encourage users to develop software with PCCTS. However, we do ask
14 * that credit is given to us for developing PCCTS. By "credit",
15 * we mean that if you incorporate our source code into one of your
16 * programs (commercial product, research project, or otherwise) that you
17 * acknowledge this fact somewhere in the documentation, research report,
18 * etc... If you like PCCTS and have developed a nice tool with the
19 * output, please mention that you developed it using PCCTS. In
20 * addition, we ask that this header remain intact in our source code.
21 * As long as these guidelines are kept, we expect to continue enhancing
22 * this system and expect to make other tools available as they are
23 * completed.
24 *
25 * ANTLR 1.33
26 * Terence Parr
27 * Parr Research Corporation
28 * with Purdue University and AHPCRC, University of Minnesota
29 * 1989-2000
30 */
31
32 #define ZZINC {if ( track_columns ) (++_endcol);}
33
34 #define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}
35
36 #define ZZNEWSTATE (newstate = dfa[state][cl])
37
38 #ifndef ZZCOPY
39 #define ZZCOPY \
40 /* Truncate matching buffer to size (not an error) */ \
41 if (nextpos < lastpos){ \
42 *(nextpos++) = ch; \
43 }else{ \
44 bufovf = 1; \
45 }
46 #endif
47
48 void DLGLexer::
49 mode( int m )
50 {
51 /* points to base of dfa table */
52 if (m<MAX_MODE){
53 automaton = m;
54 /* have to redo class since using different compression */
55 cl = ZZSHIFT(ch);
56 }else{
57 sprintf((char *)ebuf,"Invalid automaton mode = %d ",m);
58 errstd(ebuf);
59 }
60 }
61
62 ANTLRTokenType DLGLexer::
63 nextTokenType(void)
64 {
65 register int state, newstate;
66 /* last space reserved for the null char */
67 register DLGChar *lastpos;
68 ANTLRTokenType tk;
69
70 skip:
71 bufovf = 0;
72 lastpos = &_lextext[_bufsize-1];
73 nextpos = _lextext;
74 _begcol = _endcol+1;
75 more:
76 _begexpr = nextpos;
77 if ( interactive ) {
78 /* interactive version of automaton */
79 /* if there is something in ch, process it */
80 state = newstate = dfa_base[automaton];
81 if (charfull){
82 ZZINC;
83 ZZCOPY;
84 ZZNEWSTATE;
85 }
86 while (alternatives[newstate]){
87 state = newstate;
88 ZZGETC;
89 ZZINC;
90 ZZCOPY;
91 ZZNEWSTATE;
92 }
93 /* figure out if last character really part of token */
94 if ((state != dfa_base[automaton]) && (newstate == DfaStates)){
95 charfull = 1;
96 --nextpos;
97 }else{
98 charfull = 0;
99 state = newstate;
100 }
101 *(nextpos) = '\0';
102 /* Able to transition out of start state to some non err state?*/
103 if ( state == dfa_base[automaton] ){
104 /* make sure doesn't get stuck */
105 advance();
106 }
107 }
108 else { /* non-interactive version of automaton */
109 if (!charfull)
110 advance();
111 else
112 ZZINC;
113 state = dfa_base[automaton];
114 while (ZZNEWSTATE != DfaStates) {
115 state = newstate;
116 ZZCOPY;
117 ZZGETC;
118 ZZINC;
119 }
120 charfull = 1;
121 if ( state == dfa_base[automaton] ){
122 if (nextpos < lastpos){
123 *(nextpos++) = ch;
124 }else{
125 bufovf = 1;
126 }
127 *nextpos = '\0';
128 /* make sure doesn't get stuck */
129 advance();
130 }else{
131 *nextpos = '\0';
132 }
133 }
134 if ( track_columns ) _endcol -= charfull;
135 _endexpr = nextpos -1;
136 add_erase = 0;
137 #ifdef OLD
138 tk = (ANTLRTokenType)
139 (*actions[accepts[state]])(this); // must pass this manually
140 // actions is not a [] of pointers
141 // to member functions.
142 #endif
143 tk = (this->*actions[accepts[state]])();
144
145 // MR1
146 // MR1 11-Apr-97 Help for tracking DLG results
147 // MR1
148
149 #ifdef DEBUG_LEXER
150
151 /* MR1 */ if (debugLexerFlag) {
152 /* MR1 */ if (parser != NULL) {
153 /* MR1 */ /* MR23 */ printMessage(stdout, "\ntoken name=%s",parser->parserTokenName(tk));
154 /* MR1 */ } else {
155 /* MR1 */ /* MR23 */ printMessage(stdout, "\ntoken nnumber=%d",tk);
156 /* MR1 */ };
157 /* MR1 */ /* MR23 */ printMessage(stdout, " lextext=(%s) mode=%d",
158 /* MR1 */ (_lextext[0]=='\n' && _lextext[1]==0) ?
159 /* MR1 */ "newline" : _lextext,
160 /* MR1 */ automaton);
161 /* MR1 */ if (interactive && !charfull) {
162 /* MR1 */ /* MR23 */ printMessage(stdout, " char=empty");
163 /* MR1 */ } else {
164 /* MR1 */ if (ch=='\n') {
165 /* MR1 */ /* MR23 */ printMessage(stdout, " char=newline");
166 /* MR1 */ } else {
167 /* MR1 */ /* MR23 */ printMessage(stdout, " char=(%c)",ch);
168 /* MR1 */ };
169 /* MR1 */ };
170 /* MR1 */ /* MR23 */ printMessage(stdout, " %s\n",
171 /* MR1 */ (add_erase==1 ? "skip()" :
172 /* MR1 */ add_erase==2 ? "more()" :
173 /* MR1 */ ""));
174 /* MR1 */ };
175
176 #endif
177
178 switch (add_erase) {
179 case 1: goto skip;
180 case 2: goto more;
181 }
182 return tk;
183 }
184
185 void DLGLexer::
186 advance()
187 {
188 if ( input==NULL ) err_in();
189 ZZGETC; charfull = 1; ZZINC;
190 }
+0
-302
contrib/pccts/h/DLexerBase.cpp less more
0 /* DLGLexerBase.c
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #include "pcctscfg.h"
30
31 #include "pccts_stdio.h"
32 #include "pccts_stdlib.h"
33
34 PCCTS_NAMESPACE_STD
35
36 /* I have to put this here due to C++ limitation
37 * that you can't have a 'forward' decl for enums.
38 * I hate C++!!!!!!!!!!!!!!!
39 */
40
41 // MR1
42 // MR1 10-Apr-97 133MR1 Prevent use of varying sizes for the
43 // MR1 ANTLRTokenType enum
44 // MR1
45
46 enum ANTLRTokenType { TER_HATES_CPP=0, ITS_UTTER_GARBAGE, // MR1
47 WITH_SOME_GOOD_IDEAS=9999}; // MR1
48
49 #define ANTLR_SUPPORT_CODE
50
51 #include "pcctscfg.h"
52 #include DLEXERBASE_H
53 #include APARSER_H // MR23
54
55 DLGLexerBase::
56 DLGLexerBase(DLGInputStream *in,
57 unsigned bufsize,
58 int _interactive,
59 int _track_columns)
60 {
61 this->_bufsize = bufsize;
62 this->_lextext = new DLGChar[_bufsize];
63 if ( this->_lextext==NULL ) {
64 panic("text buffer is NULL");
65 }
66 this->_begexpr = this->_endexpr = NULL;
67 this->ch = this->bufovf = 0;
68 this->nextpos = NULL;
69 this->cl = 0;
70 this->add_erase = 0;
71 this->input = in;
72 this->_begcol = 0;
73 this->_endcol = 0;
74 this->_line = 1;
75 this->charfull = 0;
76 this->automaton = 0;
77 this->token_to_fill = NULL;
78 this->interactive = _interactive;
79 this->track_columns = _track_columns;
80 this->debugLexerFlag = 0; // MR1
81 this->parser = NULL; // MR1
82 this->lexErrCount=0; // MR11
83 }
84
85 // MR19 THM
86
87 void DLGLexerBase::reset()
88 {
89 this->charfull = 0;
90 this->_begcol = 0;
91 this->_endcol = 0;
92 this->automaton = 0;
93 this->_line=1;
94 this->lexErrCount=0;
95 }
96
97 void DLGLexerBase::
98 setInputStream( DLGInputStream *in )
99 {
100 this->input = in;
101 _line = 1;
102 charfull = 0;
103 }
104
105 /* saves dlg state, but not what feeds dlg (such as file position) */
106 void DLGLexerBase::
107 saveState(DLGState *state)
108 {
109 state->input = input;
110 state->interactive = interactive;
111 state->track_columns = track_columns;
112 state->auto_num = automaton;
113 state->add_erase = add_erase;
114 state->lookc = ch;
115 state->char_full = charfull;
116 state->begcol = _begcol;
117 state->endcol = _endcol;
118 state->line = _line;
119 state->lextext = _lextext;
120 state->begexpr = _begexpr;
121 state->endexpr = _endexpr;
122 state->bufsize = _bufsize;
123 state->bufovf = bufovf;
124 state->nextpos = nextpos;
125 state->class_num = cl;
126 state->debugLexerFlag = debugLexerFlag; // MR1
127 state->parser = parser; // MR1
128 }
129
130 void DLGLexerBase::
131 restoreState(DLGState *state)
132 {
133 input = state->input;
134 interactive = state->interactive;
135 track_columns = state->track_columns;
136 automaton = state->auto_num;
137 add_erase = state->add_erase;
138 ch = state->lookc;
139 charfull = state->char_full;
140 _begcol = state->begcol;
141 _endcol = state->endcol;
142 _line = state->line;
143 _lextext = state->lextext;
144 _begexpr = state->begexpr;
145 _endexpr = state->endexpr;
146 _bufsize = state->bufsize;
147 bufovf = state->bufovf;
148 nextpos = state->nextpos;
149 cl = state->class_num;
150 debugLexerFlag = state->debugLexerFlag; // MR1
151 parser = state->parser; // MR1
152 }
153
154 /* erase what is currently in the buffer, and get a new reg. expr */
155 void DLGLexerBase::
156 skip()
157 {
158 add_erase = 1;
159 }
160
161 /* don't erase what is in the lextext buffer, add on to it */
162 void DLGLexerBase::
163 more()
164 {
165 add_erase = 2;
166 }
167
168 /* substitute c for the reg. expr last matched and is in the buffer */
169 void DLGLexerBase::
170 replchar(DLGChar c)
171 {
172 /* can't allow overwriting null at end of string */
173 if (_begexpr < &_lextext[_bufsize-1]){
174 *_begexpr = c;
175 *(_begexpr+1) = '\0';
176 }
177 _endexpr = _begexpr;
178 if (c != '\0') {
179 nextpos = _begexpr + 1;
180 }
181 else {
182 nextpos = _begexpr; /* MR30 Zero terminates string. */
183 }
184 }
185
186 /* replace the string s for the reg. expr last matched and in the buffer */
187
188 #ifdef _MSC_VER // MR23
189 //Turn off "assignment within conditional expression" warning
190 #pragma warning(disable : 4706)
191 #endif
192 void DLGLexerBase::
193 replstr(const DLGChar *s) /* MR20 const */
194 {
195 register DLGChar *l= &_lextext[_bufsize -1];
196
197 nextpos = _begexpr;
198 if (s){
199 while ((nextpos <= l) && (*(nextpos++) = *(s++))){
200 /* empty */
201 }
202 /* correct for NULL at end of string */
203 nextpos--;
204 }
205 if ((nextpos <= l) && (*(--s) == 0)){
206 bufovf = 0;
207 }else{
208 bufovf = 1;
209 }
210 *(nextpos) = '\0';
211 _endexpr = nextpos - 1;
212 }
213 #ifdef _MSC_VER // MR23
214 #pragma warning(default: 4706)
215 #endif
216
217 void DLGLexerBase::
218 errstd(const char *s) /* MR20 const */
219 {
220 lexErrCount++; /* MR11 */
221 /* MR23 */ printMessage(stderr,
222 "%s near line %d (text was '%s')\n",
223 ((s == NULL) ? "Lexical error" : s),
224 _line,_lextext);
225 }
226
227 int DLGLexerBase::
228 err_in()
229 {
230 /* MR23 */ printMessage(stderr,"No input stream, function, or string\n");
231 /* return eof to get out gracefully */
232 return EOF;
233 }
234
235 ANTLRTokenType DLGLexerBase::
236 erraction()
237 {
238 errstd("invalid token");
239 advance();
240 skip();
241 return (ANTLRTokenType) 0; // bogus, but satisfies compiler
242 }
243
244 _ANTLRTokenPtr DLGLexerBase::
245 getToken()
246 {
247 if ( token_to_fill==NULL ) panic("NULL token_to_fill");
248 ANTLRTokenType tt = nextTokenType();
249 _ANTLRTokenPtr tk = token_to_fill->makeToken(tt, _lextext,_line);
250 return tk;
251 }
252
253 void DLGLexerBase::
254 panic(const char *msg) /* MR20 const */
255 {
256 if (parser) //MR23
257 parser->panic(msg); //MR23
258 else //MR23
259 {
260 /* MR23 */ printMessage(stderr, "DLG panic: %s\n", msg);
261 //
262 // 7-Apr-97 133MR1
263 //
264 exit(PCCTS_EXIT_FAILURE); // MR1
265 }
266 }
267
268 ANTLRParser * DLGLexerBase:: // MR1
269 setParser(ANTLRParser *p) { // MR1
270 ANTLRParser *oldValue=parser; // MR1
271 parser=p; // MR1
272 return oldValue; // MR1
273 } // MR1
274 // MR1
275 ANTLRParser * DLGLexerBase:: // MR1
276 getParser() { // MR1
277 return parser; // MR1
278 } // MR1
279 // MR1
280 int DLGLexerBase:: // MR1
281 debugLexer(int newValue) { // MR1
282 int oldValue=debugLexerFlag; // MR1
283 debugLexerFlag=newValue; // MR1
284 return oldValue; // MR1
285 } // MR1
286
287 //MR23
288 int DLGLexerBase::printMessage(FILE* pFile, const char* pFormat, ...)
289 {
290 va_list marker;
291 va_start( marker, pFormat );
292
293 int iRet = 0;
294 if (parser)
295 parser->printMessageV(pFile, pFormat, marker);
296 else
297 iRet = vfprintf(pFile, pFormat, marker);
298
299 va_end( marker );
300 return iRet;
301 }
+0
-198
contrib/pccts/h/DLexerBase.h less more
0 /* DLGLexerBase.h
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef DLGX_H
30 #define DLGX_H
31
32 #include "pcctscfg.h"
33 #include "pccts_stdio.h"
34
35 PCCTS_NAMESPACE_STD
36
37 #include ATOKEN_H
38 #include ATOKENSTREAM_H
39
40 class ANTLRParser; // MR1
41
42 /* must define what a char looks like; can make this a class too */
43 typedef char DLGChar;
44
45 /* Can have it as a class too: (ack this looks weird; is it right?)
46 class DllExportPCCTS DLGChar {
47 private:
48 int c;
49 public:
50 DLGChar(int ch) { c = ch; }
51 int atom() { return c; }
52 };
53 */
54
55 /* user must subclass this */
56 class DllExportPCCTS DLGInputStream {
57 public:
58 virtual int nextChar() = 0;
59 };
60
61 /* Predefined char stream: Input from FILE */
62 class DllExportPCCTS DLGFileInput : public DLGInputStream {
63 private:
64 int found_eof;
65 FILE *input;
66 public:
67 DLGFileInput(FILE *f) { input = f; found_eof = 0; }
68 int nextChar() {
69 int c;
70 if ( found_eof ) return EOF;
71 else {
72 c=getc(input);
73 if ( c==EOF ) found_eof = 1;
74 return c;
75 }
76 }
77 void DLGFileReset(FILE *f) {input=f; found_eof = 0; }; // MR11
78 };
79
80 // MR9 Suggested by Bruce Guenter (bruceg@qcc.sk.ca)
81 // MR9 Make DLGStringInput const correct
82
83 /* Predefined char stream: Input from string */
84 class DllExportPCCTS DLGStringInput : public DLGInputStream {
85 private:
86 const DLGChar *input; // MR9
87 const DLGChar *p; // MR9
88 public:
89 DLGStringInput(const DLGChar *s) { input = s; p = &input[0];} // MR9
90 int nextChar()
91 {
92 if (*p) return (int) (unsigned char) *p++; // MR14
93 else return EOF;
94 }
95
96 void DLGStringReset(const DLGChar *s) {input=s; p= &input[0]; }; // MR11 // MR16
97 };
98
99 class DllExportPCCTS DLGState {
100 public:
101 DLGInputStream *input;
102 int interactive;
103 int track_columns;
104 int auto_num;
105 int add_erase;
106 int lookc;
107 int char_full;
108 int begcol, endcol;
109 int line;
110 DLGChar *lextext, *begexpr, *endexpr;
111 int bufsize;
112 int bufovf;
113 DLGChar *nextpos;
114 int class_num;
115 int debugLexerFlag; // MR1
116 ANTLRParser *parser; // MR1
117 };
118
119 /* user must subclass this */
120 class DllExportPCCTS DLGLexerBase : public ANTLRTokenStream {
121 public:
122 virtual ANTLRTokenType erraction();
123
124 protected:
125 DLGInputStream *input;
126 int interactive;
127 int track_columns;
128 DLGChar *_lextext; /* text of most recently matched token */
129 DLGChar *_begexpr; /* beginning of last reg expr recogn. */
130 DLGChar *_endexpr; /* beginning of last reg expr recogn. */
131 int _bufsize; /* number of characters in lextext */
132 int _begcol; /* column that first character of token is in*/
133 int _endcol; /* column that last character of token is in */
134 int _line; /* line current token is on */
135 int ch; /* character to determine next state */
136 int bufovf; /* indicates that buffer too small for text */
137 int charfull;
138 DLGChar *nextpos; /* points to next available position in lextext*/
139 int cl;
140 int automaton;
141 int add_erase;
142 DLGChar ebuf[70];
143 _ANTLRTokenPtr token_to_fill;
144
145 int debugLexerFlag; // MR1
146 ANTLRParser *parser; // MR1
147 public:
148 virtual _ANTLRTokenPtr getToken(); // MR12 public
149 virtual void advance(void) = 0;
150 void skip(void); /* erase lextext, look for antoher token */
151 void more(void); /* keep lextext, look for another token */
152 void mode(int k); /* switch to automaton 'k' */
153 void saveState(DLGState *);
154 void restoreState(DLGState *);
155 virtual ANTLRTokenType nextTokenType(void)=0;/* get next token */
156 void replchar(DLGChar c); /* replace last recognized reg. expr. with
157 a character */
158 void replstr(const DLGChar *s); /* replace last recognized reg. expr. with
159 a string */ /* MR20 const */
160 virtual int err_in(); // MR1
161 virtual void errstd(const char *); // MR1 MR20 const
162 int line() { return _line; }
163 void set_line(int newValue) { _line=newValue; }; // MR1
164 virtual void newline() { _line++; }
165 DLGChar *lextext() { return _lextext; }
166
167 int begcol() { return _begcol; }
168 int endcol() { return _endcol; }
169 void set_begcol(int a) { _begcol=a; }
170 void set_endcol(int a) { _endcol=a; }
171 DLGChar *begexpr() { return _begexpr; }
172 DLGChar *endexpr() { return _endexpr; }
173 int bufsize() { return _bufsize; }
174
175 void setToken(ANTLRAbstractToken *t) { token_to_fill = t; }
176
177 void setInputStream(DLGInputStream *);
178 DLGLexerBase(DLGInputStream *in,
179 unsigned bufsize=2000,
180 int interactive=0,
181 int track_columns=0);
182 void reset(); // MR19
183 virtual ~DLGLexerBase() { delete [] _lextext; }
184 virtual void panic(const char *msg); // MR1 MR20 const
185 void trackColumns() {
186 track_columns = 1;
187 this->_begcol = 0;
188 this->_endcol = 0;
189 };
190 virtual ANTLRParser *setParser(ANTLRParser *p); // MR1
191 virtual ANTLRParser *getParser(); // MR1
192 virtual int debugLexer(int value); // MR1
193 int lexErrCount; // MR12
194 virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
195 };
196
197 #endif
+0
-14
contrib/pccts/h/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 EXTRA_DIST= \
4 AParser.cpp AParser.h ASTBase.cpp ASTBase.h ATokPtr.h \
5 ATokPtrImpl.h AToken.h ATokenBuffer.cpp ATokenBuffer.h \
6 ATokenStream.h BufFileInput.cpp BufFileInput.h DLG_stream_input.h \
7 DLexer.h DLexerBase.cpp DLexerBase.h PBlackBox.h PCCTSAST.cpp \
8 PCCTSAST.h SList.h antlr.h ast.c ast.h charbuf.h charptr.c charptr.h \
9 config.h dlgauto.h dlgdef.h err.h int.h pccts_assert.h pccts_iostream.h \
10 pccts_istream.h pccts_setjmp.h pccts_stdarg.h pccts_stdio.h pccts_stdlib.h \
11 pccts_string.h pcctscfg.h pcctslib50.dsp pcctslib50.dsw pcctslib60.dsp \
12 pcctslib60.dsw pcnames.bat slist.cpp
13
+0
-466
contrib/pccts/h/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/h
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 am__can_run_installinfo = \
102 case $$AM_UPDATE_INFO_DIR in \
103 n|no|NO) false;; \
104 *) (install-info --version) >/dev/null 2>&1;; \
105 esac
106 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
107 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
108 ACLOCAL = @ACLOCAL@
109 AET2_CFLAGS = @AET2_CFLAGS@
110 AET2_LDADD = @AET2_LDADD@
111 ALLOCA = @ALLOCA@
112 AMTAR = @AMTAR@
113 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
114 AUTOCONF = @AUTOCONF@
115 AUTOHEADER = @AUTOHEADER@
116 AUTOMAKE = @AUTOMAKE@
117 AWK = @AWK@
118 CC = @CC@
119 CCDEPMODE = @CCDEPMODE@
120 CFLAGS = @CFLAGS@
121 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
122 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
123 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
124 CPP = @CPP@
125 CPPFLAGS = @CPPFLAGS@
126 CXX = @CXX@
127 CXXDEPMODE = @CXXDEPMODE@
128 CXXFLAGS = @CXXFLAGS@
129 CYGPATH_W = @CYGPATH_W@
130 DEFS = @DEFS@
131 DEPDIR = @DEPDIR@
132 ECHO_C = @ECHO_C@
133 ECHO_N = @ECHO_N@
134 ECHO_T = @ECHO_T@
135 EGREP = @EGREP@
136 EXEEXT = @EXEEXT@
137 EXTDEBUG = @EXTDEBUG@
138 EXTDEBUG2 = @EXTDEBUG2@
139 EXTDEBUG3 = @EXTDEBUG3@
140 EXTDEBUG4 = @EXTDEBUG4@
141 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
142 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
143 FSDB_CFLAGS = @FSDB_CFLAGS@
144 FSDB_LDADD = @FSDB_LDADD@
145 GCONF_CFLAGS = @GCONF_CFLAGS@
146 GCONF_LIBS = @GCONF_LIBS@
147 GEDITTEST = @GEDITTEST@
148 GEDIT_CFLAGS = @GEDIT_CFLAGS@
149 GIO_CFLAGS = @GIO_CFLAGS@
150 GIO_LIBS = @GIO_LIBS@
151 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
152 GPERF = @GPERF@
153 GREP = @GREP@
154 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
155 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
156 GTK_CFLAGS = @GTK_CFLAGS@
157 GTK_CONFIG = @GTK_CONFIG@
158 GTK_LIBS = @GTK_LIBS@
159 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
160 GTK_MAC_LIBS = @GTK_MAC_LIBS@
161 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
162 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
163 INSTALL = @INSTALL@
164 INSTALL_DATA = @INSTALL_DATA@
165 INSTALL_PROGRAM = @INSTALL_PROGRAM@
166 INSTALL_SCRIPT = @INSTALL_SCRIPT@
167 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
168 LDFLAGS = @LDFLAGS@
169 LEX = @LEX@
170 LEXLIB = @LEXLIB@
171 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
172 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
173 LIBBZ2_DIR = @LIBBZ2_DIR@
174 LIBBZ2_LDADD = @LIBBZ2_LDADD@
175 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
176 LIBJUDY_LDADD = @LIBJUDY_LDADD@
177 LIBOBJS = @LIBOBJS@
178 LIBS = @LIBS@
179 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
180 LIBXZ_LDADD = @LIBXZ_LDADD@
181 LIBZ_CFLAGS = @LIBZ_CFLAGS@
182 LIBZ_DIR = @LIBZ_DIR@
183 LIBZ_LDADD = @LIBZ_LDADD@
184 LTLIBOBJS = @LTLIBOBJS@
185 MAINT = @MAINT@
186 MAKEINFO = @MAKEINFO@
187 MINGW_LDADD = @MINGW_LDADD@
188 MKDIR_P = @MKDIR_P@
189 OBJEXT = @OBJEXT@
190 PACKAGE = @PACKAGE@
191 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
192 PACKAGE_NAME = @PACKAGE_NAME@
193 PACKAGE_STRING = @PACKAGE_STRING@
194 PACKAGE_TARNAME = @PACKAGE_TARNAME@
195 PACKAGE_URL = @PACKAGE_URL@
196 PACKAGE_VERSION = @PACKAGE_VERSION@
197 PATH_SEPARATOR = @PATH_SEPARATOR@
198 PKG_CONFIG = @PKG_CONFIG@
199 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
200 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
201 POW_LIB = @POW_LIB@
202 RANLIB = @RANLIB@
203 RPC_CFLAGS = @RPC_CFLAGS@
204 RPC_LDADD = @RPC_LDADD@
205 SET_MAKE = @SET_MAKE@
206 SHELL = @SHELL@
207 STRIP = @STRIP@
208 STRUCT_PACK = @STRUCT_PACK@
209 TCL_DEFADD = @TCL_DEFADD@
210 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
211 TCL_LDADD = @TCL_LDADD@
212 TCL_LIB_SPEC = @TCL_LIB_SPEC@
213 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
214 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
215 TIRPC_CFLAGS = @TIRPC_CFLAGS@
216 TIRPC_LIBS = @TIRPC_LIBS@
217 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
218 TK_LDADD = @TK_LDADD@
219 TK_LIB_SPEC = @TK_LIB_SPEC@
220 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
221 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
222 VERSION = @VERSION@
223 XDGDATADIR = @XDGDATADIR@
224 abs_builddir = @abs_builddir@
225 abs_srcdir = @abs_srcdir@
226 abs_top_builddir = @abs_top_builddir@
227 abs_top_srcdir = @abs_top_srcdir@
228 ac_ct_CC = @ac_ct_CC@
229 ac_ct_CXX = @ac_ct_CXX@
230 am__include = @am__include@
231 am__leading_dot = @am__leading_dot@
232 am__quote = @am__quote@
233 am__tar = @am__tar@
234 am__untar = @am__untar@
235 bindir = @bindir@
236 build_alias = @build_alias@
237 builddir = @builddir@
238 datadir = @datadir@
239 datarootdir = @datarootdir@
240 docdir = @docdir@
241 dvidir = @dvidir@
242 exec_prefix = @exec_prefix@
243 gsettingsschemadir = @gsettingsschemadir@
244 host_alias = @host_alias@
245 htmldir = @htmldir@
246 includedir = @includedir@
247 infodir = @infodir@
248 install_sh = @install_sh@
249 libdir = @libdir@
250 libexecdir = @libexecdir@
251 localedir = @localedir@
252 localstatedir = @localstatedir@
253 mandir = @mandir@
254 mkdir_p = @mkdir_p@
255 oldincludedir = @oldincludedir@
256 pdfdir = @pdfdir@
257 prefix = @prefix@
258 program_transform_name = @program_transform_name@
259 psdir = @psdir@
260 sbindir = @sbindir@
261 sharedstatedir = @sharedstatedir@
262 srcdir = @srcdir@
263 sysconfdir = @sysconfdir@
264 target_alias = @target_alias@
265 top_build_prefix = @top_build_prefix@
266 top_builddir = @top_builddir@
267 top_srcdir = @top_srcdir@
268 EXTRA_DIST = \
269 AParser.cpp AParser.h ASTBase.cpp ASTBase.h ATokPtr.h \
270 ATokPtrImpl.h AToken.h ATokenBuffer.cpp ATokenBuffer.h \
271 ATokenStream.h BufFileInput.cpp BufFileInput.h DLG_stream_input.h \
272 DLexer.h DLexerBase.cpp DLexerBase.h PBlackBox.h PCCTSAST.cpp \
273 PCCTSAST.h SList.h antlr.h ast.c ast.h charbuf.h charptr.c charptr.h \
274 config.h dlgauto.h dlgdef.h err.h int.h pccts_assert.h pccts_iostream.h \
275 pccts_istream.h pccts_setjmp.h pccts_stdarg.h pccts_stdio.h pccts_stdlib.h \
276 pccts_string.h pcctscfg.h pcctslib50.dsp pcctslib50.dsw pcctslib60.dsp \
277 pcctslib60.dsw pcnames.bat slist.cpp
278
279 all: all-am
280
281 .SUFFIXES:
282 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
283 @for dep in $?; do \
284 case '$(am__configure_deps)' in \
285 *$$dep*) \
286 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
287 && { if test -f $@; then exit 0; else break; fi; }; \
288 exit 1;; \
289 esac; \
290 done; \
291 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/h/Makefile'; \
292 $(am__cd) $(top_srcdir) && \
293 $(AUTOMAKE) --foreign contrib/pccts/h/Makefile
294 .PRECIOUS: Makefile
295 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
296 @case '$?' in \
297 *config.status*) \
298 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
299 *) \
300 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
301 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
302 esac;
303
304 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
305 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
306
307 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
308 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
309 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
310 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
311 $(am__aclocal_m4_deps):
312 tags TAGS:
313
314 ctags CTAGS:
315
316 cscope cscopelist:
317
318
319 distdir: $(DISTFILES)
320 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
321 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
322 list='$(DISTFILES)'; \
323 dist_files=`for file in $$list; do echo $$file; done | \
324 sed -e "s|^$$srcdirstrip/||;t" \
325 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
326 case $$dist_files in \
327 */*) $(MKDIR_P) `echo "$$dist_files" | \
328 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
329 sort -u` ;; \
330 esac; \
331 for file in $$dist_files; do \
332 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
333 if test -d $$d/$$file; then \
334 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
335 if test -d "$(distdir)/$$file"; then \
336 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
337 fi; \
338 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
339 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
340 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
341 fi; \
342 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
343 else \
344 test -f "$(distdir)/$$file" \
345 || cp -p $$d/$$file "$(distdir)/$$file" \
346 || exit 1; \
347 fi; \
348 done
349 check-am: all-am
350 check: check-am
351 all-am: Makefile
352 installdirs:
353 install: install-am
354 install-exec: install-exec-am
355 install-data: install-data-am
356 uninstall: uninstall-am
357
358 install-am: all-am
359 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
360
361 installcheck: installcheck-am
362 install-strip:
363 if test -z '$(STRIP)'; then \
364 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
365 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
366 install; \
367 else \
368 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
369 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
370 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
371 fi
372 mostlyclean-generic:
373
374 clean-generic:
375
376 distclean-generic:
377 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
378 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
379
380 maintainer-clean-generic:
381 @echo "This command is intended for maintainers to use"
382 @echo "it deletes files that may require special tools to rebuild."
383 clean: clean-am
384
385 clean-am: clean-generic mostlyclean-am
386
387 distclean: distclean-am
388 -rm -f Makefile
389 distclean-am: clean-am distclean-generic
390
391 dvi: dvi-am
392
393 dvi-am:
394
395 html: html-am
396
397 html-am:
398
399 info: info-am
400
401 info-am:
402
403 install-data-am:
404
405 install-dvi: install-dvi-am
406
407 install-dvi-am:
408
409 install-exec-am:
410
411 install-html: install-html-am
412
413 install-html-am:
414
415 install-info: install-info-am
416
417 install-info-am:
418
419 install-man:
420
421 install-pdf: install-pdf-am
422
423 install-pdf-am:
424
425 install-ps: install-ps-am
426
427 install-ps-am:
428
429 installcheck-am:
430
431 maintainer-clean: maintainer-clean-am
432 -rm -f Makefile
433 maintainer-clean-am: distclean-am maintainer-clean-generic
434
435 mostlyclean: mostlyclean-am
436
437 mostlyclean-am: mostlyclean-generic
438
439 pdf: pdf-am
440
441 pdf-am:
442
443 ps: ps-am
444
445 ps-am:
446
447 uninstall-am:
448
449 .MAKE: install-am install-strip
450
451 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
452 ctags-am distclean distclean-generic distdir dvi dvi-am html \
453 html-am info info-am install install-am install-data \
454 install-data-am install-dvi install-dvi-am install-exec \
455 install-exec-am install-html install-html-am install-info \
456 install-info-am install-man install-pdf install-pdf-am \
457 install-ps install-ps-am install-strip installcheck \
458 installcheck-am installdirs maintainer-clean \
459 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
460 pdf-am ps ps-am tags-am uninstall uninstall-am
461
462
463 # Tell versions [3.59,3.63) of GNU make to not export all variables.
464 # Otherwise a system limit (for SysV at least) may be exceeded.
465 .NOEXPORT:
+0
-134
contrib/pccts/h/PBlackBox.h less more
0 #ifndef PBLACKBOX_H
1 #define PBLACKBOX_H
2
3 /*
4 * SOFTWARE RIGHTS
5 *
6 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
7 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
8 * company may do whatever they wish with source code distributed with
9 * PCCTS or the code generated by PCCTS, including the incorporation of
10 * PCCTS, or its output, into commerical software.
11 *
12 * We encourage users to develop software with PCCTS. However, we do ask
13 * that credit is given to us for developing PCCTS. By "credit",
14 * we mean that if you incorporate our source code into one of your
15 * programs (commercial product, research project, or otherwise) that you
16 * acknowledge this fact somewhere in the documentation, research report,
17 * etc... If you like PCCTS and have developed a nice tool with the
18 * output, please mention that you developed it using PCCTS. In
19 * addition, we ask that this header remain intact in our source code.
20 * As long as these guidelines are kept, we expect to continue enhancing
21 * this system and expect to make other tools available as they are
22 * completed.
23 *
24 * ANTLR 1.33
25 * Terence Parr
26 * Parr Research Corporation
27 * with Purdue University and AHPCRC, University of Minnesota
28 * 1989-2000
29 */
30
31 /* Completely rewritten by Chris Uzdavinis (chris@atdesk.com) for MR23 */
32
33 #include "pcctscfg.h"
34
35 #include "pccts_iostream.h"
36
37 PCCTS_NAMESPACE_STD
38
39 // MR20 Added #include for "DLexerBase.h"
40
41 #include "DLexerBase.h"
42
43 //
44 // The default buffer size of the lexer is given by the
45 // second argument of the lexer's ctor. It is optional
46 // and defaults to 2000
47 //
48
49 template<class Lexer, class Parser, class Token>
50 class DllExportPCCTS ParserBlackBox {
51 private:
52 // no copy construction allowed
53 ParserBlackBox(ParserBlackBox const &);
54
55 // no copy assignment allowed
56 ParserBlackBox & operator=(ParserBlackBox const &);
57
58 protected:
59 DLGFileInput *in;
60 Lexer *scan;
61 _ANTLRTokenPtr tok;
62 ANTLRTokenBuffer *pipe;
63 Parser *_parser;
64 FILE *file;
65 int openByBlackBox; /* MR21 Don't close what we haven't opened */
66 public:
67
68 ParserBlackBox(FILE *f)
69 : in(0)
70 , scan(0)
71 , tok(0)
72 , pipe(0)
73 , _parser(0)
74 , file(0)
75 , openByBlackBox(0)
76 {
77 if (f == NULL)
78 {
79 cerr << "invalid file pointer\n";
80 }
81 else
82 {
83 openByBlackBox = 0; /* MR21a */
84 file = f;
85 in = new DLGFileInput(f);
86 scan = new Lexer(in);
87 pipe = new ANTLRTokenBuffer(scan);
88 tok = new Token;
89 scan->setToken(tok);
90 _parser = new Parser(pipe);
91 _parser->init();
92 }
93 }
94 ParserBlackBox(char *fname)
95 : in(0)
96 , scan(0)
97 , tok(0)
98 , pipe(0)
99 , _parser(0)
100 , file(0)
101 , openByBlackBox(0)
102 {
103 FILE *f = fopen(fname, "r");
104 if ( f==NULL ) {
105 openByBlackBox = 0;
106 cerr << "cannot open " << fname << "\n"; return;
107 }
108 else {
109 openByBlackBox = 1;
110 file = f;
111 in = new DLGFileInput(f);
112 scan = new Lexer(in);
113 pipe = new ANTLRTokenBuffer(scan);
114 tok = new Token;
115 scan->setToken(tok);
116 _parser = new Parser(pipe);
117 _parser->init();
118 }
119 }
120
121 ~ParserBlackBox()
122 {
123 delete in; delete scan; delete pipe; delete _parser; delete tok;
124 if (1 == openByBlackBox) {
125 fclose(file);
126 }
127 }
128
129 Parser *parser() { return _parser; }
130 Lexer *getLexer() { return scan; }
131 };
132
133 #endif
+0
-684
contrib/pccts/h/PCCTSAST.cpp less more
0 /*
1 * PCCTSAST.C
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B14 and ANTLR 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * AHPCRC, University of Minnesota
27 * 1992-2000
28 */
29
30 #define ANTLR_SUPPORT_CODE
31
32 #include "pcctscfg.h"
33
34 #include "PCCTSAST.h"
35 #include "pccts_stdarg.h"
36
37 PCCTS_NAMESPACE_STD
38
39 #include <ctype.h>
40
41 //#include "SList.h"
42
43 /* String Scanning/Parsing Stuff */
44
45 const char *PCCTS_AST::scan_token_tbl[] = { /* MR20 const */
46 "invalid", /* 0 */
47 "LPAREN", /* 1 */
48 "RPAREN", /* 2 */
49 "PERCENT", /* 3 */
50 "INT", /* 4 */
51 "COLON", /* 5 */
52 "POUND", /* 6 */
53 "PERIOD", /* 7 */
54 };
55
56 void PCCTS_AST::
57 addChild(PCCTS_AST *t)
58 {
59 if ( t==NULL ) return;
60 PCCTS_AST *s = down();
61 if ( s!=NULL )
62 {
63 while ( s->right()!=NULL ) s = s->right();
64 s->setRight(t);
65 }
66 else
67 this->setDown(t);
68 }
69
70 void PCCTS_AST::
71 lisp(FILE *f)
72 {
73 if ( down() != NULL ) /* MR23 */ printMessage(f," (");
74 lisp_action(f);
75 if ( down()!=NULL ) down()->lisp(f);
76 if ( down() != NULL ) /* MR23 */ printMessage(f," )");
77 if ( right()!=NULL ) right()->lisp(f);
78 }
79
80 /* build a tree (root child1 child2 ... NULL)
81 * If root is NULL, simply make the children siblings and return ptr
82 * to 1st sibling (child1). If root is not single node, return NULL.
83 *
84 * Siblings that are actually sibling lists themselves are handled
85 * correctly. For example #( NULL, #( NULL, A, B, C), D) results
86 * in the tree ( NULL A B C D ).
87 *
88 * Requires at least two parameters with the last one being NULL. If
89 * both are NULL, return NULL.
90 *
91 * The down() and right() down/right pointers are used to make the tree.
92 */
93 PCCTS_AST *PCCTS_AST::
94 make(PCCTS_AST *rt, ...)
95 {
96 va_list ap;
97 register PCCTS_AST *child, *sibling=NULL, *tail=NULL /*MR23*/, *w;
98 PCCTS_AST *root;
99
100 va_start(ap, rt);
101 root = rt;
102
103 if ( root != NULL )
104 if ( root->down() != NULL ) return NULL;
105 child = va_arg(ap, PCCTS_AST *);
106 while ( child != NULL )
107 {
108 /* find end of child */
109 for (w=child; w->right()!=NULL; w=w->right()) {;}
110 if ( sibling == NULL ) {sibling = child; tail = w;}
111 else {tail->setRight(child); tail = w;}
112 child = va_arg(ap, PCCTS_AST *);
113 }
114 if ( root==NULL ) root = sibling;
115 else root->setDown(sibling);
116 va_end(ap);
117 return root;
118 }
119
120 /* The following push and pop routines are only used by ast_find_all() */
121
122 void PCCTS_AST::
123 _push(PCCTS_AST **st, int *sp, PCCTS_AST *e)
124 {
125 (*sp)--;
126 require((*sp)>=0, "stack overflow");
127 st[(*sp)] = e;
128 }
129
130 PCCTS_AST *PCCTS_AST::
131 _pop(PCCTS_AST **st, int *sp)
132 {
133 PCCTS_AST *e = st[*sp];
134 (*sp)++;
135 require((*sp)<=MaxTreeStackDepth, "stack underflow");
136 return e;
137 }
138
139 /* Find all occurrences of u in t.
140 * 'cursor' must be initialized to 't'. It eventually
141 * returns NULL when no more occurrences of 'u' are found.
142 */
143 PCCTS_AST *PCCTS_AST::
144 ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor)
145 {
146 PCCTS_AST *sib;
147 /*** static ***/ PCCTS_AST *template_stack[MaxTreeStackDepth]; /* MR23 Remove "static" */
148 /*** static ***/ int tsp = MaxTreeStackDepth; /* MR23 Remove "static" */
149
150 ////static int nesting = 0; /* MR23 Not referenced */
151
152 if ( *cursor == NULL ) return NULL;
153 if ( *cursor!=this ) sib = *cursor;
154 else {
155 /* else, first time--start at top of template 't' */
156 tsp = MaxTreeStackDepth;
157 sib = this;
158 /* bottom of stack is always a NULL--"cookie" indicates "done" */
159 _push(template_stack, &tsp, NULL);
160 }
161
162 keep_looking:
163 if ( sib==NULL ) /* hit end of sibling list */
164 {
165 sib = _pop(template_stack, &tsp);
166 if ( sib == NULL ) { *cursor = NULL; return NULL; }
167 }
168
169 if ( sib->type() != u->type() )
170 {
171 /* look for another match */
172 if ( sib->down()!=NULL )
173 {
174 if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());
175 sib=sib->down();
176 goto keep_looking;
177 }
178 /* nothing below to try, try next sibling */
179 sib=sib->right();
180 goto keep_looking;
181 }
182
183 /* found a matching root node, try to match what's below */
184 if ( match_partial(sib, u) )
185 {
186 /* record sibling cursor so we can pick up next from there */
187 if ( sib->down()!=NULL )
188 {
189 if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());
190 *cursor = sib->down();
191 }
192 else if ( sib->right()!=NULL ) *cursor = sib->right();
193 else *cursor = _pop(template_stack, &tsp);
194 return sib;
195 }
196
197 /* no match, keep searching */
198 if ( sib->down()!=NULL )
199 {
200 if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());
201 sib=sib->down();
202 }
203 else sib = sib->right(); /* else, try to right if zip below */
204 goto keep_looking;
205 }
206
207 /* are two trees exactly alike? */
208 int PCCTS_AST::
209 match(PCCTS_AST *u)
210 {
211 PCCTS_AST *t = this;
212 PCCTS_AST *sib;
213
214 if ( u==NULL ) return 0;
215
216 for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())
217 {
218 if ( sib->type() != u->type() ) return 0;
219 if ( sib->down()!=NULL )
220 if ( !sib->down()->match(u->down()) ) return 0;
221 }
222 return 1;
223 }
224
225 /* Is 'u' a subtree of 't' beginning at the root? */
226 int PCCTS_AST::
227 match_partial(PCCTS_AST *t, PCCTS_AST *u)
228 {
229 PCCTS_AST *sib;
230
231 if ( u==NULL ) return 1;
232 if ( t==NULL ) return 0; /* MR23 removed unreachable code */
233
234 for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())
235 {
236 if ( sib->type() != u->type() ) return 0;
237 if ( sib->down()!=NULL )
238 if ( !match_partial(sib->down(), u->down()) ) return 0;
239 }
240 return 1;
241 }
242
243 #ifdef _MSC_VER // MR23
244 //Turn off "unreachable code" warning
245 #pragma warning(disable : 4702)
246 #endif
247 /* Walk the template tree 't' (matching against 'this'), filling in the
248 * 'labels' array, and setting 'n' according to how many labels were matched.
249 */
250 int PCCTS_AST::
251 scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n)
252 {
253 ScanAST *sib;
254 PCCTS_AST *u = this;
255
256 if ( u==NULL ) return 0;
257
258 for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())
259 {
260 /* make sure tokens match; token of '0' means wildcard match */
261 if ( sib->type() != u->type() && sib->type()!=0 ) return 0;
262 /* we have a matched token here; set label pointers if exists */
263 if ( sib->label_num>0 )
264 {
265 require(labels!=NULL, "label found in template, but no array of labels");
266 (*n)++;
267 *(labels[sib->label_num-1]) = u;
268 }
269 /* match what's below if something there and current node is not wildcard */
270 if ( sib->down()!=NULL && sib->type()!=0 )
271 {
272 if ( sib->down()==NULL )
273 {
274 if ( u->down()!=NULL )
275 return 0;
276 else
277 return 1;
278 }
279 if ( !u->down()->scanmatch(sib->down(), labels, n) ) return 0;
280 }
281 }
282 return 1;
283 }
284 #ifdef _MSC_VER // MR23
285 #pragma warning(default : 4702)
286 #endif
287
288 void PCCTS_AST::
289 insert_after(PCCTS_AST *b)
290 {
291 PCCTS_AST *end;
292 if ( b==NULL ) return;
293 /* find end of b's child list */
294 for (end=b; end->right()!=NULL; end=end->right()) {;}
295 end->setRight(this->right());
296 this->setRight(b);
297 }
298
299 void PCCTS_AST::
300 append(PCCTS_AST *b)
301 {
302 PCCTS_AST *end;
303 require(b!=NULL, "append: NULL input tree");
304 /* find end of child list */
305 for (end=this; end->right()!=NULL; end=end->right()) {;}
306 end->setRight(b);
307 }
308
309 PCCTS_AST *PCCTS_AST::
310 tail()
311 {
312 PCCTS_AST *end;
313 /* find end of child list */
314 for (end=this; end->right()!=NULL; end=end->right()) {;}
315 return end;
316 }
317
318 PCCTS_AST *PCCTS_AST::
319 bottom()
320 {
321 PCCTS_AST *end;
322 /* find end of child list */
323 for (end=this; end->down()!=NULL; end=end->down()) {;}
324 return end;
325 }
326
327 PCCTS_AST *PCCTS_AST::
328 cut_between(PCCTS_AST *a, PCCTS_AST *b)
329 {
330 PCCTS_AST *end, *ret;
331 if (a==NULL||b==NULL) return NULL;
332 /* find node pointing to b */
333 for (end=a; end->right()!=NULL&&end->right()!=b; end=end->right())
334 {;}
335 if (end->right()==NULL) return NULL; //ast_cut_between: a,b not connected
336 end->setRight(NULL); /* don't want it point to 'b' anymore */
337 ret = a->right();
338 a->setRight(b);
339 return ret;
340 }
341
342 #ifdef NOT_YET
343 SList *PCCTS_AST::
344 to_slist()
345 {
346 SList *list = new SList;
347 PCCTS_AST *p;
348
349 for (p=this; p!=NULL; p=p->right())
350 {
351 list->add(p);
352 }
353 return list;
354 }
355 #endif
356
357 void PCCTS_AST::
358 tfree()
359 {
360 PCCTS_AST *t = this;
361 if ( t->down()!=NULL ) t->down()->tfree();
362 if ( t->right()!=NULL ) t->right()->tfree();
363 delete t;
364 }
365
366 int PCCTS_AST::
367 nsiblings()
368 {
369 PCCTS_AST *t = this;
370 int n=0;
371
372 while ( t!=NULL )
373 {
374 n++;
375 t = t->right();
376 }
377 return n;
378 }
379
380 PCCTS_AST *PCCTS_AST::
381 sibling_index(int i)
382 {
383 PCCTS_AST *t = this;
384 int j=1;
385 require(i>0, "sibling_index: i<=0");
386
387 while ( t!=NULL )
388 {
389 if ( j==i ) return t;
390 j++;
391 t = t->right();
392 }
393 return NULL;
394 }
395
396 /* Assume this is a root node of a tree--
397 * duplicate that node and what's below; ignore siblings of root node.
398 */
399
400 // MR9 23-Sep-97 RJV
401 // MR9
402 // MR9 RJV: Original version only duplicated the node and down elements.
403 // MR9 Made copies of the pointers to sibling.
404 // MR9 Changed call "down()->deepCopy()" to "down()->deepCopyBushy()"
405 // MR9
406
407 PCCTS_AST *PCCTS_AST::
408 deepCopy()
409 {
410 PCCTS_AST *u = this->shallowCopy();
411 if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());
412 u->setRight(NULL);
413 return u;
414 }
415
416 /* Copy all nodes including siblings of root. */
417 PCCTS_AST *PCCTS_AST::
418 deepCopyBushy()
419 {
420 PCCTS_AST *u = this->shallowCopy();
421 /* copy the rest of the tree */
422 if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());
423 if ( right()!=NULL ) u->setRight(right()->deepCopyBushy());
424 return u;
425 }
426
427 void PCCTS_AST::
428 scanast_free(ScanAST *t)
429 {
430 if ( t == NULL ) return;
431 scanast_free( t->down() );
432 scanast_free( t->right() );
433 free( (char *) t ); // MR1
434 }
435
436 /*
437 * scan
438 *
439 * This function is like scanf(): it attempts to match a template
440 * against an input tree. A variable number of tree pointers
441 * may be set according to the '%i' labels in the template string.
442 * For example:
443 *
444 * t->ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",
445 * &w, &x, &y, &z);
446 *
447 * Naturally, you'd want this converted from
448 *
449 * t->ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )",
450 * &w, &x, &y, &z);
451 *
452 * by SORCERER.
453 *
454 * This function call must be done withing a SORCERER file because SORCERER
455 * must convert the token references to the associated token number.
456 *
457 * This functions parses the template and creates trees which are then
458 * matched against the input tree. The labels are set as they are
459 * encountered; hence, partial matches may leave some pointers set
460 * and some NULL. This routines initializes all argument pointers to NULL
461 * at the beginning.
462 *
463 * This function returns the number of labels matched.
464 */
465 int PCCTS_AST::
466 ast_scan(char *templ, ...)
467 {
468 va_list ap;
469 ScanAST *tmpl;
470 int n, i, found=0;
471 PCCTS_AST ***label_ptrs=NULL;
472
473 va_start(ap, templ);
474
475 /* make a ScanAST tree out of the template */
476 tmpl = stringparser_parse_scanast(templ, &n);
477
478 /* make an array out of the labels */
479 if ( n>0 )
480 {
481 label_ptrs = (PCCTS_AST ***) calloc(n, sizeof(PCCTS_AST **));
482 require(label_ptrs!=NULL, "scan: out of memory");
483 for (i=1; i<=n; i++)
484 {
485 label_ptrs[i-1] = va_arg(ap, PCCTS_AST **);
486 *(label_ptrs[i-1]) = NULL;
487 }
488 }
489
490 /* match the input tree against the template */
491 scanmatch(tmpl, label_ptrs, &found);
492
493 scanast_free(tmpl);
494 free( (char *) label_ptrs); // MR1
495
496 return found;
497 }
498
499 ScanAST *PCCTS_AST::
500 new_scanast(int tok)
501 {
502 ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST));
503 //
504 // 7-Apr-97 133MR1
505 //
506 if ( p == NULL )
507 panic("out of memory\n"); // MR23
508 p->_token = tok;
509 return p;
510 }
511
512 ScanAST *PCCTS_AST::
513 stringparser_parse_scanast(char *templ, int *num_labels)
514 {
515 StringLexer lex;
516 StringParser parser;
517 ScanAST *t;
518
519 stringlexer_init(&lex, templ);
520 stringparser_init(&parser, &lex);
521 t = stringparser_parse_tree(&parser);
522 *num_labels = parser.num_labels;
523 return t;
524 }
525
526 void PCCTS_AST::
527 stringparser_match(StringParser *parser, int token)
528 {
529 if ( parser->token != token ) panic("bad tree in scan()");
530 }
531
532 /*
533 * Match a tree of the form:
534 * (root child1 child2 ... childn)
535 * or,
536 * node
537 *
538 * where the elements are integers or labeled integers.
539 */
540 ScanAST *PCCTS_AST::
541 stringparser_parse_tree(StringParser *parser)
542 {
543 ScanAST *t=NULL, *root, *child, *last=NULL /*MR23*/;
544
545 if ( parser->token != __POUND )
546 {
547 return stringparser_parse_element(parser);
548 }
549 stringparser_match(parser,__POUND);
550 parser->token = stringscan_gettok(parser->lexer);
551 stringparser_match(parser,__LPAREN);
552 parser->token = stringscan_gettok(parser->lexer);
553 root = stringparser_parse_element(parser);
554 while ( parser->token != __RPAREN )
555 {
556 child = stringparser_parse_element(parser);
557 if ( t==NULL ) { t = child; last = t; }
558 else { last->_right = child; last = child; }
559 }
560 stringparser_match(parser,__RPAREN);
561 parser->token = stringscan_gettok(parser->lexer);
562 root->_down = t;
563 return root;
564 }
565
566 ScanAST *PCCTS_AST::
567 stringparser_parse_element(StringParser *parser)
568 {
569 char ebuf[100];
570 int label = 0;
571
572 if ( parser->token == __POUND )
573 {
574 return stringparser_parse_tree(parser);
575 }
576 if ( parser->token == __PERCENT )
577 {
578 parser->token = stringscan_gettok(parser->lexer);
579 stringparser_match(parser,__INT);
580 label = atoi(parser->lexer->text);
581 parser->num_labels++;
582 if ( label==0 ) panic("%%0 is an invalid label");
583 parser->token = stringscan_gettok(parser->lexer);
584 stringparser_match(parser,__COLON);
585 parser->token = stringscan_gettok(parser->lexer);
586 /* can label tokens and wildcards */
587 if ( parser->token != __INT && parser->token != __PERIOD )
588 panic("can only label tokens");
589 }
590 if ( parser->token == __INT )
591 {
592 ScanAST *p = new_scanast(atoi(parser->lexer->text));
593 parser->token = stringscan_gettok(parser->lexer);
594 p->label_num = label;
595 return p;
596 }
597 if ( parser->token == __PERIOD )
598 {
599 ScanAST *p = new_scanast(0); /* token of 0 is wildcard */
600 parser->token = stringscan_gettok(parser->lexer);
601 p->label_num = label;
602 return p;
603 }
604 sprintf(ebuf, "mismatch token in scan(): %s", scan_token_str(parser->token));
605 panic(ebuf);
606 return NULL;
607 }
608
609 void PCCTS_AST::
610 stringparser_init(StringParser *parser, StringLexer *input)
611 {
612 parser->lexer = input;
613 parser->token = stringscan_gettok(parser->lexer);
614 parser->num_labels = 0;
615 }
616
617 void PCCTS_AST::
618 stringlexer_init(StringLexer *scanner, char *input)
619 {
620 scanner->text[0]='\0';
621 scanner->input = input;
622 scanner->p = input;
623 stringscan_advance(scanner);
624 }
625
626 void PCCTS_AST::
627 stringscan_advance(StringLexer *scanner)
628 {
629 if ( *(scanner->p) == '\0' ) scanner->c = __StringScanEOF;
630 scanner->c = *(scanner->p)++;
631 }
632
633 int PCCTS_AST::
634 stringscan_gettok(StringLexer *scanner)
635 {
636 char *index = &scanner->text[0];
637 char ebuf[100]; /* MR23 Remove static */
638
639 while ( isspace(scanner->c) ) { stringscan_advance(scanner); }
640 if ( isdigit(scanner->c) )
641 {
642 int tok = __INT;
643 while ( isdigit(scanner->c) ) {
644 *index++ = (char) /* static_cast<char> */ (scanner->c); // MR23
645 stringscan_advance(scanner);
646 }
647 *index = '\0';
648 return tok;
649 }
650 switch ( scanner->c )
651 {
652 case '#' : stringscan_advance(scanner); return __POUND;
653 case '(' : stringscan_advance(scanner); return __LPAREN;
654 case ')' : stringscan_advance(scanner); return __RPAREN;
655 case '%' : stringscan_advance(scanner); return __PERCENT;
656 case ':' : stringscan_advance(scanner); return __COLON;
657 case '.' : stringscan_advance(scanner); return __PERIOD;
658 case '\0' : return __StringScanEOF;
659 case __StringScanEOF : return __StringScanEOF;
660 default :
661 sprintf(ebuf, "invalid char in scan: '%c'", scanner->c);
662 panic(ebuf);
663 }
664 return __StringScanEOF; // never reached
665 }
666
667 const char *PCCTS_AST:: /* MR20 const */
668 scan_token_str(int t)
669 {
670 if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t];
671 else if ( t==__StringScanEOF ) return "<end-of-string>";
672 else return "<invalid-token>";
673 }
674
675 //MR23
676 int PCCTS_AST::printMessage(FILE* pFile, const char* pFormat, ...)
677 {
678 va_list marker;
679 va_start( marker, pFormat );
680 int iRet = vfprintf(pFile, pFormat, marker);
681 va_end( marker );
682 return iRet;
683 }
+0
-143
contrib/pccts/h/PCCTSAST.h less more
0 /* Abstract syntax tree
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef PCCTSAST_H
30 #define PCCTSAST_H
31
32 #include "pcctscfg.h"
33
34 #include "pccts_stdio.h"
35 #include "pccts_stdlib.h"
36
37 PCCTS_NAMESPACE_STD
38
39 //class SList;
40
41 #define StringScanMaxText 50
42 #define MaxTreeStackDepth 400
43
44 //
45 // 7-Apr-97 133MR1 signed int not accepted by AT&T cfront
46 //
47 typedef struct stringlexer {
48 int c; // MR1
49 char *input;
50 char *p;
51 char text[StringScanMaxText];
52 } StringLexer;
53
54 /* Define the structures needed for ast_scan() */
55 typedef struct stringparser {
56 int token;
57 StringLexer *lexer;
58 int num_labels;
59 } StringParser;
60
61 typedef struct _scanast {
62 struct _scanast *_right, *_down;
63 int _token;
64 int label_num;
65 int type() { return _token; }
66 struct _scanast *right() { return _right; }
67 struct _scanast *down() { return _down; }
68 } ScanAST;
69
70 #define VALID_SCAN_TOKEN(t) (t>=__LPAREN && t<=__PERIOD)
71
72 class DllExportPCCTS PCCTS_AST {
73 protected:
74 static const char *scan_token_tbl[]; /* MR20 const */
75 enum {
76 __LPAREN=1,
77 __RPAREN=2,
78 __PERCENT=3,
79 __INT=4,
80 __COLON=5,
81 __POUND=6,
82 __PERIOD=7,
83 __StringScanEOF=-1};
84
85 protected:
86 const char *scan_token_str(int t); /* MR20 const */
87 void stringlexer_init(StringLexer *scanner, char *input);
88 void stringparser_init(StringParser *, StringLexer *);
89 ScanAST *stringparser_parse_scanast(char *templ, int *n);
90 ScanAST *stringparser_parse_tree(StringParser *parser);
91 ScanAST *stringparser_parse_element(StringParser *parser);
92 void stringscan_advance(StringLexer *scanner);
93 int stringscan_gettok(StringLexer *scanner);
94 void _push(PCCTS_AST **st, int *sp, PCCTS_AST *e);
95 PCCTS_AST *_pop(PCCTS_AST **st, int *sp);
96 int match_partial(PCCTS_AST *t, PCCTS_AST *u);
97 int scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n);
98 void scanast_free(ScanAST *t);
99 ScanAST *new_scanast(int tok);
100 void stringparser_match(StringParser *parser, int type);
101 virtual PCCTS_AST *deepCopyBushy();
102
103 public:
104 PCCTS_AST() {;}
105 virtual ~PCCTS_AST() {;}
106
107 /* This group must be defined for SORCERER to work correctly */
108 virtual PCCTS_AST *right() = 0;
109 virtual PCCTS_AST *down() = 0;
110 virtual void setRight(PCCTS_AST *t) = 0;
111 virtual void setDown(PCCTS_AST *t) = 0;
112 // we define these so ANTLR doesn't have to
113 virtual int type() { return 0; }
114 virtual void setType(int /*t MR23 */) {;}
115 virtual PCCTS_AST *shallowCopy() {panic("no shallowCopy() defined"); return NULL;}
116
117 /* These are not needed by ANTLR, but are support functions */
118 virtual PCCTS_AST *deepCopy(); // used by SORCERER in transform mode
119 virtual void addChild(PCCTS_AST *t);
120 virtual void lisp_action(FILE * /*f MR23 */) {;}
121 virtual void lisp(FILE *f);
122 static PCCTS_AST *make(PCCTS_AST *rt, ...);
123 virtual PCCTS_AST *ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor);
124 virtual int match(PCCTS_AST *u);
125 virtual void insert_after(PCCTS_AST *b);
126 virtual void append(PCCTS_AST *b);
127 virtual PCCTS_AST *tail();
128 virtual PCCTS_AST *bottom();
129 static PCCTS_AST *cut_between(PCCTS_AST *a, PCCTS_AST *b);
130 // virtual SList *to_slist();
131 virtual void tfree();
132 int ast_scan(char *templ, ...);
133 virtual int nsiblings();
134 virtual PCCTS_AST *sibling_index(int i);
135
136 void require(int e,const char *err){ if ( !e ) panic(err); } /* MR20 const */
137 virtual void panic(const char *err) // MR20 const
138 { /* MR23 */ printMessage(stderr, "PCCTS_AST: %s\n", err); exit(PCCTS_EXIT_FAILURE); }
139 virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
140 };
141
142 #endif /* PCCTSAST_H */
+0
-72
contrib/pccts/h/SList.h less more
0 #ifndef SList_h
1 #define SList_h
2
3 /*
4 * SList.h
5 *
6 * SOFTWARE RIGHTS
7 *
8 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
9 * domain. An individual or company may do whatever they wish with
10 * source code distributed with SORCERER or the code generated by
11 * SORCERER, including the incorporation of SORCERER, or its output, into
12 * commerical software.
13 *
14 * We encourage users to develop software with SORCERER. However, we do
15 * ask that credit is given to us for developing SORCERER. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like SORCERER and have developed a nice tool with the
20 * output, please mention that you developed it using SORCERER. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
24 * completed.
25 *
26 * PCCTS 1.33
27 * Terence Parr
28 * Parr Research Corporation
29 * with Purdue University and AHPCRC, University of Minnesota
30 * 1992-2000
31 */
32
33 #include "pcctscfg.h"
34
35 #include "pccts_stdio.h"
36 #include "pccts_stdlib.h"
37
38 PCCTS_NAMESPACE_STD
39
40 #include "PCCTSAST.h"
41
42 class PCCTS_AST;
43
44 class SListNode {
45 protected:
46 void *_elem; /* pointer to any kind of element */
47 SListNode *_next;
48 public:
49 SListNode() {_elem=_next=NULL;}
50 virtual ~SListNode() {_elem=_next=NULL;}
51 void *elem() { return _elem; }
52 void setElem(void *e) { _elem = e; }
53 void setNext(SListNode *t) { _next = t; }
54 SListNode *next() { return _next; }
55 };
56
57 class SList {
58 SListNode *head, *tail;
59 public:
60 SList() {head=tail=NULL;}
61 virtual ~SList() {head=tail=NULL;}
62 virtual void *iterate(SListNode **);
63 virtual void add(void *e);
64 virtual void lfree();
65 virtual PCCTS_AST *to_ast(SList list);
66 virtual void require(int e,char *err){ if ( !e ) panic(err); }
67 virtual void panic(char *err){ /* MR23 */ printMessage(stderr, "SList panic: %s\n", err); exit(PCCTS_EXIT_FAILURE); }
68 virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
69 };
70
71 #endif
+0
-807
contrib/pccts/h/antlr.h less more
0 /* antlr.h
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef ANTLR_H
30 #define ANTLR_H
31
32 #include "pcctscfg.h"
33
34 #include "pccts_stdio.h"
35
36 /* turn off warnings for unreferenced labels */
37
38 #ifdef _MSC_VER
39 #pragma warning(disable:4102)
40 #endif
41
42 /*
43 * Define all of the stack setup and manipulation of $i, #i variables.
44 *
45 * Notes:
46 * The type 'Attrib' must be defined before entry into this .h file.
47 */
48
49
50 #ifdef __USE_PROTOS
51 #include "pccts_stdlib.h"
52 #else
53 #ifdef VAXC
54 #include <stdlib.h>
55 #else
56 #include <malloc.h>
57 #endif
58 #endif
59 #include "pccts_string.h"
60
61 #if 0
62 #include "set.h"
63 #endif
64
65
66 typedef int ANTLRTokenType;
67 typedef unsigned char SetWordType;
68
69 typedef char ANTLRChar;
70
71 /* G u e s s S t u f f */
72
73 #ifdef ZZCAN_GUESS
74 #ifndef ZZINF_LOOK
75 #define ZZINF_LOOK
76 #endif
77 #endif
78
79 #ifdef ZZCAN_GUESS
80 typedef struct _zzjmp_buf {
81 jmp_buf state;
82 } zzjmp_buf;
83 #endif
84
85
86 /* can make this a power of 2 for more efficient lookup */
87
88 #ifndef ZZLEXBUFSIZE
89 #define ZZLEXBUFSIZE 8000 /* MR22 raise from 2k to 8k */
90 #endif
91
92 #define zzOvfChk \
93 if ( zzasp <= 0 ) \
94 { \
95 fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__); \
96 exit(PCCTS_EXIT_FAILURE); \
97 }
98
99 #ifndef ZZA_STACKSIZE
100 #define ZZA_STACKSIZE 400
101 #endif
102 #ifndef ZZAST_STACKSIZE
103 #define ZZAST_STACKSIZE 400
104 #endif
105
106 #ifndef zzfailed_pred
107 #ifdef ZZCAN_GUESS
108 #define zzfailed_pred(_p,_hasuseraction,_useraction) \
109 if (zzguessing) { \
110 zzGUESS_FAIL; \
111 } else { \
112 zzfailed_pred_action(_p,_hasuseraction,_useraction); \
113 }
114 #else
115 #define zzfailed_pred(_p,_hasuseraction,_useraction) \
116 zzfailed_pred_action(_p,_hasuseraction,_useraction);
117 #endif
118 #endif
119
120 /* MR23 Provide more control over failed predicate action
121 without any need for user to worry about guessing internals.
122 _hasuseraction == 0 => no user specified error action
123 _hasuseraction == 1 => user specified error action
124 */
125
126 #ifndef zzfailed_pred_action
127 #define zzfailed_pred_action(_p,_hasuseraction,_useraction) \
128 if (_hasuseraction) { _useraction } \
129 else { fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p); }
130 #endif
131
132 /* MR19 zzchar_t additions */
133
134 #ifdef LL_K
135 #define LOOKAHEAD \
136 int zztokenLA[LL_K]; \
137 zzchar_t zztextLA[LL_K][ZZLEXBUFSIZE]; \
138 int zzlap = 0, zzlabase=0; /* labase only used for DEMAND_LOOK */
139 #else
140 #define LOOKAHEAD \
141 int zztoken;
142 #endif
143
144 #ifndef zzcr_ast
145 #define zzcr_ast(ast,attr,tok,text)
146 #endif
147
148 #ifdef DEMAND_LOOK
149 #define DemandLookData int zzdirty=1;
150 #else
151 #define DemandLookData
152 #endif
153
154 #ifndef zzUSER_GUESS_HOOK
155 #define zzUSER_GUESS_HOOK(seqFrozen,zzrv)
156 #endif
157
158 #ifndef zzUSER_GUESS_DONE_HOOK
159 #define zzUSER_GUESS_DONE_HOOK(seqFrozen)
160 #endif
161
162 /* S t a t e S t u f f */
163
164 #ifdef ZZCAN_GUESS
165 #define zzGUESS_BLOCK zzantlr_state zzst; int zzrv; int zzGuessSeqFrozen;
166
167 /* MR10 change zzGUESS: do zzGUESS_DONE when zzrv==1 after longjmp as in C++ mode */
168
169 #define zzGUESS zzsave_antlr_state(&zzst); \
170 zzguessing = 1; \
171 zzGuessSeqFrozen=++zzGuessSeq; \
172 zzrv = setjmp(zzguess_start.state); \
173 zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \
174 if (zzrv) zzGUESS_DONE;
175 #ifdef zzTRACE_RULES
176 #define zzGUESS_FAIL { zzTraceGuessFail(); longjmp(zzguess_start.state, 1); }
177 #else
178 #define zzGUESS_FAIL longjmp(zzguess_start.state, 1)
179 #endif
180
181 /* MR10 change zzGUESS_DONE: zzrv=1 to simulate longjmp() return value as in C++ mode */
182
183 #define zzGUESS_DONE { zzrestore_antlr_state(&zzst); zzrv=1; zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }
184 #define zzNON_GUESS_MODE if ( !zzguessing )
185 #define zzGuessData \
186 zzjmp_buf zzguess_start; \
187 int zzguessing;
188 #else
189 #define zzGUESS_BLOCK
190 #define zzGUESS
191 #define zzGUESS_FAIL
192 #define zzGUESS_DONE
193 #define zzNON_GUESS_MODE
194 #define zzGuessData
195 #endif
196
197 typedef struct _zzantlr_state {
198 #ifdef ZZCAN_GUESS
199 zzjmp_buf guess_start;
200 int guessing;
201 #endif
202 int asp;
203 int ast_sp;
204 #ifdef ZZINF_LOOK
205 int inf_lap; /* not sure we need to save this one */
206 int inf_labase;
207 int inf_last;
208
209 /* MR6 Gunnar Rxnning (gunnar@candleweb.no) */
210 /* MR6 Additional state needs to be saved/restored */
211 /* MR6 Matching changes in err.h */
212
213 int *inf_tokens; /* MR6 */
214 char **inf_text; /* MR6 */
215 char *inf_text_buffer; /* MR6 */
216 int *inf_line; /* MR6 */
217 #endif
218 #ifdef DEMAND_LOOK
219 int dirty;
220 #endif
221
222 #ifdef LL_K
223 int tokenLA[LL_K];
224 char textLA[LL_K][ZZLEXBUFSIZE];
225 int lap;
226 int labase;
227 #else
228 int token;
229 char text[ZZLEXBUFSIZE];
230 #endif
231 #ifdef zzTRACE_RULES
232 int traceOptionValue; /* MR10 */
233 int traceGuessOptionValue; /* MR10 */
234 char *traceCurrentRuleName; /* MR10 */
235 int traceDepth; /* MR10 */
236 #endif
237
238 } zzantlr_state;
239
240 #ifdef zzTRACE_RULES
241 extern int zzTraceOptionValueDefault;
242 extern int zzTraceOptionValue;
243 extern int zzTraceGuessOptionValue;
244 extern char *zzTraceCurrentRuleName;
245 extern int zzTraceDepth;
246 #endif
247
248 extern int zzGuessSeq; /* MR10 */
249 extern int zzSyntaxErrCount; /* MR11 */
250 extern int zzLexErrCount; /* MR11 */
251
252 /* I n f i n i t e L o o k a h e a d */
253
254
255 #ifdef ZZINF_LOOK
256 #define InfLookData \
257 int *zzinf_tokens; \
258 char **zzinf_text; \
259 char *zzinf_text_buffer; \
260 int *zzinf_line; \
261 int zzinf_labase; \
262 int zzinf_last;
263 #else
264 #define InfLookData
265 #endif
266
267 #ifdef ZZINF_LOOK
268
269 #ifndef ZZINF_DEF_TEXT_BUFFER_SIZE
270 #define ZZINF_DEF_TEXT_BUFFER_SIZE 20000
271 #endif
272 #ifndef ZZINF_DEF_TOKEN_BUFFER_SIZE
273 #define ZZINF_DEF_TOKEN_BUFFER_SIZE 2000
274 #endif
275 /* WARNING!!!!!!
276 * ZZINF_BUFFER_TEXT_CHUNK_SIZE must be > sizeof(text) largest possible token.
277 */
278 #ifndef ZZINF_BUFFER_TEXT_CHUNK_SIZE
279 #define ZZINF_BUFFER_TEXT_CHUNK_SIZE 5000
280 #endif
281 #ifndef ZZINF_BUFFER_TOKEN_CHUNK_SIZE
282 #define ZZINF_BUFFER_TOKEN_CHUNK_SIZE 1000
283 #endif
284
285 #if ZZLEXBUFSIZE > ZZINF_BUFFER_TEXT_CHUNK_SIZE
286 #define ZZINF_BUFFER_TEXT_CHUNK_SIZE ZZLEXBUFSIZE+5
287 #endif
288
289 /* make inf_look user-access macros */
290 #ifdef LL_K
291 #define ZZINF_LA_VALID(i) (((zzinf_labase+i-1)-LL_K+1) <= zzinf_last)
292 #define ZZINF_LA(i) zzinf_tokens[(zzinf_labase+i-1)-LL_K+1]
293 #define ZZINF_LATEXT(i) zzinf_text[(zzinf_labase+i-1)-LL_K+1]
294 /* MR6 In 1.33 vanilla the #define ZZINF_LINE(i) is was commented out */
295 #define ZZINF_LINE(i) zzinf_line[(zzinf_labase+i-1)-LL_K+1]
296 #else
297 #define ZZINF_LA_VALID(i) (((zzinf_labase+i-1)) <= zzinf_last)
298 #define ZZINF_LA(i) zzinf_tokens[(zzinf_labase+i-1)]
299 #define ZZINF_LATEXT(i) zzinf_text[(zzinf_labase+i-1)]
300 #endif
301
302 #define inf_zzgettok _inf_zzgettok()
303 extern void _inf_zzgettok();
304
305 #endif /* ZZINF_LOOK */
306
307
308 #ifdef LL_K
309
310 #ifdef __USE_PROTOS
311 #define ANTLR_INFO \
312 Attrib zzempty_attr(void) {static Attrib a; return a;} \
313 Attrib zzconstr_attr(int _tok, char *_text) \
314 {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \
315 int zzasp=ZZA_STACKSIZE; \
316 char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
317 Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \
318 InfLookData \
319 zzGuessData
320 #else
321 #define ANTLR_INFO \
322 Attrib zzempty_attr() {static Attrib a; return a;} \
323 Attrib zzconstr_attr(_tok, _text) int _tok; char *_text; \
324 {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \
325 int zzasp=ZZA_STACKSIZE; \
326 char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
327 Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \
328 InfLookData \
329 zzGuessData
330 #endif
331
332 #else
333
334 #ifdef __USE_PROTOS
335 #define ANTLR_INFO \
336 Attrib zzempty_attr(void) {static Attrib a; return a;} \
337 Attrib zzconstr_attr(int _tok, char *_text) \
338 {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \
339 int zzasp=ZZA_STACKSIZE; \
340 char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
341 Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \
342 InfLookData \
343 zzGuessData
344 #else
345 #define ANTLR_INFO \
346 Attrib zzempty_attr() {static Attrib a; return a;} \
347 Attrib zzconstr_attr(_tok, _text) int _tok; char *_text; \
348 {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \
349 int zzasp=ZZA_STACKSIZE; \
350 char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
351 Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \
352 InfLookData \
353 zzGuessData
354 #endif
355
356 #endif /* LL_k */
357
358
359 #ifdef ZZINF_LOOK
360
361 #ifdef LL_K
362 #ifdef DEMAND_LOOK
363 #define zzPrimeLookAhead {zzdirty=LL_K; zzlap = zzlabase = 0;}
364 #else
365 #define zzPrimeLookAhead {zzlap = zzlabase = 0; zzfill_inf_look();\
366 {int _i; for(_i=1;_i<=LL_K; _i++) \
367 {zzCONSUME;} zzlap = zzlabase = 0;}}
368 #endif
369
370 #else /* LL_K */
371
372 #ifdef DEMAND_LOOK
373 #define zzPrimeLookAhead zzfill_inf_look(); zzdirty=1
374 #else
375 #define zzPrimeLookAhead zzfill_inf_look(); inf_zzgettok
376
377 #endif
378 #endif /* LL_K */
379
380 #else /* ZZINF_LOOK */
381
382 #ifdef LL_K
383 #ifdef DEMAND_LOOK
384 #define zzPrimeLookAhead {zzdirty=LL_K; zzlap = zzlabase = 0;}
385 #else
386 #define zzPrimeLookAhead {int _i; zzlap = 0; for(_i=1;_i<=LL_K; _i++) \
387 {zzCONSUME;} zzlap = 0;}
388 #endif
389
390 #else
391
392 #ifdef DEMAND_LOOK
393 #define zzPrimeLookAhead zzdirty=1
394 #else
395 #define zzPrimeLookAhead zzgettok()
396 #endif
397 #endif /* LL_K */
398
399 #endif /* ZZINF_LOOK */
400
401
402 #ifdef LL_K
403 #define zzenterANTLRs(s) \
404 zzlextext = &(zztextLA[0][0]); zzrdstr( s ); zzPrimeLookAhead;
405 #define zzenterANTLRf(f) \
406 zzlextext = &(zztextLA[0][0]); zzrdfunc( f ); zzPrimeLookAhead;
407 #define zzenterANTLR(f) \
408 zzlextext = &(zztextLA[0][0]); zzrdstream( f ); zzPrimeLookAhead;
409 #ifdef ZZINF_LOOK
410 #define zzleaveANTLR(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
411 #define zzleaveANTLRf(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
412 #define zzleaveANTLRs(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
413 #else
414 #define zzleaveANTLR(f)
415 #define zzleaveANTLRf(f)
416 #define zzleaveANTLRs(f)
417 #endif
418
419 #else
420
421 #define zzenterANTLRs(s) \
422 {static char zztoktext[ZZLEXBUFSIZE]; \
423 zzlextext = zztoktext; zzrdstr( s ); zzPrimeLookAhead;}
424 #define zzenterANTLRf(f) \
425 {static char zztoktext[ZZLEXBUFSIZE]; \
426 zzlextext = zztoktext; zzrdfunc( f ); zzPrimeLookAhead;}
427 #define zzenterANTLR(f) \
428 {static char zztoktext[ZZLEXBUFSIZE]; \
429 zzlextext = zztoktext; zzrdstream( f ); zzPrimeLookAhead;}
430 #ifdef ZZINF_LOOK
431 #define zzleaveANTLR(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
432 #define zzleaveANTLRf(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
433 #define zzleaveANTLRs(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
434 #else
435 #define zzleaveANTLR(f)
436 #define zzleaveANTLRf(f)
437 #define zzleaveANTLRs(f)
438 #endif
439
440 #endif
441
442 /* MR19 Paul D. Smith (psmith@baynetworks.com)
443 Need to adjust AST stack pointer at exit.
444 Referenced in ANTLRx macros.
445 */
446
447 #ifdef GENAST
448 #define ZZAST_ADJUST ++zzast_sp;
449 #else
450 #define ZZAST_ADJUST
451 #endif
452
453 #define ANTLR(st, f) zzbufsize = ZZLEXBUFSIZE; \
454 zzenterANTLR(f); \
455 { \
456 zzBLOCK(zztasp1); \
457 st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
458 /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
459 /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
460 zzEXIT_ANTLR(zztasp1 + 1); \
461 } \
462 zzleaveANTLR(f);
463
464 #define ANTLRm(st, f, _m) zzbufsize = ZZLEXBUFSIZE; \
465 zzmode(_m); \
466 zzenterANTLR(f); \
467 { \
468 zzBLOCK(zztasp1); \
469 st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
470 /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
471 /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
472 zzEXIT_ANTLR(zztasp1 + 1); \
473 } \
474 zzleaveANTLR(f);
475
476 #define ANTLRf(st, f) zzbufsize = ZZLEXBUFSIZE; \
477 zzenterANTLRf(f); \
478 { \
479 zzBLOCK(zztasp1); \
480 st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
481 /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
482 /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
483 zzEXIT_ANTLR(zztasp1 + 1); \
484 } \
485 zzleaveANTLRf(f);
486
487 #define ANTLRs(st, s) zzbufsize = ZZLEXBUFSIZE; \
488 zzenterANTLRs(s); \
489 { \
490 zzBLOCK(zztasp1); \
491 st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
492 /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
493 /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
494 zzEXIT_ANTLR(zztasp1 + 1); \
495 } \
496 zzleaveANTLRs(s);
497
498 #ifdef LL_K
499 #define zztext (&(zztextLA[zzlap][0]))
500 #else
501 #define zztext zzlextext
502 #endif
503
504
505 /* A r g u m e n t A c c e s s */
506
507 #define zzaCur (zzaStack[zzasp])
508 #define zzaRet (*zzaRetPtr)
509 #define zzaArg(v,n) zzaStack[v-n]
510 #define zzMakeAttr { zzNON_GUESS_MODE {zzOvfChk; --zzasp; zzcr_attr(&(zzaStack[zzasp]),LA(1),LATEXT(1));}}
511 #ifdef zzdef0
512 #define zzMake0 { zzOvfChk; --zzasp; zzdef0(&(zzaStack[zzasp]));}
513 #else
514 #define zzMake0 { zzOvfChk; --zzasp;}
515 #endif
516 #define zzaPush(_v) { zzOvfChk; zzaStack[--zzasp] = _v;}
517 #ifndef zzd_attr
518 #define zzREL(t) zzasp=(t); /* Restore state of stack */
519 #else
520 #define zzREL(t) for (; zzasp<(t); zzasp++) \
521 { zzd_attr(&(zzaStack[zzasp])); }
522 #endif
523
524
525 #define zzsetmatch(_es,_tokclassErrset) \
526 if ( !_zzsetmatch(_es, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet, _tokclassErrset) ) goto fail; /* MR23 */
527
528 #ifdef ZZCAN_GUESS
529 #define zzsetmatch_wsig(_es, handler) \
530 if ( !_zzsetmatch_wsig(_es) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}
531 #else
532 #define zzsetmatch_wsig(_es, handler) \
533 if ( !_zzsetmatch_wsig(_es) ) {_signal=MismatchedToken; goto handler;}
534 #endif
535
536 #ifdef __USE_PROTOS
537 extern int _zzsetmatch(SetWordType *, char **, char **, int *, int *, SetWordType **, SetWordType * /* MR23 */);
538 extern int _zzsetmatch_wsig(SetWordType *);
539 #else
540 extern int _zzsetmatch();
541 extern int _zzsetmatch_wsig();
542 #endif
543
544 #define zzmatch(_t) \
545 if ( !_zzmatch(_t, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail;
546
547 #ifdef ZZCAN_GUESS
548 #define zzmatch_wsig(_t,handler) \
549 if ( !_zzmatch_wsig(_t) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}
550 #else
551 #define zzmatch_wsig(_t,handler) \
552 if ( !_zzmatch_wsig(_t) ) {_signal=MismatchedToken; goto handler;}
553 #endif
554
555 #ifdef __USE_PROTOS
556 extern int _zzmatch(int, char **, char **, int *, int *, SetWordType **);
557 extern int _zzmatch_wsig(int);
558 #else
559 extern int _zzmatch();
560 extern int _zzmatch_wsig();
561 #endif
562
563 #define zzmatch_wdfltsig(_t,_f) \
564 if ( !_zzmatch_wdfltsig(_t,_f) ) _signal=MismatchedToken;
565 #define zzsetmatch_wdfltsig(tw,tt,wf) \
566 if ( !_zzsetmatch_wdfltsig(tw,tt,wf) ) _signal=MismatchedToken;
567
568 #ifdef __USE_PROTOS
569 extern int _zzmatch_wdfltsig(int, SetWordType *);
570 extern int _zzsetmatch_wdfltsig(SetWordType *tokensWanted,
571 int tokenTypeOfSet,
572 SetWordType *whatFollows);
573 #else
574 extern int _zzmatch_wdfltsig();
575 extern int _zzsetmatch_wdfltsig();
576 #endif
577
578 #ifdef GENAST
579 #define zzRULE Attrib *zzaRetPtr = &(zzaStack[zzasp-1]); \
580 SetWordType *zzMissSet=NULL; int zzMissTok=0; \
581 int zzBadTok=0; char *zzBadText=""; \
582 int zzErrk=1,zzpf=0; \
583 zzTRACEdata \
584 char *zzMissText=""; zzASTVars
585 #else
586 #define zzRULE Attrib *zzaRetPtr = &(zzaStack[zzasp-1]); \
587 int zzBadTok=0; char *zzBadText=""; \
588 int zzErrk=1,zzpf=0; \
589 zzTRACEdata \
590 SetWordType *zzMissSet=NULL; int zzMissTok=0; char *zzMissText=""
591 #endif
592
593 #ifdef GENAST
594 #define zzBLOCK(i) int i = zzasp - 1; int zztsp = zzast_sp
595 #define zzEXIT(i) zzREL(i); zzastREL; zzNON_GUESS_MODE { zzastPush(*_root); }
596 #define zzEXIT_ANTLR(i) zzREL(i); zzastREL /* [i_a] added as we want this for the ANTLRx() macros */
597 #define zzLOOP(i) zzREL(i); zzastREL
598 #else
599 #define zzBLOCK(i) int i = zzasp - 1
600 #define zzEXIT(i) zzREL(i)
601 #define zzEXIT_ANTLR(i) zzREL(i) /* [i_a] added as we want this for the ANTLRx() macros */
602 #define zzLOOP(i) zzREL(i)
603 #endif
604
605 #ifdef LL_K
606
607 #ifdef DEMAND_LOOK
608 #define LOOK(_k) {int i,stop=_k-(LL_K-zzdirty); for (i=1; i<=stop; i++) \
609 zzCONSUME;}
610 #define zzCONSUME {zzgettok(); zzdirty--; \
611 zzlap = (zzlap+1)&(LL_K-1); \
612 zzlextext = &(zztextLA[zzlap][0]);}
613 #else
614 #ifdef ZZINF_LOOK
615 #define zzCONSUME {inf_zzgettok; \
616 zzlap = (zzlap+1)&(LL_K-1); \
617 zzlextext = &(zztextLA[zzlap][0]); \
618 }
619 #else
620 #define zzCONSUME {zzgettok(); \
621 zzlap = (zzlap+1)&(LL_K-1); \
622 zzlextext = &(zztextLA[zzlap][0]);}
623 #endif /* ZZINF_LOOK */
624 #endif /* DEMAND_LOOK */
625
626 #else /* LL_K */
627
628 #ifdef DEMAND_LOOK
629 #define LOOK(_k) if ( zzdirty) zzCONSUME;
630 #ifdef ZZINF_LOOK
631 #define zzCONSUME inf_zzgettok; zzdirty=0;
632 #else
633 #define zzCONSUME zzgettok(); zzdirty=0;
634 #endif /* ZZINF_LOOK */
635
636 #else /* DEMAND_LOOK */
637
638 #ifdef ZZINF_LOOK
639 #define zzCONSUME inf_zzgettok
640 #else
641 #define zzCONSUME zzgettok();
642 #endif
643
644 #endif /* DEMAND_LOOK */
645
646 #endif /* LL_K */
647
648 #ifdef LL_K
649 #define NLA zztokenLA[zzlap&(LL_K-1)] /* --> next LA */
650 #define NLATEXT zztextLA[zzlap&(LL_K-1)] /* --> next text of LA */
651 #ifdef DEMAND_LOOK
652 #define LA(i) zztokenLA[(zzlabase+(i)-1)&(LL_K-1)]
653 #define LATEXT(i) (&(zztextLA[(zzlabase+(i)-1)&(LL_K-1)][0]))
654 #else
655 #define LA(i) zztokenLA[(zzlap+(i)-1)&(LL_K-1)]
656 #define LATEXT(i) (&(zztextLA[(zzlap+(i)-1)&(LL_K-1)][0]))
657 #endif
658 #else
659 #define NLA zztoken
660 #define NLATEXT zztext
661 #define LA(i) zztoken
662 #define LATEXT(i) zztext
663 #endif
664
665
666 /* S t a n d a r d S i g n a l s */
667
668 #define NoSignal 0
669 #define MismatchedToken 1
670 #define NoViableAlt 2
671 #define NoSemViableAlt 3
672
673 /* MR7 Allow more control over signalling */
674 /* by adding "Unwind" and "zzsetSignal" */
675
676 #define Unwind 4
677 #define zzsetSignal(newValue) *_retsignal=_signal=(newValue)
678 #define zzsuppressSignal *_retsignal=_signal=0
679 #define zzexportSignal *_retsignal=_signal
680
681 /* F u n c t i o n T r a c i n g */
682
683 #ifndef zzTRACE_RULES
684 #define zzTRACEdata
685 #else
686 #ifndef zzTRACEdata
687 #define zzTRACEdata ANTLRChar *zzTracePrevRuleName = NULL;
688 #endif
689 #endif
690
691 #ifndef zzTRACEIN
692 #define zzTRACEIN(r) zzTracePrevRuleName=zzTraceCurrentRuleName;zzTraceIn(r);
693 #endif
694 #ifndef zzTRACEOUT
695 #define zzTRACEOUT(r) zzTraceOut(r);zzTraceCurrentRuleName=zzTracePrevRuleName;
696 #endif
697
698 /* MR19 zzchar_t additions */
699
700 #ifndef zzchar_t
701 #ifdef ZZWCHAR_T
702 #define zzchar_t wchar_t
703 #else
704 #define zzchar_t char
705 #endif
706 #endif
707
708
709 /* MR26 */
710
711 #ifdef PCCTS_USE_STDARG
712 extern void zzFAIL(int k, ...);
713 #else
714 extern void zzFAIL();
715 #endif
716 /* E x t e r n D e f s */
717
718 #ifdef __USE_PROTOS
719 extern Attrib zzempty_attr(void);
720 extern Attrib zzconstr_attr(int, char *);
721 extern void zzsyn(char *, int, char *, SetWordType *, int, int, char *);
722 extern int zzset_el(unsigned, SetWordType *);
723 extern int zzset_deg(SetWordType *);
724 extern void zzedecode(SetWordType *);
725
726 extern void zzresynch(SetWordType *, SetWordType);
727 extern void zzsave_antlr_state(zzantlr_state *);
728 extern void zzrestore_antlr_state(zzantlr_state *);
729 extern void zzfill_inf_look(void);
730 extern void zzconsumeUntil(SetWordType *st); /* MR7 */
731 extern void zzconsumeUntilToken(int t); /* MR7 */
732 extern void zzTraceIn(char * ruleName); /* MR10 */
733 extern void zzTraceOut(char * ruleName); /* MR10 */
734 extern int zzTraceOption(int delta); /* MR10 */
735 extern int zzTraceGuessOption(int delta); /* MR10 */
736 extern void zzTraceReset(void); /* MR10 */
737 extern void zzTraceGuessFail(void); /* MR10 */
738 #ifdef EXCEPTION_HANDLING
739 extern void zzdflthandlers(int, int *);
740 #endif
741 #else
742 extern Attrib zzempty_attr();
743 extern Attrib zzconstr_attr();
744 extern void zzsyn();
745 extern int zzset_el();
746 extern int zzset_deg();
747 extern void zzedecode();
748 extern void zzresynch();
749 extern void zzsave_antlr_state();
750 extern void zzrestore_antlr_state();
751 extern void zzfill_inf_look();
752 extern void zzconsumeUntil(); /* MR7 */
753 extern void zzconsumeUntilToken(); /* MR7 */
754 extern void zzTraceIn(); /* MR10 */
755 extern void zzTraceOut(); /* MR10 */
756 extern int zzTraceOption(); /* MR10 */
757 extern int zzTraceGuessOption(); /* MR10 */
758 extern void zzTraceReset(); /* MR10 */
759 extern void zzTraceGuessFail(); /* MR10 */
760 #ifdef EXCEPTION_HANDLING
761 extern void zzdflthandlers();
762 #endif
763 #endif
764
765 /* G l o b a l V a r i a b l e s */
766
767 /* Define a parser; user should do a "#parser myname" in their grammar file */
768 /*extern struct pccts_parser zzparser;*/
769
770 extern char *zztokens[];
771 #ifdef LL_K
772 extern int zztokenLA[];
773 extern zzchar_t zztextLA[][ZZLEXBUFSIZE];
774 extern int zzlap;
775 extern int zzlabase;
776 #else
777 extern int zztoken;
778 #endif
779
780 extern char zzStackOvfMsg[];
781 extern int zzasp;
782 extern Attrib zzaStack[];
783 #ifdef ZZINF_LOOK
784 extern int *zzinf_tokens;
785 extern char **zzinf_text;
786 extern char *zzinf_text_buffer;
787 extern int *zzinf_line;
788 extern int zzinf_labase;
789 extern int zzinf_last;
790 #endif
791 #ifdef DEMAND_LOOK
792 extern int zzdirty;
793 #endif
794 #ifdef ZZCAN_GUESS
795 extern int zzguessing;
796 extern zzjmp_buf zzguess_start;
797 #endif
798
799 /* Define global veriables that refer to values exported by the scanner.
800 * These declarations duplicate those in dlgdef.h, but are needed
801 * if ANTLR is not to generate a .dlg file (-gx); PS, this is a hack.
802 */
803 extern zzchar_t *zzlextext; /* text of most recently matched token */
804 extern int zzbufsize; /* how long zzlextext is */
805
806 #endif
+0
-345
contrib/pccts/h/ast.c less more
0 /* Abstract syntax tree manipulation functions
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #include "pcctscfg.h"
30
31 #ifdef PCCTS_USE_STDARG
32 #include "pccts_stdarg.h"
33 #else
34 #include <varargs.h>
35 #endif
36
37 /* ensure that tree manipulation variables are current after a rule
38 * reference
39 */
40
41 void
42 #ifdef __USE_PROTOS
43 zzlink(AST **_root, AST **_sibling, AST **_tail)
44 #else
45 zzlink(_root, _sibling, _tail)
46 AST **_root, **_sibling, **_tail;
47 #endif
48 {
49 if ( *_sibling == NULL ) return;
50 if ( *_root == NULL ) *_root = *_sibling;
51 else if ( *_root != *_sibling ) (*_root)->down = *_sibling;
52 if ( *_tail==NULL ) *_tail = *_sibling;
53 while ( (*_tail)->right != NULL ) *_tail = (*_tail)->right;
54 }
55
56 AST *
57 #ifdef __USE_PROTOS
58 zzastnew(void)
59 #else
60 zzastnew()
61 #endif
62 {
63 AST *p = (AST *) calloc(1, sizeof(AST));
64 if ( p == NULL ) fprintf(stderr,"%s(%d): cannot allocate AST node\n",__FILE__,__LINE__);
65 return p;
66 }
67
68 /* add a child node to the current sibling list */
69 void
70 #ifdef __USE_PROTOS
71 zzsubchild(AST **_root, AST **_sibling, AST **_tail)
72 #else
73 zzsubchild(_root, _sibling, _tail)
74 AST **_root, **_sibling, **_tail;
75 #endif
76 {
77 AST *n;
78 zzNON_GUESS_MODE {
79 n = zzastnew();
80 #ifdef DEMAND_LOOK
81 zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));
82 #else
83 zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));
84 #endif
85 zzastPush( n );
86 if ( *_tail != NULL ) (*_tail)->right = n;
87 else {
88 *_sibling = n;
89 if ( *_root != NULL ) (*_root)->down = *_sibling;
90 }
91 *_tail = n;
92 if ( *_root == NULL ) *_root = *_sibling;
93 }
94 }
95
96 /* make a new AST node. Make the newly-created
97 * node the root for the current sibling list. If a root node already
98 * exists, make the newly-created node the root of the current root.
99 */
100 void
101 #ifdef __USE_PROTOS
102 zzsubroot(AST **_root, AST **_sibling, AST **_tail)
103 #else
104 zzsubroot(_root, _sibling, _tail)
105 AST **_root, **_sibling, **_tail;
106 #endif
107 {
108 AST *n;
109 zzNON_GUESS_MODE {
110 n = zzastnew();
111 #ifdef DEMAND_LOOK
112 zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));
113 #else
114 zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));
115 #endif
116 zzastPush( n );
117 if ( *_root != NULL )
118 if ( (*_root)->down == *_sibling ) *_sibling = *_tail = *_root;
119 *_root = n;
120 (*_root)->down = *_sibling;
121 }
122 }
123
124 /* Apply function to root then each sibling
125 * example: print tree in child-sibling LISP-format (AST has token field)
126 *
127 * void show(tree)
128 * AST *tree;
129 * {
130 * if ( tree == NULL ) return;
131 * printf(" %s", zztokens[tree->token]);
132 * }
133 *
134 * void before() { printf(" ("); }
135 * void after() { printf(" )"); }
136 *
137 * LISPdump() { zzpre_ast(tree, show, before, after); }
138 *
139 */
140 void
141 #ifdef __USE_PROTOS
142 zzpre_ast(
143 AST *tree,
144 void (*func)(AST *), /* apply this to each tree node */
145 void (*before)(AST *), /* apply this to root of subtree before preordering it */
146 void (*after)(AST *)) /* apply this to root of subtree after preordering it */
147 #else
148 zzpre_ast(tree, func, before, after)
149 AST *tree;
150 void (*func)(), /* apply this to each tree node */
151 (*before)(), /* apply this to root of subtree before preordering it */
152 (*after)(); /* apply this to root of subtree after preordering it */
153 #endif
154 {
155 while ( tree!= NULL )
156 {
157 if ( tree->down != NULL ) (*before)(tree);
158 (*func)(tree);
159 zzpre_ast(tree->down, func, before, after);
160 if ( tree->down != NULL ) (*after)(tree);
161 tree = tree->right;
162 }
163 }
164
165 /* free all AST nodes in tree; apply func to each before freeing */
166
167 #if 0
168 ////void
169 ////#ifdef __USE_PROTOS
170 ////zzfree_ast(AST *tree)
171 ////#else
172 ////zzfree_ast(tree)
173 ////AST *tree;
174 ////#endif
175 ////{
176 //// if ( tree == NULL ) return;
177 //// zzfree_ast( tree->down );
178 //// zzfree_ast( tree->right );
179 //// zztfree( tree );
180 ////}
181 #endif
182
183 /*
184 MR19 Optimize freeing of the following structure to limit recursion
185 SAKAI Kiyotaka (ksakai@isr.co.jp)
186 */
187
188 /*
189 NULL o
190 / \
191 NULL o
192 / \
193 NULL NULL
194 */
195
196 /*
197 MR21 Another refinement to replace recursion with iteration
198 NAKAJIMA Mutsuki (muc@isr.co.jp).
199 */
200
201 void
202 #ifdef __USE_PROTOS
203 zzfree_ast(AST *tree)
204 #else
205 zzfree_ast(tree)
206 AST *tree;
207 #endif
208 {
209
210 AST *otree;
211
212 if (tree == NULL) return;
213
214 while (tree->down == NULL || tree->right == NULL) {
215
216 if (tree->down == NULL && tree->right == NULL) {
217 zztfree(tree);
218 return;
219 }
220
221 otree = tree;
222 if (tree->down == NULL) {
223 tree = tree->right;
224 } else {
225 tree = tree->down;
226 }
227 zztfree( otree );
228 }
229
230 while (tree != NULL) {
231 zzfree_ast(tree->down);
232 otree = tree;
233 tree = otree->right;
234 zztfree(otree);
235 }
236 }
237
238 /* build a tree (root child1 child2 ... NULL)
239 * If root is NULL, simply make the children siblings and return ptr
240 * to 1st sibling (child1). If root is not single node, return NULL.
241 *
242 * Siblings that are actually siblins lists themselves are handled
243 * correctly. For example #( NULL, #( NULL, A, B, C), D) results
244 * in the tree ( NULL A B C D ).
245 *
246 * Requires at least two parameters with the last one being NULL. If
247 * both are NULL, return NULL.
248 */
249 #ifdef PCCTS_USE_STDARG
250 AST *zztmake(AST *rt, ...)
251 #else
252 AST *zztmake(va_alist)
253 va_dcl
254 #endif
255 {
256 va_list ap;
257 register AST *child, *sibling=NULL, *tail=NULL /* MR20 */, *w;
258 AST *root;
259
260 #ifdef PCCTS_USE_STDARG
261 va_start(ap, rt);
262 root = rt;
263 #else
264 va_start(ap);
265 root = va_arg(ap, AST *);
266 #endif
267
268 if ( root != NULL )
269 if ( root->down != NULL ) return NULL;
270 child = va_arg(ap, AST *);
271 while ( child != NULL )
272 {
273 for (w=child; w->right!=NULL; w=w->right) {;} /* find end of child */
274 if ( sibling == NULL ) {sibling = child; tail = w;}
275 else {tail->right = child; tail = w;}
276 child = va_arg(ap, AST *);
277 }
278 if ( root==NULL ) root = sibling;
279 else root->down = sibling;
280 va_end(ap);
281 return root;
282 }
283
284 /* tree duplicate */
285 AST *
286 #ifdef __USE_PROTOS
287 zzdup_ast(AST *t)
288 #else
289 zzdup_ast(t)
290 AST *t;
291 #endif
292 {
293 AST *u;
294
295 if ( t == NULL ) return NULL;
296 u = zzastnew();
297 *u = *t;
298 #ifdef zzAST_DOUBLE
299 u->up = NULL; /* set by calling invocation */
300 u->left = NULL;
301 #endif
302 u->right = zzdup_ast(t->right);
303 u->down = zzdup_ast(t->down);
304 #ifdef zzAST_DOUBLE
305 if ( u->right!=NULL ) u->right->left = u;
306 if ( u->down!=NULL ) u->down->up = u;
307 #endif
308 return u;
309 }
310
311 void
312 #ifdef __USE_PROTOS
313 zztfree(AST *t)
314 #else
315 zztfree(t)
316 AST *t;
317 #endif
318 {
319 #ifdef zzd_ast
320 zzd_ast( t );
321 #endif
322 free( t );
323 }
324
325 #ifdef zzAST_DOUBLE
326 /*
327 * Set the 'up', and 'left' pointers of all nodes in 't'.
328 * Initial call is double_link(your_tree, NULL, NULL).
329 */
330 void
331 #ifdef __USE_PROTOS
332 zzdouble_link(AST *t, AST *left, AST *up)
333 #else
334 zzdouble_link(t, left, up)
335 AST *t, *left, *up;
336 #endif
337 {
338 if ( t==NULL ) return;
339 t->left = left;
340 t->up = up;
341 zzdouble_link(t->down, NULL, t);
342 zzdouble_link(t->right, t, up);
343 }
344 #endif
+0
-121
contrib/pccts/h/ast.h less more
0 /* Abstract syntax tree
1 *
2 * Macros, definitions
3 *
4 * SOFTWARE RIGHTS
5 *
6 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
7 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
8 * company may do whatever they wish with source code distributed with
9 * PCCTS or the code generated by PCCTS, including the incorporation of
10 * PCCTS, or its output, into commerical software.
11 *
12 * We encourage users to develop software with PCCTS. However, we do ask
13 * that credit is given to us for developing PCCTS. By "credit",
14 * we mean that if you incorporate our source code into one of your
15 * programs (commercial product, research project, or otherwise) that you
16 * acknowledge this fact somewhere in the documentation, research report,
17 * etc... If you like PCCTS and have developed a nice tool with the
18 * output, please mention that you developed it using PCCTS. In
19 * addition, we ask that this header remain intact in our source code.
20 * As long as these guidelines are kept, we expect to continue enhancing
21 * this system and expect to make other tools available as they are
22 * completed.
23 *
24 * ANTLR 1.33
25 * Terence Parr
26 * Parr Research Corporation
27 * with Purdue University and AHPCRC, University of Minnesota
28 * 1989-2000
29 */
30
31 #ifndef ZZAST_H
32 #define ZZAST_H
33
34 #define zzastOvfChk \
35 if ( zzast_sp <= 0 ) \
36 { \
37 fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__); \
38 exit(PCCTS_EXIT_FAILURE); \
39 }
40
41 #ifndef USER_DEFINED_AST
42 #ifndef AST_FIELDS
43 #define AST_FIELDS
44 #endif
45
46 typedef struct _ast {
47 struct _ast *right, *down;
48 #ifdef zzAST_DOUBLE
49 struct _ast *left, *up;
50 #endif
51 AST_FIELDS
52 } AST;
53
54 #else
55
56 #ifdef zzAST_DOUBLE
57 #define AST_REQUIRED_FIELDS struct _ast *right, *down, *left, *up;
58 #else
59 #define AST_REQUIRED_FIELDS struct _ast *right, *down;
60 #endif
61
62 #endif
63
64
65 /* N o d e a c c e s s m a c r o s */
66 #define zzchild(t) (((t)==NULL)? (AST *) NULL:(t->down)) /* MR19 */
67 #define zzsibling(t) (((t)==NULL)? (AST *) NULL:(t->right)) /* MR19 */
68
69
70 /* define global variables needed by #i stack */
71 #define zzASTgvars \
72 AST *zzastStack[ZZAST_STACKSIZE]; \
73 int zzast_sp = ZZAST_STACKSIZE;
74
75 #define zzASTVars AST *_ast = NULL, *_sibling = NULL, *_tail = NULL
76 #define zzSTR ( (_tail==NULL)?(&_sibling):(&(_tail->right)) )
77 #define zzastCur (zzastStack[zzast_sp])
78 #define zzastArg(i) (zzastStack[zztsp-i])
79 #define zzastPush(p) zzastOvfChk; zzastStack[--zzast_sp] = p;
80 #define zzastDPush --zzast_sp
81 #define zzastMARK zztsp=zzast_sp; /* Save state of stack */
82 #define zzastREL zzast_sp=zztsp; /* Return state of stack */
83 #define zzrm_ast {zzfree_ast(*_root); _tail = _sibling = (*_root)=NULL;}
84
85 extern int zzast_sp;
86 extern AST *zzastStack[];
87
88 /* MR26 */
89
90 #ifdef PCCTS_USE_STDARG
91 AST *zztmake(AST *, ...);
92 #else
93 AST *zztmake();
94 #endif
95
96 #ifdef __USE_PROTOS
97 void zzlink(AST **, AST **, AST **);
98 void zzsubchild(AST **, AST **, AST **);
99 void zzsubroot(AST **, AST **, AST **);
100 void zzpre_ast(AST *, void (*)(AST *), void (*)(AST *), void (*)(AST *));
101 void zzfree_ast(AST *);
102 AST *zzdup_ast(AST *);
103 void zztfree(AST *);
104 void zzdouble_link(AST *, AST *, AST *);
105 AST *zzastnew(void);
106
107 #else
108
109 void zzlink();
110 AST *zzastnew();
111 void zzsubchild();
112 void zzsubroot();
113 void zzpre_ast();
114 void zzfree_ast();
115 AST *zzdup_ast();
116 void zztfree();
117 void zzdouble_link();
118 #endif
119
120 #endif
+0
-46
contrib/pccts/h/charbuf.h less more
0 /* ANTLR attribute definition -- constant width text
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef ZZCHARBUF_H
30 #define ZZCHARBUF_H
31
32 #include "pcctscfg.h"
33
34 #include "pccts_string.h"
35
36 #ifndef D_TextSize
37 #define D_TextSize 30
38 #endif
39
40 typedef struct { char text[D_TextSize]; } Attrib;
41
42 #define zzcr_attr(a,tok,t) strncpy((a)->text, t, D_TextSize-1); \
43 (a)->text[D_TextSize-1] = '\0';
44
45 #endif
+0
-58
contrib/pccts/h/charptr.c less more
0 /*
1 * SOFTWARE RIGHTS
2 *
3 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
4 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
5 * company may do whatever they wish with source code distributed with
6 * PCCTS or the code generated by PCCTS, including the incorporation of
7 * PCCTS, or its output, into commerical software.
8 *
9 * We encourage users to develop software with PCCTS. However, we do ask
10 * that credit is given to us for developing PCCTS. By "credit",
11 * we mean that if you incorporate our source code into one of your
12 * programs (commercial product, research project, or otherwise) that you
13 * acknowledge this fact somewhere in the documentation, research report,
14 * etc... If you like PCCTS and have developed a nice tool with the
15 * output, please mention that you developed it using PCCTS. In
16 * addition, we ask that this header remain intact in our source code.
17 * As long as these guidelines are kept, we expect to continue enhancing
18 * this system and expect to make other tools available as they are
19 * completed.
20 *
21 * ANTLR 1.33
22 * Terence Parr
23 * Parr Research Corporation
24 * with Purdue University and AHPCRC, University of Minnesota
25 * 1989-2000
26 */
27
28 #include "pcctscfg.h"
29
30 #ifdef __STDC__
31 #include "pccts_stdlib.h"
32 #else
33 #include <malloc.h>
34 #endif
35 #include "pccts_string.h"
36
37 /* 133MR1 include stdio.h for fprintf in charptr.c */
38
39 #include "pccts_stdio.h"
40
41 /* 133MR1 include charptr.h for Attrib in charptr.c */
42
43 #include "charptr.h"
44
45 #ifdef __USE_PROTOS
46 zzcr_attr(Attrib *a,int token,char *text)
47 #else
48 zzcr_attr(a,token,text)
49 Attrib *a;
50 int token;
51 char *text;
52 #endif
53 {
54 *a = (char *) malloc(strlen(text)+1); /* MR6 */
55 if ( *a == NULL ) {fprintf(stderr, "zzcr_attr: out of memory!\n"); exit(-1);}
56 strcpy(*a, text);
57 }
+0
-48
contrib/pccts/h/charptr.h less more
0 /*
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 /*
30 * WARNING!!!!: charptr.h does NOT make copies and the
31 * memory is freed after the attribute scope exits.
32 */
33
34 #ifndef ZZCHARPTR_H
35 #define ZZCHARPTR_H
36
37 typedef char *Attrib;
38 #define zzdef0(a) {*(a)=NULL;}
39 /* MR8 Jens Tingleff (jensting@imaginet.fr) */
40 /* Set memory pointer to null after free() */
41 #define zzd_attr(a) {if ( *(a)!=NULL ) {free(*(a)); *(a)=NULL; }; }
42
43 #ifdef __STDC__
44 extern zzcr_attr(Attrib *,int,char *);
45 #endif
46
47 #endif
+0
-1
contrib/pccts/h/config.h less more
0 #include "pcctscfg.h"
+0
-504
contrib/pccts/h/dlgauto.h less more
0 /* dlgauto.h automaton
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Will Cohen and Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef ZZDEFAUTO_H
30 #define ZZDEFAUTO_H
31
32 /* 10-Apr-97 133MR1 Uses __USE_PROTOS show should #include pcctscfg.h */
33
34 #include "pcctscfg.h"
35
36 zzchar_t *zzlextext; /* text of most recently matched token */
37 zzchar_t *zzbegexpr; /* beginning of last reg expr recogn. */
38 zzchar_t *zzendexpr; /* beginning of last reg expr recogn. */
39 int zzbufsize = 0; /* number of characters in zzlextext */ /* MR7 */
40 int zzbegcol = 0; /* column that first character of token is in*/
41 int zzendcol = 0; /* column that last character of token is in */
42 int zzline = 1; /* line current token is on */
43 int zzreal_line=1; /* line of 1st portion of token that is not skipped */
44 int zzchar; /* character to determine next state */
45 int zzbufovf; /* indicates that buffer too small for text */
46 int zzcharfull = 0;
47 static zzchar_t *zznextpos;/* points to next available position in zzlextext*/
48 static int zzclass;
49
50 #ifdef __USE_PROTOS
51 void zzerrstd(const char *);
52 void (*zzerr)(const char *)=zzerrstd;/* pointer to error reporting function */
53 extern int zzerr_in(void);
54 static int (*zzfunc_in)(void) = zzerr_in; /* MR20 */
55 #else
56 void zzerrstd();
57 void (*zzerr)()=zzerrstd; /* pointer to error reporting function */
58 extern int zzerr_in();
59 static int (*zzfunc_in)() = zzerr_in; /* MR20 */
60 #endif
61
62 static FILE *zzstream_in=0;
63 static zzchar_t *zzstr_in=0;
64
65 #ifdef USER_ZZMODE_STACK
66 int zzauto = 0;
67 #else
68 static int zzauto = 0;
69 #endif
70 static int zzadd_erase;
71 static char zzebuf[70];
72
73 #ifdef ZZCOL
74 #define ZZINC (++zzendcol)
75 #else
76 #define ZZINC
77 #endif
78
79
80 #define ZZGETC_STREAM {zzchar = getc(zzstream_in); zzclass = ZZSHIFT(zzchar);}
81 #define ZZGETC_FUNC {zzchar = (*zzfunc_in)(); zzclass = ZZSHIFT(zzchar);}
82 #define ZZGETC_STR { \
83 if (*zzstr_in){ \
84 zzchar = *zzstr_in; \
85 ++zzstr_in; \
86 }else{ \
87 zzchar = EOF; \
88 } \
89 zzclass = ZZSHIFT(zzchar); \
90 }
91
92 #define ZZNEWSTATE (newstate = dfa[state][zzclass])
93
94 #ifndef ZZCOPY
95 #define ZZCOPY \
96 /* Truncate matching buffer to size (not an error) */ \
97 if (zznextpos < lastpos){ \
98 *(zznextpos++) = zzchar; \
99 }else{ \
100 zzbufovf = 1; \
101 }
102 #endif
103
104 void
105 #ifdef __USE_PROTOS
106 zzrdstream( FILE *f )
107 #else
108 zzrdstream( f )
109 FILE *f;
110 #endif
111 {
112 /* make sure that it is really set to something, otherwise just
113 leave it be.
114 */
115 if (f){
116 /* make sure that there is always someplace to get input
117 before closing zzstream_in
118 */
119 #if 0
120 if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );
121 #endif
122 zzline = 1;
123 zzstream_in = f;
124 zzfunc_in = NULL;
125 zzstr_in = 0;
126 zzcharfull = 0;
127 }
128 }
129
130 void
131 #ifdef __USE_PROTOS
132 zzrdfunc( int (*f)(void) )
133 #else
134 zzrdfunc( f )
135 int (*f)();
136 #endif
137 {
138 /* make sure that it is really set to something, otherwise just
139 leave it be.
140 */
141 if (f){
142 /* make sure that there is always someplace to get input
143 before closing zzstream_in
144 */
145 #if 0
146 if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );
147 #endif
148 zzline = 1;
149 zzstream_in = NULL;
150 zzfunc_in = f;
151 zzstr_in = 0;
152 zzcharfull = 0;
153 }
154 }
155
156
157 void
158 #ifdef __USE_PROTOS
159 zzrdstr( zzchar_t *s )
160 #else
161 zzrdstr( s )
162 zzchar_t *s;
163 #endif
164 {
165 /* make sure that it is really set to something, otherwise just
166 leave it be.
167 */
168 if (s){
169 /* make sure that there is always someplace to get input
170 before closing zzstream_in
171 */
172 #if 0
173 if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );
174 #endif
175 zzline = 1;
176 zzstream_in = NULL;
177 zzfunc_in = 0;
178 zzstr_in = s;
179 zzcharfull = 0;
180 }
181 }
182
183
184 #ifdef __USE_PROTOS
185 void zzclose_stream(void)
186 #else
187 void zzclose_stream()
188 #endif
189 {
190 #if 0
191 fclose( zzstream_in );
192 zzstream_in = NULL;
193 zzfunc_in = NULL;
194 #endif
195 }
196
197 /* saves dlg state, but not what feeds dlg (such as file position) */
198 void
199 #ifdef __USE_PROTOS
200 zzsave_dlg_state(struct zzdlg_state *state)
201 #else
202 zzsave_dlg_state(state)
203 struct zzdlg_state *state;
204 #endif
205 {
206 state->stream = zzstream_in;
207 state->func_ptr = zzfunc_in;
208 state->str = zzstr_in;
209 state->auto_num = zzauto;
210 state->add_erase = zzadd_erase;
211 state->lookc = zzchar;
212 state->char_full = zzcharfull;
213 state->begcol = zzbegcol;
214 state->endcol = zzendcol;
215 state->line = zzline;
216 state->lextext = zzlextext;
217 state->begexpr = zzbegexpr;
218 state->endexpr = zzendexpr;
219 state->bufsize = zzbufsize;
220 state->bufovf = zzbufovf;
221 state->nextpos = zznextpos;
222 state->class_num = zzclass;
223 }
224
225 void
226 #ifdef __USE_PROTOS
227 zzrestore_dlg_state(struct zzdlg_state *state)
228 #else
229 zzrestore_dlg_state(state)
230 struct zzdlg_state *state;
231 #endif
232 {
233 zzstream_in = state->stream;
234 zzfunc_in = state->func_ptr;
235 zzstr_in = state->str;
236 zzauto = state->auto_num;
237 zzadd_erase = state->add_erase;
238 zzchar = state->lookc;
239 zzcharfull = state->char_full;
240 zzbegcol = state->begcol;
241 zzendcol = state->endcol;
242 zzline = state->line;
243 zzlextext = state->lextext;
244 zzbegexpr = state->begexpr;
245 zzendexpr = state->endexpr;
246 zzbufsize = state->bufsize;
247 zzbufovf = state->bufovf;
248 zznextpos = state->nextpos;
249 zzclass = state->class_num;
250 }
251
252 void
253 #ifdef __USE_PROTOS
254 zzmode( int m )
255 #else
256 zzmode( m )
257 int m;
258 #endif
259 {
260 /* points to base of dfa table */
261 if (m<MAX_MODE){
262 zzauto = m;
263 /* have to redo class since using different compression */
264 zzclass = ZZSHIFT(zzchar);
265 }else{
266 sprintf(zzebuf,"Invalid automaton mode = %d ",m);
267 zzerr(zzebuf);
268 }
269 }
270
271 /* erase what is currently in the buffer, and get a new reg. expr */
272
273 #ifdef __USE_PROTOS
274 void zzskip(void)
275 #else
276 void zzskip()
277 #endif
278 {
279 zzadd_erase = 1;
280 }
281
282 /* don't erase what is in the zzlextext buffer, add on to it */
283 #ifdef __USE_PROTOS
284 void zzmore()
285 #else
286 void zzmore()
287 #endif
288 {
289 zzadd_erase = 2;
290 }
291
292 /* substitute c for the reg. expr last matched and is in the buffer */
293 #ifdef __USE_PROTOS
294 void
295 zzreplchar(zzchar_t c)
296 #else
297 void
298 zzreplchar(c)
299 zzchar_t c;
300 #endif
301 {
302 /* can't allow overwriting null at end of string */
303 if (zzbegexpr < &zzlextext[zzbufsize-1]){
304 *zzbegexpr = c;
305 *(zzbegexpr+1) = '\0';
306 }
307 zzendexpr = zzbegexpr;
308 if (c != '\0') {
309 zznextpos = zzbegexpr + 1;
310 }
311 else {
312 zznextpos = zzbegexpr; /* MR30 Zero terminates string. */
313 }
314 }
315
316 /* replace the string s for the reg. expr last matched and in the buffer */
317 void
318 #ifdef __USE_PROTOS
319 zzreplstr(register zzchar_t *s)
320 #else
321 zzreplstr(s)
322 register zzchar_t *s;
323 #endif
324 {
325 register zzchar_t *l= &zzlextext[zzbufsize -1];
326
327 zznextpos = zzbegexpr;
328 if (s){
329 while ((zznextpos <= l) && (*(zznextpos++) = *(s++))!=0){
330 /* empty */
331 }
332 /* correct for NULL at end of string */
333 zznextpos--;
334 }
335 if ((zznextpos <= l) && (*(--s) == 0)){
336 zzbufovf = 0;
337 }else{
338 zzbufovf = 1;
339 }
340 *(zznextpos) = '\0';
341 zzendexpr = zznextpos - 1;
342 }
343
344 #ifdef __USE_PROTOS
345 void zzgettok(void)
346 #else
347 void zzgettok()
348 #endif
349 {
350 register int state, newstate;
351 /* last space reserved for the null char */
352 zzchar_t *lastpos; /* MR27 Remove register since address operator used. */
353
354 skip:
355 zzreal_line = zzline;
356 zzbufovf = 0;
357 lastpos = &zzlextext[zzbufsize-1];
358 zznextpos = zzlextext;
359 zzbegcol = zzendcol+1;
360 more:
361 zzbegexpr = zznextpos;
362 #ifdef ZZINTERACTIVE
363 /* interactive version of automaton */
364 /* if there is something in zzchar, process it */
365 state = newstate = dfa_base[zzauto];
366 if (zzcharfull){
367 ZZINC;
368 ZZCOPY;
369 ZZNEWSTATE;
370 }
371 if (zzstr_in)
372 while (zzalternatives[newstate]){
373 state = newstate;
374 ZZGETC_STR;
375 ZZINC;
376 ZZCOPY;
377 ZZNEWSTATE;
378 }
379 else if (zzstream_in)
380 while (zzalternatives[newstate]){
381 state = newstate;
382 ZZGETC_STREAM;
383 ZZINC;
384 ZZCOPY;
385 ZZNEWSTATE;
386 }
387 else if (zzfunc_in)
388 while (zzalternatives[newstate]){
389 state = newstate;
390 ZZGETC_FUNC;
391 ZZINC;
392 ZZCOPY;
393 ZZNEWSTATE;
394 }
395 /* figure out if last character really part of token */
396 if ((state != dfa_base[zzauto]) && (newstate == DfaStates)){
397 zzcharfull = 1;
398 --zznextpos;
399 }else{
400 zzcharfull = 0;
401 state = newstate;
402 }
403 *(zznextpos) = '\0';
404 /* Able to transition out of start state to some non err state?*/
405 if ( state == dfa_base[zzauto] ){
406 /* make sure doesn't get stuck */
407 zzadvance();
408 }
409 #else
410 /* non-interactive version of automaton */
411 if (!zzcharfull)
412 zzadvance();
413 else
414 ZZINC;
415 state = dfa_base[zzauto];
416 if (zzstr_in)
417 while (ZZNEWSTATE != DfaStates){
418 state = newstate;
419 ZZCOPY;
420 ZZGETC_STR;
421 ZZINC;
422 }
423 else if (zzstream_in)
424 while (ZZNEWSTATE != DfaStates){
425 state = newstate;
426 ZZCOPY;
427 ZZGETC_STREAM;
428 ZZINC;
429 }
430 else if (zzfunc_in)
431 while (ZZNEWSTATE != DfaStates){
432 state = newstate;
433 ZZCOPY;
434 ZZGETC_FUNC;
435 ZZINC;
436 }
437 zzcharfull = 1;
438 if ( state == dfa_base[zzauto] ){
439 if (zznextpos < lastpos){
440 *(zznextpos++) = zzchar;
441 }else{
442 zzbufovf = 1;
443 }
444 *zznextpos = '\0';
445 /* make sure doesn't get stuck */
446 zzadvance();
447 }else{
448 *zznextpos = '\0';
449 }
450 #endif
451 #ifdef ZZCOL
452 zzendcol -= zzcharfull;
453 #endif
454 zzendexpr = zznextpos -1;
455 zzadd_erase = 0;
456 (*actions[accepts[state]])();
457 switch (zzadd_erase) {
458 case 1: goto skip;
459 case 2: goto more;
460 }
461 }
462
463 #ifdef __USE_PROTOS
464 void zzadvance(void)
465 #else
466 void zzadvance()
467 #endif
468 {
469 if (zzstream_in) { ZZGETC_STREAM; zzcharfull = 1; ZZINC;}
470 if (zzfunc_in) { ZZGETC_FUNC; zzcharfull = 1; ZZINC;}
471 if (zzstr_in) { ZZGETC_STR; zzcharfull = 1; ZZINC;}
472 if (!(zzstream_in || zzfunc_in || zzstr_in)){
473 zzerr_in();
474 }
475 }
476
477 void
478 #ifdef __USE_PROTOS
479 zzerrstd(const char *s)
480 #else
481 zzerrstd(s)
482 char *s;
483 #endif
484 {
485 zzLexErrCount++; /* MR11 */
486 fprintf(stderr,
487 "%s near line %d (text was '%s')\n",
488 ((s == NULL) ? "Lexical error" : s),
489 zzline,zzlextext);
490 }
491
492 #ifdef __USE_PROTOS
493 int zzerr_in(void)
494 #else
495 int zzerr_in()
496 #endif
497 {
498 fprintf(stderr,"No input stream, function, or string\n");
499 /* return eof to get out gracefully */
500 return EOF;
501 }
502
503 #endif
+0
-128
contrib/pccts/h/dlgdef.h less more
0 /* dlgdef.h
1 * Things in scanner produced by dlg that should be visible to the outside
2 * world
3 *
4 * SOFTWARE RIGHTS
5 *
6 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
7 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
8 * company may do whatever they wish with source code distributed with
9 * PCCTS or the code generated by PCCTS, including the incorporation of
10 * PCCTS, or its output, into commerical software.
11 *
12 * We encourage users to develop software with PCCTS. However, we do ask
13 * that credit is given to us for developing PCCTS. By "credit",
14 * we mean that if you incorporate our source code into one of your
15 * programs (commercial product, research project, or otherwise) that you
16 * acknowledge this fact somewhere in the documentation, research report,
17 * etc... If you like PCCTS and have developed a nice tool with the
18 * output, please mention that you developed it using PCCTS. In
19 * addition, we ask that this header remain intact in our source code.
20 * As long as these guidelines are kept, we expect to continue enhancing
21 * this system and expect to make other tools available as they are
22 * completed.
23 *
24 * ANTLR 1.33
25 * Terence Parr
26 * Parr Research Corporation
27 * with Purdue University and AHPCRC, University of Minnesota
28 * 1989-2000
29 */
30
31 #ifndef ZZDLGDEF_H
32 #define ZZDLGDEF_H
33
34 #include "pcctscfg.h"
35
36 #ifndef zzchar_t
37 #ifdef ZZWCHAR_T
38 #define zzchar_t wchar_t
39 #else
40 #define zzchar_t char
41 #endif
42 #endif
43
44 struct zzdlg_state {
45 FILE *stream;
46 #ifdef __USE_PROTOS
47 int (*func_ptr)(void);
48 #else
49 int (*func_ptr)();
50 #endif
51 zzchar_t *str;
52 int auto_num;
53 int add_erase;
54 int lookc;
55 int char_full;
56 int begcol, endcol;
57 int line;
58 zzchar_t *lextext, *begexpr, *endexpr;
59 int bufsize;
60 int bufovf;
61 zzchar_t *nextpos;
62 int class_num;
63 };
64
65 extern zzchar_t *zzlextext; /* text of most recently matched token */
66 extern zzchar_t *zzbegexpr; /* beginning of last reg expr recogn. */
67 extern zzchar_t *zzendexpr; /* beginning of last reg expr recogn. */
68 extern int zzbufsize; /* how long zzlextext is */
69 extern int zzbegcol; /* column that first character of token is in*/
70 extern int zzendcol; /* column that last character of token is in */
71 extern int zzline; /* line current token is on */
72 extern int zzreal_line; /* line of 1st portion of token that is not skipped */
73 extern int zzchar; /* character to determine next state */
74 extern int zzbufovf; /* indicates that buffer too small for text */
75 #ifdef __USE_PROTOS
76 extern void (*zzerr)(const char *);/* pointer to error reporting function */
77 #else
78 extern void (*zzerr)();
79 #endif
80
81 #ifdef USER_ZZMODE_STACK
82 extern int zzauto;
83 #endif
84
85 #ifdef __USE_PROTOS
86 extern void zzadvance(void);
87 extern void zzskip(void); /* erase zzlextext, look for antoher token */
88 extern void zzmore(void); /* keep zzlextext, look for another token */
89 extern void zzmode(int k); /* switch to automaton 'k' */
90 extern void zzrdstream(FILE *);/* what stream to read from */
91 extern void zzclose_stream(void);/* close the current input stream */
92 extern void zzrdfunc(int (*)(void));/* what function to get char from */
93 extern void zzrdstr( zzchar_t * );
94 extern void zzgettok(void); /* get next token */
95 extern void zzreplchar(zzchar_t c);/* replace last recognized reg. expr. with
96 a character */
97 extern void zzreplstr(zzchar_t *s);/* replace last recognized reg. expr. with
98 a string */
99 extern void zzsave_dlg_state(struct zzdlg_state *);
100 extern void zzrestore_dlg_state(struct zzdlg_state *);
101 extern int zzerr_in(void);
102 extern void zzerrstd(const char *);
103 extern void zzerraction(void);
104
105 #else
106
107 extern void zzadvance();
108 extern void zzskip(); /* erase zzlextext, look for antoher token */
109 extern void zzmore(); /* keep zzlextext, look for another token */
110 extern void zzmode(/*k*/); /* switch to automaton 'k' */
111 extern void zzrdstream(); /* what stream to read from */
112 extern void zzclose_stream();/* close the current input stream */
113 extern void zzrdfunc(); /* what function to get char from */
114 extern void zzrdstr();
115 extern void zzgettok(); /* get next token */
116 extern void zzreplchar(); /* replace last recognized reg. expr. with
117 a character */
118 extern void zzreplstr(); /* replace last recognized reg. expr. with
119 a string */
120 extern void zzsave_dlg_state();
121 extern void zzrestore_dlg_state();
122 extern int zzerr_in();
123 extern void zzerrstd();
124 extern void zzerraction();
125 #endif
126
127 #endif
+0
-1170
contrib/pccts/h/err.h less more
0 /*
1 * err.h
2 *
3 * Standard error handling mechanism
4 *
5 * SOFTWARE RIGHTS
6 *
7 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
8 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
9 * company may do whatever they wish with source code distributed with
10 * PCCTS or the code generated by PCCTS, including the incorporation of
11 * PCCTS, or its output, into commerical software.
12 *
13 * We encourage users to develop software with PCCTS. However, we do ask
14 * that credit is given to us for developing PCCTS. By "credit",
15 * we mean that if you incorporate our source code into one of your
16 * programs (commercial product, research project, or otherwise) that you
17 * acknowledge this fact somewhere in the documentation, research report,
18 * etc... If you like PCCTS and have developed a nice tool with the
19 * output, please mention that you developed it using PCCTS. In
20 * addition, we ask that this header remain intact in our source code.
21 * As long as these guidelines are kept, we expect to continue enhancing
22 * this system and expect to make other tools available as they are
23 * completed.
24 *
25 * Has grown to hold all kinds of stuff (err.h is increasingly misnamed)
26 *
27 * ANTLR 1.33
28 * Terence Parr
29 * Parr Research Corporation
30 * with Purdue University and AHPCRC, University of Minnesota
31 * 1989-2000
32 */
33
34 #ifndef ERR_H
35 #define ERR_H
36
37 #include "pcctscfg.h"
38 #include <stdlib.h>
39 #include <assert.h>
40
41 /* */
42 /* 7-Apr-97 133MR1 */
43 /* Proper choice of STDC and cplusplus pre-processor symbols (?) */
44 /* */
45 #include "pccts_string.h"
46
47 #ifdef PCCTS_USE_STDARG
48 #include "pccts_stdarg.h"
49 #else
50 #include <varargs.h>
51 #endif
52
53 #ifdef DUM
54 /* Define usable bits per unsigned int word (used for set stuff) */
55 #ifdef PC
56 #define BSETWORDSIZE 16
57 #define BSETLOGWORDSIZE 4
58 #else
59 #define BSETWORDSIZE 32
60 #define BSETLOGWORDSIZE 5
61 #endif
62 #endif
63
64 #define BSETWORDSIZE 8
65 #define BSETLOGWORDSIZE 3 /* SetWordType is 8bits */
66
67 #define BSETMODWORD(x) ((x) & (BSETWORDSIZE-1)) /* x % BSETWORDSIZE */
68 #define BSETDIVWORD(x) ((x) >> BSETLOGWORDSIZE) /* x / BSETWORDSIZE */
69
70 /* This is not put into the global pccts_parser structure because it is
71 * hidden and does not need to be saved during a "save state" operation
72 */
73 /* maximum of 32 bits/unsigned int and must be 8 bits/byte */
74 static SetWordType bitmask[] = {
75 0x00000001, 0x00000002, 0x00000004, 0x00000008,
76 0x00000010, 0x00000020, 0x00000040, 0x00000080
77 };
78
79 #ifdef zzTRACE_RULES
80 int zzTraceOptionValueDefault=1;
81 int zzTraceOptionValue=1;
82 int zzTraceGuessOptionValue=1;
83 char *zzTraceCurrentRuleName=NULL;
84 int zzTraceDepth=0;
85 #endif
86
87 int zzGuessSeq=0; /* MR10 */
88 int zzSyntaxErrCount=0; /* MR11 */
89 int zzLexErrCount=0; /* MR11 */
90
91 void
92 #ifdef __USE_PROTOS
93 zzresynch(SetWordType *wd,SetWordType mask)
94 #else
95 zzresynch(wd,mask)
96 SetWordType *wd, mask;
97 #endif
98 {
99 static int consumed = 1;
100
101 /* if you enter here without having consumed a token from last resynch
102 * force a token consumption.
103 */
104 if ( !consumed ) {zzCONSUME; consumed=1; return;} /* MR10 */
105
106 /* if current token is in resynch set, we've got what we wanted */
107 if ( wd[LA(1)]&mask || LA(1) == zzEOF_TOKEN ) {consumed=0; return;}
108
109 /* scan until we find something in the resynch set */
110 while ( !(wd[LA(1)]&mask) && LA(1) != zzEOF_TOKEN ) {zzCONSUME;}
111 consumed=1;
112 }
113
114 /* */
115 /* 7-Apr-97 133MR1 for C++ and MR7 for C */
116 /* Change suggested by Eli Sternheim (eli@interhdl.com) */
117 /* */
118
119 void
120 #ifdef __USE_PROTOS
121 zzconsumeUntil(SetWordType *st)
122 #else
123 zzconsumeUntil(st)
124 SetWordType *st;
125 #endif
126 {
127 int tmp; /* MR7 */
128 while ( !zzset_el( (tmp=LA(1)), st) && tmp!=1 /* Eof */) { /* MR7 */
129 zzCONSUME; } /* MR7 */
130 }
131
132 /* */
133 /* 7-Apr-97 133MR1 for C++ and MR7 for C */
134 /* Change suggested by Eli Sternheim (eli@interhdl.com) */
135 /* */
136
137 void
138 #ifdef __USE_PROTOS
139 zzconsumeUntilToken(int t)
140 #else
141 zzconsumeUntilToken(t)
142 int t;
143 #endif
144 {
145 int tmp; /* MR7 */
146 while ( (tmp=LA(1)) !=t && tmp!=1 /* Eof */) { zzCONSUME; } /* MR7 */
147 }
148
149 /* input looks like:
150 * zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText)
151 * where the zzMiss stuff is set here to the token that did not match
152 * (and which set wasn't it a member of).
153 */
154
155 #ifdef PCCTS_USE_STDARG
156 void zzFAIL(int k, ...)
157 #else
158 void zzFAIL(va_alist)
159 va_dcl
160 #endif
161 {
162 #ifdef LL_K
163 static char text[LL_K*ZZLEXBUFSIZE+1];
164 SetWordType *f[LL_K];
165 #else
166 static char text[ZZLEXBUFSIZE+1];
167 SetWordType *f[1];
168 #endif
169 SetWordType **miss_set;
170 char **miss_text;
171 int *bad_tok;
172 char **bad_text;
173 int *err_k;
174 int i;
175 va_list ap;
176 #ifndef PCCTS_USE_STDARG /* MR20 */
177 int k;
178 #endif
179 #ifdef PCCTS_USE_STDARG /* MR20 */
180 va_start(ap, k);
181 #else
182 va_start(ap);
183 k = va_arg(ap, int); /* how many lookahead sets? */
184 #endif
185 assert(k <= sizeof(f)/sizeof(f[0])); /* MR20 G. Hobbelt */
186 text[0] = '\0';
187 for (i=1; i<=k; i++) /* collect all lookahead sets */
188 {
189 f[i-1] = va_arg(ap, SetWordType *);
190 }
191 for (i=1; i<=k; i++) /* look for offending token */
192 {
193 if ( i>1 ) strcat(text, " ");
194 strcat(text, LATEXT(i));
195 if ( !zzset_el((unsigned)LA(i), f[i-1]) ) break;
196 }
197 miss_set = va_arg(ap, SetWordType **);
198 miss_text = va_arg(ap, char **);
199 bad_tok = va_arg(ap, int *);
200 bad_text = va_arg(ap, char **);
201 err_k = va_arg(ap, int *);
202 if ( i>k )
203 {
204 /* bad; lookahead is permutation that cannot be matched,
205 * but, the ith token of lookahead is valid at the ith position
206 * (The old LL sub 1 (k) versus LL(k) parsing technique)
207 */
208 *miss_set = NULL;
209 *miss_text = zzlextext;
210 *bad_tok = LA(1);
211 *bad_text = LATEXT(1);
212 *err_k = k;
213 return;
214 }
215 /* fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/
216 *miss_set = f[i-1];
217 *miss_text = text;
218 *bad_tok = LA(i);
219 *bad_text = LATEXT(i);
220 if ( i==1 ) *err_k = 1;
221 else *err_k = k;
222 }
223
224 #ifdef __USE_PROTOS
225 void zzTraceGuessDone(zzantlr_state *state)
226 #else
227 void zzTraceGuessDone(state)
228 zzantlr_state *state;
229 #endif
230 {
231 #ifdef zzTRACE_RULES
232 #ifdef ZZCAN_GUESS
233
234 int doIt=0;
235
236 if (zzTraceCurrentRuleName == NULL) return;
237
238 if (zzTraceOptionValue <= 0) {
239 doIt=0;
240 } else if (zzTraceGuessOptionValue <= 0) {
241 doIt=0;
242 } else {
243 doIt=1;
244 };
245
246 if (doIt) {
247 fprintf(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",
248 state->traceCurrentRuleName,
249 LATEXT(1),
250 state->traceDepth);
251 if (state->guessing != 0) {
252 fprintf(stderr," (guess mode continues - an enclosing guess is still active)");
253 } else {
254 fprintf(stderr," (guess mode ends)");
255 };
256 fprintf(stderr,"\n");
257 };
258 #endif
259 #endif
260 }
261
262 void
263 #ifdef __USE_PROTOS
264 zzsave_antlr_state(zzantlr_state *buf)
265 #else
266 zzsave_antlr_state(buf)
267 zzantlr_state *buf;
268 #endif
269 {
270 #ifdef LL_K
271 int i;
272 #endif
273
274 #ifdef ZZCAN_GUESS
275 buf->guess_start = zzguess_start;
276 buf->guessing = zzguessing;
277 #endif
278 buf->asp = zzasp;
279 #ifdef GENAST
280 buf->ast_sp = zzast_sp;
281 #endif
282 #ifdef ZZINF_LOOK
283 buf->inf_labase = zzinf_labase;
284 buf->inf_last = zzinf_last;
285
286 /* MR6 Gunnar Rxnning (gunnar@candleweb.no) */
287 /* MR6 Additional state needs to be saved/restored */
288
289 buf->inf_tokens = zzinf_tokens; /* MR6 */
290 buf->inf_text = zzinf_text; /* MR6 */
291 buf->inf_text_buffer = zzinf_text_buffer; /* MR6 */
292 buf->inf_line = zzinf_line; /* MR6 */
293
294 #endif
295 #ifdef DEMAND_LOOK
296 buf->dirty = zzdirty;
297 #endif
298 #ifdef LL_K
299 for (i=0; i<LL_K; i++) buf->tokenLA[i] = zztokenLA[i];
300 for (i=0; i<LL_K; i++) strcpy(buf->textLA[i], zztextLA[i]);
301 buf->lap = zzlap;
302 buf->labase = zzlabase;
303 #else
304 buf->token = zztoken;
305 strcpy(buf->text, zzlextext);
306 #endif
307 #ifdef zzTRACE_RULES
308
309 /* MR10 */
310
311 buf->traceOptionValue=zzTraceOptionValue;
312 buf->traceGuessOptionValue=zzTraceGuessOptionValue;
313 buf->traceCurrentRuleName=zzTraceCurrentRuleName;
314 buf->traceDepth=zzTraceDepth;
315 #endif
316 }
317
318 void
319 #ifdef __USE_PROTOS
320 zzrestore_antlr_state(zzantlr_state *buf)
321 #else
322 zzrestore_antlr_state(buf)
323 zzantlr_state *buf;
324 #endif
325 {
326
327 #ifdef zzTRACE_RULES
328 int prevTraceOptionValue;
329 #endif
330
331 #ifdef LL_K
332 int i;
333 #endif
334
335 #ifdef ZZCAN_GUESS
336 zzguess_start = buf->guess_start;
337 zzguessing = buf->guessing;
338 #endif
339 zzasp = buf->asp;
340 #ifdef GENAST
341 zzast_sp = buf->ast_sp;
342 #endif
343 #ifdef ZZINF_LOOK
344 zzinf_labase = buf->inf_labase;
345 zzinf_last = buf->inf_last;
346
347 /* MR6 Gunnar Rxnning (gunnar@candleweb.no) */
348 /* MR6 Additional state needs to be saved/restored */
349
350 zzinf_tokens = buf->inf_tokens; /* MR6 */
351 zzinf_text = buf->inf_text; /* MR6 */
352 zzinf_text_buffer = buf->inf_text_buffer; /* MR6 */
353 zzinf_line = buf->inf_line; /* MR6 */
354 #endif
355 #ifdef DEMAND_LOOK
356 zzdirty = buf->dirty;
357 #endif
358 #ifdef LL_K
359 for (i=0; i<LL_K; i++) zztokenLA[i] = buf->tokenLA[i];
360 for (i=0; i<LL_K; i++) strcpy(zztextLA[i], buf->textLA[i]);
361 zzlap = buf->lap;
362 zzlabase = buf->labase;
363 #else
364 zztoken = buf->token;
365 strcpy(zzlextext, buf->text);
366 #endif
367 #ifdef zzTRACE_RULES
368
369 prevTraceOptionValue=zzTraceOptionValue;
370 zzTraceOptionValue=buf->traceOptionValue;
371 if ( (prevTraceOptionValue > 0) !=
372 (zzTraceOptionValue > 0)) {
373 if (zzTraceOptionValue > 0) {
374 fprintf(stderr,"trace enable restored in rule %s depth %d\n",
375 zzTraceCurrentRuleName,zzTraceDepth);
376 };
377 if (zzTraceOptionValue <= 0) {
378 fprintf(stderr,"trace disable restored in rule %s depth %d\n",
379 zzTraceCurrentRuleName,zzTraceDepth);
380 };
381 };
382
383 zzTraceOptionValue=buf->traceOptionValue; /* MR10 */
384 zzTraceGuessOptionValue=buf->traceGuessOptionValue; /* MR10 */
385 zzTraceCurrentRuleName=buf->traceCurrentRuleName; /* MR10 */
386 zzTraceDepth=buf->traceDepth; /* MR10 */
387 zzTraceGuessDone(buf); /* MR10 */
388 #endif
389 }
390
391 void
392 #ifdef __USE_PROTOS
393 zzedecode(SetWordType *a)
394 #else
395 zzedecode(a)
396 SetWordType *a;
397 #endif
398 {
399 register SetWordType *p = a;
400 register SetWordType *endp = &(p[zzSET_SIZE]);
401 register unsigned e = 0;
402
403 if ( zzset_deg(a)>1 ) fprintf(stderr, " {");
404 do {
405 register SetWordType t = *p;
406 register SetWordType *b = &(bitmask[0]);
407 do {
408 if ( t & *b ) fprintf(stderr, " %s", zztokens[e]);
409 e++;
410 } while (++b < &(bitmask[sizeof(SetWordType)*8]));
411 } while (++p < endp);
412 if ( zzset_deg(a)>1 ) fprintf(stderr, " }");
413 }
414
415 #ifndef USER_ZZSYN
416 /* standard error reporting function */
417 void
418 #ifdef __USE_PROTOS
419 zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
420 #else
421 zzsyn(text, tok, egroup, eset, etok, k, bad_text)
422 char *text, *egroup, *bad_text;
423 int tok;
424 int etok;
425 int k;
426 SetWordType *eset;
427 #endif
428 {
429
430 zzSyntaxErrCount++; /* MR11 */
431 fprintf(stderr, "line %d: syntax error at \"%s\"", zzline, (tok==zzEOF_TOKEN)?"EOF":bad_text);
432 if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
433 if ( k==1 ) fprintf(stderr, " missing");
434 else
435 {
436 fprintf(stderr, "; \"%s\" not", bad_text);
437 if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
438 }
439 if ( zzset_deg(eset)>0 ) zzedecode(eset);
440 else fprintf(stderr, " %s", zztokens[etok]);
441 if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);
442 fprintf(stderr, "\n");
443 }
444 #endif
445
446 /* is b an element of set p? */
447 int
448 #ifdef __USE_PROTOS
449 zzset_el(unsigned b, SetWordType *p)
450 #else
451 zzset_el(b,p)
452 unsigned b;
453 SetWordType *p;
454 #endif
455 {
456 return( p[BSETDIVWORD(b)] & bitmask[BSETMODWORD(b)] );
457 }
458
459 int
460 #ifdef __USE_PROTOS
461 zzset_deg(SetWordType *a)
462 #else
463 zzset_deg(a)
464 SetWordType *a;
465 #endif
466 {
467 /* Fast compute degree of a set... the number
468 of elements present in the set. Assumes
469 that all word bits are used in the set
470 */
471 register SetWordType *p = a;
472 register SetWordType *endp = &(a[zzSET_SIZE]);
473 register int degree = 0;
474
475 if ( a == NULL ) return 0;
476 while ( p < endp )
477 {
478 register SetWordType t = *p;
479 register SetWordType *b = &(bitmask[0]);
480 do {
481 if (t & *b) ++degree;
482 } while (++b < &(bitmask[sizeof(SetWordType)*8]));
483 p++;
484 }
485
486 return(degree);
487 }
488
489 #ifdef DEMAND_LOOK
490
491 #ifdef LL_K
492 int
493 #ifdef __USE_PROTOS
494 _zzmatch(int _t, char **zzBadText, char **zzMissText,
495 int *zzMissTok, int *zzBadTok,
496 SetWordType **zzMissSet)
497 #else
498 _zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
499 int _t;
500 char **zzBadText;
501 char **zzMissText;
502 int *zzMissTok, *zzBadTok;
503 SetWordType **zzMissSet;
504 #endif
505 {
506 if ( zzdirty==LL_K ) {
507 zzCONSUME;
508 }
509 if ( LA(1)!=_t ) {
510 *zzBadText = *zzMissText=LATEXT(1);
511 *zzMissTok= _t; *zzBadTok=LA(1);
512 *zzMissSet=NULL;
513 return 0;
514 }
515 zzMakeAttr
516 zzdirty++;
517 zzlabase++;
518 return 1;
519 }
520
521 int
522 #ifdef __USE_PROTOS
523 _zzmatch_wsig(int _t)
524 #else
525 _zzmatch_wsig(_t)
526 int _t;
527 #endif
528 {
529 if ( zzdirty==LL_K ) {
530 zzCONSUME;
531 }
532 if ( LA(1)!=_t ) {
533 return 0;
534 }
535 zzMakeAttr
536 zzdirty++;
537 zzlabase++;
538 return 1;
539 }
540
541 #else
542
543 int
544 #ifdef __USE_PROTOS
545 _zzmatch(int _t, char **zzBadText, char **zzMissText,
546 int *zzMissTok, int *zzBadTok, SetWordType **zzMissSet)
547 #else
548 _zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
549 int _t;
550 char **zzBadText;
551 char **zzMissText;
552 int *zzMissTok, *zzBadTok;
553 SetWordType **zzMissSet;
554 #endif
555 {
556 if ( zzdirty ) {zzCONSUME;}
557 if ( LA(1)!=_t ) {
558 *zzBadText = *zzMissText=LATEXT(1);
559 *zzMissTok= _t; *zzBadTok=LA(1);
560 *zzMissSet=NULL;
561 return 0;
562 }
563 zzdirty = 1;
564 zzMakeAttr
565 return 1;
566 }
567
568 int
569 #ifdef __USE_PROTOS
570 _zzmatch_wsig(int _t)
571 #else
572 _zzmatch_wsig(_t)
573 int _t;
574 #endif
575 {
576 if ( zzdirty ) {zzCONSUME;}
577 if ( LA(1)!=_t ) {
578 return 0;
579 }
580 zzdirty = 1;
581 zzMakeAttr
582 return 1;
583 }
584
585 #endif /*LL_K*/
586
587 #else
588
589 int
590 #ifdef __USE_PROTOS
591 _zzmatch(int _t, char **zzBadText, char **zzMissText,
592 int *zzMissTok, int *zzBadTok,
593 SetWordType **zzMissSet)
594 #else
595 _zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
596 int _t;
597 char **zzBadText;
598 char **zzMissText;
599 int *zzMissTok, *zzBadTok;
600 SetWordType **zzMissSet;
601 #endif
602 {
603 if ( LA(1)!=_t ) {
604 *zzBadText = *zzMissText=LATEXT(1);
605 *zzMissTok= _t; *zzBadTok=LA(1);
606 *zzMissSet=NULL;
607 return 0;
608 }
609 zzMakeAttr
610 return 1;
611 }
612
613 int
614 #ifdef __USE_PROTOS
615 _zzmatch_wsig(int _t)
616 #else
617 _zzmatch_wsig(_t)
618 int _t;
619 #endif
620 {
621 if ( LA(1)!=_t ) return 0;
622 zzMakeAttr
623 return 1;
624 }
625
626 #endif /*DEMAND_LOOK*/
627
628 #ifdef ZZINF_LOOK
629 void
630 #ifdef __USE_PROTOS
631 _inf_zzgettok(void)
632 #else
633 _inf_zzgettok()
634 #endif
635 {
636 if ( zzinf_labase >= zzinf_last )
637 {NLA = zzEOF_TOKEN; strcpy(NLATEXT, "");}
638 else {
639 NLA = zzinf_tokens[zzinf_labase];
640 zzline = zzinf_line[zzinf_labase]; /* wrong in 1.21 */
641 strcpy(NLATEXT, zzinf_text[zzinf_labase]);
642 zzinf_labase++;
643 }
644 }
645 #endif
646
647 #ifdef ZZINF_LOOK
648 /* allocate default size text,token and line arrays;
649 * then, read all of the input reallocing the arrays as needed.
650 * Once the number of total tokens is known, the LATEXT(i) array (zzinf_text)
651 * is allocated and it's pointers are set to the tokens in zzinf_text_buffer.
652 */
653 void
654 #ifdef __USE_PROTOS
655 zzfill_inf_look(void)
656 #else
657 zzfill_inf_look()
658 #endif
659 {
660 int tok, line;
661 int zzinf_token_buffer_size = ZZINF_DEF_TOKEN_BUFFER_SIZE;
662 int zzinf_text_buffer_size = ZZINF_DEF_TEXT_BUFFER_SIZE;
663 int zzinf_text_buffer_index = 0;
664 int zzinf_lap = 0;
665
666 /* allocate text/token buffers */
667 zzinf_text_buffer = (char *) malloc(zzinf_text_buffer_size);
668 if ( zzinf_text_buffer == NULL )
669 {
670 fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n",
671 zzinf_text_buffer_size);
672 exit(PCCTS_EXIT_FAILURE);
673 }
674 zzinf_tokens = (int *) calloc(zzinf_token_buffer_size,sizeof(int));
675 if ( zzinf_tokens == NULL )
676 {
677 fprintf(stderr, "cannot allocate token buffer (%d tokens)\n",
678 zzinf_token_buffer_size);
679 exit(PCCTS_EXIT_FAILURE);
680 }
681 zzinf_line = (int *) calloc(zzinf_token_buffer_size,sizeof(int));
682 if ( zzinf_line == NULL )
683 {
684 fprintf(stderr, "cannot allocate line buffer (%d ints)\n",
685 zzinf_token_buffer_size);
686 exit(PCCTS_EXIT_FAILURE);
687 }
688
689 /* get tokens, copying text to text buffer */
690 zzinf_text_buffer_index = 0;
691 do {
692 zzgettok();
693 line = zzreal_line;
694 while ( zzinf_lap>=zzinf_token_buffer_size )
695 {
696 zzinf_token_buffer_size += ZZINF_BUFFER_TOKEN_CHUNK_SIZE;
697 zzinf_tokens = (int *) realloc(zzinf_tokens,
698 zzinf_token_buffer_size*sizeof(int));
699 if ( zzinf_tokens == NULL )
700 {
701 fprintf(stderr, "cannot allocate lookahead token buffer (%d tokens)\n",
702 zzinf_token_buffer_size);
703 exit(PCCTS_EXIT_FAILURE);
704 }
705 zzinf_line = (int *) realloc(zzinf_line,
706 zzinf_token_buffer_size*sizeof(int));
707 if ( zzinf_line == NULL )
708 {
709 fprintf(stderr, "cannot allocate lookahead line buffer (%d ints)\n",
710 zzinf_token_buffer_size);
711 exit(PCCTS_EXIT_FAILURE);
712 }
713
714 }
715 while ( (zzinf_text_buffer_index+strlen(NLATEXT)+1) >= zzinf_text_buffer_size )
716 {
717 zzinf_text_buffer_size += ZZINF_BUFFER_TEXT_CHUNK_SIZE;
718 zzinf_text_buffer = (char *) realloc(zzinf_text_buffer,
719 zzinf_text_buffer_size);
720 if ( zzinf_text_buffer == NULL )
721 {
722 fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n",
723 zzinf_text_buffer_size);
724 exit(PCCTS_EXIT_FAILURE);
725 }
726 }
727 /* record token and text and line of input symbol */
728 tok = zzinf_tokens[zzinf_lap] = NLA;
729 strcpy(&zzinf_text_buffer[zzinf_text_buffer_index], NLATEXT);
730 zzinf_text_buffer_index += strlen(NLATEXT)+1;
731 zzinf_line[zzinf_lap] = line;
732 zzinf_lap++;
733 } while (tok!=zzEOF_TOKEN);
734 zzinf_labase = 0;
735 zzinf_last = zzinf_lap-1;
736
737 /* allocate ptrs to text of ith token */
738 zzinf_text = (char **) calloc(zzinf_last+1,sizeof(char *));
739 if ( zzinf_text == NULL )
740 {
741 fprintf(stderr, "cannot allocate lookahead text buffer (%d)\n",
742 zzinf_text_buffer_size);
743 exit(PCCTS_EXIT_FAILURE);
744 }
745 zzinf_text_buffer_index = 0;
746 zzinf_lap = 0;
747 /* set ptrs so that zzinf_text[i] is the text of the ith token found on input */
748 while (zzinf_lap<=zzinf_last)
749 {
750 zzinf_text[zzinf_lap++] = &zzinf_text_buffer[zzinf_text_buffer_index];
751 zzinf_text_buffer_index += strlen(&zzinf_text_buffer[zzinf_text_buffer_index])+1;
752 }
753 }
754 #endif
755
756 int
757 #ifdef __USE_PROTOS
758 _zzsetmatch(SetWordType *e, char **zzBadText, char **zzMissText,
759 int *zzMissTok, int *zzBadTok,
760 SetWordType **zzMissSet,
761 SetWordType *zzTokclassErrset /* MR23 */)
762 #else
763 _zzsetmatch(e, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet, zzTokclassErrset /* MR23 */)
764 SetWordType *e;
765 char **zzBadText;
766 char **zzMissText;
767 int *zzMissTok, *zzBadTok;
768 SetWordType **zzMissSet;
769 SetWordType *zzTokclassErrset;
770 #endif
771 {
772 #ifdef DEMAND_LOOK
773 #ifdef LL_K
774 if ( zzdirty==LL_K ) {zzCONSUME;}
775 #else
776 if ( zzdirty ) {zzCONSUME;}
777 #endif
778 #endif
779 if ( !zzset_el((unsigned)LA(1), e) ) {
780 *zzBadText = LATEXT(1); *zzMissText=NULL;
781 *zzMissTok= 0; *zzBadTok=LA(1);
782 *zzMissSet=zzTokclassErrset; /* MR23 */
783 return 0;
784 }
785 zzMakeAttr /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
786 #ifdef DEMAND_LOOK
787 #ifdef LL_K
788 zzdirty++;
789 zzlabase++; /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
790 #else
791 zzdirty = 1;
792 #endif
793 #endif
794 return 1;
795 }
796
797 int
798 #ifdef __USE_PROTOS
799 _zzmatch_wdfltsig(int tokenWanted, SetWordType *whatFollows)
800 #else
801 _zzmatch_wdfltsig(tokenWanted, whatFollows)
802 int tokenWanted;
803 SetWordType *whatFollows;
804 #endif
805 {
806 #ifdef DEMAND_LOOK
807 #ifdef LL_K
808 if ( zzdirty==LL_K ) {
809 zzCONSUME;
810 }
811 #else
812 if ( zzdirty ) {zzCONSUME;}
813 #endif
814 #endif
815
816 if ( LA(1)!=tokenWanted )
817 {
818 zzSyntaxErrCount++; /* MR11 */
819 fprintf(stderr,
820 "line %d: syntax error at \"%s\" missing %s\n",
821 zzline,
822 (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),
823 zztokens[tokenWanted]);
824 zzconsumeUntil( whatFollows );
825 return 0;
826 }
827 else {
828 zzMakeAttr
829 #ifdef DEMAND_LOOK
830 #ifdef LL_K
831 zzdirty++;
832 zzlabase++;
833 #else
834 zzdirty = 1;
835 #endif
836 #else
837 /* zzCONSUME; consume if not demand lookahead */
838 #endif
839 return 1;
840 }
841 }
842
843 int
844 #ifdef __USE_PROTOS
845 _zzsetmatch_wdfltsig(SetWordType *tokensWanted,
846 int tokenTypeOfSet,
847 SetWordType *whatFollows)
848 #else
849 _zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows)
850 SetWordType *tokensWanted;
851 int tokenTypeOfSet;
852 SetWordType *whatFollows;
853 #endif
854 {
855 #ifdef DEMAND_LOOK
856 #ifdef LL_K
857 if ( zzdirty==LL_K ) {zzCONSUME;}
858 #else
859 if ( zzdirty ) {zzCONSUME;}
860 #endif
861 #endif
862 if ( !zzset_el((unsigned)LA(1), tokensWanted) )
863 {
864 zzSyntaxErrCount++; /* MR11 */
865 fprintf(stderr,
866 "line %d: syntax error at \"%s\" missing %s\n",
867 zzline,
868 (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),
869 zztokens[tokenTypeOfSet]);
870 zzconsumeUntil( whatFollows );
871 return 0;
872 }
873 else {
874 zzMakeAttr
875 #ifdef DEMAND_LOOK
876 #ifdef LL_K
877 zzdirty++;
878 zzlabase++;
879 #else
880 zzdirty = 1;
881 #endif
882 #else
883 /* zzCONSUME; consume if not demand lookahead */
884 #endif
885 return 1;
886 }
887 }
888
889 int
890 #ifdef __USE_PROTOS
891 _zzsetmatch_wsig(SetWordType *e)
892 #else
893 _zzsetmatch_wsig(e)
894 SetWordType *e;
895 #endif
896 {
897 #ifdef DEMAND_LOOK
898 #ifdef LL_K
899 if ( zzdirty==LL_K ) {zzCONSUME;}
900 #else
901 if ( zzdirty ) {zzCONSUME;}
902 #endif
903 #endif
904 if ( !zzset_el((unsigned)LA(1), e) ) return 0;
905 zzMakeAttr /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
906 #ifdef DEMAND_LOOK
907 #ifdef LL_K
908 zzdirty++;
909 zzlabase++; /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
910 #else
911 zzdirty = 1;
912 #endif
913 #endif
914 return 1;
915 }
916
917 #ifdef USER_ZZMODE_STACK
918 static int zzmstk[ZZMAXSTK] = { -1 };
919 static int zzmdep = 0;
920 static char zzmbuf[70];
921
922 void
923 #ifdef __USE_PROTOS
924 zzmpush( int m )
925 #else
926 zzmpush( m )
927 int m;
928 #endif
929 {
930 if(zzmdep == ZZMAXSTK - 1) {
931 sprintf(zzmbuf, "Mode stack overflow ");
932 zzerr(zzmbuf);
933 } else {
934 zzmstk[zzmdep++] = zzauto;
935 zzmode(m);
936 }
937 }
938
939 void
940 #ifdef __USE_PROTOS
941 zzmpop( void )
942 #else
943 zzmpop( )
944 #endif
945 {
946 if(zzmdep == 0)
947 { sprintf(zzmbuf, "Mode stack underflow ");
948 zzerr(zzmbuf);
949 }
950 else
951 { zzmdep--;
952 zzmode(zzmstk[zzmdep]);
953 }
954 }
955
956 void
957 #ifdef __USE_PROTOS
958 zzsave_mode_stack( int modeStack[], int *modeLevel )
959 #else
960 zzsave_mode_stack( modeStack, modeLevel )
961 int modeStack[];
962 int *modeLevel;
963 #endif
964 {
965 int i;
966 memcpy(modeStack, zzmstk, sizeof(zzmstk));
967 *modeLevel = zzmdep;
968 zzmdep = 0;
969
970 return;
971 }
972
973 void
974 #ifdef __USE_PROTOS
975 zzrestore_mode_stack( int modeStack[], int *modeLevel )
976 #else
977 zzrestore_mode_stack( modeStack, modeLevel )
978 int modeStack[];
979 int *modeLevel;
980 #endif
981 {
982 int i;
983
984 memcpy(zzmstk, modeStack, sizeof(zzmstk));
985 zzmdep = *modeLevel;
986
987 return;
988 }
989 #endif /* USER_ZZMODE_STACK */
990
991 #ifdef __USE_PROTOS
992 void zzTraceReset(void)
993 #else
994 void zzTraceReset()
995 #endif
996 {
997 #ifdef zzTRACE_RULES
998 zzTraceOptionValue=zzTraceOptionValueDefault;
999 zzTraceGuessOptionValue=1;
1000 zzTraceCurrentRuleName=NULL;
1001 zzTraceDepth=0;
1002 #endif
1003 }
1004
1005 #ifdef __USE_PROTOS
1006 void zzTraceGuessFail(void)
1007 #else
1008 void zzTraceGuessFail()
1009 #endif
1010 {
1011
1012 #ifdef zzTRACE_RULES
1013 #ifdef ZZCAN_GUESS
1014
1015 int doIt=0;
1016
1017 if (zzTraceOptionValue <= 0) {
1018 doIt=0;
1019 } else if (zzguessing && zzTraceGuessOptionValue <= 0) {
1020 doIt=0;
1021 } else {
1022 doIt=1;
1023 };
1024
1025 if (doIt) {
1026 fprintf(stderr,"guess failed\n");
1027 };
1028 #endif
1029 #endif
1030 }
1031
1032 /* zzTraceOption:
1033 zero value turns off trace
1034 */
1035
1036 #ifdef __USE_PROTOS
1037 void zzTraceIn(char * rule)
1038 #else
1039 void zzTraceIn(rule)
1040 char *rule;
1041 #endif
1042 {
1043 #ifdef zzTRACE_RULES
1044
1045 int doIt=0;
1046
1047 zzTraceDepth++;
1048 zzTraceCurrentRuleName=rule;
1049
1050 if (zzTraceOptionValue <= 0) {
1051 doIt=0;
1052 #ifdef ZZCAN_GUESS
1053 } else if (zzguessing && zzTraceGuessOptionValue <= 0) {
1054 doIt=0;
1055 #endif
1056 } else {
1057 doIt=1;
1058 };
1059
1060 if (doIt) {
1061 fprintf(stderr,"enter rule %s {\"%s\"} depth %d",
1062 rule,
1063 LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */
1064 zzTraceDepth);
1065 #ifdef ZZCAN_GUESS
1066 if (zzguessing) fprintf(stderr," guessing");
1067 #endif
1068 fprintf(stderr,"\n");
1069 };
1070 #endif
1071 return;
1072 }
1073
1074 #ifdef __USE_PROTOS
1075 void zzTraceOut(char * rule)
1076 #else
1077 void zzTraceOut(rule)
1078 char *rule;
1079 #endif
1080 {
1081 #ifdef zzTRACE_RULES
1082 int doIt=0;
1083
1084 zzTraceDepth--;
1085
1086 if (zzTraceOptionValue <= 0) {
1087 doIt=0;
1088 #ifdef ZZCAN_GUESS
1089 } else if (zzguessing && zzTraceGuessOptionValue <= 0) {
1090 doIt=0;
1091 #endif
1092 } else {
1093 doIt=1;
1094 };
1095
1096 if (doIt) {
1097 fprintf(stderr,"exit rule %s {\"%s\"} depth %d",
1098 rule,
1099 LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */
1100 zzTraceDepth+1);
1101 #ifdef ZZCAN_GUESS
1102 if (zzguessing) fprintf(stderr," guessing");
1103 #endif
1104 fprintf(stderr,"\n");
1105 };
1106 #endif
1107 }
1108
1109 #ifdef __USE_PROTOS
1110 int zzTraceOption(int delta)
1111 #else
1112 int zzTraceOption(delta)
1113 int delta;
1114 #endif
1115 {
1116 #ifdef zzTRACE_RULES
1117 int prevValue=zzTraceOptionValue;
1118
1119 zzTraceOptionValue=zzTraceOptionValue+delta;
1120
1121 if (zzTraceCurrentRuleName != NULL) {
1122 if (prevValue <= 0 && zzTraceOptionValue > 0) {
1123 fprintf(stderr,"trace enabled in rule %s depth %d\n",
1124 zzTraceCurrentRuleName,zzTraceDepth);
1125 };
1126 if (prevValue > 0 && zzTraceOptionValue <= 0) {
1127 fprintf(stderr,"trace disabled in rule %s depth %d\n",
1128 zzTraceCurrentRuleName,zzTraceDepth);
1129 };
1130 };
1131 return prevValue;
1132 #else
1133 return 0;
1134 #endif
1135 }
1136
1137 #ifdef __USE_PROTOS
1138 int zzTraceGuessOption(int delta)
1139 #else
1140 int zzTraceGuessOption(delta)
1141 int delta;
1142 #endif
1143 {
1144 #ifdef zzTRACE_RULES
1145 #ifdef ZZCAN_GUESS
1146 int prevValue=zzTraceGuessOptionValue;
1147
1148 zzTraceGuessOptionValue=zzTraceGuessOptionValue+delta;
1149
1150 if (zzTraceCurrentRuleName != NULL) {
1151 if (prevValue <= 0 && zzTraceGuessOptionValue > 0) {
1152 fprintf(stderr,"guess trace enabled in rule %s depth %d\n",
1153 zzTraceCurrentRuleName,zzTraceDepth);
1154 };
1155 if (prevValue > 0 && zzTraceGuessOptionValue <= 0) {
1156 fprintf(stderr,"guess trace disabled in rule %s depth %d\n",
1157 zzTraceCurrentRuleName,zzTraceDepth);
1158 };
1159 };
1160 return prevValue;
1161 #else
1162 return 0;
1163 #endif
1164 #else
1165 return 0;
1166 #endif
1167 }
1168
1169 #endif /* ERR_H */
+0
-37
contrib/pccts/h/int.h less more
0 /* ANTLR attribute definition -- long integers
1 *
2 * SOFTWARE RIGHTS
3 *
4 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
5 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
6 * company may do whatever they wish with source code distributed with
7 * PCCTS or the code generated by PCCTS, including the incorporation of
8 * PCCTS, or its output, into commerical software.
9 *
10 * We encourage users to develop software with PCCTS. However, we do ask
11 * that credit is given to us for developing PCCTS. By "credit",
12 * we mean that if you incorporate our source code into one of your
13 * programs (commercial product, research project, or otherwise) that you
14 * acknowledge this fact somewhere in the documentation, research report,
15 * etc... If you like PCCTS and have developed a nice tool with the
16 * output, please mention that you developed it using PCCTS. In
17 * addition, we ask that this header remain intact in our source code.
18 * As long as these guidelines are kept, we expect to continue enhancing
19 * this system and expect to make other tools available as they are
20 * completed.
21 *
22 * ANTLR 1.33
23 * Terence Parr
24 * Parr Research Corporation
25 * with Purdue University and AHPCRC, University of Minnesota
26 * 1989-2000
27 */
28
29 #ifndef ZZINT_H
30 #define ZZINT_H
31
32 typedef long Attrib;
33
34 #define zzcr_attr(a,tok,t) *(a) = atol(t);
35
36 #endif
+0
-10
contrib/pccts/h/pccts_assert.h less more
0 #ifndef __PCCTS_ASSERT_H__
1 #define __PCCTS_ASSERT_H__
2
3 #ifdef PCCTS_USE_NAMESPACE_STD
4 #include <cassert>
5 #else
6 #include <assert.h>
7 #endif
8
9 #endif
+0
-10
contrib/pccts/h/pccts_iostream.h less more
0 #ifndef __PCCTS_IOSTREAM_H__
1 #define __PCCTS_IOSTREAM_H__
2
3 #ifdef PCCTS_USE_NAMESPACE_STD
4 #include <iostream>
5 #else
6 #include <iostream.h>
7 #endif
8
9 #endif
+0
-10
contrib/pccts/h/pccts_istream.h less more
0 #ifndef __PCCTS_ISTREAM_H__
1 #define __PCCTS_ISTREAM_H__
2
3 #ifdef PCCTS_USE_NAMESPACE_STD
4 #include <istream>
5 #else
6 #include <istream.h>
7 #endif
8
9 #endif
+0
-10
contrib/pccts/h/pccts_setjmp.h less more
0 #ifndef __PCCTS_SETJMP_H__
1 #define __PCCTS_SETJMP_H__
2
3 #ifdef PCCTS_USE_NAMESPACE_STD
4 #include <csetjmp>
5 #else
6 #include <setjmp.h>
7 #endif
8
9 #endif
+0
-10
contrib/pccts/h/pccts_stdarg.h less more
0 #ifndef __PCCTS_STDARG_H__
1 #define __PCCTS_STDARG_H__
2
3 #ifdef PCCTS_USE_NAMESPACE_STD
4 #include <cstdarg>
5 #else
6 #include <stdarg.h>
7 #endif
8
9 #endif
+0
-10
contrib/pccts/h/pccts_stdio.h less more
0 #ifndef __PCCTS_STDIO_H__
1 #define __PCCTS_STDIO_H__
2
3 #ifdef PCCTS_USE_NAMESPACE_STD
4 #include <cstdio>
5 #else
6 #include <stdio.h>
7 #endif
8
9 #endif
+0
-10
contrib/pccts/h/pccts_stdlib.h less more
0 #ifndef __PCCTS_STDLIB_H__
1 #define __PCCTS_STDLIB_H__
2
3 #ifdef PCCTS_USE_NAMESPACE_STD
4 #include <cstdlib>
5 #else
6 #include <stdlib.h>
7 #endif
8
9 #endif
+0
-10
contrib/pccts/h/pccts_string.h less more
0 #ifndef __PCCTS_STRING_H__
1 #define __PCCTS_STRING_H__
2
3 #ifdef PCCTS_USE_NAMESPACE_STD
4 #include <cstring>
5 #else
6 #include <string.h>
7 #endif
8
9 #endif
+0
-359
contrib/pccts/h/pcctscfg.h less more
0 #ifndef PCCTS_CONFIG_H
1 #define PCCTS_CONFIG_H
2 /*
3 * pcctscfg.h (formerly config.h) (for ANTLR, DLG, and SORCERER)
4 *
5 * This is a simple configuration file that doesn't have config stuff
6 * in it, but it's a start.
7 *
8 * SOFTWARE RIGHTS
9 *
10 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
11 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
12 * company may do whatever they wish with source code distributed with
13 * PCCTS or the code generated by PCCTS, including the incorporation of
14 * PCCTS, or its output, into commerical software.
15 *
16 * We encourage users to develop software with PCCTS. However, we do ask
17 * that credit is given to us for developing PCCTS. By "credit",
18 * we mean that if you incorporate our source code into one of your
19 * programs (commercial product, research project, or otherwise) that you
20 * acknowledge this fact somewhere in the documentation, research report,
21 * etc... If you like PCCTS and have developed a nice tool with the
22 * output, please mention that you developed it using PCCTS. In
23 * addition, we ask that this header remain intact in our source code.
24 * As long as these guidelines are kept, we expect to continue enhancing
25 * this system and expect to make other tools available as they are
26 * completed.
27 *
28 * Used by PCCTS 1.33 (SORCERER 1.00B11 and up)
29 * Terence Parr
30 * Parr Research Corporation
31 * with Purdue University and AHPCRC, University of Minnesota
32 * 1989-2000
33 */
34
35 /* This file knows about the following ``environments''
36 UNIX (default)
37 DOS (use #define PC)
38 MAC (use #define MPW; has a few things for THINK C, Metrowerks)
39 MS/C++ (MR14 Microsoft Visual C++ environment uses symbol _MSC_VER)
40
41 */
42
43 /* should test __STDC__ for 1, but some compilers don't set value, just def */
44
45 #ifndef __USE_PROTOS
46 #ifdef __STDC__
47 #define __USE_PROTOS
48 #endif
49 #ifdef __cplusplus
50 #define __USE_PROTOS
51 #endif
52 #endif
53
54 #ifdef PCCTS_USE_NAMESPACE_STD
55 #define PCCTS_NAMESPACE_STD namespace std {}; using namespace std;
56 #else
57 #define PCCTS_NAMESPACE_STD
58 #endif
59
60 #include "pccts_stdio.h"
61 #include "pccts_stdlib.h"
62
63 /* largest file name size */
64
65 #ifdef _MAX_PATH
66 #define MaxFileName _MAX_PATH /* MR9 RJV: MAX_PATH defined in stdlib.h (MSVC++ 5.0) */
67 #else
68 #define MaxFileName 300
69 #endif
70
71 /*
72 * Define PC32 if in a 32-bit PC environment (e.g. extended DOS or Win32).
73 * The macros tested here are defined by Watcom, Microsoft, Borland,
74 * and djgpp, respectively, when they are used as 32-bit compilers.
75 * Users of these compilers *must* be sure to define PC in their
76 * makefiles for this to work correctly.
77 */
78 #ifdef PC
79 # if (defined(__WATCOMC__) || defined(_WIN32) || defined(__WIN32__) || \
80 defined(__GNUC__) || defined(__GNUG__))
81 # ifndef PC32
82 # define PC32
83 # endif
84 # endif
85 #endif
86
87 /* MR1 10-Apr-97 Default for PC is short file names */
88 /* MR1 Default for non-PC is long file names */
89 /* MR1 Can override via command line option LONGFILENAMES */
90
91 #ifndef LONGFILENAMES
92 #ifndef PC
93 #define LONGFILENAMES
94 #endif
95 #endif
96
97 #ifndef LONGFILENAMES
98 #define ATOKEN_H "AToken.h"
99 #define ATOKPTR_H "ATokPtr.h"
100 #define ATOKPTR_IMPL_H "ATokPtrIm.h"
101 #define ATOKENBUFFER_H "ATokBuf.h"
102 #define ATOKENBUFFER_C "ATokBuf.cpp"
103 #define ATOKENSTREAM_H "ATokStr.h"
104 #define APARSER_H "AParser.h"
105 #define APARSER_C "AParser.cpp"
106 #define ASTBASE_H "ASTBase.h"
107 #define ASTBASE_C "ASTBase.cpp"
108 #define PCCTSAST_C "PCCTSAST.cpp"
109 #define LIST_C "List.cpp"
110 #define DLEXERBASE_H "DLexBase.h"
111 #define DLEXERBASE_C "DLexBase.cpp"
112 #define DLEXER_H "DLexer.h"
113 #define STREESUPPORT_C "STreeSup.C"
114 #else
115 #define ATOKEN_H "AToken.h"
116 #define ATOKPTR_H "ATokPtr.h"
117 #define ATOKPTR_IMPL_H "ATokPtrImpl.h"
118 #define ATOKENBUFFER_H "ATokenBuffer.h"
119 #define ATOKENBUFFER_C "ATokenBuffer.cpp"
120 #define ATOKENSTREAM_H "ATokenStream.h"
121 #define APARSER_H "AParser.h"
122 #define APARSER_C "AParser.cpp"
123 #define ASTBASE_H "ASTBase.h"
124 #define ASTBASE_C "ASTBase.cpp"
125 #define PCCTSAST_C "PCCTSAST.cpp"
126 #define LIST_C "List.cpp"
127 #define DLEXERBASE_H "DLexerBase.h"
128 #define DLEXERBASE_C "DLexerBase.cpp"
129 #define DLEXER_H "DLexer.h"
130 #define STREESUPPORT_C "STreeSupport.cpp"
131 #endif
132
133 /* SORCERER Stuff */
134
135 /* MR8 6-Aug-97 Change from ifdef PC to ifndef LONGFILENAMES */
136
137 #ifndef LONGFILENAMES
138 #define STPARSER_H "STreePar.h"
139 #define STPARSER_C "STreePar.C"
140 #else
141 #define STPARSER_H "STreeParser.h"
142 #define STPARSER_C "STreeParser.cpp"
143 #endif
144
145 #ifdef MPW
146 #define CPP_FILE_SUFFIX ".cp"
147 #define CPP_FILE_SUFFIX_NO_DOT "cp"
148 #define OBJ_FILE_SUFFIX ".o"
149 #else
150 #ifdef PC
151 #define CPP_FILE_SUFFIX ".cpp"
152 #define CPP_FILE_SUFFIX_NO_DOT "cpp"
153 #define OBJ_FILE_SUFFIX ".obj"
154 #else
155 #ifdef __VMS
156 #define CPP_FILE_SUFFIX ".cpp"
157 #define CPP_FILE_SUFFIX_NO_DOT "cpp"
158 #define OBJ_FILE_SUFFIX ".obj"
159 #else
160 #define CPP_FILE_SUFFIX ".cpp"
161 #define CPP_FILE_SUFFIX_NO_DOT "cpp"
162 #define OBJ_FILE_SUFFIX ".o"
163 #endif
164 #endif
165 #endif
166
167 /* User may redefine how line information looks */ /* make it #line MR7 */
168 /* MR21 Use #ifndef */
169
170 #ifndef LineInfoFormatStr
171 #define LineInfoFormatStr "#line %d \"%s\"\n"
172 #endif
173
174 #ifdef MPW /* Macintosh Programmer's Workshop */
175 #define ErrHdr "File \"%s\"; Line %d #"
176 #else
177 #ifdef _MSC_VER /* MR14 Microsoft Visual C++ environment */
178 #define ErrHdr "%s(%d) :"
179 #else
180 #define ErrHdr "%s, line %d:" /* default */
181 #endif
182 #endif
183
184 /* must assume old K&R cpp here, can't use #if defined(..)... */
185
186 #ifdef MPW
187 #define TopDirectory ":"
188 #define DirectorySymbol ":"
189 #define OutputDirectoryOption "Directory where all output files should go (default=\":\")"
190 #else
191 #ifdef PC
192 #define TopDirectory "."
193 #define DirectorySymbol "\\"
194 #define OutputDirectoryOption "Directory where all output files should go (default=\".\")"
195 #else
196 #ifdef __VMS
197 #define TopDirectory "[000000]"
198 #define DirectorySymbol "]"
199 #define OutputDirectoryOption "Directory where all output files should go (default=\"[]\")"
200 #else
201 #define TopDirectory "."
202 #define DirectorySymbol "/"
203 #define OutputDirectoryOption "Directory where all output files should go (default=\".\")"
204 #endif
205 #endif
206 #endif
207
208 #ifdef MPW
209
210 /* Make sure we have prototypes for all functions under MPW */
211
212 #include "pccts_string.h"
213 #include "pccts_stdlib.h"
214
215 /* MR6 2-Jun-97 Fixes false dependency caused by VC++ #include scanner */
216 /* MR6 Reported by Brad Schick (schick@interaccess.com) */
217 #define MPW_CursorCtl_Header <CursorCtl.h>
218 #include MPW_CursorCtl_Header
219 #ifdef __cplusplus
220 extern "C" {
221 #endif
222 extern void fsetfileinfo (const char *filename, unsigned long newcreator, unsigned long newtype);
223 #ifdef __cplusplus
224 }
225 #endif
226
227 /* File creators for various popular development environments */
228
229 #define MAC_FILE_CREATOR 'MPS ' /* MPW Text files */
230 #if 0
231 #define MAC_FILE_CREATOR 'KAHL' /* THINK C/Symantec C++ Text files */
232 #endif
233 #if 0
234 #define MAC_FILE_CREATOR 'CWIE' /* Metrowerks C/C++ Text files */
235 #endif
236
237 #endif
238
239 #ifdef MPW
240 #define DAWDLE SpinCursor(1)
241 #else
242 #define DAWDLE
243 #endif
244
245 #ifdef MPW
246 #define SPECIAL_INITS
247 #define SPECIAL_FOPEN
248 #endif
249
250 #ifdef MPW
251 #ifdef __cplusplus
252 inline
253 #else
254 static
255 #endif
256 void special_inits()
257 {
258 InitCursorCtl((acurHandle) 0);
259 }
260 #endif
261
262 #ifdef MPW
263 #ifdef __cplusplus
264 inline
265 #else
266 static
267 #endif
268 void special_fopen_actions(char * s)
269 {
270 fsetfileinfo (s, MAC_FILE_CREATOR, 'TEXT');
271 }
272 #endif
273
274 /* Define usable bits for set.c stuff */
275 #define BytesPerWord sizeof(unsigned)
276 #define WORDSIZE (sizeof(unsigned)*8)
277 #define LogWordSize (WORDSIZE==16?4:5)
278
279 #ifndef TRUE
280 #define TRUE 1
281 #endif
282 #ifndef FALSE
283 #define FALSE 0
284 #endif
285
286 #if defined(VAXC) || defined(__VMS)
287 #include <ssdef.h>
288 #define PCCTS_EXIT_SUCCESS 1
289 #define PCCTS_EXIT_FAILURE SS$_ABORT
290 #define zzDIE return SS$_ABORT;
291 #define zzDONE return 1;
292
293 #else /* !VAXC and !__VMS */
294
295 #define PCCTS_EXIT_SUCCESS 0
296 #define PCCTS_EXIT_FAILURE 1
297 #define zzDIE return 1;
298 #define zzDONE return 0;
299
300 #endif
301
302 #ifdef USER_ZZMODE_STACK
303 # ifndef ZZSTACK_MAX_MODE
304 # define ZZSTACK_MAX_MODE 32
305 # endif
306 # define ZZMAXSTK (ZZSTACK_MAX_MODE * 2)
307 #endif
308
309 #ifndef DllExportPCCTS
310 #define DllExportPCCTS
311 #endif
312
313 #ifdef PC
314 #ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME
315 #define PCCTS_CASE_INSENSITIVE_FILE_NAME
316 #endif
317 #endif
318
319 #ifdef PC32
320 #ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME
321 #define PCCTS_CASE_INSENSITIVE_FILE_NAME
322 #endif
323 #endif
324
325 #ifdef __VMS
326 #ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME
327 #define PCCTS_CASE_INSENSITIVE_FILE_NAME
328 #endif
329 #endif
330
331 #ifdef __USE_PROTOS
332 #ifndef PCCTS_USE_STDARG
333 #define PCCTS_USE_STDARG
334 #endif
335 #endif
336
337 #ifdef __STDC__
338 #ifndef PCCTS_USE_STDARG
339 #define PCCTS_USE_STDARG
340 #endif
341 #endif
342
343 #ifdef __cplusplus
344 #ifndef PCCTS_USE_STDARG
345 #define PCCTS_USE_STDARG
346 #endif
347 #endif
348
349 #ifdef _MSC_VER
350 /*Turn off the warnings for:
351 unreferenced inline/local function has been removed
352 */
353 #pragma warning(disable : 4514)
354 /* function not expanded */
355 #pragma warning(disable : 4710)
356 #endif
357
358 #endif
+0
-118
contrib/pccts/h/pcctslib50.dsp less more
0 # Microsoft Developer Studio Project File - Name="pcctslib" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 5.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Static Library" 0x0104
5
6 CFG=pcctslib - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "pcctslib50.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "pcctslib50.mak" CFG="pcctslib - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "pcctslib - Win32 Release" (based on "Win32 (x86) Static Library")
20 !MESSAGE "pcctslib - Win32 Debug" (based on "Win32 (x86) Static Library")
21 !MESSAGE
22
23 # Begin Project
24 # PROP Scc_ProjName ""
25 # PROP Scc_LocalPath ""
26 CPP=cl.exe
27
28 !IF "$(CFG)" == "pcctslib - Win32 Release"
29
30 # PROP BASE Use_MFC 0
31 # PROP BASE Use_Debug_Libraries 0
32 # PROP BASE Output_Dir "Release"
33 # PROP BASE Intermediate_Dir "Release"
34 # PROP BASE Target_Dir ""
35 # PROP Use_MFC 0
36 # PROP Use_Debug_Libraries 0
37 # PROP Output_Dir "Release"
38 # PROP Intermediate_Dir "Release"
39 # PROP Target_Dir ""
40 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
41 # ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c
42 # SUBTRACT CPP /YX
43 BSC32=bscmake.exe
44 # ADD BASE BSC32 /nologo
45 # ADD BSC32 /nologo
46 LIB32=link.exe -lib
47 # ADD BASE LIB32 /nologo
48 # ADD LIB32 /nologo /out:"pccts_release.lib"
49 # Begin Special Build Tool
50 SOURCE=$(InputPath)
51 PostBuild_Desc=Copy to ..\lib
52 PostBuild_Cmds=mkdir ..\lib copy pccts_release.lib ..\lib\pccts_release.lib
53 # End Special Build Tool
54
55 !ELSEIF "$(CFG)" == "pcctslib - Win32 Debug"
56
57 # PROP BASE Use_MFC 0
58 # PROP BASE Use_Debug_Libraries 1
59 # PROP BASE Output_Dir "Debug"
60 # PROP BASE Intermediate_Dir "Debug"
61 # PROP BASE Target_Dir ""
62 # PROP Use_MFC 0
63 # PROP Use_Debug_Libraries 1
64 # PROP Output_Dir "Debug"
65 # PROP Intermediate_Dir "Debug"
66 # PROP Target_Dir ""
67 # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
68 # ADD CPP /nologo /W3 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FD /c
69 # SUBTRACT CPP /YX
70 BSC32=bscmake.exe
71 # ADD BASE BSC32 /nologo
72 # ADD BSC32 /nologo
73 LIB32=link.exe -lib
74 # ADD BASE LIB32 /nologo
75 # ADD LIB32 /nologo /out:"pccts_debug.lib"
76 # Begin Special Build Tool
77 SOURCE=$(InputPath)
78 PostBuild_Desc=Copy to ..\lib
79 PostBuild_Cmds=mkdir ..\lib copy pccts_debug.lib ..\lib\pccts_debug.lib
80 # End Special Build Tool
81
82 !ENDIF
83
84 # Begin Target
85
86 # Name "pcctslib - Win32 Release"
87 # Name "pcctslib - Win32 Debug"
88 # Begin Source File
89
90 SOURCE=.\AParser.cpp
91 # End Source File
92 # Begin Source File
93
94 SOURCE=.\ASTBase.cpp
95 # End Source File
96 # Begin Source File
97
98 SOURCE=.\ATokenBuffer.cpp
99 # End Source File
100 # Begin Source File
101
102 SOURCE=.\BufFileInput.cpp
103 # End Source File
104 # Begin Source File
105
106 SOURCE=.\DLexerBase.cpp
107 # End Source File
108 # Begin Source File
109
110 SOURCE=.\PCCTSAST.cpp
111 # End Source File
112 # Begin Source File
113
114 SOURCE=.\SList.cpp
115 # End Source File
116 # End Target
117 # End Project
+0
-29
contrib/pccts/h/pcctslib50.dsw less more
0 Microsoft Developer Studio Workspace File, Format Version 5.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "pcctslib"=.\pcctslib50.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 }}}
10
11 Package=<4>
12 {{{
13 }}}
14
15 ###############################################################################
16
17 Global:
18
19 Package=<5>
20 {{{
21 }}}
22
23 Package=<3>
24 {{{
25 }}}
26
27 ###############################################################################
28
+0
-193
contrib/pccts/h/pcctslib60.dsp less more
0 # Microsoft Developer Studio Project File - Name="pcctslib" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 6.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Static Library" 0x0104
5
6 CFG=pcctslib - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "pcctslib60.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "pcctslib60.mak" CFG="pcctslib - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "pcctslib - Win32 Release" (based on "Win32 (x86) Static Library")
20 !MESSAGE "pcctslib - Win32 Debug" (based on "Win32 (x86) Static Library")
21 !MESSAGE
22
23 # Begin Project
24 # PROP AllowPerConfigDependencies 0
25 # PROP Scc_ProjName "pcctslib60"
26 # PROP Scc_LocalPath ".."
27 CPP=cl.exe
28 RSC=rc.exe
29
30 !IF "$(CFG)" == "pcctslib - Win32 Release"
31
32 # PROP BASE Use_MFC 0
33 # PROP BASE Use_Debug_Libraries 0
34 # PROP BASE Output_Dir "Release"
35 # PROP BASE Intermediate_Dir "Release"
36 # PROP BASE Target_Dir ""
37 # PROP Use_MFC 0
38 # PROP Use_Debug_Libraries 0
39 # PROP Output_Dir "Release"
40 # PROP Intermediate_Dir "Release"
41 # PROP Target_Dir ""
42 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
43 # ADD CPP /nologo /MD /W4 /WX /GX /O2 /I "$(PCCTS)\sorcerer\h" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c
44 # SUBTRACT CPP /YX
45 # ADD BASE RSC /l 0x409
46 # ADD RSC /l 0x409
47 BSC32=bscmake.exe
48 # ADD BASE BSC32 /nologo
49 # ADD BSC32 /nologo
50 LIB32=link.exe -lib
51 # ADD BASE LIB32 /nologo
52 # ADD LIB32 /nologo /out:"pccts_release.lib"
53 # Begin Special Build Tool
54 SOURCE="$(InputPath)"
55 PostBuild_Desc=Copy to ..\lib
56 PostBuild_Cmds=mkdir ..\lib copy pccts_release.lib ..\lib\pccts_release.lib
57 # End Special Build Tool
58
59 !ELSEIF "$(CFG)" == "pcctslib - Win32 Debug"
60
61 # PROP BASE Use_MFC 0
62 # PROP BASE Use_Debug_Libraries 1
63 # PROP BASE Output_Dir "Debug"
64 # PROP BASE Intermediate_Dir "Debug"
65 # PROP BASE Target_Dir ""
66 # PROP Use_MFC 0
67 # PROP Use_Debug_Libraries 1
68 # PROP Output_Dir "Debug"
69 # PROP Intermediate_Dir "Debug"
70 # PROP Target_Dir ""
71 # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
72 # ADD CPP /nologo /MDd /W4 /WX /GX /ZI /Od /I "$(PCCTS)\sorcerer\h" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FR /FD /c
73 # SUBTRACT CPP /YX
74 # ADD BASE RSC /l 0x409
75 # ADD RSC /l 0x409
76 BSC32=bscmake.exe
77 # ADD BASE BSC32 /nologo
78 # ADD BSC32 /nologo
79 LIB32=link.exe -lib
80 # ADD BASE LIB32 /nologo
81 # ADD LIB32 /nologo /out:"pccts_debug.lib"
82 # Begin Special Build Tool
83 SOURCE="$(InputPath)"
84 PostBuild_Desc=Copy to ..\lib
85 PostBuild_Cmds=mkdir ..\lib copy pccts_debug.lib ..\lib\pccts_debug.lib
86 # End Special Build Tool
87
88 !ENDIF
89
90 # Begin Target
91
92 # Name "pcctslib - Win32 Release"
93 # Name "pcctslib - Win32 Debug"
94 # Begin Group "Source Files"
95
96 # PROP Default_Filter ""
97 # Begin Source File
98
99 SOURCE=.\AParser.cpp
100 # End Source File
101 # Begin Source File
102
103 SOURCE=.\ASTBase.cpp
104 # End Source File
105 # Begin Source File
106
107 SOURCE=.\ATokenBuffer.cpp
108 # End Source File
109 # Begin Source File
110
111 SOURCE=.\BufFileInput.cpp
112 # End Source File
113 # Begin Source File
114
115 SOURCE=.\DLexerBase.cpp
116 # End Source File
117 # Begin Source File
118
119 SOURCE=.\PCCTSAST.cpp
120 # End Source File
121 # Begin Source File
122
123 SOURCE=.\SList.cpp
124 # End Source File
125 # Begin Source File
126
127 SOURCE=..\sorcerer\lib\STreeParser.cpp
128 # ADD CPP /I "$(PCCTS)\h"
129 # End Source File
130 # End Group
131 # Begin Group "Header Files"
132
133 # PROP Default_Filter ""
134 # Begin Source File
135
136 SOURCE=.\AParser.h
137 # End Source File
138 # Begin Source File
139
140 SOURCE=.\ASTBase.h
141 # End Source File
142 # Begin Source File
143
144 SOURCE=.\AToken.h
145 # End Source File
146 # Begin Source File
147
148 SOURCE=.\ATokenBuffer.h
149 # End Source File
150 # Begin Source File
151
152 SOURCE=.\ATokenStream.h
153 # End Source File
154 # Begin Source File
155
156 SOURCE=.\ATokPtr.h
157 # End Source File
158 # Begin Source File
159
160 SOURCE=.\BufFileInput.h
161 # End Source File
162 # Begin Source File
163
164 SOURCE=.\DLexerBase.h
165 # End Source File
166 # Begin Source File
167
168 SOURCE=.\PBlackBox.h
169 # End Source File
170 # Begin Source File
171
172 SOURCE=.\PCCTSAST.h
173 # End Source File
174 # Begin Source File
175
176 SOURCE=..\sorcerer\h\SASTBase.h
177 # End Source File
178 # Begin Source File
179
180 SOURCE=..\sorcerer\h\SCommonAST.h
181 # End Source File
182 # Begin Source File
183
184 SOURCE=.\SList.h
185 # End Source File
186 # Begin Source File
187
188 SOURCE=..\sorcerer\h\STreeParser.h
189 # End Source File
190 # End Group
191 # End Target
192 # End Project
+0
-33
contrib/pccts/h/pcctslib60.dsw less more
0 Microsoft Developer Studio Workspace File, Format Version 6.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "pcctslib"=.\pcctslib60.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 begin source code control
10 pcctslib60
11 ..
12 end source code control
13 }}}
14
15 Package=<4>
16 {{{
17 }}}
18
19 ###############################################################################
20
21 Global:
22
23 Package=<5>
24 {{{
25 }}}
26
27 Package=<3>
28 {{{
29 }}}
30
31 ###############################################################################
32
+0
-11
contrib/pccts/h/pcnames.bat less more
0 ren aparser.c aparser.cpp
1 ren astbase.c astbase.cpp
2 ren atokenbu.c atokbuf.cpp
3 ren atokenbu.h atokbuf.h
4 ren atokenst.h atokstr.h
5 ren dlexerba.c dlexbase.cpp
6 ren dlexerba.h dlexbase.h
7 ren dlexer.c dlexer.cpp
8 ren list.c list.cpp
9 ren pblackbo.h pblckbox.h
10 ren pcctsast.c pcctsast.cpp
+0
-116
contrib/pccts/h/slist.cpp less more
0 /*
1 * SList.C
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * PCCTS 1.33
24 * Terence Parr
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
27 * 1992-2000
28 */
29
30 #define ANTLR_SUPPORT_CODE
31
32 #include "SList.h"
33 #include "pccts_stdarg.h" // MR23
34
35 /* Iterate over a list of elements; returns ptr to a new element
36 * in list upon every call and NULL when no more are left.
37 * Very useful like this:
38 *
39 * cursor = mylist;
40 * while ( (p=mylist->iterate(&cursor)) ) {
41 * // place with element p
42 * }
43 *
44 * The cursor must be initialized to point to the list to iterate over.
45 */
46 void *SList::
47 iterate(SListNode **cursor)
48 {
49 void *e;
50
51 if ( cursor == NULL || *cursor==NULL ) return NULL;
52 if ( head == *cursor ) { *cursor = (*cursor)->next(); }
53 e = (*cursor)->elem();
54 (*cursor) = (*cursor)->next();
55 return e;
56 }
57
58 /* add an element to end of list. */
59 void SList::
60 add(void *e)
61 {
62 SListNode *p, *tail=NULL;
63 require(e!=NULL, "slist_add: attempting to add NULL list element");
64
65 p = new SListNode;
66 require(p!=NULL, "add: cannot alloc new list node");
67 p->setElem(e);
68 if ( head == NULL )
69 {
70 head = tail = p;
71 }
72 else /* find end of list */
73 {
74 tail->setNext(p);
75 tail = p;
76 }
77 }
78
79 void SList::
80 lfree()
81 {
82 SListNode *p,*q;
83
84 if ( head==NULL ) return; /* empty list */
85 for (p = head; p!=NULL; p=q)
86 {
87 q = p->next();
88 free(p);
89 }
90 }
91
92 PCCTS_AST *SList::
93 to_ast(SList list)
94 {
95 PCCTS_AST *t=NULL, *last=NULL;
96 SListNode *p;
97
98 for (p = head; p!=NULL; p=p->next())
99 {
100 PCCTS_AST *u = (PCCTS_AST *)p->elem();
101 if ( last==NULL ) last = t = u;
102 else { last->setRight(u); last = u; }
103 }
104 return t;
105 }
106
107 // MR23
108 int SList::printMessage(FILE* pFile, const char* pFormat, ...)
109 {
110 va_list marker;
111 va_start( marker, pFormat );
112 int iRet = vfprintf(pFile, pFormat, marker);
113 va_end( marker );
114 return iRet;
115 }
+0
-473
contrib/pccts/history.ps less more
0 %!PS-Adobe-3.0
1 %%Creator: groff version 1.06
2 %%DocumentNeededResources: font Times-Roman
3 %%+ font Times-Italic
4 %%+ font Courier
5 %%DocumentSuppliedResources: procset grops 1.06 0
6 %%Pages: 3
7 %%PageOrder: Ascend
8 %%Orientation: Portrait
9 %%EndComments
10 %%BeginProlog
11 %%BeginResource: procset grops 1.06 0
12
13 /setpacking where {
14 pop
15 currentpacking
16 true setpacking
17 } if
18
19 /grops 120 dict dup begin
20
21 % The ASCII code of the space character.
22 /SC 32 def
23
24 /A /show load def
25 /B { 0 SC 3 -1 roll widthshow } bind def
26 /C { 0 exch ashow } bind def
27 /D { 0 exch 0 SC 5 2 roll awidthshow } bind def
28 /E { 0 rmoveto show } bind def
29 /F { 0 rmoveto 0 SC 3 -1 roll widthshow } bind def
30 /G { 0 rmoveto 0 exch ashow } bind def
31 /H { 0 rmoveto 0 exch 0 SC 5 2 roll awidthshow } bind def
32 /I { 0 exch rmoveto show } bind def
33 /J { 0 exch rmoveto 0 SC 3 -1 roll widthshow } bind def
34 /K { 0 exch rmoveto 0 exch ashow } bind def
35 /L { 0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow } bind def
36 /M { rmoveto show } bind def
37 /N { rmoveto 0 SC 3 -1 roll widthshow } bind def
38 /O { rmoveto 0 exch ashow } bind def
39 /P { rmoveto 0 exch 0 SC 5 2 roll awidthshow } bind def
40 /Q { moveto show } bind def
41 /R { moveto 0 SC 3 -1 roll widthshow } bind def
42 /S { moveto 0 exch ashow } bind def
43 /T { moveto 0 exch 0 SC 5 2 roll awidthshow } bind def
44
45 % name size font SF -
46
47 /SF {
48 findfont exch
49 [ exch dup 0 exch 0 exch neg 0 0 ] makefont
50 dup setfont
51 [ exch /setfont cvx ] cvx bind def
52 } bind def
53
54 % name a c d font MF -
55
56 /MF {
57 findfont
58 [ 5 2 roll
59 0 3 1 roll % b
60 neg 0 0 ] makefont
61 dup setfont
62 [ exch /setfont cvx ] cvx bind def
63 } bind def
64
65 /level0 0 def
66 /RES 0 def
67 /PL 0 def
68 /LS 0 def
69
70 % Guess the page length.
71 % This assumes that the imageable area is vertically centered on the page.
72 % PLG - length
73
74 /PLG {
75 gsave newpath clippath pathbbox grestore
76 exch pop add exch pop
77 } bind def
78
79 % BP -
80
81 /BP {
82 /level0 save def
83 1 setlinecap
84 1 setlinejoin
85 72 RES div dup scale
86 LS {
87 90 rotate
88 } {
89 0 PL translate
90 } ifelse
91 1 -1 scale
92 } bind def
93
94 /EP {
95 level0 restore
96 showpage
97 } bind def
98
99
100 % centerx centery radius startangle endangle DA -
101
102 /DA {
103 newpath arcn stroke
104 } bind def
105
106 % x y SN - x' y'
107 % round a position to nearest (pixel + (.25,.25))
108
109 /SN {
110 transform
111 .25 sub exch .25 sub exch
112 round .25 add exch round .25 add exch
113 itransform
114 } bind def
115
116 % endx endy startx starty DL -
117 % we round the endpoints of the line, so that parallel horizontal
118 % and vertical lines will appear even
119
120 /DL {
121 SN
122 moveto
123 SN
124 lineto stroke
125 } bind def
126
127 % centerx centery radius DC -
128
129 /DC {
130 newpath 0 360 arc closepath
131 } bind def
132
133
134 /TM matrix def
135
136 % width height centerx centery DE -
137
138 /DE {
139 TM currentmatrix pop
140 translate scale newpath 0 0 .5 0 360 arc closepath
141 TM setmatrix
142 } bind def
143
144 % these are for splines
145
146 /RC /rcurveto load def
147 /RL /rlineto load def
148 /ST /stroke load def
149 /MT /moveto load def
150 /CL /closepath load def
151
152 % fill the last path
153
154 % amount FL -
155
156 /FL {
157 currentgray exch setgray fill setgray
158 } bind def
159
160 % fill with the ``current color''
161
162 /BL /fill load def
163
164 /LW /setlinewidth load def
165 % new_font_name encoding_vector old_font_name RE -
166
167 /RE {
168 findfont
169 dup maxlength dict begin
170 {
171 1 index /FID ne { def } { pop pop } ifelse
172 } forall
173 /Encoding exch def
174 dup /FontName exch def
175 currentdict end definefont pop
176 } bind def
177
178 /DEFS 0 def
179
180 % hpos vpos EBEGIN -
181
182 /EBEGIN {
183 moveto
184 DEFS begin
185 } bind def
186
187 /EEND /end load def
188
189 /CNT 0 def
190 /level1 0 def
191
192 % llx lly newwid wid newht ht newllx newlly PBEGIN -
193
194 /PBEGIN {
195 /level1 save def
196 translate
197 div 3 1 roll div exch scale
198 neg exch neg exch translate
199 % set the graphics state to default values
200 0 setgray
201 0 setlinecap
202 1 setlinewidth
203 0 setlinejoin
204 10 setmiterlimit
205 [] 0 setdash
206 /setstrokeadjust where {
207 pop
208 false setstrokeadjust
209 } if
210 /setoverprint where {
211 pop
212 false setoverprint
213 } if
214 newpath
215 /CNT countdictstack def
216 userdict begin
217 /showpage {} def
218 } bind def
219
220 /PEND {
221 clear
222 countdictstack CNT sub { end } repeat
223 level1 restore
224 } bind def
225
226 end def
227
228 /setpacking where {
229 pop
230 setpacking
231 } if
232 %%EndResource
233 %%IncludeResource: font Times-Roman
234 %%IncludeResource: font Times-Italic
235 %%IncludeResource: font Courier
236 grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL
237 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron/scaron/zcaron
238 /Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef/.notdef/.notdef
239 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
240 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/space
241 /exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright/parenleft
242 /parenright/asterisk/plus/comma/hyphen/period/slash/zero/one/two/three/four
243 /five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question/at/A/B/C
244 /D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash
245 /bracketright/circumflex/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q
246 /r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase
247 /guillemotleft/guillemotright/bullet/florin/fraction/perthousand/dagger
248 /daggerdbl/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
249 /dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
250 /quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar
251 /section/dieresis/copyright/ordfeminine/guilsinglleft/logicalnot/minus
252 /registered/macron/degree/plusminus/twosuperior/threesuperior/acute/mu
253 /paragraph/periodcentered/cedilla/onesuperior/ordmasculine/guilsinglright
254 /onequarter/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde
255 /Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
256 /Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
257 /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
258 /agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
259 /ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
260 /oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
261 /udieresis/yacute/thorn/ydieresis]def/Courier@0 ENC0/Courier RE/Times-Italic@0
262 ENC0/Times-Italic RE/Times-Roman@0 ENC0/Times-Roman RE
263 %%EndProlog
264 %%Page: 1 1
265 %%BeginPageSetup
266 BP
267 %%EndPageSetup
268 /F0 13/Times-Roman@0 SF(The History of PCCTS)228.232 84 Q/F1 11/Times-Roman@0
269 SF(The Purdue Compiler)190.468 108 Q(-Construction T)-.22 E(ool Set)-.88 E/F2
270 10/Times-Italic@0 SF -.92(Te)262.245 144 S -.37(re).92 G(nce P).37 E(arr)-.8 E
271 /F3 10/Times-Roman@0 SF -.15(Pa)234.755 156 S(rr Research Corporation).15 E
272 (Minneapolis, Minnesota)239.39 168 Q(and)280.78 180 Q(Uni)239.315 192 Q -.15
273 (ve)-.25 G(rsity of Minnesota).15 E
274 (Army High Performance Computing Research Center)180.38 204 Q F2
275 ([Updated 8-7-94])252.31 228 Q F1 .084(The PCCTS project be)97 259.6 R -.055
276 (ga)-.165 G 2.834(na).055 G 2.833(sap)220.547 259.6 S(arser)240.876 259.6 Q
277 .083(-generator project for a graduate course at Purdue Uni-)-.22 F -.165(ve)72
278 275.6 S 1.085(rsity in the F).165 F 1.086
279 (all of 1988 taught by Hank Dietz\212 translator)-.165 F 1.086
280 (-writing systems.)-.22 F 1.086(Under the guid-)6.586 F .627
281 (ance of Professor Dietz, the parser generator)72 291.6 R 3.377(,A)-.44 G .626
282 (NTLR \(originally called YUCC\), continued after)285.18 291.6 R .253
283 (the termination of the course and e)72 307.6 R -.165(ve)-.275 G .254
284 (ntually became the subject of T).165 F .254(erence P)-.77 F(arr')-.165 E 3.004
285 (sM)-.605 G(aster')445.083 307.6 Q 3.004(st)-.605 G(hesis.)479.25 307.6 Q
286 (Originally)72 323.6 Q 4.092(,l)-.715 G -.165(ex)126.406 323.6 S 1.342
287 (ical analysis w).165 F 1.342(as performed via ALX which w)-.11 F 1.342
288 (as soon replaced by W)-.11 F 1.341(ill Cohen')-.44 F(s)-.605 E .594
289 (DLG in the F)72 339.6 R .594(all of 1989 \(DF)-.165 F .595(A-based le)-.814 F
290 .595(xical-analyzer generator)-.165 F 3.345(,a)-.44 G .595(lso an of)367.188
291 339.6 R .595(fshoot of the graduate)-.275 F(translation course\).)72 355.6 Q
292 .877(The alpha v)97 375.2 R .877(ersion of ANTLR w)-.165 F .877(as totally re)
293 -.11 F .876(written resulting in 1.00B.)-.275 F -1.221(Ve)6.376 G .876
294 (rsion 1.00B w)1.221 F(as)-.11 E 1.577(released via an internet ne)72 391.2 R
295 1.577(wsgroup \(comp.compilers\) posting in February of 1990 and quickly)-.275
296 F -.055(ga)72 407.2 S .356(thered a lar).055 F .356(ge follo)-.198 F 3.106
297 (wing. 1.00B)-.275 F .356(generated only LL\(1\) parsers, b)3.106 F .356
298 (ut allo)-.22 F .356(wed the mer)-.275 F .356(ged descrip-)-.198 F 1.859
299 (tion of le)72 423.2 R 1.859(xical and syntactic analysis.)-.165 F 1.86
300 (It had rudimentary attrib)7.359 F 1.86(ute handling similar to that of)-.22 F
301 -.55 -1.32(YA C)72 439.2 T 3.549(Ca)1.32 G .799
302 (nd did not incorporate rule parameters or return v)109.231 439.2 R .798
303 (alues; do)-.275 F(wnw)-.275 E .798(ard inheritance w)-.11 F .798(as v)-.11 F
304 (ery)-.165 E -.165(aw)72 455.2 S(kw).165 E 6.433(ard. 1.00B-generated)-.11 F
305 3.684(parsers terminated upon the \214rst syntax error)6.433 F 9.184(.L)-.605 G
306 -.165(ex)440.916 455.2 S 3.684(ical classes).165 F(\(modes\) were not allo)72
307 471.2 Q(wed and DLG did not ha)-.275 E .33 -.165(ve a)-.22 H 2.75(ni).165 G
308 (nteracti)305.959 471.2 Q .33 -.165(ve m)-.275 H(ode.).165 E .831
309 (Upon starting his Ph.D. at Purdue in the F)97 490.8 R .83(all of 1990, T)-.165
310 F .83(erence P)-.77 F .83(arr be)-.165 F -.055(ga)-.165 G 3.58(nt).055 G .83
311 (he second total)436.351 490.8 R(re)72 506.8 Q 1.646(write of ANTLR.)-.275 F
312 1.646(The method by which grammars may be practically analyzed to generate)
313 7.146 F/F4 11/Times-Italic@0 SF(LL)72.638 522.8 Q F1(\().583 E F4(k).396 E F1
314 3.849(\)l).737 G 1.099(ookahead information w)105.703 522.8 R 1.099(as disco)
315 -.11 F -.165(ve)-.165 G 1.099(red in August of 1990 just before his return.)
316 .165 F -1.221(Ve)6.598 G(rsion)1.221 E .626
317 (1.00 incorporated this algorithm and included the AST mechanism, le)72 538.8 R
318 .626(xical classes, error classes,)-.165 F .354(and automatic error reco)72
319 554.8 R -.165(ve)-.165 G .353(ry; code quality and portability were higher).165
320 F 5.853(.I)-.605 G 3.103(nF)395.965 554.8 S .353(ebruary of 1992 1.00)410.684
321 554.8 R -.11(wa)72 570.8 S 2.76(sr).11 G .01
322 (eleased via an article in SIGPLAN Notices.)95.418 570.8 R .01
323 (Peter Dahl, Ph.D. candidate, and Professor Matt)5.51 F(O'K)72 586.8 Q 2.074
324 (eefe \(both at the Uni)-.275 F -.165(ve)-.275 G 2.073
325 (rsity of Minnesota\) tested this v).165 F 2.073(ersion e)-.165 F(xtensi)-.165
326 E -.165(ve)-.275 G(ly).165 E 7.573(.D)-.715 G 2.073(ana Hogg)448.522 586.8 R
327 (att)-.055 E .078(\(Micro Data Base Systems, Inc.\) came up with the idea of e\
328 rror grouping \(strings attached to non-)72 602.8 R
329 (terminals\) and tested 1.00 hea)72 618.8 Q(vily)-.22 E(.)-.715 E -1.221(Ve)97
330 638.4 S .878(rsion 1.06 w)1.221 F .877
331 (as released in December 1992 and represented a lar)-.11 F .877
332 (ge feature enhancement)-.198 F -.165(ove)72 654.4 S 3.648(r1).165 G 3.648
333 (.00. F)100.365 654.4 R .898(or e)-.165 F .899
334 (xample, rudimentary semantic predicates were introduced, error messages were)
335 -.165 F 2.281(signi\214cantly impro)72 670.4 R -.165(ve)-.165 G 5.031(df).165 G
336 (or)181.953 670.4 Q F4(k)5.427 E F1 2.281
337 (>1 lookahead and ANTLR parsers could indicate that lookahead).737 F 1.381
338 (fetches were to occur only when necessary for the parse \(normally)72 686.4 R
339 4.131(,t)-.715 G 1.381(he lookahead `)387.051 686.4 R(`pipe')-.814 E 4.132('w)
340 -.814 G(as)494.837 686.4 Q 1.182(constantly full\).)72 702.4 R 1.182
341 (Russell Quong joined the project in the Spring of 1992 to aid in the semantic)
342 6.682 F .681(predicate design.)72 718.4 R(Be)6.181 E .681(ginning and adv)-.165
343 F .682(anced tutorials were created and released as well.)-.275 F 3.432(Am)
344 6.182 G(ak)485.179 718.4 Q(e-)-.11 E .993(\214le generator w)72 734.4 R .993
345 (as included that sets up dependencies and such correctly for ANTLR and DLG.)
346 -.11 F EP
347 %%Page: 2 2
348 %%BeginPageSetup
349 BP
350 %%EndPageSetup
351 /F0 11/Times-Roman@0 SF 2.75(-2-)278.837 52 S -1.221(Ve)72 88 S 1.414(ry fe)
352 1.221 F 4.164(w1)-.275 G 1.414(.00 incompatibilities were introduced \(1.00 w)
353 122.81 88 R 1.415(as quite dif)-.11 F 1.415(ferent from 1.00B in some)-.275 F
354 (areas\).)72 104 Q 1.089(1.10 w)97 123.6 R 1.088
355 (as released on August 31, 1993 and incorporated b)-.11 F 1.088(ug \214x)-.22 F
356 1.088(es, a fe)-.165 F 3.838(wf)-.275 G 1.088(eature enhance-)433.59 123.6 R
357 3.112(ments and a major ne)72 139.6 R 5.863(wc)-.275 G(apability \212)196.957
358 139.6 Q 3.113(an arbitrary lookahead operator \(syntactic predicate\),)5.863 F
359 /F1 11/Courier@0 SF(\(alpha\)?beta)72 155.6 Q F0 6.754(.T)C 1.254
360 (his feature w)167.425 155.6 R 1.254
361 (as co-designed with Professor Russell Quong also at Purdue.)-.11 F 3.297 -.88
362 (To s)72 171.6 T 1.537
363 (upport in\214nite lookahead, a preprocessor \215ag, ZZINF_LOOK, w).88 F 1.537
364 (as created that forced the)-.11 F .21(ANTLR\(\) macro to tok)72 187.6 R .21
365 (enize all input prior to parsing.)-.11 F .209(Hence, at an)5.709 F 2.959(ym)
366 -.165 G .209(oment, an action or predi-)389.215 187.6 R .936
367 (cate can see the entire input sentence.)72 203.6 R .936
368 (The predicate mechanism of 1.06 w)6.436 F .937(as e)-.11 F .937
369 (xtended to allo)-.165 F(w)-.275 E .55
370 (multiple predicates to be hoisted; the syntactic conte)72 219.6 R .55
371 (xt of a predicate w)-.165 F .55(as also mo)-.11 F -.165(ve)-.165 G 3.299(da)
372 .165 G .549(long with)461.585 219.6 R(the predicate.)72 235.6 Q .754
373 (In February of 1994, SORCERER \(a simple tree-parser generator\) w)97 255.2 R
374 .755(as released.)-.11 F .755(This tool)6.255 F(allo)72 271.2 Q .6(ws the user\
375 to parse child-sibling trees by specifying a grammar rather than b)-.275 F
376 .599(uilding a recur)-.22 F(-)-.22 E(si)72 287.2 Q -.165(ve)-.275 G 1.39
377 (-descent tree w).165 F(alk)-.11 E 1.391(er by hand.)-.11 F -.88(Wo)6.891 G
378 1.391(rk to).88 F -.11(wa)-.275 G 1.391
379 (rds a library of tree transformations is underw).11 F(ay)-.11 E(.)-.715 E .581
380 (Aaron Sa)72 303.2 R(wde)-.165 E 3.331(ya)-.165 G 3.331(tT)145.531 303.2 S .581
381 (he Uni)158.641 303.2 R -.165(ve)-.275 G .58
382 (rsity of Minnesota became a second author of SORCERER after the).165 F
383 (initial release.)72 319.2 Q .627(On April 1, 1994, PCCTS 1.20 w)97 338.8 R
384 .627(as released.)-.11 F .627(This w)6.127 F .627(as the \214rst v)-.11 F .627
385 (ersion to acti)-.165 F -.165(ve)-.275 G .627(ly support).165 F 1.664
386 (C++ output.)72 354.8 R 1.664(It also included important \214x)7.164 F 1.663
387 (es re)-.165 F -.055(ga)-.165 G 1.663
388 (rding semantic predicates and \(..\)+ subrules.).055 F(This v)72 370.8 Q
389 (ersion also introduced tok)-.165 E(en classes, the `)-.11 E(`)-.814 E/F2 11
390 /Times-Italic@0 SF(not)A F0 1.628 -.814('' o)D(perator).814 E 2.75(,a)-.44 G
391 (nd tok)355.294 370.8 Q(en ranges.)-.11 E .764
392 (On June 19, 1994, SORCERER 1.00B9 w)97 390.4 R .765(as released.)-.11 F .765
393 (Gary Funck of Intrepid T)6.265 F(echnology)-.77 E .807
394 (joined the SORCERER team and pro)72 406.4 R .807(vided v)-.165 F .807(ery v)
395 -.165 F .807(aluable suggestions re)-.275 F -.055(ga)-.165 G .806(rding the `)
396 .055 F(`transform')-.814 E(')-.814 E(mode of SORCERER.)72 422.4 Q 1.137
397 (On August 8, 1994, PCCTS 1.21 w)97 442 R 1.137(as released.)-.11 F 1.138
398 (It mainly cleaned up the C++ output and)6.637 F(included a number of b)72 458
399 Q(ug \214x)-.22 E(es.)-.165 E .316(From the 1.21 release forw)97 477.6 R .316
400 (ard, the maintenance and support of all PCCTS tools will be pri-)-.11 F 1.557
401 (marily pro)72 493.6 R 1.557(vided by P)-.165 F 1.557
402 (arr Research Corporation, Minneapolis MN---an or)-.165 F -.055(ga)-.198 G
403 1.558(nization founded on).055 F 1.616(the principles of e)72 509.6 R 1.616
404 (xcellence in research and inte)-.165 F 1.616(grity in b)-.165 F 1.616
405 (usiness; we are de)-.22 F -.22(vo)-.275 G 1.616(ted to pro).22 F(viding)-.165
406 E 1.202(really cool softw)72 525.6 R 1.202(are tools.)-.11 F 1.202
407 (Please see \214le PCCTS.FUTURE for more information.)6.702 F 1.203(All PCCTS)
408 6.703 F(tools currently in the public domain will continue to be in the public\
409 domain.)72 541.6 Q 1.198(Looking to)97 561.2 R -.11(wa)-.275 G 1.198
410 (rds the future, a graphical user).11 F(-interf)-.22 E 1.197
411 (ace is in the design phase.)-.11 F 1.197(This w)6.697 F(ould)-.11 E(allo)72
412 577.2 Q 2.753(wu)-.275 G .003(sers to vie)104.42 577.2 R 2.753(wt)-.275 G .004
413 (he syntax diagram representation of their grammars and w)162.509 577.2 R .004
414 (ould highlight non-)-.11 F 1.181(deterministic productions.)72 593.2 R -.165
415 (Pa)6.681 G 1.18(rsing can be traced graphically as well.).165 F 1.18
416 (This system will be b)6.68 F(uilt)-.22 E .167(using a multiplatform windo)72
417 609.2 R 2.917(wl)-.275 G(ibrary)211.73 609.2 Q 5.667(.W)-.715 G 2.917(ea)
418 255.204 609.2 S .168(lso anticipate the introduction of a sophisticated error)
419 267.889 609.2 R(handling mechanism called `)72 625.2 Q(`parser e)-.814 E
420 (xception handling')-.165 E 2.75('i)-.814 G 2.75(nan)327.431 625.2 S
421 (ear future release.)348.815 625.2 Q(Currently)97 644.8 Q 3.019(,P)-.715 G .269
422 (CCTS is used at o)150.333 644.8 R -.165(ve)-.165 G 3.019(r1).165 G .269
423 (000 kno)253.098 644.8 R .268(wn academic, go)-.275 F -.165(ve)-.165 G .268
424 (rnment, and commercial sites).165 F .859(in 37 countries.)72 660.8 R .859
425 (Of course, the true number of users is unkno)6.359 F .859(wn due to the lar)
426 -.275 F .859(ge number of ftp)-.198 F(sites.)72 676.8 Q EP
427 %%Page: 3 3
428 %%BeginPageSetup
429 BP
430 %%EndPageSetup
431 /F0 11/Times-Roman@0 SF 2.75(-3-)278.837 52 S(Credits)272.11 88 Q .44 LW
432 472.162 103.75 103.838 103.75 DL(Idea/T)134.236 117 Q 52.987(ool Coder)-.88 F
433 (Co-designer\(s\))345.436 117 Q 281.334 103.75 281.334 124.75 DL 209.273 103.75
434 209.273 124.75 DL 209.273 124.75 103.838 124.75 DL 103.838 126.75 209.273
435 126.75 DL 281.334 124.75 209.273 124.75 DL 209.273 126.75 281.334 126.75 DL
436 472.162 124.75 281.334 124.75 DL 281.334 126.75 472.162 126.75 DL(ANTLR 1.00A)
437 109.338 140 Q -.77(Te)217.523 140 S(rence P).77 E 13.75(arr Hank)-.165 F(Dietz)
438 2.75 E 82.83(ALX T)109.338 156 R(erence P)-.77 E 13.75(arr Hank)-.165 F(Dietz)
439 2.75 E(ANTLR 1.00B)109.338 172 Q -.77(Te)217.523 172 S(rence P).77 E 13.75
440 (arr Hank)-.165 F(Dietz, W)2.75 E(ill Cohen)-.44 E(DLG 1.00B)109.338 188 Q -.44
441 (Wi)217.523 188 S(ll Cohen).44 E -.77(Te)289.584 188 S(rence P).77 E(arr)-.165
442 E 2.75(,H)-.44 G(ank Dietz)358.147 188 Q(NF)109.338 204 Q 2.75(AR)-.814 G
443 30.778(elabelling W)140.611 204 R(ill Cohen)-.44 E/F1 11/Times-Italic@0 SF(LL)
444 109.976 220 Q F0(\().583 E F1(k).396 E F0 2.75(\)a).737 G 40.447(nalysis T)
445 143.768 220 R(erence P)-.77 E 13.75(arr Hank)-.165 F(Dietz)2.75 E(ANTLR 1.00)
446 109.338 236 Q -.77(Te)217.523 236 S(rence P).77 E 13.75(arr Hank)-.165 F
447 (Dietz, W)2.75 E(ill Cohen)-.44 E(DLG 1.00)109.338 252 Q -.44(Wi)217.523 252 S
448 (ll Cohen).44 E -.77(Te)289.584 252 S(rence P).77 E(arr)-.165 E 2.75(,H)-.44 G
449 (ank Dietz)358.147 252 Q(ANTLR 1.06)109.338 268 Q -.77(Te)217.523 268 S
450 (rence P).77 E 13.75(arr W)-.165 F(ill Cohen, Russell Quong, Hank Dietz)-.44 E
451 (DLG 1.06)109.338 284 Q -.44(Wi)217.523 284 S(ll Cohen).44 E -.77(Te)289.584
452 284 S(rence P).77 E(arr)-.165 E 2.75(,H)-.44 G(ank Dietz)358.147 284 Q
453 (ANTLR 1.10)109.338 300 Q -.77(Te)217.523 300 S(rence P).77 E 13.75(arr W)-.165
454 F(ill Cohen, Russell Quong)-.44 E(ANTLR 1.20)109.338 316 Q -.77(Te)217.523 316
455 S(rence P).77 E 13.75(arr W)-.165 F(ill Cohen, Russell Quong)-.44 E(ANTLR 1.21)
456 109.338 332 Q -.77(Te)217.523 332 S(rence P).77 E 13.75(arr Russell)-.165 F
457 (Quong)2.75 E(DLG 1.10)109.338 348 Q -.44(Wi)217.523 348 S(ll Cohen).44 E -.77
458 (Te)289.584 348 S(rence P).77 E(arr)-.165 E(DLG 1.20)109.338 364 Q -.44(Wi)
459 217.523 364 S(ll Cohen).44 E -.77(Te)289.584 364 S(rence P).77 E(arr)-.165 E
460 (DLG 1.21)109.338 380 Q -.77(Te)217.523 380 S(rence P).77 E(arr)-.165 E
461 (Semantic predicates)109.338 396 Q -.77(Te)217.523 396 S(rence P).77 E 13.75
462 (arr Russell)-.165 F(Quonq)2.75 E(Syntactic predicates)109.338 412 Q -.77(Te)
463 217.523 412 S(rence P).77 E 13.75(arr Russell)-.165 F(Quonq)2.75 E
464 (SORCERER 1.00A)109.338 428 Q -.77(Te)217.523 428 S(rence P).77 E(arr)-.165 E
465 (SORCERER 1.00B)109.338 444 Q -.77(Te)217.523 444 S(rence P).77 E 13.75
466 (arr Aaron)-.165 F(Sa)2.75 E(wde)-.165 E(y)-.165 E(SORCERER 1.00B9)109.338 460
467 Q -.77(Te)217.523 460 S(rence P).77 E 13.75(arr Aaron)-.165 F(Sa)2.75 E(wde)
468 -.165 E 1.43 -.715(y, G)-.165 H(ary Funck).715 E 472.162 467.75 103.838 467.75
469 DL 472.162 103.75 472.162 467.75 DL 103.838 103.75 103.838 467.75 DL EP
470 %%Trailer
471 end
472 %%EOF
+0
-186
contrib/pccts/history.txt less more
0
1
2
3 The History of PCCTS
4
5 The Purdue Compiler-Construction Tool Set
6
7
8 Terence Parr
9 Parr Research Corporation
10 Minneapolis, Minnesota
11 and
12 University of Minnesota
13 Army High Performance Computing Research Center
14
15 [Updated 8-7-94]
16
17
18 The PCCTS project began as a parser-generator project for a gra-
19 duate course at Purdue University in the Fall of 1988 taught by Hank
20 Dietz- translator-writing systems. Under the guidance of Professor
21 Dietz, the parser generator, ANTLR (originally called YUCC), continued
22 after the termination of the course and eventually became the subject
23 of Terence Parr's Master's thesis. Originally, lexical analysis was
24 performed via ALX which was soon replaced by Will Cohen's DLG in the
25 Fall of 1989 (DFA-based lexical-analyzer generator, also an offshoot
26 of the graduate translation course).
27
28 The alpha version of ANTLR was totally rewritten resulting in
29 1.00B. Version 1.00B was released via an internet newsgroup
30 (comp.compilers) posting in February of 1990 and quickly gathered a
31 large following. 1.00B generated only LL(1) parsers, but allowed the
32 merged description of lexical and syntactic analysis. It had rudimen-
33 tary attribute handling similar to that of YACC and did not incor-
34 porate rule parameters or return values; downward inheritance was very
35 awkward. 1.00B-generated parsers terminated upon the first syntax
36 error. Lexical classes (modes) were not allowed and DLG did not have
37 an interactive mode.
38
39 Upon starting his Ph.D. at Purdue in the Fall of 1990, Terence
40 Parr began the second total rewrite of ANTLR. The method by which
41 grammars may be practically analyzed to generate LL(k) lookahead
42 information was discovered in August of 1990 just before his return.
43 Version 1.00 incorporated this algorithm and included the AST mechan-
44 ism, lexical classes, error classes, and automatic error recovery;
45 code quality and portability were higher. In February of 1992 1.00
46 was released via an article in SIGPLAN Notices. Peter Dahl, Ph.D.
47 candidate, and Professor Matt O'Keefe (both at the University of Min-
48 nesota) tested this version extensively. Dana Hoggatt (Micro Data
49 Base Systems, Inc.) came up with the idea of error grouping (strings
50 attached to non-terminals) and tested 1.00 heavily.
51
52 Version 1.06 was released in December 1992 and represented a
53 large feature enhancement over 1.00. For example, rudimentary seman-
54 tic predicates were introduced, error messages were significantly
55 improved for k>1 lookahead and ANTLR parsers could indicate that loo-
56 kahead fetches were to occur only when necessary for the parse
57
58
59
60 Page 1
61
62 PCCTS
63
64
65 (normally, the lookahead "pipe" was constantly full). Russell Quong
66 joined the project in the Spring of 1992 to aid in the semantic predi-
67 cate design. Beginning and advanced tutorials were created and
68 released as well. A makefile generator was included that sets up
69 dependencies and such correctly for ANTLR and DLG. Very few 1.00
70 incompatibilities were introduced (1.00 was quite different from 1.00B
71 in some areas).
72
73 1.10 was released on August 31, 1993 and incorporated bug fixes,
74 a few feature enhancements and a major new capability - an arbitrary
75 lookahead operator (syntactic predicate), (alpha)?beta. This feature
76 was co-designed with Professor Russell Quong also at Purdue. To sup-
77 port infinite lookahead, a preprocessor flag, ZZINF_LOOK, was created
78 that forced the ANTLR() macro to tokenize all input prior to parsing.
79 Hence, at any moment, an action or predicate can see the entire input
80 sentence. The predicate mechanism of 1.06 was extended to allow mul-
81 tiple predicates to be hoisted; the syntactic context of a predicate
82 was also moved along with the predicate.
83
84 In February of 1994, SORCERER (a simple tree-parser generator)
85 was released. This tool allows the user to parse child-sibling trees
86 by specifying a grammar rather than building a recursive-descent tree
87 walker by hand. Work towards a library of tree transformations is
88 underway. Aaron Sawdey at The University of Minnesota became a second
89 author of SORCERER after the initial release.
90
91 On April 1, 1994, PCCTS 1.20 was released. This was the first
92 version to actively support C++ output. It also included important
93 fixes regarding semantic predicates and (..)+ subrules. This version
94 also introduced token classes, the "not" operator, and token ranges.
95
96 On June 19, 1994, SORCERER 1.00B9 was released. Gary Funck of
97 Intrepid Technology joined the SORCERER team and provided very valu-
98 able suggestions regarding the "transform" mode of SORCERER.
99
100 On August 8, 1994, PCCTS 1.21 was released. It mainly cleaned up
101 the C++ output and included a number of bug fixes.
102
103 From the 1.21 release forward, the maintenance and support of all
104 PCCTS tools will be primarily provided by Parr Research Corporation,
105 Minneapolis MN---an organization founded on the principles of excel-
106 lence in research and integrity in business; we are devoted to provid-
107 ing really cool software tools. Please see file PCCTS.FUTURE for more
108 information. All PCCTS tools currently in the public domain will con-
109 tinue to be in the public domain.
110
111 Looking towards the future, a graphical user-interface is in the
112 design phase. This would allow users to view the syntax diagram
113 representation of their grammars and would highlight nondeterministic
114 productions. Parsing can be traced graphically as well. This system
115 will be built using a multiplatform window library. We also antici-
116 pate the introduction of a sophisticated error handling mechanism
117 called "parser exception handling" in a near future release.
118
119
120
121
122 Page 2
123
124 PCCTS
125
126
127 Currently, PCCTS is used at over 1000 known academic, government,
128 and commercial sites in 37 countries. Of course, the true number of
129 users is unknown due to the large number of ftp sites.
130 Credits
131
132 _____________________________________________________________________________
133 _____________________________________________________________________________
134 |ANTLR 1.00A Terence Parr Hank Dietz |
135 |ALX Terence Parr Hank Dietz |
136 |ANTLR 1.00B Terence Parr Hank Dietz, Will Cohen |
137 |DLG 1.00B Will Cohen Terence Parr, Hank Dietz |
138 |NFA Relabelling Will Cohen |
139 |LL(k) analysis Terence Parr Hank Dietz |
140 |ANTLR 1.00 Terence Parr Hank Dietz, Will Cohen |
141 |DLG 1.00 Will Cohen Terence Parr, Hank Dietz |
142 |ANTLR 1.06 Terence Parr Will Cohen, Russell Quong, Hank Dietz|
143 |DLG 1.06 Will Cohen Terence Parr, Hank Dietz |
144 |ANTLR 1.10 Terence Parr Will Cohen, Russell Quong |
145 |ANTLR 1.20 Terence Parr Will Cohen, Russell Quong |
146 |ANTLR 1.21 Terence Parr Russell Quong |
147 |DLG 1.10 Will Cohen Terence Parr |
148 |DLG 1.20 Will Cohen Terence Parr |
149 |DLG 1.21 Terence Parr |
150 |Semantic predicates Terence Parr Russell Quonq |
151 |Syntactic predicates Terence Parr Russell Quonq |
152 |SORCERER 1.00A Terence Parr |
153 |SORCERER 1.00B Terence Parr Aaron Sawdey |
154 |SORCERER 1.00B9 Terence Parr Aaron Sawdey, Gary Funck |
155 |___________________________________________________________________________|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184 Page 3
185
+0
-90
contrib/pccts/install68K.mpw less more
0 #
1 # File name install68K.mpw
2 #
3 # Description This script builds 68K version of antlr, dlg and sor.
4 # and install them into Tools folder in your MPW.
5 # They have commando interfaces.
6 #
7 # Installation Set Directory to the directory containing this file.
8 # Enter "install68K.mpw" and press enter key.
9 #
10 # Requirements SC compiler
11 # http://developer.apple.com/dev/tools/mpw-tools/compilers/index.html
12 #
13 # Author Kenji Tanaka (kentar@osa.att.ne.jp)
14 # http://www.geocities.com/SiliconValley/Platform/5502/pccts
15 # Created 06/16/98
16 # Modified 12/14/98
17 #
18
19 Echo "# `Date -t` ----- Building 68K version of PCCTS tools."
20
21 # Make 'Macintosh' folders to hold object files.
22
23 Echo "# `Date -t` ----- Making Object File Folders."
24 If (!`exists :dlg:Obj:`)
25 NewFolder :dlg:Obj:
26 End
27 If (!`exists :antlr:Obj:`)
28 NewFolder :antlr:Obj:
29 End
30 If (!`exists :sorcerer:Obj:`)
31 NewFolder :sorcerer:Obj:
32 End
33
34 Echo "# `Date -t` ----- Done."
35 Echo "#"
36
37 # DLG build commands
38
39 Echo "# `Date -t` ----- Building DLG."
40 Echo "# `Date -t` ----- Analyzing dependencies."
41 Directory :dlg:
42 Begin
43 Echo "Set Echo 1"
44 Make Install -f dlg68K.make
45 End > dlg.makeout
46 Echo "# `Date -t` ----- Executing build commands."
47 dlg.makeout
48 Delete dlg.makeout
49 Delete -y Obj
50
51 Echo "# `Date -t` ----- Done."
52 Echo "#"
53 Directory ::
54
55 # ANTLR build commands
56
57 Echo "# `Date -t` ----- Building ANTLR."
58 Echo "# `Date -t` ----- Analyzing dependencies."
59 Directory :antlr:
60 Begin
61 Echo "Set Echo 1"
62 Make Install -f antlr68K.make
63 End > antlr.makeout
64 antlr.makeout
65 Delete antlr.makeout
66 Delete -y Obj
67 Echo "# `Date -t` ----- Done."
68 Echo "#"
69 Directory ::
70
71 # SORCERER build commands
72
73 Echo "# `Date -t` ----- Building SORCERER."
74 Echo "# `Date -t` ----- Analyzing dependencies."
75 Directory :sorcerer:
76 Begin
77 Echo "Set Echo 1"
78 Make Install -f sor68K.make
79 End > sorcerer.makeout
80 sorcerer.makeout
81 Delete sorcerer.makeout
82 Delete -y Obj
83 Echo "# `Date -t` ----- Done."
84 Echo "#"
85 Directory ::
86
87 # Done
88
89 Echo "# `Date -t` ----- Done Building 68K version of PCCTS tools."
+0
-89
contrib/pccts/installPPC.mpw less more
0 # File name installPPC.mpw
1 #
2 # Description This script builds PPC version of antlr, dlg and sor.
3 # and install them into Tools folder in your MPW.
4 # They have commando interfaces.
5 #
6 # Installation Set Directory to the directory containing this file.
7 # Enter "installPPC.mpw" and press enter key.
8 #
9 # Requirements MrC(for PPC) compiler
10 # http://developer.apple.com/dev/tools/mpw-tools/compilers/index.html
11 #
12 # Author Kenji Tanaka (kentar@osa.att.ne.jp)
13 # http://www.geocities.com/SiliconValley/Platform/5502/pccts
14 # Created 06/16/98
15 # Modified 12/14/98
16
17 Echo "# `Date -t` ----- Building PPC version of PCCTS tools."
18
19 # Make 'Macintosh' folders to hold object files.
20
21 Echo "# `Date -t` ----- Making Object File Folders."
22 If (!`exists :dlg:Obj:`)
23 NewFolder :dlg:Obj:
24 End
25 If (!`exists :antlr:Obj:`)
26 NewFolder :antlr:Obj:
27 End
28 If (!`exists :sorcerer:Obj:`)
29 NewFolder :sorcerer:Obj:
30 End
31
32 Echo "# `Date -t` ----- Done."
33 Echo "#"
34
35 # DLG build commands
36
37 Echo "# `Date -t` ----- Building DLG."
38 Echo "# `Date -t` ----- Analyzing dependencies."
39 Directory :dlg:
40 Begin
41 Echo "Set Echo 1"
42 Make Install -f dlgPPC.make
43 End > dlg.makeout
44 Echo "# `Date -t` ----- Executing build commands."
45 dlg.makeout
46 Delete dlg.makeout
47 Delete -y Obj
48
49 Echo "# `Date -t` ----- Done."
50 Echo "#"
51 Directory ::
52
53 # ANTLR build commands
54
55 Echo "# `Date -t` ----- Building ANTLR."
56 Echo "# `Date -t` ----- Analyzing dependencies."
57 Directory :antlr:
58 Begin
59 Echo "Set Echo 1"
60 Make Install -f antlrPPC.make
61 End > antlr.makeout
62 antlr.makeout
63 Delete antlr.makeout
64 Delete -y Obj
65 Echo "# `Date -t` ----- Done."
66 Echo "#"
67 Directory ::
68
69 # SORCERER build commands
70
71 Echo "# `Date -t` ----- Building SORCERER."
72 Echo "# `Date -t` ----- Analyzing dependencies."
73 Directory :sorcerer:
74 Begin
75 Echo "Set Echo 1"
76 Make Install -f sorPPC.make
77 End > sorcerer.makeout
78 sorcerer.makeout
79 Delete sorcerer.makeout
80 Delete -y Obj
81 Echo "# `Date -t` ----- Done."
82 Echo "#"
83 Directory ::
84
85
86 # Done
87
88 Echo "# `Date -t` ----- Done Building PPC version of PCCTS tools."
+0
-13
contrib/pccts/makefile.vms less more
0 $ set def [.antlr]
1 $ @makefile.vms
2 $ rename *.exe [-.bin]
3 $ set def [-.dlg]
4 $ @makefile.vms
5 $ rename *.exe [-.bin]
6 $ set def [-.sorcerer]
7 $ @makefile.vms
8 $ rename *.exe [-.bin]
9 $ set def [-.support.decmms]
10 $ @makefile.vms
11 $ rename *.exe [--.bin]
12 $ set def [--]
+0
-42
contrib/pccts/sorcerer/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 SUBDIRS= h lib test testcpp
4
5 #PCCTS=..
6 #BIN = $(PCCTS)/bin
7 #ANTLR = $(BIN)/antlr
8 #DLG = $(BIN)/dlg
9 #PCCTS_H = $(PCCTS)/h
10 #SET = $(PCCTS)/support/set
11
12 AM_CFLAGS = -I$(srcdir)/h -I$(srcdir) -I$(srcdir)/../h \
13 -I$(srcdir)/../support/set -DZZLEXBUFSIZE=32000
14 #AFLAGS = -gh -k 2 -gt
15 #DFLAGS = -C2
16 #GRM = sor.g
17 #GENHFILES = tokens.h mode.h stdpccts.h
18
19 noinst_PROGRAMS= sor
20
21 sor_SOURCES= \
22 cpp.c err.c gen.c globals.c hash.c hash.h look.c \
23 main.c mode.h proto.h scan.c $(srcdir)/../support/set/set.c \
24 sor.c sor.h stdpccts.h sym.h tokens.h
25
26 #sor.c stdpccts.h parser.dlg tokens.h err.c : sor.g
27 # $(ANTLR) $(AFLAGS) sor.g
28
29 #scan.c mode.h : parser.dlg
30 # $(DLG) $(DFLAGS) parser.dlg scan.c
31
32 #scrub:
33 # rm -f *.o core $(GENHFILES) parser.dlg scan.c err.c sor.c sor
34
35
36 EXTRA_DIST= \
37 README SorcererMSVC50.dsp SorcererMSVC50.dsw SorcererMSVC50.mak \
38 SorcererMSVC60.dsp SorcererMSVC60.dsw UPDATES makefile.VMS \
39 makefile1 msvc.dsw parser.dlg sor.g sor.r sor68K.make \
40 sorPPC.make
41
+0
-753
contrib/pccts/sorcerer/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 noinst_PROGRAMS = sor$(EXEEXT)
79 subdir = contrib/pccts/sorcerer
80 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
81 $(top_srcdir)/depcomp README
82 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
83 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
84 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
85 $(ACLOCAL_M4)
86 mkinstalldirs = $(install_sh) -d
87 CONFIG_HEADER = $(top_builddir)/config.h
88 CONFIG_CLEAN_FILES =
89 CONFIG_CLEAN_VPATH_FILES =
90 PROGRAMS = $(noinst_PROGRAMS)
91 am_sor_OBJECTS = cpp.$(OBJEXT) err.$(OBJEXT) gen.$(OBJEXT) \
92 globals.$(OBJEXT) hash.$(OBJEXT) look.$(OBJEXT) main.$(OBJEXT) \
93 scan.$(OBJEXT) set.$(OBJEXT) sor.$(OBJEXT)
94 sor_OBJECTS = $(am_sor_OBJECTS)
95 sor_LDADD = $(LDADD)
96 AM_V_P = $(am__v_P_@AM_V@)
97 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
98 am__v_P_0 = false
99 am__v_P_1 = :
100 AM_V_GEN = $(am__v_GEN_@AM_V@)
101 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
102 am__v_GEN_0 = @echo " GEN " $@;
103 am__v_GEN_1 =
104 AM_V_at = $(am__v_at_@AM_V@)
105 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
106 am__v_at_0 = @
107 am__v_at_1 =
108 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
109 depcomp = $(SHELL) $(top_srcdir)/depcomp
110 am__depfiles_maybe = depfiles
111 am__mv = mv -f
112 AM_V_lt = $(am__v_lt_@AM_V@)
113 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
114 am__v_lt_0 = --silent
115 am__v_lt_1 =
116 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
117 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
118 AM_V_CC = $(am__v_CC_@AM_V@)
119 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
120 am__v_CC_0 = @echo " CC " $@;
121 am__v_CC_1 =
122 CCLD = $(CC)
123 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
124 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
125 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
126 am__v_CCLD_0 = @echo " CCLD " $@;
127 am__v_CCLD_1 =
128 SOURCES = $(sor_SOURCES)
129 DIST_SOURCES = $(sor_SOURCES)
130 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
131 ctags-recursive dvi-recursive html-recursive info-recursive \
132 install-data-recursive install-dvi-recursive \
133 install-exec-recursive install-html-recursive \
134 install-info-recursive install-pdf-recursive \
135 install-ps-recursive install-recursive installcheck-recursive \
136 installdirs-recursive pdf-recursive ps-recursive \
137 tags-recursive uninstall-recursive
138 am__can_run_installinfo = \
139 case $$AM_UPDATE_INFO_DIR in \
140 n|no|NO) false;; \
141 *) (install-info --version) >/dev/null 2>&1;; \
142 esac
143 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
144 distclean-recursive maintainer-clean-recursive
145 am__recursive_targets = \
146 $(RECURSIVE_TARGETS) \
147 $(RECURSIVE_CLEAN_TARGETS) \
148 $(am__extra_recursive_targets)
149 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
150 distdir
151 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
152 # Read a list of newline-separated strings from the standard input,
153 # and print each of them once, without duplicates. Input order is
154 # *not* preserved.
155 am__uniquify_input = $(AWK) '\
156 BEGIN { nonempty = 0; } \
157 { items[$$0] = 1; nonempty = 1; } \
158 END { if (nonempty) { for (i in items) print i; }; } \
159 '
160 # Make sure the list of sources is unique. This is necessary because,
161 # e.g., the same source file might be shared among _SOURCES variables
162 # for different programs/libraries.
163 am__define_uniq_tagged_files = \
164 list='$(am__tagged_files)'; \
165 unique=`for i in $$list; do \
166 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
167 done | $(am__uniquify_input)`
168 ETAGS = etags
169 CTAGS = ctags
170 DIST_SUBDIRS = $(SUBDIRS)
171 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
172 am__relativize = \
173 dir0=`pwd`; \
174 sed_first='s,^\([^/]*\)/.*$$,\1,'; \
175 sed_rest='s,^[^/]*/*,,'; \
176 sed_last='s,^.*/\([^/]*\)$$,\1,'; \
177 sed_butlast='s,/*[^/]*$$,,'; \
178 while test -n "$$dir1"; do \
179 first=`echo "$$dir1" | sed -e "$$sed_first"`; \
180 if test "$$first" != "."; then \
181 if test "$$first" = ".."; then \
182 dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
183 dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
184 else \
185 first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
186 if test "$$first2" = "$$first"; then \
187 dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
188 else \
189 dir2="../$$dir2"; \
190 fi; \
191 dir0="$$dir0"/"$$first"; \
192 fi; \
193 fi; \
194 dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
195 done; \
196 reldir="$$dir2"
197 ACLOCAL = @ACLOCAL@
198 AET2_CFLAGS = @AET2_CFLAGS@
199 AET2_LDADD = @AET2_LDADD@
200 ALLOCA = @ALLOCA@
201 AMTAR = @AMTAR@
202 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
203 AUTOCONF = @AUTOCONF@
204 AUTOHEADER = @AUTOHEADER@
205 AUTOMAKE = @AUTOMAKE@
206 AWK = @AWK@
207 CC = @CC@
208 CCDEPMODE = @CCDEPMODE@
209 CFLAGS = @CFLAGS@
210 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
211 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
212 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
213 CPP = @CPP@
214 CPPFLAGS = @CPPFLAGS@
215 CXX = @CXX@
216 CXXDEPMODE = @CXXDEPMODE@
217 CXXFLAGS = @CXXFLAGS@
218 CYGPATH_W = @CYGPATH_W@
219 DEFS = @DEFS@
220 DEPDIR = @DEPDIR@
221 ECHO_C = @ECHO_C@
222 ECHO_N = @ECHO_N@
223 ECHO_T = @ECHO_T@
224 EGREP = @EGREP@
225 EXEEXT = @EXEEXT@
226 EXTDEBUG = @EXTDEBUG@
227 EXTDEBUG2 = @EXTDEBUG2@
228 EXTDEBUG3 = @EXTDEBUG3@
229 EXTDEBUG4 = @EXTDEBUG4@
230 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
231 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
232 FSDB_CFLAGS = @FSDB_CFLAGS@
233 FSDB_LDADD = @FSDB_LDADD@
234 GCONF_CFLAGS = @GCONF_CFLAGS@
235 GCONF_LIBS = @GCONF_LIBS@
236 GEDITTEST = @GEDITTEST@
237 GEDIT_CFLAGS = @GEDIT_CFLAGS@
238 GIO_CFLAGS = @GIO_CFLAGS@
239 GIO_LIBS = @GIO_LIBS@
240 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
241 GPERF = @GPERF@
242 GREP = @GREP@
243 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
244 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
245 GTK_CFLAGS = @GTK_CFLAGS@
246 GTK_CONFIG = @GTK_CONFIG@
247 GTK_LIBS = @GTK_LIBS@
248 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
249 GTK_MAC_LIBS = @GTK_MAC_LIBS@
250 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
251 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
252 INSTALL = @INSTALL@
253 INSTALL_DATA = @INSTALL_DATA@
254 INSTALL_PROGRAM = @INSTALL_PROGRAM@
255 INSTALL_SCRIPT = @INSTALL_SCRIPT@
256 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
257 LDFLAGS = @LDFLAGS@
258 LEX = @LEX@
259 LEXLIB = @LEXLIB@
260 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
261 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
262 LIBBZ2_DIR = @LIBBZ2_DIR@
263 LIBBZ2_LDADD = @LIBBZ2_LDADD@
264 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
265 LIBJUDY_LDADD = @LIBJUDY_LDADD@
266 LIBOBJS = @LIBOBJS@
267 LIBS = @LIBS@
268 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
269 LIBXZ_LDADD = @LIBXZ_LDADD@
270 LIBZ_CFLAGS = @LIBZ_CFLAGS@
271 LIBZ_DIR = @LIBZ_DIR@
272 LIBZ_LDADD = @LIBZ_LDADD@
273 LTLIBOBJS = @LTLIBOBJS@
274 MAINT = @MAINT@
275 MAKEINFO = @MAKEINFO@
276 MINGW_LDADD = @MINGW_LDADD@
277 MKDIR_P = @MKDIR_P@
278 OBJEXT = @OBJEXT@
279 PACKAGE = @PACKAGE@
280 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
281 PACKAGE_NAME = @PACKAGE_NAME@
282 PACKAGE_STRING = @PACKAGE_STRING@
283 PACKAGE_TARNAME = @PACKAGE_TARNAME@
284 PACKAGE_URL = @PACKAGE_URL@
285 PACKAGE_VERSION = @PACKAGE_VERSION@
286 PATH_SEPARATOR = @PATH_SEPARATOR@
287 PKG_CONFIG = @PKG_CONFIG@
288 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
289 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
290 POW_LIB = @POW_LIB@
291 RANLIB = @RANLIB@
292 RPC_CFLAGS = @RPC_CFLAGS@
293 RPC_LDADD = @RPC_LDADD@
294 SET_MAKE = @SET_MAKE@
295 SHELL = @SHELL@
296 STRIP = @STRIP@
297 STRUCT_PACK = @STRUCT_PACK@
298 TCL_DEFADD = @TCL_DEFADD@
299 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
300 TCL_LDADD = @TCL_LDADD@
301 TCL_LIB_SPEC = @TCL_LIB_SPEC@
302 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
303 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
304 TIRPC_CFLAGS = @TIRPC_CFLAGS@
305 TIRPC_LIBS = @TIRPC_LIBS@
306 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
307 TK_LDADD = @TK_LDADD@
308 TK_LIB_SPEC = @TK_LIB_SPEC@
309 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
310 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
311 VERSION = @VERSION@
312 XDGDATADIR = @XDGDATADIR@
313 abs_builddir = @abs_builddir@
314 abs_srcdir = @abs_srcdir@
315 abs_top_builddir = @abs_top_builddir@
316 abs_top_srcdir = @abs_top_srcdir@
317 ac_ct_CC = @ac_ct_CC@
318 ac_ct_CXX = @ac_ct_CXX@
319 am__include = @am__include@
320 am__leading_dot = @am__leading_dot@
321 am__quote = @am__quote@
322 am__tar = @am__tar@
323 am__untar = @am__untar@
324 bindir = @bindir@
325 build_alias = @build_alias@
326 builddir = @builddir@
327 datadir = @datadir@
328 datarootdir = @datarootdir@
329 docdir = @docdir@
330 dvidir = @dvidir@
331 exec_prefix = @exec_prefix@
332 gsettingsschemadir = @gsettingsschemadir@
333 host_alias = @host_alias@
334 htmldir = @htmldir@
335 includedir = @includedir@
336 infodir = @infodir@
337 install_sh = @install_sh@
338 libdir = @libdir@
339 libexecdir = @libexecdir@
340 localedir = @localedir@
341 localstatedir = @localstatedir@
342 mandir = @mandir@
343 mkdir_p = @mkdir_p@
344 oldincludedir = @oldincludedir@
345 pdfdir = @pdfdir@
346 prefix = @prefix@
347 program_transform_name = @program_transform_name@
348 psdir = @psdir@
349 sbindir = @sbindir@
350 sharedstatedir = @sharedstatedir@
351 srcdir = @srcdir@
352 sysconfdir = @sysconfdir@
353 target_alias = @target_alias@
354 top_build_prefix = @top_build_prefix@
355 top_builddir = @top_builddir@
356 top_srcdir = @top_srcdir@
357 SUBDIRS = h lib test testcpp
358
359 #PCCTS=..
360 #BIN = $(PCCTS)/bin
361 #ANTLR = $(BIN)/antlr
362 #DLG = $(BIN)/dlg
363 #PCCTS_H = $(PCCTS)/h
364 #SET = $(PCCTS)/support/set
365 AM_CFLAGS = -I$(srcdir)/h -I$(srcdir) -I$(srcdir)/../h \
366 -I$(srcdir)/../support/set -DZZLEXBUFSIZE=32000
367
368 sor_SOURCES = \
369 cpp.c err.c gen.c globals.c hash.c hash.h look.c \
370 main.c mode.h proto.h scan.c $(srcdir)/../support/set/set.c \
371 sor.c sor.h stdpccts.h sym.h tokens.h
372
373
374 #sor.c stdpccts.h parser.dlg tokens.h err.c : sor.g
375 # $(ANTLR) $(AFLAGS) sor.g
376
377 #scan.c mode.h : parser.dlg
378 # $(DLG) $(DFLAGS) parser.dlg scan.c
379
380 #scrub:
381 # rm -f *.o core $(GENHFILES) parser.dlg scan.c err.c sor.c sor
382 EXTRA_DIST = \
383 README SorcererMSVC50.dsp SorcererMSVC50.dsw SorcererMSVC50.mak \
384 SorcererMSVC60.dsp SorcererMSVC60.dsw UPDATES makefile.VMS \
385 makefile1 msvc.dsw parser.dlg sor.g sor.r sor68K.make \
386 sorPPC.make
387
388 all: all-recursive
389
390 .SUFFIXES:
391 .SUFFIXES: .c .o .obj
392 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
393 @for dep in $?; do \
394 case '$(am__configure_deps)' in \
395 *$$dep*) \
396 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
397 && { if test -f $@; then exit 0; else break; fi; }; \
398 exit 1;; \
399 esac; \
400 done; \
401 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/sorcerer/Makefile'; \
402 $(am__cd) $(top_srcdir) && \
403 $(AUTOMAKE) --foreign contrib/pccts/sorcerer/Makefile
404 .PRECIOUS: Makefile
405 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
406 @case '$?' in \
407 *config.status*) \
408 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
409 *) \
410 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
411 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
412 esac;
413
414 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
415 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
416
417 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
418 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
419 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
420 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
421 $(am__aclocal_m4_deps):
422
423 clean-noinstPROGRAMS:
424 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
425
426 sor$(EXEEXT): $(sor_OBJECTS) $(sor_DEPENDENCIES) $(EXTRA_sor_DEPENDENCIES)
427 @rm -f sor$(EXEEXT)
428 $(AM_V_CCLD)$(LINK) $(sor_OBJECTS) $(sor_LDADD) $(LIBS)
429
430 mostlyclean-compile:
431 -rm -f *.$(OBJEXT)
432
433 distclean-compile:
434 -rm -f *.tab.c
435
436 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpp.Po@am__quote@
437 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Po@am__quote@
438 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen.Po@am__quote@
439 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/globals.Po@am__quote@
440 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@
441 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/look.Po@am__quote@
442 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
443 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan.Po@am__quote@
444 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set.Po@am__quote@
445 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sor.Po@am__quote@
446
447 .c.o:
448 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
449 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
450 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
451 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
452 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
453
454 .c.obj:
455 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
456 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
457 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
458 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
459 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
460
461 set.o: $(srcdir)/../support/set/set.c
462 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT set.o -MD -MP -MF $(DEPDIR)/set.Tpo -c -o set.o `test -f '$(srcdir)/../support/set/set.c' || echo '$(srcdir)/'`$(srcdir)/../support/set/set.c
463 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/set.Tpo $(DEPDIR)/set.Po
464 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../support/set/set.c' object='set.o' libtool=no @AMDEPBACKSLASH@
465 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
466 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o set.o `test -f '$(srcdir)/../support/set/set.c' || echo '$(srcdir)/'`$(srcdir)/../support/set/set.c
467
468 set.obj: $(srcdir)/../support/set/set.c
469 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT set.obj -MD -MP -MF $(DEPDIR)/set.Tpo -c -o set.obj `if test -f '$(srcdir)/../support/set/set.c'; then $(CYGPATH_W) '$(srcdir)/../support/set/set.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../support/set/set.c'; fi`
470 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/set.Tpo $(DEPDIR)/set.Po
471 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../support/set/set.c' object='set.obj' libtool=no @AMDEPBACKSLASH@
472 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
473 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o set.obj `if test -f '$(srcdir)/../support/set/set.c'; then $(CYGPATH_W) '$(srcdir)/../support/set/set.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../support/set/set.c'; fi`
474
475 # This directory's subdirectories are mostly independent; you can cd
476 # into them and run 'make' without going through this Makefile.
477 # To change the values of 'make' variables: instead of editing Makefiles,
478 # (1) if the variable is set in 'config.status', edit 'config.status'
479 # (which will cause the Makefiles to be regenerated when you run 'make');
480 # (2) otherwise, pass the desired values on the 'make' command line.
481 $(am__recursive_targets):
482 @fail=; \
483 if $(am__make_keepgoing); then \
484 failcom='fail=yes'; \
485 else \
486 failcom='exit 1'; \
487 fi; \
488 dot_seen=no; \
489 target=`echo $@ | sed s/-recursive//`; \
490 case "$@" in \
491 distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
492 *) list='$(SUBDIRS)' ;; \
493 esac; \
494 for subdir in $$list; do \
495 echo "Making $$target in $$subdir"; \
496 if test "$$subdir" = "."; then \
497 dot_seen=yes; \
498 local_target="$$target-am"; \
499 else \
500 local_target="$$target"; \
501 fi; \
502 ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
503 || eval $$failcom; \
504 done; \
505 if test "$$dot_seen" = "no"; then \
506 $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
507 fi; test -z "$$fail"
508
509 ID: $(am__tagged_files)
510 $(am__define_uniq_tagged_files); mkid -fID $$unique
511 tags: tags-recursive
512 TAGS: tags
513
514 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
515 set x; \
516 here=`pwd`; \
517 if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
518 include_option=--etags-include; \
519 empty_fix=.; \
520 else \
521 include_option=--include; \
522 empty_fix=; \
523 fi; \
524 list='$(SUBDIRS)'; for subdir in $$list; do \
525 if test "$$subdir" = .; then :; else \
526 test ! -f $$subdir/TAGS || \
527 set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
528 fi; \
529 done; \
530 $(am__define_uniq_tagged_files); \
531 shift; \
532 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
533 test -n "$$unique" || unique=$$empty_fix; \
534 if test $$# -gt 0; then \
535 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
536 "$$@" $$unique; \
537 else \
538 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
539 $$unique; \
540 fi; \
541 fi
542 ctags: ctags-recursive
543
544 CTAGS: ctags
545 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
546 $(am__define_uniq_tagged_files); \
547 test -z "$(CTAGS_ARGS)$$unique" \
548 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
549 $$unique
550
551 GTAGS:
552 here=`$(am__cd) $(top_builddir) && pwd` \
553 && $(am__cd) $(top_srcdir) \
554 && gtags -i $(GTAGS_ARGS) "$$here"
555 cscopelist: cscopelist-recursive
556
557 cscopelist-am: $(am__tagged_files)
558 list='$(am__tagged_files)'; \
559 case "$(srcdir)" in \
560 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
561 *) sdir=$(subdir)/$(srcdir) ;; \
562 esac; \
563 for i in $$list; do \
564 if test -f "$$i"; then \
565 echo "$(subdir)/$$i"; \
566 else \
567 echo "$$sdir/$$i"; \
568 fi; \
569 done >> $(top_builddir)/cscope.files
570
571 distclean-tags:
572 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
573
574 distdir: $(DISTFILES)
575 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
576 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
577 list='$(DISTFILES)'; \
578 dist_files=`for file in $$list; do echo $$file; done | \
579 sed -e "s|^$$srcdirstrip/||;t" \
580 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
581 case $$dist_files in \
582 */*) $(MKDIR_P) `echo "$$dist_files" | \
583 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
584 sort -u` ;; \
585 esac; \
586 for file in $$dist_files; do \
587 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
588 if test -d $$d/$$file; then \
589 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
590 if test -d "$(distdir)/$$file"; then \
591 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
592 fi; \
593 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
594 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
595 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
596 fi; \
597 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
598 else \
599 test -f "$(distdir)/$$file" \
600 || cp -p $$d/$$file "$(distdir)/$$file" \
601 || exit 1; \
602 fi; \
603 done
604 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
605 if test "$$subdir" = .; then :; else \
606 $(am__make_dryrun) \
607 || test -d "$(distdir)/$$subdir" \
608 || $(MKDIR_P) "$(distdir)/$$subdir" \
609 || exit 1; \
610 dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
611 $(am__relativize); \
612 new_distdir=$$reldir; \
613 dir1=$$subdir; dir2="$(top_distdir)"; \
614 $(am__relativize); \
615 new_top_distdir=$$reldir; \
616 echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
617 echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
618 ($(am__cd) $$subdir && \
619 $(MAKE) $(AM_MAKEFLAGS) \
620 top_distdir="$$new_top_distdir" \
621 distdir="$$new_distdir" \
622 am__remove_distdir=: \
623 am__skip_length_check=: \
624 am__skip_mode_fix=: \
625 distdir) \
626 || exit 1; \
627 fi; \
628 done
629 check-am: all-am
630 check: check-recursive
631 all-am: Makefile $(PROGRAMS)
632 installdirs: installdirs-recursive
633 installdirs-am:
634 install: install-recursive
635 install-exec: install-exec-recursive
636 install-data: install-data-recursive
637 uninstall: uninstall-recursive
638
639 install-am: all-am
640 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
641
642 installcheck: installcheck-recursive
643 install-strip:
644 if test -z '$(STRIP)'; then \
645 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
646 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
647 install; \
648 else \
649 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
650 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
651 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
652 fi
653 mostlyclean-generic:
654
655 clean-generic:
656
657 distclean-generic:
658 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
659 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
660
661 maintainer-clean-generic:
662 @echo "This command is intended for maintainers to use"
663 @echo "it deletes files that may require special tools to rebuild."
664 clean: clean-recursive
665
666 clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am
667
668 distclean: distclean-recursive
669 -rm -rf ./$(DEPDIR)
670 -rm -f Makefile
671 distclean-am: clean-am distclean-compile distclean-generic \
672 distclean-tags
673
674 dvi: dvi-recursive
675
676 dvi-am:
677
678 html: html-recursive
679
680 html-am:
681
682 info: info-recursive
683
684 info-am:
685
686 install-data-am:
687
688 install-dvi: install-dvi-recursive
689
690 install-dvi-am:
691
692 install-exec-am:
693
694 install-html: install-html-recursive
695
696 install-html-am:
697
698 install-info: install-info-recursive
699
700 install-info-am:
701
702 install-man:
703
704 install-pdf: install-pdf-recursive
705
706 install-pdf-am:
707
708 install-ps: install-ps-recursive
709
710 install-ps-am:
711
712 installcheck-am:
713
714 maintainer-clean: maintainer-clean-recursive
715 -rm -rf ./$(DEPDIR)
716 -rm -f Makefile
717 maintainer-clean-am: distclean-am maintainer-clean-generic
718
719 mostlyclean: mostlyclean-recursive
720
721 mostlyclean-am: mostlyclean-compile mostlyclean-generic
722
723 pdf: pdf-recursive
724
725 pdf-am:
726
727 ps: ps-recursive
728
729 ps-am:
730
731 uninstall-am:
732
733 .MAKE: $(am__recursive_targets) install-am install-strip
734
735 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
736 check-am clean clean-generic clean-noinstPROGRAMS \
737 cscopelist-am ctags ctags-am distclean distclean-compile \
738 distclean-generic distclean-tags distdir dvi dvi-am html \
739 html-am info info-am install install-am install-data \
740 install-data-am install-dvi install-dvi-am install-exec \
741 install-exec-am install-html install-html-am install-info \
742 install-info-am install-man install-pdf install-pdf-am \
743 install-ps install-ps-am install-strip installcheck \
744 installcheck-am installdirs installdirs-am maintainer-clean \
745 maintainer-clean-generic mostlyclean mostlyclean-compile \
746 mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
747 uninstall-am
748
749
750 # Tell versions [3.59,3.63) of GNU make to not export all variables.
751 # Otherwise a system limit (for SysV at least) may be exceeded.
752 .NOEXPORT:
+0
-77
contrib/pccts/sorcerer/README less more
0
1 Welcome to SORCERER 1.00B15
2
3 September 1995
4
5
6 Terence John Parr, Aaron Sawdey, and Gary Funck
7 parrt@parr-research.com
8 sawdey@everest.ee.umn.edu
9 gary@intrepid.com
10
11 SORCERER is a simple tree-parser generator that automates the process
12 of tree walking that is so common in many large programs. E.g., in the
13 case of source-to-source translators, a programmer typically has a
14 front-end that constructs intermediate form trees and simply wants to
15 traverse the trees and execute a few actions. In this case, the
16 optimal tree walks of code-generator generators and the powerful
17 attribute evaluation schemes of source-to-source translator systems
18 are overkill; programmers would rather avoid the overhead and
19 complexity.
20
21 SORCERER is more suitable for the class of translation problems lying
22 between those solved by code-generator generators and by full
23 source-to-source translator generators. SORCERER generates simple,
24 flexible, top-down, tree parsers that, in contrast to code-generators,
25 may execute actions at any point during a tree walk. SORCERER accepts
26 extended BNF notation, allows predicates to direct the tree walk with
27 semantic and syntactic context information, and does not rely on any
28 particular intermediate form, parser generator, or other pre-existing
29 application.
30
31 This is the 1.00B14 release and, therefore, may be less robust than
32 ANTLR and DLG; the source has not been heavily tested for portability;
33 especially outside the UNIX, PC, and MacIntosh world. This initial
34 release contains the full public-domain source code, a manual, and two
35 simple examples. Naturally, as the system matures, more goodies will
36 become available. Though not included in the actual release (to cut
37 down on net traffic), an overview paper is also available.
38
39 We anticipate SORCERER's inclusion with PCCTS release very soon.
40
41 We hope to have the book done very soon now also.
42
43
44 INSTALLATION
45
46 [Mac users: see NOTES.Mac also]
47
48 Simply copy the tar file over (or the compressed tar) and untar it will
49
50 tar xvf sor.tar
51
52 Then, 'cd' into the 'sorcerer' directory that was created by 'tar',
53 type 'make'--the executable 'sor' will appear in the 'sorcerer'
54 directory. Subdirectory 'test' contains two simple test programs and
55 'support' contains a necessary include file and a C file containing
56 default error reporting routines that you can use.
57
58
59 WORD SIZE AND PC USERS
60
61 SORCERER makefiles assume 32-bit integers. If you have 16-bit
62 integers, you must turn on preprocessor symbol PC to change wordsize
63 definitions; see PC32 definition also in config.h. You can add
64 another "#ifdef" for your machine or specific wordsize (see set.h and
65 config.h) if your machine is really weird. [SORCERER has not been
66 adequately tested for portability to non-32-bit machines.]
67
68 BUG REPORTS & QUESTIONS
69
70 Please send bug reports to parrt@parr-research.com.
71
72 If you are interested in sharing your experiences/problems/
73 successes/suggestions regarding SORCERER or PCCTS, subscribe to
74 newsgroup
75
76 comp.compilers.tools.pccts
+0
-207
contrib/pccts/sorcerer/SorcererMSVC50.dsp less more
0 # Microsoft Developer Studio Project File - Name="Sorcerer" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 5.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Console Application" 0x0103
5
6 CFG=Sorcerer - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "SorcererMSVC50.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "SorcererMSVC50.mak" CFG="Sorcerer - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "Sorcerer - Win32 Release" (based on\
20 "Win32 (x86) Console Application")
21 !MESSAGE "Sorcerer - Win32 Debug" (based on "Win32 (x86) Console Application")
22 !MESSAGE
23
24 # Begin Project
25 # PROP Scc_ProjName ""
26 # PROP Scc_LocalPath ""
27 CPP=cl.exe
28 RSC=rc.exe
29
30 !IF "$(CFG)" == "Sorcerer - Win32 Release"
31
32 # PROP BASE Use_MFC 0
33 # PROP BASE Use_Debug_Libraries 0
34 # PROP BASE Output_Dir "Release"
35 # PROP BASE Intermediate_Dir "Release"
36 # PROP BASE Target_Dir ""
37 # PROP Use_MFC 0
38 # PROP Use_Debug_Libraries 0
39 # PROP Output_Dir "."
40 # PROP Intermediate_Dir "."
41 # PROP Ignore_Export_Lib 0
42 # PROP Target_Dir ""
43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
44 # ADD CPP /nologo /W3 /O2 /I "." /I "..\h" /I "..\support\set" /D "__STDC__" /D "NDEBUG" /D "LONGFILENAMES" /D "PC" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c
45 # SUBTRACT CPP /YX
46 # ADD BASE RSC /l 0x409 /d "NDEBUG"
47 # ADD RSC /l 0x409 /d "NDEBUG"
48 BSC32=bscmake.exe
49 # ADD BASE BSC32 /nologo
50 # ADD BSC32 /nologo
51 LINK32=link.exe
52 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
53 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"./Sorcerer.exe"
54 # Begin Special Build Tool
55 SOURCE=$(InputPath)
56 PostBuild_Desc=Update executables in BIN directory
57 PostBuild_Cmds=rename ..\bin\Sorcerer.exe Sorcerer_old.exe \
58 copy ..\Sorcerer\Sorcerer.exe ..\bin\
59 # End Special Build Tool
60
61 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
62
63 # PROP BASE Use_MFC 0
64 # PROP BASE Use_Debug_Libraries 1
65 # PROP BASE Output_Dir "Debug"
66 # PROP BASE Intermediate_Dir "Debug"
67 # PROP BASE Target_Dir ""
68 # PROP Use_MFC 0
69 # PROP Use_Debug_Libraries 1
70 # PROP Output_Dir "."
71 # PROP Intermediate_Dir "."
72 # PROP Ignore_Export_Lib 0
73 # PROP Target_Dir ""
74 # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
75 # ADD CPP /nologo /W3 /Gm /Zi /Od /I "." /I "..\h" /I "..\support\set" /D "__STDC__" /D "LONGFILENAMES" /D "PC" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /FD /c
76 # SUBTRACT CPP /YX
77 # ADD BASE RSC /l 0x409 /d "_DEBUG"
78 # ADD RSC /l 0x409 /d "_DEBUG"
79 BSC32=bscmake.exe
80 # ADD BASE BSC32 /nologo
81 # ADD BSC32 /nologo
82 LINK32=link.exe
83 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
84 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"./Sorcerer.exe" /pdbtype:sept
85 # Begin Special Build Tool
86 SOURCE=$(InputPath)
87 PostBuild_Desc=Update executables in BIN directory
88 PostBuild_Cmds=rename ..\bin\Sorcerer.exe Sorcerer_old.exe \
89 copy ..\Sorcerer\Sorcerer.exe ..\bin\
90 # End Special Build Tool
91
92 !ENDIF
93
94 # Begin Target
95
96 # Name "Sorcerer - Win32 Release"
97 # Name "Sorcerer - Win32 Debug"
98 # Begin Source File
99
100 SOURCE=.\cpp.c
101 # End Source File
102 # Begin Source File
103
104 SOURCE=.\err.c
105 # End Source File
106 # Begin Source File
107
108 SOURCE=.\gen.c
109 # End Source File
110 # Begin Source File
111
112 SOURCE=.\globals.c
113 # End Source File
114 # Begin Source File
115
116 SOURCE=.\hash.c
117 # End Source File
118 # Begin Source File
119
120 SOURCE=.\look.c
121 # End Source File
122 # Begin Source File
123
124 SOURCE=.\main.c
125 # End Source File
126 # Begin Source File
127
128 SOURCE=.\scan.c
129 # End Source File
130 # Begin Source File
131
132 SOURCE=..\support\set\set.c
133 # End Source File
134 # Begin Source File
135
136 SOURCE=.\sor.c
137 # End Source File
138 # Begin Source File
139
140 SOURCE=.\sor.g
141
142 !IF "$(CFG)" == "Sorcerer - Win32 Release"
143
144 # Begin Custom Build - Generating Parser
145 InputPath=.\sor.g
146 InputName=sor
147
148 BuildCmds= \
149 ..\bin\antlr -gh -k 2 -gt $(InputName).g \
150 ..\bin\dlg -C2 parser.dlg scan.c \
151
152
153 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
154 $(BuildCmds)
155
156 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
157 $(BuildCmds)
158
159 "stdpccts.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
160 $(BuildCmds)
161
162 "sor.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
163 $(BuildCmds)
164
165 "scan.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
166 $(BuildCmds)
167
168 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
169 $(BuildCmds)
170 # End Custom Build
171
172 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
173
174 # Begin Custom Build - Generating Parser
175 InputPath=.\sor.g
176 InputName=sor
177
178 BuildCmds= \
179 ..\bin\antlr -gh -k 2 -gt $(InputName).g \
180 ..\bin\dlg -C2 parser.dlg scan.c \
181
182
183 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
184 $(BuildCmds)
185
186 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
187 $(BuildCmds)
188
189 "stdpccts.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
190 $(BuildCmds)
191
192 "sor.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
193 $(BuildCmds)
194
195 "scan.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
196 $(BuildCmds)
197
198 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
199 $(BuildCmds)
200 # End Custom Build
201
202 !ENDIF
203
204 # End Source File
205 # End Target
206 # End Project
+0
-29
contrib/pccts/sorcerer/SorcererMSVC50.dsw less more
0 Microsoft Developer Studio Workspace File, Format Version 5.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "Sorcerer"=.\SorcererMSVC50.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 }}}
10
11 Package=<4>
12 {{{
13 }}}
14
15 ###############################################################################
16
17 Global:
18
19 Package=<5>
20 {{{
21 }}}
22
23 Package=<3>
24 {{{
25 }}}
26
27 ###############################################################################
28
+0
-725
contrib/pccts/sorcerer/SorcererMSVC50.mak less more
0 # Microsoft Developer Studio Generated NMAKE File, Based on SorcererMSVC50.dsp
1 !IF "$(CFG)" == ""
2 CFG=Sorcerer - Win32 Debug
3 !MESSAGE No configuration specified. Defaulting to Sorcerer - Win32 Debug.
4 !ENDIF
5
6 !IF "$(CFG)" != "Sorcerer - Win32 Release" && "$(CFG)" !=\
7 "Sorcerer - Win32 Debug"
8 !MESSAGE Invalid configuration "$(CFG)" specified.
9 !MESSAGE You can specify a configuration when running NMAKE
10 !MESSAGE by defining the macro CFG on the command line. For example:
11 !MESSAGE
12 !MESSAGE NMAKE /f "SorcererMSVC50.mak" CFG="Sorcerer - Win32 Debug"
13 !MESSAGE
14 !MESSAGE Possible choices for configuration are:
15 !MESSAGE
16 !MESSAGE "Sorcerer - Win32 Release" (based on\
17 "Win32 (x86) Console Application")
18 !MESSAGE "Sorcerer - Win32 Debug" (based on "Win32 (x86) Console Application")
19 !MESSAGE
20 !ERROR An invalid configuration is specified.
21 !ENDIF
22
23 !IF "$(OS)" == "Windows_NT"
24 NULL=
25 !ELSE
26 NULL=nul
27 !ENDIF
28
29 !IF "$(CFG)" == "Sorcerer - Win32 Release"
30
31 OUTDIR=.\.
32 INTDIR=.\.
33 # Begin Custom Macros
34 OutDir=.\.
35 # End Custom Macros
36
37 !IF "$(RECURSE)" == "0"
38
39 ALL : "stdpccts.h" "sor.c" "scan.c" "parser.dlg" "mode.h" "err.c"\
40 "$(OUTDIR)\Sorcerer.exe"
41
42 !ELSE
43
44 ALL : "DLG - Win32 Release" "ANTLR - Win32 Release" "stdpccts.h" "sor.c"\
45 "scan.c" "parser.dlg" "mode.h" "err.c" "$(OUTDIR)\Sorcerer.exe"
46
47 !ENDIF
48
49 !IF "$(RECURSE)" == "1"
50 CLEAN :"ANTLR - Win32 ReleaseCLEAN" "DLG - Win32 ReleaseCLEAN"
51 !ELSE
52 CLEAN :
53 !ENDIF
54 -@erase "$(INTDIR)\cpp.obj"
55 -@erase "$(INTDIR)\err.obj"
56 -@erase "$(INTDIR)\gen.obj"
57 -@erase "$(INTDIR)\globals.obj"
58 -@erase "$(INTDIR)\hash.obj"
59 -@erase "$(INTDIR)\look.obj"
60 -@erase "$(INTDIR)\main.obj"
61 -@erase "$(INTDIR)\scan.obj"
62 -@erase "$(INTDIR)\set.obj"
63 -@erase "$(INTDIR)\sor.obj"
64 -@erase "$(INTDIR)\vc50.idb"
65 -@erase "$(OUTDIR)\Sorcerer.exe"
66 -@erase "err.c"
67 -@erase "mode.h"
68 -@erase "parser.dlg"
69 -@erase "scan.c"
70 -@erase "sor.c"
71 -@erase "stdpccts.h"
72
73 "$(OUTDIR)" :
74 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
75
76 CPP=cl.exe
77 CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "." /I "..\h" /I "..\support\set" /D\
78 "NDEBUG" /D "LONGFILENAMES" /D "PC" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D\
79 "WIN32" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\SorcererMSVC50.pch" /YX\
80 /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
81 CPP_OBJS=./
82 CPP_SBRS=.
83
84 .c{$(CPP_OBJS)}.obj::
85 $(CPP) @<<
86 $(CPP_PROJ) $<
87 <<
88
89 .cpp{$(CPP_OBJS)}.obj::
90 $(CPP) @<<
91 $(CPP_PROJ) $<
92 <<
93
94 .cxx{$(CPP_OBJS)}.obj::
95 $(CPP) @<<
96 $(CPP_PROJ) $<
97 <<
98
99 .c{$(CPP_SBRS)}.sbr::
100 $(CPP) @<<
101 $(CPP_PROJ) $<
102 <<
103
104 .cpp{$(CPP_SBRS)}.sbr::
105 $(CPP) @<<
106 $(CPP_PROJ) $<
107 <<
108
109 .cxx{$(CPP_SBRS)}.sbr::
110 $(CPP) @<<
111 $(CPP_PROJ) $<
112 <<
113
114 RSC=rc.exe
115 BSC32=bscmake.exe
116 BSC32_FLAGS=/nologo /o"$(OUTDIR)\SorcererMSVC50.bsc"
117 BSC32_SBRS= \
118
119 LINK32=link.exe
120 LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
121 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
122 odbccp32.lib /nologo /subsystem:console /incremental:no\
123 /pdb:"$(OUTDIR)\Sorcerer.pdb" /machine:I386 /out:"$(OUTDIR)\Sorcerer.exe"
124 LINK32_OBJS= \
125 "$(INTDIR)\cpp.obj" \
126 "$(INTDIR)\err.obj" \
127 "$(INTDIR)\gen.obj" \
128 "$(INTDIR)\globals.obj" \
129 "$(INTDIR)\hash.obj" \
130 "$(INTDIR)\look.obj" \
131 "$(INTDIR)\main.obj" \
132 "$(INTDIR)\scan.obj" \
133 "$(INTDIR)\set.obj" \
134 "$(INTDIR)\sor.obj"
135
136 "$(OUTDIR)\Sorcerer.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
137 $(LINK32) @<<
138 $(LINK32_FLAGS) $(LINK32_OBJS)
139 <<
140
141 SOURCE=$(InputPath)
142 PostBuild_Desc=Update executables in BIN directory and remove intermediate\
143 files
144 DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
145
146 ALL : $(DS_POSTBUILD_DEP)
147
148 # Begin Custom Macros
149 OutDir=.\.
150 # End Custom Macros
151
152 $(DS_POSTBUILD_DEP) : "DLG - Win32 Release" "ANTLR - Win32 Release"\
153 "stdpccts.h" "sor.c" "scan.c" "parser.dlg" "mode.h" "err.c"\
154 "$(OUTDIR)\Sorcerer.exe"
155 del ..\bin\Win32\Antlr.old
156 rename ..\bin\Win32\Antlr.exe Antlr.old
157 copy ..\Antlr\Antlr.exe ..\bin\Win32
158 del ..\bin\Win32\Dlg.old
159 rename ..\bin\Win32\Dlg.exe Dlg.old
160 copy ..\Dlg\dlg.exe ..\bin\Win32
161 del ..\bin\Win32\Sorcerer.old
162 rename ..\bin\Win32\Sorcerer.exe Sorcerer.old
163 copy ..\Sorcerer\Sorcerer.exe ..\bin\Win32
164 echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
165
166 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
167
168 OUTDIR=.\.
169 INTDIR=.\.
170 # Begin Custom Macros
171 OutDir=.\.
172 # End Custom Macros
173
174 !IF "$(RECURSE)" == "0"
175
176 ALL : "stdpccts.h" "sor.c" "scan.c" "parser.dlg" "mode.h" "err.c"\
177 "$(OUTDIR)\Sorcerer.exe" "$(OUTDIR)\SorcererMSVC50.bsc"
178
179 !ELSE
180
181 ALL : "DLG - Win32 Debug" "ANTLR - Win32 Debug" "stdpccts.h" "sor.c" "scan.c"\
182 "parser.dlg" "mode.h" "err.c" "$(OUTDIR)\Sorcerer.exe"\
183 "$(OUTDIR)\SorcererMSVC50.bsc"
184
185 !ENDIF
186
187 !IF "$(RECURSE)" == "1"
188 CLEAN :"ANTLR - Win32 DebugCLEAN" "DLG - Win32 DebugCLEAN"
189 !ELSE
190 CLEAN :
191 !ENDIF
192 -@erase "$(INTDIR)\cpp.obj"
193 -@erase "$(INTDIR)\cpp.sbr"
194 -@erase "$(INTDIR)\err.obj"
195 -@erase "$(INTDIR)\err.sbr"
196 -@erase "$(INTDIR)\gen.obj"
197 -@erase "$(INTDIR)\gen.sbr"
198 -@erase "$(INTDIR)\globals.obj"
199 -@erase "$(INTDIR)\globals.sbr"
200 -@erase "$(INTDIR)\hash.obj"
201 -@erase "$(INTDIR)\hash.sbr"
202 -@erase "$(INTDIR)\look.obj"
203 -@erase "$(INTDIR)\look.sbr"
204 -@erase "$(INTDIR)\main.obj"
205 -@erase "$(INTDIR)\main.sbr"
206 -@erase "$(INTDIR)\scan.obj"
207 -@erase "$(INTDIR)\scan.sbr"
208 -@erase "$(INTDIR)\set.obj"
209 -@erase "$(INTDIR)\set.sbr"
210 -@erase "$(INTDIR)\sor.obj"
211 -@erase "$(INTDIR)\sor.sbr"
212 -@erase "$(INTDIR)\vc50.idb"
213 -@erase "$(INTDIR)\vc50.pdb"
214 -@erase "$(OUTDIR)\Sorcerer.exe"
215 -@erase "$(OUTDIR)\Sorcerer.ilk"
216 -@erase "$(OUTDIR)\Sorcerer.pdb"
217 -@erase "$(OUTDIR)\SorcererMSVC50.bsc"
218 -@erase "err.c"
219 -@erase "mode.h"
220 -@erase "parser.dlg"
221 -@erase "scan.c"
222 -@erase "sor.c"
223 -@erase "stdpccts.h"
224
225 "$(OUTDIR)" :
226 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
227
228 CPP=cl.exe
229 CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "." /I "..\h" /I "..\support\set"\
230 /D "LONGFILENAMES" /D "PC" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D\
231 "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\SorcererMSVC50.pch" /YX\
232 /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
233 CPP_OBJS=./
234 CPP_SBRS=./
235
236 .c{$(CPP_OBJS)}.obj::
237 $(CPP) @<<
238 $(CPP_PROJ) $<
239 <<
240
241 .cpp{$(CPP_OBJS)}.obj::
242 $(CPP) @<<
243 $(CPP_PROJ) $<
244 <<
245
246 .cxx{$(CPP_OBJS)}.obj::
247 $(CPP) @<<
248 $(CPP_PROJ) $<
249 <<
250
251 .c{$(CPP_SBRS)}.sbr::
252 $(CPP) @<<
253 $(CPP_PROJ) $<
254 <<
255
256 .cpp{$(CPP_SBRS)}.sbr::
257 $(CPP) @<<
258 $(CPP_PROJ) $<
259 <<
260
261 .cxx{$(CPP_SBRS)}.sbr::
262 $(CPP) @<<
263 $(CPP_PROJ) $<
264 <<
265
266 RSC=rc.exe
267 BSC32=bscmake.exe
268 BSC32_FLAGS=/nologo /o"$(OUTDIR)\SorcererMSVC50.bsc"
269 BSC32_SBRS= \
270 "$(INTDIR)\cpp.sbr" \
271 "$(INTDIR)\err.sbr" \
272 "$(INTDIR)\gen.sbr" \
273 "$(INTDIR)\globals.sbr" \
274 "$(INTDIR)\hash.sbr" \
275 "$(INTDIR)\look.sbr" \
276 "$(INTDIR)\main.sbr" \
277 "$(INTDIR)\scan.sbr" \
278 "$(INTDIR)\set.sbr" \
279 "$(INTDIR)\sor.sbr"
280
281 "$(OUTDIR)\SorcererMSVC50.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
282 $(BSC32) @<<
283 $(BSC32_FLAGS) $(BSC32_SBRS)
284 <<
285
286 LINK32=link.exe
287 LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
288 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
289 odbccp32.lib /nologo /subsystem:console /incremental:yes\
290 /pdb:"$(OUTDIR)\Sorcerer.pdb" /debug /machine:I386\
291 /out:"$(OUTDIR)\Sorcerer.exe" /pdbtype:sept
292 LINK32_OBJS= \
293 "$(INTDIR)\cpp.obj" \
294 "$(INTDIR)\err.obj" \
295 "$(INTDIR)\gen.obj" \
296 "$(INTDIR)\globals.obj" \
297 "$(INTDIR)\hash.obj" \
298 "$(INTDIR)\look.obj" \
299 "$(INTDIR)\main.obj" \
300 "$(INTDIR)\scan.obj" \
301 "$(INTDIR)\set.obj" \
302 "$(INTDIR)\sor.obj"
303
304 "$(OUTDIR)\Sorcerer.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
305 $(LINK32) @<<
306 $(LINK32_FLAGS) $(LINK32_OBJS)
307 <<
308
309 SOURCE=$(InputPath)
310 PostBuild_Desc=Update executables in BIN directory and remove intermediate\
311 files
312 DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
313
314 ALL : $(DS_POSTBUILD_DEP)
315
316 # Begin Custom Macros
317 OutDir=.\.
318 # End Custom Macros
319
320 $(DS_POSTBUILD_DEP) : "DLG - Win32 Debug" "ANTLR - Win32 Debug" "stdpccts.h"\
321 "sor.c" "scan.c" "parser.dlg" "mode.h" "err.c" "$(OUTDIR)\Sorcerer.exe"\
322 "$(OUTDIR)\SorcererMSVC50.bsc"
323 del ..\bin\Win32\Antlr.old
324 rename ..\bin\Win32\Antlr.exe Antlr.old
325 copy ..\Antlr\Antlr.exe ..\bin\Win32
326 del ..\bin\Win32\Dlg.old
327 rename ..\bin\Win32\Dlg.exe Dlg.old
328 copy ..\Dlg\dlg.exe ..\bin\Win32
329 del ..\bin\Win32\Sorcerer.old
330 rename ..\bin\Win32\Sorcerer.exe Sorcerer.old
331 copy ..\Sorcerer\Sorcerer.exe ..\bin\Win32
332 echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
333
334 !ENDIF
335
336
337 !IF "$(CFG)" == "Sorcerer - Win32 Release" || "$(CFG)" ==\
338 "Sorcerer - Win32 Debug"
339
340 !IF "$(CFG)" == "Sorcerer - Win32 Release"
341
342 "ANTLR - Win32 Release" :
343 cd "\SDK\pccts\antlr"
344 $(MAKE) /$(MAKEFLAGS) /F .\AntlrMSVC50.mak CFG="ANTLR - Win32 Release"
345 cd "..\sorcerer"
346
347 "ANTLR - Win32 ReleaseCLEAN" :
348 cd "\SDK\pccts\antlr"
349 $(MAKE) /$(MAKEFLAGS) CLEAN /F .\AntlrMSVC50.mak CFG="ANTLR - Win32 Release"\
350 RECURSE=1
351 cd "..\sorcerer"
352
353 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
354
355 "ANTLR - Win32 Debug" :
356 cd "\SDK\pccts\antlr"
357 $(MAKE) /$(MAKEFLAGS) /F .\AntlrMSVC50.mak CFG="ANTLR - Win32 Debug"
358 cd "..\sorcerer"
359
360 "ANTLR - Win32 DebugCLEAN" :
361 cd "\SDK\pccts\antlr"
362 $(MAKE) /$(MAKEFLAGS) CLEAN /F .\AntlrMSVC50.mak CFG="ANTLR - Win32 Debug"\
363 RECURSE=1
364 cd "..\sorcerer"
365
366 !ENDIF
367
368 !IF "$(CFG)" == "Sorcerer - Win32 Release"
369
370 "DLG - Win32 Release" :
371 cd "\SDK\pccts\dlg"
372 $(MAKE) /$(MAKEFLAGS) /F .\DlgMSVC50.mak CFG="DLG - Win32 Release"
373 cd "..\sorcerer"
374
375 "DLG - Win32 ReleaseCLEAN" :
376 cd "\SDK\pccts\dlg"
377 $(MAKE) /$(MAKEFLAGS) CLEAN /F .\DlgMSVC50.mak CFG="DLG - Win32 Release"\
378 RECURSE=1
379 cd "..\sorcerer"
380
381 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
382
383 "DLG - Win32 Debug" :
384 cd "\SDK\pccts\dlg"
385 $(MAKE) /$(MAKEFLAGS) /F .\DlgMSVC50.mak CFG="DLG - Win32 Debug"
386 cd "..\sorcerer"
387
388 "DLG - Win32 DebugCLEAN" :
389 cd "\SDK\pccts\dlg"
390 $(MAKE) /$(MAKEFLAGS) CLEAN /F .\DlgMSVC50.mak CFG="DLG - Win32 Debug"\
391 RECURSE=1
392 cd "..\sorcerer"
393
394 !ENDIF
395
396 SOURCE=.\cpp.c
397 DEP_CPP_CPP_C=\
398 "..\h\antlr.h"\
399 "..\h\ast.h"\
400 "..\h\charbuf.h"\
401 "..\h\pcctscfg.h"\
402 "..\h\dlgdef.h"\
403 "..\support\set\set.h"\
404 ".\hash.h"\
405 ".\mode.h"\
406 ".\proto.h"\
407 ".\sor.h"\
408 ".\stdpccts.h"\
409 ".\sym.h"\
410 ".\tokens.h"\
411
412
413 !IF "$(CFG)" == "Sorcerer - Win32 Release"
414
415
416 "$(INTDIR)\cpp.obj" : $(SOURCE) $(DEP_CPP_CPP_C) "$(INTDIR)"\
417 "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
418
419
420 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
421
422
423 "$(INTDIR)\cpp.obj" "$(INTDIR)\cpp.sbr" : $(SOURCE) $(DEP_CPP_CPP_C)\
424 "$(INTDIR)" "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
425
426
427 !ENDIF
428
429 SOURCE=.\err.c
430 DEP_CPP_ERR_C=\
431 "..\h\antlr.h"\
432 "..\h\ast.h"\
433 "..\h\charbuf.h"\
434 "..\h\pcctscfg.h"\
435 "..\h\dlgdef.h"\
436 "..\h\err.h"\
437 "..\support\set\set.h"\
438 ".\hash.h"\
439 ".\sor.h"\
440 ".\tokens.h"\
441
442
443 !IF "$(CFG)" == "Sorcerer - Win32 Release"
444
445
446 "$(INTDIR)\err.obj" : $(SOURCE) $(DEP_CPP_ERR_C) "$(INTDIR)"
447
448
449 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
450
451
452 "$(INTDIR)\err.obj" "$(INTDIR)\err.sbr" : $(SOURCE) $(DEP_CPP_ERR_C)\
453 "$(INTDIR)"
454
455
456 !ENDIF
457
458 SOURCE=.\gen.c
459 DEP_CPP_GEN_C=\
460 "..\h\antlr.h"\
461 "..\h\ast.h"\
462 "..\h\charbuf.h"\
463 "..\h\pcctscfg.h"\
464 "..\h\dlgdef.h"\
465 "..\support\set\set.h"\
466 ".\hash.h"\
467 ".\mode.h"\
468 ".\proto.h"\
469 ".\sor.h"\
470 ".\stdpccts.h"\
471 ".\sym.h"\
472 ".\tokens.h"\
473
474
475 !IF "$(CFG)" == "Sorcerer - Win32 Release"
476
477
478 "$(INTDIR)\gen.obj" : $(SOURCE) $(DEP_CPP_GEN_C) "$(INTDIR)"\
479 "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
480
481
482 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
483
484
485 "$(INTDIR)\gen.obj" "$(INTDIR)\gen.sbr" : $(SOURCE) $(DEP_CPP_GEN_C)\
486 "$(INTDIR)" "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
487
488
489 !ENDIF
490
491 SOURCE=.\globals.c
492 DEP_CPP_GLOBA=\
493 "..\h\antlr.h"\
494 "..\h\ast.h"\
495 "..\h\charbuf.h"\
496 "..\h\pcctscfg.h"\
497 "..\h\dlgdef.h"\
498 "..\support\set\set.h"\
499 ".\hash.h"\
500 ".\mode.h"\
501 ".\sor.h"\
502 ".\stdpccts.h"\
503 ".\tokens.h"\
504
505
506 !IF "$(CFG)" == "Sorcerer - Win32 Release"
507
508
509 "$(INTDIR)\globals.obj" : $(SOURCE) $(DEP_CPP_GLOBA) "$(INTDIR)"\
510 "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
511
512
513 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
514
515
516 "$(INTDIR)\globals.obj" "$(INTDIR)\globals.sbr" : $(SOURCE) $(DEP_CPP_GLOBA)\
517 "$(INTDIR)" "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
518
519
520 !ENDIF
521
522 SOURCE=.\hash.c
523 DEP_CPP_HASH_=\
524 ".\hash.h"\
525
526
527 !IF "$(CFG)" == "Sorcerer - Win32 Release"
528
529
530 "$(INTDIR)\hash.obj" : $(SOURCE) $(DEP_CPP_HASH_) "$(INTDIR)"
531
532
533 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
534
535
536 "$(INTDIR)\hash.obj" "$(INTDIR)\hash.sbr" : $(SOURCE) $(DEP_CPP_HASH_)\
537 "$(INTDIR)"
538
539
540 !ENDIF
541
542 SOURCE=.\look.c
543 DEP_CPP_LOOK_=\
544 "..\h\antlr.h"\
545 "..\h\ast.h"\
546 "..\h\charbuf.h"\
547 "..\h\pcctscfg.h"\
548 "..\h\dlgdef.h"\
549 "..\support\set\set.h"\
550 ".\hash.h"\
551 ".\mode.h"\
552 ".\proto.h"\
553 ".\sor.h"\
554 ".\stdpccts.h"\
555 ".\sym.h"\
556 ".\tokens.h"\
557
558
559 !IF "$(CFG)" == "Sorcerer - Win32 Release"
560
561
562 "$(INTDIR)\look.obj" : $(SOURCE) $(DEP_CPP_LOOK_) "$(INTDIR)"\
563 "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
564
565
566 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
567
568
569 "$(INTDIR)\look.obj" "$(INTDIR)\look.sbr" : $(SOURCE) $(DEP_CPP_LOOK_)\
570 "$(INTDIR)" "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
571
572
573 !ENDIF
574
575 SOURCE=.\main.c
576 DEP_CPP_MAIN_=\
577 "..\h\antlr.h"\
578 "..\h\ast.h"\
579 "..\h\charbuf.h"\
580 "..\h\pcctscfg.h"\
581 "..\h\dlgdef.h"\
582 "..\support\set\set.h"\
583 ".\hash.h"\
584 ".\mode.h"\
585 ".\proto.h"\
586 ".\sor.h"\
587 ".\stdpccts.h"\
588 ".\sym.h"\
589 ".\tokens.h"\
590
591
592 !IF "$(CFG)" == "Sorcerer - Win32 Release"
593
594
595 "$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"\
596 "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
597
598
599 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
600
601
602 "$(INTDIR)\main.obj" "$(INTDIR)\main.sbr" : $(SOURCE) $(DEP_CPP_MAIN_)\
603 "$(INTDIR)" "$(INTDIR)\stdpccts.h" "$(INTDIR)\mode.h"
604
605
606 !ENDIF
607
608 SOURCE=.\scan.c
609 DEP_CPP_SCAN_=\
610 "..\h\antlr.h"\
611 "..\h\ast.h"\
612 "..\h\charbuf.h"\
613 "..\h\pcctscfg.h"\
614 "..\h\dlgauto.h"\
615 "..\h\dlgdef.h"\
616 "..\support\set\set.h"\
617 ".\hash.h"\
618 ".\mode.h"\
619 ".\proto.h"\
620 ".\sor.h"\
621 ".\sym.h"\
622 ".\tokens.h"\
623
624
625 !IF "$(CFG)" == "Sorcerer - Win32 Release"
626
627
628 "$(INTDIR)\scan.obj" : $(SOURCE) $(DEP_CPP_SCAN_) "$(INTDIR)"\
629 "$(INTDIR)\mode.h"
630
631
632 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
633
634
635 "$(INTDIR)\scan.obj" "$(INTDIR)\scan.sbr" : $(SOURCE) $(DEP_CPP_SCAN_)\
636 "$(INTDIR)" "$(INTDIR)\mode.h"
637
638
639 !ENDIF
640
641 SOURCE=..\support\set\set.c
642 DEP_CPP_SET_C=\
643 "..\h\pcctscfg.h"\
644 "..\support\set\set.h"\
645
646
647 !IF "$(CFG)" == "Sorcerer - Win32 Release"
648
649
650 "$(INTDIR)\set.obj" : $(SOURCE) $(DEP_CPP_SET_C) "$(INTDIR)"
651 $(CPP) $(CPP_PROJ) $(SOURCE)
652
653
654 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
655
656
657 "$(INTDIR)\set.obj" "$(INTDIR)\set.sbr" : $(SOURCE) $(DEP_CPP_SET_C)\
658 "$(INTDIR)"
659 $(CPP) $(CPP_PROJ) $(SOURCE)
660
661
662 !ENDIF
663
664 SOURCE=.\sor.c
665 DEP_CPP_SOR_C=\
666 "..\h\antlr.h"\
667 "..\h\ast.c"\
668 "..\h\ast.h"\
669 "..\h\charbuf.h"\
670 "..\h\pcctscfg.h"\
671 "..\h\dlgdef.h"\
672 "..\support\set\set.h"\
673 ".\hash.h"\
674 ".\mode.h"\
675 ".\proto.h"\
676 ".\sor.h"\
677 ".\sym.h"\
678 ".\tokens.h"\
679
680
681 !IF "$(CFG)" == "Sorcerer - Win32 Release"
682
683
684 "$(INTDIR)\sor.obj" : $(SOURCE) $(DEP_CPP_SOR_C) "$(INTDIR)" "$(INTDIR)\mode.h"
685
686
687 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
688
689
690 "$(INTDIR)\sor.obj" "$(INTDIR)\sor.sbr" : $(SOURCE) $(DEP_CPP_SOR_C)\
691 "$(INTDIR)" "$(INTDIR)\mode.h"
692
693
694 !ENDIF
695
696 SOURCE=.\sor.g
697
698 !IF "$(CFG)" == "Sorcerer - Win32 Release"
699
700 InputPath=.\sor.g
701 InputName=sor
702
703 "parser.dlg" "mode.h" "stdpccts.h" "sor.c" "scan.c" "err.c" : $(SOURCE)\
704 "$(INTDIR)" "$(OUTDIR)"
705 ..\bin\Win32\antlr -gh -k 2 -gt $(InputName).g
706 ..\bin\Win32\dlg -C2 parser.dlg scan.c
707
708
709 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
710
711 InputPath=.\sor.g
712 InputName=sor
713
714 "parser.dlg" "mode.h" "stdpccts.h" "sor.c" "scan.c" "err.c" : $(SOURCE)\
715 "$(INTDIR)" "$(OUTDIR)"
716 ..\bin\Win32\antlr -gh -k 2 -gt $(InputName).g
717 ..\bin\Win32\dlg -C2 parser.dlg scan.c
718
719
720 !ENDIF
721
722
723 !ENDIF
724
+0
-205
contrib/pccts/sorcerer/SorcererMSVC60.dsp less more
0 # Microsoft Developer Studio Project File - Name="Sorcerer" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 6.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Console Application" 0x0103
5
6 CFG=Sorcerer - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "SorcererMSVC60.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "SorcererMSVC60.mak" CFG="Sorcerer - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "Sorcerer - Win32 Release" (based on "Win32 (x86) Console Application")
20 !MESSAGE "Sorcerer - Win32 Debug" (based on "Win32 (x86) Console Application")
21 !MESSAGE
22
23 # Begin Project
24 # PROP AllowPerConfigDependencies 0
25 # PROP Scc_ProjName "SorcererMSVC60"
26 # PROP Scc_LocalPath ".."
27 CPP=cl.exe
28 RSC=rc.exe
29
30 !IF "$(CFG)" == "Sorcerer - Win32 Release"
31
32 # PROP BASE Use_MFC 0
33 # PROP BASE Use_Debug_Libraries 0
34 # PROP BASE Output_Dir "Release"
35 # PROP BASE Intermediate_Dir "Release"
36 # PROP BASE Target_Dir ""
37 # PROP Use_MFC 0
38 # PROP Use_Debug_Libraries 0
39 # PROP Output_Dir "."
40 # PROP Intermediate_Dir "."
41 # PROP Ignore_Export_Lib 0
42 # PROP Target_Dir ""
43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
44 # ADD CPP /nologo /W3 /O2 /I "." /I "..\h" /I "..\support\set" /D "__STDC__" /D "NDEBUG" /D "LONGFILENAMES" /D "PC" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c
45 # SUBTRACT CPP /YX
46 # ADD BASE RSC /l 0x409 /d "NDEBUG"
47 # ADD RSC /l 0x409 /d "NDEBUG"
48 BSC32=bscmake.exe
49 # ADD BASE BSC32 /nologo
50 # ADD BSC32 /nologo
51 LINK32=link.exe
52 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
53 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"./Sorcerer.exe"
54 # Begin Special Build Tool
55 SOURCE="$(InputPath)"
56 PostBuild_Desc=Update executables in BIN directory
57 PostBuild_Cmds=rename ..\bin\Sorcerer.exe Sorcerer_old.exe copy ..\Sorcerer\Sorcerer.exe ..\bin\
58 # End Special Build Tool
59
60 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
61
62 # PROP BASE Use_MFC 0
63 # PROP BASE Use_Debug_Libraries 1
64 # PROP BASE Output_Dir "Debug"
65 # PROP BASE Intermediate_Dir "Debug"
66 # PROP BASE Target_Dir ""
67 # PROP Use_MFC 0
68 # PROP Use_Debug_Libraries 1
69 # PROP Output_Dir "."
70 # PROP Intermediate_Dir "."
71 # PROP Ignore_Export_Lib 0
72 # PROP Target_Dir ""
73 # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
74 # ADD CPP /nologo /W3 /Gm /ZI /Od /I "." /I "..\h" /I "..\support\set" /D "__STDC__" /D "LONGFILENAMES" /D "PC" /D ZZLEXBUFSIZE=65536 /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /FD /c
75 # SUBTRACT CPP /YX
76 # ADD BASE RSC /l 0x409 /d "_DEBUG"
77 # ADD RSC /l 0x409 /d "_DEBUG"
78 BSC32=bscmake.exe
79 # ADD BASE BSC32 /nologo
80 # ADD BSC32 /nologo
81 LINK32=link.exe
82 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
83 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"./Sorcerer.exe" /pdbtype:sept
84 # Begin Special Build Tool
85 SOURCE="$(InputPath)"
86 PostBuild_Desc=Update executables in BIN directory
87 PostBuild_Cmds=rename ..\bin\Sorcerer.exe Sorcerer_old.exe copy ..\Sorcerer\Sorcerer.exe ..\bin\
88 # End Special Build Tool
89
90 !ENDIF
91
92 # Begin Target
93
94 # Name "Sorcerer - Win32 Release"
95 # Name "Sorcerer - Win32 Debug"
96 # Begin Source File
97
98 SOURCE=.\cpp.c
99 # End Source File
100 # Begin Source File
101
102 SOURCE=.\err.c
103 # End Source File
104 # Begin Source File
105
106 SOURCE=.\gen.c
107 # End Source File
108 # Begin Source File
109
110 SOURCE=.\globals.c
111 # End Source File
112 # Begin Source File
113
114 SOURCE=.\hash.c
115 # End Source File
116 # Begin Source File
117
118 SOURCE=.\look.c
119 # End Source File
120 # Begin Source File
121
122 SOURCE=.\main.c
123 # End Source File
124 # Begin Source File
125
126 SOURCE=.\scan.c
127 # End Source File
128 # Begin Source File
129
130 SOURCE=..\support\set\set.c
131 # End Source File
132 # Begin Source File
133
134 SOURCE=.\sor.c
135 # End Source File
136 # Begin Source File
137
138 SOURCE=.\sor.g
139
140 !IF "$(CFG)" == "Sorcerer - Win32 Release"
141
142 # Begin Custom Build - Generating Parser
143 InputPath=.\sor.g
144 InputName=sor
145
146 BuildCmds= \
147 ..\bin\antlr -gh -k 2 -gt $(InputName).g \
148 ..\bin\dlg -C2 parser.dlg scan.c \
149
150
151 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
152 $(BuildCmds)
153
154 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
155 $(BuildCmds)
156
157 "stdpccts.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
158 $(BuildCmds)
159
160 "sor.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
161 $(BuildCmds)
162
163 "scan.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
164 $(BuildCmds)
165
166 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
167 $(BuildCmds)
168 # End Custom Build
169
170 !ELSEIF "$(CFG)" == "Sorcerer - Win32 Debug"
171
172 # Begin Custom Build - Generating Parser
173 InputPath=.\sor.g
174 InputName=sor
175
176 BuildCmds= \
177 ..\bin\antlr -gh -k 2 -gt $(InputName).g \
178 ..\bin\dlg -C2 parser.dlg scan.c \
179
180
181 "parser.dlg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
182 $(BuildCmds)
183
184 "mode.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
185 $(BuildCmds)
186
187 "stdpccts.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
188 $(BuildCmds)
189
190 "sor.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
191 $(BuildCmds)
192
193 "scan.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
194 $(BuildCmds)
195
196 "err.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
197 $(BuildCmds)
198 # End Custom Build
199
200 !ENDIF
201
202 # End Source File
203 # End Target
204 # End Project
+0
-33
contrib/pccts/sorcerer/SorcererMSVC60.dsw less more
0 Microsoft Developer Studio Workspace File, Format Version 6.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "Sorcerer"=.\SorcererMSVC60.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 begin source code control
10 SorcererMSVC60
11 ..
12 end source code control
13 }}}
14
15 Package=<4>
16 {{{
17 }}}
18
19 ###############################################################################
20
21 Global:
22
23 Package=<5>
24 {{{
25 }}}
26
27 Package=<3>
28 {{{
29 }}}
30
31 ###############################################################################
32
+0
-153
contrib/pccts/sorcerer/UPDATES less more
0 1.00B1 Fixes:
1 Missing includes from antlr.h
2
3 1.00B2 Fixes:
4 Didn't save _t during (...)?
5
6 1.00B3 Fixes:
7 Fixed bug that wouldn't allow labels on wildcard nodes
8 Would dump argument list to some labelled rule refs
9 Fixed code gen bug with #(. B) as last element of production
10
11 1.00B4 Fixes:
12 Another teeny-weeny little code gen fix related to "rule > [result]"
13
14 1.00B5 Fixes:
15 Made tar file create a root directory called sorcerer
16 Line 465 in gen.c had an 'stdout' where an 'output' was needed.
17
18 1.00B6 Fixes:
19 K&R function headers were missing a ',' in the argument list
20 Made the default prototype style the same as how you compiled SORCERER itself.
21
22 1.00B7
23 Rik Faith <faith@cs.unc.edu>:
24 [...] patch fixes a bug in sorcerer where the "actions" in the
25 input file which appeared between the second set of << >>'s (i.e.,
26 the user's main routine) would format poorly in the output file.
27
28 1.00B8:
29 changed the STreeTry() macro (it's much better now)
30 added -transform option (double pointers now needed in tree structure)
31 added ``!'' operator to indicate what is not to be included in tree copy
32 from input to output tree in transform mode.
33 Added _result parameter for transform mode
34 Changed sorcerer.c to errsupport.c; sorcerer.c is now regular support code.
35 function sorcerer_panic() was added
36 Added all of the libraries for tree rewrite support
37 (ast.c slist.c sint.c hash.c sstack.c)
38 Added a very cool function ast_scan(); check it out
39 Added @-variables; e.g., @(int i = 3) ... @i = 4;
40 Added __USE_PROTOS definition in sorcerer.h
41 SORCERER now reads the config.h file used by ANTLR/DLG.
42 Uses ast_right(rw) and ast_down(rw) so C/C++ compatible -- also means
43 C/C++ can have different tree layout and use these as functions to
44 simulate child-sibling trees.
45 Fixed: Bad error messages:
46 a : A | (b)? b;
47 b : B;
48 error: infinite recursion from rule a to rule b
49 Fixed a bug:
50 Sorcerer a simple tree-parser generator Version 1.00B3 1992-1994
51 warning: missing #header statement
52 test.t, line 3: warning: (...)? predicate in block with one alternative; will genera!
53 bash$ more test.t
54 expr: ;
55
56 variable:
57 #( VARIABLE
58 ID
59 ( DOT ID
60 | UPARROW
61 | LBRACK
62 expr
63 ( COMMA expr
64 )*
65 RBRACK
66 | COLON_COLON ID
67 )*
68 )
69 ;
70
71 1.00B9:
72 Fixed support/ast.c so K&R C would compile it.
73
74 1.00B13:
75 Totally new, cool, simple tree rewriting mechanism. Not many bug fixes
76
77 Made enum def ignore #ifdef #else #endif etc... in #tokdefs
78
79 Added C++ support
80
81 Made h and lib directory
82
83 Changed name: AST_NONTRANSFORM_FIELDS -> AST_REQD_FIELDS
84
85 -def-tokens and -proto-file are not valid in C++ mode.
86
87 Changed name: AST -> SORAST in C and C++.
88
89 When you -def-tokens, it generates them ast consts inside class def.
90 Ref with classname::def.
91
92 All #[] constructor calls must be done in class A { ... } def of grammar
93 so it knows which to call. Else, put Classname:: on front manually.
94
95 1.00B14
96
97 [Not completed yet]
98
99 #label -> label; #label is no longer valid. Just use label to access
100 output node in transform mode. label_in is the input node (for token
101 references only).
102
103 ast_node, ast_dup -> shallowCopy() (user must define for transform
104 mode), deepCopy().
105
106 Fixed the C support functions for ASTs
107
108 #[] -> new SORAST
109
110 token() -> type() (sorry, but had to make more consistent)
111 setToken() -> setType() (you can just add type() { token(); } if you want).
112
113 Remove guessing gate on actions if no (...)?
114
115 Wildcard as root of tree made SOR bomb
116
117 All the token field refs in PCCTSAST.C -> type()
118
119 ASTBase::double_link didn't check for NULL pointers.
120
121 #if in action caused trouble.
122
123 made action buffer bigger (8k bytes)
124
125 SORCERER had a bug in that it did not update the tree result before
126 returning sometimes.
127
128 PCCTS_AST::ast_scan() is now non-virtual
129
130 C++ support functions like tail(), bottom(), etc... now use 'this'
131 pointer rather a passed argument.
132
133 Sorcerer spun when it found identifier+ instead of (identifier)+ in a
134 tree rule.
135
136 This version corresponds pretty to the state of the book.
137
138 1.00B15
139
140 All .C files are changed to .cpp.
141
142 ASTBase::dup() and ASTDoublyLinkedBase::dup() now call shallowCopy()
143 to actually duplicate a node. shallowCopy() can either call a copy
144 constructor or can just duplicate things right there.
145
146 C++ keyword "template" was used as a variable in some SORCERER files.
147
148 1.00b20 (2-Oct-1998)
149
150 Minor changes as reported in CHANGES_FROM_1.33 of the main pccts
151 distribution kit. Main reason for change in version number is to
152 indicate that it matches the new release of pccts 1.33MR15.
+0
-153
contrib/pccts/sorcerer/cpp.c less more
0 /*
1 * cpp.c -- support for generating C++ output
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-2001
27 */
28 #include "stdpccts.h"
29 #include "sym.h"
30 #include "pcctscfg.h"
31 #include "proto.h"
32
33 void GenCPPClassHeader()
34 {
35 FILE *Parser_h;
36 char CPPParser_h_Name[MaxFileName+1];
37
38 strcpy(CPPParser_h_Name, CurClassName);
39 strcat(CPPParser_h_Name, ".h");
40 Parser_h = fopen(OutMetaName(CPPParser_h_Name), "w");
41 require(Parser_h != NULL, "can't open parser.h file");
42 #ifdef SPECIAL_FOPEN
43 special_fopen_actions(OutMetaName(CPPParser_h_Name));
44 #endif
45
46 /* Put a gate on the header file */
47 fprintf(Parser_h, "#ifndef %s_h\n", CurClassName);
48 fprintf(Parser_h, "#define %s_h\n", CurClassName);
49
50 gen_info_hdr(Parser_h);
51
52 fprintf(Parser_h, "#include \"%s\"\n", STPARSER_H);
53
54 if ( header_action!=NULL )
55 dumpAction(header_action, Parser_h, 0, -1, 0, 1);
56
57 fprintf(Parser_h, "\n");
58 fprintf(Parser_h, "class %s : public STreeParser {\n", CurClassName);
59 fprintf(Parser_h, "protected:\n");
60 /* Define @-vars in class */
61 if ( AllRefVars!=NULL )
62 {
63 ListNode *p;
64 for (p = AllRefVars->next; p!=NULL; p=p->next)
65 {
66 RefVarRec *r = (RefVarRec *)p->elem;
67 fprintf(Parser_h, "\t%s;\n", r->decl);
68 }
69 }
70 /* Generate list of tokens if demanded */
71 if ( def_tokens )
72 {
73 ListNode *p;
74 fprintf(Parser_h, "public:\n");
75 fprintf(Parser_h, "\tenum STokenType {\n");
76 for (p = token_list->next; p!=NULL; p=p->next)
77 {
78 SymEntry *t = (SymEntry *) p->elem;
79 fprintf(Parser_h,
80 "\t\t%s=%d", t->str, t->token_type);
81 if ( p->next!=NULL ) fprintf(Parser_h, ",\n");
82 else fprintf(Parser_h, "\n");
83 }
84 fprintf(Parser_h, "\t};\n");
85 }
86 fprintf(Parser_h, "public:\n");
87 if (NoCtor) { /* MR23 */
88 fprintf(Parser_h, "#if 0\n");
89 fprintf(Parser_h, "\t// The default ctor has been suppressed\n\t// by the -noctor option.\n\n");
90 }
91 fprintf(Parser_h, " %s();\n", CurClassName);
92 if (NoCtor) { /* MR23 */
93 fprintf(Parser_h, "#endif\n");
94 }
95 /* fprintf(Parser_h, " virtual AST *ast_node(int, char *) {return NULL;}\n");*/
96 fprintf(Parser_h, "\n");
97 GenRulePrototypes( Parser_h, 1 );
98
99 if ( class_actions != NULL )
100 {
101 ListNode *p;
102 for (p = class_actions->next; p!=NULL; p=p->next)
103 dumpAction( (char *)p->elem, output, 1, -1, 0, 1);
104 }
105
106 fprintf(Parser_h, "};\n");
107
108 fprintf(Parser_h, "\n#endif /* %s_h */\n", CurClassName);
109 fclose(Parser_h);
110 }
111
112 void GenCPPClassCode()
113 {
114 FILE *Parser_c;
115 char CPPParser_C_Name[MaxFileName+1];
116
117 strcpy(CPPParser_C_Name, CurClassName);
118 strcat(CPPParser_C_Name, CPP_FILE_SUFFIX);
119 ensure_no_C_file_collisions(CPPParser_C_Name);
120 Parser_c = fopen(OutMetaName(CPPParser_C_Name), "w");
121 require(Parser_c != NULL, "can't open class Parserx.c file");
122 #ifdef SPECIAL_FOPEN
123 special_fopen_actions(OutMetaName(CPPParser_C_Name));
124 #endif
125
126 gen_info_hdr(Parser_c);
127 fprintf(Parser_c, "#include \"%s.h\"\n\n", CurClassName);
128
129 if (NoCtor) { /* MR23 */
130 fprintf(Parser_c, "#if 0\n\n");
131 fprintf(Parser_c, "\t// The default ctor has been suppressed\n\t// by the -noctor option.\n\n");
132 }
133
134 /* Build constructor (init @-vars) */
135 fprintf(Parser_c, "%s::%s()\n{\n", CurClassName, CurClassName);
136 if ( AllRefVars!=NULL )
137 {
138 ListNode *p;
139 for (p = AllRefVars->next; p!=NULL; p=p->next)
140 {
141 RefVarRec *r = (RefVarRec *)p->elem;
142 if ( r->init[0]!='\0' )
143 fprintf(Parser_c, "\t%s=%s;\n", r->var, r->init);
144 }
145 }
146 fprintf(Parser_c, "}\n\n");
147
148 if (NoCtor) { /* MR23 */
149 fprintf(Parser_c, "#endif\n\n");
150 }
151 fclose(Parser_c);
152 }
+0
-386
contrib/pccts/sorcerer/err.c less more
0 /*
1 * A n t l r S e t s / E r r o r F i l e H e a d e r
2 *
3 * Generated from: sor.g
4 *
5 * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001
6 * Parr Research Corporation
7 * with Purdue University Electrical Engineering
8 * With AHPCRC, University of Minnesota
9 * ANTLR Version 1.33MR33
10 */
11
12 #define ANTLR_VERSION 13333
13 #include "pcctscfg.h"
14 #include "pccts_stdio.h"
15
16 /* 23-Sep-97 thm Accomodate user who needs to redefine ZZLEXBUFSIZE */
17
18 #ifndef ZZLEXBUFSIZE
19 #define ZZLEXBUFSIZE 8000
20 #endif
21 #include "pcctscfg.h" /* MR20 G. Hobbelt __USE_PROTOS #define */
22 #include "charbuf.h"
23 #include "hash.h"
24 #include "set.h"
25 #include "sor.h"
26 #define AST_FIELDS \
27 int token; char text[MaxAtom+1], label[MaxRuleName+1]; \
28 char *action; /* if action node, here is ptr to it */ \
29 char in,out; \
30 char init_action; /* set if Action and 1st action of alt */ \
31 int file; int line; /* set for BLOCK, ALT, nonterm nodes */ \
32 int upper_range; /* only if T1..T2 found */ \
33 GLA *start_state; /* ptr into GLA for this block */ \
34 int no_copy; /* copy input ptr to output ptr? */ \
35 ListNode *refvars; /* any ref vars defined for this rule */ \
36 unsigned char is_root; /* this token is a root #( A ... ) */
37 #define zzcr_ast(node, cur, _tok, _text) \
38 {(node)->token=_tok; strncpy((node)->text, _text,MaxAtom);}
39 #define USER_ZZSYN
40 #define zzAST_DOUBLE
41 extern int define_num;
42 #define LL_K 2
43 #define zzSET_SIZE 16
44 #include "antlr.h"
45 #include "ast.h"
46 #include "tokens.h"
47 #include "dlgdef.h"
48 #include "err.h"
49
50 ANTLRChar *zztokens[118]={
51 /* 00 */ "Invalid",
52 /* 01 */ "Eof",
53 /* 02 */ "RExpr",
54 /* 03 */ "\\n|\\r|\\r\\n",
55 /* 04 */ "\\~[]",
56 /* 05 */ "~[\\n\\r\"\\]+",
57 /* 06 */ "\"",
58 /* 07 */ "\\n|\\r|\\r\\n",
59 /* 08 */ "\\~[]",
60 /* 09 */ "~[\\n\\r\"\\]+",
61 /* 10 */ "'",
62 /* 11 */ "\\n|\\r|\\r\\n",
63 /* 12 */ "\\~[]",
64 /* 13 */ "~[\\n\\r'\\]+",
65 /* 14 */ "\\*/",
66 /* 15 */ "\\*",
67 /* 16 */ "\\n|\\r|\\r\\n",
68 /* 17 */ "~[\\n\\r\\*]+",
69 /* 18 */ "\\n|\\r|\\r\\n",
70 /* 19 */ "~[\\n\\r]+",
71 /* 20 */ "\\n|\\r|\\r\\n",
72 /* 21 */ "~[\\n\\r]+",
73 /* 22 */ "\\*/",
74 /* 23 */ "\\*",
75 /* 24 */ "\\n|\\r|\\r\\n",
76 /* 25 */ "~[\\n\\r\\*]+",
77 /* 26 */ "~[\\)]+ \\)",
78 /* 27 */ "Action",
79 /* 28 */ "PassAction",
80 /* 29 */ "\\n|\\r|\\r\\n",
81 /* 30 */ "\\>",
82 /* 31 */ "#[_a-zA-Z][_a-zA-Z0-9]*",
83 /* 32 */ "#\\[\\]",
84 /* 33 */ "#\\(\\)",
85 /* 34 */ "#\\[",
86 /* 35 */ "#\\(",
87 /* 36 */ "#",
88 /* 37 */ "\\)",
89 /* 38 */ "\\[",
90 /* 39 */ "\\(",
91 /* 40 */ "\\\\]",
92 /* 41 */ "\\\\)",
93 /* 42 */ "\\>",
94 /* 43 */ "'",
95 /* 44 */ "\"",
96 /* 45 */ "\\#",
97 /* 46 */ "\\~[\\]\\)>#]",
98 /* 47 */ "/",
99 /* 48 */ "/\\*",
100 /* 49 */ "\\*/",
101 /* 50 */ "//",
102 /* 51 */ "\\@\\(",
103 /* 52 */ "\\@",
104 /* 53 */ "[a-zA-Z_]+\\(",
105 /* 54 */ "[a-zA-Z_]+",
106 /* 55 */ "~[a-zA-Z_\\n\\r\\)\\(\\#\\>\\]\\[\"'/\\@]+",
107 /* 56 */ "[\\t\\ ]+",
108 /* 57 */ "\\n|\\r|\\n\\r",
109 /* 58 */ "\\[",
110 /* 59 */ "\\<\\<",
111 /* 60 */ "\"",
112 /* 61 */ "/\\*",
113 /* 62 */ "\\*/",
114 /* 63 */ "//",
115 /* 64 */ "\\>\\>",
116 /* 65 */ "Header",
117 /* 66 */ "Tokdef",
118 /* 67 */ "BLOCK",
119 /* 68 */ "ALT",
120 /* 69 */ "LABEL",
121 /* 70 */ "OPT",
122 /* 71 */ "POS_CLOSURE",
123 /* 72 */ "CLOSURE",
124 /* 73 */ "WILD",
125 /* 74 */ "PRED_OP",
126 /* 75 */ "BT",
127 /* 76 */ "RULE",
128 /* 77 */ "REFVAR",
129 /* 78 */ "atomic-element",
130 /* 79 */ "rule-header",
131 /* 80 */ "\\}",
132 /* 81 */ "class",
133 /* 82 */ "NonTerm",
134 /* 83 */ "Token",
135 /* 84 */ "!",
136 /* 85 */ "\\<",
137 /* 86 */ "\\>",
138 /* 87 */ ";",
139 /* 88 */ "\\|",
140 /* 89 */ "\\(",
141 /* 90 */ "\\)",
142 /* 91 */ "..",
143 /* 92 */ "#[A-Za-z0-9_]*",
144 /* 93 */ "\\*/",
145 /* 94 */ "\\*",
146 /* 95 */ "\\n|\\r|\\r\\n",
147 /* 96 */ "~[\\n\\r\\*]+",
148 /* 97 */ "\\n|\\r|\\r\\n",
149 /* 98 */ "~[\\n\\r]+",
150 /* 99 */ "[\\t\\ ]+",
151 /* 100 */ "\\n|\\r|\\r\\n",
152 /* 101 */ "//",
153 /* 102 */ "/\\*",
154 /* 103 */ "#ifndef",
155 /* 104 */ "#ifdef",
156 /* 105 */ "#else",
157 /* 106 */ "#define",
158 /* 107 */ "#endif",
159 /* 108 */ "ID",
160 /* 109 */ "INT",
161 /* 110 */ "enum",
162 /* 111 */ "\\{",
163 /* 112 */ "=",
164 /* 113 */ ",",
165 /* 114 */ "DLGminToken",
166 /* 115 */ "DLGmaxToken",
167 /* 116 */ "\\}",
168 /* 117 */ ";"
169 };
170 SetWordType zzerr1[16] = {0x2,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x0,0x0,0x7,0x0,
171 0x0,0x0,0x0,0x0};
172 SetWordType zzerr2[16] = {0x2,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x0,0x0,0x1,0x0,
173 0x0,0x0,0x0,0x0};
174 SetWordType setwd1[118] = {0x0,0xfe,0x0,0x0,0x0,0x0,0x0,
175 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
176 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
177 0x0,0x0,0x0,0x0,0xbe,0x0,0x0,0x0,
178 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
179 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
180 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
181 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
182 0x0,0x0,0x81,0x81,0x0,0x0,0x0,0x0,
183 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
184 0x0,0x9e,0x82,0x8e,0x0,0x0,0x0,0x0,
185 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
186 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
187 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
188 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
189 SetWordType zzerr3[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0xc,0x0,
190 0x0,0x0,0x0,0x0};
191 SetWordType zzerr4[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x80,0x10,0x0,
192 0x0,0x0,0x0,0x0};
193 SetWordType zzerr5[16] = {0x0,0x0,0x0,0x10, 0x0,0x0,0x0,0x0, 0x0,0x0,0x20,0x0,
194 0x0,0x0,0x0,0x0};
195 SetWordType zzerr6[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x80,0x0,0x0,
196 0x0,0x0,0x0,0x0};
197 SetWordType zzerr7[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x20,0x0,0x40,0x0,
198 0x0,0x0,0x0,0x0};
199 SetWordType zzerr8[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x91,0x7,
200 0x0,0x0,0x0,0x0};
201 SetWordType setwd2[118] = {0x0,0x23,0x0,0x0,0x0,0x0,0x0,
202 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
203 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
204 0x0,0x0,0x0,0x0,0xa3,0xc,0x0,0x0,
205 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
206 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
207 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
208 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
209 0x0,0x0,0x1,0x1,0x0,0x0,0x14,0x80,
210 0x0,0x0,0x80,0x0,0x80,0x0,0x0,0x0,
211 0x0,0xe3,0x1,0xa3,0x80,0x0,0xc,0x14,
212 0xc0,0x80,0x80,0xc0,0x0,0x0,0x0,0x0,
213 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
214 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
215 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
216 SetWordType zzerr9[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x81,0x7,
217 0x0,0x0,0x0,0x0};
218 SetWordType zzerr10[16] = {0x2,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0xc0,0xcd,0x91,0xf,
219 0x0,0x0,0x0,0x0};
220 SetWordType zzerr11[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x81,0x7,
221 0x0,0x0,0x0,0x0};
222 SetWordType zzerr12[16] = {0x0,0x0,0x0,0x18, 0x0,0x0,0x0,0x0, 0x40,0x48,0xf1,0x7,
223 0x0,0x0,0x0,0x0};
224 SetWordType zzerr13[16] = {0x0,0x0,0x0,0x10, 0x0,0x0,0x0,0x0, 0x0,0x0,0x20,0x0,
225 0x0,0x0,0x0,0x0};
226 SetWordType setwd3[118] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,
227 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
228 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
229 0x0,0x0,0x0,0x0,0x4d,0xc8,0x0,0x0,
230 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
231 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
232 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
233 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
234 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4d,
235 0x0,0x0,0x4d,0x8,0x49,0x0,0x0,0x0,
236 0x0,0x78,0x0,0x4f,0x4f,0x8,0xc8,0x48,
237 0x78,0x78,0x4d,0x78,0x8,0x0,0x0,0x0,
238 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
239 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
240 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
241 SetWordType zzerr14[16] = {0x0,0x0,0x0,0x18, 0x0,0x0,0x0,0x0, 0x40,0x48,0xe1,0x7,
242 0x0,0x0,0x0,0x0};
243 SetWordType zzerr15[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0xc1,0x7,
244 0x0,0x0,0x0,0x0};
245 SetWordType zzerr16[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x4c,0x81,0x7,
246 0x0,0x0,0x0,0x0};
247 SetWordType zzerr17[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0xc0,0x4d,0x81,0x7,
248 0x0,0x0,0x0,0x0};
249 SetWordType zzerr18[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x91,0x7,
250 0x0,0x0,0x0,0x0};
251 SetWordType zzerr19[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x40,0x0,0x2,
252 0x0,0x0,0x0,0x0};
253 SetWordType zzerr20[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0xc,0x0,
254 0x0,0x0,0x0,0x0};
255 SetWordType zzerr21[16] = {0x0,0x0,0x0,0x18, 0x0,0x0,0x0,0x0, 0x40,0x48,0xf1,0x7,
256 0x0,0x0,0x0,0x0};
257 SetWordType zzerr22[16] = {0x0,0x0,0x0,0x10, 0x0,0x0,0x0,0x0, 0x0,0x0,0x20,0x0,
258 0x0,0x0,0x0,0x0};
259 SetWordType setwd4[118] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,
260 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
261 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
262 0x0,0x0,0x0,0x0,0x7f,0xc0,0x0,0x0,
263 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
264 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
265 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
266 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
267 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f,
268 0x0,0x0,0x7f,0x0,0x7f,0x0,0x0,0x0,
269 0x0,0x7f,0x0,0x7f,0x7f,0x0,0xc0,0x41,
270 0x7f,0x7f,0x7f,0x7f,0x0,0x0,0x0,0x0,
271 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
272 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
273 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
274 SetWordType zzerr23[16] = {0x0,0x0,0x0,0x18, 0x0,0x0,0x0,0x0, 0x40,0x48,0xe1,0x7,
275 0x0,0x0,0x0,0x0};
276 SetWordType zzerr24[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0xc1,0x7,
277 0x0,0x0,0x0,0x0};
278 SetWordType zzerr25[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x91,0x7,
279 0x0,0x0,0x0,0x0};
280 SetWordType zzerr26[16] = {0x2,0x0,0x0,0x18, 0x0,0x0,0x0,0x0, 0x40,0x8,0x81,0x7,
281 0x0,0x0,0x0,0x0};
282 SetWordType zzerr27[16] = {0x2,0x0,0x0,0x18, 0x0,0x0,0x0,0x0, 0x40,0x48,0x81,0x7,
283 0x0,0x0,0x0,0x0};
284 SetWordType zzerr28[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x91,0x7,
285 0x0,0x0,0x0,0x0};
286 SetWordType zzerr29[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x91,0xf,
287 0x0,0x0,0x0,0x0};
288 SetWordType setwd5[118] = {0x0,0x8,0x0,0x0,0x0,0x0,0x0,
289 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
290 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
291 0x0,0x0,0x0,0x0,0xff,0x8,0x0,0x0,
292 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
293 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
294 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
295 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
296 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,
297 0x0,0x0,0xf7,0x0,0xff,0x0,0x0,0x0,
298 0x0,0xff,0x0,0xf7,0xf7,0x0,0x0,0x1,
299 0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,
300 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
301 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
302 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
303 SetWordType zzerr30[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x10,0x6,
304 0x0,0x0,0x0,0x0};
305 SetWordType zzerr31[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x10,0xe,
306 0x0,0x0,0x0,0x0};
307 SetWordType zzerr32[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x10,0x6,
308 0x0,0x0,0x0,0x0};
309 SetWordType zzerr33[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0xc,0x0,
310 0x0,0x0,0x0,0x0};
311 SetWordType zzerr34[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x10,0x6,
312 0x0,0x0,0x0,0x0};
313 SetWordType zzerr35[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x10,0xe,
314 0x0,0x0,0x0,0x0};
315 SetWordType zzerr36[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x40,0x48,0x10,0x6,
316 0x0,0x0,0x0,0x0};
317 SetWordType zzerr37[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x2,0x8,0x0,
318 0x0,0x0,0x0,0x0};
319 SetWordType zzerr38[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x40,0x0,0x0,
320 0x0,0x0,0x0,0x0};
321 SetWordType zzerr39[16] = {0x0,0x0,0x0,0x8, 0x0,0x0,0x0,0x0, 0x60,0x48,0x10,0xe,
322 0x0,0x0,0x0,0x0};
323 SetWordType setwd6[118] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,
324 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
325 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
326 0x0,0x0,0x0,0x0,0xef,0x0,0x0,0x0,
327 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
328 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
329 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
330 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
331 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xef,
332 0x0,0x0,0xef,0x0,0xef,0x0,0x0,0x0,
333 0x0,0x0,0x0,0xff,0xff,0x1,0x0,0x0,
334 0x0,0x0,0xef,0xef,0x1,0x0,0x0,0x0,
335 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
336 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
337 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
338 SetWordType zzerr40[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
339 0x0,0x44,0x0,0x0};
340 SetWordType zzerr41[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
341 0x80,0x40,0x0,0x0};
342 SetWordType zzerr42[16] = {0x2,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
343 0x80,0x44,0x0,0x0};
344 SetWordType zzerr43[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
345 0x0,0x90,0x0,0x0};
346 SetWordType setwd7[118] = {0x0,0xc0,0x0,0x0,0x0,0x0,0x0,
347 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
348 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
349 0x0,0x0,0x0,0x0,0x1d,0x8,0x0,0x0,
350 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
351 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
352 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
353 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
354 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1d,
355 0x0,0x0,0x1d,0x8,0x19,0x0,0x0,0x0,
356 0x0,0x18,0x0,0x1f,0x1f,0x8,0x8,0x8,
357 0x10,0x18,0x1d,0x18,0x8,0x0,0x0,0x0,
358 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
359 0x20,0x0,0x0,0x0,0x0,0x0,0x0,0x20,
360 0x0,0x0,0x0,0x0,0x0,0x0,0x0};
361 SetWordType zzerr44[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
362 0x0,0x0,0x13,0x0};
363 SetWordType zzerr45[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
364 0x0,0x0,0x13,0x0};
365 SetWordType zzerr46[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
366 0x0,0x0,0x13,0x0};
367 SetWordType zzerr47[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
368 0x0,0x0,0x13,0x0};
369 SetWordType zzerr48[16] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,
370 0x0,0x10,0x1e,0x0};
371 SetWordType setwd8[118] = {0x0,0x20,0x0,0x0,0x0,0x0,0x0,
372 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
373 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
374 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
375 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
376 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
377 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
378 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
379 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
380 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
381 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
382 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
383 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
384 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20,
385 0x0,0x0,0x1f,0x0,0x0,0x1f,0x0};
+0
-1278
contrib/pccts/sorcerer/gen.c less more
0 /* Code generator for SORCERER
1 *
2 * Translate sorcerer rules (in intermediate trees) to C / C++
3 *
4 * SOFTWARE RIGHTS
5 *
6 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
7 * domain. An individual or company may do whatever they wish with
8 * source code distributed with SORCERER or the code generated by
9 * SORCERER, including the incorporation of SORCERER, or its output, into
10 * commerical software.
11 *
12 * We encourage users to develop software with SORCERER. However, we do
13 * ask that credit is given to us for developing SORCERER. By "credit",
14 * we mean that if you incorporate our source code into one of your
15 * programs (commercial product, research project, or otherwise) that you
16 * acknowledge this fact somewhere in the documentation, research report,
17 * etc... If you like SORCERER and have developed a nice tool with the
18 * output, please mention that you developed it using SORCERER. In
19 * addition, we ask that this header remain intact in our source code.
20 * As long as these guidelines are kept, we expect to continue enhancing
21 * this system and expect to make other tools available as they are
22 * completed.
23 *
24 * SORCERER 1.00B
25 * Terence Parr
26 * AHPCRC, University of Minnesota
27 * 1992-2001
28 *
29 * The latest (October 1994) transformation mode works as follows:
30 *
31 * o All elements set _tresult, a function-scoped var
32 * o All rules are passed the address of a SORAST ptr
33 * called '_result' that is set at the end of each
34 * alternative. The return tree is guaranteed to
35 * be complete only at this point.
36 * o Each alt AND #(...) tree have their own root (_r),
37 * sibling (_s) and tail/end pointers (_e). #(...) trees
38 * set _tresult just before exiting their scope. Hence,
39 * #(...) are just like elements--they set _tresult.
40 * o At the end of a rule, *_result is set to _tresult.
41 * o After each root node ref, a _mkroot(&_r,&_s,&_e,_tresult)
42 * is generated to set the pointers.
43 * o After each child node ref, a _mkchild(&_r,&_s,&_e,_tresult)
44 * is generated to set the pointers.
45 * o After each rule ref, a _mkroot(&_r,&_s,&_e,_tresult)
46 * is generated to set the pointers.
47 * o After each #(...) ref, a _mkroot(&_r,&_s,&_e,_tresult)
48 * is generated to set the pointers.
49 * o token references: gen a _tresult=ast_dup(_t);
50 * (only if labeled, however).
51 * o rules or alts with nocopy set don't construct trees.
52 */
53 #include "pcctscfg.h"
54 #include "stdpccts.h"
55 #include "sym.h"
56 #include "proto.h"
57
58 static int outfile = -1; /* added missing int def : ajb 11nov11 */
59 static char *current_rule;
60 static ListNode *labels_for_func = NULL;
61 static AST *whichRule;
62 static int tabs=0;
63 #define TAB {int i=1; for (;i<=tabs;i++) {putc('\t', output);}}
64
65 #define PastWhiteSpace(s) while (*(s) == ' ' || *(s) == '\t') {s++;}
66
67
68 static void
69 #ifdef __USE_PROTOS
70 go_down(int nl)
71 #else
72 go_down(nl)
73 int nl;
74 #endif
75 {
76 fprintf(output, "_DOWN;");
77 if ( nl ) fprintf(output, "\n");
78 }
79
80 static void
81 #ifdef __USE_PROTOS
82 go_right(int nl)
83 #else
84 go_right(nl)
85 int nl;
86 #endif
87 {
88 fprintf(output, "_RIGHT;");
89 if ( nl ) fprintf(output, "\n");
90 }
91
92 void
93 #ifdef __USE_PROTOS
94 gen_info_hdr( FILE *f )
95 #else
96 gen_info_hdr( f )
97 FILE *f;
98 #endif
99 {
100 fprintf(f, "/*\n");
101 fprintf(f, " * S O R C E R E R T r a n s l a t i o n H e a d e r\n");
102 fprintf(f, " *\n");
103 fprintf(f, " * SORCERER Developed by Terence Parr, Aaron Sawdey, & Gary Funck\n");
104 fprintf(f, " * Parr Research Corporation, Intrepid Technology, University of Minnesota\n");
105 fprintf(f, " * 1992-1994\n");
106 fprintf(f, " * SORCERER Version %s\n", VersionText);
107 fprintf(f, " */\n");
108 }
109
110 void
111 #ifdef __USE_PROTOS
112 gen_hdr_CPP( void )
113 #else
114 gen_hdr_CPP( )
115 #endif
116 {
117 char CPPParser_h_Name[MaxFileName+1];
118
119 gen_info_hdr(output);
120 fprintf(output, "#define SORCERER_VERSION\t%s\n", VersionNumber);
121 if ( transform ) fprintf(output, "#define SORCERER_TRANSFORM\n");
122 else fprintf(output, "#define SORCERER_NONTRANSFORM\n");
123 /* Don't gen header action here as it's in the ClassName.h
124 if ( header_action!=NULL )
125 dumpAction(header_action, output, 0, -1, 0, 1); */
126 fprintf(output, "#include \"%s\"\n", STPARSER_H);
127
128 if ( UserDefdTokens ) fprintf(output, "#include \"%s\"\n", tokdefs_file);
129 strcpy(CPPParser_h_Name, CurClassName);
130 strcat(CPPParser_h_Name, ".h");
131 fprintf(output, "#include \"%s\"\n", CPPParser_h_Name);
132 }
133
134 void
135 #ifdef __USE_PROTOS
136 gen_hdr_C( void )
137 #else
138 gen_hdr_C( )
139 #endif
140 {
141 if ( Inline ) return;
142 gen_info_hdr(output);
143 fprintf(output, "#define SORCERER_VERSION\t%s\n", VersionNumber);
144 if ( transform ) fprintf(output, "#define SORCERER_TRANSFORM\n");
145 else fprintf(output, "#define SORCERER_NONTRANSFORM\n");
146 fprintf(output, "#include \"pcctscfg.h\"\n");
147 fprintf(output, "#include <stdio.h>\n");
148 fprintf(output, "#include <setjmp.h>\n");
149 if ( Prefix[0]!='\0' )
150 {
151 fprintf(output, "/* rename error routines; used in macros, must use /lib/cpp */\n");
152 fprintf(output, "#define mismatched_token %smismatched_token\n", Prefix);
153 fprintf(output, "#define mismatched_range %smismatched_range\n", Prefix);
154 fprintf(output, "#define missing_wildcard %smissing_wildcard\n", Prefix);
155 fprintf(output, "#define no_viable_alt %sno_viable_alt\n", Prefix);
156 fprintf(output, "#define sorcerer_panic %ssorcerer_panic\n", Prefix);
157 }
158 if ( header_action!=NULL )
159 dumpAction(header_action, output, 0, -1, 0, 1);
160
161 /* make a #define for the STreeParser containing the ref vars */
162 if ( AllRefVars!=NULL )
163 {
164 ListNode *p;
165 fprintf(output, "#define _REFVARS \\\n");
166 for (p = AllRefVars->next; p!=NULL; p=p->next)
167 {
168 RefVarRec *r = (RefVarRec *)p->elem;
169 fprintf(output, "\t%s; \\\n", r->decl);
170 }
171 fprintf(output, "\n\n");
172 }
173
174 fprintf(output, "#include \"sorcerer.h\"\n");
175 if ( UserDefdTokens ) fprintf(output, "#include \"%s\"\n", tokdefs_file);
176 if ( GenProtoFile!=NULL ) fprintf(output, "#include \"%s\"\n", GenProtoFile);
177 else GenRulePrototypes( output, 0 );
178 if ( transform ) fprintf(output, "#include \"sorcerer.c\"\n");
179 }
180
181 void
182 #ifdef __USE_PROTOS
183 gen_hdr( void )
184 #else
185 gen_hdr( )
186 #endif
187 {
188 if ( GenCPP ) gen_hdr_CPP();
189 else gen_hdr_C();
190 }
191
192 void
193 #ifdef __USE_PROTOS
194 gen_hdr1( void )
195 #else
196 gen_hdr1( )
197 #endif
198 {
199 if ( !Inline )
200 {
201 gen_hdr();
202 }
203
204 if ( GenCPP )
205 {
206 /* fprintf(output, "#include \"%s\"\n", STREESUPPORT_C); */
207 }
208 else {
209 /* make a func to init the ref vars with inits */
210 fprintf(output, "\nvoid\n");
211 fprintf(output, "#ifdef __USE_PROTOS\n");
212 fprintf(output, "_refvar_inits(STreeParser *p)\n");
213 fprintf(output, "#else\n");
214 fprintf(output, "_refvar_inits(p)\n");
215 fprintf(output, "STreeParser *p;\n");
216 fprintf(output, "#endif\n");
217 fprintf(output, "{\n");
218 if ( AllRefVars!=NULL )
219 {
220 ListNode *p;
221 for (p = AllRefVars->next; p!=NULL; p=p->next)
222 {
223 RefVarRec *r = (RefVarRec *)p->elem;
224 if ( r->init[0]!='\0' )
225 fprintf(output, "\tp->%s=%s;\n", r->var, r->init);
226 }
227 }
228 fprintf(output, "}\n\n");
229 }
230
231 if ( before_actions != NULL )
232 {
233 ListNode *p;
234 for (p = before_actions->next; p!=NULL; p=p->next)
235 dumpAction( (char *)p->elem, output, 0, -1, 0, 1);
236 }
237 }
238
239 void
240 #ifdef __USE_PROTOS
241 gen( AST *t )
242 #else
243 gen( t )
244 AST *t;
245 #endif
246 {
247 if ( t==NULL ) return;
248 while ( t!=NULL && t->token == NonTerm )
249 {
250 if ( labels_for_func != NULL )
251 {
252 /* reset 'defined' flag for previously defined labels and free list */
253 ListNode *p, *q;
254 for (p = labels_for_func->next; p!=NULL; p=q)
255 {
256 SymEntry *s = (SymEntry *)p->elem;
257 s->defined = 0;
258 q = p->next;
259 free(p);
260 }
261 free(labels_for_func);
262 labels_for_func = NULL;
263 }
264 gen_rule(t);
265 t = t->right;
266 }
267
268 if ( after_actions != NULL )
269 {
270 ListNode *p;
271 for (p = after_actions->next; p!=NULL; p=p->next)
272 dumpAction( (char *)p->elem, output, 0, -1, 0, 1);
273 }
274 fclose(output);
275 }
276
277 void
278 #ifdef __USE_PROTOS
279 gen_rule( AST *t )
280 #else
281 gen_rule( t )
282 AST *t;
283 #endif
284 {
285 SymEntry *s;
286
287 if ( t==NULL ) return;
288 whichRule=t;
289 s = (SymEntry *) hash_get(symbols, t->text);
290 require(s!=NULL, "gen_rule: sym tab broken");
291
292 if ( t->file != outfile ) /* open new output file if need to */
293 {
294 if (strcmp(FileStr[t->file], "stdin")==0) output = stdout;
295 else {
296 if ( output != NULL ) fclose( output );
297 output = fopen(OutMetaName(outname(FileStr[t->file])), "w");
298 require(output != NULL, "gen_rule: can't open output file");
299 #ifdef SPECIAL_FOPEN
300 special_fopen_actions(OutMetaName(outname(FileStr[t->file])));
301 #endif
302 }
303 if ( outfile == -1 ) gen_hdr1();
304 else gen_hdr();
305 outfile = t->file;
306 }
307
308 fprintf(output, "\n");
309 current_rule = t->text;
310 GenRulePrototype(output, t, s, 0);
311
312 /* What locals do we need? */
313 tabs=1;
314 if ( GenCPP ) fprintf(output, "{\n\tSORASTBase *_t = *_root;\n");
315 else fprintf(output, "{\n\tSORAST *_t = *_root;\n");
316 if ( s->rt!=NULL ) fprintf(output, "\t%s;\n", s->rt);
317 if ( transform )
318 {
319 if ( GenCPP ) fprintf(output, "\tSORASTBase *_tresult=NULL;\n");
320 else fprintf(output, "\tSORAST *_tresult=NULL;\n");
321 fprintf(output, "\tTREE_CONSTR_PTRS;\n");
322 }
323
324 if ( t->refvars!=NULL )
325 {
326 ListNode *p;
327 for (p = t->refvars->next; p!=NULL; p=p->next)
328 {
329 RefVarRec *r = (RefVarRec *)p->elem;
330 if ( !r->global ) {
331 TAB;
332 dump_prefixed_decl("_save_", r->decl, output);
333 if ( GenCPP ) fprintf(output, "=%s;\n", r->var);
334 else fprintf(output, "=_parser->%s;\n", r->var);
335 }
336 }
337 }
338
339 define_labels_in_block(t->down);
340 if ( found_guess_block ) fprintf(output, "\t_GUESS_BLOCK;\n");
341 if ( transform ) fprintf(output, " *_result = NULL;\n");
342 gen_block(t->down, BLOCK);
343 TAB;
344 fprintf(output, "*_root = _t;\n");
345
346 /* reset any ref vars defined in this routine */
347 if ( t->refvars!=NULL )
348 {
349 ListNode *p;
350 for (p = t->refvars->next; p!=NULL; p=p->next)
351 {
352 RefVarRec *r = (RefVarRec *)p->elem;
353 if ( !r->global )
354 {
355 if ( GenCPP ) fprintf(output, "\t%s = _save_%s;\n", r->var, r->var);
356 else fprintf(output, "\t_parser->%s = _save_%s;\n", r->var, r->var);
357 }
358 }
359 }
360
361 /* set result of tree copying efforts if no ! on rule */
362 if ( transform&&!t->no_copy ) {
363 TAB;
364 /* The 'if' check in front of the *_result assignment ensures
365 * that if someone sets the result before here, don't mess with
366 * it. This assignment is the default.
367 */
368 fprintf(output, "if ( (*_result) == NULL ) *_result = _r;\n");
369 }
370
371 /* send back and return value */
372 if ( s->rt!=NULL )
373 {
374 char *str = s->rt;
375 TAB;
376 fprintf(output, "return ");
377 DumpNextNameInDef(&str, output);
378 fprintf(output, ";\n");
379 }
380
381 tabs=0;
382 fprintf(output, "}\n");
383 }
384
385 /*
386 * The lookahead is stored in the 1st node of each alt of the block.
387 * The Lookahead of what follows (for CLOSURE and OPT) blocks, is stored
388 * in the node which branches over the enclosed, optional block.
389 */
390 void
391 #ifdef __USE_PROTOS
392 gen_block( AST *q, int block_type )
393 #else
394 gen_block( q, block_type )
395 AST *q;
396 int block_type;
397 #endif
398 {
399 AST *t = q, *u, *g;
400 GLA *start_state, *follow=NULL;
401 int need_right_curly=0, guess_block_in_prev_alt=0, num_alts=0;
402 require(q!=NULL, "gen_block: NULL block");
403 require(q->start_state!=NULL, "gen_block: NULL start state");
404
405 start_state = t->start_state->p1;
406 require(start_state!=NULL, "gen_block: no GLA start state for AST block");
407
408 switch ( block_type ) {
409 case PRED_OP :
410 TAB;
411 fprintf(output, "{_SAVE; TREE_CONSTR_PTRS;\n");
412 break;
413 case CLOSURE :
414 TAB;
415 fprintf(output, "{int _done=0;\n");
416 TAB;
417 fprintf(output, "while ( !_done ) {\n");
418 tabs++;
419 break;
420 case POS_CLOSURE :
421 TAB;
422 fprintf(output, "{int _done=0;\n");
423 TAB;
424 fprintf(output, "do {\n");
425 tabs++;
426 }
427
428 /* Error if (...)? with only one alt */
429 for (u = q->down; u!=NULL; u=u->right ) {num_alts++;}
430 g = first_guess_block(q->down);
431 if ( num_alts==1 && g!=NULL )
432 {
433 warnFL("(...)? predicate in block with one alternative; will generate bad code",
434 FileStr[g->file], g->line);
435 }
436
437 t = t->down; /* move down to first alt */
438 while ( t!=NULL && t->token == ALT )
439 {
440 require(start_state!=NULL, "gen_block: invalid GLA for block");
441 if ( t!=q->down ) {
442 TAB;
443 fprintf(output, "else {\n");
444 need_right_curly++;
445 }
446 code_for_guess_block(t, &guess_block_in_prev_alt);
447 TAB;
448 fprintf(output, "if (");
449 /* To prevent/detect infinite recursion, ensure 'visited' flag is set
450 * on node starting this alt
451 */
452 start_state->visited = 1;
453 start_state->lookahead = gen_prediction_expr(t, start_state->p1);
454 start_state->visited = 0;
455 fprintf(output, " ) {\n");
456 tabs++;
457 gen_alt(t);
458 tabs--; TAB;
459 fprintf(output, "}\n");
460 t = t->right; /* move to next alt in AST */
461 start_state = start_state->p2; /* move to next alt in GLA */
462 }
463
464 switch ( block_type ) {
465 case OPT :
466 case CLOSURE :
467 follow = q->start_state->p2;
468 break;
469 case POS_CLOSURE :
470 follow = q->start_state->next;
471 }
472
473 if ( block_type == OPT || block_type == CLOSURE || block_type == POS_CLOSURE )
474 {
475 TAB;
476 fprintf(output, "else {\n");
477 need_right_curly++;
478 TAB;
479 fprintf(output, "if (");
480 /* what follows the block? */
481 q->start_state->visited = 1;
482 q->start_state->lookahead = gen_prediction_expr(NULL, follow);
483 q->start_state->visited = 0;
484 fprintf(output, " ) {\n");
485 if ( block_type != OPT )
486 {
487 tabs++; TAB;
488 fprintf(output, "_done = 1;\n");
489 tabs--;
490 }
491 TAB;
492 fprintf(output, "}\n");
493 }
494
495 /* Generate error clause */
496 TAB;
497 fprintf(output, "else {\n");
498 /* generate the _GUESS_FAIL even if no (..)? found because calling
499 * routine may be using STreeTest()
500 */
501 tabs++;
502 TAB;
503 if ( GenCPP ) fprintf(output, "if ( guessing ) _GUESS_FAIL;\n");
504 else fprintf(output, "if ( _parser->guessing ) _GUESS_FAIL;\n");
505 TAB;
506 if ( GenCPP ) fprintf(output, "no_viable_alt(\"%s\", _t);\n", current_rule);
507 else fprintf(output, "no_viable_alt(_parser, \"%s\", _t);\n", current_rule);
508 tabs--;
509 TAB;
510 fprintf(output, "}\n");
511 if ( transform ) { TAB; fprintf(output, " _tresult = _r;\n"); }
512
513 for (;need_right_curly>0; need_right_curly--)
514 {
515 TAB;
516 fprintf(output, "}\n");
517 }
518
519 switch ( block_type ) {
520 case BLOCK :
521 break;
522 case CLOSURE :
523 tabs--;
524 TAB; fprintf(output, "}\n");
525 /* if ( transform ) fprintf(output, " _tresult = _r;\n"); */
526 TAB; fprintf(output, "}\n");
527 break;
528 case POS_CLOSURE :
529 tabs--;
530 TAB;
531 fprintf(output, "} while ( !_done );\n");
532 /* if ( transform ) { TAB; fprintf(output, " _tresult = _r;\n"); } */
533 TAB;
534 fprintf(output, "}\n");
535 break;
536 case PRED_OP :
537 TAB;
538 fprintf(output, "_RESTORE;\n");
539 /* if ( transform ) { TAB; fprintf(output, " _tresult = _r;\n"); } */
540 TAB; fprintf(output, "}\n");
541 TAB; fprintf(output, "_GUESS_DONE;\n");
542 break;
543 }
544
545 test_block_consistency(q, block_type);
546 }
547
548 void
549 #ifdef __USE_PROTOS
550 gen_alt( AST *t )
551 #else
552 gen_alt( t )
553 AST *t;
554 #endif
555 {
556 require(t!=NULL && t->token==ALT, "gen_alt: invalid alt");
557
558 t = t->down;
559 if ( t==NULL ) return;
560 if ( t->token==Action ) t->init_action = 1;
561 gen_tree_pattern(t);
562
563 /* find last element of alternative to see if it's a simple token */
564 while ( t->right!=NULL ) { t = t->right; }
565 if ( t->down==NULL && (t->token == Token || t->token == WILD) )
566 { TAB; go_right(1); }
567 }
568
569 void
570 #ifdef __USE_PROTOS
571 gen_tree_pattern( AST *t )
572 #else
573 gen_tree_pattern( t )
574 AST *t;
575 #endif
576 {
577 while ( t != NULL )
578 {
579 /* could be root of a tree, check it */
580 if ( t->down != NULL && (t->token==Token||t->token==WILD) ) {
581 TAB;
582 fprintf(output, "{_SAVE; TREE_CONSTR_PTRS;\n");
583 }
584 gen_element(t);
585 if ( t->down != NULL ) {
586 if ( t->token == Token || t->token==WILD )
587 {
588 gen_tree_pattern(t->down); /* only token/wildcard can be root of tree */
589 TAB;
590 fprintf(output, "_RESTORE;");
591 if ( transform ) fprintf(output, " _tresult = _r;");
592 fprintf(output, "\n");
593 TAB; fprintf(output, "}\n");
594 /* link in result of #(...) */
595 if ( transform && !whichRule->no_copy ) {
596 TAB; fprintf(output, "_mkchild(&_r,&_s,&_e,_tresult);\n");
597 }
598 TAB; go_right(1);
599 }
600 }
601 t = t->right;
602 }
603 }
604
605 void
606 #ifdef __USE_PROTOS
607 gen_element( AST *t )
608 #else
609 gen_element( t )
610 AST *t;
611 #endif
612 {
613 char *res;
614 require(t!=NULL, "gen_element: NULL tree pointer");
615
616 switch ( t->token )
617 {
618 case Token :
619 TAB;
620 if ( t->upper_range!=0 )
621 fprintf(output, "_MATCHRANGE(%s,%s);",
622 t->text, token_dict[t->upper_range]);
623 else fprintf(output, "_MATCH(%s);", t->text);
624 fprintf(output, "\n");
625 /* Make copy of token if transform && (copy or (labeled&&!copy)) */
626 if ( transform && (t->label[0]!='\0'||!t->no_copy) ) {
627 TAB;
628 if ( GenCPP )
629 fprintf(output, "_tresult=_t->shallowCopy();\n");
630 else
631 fprintf(output, "_tresult=ast_dup_node(_t);\n");
632 }
633 if ( transform && !t->no_copy ) {
634 if ( t->is_root )
635 fprintf(output, " _mkroot(&_r,&_s,&_e,_tresult);\n");
636 else
637 fprintf(output, " _mkchild(&_r,&_s,&_e,_tresult);\n");
638 }
639 /* Do Label if any */
640 if ( transform ) { /* label is output, label_in is input */
641 if ( t->label[0]!='\0' )
642 {
643 TAB;
644 fprintf(output,
645 "%s=(SORAST *)_tresult; %s_in=(SORAST *)_t;\n",
646 t->label,t->label);
647 }
648 } else {
649 if ( t->label[0]!='\0' )
650 { TAB; fprintf(output, "%s=(SORAST *)_t;\n", t->label); }
651 }
652 /* Move tree parser pointer */
653 if ( t->down != NULL ) { TAB; go_down(1); }
654 else if ( t->right != NULL ) { TAB; go_right(1); }
655 break;
656 case WILD :
657 TAB;
658 fprintf(output, "_WILDCARD;");
659 /* Make copy of token or tree if transform */
660 if ( transform ) {
661 TAB;
662 if ( GenCPP )
663 fprintf(output, "_tresult=_t->deepCopy();");
664 else
665 fprintf(output, "_tresult=ast_dup(_t);");
666 /* wildcard can't be root, must be child */
667 if ( !t->no_copy ) {
668 if ( t->is_root )
669 fprintf(output, " _mkroot(&_r,&_s,&_e,_tresult);");
670 else
671 fprintf(output, " _mkchild(&_r,&_s,&_e,_tresult);");
672 }
673 }
674 fprintf(output, "\n");
675 if ( transform ) {
676 if ( t->label[0]!='\0' )
677 {
678 TAB;
679 fprintf(output,
680 "%s=(SORAST *)_tresult; %s_in=(SORAST *)_t;\n",
681 t->label,t->label);
682 }
683 } else {
684 if ( t->label[0]!='\0' )
685 { TAB; fprintf(output, "%s=(SORAST *)_t;\n", t->label); }
686 }
687 if ( t->down != NULL ) { TAB; go_down(1); }
688 else if ( t->right != NULL ) { TAB; go_right(1); }
689 break;
690 case NonTerm :
691 TAB;
692 /* For nontransform mode, do labels first */
693 if (t->label[0]!='\0')
694 fprintf(output, "%s=(SORAST *)_t; ", t->label);
695 if ( t->out ) {
696 if ( t->in ) fprintf(output, "%s=", t->down->right->text);
697 else fprintf(output, "%s=", t->down->text);
698 }
699 fprintf(output, "%s%s", Prefix, t->text);
700 if ( transform ) res = ", &_tresult"; else res = "";
701 if ( GenCPP ) {
702 if ( t->in ) fprintf(output, "(&_t%s, %s);",
703 res, t->down->text);
704 else fprintf(output, "(&_t%s);", res);
705 }
706 else {
707 if ( t->in ) fprintf(output, "(_parser, &_t%s, %s);",
708 res, t->down->text);
709 else fprintf(output, "(_parser, &_t%s);", res);
710 }
711 fprintf(output, "\n");
712 if (transform && t->label[0]!='\0')
713 {
714 TAB;
715 fprintf(output, "%s=(SORAST *)_tresult;\n", t->label);
716 }
717 /* Link in result of rule */
718 if ( transform&&!t->no_copy ) {
719 TAB;
720 fprintf(output, "_mkchild(&_r,&_s,&_e,_tresult);\n");
721 }
722 break;
723 case Action :
724 if ( !t->init_action && found_guess_block ) {
725 TAB;
726 if ( GenCPP ) fprintf(output, "if ( !guessing ) {\n");
727 else fprintf(output, "if ( !_parser->guessing ) {\n");
728 }
729 dumpAction(t->action, output, tabs, 0, 0, 1);
730 if ( !t->init_action && found_guess_block ) {TAB; fprintf(output, "}\n");}
731 break;
732 case CLOSURE :
733 gen_block(t->down, CLOSURE);
734 break;
735 case POS_CLOSURE :
736 gen_block(t->down, POS_CLOSURE);
737 break;
738 case OPT :
739 gen_block(t->down, OPT);
740 break;
741 case BLOCK :
742 gen_block(t, BLOCK);
743 break;
744 case PRED_OP :
745 require(t->up!=NULL, "define_labels_in_element: GLA is broken");
746 if ( t->up->down==t ) {
747 if ( t->down->token == BLOCK ) gen_block(t->down, PRED_OP);
748 }
749 else if ( t->up->down->token==Action && t->up->down->right==t ) {
750 if ( t->down->token == BLOCK ) gen_block(t->down, PRED_OP);
751 }
752 else {
753 warnFL("predicate not at beginning of alternative; ignored",
754 FileStr[t->file], t->line);
755 }
756 break;
757 default :
758 fatal(eMsgd("invalid elemental node type: %d", t->token));
759 }
760 }
761
762 /* walk the block of a rule and define all labels to be "SORAST *label_i" */
763 void
764 #ifdef __USE_PROTOS
765 define_labels_in_block( AST *t )
766 #else
767 define_labels_in_block( t )
768 AST *t;
769 #endif
770 {
771 require(t!=NULL, "define_labels_in_block: NULL tree pointer");
772 require(t->token==BLOCK, "define_labels_in_block: invalid block");
773 t = t->down;
774 while ( t!=NULL )
775 {
776 define_labels_in_alt(t);
777 t = t->right;
778 }
779 }
780
781 void
782 #ifdef __USE_PROTOS
783 define_labels_in_alt( AST *t )
784 #else
785 define_labels_in_alt( t )
786 AST *t;
787 #endif
788 {
789 require(t!=NULL, "define_labels_in_alt: NULL tree pointer");
790 require(t->token==ALT, "gen_alt: invalid alt");
791
792 define_labels_in_tree(t->down);
793 }
794
795 void
796 #ifdef __USE_PROTOS
797 define_labels_in_tree( AST *t )
798 #else
799 define_labels_in_tree( t )
800 AST *t;
801 #endif
802 {
803 while ( t != NULL )
804 {
805 define_labels_in_element(t);
806 /* could be root of a tree, check it */
807 if ( t->down != NULL ) {
808 if ( t->token == Token || t->token==WILD )
809 {
810 define_labels_in_tree(t->down);
811 }
812 }
813 t = t->right;
814 }
815 }
816
817 void
818 #ifdef __USE_PROTOS
819 define_labels_in_element( AST *t )
820 #else
821 define_labels_in_element( t )
822 AST *t;
823 #endif
824 {
825 require(t!=NULL, "define_labels_in_element: NULL tree pointer");
826 switch ( t->token )
827 {
828 case Token :
829 case WILD :
830 case NonTerm :
831 if ( t->label[0]!='\0' ) {
832 SymEntry *s;
833 s = (SymEntry *) hash_get(symbols, t->label);
834 require(s!=NULL, "define_labels_in_element: sym tab broken");
835 if ( s->token==LABEL && !s->defined ) {
836 s->defined = 1;
837 TAB;
838 fprintf(output, "SORAST *%s=NULL", t->label);
839 if ( transform ) fprintf(output, ",*%s_in=NULL", t->label);
840 fprintf(output, ";\n");
841 /* track which ones we define so that we can undefine
842 * them for the next rule
843 */
844 list_add(&labels_for_func, (void *)s);
845 }
846 }
847 break;
848 case Action :
849 break;
850 case CLOSURE :
851 case POS_CLOSURE :
852 define_labels_in_block(t->down);
853 break;
854 case PRED_OP :
855 if ( t->down->token != Action )
856 {
857 define_labels_in_block(t->down);
858 }
859 break;
860 case OPT :
861 define_labels_in_block(t->down);
862 break;
863 case BLOCK :
864 define_labels_in_block(t);
865 break;
866 }
867 }
868
869 /* dump action 's' to file 'output' starting at "local" tab 'tabs'
870 Dump line information in front of action if GenLineInfo is set
871 If file == -1 then GenLineInfo is ignored.
872 The user may redefine the LineInfoFormatStr to his/her liking
873 most compilers will like the default, however.
874
875 June '93; changed so that empty lines are left alone so that
876 line information is correct for the compiler/debuggers.
877 */
878 void
879 #ifdef __USE_PROTOS
880 dumpAction( char *s, FILE *output, int tabs, int file, int line, int final_newline )
881 #else
882 dumpAction( s, output, tabs, file, line, final_newline )
883 char *s;
884 FILE *output;
885 int tabs;
886 int file;
887 int line;
888 int final_newline;
889 #endif
890 {
891 int inDQuote, inSQuote;
892 require(s!=NULL, "dumpAction: NULL action");
893 require(output!=NULL, eMsg1("dumpAction: output FILE is NULL for %s",s));
894
895 /* if ( GenLineInfo && file != -1 )
896 {
897 fprintf(output, LineInfoFormatStr, line, FileStr[file]);
898 }*/
899 PastWhiteSpace( s );
900 /* don't print a tab if first non-white char is a # (preprocessor command) */
901 if ( *s!='#' ) {TAB;}
902 inDQuote = inSQuote = 0;
903 while ( *s != '\0' )
904 {
905 if ( *s == '\\' )
906 {
907 putc( *s++, output ); /* Avoid '"' Case */
908 if ( *s == '\0' ) return;
909 if ( *s == '\'' ) putc( *s++, output );
910 if ( *s == '\"' ) putc( *s++, output );
911 }
912 if ( *s == '\'' )
913 {
914 if ( !inDQuote ) inSQuote = !inSQuote;
915 }
916 if ( *s == '"' )
917 {
918 if ( !inSQuote ) inDQuote = !inDQuote;
919 }
920 if ( *s == '\n' )
921 {
922 putc('\n', output);
923 s++;
924 while (*s == '\n') {
925 putc('\n', output);
926 s++;
927 }
928 PastWhiteSpace( s );
929 if ( *s == '}' )
930 {
931 --tabs;
932 TAB;
933 putc( *s++, output );
934 continue;
935 }
936 if ( *s == '\0' ) return;
937 if ( *s != '#' ) /* #define, #endif etc.. start at col 1 */
938 {
939 TAB;
940 }
941 }
942 if ( *s == '}' && !(inSQuote || inDQuote) )
943 {
944 --tabs; /* Indent one fewer */
945 }
946 if ( *s == '{' && !(inSQuote || inDQuote) )
947 {
948 tabs++; /* Indent one more */
949 }
950 putc( *s, output );
951 s++;
952 }
953 if ( final_newline ) putc('\n', output);
954 }
955
956 char *
957 #ifdef __USE_PROTOS
958 find_predicate( AST *t )
959 #else
960 find_predicate( t )
961 AST *t;
962 #endif
963 {
964 if ( t==NULL ) return NULL;
965 if ( t->token == Action )
966 {
967 if ( t->right!=NULL && t->right->token==PRED_OP && t->right->down->token!=BLOCK )
968 {
969 return t->right->down->action;
970 }
971 }
972 else if ( t->token == PRED_OP && t->down->token!=BLOCK )
973 {
974 return t->down->action;
975 }
976 return NULL;
977 }
978
979 /* Given a pointer to a tree pattern element (Token, BLOCK, etc...),
980 * generate an expression that predicts when that path would match.
981 */
982 set
983 #ifdef __USE_PROTOS
984 gen_prediction_expr( AST *alt, GLA *t )
985 #else
986 gen_prediction_expr( alt, t )
987 AST *alt;
988 GLA *t;
989 #endif
990 {
991 char *sempred;
992 set a, rs;
993 int tok, first=1, num_on_line=0;
994 require(alt==NULL||alt->token==ALT,
995 "gen_prediction_expr: AST node is invalid");
996
997 a = Lookahead(t);
998 rs = set_dup(a);
999
1000 /* if this production is a guess block, then test return value of setjmp() */
1001
1002 /* MR21 Problem reported by Peter Keller
1003 THM: Sor doesn't see predicate because of intervening action.
1004
1005 */
1006
1007 if (alt != NULL) {
1008 AST* cursor;
1009 for (cursor = alt->down;
1010 cursor != NULL && Action == cursor->token;
1011 cursor = cursor->right) {
1012 /* nothing */
1013 }
1014 if (cursor != NULL &&
1015 cursor->token == PRED_OP &&
1016 cursor->down->token == BLOCK) {
1017 fprintf(output," !_gv &&");
1018 }
1019 }
1020
1021 #if 0
1022 /* The old code which was replaced */
1023
1024 if ( alt!=NULL && alt->down!=NULL && alt->down->token==PRED_OP &&
1025 alt->down->down->token==BLOCK ) fprintf(output, " !_gv &&");
1026
1027 #endif
1028
1029 /* handle end of input first */
1030 if ( set_el(end_of_input, a) )
1031 {
1032 fprintf(output, " _t==NULL");
1033 set_rm(end_of_input, a);
1034 if ( !set_nil(a) ) fprintf(output, " ||");
1035 }
1036 else if ( set_el(wild_card, a) )
1037 {
1038 fprintf(output, " _t!=NULL");
1039 if ( alt!=NULL ) {
1040 sempred = find_predicate(alt->down);
1041 if ( sempred!=NULL ) fprintf(output, " && (%s)", sempred);
1042 }
1043 set_free(a);
1044 return rs;
1045 }
1046 else
1047 {
1048 fprintf(output, " _t!=NULL");
1049 if ( !set_nil(a) ) fprintf(output, " &&");
1050 }
1051
1052 if ( set_nil(a) ) { set_free(a); return rs; }
1053
1054 fprintf(output, " (");
1055 while ( !set_nil(a) )
1056 {
1057 tok = set_int(a);
1058 set_rm(tok, a);
1059 if ( first ) first = 0;
1060 else fprintf(output, "||");
1061 if ( num_on_line>=2 ) {num_on_line=0; fprintf(output,"\n"); TAB;}
1062 else num_on_line++;
1063 if ( tok==wild_card ) fprintf(output, "_t!=NULL");
1064 else if ( token_dict[tok]==0 )
1065 {
1066 if ( GenCPP )
1067 fprintf(output, "_t->type()==UNDEFINED_TOKEN");
1068 else
1069 fprintf(output, "_t->token==UNDEFINED_TOKEN");
1070 }
1071 else
1072 {
1073 if ( GenCPP )
1074 fprintf(output, "_t->type()==%s", token_dict[tok]);
1075 else
1076 fprintf(output, "_t->token==%s", token_dict[tok]);
1077 }
1078 }
1079 fprintf(output, ")");
1080
1081 if ( alt!=NULL ) {
1082 sempred = find_predicate(alt->down);
1083 if ( sempred!=NULL ) fprintf(output, " && (%s)", sempred);
1084 }
1085 set_free(a);
1086 return rs;
1087 }
1088
1089 /* Find all return types/parameters that require structs and def
1090 * all rules with ret types.
1091 */
1092 void
1093 #ifdef __USE_PROTOS
1094 GenRulePrototypes( FILE *f, int tabs )
1095 #else
1096 GenRulePrototypes( f, tabs )
1097 FILE *f;
1098 int tabs;
1099 #endif
1100 {
1101 AST *p;
1102 SymEntry *s;
1103
1104 for (p=rules; p!=NULL; p=p->right)
1105 {
1106 int i;
1107 s = (SymEntry *) hash_get(symbols, p->text);
1108 require(s!=NULL, "GenRulePrototypes: sym tab broken");
1109
1110 for (i=1; i<=tabs; i++) fprintf(f, "\t");
1111 GenRulePrototype(f, p, s, 1);
1112 }
1113 }
1114
1115 void
1116 #ifdef __USE_PROTOS
1117 GenRulePrototype(FILE *f, AST *p, SymEntry *s, int decl_not_def)
1118 #else
1119 GenRulePrototype(f, p, s, decl_not_def)
1120 FILE *f;
1121 SymEntry *s;
1122 AST *p;
1123 int decl_not_def;
1124 #endif
1125 {
1126 require(s!=NULL&&s->definition!=NULL, "GenRulePrototype: no def for rule");
1127
1128 if ( GenCPP )
1129 {
1130 if ( s->rt != NULL )
1131 DumpType(s->rt, f, FileStr[s->definition->file], s->definition->line);
1132 else fprintf(f, "void");
1133 if ( decl_not_def )
1134 fprintf(f, " %s(SORASTBase **_root%s",
1135 p->text,
1136 transform?", SORASTBase **_result":"");
1137 else
1138 fprintf(f, " %s::%s(SORASTBase **_root%s",
1139 CurClassName,
1140 p->text,
1141 transform?", SORASTBase **_result":"");
1142 if ( s->args != NULL ) fprintf(f, ",%s", s->args);
1143 fprintf(f, ")");
1144 if ( decl_not_def ) fprintf(f, ";");
1145 fprintf(f, "\n");
1146 return;
1147 }
1148
1149 if ( decl_not_def ) fprintf(f, "extern ");
1150 if ( GenAnsiProtos && GenKRProtos ) fprintf(f, "\n#ifdef __USE_PROTOS\n");
1151 if ( GenAnsiProtos )
1152 {
1153 if ( s->rt != NULL )
1154 DumpType(s->rt, f, FileStr[s->definition->file], s->definition->line);
1155 else fprintf(f, "void");
1156 fprintf(f, " %s%s(STreeParser *_parser, SORAST **_root%s",
1157 Prefix,
1158 p->text,
1159 transform?", SORAST **_result":"");
1160 if ( s->args != NULL ) fprintf(f, ",%s", s->args);
1161 fprintf(f, ")");
1162 if ( decl_not_def ) fprintf(f, ";");
1163 fprintf(f, "\n");
1164 }
1165 if ( GenAnsiProtos && GenKRProtos ) fprintf(f, "#else\n");
1166 if ( GenKRProtos )
1167 {
1168 if ( s->rt != NULL )
1169 DumpType(s->rt, f, FileStr[s->definition->file], s->definition->line);
1170 else fprintf(f, "void");
1171 if ( decl_not_def) fprintf(f, " %s%s();\n", Prefix, p->text);
1172 else
1173 {
1174 fprintf(f, " %s%s(_parser, _root%s",
1175 Prefix, p->text,transform?", _result":"");
1176 if ( s->args!=NULL ) fprintf(f, ",");
1177 DumpListOfParmNames(s->args, f);
1178 fprintf(f, ")\n");
1179 fprintf(f, "STreeParser *_parser;\n");
1180 fprintf(f, "SORAST **_root%s;\n", transform?", **_result":"");
1181 DumpOldStyleParms(s->args, f);
1182 }
1183 }
1184 if ( GenAnsiProtos && GenKRProtos ) fprintf(f, "#endif\n");
1185 }
1186
1187 /*
1188 * For each referenced token, generate a #define in a file defined in
1189 * 'def_token_file'.
1190 */
1191 void
1192 #ifdef __USE_PROTOS
1193 gen_tokens_file( void )
1194 #else
1195 gen_tokens_file( )
1196 #endif
1197 {
1198 FILE *f;
1199 ListNode *p;
1200
1201 if ( def_token_file==NULL ) return;
1202
1203 f = fopen(def_token_file, "w");
1204 if ( f==NULL )
1205 {
1206 errNoFL(eMsg1("cannot write token definition file %s", def_token_file));
1207 return;
1208 }
1209 #ifdef SPECIAL_FOPEN
1210 special_fopen_actions(def_token_file);
1211 #endif
1212
1213 gen_info_hdr(f);
1214 fprintf(f, "\n");
1215 for (p = token_list->next; p!=NULL; p=p->next)
1216 {
1217 SymEntry *t = (SymEntry *) p->elem;
1218 fprintf(f, "#define %s %d\n", t->str, t->token_type);
1219 }
1220 fclose(f);
1221 }
1222
1223 AST *
1224 #ifdef __USE_PROTOS
1225 first_guess_block(AST *q)
1226 #else
1227 first_guess_block(q)
1228 AST *q;
1229 #endif
1230 {
1231 require(q!=NULL&&q->token==ALT, "first_guess_block: non-ALT ptr");
1232
1233 if ( q->down!=NULL )
1234 {
1235 if ( (q->down->token==PRED_OP && q->down->down!=NULL &&
1236 q->down->down->token==BLOCK) )
1237 {
1238 return q->down;
1239 }
1240 else if (q->down->token==Action && q->down->right!=NULL &&
1241 q->down->right->token==PRED_OP && q->down->right->down!=NULL &&
1242 q->down->right->down->token==BLOCK)
1243 {
1244 return q->down->right;
1245 }
1246 else return NULL;
1247 }
1248 return NULL;
1249 }
1250
1251 void
1252 #ifdef __USE_PROTOS
1253 code_for_guess_block( AST *t, int *guess_block_in_prev_alt )
1254 #else
1255 code_for_guess_block( t, guess_block_in_prev_alt )
1256 AST *t;
1257 int *guess_block_in_prev_alt;
1258 #endif
1259 {
1260 if ( found_guess_block )
1261 {
1262 /* if previous alt had a guess block, check to turn it off */
1263 if ( *guess_block_in_prev_alt )
1264 {
1265 TAB;
1266 if ( GenCPP ) fprintf(output, "if ( guessing ) _GUESS_DONE;\n");
1267 else fprintf(output, "if ( _parser->guessing ) _GUESS_DONE;\n");
1268 }
1269 /* if current alt has a guess block... */
1270 if ( first_guess_block(t)!=NULL )
1271 {
1272 TAB;
1273 fprintf(output, "_GUESS;\n");
1274 *guess_block_in_prev_alt = 1;
1275 }
1276 }
1277 }
+0
-88
contrib/pccts/sorcerer/globals.c less more
0 /*
1 * globals.c
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B24
24 * Terence Parr
25 * Parr Research Corporation
26 * With AHPCRC, University of Minnesota
27 * 1992-2001
28 */
29 #include "stdpccts.h"
30
31 char *VersionNumber = "13333"; /* mrxxx */
32 char *VersionText = "13333"; /* mrxxx */
33 char *FileStr[MaxNumFiles];/* Ptr to array of file names on command-line */
34 int NumFiles=0; /* current grammar file number */
35 int action_file; /* used to track start of action */
36 int action_line;
37 int CurFile= -1; /* Index into FileStr table */
38 char *CurRule=NULL; /* Pointer to current rule name */
39 char *CurRetDef=NULL; /* Pointer to current return type definition */
40 char *CurParmDef=NULL; /* Pointer to current parameter definition */
41 FILE *output=NULL; /* current parser output file */
42 FILE *input=NULL; /* current grammar input file */
43 Entry **symbols; /* both tokens and nonterminals */
44 int token_table_size = 1000;
45 char **token_dict=NULL;
46 int token_type = 1; /* used only if #tokdefs it not used */
47 int end_of_input = 0;
48 int epsilon = 0;
49 int last_valid_token = 0;
50 int DumpIR = 0;
51 char *OutputDirectory = TopDirectory;
52 ListNode *before_actions = NULL,
53 *after_actions = NULL,
54 *class_actions = NULL;
55 char translator[MaxFileName+1];
56 char tokdefs_file[MaxFileName+1];
57 char *header_action = NULL;
58 AST *rules=NULL;
59 int print_guts = 0;
60 int transform = 0; /* Don't assume a transformation */
61 int found_guess_block = 0;
62 char *def_token_file=NULL;
63 int def_tokens=0;
64 ListNode *token_list = NULL;
65 int found_error=0;
66 set referenced_tokens = set_init;
67 int wild_card = 0;
68 int UserDefdTokens=0;
69 int Inline = 0;
70 char *Prefix="";
71 FILE *ProtoFILE = NULL;
72 char *GenProtoFile = NULL;
73 ListNode *RefVars = NULL;
74 ListNode *AllRefVars = NULL;
75 char CurRefVarType[MaxAtom+1];
76 char CurRefVarLabel[MaxAtom+1];
77 char CurClassName[MaxAtom+1]="";
78 int GenCPP = 0;
79 int NoCtor = 0; /* MR23 */
80
81 #if defined(__STDC__) || defined(__cplusplus) || defined(__USE_PROTOS)
82 int GenAnsiProtos=1; /* Gen both if both Protos are on */
83 int GenKRProtos=0;
84 #else
85 int GenAnsiProtos=0;
86 int GenKRProtos=1;
87 #endif
+0
-6
contrib/pccts/sorcerer/h/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 EXTRA_DIST= SASTBase.h SCommonAST.h STreeParser.h astlib.h \
4 sintstack.h sorcerer.h sorlist.h sstack.h
5
+0
-458
contrib/pccts/sorcerer/h/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/sorcerer/h
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 am__can_run_installinfo = \
102 case $$AM_UPDATE_INFO_DIR in \
103 n|no|NO) false;; \
104 *) (install-info --version) >/dev/null 2>&1;; \
105 esac
106 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
107 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
108 ACLOCAL = @ACLOCAL@
109 AET2_CFLAGS = @AET2_CFLAGS@
110 AET2_LDADD = @AET2_LDADD@
111 ALLOCA = @ALLOCA@
112 AMTAR = @AMTAR@
113 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
114 AUTOCONF = @AUTOCONF@
115 AUTOHEADER = @AUTOHEADER@
116 AUTOMAKE = @AUTOMAKE@
117 AWK = @AWK@
118 CC = @CC@
119 CCDEPMODE = @CCDEPMODE@
120 CFLAGS = @CFLAGS@
121 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
122 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
123 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
124 CPP = @CPP@
125 CPPFLAGS = @CPPFLAGS@
126 CXX = @CXX@
127 CXXDEPMODE = @CXXDEPMODE@
128 CXXFLAGS = @CXXFLAGS@
129 CYGPATH_W = @CYGPATH_W@
130 DEFS = @DEFS@
131 DEPDIR = @DEPDIR@
132 ECHO_C = @ECHO_C@
133 ECHO_N = @ECHO_N@
134 ECHO_T = @ECHO_T@
135 EGREP = @EGREP@
136 EXEEXT = @EXEEXT@
137 EXTDEBUG = @EXTDEBUG@
138 EXTDEBUG2 = @EXTDEBUG2@
139 EXTDEBUG3 = @EXTDEBUG3@
140 EXTDEBUG4 = @EXTDEBUG4@
141 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
142 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
143 FSDB_CFLAGS = @FSDB_CFLAGS@
144 FSDB_LDADD = @FSDB_LDADD@
145 GCONF_CFLAGS = @GCONF_CFLAGS@
146 GCONF_LIBS = @GCONF_LIBS@
147 GEDITTEST = @GEDITTEST@
148 GEDIT_CFLAGS = @GEDIT_CFLAGS@
149 GIO_CFLAGS = @GIO_CFLAGS@
150 GIO_LIBS = @GIO_LIBS@
151 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
152 GPERF = @GPERF@
153 GREP = @GREP@
154 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
155 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
156 GTK_CFLAGS = @GTK_CFLAGS@
157 GTK_CONFIG = @GTK_CONFIG@
158 GTK_LIBS = @GTK_LIBS@
159 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
160 GTK_MAC_LIBS = @GTK_MAC_LIBS@
161 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
162 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
163 INSTALL = @INSTALL@
164 INSTALL_DATA = @INSTALL_DATA@
165 INSTALL_PROGRAM = @INSTALL_PROGRAM@
166 INSTALL_SCRIPT = @INSTALL_SCRIPT@
167 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
168 LDFLAGS = @LDFLAGS@
169 LEX = @LEX@
170 LEXLIB = @LEXLIB@
171 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
172 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
173 LIBBZ2_DIR = @LIBBZ2_DIR@
174 LIBBZ2_LDADD = @LIBBZ2_LDADD@
175 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
176 LIBJUDY_LDADD = @LIBJUDY_LDADD@
177 LIBOBJS = @LIBOBJS@
178 LIBS = @LIBS@
179 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
180 LIBXZ_LDADD = @LIBXZ_LDADD@
181 LIBZ_CFLAGS = @LIBZ_CFLAGS@
182 LIBZ_DIR = @LIBZ_DIR@
183 LIBZ_LDADD = @LIBZ_LDADD@
184 LTLIBOBJS = @LTLIBOBJS@
185 MAINT = @MAINT@
186 MAKEINFO = @MAKEINFO@
187 MINGW_LDADD = @MINGW_LDADD@
188 MKDIR_P = @MKDIR_P@
189 OBJEXT = @OBJEXT@
190 PACKAGE = @PACKAGE@
191 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
192 PACKAGE_NAME = @PACKAGE_NAME@
193 PACKAGE_STRING = @PACKAGE_STRING@
194 PACKAGE_TARNAME = @PACKAGE_TARNAME@
195 PACKAGE_URL = @PACKAGE_URL@
196 PACKAGE_VERSION = @PACKAGE_VERSION@
197 PATH_SEPARATOR = @PATH_SEPARATOR@
198 PKG_CONFIG = @PKG_CONFIG@
199 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
200 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
201 POW_LIB = @POW_LIB@
202 RANLIB = @RANLIB@
203 RPC_CFLAGS = @RPC_CFLAGS@
204 RPC_LDADD = @RPC_LDADD@
205 SET_MAKE = @SET_MAKE@
206 SHELL = @SHELL@
207 STRIP = @STRIP@
208 STRUCT_PACK = @STRUCT_PACK@
209 TCL_DEFADD = @TCL_DEFADD@
210 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
211 TCL_LDADD = @TCL_LDADD@
212 TCL_LIB_SPEC = @TCL_LIB_SPEC@
213 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
214 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
215 TIRPC_CFLAGS = @TIRPC_CFLAGS@
216 TIRPC_LIBS = @TIRPC_LIBS@
217 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
218 TK_LDADD = @TK_LDADD@
219 TK_LIB_SPEC = @TK_LIB_SPEC@
220 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
221 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
222 VERSION = @VERSION@
223 XDGDATADIR = @XDGDATADIR@
224 abs_builddir = @abs_builddir@
225 abs_srcdir = @abs_srcdir@
226 abs_top_builddir = @abs_top_builddir@
227 abs_top_srcdir = @abs_top_srcdir@
228 ac_ct_CC = @ac_ct_CC@
229 ac_ct_CXX = @ac_ct_CXX@
230 am__include = @am__include@
231 am__leading_dot = @am__leading_dot@
232 am__quote = @am__quote@
233 am__tar = @am__tar@
234 am__untar = @am__untar@
235 bindir = @bindir@
236 build_alias = @build_alias@
237 builddir = @builddir@
238 datadir = @datadir@
239 datarootdir = @datarootdir@
240 docdir = @docdir@
241 dvidir = @dvidir@
242 exec_prefix = @exec_prefix@
243 gsettingsschemadir = @gsettingsschemadir@
244 host_alias = @host_alias@
245 htmldir = @htmldir@
246 includedir = @includedir@
247 infodir = @infodir@
248 install_sh = @install_sh@
249 libdir = @libdir@
250 libexecdir = @libexecdir@
251 localedir = @localedir@
252 localstatedir = @localstatedir@
253 mandir = @mandir@
254 mkdir_p = @mkdir_p@
255 oldincludedir = @oldincludedir@
256 pdfdir = @pdfdir@
257 prefix = @prefix@
258 program_transform_name = @program_transform_name@
259 psdir = @psdir@
260 sbindir = @sbindir@
261 sharedstatedir = @sharedstatedir@
262 srcdir = @srcdir@
263 sysconfdir = @sysconfdir@
264 target_alias = @target_alias@
265 top_build_prefix = @top_build_prefix@
266 top_builddir = @top_builddir@
267 top_srcdir = @top_srcdir@
268 EXTRA_DIST = SASTBase.h SCommonAST.h STreeParser.h astlib.h \
269 sintstack.h sorcerer.h sorlist.h sstack.h
270
271 all: all-am
272
273 .SUFFIXES:
274 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
275 @for dep in $?; do \
276 case '$(am__configure_deps)' in \
277 *$$dep*) \
278 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
279 && { if test -f $@; then exit 0; else break; fi; }; \
280 exit 1;; \
281 esac; \
282 done; \
283 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/sorcerer/h/Makefile'; \
284 $(am__cd) $(top_srcdir) && \
285 $(AUTOMAKE) --foreign contrib/pccts/sorcerer/h/Makefile
286 .PRECIOUS: Makefile
287 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
288 @case '$?' in \
289 *config.status*) \
290 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
291 *) \
292 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
293 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
294 esac;
295
296 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
297 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
298
299 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
300 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
301 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
302 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
303 $(am__aclocal_m4_deps):
304 tags TAGS:
305
306 ctags CTAGS:
307
308 cscope cscopelist:
309
310
311 distdir: $(DISTFILES)
312 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
313 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
314 list='$(DISTFILES)'; \
315 dist_files=`for file in $$list; do echo $$file; done | \
316 sed -e "s|^$$srcdirstrip/||;t" \
317 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
318 case $$dist_files in \
319 */*) $(MKDIR_P) `echo "$$dist_files" | \
320 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
321 sort -u` ;; \
322 esac; \
323 for file in $$dist_files; do \
324 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
325 if test -d $$d/$$file; then \
326 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
327 if test -d "$(distdir)/$$file"; then \
328 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
329 fi; \
330 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
331 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
332 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
333 fi; \
334 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
335 else \
336 test -f "$(distdir)/$$file" \
337 || cp -p $$d/$$file "$(distdir)/$$file" \
338 || exit 1; \
339 fi; \
340 done
341 check-am: all-am
342 check: check-am
343 all-am: Makefile
344 installdirs:
345 install: install-am
346 install-exec: install-exec-am
347 install-data: install-data-am
348 uninstall: uninstall-am
349
350 install-am: all-am
351 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
352
353 installcheck: installcheck-am
354 install-strip:
355 if test -z '$(STRIP)'; then \
356 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
357 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
358 install; \
359 else \
360 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
361 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
362 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
363 fi
364 mostlyclean-generic:
365
366 clean-generic:
367
368 distclean-generic:
369 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
370 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
371
372 maintainer-clean-generic:
373 @echo "This command is intended for maintainers to use"
374 @echo "it deletes files that may require special tools to rebuild."
375 clean: clean-am
376
377 clean-am: clean-generic mostlyclean-am
378
379 distclean: distclean-am
380 -rm -f Makefile
381 distclean-am: clean-am distclean-generic
382
383 dvi: dvi-am
384
385 dvi-am:
386
387 html: html-am
388
389 html-am:
390
391 info: info-am
392
393 info-am:
394
395 install-data-am:
396
397 install-dvi: install-dvi-am
398
399 install-dvi-am:
400
401 install-exec-am:
402
403 install-html: install-html-am
404
405 install-html-am:
406
407 install-info: install-info-am
408
409 install-info-am:
410
411 install-man:
412
413 install-pdf: install-pdf-am
414
415 install-pdf-am:
416
417 install-ps: install-ps-am
418
419 install-ps-am:
420
421 installcheck-am:
422
423 maintainer-clean: maintainer-clean-am
424 -rm -f Makefile
425 maintainer-clean-am: distclean-am maintainer-clean-generic
426
427 mostlyclean: mostlyclean-am
428
429 mostlyclean-am: mostlyclean-generic
430
431 pdf: pdf-am
432
433 pdf-am:
434
435 ps: ps-am
436
437 ps-am:
438
439 uninstall-am:
440
441 .MAKE: install-am install-strip
442
443 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
444 ctags-am distclean distclean-generic distdir dvi dvi-am html \
445 html-am info info-am install install-am install-data \
446 install-data-am install-dvi install-dvi-am install-exec \
447 install-exec-am install-html install-html-am install-info \
448 install-info-am install-man install-pdf install-pdf-am \
449 install-ps install-ps-am install-strip installcheck \
450 installcheck-am installdirs maintainer-clean \
451 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
452 pdf-am ps ps-am tags-am uninstall uninstall-am
453
454
455 # Tell versions [3.59,3.63) of GNU make to not export all variables.
456 # Otherwise a system limit (for SysV at least) may be exceeded.
457 .NOEXPORT:
+0
-8
contrib/pccts/sorcerer/h/SASTBase.h less more
0 #ifndef SASTBase_h
1 #define SASTBase_h
2
3 #include "PCCTSAST.h"
4
5 typedef PCCTS_AST SORASTBase;
6
7 #endif
+0
-26
contrib/pccts/sorcerer/h/SCommonAST.h less more
0 #ifndef SCommonAST_h
1 #define SCommonAST_h
2
3 #include <stdio.h>
4 #include "PCCTSAST.h"
5 #include "SASTBase.h"
6
7 /* If you use SORCERER alone, you can subclass this to get a nice tree def */
8
9 class SORCommonAST : public SORASTBase {
10 protected:
11 SORCommonAST *_right, *_down;
12 int _type;
13
14 public:
15 SORCommonAST() { _right = _down = NULL; }
16 PCCTS_AST *right() { return _right; } // define the SORCERER interface
17 PCCTS_AST *down() { return _down; }
18 int type() { return _type; }
19 void setRight(PCCTS_AST *t) { _right = (SORCommonAST *)t; }
20 void setDown(PCCTS_AST *t) { _down = (SORCommonAST *)t; }
21 void setType(int t) { _type = t; }
22 virtual PCCTS_AST *shallowCopy() {return NULL;}
23 };
24
25 #endif
+0
-112
contrib/pccts/sorcerer/h/STreeParser.h less more
0 #ifndef STreeParser_h
1 #define STreeParser_h
2
3 /*
4 * STreeParser.h
5 *
6 * SOFTWARE RIGHTS
7 *
8 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
9 * domain. An individual or company may do whatever they wish with
10 * source code distributed with SORCERER or the code generated by
11 * SORCERER, including the incorporation of SORCERER, or its output, into
12 * commerical software.
13 *
14 * We encourage users to develop software with SORCERER. However, we do
15 * ask that credit is given to us for developing SORCERER. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like SORCERER and have developed a nice tool with the
20 * output, please mention that you developed it using SORCERER. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
24 * completed.
25 *
26 * SORCERER 1.00B
27 * Parr Research Corporation
28 * with Purdue University and AHPCRC, University of Minnesota
29 * 1992-1994
30 */
31
32 /* The programmer should derive a class from SORASTBase; SORASTBase defines
33 * the minimum public interface that a tree node must follow for SORCERER to
34 * be able to walk the trees.
35 */
36
37 /* The @-vars are added by the subclass created by SORCERER; the constructor
38 * is used to init the @-vars.
39 */
40
41 #include <stdio.h>
42 #include <setjmp.h>
43 #include <stdlib.h>
44 #include "SASTBase.h"
45
46 #define _DOWN _t=(SORASTBase *)_t->down()
47 #define _RIGHT _t=(SORASTBase *)_t->right()
48
49 #define _SAVE SORASTBase *_save=_t
50 #define _RESTORE _t = _save
51 #define _GUESS_BLOCK STreeParser _st; int _gv; SORASTBase *_savet=NULL;
52 #define _GUESS {save_state(&_st); \
53 _savet = _t; \
54 guessing = 1; \
55 _gv = setjmp(startofguess.state);}
56 #define _GUESS_FAIL longjmp(startofguess.state, 1)
57 #define _GUESS_DONE {restore_state(&_st); _t = _savet;}
58 #define _MATCH(tok) MATCH(_t,tok)
59 #define _MATCHRANGE(t1,t2) MATCHRANGE(_t,t1,t2)
60 #define _WILDCARD WILDCARD(_t)
61
62 #define ast_return(t) *_result = (SORASTBase *)t;
63
64 #define STreeTry(r,p,t) \
65 (p)->try_result = NULL; \
66 (p)->sjrv = setjmp((p)->startofguess); \
67 if ( !(p)->sjrv ) { \
68 rule(p,t,&try_result); \
69 (p)->try_ok = 1; \
70 } \
71 else { \
72 (p)->try_ok = 0; \
73 } \
74 if ( (p)->try_ok )
75
76
77 /* Used only during TRANSFORM mode */
78 #define TREE_CONSTR_PTRS SORASTBase *_r=NULL,*_s=NULL,*_e=NULL
79
80 typedef struct _Sjmp_buf {
81 jmp_buf state;
82 } Sjmp_buf;
83
84 class STreeParser {
85 protected:
86 int try_ok, sjrv; /* used by STreeTry macro */
87 SORASTBase *try_result; /* tree coming back from try */
88 int guessing;
89 Sjmp_buf startofguess;
90 // SORASTBase *t;
91
92 void _mkroot(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);
93 void _mkchild(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);
94 virtual void mismatched_range(int looking_for, int upper_token, SORASTBase *found);
95 virtual void missing_wildcard();
96 virtual void mismatched_token(int looking_for, SORASTBase *found);
97 virtual void no_viable_alt(char *rulename, SORASTBase *root);
98 virtual void MATCH(SORASTBase *_t, int tok);
99 virtual void MATCHRANGE(SORASTBase *_t, int tok, int tok2);
100 virtual void WILDCARD(SORASTBase *_t);
101
102 public:
103 STreeParser() { guessing = 0; }
104 virtual void panic(char *err);
105 void save_state(STreeParser *);
106 void restore_state(STreeParser *);
107
108 virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
109 };
110
111 #endif
+0
-79
contrib/pccts/sorcerer/h/astlib.h less more
0 #ifndef astlib_h
1 #define astlib_h
2
3 /*
4 * astlib.h -- C ast_* library header
5 *
6 * SOFTWARE RIGHTS
7 *
8 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
9 * domain. An individual or company may do whatever they wish with
10 * source code distributed with SORCERER or the code generated by
11 * SORCERER, including the incorporation of SORCERER, or its output, into
12 * commerical software.
13 *
14 * We encourage users to develop software with SORCERER. However, we do
15 * ask that credit is given to us for developing SORCERER. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like SORCERER and have developed a nice tool with the
20 * output, please mention that you developed it using SORCERER. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
24 * completed.
25 *
26 * SORCERER 1.00B
27 * Terence Parr
28 * AHPCRC, University of Minnesota
29 * 1992-1994
30 */
31 #include <setjmp.h>
32 #include "sorcerer.h"
33 #include "sorlist.h"
34
35 #define MaxTreeStackDepth 400
36
37 /* MR26 */
38
39 #ifdef PCCTS_USE_STDARG
40 extern SORAST *ast_make(SORAST *rt, ...);
41 extern int ast_scan(char *_template /* MR32 */, SORAST *tree, ...);
42 #else
43 extern SORAST *ast_make();
44 extern int ast_scan();
45 #endif
46
47 #ifdef __USE_PROTOS
48
49 extern SORAST *ast_find_all(SORAST *t, SORAST *u, SORAST **cursor);
50 extern int ast_match(SORAST *t, SORAST *u);
51 extern void ast_insert_after(SORAST *a, SORAST *b);
52 extern void ast_append(SORAST *a, SORAST *b);
53 extern SORAST *ast_tail(SORAST *a);
54 extern SORAST *ast_bottom(SORAST *a);
55 extern SORAST *ast_cut_between(SORAST *a, SORAST *b);
56 extern SList *ast_to_slist(SORAST *t);
57 extern SORAST *slist_to_ast(SList *list);
58 extern void ast_free(SORAST *t);
59 extern int ast_nsiblings(SORAST *t);
60 extern SORAST *ast_sibling_index(SORAST *t, int i);
61 extern int ast_match_partial(SORAST *t, SORAST *u);
62 #else
63 extern SORAST *ast_find_all();
64 extern int ast_match();
65 extern void ast_insert_after();
66 extern void ast_append();
67 extern SORAST *ast_tail();
68 extern SORAST *ast_bottom();
69 extern SORAST *ast_cut_between();
70 extern SList *ast_to_slist();
71 extern SORAST *slist_to_ast();
72 extern void ast_free();
73 extern int ast_nsiblings();
74 extern SORAST *ast_sibling_index();
75 extern int ast_match_partial();
76 #endif
77
78 #endif
+0
-61
contrib/pccts/sorcerer/h/sintstack.h less more
0 #ifndef SINTSTACK_H
1 #define SINTSTACK_H
2
3 /*
4 * SIntStack.h
5 *
6 * SOFTWARE RIGHTS
7 *
8 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
9 * domain. An individual or company may do whatever they wish with
10 * source code distributed with SORCERER or the code generated by
11 * SORCERER, including the incorporation of SORCERER, or its output, into
12 * commerical software.
13 *
14 * We encourage users to develop software with SORCERER. However, we do
15 * ask that credit is given to us for developing SORCERER. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like SORCERER and have developed a nice tool with the
20 * output, please mention that you developed it using SORCERER. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
24 * completed.
25 *
26 * SORCERER 1.00B
27 * Terence Parr
28 * AHPCRC, University of Minnesota
29 * 1992-1994
30 */
31
32 #include "sorcerer.h"
33
34 typedef struct _istack {
35 int *data;
36 int sp;
37 int size;
38 } SIntStack;
39
40 #ifdef __USE_PROTOS
41 extern SIntStack *sint_newstack(int size);
42 extern void sint_freestack(SIntStack *st);
43 extern void sint_push(SIntStack *st, int i);
44 extern int sint_pop(SIntStack *st);
45 extern int sint_stacksize(SIntStack *st);
46 extern void sint_stackreset(SIntStack *st);
47 extern int sint_stackempty(SIntStack *st);
48 extern int sint_top(SIntStack *st);
49 #else
50 extern SIntStack *sint_newstack();
51 extern void sint_freestack();
52 extern void sint_push();
53 extern int sint_pop();
54 extern int sint_stacksize();
55 extern void sint_stackreset();
56 extern int sint_stackempty();
57 extern int sint_top();
58 #endif
59
60 #endif
+0
-172
contrib/pccts/sorcerer/h/sorcerer.h less more
0 #ifndef sorcerer_h
1 #define sorcerer_h
2
3 /*
4 * sorcerer.h -- header for all sorcerer files
5 *
6 * SOFTWARE RIGHTS
7 *
8 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
9 * domain. An individual or company may do whatever they wish with
10 * source code distributed with SORCERER or the code generated by
11 * SORCERER, including the incorporation of SORCERER, or its output, into
12 * commerical software.
13 *
14 * We encourage users to develop software with SORCERER. However, we do
15 * ask that credit is given to us for developing SORCERER. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like SORCERER and have developed a nice tool with the
20 * output, please mention that you developed it using SORCERER. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
24 * completed.
25 *
26 * SORCERER 1.00B
27 * Terence Parr
28 * AHPCRC, University of Minnesota
29 * 1992-1994
30 */
31
32 #include "pcctscfg.h"
33
34 #ifdef __USE_PROTOS
35 #include <stdlib.h>
36 #else
37 #include <malloc.h>
38 #endif
39
40 #include <setjmp.h>
41
42 /* SUPERCLASS SORAST (your tree must look at minimum like this)
43 typedef struct _node {
44 struct _node *right, *down;
45 int token;
46 -- user-defined stuff goes here
47 } SORAST;
48 */
49
50 /* Can be used sort of like inheritance to get the desired struct def */
51 #define AST_REQD_FIELDS \
52 struct _node *right, *down; \
53 int token;
54
55 /* C MATCH */ /* MR21 Short circuit on null pointer */
56 #define _MATCH(tok) if (! _t || _t->token!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t)
57 #define _MATCHRANGE(tok,tok2) \
58 if (! _t || _t->token<tok || _t->token>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t)
59
60 /* C++ MATCH */
61 #define _CPPMATCH(tok) if ( _t->token()!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t)
62 #define _CPPMATCHRANGE(tok,tok2) \
63 if ( _t->token()<tok || _t->token()>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t)
64
65 /* Normal DOWN and RIGHT */
66 #define _DOWN _t=_t->down
67 #define _RIGHT _t=_t->right
68
69 /* C++ DOWN and RIGHT */
70 #define _CPPDOWN _t=(SORAST *) _t->down()
71 #define _CPPRIGHT _t=(SORAST *) _t->right()
72
73 #define _SAVE SORAST *_save=_t
74 #define _RESTORE _t = _save
75 #define _SETLABEL(u) u=_t
76 #define _WILDCARD if ( _t==NULL ) if ( _parser->guessing ) _GUESS_FAIL; else missing_wildcard(_parser)
77 #define _GUESS_BLOCK STreeParser _st; int _gv; SORAST *_savet=NULL;
78 #define _GUESS {_st = *_parser; \
79 _savet = _t; \
80 _parser->guessing = 1; \
81 _gv = setjmp(_parser->startofguess.state);}
82 #define _GUESS_FAIL longjmp(_parser->startofguess.state, 1)
83 #define _GUESS_DONE {*_parser = _st; _t = _savet;}
84
85 /* These are used mainly by the C output */
86 #ifndef ast_down
87 #define ast_down down
88 #endif
89 #ifndef ast_right
90 #define ast_right right
91 #endif
92
93 #define STreeTry(r,p,t) \
94 (p)->try_result = NULL; \
95 (p)->sjrv = setjmp((p)->startofguess); \
96 if ( !(p)->sjrv ) { \
97 rule(p,t,&try_result); \
98 (p)->try_ok = 1; \
99 } \
100 else { \
101 (p)->try_ok = 0; \
102 } \
103 if ( (p)->try_ok )
104
105
106 /* Used only during TRANSFORM mode */
107 #define TREE_CONSTR_PTRS SORAST *_r=NULL,*_s=NULL,*_e=NULL
108
109 typedef struct _Sjmp_buf {
110 jmp_buf state;
111 } Sjmp_buf;
112
113 #ifndef _PARSER_VARS
114 #define _PARSER_VARS
115 #endif
116
117 #ifndef _REFVARS
118 #define _REFVARS
119 #endif
120
121 typedef struct _STreeParser {
122 int try_ok, sjrv; /* used by STreeTry macro */
123 SORAST *try_result; /* tree coming back from try */
124 int guessing;
125 Sjmp_buf startofguess;
126 SORAST *t;
127 _REFVARS
128 _PARSER_VARS
129 } STreeParser;
130
131 #define STreeParserInit(_p) { (_p)->guessing = 0; _refvar_inits(_p); }
132
133
134 /* S a n i t y C h e c k i n g */
135
136 #ifndef require
137 #define require(expr, err) {if ( !(expr) ) sorcerer_panic(err);}
138 #endif
139
140
141 /* T r a n s f o r m M a c r o s */
142 #define ast_return(_t) *_result = _t
143
144
145 #ifdef __USE_PROTOS
146 extern void mismatched_range(STreeParser *_parser, int looking_for, int upper_token, SORAST *found);
147 extern void missing_wildcard(STreeParser *_parser);
148 extern void mismatched_token(STreeParser *_parser, int looking_for, SORAST *found);
149 extern void no_viable_alt(STreeParser *_parser, char *rulename, SORAST *root);
150 extern void sorcerer_panic(char *err);
151 extern void _refvar_inits(STreeParser *); /* MR15 Kevin J. Cummings */
152 extern void _mkroot(SORAST **, SORAST **, SORAST **, SORAST *);
153 extern void _mkchild(SORAST **, SORAST **, SORAST **, SORAST *);
154 extern SORAST *ast_alloc(void);
155 extern SORAST *ast_dup(SORAST *t);
156 extern SORAST *ast_dup_node(SORAST *t);
157 #else
158 extern void mismatched_range();
159 extern void missing_wildcard();
160 extern void mismatched_token();
161 extern void no_viable_alt();
162 extern void sorcerer_panic();
163 extern void _refvar_inits(); /* MR15 Kevin J. Cummings */
164 extern void _mkroot();
165 extern void _mkchild();
166 extern SORAST *ast_alloc();
167 extern SORAST *ast_dup();
168 extern SORAST *ast_dup_node();
169 #endif
170
171 #endif
+0
-52
contrib/pccts/sorcerer/h/sorlist.h less more
0 #ifndef SLIST_H
1 #define SLIST_H
2
3 /*
4 * SList.h
5 *
6 * SOFTWARE RIGHTS
7 *
8 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
9 * domain. An individual or company may do whatever they wish with
10 * source code distributed with SORCERER or the code generated by
11 * SORCERER, including the incorporation of SORCERER, or its output, into
12 * commerical software.
13 *
14 * We encourage users to develop software with SORCERER. However, we do
15 * ask that credit is given to us for developing SORCERER. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like SORCERER and have developed a nice tool with the
20 * output, please mention that you developed it using SORCERER. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
24 * completed.
25 *
26 * SORCERER 1.00B
27 * Terence Parr
28 * AHPCRC, University of Minnesota
29 * 1992-1994
30 */
31
32 #include "sorcerer.h"
33
34 typedef struct _SList {
35 void *elem; /* pointer to any kind of element */
36 struct _SList *next;
37 } SList;
38
39 #define newSList (SList *) calloc(1, sizeof(SList));
40
41 #ifdef __USE_PROTOS
42 extern void *slist_iterate(SList *list, SList **);
43 extern void slist_add( SList **list, void *e );
44 extern void slist_free(SList *list);
45 #else
46 extern void *slist_iterate();
47 extern void slist_add();
48 extern void slist_free();
49 #endif
50
51 #endif
+0
-46
contrib/pccts/sorcerer/h/sstack.h less more
0 #ifndef SSTACK_H
1 #define SSTACK_H
2
3 /*
4 * SStack.h
5 *
6 * SOFTWARE RIGHTS
7 *
8 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
9 * domain. An individual or company may do whatever they wish with
10 * source code distributed with SORCERER or the code generated by
11 * SORCERER, including the incorporation of SORCERER, or its output, into
12 * commerical software.
13 *
14 * We encourage users to develop software with SORCERER. However, we do
15 * ask that credit is given to us for developing SORCERER. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like SORCERER and have developed a nice tool with the
20 * output, please mention that you developed it using SORCERER. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
24 * completed.
25 *
26 * SORCERER 1.00B
27 * Terence Parr
28 * AHPCRC, University of Minnesota
29 * 1992-1994
30 */
31 #include "sorlist.h"
32
33 typedef SList SStack;
34
35 #define newSStack (SStack *) calloc(1, sizeof(SStack));
36
37 #ifdef __USE_PROTOS
38 extern void sstack_push( SStack **st, void *e );
39 extern void *sstack_pop( SStack **st );
40 #else
41 extern void sstack_push();
42 extern void *sstack_pop();
43 #endif
44
45 #endif
+0
-199
contrib/pccts/sorcerer/hash.c less more
0 /*
1 * hash.c -- Manage hash tables.
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-2001
27 */
28 #include <stdio.h>
29
30 #include "pcctscfg.h"
31 #include "hash.h"
32
33 #ifdef __USE_PROTOS
34 #include <stdlib.h>
35 #else
36 #ifdef VAXC
37 #include <stdlib.h>
38 #else
39 #include <malloc.h>
40 #endif
41 #endif
42 #include <string.h>
43
44 /* OSX warning fix */
45 #define GR_INT int
46
47 #define StrSame 0
48 #define fatal(err) \
49 {fprintf(stderr, "%s(%d):", __FILE__, __LINE__); \
50 fprintf(stderr, " %s\n", err); exit(1);}
51 #define require(expr, err) {if ( !(expr) ) fatal(err);}
52
53 static unsigned size = HashTableSize;
54 static char *strings = NULL;
55 static char *strp;
56 static unsigned strsize = StrTableSize;
57
58 /* create the hash table and string table for terminals (string table only once) */
59 Entry **
60 #ifdef __USE_PROTOS
61 newHashTable( void )
62 #else
63 newHashTable( )
64 #endif
65 {
66 Entry **table;
67
68 table = (Entry **) calloc(size, sizeof(Entry *));
69 require( table != NULL, "cannot allocate hash table");
70 if ( strings == NULL )
71 {
72 strings = (char *) calloc(strsize, sizeof(char));
73 require( strings != NULL, "cannot allocate string table");
74 strp = strings;
75 }
76 return table;
77 }
78
79 /* Given a table, add 'rec' with key 'key' (add to front of list). return ptr to entry */
80 Entry *
81 #ifdef __USE_PROTOS
82 hash_add( Entry **table, char *key, Entry *rec )
83 #else
84 hash_add( table, key, rec )
85 Entry **table;
86 char *key;
87 Entry *rec;
88 #endif
89 {
90 unsigned h=0;
91 char *p=key;
92 /* extern Entry *Globals; MR20 G. Hobbelt unused reference */
93 require(table!=NULL && key!=NULL && rec!=NULL, "add: invalid addition");
94
95 Hash(p,h,size);
96 rec->next = table[h]; /* Add to singly-linked list */
97 table[h] = rec;
98 return rec;
99 }
100
101 /* Return ptr to 1st entry found in table under key (return NULL if none found) */
102 Entry *
103 #ifdef __USE_PROTOS
104 hash_get( Entry **table, char *key )
105 #else
106 hash_get( table, key )
107 Entry **table;
108 char *key;
109 #endif
110 {
111 unsigned h=0;
112 char *p=key;
113 Entry *q;
114 require(table!=NULL && key!=NULL, "get: invalid table and/or key");
115
116 Hash(p,h,size);
117 for (q = table[h]; q != NULL; q = q->next)
118 {
119 if ( strcmp(key, q->str) == StrSame ) return( q );
120 }
121 return( NULL );
122 }
123
124 void
125 #ifdef __USE_PROTOS
126 hashStat( Entry **table )
127 #else
128 hashStat( table )
129 Entry **table;
130 #endif
131 {
132 static unsigned short count[20];
133 int i,n=0,low=0, hi=0;
134 Entry **p;
135 float avg=0.0;
136
137 for (i=0; i<20; i++) count[i] = 0;
138 for (p=table; p<&(table[size]); p++)
139 {
140 Entry *q = *p;
141 int len;
142
143 if ( q != NULL && low==0 ) low = p-table;
144 len = 0;
145 if ( q != NULL ) fprintf(stderr, "[%d]", (GR_INT)(p-table));
146 while ( q != NULL )
147 {
148 len++;
149 n++;
150 fprintf(stderr, " %s", q->str);
151 q = q->next;
152 if ( q == NULL ) fprintf(stderr, "\n");
153 }
154 count[len]++;
155 if ( *p != NULL ) hi = p-table;
156 }
157
158 fprintf(stderr, "Storing %d recs used %d hash positions out of %d\n",
159 n, size-count[0], size);
160 fprintf(stderr, "%f %% utilization\n",
161 ((float)(size-count[0]))/((float)size));
162 for (i=0; i<20; i++)
163 {
164 if ( count[i] != 0 )
165 {
166 avg += (((float)(i*count[i]))/((float)n)) * i;
167 fprintf(stderr, "Bucket len %d == %d (%f %% of recs)\n",
168 i, count[i], ((float)(i*count[i]))/((float)n));
169 }
170 }
171 fprintf(stderr, "Avg bucket length %f\n", avg);
172 fprintf(stderr, "Range of hash function: %d..%d\n", low, hi);
173 }
174
175 /* Add a string to the string table and return a pointer to it.
176 * Bump the pointer into the string table to next avail position.
177 */
178 char *
179 #ifdef __USE_PROTOS
180 mystrdup( char *s )
181 #else
182 mystrdup( s )
183 char *s;
184 #endif
185 {
186 char *start=strp;
187 require(s!=NULL, "mystrdup: NULL string");
188
189 while ( *s != '\0' )
190 {
191 require( strp <= &(strings[strsize-2]),
192 "string table overflow\nIncrease StrTableSize in hash.h and recompile hash.c\n");
193 *strp++ = *s++;
194 }
195 *strp++ = '\0';
196
197 return( start );
198 }
+0
-66
contrib/pccts/sorcerer/hash.h less more
0 /*
1 * hash.h -- define hash table entries, sizes, hash function...
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-2001
27 */
28
29 /* H a s h T a b l e S t u f f */
30 #ifndef __sorcerer_hash_h__
31 #define __sorcerer_hash_h__
32
33 #include "pcctscfg.h" /* MR20 G. Hobbelt - Use __USE_PROTOS */
34
35 #ifndef HashTableSize
36 #define HashTableSize 553
37 #endif
38 #ifndef StrTableSize
39 #define StrTableSize 40000
40 #endif
41
42 typedef struct _entry { /* Minimum hash table entry -- superclass */
43 char *str;
44 struct _entry *next;
45 } Entry;
46
47 /* Hash 's' using 'size', place into h (s is modified) */
48 #define Hash(s,h,size) \
49 {while ( *s != '\0' ) h = (h<<1) + *s++; \
50 h %= size;}
51
52 #ifdef __USE_PROTOS
53 Entry *hash_get(Entry **, char *),
54 **newHashTable(void),
55 *hash_add(Entry **, char *, Entry *);
56 char *mystrdup(char *);
57 void hashStat( Entry ** );
58 #else
59 Entry *hash_get(), **newHashTable(), *hash_add();
60 char *mystrdup();
61 void hashStat();
62 #endif
63
64 #endif
65
+0
-45
contrib/pccts/sorcerer/lib/CASTBase.h less more
0 #ifndef CASTBase_h
1 #define CASTBase_h
2
3 /*
4 * CASTBase.h
5 *
6 * SOFTWARE RIGHTS
7 *
8 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
9 * domain. An individual or company may do whatever they wish with
10 * source code distributed with SORCERER or the code generated by
11 * SORCERER, including the incorporation of SORCERER, or its output, into
12 * commerical software.
13 *
14 * We encourage users to develop software with SORCERER. However, we do
15 * ask that credit is given to us for developing SORCERER. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like SORCERER and have developed a nice tool with the
20 * output, please mention that you developed it using SORCERER. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
24 * completed.
25 *
26 * SORCERER 1.00B
27 * Terence Parr
28 * AHPCRC, University of Minnesota
29 * 1992-1994
30 */
31
32 /* ONLY USED TO C COMPILE LIBRARY FUNCTIONS; YOU CAN FORCE THEM TO COMPILE WITH
33 * YOUR SORAST DEF IF YOU WANT (THAT WAY, ORDER OF FIELD DEFINITION IS IRRELEVANT)
34 */
35
36 /* Typically, this file is not used / seen by the programmer */
37
38 /* Used as "super-class" for compiling C library routines */
39 typedef struct _nodebase {
40 struct _nodebase *right, *down;
41 int token;
42 } SORAST;
43
44 #endif
+0
-12
contrib/pccts/sorcerer/lib/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3
4 #SRC = astlib.c sstack.c sorlist.c sintstack.c
5 #OBJ = astlib.o sstack.o sorlist.o sintstack.o
6 #CFLAGS=$(COPT) -I../../h -I../h
7
8 EXTRA_DIST= \
9 CASTBase.h STreeParser.cpp astlib.c errsupport.c \
10 msvc.dsp sintstack.c sorcerer.c sorlist.c sstack.c
11
+0
-463
contrib/pccts/sorcerer/lib/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 #SRC = astlib.c sstack.c sorlist.c sintstack.c
17 #OBJ = astlib.o sstack.o sorlist.o sintstack.o
18 #CFLAGS=$(COPT) -I../../h -I../h
19 VPATH = @srcdir@
20 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
21 am__make_running_with_option = \
22 case $${target_option-} in \
23 ?) ;; \
24 *) echo "am__make_running_with_option: internal error: invalid" \
25 "target option '$${target_option-}' specified" >&2; \
26 exit 1;; \
27 esac; \
28 has_opt=no; \
29 sane_makeflags=$$MAKEFLAGS; \
30 if $(am__is_gnu_make); then \
31 sane_makeflags=$$MFLAGS; \
32 else \
33 case $$MAKEFLAGS in \
34 *\\[\ \ ]*) \
35 bs=\\; \
36 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
37 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
38 esac; \
39 fi; \
40 skip_next=no; \
41 strip_trailopt () \
42 { \
43 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
44 }; \
45 for flg in $$sane_makeflags; do \
46 test $$skip_next = yes && { skip_next=no; continue; }; \
47 case $$flg in \
48 *=*|--*) continue;; \
49 -*I) strip_trailopt 'I'; skip_next=yes;; \
50 -*I?*) strip_trailopt 'I';; \
51 -*O) strip_trailopt 'O'; skip_next=yes;; \
52 -*O?*) strip_trailopt 'O';; \
53 -*l) strip_trailopt 'l'; skip_next=yes;; \
54 -*l?*) strip_trailopt 'l';; \
55 -[dEDm]) skip_next=yes;; \
56 -[JT]) skip_next=yes;; \
57 esac; \
58 case $$flg in \
59 *$$target_option*) has_opt=yes; break;; \
60 esac; \
61 done; \
62 test $$has_opt = yes
63 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
64 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
65 pkgdatadir = $(datadir)/@PACKAGE@
66 pkgincludedir = $(includedir)/@PACKAGE@
67 pkglibdir = $(libdir)/@PACKAGE@
68 pkglibexecdir = $(libexecdir)/@PACKAGE@
69 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
70 install_sh_DATA = $(install_sh) -c -m 644
71 install_sh_PROGRAM = $(install_sh) -c
72 install_sh_SCRIPT = $(install_sh) -c
73 INSTALL_HEADER = $(INSTALL_DATA)
74 transform = $(program_transform_name)
75 NORMAL_INSTALL = :
76 PRE_INSTALL = :
77 POST_INSTALL = :
78 NORMAL_UNINSTALL = :
79 PRE_UNINSTALL = :
80 POST_UNINSTALL = :
81 subdir = contrib/pccts/sorcerer/lib
82 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
83 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
84 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
85 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
86 $(ACLOCAL_M4)
87 mkinstalldirs = $(install_sh) -d
88 CONFIG_HEADER = $(top_builddir)/config.h
89 CONFIG_CLEAN_FILES =
90 CONFIG_CLEAN_VPATH_FILES =
91 AM_V_P = $(am__v_P_@AM_V@)
92 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
93 am__v_P_0 = false
94 am__v_P_1 = :
95 AM_V_GEN = $(am__v_GEN_@AM_V@)
96 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
97 am__v_GEN_0 = @echo " GEN " $@;
98 am__v_GEN_1 =
99 AM_V_at = $(am__v_at_@AM_V@)
100 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
101 am__v_at_0 = @
102 am__v_at_1 =
103 SOURCES =
104 DIST_SOURCES =
105 am__can_run_installinfo = \
106 case $$AM_UPDATE_INFO_DIR in \
107 n|no|NO) false;; \
108 *) (install-info --version) >/dev/null 2>&1;; \
109 esac
110 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
111 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
112 ACLOCAL = @ACLOCAL@
113 AET2_CFLAGS = @AET2_CFLAGS@
114 AET2_LDADD = @AET2_LDADD@
115 ALLOCA = @ALLOCA@
116 AMTAR = @AMTAR@
117 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
118 AUTOCONF = @AUTOCONF@
119 AUTOHEADER = @AUTOHEADER@
120 AUTOMAKE = @AUTOMAKE@
121 AWK = @AWK@
122 CC = @CC@
123 CCDEPMODE = @CCDEPMODE@
124 CFLAGS = @CFLAGS@
125 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
126 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
127 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
128 CPP = @CPP@
129 CPPFLAGS = @CPPFLAGS@
130 CXX = @CXX@
131 CXXDEPMODE = @CXXDEPMODE@
132 CXXFLAGS = @CXXFLAGS@
133 CYGPATH_W = @CYGPATH_W@
134 DEFS = @DEFS@
135 DEPDIR = @DEPDIR@
136 ECHO_C = @ECHO_C@
137 ECHO_N = @ECHO_N@
138 ECHO_T = @ECHO_T@
139 EGREP = @EGREP@
140 EXEEXT = @EXEEXT@
141 EXTDEBUG = @EXTDEBUG@
142 EXTDEBUG2 = @EXTDEBUG2@
143 EXTDEBUG3 = @EXTDEBUG3@
144 EXTDEBUG4 = @EXTDEBUG4@
145 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
146 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
147 FSDB_CFLAGS = @FSDB_CFLAGS@
148 FSDB_LDADD = @FSDB_LDADD@
149 GCONF_CFLAGS = @GCONF_CFLAGS@
150 GCONF_LIBS = @GCONF_LIBS@
151 GEDITTEST = @GEDITTEST@
152 GEDIT_CFLAGS = @GEDIT_CFLAGS@
153 GIO_CFLAGS = @GIO_CFLAGS@
154 GIO_LIBS = @GIO_LIBS@
155 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
156 GPERF = @GPERF@
157 GREP = @GREP@
158 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
159 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
160 GTK_CFLAGS = @GTK_CFLAGS@
161 GTK_CONFIG = @GTK_CONFIG@
162 GTK_LIBS = @GTK_LIBS@
163 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
164 GTK_MAC_LIBS = @GTK_MAC_LIBS@
165 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
166 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
167 INSTALL = @INSTALL@
168 INSTALL_DATA = @INSTALL_DATA@
169 INSTALL_PROGRAM = @INSTALL_PROGRAM@
170 INSTALL_SCRIPT = @INSTALL_SCRIPT@
171 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
172 LDFLAGS = @LDFLAGS@
173 LEX = @LEX@
174 LEXLIB = @LEXLIB@
175 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
176 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
177 LIBBZ2_DIR = @LIBBZ2_DIR@
178 LIBBZ2_LDADD = @LIBBZ2_LDADD@
179 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
180 LIBJUDY_LDADD = @LIBJUDY_LDADD@
181 LIBOBJS = @LIBOBJS@
182 LIBS = @LIBS@
183 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
184 LIBXZ_LDADD = @LIBXZ_LDADD@
185 LIBZ_CFLAGS = @LIBZ_CFLAGS@
186 LIBZ_DIR = @LIBZ_DIR@
187 LIBZ_LDADD = @LIBZ_LDADD@
188 LTLIBOBJS = @LTLIBOBJS@
189 MAINT = @MAINT@
190 MAKEINFO = @MAKEINFO@
191 MINGW_LDADD = @MINGW_LDADD@
192 MKDIR_P = @MKDIR_P@
193 OBJEXT = @OBJEXT@
194 PACKAGE = @PACKAGE@
195 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
196 PACKAGE_NAME = @PACKAGE_NAME@
197 PACKAGE_STRING = @PACKAGE_STRING@
198 PACKAGE_TARNAME = @PACKAGE_TARNAME@
199 PACKAGE_URL = @PACKAGE_URL@
200 PACKAGE_VERSION = @PACKAGE_VERSION@
201 PATH_SEPARATOR = @PATH_SEPARATOR@
202 PKG_CONFIG = @PKG_CONFIG@
203 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
204 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
205 POW_LIB = @POW_LIB@
206 RANLIB = @RANLIB@
207 RPC_CFLAGS = @RPC_CFLAGS@
208 RPC_LDADD = @RPC_LDADD@
209 SET_MAKE = @SET_MAKE@
210 SHELL = @SHELL@
211 STRIP = @STRIP@
212 STRUCT_PACK = @STRUCT_PACK@
213 TCL_DEFADD = @TCL_DEFADD@
214 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
215 TCL_LDADD = @TCL_LDADD@
216 TCL_LIB_SPEC = @TCL_LIB_SPEC@
217 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
218 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
219 TIRPC_CFLAGS = @TIRPC_CFLAGS@
220 TIRPC_LIBS = @TIRPC_LIBS@
221 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
222 TK_LDADD = @TK_LDADD@
223 TK_LIB_SPEC = @TK_LIB_SPEC@
224 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
225 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
226 VERSION = @VERSION@
227 XDGDATADIR = @XDGDATADIR@
228 abs_builddir = @abs_builddir@
229 abs_srcdir = @abs_srcdir@
230 abs_top_builddir = @abs_top_builddir@
231 abs_top_srcdir = @abs_top_srcdir@
232 ac_ct_CC = @ac_ct_CC@
233 ac_ct_CXX = @ac_ct_CXX@
234 am__include = @am__include@
235 am__leading_dot = @am__leading_dot@
236 am__quote = @am__quote@
237 am__tar = @am__tar@
238 am__untar = @am__untar@
239 bindir = @bindir@
240 build_alias = @build_alias@
241 builddir = @builddir@
242 datadir = @datadir@
243 datarootdir = @datarootdir@
244 docdir = @docdir@
245 dvidir = @dvidir@
246 exec_prefix = @exec_prefix@
247 gsettingsschemadir = @gsettingsschemadir@
248 host_alias = @host_alias@
249 htmldir = @htmldir@
250 includedir = @includedir@
251 infodir = @infodir@
252 install_sh = @install_sh@
253 libdir = @libdir@
254 libexecdir = @libexecdir@
255 localedir = @localedir@
256 localstatedir = @localstatedir@
257 mandir = @mandir@
258 mkdir_p = @mkdir_p@
259 oldincludedir = @oldincludedir@
260 pdfdir = @pdfdir@
261 prefix = @prefix@
262 program_transform_name = @program_transform_name@
263 psdir = @psdir@
264 sbindir = @sbindir@
265 sharedstatedir = @sharedstatedir@
266 srcdir = @srcdir@
267 sysconfdir = @sysconfdir@
268 target_alias = @target_alias@
269 top_build_prefix = @top_build_prefix@
270 top_builddir = @top_builddir@
271 top_srcdir = @top_srcdir@
272 EXTRA_DIST = \
273 CASTBase.h STreeParser.cpp astlib.c errsupport.c \
274 msvc.dsp sintstack.c sorcerer.c sorlist.c sstack.c
275
276 all: all-am
277
278 .SUFFIXES:
279 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
280 @for dep in $?; do \
281 case '$(am__configure_deps)' in \
282 *$$dep*) \
283 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
284 && { if test -f $@; then exit 0; else break; fi; }; \
285 exit 1;; \
286 esac; \
287 done; \
288 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/sorcerer/lib/Makefile'; \
289 $(am__cd) $(top_srcdir) && \
290 $(AUTOMAKE) --foreign contrib/pccts/sorcerer/lib/Makefile
291 .PRECIOUS: Makefile
292 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
293 @case '$?' in \
294 *config.status*) \
295 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
296 *) \
297 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
298 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
299 esac;
300
301 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
302 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
303
304 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
305 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
306 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
307 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
308 $(am__aclocal_m4_deps):
309 tags TAGS:
310
311 ctags CTAGS:
312
313 cscope cscopelist:
314
315
316 distdir: $(DISTFILES)
317 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
318 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
319 list='$(DISTFILES)'; \
320 dist_files=`for file in $$list; do echo $$file; done | \
321 sed -e "s|^$$srcdirstrip/||;t" \
322 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
323 case $$dist_files in \
324 */*) $(MKDIR_P) `echo "$$dist_files" | \
325 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
326 sort -u` ;; \
327 esac; \
328 for file in $$dist_files; do \
329 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
330 if test -d $$d/$$file; then \
331 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
332 if test -d "$(distdir)/$$file"; then \
333 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
334 fi; \
335 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
336 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
337 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
338 fi; \
339 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
340 else \
341 test -f "$(distdir)/$$file" \
342 || cp -p $$d/$$file "$(distdir)/$$file" \
343 || exit 1; \
344 fi; \
345 done
346 check-am: all-am
347 check: check-am
348 all-am: Makefile
349 installdirs:
350 install: install-am
351 install-exec: install-exec-am
352 install-data: install-data-am
353 uninstall: uninstall-am
354
355 install-am: all-am
356 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
357
358 installcheck: installcheck-am
359 install-strip:
360 if test -z '$(STRIP)'; then \
361 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
362 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
363 install; \
364 else \
365 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
366 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
367 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
368 fi
369 mostlyclean-generic:
370
371 clean-generic:
372
373 distclean-generic:
374 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
375 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
376
377 maintainer-clean-generic:
378 @echo "This command is intended for maintainers to use"
379 @echo "it deletes files that may require special tools to rebuild."
380 clean: clean-am
381
382 clean-am: clean-generic mostlyclean-am
383
384 distclean: distclean-am
385 -rm -f Makefile
386 distclean-am: clean-am distclean-generic
387
388 dvi: dvi-am
389
390 dvi-am:
391
392 html: html-am
393
394 html-am:
395
396 info: info-am
397
398 info-am:
399
400 install-data-am:
401
402 install-dvi: install-dvi-am
403
404 install-dvi-am:
405
406 install-exec-am:
407
408 install-html: install-html-am
409
410 install-html-am:
411
412 install-info: install-info-am
413
414 install-info-am:
415
416 install-man:
417
418 install-pdf: install-pdf-am
419
420 install-pdf-am:
421
422 install-ps: install-ps-am
423
424 install-ps-am:
425
426 installcheck-am:
427
428 maintainer-clean: maintainer-clean-am
429 -rm -f Makefile
430 maintainer-clean-am: distclean-am maintainer-clean-generic
431
432 mostlyclean: mostlyclean-am
433
434 mostlyclean-am: mostlyclean-generic
435
436 pdf: pdf-am
437
438 pdf-am:
439
440 ps: ps-am
441
442 ps-am:
443
444 uninstall-am:
445
446 .MAKE: install-am install-strip
447
448 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
449 ctags-am distclean distclean-generic distdir dvi dvi-am html \
450 html-am info info-am install install-am install-data \
451 install-data-am install-dvi install-dvi-am install-exec \
452 install-exec-am install-html install-html-am install-info \
453 install-info-am install-man install-pdf install-pdf-am \
454 install-ps install-ps-am install-strip installcheck \
455 installcheck-am installdirs maintainer-clean \
456 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
457 pdf-am ps ps-am tags-am uninstall uninstall-am
458
459
460 # Tell versions [3.59,3.63) of GNU make to not export all variables.
461 # Otherwise a system limit (for SysV at least) may be exceeded.
462 .NOEXPORT:
+0
-161
contrib/pccts/sorcerer/lib/STreeParser.cpp less more
0 #include "pccts_stdio.h" //MR23
1 #include "pccts_stdarg.h" //MR23
2 #include "STreeParser.h"
3
4 void STreeParser::
5 MATCH(SORASTBase *_t,int tok)
6 {
7 if ( _t->type()!=tok )
8 {
9 if ( guessing ) _GUESS_FAIL;
10 else mismatched_token(tok, _t);
11 }
12 }
13
14 void STreeParser::
15 MATCHRANGE(SORASTBase *_t,int tok,int tok2)
16 {
17 if ( _t->type()<tok || _t->type()>tok2 )
18 {
19 if ( guessing ) _GUESS_FAIL;
20 else mismatched_range(tok, tok2, _t);
21 }
22 }
23
24 void STreeParser::
25 WILDCARD(SORASTBase *_t)
26 {
27 if ( _t==NULL )
28 {
29 if ( guessing ) _GUESS_FAIL;
30 else missing_wildcard();
31 }
32 }
33
34 void STreeParser::
35 mismatched_range(int looking_for, int upper_token, SORASTBase *found)
36 {
37 if ( found!=NULL ) {
38 /* MR23 */ printMessage(stderr,
39 "parse error: expected token range %d..%d found token %d\n",
40 looking_for, upper_token,
41 found->type());
42 }
43 else {
44 /* MR23 */ printMessage(stderr,
45 "parse error: expected token range %d..%d found NULL tree\n",
46 looking_for, upper_token);
47 }
48 }
49
50 void STreeParser::
51 missing_wildcard()
52 {
53 /* MR23 */ printMessage(stderr, "parse error: expected any token/tree found found NULL tree\n");
54 }
55
56 void STreeParser::
57 mismatched_token(int looking_for, SORASTBase *found)
58 {
59 if ( found!=NULL ) {
60 /* MR23 */ printMessage(stderr,
61 "parse error: expected token %d found token %d\n",
62 looking_for,
63 found->type());
64 }
65 else {
66 /* MR23 */ printMessage(stderr,
67 "parse error: expected token %d found NULL tree\n",
68 looking_for);
69 }
70 }
71
72 void STreeParser::
73 no_viable_alt(char *rulename, SORASTBase *root)
74 {
75 if ( root==NULL )
76 /* MR23 */ printMessage(stderr,
77 "parse error: in rule %s, no viable alternative for NULL tree\n",
78 rulename);
79 else
80 /* MR23 */ printMessage(stderr,
81 "parse error: in rule %s, no viable alternative for tree\n",
82 rulename);
83 }
84
85 void STreeParser::
86 panic(char *err)
87 {
88 /* MR23 */ printMessage(stderr, "panic: %s\n", err);
89 exit(-1);
90 }
91
92 void STreeParser::
93 save_state(STreeParser *buf)
94 {
95 buf->try_ok = this->try_ok;
96 buf->sjrv = this->sjrv;
97 buf->guessing = this->guessing;
98 buf->startofguess = this->startofguess;
99 }
100
101 void STreeParser::
102 restore_state(STreeParser *buf)
103 {
104 this->try_ok = buf->try_ok;
105 this->sjrv = buf->sjrv;
106 this->guessing = buf->guessing;
107 this->startofguess = buf->startofguess;
108 }
109
110 void STreeParser::
111 _mkroot(SORASTBase **r, SORASTBase ** /*s*/, SORASTBase ** /*e*/, SORASTBase *t)
112 {
113 *r = t;
114 }
115
116 void STreeParser::
117 _mkchild(SORASTBase **r, SORASTBase **s, SORASTBase **e, SORASTBase *t)
118 {
119 #ifdef BEFORE_GARYS_FIX
120 /* if no sibling list, must attach to any existing root */
121 if ( *s==NULL )
122 {
123 *s = *e = t;
124 /* If r is NULL, then there was no root defined--must be sibling list */
125 if ( *r==NULL ) *r = *s;
126 else (*r)->setDown(t);
127 }
128 else { (*e)->setRight(t); *e = t; }
129 #endif
130 /*
131 should do nothing if asked to add a NULL argument. NULL's come up
132 when a rule wants to return "nothing".
133 */
134 /* if no sibling list, must attach to any existing root */
135 if (*s == NULL)
136 {
137 *s = *e = t;
138 // If r is NULL then there was no root defined--must be sibling list
139 if (*r == NULL) *r = *s;
140 else (*r)->setDown(t);
141 }
142 else if (*e != NULL)
143 {
144 (*e)->setRight(t);
145 *e = t;
146 }
147 if (*e != NULL) {
148 while ((*e)->right() != NULL) *e = (SORASTBase *)(*e)->right();
149 }
150 }
151
152 //MR23
153 int STreeParser::printMessage(FILE* pFile, const char* pFormat, ...)
154 {
155 va_list marker;
156 va_start( marker, pFormat );
157 int iRet = vfprintf(pFile, pFormat, marker);
158 va_end( marker );
159 return iRet;
160 }
+0
-834
contrib/pccts/sorcerer/lib/astlib.c less more
0 /*
1 * astlib.c
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-1994
27 */
28
29 #include <stdio.h>
30 #include "pcctscfg.h"
31 #include <ctype.h>
32
33 #define SORCERER_TRANSFORM
34
35 #include "CASTBase.h"
36 #include "astlib.h"
37
38 #ifdef PCCTS_USE_STDARG
39 #include <stdarg.h>
40 #else
41 #include <varargs.h>
42 #endif
43
44 /* String Scanning/Parsing Stuff */
45
46 #define StringScanMaxText 50
47
48 typedef struct stringlexer {
49 #ifdef __USE_PROTOS
50 signed int c;
51 #else
52 int c;
53 #endif
54 char *input;
55 char *p;
56 char text[StringScanMaxText];
57 } StringLexer;
58
59 #define LPAREN 1
60 #define RPAREN 2
61 #define PERCENT 3
62 #define INT 4
63 #define COLON 5
64 #define POUND 6
65 #define PERIOD 7
66 #define StringScanEOF -1
67 #define VALID_SCAN_TOKEN(t) (t>=LPAREN && t<=PERIOD)
68
69 static char *scan_token_tbl[] = {
70 "invalid", /* 0 */
71 "LPAREN", /* 1 */
72 "RPAREN", /* 2 */
73 "PERCENT", /* 3 */
74 "INT", /* 4 */
75 "COLON", /* 5 */
76 "POUND", /* 6 */
77 "PERIOD", /* 7 */
78 };
79
80 char *
81 #ifdef __USE_PROTOS
82 scan_token_str(int t)
83 #else
84 scan_token_str(t)
85 int t;
86 #endif
87 {
88 if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t];
89 else if ( t==StringScanEOF ) return "<end-of-string>";
90 else return "<invalid-token>";
91 }
92
93 typedef struct stringparser {
94 int token;
95 StringLexer *lexer;
96 int num_labels;
97 } StringParser;
98
99 /* This type ONLY USED by ast_scan() */
100
101 typedef struct _scanast {
102 struct _scanast *right, *down;
103 int token;
104 int label_num;
105 } ScanAST;
106
107 #ifdef __USE_PROTOS
108 static void stringlexer_init(StringLexer *scanner, char *input);
109 static void stringparser_init(StringParser *, StringLexer *);
110 static ScanAST *stringparser_parse_scanast(char *templ, int *n);
111 static ScanAST *stringparser_parse_tree(StringParser *parser);
112 static ScanAST *stringparser_parse_element(StringParser *parser);
113 static void stringscan_advance(StringLexer *scanner);
114 static int stringscan_gettok(StringLexer *scanner);
115 #else
116 static void stringlexer_init();
117 static void stringparser_init();
118 static ScanAST *stringparser_parse_scanast();
119 static ScanAST *stringparser_parse_tree();
120 static ScanAST *stringparser_parse_element();
121 static void stringscan_advance();
122 static int stringscan_gettok();
123 #endif
124
125 /* build a tree (root child1 child2 ... NULL)
126 * If root is NULL, simply make the children siblings and return ptr
127 * to 1st sibling (child1). If root is not single node, return NULL.
128 *
129 * Siblings that are actually sibling lists themselves are handled
130 * correctly. For example #( NULL, #( NULL, A, B, C), D) results
131 * in the tree ( NULL A B C D ).
132 *
133 * Requires at least two parameters with the last one being NULL. If
134 * both are NULL, return NULL.
135 *
136 * The ast_down and ast_right down/right pointers are used to make the tree.
137 */
138 SORAST *
139 #ifdef PCCTS_USE_STDARG
140 ast_make(SORAST *rt, ...)
141 #else
142 ast_make(va_alist)
143 va_dcl
144 #endif
145 {
146 va_list ap;
147 register SORAST *child, *sibling=NULL, *tail = NULL, *w;
148 SORAST *root;
149
150 #ifdef PCCTS_USE_STDARG
151 va_start(ap, rt);
152 root = rt;
153 #else
154 va_start(ap);
155 root = va_arg(ap, SORAST *);
156 #endif
157
158 if ( root != NULL )
159 if ( root->ast_down != NULL ) return NULL;
160 child = va_arg(ap, SORAST *);
161 while ( child != NULL )
162 {
163 /* find end of child */
164 for (w=child; w->ast_right!=NULL; w=w->ast_right) {;}
165 if ( sibling == NULL ) {sibling = child; tail = w;}
166 else {tail->ast_right = child; tail = w;}
167 child = va_arg(ap, SORAST *);
168 }
169 if ( root==NULL ) root = sibling;
170 else root->ast_down = sibling;
171 va_end(ap);
172 return root;
173 }
174
175 /* The following push and pop routines are only used by ast_find_all() */
176
177 static void
178 #ifdef __USE_PROTOS
179 _push(SORAST **st, int *sp, SORAST *e)
180 #else
181 _push(st, sp, e)
182 SORAST **st;
183 int *sp;
184 SORAST *e;
185 #endif
186 {
187 (*sp)--;
188 require((*sp)>=0, "stack overflow");
189 st[(*sp)] = e;
190 }
191
192 static SORAST *
193 #ifdef __USE_PROTOS
194 _pop(SORAST **st, int *sp)
195 #else
196 _pop(st, sp)
197 SORAST **st;
198 int *sp;
199 #endif
200 {
201 SORAST *e = st[*sp];
202 (*sp)++;
203 require((*sp)<=MaxTreeStackDepth, "stack underflow");
204 return e;
205 }
206
207 /* Is 'u' a subtree of 't' beginning at the root? */
208 int
209 #ifdef __USE_PROTOS
210 ast_match_partial(SORAST *t, SORAST *u)
211 #else
212 ast_match_partial(t, u)
213 SORAST *t, *u;
214 #endif
215 {
216 SORAST *sib;
217
218 if ( u==NULL ) return 1;
219 if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
220
221 for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right)
222 {
223 if ( sib->token != u->token ) return 0;
224 if ( sib->ast_down!=NULL )
225 if ( !ast_match_partial(sib->ast_down, u->ast_down) ) return 0;
226 }
227 return 1;
228 }
229
230 /* Find all occurrences of u in t.
231 * 'cursor' must be initialized to 't'. It eventually
232 * returns NULL when no more occurrences of 'u' are found.
233 */
234 SORAST *
235 #ifdef __USE_PROTOS
236 ast_find_all(SORAST *t, SORAST *u, SORAST **cursor)
237 #else
238 ast_find_all(t, u, cursor)
239 SORAST *t, *u, **cursor;
240 #endif
241 {
242 SORAST *sib;
243 static SORAST *template_stack[MaxTreeStackDepth];
244 static int tsp = MaxTreeStackDepth;
245
246 if ( *cursor == NULL ) return NULL;
247 if ( *cursor!=t ) sib = *cursor;
248 else {
249 /* else, first time--start at top of template 't' */
250 tsp = MaxTreeStackDepth;
251 sib = t;
252 /* bottom of stack is always a NULL--"cookie" indicates "done" */
253 _push(template_stack, &tsp, NULL);
254 }
255
256 keep_looking:
257 if ( sib==NULL ) /* hit end of sibling list */
258 {
259 sib = _pop(template_stack, &tsp);
260 if ( sib == NULL ) { *cursor = NULL; return NULL; }
261 }
262
263 if ( sib->token != u->token )
264 {
265 /* look for another match */
266 if ( sib->ast_down!=NULL )
267 {
268 if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);
269 sib=sib->ast_down;
270 goto keep_looking;
271 }
272 /* nothing below to try, try next sibling */
273 sib=sib->ast_right;
274 goto keep_looking;
275 }
276
277 /* found a matching root node, try to match what's below */
278 if ( ast_match_partial(sib, u) )
279 {
280 /* record sibling cursor so we can pick up next from there */
281 if ( sib->ast_down!=NULL )
282 {
283 if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);
284 *cursor = sib->ast_down;
285 }
286 else if ( sib->ast_right!=NULL ) *cursor = sib->ast_right;
287 else *cursor = _pop(template_stack, &tsp);
288 return sib;
289 }
290
291 /* no match, keep searching */
292 if ( sib->ast_down!=NULL )
293 {
294 if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);
295 sib=sib->ast_down;
296 }
297 else sib = sib->ast_right; /* else, try to right if zip below */
298 goto keep_looking;
299 }
300
301 /* are two trees exactly alike? */
302 int
303 #ifdef __USE_PROTOS
304 ast_match(SORAST *t, SORAST *u)
305 #else
306 ast_match(t, u)
307 SORAST *t, *u;
308 #endif
309 {
310 SORAST *sib;
311
312 if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
313 if ( u==NULL ) return 0;
314
315 for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right)
316 {
317 if ( sib->token != u->token ) return 0;
318 if ( sib->ast_down!=NULL )
319 if ( !ast_match(sib->ast_down, u->ast_down) ) return 0;
320 }
321 return 1;
322 }
323
324 static int
325 #ifdef __USE_PROTOS
326 ast_scanmatch(ScanAST *t, SORAST *u, SORAST **labels[], int *n)
327 #else
328 ast_scanmatch(t, u, labels, n)
329 ScanAST *t;
330 SORAST *u;
331 SORAST **labels[];
332 int *n;
333 #endif
334 {
335 ScanAST *sib;
336
337 if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
338 if ( u==NULL ) return 0;
339
340 for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right, u=u->ast_right)
341 {
342 /* make sure tokens match; token of '0' means wildcard match */
343 if ( sib->token != u->token && sib->token!=0 ) return 0;
344 /* we have a matched token here; set label pointers if exists */
345 if ( sib->label_num>0 )
346 {
347 require(labels!=NULL, "label found in template, but no array of labels");
348 (*n)++;
349 *(labels[sib->label_num-1]) = u;
350 }
351 /* match what's below if something there and current node is not wildcard */
352 if ( sib->down!=NULL && sib->token!=0 )
353 if ( !ast_scanmatch(sib->down, u->ast_down, labels, n) ) return 0;
354 }
355 return 1;
356 }
357
358 void
359 #ifdef __USE_PROTOS
360 ast_insert_after(SORAST *a, SORAST *b)
361 #else
362 ast_insert_after(a, b)
363 SORAST *a,*b;
364 #endif
365 {
366 SORAST *end;
367 require(a!=NULL, "ast_insert_after: NULL input tree");
368 if ( b==NULL ) return;
369 /* find end of b's child list */
370 for (end=b; end->ast_right!=NULL; end=end->ast_right) {;}
371 end->ast_right = a->ast_right;
372 a->ast_right = b;
373 }
374
375 void
376 #ifdef __USE_PROTOS
377 ast_append(SORAST *a, SORAST *b)
378 #else
379 ast_append(a, b)
380 SORAST *a,*b;
381 #endif
382 {
383 SORAST *end;
384 require(a!=NULL&&b!=NULL, "ast_append: NULL input tree");
385 /* find end of child list */
386 for (end=a; end->ast_right!=NULL; end=end->ast_right) {;}
387 end->ast_right = b;
388 }
389
390 SORAST *
391 #ifdef __USE_PROTOS
392 ast_tail(SORAST *a)
393 #else
394 ast_tail(a)
395 SORAST *a;
396 #endif
397 {
398 SORAST *end;
399 require(a!=NULL, "ast_tail: NULL input tree");
400 /* find end of child list */
401 for (end=a; end->ast_right!=NULL; end=end->ast_right) {;}
402 return end;
403 }
404
405 SORAST *
406 #ifdef __USE_PROTOS
407 ast_bottom(SORAST *a)
408 #else
409 ast_bottom(a)
410 SORAST *a;
411 #endif
412 {
413 SORAST *end;
414 require(a!=NULL, "ast_bottom: NULL input tree");
415 /* find end of child list */
416 for (end=a; end->ast_down!=NULL; end=end->ast_down) {;}
417 return end;
418 }
419
420 SORAST *
421 #ifdef __USE_PROTOS
422 ast_cut_between(SORAST *a, SORAST *b)
423 #else
424 ast_cut_between(a, b)
425 SORAST *a,*b;
426 #endif
427 {
428 SORAST *end, *ret;
429 require(a!=NULL&&b!=NULL, "ast_cut_between: NULL input tree");
430 /* find node pointing to b */
431 for (end=a; end->ast_right!=NULL&&end->ast_right!=b; end=end->ast_right)
432 {;}
433 require(end->ast_right!=NULL, "ast_cut_between: a,b not connected");
434 end->ast_right = NULL; /* don't want it point to 'b' anymore */
435 ret = a->ast_right;
436 a->ast_right = b;
437 return ret;
438 }
439
440 SList *
441 #ifdef __USE_PROTOS
442 ast_to_slist(SORAST *t)
443 #else
444 ast_to_slist(t)
445 SORAST *t;
446 #endif
447 {
448 SList *list=NULL;
449 SORAST *p;
450
451 for (p=t; p!=NULL; p=p->ast_right)
452 {
453 slist_add(&list, p);
454 }
455 return list;
456 }
457
458 SORAST *
459 #ifdef __USE_PROTOS
460 slist_to_ast(SList *list)
461 #else
462 slist_to_ast(list)
463 SList *list;
464 #endif
465 {
466 SORAST *t=NULL, *last=NULL;
467 SList *p;
468
469 for (p = list->next; p!=NULL; p=p->next)
470 {
471 SORAST *u = (SORAST *)p->elem;
472 if ( last==NULL ) last = t = u;
473 else { last->ast_right = u; last = u; }
474 }
475 return t;
476 }
477
478 void
479 #ifdef __USE_PROTOS
480 ast_free(SORAST *t)
481 #else
482 ast_free(t)
483 SORAST *t;
484 #endif
485 {
486 if ( t == NULL ) return;
487 ast_free( t->ast_down );
488 ast_free( t->ast_right );
489 free( t );
490 }
491
492 int
493 #ifdef __USE_PROTOS
494 ast_nsiblings(SORAST *t)
495 #else
496 ast_nsiblings(t)
497 SORAST *t;
498 #endif
499 {
500 int n=0;
501
502 while ( t!=NULL )
503 {
504 n++;
505 t = t->ast_right;
506 }
507 return n;
508 }
509
510 SORAST *
511 #ifdef __USE_PROTOS
512 ast_sibling_index(SORAST *t, int i)
513 #else
514 ast_sibling_index(t,i)
515 SORAST *t;
516 int i;
517 #endif
518 {
519 int j=1;
520 require(i>0, "ast_sibling_index: i<=0");
521
522 while ( t!=NULL )
523 {
524 if ( j==i ) return t;
525 j++;
526 t = t->ast_right;
527 }
528 return NULL;
529 }
530
531 static void
532 #ifdef __USE_PROTOS
533 scanast_free(ScanAST *t)
534 #else
535 scanast_free(t)
536 ScanAST *t;
537 #endif
538 {
539 if ( t == NULL ) return;
540 scanast_free( t->down );
541 scanast_free( t->right );
542 free( t );
543 }
544
545 /*
546 * ast_scan
547 *
548 * This function is like scanf(): it attempts to match a template
549 * against an input tree. A variable number of tree pointers
550 * may be set according to the '%i' labels in the template string.
551 * For example:
552 *
553 * ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",
554 * t, &w, &x, &y, &z);
555 *
556 * Naturally, you'd want this converted from
557 *
558 * ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )",
559 * t, &w, &x, &y, &z);
560 *
561 * by SORCERER.
562 *
563 * This function call must be done withing a SORCERER file because SORCERER
564 * must convert the token references to the associated token number.
565 *
566 * This functions parses the template and creates trees which are then
567 * matched against the input tree. The labels are set as they are
568 * encountered; hence, partial matches may leave some pointers set
569 * and some NULL. This routines initializes all argument pointers to NULL
570 * at the beginning.
571 *
572 * This function returns the number of labels matched.
573 */
574 int
575 #ifdef PCCTS_USE_STDARG
576 ast_scan(char *templ, SORAST *tree, ...)
577 #else
578 ast_scan(va_alist)
579 va_dcl
580 #endif
581 {
582 va_list ap;
583 ScanAST *t;
584 int n, i, found=0;
585 SORAST ***label_ptrs=NULL;
586
587 #ifdef PCCTS_USE_STDARG
588 va_start(ap, tree);
589 #else
590 char *templ;
591 SORAST *tree;
592
593 va_start(ap);
594 templ = va_arg(ap, char *);
595 tree = va_arg(ap, SORAST *);
596 #endif
597
598 /* make a ScanAST tree out of the template */
599 t = stringparser_parse_scanast(templ, &n);
600
601 /* make an array out of the labels */
602 if ( n>0 )
603 {
604 label_ptrs = (SORAST ***) calloc(n, sizeof(SORAST **));
605 require(label_ptrs!=NULL, "ast_scan: out of memory");
606 for (i=1; i<=n; i++)
607 {
608 label_ptrs[i-1] = va_arg(ap, SORAST **);
609 *(label_ptrs[i-1]) = NULL;
610 }
611 }
612
613 /* match the input tree against the template */
614 ast_scanmatch(t, tree, label_ptrs, &found);
615
616 scanast_free(t);
617 free(label_ptrs);
618
619 return found;
620 }
621
622 static ScanAST *
623 #ifdef __USE_PROTOS
624 new_scanast(int tok)
625 #else
626 new_scanast(tok)
627 int tok;
628 #endif
629 {
630 ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST));
631 if ( p == NULL ) {fprintf(stderr, "out of mem\n"); exit(-1);}
632 p->token = tok;
633 return p;
634 }
635
636 static ScanAST *
637 #ifdef __USE_PROTOS
638 stringparser_parse_scanast(char *templ, int *num_labels)
639 #else
640 stringparser_parse_scanast(templ, num_labels)
641 char *templ;
642 int *num_labels;
643 #endif
644 {
645 StringLexer lex;
646 StringParser parser;
647 ScanAST *t;
648
649 stringlexer_init(&lex, templ);
650 stringparser_init(&parser, &lex);
651 t = stringparser_parse_tree(&parser);
652 *num_labels = parser.num_labels;
653 return t;
654 }
655
656 static void
657 #ifdef __USE_PROTOS
658 stringparser_match(StringParser *parser, int token)
659 #else
660 stringparser_match(parser, token)
661 StringParser *parser;
662 int token;
663 #endif
664 {
665 if ( parser->token != token ) sorcerer_panic("bad tree in ast_scan()");
666 }
667
668 /*
669 * Match a tree of the form:
670 * (root child1 child2 ... childn)
671 * or,
672 * node
673 *
674 * where the elements are integers or labeled integers.
675 */
676 static ScanAST *
677 #ifdef __USE_PROTOS
678 stringparser_parse_tree(StringParser *parser)
679 #else
680 stringparser_parse_tree(parser)
681 StringParser *parser;
682 #endif
683 {
684 ScanAST *t=NULL, *root, *child, *last = NULL;
685
686 if ( parser->token != POUND )
687 {
688 return stringparser_parse_element(parser);
689 }
690 stringparser_match(parser,POUND);
691 parser->token = stringscan_gettok(parser->lexer);
692 stringparser_match(parser,LPAREN);
693 parser->token = stringscan_gettok(parser->lexer);
694 root = stringparser_parse_element(parser);
695 while ( parser->token != RPAREN )
696 {
697 child = stringparser_parse_element(parser);
698 if ( t==NULL ) { t = child; last = t; }
699 else { last->right = child; last = child; }
700 }
701 stringparser_match(parser,RPAREN);
702 parser->token = stringscan_gettok(parser->lexer);
703 root->down = t;
704 return root;
705 }
706
707 static ScanAST *
708 #ifdef __USE_PROTOS
709 stringparser_parse_element(StringParser *parser)
710 #else
711 stringparser_parse_element(parser)
712 StringParser *parser;
713 #endif
714 {
715 static char ebuf[100];
716 int label = 0;
717
718 if ( parser->token == POUND )
719 {
720 return stringparser_parse_tree(parser);
721 }
722 if ( parser->token == PERCENT )
723 {
724 parser->token = stringscan_gettok(parser->lexer);
725 stringparser_match(parser,INT);
726 label = atoi(parser->lexer->text);
727 parser->num_labels++;
728 if ( label==0 ) sorcerer_panic("%%0 is an invalid label");
729 parser->token = stringscan_gettok(parser->lexer);
730 stringparser_match(parser,COLON);
731 parser->token = stringscan_gettok(parser->lexer);
732 /* can label tokens and wildcards */
733 if ( parser->token != INT && parser->token != PERIOD )
734 sorcerer_panic("can only label tokens");
735 }
736 if ( parser->token == INT )
737 {
738 ScanAST *p = new_scanast(atoi(parser->lexer->text));
739 parser->token = stringscan_gettok(parser->lexer);
740 p->label_num = label;
741 return p;
742 }
743 if ( parser->token == PERIOD )
744 {
745 ScanAST *p = new_scanast(0); /* token of 0 is wildcard */
746 parser->token = stringscan_gettok(parser->lexer);
747 p->label_num = label;
748 return p;
749 }
750 sprintf(ebuf, "mismatch token in ast_scan(): %s", scan_token_str(parser->token));
751 sorcerer_panic(ebuf);
752 return NULL; /* MR20 make -Wall happy */
753 }
754
755 static void
756 #ifdef __USE_PROTOS
757 stringparser_init(StringParser *parser, StringLexer *input)
758 #else
759 stringparser_init(parser, input)
760 StringParser *parser;
761 StringLexer *input;
762 #endif
763 {
764 parser->lexer = input;
765 parser->token = stringscan_gettok(parser->lexer);
766 parser->num_labels = 0;
767 }
768
769 static void
770 #ifdef __USE_PROTOS
771 stringlexer_init(StringLexer *scanner, char *input)
772 #else
773 stringlexer_init(scanner, input)
774 StringLexer *scanner;
775 char *input;
776 #endif
777 {
778 scanner->text[0]='\0';
779 scanner->input = input;
780 scanner->p = input;
781 stringscan_advance(scanner);
782 }
783
784 static void
785 #ifdef __USE_PROTOS
786 stringscan_advance(StringLexer *scanner)
787 #else
788 stringscan_advance(scanner)
789 StringLexer *scanner;
790 #endif
791 {
792 if ( *(scanner->p) == '\0' ) scanner->c = StringScanEOF;
793 scanner->c = *(scanner->p)++;
794 }
795
796 static int
797 #ifdef __USE_PROTOS
798 stringscan_gettok(StringLexer *scanner)
799 #else
800 stringscan_gettok(scanner)
801 StringLexer *scanner;
802 #endif
803 {
804 char *index = &scanner->text[0];
805 static char ebuf[100];
806
807 while ( isspace(scanner->c) ) { stringscan_advance(scanner); }
808 if ( isdigit(scanner->c) )
809 {
810 int tok = INT;
811 while ( isdigit(scanner->c) ) {
812 *index++ = scanner->c;
813 stringscan_advance(scanner);
814 }
815 *index = '\0';
816 return tok;
817 }
818 switch ( scanner->c )
819 {
820 case '#' : stringscan_advance(scanner); return POUND;
821 case '(' : stringscan_advance(scanner); return LPAREN;
822 case ')' : stringscan_advance(scanner); return RPAREN;
823 case '%' : stringscan_advance(scanner); return PERCENT;
824 case ':' : stringscan_advance(scanner); return COLON;
825 case '.' : stringscan_advance(scanner); return PERIOD;
826 case '\0' : return StringScanEOF;
827 case StringScanEOF : return StringScanEOF;
828 default :
829 sprintf(ebuf, "invalid char in ast_scan: '%c'", scanner->c);
830 sorcerer_panic(ebuf);
831 return 0; /* MR20 Make -Wall happy */
832 }
833 }
+0
-100
contrib/pccts/sorcerer/lib/errsupport.c less more
0 /*
1 * errsupport.c -- error support code for SORCERER output
2 *
3 * Define your own or compile and link this in.
4 *
5 * Terence Parr
6 * U of MN, AHPCRC
7 * February 1994
8 */
9 #include "sorcerer.h"
10
11 void
12 #ifdef __USE_PROTOS
13 mismatched_range( STreeParser *_parser, int looking_for, int upper_token, SORAST *found )
14 #else
15 mismatched_range( _parser, looking_for, upper_token, found )
16 int looking_for;
17 int upper_token;
18 SORAST *found;
19 STreeParser *_parser;
20 #endif
21 {
22 if ( found!=NULL ) {
23 fprintf(stderr,
24 "parse error: expected token range %d..%d found token %d\n",
25 looking_for, upper_token,
26 found->token);
27 }
28 else {
29 fprintf(stderr,
30 "parse error: expected token range %d..%d found NULL tree\n",
31 looking_for, upper_token);
32 }
33 }
34
35 void
36 #ifdef __USE_PROTOS
37 missing_wildcard(STreeParser *_parser)
38 #else
39 missing_wildcard(_parser)
40 STreeParser *_parser;
41 #endif
42 {
43 fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n");
44 }
45
46 void
47 #ifdef __USE_PROTOS
48 mismatched_token( STreeParser *_parser, int looking_for, SORAST *found )
49 #else
50 mismatched_token( _parser, looking_for, found )
51 int looking_for;
52 SORAST *found;
53 STreeParser *_parser;
54 #endif
55 {
56 if ( found!=NULL ) {
57 fprintf(stderr,
58 "parse error: expected token %d found token %d\n",
59 looking_for,
60 found->token);
61 }
62 else {
63 fprintf(stderr,
64 "parse error: expected token %d found NULL tree\n",
65 looking_for);
66 }
67 }
68
69 void
70 #ifdef __USE_PROTOS
71 no_viable_alt( STreeParser *_parser, char *rulename, SORAST *root )
72 #else
73 no_viable_alt( _parser, rulename, root )
74 char *rulename;
75 SORAST *root;
76 STreeParser *_parser;
77 #endif
78 {
79 if ( root==NULL )
80 fprintf(stderr,
81 "parse error: in rule %s, no viable alternative for NULL tree\n",
82 rulename);
83 else
84 fprintf(stderr,
85 "parse error: in rule %s, no viable alternative for tree\n",
86 rulename);
87 }
88
89 void
90 #ifdef __USE_PROTOS
91 sorcerer_panic(char *err)
92 #else
93 sorcerer_panic(err)
94 char *err;
95 #endif
96 {
97 fprintf(stderr, "panic: %s\n", err);
98 exit(-1);
99 }
+0
-130
contrib/pccts/sorcerer/lib/msvc.dsp less more
0 # Microsoft Developer Studio Project File - Name="lib" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 5.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Static Library" 0x0104
5
6 CFG=lib - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "lib.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "lib.mak" CFG="lib - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "lib - Win32 Release" (based on "Win32 (x86) Static Library")
20 !MESSAGE "lib - Win32 Debug" (based on "Win32 (x86) Static Library")
21 !MESSAGE
22
23 # Begin Project
24 # PROP Scc_ProjName ""$/pccts/Sorcerer/lib", EPABAAAA"
25 # PROP Scc_LocalPath "."
26 CPP=cl.exe
27
28 !IF "$(CFG)" == "lib - Win32 Release"
29
30 # PROP BASE Use_MFC 0
31 # PROP BASE Use_Debug_Libraries 0
32 # PROP BASE Output_Dir "Release"
33 # PROP BASE Intermediate_Dir "Release"
34 # PROP BASE Target_Dir ""
35 # PROP Use_MFC 0
36 # PROP Use_Debug_Libraries 0
37 # PROP Output_Dir "Release"
38 # PROP Intermediate_Dir "Release"
39 # PROP Target_Dir ""
40 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
41 # ADD CPP /nologo /W3 /GX /O2 /I "h" /I "..\h" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c
42 BSC32=bscmake.exe
43 # ADD BASE BSC32 /nologo
44 # ADD BSC32 /nologo
45 LIB32=link.exe -lib
46 # ADD BASE LIB32 /nologo
47 # ADD LIB32 /nologo
48
49 !ELSEIF "$(CFG)" == "lib - Win32 Debug"
50
51 # PROP BASE Use_MFC 0
52 # PROP BASE Use_Debug_Libraries 1
53 # PROP BASE Output_Dir "Debug"
54 # PROP BASE Intermediate_Dir "Debug"
55 # PROP BASE Target_Dir ""
56 # PROP Use_MFC 0
57 # PROP Use_Debug_Libraries 1
58 # PROP Output_Dir "Debug"
59 # PROP Intermediate_Dir "Debug"
60 # PROP Target_Dir ""
61 # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
62 # ADD CPP /nologo /W3 /GX /Z7 /Od /I "h" /I "..\h" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c
63 BSC32=bscmake.exe
64 # ADD BASE BSC32 /nologo
65 # ADD BSC32 /nologo
66 LIB32=link.exe -lib
67 # ADD BASE LIB32 /nologo
68 # ADD LIB32 /nologo
69
70 !ENDIF
71
72 # Begin Target
73
74 # Name "lib - Win32 Release"
75 # Name "lib - Win32 Debug"
76 # Begin Group "Header files"
77
78 # PROP Default_Filter "h"
79 # Begin Source File
80
81 SOURCE=.\CASTBase.h
82 # End Source File
83 # End Group
84 # Begin Group "Source files"
85
86 # PROP Default_Filter "c,cpp"
87 # Begin Source File
88
89 SOURCE=.\astlib.c
90 # PROP Exclude_From_Build 1
91 # End Source File
92 # Begin Source File
93
94 SOURCE=.\errsupport.c
95 # PROP Exclude_From_Build 1
96 # End Source File
97 # Begin Source File
98
99 SOURCE=.\PCCTSAST.cpp
100 # End Source File
101 # Begin Source File
102
103 SOURCE=.\sintstack.c
104 # End Source File
105 # Begin Source File
106
107 SOURCE=.\SList.cpp
108 # End Source File
109 # Begin Source File
110
111 SOURCE=.\sorcerer.c
112 # PROP Exclude_From_Build 1
113 # End Source File
114 # Begin Source File
115
116 SOURCE=.\sorlist.c
117 # PROP Exclude_From_Build 1
118 # End Source File
119 # Begin Source File
120
121 SOURCE=.\sstack.c
122 # End Source File
123 # Begin Source File
124
125 SOURCE=.\STreeParser.cpp
126 # End Source File
127 # End Group
128 # End Target
129 # End Project
+0
-140
contrib/pccts/sorcerer/lib/sintstack.c less more
0 /*
1 * sint.c
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-1994
27 */
28 #include <stdio.h>
29 #include <setjmp.h>
30
31 #ifdef PCCTS_USE_STDARG
32 #include <stdarg.h>
33 #else
34 #include <varargs.h>
35 #endif
36
37 #include "CASTBase.h"
38 #include "sintstack.h"
39
40 SIntStack *
41 #ifdef __USE_PROTOS
42 sint_newstack(int size)
43 #else
44 sint_newstack(size)
45 int size;
46 #endif
47 {
48 SIntStack *p = (SIntStack *) calloc(1, sizeof(SIntStack));
49 require(p!=NULL, "sint_newstack: out of memory");
50 p->data = (int *) calloc(size, sizeof(int));
51 require(p!=NULL, "sint_newstack: out of memory");
52 p->size = size;
53 p->sp = size;
54 return p;
55 }
56
57 void
58 #ifdef __USE_PROTOS
59 sint_freestack(SIntStack *st)
60 #else
61 sint_freestack(st)
62 SIntStack *st;
63 #endif
64 {
65 if ( st==NULL ) return;
66 if ( st->data==NULL ) return;
67 free(st->data);
68 free(st);
69 }
70
71 void
72 #ifdef __USE_PROTOS
73 sint_push(SIntStack *st,int i)
74 #else
75 sint_push(st,i)
76 SIntStack *st;
77 int i;
78 #endif
79 {
80 require(st->sp>0, "sint_push: stack overflow");
81 st->data[--(st->sp)] = i;
82 }
83
84 int
85 #ifdef __USE_PROTOS
86 sint_pop(SIntStack *st)
87 #else
88 sint_pop(st)
89 SIntStack *st;
90 #endif
91 {
92 require(st->sp<st->size, "sint_pop: stack underflow");
93 return st->data[st->sp++];
94 }
95
96 int
97 #ifdef __USE_PROTOS
98 sint_stacksize(SIntStack *st)
99 #else
100 sint_stacksize(st)
101 SIntStack *st;
102 #endif
103 {
104 return st->size - st->sp;
105 }
106
107 void
108 #ifdef __USE_PROTOS
109 sint_stackreset(SIntStack *st)
110 #else
111 sint_stackreset(st)
112 SIntStack *st;
113 #endif
114 {
115 st->sp = st->size;
116 }
117
118 int
119 #ifdef __USE_PROTOS
120 sint_stackempty(SIntStack *st)
121 #else
122 sint_stackempty(st)
123 SIntStack *st;
124 #endif
125 {
126 return st->sp==st->size;
127 }
128
129 int
130 #ifdef __USE_PROTOS
131 sint_top(SIntStack *st)
132 #else
133 sint_top(st)
134 SIntStack *st;
135 #endif
136 {
137 require(st->sp<st->size, "sint_top: stack underflow");
138 return st->data[st->sp];
139 }
+0
-169
contrib/pccts/sorcerer/lib/sorcerer.c less more
0 /*
1 * sorcerer.c -- support code for SORCERER output
2 *
3 * Define your own or compile and link this in.
4 *
5 * Terence Parr
6 * U of MN, AHPCRC
7 * February 1994
8 */
9
10 /***********************************************************************
11 2-Oct-97 The routine ast_dup() appeared to have a bug in it. Instead
12 of providing a deep copy of its argument it made a bushy copy
13 of its argument - by duplicating the nodes pointed to by
14 its right link. This is certainly not deliberate and does
15 not match code in PCCTSAST.cpp (which had its own bug). This
16 has been changed to do a deep copy in the traditional sense.
17 ***********************************************************************/
18
19 #ifdef OLD
20 /* Given a result pointer, return the same one if *t is NULL,
21 * else find the end of the sibling list and return the address
22 * the 'next[write]' field in that last node.
23 */
24 AST **
25 #ifdef __USE_PROTOS
26 _nextresult(STreeParser *_parser, AST **t)
27 #else
28 _nextresult(_parser, t)
29 AST **t;
30 STreeParser *_parser;
31 #endif
32 {
33 AST *p = *t;
34
35 if ( p==NULL ) return t;
36 while ( p->ast_right(_parser->write) != NULL )
37 {
38 p = p->ast_right(_parser->write);
39 }
40 return &(p->ast_right(_parser->write));
41 }
42
43 /*
44 * Copy the read pointers to the write pointers for a node or entire subtree
45 */
46 void
47 #ifdef __USE_PROTOS
48 _copy_wildcard(STreeParser *_parser, AST *t, int root)
49 #else
50 _copy_wildcard(_parser, t, root)
51 STreeParser *_parser;
52 AST *t;
53 int root;
54 #endif
55 {
56 while ( t!=NULL )
57 {
58 if ( !root ) t->ast_right(_parser->write) = t->ast_right(_parser->read);
59 t->ast_down(_parser->write) = t->ast_down(_parser->read);
60 if ( t->ast_down(_parser->read)!=NULL )
61 _copy_wildcard(_parser, t->ast_down(_parser->read), 0);
62 if ( root ) return;
63 else root=0;
64 t = t->ast_right(_parser->read);
65 }
66 }
67 #endif
68
69 void
70 #ifdef __USE_PROTOS
71 _mkroot(SORAST **r, SORAST **s, SORAST **e, SORAST *t)
72 #else
73 _mkroot(r,s,e,t)
74 SORAST **r, **s, **e, *t;
75 #endif
76 {
77 *r = t;
78 }
79
80 void
81 #ifdef __USE_PROTOS
82 _mkchild(SORAST **r, SORAST **s, SORAST **e, SORAST *t)
83 #else
84 _mkchild(r,s,e,t)
85 SORAST **r, **s, **e, *t;
86 #endif
87 {
88 /* if no sibling list, must attach to any existing root */
89 if ( *s==NULL )
90 {
91 *s = *e = t;
92 /* If r is NULL, then there was no root defined--must be sibling list */
93 if ( *r==NULL ) *r = *s;
94 else (*r)->ast_down = t;
95 }
96 else { (*e)->ast_right = t; *e = t; }
97 }
98
99 /* THESE FUNCS HAVE TO GO HERE BECAUSE THEY ARE SENSITIVE TO USER'S SORAST DEF */
100 SORAST *
101 #ifdef __USE_PROTOS
102 ast_alloc(void)
103 #else
104 ast_alloc()
105 #endif
106 {
107 SORAST *t = (SORAST *)calloc(1, sizeof(SORAST));
108 if ( t==NULL ) sorcerer_panic("out of memory");
109 return t;
110 }
111
112 SORAST *
113 #ifdef __USE_PROTOS
114 ast_dup_bushy(SORAST *t)
115 #else
116 ast_dup_bushy(t)
117 SORAST *t;
118 #endif
119 {
120 SORAST *u;
121
122 if ( t == NULL ) return NULL;
123 u = ast_alloc();
124 *u = *t; /* copy contents */
125 u->ast_down = ast_dup_bushy(t->ast_down); /* copy the rest of the tree */
126 u->ast_right = ast_dup_bushy(t->ast_right);
127 return u;
128 }
129
130
131 /* Assume t is a root node of a tree--duplicate that node and what's below */
132
133 SORAST *
134 #ifdef __USE_PROTOS
135 ast_dup(SORAST *t)
136 #else
137 ast_dup(t)
138 SORAST *t;
139 #endif
140 {
141 SORAST *u;
142
143 if ( t == NULL ) return NULL;
144 u = ast_alloc();
145 *u = *t; /* copy contents */
146 u->ast_down = ast_dup_bushy(t->ast_down); /* copy the rest of the tree */
147 u->ast_right = NULL;
148 return u;
149 }
150
151 /* Assume t is a root node of a tree--duplicate that node and what's below */
152 SORAST *
153 #ifdef __USE_PROTOS
154 ast_dup_node(SORAST *t)
155 #else
156 ast_dup_node(t)
157 SORAST *t;
158 #endif
159 {
160 SORAST *u;
161
162 if ( t == NULL ) return NULL;
163 u = ast_alloc();
164 *u = *t; /* copy contents */
165 u->down = NULL;
166 u->right = NULL;
167 return u;
168 }
+0
-123
contrib/pccts/sorcerer/lib/sorlist.c less more
0 /*
1 * slist.c
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-1994
27 */
28 #include <stdio.h>
29 #include <setjmp.h>
30
31 #ifdef PCCTS_USE_STDARG
32 #include <stdarg.h>
33 #else
34 #include <varargs.h>
35 #endif
36
37 #include "CASTBase.h"
38 #include "sorlist.h"
39
40 /* Iterate over a list of elements; returns ptr to a new element
41 * in list upon every call and NULL when no more are left.
42 * Very useful like this:
43 *
44 * cursor = mylist;
45 * while ( (p=slist_iterate(mylist,&cursor)) ) {
46 * / * place with element p * /
47 * }
48 *
49 * The cursor must be initialized to point to the list to iterate over.
50 */
51 void *
52 #ifdef __USE_PROTOS
53 slist_iterate(SList *list, SList **cursor)
54 #else
55 slist_iterate(list, cursor)
56 SList *list, **cursor;
57 #endif
58 {
59 void *e;
60
61 if ( list==NULL || cursor == NULL || *cursor==NULL ) return NULL;
62 if ( list== *cursor ) { *cursor = (*cursor)->next; }
63 e = (*cursor)->elem;
64 (*cursor) = (*cursor)->next;
65 return e;
66 }
67
68 /*
69 * add an element to a list.
70 *
71 * Any non-empty list has a sentinel node whose 'elem' pointer is really
72 * a pointer to the last element. (i.e. length(list) = #elemIn(list)+1).
73 * Elements are appended to the list.
74 */
75 void
76 #ifdef __USE_PROTOS
77 slist_add( SList **list, void *e )
78 #else
79 slist_add( list, e )
80 SList **list;
81 void *e;
82 #endif
83 {
84 SList *p, *tail;
85 require(e!=NULL, "slist_add: attempting to add NULL list element");
86
87 p = newSList;
88 require(p!=NULL, "slist_add: cannot alloc new list node");
89 p->elem = e;
90 if ( *list == NULL )
91 {
92 SList *sentinel = newSList;
93 require(sentinel!=NULL, "slist_add: cannot alloc sentinel node");
94 *list=sentinel;
95 sentinel->next = p;
96 sentinel->elem = (char *)p; /* set tail pointer */
97 }
98 else /* find end of list */
99 {
100 tail = (SList *) (*list)->elem; /* get tail pointer */
101 tail->next = p;
102 (*list)->elem = (char *) p; /* reset tail */
103 }
104 }
105
106 void
107 #ifdef __USE_PROTOS
108 slist_free(SList *list)
109 #else
110 slist_free(list)
111 SList *list;
112 #endif
113 {
114 SList *p,*q;
115
116 if ( list==NULL ) return; /* empty list */
117 for (p = list->next; p!=NULL; p=q)
118 {
119 q = p->next;
120 free(p);
121 }
122 }
+0
-78
contrib/pccts/sorcerer/lib/sstack.c less more
0 /*
1 * sstack.c
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-1994
27 */
28
29 #include "pcctscfg.h"
30 #include <stdio.h>
31 #include <setjmp.h>
32
33 #ifdef PCCTS_USE_STDARG
34 #include <stdarg.h>
35 #else
36 #include <varargs.h>
37 #endif
38
39 #include "CASTBase.h"
40 #include "sstack.h"
41
42 void
43 #ifdef __USE_PROTOS
44 sstack_push( SStack **st, void *e )
45 #else
46 sstack_push( st, e )
47 SStack **st;
48 void *e;
49 #endif
50 {
51 SStack *p;
52 require(e!=NULL, "sstack_push: attempting to add NULL list element");
53
54 p = newSStack;
55 require(p!=NULL, "sstack_push: cannot alloc new list node");
56 p->elem = e;
57 p->next = *st;
58 *st = p;
59 }
60
61 void *
62 #ifdef __USE_PROTOS
63 sstack_pop( SStack **st )
64 #else
65 sstack_pop( st )
66 SStack **st;
67 #endif
68 {
69 SStack *p = *st;
70 void *r;
71
72 *st = (*st)->next;
73 r = p->elem;
74 free(p);
75 return r;
76 }
77
+0
-686
contrib/pccts/sorcerer/look.c less more
0 /*
1 * look.c
2 *
3 * Compute LL(1) lookahead sets for SORCERER code-generator
4 *
5 * SOFTWARE RIGHTS
6 *
7 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
8 * domain. An individual or company may do whatever they wish with
9 * source code distributed with SORCERER or the code generated by
10 * SORCERER, including the incorporation of SORCERER, or its output, into
11 * commerical software.
12 *
13 * We encourage users to develop software with SORCERER. However, we do
14 * ask that credit is given to us for developing SORCERER. By "credit",
15 * we mean that if you incorporate our source code into one of your
16 * programs (commercial product, research project, or otherwise) that you
17 * acknowledge this fact somewhere in the documentation, research report,
18 * etc... If you like SORCERER and have developed a nice tool with the
19 * output, please mention that you developed it using SORCERER. In
20 * addition, we ask that this header remain intact in our source code.
21 * As long as these guidelines are kept, we expect to continue enhancing
22 * this system and expect to make other tools available as they are
23 * completed.
24 *
25 * SORCERER 1.00B
26 * Terence Parr
27 * AHPCRC, University of Minnesota
28 * 1992-2001
29 */
30 #include "stdpccts.h"
31 #include "sym.h"
32 #include "proto.h"
33
34 static GLA *end_node;
35
36 static GLA *
37 #ifdef __USE_PROTOS
38 newGLANode(void);
39 #else
40 newGLANode();
41 #endif
42
43 set
44 #ifdef __USE_PROTOS
45 Lookahead( GLA *p )
46 #else
47 Lookahead( p )
48 GLA *p;
49 #endif
50 {
51 set r, rv;
52
53 if ( p == NULL ) return empty;
54 r = rv = empty;
55
56 /* have we been here before for this k? Detect cycles */
57 if ( p->visited )
58 {
59 return empty;
60 }
61 p->visited = 1;
62
63 /* Does edge 1 have a token label? */
64 if ( p->label1 <= last_valid_token )
65 {
66 rv = set_of(p->label1);
67 if ( p->upper_range!=0 )
68 {
69 int i;
70 /* put all elements of range into lookahead set */
71 for (i=p->label1+1; i<=p->upper_range; i++)
72 {
73 set_orel(i, &rv);
74 }
75 }
76 }
77 else if ( p->label1 == wild_card || p->label1 == end_of_input )
78 {
79 rv = set_of(p->label1);
80 }
81 else /* must be an epsilon transfer */
82 {
83 int trouble = 0;
84 if ( p->p1!=NULL )
85 {
86 /* check for infinite-recursion */
87 /* o->o->o->o-A->o.. Rule def (p->p1 points to far left node)
88 * | for 'a : A | B;'
89 * o->o-B->o..
90 *
91 * the visited flag is set on the start of the alts.
92 */
93 if ( p->is_rule_ref && p->p1->is_rule_entry )
94 {
95 require(p->p1->p1!=NULL, "Lookahead: invalid GLA");
96 require(p->p1->p1->p1!=NULL, "Lookahead: invalid GLA");
97 if ( p->p1->p1->p1->visited ) {
98 errNoFL(eMsg2("infinite recursion from rule %s to rule %s",
99 p->in_rule,p->p1->in_rule));
100 rv = set_of(wild_card);
101 trouble = 1;
102 }
103 }
104 if ( !trouble )
105 {
106 r = Lookahead(p->p1);
107 rv = set_or(r, rv);
108 set_free(r);
109 }
110 }
111 }
112
113 /* handle edge 2 */
114 r = Lookahead(p->p2); /* tokens can't be on e2 edges */
115 set_orin(&rv, r);
116 set_free(r);
117
118 /* this node is no longer visited */
119 p->visited = 0;
120
121 return rv;
122 }
123
124 /*
125 * Build a big, interwined, lookahead GLA from the lookahead GLA created
126 * for each rule. From this, lookahead computation is trivial.
127 *
128 * [1] Build the GLA start states for each nonterminal. Each nonterminal
129 * looks like "o-->o" where the 2nd 'o' is the start of the GLA list
130 * of alts for the grammar block. Alternatives are connected like this:
131 *
132 * o-->o-->alt1 -->o
133 * | ^
134 * o-->alt2 ---|
135 * ... |
136 * | |
137 * o-->altn ---|
138 *
139 * The BLOCK building function actually makes the ALT list. This
140 * function only builds the first 'o' node (upper left).
141 *
142 * [2] Make GLA for block of each rule.
143 *
144 * [3] Make a set of links to the nodes following all references to
145 * this rule.
146 */
147 void
148 #ifdef __USE_PROTOS
149 build_GLA( AST *rules )
150 #else
151 build_GLA( rules )
152 AST *rules;
153 #endif
154 {
155 SymEntry *s;
156 AST *r;
157 GLA *end_of_rule, *blk_start;
158 require(rules!=NULL, "build_GLA: NULL rule list");
159
160 for (r=rules; r!=NULL; r=r->right)
161 {
162 s = (SymEntry *) hash_get(symbols, r->text);
163 require(s!=NULL, "build_GLA: sym tab broken");
164 CurRule = s->str;
165 s->start_state = newGLANode();
166 s->start_state->is_rule_entry = 1;
167 }
168
169 end_node = newGLANode();
170 for (r=rules; r!=NULL; r=r->right)
171 {
172 s = (SymEntry *) hash_get(symbols, r->text);
173 require(s!=NULL, "build_GLA: sym tab broken");
174 CurRule = s->str;
175 blk_start = newGLANode();
176 blk_start->p1 = build_GLA_for_block(r->down, &end_of_rule);
177 blk_start->label1 = epsilon;
178 s->start_state->p1 = blk_start;
179 s->start_state->label1 = epsilon;
180 s->end_rule = end_of_rule;
181 /* make this BLOCK correspond to the GLA for this rule */
182 r->down->start_state = s->start_state->p1;
183 }
184
185 for (r=rules; r!=NULL; r=r->right)
186 {
187 s = (SymEntry *) hash_get(symbols, r->text);
188 require(s!=NULL, "build_GLA: sym tab broken");
189 build_follow_links(s->end_rule, s->refs);
190 }
191
192 }
193
194 /*
195 * Tree looks like ( BLOCK ( ALT alpha ) ... ( AST beta ) ).
196 *
197 * For each ALT of BLOCK, build a new alternative into the GLA.
198 *
199 * Build a block that looks like:
200 *
201 * o-->alt1 -->o
202 * | ^
203 * o-->alt2 ---|
204 * ... |
205 * | |
206 * o-->altn ---|
207 */
208 GLA *
209 #ifdef __USE_PROTOS
210 build_GLA_for_block( AST *block, GLA **tail )
211 #else
212 build_GLA_for_block( block, tail )
213 AST *block;
214 GLA **tail;
215 #endif
216 {
217 GLA *p, *alt_tail, *blk_tail, *prev=NULL, *first=NULL;
218 AST *alt;
219 require(block!=NULL, "build_GLA_for_block: NULL tree pointer");
220
221 blk_tail = newGLANode();
222 for (alt=block->down; alt!=NULL; alt=alt->right)
223 {
224 p = newGLANode();
225 p->p1 = build_GLA_for_ALT(alt, &alt_tail);
226 p->label1 = epsilon;
227 /* connect new alt into downward link */
228 if ( prev!=NULL )
229 {
230 prev->p2 = p;
231 prev->label2 = epsilon;
232 }
233 else
234 {
235 first = p;
236 }
237 prev = p;
238 /* link alt to block tail node */
239 alt_tail->p1 = blk_tail;
240 alt_tail->label1 = epsilon;
241 }
242 *tail = blk_tail;
243 return first;
244 }
245
246 /*
247 * Tree looks like ( ALT elem1 ... elemn ). Generate a GLA for each
248 * element with build_GLA_for_element; make a tail node and return
249 * pointer to GLA element built for first element.
250 *
251 * Tree patterns such as #(A b C) must be included because they may
252 * invoke other rules or have subrules in them for which lookahead
253 * must be computed. The '#(' and ')' are basically ignored and #(A b C)
254 * turns into 'A b C' for GLA construction purposes. Note that this would
255 * NOT work for LL(k>1).
256 */
257 GLA *
258 #ifdef __USE_PROTOS
259 build_GLA_for_ALT( AST *alt, GLA **alt_tail )
260 #else
261 build_GLA_for_ALT( alt, alt_tail )
262 AST *alt;
263 GLA **alt_tail;
264 #endif
265 {
266 GLA *elem_tail, *first;
267 require(alt!=NULL, "build_GLA_for_alt: NULL tree pointer");
268
269 first = build_GLA_for_tree(alt->down, &elem_tail);
270 *alt_tail = elem_tail;
271 return first;
272 }
273
274 GLA *
275 #ifdef __USE_PROTOS
276 build_GLA_for_tree( AST *q, GLA **tree_tail )
277 #else
278 build_GLA_for_tree( q, tree_tail )
279 AST *q;
280 GLA **tree_tail;
281 #endif
282 {
283 AST *t;
284 GLA *elem_tail, *alt_tail=NULL, *start=NULL, *elem;
285
286 for (t=q; t!=NULL; t = t->right)
287 {
288 elem = build_GLA_for_element(t, &elem_tail);
289 if ( elem!=NULL )
290 {
291 if ( start==NULL ) { start = elem; alt_tail = elem_tail; }
292 else {
293 alt_tail->p1 = elem;
294 alt_tail->label1 = epsilon;
295 alt_tail = elem_tail;
296 }
297 }
298
299 if ( t->down != NULL && (t->token == Token||t->token == WILD) )
300 {
301 elem = build_GLA_for_tree(t->down, &elem_tail);
302 if ( elem==NULL ) continue;
303 alt_tail->p1 = elem;
304 alt_tail->label1 = epsilon;
305
306 /* put an end-of-input node at the end of each sibling list so
307 * that lookahead computation don't take '#(A b) D' to be same
308 * as 'A b D'; i.e., 'D' CANNOT follow a reference to a 'b' in
309 * this context as the 'b' is at a lower level. Only a NULL ptr
310 * can follow a ref to 'b'. For example,
311 *
312 * a : #(A b) D;
313 * b : E
314 * |
315 * ;
316 *
317 * The lookahead for 'b' is {E} for alt1 and {end_of_input} of
318 * alt2 because for the second alt to match, the input subtree
319 * must be NULL.
320 */
321 elem_tail->p1 = newGLANode();
322 elem_tail->label1 = end_of_input;
323 elem_tail = elem_tail->p1;
324 alt_tail = elem_tail;
325 }
326 }
327 if ( start==NULL )
328 {
329 start = newGLANode();
330 *tree_tail = start;
331 }
332 else *tree_tail = alt_tail;
333 return start;
334 }
335
336 GLA *
337 #ifdef __USE_PROTOS
338 build_GLA_for_element( AST *elem, GLA **elem_tail )
339 #else
340 build_GLA_for_element( elem, elem_tail )
341 AST *elem;
342 GLA **elem_tail;
343 #endif
344 {
345 SymEntry *p;
346 GLA *blkstart, *blkend, *blkloopback, *start=NULL;
347 require(elem!=NULL, "build_GLA_for_element: NULL tree pointer");
348
349 if ( elem == NULL ) return NULL;
350 switch ( elem->token )
351 {
352 case Token :
353 p = (SymEntry *) hash_get(symbols, elem->text);
354 require(p!=NULL, "build_GLA_for_element: token not in sym tab");
355 start = newGLANode();
356 start->p1 = newGLANode();
357 start->label1 = p->token_type;
358 start->upper_range = elem->upper_range;
359 *elem_tail = start->p1;
360 break;
361 case NonTerm :
362 /* edge 1 points to the start of the GLA for the referenced rule.
363 * Make a new node as if it
364 * were connected, however, so that this node can be connected to the end
365 * of block node by the build BLOCK routine.
366 */
367 p = (SymEntry *) hash_get(symbols, elem->text);
368 if ( p==NULL || !p->defined ) {
369 errNoFL(eMsg1("rule not defined: '%s'", elem->text));
370 start = newGLANode();
371 start->p1 = newGLANode();
372 start->label1 = wild_card;
373 *elem_tail = start->p1;
374 break;
375 }
376 start = newGLANode();
377 start->is_rule_ref = 1;
378 start->p1 = p->start_state;
379 start->label1 = epsilon;
380 start->next = newGLANode();
381 *elem_tail = start->next;
382 /* maintain reference list for this nonterminal */
383 list_add(&p->refs, start->next);
384 break;
385 case WILD :
386 start = newGLANode();
387 start->p1 = newGLANode();
388 start->label1 = wild_card;
389 *elem_tail = start->p1;
390 break;
391 case Action :
392 *elem_tail = NULL;
393 break;
394 case PRED_OP :
395 /* return o->blk */
396 start = newGLANode();
397 start->p1 = build_GLA_for_block(elem->down, elem_tail);
398 start->label1 = epsilon;
399 elem->down->start_state = start;
400 /* DO NOT RETURN the block ptr because we don't want the lookahead
401 * analysis to see it. However, the AST BLOCK node will pt to it.
402 */
403 start = NULL;
404 *elem_tail = NULL;
405 break;
406 case CLOSURE :
407 /* Make a blk like this:
408 * v---------|
409 * o-->o-->blk-->o-->o
410 * |-------------^
411 * where the farthest left node is the start node passed in,
412 * the 2nd from the right is created here, and the 2nd from the left
413 * is a node created here. The farthest right node is created
414 * here as the end_blk node for the CLOSURE block. The 'p2' ptr
415 * of the blkloopback node goes back to the blkstart node.
416 */
417 blkstart = newGLANode();
418 blkloopback = newGLANode();
419 blkend = newGLANode();
420 blkstart->p1 = build_GLA_for_block(elem->down, elem_tail);
421 blkstart->label1 = epsilon;
422 blkstart->p2 = blkend;
423 blkstart->label2 = epsilon;
424 blkloopback->p1 = blkend;
425 blkloopback->label1 = epsilon;
426 blkloopback->p2 = blkstart;
427 blkloopback->label2 = epsilon;
428 (*elem_tail)->p1 = blkloopback;
429 (*elem_tail)->label1 = epsilon;
430 *elem_tail = blkend;
431 elem->down->start_state = blkstart;
432 start = newGLANode();
433 start->p1 = blkstart;
434 start->label1 = epsilon;
435 break;
436 case POS_CLOSURE :
437 /* Make a blk like this:
438 * o-->o-->blk-->o-->o
439 * ^---------|
440 * where the farthest left node is the start node passed in.
441 * The 'next' ptr of the blkstart node points to the endblk node.
442 */
443 blkstart = newGLANode();
444 blkloopback = newGLANode();
445 blkend = newGLANode();
446 blkstart->p1 = build_GLA_for_block(elem->down, elem_tail);
447 blkstart->label1 = epsilon;
448 /* record the end of loop for "follow" computation */
449 blkstart->next = blkend;
450 blkloopback->p1 = blkend;
451 blkloopback->label1 = epsilon;
452 blkloopback->p2 = blkstart;
453 blkloopback->label2 = epsilon;
454 (*elem_tail)->p1 = blkloopback;
455 (*elem_tail)->label1 = epsilon;
456 *elem_tail = blkend;
457 elem->down->start_state = blkstart;
458 start = newGLANode();
459 start->p1 = blkstart;
460 start->label1 = epsilon;
461 break;
462 case OPT :
463 /* Make a blk like this:
464 * o-->o-->blk-->o
465 * |---------^
466 * where the farthest left node is the start node passed in.
467 */
468 blkstart = newGLANode();
469 blkend = newGLANode();
470 blkstart->p1 = build_GLA_for_block(elem->down, elem_tail);
471 blkstart->label1 = epsilon;
472 blkstart->p2 = blkend;
473 blkstart->label2 = epsilon;
474 (*elem_tail)->p1 = blkend;
475 (*elem_tail)->label1 = epsilon;
476 *elem_tail = (*elem_tail)->p1;
477 elem->down->start_state = blkstart;
478 start = newGLANode();
479 start->p1 = blkstart;
480 start->label1 = epsilon;
481 break;
482 case BLOCK :
483 /* return o->blk */
484 start = newGLANode();
485 start->p1 = build_GLA_for_block(elem, elem_tail);
486 start->label1 = epsilon;
487 elem->start_state = start;
488 break;
489 }
490 return start;
491 }
492
493 void
494 #ifdef __USE_PROTOS
495 build_follow_links( GLA *end_of_rule, ListNode *refs )
496 #else
497 build_follow_links( end_of_rule, refs )
498 GLA *end_of_rule;
499 ListNode *refs;
500 #endif
501 {
502 ListNode *p;
503 GLA *f, *prev, *first=NULL;
504 require(end_of_rule!=NULL, "build_follow_links: NULL tree pointer");
505
506 if ( refs == NULL ) /* no ref list, must be start symbol */
507 {
508 /* append a '$' link to the end_input node */
509 end_of_rule->p1 = end_node;
510 end_of_rule->label1 = end_of_input;
511 return;
512 }
513
514 /* the refs list is a list of GLA nodes that follow references to
515 * the rule associated with 'end_of_rule'.
516 */
517 prev = NULL;
518 for (p = refs->next; p!=NULL; p=p->next)
519 {
520 f = newGLANode();
521 f->p1 = (GLA *)p->elem;
522 f->label1 = epsilon;
523 /* connect new follow link into downward list */
524 if ( prev!=NULL )
525 {
526 prev->p2 = f;
527 prev->label2 = epsilon;
528 }
529 else
530 {
531 first = f;
532 }
533 prev = f;
534 }
535
536 /* connect end of rule to follow list */
537 end_of_rule->p1 = first;
538 end_of_rule->label1 = epsilon;
539 }
540
541 void
542 #ifdef __USE_PROTOS
543 dump_GLAs( AST *rules )
544 #else
545 dump_GLAs( rules )
546 AST *rules;
547 #endif
548 {
549 AST *r;
550 SymEntry *s;
551 require(rules!=NULL, "dump_GLAs: NULL rules pointer");
552
553 fprintf(stderr,"\n");
554 for (r=rules; r!=NULL; r=r->right)
555 {
556 s = (SymEntry *) hash_get(symbols, r->text);
557 require(s!=NULL, "build_GLA: sym tab broken");
558 dump_GLA( s->start_state );
559 fprintf(stderr,"\n");
560 }
561 }
562
563 /* Can only dump GLA's for BNF for the moment */
564 void
565 #ifdef __USE_PROTOS
566 dump_GLA( GLA *q )
567 #else
568 dump_GLA( q )
569 GLA *q;
570 #endif
571 {
572 GLA *prod, *p;
573
574 fprintf(stderr,"o-->");
575 for (prod=q->p1; prod!=NULL; prod=prod->p2)
576 {
577 fprintf(stderr,"o");
578
579 for (p = prod; p->p1!=NULL;)
580 {
581 if ( p->visited ) break;
582 p->visited = 1;
583
584 if ( p->label1 > 0 && p->label1!=epsilon )
585 {
586 fprintf(stderr,"--%s-->o", token_dict[p->label1]);
587 p = p->p1;
588 if ( p->label1 == end_of_input ) break;
589 }
590 else if ( p->next!=NULL )
591 {
592 /*fprintf(stderr,"-%d-^ o", p->context); */
593 fprintf(stderr,"---^ o");
594 p = p->next;
595 }
596 else
597 {
598 fprintf(stderr,"----->o");
599 p = p->p1;
600 }
601 }
602 fprintf(stderr,"\n");
603 if ( prod->p2!=NULL ) fprintf(stderr," |\n ");
604 }
605 }
606
607 /*
608 * Compare each alt of a BLOCK against every other to determine
609 * whether or not any tokens predict more than one alt.
610 */
611 void
612 #ifdef __USE_PROTOS
613 test_block_consistency( AST *blk, int block_type )
614 #else
615 test_block_consistency( blk, block_type )
616 AST *blk;
617 int block_type;
618 #endif
619 {
620 AST *t;
621 set in_common;
622 GLA *alt1, *alt2, *start;
623 int i1, i2;
624 require(blk!=NULL&&blk->token==BLOCK,
625 "test_BLOCK_consistency: NULL or invalid block");
626
627 t = blk->down;
628 require(t!=NULL&&t->token==ALT,
629 "test_BLOCK_consistency: invalid AST structure");
630 require(blk->start_state!=NULL,
631 "test_BLOCK_consistency: no GLA structure for block");
632
633 start = blk->start_state->p1;
634 for (alt1=start,i1=1; alt1!=NULL; alt1=alt1->p2,i1++, t=t->right)
635 {
636 require(!set_nil(alt1->lookahead), "test_BLOCK_consistency: invalid lookahead set");
637 for (alt2=alt1->p2,i2=i1+1; alt2!=NULL; alt2=alt2->p2,i2++)
638 {
639 in_common = set_and(alt1->lookahead, alt2->lookahead);
640 if ( !set_nil(in_common) )
641 {
642 fprintf(stderr, ErrHdr, FileStr[t->file], t->line);
643 fprintf(stderr, " warning: alts %d and %d of (...) nondeterministic upon ",
644 i1, i2);
645 set_fprint(stderr, in_common);
646 fprintf(stderr, "\n");
647 }
648 set_free(in_common);
649 }
650 }
651
652 if ( block_type == OPT || block_type == CLOSURE )
653 {
654 /* test optional alt against all regular alts */
655 t = blk->down;
656 for (alt1=blk->start_state->p1,i1=1; alt1!=NULL; alt1=alt1->p2,i1++, t=t->right)
657 {
658 in_common = set_and(alt1->lookahead, blk->start_state->lookahead);
659 if ( !set_nil(in_common) )
660 {
661 fprintf(stderr, ErrHdr, FileStr[t->file], t->line);
662 fprintf(stderr, " warning: alt %d and optional branch of %s nondeterministic upon ",
663 i1, block_type==OPT?"{...}":"(...)*");
664 set_fprint(stderr, in_common);
665 fprintf(stderr, "\n");
666 }
667 set_free(in_common);
668 }
669 }
670 }
671
672 static GLA *
673 #ifdef __USE_PROTOS
674 newGLANode(void)
675 #else
676 newGLANode()
677 #endif
678 {
679 GLA *p;
680
681 p = (GLA *) calloc(1, sizeof(GLA));
682 require(p!=NULL, "newGLANode: can't alloc memory");
683 p->in_rule = CurRule;
684 return p;
685 }
+0
-1114
contrib/pccts/sorcerer/main.c less more
0 /*
1 * main.c
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-2001
27 */
28 #include "pcctscfg.h"
29 #include "stdpccts.h"
30 #include "sym.h"
31 #include "proto.h"
32 #include <ctype.h>
33
34 #define MAX_INT_STACK 50
35 static int istack[MAX_INT_STACK]; /* Int stack */
36 static int isp = MAX_INT_STACK;
37
38 static int DontAcceptStdin = 0;
39 static int DontAcceptFiles = 0;
40
41 typedef struct _Opt {
42 char *option;
43 int arg;
44 #ifdef __cplusplus
45 void (*process)(...);
46 #else
47 void (*process)();
48 #endif
49 char *descr;
50 } Opt;
51
52 #ifdef __USE_PROTOS
53 static int cistrequ(char *a,char *b)
54 #else
55 static int cistrequ(a,b)
56 char *a;
57 char *b;
58 #endif
59 {
60 for ( ;*a != 0 && *b != 0; a++, b++) {
61 if (toupper(*a) != toupper(*b)) return 0;
62 }
63 return (*a == *b);
64 }
65
66 #ifdef __USE_PROTOS
67 static void ProcessArgs(int, char **, Opt *);
68 #else
69 static void ProcessArgs();
70 #endif
71
72 static void
73 #ifdef __USE_PROTOS
74 pOut( char *s, char *t )
75 #else
76 pOut( s, t )
77 char *s;
78 char *t;
79 #endif
80 {
81 OutputDirectory = t;
82 }
83
84 static void
85 #ifdef __USE_PROTOS
86 pFile( char *s )
87 #else
88 pFile( s )
89 char *s;
90 #endif
91 {
92 if ( *s=='-' ) { warnNoFL( eMsg1("invalid option: '%s'",s) ); return; }
93 if ( DontAcceptFiles )
94 {
95 warnNoFL(eMsg1("file '%s' ignored as '-' (stdin option) was specified first",s));
96 return;
97 }
98
99 require(NumFiles<MaxNumFiles,"exceeded max # of input files");
100 FileStr[NumFiles++] = s;
101 DontAcceptStdin = 1;
102 }
103
104 static void
105 #ifdef __USE_PROTOS
106 pDToks( char *s, char *t )
107 #else
108 pDToks( s, t )
109 char *s, *t;
110 #endif
111 {
112 if ( !GenCPP )
113 {
114 warnNoFL("-def-tokens valid with C++ interface only; ignored");
115 return;
116 }
117 else {
118 def_tokens = 1;
119 }
120 }
121
122 static void
123 #ifdef __USE_PROTOS
124 pDToksFile( char *s, char *t )
125 #else
126 pDToksFile( s, t )
127 char *s, *t;
128 #endif
129 {
130 if ( GenCPP )
131 {
132 warnNoFL("-def-tokens-file not valid with C++ interface; ignored");
133 return;
134 }
135 if ( Inline )
136 {
137 warnNoFL("-def-tokens-file conflicts with -inline; ignored");
138 }
139 else {
140 def_token_file = t;
141 if ( def_token_file == NULL )
142 {
143 warnNoFL("don't you want filename with that -def-tokens-file?; ignored");
144 }
145 }
146 }
147
148 static void
149 #ifdef __USE_PROTOS
150 pPrefix( char *s, char *t )
151 #else
152 pPrefix( s, t )
153 char *s, *t;
154 #endif
155 {
156 Prefix = t;
157 if ( GenCPP ) {
158 warnNoFL("-prefix conflicts with C++ interface; ignored");
159 Prefix = "";
160 return;
161 }
162
163 if ( Prefix == NULL )
164 {
165 warnNoFL("don't you want string with that -prefix?; ignored");
166 Prefix = "";
167 }
168 }
169
170 static void
171 #ifdef __USE_PROTOS
172 pFuncs( char *s, char *t )
173 #else
174 pFuncs( s, t )
175 char *s, *t;
176 #endif
177 {
178 if ( GenCPP ) { errNoFL("-funcs option makes no sense in C++ mode; ignored"); return; }
179 GenKRProtos = GenAnsiProtos = 0;
180 if ( cistrequ(t, "kr")) GenKRProtos = 1;
181 else if ( cistrequ(t, "ansi")) GenAnsiProtos = 1;
182 else if ( cistrequ(t, "both")) {GenAnsiProtos = 1; GenKRProtos = 1;}
183 else {
184 warnNoFL(eMsg1("don't know how to generate '%s' style functions; assuming ANSI",t));
185 GenAnsiProtos = 1;
186 }
187 }
188
189 static void
190 #ifdef __USE_PROTOS
191 pProtoFile( char *s, char *t )
192 #else
193 pProtoFile( s, t )
194 char *s, *t;
195 #endif
196 {
197 if ( GenCPP )
198 {warnNoFL("-proto-file not valid with C++ interface; ignored");}
199 if ( t==NULL )
200 {warnNoFL("don't you want filename with that -proto-file?; ignored");}
201 else {
202 GenProtoFile = t;
203 }
204 }
205
206 static void
207 pstdin()
208 {
209 if ( DontAcceptStdin )
210 {
211 warnNoFL("'-' (stdin) ignored as files were specified first");
212 return;
213 }
214 if ( GenCPP )
215 {warnNoFL("'-' (stdin) cannot be used with C++ interface; ignored");}
216
217 require(NumFiles<MaxNumFiles,"exceeded max # of input files");
218 FileStr[NumFiles++] = "stdin";
219 DontAcceptFiles = 1;
220 }
221
222 static void
223 pGuts()
224 {
225 print_guts = 1;
226 }
227
228 static void
229 pTrans()
230 {
231 transform = 1;
232 }
233
234 static void
235 pInline()
236 {
237 if ( def_token_file!=NULL )
238 {
239 warnNoFL("-inline conflicts with -def-tokens; ignored");
240 }
241 else if ( GenCPP )
242 {
243 warnNoFL("-inline conflicts with C++ interface; ignored");
244 }
245 else Inline = 1;
246 }
247
248 static void
249 pCPP()
250 {
251 GenCPP = 1;
252 }
253
254 /* MR23 */
255
256 static void
257 pNoCtor()
258 {
259 NoCtor = 1;
260 if ( ! GenCPP )
261 {warnNoFL("-noctor needs -CPP option; ignored");}
262 }
263
264 Opt options[] = {
265 #ifdef __cplusplus
266 { "-CPP", 0, (void (*)(...)) pCPP,"Generate C++ output"},
267 { "-def-tokens", 0, (void (*)(...)) pDToks,"Define ref'd tokens w/unique integer (C++ interface)"},
268 { "-def-tokens-file", 1, (void (*)(...)) pDToksFile,"Define ref'd tokens w/unique integer (put in file)"},
269 { "-funcs", 1, (void (*)(...)) pFuncs,"Gen 'ANSI', 'KR', or 'both' style function headers"},
270 { "-guts", 0, (void (*)(...)) pGuts,"Print out a bunch of internal data structures"},
271 { "-inline", 0, (void (*)(...)) pInline, "Gen only actions and functions for given rules"},
272 { "-noctor", 0, (void (*)(...)) pNoCtor, "Do not generate a blank constructor"}, /* MR23 */
273 { "-prefix", 1, (void (*)(...)) pPrefix, "Prefix all globally visible symbols"},
274 { "-proto-file", 1, (void (*)(...)) pProtoFile, "Put all prototypes for rule functions in this file"},
275 { "-out-dir", 1, (void (*)(...)) pOut, "Directory where all output files go (default=\".\")"},
276 { "-transform", 0, (void (*)(...)) pTrans, "Transformation mode; read/write to different pointers"},
277 { "-", 0, (void (*)(...)) pstdin, "take input from stdin"},
278 { "*", 0, (void (*)(...)) pFile, "" }, /* anything else is a file */
279 #else
280 { "-CPP", 0, pCPP, "Generate C++ output"},
281 { "-def-tokens", 0, pDToks,"Define ref'd tokens w/unique integer (C++ interface)"},
282 { "-def-tokens-file", 1, pDToksFile,"Define ref'd tokens w/unique integer (put in file)"},
283 { "-funcs", 1, pFuncs,"Gen 'ANSI', 'KR', or 'both' style function headers"},
284 { "-guts", 0, pGuts,"Print out a bunch of internal data structures"},
285 { "-inline", 0, pInline, "Gen only actions and functions for given rules"},
286 { "-noctor", 0, pNoCtor, "Do not generate a blank constructor"}, /* MR23 */
287 { "-prefix", 1, pPrefix, "Prefix all globally visible symbols"},
288 { "-proto-file", 1, pProtoFile, "Put all prototypes for rule functions in this file"},
289 { "-out-dir", 1, pOut, "Directory where all output files go (default=\".\")"},
290 { "-transform", 0, pTrans, "Transformation mode; read/write to different pointers"},
291 { "-", 0, pstdin, "take input from stdin"},
292 { "*", 0, pFile, "" }, /* anything else is a file */
293 #endif
294 { NULL, 0, NULL, NULL }
295 };
296
297 int
298 #ifdef __USE_PROTOS
299 main(int argc, char *argv[])
300
301 #else
302 main(argc, argv)
303 int argc;
304 char *argv[];
305 #endif
306 {
307 AST *root;
308 #ifdef THINK_C
309 #include <console.h>
310 argc = ccommand (&argv);
311 #endif
312
313 fprintf(stderr,
314 "Sorcerer - A simple tree-parser generator Version %s 1992-2001\n",
315 VersionText);
316
317 if ( argc == 1 ) { help(); zzDONE; }
318 ProcessArgs(argc-1, &(argv[1]), options);
319
320 symbols = newHashTable();
321 token_dict = (char **) calloc(token_table_size, sizeof(char *));
322 require(token_dict != NULL, "main: can't create token_dict");
323
324 output = stdout;
325 input = NextFile();
326 require(input!=NULL, "No grammar description found (exiting...)");
327 root = read_sor_desc(input);
328
329 if ( root!=NULL ) gen(root);
330
331 if ( found_error )
332 {
333 fprintf(stderr, "no parser generated due to parsing errors; exiting...\n");
334 zzDIE;
335 }
336
337 if ( GenCPP ) {
338 GenCPPClassHeader();
339 GenCPPClassCode();
340 }
341
342 if ( !UserDefdTokens ) gen_tokens_file();
343 else if ( def_token_file!=NULL ) {
344 warnNoFL("tokens file not generated; it conflicts with use of #tokdefs");
345 }
346
347 if ( GenProtoFile!=NULL )
348 {
349 FILE *ProtoFILE;
350 ProtoFILE = fopen(OutMetaName(GenProtoFile), "w");
351 if ( ProtoFILE==NULL ) {warnNoFL(eMsg1("Can't open prototype file '%s'; ignored",GenProtoFile));}
352 else {
353 #ifdef SPECIAL_FOPEN
354 special_fopen_actions(OutMetaName(GenProtoFile));
355 #endif
356 gen_info_hdr( ProtoFILE );
357 if ( header_action!=NULL )
358 dumpAction(header_action, ProtoFILE, 0, -1, 0, 1);
359 GenRulePrototypes( ProtoFILE, 0 );
360 fclose(ProtoFILE);
361 }
362 }
363 if ( found_error ) {zzDIE;}
364 else zzDONE;
365 }
366
367 void
368 #ifdef __USE_PROTOS
369 help(void)
370 #else
371 help()
372 #endif
373 {
374 Opt *p = options;
375 static char buf[MaxRuleName+1];
376
377 fprintf(stderr, "sor [options] f1.sor ... fn.sor\n");
378 while ( p->option!=NULL && *(p->option) != '*' )
379 {
380 buf[0]='\0';
381 if ( p->arg ) sprintf(buf, "%s ___", p->option);
382 else strcpy(buf, p->option);
383 fprintf(stderr, " %-20s %s\n", buf, p->descr);
384 p++;
385 }
386 }
387
388 FILE *
389 #ifdef __USE_PROTOS
390 NextFile( void )
391 #else
392 NextFile( )
393 #endif
394 {
395 FILE *f;
396
397 for (;;)
398 {
399 if ( CurFile+1 >= NumFiles ) return(NULL);
400 CurFile++;
401 if ( cistrequ(FileStr[CurFile],"stdin")) return stdin;
402 f = fopen(FileStr[CurFile], "r");
403 if ( f == NULL )
404 {
405 warnNoFL( eMsg1("file %s doesn't exist; ignored", FileStr[CurFile]) );
406 }
407 else
408 {
409 return(f);
410 }
411 }
412 }
413
414 void
415 #ifdef __USE_PROTOS
416 pushint( int i )
417 #else
418 pushint( i )
419 int i;
420 #endif
421 {
422 require(isp>0, "pushint: stack overflow");
423 istack[--isp] = i;
424 }
425
426 int
427 #ifdef __USE_PROTOS
428 popint( void )
429 #else
430 popint( )
431 #endif
432 {
433 require(isp<MAX_INT_STACK, "popint: stack underflow");
434 return istack[isp++];
435 }
436
437 int
438 #ifdef __USE_PROTOS
439 istacksize( void )
440 #else
441 istacksize( )
442 #endif
443 {
444 return MAX_INT_STACK-isp;
445 }
446
447 void
448 #ifdef __USE_PROTOS
449 istackreset( void )
450 #else
451 istackreset( )
452 #endif
453 {
454 isp = MAX_INT_STACK;
455 }
456
457 int
458 #ifdef __USE_PROTOS
459 istackempty( void )
460 #else
461 istackempty( )
462 #endif
463 {
464 return isp==MAX_INT_STACK;
465 }
466
467 int
468 #ifdef __USE_PROTOS
469 topint( void )
470 #else
471 topint( )
472 #endif
473 {
474 require(isp<MAX_INT_STACK, "topint: stack underflow");
475 return istack[isp];
476 }
477
478 /* sprintf up to 3 strings */
479 char *
480 #ifdef __USE_PROTOS
481 eMsg3( char *s, char *a1, char *a2, char *a3 )
482 #else
483 eMsg3( s, a1, a2, a3 )
484 char *s;
485 char *a1;
486 char *a2;
487 char *a3;
488 #endif
489 {
490 static char buf[250]; /* DANGEROUS as hell !!!!!! */
491
492 sprintf(buf, s, a1, a2, a3);
493 return( buf );
494 }
495
496 char *
497 #ifdef __USE_PROTOS
498 eMsgd( char *s, int d )
499 #else
500 eMsgd( s, d )
501 char *s;
502 int d;
503 #endif
504 {
505 static char buf[250]; /* DANGEROUS as hell !!!!!! */
506
507 sprintf(buf, s, d);
508 return( buf );
509 }
510
511 void
512 #ifdef __USE_PROTOS
513 fatalFL( char *err_, char *f, int l )
514 #else
515 fatalFL( err_, f, l )
516 char *err_;
517 char *f;
518 int l;
519 #endif
520 {
521 fprintf(stderr, ErrHdr, f, l);
522 fprintf(stderr, " %s\n", err_);
523 exit(1);
524 }
525
526 /*
527 * add an element to a list.
528 *
529 * Any non-empty list has a sentinel node whose 'elem' pointer is really
530 * a pointer to the last element. (i.e. length(list) = #elemIn(list)+1).
531 * Elements are appended to the list.
532 */
533 void
534 #ifdef __USE_PROTOS
535 list_add( ListNode **list, void *e )
536 #else
537 list_add( list, e )
538 ListNode **list;
539 void *e;
540 #endif
541 {
542 ListNode *p, *tail;
543 require(e!=NULL, "list_add: attempting to add NULL list element");
544
545 p = newListNode;
546 require(p!=NULL, "list_add: cannot alloc new list node");
547 p->elem = e;
548 if ( *list == NULL )
549 {
550 ListNode *sentinel = newListNode;
551 require(sentinel!=NULL, "list_add: cannot alloc sentinel node");
552 *list=sentinel;
553 sentinel->next = p;
554 sentinel->elem = (char *)p; /* set tail pointer */
555 }
556 else /* find end of list */
557 {
558 tail = (ListNode *) (*list)->elem; /* get tail pointer */
559 tail->next = p;
560 (*list)->elem = (char *) p; /* reset tail */
561 }
562 }
563
564 static void
565 #ifdef __USE_PROTOS
566 ProcessArgs( int argc, char **argv, Opt *options )
567 #else
568 ProcessArgs( argc, argv, options )
569 int argc;
570 char **argv;
571 Opt *options;
572 #endif
573 {
574 Opt *p;
575 require(argv!=NULL, "ProcessArgs: command line NULL");
576
577 while ( argc-- > 0 )
578 {
579 p = options;
580 while ( p->option != NULL )
581 {
582 if ( strcmp(p->option, "*") == 0 ||
583 cistrequ(p->option, *argv))
584 {
585 if ( p->arg )
586 {
587 (*p->process)( *argv, *(argv+1) );
588 argv++;
589 argc--;
590 }
591 else
592 (*p->process)( *argv );
593 break;
594 }
595 p++;
596 }
597 argv++;
598 }
599 }
600
601 /*
602 * Given a string, this function allocates and returns a pointer to a
603 * hash table record of size 'sz' whose "str" pointer is reset to a position
604 * in the string table.
605 */
606 Entry *
607 #ifdef __USE_PROTOS
608 newEntry( char *text, int sz )
609 #else
610 newEntry( text, sz )
611 char *text;
612 int sz;
613 #endif
614 {
615 Entry *p;
616 require(text!=NULL, "new: NULL terminal");
617
618 if ( (p = (Entry *) calloc(1,sz)) == 0 )
619 {
620 fatal("newEntry: out of memory for terminals\n");
621 exit(1);
622 }
623 p->str = mystrdup(text);
624
625 return(p);
626 }
627
628 void
629 #ifdef __USE_PROTOS
630 token_association(int token_type, char *text)
631 #else
632 token_association( token_type, text )
633 int token_type;
634 char *text;
635 #endif
636 {
637 if ( token_type >= token_table_size ) /* overflow? */
638 {
639 char **p;
640 int i, more;
641
642 more = 100;
643 token_table_size += more;
644 token_dict = (char **) realloc(token_dict, token_table_size*sizeof(char *));
645 require(token_dict != NULL, "token_association: can't extend token_dict");
646 for (p= &token_dict[token_table_size-more],i=1; i<=more; i++) *p++ = NULL;
647 }
648 token_dict[token_type] = text;
649 }
650
651 /*
652 * Return a string corresponding to the output file name associated
653 * with the input file name passed in.
654 *
655 * Observe the following rules:
656 *
657 * f.e --> f".c"
658 * f --> f".c"
659 * f. --> f".c"
660 * f.e.t --> f.e".c"
661 *
662 * Where f,e,t are arbitrarily long sequences of characters in a file
663 * name.
664 *
665 * In other words, if a ".x" appears on the end of a file name, make it
666 * ".c". If no ".x" appears, append ".c" to the end of the file name.
667 *
668 * Use malloc() for new string.
669 */
670 char *
671 #ifdef __USE_PROTOS
672 outname( char *fs )
673 #else
674 outname( fs )
675 char *fs;
676 #endif
677 {
678 static char buf[MaxFileName+1];
679 char *p;
680
681 p = buf;
682 strcpy(buf, fs);
683 while ( *p != '\0' ) {p++;} /* Stop on '\0' */
684 while ( *p != '.' && p != buf ) {--p;} /* Find '.' */
685 if ( p != buf ) *p = '\0'; /* Found '.' */
686 require(strlen(buf) + 2 < (size_t)MaxFileName, "outname: filename too big");
687 if ( GenCPP ) strcat(buf, CPP_FILE_SUFFIX);
688 else strcat(buf, ".c");
689 return( buf );
690 }
691
692 void
693 #ifdef __USE_PROTOS
694 ensure_no_C_file_collisions(char *class_c_file)
695 #else
696 ensure_no_C_file_collisions(class_c_file)
697 char *class_c_file;
698 #endif
699 {
700 int i;
701
702 for (i=0; i<NumFiles; i++)
703 {
704 #ifdef PCCTS_CASE_INSENSITIVE_FILE_NAME
705 /* assume that file names are case insensitive */
706 if ( STRICMP(outname(FileStr[i]), class_c_file)==0 )
707 #else
708 if ( strcmp(outname(FileStr[i]), class_c_file)==0 )
709 #endif
710 {
711 fatal(eMsg1("class def output file conflicts with parser output file: %s",
712 outname(FileStr[i])));
713 }
714 }
715 }
716
717 /* MR10: Jeff Vincent
718 MR10: Changed to remove directory information from n only if
719 MR10: if OutputDirectory was changed by user (-o option)
720 */
721 char *
722 #ifdef __USE_PROTOS
723 OutMetaName(char *n)
724 #else
725 OutMetaName(n)
726 char *n;
727 #endif
728 {
729 static char *dir_sym = DirectorySymbol;
730 static char newname[MaxFileName+1];
731 char *p;
732
733 /* If OutputDirectory is same as TopDirectory (platform default) then leave n alone. */
734 if (strcmp(OutputDirectory, TopDirectory) == 0)
735 return n;
736
737 /* p will point to filename without path information */
738 if ((p = strrchr(n, *dir_sym)) != NULL)
739 p++;
740 else
741 p = n;
742
743 /* Copy new output directory into newname[] */
744 strcpy(newname, OutputDirectory);
745
746 /* if new output directory does not have trailing dir_sym, add it! */
747 if (newname[strlen(newname)-1] != *dir_sym)
748 strcat(newname, dir_sym);
749
750 /* contatenate FILE NAME ONLY to new output directory */
751 strcat(newname, p);
752
753 return newname;
754 }
755
756 void
757 #ifdef __USE_PROTOS
758 set_fprint( FILE *f, set e )
759 #else
760 set_fprint( f, e )
761 FILE *f;
762 set e;
763 #endif
764 {
765 int t;
766
767 if ( set_nil(e) ) return;
768 fprintf(f, "{");
769 while ( !set_nil(e) )
770 {
771 t = set_int(e);
772 set_rm(t, e);
773 fprintf(f, " %s", token_dict[t]);
774 }
775 fprintf(f, " }");
776 }
777
778 /* Given a list of ANSI-style parameter declarations, print out a
779 * comma-separated list of the symbols (w/o types).
780 * Basically, we look for a comma, then work backwards until start of
781 * the symbol name. Then print it out until 1st non-alnum char. Now,
782 * move on to next parameter.
783 */
784 void
785 #ifdef __USE_PROTOS
786 DumpListOfParmNames( char *pdecl, FILE *output )
787 #else
788 DumpListOfParmNames( pdecl, output )
789 char *pdecl;
790 FILE *output;
791 #endif
792 {
793 int firstTime = 1, done = 0;
794 require(output!=NULL, "DumpListOfParmNames: NULL parm");
795
796 if ( pdecl == NULL ) return;
797 while ( !done )
798 {
799 if ( !firstTime ) putc(',', output);
800 done = DumpNextNameInDef(&pdecl, output);
801 firstTime = 0;
802 }
803 }
804
805 /* given a list of parameters or return values, dump the next
806 * name to output. Return 1 if last one just printed, 0 if more to go.
807 */
808 int
809 #ifdef __USE_PROTOS
810 DumpNextNameInDef( char **q, FILE *output )
811 #else
812 DumpNextNameInDef( q, output )
813 char **q;
814 FILE *output;
815 #endif
816 {
817 char *p = *q; /* where did we leave off? */
818 int done=0;
819
820 while ( *p!='\0' && *p!=',' ) p++; /* find end of decl */
821 if ( *p == '\0' ) done = 1;
822 while ( !isalnum(*p) && *p!='_' ) --p; /* scan back until valid var character */
823 while ( isalnum(*p) || *p=='_' ) --p; /* scan back until beginning of variable */
824 p++; /* move to start of variable */
825 while ( isalnum(*p) || *p=='_' ) {putc(*p, output); p++;}
826 while ( *p!='\0' && *p!=',' ) p++; /* find end of decl */
827 p++; /* move past this parameter */
828
829 *q = p; /* record where we left off */
830 return done;
831 }
832
833 /* Given a list of ANSI-style parameter declarations, dump K&R-style
834 * declarations, one per line for each parameter. Basically, convert
835 * comma to semi-colon, newline.
836 */
837 void
838 #ifdef __USE_PROTOS
839 DumpOldStyleParms( char *pdecl, FILE *output )
840 #else
841 DumpOldStyleParms( pdecl, output )
842 char *pdecl;
843 FILE *output;
844 #endif
845 {
846 require(output!=NULL, "DumpOldStyleParms: NULL parm");
847
848 if ( pdecl == NULL ) return;
849 while ( *pdecl != '\0' )
850 {
851 if ( *pdecl == ',' )
852 {
853 pdecl++;
854 putc(';', output); putc('\n', output);
855 while ( *pdecl==' ' || *pdecl=='\t' || *pdecl=='\n' ) pdecl++;
856 }
857 else {putc(*pdecl, output); pdecl++;}
858 }
859 putc(';', output);
860 putc('\n', output);
861 }
862
863 /* Take in a type definition (type + symbol) and print out type only */
864 void
865 #ifdef __USE_PROTOS
866 DumpType( char *s, FILE *f, char *file, int line )
867 #else
868 DumpType( s, f, file, line )
869 char *s;
870 FILE *f;
871 char *file;
872 int line;
873 #endif
874 {
875 char *p, *end;
876 require(s!=NULL, "DumpType: invalid type string");
877
878 p = &s[strlen(s)-1]; /* start at end of string and work back */
879 /* scan back until valid variable character */
880 while ( !isalnum(*p) && *p!='_' ) --p;
881 /* scan back until beginning of variable */
882 while ( isalnum(*p) || *p=='_' ) --p;
883 if ( p<=s )
884 {
885 warnFL(eMsg1("invalid parameter/return value: '%s'",s), file, line);
886 return;
887 }
888 end = p; /* here is where we stop printing alnum */
889 p = s;
890 while ( p!=end ) {putc(*p, f); p++;} /* dump until just before variable */
891 while ( *p!='\0' ) /* dump rest w/o variable */
892 {
893 if ( !isalnum(*p) && *p!='_' ) putc(*p, f);
894 p++;
895 }
896 }
897
898 char *
899 #ifdef __USE_PROTOS
900 actiondup(char *s)
901 #else
902 actiondup(s)
903 char *s;
904 #endif
905 {
906 char *p = (char *) malloc(strlen(s)+1);
907 require(p!=NULL, "actiondup: no memory");
908 strcpy(p, s);
909 return p;
910 }
911
912 #ifdef OLD
913 RefVarRec *
914 #ifdef __USE_PROTOS
915 newRefVarRec(char *t,char *lab, char *init)
916 #else
917 newRefVarRec(t,lab,init)
918 char *t,*lab,*init;
919 #endif
920 {
921 RefVarRec *p;
922 SymEntry *q;
923
924 q = (SymEntry *) hash_get(symbols, lab);
925 if ( q==NULL )
926 {
927 q = (SymEntry *) hash_add(symbols, lab, (Entry *) newSymEntry(lab));
928 q->token = REFVAR;
929 q->defined = 1;
930 }
931 else err(eMsg2("Reference variable clashes with %s: '%s'", zztokens[q->token], lab));
932
933 p = (RefVarRec *) calloc(1, sizeof(RefVarRec));
934 require(p!=NULL, "newRefVarRec: no memory");
935 strcpy(p->type, t);
936 strcpy(p->label, lab);
937 strcpy(p->init, init);
938 return p;
939 }
940 #endif
941
942 /* From one of the following ref var defs, create a record to track
943 * the info:
944 *
945 * @(int *p);
946 * @(int *p=NULL); -- initialized
947 * @(static int *p); -- global
948 *
949 * The 'def' pointer should point to the first char after the '('
950 */
951 RefVarRec *
952 #ifdef __USE_PROTOS
953 refVarRec(char *def)
954 #else
955 refVarRec(def)
956 char *def;
957 #endif
958 {
959 RefVarRec *p;
960 char *s,*decl;
961
962 p = (RefVarRec *) calloc(1, sizeof(RefVarRec));
963 require(p!=NULL, "newRefVarRec: no memory");
964
965 /* find first word; must be type or "static" */
966 s = def;
967 while ( isalpha(*s) ) s++;
968 if ( strncmp(def, "static", s-def)==0 ) p->global = 1;
969 else s = def;
970
971 /* now get type from s position until '=' or ')' */
972 decl = s;
973 while ( *s!='=' && *s!='\0' ) s++;
974 if ( *s=='=' ) {
975 /* there is an initializer */
976 strcpy(p->init, s+1);
977 *s='\0';
978 }
979 strcpy(p->decl, decl);
980 strcpy(p->var, id_in_decl(decl));
981 return p;
982 }
983
984 /* given a decl (type + id) return a ptr to the id; nondestructive to 'decl'.
985 * Just scan backwards from the end looking for the start of the first id.
986 */
987 char *
988 #ifdef __USE_PROTOS
989 id_in_decl( char *decl )
990 #else
991 id_in_decl( decl )
992 char *decl;
993 #endif
994 {
995 static char id[MaxAtom+1];
996 char *p = &(decl[strlen(decl)-1]);
997 char *end, *start;
998 require(decl!=NULL, "id_in_decl: NULL decl");
999 require(strlen(decl)>(size_t)0, "id_in_decl: empty decl");
1000
1001 /* scan back until valid var character */
1002 while ( !isalnum(*p) || *p=='_' ) --p;
1003 end = p+1;
1004 /* scan back until beginning of variable */
1005 while ( isalnum(*p) || *p=='_' ) --p;
1006 p++; /* move to start of variable */
1007 start = p;
1008 strncpy(id, start, end-start);
1009 id[end-start] = '\0';
1010 return id;
1011 }
1012
1013 /* Take in a decl (type + id) and print it out with a prefix on id */
1014 void
1015 #ifdef __USE_PROTOS
1016 dump_prefixed_decl( char *prefix, char *s, FILE *f )
1017 #else
1018 dump_prefixed_decl( prefix, s, f )
1019 char *prefix;
1020 char *s;
1021 FILE *f;
1022 #endif
1023 {
1024 char *p, *id;
1025 require(s!=NULL, "invalid type string");
1026
1027 p = &s[strlen(s)-1]; /* start at end of string and work back */
1028 /* scan back until valid variable character */
1029 while ( !isalnum(*p) && *p!='_' ) --p;
1030 /* scan back until beginning of variable */
1031 while ( isalnum(*p) || *p=='_' ) --p;
1032 require(p>s, "invalid decl");
1033 p++;
1034 id = p; /* here is where id is */
1035 p = s;
1036 while ( p!=id ) {fputc(*p, f); p++;} /* dump until just before variable */
1037 fprintf(f, "%s", prefix);
1038 while ( isspace(*p) ) p++;
1039 while ( *p!='\0' ) /* dump rest */
1040 {
1041 fputc(*p, f);
1042 p++;
1043 }
1044 }
1045
1046 /*
1047 * Convert
1048 *
1049 * 0, "#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4:Var) )",
1050 * t, &w, &x, &y, &z);
1051 *
1052 * to
1053 *
1054 * 0, "#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",
1055 * t, &w, &x, &y, &z);
1056 */
1057 char *
1058 #ifdef __USE_PROTOS
1059 cvt_token_str(char *prefix, char *s)
1060 #else
1061 cvt_token_str(prefix, s)
1062 char *prefix, *s;
1063 #endif
1064 {
1065 SymEntry *q;
1066 char *b, *e, *p;
1067 char tname[MaxRuleName+1];
1068 char duh[MaxRuleName+1];
1069 static char call[MaxAtom+1];
1070 require(prefix!=NULL&&s!=NULL, "cvt_token_str: NULL string");
1071 require(s[0]!='\0', "cvt_token_str: empty string");
1072
1073 /* printf("cvt incoming: '%s'\n", s);*/
1074
1075 strcpy(call, prefix);
1076 p = &call[strlen(prefix)];
1077
1078 while ( *s!='"' ) *p++ = *s++; /* ignore until string start */
1079 *p++ = *s++;
1080
1081 do
1082 {
1083 while ( !isalpha(*s) )
1084 {
1085 if ( *s=='"' ) { *p='\0'; goto done; }
1086 *p++ = *s++; /* ignore until a token name */
1087 }
1088 *p='\0';
1089 b = s;
1090 while ( isalpha(*s) ) s++; /* ignore until end of token name */
1091 e = s-1;
1092 strncpy(tname, b, e-b+1);
1093 tname[e-b+1] = '\0';
1094
1095 /* printf("looking up %s\n", tname);*/
1096 q = (SymEntry *) hash_get(symbols, tname);
1097 if ( q==NULL )
1098 {
1099 warnNoFL(eMsg1("call to ast_scan() has reference to unknown token: '%s'",tname));
1100 }
1101 else
1102 {
1103 sprintf(duh, "%d", q->token_type);
1104 strcpy(p, duh);
1105 p += strlen(duh);
1106 *p='\0';
1107 }
1108 } while ( *s!='\0' && *s!='"' );
1109 done:
1110 strcat(call, s);
1111 /* printf("cvt: result is '%s'\n", call);*/
1112 return call;
1113 }
+0
-33
contrib/pccts/sorcerer/makefile.VMS less more
0 $! File: MAKE.COM - Makefile for SORCERER on OpenVMS, DECC
1 $!
2 $! History:
3 $! ---------
4 $! 27-Jan-1998 J.F. Pieronne Initial Version
5 $!
6 $ set noon !Don't stop on errors.
7 $!
8 $ if P1 .eqs. "LINK" then goto relink
9 $!
10 $ define/nolog pccts_h "[-.h]"
11 $ define/nolog support_set "[-.support.set]"
12 $!
13 $ delete/nolog *.obj;* !Get rid of existing .OBJ files.
14 $!
15 $ options = "/INCLUDE=(pccts_h,support_set)"
16 $ CC 'options' sor
17 $ CC 'options' scan
18 $ CC 'options' err
19 $ CC 'options' main
20 $ CC 'options' globals
21 $ CC 'options' gen
22 $ CC 'options' hash
23 $ CC 'options' look
24 $ CC 'options' cpp
25 $ CC 'options' [-.support.set]set
26 $!
27 $relink:
28 $ LINK/EXE=SOR.EXE sor,scan,err,main,globals, -
29 gen,hash,look,cpp,set, -
30 sys$input:/options
31 ! sys$share:vaxcrtl.exe/share
32 $ EXIT
+0
-53
contrib/pccts/sorcerer/makefile1 less more
0 #
1 # PCCTS makefile for: SORCERER 1.00B
2 # Uses PCCTS release 1.20
3 #
4 PCCTS=..
5 BIN = $(PCCTS)/bin
6 ANTLR = $(BIN)/antlr
7 DLG = $(BIN)/dlg
8 PCCTS_H = $(PCCTS)/h
9 SET = $(PCCTS)/support/set
10
11 CFLAGS = -Ih -I. -I$(PCCTS_H) -I$(SET) -g -O $(ANSI) $(COTHER) -DZZLEXBUFSIZE=32000
12 AFLAGS = -gh -k 2 -gt
13 DFLAGS = -C2
14 GRM = sor.g
15 SRC = sor.c scan.c err.c main.c globals.c gen.c $(SET)/set.c hash.c look.c cpp.c
16 OBJ = sor.o scan.o err.o main.o globals.o gen.o set.o hash.o look.o cpp.o
17 GENHFILES = tokens.h mode.h stdpccts.h
18 CC=cc
19 SHELL=/bin/sh
20
21 all:
22 make sor
23 (cd lib; make)
24
25 sor: $(OBJ) $(SRC)
26 $(CC) -o sor $(CFLAGS) $(OBJ) -O
27
28 sor.o : sor.c mode.h tokens.h
29 $(CC) $(CFLAGS) -c -o sor.o sor.c
30
31 sor.c stdpccts.h parser.dlg tokens.h err.c : sor.g
32 $(ANTLR) $(AFLAGS) sor.g
33
34 set.o : $(SET)/set.c
35 $(CC) $(CFLAGS) -c -o set.o $(SET)/set.c
36
37 scan.c mode.h : parser.dlg
38 $(DLG) $(DFLAGS) parser.dlg scan.c
39
40 scan.o : scan.c mode.h tokens.h
41
42 clean:
43 rm -f *.o core sor
44
45 scrub:
46 rm -f *.o core $(GENHFILES) parser.dlg scan.c err.c sor.c sor
47
48 ci:
49 ci -u sor.g Makefile main.c globals.c gen.c set.c hash.c look.c cpp.c
50
51 co:
52 co -l sor.g Makefile main.c globals.c gen.c set.c hash.c look.c cpp.c
+0
-13
contrib/pccts/sorcerer/mode.h less more
0 #define START 0
1 #define STRINGS 1
2 #define ACTION_STRINGS 2
3 #define ACTION_CHARS 3
4 #define ACTION_COMMENTS 4
5 #define ACTION_CPP_COMMENTS 5
6 #define CPP_COMMENTS 6
7 #define COMMENTS 7
8 #define REFVAR_SCARF 8
9 #define ACTIONS 9
10 #define TOK_DEF_COMMENTS 10
11 #define TOK_DEF_CPP_COMMENTS 11
12 #define PARSE_ENUM_FILE 12
+0
-29
contrib/pccts/sorcerer/msvc.dsw less more
0 Microsoft Developer Studio Workspace File, Format Version 5.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "Sorcerer"=.\Sorcerer.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 }}}
10
11 Package=<4>
12 {{{
13 }}}
14
15 ###############################################################################
16
17 Global:
18
19 Package=<5>
20 {{{
21 }}}
22
23 Package=<3>
24 {{{
25 }}}
26
27 ###############################################################################
28
+0
-957
contrib/pccts/sorcerer/parser.dlg less more
0 <<
1 /* parser.dlg -- DLG Description of scanner
2 *
3 * Generated from: sor.g
4 *
5 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
6 * Purdue University Electrical Engineering
7 * With AHPCRC, University of Minnesota
8 * ANTLR Version 1.33MR33
9 */
10
11 #define ANTLR_VERSION 13333
12 #include "pcctscfg.h"
13 #include "pccts_stdio.h"
14
15 /* 23-Sep-97 thm Accomodate user who needs to redefine ZZLEXBUFSIZE */
16
17 #ifndef ZZLEXBUFSIZE
18 #define ZZLEXBUFSIZE 8000
19 #endif
20 #include "pcctscfg.h" /* MR20 G. Hobbelt __USE_PROTOS #define */
21 #include "charbuf.h"
22 #include "hash.h"
23 #include "set.h"
24 #include "sor.h"
25 #define AST_FIELDS \
26 int token; char text[MaxAtom+1], label[MaxRuleName+1]; \
27 char *action; /* if action node, here is ptr to it */ \
28 char in,out; \
29 char init_action; /* set if Action and 1st action of alt */ \
30 int file; int line; /* set for BLOCK, ALT, nonterm nodes */ \
31 int upper_range; /* only if T1..T2 found */ \
32 GLA *start_state; /* ptr into GLA for this block */ \
33 int no_copy; /* copy input ptr to output ptr? */ \
34 ListNode *refvars; /* any ref vars defined for this rule */ \
35 unsigned char is_root; /* this token is a root #( A ... ) */
36 #define zzcr_ast(node, cur, _tok, _text) \
37 {(node)->token=_tok; strncpy((node)->text, _text,MaxAtom);}
38 #define USER_ZZSYN
39 #define zzAST_DOUBLE
40 extern int define_num;
41 #define LL_K 2
42 #include "antlr.h"
43 #include "ast.h"
44 #include "tokens.h"
45 #include "dlgdef.h"
46 LOOKAHEAD
47
48 void
49 #ifdef __USE_PROTOS
50 zzerraction(void)
51 #else
52 zzerraction()
53 #endif
54 {
55 (*zzerr)("invalid token");
56 zzadvance();
57 zzskip();
58 }
59 >>
60
61 <<%%lexaction
62
63 #include "sym.h"
64 #include "proto.h"
65
66 int define_num = 0;
67
68 char *
69 #ifdef __USE_PROTOS
70 scarf_to_end_of_func_call(void)
71 #else
72 scarf_to_end_of_func_call()
73 #endif
74 {
75 static char func_call_str[MaxAtom+1];
76 char *p;
77
78 p = &func_call_str[0];
79
80 more:
81 if ( zzchar==')' ) { *p++ = zzchar; *p++ = '\0'; zzadvance(); return func_call_str; }
82 if ( zzchar=='"' )
83 {
84 *p++ = zzchar; zzadvance();
85 while ( zzchar!='"' )
86 {
87 if ( zzchar=='\\' ) { *p++ = zzchar; zzadvance(); }
88 *p++ = zzchar; zzadvance();
89 }
90 }
91 *p++ = zzchar; zzadvance();
92 goto more;
93 }
94 >>
95
96
97 %%START
98
99 @
100 <<
101 NLA = Eof;
102 /* L o o k F o r A n o t h e r F i l e */
103 {
104 FILE *new_input;
105 new_input = NextFile();
106 if ( new_input != NULL ) {
107 fclose( input );
108 input = new_input;
109 zzrdstream( input );
110 /*zzadvance(); ** Get 1st char of this file */
111 zzskip(); /* Skip the Eof (@) char i.e continue */
112 }
113 }
114 >>
115
116 [\t\ ]+
117 <<
118 NLA = 56;
119 zzskip();
120 >>
121
122 \n|\r|\n\r
123 <<
124 NLA = 57;
125 zzline++; zzskip();
126 >>
127
128 \[
129 <<
130 NLA = 58;
131 zzmode(ACTIONS); zzmore();
132 istackreset();
133 pushint(']');
134 >>
135
136 \<\<
137 <<
138 NLA = 59;
139 action_file=CurFile; action_line=zzline;
140 zzmode(ACTIONS); zzmore();
141 istackreset();
142 pushint('>');
143 >>
144
145 \"
146 <<
147 NLA = 60;
148 zzmode(STRINGS); zzmore();
149 >>
150
151 /\*
152 <<
153 NLA = 61;
154 zzmode(COMMENTS); zzskip();
155 >>
156
157 \*/
158 <<
159 NLA = 62;
160 err("Missing /*; found dangling */"); zzskip();
161 >>
162
163 //
164 <<
165 NLA = 63;
166 zzmode(CPP_COMMENTS); zzskip();
167 >>
168
169 \>\>
170 <<
171 NLA = 64;
172 err("Missing <<; found dangling \>\>"); zzskip();
173 >>
174
175 #header
176 <<
177 NLA = Header;
178 >>
179
180 #tokdefs
181 <<
182 NLA = Tokdef;
183 >>
184
185 :
186 <<
187 NLA = LABEL;
188 >>
189
190 \{
191 <<
192 NLA = OPT;
193 >>
194
195 \+
196 <<
197 NLA = POS_CLOSURE;
198 >>
199
200 \*
201 <<
202 NLA = CLOSURE;
203 >>
204
205 .
206 <<
207 NLA = WILD;
208 >>
209
210 ?
211 <<
212 NLA = PRED_OP;
213 >>
214
215 #\(
216 <<
217 NLA = BT;
218 >>
219
220 \}
221 <<
222 NLA = 80;
223 >>
224
225 class
226 <<
227 NLA = 81;
228 >>
229
230 !
231 <<
232 NLA = 84;
233 >>
234
235 \<
236 <<
237 NLA = 85;
238 >>
239
240 \>
241 <<
242 NLA = 86;
243 >>
244
245 ;
246 <<
247 NLA = 87;
248 >>
249
250 \|
251 <<
252 NLA = 88;
253 >>
254
255 \(
256 <<
257 NLA = 89;
258 >>
259
260 \)
261 <<
262 NLA = 90;
263 >>
264
265 ..
266 <<
267 NLA = 91;
268 >>
269
270 [a-z] [A-Za-z0-9_]*
271 <<
272 NLA = NonTerm;
273 >>
274
275 [A-Z] [A-Za-z0-9_]*
276 <<
277 NLA = Token;
278 >>
279
280 #[A-Za-z0-9_]*
281 <<
282 NLA = 92;
283 warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip();
284 >>
285
286
287 %%STRINGS
288
289 @
290 <<
291 NLA = Eof;
292 >>
293
294 \"
295 <<
296 NLA = RExpr;
297 zzmode(START);
298 >>
299
300 \n|\r|\r\n
301 <<
302 NLA = 3;
303 /* MR16a */
304 zzline++;
305 warn("eoln found in string");
306 zzskip();
307 >>
308
309 \\~[]
310 <<
311 NLA = 4;
312 zzmore();
313 >>
314
315 ~[\n\r\"\\]+
316 <<
317 NLA = 5;
318 zzmore();
319 >>
320
321
322 %%ACTION_STRINGS
323
324 @
325 <<
326 NLA = Eof;
327 >>
328
329 \"
330 <<
331 NLA = 6;
332 zzmode(ACTIONS); zzmore();
333 >>
334
335 \n|\r|\r\n
336 <<
337 NLA = 7;
338 /* MR16a */
339 zzline++;
340 warn("eoln found in string (in user action)");
341 zzskip();
342 >>
343
344 \\~[]
345 <<
346 NLA = 8;
347 zzmore();
348 >>
349
350 ~[\n\r\"\\]+
351 <<
352 NLA = 9;
353 zzmore();
354 >>
355
356
357 %%ACTION_CHARS
358
359 @
360 <<
361 NLA = Eof;
362 >>
363
364 '
365 <<
366 NLA = 10;
367 zzmode(ACTIONS); zzmore();
368 >>
369
370 \n|\r|\r\n
371 <<
372 NLA = 11;
373 /* MR16a */
374 zzline++;
375 warn("eoln found in char literal (in user action)");
376 zzskip();
377 >>
378
379 \\~[]
380 <<
381 NLA = 12;
382 zzmore();
383 >>
384
385 ~[\n\r'\\]+
386 <<
387 NLA = 13;
388 zzmore();
389 >>
390
391
392 %%ACTION_COMMENTS
393
394 @
395 <<
396 NLA = Eof;
397 >>
398
399 \*/
400 <<
401 NLA = 14;
402 zzmode(ACTIONS); zzmore();
403 >>
404
405 \*
406 <<
407 NLA = 15;
408 zzmore();
409 >>
410
411 \n|\r|\r\n
412 <<
413 NLA = 16;
414 zzline++; zzmore();
415 >>
416
417 ~[\n\r\*]+
418 <<
419 NLA = 17;
420 zzmore();
421 >>
422
423
424 %%ACTION_CPP_COMMENTS
425
426 @
427 <<
428 NLA = Eof;
429 >>
430
431 \n|\r|\r\n
432 <<
433 NLA = 18;
434 zzline++; zzmode(ACTIONS); zzmore();
435 >>
436
437 ~[\n\r]+
438 <<
439 NLA = 19;
440 zzmore();
441 >>
442
443
444 %%CPP_COMMENTS
445
446 @
447 <<
448 NLA = Eof;
449 >>
450
451 \n|\r|\r\n
452 <<
453 NLA = 20;
454 zzline++; zzmode(START); zzskip();
455 >>
456
457 ~[\n\r]+
458 <<
459 NLA = 21;
460 zzskip();
461 >>
462
463
464 %%COMMENTS
465
466 @
467 <<
468 NLA = Eof;
469 >>
470
471 \*/
472 <<
473 NLA = 22;
474 zzmode(START); zzskip();
475 >>
476
477 \*
478 <<
479 NLA = 23;
480 zzskip();
481 >>
482
483 \n|\r|\r\n
484 <<
485 NLA = 24;
486 zzline++; zzskip();
487 >>
488
489 ~[\n\r\*]+
490 <<
491 NLA = 25;
492 zzskip();
493 >>
494
495
496 %%REFVAR_SCARF
497
498 @
499 <<
500 NLA = Eof;
501 >>
502
503 ~[\)]+ \)
504 <<
505 NLA = 26;
506 {
507 RefVarRec *rf;
508 zzskip();
509 zzbegexpr[strlen(zzbegexpr)-1] = '\0';
510 rf=refVarRec(zzbegexpr);
511 list_add(&AllRefVars, rf);
512 list_add(&RefVars, rf);
513 zzmode(ACTIONS); zzmore(); zzreplstr("");
514 }
515 >>
516
517
518 %%ACTIONS
519
520 @
521 <<
522 NLA = Eof;
523 >>
524
525 \>\>
526 <<
527 NLA = Action;
528 /* these do not nest */
529 zzmode(START);
530 NLATEXT[0] = ' ';
531 NLATEXT[1] = ' ';
532 zzbegexpr[0] = ' ';
533 zzbegexpr[1] = ' ';
534 if ( zzbufovf ) {
535 found_error = 1;
536 err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));
537 }
538 >>
539
540 \]
541 <<
542 NLA = PassAction;
543 if ( topint() == ']' ) {
544 popint();
545 if ( istackempty() ) /* terminate action */
546 {
547 zzmode(START);
548 NLATEXT[0] = ' ';
549 zzbegexpr[0] = ' ';
550 if ( zzbufovf ) {
551 found_error = 1;
552 err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));
553 }
554 }
555 else {
556 /* terminate #[..] */
557 zzreplstr(")");
558 zzmore();
559 }
560 }
561 else if ( topint() == '|' ) { /* end of simple [...] */
562 popint();
563 zzmore();
564 }
565 else zzmore();
566 >>
567
568 \n|\r|\r\n
569 <<
570 NLA = 29;
571 zzline++; zzmore();
572 >>
573
574 \>
575 <<
576 NLA = 30;
577 zzmore();
578 >>
579
580 #[_a-zA-Z][_a-zA-Z0-9]*
581 <<
582 NLA = 31;
583
584 if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||
585 strcmp(zzbegexpr, "#else")==0 ||
586 strcmp(zzbegexpr, "#endif")==0 ||
587 strcmp(zzbegexpr, "#ifndef")==0 ||
588 strcmp(zzbegexpr, "#if")==0 ||
589 strcmp(zzbegexpr, "#define")==0 ||
590 strcmp(zzbegexpr, "#pragma")==0 ||
591 strcmp(zzbegexpr, "#undef")==0 ||
592 strcmp(zzbegexpr, "#import")==0 ||
593 strcmp(zzbegexpr, "#line")==0 ||
594 strcmp(zzbegexpr, "#include")==0 ||
595 strcmp(zzbegexpr, "#error")==0) )
596 {
597 static char buf[100];
598 if ( !transform ) {
599 warn("#id used in nontransform mode; # ignored");
600 sprintf(buf, "%s", zzbegexpr+1);
601 }
602 else {
603 if ( CurRule==NULL )
604 {warn("#id used in action outside of rule; ignored");}
605 else if ( strcmp(zzbegexpr+1,CurRule)==0 )
606 strcpy(buf, "(*_result)");
607 }
608 zzreplstr(buf);
609 }
610 zzmore();
611 >>
612
613 #\[\]
614 <<
615 NLA = 32;
616
617 if ( GenCPP ) zzreplstr("new SORAST");
618 else zzreplstr("ast_empty_node()");
619 zzmore();
620 >>
621
622 #\(\)
623 <<
624 NLA = 33;
625 zzreplstr("NULL"); zzmore();
626 >>
627
628 #\[
629 <<
630 NLA = 34;
631
632 pushint(']');
633 if ( GenCPP ) zzreplstr("new SORAST(");
634 else zzreplstr("ast_node(");
635 zzmore();
636 >>
637
638 #\(
639 <<
640 NLA = 35;
641
642 pushint('}');
643 if ( GenCPP ) zzreplstr("PCCTS_AST::make(");
644 else zzreplstr("ast_make(");
645 zzmore();
646 >>
647
648 #
649 <<
650 NLA = 36;
651 zzmore();
652 >>
653
654 \)
655 <<
656 NLA = 37;
657
658 if ( istackempty() )
659 zzmore();
660 else if ( topint()==')' ) {
661 popint();
662 }
663 else if ( topint()=='}' ) {
664 popint();
665 /* terminate #(..) */
666 zzreplstr(", NULL)");
667 }
668 zzmore();
669 >>
670
671 \[
672 <<
673 NLA = 38;
674
675 pushint('|'); /* look for '|' to terminate simple [...] */
676 zzmore();
677 >>
678
679 \(
680 <<
681 NLA = 39;
682
683 pushint(')');
684 zzmore();
685 >>
686
687 \\\]
688 <<
689 NLA = 40;
690 zzreplstr("]"); zzmore();
691 >>
692
693 \\\)
694 <<
695 NLA = 41;
696 zzreplstr(")"); zzmore();
697 >>
698
699 \\>
700 <<
701 NLA = 42;
702 zzreplstr(">"); zzmore();
703 >>
704
705 '
706 <<
707 NLA = 43;
708 zzmode(ACTION_CHARS); zzmore();
709 >>
710
711 \"
712 <<
713 NLA = 44;
714 zzmode(ACTION_STRINGS); zzmore();
715 >>
716
717 \\#
718 <<
719 NLA = 45;
720 zzreplstr("#"); zzmore();
721 >>
722
723 \\~[\]\)>#]
724 <<
725 NLA = 46;
726 zzmore();
727 >>
728
729 /
730 <<
731 NLA = 47;
732 zzmore();
733 >>
734
735 /\*
736 <<
737 NLA = 48;
738 zzmode(ACTION_COMMENTS); zzmore();
739 >>
740
741 \*/
742 <<
743 NLA = 49;
744 err("Missing /*; found dangling */ in action"); zzmore();
745 >>
746
747 //
748 <<
749 NLA = 50;
750 zzmode(ACTION_CPP_COMMENTS); zzmore();
751 >>
752
753 \@\(
754 <<
755 NLA = 51;
756 zzmode(REFVAR_SCARF); zzmore(); zzreplstr("");
757 >>
758
759 \@
760 <<
761 NLA = 52;
762
763 zzmore(); if ( !GenCPP ) zzreplstr("_parser->");
764 >>
765
766 [a-zA-Z_]+\(
767 <<
768 NLA = 53;
769
770 if ( (GenCPP && strcmp(zzbegexpr,"ast_scan(")==0) ||
771 (!GenCPP && strcmp(zzbegexpr,"ast_scan(")==0) ) {
772 char *args=scarf_to_end_of_func_call();
773 zzreplstr(cvt_token_str(zzbegexpr, args));
774 zzmore();
775 }
776 else { pushint(')'); zzmore(); }
777 >>
778
779 [a-zA-Z_]+
780 <<
781 NLA = 54;
782 zzmore();
783 >>
784
785 ~[a-zA-Z_\n\r\)\(\\#\>\]\[\"'/\@]+
786 <<
787 NLA = 55;
788 zzmore();
789 >>
790
791
792 %%TOK_DEF_COMMENTS
793
794 @
795 <<
796 NLA = Eof;
797 >>
798
799 \*/
800 <<
801 NLA = 93;
802 zzmode(PARSE_ENUM_FILE); zzmore();
803 >>
804
805 \*
806 <<
807 NLA = 94;
808 zzmore();
809 >>
810
811 \n|\r|\r\n
812 <<
813 NLA = 95;
814 zzline++; zzmore();
815 >>
816
817 ~[\n\r\*]+
818 <<
819 NLA = 96;
820 zzmore();
821 >>
822
823
824 %%TOK_DEF_CPP_COMMENTS
825
826 @
827 <<
828 NLA = Eof;
829 >>
830
831 \n|\r|\r\n
832 <<
833 NLA = 97;
834 zzline++; zzmode(PARSE_ENUM_FILE); zzskip();
835 >>
836
837 ~[\n\r]+
838 <<
839 NLA = 98;
840 zzskip();
841 >>
842
843
844 %%PARSE_ENUM_FILE
845
846 @
847 <<
848 NLA = Eof;
849 /*zzmode(START); zzskip();*/
850 >>
851
852 [\t\ ]+
853 <<
854 NLA = 99;
855 zzskip();
856 >>
857
858 \n|\r|\r\n
859 <<
860 NLA = 100;
861 zzline++; zzskip();
862 >>
863
864 //
865 <<
866 NLA = 101;
867 zzmode(TOK_DEF_CPP_COMMENTS); zzmore();
868 >>
869
870 /\*
871 <<
872 NLA = 102;
873 zzmode(TOK_DEF_COMMENTS); zzmore();
874 >>
875
876 #ifndef
877 <<
878 NLA = 103;
879
880 >>
881
882 #ifdef
883 <<
884 NLA = 104;
885 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
886 >>
887
888 #else
889 <<
890 NLA = 105;
891 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
892 >>
893
894 #define
895 <<
896 NLA = 106;
897
898 >>
899
900 #endif
901 <<
902 NLA = 107;
903 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
904 >>
905
906 enum
907 <<
908 NLA = 110;
909 >>
910
911 \{
912 <<
913 NLA = 111;
914 >>
915
916 =
917 <<
918 NLA = 112;
919 >>
920
921 ,
922 <<
923 NLA = 113;
924 >>
925
926 DLGminToken
927 <<
928 NLA = 114;
929 >>
930
931 DLGmaxToken
932 <<
933 NLA = 115;
934 >>
935
936 \}
937 <<
938 NLA = 116;
939 >>
940
941 ;
942 <<
943 NLA = 117;
944 >>
945
946 [0-9]+
947 <<
948 NLA = INT;
949 >>
950
951 [a-zA-Z_][_a-zA-Z0-9]*
952 <<
953 NLA = ID;
954 >>
955
956 %%
+0
-222
contrib/pccts/sorcerer/proto.h less more
0 /*
1 * proto.h
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-2001
27 */
28
29 /* G l o b a l s */
30
31 extern char *VersionNumber;
32 extern char *VersionText;
33 extern char *FileStr[];
34 extern int NumFiles;
35 extern int action_file;
36 extern int action_line;
37 extern int CurFile;
38 extern char *CurRule;
39 extern char *CurRetDef;
40 extern char *CurParmDef;
41 extern FILE *output;
42 extern FILE *input;
43 extern Entry **symbols;
44 extern int token_table_size;
45 extern char **token_dict;
46 extern int token_type;
47 extern int end_of_input;
48 extern int epsilon;
49 extern int last_valid_token;
50 extern char *OutputDirectory;
51 extern ListNode *before_actions, *after_actions, *class_actions;
52 extern char translator[];
53 extern char tokdefs_file[];
54 extern char *header_action;
55 extern struct _ast *rules;
56 extern int print_guts;
57 extern int transform;
58 extern int found_guess_block;
59 extern ListNode *token_list;
60 extern char *def_token_file;
61 extern int def_tokens;
62 extern int found_error;
63 extern set referenced_tokens;
64 extern int wild_card;
65 extern int UserDefdTokens;
66 extern int Inline;
67 extern char *Prefix;
68 extern int GenAnsiProtos;
69 extern int GenKRProtos;
70 extern FILE *ProtoFILE;
71 extern char *GenProtoFile;
72 extern ListNode *RefVars;
73 extern ListNode *AllRefVars;
74 extern ListNode *AllGlobVars;
75 extern char CurRefVarType[];
76 extern char CurRefVarLabel[];
77 extern char CurClassName[];
78 extern int GenCPP;
79 extern int NoCtor; /* MR23 */
80
81 #ifdef __VMS
82 #define STRICMP strcasecmp
83 #else
84 #define STRICMP stricmp
85 #endif
86 /* F u n c t i o n s */
87
88 #ifdef __USE_PROTOS
89 extern int main( int, char *[] );
90 extern int STRICMP(const char *, const char *); /* MR20 */
91 extern void help( void );
92 extern FILE * NextFile( void );
93 extern void pushint( int );
94 extern int popint( void );
95 extern int istacksize( void );
96 extern void istackreset( void );
97 extern int istackempty( void );
98 extern int topint( void );
99 extern char * eMsg3( char *, char *, char *, char * );
100 extern char * eMsgd( char *, int );
101 extern void fatalFL( char *, char *, int );
102 extern void list_add( ListNode **, void * );
103 extern Entry * newEntry( char *, int );
104 extern void token_association( int, char * );
105 extern char * outname( char * );
106 extern char * OutMetaName( char * );
107 extern void set_fprint( FILE *, set );
108 extern void gen_info_hdr( FILE * );
109 extern void gen_hdr( void );
110 extern void gen_hdr1( void );
111 extern void gen( AST * );
112 extern void gen_header( AST * );
113 extern void gen_rule( AST * );
114 extern void gen_block( AST *, int );
115 extern void gen_alt( AST * );
116 extern void gen_tree_pattern( AST * );
117 extern void gen_element( AST * );
118 extern void define_labels_in_block( AST * );
119 extern void define_labels_in_alt( AST * );
120 extern void define_labels_in_tree( AST * );
121 extern void define_labels_in_element( AST * );
122 extern void dumpAction( char *, FILE *, int, int, int, int );
123 extern char * find_predicate( AST * );
124 extern set gen_prediction_expr( AST *, GLA * );
125 extern void GenRulePrototypes( FILE *, int );
126 extern void gen_tokens_file( void );
127 extern void code_for_guess_block( AST *, int * );
128 extern set Lookahead( GLA * );
129 extern void build_GLA( AST * );
130 extern GLA * build_GLA_for_block( AST *, GLA ** );
131 extern GLA * build_GLA_for_ALT( AST *, GLA ** );
132 extern GLA * build_GLA_for_tree( AST *, GLA ** );
133 extern GLA * build_GLA_for_element( AST *, GLA ** );
134 extern void build_follow_links( GLA *, ListNode * );
135 extern void dump_GLAs( AST * );
136 extern void dump_GLA( GLA * );
137 extern void test_block_consistency( AST *, int );
138 extern void GenRulePrototype(FILE *f, AST *p, SymEntry *s, int decl_not_def);
139 extern void DumpOldStyleParms( char *pdecl, FILE *output );
140 extern int DumpNextNameInDef( char **q, FILE *output );
141 extern void DumpListOfParmNames( char *pdecl, FILE *output );
142 extern SymEntry *define_token(char *text);
143 extern char *actiondup(char *s);
144 extern AST *read_sor_desc(FILE *f);
145 extern void DumpType( char *s, FILE *f, char *file, int line );
146 extern AST *first_guess_block(AST *q);
147 extern RefVarRec *refVarRec(char *);
148 extern char *cvt_token_str(char *, char *);
149 extern char *id_in_decl( char *decl );
150 extern void dump_prefixed_decl( char *prefix, char *s, FILE *f );
151 extern void ensure_no_C_file_collisions(char *class_c_file);
152 extern void GenCPPClassHeader(void);
153 extern void GenCPPClassCode(void);
154 #else
155 extern int main( );
156 extern int STRICMP(); /* MR20 */
157 extern void help( );
158 extern FILE * NextFile( );
159 extern void pushint( );
160 extern int popint( );
161 extern int istacksize( );
162 extern void istackreset( );
163 extern int istackempty( );
164 extern int topint( );
165 extern char * eMsg3( );
166 extern char * eMsgd( );
167 extern void fatalFL( );
168 extern void list_add( );
169 extern Entry * newEntry( );
170 extern void token_association( );
171 extern char * outname( );
172 extern char * OutMetaName( );
173 extern void set_fprint( );
174 extern void gen_info_hdr( );
175 extern void gen_hdr( );
176 extern void gen_hdr1( );
177 extern void gen( );
178 extern void gen_header( );
179 extern void gen_rule( );
180 extern void gen_block( );
181 extern void gen_alt( );
182 extern void gen_tree_pattern( );
183 extern void gen_element( );
184 extern void define_labels_in_block( );
185 extern void define_labels_in_alt( );
186 extern void define_labels_in_tree( );
187 extern void define_labels_in_element( );
188 extern void dumpAction( );
189 extern char * find_predicate( );
190 extern set gen_prediction_expr( );
191 extern void GenRulePrototypes( );
192 extern void gen_tokens_file( );
193 extern void code_for_guess_block( );
194 extern set Lookahead( );
195 extern void build_GLA( );
196 extern GLA * build_GLA_for_block( );
197 extern GLA * build_GLA_for_ALT( );
198 extern GLA * build_GLA_for_tree( );
199 extern GLA * build_GLA_for_element( );
200 extern void build_follow_links( );
201 extern void dump_GLAs( );
202 extern void dump_GLA( );
203 extern void test_block_consistency( );
204 extern void GenRulePrototype();
205 extern void GenRulePrototype();
206 extern void DumpOldStyleParms();
207 extern int DumpNextNameInDef();
208 extern void DumpListOfParmNames();
209 extern SymEntry *define_token();
210 extern char *actiondup();
211 extern AST *read_sor_desc();
212 extern void DumpType();
213 extern AST *first_guess_block();
214 extern RefVarRec *refVarRec();
215 extern char *cvt_token_str();
216 extern char *id_in_decl();
217 extern void dump_prefixed_decl();
218 extern void ensure_no_C_file_collisions();
219 extern void GenCPPClassHeader();
220 extern void GenCPPClassCode();
221 #endif
+0
-3141
contrib/pccts/sorcerer/scan.c less more
0
1 /* parser.dlg -- DLG Description of scanner
2 *
3 * Generated from: sor.g
4 *
5 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
6 * Purdue University Electrical Engineering
7 * With AHPCRC, University of Minnesota
8 * ANTLR Version 1.33MR33
9 */
10
11 #define ANTLR_VERSION 13333
12 #include "pcctscfg.h"
13 #include "pccts_stdio.h"
14
15 /* 23-Sep-97 thm Accomodate user who needs to redefine ZZLEXBUFSIZE */
16
17 #ifndef ZZLEXBUFSIZE
18 #define ZZLEXBUFSIZE 8000
19 #endif
20 #include "pcctscfg.h" /* MR20 G. Hobbelt __USE_PROTOS #define */
21 #include "charbuf.h"
22 #include "hash.h"
23 #include "set.h"
24 #include "sor.h"
25 #define AST_FIELDS \
26 int token; char text[MaxAtom+1], label[MaxRuleName+1]; \
27 char *action; /* if action node, here is ptr to it */ \
28 char in,out; \
29 char init_action; /* set if Action and 1st action of alt */ \
30 int file; int line; /* set for BLOCK, ALT, nonterm nodes */ \
31 int upper_range; /* only if T1..T2 found */ \
32 GLA *start_state; /* ptr into GLA for this block */ \
33 int no_copy; /* copy input ptr to output ptr? */ \
34 ListNode *refvars; /* any ref vars defined for this rule */ \
35 unsigned char is_root; /* this token is a root #( A ... ) */
36 #define zzcr_ast(node, cur, _tok, _text) \
37 {(node)->token=_tok; strncpy((node)->text, _text,MaxAtom);}
38 #define USER_ZZSYN
39 #define zzAST_DOUBLE
40 extern int define_num;
41 #define LL_K 2
42 #include "antlr.h"
43 #include "ast.h"
44 #include "tokens.h"
45 #include "dlgdef.h"
46 LOOKAHEAD
47
48 void
49 #ifdef __USE_PROTOS
50 zzerraction(void)
51 #else
52 zzerraction()
53 #endif
54 {
55 (*zzerr)("invalid token");
56 zzadvance();
57 zzskip();
58 }
59 /*
60 * D L G tables
61 *
62 * Generated from: parser.dlg
63 *
64 * 1989-2001 by Will Cohen, Terence Parr, and Hank Dietz
65 * Purdue University Electrical Engineering
66 * DLG Version 1.33MR33
67 */
68
69 #include "mode.h"
70
71
72
73
74 #include "sym.h"
75 #include "proto.h"
76
77 int define_num = 0;
78
79 char *
80 #ifdef __USE_PROTOS
81 scarf_to_end_of_func_call(void)
82 #else
83 scarf_to_end_of_func_call()
84 #endif
85 {
86 static char func_call_str[MaxAtom+1];
87 char *p;
88
89 p = &func_call_str[0];
90
91 more:
92 if ( zzchar==')' ) { *p++ = zzchar; *p++ = '\0'; zzadvance(); return func_call_str; }
93 if ( zzchar=='"' )
94 {
95 *p++ = zzchar; zzadvance();
96 while ( zzchar!='"' )
97 {
98 if ( zzchar=='\\' ) { *p++ = zzchar; zzadvance(); }
99 *p++ = zzchar; zzadvance();
100 }
101 }
102 *p++ = zzchar; zzadvance();
103 goto more;
104 }
105
106 static void act1()
107 {
108 NLA = Eof;
109 /* L o o k F o r A n o t h e r F i l e */
110 {
111 FILE *new_input;
112 new_input = NextFile();
113 if ( new_input != NULL ) {
114 fclose( input );
115 input = new_input;
116 zzrdstream( input );
117 /*zzadvance(); ** Get 1st char of this file */
118 zzskip(); /* Skip the Eof (@) char i.e continue */
119 }
120 }
121 }
122
123
124 static void act2()
125 {
126 NLA = 56;
127 zzskip();
128 }
129
130
131 static void act3()
132 {
133 NLA = 57;
134 zzline++; zzskip();
135 }
136
137
138 static void act4()
139 {
140 NLA = 58;
141 zzmode(ACTIONS); zzmore();
142 istackreset();
143 pushint(']');
144 }
145
146
147 static void act5()
148 {
149 NLA = 59;
150 action_file=CurFile; action_line=zzline;
151 zzmode(ACTIONS); zzmore();
152 istackreset();
153 pushint('>');
154 }
155
156
157 static void act6()
158 {
159 NLA = 60;
160 zzmode(STRINGS); zzmore();
161 }
162
163
164 static void act7()
165 {
166 NLA = 61;
167 zzmode(COMMENTS); zzskip();
168 }
169
170
171 static void act8()
172 {
173 NLA = 62;
174 err("Missing /*; found dangling */"); zzskip();
175 }
176
177
178 static void act9()
179 {
180 NLA = 63;
181 zzmode(CPP_COMMENTS); zzskip();
182 }
183
184
185 static void act10()
186 {
187 NLA = 64;
188 err("Missing <<; found dangling >>"); zzskip();
189 }
190
191
192 static void act11()
193 {
194 NLA = Header;
195 }
196
197
198 static void act12()
199 {
200 NLA = Tokdef;
201 }
202
203
204 static void act13()
205 {
206 NLA = LABEL;
207 }
208
209
210 static void act14()
211 {
212 NLA = OPT;
213 }
214
215
216 static void act15()
217 {
218 NLA = POS_CLOSURE;
219 }
220
221
222 static void act16()
223 {
224 NLA = CLOSURE;
225 }
226
227
228 static void act17()
229 {
230 NLA = WILD;
231 }
232
233
234 static void act18()
235 {
236 NLA = PRED_OP;
237 }
238
239
240 static void act19()
241 {
242 NLA = BT;
243 }
244
245
246 static void act20()
247 {
248 NLA = 80;
249 }
250
251
252 static void act21()
253 {
254 NLA = 81;
255 }
256
257
258 static void act22()
259 {
260 NLA = 84;
261 }
262
263
264 static void act23()
265 {
266 NLA = 85;
267 }
268
269
270 static void act24()
271 {
272 NLA = 86;
273 }
274
275
276 static void act25()
277 {
278 NLA = 87;
279 }
280
281
282 static void act26()
283 {
284 NLA = 88;
285 }
286
287
288 static void act27()
289 {
290 NLA = 89;
291 }
292
293
294 static void act28()
295 {
296 NLA = 90;
297 }
298
299
300 static void act29()
301 {
302 NLA = 91;
303 }
304
305
306 static void act30()
307 {
308 NLA = NonTerm;
309 }
310
311
312 static void act31()
313 {
314 NLA = Token;
315 }
316
317
318 static void act32()
319 {
320 NLA = 92;
321 warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip();
322 }
323
324 static unsigned char shift0[257] = {
325 0, 37, 37, 37, 37, 37, 37, 37, 37, 37,
326 1, 2, 37, 37, 3, 37, 37, 37, 37, 37,
327 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
328 37, 37, 37, 1, 30, 6, 10, 37, 37, 37,
329 37, 26, 33, 8, 23, 37, 37, 24, 7, 36,
330 36, 36, 36, 36, 36, 36, 36, 36, 36, 21,
331 31, 5, 37, 9, 25, 37, 35, 35, 35, 35,
332 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
333 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
334 35, 35, 4, 37, 37, 37, 36, 37, 13, 34,
335 28, 14, 12, 19, 34, 11, 34, 34, 18, 29,
336 34, 34, 17, 34, 34, 15, 20, 16, 34, 34,
337 34, 34, 34, 34, 22, 32, 27, 37, 37, 37,
338 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
339 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
340 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
341 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
342 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
343 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
344 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
345 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
346 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
347 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
348 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
349 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
350 37, 37, 37, 37, 37, 37, 37
351 };
352
353
354 static void act33()
355 {
356 NLA = Eof;
357 }
358
359
360 static void act34()
361 {
362 NLA = RExpr;
363 zzmode(START);
364 }
365
366
367 static void act35()
368 {
369 NLA = 3;
370 /* MR16a */
371 zzline++;
372 warn("eoln found in string");
373 zzskip();
374 }
375
376
377 static void act36()
378 {
379 NLA = 4;
380 zzmore();
381 }
382
383
384 static void act37()
385 {
386 NLA = 5;
387 zzmore();
388 }
389
390 static unsigned char shift1[257] = {
391 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
392 5, 2, 5, 5, 3, 5, 5, 5, 5, 5,
393 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
394 5, 5, 5, 5, 5, 1, 5, 5, 5, 5,
395 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
396 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
397 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
398 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
399 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
400 5, 5, 5, 4, 5, 5, 5, 5, 5, 5,
401 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
402 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
403 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
404 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
405 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
406 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
407 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
408 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
409 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
410 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
411 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
412 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
413 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
414 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
415 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
416 5, 5, 5, 5, 5, 5, 5
417 };
418
419
420 static void act38()
421 {
422 NLA = Eof;
423 }
424
425
426 static void act39()
427 {
428 NLA = 6;
429 zzmode(ACTIONS); zzmore();
430 }
431
432
433 static void act40()
434 {
435 NLA = 7;
436 /* MR16a */
437 zzline++;
438 warn("eoln found in string (in user action)");
439 zzskip();
440 }
441
442
443 static void act41()
444 {
445 NLA = 8;
446 zzmore();
447 }
448
449
450 static void act42()
451 {
452 NLA = 9;
453 zzmore();
454 }
455
456 static unsigned char shift2[257] = {
457 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
458 5, 2, 5, 5, 3, 5, 5, 5, 5, 5,
459 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
460 5, 5, 5, 5, 5, 1, 5, 5, 5, 5,
461 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
462 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
463 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
464 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
465 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
466 5, 5, 5, 4, 5, 5, 5, 5, 5, 5,
467 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
468 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
469 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
470 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
471 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
472 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
473 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
474 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
475 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
476 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
477 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
478 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
479 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
480 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
481 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
482 5, 5, 5, 5, 5, 5, 5
483 };
484
485
486 static void act43()
487 {
488 NLA = Eof;
489 }
490
491
492 static void act44()
493 {
494 NLA = 10;
495 zzmode(ACTIONS); zzmore();
496 }
497
498
499 static void act45()
500 {
501 NLA = 11;
502 /* MR16a */
503 zzline++;
504 warn("eoln found in char literal (in user action)");
505 zzskip();
506 }
507
508
509 static void act46()
510 {
511 NLA = 12;
512 zzmore();
513 }
514
515
516 static void act47()
517 {
518 NLA = 13;
519 zzmore();
520 }
521
522 static unsigned char shift3[257] = {
523 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
524 5, 2, 5, 5, 3, 5, 5, 5, 5, 5,
525 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
526 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
527 1, 5, 5, 5, 5, 5, 5, 5, 5, 5,
528 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
529 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
530 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
531 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
532 5, 5, 5, 4, 5, 5, 5, 5, 5, 5,
533 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
534 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
535 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
536 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
537 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
538 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
539 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
540 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
541 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
542 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
543 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
544 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
545 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
546 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
547 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
548 5, 5, 5, 5, 5, 5, 5
549 };
550
551
552 static void act48()
553 {
554 NLA = Eof;
555 }
556
557
558 static void act49()
559 {
560 NLA = 14;
561 zzmode(ACTIONS); zzmore();
562 }
563
564
565 static void act50()
566 {
567 NLA = 15;
568 zzmore();
569 }
570
571
572 static void act51()
573 {
574 NLA = 16;
575 zzline++; zzmore();
576 }
577
578
579 static void act52()
580 {
581 NLA = 17;
582 zzmore();
583 }
584
585 static unsigned char shift4[257] = {
586 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
587 5, 3, 5, 5, 4, 5, 5, 5, 5, 5,
588 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
589 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
590 5, 5, 5, 1, 5, 5, 5, 5, 2, 5,
591 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
592 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
593 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
594 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
595 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
596 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
597 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
598 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
599 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
600 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
601 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
602 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
603 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
604 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
605 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
606 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
607 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
608 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
609 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
610 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
611 5, 5, 5, 5, 5, 5, 5
612 };
613
614
615 static void act53()
616 {
617 NLA = Eof;
618 }
619
620
621 static void act54()
622 {
623 NLA = 18;
624 zzline++; zzmode(ACTIONS); zzmore();
625 }
626
627
628 static void act55()
629 {
630 NLA = 19;
631 zzmore();
632 }
633
634 static unsigned char shift5[257] = {
635 0, 3, 3, 3, 3, 3, 3, 3, 3, 3,
636 3, 1, 3, 3, 2, 3, 3, 3, 3, 3,
637 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
638 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
639 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
640 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
641 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
642 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
643 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
644 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
645 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
646 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
647 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
648 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
649 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
650 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
651 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
652 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
653 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
654 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
655 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
656 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
657 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
658 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
659 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
660 3, 3, 3, 3, 3, 3, 3
661 };
662
663
664 static void act56()
665 {
666 NLA = Eof;
667 }
668
669
670 static void act57()
671 {
672 NLA = 20;
673 zzline++; zzmode(START); zzskip();
674 }
675
676
677 static void act58()
678 {
679 NLA = 21;
680 zzskip();
681 }
682
683 static unsigned char shift6[257] = {
684 0, 3, 3, 3, 3, 3, 3, 3, 3, 3,
685 3, 1, 3, 3, 2, 3, 3, 3, 3, 3,
686 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
687 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
688 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
689 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
690 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
691 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
692 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
693 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
694 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
695 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
696 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
697 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
698 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
699 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
700 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
701 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
702 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
703 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
704 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
705 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
706 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
707 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
708 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
709 3, 3, 3, 3, 3, 3, 3
710 };
711
712
713 static void act59()
714 {
715 NLA = Eof;
716 }
717
718
719 static void act60()
720 {
721 NLA = 22;
722 zzmode(START); zzskip();
723 }
724
725
726 static void act61()
727 {
728 NLA = 23;
729 zzskip();
730 }
731
732
733 static void act62()
734 {
735 NLA = 24;
736 zzline++; zzskip();
737 }
738
739
740 static void act63()
741 {
742 NLA = 25;
743 zzskip();
744 }
745
746 static unsigned char shift7[257] = {
747 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
748 5, 3, 5, 5, 4, 5, 5, 5, 5, 5,
749 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
750 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
751 5, 5, 5, 1, 5, 5, 5, 5, 2, 5,
752 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
753 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
754 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
755 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
756 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
757 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
758 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
759 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
760 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
761 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
762 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
763 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
764 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
765 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
766 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
767 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
768 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
769 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
770 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
771 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
772 5, 5, 5, 5, 5, 5, 5
773 };
774
775
776 static void act64()
777 {
778 NLA = Eof;
779 }
780
781
782 static void act65()
783 {
784 NLA = 26;
785 {
786 RefVarRec *rf;
787 zzskip();
788 zzbegexpr[strlen(zzbegexpr)-1] = '\0';
789 rf=refVarRec(zzbegexpr);
790 list_add(&AllRefVars, rf);
791 list_add(&RefVars, rf);
792 zzmode(ACTIONS); zzmore(); zzreplstr("");
793 }
794 }
795
796 static unsigned char shift8[257] = {
797 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
798 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
799 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
800 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
801 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
802 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
803 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
804 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
805 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
806 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
807 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
808 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
809 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
810 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
811 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
812 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
813 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
814 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
815 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
816 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
817 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
818 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
819 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
820 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
821 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
822 1, 1, 1, 1, 1, 1, 1
823 };
824
825
826 static void act66()
827 {
828 NLA = Eof;
829 }
830
831
832 static void act67()
833 {
834 NLA = Action;
835 /* these do not nest */
836 zzmode(START);
837 NLATEXT[0] = ' ';
838 NLATEXT[1] = ' ';
839 zzbegexpr[0] = ' ';
840 zzbegexpr[1] = ' ';
841 if ( zzbufovf ) {
842 found_error = 1;
843 err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));
844 }
845 }
846
847
848 static void act68()
849 {
850 NLA = PassAction;
851 if ( topint() == ']' ) {
852 popint();
853 if ( istackempty() ) /* terminate action */
854 {
855 zzmode(START);
856 NLATEXT[0] = ' ';
857 zzbegexpr[0] = ' ';
858 if ( zzbufovf ) {
859 found_error = 1;
860 err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));
861 }
862 }
863 else {
864 /* terminate #[..] */
865 zzreplstr(")");
866 zzmore();
867 }
868 }
869 else if ( topint() == '|' ) { /* end of simple [...] */
870 popint();
871 zzmore();
872 }
873 else zzmore();
874 }
875
876
877 static void act69()
878 {
879 NLA = 29;
880 zzline++; zzmore();
881 }
882
883
884 static void act70()
885 {
886 NLA = 30;
887 zzmore();
888 }
889
890
891 static void act71()
892 {
893 NLA = 31;
894
895 if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||
896 strcmp(zzbegexpr, "#else")==0 ||
897 strcmp(zzbegexpr, "#endif")==0 ||
898 strcmp(zzbegexpr, "#ifndef")==0 ||
899 strcmp(zzbegexpr, "#if")==0 ||
900 strcmp(zzbegexpr, "#define")==0 ||
901 strcmp(zzbegexpr, "#pragma")==0 ||
902 strcmp(zzbegexpr, "#undef")==0 ||
903 strcmp(zzbegexpr, "#import")==0 ||
904 strcmp(zzbegexpr, "#line")==0 ||
905 strcmp(zzbegexpr, "#include")==0 ||
906 strcmp(zzbegexpr, "#error")==0) )
907 {
908 static char buf[100];
909 if ( !transform ) {
910 warn("#id used in nontransform mode; # ignored");
911 sprintf(buf, "%s", zzbegexpr+1);
912 }
913 else {
914 if ( CurRule==NULL )
915 {warn("#id used in action outside of rule; ignored");}
916 else if ( strcmp(zzbegexpr+1,CurRule)==0 )
917 strcpy(buf, "(*_result)");
918 }
919 zzreplstr(buf);
920 }
921 zzmore();
922 }
923
924
925 static void act72()
926 {
927 NLA = 32;
928
929 if ( GenCPP ) zzreplstr("new SORAST");
930 else zzreplstr("ast_empty_node()");
931 zzmore();
932 }
933
934
935 static void act73()
936 {
937 NLA = 33;
938 zzreplstr("NULL"); zzmore();
939 }
940
941
942 static void act74()
943 {
944 NLA = 34;
945
946 pushint(']');
947 if ( GenCPP ) zzreplstr("new SORAST(");
948 else zzreplstr("ast_node(");
949 zzmore();
950 }
951
952
953 static void act75()
954 {
955 NLA = 35;
956
957 pushint('}');
958 if ( GenCPP ) zzreplstr("PCCTS_AST::make(");
959 else zzreplstr("ast_make(");
960 zzmore();
961 }
962
963
964 static void act76()
965 {
966 NLA = 36;
967 zzmore();
968 }
969
970
971 static void act77()
972 {
973 NLA = 37;
974
975 if ( istackempty() )
976 zzmore();
977 else if ( topint()==')' ) {
978 popint();
979 }
980 else if ( topint()=='}' ) {
981 popint();
982 /* terminate #(..) */
983 zzreplstr(", NULL)");
984 }
985 zzmore();
986 }
987
988
989 static void act78()
990 {
991 NLA = 38;
992
993 pushint('|'); /* look for '|' to terminate simple [...] */
994 zzmore();
995 }
996
997
998 static void act79()
999 {
1000 NLA = 39;
1001
1002 pushint(')');
1003 zzmore();
1004 }
1005
1006
1007 static void act80()
1008 {
1009 NLA = 40;
1010 zzreplstr("]"); zzmore();
1011 }
1012
1013
1014 static void act81()
1015 {
1016 NLA = 41;
1017 zzreplstr(")"); zzmore();
1018 }
1019
1020
1021 static void act82()
1022 {
1023 NLA = 42;
1024 zzreplstr(">"); zzmore();
1025 }
1026
1027
1028 static void act83()
1029 {
1030 NLA = 43;
1031 zzmode(ACTION_CHARS); zzmore();
1032 }
1033
1034
1035 static void act84()
1036 {
1037 NLA = 44;
1038 zzmode(ACTION_STRINGS); zzmore();
1039 }
1040
1041
1042 static void act85()
1043 {
1044 NLA = 45;
1045 zzreplstr("#"); zzmore();
1046 }
1047
1048
1049 static void act86()
1050 {
1051 NLA = 46;
1052 zzmore();
1053 }
1054
1055
1056 static void act87()
1057 {
1058 NLA = 47;
1059 zzmore();
1060 }
1061
1062
1063 static void act88()
1064 {
1065 NLA = 48;
1066 zzmode(ACTION_COMMENTS); zzmore();
1067 }
1068
1069
1070 static void act89()
1071 {
1072 NLA = 49;
1073 err("Missing /*; found dangling */ in action"); zzmore();
1074 }
1075
1076
1077 static void act90()
1078 {
1079 NLA = 50;
1080 zzmode(ACTION_CPP_COMMENTS); zzmore();
1081 }
1082
1083
1084 static void act91()
1085 {
1086 NLA = 51;
1087 zzmode(REFVAR_SCARF); zzmore(); zzreplstr("");
1088 }
1089
1090
1091 static void act92()
1092 {
1093 NLA = 52;
1094
1095 zzmore(); if ( !GenCPP ) zzreplstr("_parser->");
1096 }
1097
1098
1099 static void act93()
1100 {
1101 NLA = 53;
1102
1103 if ( (GenCPP && strcmp(zzbegexpr,"ast_scan(")==0) ||
1104 (!GenCPP && strcmp(zzbegexpr,"ast_scan(")==0) ) {
1105 char *args=scarf_to_end_of_func_call();
1106 zzreplstr(cvt_token_str(zzbegexpr, args));
1107 zzmore();
1108 }
1109 else { pushint(')'); zzmore(); }
1110 }
1111
1112
1113 static void act94()
1114 {
1115 NLA = 54;
1116 zzmore();
1117 }
1118
1119
1120 static void act95()
1121 {
1122 NLA = 55;
1123 zzmore();
1124 }
1125
1126 static unsigned char shift9[257] = {
1127 0, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1128 17, 3, 17, 17, 4, 17, 17, 17, 17, 17,
1129 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1130 17, 17, 17, 17, 17, 13, 5, 17, 17, 17,
1131 12, 9, 10, 15, 17, 17, 17, 17, 14, 7,
1132 7, 7, 7, 7, 7, 7, 7, 7, 7, 17,
1133 17, 17, 17, 1, 17, 16, 6, 6, 6, 6,
1134 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
1135 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
1136 6, 6, 8, 11, 2, 17, 6, 17, 6, 6,
1137 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
1138 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
1139 6, 6, 6, 6, 17, 17, 17, 17, 17, 17,
1140 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1141 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1142 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1143 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1144 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1145 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1146 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1147 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1148 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1149 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1150 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1151 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1152 17, 17, 17, 17, 17, 17, 17
1153 };
1154
1155
1156 static void act96()
1157 {
1158 NLA = Eof;
1159 }
1160
1161
1162 static void act97()
1163 {
1164 NLA = 93;
1165 zzmode(PARSE_ENUM_FILE); zzmore();
1166 }
1167
1168
1169 static void act98()
1170 {
1171 NLA = 94;
1172 zzmore();
1173 }
1174
1175
1176 static void act99()
1177 {
1178 NLA = 95;
1179 zzline++; zzmore();
1180 }
1181
1182
1183 static void act100()
1184 {
1185 NLA = 96;
1186 zzmore();
1187 }
1188
1189 static unsigned char shift10[257] = {
1190 0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1191 5, 3, 5, 5, 4, 5, 5, 5, 5, 5,
1192 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1193 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1194 5, 5, 5, 1, 5, 5, 5, 5, 2, 5,
1195 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1196 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1197 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1198 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1199 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1200 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1201 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1202 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1203 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1204 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1205 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1206 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1207 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1208 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1209 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1210 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1211 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1212 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1213 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1214 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1215 5, 5, 5, 5, 5, 5, 5
1216 };
1217
1218
1219 static void act101()
1220 {
1221 NLA = Eof;
1222 }
1223
1224
1225 static void act102()
1226 {
1227 NLA = 97;
1228 zzline++; zzmode(PARSE_ENUM_FILE); zzskip();
1229 }
1230
1231
1232 static void act103()
1233 {
1234 NLA = 98;
1235 zzskip();
1236 }
1237
1238 static unsigned char shift11[257] = {
1239 0, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1240 3, 1, 3, 3, 2, 3, 3, 3, 3, 3,
1241 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1242 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1243 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1244 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1245 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1246 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1247 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1248 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1249 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1250 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1251 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1252 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1253 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1254 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1255 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1256 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1257 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1258 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1259 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1260 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1261 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1262 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1263 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1264 3, 3, 3, 3, 3, 3, 3
1265 };
1266
1267
1268 static void act104()
1269 {
1270 NLA = Eof;
1271 /*zzmode(START); zzskip();*/
1272 }
1273
1274
1275 static void act105()
1276 {
1277 NLA = 99;
1278 zzskip();
1279 }
1280
1281
1282 static void act106()
1283 {
1284 NLA = 100;
1285 zzline++; zzskip();
1286 }
1287
1288
1289 static void act107()
1290 {
1291 NLA = 101;
1292 zzmode(TOK_DEF_CPP_COMMENTS); zzmore();
1293 }
1294
1295
1296 static void act108()
1297 {
1298 NLA = 102;
1299 zzmode(TOK_DEF_COMMENTS); zzmore();
1300 }
1301
1302
1303 static void act109()
1304 {
1305 NLA = 103;
1306
1307 }
1308
1309
1310 static void act110()
1311 {
1312 NLA = 104;
1313 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1314 }
1315
1316
1317 static void act111()
1318 {
1319 NLA = 105;
1320 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1321 }
1322
1323
1324 static void act112()
1325 {
1326 NLA = 106;
1327
1328 }
1329
1330
1331 static void act113()
1332 {
1333 NLA = 107;
1334 zzmode(TOK_DEF_CPP_COMMENTS); zzskip();
1335 }
1336
1337
1338 static void act114()
1339 {
1340 NLA = 110;
1341 }
1342
1343
1344 static void act115()
1345 {
1346 NLA = 111;
1347 }
1348
1349
1350 static void act116()
1351 {
1352 NLA = 112;
1353 }
1354
1355
1356 static void act117()
1357 {
1358 NLA = 113;
1359 }
1360
1361
1362 static void act118()
1363 {
1364 NLA = 114;
1365 }
1366
1367
1368 static void act119()
1369 {
1370 NLA = 115;
1371 }
1372
1373
1374 static void act120()
1375 {
1376 NLA = 116;
1377 }
1378
1379
1380 static void act121()
1381 {
1382 NLA = 117;
1383 }
1384
1385
1386 static void act122()
1387 {
1388 NLA = INT;
1389 }
1390
1391
1392 static void act123()
1393 {
1394 NLA = ID;
1395 }
1396
1397 static unsigned char shift12[257] = {
1398 0, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1399 1, 2, 31, 31, 3, 31, 31, 31, 31, 31,
1400 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1401 31, 31, 31, 1, 31, 31, 6, 31, 31, 31,
1402 31, 31, 31, 5, 31, 18, 31, 31, 4, 29,
1403 29, 29, 29, 29, 29, 29, 29, 29, 29, 31,
1404 28, 31, 17, 31, 31, 31, 30, 30, 30, 19,
1405 30, 30, 21, 30, 30, 30, 30, 20, 30, 30,
1406 30, 30, 30, 30, 30, 22, 30, 30, 30, 30,
1407 30, 30, 31, 31, 31, 31, 30, 31, 25, 30,
1408 30, 10, 11, 8, 30, 30, 7, 30, 24, 12,
1409 15, 9, 23, 30, 30, 30, 13, 30, 14, 30,
1410 30, 26, 30, 30, 16, 31, 27, 31, 31, 31,
1411 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1412 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1413 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1414 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1415 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1416 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1417 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1418 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1419 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1420 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1421 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1422 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1423 31, 31, 31, 31, 31, 31, 31
1424 };
1425
1426 #define DfaStates 226
1427 typedef unsigned short DfaState;
1428
1429 static DfaState st0[38] = {
1430 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1431 11, 12, 12, 12, 12, 12, 12, 12, 12, 12,
1432 12, 13, 14, 15, 16, 17, 18, 19, 20, 12,
1433 21, 22, 23, 24, 12, 25, 226, 226
1434 };
1435
1436 static DfaState st1[38] = {
1437 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1438 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1439 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1440 226, 226, 226, 226, 226, 226, 226, 226
1441 };
1442
1443 static DfaState st2[38] = {
1444 226, 2, 226, 226, 226, 226, 226, 226, 226, 226,
1445 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1446 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1447 226, 226, 226, 226, 226, 226, 226, 226
1448 };
1449
1450 static DfaState st3[38] = {
1451 226, 226, 226, 26, 226, 226, 226, 226, 226, 226,
1452 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1453 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1454 226, 226, 226, 226, 226, 226, 226, 226
1455 };
1456
1457 static DfaState st4[38] = {
1458 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1459 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1460 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1461 226, 226, 226, 226, 226, 226, 226, 226
1462 };
1463
1464 static DfaState st5[38] = {
1465 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1466 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1467 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1468 226, 226, 226, 226, 226, 226, 226, 226
1469 };
1470
1471 static DfaState st6[38] = {
1472 226, 226, 226, 226, 226, 27, 226, 226, 226, 226,
1473 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1474 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1475 226, 226, 226, 226, 226, 226, 226, 226
1476 };
1477
1478 static DfaState st7[38] = {
1479 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1480 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1481 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1482 226, 226, 226, 226, 226, 226, 226, 226
1483 };
1484
1485 static DfaState st8[38] = {
1486 226, 226, 226, 226, 226, 226, 226, 28, 29, 226,
1487 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1488 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1489 226, 226, 226, 226, 226, 226, 226, 226
1490 };
1491
1492 static DfaState st9[38] = {
1493 226, 226, 226, 226, 226, 226, 226, 30, 226, 226,
1494 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1495 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1496 226, 226, 226, 226, 226, 226, 226, 226
1497 };
1498
1499 static DfaState st10[38] = {
1500 226, 226, 226, 226, 226, 226, 226, 226, 226, 31,
1501 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1502 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1503 226, 226, 226, 226, 226, 226, 226, 226
1504 };
1505
1506 static DfaState st11[38] = {
1507 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1508 226, 32, 33, 33, 33, 33, 34, 33, 33, 33,
1509 33, 226, 226, 226, 226, 226, 35, 226, 33, 33,
1510 226, 226, 226, 226, 33, 33, 33, 226
1511 };
1512
1513 static DfaState st12[38] = {
1514 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1515 226, 36, 36, 36, 36, 36, 36, 36, 36, 36,
1516 36, 226, 226, 226, 226, 226, 226, 226, 36, 36,
1517 226, 226, 226, 226, 36, 36, 36, 226
1518 };
1519
1520 static DfaState st13[38] = {
1521 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1522 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1523 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1524 226, 226, 226, 226, 226, 226, 226, 226
1525 };
1526
1527 static DfaState st14[38] = {
1528 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1529 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1530 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1531 226, 226, 226, 226, 226, 226, 226, 226
1532 };
1533
1534 static DfaState st15[38] = {
1535 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1536 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1537 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1538 226, 226, 226, 226, 226, 226, 226, 226
1539 };
1540
1541 static DfaState st16[38] = {
1542 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1543 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1544 226, 226, 226, 226, 37, 226, 226, 226, 226, 226,
1545 226, 226, 226, 226, 226, 226, 226, 226
1546 };
1547
1548 static DfaState st17[38] = {
1549 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1550 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1551 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1552 226, 226, 226, 226, 226, 226, 226, 226
1553 };
1554
1555 static DfaState st18[38] = {
1556 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1557 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1558 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1559 226, 226, 226, 226, 226, 226, 226, 226
1560 };
1561
1562 static DfaState st19[38] = {
1563 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1564 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1565 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1566 226, 226, 226, 226, 226, 226, 226, 226
1567 };
1568
1569 static DfaState st20[38] = {
1570 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1571 226, 36, 36, 36, 36, 36, 36, 36, 36, 36,
1572 36, 226, 226, 226, 226, 226, 226, 226, 36, 38,
1573 226, 226, 226, 226, 36, 36, 36, 226
1574 };
1575
1576 static DfaState st21[38] = {
1577 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1578 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1579 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1580 226, 226, 226, 226, 226, 226, 226, 226
1581 };
1582
1583 static DfaState st22[38] = {
1584 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1585 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1586 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1587 226, 226, 226, 226, 226, 226, 226, 226
1588 };
1589
1590 static DfaState st23[38] = {
1591 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1592 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1593 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1594 226, 226, 226, 226, 226, 226, 226, 226
1595 };
1596
1597 static DfaState st24[38] = {
1598 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1599 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1600 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1601 226, 226, 226, 226, 226, 226, 226, 226
1602 };
1603
1604 static DfaState st25[38] = {
1605 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1606 226, 39, 39, 39, 39, 39, 39, 39, 39, 39,
1607 39, 226, 226, 226, 226, 226, 226, 226, 39, 39,
1608 226, 226, 226, 226, 39, 39, 39, 226
1609 };
1610
1611 static DfaState st26[38] = {
1612 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1613 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1614 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1615 226, 226, 226, 226, 226, 226, 226, 226
1616 };
1617
1618 static DfaState st27[38] = {
1619 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1620 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1621 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1622 226, 226, 226, 226, 226, 226, 226, 226
1623 };
1624
1625 static DfaState st28[38] = {
1626 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1627 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1628 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1629 226, 226, 226, 226, 226, 226, 226, 226
1630 };
1631
1632 static DfaState st29[38] = {
1633 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1634 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1635 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1636 226, 226, 226, 226, 226, 226, 226, 226
1637 };
1638
1639 static DfaState st30[38] = {
1640 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1641 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1642 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1643 226, 226, 226, 226, 226, 226, 226, 226
1644 };
1645
1646 static DfaState st31[38] = {
1647 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1648 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1649 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1650 226, 226, 226, 226, 226, 226, 226, 226
1651 };
1652
1653 static DfaState st32[38] = {
1654 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1655 226, 33, 40, 33, 33, 33, 33, 33, 33, 33,
1656 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1657 226, 226, 226, 226, 33, 33, 33, 226
1658 };
1659
1660 static DfaState st33[38] = {
1661 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1662 226, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1663 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1664 226, 226, 226, 226, 33, 33, 33, 226
1665 };
1666
1667 static DfaState st34[38] = {
1668 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1669 226, 33, 33, 33, 33, 33, 33, 41, 33, 33,
1670 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1671 226, 226, 226, 226, 33, 33, 33, 226
1672 };
1673
1674 static DfaState st35[38] = {
1675 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1676 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1677 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1678 226, 226, 226, 226, 226, 226, 226, 226
1679 };
1680
1681 static DfaState st36[38] = {
1682 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1683 226, 36, 36, 36, 36, 36, 36, 36, 36, 36,
1684 36, 226, 226, 226, 226, 226, 226, 226, 36, 36,
1685 226, 226, 226, 226, 36, 36, 36, 226
1686 };
1687
1688 static DfaState st37[38] = {
1689 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1690 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1691 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1692 226, 226, 226, 226, 226, 226, 226, 226
1693 };
1694
1695 static DfaState st38[38] = {
1696 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1697 226, 36, 36, 42, 36, 36, 36, 36, 36, 36,
1698 36, 226, 226, 226, 226, 226, 226, 226, 36, 36,
1699 226, 226, 226, 226, 36, 36, 36, 226
1700 };
1701
1702 static DfaState st39[38] = {
1703 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1704 226, 39, 39, 39, 39, 39, 39, 39, 39, 39,
1705 39, 226, 226, 226, 226, 226, 226, 226, 39, 39,
1706 226, 226, 226, 226, 39, 39, 39, 226
1707 };
1708
1709 static DfaState st40[38] = {
1710 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1711 226, 33, 33, 43, 33, 33, 33, 33, 33, 33,
1712 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1713 226, 226, 226, 226, 33, 33, 33, 226
1714 };
1715
1716 static DfaState st41[38] = {
1717 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1718 226, 33, 33, 33, 33, 33, 33, 33, 44, 33,
1719 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1720 226, 226, 226, 226, 33, 33, 33, 226
1721 };
1722
1723 static DfaState st42[38] = {
1724 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1725 226, 36, 36, 36, 36, 36, 36, 36, 36, 36,
1726 45, 226, 226, 226, 226, 226, 226, 226, 36, 36,
1727 226, 226, 226, 226, 36, 36, 36, 226
1728 };
1729
1730 static DfaState st43[38] = {
1731 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1732 226, 33, 33, 33, 46, 33, 33, 33, 33, 33,
1733 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1734 226, 226, 226, 226, 33, 33, 33, 226
1735 };
1736
1737 static DfaState st44[38] = {
1738 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1739 226, 33, 33, 33, 47, 33, 33, 33, 33, 33,
1740 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1741 226, 226, 226, 226, 33, 33, 33, 226
1742 };
1743
1744 static DfaState st45[38] = {
1745 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1746 226, 36, 36, 36, 36, 36, 36, 36, 36, 36,
1747 48, 226, 226, 226, 226, 226, 226, 226, 36, 36,
1748 226, 226, 226, 226, 36, 36, 36, 226
1749 };
1750
1751 static DfaState st46[38] = {
1752 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1753 226, 33, 49, 33, 33, 33, 33, 33, 33, 33,
1754 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1755 226, 226, 226, 226, 33, 33, 33, 226
1756 };
1757
1758 static DfaState st47[38] = {
1759 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1760 226, 33, 50, 33, 33, 33, 33, 33, 33, 33,
1761 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1762 226, 226, 226, 226, 33, 33, 33, 226
1763 };
1764
1765 static DfaState st48[38] = {
1766 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1767 226, 36, 36, 36, 36, 36, 36, 36, 36, 36,
1768 36, 226, 226, 226, 226, 226, 226, 226, 36, 36,
1769 226, 226, 226, 226, 36, 36, 36, 226
1770 };
1771
1772 static DfaState st49[38] = {
1773 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1774 226, 33, 33, 33, 33, 51, 33, 33, 33, 33,
1775 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1776 226, 226, 226, 226, 33, 33, 33, 226
1777 };
1778
1779 static DfaState st50[38] = {
1780 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1781 226, 33, 33, 33, 33, 33, 33, 33, 33, 52,
1782 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1783 226, 226, 226, 226, 33, 33, 33, 226
1784 };
1785
1786 static DfaState st51[38] = {
1787 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1788 226, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1789 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1790 226, 226, 226, 226, 33, 33, 33, 226
1791 };
1792
1793 static DfaState st52[38] = {
1794 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1795 226, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1796 53, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1797 226, 226, 226, 226, 33, 33, 33, 226
1798 };
1799
1800 static DfaState st53[38] = {
1801 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
1802 226, 33, 33, 33, 33, 33, 33, 33, 33, 33,
1803 33, 226, 226, 226, 226, 226, 226, 226, 33, 33,
1804 226, 226, 226, 226, 33, 33, 33, 226
1805 };
1806
1807 static DfaState st54[7] = {
1808 55, 56, 57, 58, 59, 60, 226
1809 };
1810
1811 static DfaState st55[7] = {
1812 226, 226, 226, 226, 226, 226, 226
1813 };
1814
1815 static DfaState st56[7] = {
1816 226, 226, 226, 226, 226, 226, 226
1817 };
1818
1819 static DfaState st57[7] = {
1820 226, 226, 226, 226, 226, 226, 226
1821 };
1822
1823 static DfaState st58[7] = {
1824 226, 226, 61, 226, 226, 226, 226
1825 };
1826
1827 static DfaState st59[7] = {
1828 226, 62, 62, 62, 62, 62, 226
1829 };
1830
1831 static DfaState st60[7] = {
1832 226, 226, 226, 226, 226, 60, 226
1833 };
1834
1835 static DfaState st61[7] = {
1836 226, 226, 226, 226, 226, 226, 226
1837 };
1838
1839 static DfaState st62[7] = {
1840 226, 226, 226, 226, 226, 226, 226
1841 };
1842
1843 static DfaState st63[7] = {
1844 64, 65, 66, 67, 68, 69, 226
1845 };
1846
1847 static DfaState st64[7] = {
1848 226, 226, 226, 226, 226, 226, 226
1849 };
1850
1851 static DfaState st65[7] = {
1852 226, 226, 226, 226, 226, 226, 226
1853 };
1854
1855 static DfaState st66[7] = {
1856 226, 226, 226, 226, 226, 226, 226
1857 };
1858
1859 static DfaState st67[7] = {
1860 226, 226, 70, 226, 226, 226, 226
1861 };
1862
1863 static DfaState st68[7] = {
1864 226, 71, 71, 71, 71, 71, 226
1865 };
1866
1867 static DfaState st69[7] = {
1868 226, 226, 226, 226, 226, 69, 226
1869 };
1870
1871 static DfaState st70[7] = {
1872 226, 226, 226, 226, 226, 226, 226
1873 };
1874
1875 static DfaState st71[7] = {
1876 226, 226, 226, 226, 226, 226, 226
1877 };
1878
1879 static DfaState st72[7] = {
1880 73, 74, 75, 76, 77, 78, 226
1881 };
1882
1883 static DfaState st73[7] = {
1884 226, 226, 226, 226, 226, 226, 226
1885 };
1886
1887 static DfaState st74[7] = {
1888 226, 226, 226, 226, 226, 226, 226
1889 };
1890
1891 static DfaState st75[7] = {
1892 226, 226, 226, 226, 226, 226, 226
1893 };
1894
1895 static DfaState st76[7] = {
1896 226, 226, 79, 226, 226, 226, 226
1897 };
1898
1899 static DfaState st77[7] = {
1900 226, 80, 80, 80, 80, 80, 226
1901 };
1902
1903 static DfaState st78[7] = {
1904 226, 226, 226, 226, 226, 78, 226
1905 };
1906
1907 static DfaState st79[7] = {
1908 226, 226, 226, 226, 226, 226, 226
1909 };
1910
1911 static DfaState st80[7] = {
1912 226, 226, 226, 226, 226, 226, 226
1913 };
1914
1915 static DfaState st81[7] = {
1916 82, 83, 84, 85, 86, 84, 226
1917 };
1918
1919 static DfaState st82[7] = {
1920 226, 226, 226, 226, 226, 226, 226
1921 };
1922
1923 static DfaState st83[7] = {
1924 226, 226, 87, 226, 226, 226, 226
1925 };
1926
1927 static DfaState st84[7] = {
1928 226, 226, 84, 226, 226, 84, 226
1929 };
1930
1931 static DfaState st85[7] = {
1932 226, 226, 226, 226, 226, 226, 226
1933 };
1934
1935 static DfaState st86[7] = {
1936 226, 226, 226, 88, 226, 226, 226
1937 };
1938
1939 static DfaState st87[7] = {
1940 226, 226, 226, 226, 226, 226, 226
1941 };
1942
1943 static DfaState st88[7] = {
1944 226, 226, 226, 226, 226, 226, 226
1945 };
1946
1947 static DfaState st89[5] = {
1948 90, 91, 92, 93, 226
1949 };
1950
1951 static DfaState st90[5] = {
1952 226, 226, 226, 226, 226
1953 };
1954
1955 static DfaState st91[5] = {
1956 226, 226, 226, 226, 226
1957 };
1958
1959 static DfaState st92[5] = {
1960 226, 94, 226, 226, 226
1961 };
1962
1963 static DfaState st93[5] = {
1964 226, 226, 226, 93, 226
1965 };
1966
1967 static DfaState st94[5] = {
1968 226, 226, 226, 226, 226
1969 };
1970
1971 static DfaState st95[5] = {
1972 96, 97, 98, 99, 226
1973 };
1974
1975 static DfaState st96[5] = {
1976 226, 226, 226, 226, 226
1977 };
1978
1979 static DfaState st97[5] = {
1980 226, 226, 226, 226, 226
1981 };
1982
1983 static DfaState st98[5] = {
1984 226, 100, 226, 226, 226
1985 };
1986
1987 static DfaState st99[5] = {
1988 226, 226, 226, 99, 226
1989 };
1990
1991 static DfaState st100[5] = {
1992 226, 226, 226, 226, 226
1993 };
1994
1995 static DfaState st101[7] = {
1996 102, 103, 104, 105, 106, 104, 226
1997 };
1998
1999 static DfaState st102[7] = {
2000 226, 226, 226, 226, 226, 226, 226
2001 };
2002
2003 static DfaState st103[7] = {
2004 226, 226, 107, 226, 226, 226, 226
2005 };
2006
2007 static DfaState st104[7] = {
2008 226, 226, 104, 226, 226, 104, 226
2009 };
2010
2011 static DfaState st105[7] = {
2012 226, 226, 226, 226, 226, 226, 226
2013 };
2014
2015 static DfaState st106[7] = {
2016 226, 226, 226, 108, 226, 226, 226
2017 };
2018
2019 static DfaState st107[7] = {
2020 226, 226, 226, 226, 226, 226, 226
2021 };
2022
2023 static DfaState st108[7] = {
2024 226, 226, 226, 226, 226, 226, 226
2025 };
2026
2027 static DfaState st109[4] = {
2028 110, 111, 226, 226
2029 };
2030
2031 static DfaState st110[4] = {
2032 226, 226, 226, 226
2033 };
2034
2035 static DfaState st111[4] = {
2036 226, 111, 112, 226
2037 };
2038
2039 static DfaState st112[4] = {
2040 226, 226, 226, 226
2041 };
2042
2043 static DfaState st113[19] = {
2044 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2045 124, 125, 126, 127, 128, 129, 130, 121, 226
2046 };
2047
2048 static DfaState st114[19] = {
2049 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2050 226, 226, 226, 226, 226, 226, 226, 226, 226
2051 };
2052
2053 static DfaState st115[19] = {
2054 226, 131, 226, 226, 226, 226, 226, 226, 226, 226,
2055 226, 226, 226, 226, 226, 226, 226, 226, 226
2056 };
2057
2058 static DfaState st116[19] = {
2059 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2060 226, 226, 226, 226, 226, 226, 226, 226, 226
2061 };
2062
2063 static DfaState st117[19] = {
2064 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2065 226, 226, 226, 226, 226, 226, 226, 226, 226
2066 };
2067
2068 static DfaState st118[19] = {
2069 226, 226, 226, 132, 226, 226, 226, 226, 226, 226,
2070 226, 226, 226, 226, 226, 226, 226, 226, 226
2071 };
2072
2073 static DfaState st119[19] = {
2074 226, 226, 226, 226, 226, 226, 133, 226, 134, 135,
2075 226, 226, 226, 226, 226, 226, 226, 226, 226
2076 };
2077
2078 static DfaState st120[19] = {
2079 226, 226, 226, 226, 226, 226, 120, 226, 226, 136,
2080 226, 226, 226, 226, 226, 226, 226, 226, 226
2081 };
2082
2083 static DfaState st121[19] = {
2084 226, 226, 226, 226, 226, 226, 226, 121, 226, 226,
2085 226, 226, 226, 226, 226, 121, 226, 121, 226
2086 };
2087
2088 static DfaState st122[19] = {
2089 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2090 226, 226, 226, 226, 226, 226, 226, 226, 226
2091 };
2092
2093 static DfaState st123[19] = {
2094 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2095 226, 226, 226, 226, 226, 226, 226, 226, 226
2096 };
2097
2098 static DfaState st124[19] = {
2099 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2100 226, 226, 226, 226, 226, 226, 226, 226, 226
2101 };
2102
2103 static DfaState st125[19] = {
2104 226, 137, 138, 139, 139, 140, 139, 139, 139, 139,
2105 141, 139, 139, 139, 139, 139, 139, 139, 226
2106 };
2107
2108 static DfaState st126[19] = {
2109 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2110 226, 226, 226, 226, 226, 226, 226, 226, 226
2111 };
2112
2113 static DfaState st127[19] = {
2114 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2115 226, 226, 226, 226, 226, 226, 226, 226, 226
2116 };
2117
2118 static DfaState st128[19] = {
2119 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2120 226, 226, 226, 226, 142, 143, 226, 226, 226
2121 };
2122
2123 static DfaState st129[19] = {
2124 226, 226, 226, 226, 226, 226, 226, 121, 226, 226,
2125 226, 226, 226, 226, 144, 121, 226, 121, 226
2126 };
2127
2128 static DfaState st130[19] = {
2129 226, 226, 226, 226, 226, 226, 226, 226, 226, 145,
2130 226, 226, 226, 226, 226, 226, 226, 226, 226
2131 };
2132
2133 static DfaState st131[19] = {
2134 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2135 226, 226, 226, 226, 226, 226, 226, 226, 226
2136 };
2137
2138 static DfaState st132[19] = {
2139 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2140 226, 226, 226, 226, 226, 226, 226, 226, 226
2141 };
2142
2143 static DfaState st133[19] = {
2144 226, 226, 226, 226, 226, 226, 146, 146, 226, 226,
2145 226, 226, 226, 226, 226, 226, 226, 226, 226
2146 };
2147
2148 static DfaState st134[19] = {
2149 226, 226, 147, 226, 226, 226, 226, 226, 226, 226,
2150 226, 226, 226, 226, 226, 226, 226, 226, 226
2151 };
2152
2153 static DfaState st135[19] = {
2154 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2155 148, 226, 226, 226, 226, 226, 226, 226, 226
2156 };
2157
2158 static DfaState st136[19] = {
2159 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2160 226, 226, 226, 226, 226, 226, 226, 226, 226
2161 };
2162
2163 static DfaState st137[19] = {
2164 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2165 226, 226, 226, 226, 226, 226, 226, 226, 226
2166 };
2167
2168 static DfaState st138[19] = {
2169 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2170 226, 226, 226, 226, 226, 226, 226, 226, 226
2171 };
2172
2173 static DfaState st139[19] = {
2174 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2175 226, 226, 226, 226, 226, 226, 226, 226, 226
2176 };
2177
2178 static DfaState st140[19] = {
2179 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2180 226, 226, 226, 226, 226, 226, 226, 226, 226
2181 };
2182
2183 static DfaState st141[19] = {
2184 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2185 226, 226, 226, 226, 226, 226, 226, 226, 226
2186 };
2187
2188 static DfaState st142[19] = {
2189 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2190 226, 226, 226, 226, 226, 226, 226, 226, 226
2191 };
2192
2193 static DfaState st143[19] = {
2194 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2195 226, 226, 226, 226, 226, 226, 226, 226, 226
2196 };
2197
2198 static DfaState st144[19] = {
2199 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2200 226, 226, 226, 226, 226, 226, 226, 226, 226
2201 };
2202
2203 static DfaState st145[19] = {
2204 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2205 226, 226, 226, 226, 226, 226, 226, 226, 226
2206 };
2207
2208 static DfaState st146[19] = {
2209 226, 226, 226, 226, 226, 226, 146, 146, 226, 226,
2210 226, 226, 226, 226, 226, 226, 226, 226, 226
2211 };
2212
2213 static DfaState st147[19] = {
2214 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2215 226, 226, 226, 226, 226, 226, 226, 226, 226
2216 };
2217
2218 static DfaState st148[19] = {
2219 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2220 226, 226, 226, 226, 226, 226, 226, 226, 226
2221 };
2222
2223 static DfaState st149[7] = {
2224 150, 151, 152, 153, 154, 152, 226
2225 };
2226
2227 static DfaState st150[7] = {
2228 226, 226, 226, 226, 226, 226, 226
2229 };
2230
2231 static DfaState st151[7] = {
2232 226, 226, 155, 226, 226, 226, 226
2233 };
2234
2235 static DfaState st152[7] = {
2236 226, 226, 152, 226, 226, 152, 226
2237 };
2238
2239 static DfaState st153[7] = {
2240 226, 226, 226, 226, 226, 226, 226
2241 };
2242
2243 static DfaState st154[7] = {
2244 226, 226, 226, 156, 226, 226, 226
2245 };
2246
2247 static DfaState st155[7] = {
2248 226, 226, 226, 226, 226, 226, 226
2249 };
2250
2251 static DfaState st156[7] = {
2252 226, 226, 226, 226, 226, 226, 226
2253 };
2254
2255 static DfaState st157[5] = {
2256 158, 159, 160, 161, 226
2257 };
2258
2259 static DfaState st158[5] = {
2260 226, 226, 226, 226, 226
2261 };
2262
2263 static DfaState st159[5] = {
2264 226, 226, 226, 226, 226
2265 };
2266
2267 static DfaState st160[5] = {
2268 226, 162, 226, 226, 226
2269 };
2270
2271 static DfaState st161[5] = {
2272 226, 226, 226, 161, 226
2273 };
2274
2275 static DfaState st162[5] = {
2276 226, 226, 226, 226, 226
2277 };
2278
2279 static DfaState st163[32] = {
2280 164, 165, 166, 167, 168, 226, 169, 170, 170, 170,
2281 170, 171, 170, 170, 170, 170, 172, 173, 174, 175,
2282 170, 170, 170, 170, 170, 170, 170, 176, 177, 178,
2283 170, 226
2284 };
2285
2286 static DfaState st164[32] = {
2287 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2288 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2289 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2290 226, 226
2291 };
2292
2293 static DfaState st165[32] = {
2294 226, 165, 226, 226, 226, 226, 226, 226, 226, 226,
2295 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2296 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2297 226, 226
2298 };
2299
2300 static DfaState st166[32] = {
2301 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2302 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2303 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2304 226, 226
2305 };
2306
2307 static DfaState st167[32] = {
2308 226, 226, 179, 226, 226, 226, 226, 226, 226, 226,
2309 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2310 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2311 226, 226
2312 };
2313
2314 static DfaState st168[32] = {
2315 226, 226, 226, 226, 180, 181, 226, 226, 226, 226,
2316 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2317 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2318 226, 226
2319 };
2320
2321 static DfaState st169[32] = {
2322 226, 226, 226, 226, 226, 226, 226, 182, 226, 226,
2323 183, 184, 226, 226, 226, 226, 226, 226, 226, 226,
2324 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2325 226, 226
2326 };
2327
2328 static DfaState st170[32] = {
2329 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2330 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2331 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2332 185, 226
2333 };
2334
2335 static DfaState st171[32] = {
2336 226, 226, 226, 226, 226, 226, 226, 185, 185, 186,
2337 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2338 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2339 185, 226
2340 };
2341
2342 static DfaState st172[32] = {
2343 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2344 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2345 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2346 226, 226
2347 };
2348
2349 static DfaState st173[32] = {
2350 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2351 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2352 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2353 226, 226
2354 };
2355
2356 static DfaState st174[32] = {
2357 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2358 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2359 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2360 226, 226
2361 };
2362
2363 static DfaState st175[32] = {
2364 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2365 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2366 187, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2367 185, 226
2368 };
2369
2370 static DfaState st176[32] = {
2371 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2372 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2373 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2374 226, 226
2375 };
2376
2377 static DfaState st177[32] = {
2378 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2379 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2380 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2381 226, 226
2382 };
2383
2384 static DfaState st178[32] = {
2385 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2386 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2387 226, 226, 226, 226, 226, 226, 226, 226, 226, 178,
2388 226, 226
2389 };
2390
2391 static DfaState st179[32] = {
2392 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2393 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2394 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2395 226, 226
2396 };
2397
2398 static DfaState st180[32] = {
2399 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2400 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2401 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2402 226, 226
2403 };
2404
2405 static DfaState st181[32] = {
2406 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2407 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2408 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2409 226, 226
2410 };
2411
2412 static DfaState st182[32] = {
2413 226, 226, 226, 226, 226, 226, 226, 226, 188, 226,
2414 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2415 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2416 226, 226
2417 };
2418
2419 static DfaState st183[32] = {
2420 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2421 226, 189, 226, 226, 226, 226, 226, 226, 226, 226,
2422 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2423 226, 226
2424 };
2425
2426 static DfaState st184[32] = {
2427 226, 226, 226, 226, 226, 226, 226, 226, 226, 190,
2428 226, 226, 191, 226, 226, 226, 226, 226, 226, 226,
2429 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2430 226, 226
2431 };
2432
2433 static DfaState st185[32] = {
2434 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2435 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2436 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2437 185, 226
2438 };
2439
2440 static DfaState st186[32] = {
2441 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2442 185, 185, 185, 185, 192, 185, 226, 226, 226, 185,
2443 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2444 185, 226
2445 };
2446
2447 static DfaState st187[32] = {
2448 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2449 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2450 185, 193, 185, 185, 185, 185, 185, 226, 226, 185,
2451 185, 226
2452 };
2453
2454 static DfaState st188[32] = {
2455 226, 226, 226, 226, 226, 226, 226, 226, 226, 194,
2456 195, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2457 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2458 226, 226
2459 };
2460
2461 static DfaState st189[32] = {
2462 226, 226, 226, 226, 226, 226, 226, 226, 196, 226,
2463 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2464 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2465 226, 226
2466 };
2467
2468 static DfaState st190[32] = {
2469 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2470 197, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2471 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2472 226, 226
2473 };
2474
2475 static DfaState st191[32] = {
2476 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2477 226, 226, 226, 198, 226, 226, 226, 226, 226, 226,
2478 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2479 226, 226
2480 };
2481
2482 static DfaState st192[32] = {
2483 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2484 185, 185, 185, 185, 185, 199, 226, 226, 226, 185,
2485 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2486 185, 226
2487 };
2488
2489 static DfaState st193[32] = {
2490 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2491 185, 185, 185, 185, 185, 200, 226, 226, 226, 185,
2492 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2493 185, 226
2494 };
2495
2496 static DfaState st194[32] = {
2497 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2498 201, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2499 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2500 226, 226
2501 };
2502
2503 static DfaState st195[32] = {
2504 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2505 226, 202, 226, 226, 226, 226, 226, 226, 226, 226,
2506 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2507 226, 226
2508 };
2509
2510 static DfaState st196[32] = {
2511 226, 226, 226, 226, 226, 226, 226, 203, 226, 226,
2512 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2513 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2514 226, 226
2515 };
2516
2517 static DfaState st197[32] = {
2518 226, 226, 226, 226, 226, 226, 226, 204, 226, 226,
2519 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2520 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2521 226, 226
2522 };
2523
2524 static DfaState st198[32] = {
2525 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2526 226, 205, 226, 226, 226, 226, 226, 226, 226, 226,
2527 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2528 226, 226
2529 };
2530
2531 static DfaState st199[32] = {
2532 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2533 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2534 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2535 185, 226
2536 };
2537
2538 static DfaState st200[32] = {
2539 226, 226, 226, 226, 226, 226, 226, 206, 185, 185,
2540 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2541 185, 185, 185, 185, 185, 207, 185, 226, 226, 185,
2542 185, 226
2543 };
2544
2545 static DfaState st201[32] = {
2546 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2547 226, 208, 226, 226, 226, 226, 226, 226, 226, 226,
2548 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2549 226, 226
2550 };
2551
2552 static DfaState st202[32] = {
2553 226, 226, 226, 226, 226, 226, 226, 226, 209, 226,
2554 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2555 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2556 226, 226
2557 };
2558
2559 static DfaState st203[32] = {
2560 226, 226, 226, 226, 226, 226, 226, 226, 226, 210,
2561 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2562 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2563 226, 226
2564 };
2565
2566 static DfaState st204[32] = {
2567 226, 226, 226, 226, 226, 226, 226, 226, 211, 226,
2568 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2569 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2570 226, 226
2571 };
2572
2573 static DfaState st205[32] = {
2574 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2575 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2576 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2577 226, 226
2578 };
2579
2580 static DfaState st206[32] = {
2581 226, 226, 226, 226, 226, 226, 226, 185, 185, 212,
2582 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2583 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2584 185, 226
2585 };
2586
2587 static DfaState st207[32] = {
2588 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2589 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2590 185, 185, 185, 185, 185, 185, 213, 226, 226, 185,
2591 185, 226
2592 };
2593
2594 static DfaState st208[32] = {
2595 226, 226, 226, 226, 226, 226, 226, 226, 214, 226,
2596 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2597 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2598 226, 226
2599 };
2600
2601 static DfaState st209[32] = {
2602 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2603 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2604 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2605 226, 226
2606 };
2607
2608 static DfaState st210[32] = {
2609 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2610 226, 215, 226, 226, 226, 226, 226, 226, 226, 226,
2611 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2612 226, 226
2613 };
2614
2615 static DfaState st211[32] = {
2616 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2617 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2618 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2619 226, 226
2620 };
2621
2622 static DfaState st212[32] = {
2623 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2624 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2625 185, 185, 216, 185, 185, 185, 185, 226, 226, 185,
2626 185, 226
2627 };
2628
2629 static DfaState st213[32] = {
2630 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2631 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2632 185, 185, 217, 185, 185, 185, 185, 226, 226, 185,
2633 185, 226
2634 };
2635
2636 static DfaState st214[32] = {
2637 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2638 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2639 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2640 226, 226
2641 };
2642
2643 static DfaState st215[32] = {
2644 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2645 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2646 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
2647 226, 226
2648 };
2649
2650 static DfaState st216[32] = {
2651 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2652 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2653 185, 185, 185, 218, 185, 185, 185, 226, 226, 185,
2654 185, 226
2655 };
2656
2657 static DfaState st217[32] = {
2658 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2659 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2660 185, 185, 185, 219, 185, 185, 185, 226, 226, 185,
2661 185, 226
2662 };
2663
2664 static DfaState st218[32] = {
2665 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2666 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2667 185, 185, 185, 185, 220, 185, 185, 226, 226, 185,
2668 185, 226
2669 };
2670
2671 static DfaState st219[32] = {
2672 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2673 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2674 185, 185, 185, 185, 221, 185, 185, 226, 226, 185,
2675 185, 226
2676 };
2677
2678 static DfaState st220[32] = {
2679 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2680 185, 222, 185, 185, 185, 185, 226, 226, 226, 185,
2681 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2682 185, 226
2683 };
2684
2685 static DfaState st221[32] = {
2686 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2687 185, 223, 185, 185, 185, 185, 226, 226, 226, 185,
2688 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2689 185, 226
2690 };
2691
2692 static DfaState st222[32] = {
2693 226, 226, 226, 226, 226, 226, 226, 185, 185, 224,
2694 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2695 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2696 185, 226
2697 };
2698
2699 static DfaState st223[32] = {
2700 226, 226, 226, 226, 226, 226, 226, 185, 185, 225,
2701 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2702 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2703 185, 226
2704 };
2705
2706 static DfaState st224[32] = {
2707 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2708 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2709 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2710 185, 226
2711 };
2712
2713 static DfaState st225[32] = {
2714 226, 226, 226, 226, 226, 226, 226, 185, 185, 185,
2715 185, 185, 185, 185, 185, 185, 226, 226, 226, 185,
2716 185, 185, 185, 185, 185, 185, 185, 226, 226, 185,
2717 185, 226
2718 };
2719
2720
2721 DfaState *dfa[226] = {
2722 st0,
2723 st1,
2724 st2,
2725 st3,
2726 st4,
2727 st5,
2728 st6,
2729 st7,
2730 st8,
2731 st9,
2732 st10,
2733 st11,
2734 st12,
2735 st13,
2736 st14,
2737 st15,
2738 st16,
2739 st17,
2740 st18,
2741 st19,
2742 st20,
2743 st21,
2744 st22,
2745 st23,
2746 st24,
2747 st25,
2748 st26,
2749 st27,
2750 st28,
2751 st29,
2752 st30,
2753 st31,
2754 st32,
2755 st33,
2756 st34,
2757 st35,
2758 st36,
2759 st37,
2760 st38,
2761 st39,
2762 st40,
2763 st41,
2764 st42,
2765 st43,
2766 st44,
2767 st45,
2768 st46,
2769 st47,
2770 st48,
2771 st49,
2772 st50,
2773 st51,
2774 st52,
2775 st53,
2776 st54,
2777 st55,
2778 st56,
2779 st57,
2780 st58,
2781 st59,
2782 st60,
2783 st61,
2784 st62,
2785 st63,
2786 st64,
2787 st65,
2788 st66,
2789 st67,
2790 st68,
2791 st69,
2792 st70,
2793 st71,
2794 st72,
2795 st73,
2796 st74,
2797 st75,
2798 st76,
2799 st77,
2800 st78,
2801 st79,
2802 st80,
2803 st81,
2804 st82,
2805 st83,
2806 st84,
2807 st85,
2808 st86,
2809 st87,
2810 st88,
2811 st89,
2812 st90,
2813 st91,
2814 st92,
2815 st93,
2816 st94,
2817 st95,
2818 st96,
2819 st97,
2820 st98,
2821 st99,
2822 st100,
2823 st101,
2824 st102,
2825 st103,
2826 st104,
2827 st105,
2828 st106,
2829 st107,
2830 st108,
2831 st109,
2832 st110,
2833 st111,
2834 st112,
2835 st113,
2836 st114,
2837 st115,
2838 st116,
2839 st117,
2840 st118,
2841 st119,
2842 st120,
2843 st121,
2844 st122,
2845 st123,
2846 st124,
2847 st125,
2848 st126,
2849 st127,
2850 st128,
2851 st129,
2852 st130,
2853 st131,
2854 st132,
2855 st133,
2856 st134,
2857 st135,
2858 st136,
2859 st137,
2860 st138,
2861 st139,
2862 st140,
2863 st141,
2864 st142,
2865 st143,
2866 st144,
2867 st145,
2868 st146,
2869 st147,
2870 st148,
2871 st149,
2872 st150,
2873 st151,
2874 st152,
2875 st153,
2876 st154,
2877 st155,
2878 st156,
2879 st157,
2880 st158,
2881 st159,
2882 st160,
2883 st161,
2884 st162,
2885 st163,
2886 st164,
2887 st165,
2888 st166,
2889 st167,
2890 st168,
2891 st169,
2892 st170,
2893 st171,
2894 st172,
2895 st173,
2896 st174,
2897 st175,
2898 st176,
2899 st177,
2900 st178,
2901 st179,
2902 st180,
2903 st181,
2904 st182,
2905 st183,
2906 st184,
2907 st185,
2908 st186,
2909 st187,
2910 st188,
2911 st189,
2912 st190,
2913 st191,
2914 st192,
2915 st193,
2916 st194,
2917 st195,
2918 st196,
2919 st197,
2920 st198,
2921 st199,
2922 st200,
2923 st201,
2924 st202,
2925 st203,
2926 st204,
2927 st205,
2928 st206,
2929 st207,
2930 st208,
2931 st209,
2932 st210,
2933 st211,
2934 st212,
2935 st213,
2936 st214,
2937 st215,
2938 st216,
2939 st217,
2940 st218,
2941 st219,
2942 st220,
2943 st221,
2944 st222,
2945 st223,
2946 st224,
2947 st225
2948 };
2949
2950
2951 DfaState accepts[227] = {
2952 0, 1, 2, 3, 3, 4, 23, 6, 0, 16,
2953 24, 32, 30, 13, 14, 15, 17, 18, 27, 20,
2954 30, 22, 25, 26, 28, 31, 3, 5, 9, 7,
2955 8, 10, 32, 32, 32, 19, 30, 29, 30, 31,
2956 32, 32, 30, 32, 32, 30, 32, 32, 21, 32,
2957 32, 11, 32, 12, 0, 33, 34, 35, 35, 0,
2958 37, 35, 36, 0, 38, 39, 40, 40, 0, 42,
2959 40, 41, 0, 43, 44, 45, 45, 0, 47, 45,
2960 46, 0, 48, 50, 52, 51, 51, 49, 51, 0,
2961 53, 54, 54, 55, 54, 0, 56, 57, 57, 58,
2962 57, 0, 59, 61, 63, 62, 62, 60, 62, 0,
2963 64, 0, 65, 0, 66, 70, 68, 69, 69, 76,
2964 94, 95, 78, 79, 77, 0, 83, 84, 87, 95,
2965 92, 67, 69, 71, 74, 75, 93, 82, 80, 86,
2966 85, 81, 90, 88, 89, 91, 71, 72, 73, 0,
2967 96, 98, 100, 99, 99, 97, 99, 0, 101, 102,
2968 102, 103, 102, 0, 104, 105, 106, 106, 0, 0,
2969 123, 123, 115, 116, 117, 123, 120, 121, 122, 106,
2970 107, 108, 0, 0, 0, 123, 123, 123, 0, 0,
2971 0, 0, 123, 123, 0, 0, 0, 0, 0, 114,
2972 123, 0, 0, 0, 0, 111, 123, 123, 0, 110,
2973 0, 113, 123, 123, 109, 112, 123, 123, 123, 123,
2974 123, 123, 123, 123, 118, 119, 0
2975 };
2976
2977 void (*actions[124])() = {
2978 zzerraction,
2979 act1,
2980 act2,
2981 act3,
2982 act4,
2983 act5,
2984 act6,
2985 act7,
2986 act8,
2987 act9,
2988 act10,
2989 act11,
2990 act12,
2991 act13,
2992 act14,
2993 act15,
2994 act16,
2995 act17,
2996 act18,
2997 act19,
2998 act20,
2999 act21,
3000 act22,
3001 act23,
3002 act24,
3003 act25,
3004 act26,
3005 act27,
3006 act28,
3007 act29,
3008 act30,
3009 act31,
3010 act32,
3011 act33,
3012 act34,
3013 act35,
3014 act36,
3015 act37,
3016 act38,
3017 act39,
3018 act40,
3019 act41,
3020 act42,
3021 act43,
3022 act44,
3023 act45,
3024 act46,
3025 act47,
3026 act48,
3027 act49,
3028 act50,
3029 act51,
3030 act52,
3031 act53,
3032 act54,
3033 act55,
3034 act56,
3035 act57,
3036 act58,
3037 act59,
3038 act60,
3039 act61,
3040 act62,
3041 act63,
3042 act64,
3043 act65,
3044 act66,
3045 act67,
3046 act68,
3047 act69,
3048 act70,
3049 act71,
3050 act72,
3051 act73,
3052 act74,
3053 act75,
3054 act76,
3055 act77,
3056 act78,
3057 act79,
3058 act80,
3059 act81,
3060 act82,
3061 act83,
3062 act84,
3063 act85,
3064 act86,
3065 act87,
3066 act88,
3067 act89,
3068 act90,
3069 act91,
3070 act92,
3071 act93,
3072 act94,
3073 act95,
3074 act96,
3075 act97,
3076 act98,
3077 act99,
3078 act100,
3079 act101,
3080 act102,
3081 act103,
3082 act104,
3083 act105,
3084 act106,
3085 act107,
3086 act108,
3087 act109,
3088 act110,
3089 act111,
3090 act112,
3091 act113,
3092 act114,
3093 act115,
3094 act116,
3095 act117,
3096 act118,
3097 act119,
3098 act120,
3099 act121,
3100 act122,
3101 act123
3102 };
3103
3104 static DfaState dfa_base[] = {
3105 0,
3106 54,
3107 63,
3108 72,
3109 81,
3110 89,
3111 95,
3112 101,
3113 109,
3114 113,
3115 149,
3116 157,
3117 163
3118 };
3119
3120 static unsigned char *b_class_no[] = {
3121 shift0,
3122 shift1,
3123 shift2,
3124 shift3,
3125 shift4,
3126 shift5,
3127 shift6,
3128 shift7,
3129 shift8,
3130 shift9,
3131 shift10,
3132 shift11,
3133 shift12
3134 };
3135
3136
3137
3138 #define ZZSHIFT(c) (b_class_no[zzauto][1+c])
3139 #define MAX_MODE 13
3140 #include "dlgauto.h"
+0
-1926
contrib/pccts/sorcerer/sor.c less more
0 /*
1 * A n t l r T r a n s l a t i o n H e a d e r
2 *
3 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
4 * Purdue University Electrical Engineering
5 * With AHPCRC, University of Minnesota
6 * ANTLR Version 1.33MR33
7 *
8 * ../bin/antlr -gh -k 2 -gt sor.g
9 *
10 */
11
12 #define ANTLR_VERSION 13333
13 #include "pcctscfg.h"
14 #include "pccts_stdio.h"
15
16 /* 23-Sep-97 thm Accomodate user who needs to redefine ZZLEXBUFSIZE */
17
18 #ifndef ZZLEXBUFSIZE
19 #define ZZLEXBUFSIZE 8000
20 #endif
21 #include "pcctscfg.h" /* MR20 G. Hobbelt __USE_PROTOS #define */
22 #include "charbuf.h"
23 #include "hash.h"
24 #include "set.h"
25 #include "sor.h"
26 #define AST_FIELDS \
27 int token; char text[MaxAtom+1], label[MaxRuleName+1]; \
28 char *action; /* if action node, here is ptr to it */ \
29 char in,out; \
30 char init_action; /* set if Action and 1st action of alt */ \
31 int file; int line; /* set for BLOCK, ALT, nonterm nodes */ \
32 int upper_range; /* only if T1..T2 found */ \
33 GLA *start_state; /* ptr into GLA for this block */ \
34 int no_copy; /* copy input ptr to output ptr? */ \
35 ListNode *refvars; /* any ref vars defined for this rule */ \
36 unsigned char is_root; /* this token is a root #( A ... ) */
37 #define zzcr_ast(node, cur, _tok, _text) \
38 {(node)->token=_tok; strncpy((node)->text, _text,MaxAtom);}
39 #define USER_ZZSYN
40 #define zzAST_DOUBLE
41 extern int define_num;
42 #define LL_K 2
43 #define GENAST
44
45 #include "ast.h"
46
47 #define zzSET_SIZE 16
48 #include "antlr.h"
49 #include "tokens.h"
50 #include "dlgdef.h"
51 #include "mode.h"
52
53 /* MR23 In order to remove calls to PURIFY use the antlr -nopurify option */
54
55 #ifndef PCCTS_PURIFY
56 #define PCCTS_PURIFY(r,s) memset((char *) &(r),'\0',(s));
57 #endif
58
59 #include "ast.c"
60 zzASTgvars
61
62 ANTLR_INFO
63
64 /* MR20 G. Hobbelt Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled */
65 #if defined(__TURBOC__)
66 #pragma warn -aus /* unused assignment of 'xxx' */
67 #endif
68
69
70 #include "sym.h"
71 #include "proto.h"
72
73 void /* MR9 23-Sep-97 Eliminate complaint about no return value */
74 #ifdef __USE_PROTOS
75 lisp( AST *tree, FILE *output )
76 #else
77 lisp( tree, output )
78 AST *tree;
79 FILE *output;
80 #endif
81 {
82 while ( tree != NULL )
83 {
84 if ( tree->down != NULL ) fprintf(output," (");
85 if ( tree->text[0]!='\0' ) {
86 fprintf(output, " \"");
87 if ( tree->label[0]!='\0' ) fprintf(output, "%s:", tree->label);
88 switch ( tree->token ) {
89 case OPT :
90 case POS_CLOSURE :
91 case CLOSURE :
92 case PRED_OP :
93 fprintf(output, "%s", tree->text);
94 break;
95 default :
96 fprintf(output, "%s[%s]", zztokens[tree->token], tree->text);
97 }
98 fprintf(output, "\"");
99 }
100 else {
101 fprintf(output, " %s", zztokens[tree->token]);
102 }
103 lisp(tree->down, output);
104 if ( tree->down != NULL ) fprintf(output," )");
105 tree = tree->right;
106 }
107 }
108
109 AST *
110 #ifdef __USE_PROTOS
111 zzmk_ast(AST *node, int token)
112 #else
113 zzmk_ast(node, token)
114 AST *node;
115 int token;
116 #endif
117 {
118 node->token = token;
119 return node;
120 }
121
122 AST *
123 #ifdef __USE_PROTOS
124 read_sor_desc(FILE *f)
125 #else
126 read_sor_desc(f)
127 FILE *f;
128 #endif
129 {
130 AST *root = NULL;
131
132 zzline = 1;
133 ANTLR(sordesc(&root), f);
134
135 if ( found_error ) return NULL;
136
137 if ( print_guts ) {
138 fprintf(stderr, "Internal Represenation of Tree Grammar:\n");
139 lisp(root, stderr);
140 fprintf(stderr, "\n");
141 }
142
143 last_valid_token = token_type;
144 end_of_input = token_type++;/* end of input token type is 1 + last real token */
145 epsilon = token_type++; /* epsilon token type is 2 + last real token */
146 wild_card = token_type++; /* wild_card_token is 3 + last real token */
147 token_association(end_of_input, "$");
148 token_association(epsilon, "[Ep]");
149 token_association(wild_card, ".");
150
151 zzdouble_link(root, NULL, NULL);
152 rules = root;
153 if ( root!=NULL ) build_GLA(root);
154
155 if ( print_guts ) {
156 fprintf(stderr, "Internal Represenation of Grammar Lookahead Automaton:\n");
157 dump_GLAs(root);
158 fprintf(stderr, "\n");
159 }
160 return root;
161 }
162
163 void
164 #ifdef __USE_PROTOS
165 sordesc(AST**_root)
166 #else
167 sordesc(_root)
168 AST **_root;
169 #endif
170 {
171 zzRULE;
172 zzBLOCK(zztasp1);
173 zzMake0;
174 {
175 int he=0,to=0;
176 {
177 zzBLOCK(zztasp2);
178 zzMake0;
179 {
180 for (;;) {
181 if ( !((setwd1[LA(1)]&0x1))) break;
182 if ( (LA(1)==Header) ) {
183 header(zzSTR); zzlink(_root, &_sibling, &_tail);
184 he++;
185 }
186 else {
187 if ( (LA(1)==Tokdef) ) {
188 tokdef(zzSTR); zzlink(_root, &_sibling, &_tail);
189 to++;
190 }
191 else break; /* MR6 code for exiting loop "for sure" */
192 }
193 zzLOOP(zztasp2);
194 }
195 zzEXIT(zztasp2);
196 }
197 }
198
199 if ( he==0 && !Inline && !GenCPP ) warnNoFL("missing #header statement");
200 if ( he>1 ) warnNoFL("extra #header statement");
201 if ( to>1 ) warnNoFL("extra #tokdef statement");
202 {
203 zzBLOCK(zztasp2);
204 zzMake0;
205 {
206 while ( (LA(1)==Action) && (setwd1[LA(2)]&0x2) ) {
207 zzmatch(Action);
208 list_add(&before_actions, actiondup(LATEXT(1)));
209 zzCONSUME;
210
211 zzLOOP(zztasp2);
212 }
213 zzEXIT(zztasp2);
214 }
215 }
216 {
217 zzBLOCK(zztasp2);
218 zzMake0;
219 {
220 if ( (LA(1)==81)
221 ) {
222 class_def(zzSTR); zzlink(_root, &_sibling, &_tail);
223 }
224 else {
225 if ( (setwd1[LA(1)]&0x4) ) {
226 }
227 else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
228 }
229 zzEXIT(zztasp2);
230 }
231 }
232 {
233 zzBLOCK(zztasp2);
234 zzMake0;
235 {
236 while ( (LA(1)==Action) && (setwd1[LA(2)]&0x8) ) {
237 zzmatch(Action);
238
239 if ( CurClassName[0]!='\0' )
240 list_add(&class_actions, actiondup(LATEXT(1)));
241 else
242 list_add(&before_actions, actiondup(LATEXT(1)));
243 zzCONSUME;
244
245 zzLOOP(zztasp2);
246 }
247 zzEXIT(zztasp2);
248 }
249 }
250 {
251 zzBLOCK(zztasp2);
252 zzMake0;
253 {
254 while ( (LA(1)==NonTerm) ) {
255 rule(zzSTR); zzlink(_root, &_sibling, &_tail);
256 zzLOOP(zztasp2);
257 }
258 zzEXIT(zztasp2);
259 }
260 }
261 {
262 zzBLOCK(zztasp2);
263 zzMake0;
264 {
265 while ( (LA(1)==Action) && (setwd1[LA(2)]&0x10) ) {
266 zzmatch(Action);
267
268 if ( CurClassName[0]!='\0' )
269 list_add(&class_actions, actiondup(LATEXT(1)));
270 else
271 list_add(&before_actions, actiondup(LATEXT(1)));
272 zzCONSUME;
273
274 zzLOOP(zztasp2);
275 }
276 zzEXIT(zztasp2);
277 }
278 }
279 {
280 zzBLOCK(zztasp2);
281 zzMake0;
282 {
283 if ( (LA(1)==80)
284 ) {
285 zzmatch(80);
286
287 if ( CurClassName[0]=='\0' )
288 err("missing class definition for trailing '}'");
289 zzCONSUME;
290
291 }
292 else {
293 if ( (setwd1[LA(1)]&0x20) ) {
294 }
295 else {zzFAIL(1,zzerr2,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
296 }
297 zzEXIT(zztasp2);
298 }
299 }
300 {
301 zzBLOCK(zztasp2);
302 zzMake0;
303 {
304 while ( (LA(1)==Action) ) {
305 zzmatch(Action);
306 list_add(&after_actions, actiondup(LATEXT(1)));
307 zzCONSUME;
308
309 zzLOOP(zztasp2);
310 }
311 zzEXIT(zztasp2);
312 }
313 }
314 zzmatch(Eof); zzCONSUME;
315 zzEXIT(zztasp1);
316 return;
317 fail:
318 zzEXIT(zztasp1);
319 found_error=1;
320 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
321 zzresynch(setwd1, 0x40);
322 }
323 }
324
325 void
326 #ifdef __USE_PROTOS
327 header(AST**_root)
328 #else
329 header(_root)
330 AST **_root;
331 #endif
332 {
333 zzRULE;
334 zzBLOCK(zztasp1);
335 zzMake0;
336 {
337 zzmatch(Header); zzCONSUME;
338 zzmatch(Action);
339 header_action = actiondup(LATEXT(1));
340 zzCONSUME;
341
342 zzEXIT(zztasp1);
343 return;
344 fail:
345 zzEXIT(zztasp1);
346 found_error=1;
347 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
348 zzresynch(setwd1, 0x80);
349 }
350 }
351
352 void
353 #ifdef __USE_PROTOS
354 tokdef(AST**_root)
355 #else
356 tokdef(_root)
357 AST **_root;
358 #endif
359 {
360 zzRULE;
361 zzBLOCK(zztasp1);
362 zzMake0;
363 {
364 zzmatch(Tokdef); zzCONSUME;
365 zzmatch(RExpr);
366 {
367 AST *dumb = NULL;
368 zzantlr_state st; FILE *f; struct zzdlg_state dst;
369 strcpy(tokdefs_file, LATEXT(1));
370 strcpy(tokdefs_file, tokdefs_file+1); /* remove quotes */
371 tokdefs_file[strlen(tokdefs_file)-1] = '\0';
372 zzsave_antlr_state(&st);
373 zzsave_dlg_state(&dst);
374 define_num=0;
375 f = fopen(tokdefs_file, "r");
376 if ( f==NULL ) {found_error=1; err(eMsg1("cannot open token defs file '%s'", tokdefs_file));}
377 else {ANTLRm(enum_file(&dumb), f, PARSE_ENUM_FILE);}
378 zzrestore_antlr_state(&st);
379 zzrestore_dlg_state(&dst);
380 UserDefdTokens = 1;
381 }
382 zzCONSUME;
383
384 zzEXIT(zztasp1);
385 return;
386 fail:
387 zzEXIT(zztasp1);
388 found_error=1;
389 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
390 zzresynch(setwd2, 0x1);
391 }
392 }
393
394 void
395 #ifdef __USE_PROTOS
396 class_def(AST**_root)
397 #else
398 class_def(_root)
399 AST **_root;
400 #endif
401 {
402 zzRULE;
403 zzBLOCK(zztasp1);
404 zzMake0;
405 {
406 zzmatch(81); zzastDPush; zzCONSUME;
407 {
408 zzBLOCK(zztasp2);
409 zzMake0;
410 {
411 if ( (LA(1)==NonTerm) ) {
412 zzmatch(NonTerm); zzastDPush;
413 strncpy(CurClassName,LATEXT(1),MaxAtom);
414 zzCONSUME;
415
416 }
417 else {
418 if ( (LA(1)==Token) ) {
419 zzmatch(Token); zzastDPush;
420 strncpy(CurClassName,LATEXT(1),MaxAtom);
421 zzCONSUME;
422
423 }
424 else {zzFAIL(1,zzerr3,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
425 }
426 zzEXIT(zztasp2);
427 }
428 }
429 if ( !GenCPP ) { err("class meta-op used without C++ option"); }
430 zzmatch(OPT); zzastDPush; zzCONSUME;
431 zzEXIT(zztasp1);
432 return;
433 fail:
434 zzEXIT(zztasp1);
435 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
436 zzresynch(setwd2, 0x2);
437 }
438 }
439
440 void
441 #ifdef __USE_PROTOS
442 rule(AST**_root)
443 #else
444 rule(_root)
445 AST **_root;
446 #endif
447 {
448 zzRULE;
449 zzBLOCK(zztasp1);
450 zzMake0;
451 {
452 SymEntry *p; int trouble=0, no_copy=0;
453 zzmatch(NonTerm); zzsubroot(_root, &_sibling, &_tail);
454
455 (*_root)->file = CurFile;
456 (*_root)->line = zzline;
457 CurRule = zzaArg(zztasp1,1 ).text;
458 p = (SymEntry *) hash_get(symbols, zzaArg(zztasp1,1 ).text);
459 if ( p==NULL ) {
460 p = (SymEntry *) hash_add(symbols, zzaArg(zztasp1,1 ).text, (Entry *) newSymEntry(zzaArg(zztasp1,1 ).text));
461 p->token = NonTerm;
462 p->defined = 1;
463 p->definition = (*_root);
464 }
465 else if ( p->token != NonTerm ) {
466 err(eMsg2("rule definition clashes with %s definition: '%s'", zztokens[p->token], p->str));
467 trouble = 1;
468 }
469 else {
470 if ( p->defined ) {
471 trouble = 1;
472 err(eMsg1("rule multiply defined: '%s'", zzaArg(zztasp1,1 ).text));
473 }
474 else {
475 p->defined = 1;
476 p->definition = (*_root);
477 }
478 }
479 zzCONSUME;
480
481 {
482 zzBLOCK(zztasp2);
483 zzMake0;
484 {
485 if ( (LA(1)==84)
486 ) {
487 zzmatch(84);
488 if (!trouble) (*_root)->no_copy=no_copy=1;
489 zzCONSUME;
490
491 }
492 else {
493 if ( (setwd2[LA(1)]&0x4) ) {
494 }
495 else {zzFAIL(1,zzerr4,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
496 }
497 zzEXIT(zztasp2);
498 }
499 }
500 {
501 zzBLOCK(zztasp2);
502 zzMake0;
503 {
504 if ( (setwd2[LA(1)]&0x8) ) {
505 {
506 zzBLOCK(zztasp3);
507 zzMake0;
508 {
509 if ( (LA(1)==85) ) {
510 zzmatch(85); zzCONSUME;
511 }
512 else {
513 if ( (LA(1)==PassAction) ) {
514 }
515 else {zzFAIL(1,zzerr5,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
516 }
517 zzEXIT(zztasp3);
518 }
519 }
520 zzmatch(PassAction);
521 if (!trouble) p->args = actiondup(LATEXT(1));
522 zzCONSUME;
523
524 }
525 else {
526 if ( (setwd2[LA(1)]&0x10)
527 ) {
528 }
529 else {zzFAIL(1,zzerr6,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
530 }
531 zzEXIT(zztasp2);
532 }
533 }
534 {
535 zzBLOCK(zztasp2);
536 zzMake0;
537 {
538 if ( (LA(1)==86) ) {
539 zzmatch(86); zzCONSUME;
540 zzmatch(PassAction);
541 if (!trouble) p->rt = actiondup(LATEXT(1));
542 zzCONSUME;
543
544 }
545 else {
546 if ( (LA(1)==LABEL) ) {
547 }
548 else {zzFAIL(1,zzerr7,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
549 }
550 zzEXIT(zztasp2);
551 }
552 }
553 zzmatch(LABEL); zzCONSUME;
554 block(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
555 zzmatch(87);
556
557 if ( !trouble ) (*_root)->refvars = RefVars;
558 RefVars=NULL;
559 zzCONSUME;
560
561
562 if ( trouble ) (*_root) = NULL;
563 CurRule = NULL;
564 zzEXIT(zztasp1);
565 return;
566 fail:
567 zzEXIT(zztasp1);
568 found_error=1;
569 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
570 zzresynch(setwd2, 0x20);
571 }
572 }
573
574 void
575 #ifdef __USE_PROTOS
576 block(AST**_root,int no_copy)
577 #else
578 block(_root,no_copy)
579 AST **_root;
580 int no_copy ;
581 #endif
582 {
583 zzRULE;
584 zzBLOCK(zztasp1);
585 zzMake0;
586 {
587 int line=zzline, file=CurFile;
588 alt(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
589 {
590 zzBLOCK(zztasp2);
591 zzMake0;
592 {
593 while ( (LA(1)==88) ) {
594 zzmatch(88); zzCONSUME;
595 alt(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
596 zzLOOP(zztasp2);
597 }
598 zzEXIT(zztasp2);
599 }
600 }
601
602 (*_root) = zztmake( zzmk_ast(zzastnew(),BLOCK), (*_root) , NULL);
603 (*_root)->file = file;
604 (*_root)->line = line;
605 zzEXIT(zztasp1);
606 return;
607 fail:
608 zzEXIT(zztasp1);
609 found_error=1;
610 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
611 zzresynch(setwd2, 0x40);
612 }
613 }
614
615 void
616 #ifdef __USE_PROTOS
617 alt(AST**_root,int no_copy)
618 #else
619 alt(_root,no_copy)
620 AST **_root;
621 int no_copy ;
622 #endif
623 {
624 zzRULE;
625 zzBLOCK(zztasp1);
626 zzMake0;
627 {
628 int line=zzline, file=CurFile; int local_no_copy=0;
629 {
630 zzBLOCK(zztasp2);
631 zzMake0;
632 {
633 if ( (LA(1)==84) ) {
634 zzmatch(84);
635 local_no_copy=1;
636 zzCONSUME;
637
638 }
639 else {
640 if ( (setwd2[LA(1)]&0x80)
641 ) {
642 }
643 else {zzFAIL(1,zzerr8,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
644 }
645 zzEXIT(zztasp2);
646 }
647 }
648 {
649 zzBLOCK(zztasp2);
650 zzMake0;
651 {
652 if ( (setwd3[LA(1)]&0x1) ) {
653 {
654 zzBLOCK(zztasp3);
655 int zzcnt=1;
656 zzMake0;
657 {
658 do {
659 if ( (setwd3[LA(1)]&0x2) && (LA(2)==LABEL) ) {
660 labeled_element(zzSTR, no_copy||local_no_copy ); zzlink(_root, &_sibling, &_tail);
661 }
662 else {
663 if ( (setwd3[LA(1)]&0x4) && (setwd3[LA(2)]&0x8) ) {
664 element(zzSTR, no_copy||local_no_copy ); zzlink(_root, &_sibling, &_tail);
665 }
666 else {
667 if ( (LA(1)==BT) ) {
668 tree(zzSTR, no_copy||local_no_copy ); zzlink(_root, &_sibling, &_tail);
669 }
670 /* MR10 ()+ */ else {
671 if ( zzcnt > 1 ) break;
672 else {zzFAIL(2,zzerr9,zzerr10,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
673 }
674 }
675 }
676 zzcnt++; zzLOOP(zztasp3);
677 } while ( 1 );
678 zzEXIT(zztasp3);
679 }
680 }
681 }
682 else {
683 if ( (setwd3[LA(1)]&0x10)
684 ) {
685 }
686 else {zzFAIL(1,zzerr11,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
687 }
688 zzEXIT(zztasp2);
689 }
690 }
691
692 (*_root) = zztmake( zzmk_ast(zzastnew(),ALT), (*_root) , NULL);
693 (*_root)->file = file;
694 (*_root)->line = line;
695 zzEXIT(zztasp1);
696 return;
697 fail:
698 zzEXIT(zztasp1);
699 found_error=1;
700 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
701 zzresynch(setwd3, 0x20);
702 }
703 }
704
705 void
706 #ifdef __USE_PROTOS
707 element(AST**_root,int no_copy)
708 #else
709 element(_root,no_copy)
710 AST **_root;
711 int no_copy ;
712 #endif
713 {
714 zzRULE;
715 zzBLOCK(zztasp1);
716 zzMake0;
717 {
718 /**** SymEntry *p; **** MR10 ****/ int file,line; int local_no_copy=0;
719 if ( (LA(1)==Token) ) {
720 token(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
721 }
722 else {
723 if ( (LA(1)==NonTerm) ) {
724 file = CurFile; line=zzline;
725 zzmatch(NonTerm); zzsubroot(_root, &_sibling, &_tail); zzCONSUME;
726 {
727 zzBLOCK(zztasp2);
728 zzMake0;
729 {
730 if ( (LA(1)==84) ) {
731 zzmatch(84);
732 local_no_copy = 1;
733 zzCONSUME;
734
735 }
736 else {
737 if ( (setwd3[LA(1)]&0x40) ) {
738 }
739 else {zzFAIL(1,zzerr12,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
740 }
741 zzEXIT(zztasp2);
742 }
743 }
744 {
745 zzBLOCK(zztasp2);
746 zzMake0;
747 {
748 if ( (setwd3[LA(1)]&0x80)
749 ) {
750 {
751 zzBLOCK(zztasp3);
752 zzMake0;
753 {
754 if ( (LA(1)==85) ) {
755 zzmatch(85); zzCONSUME;
756 }
757 else {
758 if ( (LA(1)==PassAction) ) {
759 }
760 else {zzFAIL(1,zzerr13,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
761 }
762 zzEXIT(zztasp3);
763 }
764 }
765 zzmatch(PassAction); zzsubchild(_root, &_sibling, &_tail);
766 (*_root)->in = 1;
767 zzCONSUME;
768
769 }
770 else {
771 if ( (setwd4[LA(1)]&0x1) ) {
772 }
773 else {zzFAIL(1,zzerr14,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
774 }
775 zzEXIT(zztasp2);
776 }
777 }
778 {
779 zzBLOCK(zztasp2);
780 zzMake0;
781 {
782 if ( (LA(1)==86) ) {
783 zzmatch(86); zzCONSUME;
784 zzmatch(PassAction); zzsubchild(_root, &_sibling, &_tail);
785 (*_root)->out = 1;
786 zzCONSUME;
787
788 }
789 else {
790 if ( (setwd4[LA(1)]&0x2)
791 ) {
792 }
793 else {zzFAIL(1,zzerr15,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
794 }
795 zzEXIT(zztasp2);
796 }
797 }
798 (*_root)->file = file; (*_root)->line=line;
799 (*_root)->no_copy = no_copy || local_no_copy;
800 }
801 else {
802 if ( (LA(1)==Action) ) {
803 file = CurFile; line=zzline;
804 zzmatch(Action); zzsubchild(_root, &_sibling, &_tail);
805 zzastArg(1)->action = actiondup(LATEXT(1));
806 zzCONSUME;
807
808 {
809 zzBLOCK(zztasp2);
810 zzMake0;
811 {
812 if ( (LA(1)==PRED_OP) ) {
813 zzmatch(PRED_OP); zzsubroot(_root, &_sibling, &_tail); zzCONSUME;
814 }
815 else {
816 if ( (setwd4[LA(1)]&0x4) ) {
817 }
818 else {zzFAIL(1,zzerr16,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
819 }
820 zzEXIT(zztasp2);
821 }
822 }
823 (*_root)->file = file; (*_root)->line=line;
824 }
825 else {
826 if ( (LA(1)==89) ) {
827 file = CurFile; line=zzline;
828 zzmatch(89); zzCONSUME;
829 block(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
830 zzmatch(90); zzCONSUME;
831 {
832 zzBLOCK(zztasp2);
833 zzMake0;
834 {
835 if ( (LA(1)==CLOSURE)
836 ) {
837 zzmatch(CLOSURE); zzsubroot(_root, &_sibling, &_tail); zzCONSUME;
838 }
839 else {
840 if ( (LA(1)==POS_CLOSURE) ) {
841 zzmatch(POS_CLOSURE); zzsubroot(_root, &_sibling, &_tail); zzCONSUME;
842 }
843 else {
844 if ( (LA(1)==PRED_OP) ) {
845 zzmatch(PRED_OP); zzsubroot(_root, &_sibling, &_tail);
846 found_guess_block=1;
847 zzCONSUME;
848
849 }
850 else {
851 if ( (setwd4[LA(1)]&0x8) ) {
852 }
853 else {zzFAIL(1,zzerr17,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
854 }
855 }
856 }
857 zzEXIT(zztasp2);
858 }
859 }
860 (*_root)->file = file; (*_root)->line=line;
861 }
862 else {
863 if ( (LA(1)==OPT) ) {
864 zzmatch(OPT); zzsubroot(_root, &_sibling, &_tail); zzCONSUME;
865 block(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
866 zzmatch(80); zzCONSUME;
867 }
868 else {
869 if ( (LA(1)==WILD)
870 ) {
871 file = CurFile; line=zzline;
872 zzmatch(WILD); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
873 {
874 zzBLOCK(zztasp2);
875 zzMake0;
876 {
877 if ( (LA(1)==84) ) {
878 zzmatch(84);
879 local_no_copy = 1;
880 zzCONSUME;
881
882 }
883 else {
884 if ( (setwd4[LA(1)]&0x10) ) {
885 }
886 else {zzFAIL(1,zzerr18,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
887 }
888 zzEXIT(zztasp2);
889 }
890 }
891 (*_root)->no_copy = no_copy || local_no_copy;
892 (*_root)->file = file; (*_root)->line=line;
893 }
894 else {zzFAIL(1,zzerr19,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
895 }
896 }
897 }
898 }
899 }
900 zzEXIT(zztasp1);
901 return;
902 fail:
903 zzEXIT(zztasp1);
904 found_error=1;
905 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
906 zzresynch(setwd4, 0x20);
907 }
908 }
909
910 void
911 #ifdef __USE_PROTOS
912 labeled_element(AST**_root,int no_copy)
913 #else
914 labeled_element(_root,no_copy)
915 AST **_root;
916 int no_copy ;
917 #endif
918 {
919 zzRULE;
920 zzBLOCK(zztasp1);
921 zzMake0;
922 {
923 Attrib label; int file,line; SymEntry *s; int local_no_copy=0;
924 {
925 zzBLOCK(zztasp2);
926 zzMake0;
927 {
928 if ( (LA(1)==Token) ) {
929 zzmatch(Token);
930 label = zzaArg(zztasp2,1);
931 zzCONSUME;
932
933 }
934 else {
935 if ( (LA(1)==NonTerm) ) {
936 zzmatch(NonTerm);
937 label = zzaArg(zztasp2,1);
938 zzCONSUME;
939
940 }
941 else {zzFAIL(1,zzerr20,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
942 }
943 zzEXIT(zztasp2);
944 }
945 }
946
947 s = (SymEntry *) hash_get(symbols, label.text);
948 if ( s==NULL ) {
949 s = (SymEntry *) hash_add(symbols, label.text, (Entry *) newSymEntry(label.text));
950 s->token = LABEL;
951 }
952 else if ( s->token!=LABEL ) {
953 err(eMsg2("label definition clashes with %s definition: '%s'", zztokens[s->token], label.text));
954 }
955 zzmatch(LABEL); zzCONSUME;
956 {
957 zzBLOCK(zztasp2);
958 zzMake0;
959 {
960 file = CurFile; line=zzline;
961 if ( (LA(1)==Token)
962 ) {
963 token(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
964 strcpy(zzastArg(1)->label, label.text);
965 (*_root)->file = file; (*_root)->line=line;
966 }
967 else {
968 if ( (LA(1)==NonTerm) ) {
969 file = CurFile; line=zzline;
970 zzmatch(NonTerm); zzsubroot(_root, &_sibling, &_tail);
971 strcpy(zzastArg(1)->label, label.text);
972 zzCONSUME;
973
974 {
975 zzBLOCK(zztasp3);
976 zzMake0;
977 {
978 if ( (LA(1)==84) ) {
979 zzmatch(84);
980 local_no_copy = 1;
981 zzCONSUME;
982
983 }
984 else {
985 if ( (setwd4[LA(1)]&0x40) ) {
986 }
987 else {zzFAIL(1,zzerr21,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
988 }
989 zzEXIT(zztasp3);
990 }
991 }
992 {
993 zzBLOCK(zztasp3);
994 zzMake0;
995 {
996 if ( (setwd4[LA(1)]&0x80) ) {
997 {
998 zzBLOCK(zztasp4);
999 zzMake0;
1000 {
1001 if ( (LA(1)==85)
1002 ) {
1003 zzmatch(85); zzCONSUME;
1004 }
1005 else {
1006 if ( (LA(1)==PassAction) ) {
1007 }
1008 else {zzFAIL(1,zzerr22,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1009 }
1010 zzEXIT(zztasp4);
1011 }
1012 }
1013 zzmatch(PassAction); zzsubchild(_root, &_sibling, &_tail);
1014 (*_root)->in = 1;
1015 zzCONSUME;
1016
1017 }
1018 else {
1019 if ( (setwd5[LA(1)]&0x1) ) {
1020 }
1021 else {zzFAIL(1,zzerr23,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1022 }
1023 zzEXIT(zztasp3);
1024 }
1025 }
1026 {
1027 zzBLOCK(zztasp3);
1028 zzMake0;
1029 {
1030 if ( (LA(1)==86) ) {
1031 zzmatch(86); zzCONSUME;
1032 zzmatch(PassAction); zzsubchild(_root, &_sibling, &_tail);
1033 (*_root)->out = 1;
1034 zzCONSUME;
1035
1036 }
1037 else {
1038 if ( (setwd5[LA(1)]&0x2) ) {
1039 }
1040 else {zzFAIL(1,zzerr24,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1041 }
1042 zzEXIT(zztasp3);
1043 }
1044 }
1045 (*_root)->file = file; (*_root)->line=line;
1046 (*_root)->no_copy = no_copy || local_no_copy;
1047 }
1048 else {
1049 if ( (LA(1)==WILD)
1050 ) {
1051 file = CurFile; line=zzline;
1052 zzmatch(WILD); zzsubchild(_root, &_sibling, &_tail);
1053 strcpy(zzastArg(1)->label, label.text);
1054 zzCONSUME;
1055
1056 {
1057 zzBLOCK(zztasp3);
1058 zzMake0;
1059 {
1060 if ( (LA(1)==84) ) {
1061 zzmatch(84);
1062 local_no_copy = 1;
1063 zzCONSUME;
1064
1065 }
1066 else {
1067 if ( (setwd5[LA(1)]&0x4) ) {
1068 }
1069 else {zzFAIL(1,zzerr25,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1070 }
1071 zzEXIT(zztasp3);
1072 }
1073 }
1074 (*_root)->no_copy = no_copy || local_no_copy;
1075 (*_root)->file = file; (*_root)->line=line;
1076 }
1077 else {
1078 if ( (setwd5[LA(1)]&0x8) ) {
1079 {
1080 zzBLOCK(zztasp3);
1081 zzMake0;
1082 {
1083 if ( (LA(1)==88) ) {
1084 zzmatch(88); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1085 }
1086 else {
1087 if ( (LA(1)==87)
1088 ) {
1089 zzmatch(87); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1090 }
1091 else {
1092 if ( (LA(1)==PassAction) ) {
1093 zzmatch(PassAction); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1094 }
1095 else {
1096 if ( (LA(1)==Action) ) {
1097 zzmatch(Action); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1098 }
1099 else {
1100 if ( (LA(1)==Eof) ) {
1101 zzmatch(Eof); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1102 }
1103 else {
1104 if ( (LA(1)==89) ) {
1105 zzmatch(89); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1106 }
1107 else {
1108 if ( (LA(1)==OPT)
1109 ) {
1110 zzmatch(OPT); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1111 }
1112 else {
1113 if ( (LA(1)==90) ) {
1114 zzmatch(90); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1115 }
1116 else {
1117 if ( (LA(1)==80) ) {
1118 zzmatch(80); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1119 }
1120 else {
1121 if ( (LA(1)==BT) ) {
1122 zzmatch(BT); zzsubchild(_root, &_sibling, &_tail); zzCONSUME;
1123 }
1124 else {zzFAIL(1,zzerr26,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1125 }
1126 }
1127 }
1128 }
1129 }
1130 }
1131 }
1132 }
1133 }
1134 zzEXIT(zztasp3);
1135 }
1136 }
1137
1138 err("cannot label this grammar construct");
1139 found_error = 1;
1140 }
1141 else {zzFAIL(1,zzerr27,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1142 }
1143 }
1144 }
1145 zzEXIT(zztasp2);
1146 }
1147 }
1148 zzEXIT(zztasp1);
1149 return;
1150 fail:
1151 zzEXIT(zztasp1);
1152 found_error=1;
1153 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1154 zzresynch(setwd5, 0x10);
1155 }
1156 }
1157
1158 void
1159 #ifdef __USE_PROTOS
1160 token(AST**_root,int no_copy)
1161 #else
1162 token(_root,no_copy)
1163 AST **_root;
1164 int no_copy ;
1165 #endif
1166 {
1167 zzRULE;
1168 zzBLOCK(zztasp1);
1169 zzMake0;
1170 {
1171 SymEntry *p; int file, line; int local_no_copy=0;
1172 file = CurFile; line=zzline;
1173 zzmatch(Token); zzsubchild(_root, &_sibling, &_tail);
1174 (*_root)->file = file; (*_root)->line=line;
1175 zzCONSUME;
1176
1177 define_token(zzaArg(zztasp1,1 ).text);
1178 {
1179 zzBLOCK(zztasp2);
1180 zzMake0;
1181 {
1182 if ( (LA(1)==91) ) {
1183 zzmatch(91); zzCONSUME;
1184 zzmatch(Token); zzCONSUME;
1185 {
1186 zzBLOCK(zztasp3);
1187 zzMake0;
1188 {
1189 if ( (LA(1)==84)
1190 ) {
1191 zzmatch(84);
1192 local_no_copy=1;
1193 zzCONSUME;
1194
1195 }
1196 else {
1197 if ( (setwd5[LA(1)]&0x20) ) {
1198 }
1199 else {zzFAIL(1,zzerr28,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1200 }
1201 zzEXIT(zztasp3);
1202 }
1203 }
1204
1205 if ( !UserDefdTokens ) {
1206 err("range operator is illegal without #tokdefs directive");
1207 }
1208 else {
1209 p = define_token(zzaArg(zztasp2,2 ).text);
1210 require(p!=NULL, "token: hash table is broken");
1211 (*_root)->upper_range = p->token_type;
1212 }
1213 }
1214 else {
1215 if ( (LA(1)==84) ) {
1216 zzmatch(84);
1217 local_no_copy=1;
1218 zzCONSUME;
1219
1220 }
1221 else {
1222 if ( (setwd5[LA(1)]&0x40) ) {
1223 }
1224 else {zzFAIL(1,zzerr29,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1225 }
1226 }
1227 zzEXIT(zztasp2);
1228 }
1229 }
1230 (*_root)->no_copy = no_copy||local_no_copy;
1231 zzEXIT(zztasp1);
1232 return;
1233 fail:
1234 zzEXIT(zztasp1);
1235 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1236 zzresynch(setwd5, 0x80);
1237 }
1238 }
1239
1240 void
1241 #ifdef __USE_PROTOS
1242 tree(AST**_root,int no_copy)
1243 #else
1244 tree(_root,no_copy)
1245 AST **_root;
1246 int no_copy ;
1247 #endif
1248 {
1249 zzRULE;
1250 zzBLOCK(zztasp1);
1251 zzMake0;
1252 {
1253 Attrib label; SymEntry *p, *s; int local_no_copy=0; AST *t=NULL;
1254 zzmatch(BT); zzCONSUME;
1255 {
1256 zzBLOCK(zztasp2);
1257 zzMake0;
1258 {
1259 if ( (LA(1)==Token) && (setwd6[LA(2)]&0x1) ) {
1260 zzmatch(Token); zzsubroot(_root, &_sibling, &_tail);
1261 t=zzastArg(1);
1262 zzCONSUME;
1263
1264 define_token(zzaArg(zztasp2,1 ).text);
1265 {
1266 zzBLOCK(zztasp3);
1267 zzMake0;
1268 {
1269 if ( (LA(1)==91)
1270 ) {
1271 zzmatch(91); zzCONSUME;
1272 zzmatch(Token); zzCONSUME;
1273 {
1274 zzBLOCK(zztasp4);
1275 zzMake0;
1276 {
1277 if ( (LA(1)==84) ) {
1278 zzmatch(84);
1279 local_no_copy=1;
1280 zzCONSUME;
1281
1282 }
1283 else {
1284 if ( (setwd6[LA(1)]&0x2) ) {
1285 }
1286 else {zzFAIL(1,zzerr30,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1287 }
1288 zzEXIT(zztasp4);
1289 }
1290 }
1291
1292 if ( !UserDefdTokens ) {
1293 err("range operator is illegal without #tokdefs directive");
1294 }
1295 else {
1296 p = define_token(zzaArg(zztasp3,2 ).text);
1297 require(p!=NULL, "element: hash table is broken");
1298 t->upper_range = p->token_type;
1299 }
1300 }
1301 else {
1302 if ( (LA(1)==84) ) {
1303 zzmatch(84);
1304 local_no_copy=1;
1305 zzCONSUME;
1306
1307 }
1308 else {
1309 if ( (setwd6[LA(1)]&0x4) ) {
1310 }
1311 else {zzFAIL(1,zzerr31,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1312 }
1313 }
1314 zzEXIT(zztasp3);
1315 }
1316 }
1317 t->no_copy = no_copy||local_no_copy; t->is_root = 1;
1318 }
1319 else {
1320 if ( (LA(1)==WILD)
1321 ) {
1322 zzmatch(WILD); zzsubroot(_root, &_sibling, &_tail); zzCONSUME;
1323 {
1324 zzBLOCK(zztasp3);
1325 zzMake0;
1326 {
1327 if ( (LA(1)==84) ) {
1328 zzmatch(84);
1329 local_no_copy = 1;
1330 zzCONSUME;
1331
1332 }
1333 else {
1334 if ( (setwd6[LA(1)]&0x8) ) {
1335 }
1336 else {zzFAIL(1,zzerr32,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1337 }
1338 zzEXIT(zztasp3);
1339 }
1340 }
1341 zzastArg(1)->no_copy = no_copy || local_no_copy; zzastArg(1)->is_root = 1;
1342 }
1343 else {
1344 if ( (setwd6[LA(1)]&0x10) && (LA(2)==LABEL) ) {
1345 {
1346 zzBLOCK(zztasp3);
1347 zzMake0;
1348 {
1349 if ( (LA(1)==Token) ) {
1350 zzmatch(Token);
1351 label = zzaArg(zztasp3,1);
1352 zzCONSUME;
1353
1354 }
1355 else {
1356 if ( (LA(1)==NonTerm)
1357 ) {
1358 zzmatch(NonTerm);
1359 label = zzaArg(zztasp3,1);
1360 zzCONSUME;
1361
1362 }
1363 else {zzFAIL(1,zzerr33,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1364 }
1365 zzEXIT(zztasp3);
1366 }
1367 }
1368
1369 s = (SymEntry *) hash_get(symbols, label.text);
1370 if ( s==NULL ) {
1371 s = (SymEntry *) hash_add(symbols, label.text, (Entry *) newSymEntry(label.text));
1372 s->token = LABEL;
1373 }
1374 else if ( s->token!=LABEL ) {
1375 err(eMsg2("label definition clashes with %s definition: '%s'", zztokens[s->token], label.text));
1376 }
1377 zzmatch(LABEL); zzCONSUME;
1378 {
1379 zzBLOCK(zztasp3);
1380 zzMake0;
1381 {
1382 if ( (LA(1)==Token) ) {
1383 zzmatch(Token); zzsubroot(_root, &_sibling, &_tail);
1384 strcpy(zzastArg(1)->label, label.text); t = zzastArg(1);
1385 zzCONSUME;
1386
1387 define_token(zzaArg(zztasp3,1 ).text);
1388 {
1389 zzBLOCK(zztasp4);
1390 zzMake0;
1391 {
1392 if ( (LA(1)==91) ) {
1393 zzmatch(91); zzCONSUME;
1394 zzmatch(Token); zzCONSUME;
1395 {
1396 zzBLOCK(zztasp5);
1397 zzMake0;
1398 {
1399 if ( (LA(1)==84) ) {
1400 zzmatch(84);
1401 local_no_copy=1;
1402 zzCONSUME;
1403
1404 }
1405 else {
1406 if ( (setwd6[LA(1)]&0x20) ) {
1407 }
1408 else {zzFAIL(1,zzerr34,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1409 }
1410 zzEXIT(zztasp5);
1411 }
1412 }
1413
1414 if ( !UserDefdTokens ) {
1415 err("range operator is illegal without #tokdefs directive");
1416 }
1417 else {
1418 p = define_token(zzaArg(zztasp4,2 ).text);
1419 require(p!=NULL, "element: hash table is broken");
1420 t->upper_range = p->token_type;
1421 }
1422 }
1423 else {
1424 if ( (LA(1)==84)
1425 ) {
1426 zzmatch(84);
1427 local_no_copy=1;
1428 zzCONSUME;
1429
1430 }
1431 else {
1432 if ( (setwd6[LA(1)]&0x40) ) {
1433 }
1434 else {zzFAIL(1,zzerr35,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1435 }
1436 }
1437 zzEXIT(zztasp4);
1438 }
1439 }
1440 t->no_copy = no_copy||local_no_copy;
1441 }
1442 else {
1443 if ( (LA(1)==WILD) ) {
1444 zzmatch(WILD); zzsubroot(_root, &_sibling, &_tail);
1445 strcpy(zzastArg(1)->label, label.text);
1446 zzCONSUME;
1447
1448 {
1449 zzBLOCK(zztasp4);
1450 zzMake0;
1451 {
1452 if ( (LA(1)==84) ) {
1453 zzmatch(84);
1454 local_no_copy = 1;
1455 zzCONSUME;
1456
1457 }
1458 else {
1459 if ( (setwd6[LA(1)]&0x80) ) {
1460 }
1461 else {zzFAIL(1,zzerr36,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1462 }
1463 zzEXIT(zztasp4);
1464 }
1465 }
1466 zzastArg(1)->no_copy = no_copy || local_no_copy;
1467 }
1468 else {zzFAIL(1,zzerr37,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1469 }
1470 zzEXIT(zztasp3);
1471 }
1472 }
1473 t->is_root = 1;
1474 }
1475 else {zzFAIL(2,zzerr38,zzerr39,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1476 }
1477 }
1478 zzEXIT(zztasp2);
1479 }
1480 }
1481 {
1482 zzBLOCK(zztasp2);
1483 zzMake0;
1484 {
1485 for (;;) {
1486 if ( !((setwd7[LA(1)]&0x1)
1487 )) break;
1488 if ( (setwd7[LA(1)]&0x2) && (LA(2)==LABEL) ) {
1489 labeled_element(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
1490 }
1491 else {
1492 if ( (setwd7[LA(1)]&0x4) && (setwd7[LA(2)]&0x8) ) {
1493 element(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
1494 }
1495 else {
1496 if ( (LA(1)==BT) ) {
1497 tree(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
1498 }
1499 else break; /* MR6 code for exiting loop "for sure" */
1500 }
1501 }
1502 zzLOOP(zztasp2);
1503 }
1504 zzEXIT(zztasp2);
1505 }
1506 }
1507 zzmatch(90); zzCONSUME;
1508 zzEXIT(zztasp1);
1509 return;
1510 fail:
1511 zzEXIT(zztasp1);
1512 found_error=1;
1513 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1514 zzresynch(setwd7, 0x10);
1515 }
1516 }
1517
1518 void
1519 #ifdef __USE_PROTOS
1520 enum_file(AST**_root)
1521 #else
1522 enum_file(_root)
1523 AST **_root;
1524 #endif
1525 {
1526 zzRULE;
1527 zzBLOCK(zztasp1);
1528 zzMake0;
1529 {
1530 SymEntry *p=NULL;
1531 if ( (setwd7[LA(1)]&0x20) ) {
1532 {
1533 zzBLOCK(zztasp2);
1534 zzMake0;
1535 {
1536 if ( (LA(1)==103)
1537 ) {
1538 zzmatch(103); zzastDPush; zzCONSUME;
1539 zzmatch(ID); zzastDPush; zzCONSUME;
1540 {
1541 zzBLOCK(zztasp3);
1542 zzMake0;
1543 {
1544 if ( (LA(1)==106) ) {
1545 zzmatch(106); zzastDPush; zzCONSUME;
1546 zzmatch(ID); zzastDPush; zzCONSUME;
1547 }
1548 else {
1549 if ( (LA(1)==110) ) {
1550 }
1551 else {zzFAIL(1,zzerr40,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1552 }
1553 zzEXIT(zztasp3);
1554 }
1555 }
1556 }
1557 else {
1558 if ( (LA(1)==110) ) {
1559 }
1560 else {zzFAIL(1,zzerr41,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1561 }
1562 zzEXIT(zztasp2);
1563 }
1564 }
1565 {
1566 zzBLOCK(zztasp2);
1567 int zzcnt=1;
1568 zzMake0;
1569 {
1570 do {
1571 _ast = NULL; enum_def(&_ast);
1572 zzLOOP(zztasp2);
1573 } while ( (LA(1)==110) );
1574 zzEXIT(zztasp2);
1575 }
1576 }
1577 }
1578 else {
1579 if ( (LA(1)==106)
1580 ) {
1581 _ast = NULL; defines(&_ast);
1582 }
1583 else {
1584 if ( (LA(1)==Eof) ) {
1585 }
1586 else {zzFAIL(1,zzerr42,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1587 }
1588 }
1589 zzEXIT(zztasp1);
1590 return;
1591 fail:
1592 zzEXIT(zztasp1);
1593 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1594 zzresynch(setwd7, 0x40);
1595 }
1596 }
1597
1598 void
1599 #ifdef __USE_PROTOS
1600 defines(AST**_root)
1601 #else
1602 defines(_root)
1603 AST **_root;
1604 #endif
1605 {
1606 zzRULE;
1607 zzBLOCK(zztasp1);
1608 zzMake0;
1609 {
1610 int maxt= -1; /**** char *t; **** MR10 ****/ SymEntry *p; int ignore=0;
1611 {
1612 zzBLOCK(zztasp2);
1613 int zzcnt=1;
1614 zzMake0;
1615 {
1616 do {
1617 zzmatch(106); zzastDPush; zzCONSUME;
1618 zzmatch(ID); zzastDPush;
1619
1620 p = (SymEntry *) hash_get(symbols, zzaArg(zztasp2,2 ).text);
1621 if ( p==NULL ) {
1622 p = (SymEntry *) hash_add(symbols, zzaArg(zztasp2,2 ).text,
1623 (Entry *) newSymEntry(zzaArg(zztasp2,2 ).text));
1624 require(p!=NULL, "can't add to sym tab");
1625 p->token = Token;
1626 list_add(&token_list, (void *)p);
1627 set_orel(p->token_type, &referenced_tokens);
1628 }
1629 else
1630 {
1631 err(eMsg1("redefinition of token %s; ignored",zzaArg(zztasp2,2 ).text));
1632 ignore = 1;
1633 }
1634 zzCONSUME;
1635
1636 zzmatch(INT); zzastDPush;
1637
1638 if ( !ignore ) {
1639 p->token_type = atoi(zzaArg(zztasp2,3 ).text);
1640 token_association(p->token_type, p->str);
1641 /* fprintf(stderr, "#token %s=%d\n", p->str, p->token_type);*/
1642 if ( p->token_type>maxt ) maxt=p->token_type;
1643 ignore = 0;
1644 }
1645 zzCONSUME;
1646
1647 zzLOOP(zztasp2);
1648 } while ( (LA(1)==106) );
1649 zzEXIT(zztasp2);
1650 }
1651 }
1652 token_type = maxt + 1;
1653 zzEXIT(zztasp1);
1654 return;
1655 fail:
1656 zzEXIT(zztasp1);
1657 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1658 zzresynch(setwd7, 0x80);
1659 }
1660 }
1661
1662 void
1663 #ifdef __USE_PROTOS
1664 enum_def(AST**_root)
1665 #else
1666 enum_def(_root)
1667 AST **_root;
1668 #endif
1669 {
1670 zzRULE;
1671 zzBLOCK(zztasp1);
1672 zzMake0;
1673 {
1674 int maxt = -1, v= -1; /**** char *t; **** MR10 ****/ SymEntry *p; int ignore=0;
1675 zzmatch(110); zzastDPush; zzCONSUME;
1676 {
1677 zzBLOCK(zztasp2);
1678 zzMake0;
1679 {
1680 if ( (LA(1)==ID) ) {
1681 zzmatch(ID); zzastDPush; zzCONSUME;
1682 }
1683 else {
1684 if ( (LA(1)==111) ) {
1685 }
1686 else {zzFAIL(1,zzerr43,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1687 }
1688 zzEXIT(zztasp2);
1689 }
1690 }
1691 zzmatch(111); zzastDPush; zzCONSUME;
1692 zzmatch(ID); zzastDPush;
1693
1694 p = (SymEntry *) hash_get(symbols, zzaArg(zztasp1,4 ).text);
1695 if ( p==NULL ) {
1696 p = (SymEntry *) hash_add(symbols, zzaArg(zztasp1,4 ).text,
1697 (Entry *) newSymEntry(zzaArg(zztasp1,4 ).text));
1698 require(p!=NULL, "can't add to sym tab");
1699 p->token = Token;
1700 list_add(&token_list, (void *)p);
1701 set_orel(p->token_type, &referenced_tokens);
1702 }
1703 else
1704 {
1705 err(eMsg1("redefinition of token %s; ignored",zzaArg(zztasp1,4 ).text));
1706 ignore = 1;
1707 }
1708 zzCONSUME;
1709
1710 {
1711 zzBLOCK(zztasp2);
1712 zzMake0;
1713 {
1714 if ( (LA(1)==112)
1715 ) {
1716 zzmatch(112); zzastDPush; zzCONSUME;
1717 zzmatch(INT); zzastDPush;
1718 v=atoi(zzaArg(zztasp2,2 ).text);
1719 zzCONSUME;
1720
1721 }
1722 else {
1723 if ( (setwd8[LA(1)]&0x1) ) {
1724 v++;
1725 }
1726 else {zzFAIL(1,zzerr44,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1727 }
1728 zzEXIT(zztasp2);
1729 }
1730 }
1731
1732 if ( !ignore ) {
1733 /* fprintf(stderr, "#token %s=%d\n", p->str, v);*/
1734 if ( v>maxt ) maxt=v;
1735 p->token_type = v;
1736 token_association(p->token_type, p->str);
1737 ignore = 0;
1738 }
1739 {
1740 zzBLOCK(zztasp2);
1741 zzMake0;
1742 {
1743 while ( (LA(1)==113) ) {
1744 zzmatch(113); zzastDPush; zzCONSUME;
1745 {
1746 zzBLOCK(zztasp3);
1747 zzMake0;
1748 {
1749 if ( (LA(1)==114) ) {
1750 zzmatch(114); zzastDPush; zzCONSUME;
1751 {
1752 zzBLOCK(zztasp4);
1753 zzMake0;
1754 {
1755 if ( (LA(1)==112) ) {
1756 zzmatch(112); zzastDPush; zzCONSUME;
1757 zzmatch(INT); zzastDPush; zzCONSUME;
1758 }
1759 else {
1760 if ( (setwd8[LA(1)]&0x2)
1761 ) {
1762 }
1763 else {zzFAIL(1,zzerr45,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1764 }
1765 zzEXIT(zztasp4);
1766 }
1767 }
1768 }
1769 else {
1770 if ( (LA(1)==115) ) {
1771 zzmatch(115); zzastDPush; zzCONSUME;
1772 {
1773 zzBLOCK(zztasp4);
1774 zzMake0;
1775 {
1776 if ( (LA(1)==112) ) {
1777 zzmatch(112); zzastDPush; zzCONSUME;
1778 zzmatch(INT); zzastDPush; zzCONSUME;
1779 }
1780 else {
1781 if ( (setwd8[LA(1)]&0x4) ) {
1782 }
1783 else {zzFAIL(1,zzerr46,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1784 }
1785 zzEXIT(zztasp4);
1786 }
1787 }
1788 }
1789 else {
1790 if ( (LA(1)==ID) ) {
1791 zzmatch(ID); zzastDPush;
1792
1793 p = (SymEntry *) hash_get(symbols, zzaArg(zztasp3,1 ).text);
1794 if ( p==NULL ) {
1795 p = (SymEntry *) hash_add(symbols, zzaArg(zztasp3,1 ).text,
1796 (Entry *) newSymEntry(zzaArg(zztasp3,1 ).text));
1797 require(p!=NULL, "can't add to sym tab");
1798 p->token = Token;
1799 list_add(&token_list, (void *)p);
1800 set_orel(p->token_type, &referenced_tokens);
1801 }
1802 else
1803 {
1804 err(eMsg1("redefinition of token %s; ignored",zzaArg(zztasp3,1 ).text));
1805 ignore = 1;
1806 }
1807 zzCONSUME;
1808
1809 {
1810 zzBLOCK(zztasp4);
1811 zzMake0;
1812 {
1813 if ( (LA(1)==112)
1814 ) {
1815 zzmatch(112); zzastDPush; zzCONSUME;
1816 zzmatch(INT); zzastDPush;
1817 v=atoi(zzaArg(zztasp4,2 ).text);
1818 zzCONSUME;
1819
1820 }
1821 else {
1822 if ( (setwd8[LA(1)]&0x8) ) {
1823 v++;
1824 }
1825 else {zzFAIL(1,zzerr47,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1826 }
1827 zzEXIT(zztasp4);
1828 }
1829 }
1830
1831 if ( !ignore ) {
1832 /* fprintf(stderr, "#token %s=%d\n", p->str, v);*/
1833 if ( v>maxt ) maxt=v;
1834 p->token_type = v;
1835 token_association(p->token_type, p->str);
1836 ignore = 0;
1837 }
1838 }
1839 else {
1840 if ( (setwd8[LA(1)]&0x10) ) {
1841 }
1842 else {zzFAIL(1,zzerr48,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1843 }
1844 }
1845 }
1846 zzEXIT(zztasp3);
1847 }
1848 }
1849 zzLOOP(zztasp2);
1850 }
1851 zzEXIT(zztasp2);
1852 }
1853 }
1854 zzmatch(116); zzastDPush; zzCONSUME;
1855 zzmatch(117); zzastDPush;
1856 token_type = maxt + 1;
1857 zzCONSUME;
1858
1859 zzEXIT(zztasp1);
1860 return;
1861 fail:
1862 zzEXIT(zztasp1);
1863 zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1864 zzresynch(setwd8, 0x20);
1865 }
1866 }
1867
1868 /* SORCERER-specific syntax error message generator
1869 * (define USER_ZZSYN when compiling so don't get 2 definitions)
1870 */
1871 void
1872 #ifdef __USE_PROTOS
1873 zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
1874 #else
1875 zzsyn(text, tok, egroup, eset, etok, k, bad_text)
1876 char *text, *egroup, *bad_text;
1877 int tok;
1878 int etok;
1879 int k;
1880 SetWordType *eset;
1881 #endif
1882 {
1883 fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);
1884 fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
1885 if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
1886 if ( k==1 ) fprintf(stderr, " missing");
1887 else
1888 {
1889 fprintf(stderr, "; \"%s\" not", bad_text);
1890 if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
1891 }
1892 if ( zzset_deg(eset)>0 ) zzedecode(eset);
1893 else fprintf(stderr, " %s", zztokens[etok]);
1894 if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);
1895 fprintf(stderr, "\n");
1896 }
1897
1898 SymEntry *
1899 #ifdef __USE_PROTOS
1900 define_token(char *text)
1901 #else
1902 define_token(text)
1903 char *text;
1904 #endif
1905 {
1906 SymEntry *p;
1907
1908 p = (SymEntry *) hash_get(symbols, text);
1909 if ( p==NULL ) {
1910 if ( UserDefdTokens ) {
1911 err(eMsg1("implicit token definition of '%s' not allowed with #tokdefs",text));
1912 }
1913 p = (SymEntry *) hash_add(symbols, text, (Entry *) newSymEntry(text));
1914 p->token = Token;
1915 p->token_type = token_type++;
1916 token_association(p->token_type, p->str);
1917 list_add(&token_list, (void *)p);
1918 set_orel(p->token_type, &referenced_tokens);
1919 }
1920 else {
1921 if ( p->token!=Token )
1922 err(eMsg2("token definition clashes with %s definition: '%s'", zztokens[p->token], text));
1923 }
1924 return p;
1925 }
+0
-1030
contrib/pccts/sorcerer/sor.g less more
0 /*
1 * SORCERER Version 1.00B
2 *
3 * Terence Parr
4 * U of MN, AHPCRC
5 * April 1995
6 */
7
8 #header <<
9 /* 23-Sep-97 thm Accomodate user who needs to redefine ZZLEXBUFSIZE */
10
11 #ifndef ZZLEXBUFSIZE
12 #define ZZLEXBUFSIZE 8000
13 #endif
14 #include "pcctscfg.h" /* MR20 G. Hobbelt __USE_PROTOS #define */
15 #include "charbuf.h"
16 #include "hash.h"
17 #include "set.h"
18 #include "sor.h"
19 #define AST_FIELDS \
20 int token; char text[MaxAtom+1], label[MaxRuleName+1]; \
21 char *action; /* if action node, here is ptr to it */ \
22 char in,out; \
23 char init_action; /* set if Action and 1st action of alt */ \
24 int file; int line; /* set for BLOCK, ALT, nonterm nodes */ \
25 int upper_range; /* only if T1..T2 found */ \
26 GLA *start_state; /* ptr into GLA for this block */ \
27 int no_copy; /* copy input ptr to output ptr? */ \
28 ListNode *refvars; /* any ref vars defined for this rule */ \
29 unsigned char is_root; /* this token is a root #( A ... ) */
30 #define zzcr_ast(node, cur, _tok, _text) \
31 {(node)->token=_tok; strncpy((node)->text, _text,MaxAtom);}
32 #define USER_ZZSYN
33 #define zzAST_DOUBLE
34 extern int define_num;
35 >>
36
37 <<
38 /* MR20 G. Hobbelt Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled */
39 #if defined(__TURBOC__)
40 #pragma warn -aus /* unused assignment of 'xxx' */
41 #endif
42
43
44 #include "sym.h"
45 #include "proto.h"
46 >>
47
48 #lexaction <<
49 #include "sym.h"
50 #include "proto.h"
51
52 int define_num = 0;
53
54 char *
55 #ifdef __USE_PROTOS
56 scarf_to_end_of_func_call(void)
57 #else
58 scarf_to_end_of_func_call()
59 #endif
60 {
61 static char func_call_str[MaxAtom+1];
62 char *p;
63
64 p = &func_call_str[0];
65
66 more:
67 if ( zzchar==')' ) { *p++ = zzchar; *p++ = '\0'; zzadvance(); return func_call_str; }
68 if ( zzchar=='"' )
69 {
70 *p++ = zzchar; zzadvance();
71 while ( zzchar!='"' )
72 {
73 if ( zzchar=='\\' ) { *p++ = zzchar; zzadvance(); }
74 *p++ = zzchar; zzadvance();
75 }
76 }
77 *p++ = zzchar; zzadvance();
78 goto more;
79 }
80 >>
81
82 <<
83 void /* MR9 23-Sep-97 Eliminate complaint about no return value */
84 #ifdef __USE_PROTOS
85 lisp( AST *tree, FILE *output )
86 #else
87 lisp( tree, output )
88 AST *tree;
89 FILE *output;
90 #endif
91 {
92 while ( tree != NULL )
93 {
94 if ( tree->down != NULL ) fprintf(output," (");
95 if ( tree->text[0]!='\0' ) {
96 fprintf(output, " \"");
97 if ( tree->label[0]!='\0' ) fprintf(output, "%s:", tree->label);
98 switch ( tree->token ) {
99 case OPT :
100 case POS_CLOSURE :
101 case CLOSURE :
102 case PRED_OP :
103 fprintf(output, "%s", tree->text);
104 break;
105 default :
106 fprintf(output, "%s[%s]", zztokens[tree->token], tree->text);
107 }
108 fprintf(output, "\"");
109 }
110 else {
111 fprintf(output, " %s", zztokens[tree->token]);
112 }
113 lisp(tree->down, output);
114 if ( tree->down != NULL ) fprintf(output," )");
115 tree = tree->right;
116 }
117 }
118
119 AST *
120 #ifdef __USE_PROTOS
121 zzmk_ast(AST *node, int token)
122 #else
123 zzmk_ast(node, token)
124 AST *node;
125 int token;
126 #endif
127 {
128 node->token = token;
129 return node;
130 }
131
132 AST *
133 #ifdef __USE_PROTOS
134 read_sor_desc(FILE *f)
135 #else
136 read_sor_desc(f)
137 FILE *f;
138 #endif
139 {
140 AST *root = NULL;
141
142 zzline = 1;
143 ANTLR(sordesc(&root), f);
144
145 if ( found_error ) return NULL;
146
147 if ( print_guts ) {
148 fprintf(stderr, "Internal Represenation of Tree Grammar:\n");
149 lisp(root, stderr);
150 fprintf(stderr, "\n");
151 }
152
153 last_valid_token = token_type;
154 end_of_input = token_type++;/* end of input token type is 1 + last real token */
155 epsilon = token_type++; /* epsilon token type is 2 + last real token */
156 wild_card = token_type++; /* wild_card_token is 3 + last real token */
157 token_association(end_of_input, "$");
158 token_association(epsilon, "[Ep]");
159 token_association(wild_card, ".");
160
161 zzdouble_link(root, NULL, NULL);
162 rules = root;
163 if ( root!=NULL ) build_GLA(root);
164
165 if ( print_guts ) {
166 fprintf(stderr, "Internal Represenation of Grammar Lookahead Automaton:\n");
167 dump_GLAs(root);
168 fprintf(stderr, "\n");
169 }
170 return root;
171 }
172 >>
173
174 #lexclass STRINGS
175 #token RExpr "\"" << zzmode(START); >>
176 #token "\n|\r|\r\n" << /* MR16a */
177 zzline++;
178 warn("eoln found in string");
179 zzskip();
180 >>
181 #token "\\~[]" << zzmore(); >>
182 #token "~[\n\r\"\\]+" << zzmore(); >> /* MR16a */
183
184 #lexclass ACTION_STRINGS
185 #token "\"" << zzmode(ACTIONS); zzmore(); >>
186 #token "\n|\r|\r\n" << /* MR16a */
187 zzline++;
188 warn("eoln found in string (in user action)");
189 zzskip();
190 >>
191 #token "\\~[]" << zzmore(); >>
192 #token "~[\n\r\"\\]+" << zzmore(); >> /* MR16a */
193
194 #lexclass ACTION_CHARS
195 #token "'" << zzmode(ACTIONS); zzmore(); >>
196 #token "\n|\r|\r\n" << /* MR16a */
197 zzline++;
198 warn("eoln found in char literal (in user action)");
199 zzskip();
200 >>
201 #token "\\~[]" << zzmore(); >>
202 #token "~[\n\r'\\]+" << zzmore(); >> /* MR16a */
203
204 #lexclass ACTION_COMMENTS
205 #token "\*/" << zzmode(ACTIONS); zzmore(); >>
206 #token "\*" << zzmore(); >>
207 #token "\n|\r|\r\n" << zzline++; zzmore(); >> /* MR16a */
208 #token "~[\n\r\*]+" << zzmore(); >> /* MR16a */
209
210 #lexclass ACTION_CPP_COMMENTS
211 #token "\n|\r|\r\n" << zzline++; zzmode(ACTIONS); zzmore(); >> /* MR16a */
212 #token "~[\n\r]+" << zzmore(); >> /* MR16a */
213
214 #lexclass CPP_COMMENTS
215 #token "\n|\r|\r\n" << zzline++; zzmode(START); zzskip(); >> /* MR16a */
216 #token "~[\n\r]+" << zzskip(); >> /* MR16a */
217
218 #lexclass COMMENTS
219 #token "\*/" << zzmode(START); zzskip(); >>
220 #token "\*" << zzskip(); >>
221 #token "\n|\r|\r\n" << zzline++; zzskip(); >> /* MR16a */
222 #token "~[\n\r\*]+" << zzskip(); >> /* MR16a */
223
224 #lexclass REFVAR_SCARF /* everything until a ')' */
225 #token "~[\)]+ \)" <<{
226 RefVarRec *rf;
227 zzskip();
228 zzbegexpr[strlen(zzbegexpr)-1] = '\0';
229 rf=refVarRec(zzbegexpr);
230 list_add(&AllRefVars, rf);
231 list_add(&RefVars, rf);
232 zzmode(ACTIONS); zzmore(); zzreplstr("");
233 }>>
234
235 /*
236 * This lexical class accepts actions of type [..] and <<..>>
237 *
238 * It translates the following special items:
239 *
240 * #[args] --> "ast_node(args)" add "classname::" for C++, however.
241 * #[] --> "ast_empty_node()"
242 * #( root, child1, ..., childn )
243 --> "ast_make(root, child1, ...., childn, NULL)"
244 * #() --> "NULL"
245 *
246 * Things for reference variables are also recognized:
247 * blah blah
248 *
249 * To escape,
250 *
251 * \] --> ]
252 * \) --> )
253 * \$ --> $
254 * \# --> #
255 *
256 * A stack is used to nest action terminators because they can be nested
257 * like crazy: << #[#[..],..] >>
258 */
259 #lexclass ACTIONS
260 #token Action "\>\>" << /* these do not nest */
261 zzmode(START);
262 NLATEXT[0] = ' ';
263 NLATEXT[1] = ' ';
264 zzbegexpr[0] = ' ';
265 zzbegexpr[1] = ' ';
266 if ( zzbufovf ) {
267 found_error = 1;
268 err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));
269 }
270 >>
271 #token PassAction "\]" << if ( topint() == ']' ) {
272 popint();
273 if ( istackempty() ) /* terminate action */
274 {
275 zzmode(START);
276 NLATEXT[0] = ' ';
277 zzbegexpr[0] = ' ';
278 if ( zzbufovf ) {
279 found_error = 1;
280 err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));
281 }
282 }
283 else {
284 /* terminate #[..] */
285 zzreplstr(")");
286 zzmore();
287 }
288 }
289 else if ( topint() == '|' ) { /* end of simple [...] */
290 popint();
291 zzmore();
292 }
293 else zzmore();
294 >>
295 #token "\n|\r|\r\n" << zzline++; zzmore(); >> /* MR16a */
296 #token "\>" << zzmore(); >>
297 #token "#[_a-zA-Z][_a-zA-Z0-9]*"
298 <<
299 if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||
300 strcmp(zzbegexpr, "#else")==0 ||
301 strcmp(zzbegexpr, "#endif")==0 ||
302 strcmp(zzbegexpr, "#ifndef")==0 ||
303 strcmp(zzbegexpr, "#if")==0 ||
304 strcmp(zzbegexpr, "#define")==0 ||
305 strcmp(zzbegexpr, "#pragma")==0 ||
306 strcmp(zzbegexpr, "#undef")==0 ||
307 strcmp(zzbegexpr, "#import")==0 ||
308 strcmp(zzbegexpr, "#line")==0 ||
309 strcmp(zzbegexpr, "#include")==0 ||
310 strcmp(zzbegexpr, "#error")==0) )
311 {
312 static char buf[100];
313 if ( !transform ) {
314 warn("#id used in nontransform mode; # ignored");
315 sprintf(buf, "%s", zzbegexpr+1);
316 }
317 else {
318 if ( CurRule==NULL )
319 {warn("#id used in action outside of rule; ignored");}
320 else if ( strcmp(zzbegexpr+1,CurRule)==0 )
321 strcpy(buf, "(*_result)");
322 }
323 zzreplstr(buf);
324 }
325 zzmore();
326 >>
327 #token "#\[\]" <<
328 if ( GenCPP ) zzreplstr("new SORAST");
329 else zzreplstr("ast_empty_node()");
330 zzmore();
331 >>
332 #token "#\(\)" << zzreplstr("NULL"); zzmore(); >>
333 #token "#\[" <<
334 pushint(']');
335 if ( GenCPP ) zzreplstr("new SORAST(");
336 else zzreplstr("ast_node(");
337 zzmore();
338 >>
339 #token "#\(" <<
340 pushint('}');
341 if ( GenCPP ) zzreplstr("PCCTS_AST::make(");
342 else zzreplstr("ast_make(");
343 zzmore();
344 >>
345 #token "#" << zzmore(); >>
346 #token "\)" <<
347 if ( istackempty() )
348 zzmore();
349 else if ( topint()==')' ) {
350 popint();
351 }
352 else if ( topint()=='}' ) {
353 popint();
354 /* terminate #(..) */
355 zzreplstr(", NULL)");
356 }
357 zzmore();
358 >>
359 #token "\[" <<
360 pushint('|'); /* look for '|' to terminate simple [...] */
361 zzmore();
362 >>
363 #token "\(" <<
364 pushint(')');
365 zzmore();
366 >>
367
368 #token "\\\]" << zzreplstr("]"); zzmore(); >>
369 #token "\\\)" << zzreplstr(")"); zzmore(); >>
370 #token "\\>" << zzreplstr(">"); zzmore(); >>
371
372
373 #token "'" << zzmode(ACTION_CHARS); zzmore();>>
374 #token "\"" << zzmode(ACTION_STRINGS); zzmore();>>
375 #token "\\#" << zzreplstr("#"); zzmore(); >>
376 /*#token "\\\\" << zzmore(); >> /* need this for some reason */
377 #token "\\~[\]\)>#]" << zzmore(); >> /* escaped char, always ignore */
378 #token "/" << zzmore(); >>
379 #token "/\*" << zzmode(ACTION_COMMENTS); zzmore(); >>
380 #token "\*/" << err("Missing /*; found dangling */ in action"); zzmore(); >>
381 #token "//" << zzmode(ACTION_CPP_COMMENTS); zzmore(); >>
382
383 #token "\@\(" <<zzmode(REFVAR_SCARF); zzmore(); zzreplstr("");>>
384
385 #token "\@" <<
386 zzmore(); if ( !GenCPP ) zzreplstr("_parser->");
387 >>
388
389 #token "[a-zA-Z_]+\(" <<
390 if ( (GenCPP && strcmp(zzbegexpr,"ast_scan(")==0) ||
391 (!GenCPP && strcmp(zzbegexpr,"ast_scan(")==0) ) {
392 char *args=scarf_to_end_of_func_call();
393 zzreplstr(cvt_token_str(zzbegexpr, args));
394 zzmore();
395 }
396 else { pushint(')'); zzmore(); }
397 >>
398 #token "[a-zA-Z_]+" << zzmore(); >>
399 #token "~[a-zA-Z_\n\r\)\(\\#\>\]\[\"'/\@]+" << zzmore(); >> /* MR16a */
400
401 #lexclass START
402 #token "[\t\ ]+" << zzskip(); >> /* Ignore White */
403 #token "\n|\r|\n\r" << zzline++; zzskip(); >> /* Track Line # */ /* MR16a */
404 #token "\[" << zzmode(ACTIONS); zzmore();
405 istackreset();
406 pushint(']'); >>
407 #token "\<\<" << action_file=CurFile; action_line=zzline;
408 zzmode(ACTIONS); zzmore();
409 istackreset();
410 pushint('>'); >>
411 #token "\"" << zzmode(STRINGS); zzmore(); >>
412 #token "/\*" << zzmode(COMMENTS); zzskip(); >>
413 #token "\*/" << err("Missing /*; found dangling */"); zzskip(); >>
414 #token "//" << zzmode(CPP_COMMENTS); zzskip(); >>
415 #token "\>\>" << err("Missing <<; found dangling \>\>"); zzskip(); >>
416 #token Eof "@"
417 << /* L o o k F o r A n o t h e r F i l e */
418 {
419 FILE *new_input;
420 new_input = NextFile();
421 if ( new_input != NULL ) {
422 fclose( input );
423 input = new_input;
424 zzrdstream( input );
425 /*zzadvance(); ** Get 1st char of this file */
426 zzskip(); /* Skip the Eof (@) char i.e continue */
427 }
428 }
429 >>
430
431 #token Header "#header"
432 #token Tokdef "#tokdefs"
433 #token BLOCK /* used only as place-holder in intermediate tree */
434 #token ALT /* used only as place-holder in intermediate tree */
435 #token LABEL ":" /* used only as place-holder in intermediate tree */
436 #token OPT "\{" /* These are labeled so we can ref them in trees */
437 #token POS_CLOSURE "\+"
438 #token CLOSURE "\*"
439 #token WILD "."
440 #token PRED_OP "?"
441 #token BT "#\("
442 #token RULE
443 #token REFVAR
444
445 #errclass "atomic-element" { WILD NonTerm Token }
446 #errclass "rule-header" { PassAction LABEL "\<" "\>" }
447
448 /*
449 * Build trees for a sorcerer description
450 */
451 sordesc
452 : <<int he=0,to=0;>>
453 ( header <<he++;>>
454 | tokdef <<to++;>>
455 )*
456 <<
457 if ( he==0 && !Inline && !GenCPP ) warnNoFL("missing #header statement");
458 if ( he>1 ) warnNoFL("extra #header statement");
459 if ( to>1 ) warnNoFL("extra #tokdef statement");
460 >>
461 ( Action!
462 <<list_add(&before_actions, actiondup(LATEXT(1)));>>
463 )*
464 { class_def }
465 ( Action!
466 <<
467 if ( CurClassName[0]!='\0' )
468 list_add(&class_actions, actiondup(LATEXT(1)));
469 else
470 list_add(&before_actions, actiondup(LATEXT(1)));
471 >>
472 )*
473 ( rule )*
474 ( Action!
475 <<
476 if ( CurClassName[0]!='\0' )
477 list_add(&class_actions, actiondup(LATEXT(1)));
478 else
479 list_add(&before_actions, actiondup(LATEXT(1)));
480 >>
481 )*
482 { "\}"! // end of class def
483 <<
484 if ( CurClassName[0]=='\0' )
485 err("missing class definition for trailing '}'");
486 >>
487 }
488 ( Action!
489 <<list_add(&after_actions, actiondup(LATEXT(1)));>>
490 )*
491 "@"!
492 ;
493 <<found_error=1;>>
494
495 header: "#header"! Action! <<header_action = actiondup(LATEXT(1));>>
496 ;
497 <<found_error=1;>>
498
499 tokdef: "#tokdefs"! RExpr!
500 <<{
501 AST *dumb = NULL;
502 zzantlr_state st; FILE *f; struct zzdlg_state dst;
503 strcpy(tokdefs_file, LATEXT(1));
504 strcpy(tokdefs_file, tokdefs_file+1); /* remove quotes */
505 tokdefs_file[strlen(tokdefs_file)-1] = '\0';
506 zzsave_antlr_state(&st);
507 zzsave_dlg_state(&dst);
508 define_num=0;
509 f = fopen(tokdefs_file, "r");
510 if ( f==NULL ) {found_error=1; err(eMsg1("cannot open token defs file '%s'", tokdefs_file));}
511 else {ANTLRm(enum_file(&dumb), f, PARSE_ENUM_FILE);}
512 zzrestore_antlr_state(&st);
513 zzrestore_dlg_state(&dst);
514 UserDefdTokens = 1;
515 }>>
516 ;
517 <<found_error=1;>>
518
519 class_def!
520 : "class"
521 ( NonTerm <<strncpy(CurClassName,LATEXT(1),MaxAtom);>>
522 | Token <<strncpy(CurClassName,LATEXT(1),MaxAtom);>>
523 )
524 <<if ( !GenCPP ) { err("class meta-op used without C++ option"); }>>
525 "\{"
526 ;
527
528 /*
529 * Create a rule tree:
530 *
531 * NonTerm[arg_action, ret_val_action]
532 * |
533 * v
534 * block
535 */
536 rule: <<SymEntry *p; int trouble=0, no_copy=0;>>
537 NonTerm^
538 <<
539 #0->file = CurFile;
540 #0->line = zzline;
541 CurRule = $1.text;
542 p = (SymEntry *) hash_get(symbols, $1.text);
543 if ( p==NULL ) {
544 p = (SymEntry *) hash_add(symbols, $1.text, (Entry *) newSymEntry($1.text));
545 p->token = NonTerm;
546 p->defined = 1;
547 p->definition = #0;
548 }
549 else if ( p->token != NonTerm ) {
550 err(eMsg2("rule definition clashes with %s definition: '%s'", zztokens[p->token], p->str));
551 trouble = 1;
552 }
553 else {
554 if ( p->defined ) {
555 trouble = 1;
556 err(eMsg1("rule multiply defined: '%s'", $1.text));
557 }
558 else {
559 p->defined = 1;
560 p->definition = #0;
561 }
562 }
563 >>
564 { "!"! <<if (!trouble) #0->no_copy=no_copy=1;>> }
565 ( { "\<"! } PassAction! <<if (!trouble) p->args = actiondup(LATEXT(1));>>
566 |
567 )
568 { "\>"! PassAction! <<if (!trouble) p->rt = actiondup(LATEXT(1));>>
569 }
570 ":"!
571 block[no_copy]
572 ";"!
573 <<
574 if ( !trouble ) #0->refvars = RefVars;
575 RefVars=NULL;
576 >>
577 <<
578 if ( trouble ) #0 = NULL;
579 CurRule = NULL;
580 >>
581 ;
582 <<found_error=1;>>
583
584 /* Create a tree for a block:
585 *
586 * BLOCK
587 * |
588 * v
589 * alt1 ---> alt2 ---> ... ---> altn
590 */
591 block[int no_copy]
592 : <<int line=zzline, file=CurFile;>>
593 alt[$no_copy]
594 ( "\|"! alt[$no_copy]
595 )*
596 <<
597 #0 = #( #[BLOCK], #0 );
598 #0->file = file;
599 #0->line = line;
600 >>
601 ;
602 <<found_error=1;>>
603
604 /* Create a tree for an alternative:
605 *
606 * ALT
607 * |
608 * v
609 * e1 ---> e2 ---> ... ---> en
610 */
611 alt[int no_copy]
612 : <<int line=zzline, file=CurFile; int local_no_copy=0;>>
613 { "!"! <<local_no_copy=1;>> }
614 {
615 ( labeled_element[$no_copy||local_no_copy]
616 | element[$no_copy||local_no_copy]
617 | tree[$no_copy||local_no_copy]
618 )+
619 }
620 <<
621 #0 = #( #[ALT], #0 );
622 #0->file = file;
623 #0->line = line;
624 >>
625 ;
626 <<found_error=1;>>
627
628 /* a rule ref looks like:
629 *
630 * NonTerm
631 * |
632 * v
633 * arg_action ---> ret_val_action
634 *
635 * Blocks that have a suffix look like this:
636 *
637 * OP
638 * |
639 * v
640 * block
641 *
642 * Optional blocks look like:
643 *
644 * OPT
645 * |
646 * v
647 * block
648 *
649 * Predicates are like actions except they have a root: #( PRED_OP Action )
650 */
651 element[int no_copy]
652 : <</**** SymEntry *p; **** MR10 ****/ int file,line; int local_no_copy=0;>>
653 token[$no_copy]
654 | <<file = CurFile; line=zzline;>>
655 NonTerm^
656 { "!"! <<local_no_copy = 1;>> }
657 { { "\<"! } PassAction <<#0->in = 1;>> }
658 { "\>"! PassAction <<#0->out = 1;>> }
659 <<#0->file = file; #0->line=line;>>
660 <<#0->no_copy = $no_copy || local_no_copy;>>
661 | <<file = CurFile; line=zzline;>>
662 Action <<#1->action = actiondup(LATEXT(1));>>
663 { "?"^ } <<#0->file = file; #0->line=line;>>
664 | <<file = CurFile; line=zzline;>>
665 "\("! block[$no_copy] "\)"!
666 ( "\*"^
667 | "\+"^
668 | "?"^ <<found_guess_block=1;>>
669 |
670 )
671 <<#0->file = file; #0->line=line;>>
672 | "\{"^ block[$no_copy] "\}"!
673 | <<file = CurFile; line=zzline;>>
674 "."
675 { "!"! <<local_no_copy = 1;>> }
676 <<#0->no_copy = $no_copy || local_no_copy;>>
677 <<#0->file = file; #0->line=line;>>
678 ;
679 <<found_error=1;>>
680
681 /* labels on an element look like: #( LABEL element ) */
682 labeled_element[int no_copy]
683 : <<Attrib label; int file,line; SymEntry *s; int local_no_copy=0;>>
684 ( Token! <<label = $1;>>
685 | NonTerm! <<label = $1;>>
686 )
687 <<
688 s = (SymEntry *) hash_get(symbols, label.text);
689 if ( s==NULL ) {
690 s = (SymEntry *) hash_add(symbols, label.text, (Entry *) newSymEntry(label.text));
691 s->token = LABEL;
692 }
693 else if ( s->token!=LABEL ) {
694 err(eMsg2("label definition clashes with %s definition: '%s'", zztokens[s->token], label.text));
695 }
696 >>
697 ":"!
698 ( <<file = CurFile; line=zzline;>>
699 token[$no_copy] <<strcpy(#1->label, label.text);>>
700 <<#0->file = file; #0->line=line;>>
701 | <<file = CurFile; line=zzline;>>
702 NonTerm^ <<strcpy(#1->label, label.text);>>
703 { "!"! <<local_no_copy = 1;>> }
704 { { "\<"! } PassAction <<#0->in = 1;>> }
705 { "\>"! PassAction <<#0->out = 1;>> }
706 <<#0->file = file; #0->line=line;>>
707 <<#0->no_copy = $no_copy || local_no_copy;>>
708 | <<file = CurFile; line=zzline;>>
709 "." <<strcpy(#1->label, label.text);>>
710 { "!"! <<local_no_copy = 1;>> }
711 <<#0->no_copy = $no_copy || local_no_copy;>>
712 <<#0->file = file; #0->line=line;>>
713 | ("\|" | ";" | PassAction | Action | Eof | "\(" | "\{" | "\)" | "\}" | "#\(")
714 <<
715 err("cannot label this grammar construct");
716 found_error = 1;
717 >>
718 )
719 ;
720 <<found_error=1;>>
721
722 token[int no_copy]
723 : <<SymEntry *p; int file, line; int local_no_copy=0;>>
724 <<file = CurFile; line=zzline;>>
725 Token
726 <<#0->file = file; #0->line=line;>>
727 <<define_token($1.text);>>
728 { ".."! Token!
729 { "!"! <<local_no_copy=1;>>}
730 <<
731 if ( !UserDefdTokens ) {
732 err("range operator is illegal without #tokdefs directive");
733 }
734 else {
735 p = define_token($2.text);
736 require(p!=NULL, "token: hash table is broken");
737 #0->upper_range = p->token_type;
738 }
739 >>
740 | "!"! <<local_no_copy=1;>>
741 }
742 <<#0->no_copy = $no_copy||local_no_copy;>>
743 ;
744
745 /* A tree description looks like:
746 *
747 * BT
748 * |
749 * v
750 * root ---> sibling1 ---> ... ---> siblingn
751 */
752 tree[int no_copy]
753 : <<Attrib label; SymEntry *p, *s; int local_no_copy=0; AST *t=NULL;>>
754 "#\("!
755 ( Token^ <<t=#1;>>
756 <<define_token($1.text);>>
757 { ".."! Token! /* inline rather than 'token' because must be root */
758 { "!"! <<local_no_copy=1;>>}
759 <<
760 if ( !UserDefdTokens ) {
761 err("range operator is illegal without #tokdefs directive");
762 }
763 else {
764 p = define_token($2.text);
765 require(p!=NULL, "element: hash table is broken");
766 t->upper_range = p->token_type;
767 }
768 >>
769 | "!"! <<local_no_copy=1;>>
770 }
771 <<t->no_copy = $no_copy||local_no_copy; t->is_root = 1;>>
772 | "."^
773 { "!"! <<local_no_copy = 1;>> }
774 <<#1->no_copy = $no_copy || local_no_copy; #1->is_root = 1;>>
775 | ( Token! <<label = $1;>>
776 | NonTerm! <<label = $1;>>
777 )
778 <<
779 s = (SymEntry *) hash_get(symbols, label.text);
780 if ( s==NULL ) {
781 s = (SymEntry *) hash_add(symbols, label.text, (Entry *) newSymEntry(label.text));
782 s->token = LABEL;
783 }
784 else if ( s->token!=LABEL ) {
785 err(eMsg2("label definition clashes with %s definition: '%s'", zztokens[s->token], label.text));
786 }
787 >>
788 ":"!
789 ( Token^ <<strcpy(#1->label, label.text); t = #1;>>
790 <<define_token($1.text);>>
791 { ".."! Token! /* inline rather than 'token' because must be root */
792 { "!"! <<local_no_copy=1;>>}
793 <<
794 if ( !UserDefdTokens ) {
795 err("range operator is illegal without #tokdefs directive");
796 }
797 else {
798 p = define_token($2.text);
799 require(p!=NULL, "element: hash table is broken");
800 t->upper_range = p->token_type;
801 }
802 >>
803 | "!"! <<local_no_copy=1;>>
804 }
805 <<t->no_copy = $no_copy||local_no_copy;>>
806 | "."^ <<strcpy(#1->label, label.text);>>
807 { "!"! <<local_no_copy = 1;>> }
808 <<#1->no_copy = $no_copy || local_no_copy;>>
809 )
810 <<t->is_root = 1;>>
811 )
812 ( labeled_element[$no_copy] | element[$no_copy] | tree[$no_copy] )*
813 "\)"!
814 ;
815 <<found_error=1;>>
816
817 #token NonTerm "[a-z] [A-Za-z0-9_]*"
818 #token Token "[A-Z] [A-Za-z0-9_]*"
819 #token "#[A-Za-z0-9_]*" <<warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip(); >>
820
821 /* # t o k d e f s s t u f f */
822
823 #lexclass TOK_DEF_COMMENTS
824 #token "\*/" << zzmode(PARSE_ENUM_FILE); zzmore(); >>
825 #token "\*" << zzmore(); >>
826 #token "\n|\r|\r\n" << zzline++; zzmore(); >> /* MR16a */
827 #token "~[\n\r\*]+" << zzmore(); >> /* MR16a */
828
829 #lexclass TOK_DEF_CPP_COMMENTS
830 #token "\n|\r|\r\n" << zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); >> /* MR16a */
831 #token "~[\n\r]+" << zzskip(); >> /* MR16a */
832
833 #lexclass PARSE_ENUM_FILE
834
835 #token "[\t\ ]+" << zzskip(); >> /* Ignore White */
836 #token "\n|\r|\r\n" << zzline++; zzskip(); >> /* Track Line # */ /* MR16a */
837 #token "//" << zzmode(TOK_DEF_CPP_COMMENTS); zzmore(); >>
838 #token "/\*" << zzmode(TOK_DEF_COMMENTS); zzmore(); >>
839 #token "#ifndef" << >>
840 #token "#ifdef" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
841 #token "#else" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
842 #token "#define" <<
843 >>
844 #token "#endif" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>
845 #token "@" << /*zzmode(START); zzskip();*/ >>
846
847 enum_file!
848 : <<SymEntry *p=NULL;>>
849 { "#ifndef" ID
850 { "#define" ID /* ignore if it smells like a gate */
851 /* First #define after the first #ifndef (if any) is ignored */
852 }
853 }
854 ( enum_def )+
855 | defines
856 |
857 ;
858
859 defines!
860 : <<int maxt= -1; /**** char *t; **** MR10 ****/ SymEntry *p; int ignore=0;>>
861 (
862 "#define" ID
863 <<
864 p = (SymEntry *) hash_get(symbols, $2.text);
865 if ( p==NULL ) {
866 p = (SymEntry *) hash_add(symbols, $2.text,
867 (Entry *) newSymEntry($2.text));
868 require(p!=NULL, "can't add to sym tab");
869 p->token = Token;
870 list_add(&token_list, (void *)p);
871 set_orel(p->token_type, &referenced_tokens);
872 }
873 else
874 {
875 err(eMsg1("redefinition of token %s; ignored",$2.text));
876 ignore = 1;
877 }
878 >>
879 INT
880 <<
881 if ( !ignore ) {
882 p->token_type = atoi($3.text);
883 token_association(p->token_type, p->str);
884 /* fprintf(stderr, "#token %s=%d\n", p->str, p->token_type);*/
885 if ( p->token_type>maxt ) maxt=p->token_type;
886 ignore = 0;
887 }
888 >>
889 )+
890 <<token_type = maxt + 1;>> /* record max defined token */
891 ;
892
893 enum_def!
894 : <<int maxt = -1, v= -1; /**** char *t; **** MR10 ****/ SymEntry *p; int ignore=0;>>
895 "enum" {ID}
896 "\{"
897 ID
898 <<
899 p = (SymEntry *) hash_get(symbols, $4.text);
900 if ( p==NULL ) {
901 p = (SymEntry *) hash_add(symbols, $4.text,
902 (Entry *) newSymEntry($4.text));
903 require(p!=NULL, "can't add to sym tab");
904 p->token = Token;
905 list_add(&token_list, (void *)p);
906 set_orel(p->token_type, &referenced_tokens);
907 }
908 else
909 {
910 err(eMsg1("redefinition of token %s; ignored",$4.text));
911 ignore = 1;
912 }
913 >>
914 ( "=" INT <<v=atoi($2.text);>>
915 | <<v++;>>
916 )
917 <<
918 if ( !ignore ) {
919 /* fprintf(stderr, "#token %s=%d\n", p->str, v);*/
920 if ( v>maxt ) maxt=v;
921 p->token_type = v;
922 token_association(p->token_type, p->str);
923 ignore = 0;
924 }
925 >>
926 ( ","
927 { "DLGminToken" { "=" INT } /* 1.33MR6 compatibility */
928 | "DLGmaxToken" { "=" INT } /* 1.33MR6 compatibility */
929 | ID
930 <<
931 p = (SymEntry *) hash_get(symbols, $1.text);
932 if ( p==NULL ) {
933 p = (SymEntry *) hash_add(symbols, $1.text,
934 (Entry *) newSymEntry($1.text));
935 require(p!=NULL, "can't add to sym tab");
936 p->token = Token;
937 list_add(&token_list, (void *)p);
938 set_orel(p->token_type, &referenced_tokens);
939 }
940 else
941 {
942 err(eMsg1("redefinition of token %s; ignored",$1.text));
943 ignore = 1;
944 }
945 >>
946 ( "=" INT <<v=atoi($2.text);>>
947 | <<v++;>>
948 )
949 <<
950 if ( !ignore ) {
951 /* fprintf(stderr, "#token %s=%d\n", p->str, v);*/
952 if ( v>maxt ) maxt=v;
953 p->token_type = v;
954 token_association(p->token_type, p->str);
955 ignore = 0;
956 }
957 >>
958 }
959 )*
960 "\}"
961 ";"
962 <<token_type = maxt + 1;>> /* record max defined token */
963 ;
964
965 #token INT "[0-9]+"
966 #token ID "[a-zA-Z_][_a-zA-Z0-9]*"
967
968 #lexclass START
969
970 <<
971 /* SORCERER-specific syntax error message generator
972 * (define USER_ZZSYN when compiling so don't get 2 definitions)
973 */
974 void
975 #ifdef __USE_PROTOS
976 zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
977 #else
978 zzsyn(text, tok, egroup, eset, etok, k, bad_text)
979 char *text, *egroup, *bad_text;
980 int tok;
981 int etok;
982 int k;
983 SetWordType *eset;
984 #endif
985 {
986 fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);
987 fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
988 if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
989 if ( k==1 ) fprintf(stderr, " missing");
990 else
991 {
992 fprintf(stderr, "; \"%s\" not", bad_text);
993 if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
994 }
995 if ( zzset_deg(eset)>0 ) zzedecode(eset);
996 else fprintf(stderr, " %s", zztokens[etok]);
997 if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);
998 fprintf(stderr, "\n");
999 }
1000
1001 SymEntry *
1002 #ifdef __USE_PROTOS
1003 define_token(char *text)
1004 #else
1005 define_token(text)
1006 char *text;
1007 #endif
1008 {
1009 SymEntry *p;
1010
1011 p = (SymEntry *) hash_get(symbols, text);
1012 if ( p==NULL ) {
1013 if ( UserDefdTokens ) {
1014 err(eMsg1("implicit token definition of '%s' not allowed with #tokdefs",text));
1015 }
1016 p = (SymEntry *) hash_add(symbols, text, (Entry *) newSymEntry(text));
1017 p->token = Token;
1018 p->token_type = token_type++;
1019 token_association(p->token_type, p->str);
1020 list_add(&token_list, (void *)p);
1021 set_orel(p->token_type, &referenced_tokens);
1022 }
1023 else {
1024 if ( p->token!=Token )
1025 err(eMsg2("token definition clashes with %s definition: '%s'", zztokens[p->token], text));
1026 }
1027 return p;
1028 }
1029 >>
+0
-124
contrib/pccts/sorcerer/sor.h less more
0 /*
1 * sor.h
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-2001
27 */
28
29 #include "pcctscfg.h"
30
31 #define MaxNumFiles 20
32
33 /**** MR9 JVincent@novell.com Move to pcctscfg.h */
34 /**** #define MaxFileName 300 ****/ /* MR9 */ /* largest file name size */
35
36 #define MaxRuleName 100 /* largest rule name size */
37 #define MaxAtom 300
38
39 #define fatal(err) fatalFL(err, __FILE__, __LINE__)
40 #define warnNoFL(err) fprintf(stderr, "warning: %s\n", err);
41 #define warnFL(err,f,l) \
42 {fprintf(stderr, ErrHdr, f, l); \
43 fprintf(stderr, " warning: %s\n", err);}
44 #define warn(err) \
45 {fprintf(stderr, ErrHdr, FileStr[CurFile], zzline); \
46 fprintf(stderr, " warning: %s\n", err);}
47 #define warnNoCR( err ) \
48 {fprintf(stderr, ErrHdr, FileStr[CurFile], zzline); \
49 fprintf(stderr, " warning: %s", err);}
50 #define errNoFL(err) {found_error=1; fprintf(stderr, "error: %s\n", err);}
51 #define errFL(err,f,l) \
52 {found_error=1; fprintf(stderr, ErrHdr, f, l); \
53 fprintf(stderr, " error: %s\n", err);}
54 #define err(err) \
55 {found_error=1; fprintf(stderr, ErrHdr, FileStr[CurFile], zzline); \
56 fprintf(stderr, " error: %s\n", err);}
57 #define errNoCR( err ) \
58 {found_error=1; fprintf(stderr, ErrHdr, FileStr[CurFile], zzline); \
59 fprintf(stderr, " error: %s", err);}
60 #define eMsg1(s,a) eMsg3(s,a,NULL,NULL)
61 #define eMsg2(s,a,b) eMsg3(s,a,b,NULL)
62
63
64 #if 0
65
66 /* Removed in 1.33MR19
67 Don't understand why this never caused problems before
68 */
69
70 /********************************************************
71 #ifndef ANTLRm
72 #define ANTLRm(st, f, _m) zzbufsize = ZZLEXBUFSIZE; \
73 zzmode(_m); \
74 zzenterANTLR(f); \
75 st; ++zzasp; \
76 zzleaveANTLR(f);
77 #endif
78 ********************************************************/
79
80 #endif
81 /* L i s t N o d e s */
82
83 typedef struct _ListNode {
84 void *elem; /* pointer to any kind of element */
85 struct _ListNode *next;
86 } ListNode;
87
88 typedef struct {
89 char *token;
90 int tnum;
91 } TokenDef;
92
93 typedef struct {
94 char decl[MaxAtom+1];
95 char var[MaxAtom+1];
96 char init[MaxAtom+1];
97 int global;
98 } RefVarRec;
99
100 #define newListNode (ListNode *) calloc(1, sizeof(ListNode));
101 #define newTokenDef (TokenDef *) calloc(1, sizeof(TokenDef));
102
103 /* Grammar Lookahead Automata (GLA) S t u f f */
104
105 typedef struct _nfa {
106 struct _nfa *p1, *p2;
107 int label1, label2;
108 struct _nfa *next; /* used only following rule ref and blkstart nodes
109 * of (...)+ to detect what follows the loop. */
110 set lookahead;
111 char visited;
112 char is_rule_ref,
113 is_rule_entry;
114 char *in_rule; /* which rule am I in */
115 int upper_range; /* used for range operator; this will be non-zero */
116 } GLA;
117
118
119 /* S a n i t y C h e c k i n g */
120
121 #ifndef require
122 #define require(expr, err) {if ( !(expr) ) fatal(err);}
123 #endif
+0
-275
contrib/pccts/sorcerer/sor.r less more
0 #include "cmdo.r"
1
2 resource 'cmdo' (128, "Sourcerer") {
3 { /* array dialogs: 2 elements */
4 /* [1] */
5 295,
6 "Sorcerer -- Purdue Compiler Construction"
7 " Tool Set (PCCTS) simple tree-parser gen"
8 "erator.",
9 { /* array itemArray: 7 elements */
10 /* [1] */
11 NotDependent {
12
13 },
14 CheckOption {
15 NotSet,
16 {18, 23, 33, 223},
17 "Read grammar from stdin",
18 "-",
19 "Read grammar from stdin."
20 },
21 /* [2] */
22 NotDependent {
23
24 },
25 MultiFiles {
26 "Grammar File(s)É",
27 "Choose the grammar specification files y"
28 "ou wish to have Sorcerer process.",
29 {79, 22, 98, 152},
30 "Grammar specification:",
31 "",
32 MultiInputFiles {
33 { /* array MultiTypesArray: 1 elements */
34 /* [1] */
35 text
36 },
37 ".g",
38 "Files ending in .g",
39 "All text files"
40 }
41 },
42 /* [3] */
43 NotDependent {
44
45 },
46 Files {
47 DirOnly,
48 OptionalFile {
49 {58, 168, 74, 298},
50 {79, 169, 98, 299},
51 "Output Directory",
52 ":",
53 "-out-dir",
54 "",
55 "Choose the directory where SORCERER will"
56 " put its output.",
57 dim,
58 "Output Directory…",
59 "",
60 ""
61 },
62 NoMore {
63
64 }
65 },
66 /* [4] */
67 NotDependent {
68
69 },
70 Redirection {
71 StandardOutput,
72 {126, 27}
73 },
74 /* [5] */
75 NotDependent {
76
77 },
78 Redirection {
79 DiagnosticOutput,
80 {126, 178}
81 },
82 /* [6] */
83 NotDependent {
84
85 },
86 TextBox {
87 gray,
88 {117, 20, 167, 300},
89 "Redirection"
90 },
91 /* [7] */
92 NotDependent {
93
94 },
95 NestedDialog {
96 2,
97 {20, 324, 40, 460},
98 "Options…",
99 "Other options may be set with this butto"
100 "n."
101 }
102 },
103 /* [2] */
104 295,
105 "Use this dialog to specify command line "
106 "Generate Options.",
107 { /* array itemArray: 10 elements */
108 /* [1] */
109 NotDependent {
110
111 },
112 CheckOption {
113 NotSet,
114 {18, 25, 33, 225},
115 "Generate C++ code",
116 "-CPP",
117 "Turn on C++ output mode. You must define"
118 " a class around your grammar rules. An \""
119 ".h\" and \".c\" file are created for the cl"
120 "ass definition as well as the normal \".c"
121 "\" file for the parser your grammar rules"
122 "."
123 },
124 /* [2] */
125 Or {
126 { /* array OrArray: 1 elements */
127 /* [1] */
128 1
129 }
130 },
131 CheckOption {
132 NotSet,
133 {39, 25, 54, 354},
134 "Define referenced tokens in class defini"
135 "tion file",
136 "-def-tokens",
137 "For each token referenced in the grammar"
138 ", generate an enum STokenType definition"
139 " in the class definition file. This shou"
140 "ld not be used with the #tokedefs direct"
141 "ive, which specifies token types you've "
142 "already defined."
143 },
144 /* [3] */
145 Or {
146 { /* array OrArray: 1 elements */
147 /* [1] */
148 -1
149 }
150 },
151 RegularEntry {
152 "Define referenced tokens in:",
153 {63, 25, 78, 208},
154 {63, 220, 79, 291},
155 "",
156 keepCase,
157 "-def-tokens-file",
158 "For each token referenced in the grammar"
159 ", generate a #define in the specified fi"
160 "le This should not be used with the #tok"
161 "defs directive, which specifies token t"
162 "ypes you've already defined."
163 },
164 /* [4] */
165 Or {
166 { /* array OrArray: 1 elements */
167 /* [1] */
168 -1
169 }
170 },
171 RadioButtons {
172 { /* array radioArray: 3 elements */
173 /* [1] */
174 {37, 374, 52, 434}, "ANSI", "-funcs ANSI", Set, "When this option is selected, SORCERER w"
175 "ill generate ANSI style function headers"
176 " and prototypes.",
177 /* [2] */
178 {55, 374, 70, 434}, "K&R", "-funcs KR", NotSet, "When this option is selected, SORCERER w"
179 "ill generate K&R style function headers "
180 "and prototypes.",
181 /* [3] */
182 {73, 374, 88, 434}, "Both", "-funcs both", NotSet, "When this option is selected, SORCERER w"
183 "ill generate both ANSI and K&R style fun"
184 "ction headers and prototypes."
185 }
186 },
187 /* [5] */
188 NotDependent {
189
190 },
191 TextBox {
192 gray,
193 {29, 359, 101, 450},
194 "Style"
195 },
196 /* [6] */
197 NotDependent {
198
199 },
200 CheckOption {
201 NotSet,
202 {90, 25, 105, 229},
203 "Print out internal data structure",
204 "-guts",
205 "Print out a bunch of interna data struct"
206 "ures."
207 },
208 /* [7] */
209 NotDependent {
210
211 },
212 CheckOption {
213 NotSet,
214 {113, 25, 128, 226},
215 "Transformation mode",
216 "-transform",
217 "Assume that a tree transformation will t"
218 "ake place."
219 },
220 /* [8] */
221 NotDependent {
222
223 },
224 CheckOption {
225 NotSet,
226 {137, 25, 152, 238},
227 "Don't generate header info.. ",
228 "-inline",
229 "Only generate actions and functions for "
230 "the given rules. Do not generate header "
231 "information in the output. The usefulnes"
232 "s of this options for anything but docum"
233 "entation has not been established."
234 },
235 /* [9] */
236 Or {
237 { /* array OrArray: 1 elements */
238 /* [1] */
239 -1
240 }
241 },
242 RegularEntry {
243 "Prefix:",
244 {163, 25, 177, 83},
245 {163, 98, 179, 193},
246 " ",
247 keepCase,
248 "-prefix",
249 "Prefix all globally visible symbols with"
250 " this, including the error routines. Act"
251 "ions that call rules must prefix the fun"
252 "ction with this as well. "
253 },
254 /* [10] */
255 Or {
256 { /* array OrArray: 1 elements */
257 /* [1] */
258 -1
259 }
260 },
261 RegularEntry {
262 "Proto file:",
263 {163, 228, 178, 309},
264 {163, 318, 179, 413},
265 " ",
266 keepCase,
267 "-proto-file",
268 "Put all prototypes for rule functions in"
269 " this file. "
270 }
271 }
272 }
273 };
274
+0
-94
contrib/pccts/sorcerer/sor68K.make less more
0 # File: sor68K.make
1 # Target: sor68K
2 # Sources: cpp.c
3 # err.c
4 # gen.c
5 # globals.c
6 # hash.c
7 # look.c
8 # main.c
9 # scan.c
10 # sor.c
11 # ::support:set:set.c
12 # Created: Monday, May 18, 1998 12:20:50 AM
13 # Author: Kenji Tanaka
14
15
16 MAKEFILE = sor68K.make
17 ¥MondoBuild¥ = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified
18 Includes = ¶
19 -i "::h:" ¶
20 -i "::support:set:"
21 Sym¥68K =
22 ObjDir¥68K = :Obj:
23
24 COptions = {Includes} {Sym¥68K} -w off -model far -mc68020 -d __STDC__ -d MPW -d USER_ZZSYN
25
26 Objects¥68K = ¶
27 "{ObjDir¥68K}cpp.c.o" ¶
28 "{ObjDir¥68K}err.c.o" ¶
29 "{ObjDir¥68K}gen.c.o" ¶
30 "{ObjDir¥68K}globals.c.o" ¶
31 "{ObjDir¥68K}hash.c.o" ¶
32 "{ObjDir¥68K}look.c.o" ¶
33 "{ObjDir¥68K}main.c.o" ¶
34 "{ObjDir¥68K}scan.c.o" ¶
35 "{ObjDir¥68K}sor.c.o" ¶
36 "{ObjDir¥68K}set.c.o"
37
38
39 sor68K ÄÄ {¥MondoBuild¥} {Objects¥68K}
40 Link ¶
41 -o {Targ} -d {Sym¥68K} ¶
42 {Objects¥68K} ¶
43 -t 'MPST' ¶
44 -c 'MPS ' ¶
45 -mf ¶
46 -model far ¶
47 -br ON ¶
48 -srtsg ALL ¶
49 "{Libraries}Stubs.o" ¶
50 #"{Libraries}MathLib.o" ¶
51 #"{CLibraries}Complex.o" ¶
52 "{CLibraries}StdCLib.o" ¶
53 "{Libraries}MacRuntime.o" ¶
54 "{Libraries}IntEnv.o" ¶
55 #"{Libraries}ToolLibs.o" ¶
56 "{Libraries}Interface.o"
57
58
59 "{ObjDir¥68K}cpp.c.o" Ä {¥MondoBuild¥} cpp.c
60 {C} cpp.c -o {Targ} {COptions}
61
62 "{ObjDir¥68K}err.c.o" Ä {¥MondoBuild¥} err.c
63 {C} err.c -o {Targ} {COptions}
64
65 "{ObjDir¥68K}gen.c.o" Ä {¥MondoBuild¥} gen.c
66 {C} gen.c -o {Targ} {COptions}
67
68 "{ObjDir¥68K}globals.c.o" Ä {¥MondoBuild¥} globals.c
69 {C} globals.c -o {Targ} {COptions}
70
71 "{ObjDir¥68K}hash.c.o" Ä {¥MondoBuild¥} hash.c
72 {C} hash.c -o {Targ} {COptions}
73
74 "{ObjDir¥68K}look.c.o" Ä {¥MondoBuild¥} look.c
75 {C} look.c -o {Targ} {COptions}
76
77 "{ObjDir¥68K}main.c.o" Ä {¥MondoBuild¥} main.c
78 {C} main.c -o {Targ} {COptions}
79
80 "{ObjDir¥68K}scan.c.o" Ä {¥MondoBuild¥} scan.c
81 {C} scan.c -o {Targ} {COptions}
82
83 "{ObjDir¥68K}sor.c.o" Ä {¥MondoBuild¥} sor.c
84 {C} sor.c -o {Targ} {COptions}
85
86 "{ObjDir¥68K}set.c.o" Ä {¥MondoBuild¥} "::support:set:set.c"
87 {C} "::support:set:set.c" -o {Targ} {COptions}
88
89 sor68K ДД sor.r
90 Rez sor.r -o sor68K -a
91
92 Install Ä sor68K
93 Duplicate -y sor68K "{MPW}"Tools:sor
+0
-87
contrib/pccts/sorcerer/sorPPC.make less more
0 # File: sorPPC.make
1 # Target: sorPPC
2 # Sources: cpp.c
3 # err.c
4 # gen.c
5 # globals.c
6 # hash.c
7 # look.c
8 # main.c
9 # scan.c
10 # sor.c
11 # ::support:set:set.c
12 # Created: Monday, May 18, 1998 12:20:50 AM
13 # Author: Kenji Tanaka
14
15
16 MAKEFILE = sorPPC.make
17 ¥MondoBuild¥ = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified
18 Includes = ¶
19 -i "::h:" ¶
20 -i "::support:set:"
21 Sym¥PPC =
22 ObjDir¥PPC = :Obj:
23
24 PPCCOptions = {Includes} {Sym¥PPC} -w off -d __STDC__ -d MPW -d USER_ZZSYN
25
26 Objects¥PPC = ¶
27 "{ObjDir¥PPC}cpp.c.x" ¶
28 "{ObjDir¥PPC}err.c.x" ¶
29 "{ObjDir¥PPC}gen.c.x" ¶
30 "{ObjDir¥PPC}globals.c.x" ¶
31 "{ObjDir¥PPC}hash.c.x" ¶
32 "{ObjDir¥PPC}look.c.x" ¶
33 "{ObjDir¥PPC}main.c.x" ¶
34 "{ObjDir¥PPC}scan.c.x" ¶
35 "{ObjDir¥PPC}sor.c.x" ¶
36 "{ObjDir¥PPC}set.c.x"
37
38 sorPPC ÄÄ {¥MondoBuild¥} {Objects¥PPC}
39 PPCLink ¶
40 -o {Targ} {Sym¥PPC} ¶
41 {Objects¥PPC} ¶
42 -t 'MPST' ¶
43 -c 'MPS ' ¶
44 "{SharedLibraries}InterfaceLib" ¶
45 "{SharedLibraries}StdCLib" ¶
46 "{SharedLibraries}MathLib" ¶
47 "{PPCLibraries}StdCRuntime.o" ¶
48 "{PPCLibraries}PPCCRuntime.o" ¶
49 "{PPCLibraries}PPCToolLibs.o"
50
51 "{ObjDir¥PPC}cpp.c.x" Ä {¥MondoBuild¥} cpp.c
52 {PPCC} cpp.c -o {Targ} {PPCCOptions}
53
54 "{ObjDir¥PPC}err.c.x" Ä {¥MondoBuild¥} err.c
55 {PPCC} err.c -o {Targ} {PPCCOptions}
56
57 "{ObjDir¥PPC}gen.c.x" Ä {¥MondoBuild¥} gen.c
58 {PPCC} gen.c -o {Targ} {PPCCOptions}
59
60 "{ObjDir¥PPC}globals.c.x" Ä {¥MondoBuild¥} globals.c
61 {PPCC} globals.c -o {Targ} {PPCCOptions}
62
63 "{ObjDir¥PPC}hash.c.x" Ä {¥MondoBuild¥} hash.c
64 {PPCC} hash.c -o {Targ} {PPCCOptions}
65
66 "{ObjDir¥PPC}look.c.x" Ä {¥MondoBuild¥} look.c
67 {PPCC} look.c -o {Targ} {PPCCOptions}
68
69 "{ObjDir¥PPC}main.c.x" Ä {¥MondoBuild¥} main.c
70 {PPCC} main.c -o {Targ} {PPCCOptions}
71
72 "{ObjDir¥PPC}scan.c.x" Ä {¥MondoBuild¥} scan.c
73 {PPCC} scan.c -o {Targ} {PPCCOptions}
74
75 "{ObjDir¥PPC}sor.c.x" Ä {¥MondoBuild¥} sor.c
76 {PPCC} sor.c -o {Targ} {PPCCOptions}
77
78 "{ObjDir¥PPC}set.c.x" Ä {¥MondoBuild¥} "::support:set:set.c"
79 {PPCC} "::support:set:set.c" -o {Targ} {PPCCOptions}
80
81
82 sorPPC ДД sor.r
83 Rez sor.r -o sorPPC -a
84
85 Install Ä sorPPC
86 Duplicate -y sorPPC "{MPW}"Tools:sor
+0
-53
contrib/pccts/sorcerer/stdpccts.h less more
0 #ifndef STDPCCTS_H
1 #define STDPCCTS_H
2 /*
3 * stdpccts.h -- P C C T S I n c l u d e
4 *
5 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
6 * Purdue University Electrical Engineering
7 * With AHPCRC, University of Minnesota
8 * ANTLR Version 1.33MR33
9 */
10
11 #ifndef ANTLR_VERSION
12 #define ANTLR_VERSION 13333
13 #endif
14
15 #include "pcctscfg.h"
16 #include "pccts_stdio.h"
17
18 /* 23-Sep-97 thm Accomodate user who needs to redefine ZZLEXBUFSIZE */
19
20 #ifndef ZZLEXBUFSIZE
21 #define ZZLEXBUFSIZE 8000
22 #endif
23 #include "pcctscfg.h" /* MR20 G. Hobbelt __USE_PROTOS #define */
24 #include "charbuf.h"
25 #include "hash.h"
26 #include "set.h"
27 #include "sor.h"
28 #define AST_FIELDS \
29 int token; char text[MaxAtom+1], label[MaxRuleName+1]; \
30 char *action; /* if action node, here is ptr to it */ \
31 char in,out; \
32 char init_action; /* set if Action and 1st action of alt */ \
33 int file; int line; /* set for BLOCK, ALT, nonterm nodes */ \
34 int upper_range; /* only if T1..T2 found */ \
35 GLA *start_state; /* ptr into GLA for this block */ \
36 int no_copy; /* copy input ptr to output ptr? */ \
37 ListNode *refvars; /* any ref vars defined for this rule */ \
38 unsigned char is_root; /* this token is a root #( A ... ) */
39 #define zzcr_ast(node, cur, _tok, _text) \
40 {(node)->token=_tok; strncpy((node)->text, _text,MaxAtom);}
41 #define USER_ZZSYN
42 #define zzAST_DOUBLE
43 extern int define_num;
44 #define LL_K 2
45 #define GENAST
46 #define zzSET_SIZE 16
47 #include "antlr.h"
48 #include "ast.h"
49 #include "tokens.h"
50 #include "dlgdef.h"
51 #include "mode.h"
52 #endif
+0
-44
contrib/pccts/sorcerer/sym.h less more
0 /*
1 * sym.h
2 *
3 * SOFTWARE RIGHTS
4 *
5 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
6 * domain. An individual or company may do whatever they wish with
7 * source code distributed with SORCERER or the code generated by
8 * SORCERER, including the incorporation of SORCERER, or its output, into
9 * commerical software.
10 *
11 * We encourage users to develop software with SORCERER. However, we do
12 * ask that credit is given to us for developing SORCERER. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like SORCERER and have developed a nice tool with the
17 * output, please mention that you developed it using SORCERER. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
21 * completed.
22 *
23 * SORCERER 1.00B
24 * Terence Parr
25 * AHPCRC, University of Minnesota
26 * 1992-2001
27 */
28
29 typedef struct _s {
30 char *str;
31 struct _s *next;
32 int token; /* token number in {Token, NonTerm} */
33 int token_type; /* if Token, what's its type */
34 ListNode *refs; /* list of nodes that ref this rule */
35 AST *definition; /* ptr into internal repr. of rule */
36 GLA *start_state; /* ptr into internal repr. of rule */
37 GLA *end_rule; /* ptr into internal repr. of rule */
38 char *args; /* text of arguments */
39 char *rt; /* text for return type */
40 char defined; /* is this rule or label defined? */
41 } SymEntry;
42
43 #define newSymEntry(s) (SymEntry *) newEntry(s, sizeof(SymEntry))
+0
-68
contrib/pccts/sorcerer/test/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 ## FIXME
4
5 SUBDIRS= test7
6
7 #PCCTS=../..
8 #BIN=$(PCCTS)/bin
9 #SOR = $(BIN)/sor
10 #CFLAGS = -I. -I../../h -I../h -I../lib -g -ansi
11 #DFLAGS = -C2 -i
12 #SRC = test.c
13 #OBJ = test.o
14 #SRC2 = test2.c
15 #OBJ2 = test2.o ../lib/astlib.o ../lib/sorlist.o
16 #SRC3 = test3.c
17 #OBJ3 = test3.o ../lib/astlib.o ../lib/sorlist.o
18 #SRC4 = test4.c
19 #OBJ4 = test4.o
20 #SRC5 = test5.c
21 #OBJ5 = test5.o ../lib/astlib.o ../lib/sorlist.o
22 #SRC6 = test6.c
23 #OBJ6 = test6.o ../lib/astlib.o ../lib/sorlist.o
24 ##CC=gcc
25 #CC=cc
26 #TEST_SPAWN = test.c test2.c test3.c test4.c test5.c
27
28 #test1: $(OBJ) $(SRC)
29 # $(CC) -o t $(CFLAGS) $(OBJ)
30
31 #test.c : test.sor
32 # $(SOR) -funcs both test.sor
33
34 #test2: $(OBJ2) $(SRC2)
35 # $(CC) -o t2 $(CFLAGS) $(OBJ2)
36
37 #test2.c : test2.sor
38 # $(SOR) -funcs KR test2.sor
39
40 #test3: $(OBJ3) $(SRC3)
41 # $(CC) -o t3 $(CFLAGS) $(OBJ3)
42
43 #test3.c : test3.sor
44 # $(SOR) -transform -funcs KR test3.sor
45
46 #test4: $(OBJ4) $(SRC4)
47 # $(CC) -o t4 $(CFLAGS) $(OBJ4)
48
49 #test4.c : test4.sor
50 # $(SOR) -funcs KR test4.sor
51
52 #test5: $(OBJ5) $(SRC5)
53 # $(CC) -o t5 $(CFLAGS) $(OBJ5)
54
55 #test5.c : test5.sor
56 # $(SOR) -transform -funcs KR test5.sor
57 #test6: $(OBJ6) $(SRC6)
58 # $(CC) -o t6 $(CFLAGS) $(OBJ6)
59
60 #test6.c : test6.sor
61 # $(SOR) -def-tokens-file tokens6.h -transform -funcs KR test6.sor
62
63 #scrub:
64 # rm -rf *.o core $(TEST_SPAWN)
65
66 #clean:
67 # rm -rf *.o core
+0
-697
contrib/pccts/sorcerer/test/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/sorcerer/test
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
102 ctags-recursive dvi-recursive html-recursive info-recursive \
103 install-data-recursive install-dvi-recursive \
104 install-exec-recursive install-html-recursive \
105 install-info-recursive install-pdf-recursive \
106 install-ps-recursive install-recursive installcheck-recursive \
107 installdirs-recursive pdf-recursive ps-recursive \
108 tags-recursive uninstall-recursive
109 am__can_run_installinfo = \
110 case $$AM_UPDATE_INFO_DIR in \
111 n|no|NO) false;; \
112 *) (install-info --version) >/dev/null 2>&1;; \
113 esac
114 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
115 distclean-recursive maintainer-clean-recursive
116 am__recursive_targets = \
117 $(RECURSIVE_TARGETS) \
118 $(RECURSIVE_CLEAN_TARGETS) \
119 $(am__extra_recursive_targets)
120 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
121 distdir
122 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
123 # Read a list of newline-separated strings from the standard input,
124 # and print each of them once, without duplicates. Input order is
125 # *not* preserved.
126 am__uniquify_input = $(AWK) '\
127 BEGIN { nonempty = 0; } \
128 { items[$$0] = 1; nonempty = 1; } \
129 END { if (nonempty) { for (i in items) print i; }; } \
130 '
131 # Make sure the list of sources is unique. This is necessary because,
132 # e.g., the same source file might be shared among _SOURCES variables
133 # for different programs/libraries.
134 am__define_uniq_tagged_files = \
135 list='$(am__tagged_files)'; \
136 unique=`for i in $$list; do \
137 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
138 done | $(am__uniquify_input)`
139 ETAGS = etags
140 CTAGS = ctags
141 DIST_SUBDIRS = $(SUBDIRS)
142 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
143 am__relativize = \
144 dir0=`pwd`; \
145 sed_first='s,^\([^/]*\)/.*$$,\1,'; \
146 sed_rest='s,^[^/]*/*,,'; \
147 sed_last='s,^.*/\([^/]*\)$$,\1,'; \
148 sed_butlast='s,/*[^/]*$$,,'; \
149 while test -n "$$dir1"; do \
150 first=`echo "$$dir1" | sed -e "$$sed_first"`; \
151 if test "$$first" != "."; then \
152 if test "$$first" = ".."; then \
153 dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
154 dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
155 else \
156 first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
157 if test "$$first2" = "$$first"; then \
158 dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
159 else \
160 dir2="../$$dir2"; \
161 fi; \
162 dir0="$$dir0"/"$$first"; \
163 fi; \
164 fi; \
165 dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
166 done; \
167 reldir="$$dir2"
168 ACLOCAL = @ACLOCAL@
169 AET2_CFLAGS = @AET2_CFLAGS@
170 AET2_LDADD = @AET2_LDADD@
171 ALLOCA = @ALLOCA@
172 AMTAR = @AMTAR@
173 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
174 AUTOCONF = @AUTOCONF@
175 AUTOHEADER = @AUTOHEADER@
176 AUTOMAKE = @AUTOMAKE@
177 AWK = @AWK@
178 CC = @CC@
179 CCDEPMODE = @CCDEPMODE@
180 CFLAGS = @CFLAGS@
181 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
182 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
183 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
184 CPP = @CPP@
185 CPPFLAGS = @CPPFLAGS@
186 CXX = @CXX@
187 CXXDEPMODE = @CXXDEPMODE@
188 CXXFLAGS = @CXXFLAGS@
189 CYGPATH_W = @CYGPATH_W@
190 DEFS = @DEFS@
191 DEPDIR = @DEPDIR@
192 ECHO_C = @ECHO_C@
193 ECHO_N = @ECHO_N@
194 ECHO_T = @ECHO_T@
195 EGREP = @EGREP@
196 EXEEXT = @EXEEXT@
197 EXTDEBUG = @EXTDEBUG@
198 EXTDEBUG2 = @EXTDEBUG2@
199 EXTDEBUG3 = @EXTDEBUG3@
200 EXTDEBUG4 = @EXTDEBUG4@
201 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
202 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
203 FSDB_CFLAGS = @FSDB_CFLAGS@
204 FSDB_LDADD = @FSDB_LDADD@
205 GCONF_CFLAGS = @GCONF_CFLAGS@
206 GCONF_LIBS = @GCONF_LIBS@
207 GEDITTEST = @GEDITTEST@
208 GEDIT_CFLAGS = @GEDIT_CFLAGS@
209 GIO_CFLAGS = @GIO_CFLAGS@
210 GIO_LIBS = @GIO_LIBS@
211 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
212 GPERF = @GPERF@
213 GREP = @GREP@
214 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
215 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
216 GTK_CFLAGS = @GTK_CFLAGS@
217 GTK_CONFIG = @GTK_CONFIG@
218 GTK_LIBS = @GTK_LIBS@
219 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
220 GTK_MAC_LIBS = @GTK_MAC_LIBS@
221 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
222 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
223 INSTALL = @INSTALL@
224 INSTALL_DATA = @INSTALL_DATA@
225 INSTALL_PROGRAM = @INSTALL_PROGRAM@
226 INSTALL_SCRIPT = @INSTALL_SCRIPT@
227 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
228 LDFLAGS = @LDFLAGS@
229 LEX = @LEX@
230 LEXLIB = @LEXLIB@
231 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
232 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
233 LIBBZ2_DIR = @LIBBZ2_DIR@
234 LIBBZ2_LDADD = @LIBBZ2_LDADD@
235 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
236 LIBJUDY_LDADD = @LIBJUDY_LDADD@
237 LIBOBJS = @LIBOBJS@
238 LIBS = @LIBS@
239 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
240 LIBXZ_LDADD = @LIBXZ_LDADD@
241 LIBZ_CFLAGS = @LIBZ_CFLAGS@
242 LIBZ_DIR = @LIBZ_DIR@
243 LIBZ_LDADD = @LIBZ_LDADD@
244 LTLIBOBJS = @LTLIBOBJS@
245 MAINT = @MAINT@
246 MAKEINFO = @MAKEINFO@
247 MINGW_LDADD = @MINGW_LDADD@
248 MKDIR_P = @MKDIR_P@
249 OBJEXT = @OBJEXT@
250 PACKAGE = @PACKAGE@
251 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
252 PACKAGE_NAME = @PACKAGE_NAME@
253 PACKAGE_STRING = @PACKAGE_STRING@
254 PACKAGE_TARNAME = @PACKAGE_TARNAME@
255 PACKAGE_URL = @PACKAGE_URL@
256 PACKAGE_VERSION = @PACKAGE_VERSION@
257 PATH_SEPARATOR = @PATH_SEPARATOR@
258 PKG_CONFIG = @PKG_CONFIG@
259 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
260 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
261 POW_LIB = @POW_LIB@
262 RANLIB = @RANLIB@
263 RPC_CFLAGS = @RPC_CFLAGS@
264 RPC_LDADD = @RPC_LDADD@
265 SET_MAKE = @SET_MAKE@
266 SHELL = @SHELL@
267 STRIP = @STRIP@
268 STRUCT_PACK = @STRUCT_PACK@
269 TCL_DEFADD = @TCL_DEFADD@
270 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
271 TCL_LDADD = @TCL_LDADD@
272 TCL_LIB_SPEC = @TCL_LIB_SPEC@
273 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
274 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
275 TIRPC_CFLAGS = @TIRPC_CFLAGS@
276 TIRPC_LIBS = @TIRPC_LIBS@
277 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
278 TK_LDADD = @TK_LDADD@
279 TK_LIB_SPEC = @TK_LIB_SPEC@
280 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
281 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
282 VERSION = @VERSION@
283 XDGDATADIR = @XDGDATADIR@
284 abs_builddir = @abs_builddir@
285 abs_srcdir = @abs_srcdir@
286 abs_top_builddir = @abs_top_builddir@
287 abs_top_srcdir = @abs_top_srcdir@
288 ac_ct_CC = @ac_ct_CC@
289 ac_ct_CXX = @ac_ct_CXX@
290 am__include = @am__include@
291 am__leading_dot = @am__leading_dot@
292 am__quote = @am__quote@
293 am__tar = @am__tar@
294 am__untar = @am__untar@
295 bindir = @bindir@
296 build_alias = @build_alias@
297 builddir = @builddir@
298 datadir = @datadir@
299 datarootdir = @datarootdir@
300 docdir = @docdir@
301 dvidir = @dvidir@
302 exec_prefix = @exec_prefix@
303 gsettingsschemadir = @gsettingsschemadir@
304 host_alias = @host_alias@
305 htmldir = @htmldir@
306 includedir = @includedir@
307 infodir = @infodir@
308 install_sh = @install_sh@
309 libdir = @libdir@
310 libexecdir = @libexecdir@
311 localedir = @localedir@
312 localstatedir = @localstatedir@
313 mandir = @mandir@
314 mkdir_p = @mkdir_p@
315 oldincludedir = @oldincludedir@
316 pdfdir = @pdfdir@
317 prefix = @prefix@
318 program_transform_name = @program_transform_name@
319 psdir = @psdir@
320 sbindir = @sbindir@
321 sharedstatedir = @sharedstatedir@
322 srcdir = @srcdir@
323 sysconfdir = @sysconfdir@
324 target_alias = @target_alias@
325 top_build_prefix = @top_build_prefix@
326 top_builddir = @top_builddir@
327 top_srcdir = @top_srcdir@
328 SUBDIRS = test7
329 all: all-recursive
330
331 .SUFFIXES:
332 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
333 @for dep in $?; do \
334 case '$(am__configure_deps)' in \
335 *$$dep*) \
336 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
337 && { if test -f $@; then exit 0; else break; fi; }; \
338 exit 1;; \
339 esac; \
340 done; \
341 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/sorcerer/test/Makefile'; \
342 $(am__cd) $(top_srcdir) && \
343 $(AUTOMAKE) --foreign contrib/pccts/sorcerer/test/Makefile
344 .PRECIOUS: Makefile
345 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
346 @case '$?' in \
347 *config.status*) \
348 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
349 *) \
350 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
351 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
352 esac;
353
354 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
355 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
356
357 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
358 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
359 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
360 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
361 $(am__aclocal_m4_deps):
362
363 # This directory's subdirectories are mostly independent; you can cd
364 # into them and run 'make' without going through this Makefile.
365 # To change the values of 'make' variables: instead of editing Makefiles,
366 # (1) if the variable is set in 'config.status', edit 'config.status'
367 # (which will cause the Makefiles to be regenerated when you run 'make');
368 # (2) otherwise, pass the desired values on the 'make' command line.
369 $(am__recursive_targets):
370 @fail=; \
371 if $(am__make_keepgoing); then \
372 failcom='fail=yes'; \
373 else \
374 failcom='exit 1'; \
375 fi; \
376 dot_seen=no; \
377 target=`echo $@ | sed s/-recursive//`; \
378 case "$@" in \
379 distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
380 *) list='$(SUBDIRS)' ;; \
381 esac; \
382 for subdir in $$list; do \
383 echo "Making $$target in $$subdir"; \
384 if test "$$subdir" = "."; then \
385 dot_seen=yes; \
386 local_target="$$target-am"; \
387 else \
388 local_target="$$target"; \
389 fi; \
390 ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
391 || eval $$failcom; \
392 done; \
393 if test "$$dot_seen" = "no"; then \
394 $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
395 fi; test -z "$$fail"
396
397 ID: $(am__tagged_files)
398 $(am__define_uniq_tagged_files); mkid -fID $$unique
399 tags: tags-recursive
400 TAGS: tags
401
402 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
403 set x; \
404 here=`pwd`; \
405 if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
406 include_option=--etags-include; \
407 empty_fix=.; \
408 else \
409 include_option=--include; \
410 empty_fix=; \
411 fi; \
412 list='$(SUBDIRS)'; for subdir in $$list; do \
413 if test "$$subdir" = .; then :; else \
414 test ! -f $$subdir/TAGS || \
415 set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
416 fi; \
417 done; \
418 $(am__define_uniq_tagged_files); \
419 shift; \
420 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
421 test -n "$$unique" || unique=$$empty_fix; \
422 if test $$# -gt 0; then \
423 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
424 "$$@" $$unique; \
425 else \
426 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
427 $$unique; \
428 fi; \
429 fi
430 ctags: ctags-recursive
431
432 CTAGS: ctags
433 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
434 $(am__define_uniq_tagged_files); \
435 test -z "$(CTAGS_ARGS)$$unique" \
436 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
437 $$unique
438
439 GTAGS:
440 here=`$(am__cd) $(top_builddir) && pwd` \
441 && $(am__cd) $(top_srcdir) \
442 && gtags -i $(GTAGS_ARGS) "$$here"
443 cscopelist: cscopelist-recursive
444
445 cscopelist-am: $(am__tagged_files)
446 list='$(am__tagged_files)'; \
447 case "$(srcdir)" in \
448 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
449 *) sdir=$(subdir)/$(srcdir) ;; \
450 esac; \
451 for i in $$list; do \
452 if test -f "$$i"; then \
453 echo "$(subdir)/$$i"; \
454 else \
455 echo "$$sdir/$$i"; \
456 fi; \
457 done >> $(top_builddir)/cscope.files
458
459 distclean-tags:
460 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
461
462 distdir: $(DISTFILES)
463 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
464 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
465 list='$(DISTFILES)'; \
466 dist_files=`for file in $$list; do echo $$file; done | \
467 sed -e "s|^$$srcdirstrip/||;t" \
468 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
469 case $$dist_files in \
470 */*) $(MKDIR_P) `echo "$$dist_files" | \
471 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
472 sort -u` ;; \
473 esac; \
474 for file in $$dist_files; do \
475 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
476 if test -d $$d/$$file; then \
477 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
478 if test -d "$(distdir)/$$file"; then \
479 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
480 fi; \
481 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
482 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
483 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
484 fi; \
485 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
486 else \
487 test -f "$(distdir)/$$file" \
488 || cp -p $$d/$$file "$(distdir)/$$file" \
489 || exit 1; \
490 fi; \
491 done
492 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
493 if test "$$subdir" = .; then :; else \
494 $(am__make_dryrun) \
495 || test -d "$(distdir)/$$subdir" \
496 || $(MKDIR_P) "$(distdir)/$$subdir" \
497 || exit 1; \
498 dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
499 $(am__relativize); \
500 new_distdir=$$reldir; \
501 dir1=$$subdir; dir2="$(top_distdir)"; \
502 $(am__relativize); \
503 new_top_distdir=$$reldir; \
504 echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
505 echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
506 ($(am__cd) $$subdir && \
507 $(MAKE) $(AM_MAKEFLAGS) \
508 top_distdir="$$new_top_distdir" \
509 distdir="$$new_distdir" \
510 am__remove_distdir=: \
511 am__skip_length_check=: \
512 am__skip_mode_fix=: \
513 distdir) \
514 || exit 1; \
515 fi; \
516 done
517 check-am: all-am
518 check: check-recursive
519 all-am: Makefile
520 installdirs: installdirs-recursive
521 installdirs-am:
522 install: install-recursive
523 install-exec: install-exec-recursive
524 install-data: install-data-recursive
525 uninstall: uninstall-recursive
526
527 install-am: all-am
528 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
529
530 installcheck: installcheck-recursive
531 install-strip:
532 if test -z '$(STRIP)'; then \
533 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
534 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
535 install; \
536 else \
537 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
538 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
539 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
540 fi
541 mostlyclean-generic:
542
543 clean-generic:
544
545 distclean-generic:
546 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
547 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
548
549 maintainer-clean-generic:
550 @echo "This command is intended for maintainers to use"
551 @echo "it deletes files that may require special tools to rebuild."
552 clean: clean-recursive
553
554 clean-am: clean-generic mostlyclean-am
555
556 distclean: distclean-recursive
557 -rm -f Makefile
558 distclean-am: clean-am distclean-generic distclean-tags
559
560 dvi: dvi-recursive
561
562 dvi-am:
563
564 html: html-recursive
565
566 html-am:
567
568 info: info-recursive
569
570 info-am:
571
572 install-data-am:
573
574 install-dvi: install-dvi-recursive
575
576 install-dvi-am:
577
578 install-exec-am:
579
580 install-html: install-html-recursive
581
582 install-html-am:
583
584 install-info: install-info-recursive
585
586 install-info-am:
587
588 install-man:
589
590 install-pdf: install-pdf-recursive
591
592 install-pdf-am:
593
594 install-ps: install-ps-recursive
595
596 install-ps-am:
597
598 installcheck-am:
599
600 maintainer-clean: maintainer-clean-recursive
601 -rm -f Makefile
602 maintainer-clean-am: distclean-am maintainer-clean-generic
603
604 mostlyclean: mostlyclean-recursive
605
606 mostlyclean-am: mostlyclean-generic
607
608 pdf: pdf-recursive
609
610 pdf-am:
611
612 ps: ps-recursive
613
614 ps-am:
615
616 uninstall-am:
617
618 .MAKE: $(am__recursive_targets) install-am install-strip
619
620 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
621 check-am clean clean-generic cscopelist-am ctags ctags-am \
622 distclean distclean-generic distclean-tags distdir dvi dvi-am \
623 html html-am info info-am install install-am install-data \
624 install-data-am install-dvi install-dvi-am install-exec \
625 install-exec-am install-html install-html-am install-info \
626 install-info-am install-man install-pdf install-pdf-am \
627 install-ps install-ps-am install-strip installcheck \
628 installcheck-am installdirs installdirs-am maintainer-clean \
629 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
630 pdf-am ps ps-am tags tags-am uninstall uninstall-am
631
632
633 #PCCTS=../..
634 #BIN=$(PCCTS)/bin
635 #SOR = $(BIN)/sor
636 #CFLAGS = -I. -I../../h -I../h -I../lib -g -ansi
637 #DFLAGS = -C2 -i
638 #SRC = test.c
639 #OBJ = test.o
640 #SRC2 = test2.c
641 #OBJ2 = test2.o ../lib/astlib.o ../lib/sorlist.o
642 #SRC3 = test3.c
643 #OBJ3 = test3.o ../lib/astlib.o ../lib/sorlist.o
644 #SRC4 = test4.c
645 #OBJ4 = test4.o
646 #SRC5 = test5.c
647 #OBJ5 = test5.o ../lib/astlib.o ../lib/sorlist.o
648 #SRC6 = test6.c
649 #OBJ6 = test6.o ../lib/astlib.o ../lib/sorlist.o
650 #CC=cc
651 #TEST_SPAWN = test.c test2.c test3.c test4.c test5.c
652
653 #test1: $(OBJ) $(SRC)
654 # $(CC) -o t $(CFLAGS) $(OBJ)
655
656 #test.c : test.sor
657 # $(SOR) -funcs both test.sor
658
659 #test2: $(OBJ2) $(SRC2)
660 # $(CC) -o t2 $(CFLAGS) $(OBJ2)
661
662 #test2.c : test2.sor
663 # $(SOR) -funcs KR test2.sor
664
665 #test3: $(OBJ3) $(SRC3)
666 # $(CC) -o t3 $(CFLAGS) $(OBJ3)
667
668 #test3.c : test3.sor
669 # $(SOR) -transform -funcs KR test3.sor
670
671 #test4: $(OBJ4) $(SRC4)
672 # $(CC) -o t4 $(CFLAGS) $(OBJ4)
673
674 #test4.c : test4.sor
675 # $(SOR) -funcs KR test4.sor
676
677 #test5: $(OBJ5) $(SRC5)
678 # $(CC) -o t5 $(CFLAGS) $(OBJ5)
679
680 #test5.c : test5.sor
681 # $(SOR) -transform -funcs KR test5.sor
682 #test6: $(OBJ6) $(SRC6)
683 # $(CC) -o t6 $(CFLAGS) $(OBJ6)
684
685 #test6.c : test6.sor
686 # $(SOR) -def-tokens-file tokens6.h -transform -funcs KR test6.sor
687
688 #scrub:
689 # rm -rf *.o core $(TEST_SPAWN)
690
691 #clean:
692 # rm -rf *.o core
693
694 # Tell versions [3.59,3.63) of GNU make to not export all variables.
695 # Otherwise a system limit (for SysV at least) may be exceeded.
696 .NOEXPORT:
+0
-5
contrib/pccts/sorcerer/test/test7/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 ## FIXME
4
+0
-455
contrib/pccts/sorcerer/test/test7/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/sorcerer/test/test7
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 am__can_run_installinfo = \
102 case $$AM_UPDATE_INFO_DIR in \
103 n|no|NO) false;; \
104 *) (install-info --version) >/dev/null 2>&1;; \
105 esac
106 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
107 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
108 ACLOCAL = @ACLOCAL@
109 AET2_CFLAGS = @AET2_CFLAGS@
110 AET2_LDADD = @AET2_LDADD@
111 ALLOCA = @ALLOCA@
112 AMTAR = @AMTAR@
113 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
114 AUTOCONF = @AUTOCONF@
115 AUTOHEADER = @AUTOHEADER@
116 AUTOMAKE = @AUTOMAKE@
117 AWK = @AWK@
118 CC = @CC@
119 CCDEPMODE = @CCDEPMODE@
120 CFLAGS = @CFLAGS@
121 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
122 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
123 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
124 CPP = @CPP@
125 CPPFLAGS = @CPPFLAGS@
126 CXX = @CXX@
127 CXXDEPMODE = @CXXDEPMODE@
128 CXXFLAGS = @CXXFLAGS@
129 CYGPATH_W = @CYGPATH_W@
130 DEFS = @DEFS@
131 DEPDIR = @DEPDIR@
132 ECHO_C = @ECHO_C@
133 ECHO_N = @ECHO_N@
134 ECHO_T = @ECHO_T@
135 EGREP = @EGREP@
136 EXEEXT = @EXEEXT@
137 EXTDEBUG = @EXTDEBUG@
138 EXTDEBUG2 = @EXTDEBUG2@
139 EXTDEBUG3 = @EXTDEBUG3@
140 EXTDEBUG4 = @EXTDEBUG4@
141 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
142 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
143 FSDB_CFLAGS = @FSDB_CFLAGS@
144 FSDB_LDADD = @FSDB_LDADD@
145 GCONF_CFLAGS = @GCONF_CFLAGS@
146 GCONF_LIBS = @GCONF_LIBS@
147 GEDITTEST = @GEDITTEST@
148 GEDIT_CFLAGS = @GEDIT_CFLAGS@
149 GIO_CFLAGS = @GIO_CFLAGS@
150 GIO_LIBS = @GIO_LIBS@
151 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
152 GPERF = @GPERF@
153 GREP = @GREP@
154 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
155 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
156 GTK_CFLAGS = @GTK_CFLAGS@
157 GTK_CONFIG = @GTK_CONFIG@
158 GTK_LIBS = @GTK_LIBS@
159 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
160 GTK_MAC_LIBS = @GTK_MAC_LIBS@
161 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
162 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
163 INSTALL = @INSTALL@
164 INSTALL_DATA = @INSTALL_DATA@
165 INSTALL_PROGRAM = @INSTALL_PROGRAM@
166 INSTALL_SCRIPT = @INSTALL_SCRIPT@
167 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
168 LDFLAGS = @LDFLAGS@
169 LEX = @LEX@
170 LEXLIB = @LEXLIB@
171 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
172 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
173 LIBBZ2_DIR = @LIBBZ2_DIR@
174 LIBBZ2_LDADD = @LIBBZ2_LDADD@
175 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
176 LIBJUDY_LDADD = @LIBJUDY_LDADD@
177 LIBOBJS = @LIBOBJS@
178 LIBS = @LIBS@
179 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
180 LIBXZ_LDADD = @LIBXZ_LDADD@
181 LIBZ_CFLAGS = @LIBZ_CFLAGS@
182 LIBZ_DIR = @LIBZ_DIR@
183 LIBZ_LDADD = @LIBZ_LDADD@
184 LTLIBOBJS = @LTLIBOBJS@
185 MAINT = @MAINT@
186 MAKEINFO = @MAKEINFO@
187 MINGW_LDADD = @MINGW_LDADD@
188 MKDIR_P = @MKDIR_P@
189 OBJEXT = @OBJEXT@
190 PACKAGE = @PACKAGE@
191 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
192 PACKAGE_NAME = @PACKAGE_NAME@
193 PACKAGE_STRING = @PACKAGE_STRING@
194 PACKAGE_TARNAME = @PACKAGE_TARNAME@
195 PACKAGE_URL = @PACKAGE_URL@
196 PACKAGE_VERSION = @PACKAGE_VERSION@
197 PATH_SEPARATOR = @PATH_SEPARATOR@
198 PKG_CONFIG = @PKG_CONFIG@
199 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
200 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
201 POW_LIB = @POW_LIB@
202 RANLIB = @RANLIB@
203 RPC_CFLAGS = @RPC_CFLAGS@
204 RPC_LDADD = @RPC_LDADD@
205 SET_MAKE = @SET_MAKE@
206 SHELL = @SHELL@
207 STRIP = @STRIP@
208 STRUCT_PACK = @STRUCT_PACK@
209 TCL_DEFADD = @TCL_DEFADD@
210 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
211 TCL_LDADD = @TCL_LDADD@
212 TCL_LIB_SPEC = @TCL_LIB_SPEC@
213 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
214 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
215 TIRPC_CFLAGS = @TIRPC_CFLAGS@
216 TIRPC_LIBS = @TIRPC_LIBS@
217 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
218 TK_LDADD = @TK_LDADD@
219 TK_LIB_SPEC = @TK_LIB_SPEC@
220 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
221 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
222 VERSION = @VERSION@
223 XDGDATADIR = @XDGDATADIR@
224 abs_builddir = @abs_builddir@
225 abs_srcdir = @abs_srcdir@
226 abs_top_builddir = @abs_top_builddir@
227 abs_top_srcdir = @abs_top_srcdir@
228 ac_ct_CC = @ac_ct_CC@
229 ac_ct_CXX = @ac_ct_CXX@
230 am__include = @am__include@
231 am__leading_dot = @am__leading_dot@
232 am__quote = @am__quote@
233 am__tar = @am__tar@
234 am__untar = @am__untar@
235 bindir = @bindir@
236 build_alias = @build_alias@
237 builddir = @builddir@
238 datadir = @datadir@
239 datarootdir = @datarootdir@
240 docdir = @docdir@
241 dvidir = @dvidir@
242 exec_prefix = @exec_prefix@
243 gsettingsschemadir = @gsettingsschemadir@
244 host_alias = @host_alias@
245 htmldir = @htmldir@
246 includedir = @includedir@
247 infodir = @infodir@
248 install_sh = @install_sh@
249 libdir = @libdir@
250 libexecdir = @libexecdir@
251 localedir = @localedir@
252 localstatedir = @localstatedir@
253 mandir = @mandir@
254 mkdir_p = @mkdir_p@
255 oldincludedir = @oldincludedir@
256 pdfdir = @pdfdir@
257 prefix = @prefix@
258 program_transform_name = @program_transform_name@
259 psdir = @psdir@
260 sbindir = @sbindir@
261 sharedstatedir = @sharedstatedir@
262 srcdir = @srcdir@
263 sysconfdir = @sysconfdir@
264 target_alias = @target_alias@
265 top_build_prefix = @top_build_prefix@
266 top_builddir = @top_builddir@
267 top_srcdir = @top_srcdir@
268 all: all-am
269
270 .SUFFIXES:
271 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
272 @for dep in $?; do \
273 case '$(am__configure_deps)' in \
274 *$$dep*) \
275 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
276 && { if test -f $@; then exit 0; else break; fi; }; \
277 exit 1;; \
278 esac; \
279 done; \
280 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/sorcerer/test/test7/Makefile'; \
281 $(am__cd) $(top_srcdir) && \
282 $(AUTOMAKE) --foreign contrib/pccts/sorcerer/test/test7/Makefile
283 .PRECIOUS: Makefile
284 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
285 @case '$?' in \
286 *config.status*) \
287 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
288 *) \
289 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
290 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
291 esac;
292
293 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
294 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
295
296 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
297 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
298 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
299 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
300 $(am__aclocal_m4_deps):
301 tags TAGS:
302
303 ctags CTAGS:
304
305 cscope cscopelist:
306
307
308 distdir: $(DISTFILES)
309 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
310 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
311 list='$(DISTFILES)'; \
312 dist_files=`for file in $$list; do echo $$file; done | \
313 sed -e "s|^$$srcdirstrip/||;t" \
314 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
315 case $$dist_files in \
316 */*) $(MKDIR_P) `echo "$$dist_files" | \
317 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
318 sort -u` ;; \
319 esac; \
320 for file in $$dist_files; do \
321 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
322 if test -d $$d/$$file; then \
323 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
324 if test -d "$(distdir)/$$file"; then \
325 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
326 fi; \
327 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
328 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
329 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
330 fi; \
331 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
332 else \
333 test -f "$(distdir)/$$file" \
334 || cp -p $$d/$$file "$(distdir)/$$file" \
335 || exit 1; \
336 fi; \
337 done
338 check-am: all-am
339 check: check-am
340 all-am: Makefile
341 installdirs:
342 install: install-am
343 install-exec: install-exec-am
344 install-data: install-data-am
345 uninstall: uninstall-am
346
347 install-am: all-am
348 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
349
350 installcheck: installcheck-am
351 install-strip:
352 if test -z '$(STRIP)'; then \
353 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
354 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
355 install; \
356 else \
357 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
358 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
359 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
360 fi
361 mostlyclean-generic:
362
363 clean-generic:
364
365 distclean-generic:
366 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
367 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
368
369 maintainer-clean-generic:
370 @echo "This command is intended for maintainers to use"
371 @echo "it deletes files that may require special tools to rebuild."
372 clean: clean-am
373
374 clean-am: clean-generic mostlyclean-am
375
376 distclean: distclean-am
377 -rm -f Makefile
378 distclean-am: clean-am distclean-generic
379
380 dvi: dvi-am
381
382 dvi-am:
383
384 html: html-am
385
386 html-am:
387
388 info: info-am
389
390 info-am:
391
392 install-data-am:
393
394 install-dvi: install-dvi-am
395
396 install-dvi-am:
397
398 install-exec-am:
399
400 install-html: install-html-am
401
402 install-html-am:
403
404 install-info: install-info-am
405
406 install-info-am:
407
408 install-man:
409
410 install-pdf: install-pdf-am
411
412 install-pdf-am:
413
414 install-ps: install-ps-am
415
416 install-ps-am:
417
418 installcheck-am:
419
420 maintainer-clean: maintainer-clean-am
421 -rm -f Makefile
422 maintainer-clean-am: distclean-am maintainer-clean-generic
423
424 mostlyclean: mostlyclean-am
425
426 mostlyclean-am: mostlyclean-generic
427
428 pdf: pdf-am
429
430 pdf-am:
431
432 ps: ps-am
433
434 ps-am:
435
436 uninstall-am:
437
438 .MAKE: install-am install-strip
439
440 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
441 ctags-am distclean distclean-generic distdir dvi dvi-am html \
442 html-am info info-am install install-am install-data \
443 install-data-am install-dvi install-dvi-am install-exec \
444 install-exec-am install-html install-html-am install-info \
445 install-info-am install-man install-pdf install-pdf-am \
446 install-ps install-ps-am install-strip installcheck \
447 installcheck-am installdirs maintainer-clean \
448 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
449 pdf-am ps ps-am tags-am uninstall uninstall-am
450
451
452 # Tell versions [3.59,3.63) of GNU make to not export all variables.
453 # Otherwise a system limit (for SysV at least) may be exceeded.
454 .NOEXPORT:
+0
-83
contrib/pccts/sorcerer/testcpp/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 ## FIXME
4
5
6 #PCCTS=../..
7 #BIN=$(PCCTS)/bin
8 #PCCTS_H=$(PCCTS)/h
9
10 #SOR = $(BIN)/sor
11
12 #CFLAGS = -I. -I.. -I../h -I../lib -I$(PCCTS_H) -g
13 #DFLAGS = -C2 -i
14 #SRC = test.cpp ExprTreeParser.cpp ../lib/STreeParser.cpp \
15 # $(PCCTS_H)/PCCTSAST.cpp
16 #OBJ = test.o ExprTreeParser.o STreeParser.o PCCTSAST.o
17 #SRC2 = test2.cpp Cool.cpp ../lib/STreeParser.cpp $(PCCTS_H)/PCCTSAST.cpp
18 #OBJ2 = test2.o Cool.o STreeParser.o PCCTSAST.o
19 #SRC3 = test3.cpp Cool.cpp ../lib/STreeParser.cpp $(PCCTS_H)/PCCTSAST.cpp
20 #OBJ3 = test3.o Cool.o STreeParser.o PCCTSAST.o
21 #SRC4 = test4.cpp
22 #OBJ4 = test4.o
23 #SRC5 = test5.cpp Cool.cpp ../lib/STreeParser.cpp $(PCCTS_H)/PCCTSAST.cpp
24 #OBJ5 = test5.o Cool.o STreeParser.o PCCTSAST.o
25 #CCC=CC
26 #CCC=g++
27
28 #SPAWN = test.cpp test2.cpp ExprTreeParser.h ExprTreeParser.cpp Cool.h Cool.cpp \
29 # test3.cpp test5.cpp
30
31 #test: $(OBJ) $(SRC)
32 # $(CCC) -o t $(CFLAGS) $(OBJ)
33
34 #test.o : test.cpp
35 # $(CCC) -c $(CFLAGS) test.cpp
36
37 #ExprTreeParser.o : ExprTreeParser.cpp
38 # $(CCC) -c $(CFLAGS) ExprTreeParser.cpp
39
40 #STreeParser.o : ../lib/STreeParser.cpp
41 # $(CCC) -o STreeParser.o -c $(CFLAGS) ../lib/STreeParser.cpp
42
43 #PCCTSAST.o : $(PCCTS_H)/PCCTSAST.cpp
44 # $(CCC) -o PCCTSAST.o -c $(CFLAGS) $(PCCTS_H)/PCCTSAST.cpp
45
46 #test.cpp ExprTreeParser.cpp ExprTreeParser.h : test.sor
47 # $(SOR) -CPP -def-tokens test.sor
48
49 #test2: $(OBJ2) $(SRC2)
50 # $(CCC) -o t2 $(CFLAGS) $(OBJ2)
51
52 #test2.cpp : test2.sor
53 # $(SOR) -CPP -transform -def-tokens test2.sor
54
55 #test2.o : test2.cpp
56 # $(CCC) -c $(CFLAGS) test2.cpp
57
58 #test3: $(OBJ3) $(SRC3)
59 # $(CCC) -o t3 $(CFLAGS) $(OBJ3)
60
61 #test3.cpp : test3.sor
62 # $(SOR) -CPP -transform test3.sor
63
64 #test3.o : test3.cpp
65 # $(CCC) -c $(CFLAGS) test3.cpp
66
67 #test5: $(OBJ5) $(SRC5)
68 # $(CCC) -o t5 $(CFLAGS) $(OBJ5)
69
70 #test5.cpp : test5.sor
71 # $(SOR) -CPP -transform test5.sor
72
73 #test5.o : test5.cpp
74 # $(CCC) -c $(CFLAGS) test5.cpp
75
76 #Cool.o : Cool.cpp
77 # $(CCC) -c $(CFLAGS) Cool.cpp
78
79 #scrub:
80 # (cd ./test4; make scrub)
81 # rm -rf *.o core $(SPAWN) t t2 t3 t5
82 #
+0
-533
contrib/pccts/sorcerer/testcpp/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 #PCCTS=../..
17 #BIN=$(PCCTS)/bin
18 #PCCTS_H=$(PCCTS)/h
19
20 #SOR = $(BIN)/sor
21
22 #CFLAGS = -I. -I.. -I../h -I../lib -I$(PCCTS_H) -g
23 #DFLAGS = -C2 -i
24 #SRC = test.cpp ExprTreeParser.cpp ../lib/STreeParser.cpp \
25 # $(PCCTS_H)/PCCTSAST.cpp
26 #OBJ = test.o ExprTreeParser.o STreeParser.o PCCTSAST.o
27 #SRC2 = test2.cpp Cool.cpp ../lib/STreeParser.cpp $(PCCTS_H)/PCCTSAST.cpp
28 #OBJ2 = test2.o Cool.o STreeParser.o PCCTSAST.o
29 #SRC3 = test3.cpp Cool.cpp ../lib/STreeParser.cpp $(PCCTS_H)/PCCTSAST.cpp
30 #OBJ3 = test3.o Cool.o STreeParser.o PCCTSAST.o
31 #SRC4 = test4.cpp
32 #OBJ4 = test4.o
33 #SRC5 = test5.cpp Cool.cpp ../lib/STreeParser.cpp $(PCCTS_H)/PCCTSAST.cpp
34 #OBJ5 = test5.o Cool.o STreeParser.o PCCTSAST.o
35 #CCC=CC
36 #CCC=g++
37
38 #SPAWN = test.cpp test2.cpp ExprTreeParser.h ExprTreeParser.cpp Cool.h Cool.cpp \
39 # test3.cpp test5.cpp
40
41 #test: $(OBJ) $(SRC)
42 # $(CCC) -o t $(CFLAGS) $(OBJ)
43
44 #test.o : test.cpp
45 # $(CCC) -c $(CFLAGS) test.cpp
46
47 #ExprTreeParser.o : ExprTreeParser.cpp
48 # $(CCC) -c $(CFLAGS) ExprTreeParser.cpp
49
50 #STreeParser.o : ../lib/STreeParser.cpp
51 # $(CCC) -o STreeParser.o -c $(CFLAGS) ../lib/STreeParser.cpp
52
53 #PCCTSAST.o : $(PCCTS_H)/PCCTSAST.cpp
54 # $(CCC) -o PCCTSAST.o -c $(CFLAGS) $(PCCTS_H)/PCCTSAST.cpp
55
56 #test.cpp ExprTreeParser.cpp ExprTreeParser.h : test.sor
57 # $(SOR) -CPP -def-tokens test.sor
58
59 #test2: $(OBJ2) $(SRC2)
60 # $(CCC) -o t2 $(CFLAGS) $(OBJ2)
61
62 #test2.cpp : test2.sor
63 # $(SOR) -CPP -transform -def-tokens test2.sor
64
65 #test2.o : test2.cpp
66 # $(CCC) -c $(CFLAGS) test2.cpp
67
68 #test3: $(OBJ3) $(SRC3)
69 # $(CCC) -o t3 $(CFLAGS) $(OBJ3)
70
71 #test3.cpp : test3.sor
72 # $(SOR) -CPP -transform test3.sor
73
74 #test3.o : test3.cpp
75 # $(CCC) -c $(CFLAGS) test3.cpp
76
77 #test5: $(OBJ5) $(SRC5)
78 # $(CCC) -o t5 $(CFLAGS) $(OBJ5)
79
80 #test5.cpp : test5.sor
81 # $(SOR) -CPP -transform test5.sor
82
83 #test5.o : test5.cpp
84 # $(CCC) -c $(CFLAGS) test5.cpp
85
86 #Cool.o : Cool.cpp
87 # $(CCC) -c $(CFLAGS) Cool.cpp
88 VPATH = @srcdir@
89 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
90 am__make_running_with_option = \
91 case $${target_option-} in \
92 ?) ;; \
93 *) echo "am__make_running_with_option: internal error: invalid" \
94 "target option '$${target_option-}' specified" >&2; \
95 exit 1;; \
96 esac; \
97 has_opt=no; \
98 sane_makeflags=$$MAKEFLAGS; \
99 if $(am__is_gnu_make); then \
100 sane_makeflags=$$MFLAGS; \
101 else \
102 case $$MAKEFLAGS in \
103 *\\[\ \ ]*) \
104 bs=\\; \
105 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
106 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
107 esac; \
108 fi; \
109 skip_next=no; \
110 strip_trailopt () \
111 { \
112 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
113 }; \
114 for flg in $$sane_makeflags; do \
115 test $$skip_next = yes && { skip_next=no; continue; }; \
116 case $$flg in \
117 *=*|--*) continue;; \
118 -*I) strip_trailopt 'I'; skip_next=yes;; \
119 -*I?*) strip_trailopt 'I';; \
120 -*O) strip_trailopt 'O'; skip_next=yes;; \
121 -*O?*) strip_trailopt 'O';; \
122 -*l) strip_trailopt 'l'; skip_next=yes;; \
123 -*l?*) strip_trailopt 'l';; \
124 -[dEDm]) skip_next=yes;; \
125 -[JT]) skip_next=yes;; \
126 esac; \
127 case $$flg in \
128 *$$target_option*) has_opt=yes; break;; \
129 esac; \
130 done; \
131 test $$has_opt = yes
132 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
133 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
134 pkgdatadir = $(datadir)/@PACKAGE@
135 pkgincludedir = $(includedir)/@PACKAGE@
136 pkglibdir = $(libdir)/@PACKAGE@
137 pkglibexecdir = $(libexecdir)/@PACKAGE@
138 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
139 install_sh_DATA = $(install_sh) -c -m 644
140 install_sh_PROGRAM = $(install_sh) -c
141 install_sh_SCRIPT = $(install_sh) -c
142 INSTALL_HEADER = $(INSTALL_DATA)
143 transform = $(program_transform_name)
144 NORMAL_INSTALL = :
145 PRE_INSTALL = :
146 POST_INSTALL = :
147 NORMAL_UNINSTALL = :
148 PRE_UNINSTALL = :
149 POST_UNINSTALL = :
150 subdir = contrib/pccts/sorcerer/testcpp
151 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
152 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
153 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
154 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
155 $(ACLOCAL_M4)
156 mkinstalldirs = $(install_sh) -d
157 CONFIG_HEADER = $(top_builddir)/config.h
158 CONFIG_CLEAN_FILES =
159 CONFIG_CLEAN_VPATH_FILES =
160 AM_V_P = $(am__v_P_@AM_V@)
161 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
162 am__v_P_0 = false
163 am__v_P_1 = :
164 AM_V_GEN = $(am__v_GEN_@AM_V@)
165 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
166 am__v_GEN_0 = @echo " GEN " $@;
167 am__v_GEN_1 =
168 AM_V_at = $(am__v_at_@AM_V@)
169 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
170 am__v_at_0 = @
171 am__v_at_1 =
172 SOURCES =
173 DIST_SOURCES =
174 am__can_run_installinfo = \
175 case $$AM_UPDATE_INFO_DIR in \
176 n|no|NO) false;; \
177 *) (install-info --version) >/dev/null 2>&1;; \
178 esac
179 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
180 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
181 ACLOCAL = @ACLOCAL@
182 AET2_CFLAGS = @AET2_CFLAGS@
183 AET2_LDADD = @AET2_LDADD@
184 ALLOCA = @ALLOCA@
185 AMTAR = @AMTAR@
186 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
187 AUTOCONF = @AUTOCONF@
188 AUTOHEADER = @AUTOHEADER@
189 AUTOMAKE = @AUTOMAKE@
190 AWK = @AWK@
191 CC = @CC@
192 CCDEPMODE = @CCDEPMODE@
193 CFLAGS = @CFLAGS@
194 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
195 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
196 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
197 CPP = @CPP@
198 CPPFLAGS = @CPPFLAGS@
199 CXX = @CXX@
200 CXXDEPMODE = @CXXDEPMODE@
201 CXXFLAGS = @CXXFLAGS@
202 CYGPATH_W = @CYGPATH_W@
203 DEFS = @DEFS@
204 DEPDIR = @DEPDIR@
205 ECHO_C = @ECHO_C@
206 ECHO_N = @ECHO_N@
207 ECHO_T = @ECHO_T@
208 EGREP = @EGREP@
209 EXEEXT = @EXEEXT@
210 EXTDEBUG = @EXTDEBUG@
211 EXTDEBUG2 = @EXTDEBUG2@
212 EXTDEBUG3 = @EXTDEBUG3@
213 EXTDEBUG4 = @EXTDEBUG4@
214 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
215 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
216 FSDB_CFLAGS = @FSDB_CFLAGS@
217 FSDB_LDADD = @FSDB_LDADD@
218 GCONF_CFLAGS = @GCONF_CFLAGS@
219 GCONF_LIBS = @GCONF_LIBS@
220 GEDITTEST = @GEDITTEST@
221 GEDIT_CFLAGS = @GEDIT_CFLAGS@
222 GIO_CFLAGS = @GIO_CFLAGS@
223 GIO_LIBS = @GIO_LIBS@
224 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
225 GPERF = @GPERF@
226 GREP = @GREP@
227 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
228 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
229 GTK_CFLAGS = @GTK_CFLAGS@
230 GTK_CONFIG = @GTK_CONFIG@
231 GTK_LIBS = @GTK_LIBS@
232 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
233 GTK_MAC_LIBS = @GTK_MAC_LIBS@
234 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
235 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
236 INSTALL = @INSTALL@
237 INSTALL_DATA = @INSTALL_DATA@
238 INSTALL_PROGRAM = @INSTALL_PROGRAM@
239 INSTALL_SCRIPT = @INSTALL_SCRIPT@
240 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
241 LDFLAGS = @LDFLAGS@
242 LEX = @LEX@
243 LEXLIB = @LEXLIB@
244 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
245 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
246 LIBBZ2_DIR = @LIBBZ2_DIR@
247 LIBBZ2_LDADD = @LIBBZ2_LDADD@
248 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
249 LIBJUDY_LDADD = @LIBJUDY_LDADD@
250 LIBOBJS = @LIBOBJS@
251 LIBS = @LIBS@
252 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
253 LIBXZ_LDADD = @LIBXZ_LDADD@
254 LIBZ_CFLAGS = @LIBZ_CFLAGS@
255 LIBZ_DIR = @LIBZ_DIR@
256 LIBZ_LDADD = @LIBZ_LDADD@
257 LTLIBOBJS = @LTLIBOBJS@
258 MAINT = @MAINT@
259 MAKEINFO = @MAKEINFO@
260 MINGW_LDADD = @MINGW_LDADD@
261 MKDIR_P = @MKDIR_P@
262 OBJEXT = @OBJEXT@
263 PACKAGE = @PACKAGE@
264 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
265 PACKAGE_NAME = @PACKAGE_NAME@
266 PACKAGE_STRING = @PACKAGE_STRING@
267 PACKAGE_TARNAME = @PACKAGE_TARNAME@
268 PACKAGE_URL = @PACKAGE_URL@
269 PACKAGE_VERSION = @PACKAGE_VERSION@
270 PATH_SEPARATOR = @PATH_SEPARATOR@
271 PKG_CONFIG = @PKG_CONFIG@
272 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
273 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
274 POW_LIB = @POW_LIB@
275 RANLIB = @RANLIB@
276 RPC_CFLAGS = @RPC_CFLAGS@
277 RPC_LDADD = @RPC_LDADD@
278 SET_MAKE = @SET_MAKE@
279 SHELL = @SHELL@
280 STRIP = @STRIP@
281 STRUCT_PACK = @STRUCT_PACK@
282 TCL_DEFADD = @TCL_DEFADD@
283 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
284 TCL_LDADD = @TCL_LDADD@
285 TCL_LIB_SPEC = @TCL_LIB_SPEC@
286 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
287 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
288 TIRPC_CFLAGS = @TIRPC_CFLAGS@
289 TIRPC_LIBS = @TIRPC_LIBS@
290 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
291 TK_LDADD = @TK_LDADD@
292 TK_LIB_SPEC = @TK_LIB_SPEC@
293 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
294 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
295 VERSION = @VERSION@
296 XDGDATADIR = @XDGDATADIR@
297 abs_builddir = @abs_builddir@
298 abs_srcdir = @abs_srcdir@
299 abs_top_builddir = @abs_top_builddir@
300 abs_top_srcdir = @abs_top_srcdir@
301 ac_ct_CC = @ac_ct_CC@
302 ac_ct_CXX = @ac_ct_CXX@
303 am__include = @am__include@
304 am__leading_dot = @am__leading_dot@
305 am__quote = @am__quote@
306 am__tar = @am__tar@
307 am__untar = @am__untar@
308 bindir = @bindir@
309 build_alias = @build_alias@
310 builddir = @builddir@
311 datadir = @datadir@
312 datarootdir = @datarootdir@
313 docdir = @docdir@
314 dvidir = @dvidir@
315 exec_prefix = @exec_prefix@
316 gsettingsschemadir = @gsettingsschemadir@
317 host_alias = @host_alias@
318 htmldir = @htmldir@
319 includedir = @includedir@
320 infodir = @infodir@
321 install_sh = @install_sh@
322 libdir = @libdir@
323 libexecdir = @libexecdir@
324 localedir = @localedir@
325 localstatedir = @localstatedir@
326 mandir = @mandir@
327 mkdir_p = @mkdir_p@
328 oldincludedir = @oldincludedir@
329 pdfdir = @pdfdir@
330 prefix = @prefix@
331 program_transform_name = @program_transform_name@
332 psdir = @psdir@
333 sbindir = @sbindir@
334 sharedstatedir = @sharedstatedir@
335 srcdir = @srcdir@
336 sysconfdir = @sysconfdir@
337 target_alias = @target_alias@
338 top_build_prefix = @top_build_prefix@
339 top_builddir = @top_builddir@
340 top_srcdir = @top_srcdir@
341 all: all-am
342
343 .SUFFIXES:
344 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
345 @for dep in $?; do \
346 case '$(am__configure_deps)' in \
347 *$$dep*) \
348 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
349 && { if test -f $@; then exit 0; else break; fi; }; \
350 exit 1;; \
351 esac; \
352 done; \
353 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/sorcerer/testcpp/Makefile'; \
354 $(am__cd) $(top_srcdir) && \
355 $(AUTOMAKE) --foreign contrib/pccts/sorcerer/testcpp/Makefile
356 .PRECIOUS: Makefile
357 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
358 @case '$?' in \
359 *config.status*) \
360 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
361 *) \
362 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
363 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
364 esac;
365
366 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
367 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
368
369 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
370 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
371 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
372 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
373 $(am__aclocal_m4_deps):
374 tags TAGS:
375
376 ctags CTAGS:
377
378 cscope cscopelist:
379
380
381 distdir: $(DISTFILES)
382 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
383 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
384 list='$(DISTFILES)'; \
385 dist_files=`for file in $$list; do echo $$file; done | \
386 sed -e "s|^$$srcdirstrip/||;t" \
387 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
388 case $$dist_files in \
389 */*) $(MKDIR_P) `echo "$$dist_files" | \
390 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
391 sort -u` ;; \
392 esac; \
393 for file in $$dist_files; do \
394 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
395 if test -d $$d/$$file; then \
396 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
397 if test -d "$(distdir)/$$file"; then \
398 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
399 fi; \
400 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
401 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
402 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
403 fi; \
404 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
405 else \
406 test -f "$(distdir)/$$file" \
407 || cp -p $$d/$$file "$(distdir)/$$file" \
408 || exit 1; \
409 fi; \
410 done
411 check-am: all-am
412 check: check-am
413 all-am: Makefile
414 installdirs:
415 install: install-am
416 install-exec: install-exec-am
417 install-data: install-data-am
418 uninstall: uninstall-am
419
420 install-am: all-am
421 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
422
423 installcheck: installcheck-am
424 install-strip:
425 if test -z '$(STRIP)'; then \
426 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
427 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
428 install; \
429 else \
430 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
431 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
432 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
433 fi
434 mostlyclean-generic:
435
436 clean-generic:
437
438 distclean-generic:
439 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
440 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
441
442 maintainer-clean-generic:
443 @echo "This command is intended for maintainers to use"
444 @echo "it deletes files that may require special tools to rebuild."
445 clean: clean-am
446
447 clean-am: clean-generic mostlyclean-am
448
449 distclean: distclean-am
450 -rm -f Makefile
451 distclean-am: clean-am distclean-generic
452
453 dvi: dvi-am
454
455 dvi-am:
456
457 html: html-am
458
459 html-am:
460
461 info: info-am
462
463 info-am:
464
465 install-data-am:
466
467 install-dvi: install-dvi-am
468
469 install-dvi-am:
470
471 install-exec-am:
472
473 install-html: install-html-am
474
475 install-html-am:
476
477 install-info: install-info-am
478
479 install-info-am:
480
481 install-man:
482
483 install-pdf: install-pdf-am
484
485 install-pdf-am:
486
487 install-ps: install-ps-am
488
489 install-ps-am:
490
491 installcheck-am:
492
493 maintainer-clean: maintainer-clean-am
494 -rm -f Makefile
495 maintainer-clean-am: distclean-am maintainer-clean-generic
496
497 mostlyclean: mostlyclean-am
498
499 mostlyclean-am: mostlyclean-generic
500
501 pdf: pdf-am
502
503 pdf-am:
504
505 ps: ps-am
506
507 ps-am:
508
509 uninstall-am:
510
511 .MAKE: install-am install-strip
512
513 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
514 ctags-am distclean distclean-generic distdir dvi dvi-am html \
515 html-am info info-am install install-am install-data \
516 install-data-am install-dvi install-dvi-am install-exec \
517 install-exec-am install-html install-html-am install-info \
518 install-info-am install-man install-pdf install-pdf-am \
519 install-ps install-ps-am install-strip installcheck \
520 installcheck-am installdirs maintainer-clean \
521 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
522 pdf-am ps ps-am tags-am uninstall uninstall-am
523
524
525 #scrub:
526 # (cd ./test4; make scrub)
527 # rm -rf *.o core $(SPAWN) t t2 t3 t5
528 #
529
530 # Tell versions [3.59,3.63) of GNU make to not export all variables.
531 # Otherwise a system limit (for SysV at least) may be exceeded.
532 .NOEXPORT:
+0
-174
contrib/pccts/sorcerer/tokens.h less more
0 #ifndef tokens_h
1 #define tokens_h
2 /* tokens.h -- List of labelled tokens and stuff
3 *
4 * Generated from: sor.g
5 *
6 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
7 * Purdue University Electrical Engineering
8 * ANTLR Version 1.33MR33
9 */
10 #define zzEOF_TOKEN 1
11 #define Eof 1
12 #define RExpr 2
13 #define Action 27
14 #define PassAction 28
15 #define Header 65
16 #define Tokdef 66
17 #define BLOCK 67
18 #define ALT 68
19 #define LABEL 69
20 #define OPT 70
21 #define POS_CLOSURE 71
22 #define CLOSURE 72
23 #define WILD 73
24 #define PRED_OP 74
25 #define BT 75
26 #define RULE 76
27 #define REFVAR 77
28 #define NonTerm 82
29 #define Token 83
30 #define ID 108
31 #define INT 109
32
33 #ifdef __USE_PROTOS
34 void sordesc(AST**_root);
35 #else
36 extern void sordesc();
37 #endif
38
39 #ifdef __USE_PROTOS
40 void header(AST**_root);
41 #else
42 extern void header();
43 #endif
44
45 #ifdef __USE_PROTOS
46 void tokdef(AST**_root);
47 #else
48 extern void tokdef();
49 #endif
50
51 #ifdef __USE_PROTOS
52 void class_def(AST**_root);
53 #else
54 extern void class_def();
55 #endif
56
57 #ifdef __USE_PROTOS
58 void rule(AST**_root);
59 #else
60 extern void rule();
61 #endif
62
63 #ifdef __USE_PROTOS
64 void block(AST**_root,int no_copy);
65 #else
66 extern void block();
67 #endif
68
69 #ifdef __USE_PROTOS
70 void alt(AST**_root,int no_copy);
71 #else
72 extern void alt();
73 #endif
74
75 #ifdef __USE_PROTOS
76 void element(AST**_root,int no_copy);
77 #else
78 extern void element();
79 #endif
80
81 #ifdef __USE_PROTOS
82 void labeled_element(AST**_root,int no_copy);
83 #else
84 extern void labeled_element();
85 #endif
86
87 #ifdef __USE_PROTOS
88 void token(AST**_root,int no_copy);
89 #else
90 extern void token();
91 #endif
92
93 #ifdef __USE_PROTOS
94 void tree(AST**_root,int no_copy);
95 #else
96 extern void tree();
97 #endif
98
99 #ifdef __USE_PROTOS
100 void enum_file(AST**_root);
101 #else
102 extern void enum_file();
103 #endif
104
105 #ifdef __USE_PROTOS
106 void defines(AST**_root);
107 #else
108 extern void defines();
109 #endif
110
111 #ifdef __USE_PROTOS
112 void enum_def(AST**_root);
113 #else
114 extern void enum_def();
115 #endif
116
117 #endif
118 extern SetWordType zzerr1[];
119 extern SetWordType zzerr2[];
120 extern SetWordType setwd1[];
121 extern SetWordType zzerr3[];
122 extern SetWordType zzerr4[];
123 extern SetWordType zzerr5[];
124 extern SetWordType zzerr6[];
125 extern SetWordType zzerr7[];
126 extern SetWordType zzerr8[];
127 extern SetWordType setwd2[];
128 extern SetWordType zzerr9[];
129 extern SetWordType zzerr10[];
130 extern SetWordType zzerr11[];
131 extern SetWordType zzerr12[];
132 extern SetWordType zzerr13[];
133 extern SetWordType setwd3[];
134 extern SetWordType zzerr14[];
135 extern SetWordType zzerr15[];
136 extern SetWordType zzerr16[];
137 extern SetWordType zzerr17[];
138 extern SetWordType zzerr18[];
139 extern SetWordType zzerr19[];
140 extern SetWordType zzerr20[];
141 extern SetWordType zzerr21[];
142 extern SetWordType zzerr22[];
143 extern SetWordType setwd4[];
144 extern SetWordType zzerr23[];
145 extern SetWordType zzerr24[];
146 extern SetWordType zzerr25[];
147 extern SetWordType zzerr26[];
148 extern SetWordType zzerr27[];
149 extern SetWordType zzerr28[];
150 extern SetWordType zzerr29[];
151 extern SetWordType setwd5[];
152 extern SetWordType zzerr30[];
153 extern SetWordType zzerr31[];
154 extern SetWordType zzerr32[];
155 extern SetWordType zzerr33[];
156 extern SetWordType zzerr34[];
157 extern SetWordType zzerr35[];
158 extern SetWordType zzerr36[];
159 extern SetWordType zzerr37[];
160 extern SetWordType zzerr38[];
161 extern SetWordType zzerr39[];
162 extern SetWordType setwd6[];
163 extern SetWordType zzerr40[];
164 extern SetWordType zzerr41[];
165 extern SetWordType zzerr42[];
166 extern SetWordType zzerr43[];
167 extern SetWordType setwd7[];
168 extern SetWordType zzerr44[];
169 extern SetWordType zzerr45[];
170 extern SetWordType zzerr46[];
171 extern SetWordType zzerr47[];
172 extern SetWordType zzerr48[];
173 extern SetWordType setwd8[];
+0
-5
contrib/pccts/support/DECmms/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 EXTRA_DIST= genmms.c makefile.VMS
4
+0
-456
contrib/pccts/support/DECmms/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/support/DECmms
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 am__can_run_installinfo = \
102 case $$AM_UPDATE_INFO_DIR in \
103 n|no|NO) false;; \
104 *) (install-info --version) >/dev/null 2>&1;; \
105 esac
106 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
107 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
108 ACLOCAL = @ACLOCAL@
109 AET2_CFLAGS = @AET2_CFLAGS@
110 AET2_LDADD = @AET2_LDADD@
111 ALLOCA = @ALLOCA@
112 AMTAR = @AMTAR@
113 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
114 AUTOCONF = @AUTOCONF@
115 AUTOHEADER = @AUTOHEADER@
116 AUTOMAKE = @AUTOMAKE@
117 AWK = @AWK@
118 CC = @CC@
119 CCDEPMODE = @CCDEPMODE@
120 CFLAGS = @CFLAGS@
121 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
122 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
123 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
124 CPP = @CPP@
125 CPPFLAGS = @CPPFLAGS@
126 CXX = @CXX@
127 CXXDEPMODE = @CXXDEPMODE@
128 CXXFLAGS = @CXXFLAGS@
129 CYGPATH_W = @CYGPATH_W@
130 DEFS = @DEFS@
131 DEPDIR = @DEPDIR@
132 ECHO_C = @ECHO_C@
133 ECHO_N = @ECHO_N@
134 ECHO_T = @ECHO_T@
135 EGREP = @EGREP@
136 EXEEXT = @EXEEXT@
137 EXTDEBUG = @EXTDEBUG@
138 EXTDEBUG2 = @EXTDEBUG2@
139 EXTDEBUG3 = @EXTDEBUG3@
140 EXTDEBUG4 = @EXTDEBUG4@
141 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
142 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
143 FSDB_CFLAGS = @FSDB_CFLAGS@
144 FSDB_LDADD = @FSDB_LDADD@
145 GCONF_CFLAGS = @GCONF_CFLAGS@
146 GCONF_LIBS = @GCONF_LIBS@
147 GEDITTEST = @GEDITTEST@
148 GEDIT_CFLAGS = @GEDIT_CFLAGS@
149 GIO_CFLAGS = @GIO_CFLAGS@
150 GIO_LIBS = @GIO_LIBS@
151 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
152 GPERF = @GPERF@
153 GREP = @GREP@
154 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
155 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
156 GTK_CFLAGS = @GTK_CFLAGS@
157 GTK_CONFIG = @GTK_CONFIG@
158 GTK_LIBS = @GTK_LIBS@
159 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
160 GTK_MAC_LIBS = @GTK_MAC_LIBS@
161 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
162 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
163 INSTALL = @INSTALL@
164 INSTALL_DATA = @INSTALL_DATA@
165 INSTALL_PROGRAM = @INSTALL_PROGRAM@
166 INSTALL_SCRIPT = @INSTALL_SCRIPT@
167 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
168 LDFLAGS = @LDFLAGS@
169 LEX = @LEX@
170 LEXLIB = @LEXLIB@
171 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
172 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
173 LIBBZ2_DIR = @LIBBZ2_DIR@
174 LIBBZ2_LDADD = @LIBBZ2_LDADD@
175 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
176 LIBJUDY_LDADD = @LIBJUDY_LDADD@
177 LIBOBJS = @LIBOBJS@
178 LIBS = @LIBS@
179 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
180 LIBXZ_LDADD = @LIBXZ_LDADD@
181 LIBZ_CFLAGS = @LIBZ_CFLAGS@
182 LIBZ_DIR = @LIBZ_DIR@
183 LIBZ_LDADD = @LIBZ_LDADD@
184 LTLIBOBJS = @LTLIBOBJS@
185 MAINT = @MAINT@
186 MAKEINFO = @MAKEINFO@
187 MINGW_LDADD = @MINGW_LDADD@
188 MKDIR_P = @MKDIR_P@
189 OBJEXT = @OBJEXT@
190 PACKAGE = @PACKAGE@
191 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
192 PACKAGE_NAME = @PACKAGE_NAME@
193 PACKAGE_STRING = @PACKAGE_STRING@
194 PACKAGE_TARNAME = @PACKAGE_TARNAME@
195 PACKAGE_URL = @PACKAGE_URL@
196 PACKAGE_VERSION = @PACKAGE_VERSION@
197 PATH_SEPARATOR = @PATH_SEPARATOR@
198 PKG_CONFIG = @PKG_CONFIG@
199 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
200 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
201 POW_LIB = @POW_LIB@
202 RANLIB = @RANLIB@
203 RPC_CFLAGS = @RPC_CFLAGS@
204 RPC_LDADD = @RPC_LDADD@
205 SET_MAKE = @SET_MAKE@
206 SHELL = @SHELL@
207 STRIP = @STRIP@
208 STRUCT_PACK = @STRUCT_PACK@
209 TCL_DEFADD = @TCL_DEFADD@
210 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
211 TCL_LDADD = @TCL_LDADD@
212 TCL_LIB_SPEC = @TCL_LIB_SPEC@
213 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
214 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
215 TIRPC_CFLAGS = @TIRPC_CFLAGS@
216 TIRPC_LIBS = @TIRPC_LIBS@
217 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
218 TK_LDADD = @TK_LDADD@
219 TK_LIB_SPEC = @TK_LIB_SPEC@
220 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
221 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
222 VERSION = @VERSION@
223 XDGDATADIR = @XDGDATADIR@
224 abs_builddir = @abs_builddir@
225 abs_srcdir = @abs_srcdir@
226 abs_top_builddir = @abs_top_builddir@
227 abs_top_srcdir = @abs_top_srcdir@
228 ac_ct_CC = @ac_ct_CC@
229 ac_ct_CXX = @ac_ct_CXX@
230 am__include = @am__include@
231 am__leading_dot = @am__leading_dot@
232 am__quote = @am__quote@
233 am__tar = @am__tar@
234 am__untar = @am__untar@
235 bindir = @bindir@
236 build_alias = @build_alias@
237 builddir = @builddir@
238 datadir = @datadir@
239 datarootdir = @datarootdir@
240 docdir = @docdir@
241 dvidir = @dvidir@
242 exec_prefix = @exec_prefix@
243 gsettingsschemadir = @gsettingsschemadir@
244 host_alias = @host_alias@
245 htmldir = @htmldir@
246 includedir = @includedir@
247 infodir = @infodir@
248 install_sh = @install_sh@
249 libdir = @libdir@
250 libexecdir = @libexecdir@
251 localedir = @localedir@
252 localstatedir = @localstatedir@
253 mandir = @mandir@
254 mkdir_p = @mkdir_p@
255 oldincludedir = @oldincludedir@
256 pdfdir = @pdfdir@
257 prefix = @prefix@
258 program_transform_name = @program_transform_name@
259 psdir = @psdir@
260 sbindir = @sbindir@
261 sharedstatedir = @sharedstatedir@
262 srcdir = @srcdir@
263 sysconfdir = @sysconfdir@
264 target_alias = @target_alias@
265 top_build_prefix = @top_build_prefix@
266 top_builddir = @top_builddir@
267 top_srcdir = @top_srcdir@
268 EXTRA_DIST = genmms.c makefile.VMS
269 all: all-am
270
271 .SUFFIXES:
272 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
273 @for dep in $?; do \
274 case '$(am__configure_deps)' in \
275 *$$dep*) \
276 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
277 && { if test -f $@; then exit 0; else break; fi; }; \
278 exit 1;; \
279 esac; \
280 done; \
281 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/support/DECmms/Makefile'; \
282 $(am__cd) $(top_srcdir) && \
283 $(AUTOMAKE) --foreign contrib/pccts/support/DECmms/Makefile
284 .PRECIOUS: Makefile
285 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
286 @case '$?' in \
287 *config.status*) \
288 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
289 *) \
290 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
291 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
292 esac;
293
294 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
295 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
296
297 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
298 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
299 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
300 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
301 $(am__aclocal_m4_deps):
302 tags TAGS:
303
304 ctags CTAGS:
305
306 cscope cscopelist:
307
308
309 distdir: $(DISTFILES)
310 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
311 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
312 list='$(DISTFILES)'; \
313 dist_files=`for file in $$list; do echo $$file; done | \
314 sed -e "s|^$$srcdirstrip/||;t" \
315 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
316 case $$dist_files in \
317 */*) $(MKDIR_P) `echo "$$dist_files" | \
318 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
319 sort -u` ;; \
320 esac; \
321 for file in $$dist_files; do \
322 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
323 if test -d $$d/$$file; then \
324 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
325 if test -d "$(distdir)/$$file"; then \
326 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
327 fi; \
328 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
329 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
330 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
331 fi; \
332 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
333 else \
334 test -f "$(distdir)/$$file" \
335 || cp -p $$d/$$file "$(distdir)/$$file" \
336 || exit 1; \
337 fi; \
338 done
339 check-am: all-am
340 check: check-am
341 all-am: Makefile
342 installdirs:
343 install: install-am
344 install-exec: install-exec-am
345 install-data: install-data-am
346 uninstall: uninstall-am
347
348 install-am: all-am
349 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
350
351 installcheck: installcheck-am
352 install-strip:
353 if test -z '$(STRIP)'; then \
354 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
355 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
356 install; \
357 else \
358 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
359 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
360 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
361 fi
362 mostlyclean-generic:
363
364 clean-generic:
365
366 distclean-generic:
367 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
368 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
369
370 maintainer-clean-generic:
371 @echo "This command is intended for maintainers to use"
372 @echo "it deletes files that may require special tools to rebuild."
373 clean: clean-am
374
375 clean-am: clean-generic mostlyclean-am
376
377 distclean: distclean-am
378 -rm -f Makefile
379 distclean-am: clean-am distclean-generic
380
381 dvi: dvi-am
382
383 dvi-am:
384
385 html: html-am
386
387 html-am:
388
389 info: info-am
390
391 info-am:
392
393 install-data-am:
394
395 install-dvi: install-dvi-am
396
397 install-dvi-am:
398
399 install-exec-am:
400
401 install-html: install-html-am
402
403 install-html-am:
404
405 install-info: install-info-am
406
407 install-info-am:
408
409 install-man:
410
411 install-pdf: install-pdf-am
412
413 install-pdf-am:
414
415 install-ps: install-ps-am
416
417 install-ps-am:
418
419 installcheck-am:
420
421 maintainer-clean: maintainer-clean-am
422 -rm -f Makefile
423 maintainer-clean-am: distclean-am maintainer-clean-generic
424
425 mostlyclean: mostlyclean-am
426
427 mostlyclean-am: mostlyclean-generic
428
429 pdf: pdf-am
430
431 pdf-am:
432
433 ps: ps-am
434
435 ps-am:
436
437 uninstall-am:
438
439 .MAKE: install-am install-strip
440
441 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
442 ctags-am distclean distclean-generic distdir dvi dvi-am html \
443 html-am info info-am install install-am install-data \
444 install-data-am install-dvi install-dvi-am install-exec \
445 install-exec-am install-html install-html-am install-info \
446 install-info-am install-man install-pdf install-pdf-am \
447 install-ps install-ps-am install-strip installcheck \
448 installcheck-am installdirs maintainer-clean \
449 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
450 pdf-am ps ps-am tags-am uninstall uninstall-am
451
452
453 # Tell versions [3.59,3.63) of GNU make to not export all variables.
454 # Otherwise a system limit (for SysV at least) may be exceeded.
455 .NOEXPORT:
+0
-750
contrib/pccts/support/DECmms/genmms.c less more
0 /*
1 * genmms -- a program to make VMS makefiles for PCCTS
2 *
3 * ANTLR 1.33MR10
4 * Terence John Parr 1989 - 1998
5 * Purdue University
6 * U of MN
7 *
8 *
9 * VMS version from J.F. Pieronne
10 */
11
12 #include <stdio.h>
13 #include <string.h>
14 #include <ssdef.h>
15 #include "pcctscfg.h" /* be sensitive to what ANTLR/DLG call the files */
16
17 #define DIE return SS$_ABORT;
18 #define DONE return 1;
19
20 #ifndef require
21 #define require(expr, err) {if ( !(expr) ) fatal(err);}
22 #endif
23
24 #define MAX_FILES 50
25 #define MAX_CLASSES 50
26
27 char *RENAME_OBJ_FLAG="/obj=",
28 *RENAME_EXE_FLAG="/exe=";
29
30 char *dlg = "parser.dlg";
31 char *err = "err.c";
32 char *hdr = "stdpccts.h";
33 char *tok = "tokens.h";
34 char *mode = "mode.h";
35 char *scan = "scan";
36
37 char ATOKENBUFFER_O[100];
38 char APARSER_O[100];
39 char ASTBASE_O[100];
40 char PCCTSAST_O[100];
41 char LIST_O[100];
42 char DLEXERBASE_O[100];
43
44 /* Option flags */
45 static char *project="t", *files[MAX_FILES], *classes[MAX_CLASSES];
46 static int num_files = 0;
47 static int num_classes = 0;
48 static int user_lexer = 0;
49 static char *user_token_types = NULL;
50 static int gen_CPP = 0;
51 static char *outdir=".";
52 static char *dlg_class = "DLGLexer";
53 static int gen_trees = 0;
54 static int gen_hoist = 0;
55
56 typedef struct _Opt {
57 char *option;
58 int arg;
59 #ifdef __cplusplus
60 void (*process)(...);
61 #else
62 void (*process)();
63 #endif
64 char *descr;
65 } Opt;
66
67 #ifdef __STDC__
68 static void ProcessArgs(int, char **, Opt *);
69 void fatal(char*);
70 void warn(char*);
71 static void pClass(char*, char*);
72 void pclasses(char**, int, char*);
73 void help();
74 void mk(char*, char**, int, int, char**);
75 void pfiles(char**, int n, char*);
76 #else
77 static void ProcessArgs();
78 void fatal();
79 void warn();
80 void pClass();
81 void pclasses();
82 void help();
83 void mk();
84 void pfiles();
85 #endif
86
87 static void
88 pProj( s, t )
89 char *s;
90 char *t;
91 {
92 project = t;
93 }
94
95 static void
96 pUL( s )
97 char *s;
98 {
99 user_lexer = 1;
100 }
101
102 static void
103 pCPP( s )
104 char *s;
105 {
106 gen_CPP = 1;
107 }
108
109 static void
110 pUT( s, t )
111 char *s;
112 char *t;
113 {
114 user_token_types = t;
115 }
116
117 static void
118 pTrees( s )
119 char *s;
120 {
121 gen_trees = 1;
122 }
123
124 static void
125 pHoist( s )
126 char *s;
127 {
128 gen_hoist = 1;
129 }
130
131 static void
132 #ifdef __STDC__
133 pFile( char *s )
134 #else
135 pFile( s )
136 char *s;
137 #endif
138 {
139 if ( *s=='-' )
140 {
141 fprintf(stderr, "invalid option: '%s'; ignored...",s);
142 return;
143 }
144
145 require(num_files<MAX_FILES, "exceeded max # of input files");
146 files[num_files++] = s;
147 }
148
149 static void
150 #ifdef __STDC__
151 pClass( char *s, char *t )
152 #else
153 void pClass( s, t )
154 char *s;
155 char *t;
156 #endif
157 {
158 require(num_classes<MAX_CLASSES, "exceeded max # of grammar classes");
159 classes[num_classes++] = t;
160 }
161
162 static void
163 #ifdef __STDC__
164 pDLGClass( char *s, char *t )
165 #else
166 pDLGClass( s, t )
167 char *s;
168 char *t;
169 #endif
170 {
171 if ( !gen_CPP ) {
172 fprintf(stderr, "-dlg-class makes no sense without C++ mode; ignored...");
173 }
174 else dlg_class = t;
175 }
176
177 static void
178 #ifdef __STDC__
179 pOdir( char *s, char *t )
180 #else
181 pOdir( s, t )
182 char *s;
183 char *t;
184 #endif
185 {
186 outdir = t;
187 }
188
189 static void
190 #ifdef __STDC__
191 pHdr( char *s, char *t )
192 #else
193 pHdr( s, t )
194 char *s;
195 char *t;
196 #endif
197 {
198 hdr = t;
199 }
200
201 Opt options[] = {
202 { "-cc", 0, pCPP, "Generate C++ output"},
203 { "-class", 1, pClass, "Name of a grammar class defined in grammar (if C++)"},
204 { "-dlg-class", 1,pDLGClass,"Name of DLG lexer class (default=DLGLexer) (if C++)"},
205 { "-header", 1,pHdr, "Name of ANTLR standard header info (default=no file)"},
206 { "-o", 1, pOdir, "Directory where output files should go (default=\".\")"},
207 { "-project", 1, pProj, "Name of executable to create (default=t)"},
208 { "-token-types", 1, pUT, "Token types are in this file (don't use tokens.h)"},
209 { "-trees", 0, pTrees, "Generate ASTs"},
210 { "-user-lexer", 0, pUL, "Do not create a DLG-based scanner"},
211 { "-mrhoist",0,pHoist, "Maintenance release style hoisting"},
212 { "*", 0, pFile, "" }, /* anything else is a file */
213 { NULL, 0, NULL, NULL }
214 };
215
216 extern char *DIR();
217
218 main(argc, argv)
219 int argc;
220 char **argv;
221 {
222 if ( argc == 1 ) { help(); DIE; }
223 ProcessArgs(argc-1, &(argv[1]), options);
224
225 strcpy(ATOKENBUFFER_O, ATOKENBUFFER_C);
226 ATOKENBUFFER_O[strlen(ATOKENBUFFER_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
227 strcat(ATOKENBUFFER_O, OBJ_FILE_SUFFIX);
228 strcpy(APARSER_O, APARSER_C);
229 APARSER_O[strlen(APARSER_O)-strlen(CPP_FILE_SUFFIX)] = '\0';
230 strcat(APARSER_O, OBJ_FILE_SUFFIX);
231
232 strcpy(ASTBASE_O, ASTBASE_C);
233 ASTBASE_O[strlen(ASTBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
234 strcat(ASTBASE_O, OBJ_FILE_SUFFIX);
235
236 strcpy(PCCTSAST_O, PCCTSAST_C);
237 PCCTSAST_O[strlen(PCCTSAST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
238 strcat(PCCTSAST_O, OBJ_FILE_SUFFIX);
239
240 strcpy(LIST_O, LIST_C);
241 LIST_O[strlen(LIST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
242 strcat(LIST_O, OBJ_FILE_SUFFIX);
243
244 strcpy(DLEXERBASE_O, DLEXERBASE_C);
245 DLEXERBASE_O[strlen(DLEXERBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
246 strcat(DLEXERBASE_O, OBJ_FILE_SUFFIX);
247
248 if ( num_files == 0 ) fatal("no grammar files specified; exiting...");
249 if ( !gen_CPP && num_classes>0 ) {
250 warn("can't define classes w/o C++ mode; turning on C++ mode...\n");
251 gen_CPP=1;
252 }
253 if ( gen_CPP && num_classes==0 ) {
254 fatal("must define classes >0 grammar classes in C++ mode\n");
255 }
256
257 mk(project, files, num_files, argc, argv);
258 DONE;
259 }
260
261 void help()
262 {
263 Opt *p = options;
264 static char buf[1000+1];
265
266 fprintf(stderr, "genmk [options] f1.g ... fn.g\n");
267 while ( p->option!=NULL && *(p->option) != '*' )
268 {
269 buf[0]='\0';
270 if ( p->arg ) sprintf(buf, "%s ___", p->option);
271 else strcpy(buf, p->option);
272 fprintf(stderr, "\t%-16s %s\n", buf, p->descr);
273 p++;
274 }
275 }
276
277 void mk(project, files, n, argc, argv)
278 char *project;
279 char **files;
280 int n;
281 int argc;
282 char **argv;
283 {
284 int i;
285
286 printf("!\n");
287 printf("! PCCTS makefile for: ");
288 pfiles(files, n, NULL);
289 printf("\n");
290 printf("!\n");
291 printf("! Created from:");
292 for (i=0; i<argc; i++) printf(" %s", argv[i]);
293 printf("\n");
294 printf("!\n");
295 printf("! PCCTS release 1.33MR10\n");
296 printf("! Project: %s\n", project);
297 if ( gen_CPP ) printf("! C++ output\n");
298 else printf("! C output\n");
299 if ( user_lexer ) printf("! User-defined scanner\n");
300 else printf("! DLG scanner\n");
301 if ( user_token_types!=NULL ) printf("! User-defined token types in '%s'\n", user_token_types);
302 else printf("! ANTLR-defined token types\n");
303 printf("!\n");
304 if ( user_token_types!=NULL ) {
305 printf("! Make sure #tokdefs directive in ANTLR grammar lists this file:\n");
306 printf("TOKENS = %s", user_token_types);
307 }
308 else printf("TOKENS = %stokens.h", DIR());
309 printf("\n");
310 printf("!\n");
311 printf("! The following filenames must be consistent with ANTLR/DLG flags\n");
312 printf("DLG_FILE = %s%s\n", DIR(), dlg);
313 printf("ERR = %serr\n", DIR());
314 if ( strcmp(hdr,"stdpccts.h")!=0 ) printf("HDR_FILE = %s%s\n", DIR(), hdr);
315 else printf("HDR_FILE =\n");
316 if ( !gen_CPP ) printf("MOD_FILE = %s%s\n", DIR(), mode);
317 if ( !gen_CPP ) printf("SCAN = %s\n", scan);
318 else printf("SCAN = %s%s\n", DIR(), dlg_class);
319
320 printf("PCCTS = PCCTS_ROOT\n");
321 printf("ANTLR_H = $(PCCTS):[h]\n");
322 printf("BIN = $(PCCTS):[bin]\n");
323 printf("ANTLR = mcr $(BIN)antlr\n");
324 printf("DLG = mcr $(BIN)dlg\n");
325 printf("LNKFLAGS = /traceback\n");
326 if (gen_CPP)
327 printf("CFLAGS =/ASSUME=NOHEADER_TYPE_DEFAULT/define=(__STDC__)/include=($(ANTLR_H)");
328 else
329 printf("CFLAGS = /define=(__STDC__)/include=($(ANTLR_H)");
330 if ( strcmp(outdir, ".")!=0 ) printf(", %s", outdir);
331 printf(") $(COTHER)");
332 printf("\n");
333 printf("AFLAGS =");
334 if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);
335 if ( user_lexer ) printf(" -gx");
336 if ( gen_CPP ) printf(" -\"CC\"");
337 if ( strcmp(hdr,"stdpccts.h")!=0 ) printf(" -gh %s", hdr);
338 if ( gen_trees ) printf(" -gt");
339 if ( gen_hoist ) {
340 printf(" -mrhoist on") ;
341 } else {
342 printf(" -mrhoist off");
343 };
344 printf(" $(AOTHER)");
345 printf("\n");
346 printf("DFLAGS = -\"C2\" -i");
347 if ( gen_CPP ) printf(" -\"CC\"");
348 if ( strcmp(dlg_class,"DLGLexer")!=0 ) printf(" -cl %s", dlg_class);
349 if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);
350 printf(" $(DOTHER)");
351 printf("\n");
352 printf("GRM = ");
353 pfiles(files, n, NULL);
354 printf("\n");
355 printf("SRC = ");
356 if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);
357 else pfiles(files, n, "c");
358 if ( gen_CPP ) {
359 printf(" ,-\n ");
360 printf(" ");
361 pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);
362 printf(" ,-\n ");
363 printf("$(ANTLR_H)%s", APARSER_C);
364 if ( !user_lexer ) printf(", $(ANTLR_H)%s", DLEXERBASE_C);
365 if ( gen_trees ) {
366 printf(" ,-\n ");
367 printf("$(ANTLR_H)%s,", ASTBASE_C);
368 printf(" $(ANTLR_H)%s", PCCTSAST_C);
369 /* printf(" $(ANTLR_H)%s%s", DirectorySymbol, LIST_C); */
370 }
371 printf(" ,-\n ");
372 printf(" $(ANTLR_H)%s", ATOKENBUFFER_C);
373 }
374 if ( !user_lexer ) {
375 if ( gen_CPP ) printf(", $(SCAN)%s", CPP_FILE_SUFFIX);
376 else printf(", %s$(SCAN).c", DIR());
377 }
378 if ( !gen_CPP ) printf(" $(ERR).c");
379 printf("\n");
380 printf("OBJ = ");
381 pfiles(files, n, "obj");
382 if ( gen_CPP ) {
383 printf(" ,-\n ");
384 printf(" ");
385 pclasses(classes, num_classes, "o");
386 printf(" ,-\n ");
387 printf(" %s%s", DIR(), APARSER_O);
388 if ( !user_lexer ) {
389 printf(", %s%s", DIR(), DLEXERBASE_O);
390 }
391 if ( gen_trees ) {
392 printf(" ,-\n ");
393 printf("%s%s", DIR(), ASTBASE_O);
394 printf(", %s%s", DIR(), PCCTSAST_O);
395 /* printf(" %s%s", DIR(), LIST_O); */
396 }
397 printf(", %s%s", DIR(), ATOKENBUFFER_O);
398 }
399 if ( !user_lexer ) {
400 if ( gen_CPP ) printf(", $(SCAN)%s", OBJ_FILE_SUFFIX);
401 else printf(", %s$(SCAN)%s", DIR(), OBJ_FILE_SUFFIX);
402 }
403 if ( !gen_CPP ) printf(", $(ERR)%s", OBJ_FILE_SUFFIX);
404 printf("\n");
405
406 printf("ANTLR_SPAWN = ");
407 if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);
408 else pfiles(files, n, "c");
409 if ( gen_CPP ) {
410 printf(", ");
411 pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);
412 printf(" ,-\n ");
413 pclasses(classes, num_classes, "h");
414 if ( strcmp(hdr,"stdpccts.h")!=0 ) {
415 printf(" ,-\n ");
416 printf("$(HDR_FILE), stdpccts.h");
417 }
418 }
419 if ( user_lexer ) {
420 if ( !user_token_types ) printf(", $(TOKENS)");
421 }
422 else {
423 printf(", $(DLG_FILE)");
424 if ( !user_token_types ) printf(", $(TOKENS)");
425 }
426 if ( !gen_CPP ) printf(", $(ERR).c");
427 printf("\n");
428
429 if ( !user_lexer ) {
430 if ( gen_CPP ) printf("DLG_SPAWN = $(SCAN)%s", CPP_FILE_SUFFIX);
431 else printf("DLG_SPAWN = %s$(SCAN).c", DIR());
432 if ( gen_CPP ) printf(", $(SCAN).h");
433 else printf(", $(MOD_FILE)");
434 printf("\n");
435 }
436
437 printf("ANTLR_SPAWN_ALL_VERSIONS = ");
438 if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);
439 else pfiles(files, n, "c");
440 if ( gen_CPP ) {
441 printf(";*, ");
442 pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);
443 printf(";* ,-\n ");
444 pclasses(classes, num_classes, "h");
445 printf(";*");
446 if ( strcmp(hdr,"stdpccts.h")!=0 ) {
447 printf(" ,-\n ");
448 printf("$(HDR_FILE);*, stdpccts.h;*");
449 }
450 }
451 if ( user_lexer ) {
452 if ( !user_token_types ) printf(", $(TOKENS);*");
453 }
454 else {
455 printf(", $(DLG_FILE);*");
456 if ( !user_token_types ) printf(", $(TOKENS);*");
457 }
458 if ( !gen_CPP ) printf(", $(ERR).c;*");
459 printf("\n");
460
461 if ( !user_lexer ) {
462 if ( gen_CPP ) printf("DLG_SPAWN_ALL_VERSIONS = $(SCAN)%s;*", CPP_FILE_SUFFIX);
463 else printf("DLG_SPAWN_ALL_VERSIONS = %s$(SCAN).c;*", DIR());
464 if ( gen_CPP ) printf(", $(SCAN).h;*");
465 else printf(", $(MOD_FILE);*");
466 printf("\n");
467 }
468
469 if ( gen_CPP ) {
470 printf("CCC=CXX\n");
471 printf("CC=$(CCC)\n");
472 }
473 else printf("CC=cc\n");
474
475 /* set up dependencies */
476 printf("\n%s.exe : $(OBJ), $(SRC)\n", project);
477 if (gen_CPP)
478 printf(" CXXLINK %s %s $(LNKFLAGS) $(OBJ)\n",
479 RENAME_EXE_FLAG,
480 project);
481 else
482 printf(" LINK %s %s $(LNKFLAGS) $(OBJ)\n",
483 RENAME_EXE_FLAG,
484 project);
485 printf("\n");
486
487 /* how to compile parser files */
488
489 for (i=0; i<num_files; i++)
490 {
491 pfiles(&files[i], 1, "obj");
492 if ( user_lexer ) {
493 printf(" : $(TOKENS)");
494 }
495 else {
496 if ( gen_CPP ) printf(" : $(TOKENS), $(SCAN).h");
497 else printf(" : $(MOD_FILE), $(TOKENS)");
498 }
499 printf(", ");
500 if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);
501 else pfiles(&files[i], 1, "c");
502 if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(", $(HDR_FILE)");
503 printf("\n");
504 printf(" %s $(CFLAGS) %s ",gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);
505 pfiles(&files[i], 1, "obj");
506 printf(" ");
507 if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);
508 else pfiles(&files[i], 1, "c");
509 printf("\n\n");
510 }
511
512 /* how to compile err.c */
513 if ( !gen_CPP ) {
514 printf("$(ERR)%s : $(ERR).c", OBJ_FILE_SUFFIX);
515 if ( !user_lexer ) printf(", $(TOKENS)");
516 printf("\n");
517 printf(" %s $(CFLAGS) %s $(ERR)%s $(ERR).c",
518 gen_CPP?"$(CCC)":"$(CC)",
519 RENAME_OBJ_FLAG,
520 OBJ_FILE_SUFFIX);
521 printf("\n\n");
522 }
523
524 /* how to compile Class.c */
525 for (i=0; i<num_classes; i++)
526 {
527 pclasses(&classes[i], 1, "obj");
528 if ( user_lexer ) {
529 printf(" : $(TOKENS)");
530 }
531 else {
532 printf(" : $(TOKENS), $(SCAN).h");
533 }
534 printf(", ");
535 pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);
536 printf(", ");
537 pclasses(&classes[i], 1, "h");
538 if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(", $(HDR_FILE)");
539 printf("\n");
540 printf(" %s $(CFLAGS) %s ",
541 gen_CPP?"$(CCC)":"$(CC)",
542 RENAME_OBJ_FLAG);
543 pclasses(&classes[i], 1, "obj");
544 printf(" ");
545 pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);
546 printf("\n\n");
547 }
548
549 /* how to compile scan.c */
550 if ( !user_lexer ) {
551 if ( gen_CPP ) printf("$(SCAN)%s : $(SCAN)%s", OBJ_FILE_SUFFIX, CPP_FILE_SUFFIX);
552 else printf("%s$(SCAN)%s : %s$(SCAN).c", DIR(), OBJ_FILE_SUFFIX, DIR());
553 if ( !user_lexer ) printf(", $(TOKENS)");
554 printf("\n");
555 if ( gen_CPP ) printf(" $(CCC) $(CFLAGS) %s $(SCAN)%s $(SCAN)%s",
556 RENAME_OBJ_FLAG,
557 OBJ_FILE_SUFFIX,
558 CPP_FILE_SUFFIX);
559 else printf(" $(CC) $(CFLAGS) %s %s$(SCAN)%s %s$(SCAN).c",
560 RENAME_OBJ_FLAG,
561 DIR(),
562 OBJ_FILE_SUFFIX,
563 DIR());
564 printf("\n\n");
565 }
566
567 printf("$(ANTLR_SPAWN) : $(GRM)\n");
568 printf(" $(ANTLR) $(AFLAGS) $(GRM)\n");
569
570 if ( !user_lexer )
571 {
572 printf("\n");
573 printf("$(DLG_SPAWN) : $(DLG_FILE)\n");
574 if ( gen_CPP ) printf(" $(DLG) $(DFLAGS) $(DLG_FILE)\n");
575 else printf(" $(DLG) $(DFLAGS) $(DLG_FILE) $(SCAN).c\n");
576 }
577
578 /* do the makes for ANTLR/DLG support */
579 if ( gen_CPP ) {
580 printf("\n");
581 printf("%s%s : $(ANTLR_H)%s\n", DIR(), APARSER_O, APARSER_C);
582 printf(" %s $(CFLAGS) %s ",
583 gen_CPP?"$(CCC)":"$(CC)",
584 RENAME_OBJ_FLAG);
585 printf("%s%s $(ANTLR_H)%s\n", DIR(), APARSER_O, APARSER_C);
586 printf("\n");
587 printf("%s%s : $(ANTLR_H)%s\n", DIR(), ATOKENBUFFER_O, ATOKENBUFFER_C);
588 printf(" %s $(CFLAGS) %s ",
589 gen_CPP?"$(CCC)":"$(CC)",
590 RENAME_OBJ_FLAG);
591 printf("%s%s $(ANTLR_H)%s\n", DIR(), ATOKENBUFFER_O, ATOKENBUFFER_C);
592 if ( !user_lexer ) {
593 printf("\n");
594 printf("%s%s : $(ANTLR_H)%s\n", DIR(), DLEXERBASE_O, DLEXERBASE_C);
595 printf(" %s $(CFLAGS) %s ",
596 gen_CPP?"$(CCC)":"$(CC)",
597 RENAME_OBJ_FLAG);
598 printf("%s%s $(ANTLR_H)%s\n", DIR(), DLEXERBASE_O, DLEXERBASE_C);
599 }
600 if ( gen_trees ) {
601 printf("\n");
602 printf("%s%s : $(ANTLR_H)%s\n", DIR(), ASTBASE_O, ASTBASE_C);
603 printf(" %s $(CFLAGS) %s ",
604 gen_CPP?"$(CCC)":"$(CC)",
605 RENAME_OBJ_FLAG);
606 printf("%s%s $(ANTLR_H)%s\n", DIR(), ASTBASE_O, ASTBASE_C);
607 printf("\n");
608 printf("%s%s : $(ANTLR_H)%s\n", DIR(), PCCTSAST_O, PCCTSAST_C);
609 printf(" %s $(CFLAGS) %s ",
610 gen_CPP?"$(CCC)":"$(CC)",
611 RENAME_OBJ_FLAG);
612 printf("%s%s $(ANTLR_H)%s\n", DIR(), PCCTSAST_O, PCCTSAST_C);
613 printf("\n");
614 /*
615 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);
616 printf(" %s -c $(CFLAGS) %s ",
617 gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);
618 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);
619 */
620 }
621 }
622
623 /* clean and scrub targets */
624
625 printf("\nclean :\n");
626 printf(" delete *%s.*, %s.exe.*", OBJ_FILE_SUFFIX, project);
627 if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s;*", DIR(), OBJ_FILE_SUFFIX);
628 printf("\n");
629
630 printf("\nscrub :\n");
631 printf(" delete *%s.*, %s.exe;*", OBJ_FILE_SUFFIX, project);
632 if ( strcmp(outdir, ".")!=0 ) printf(", %s*%s.*", DIR(), OBJ_FILE_SUFFIX);
633 printf(", $(ANTLR_SPAWN_ALL_VERSIONS)");
634 if ( !user_lexer ) printf(", $(DLG_SPAWN_ALL_VERSIONS)");
635 printf("\n");
636 }
637
638 void pfiles(files, n, suffix)
639 char **files;
640 int n;
641 char *suffix;
642 {
643 int first=1;
644
645 while ( n>0 )
646 {
647 char *p = &(*files)[strlen(*files)-1];
648 if ( !first ) putchar(' ');
649 first=0;
650 while ( p > *files && *p != '.' ) --p;
651 if ( p == *files )
652 {
653 fprintf(stderr,
654 "genmk: filenames must be file.suffix format: %s\n",
655 *files);
656 exit(-1);
657 }
658 if ( suffix == NULL ) printf("%s", *files);
659 else
660 {
661 *p = '\0';
662 printf("%s", DIR());
663 if ( strcmp(suffix, "o")==0 ) printf("%s%s", *files, OBJ_FILE_SUFFIX);
664 else printf("%s.%s", *files, suffix);
665 *p = '.';
666 }
667 files++;
668 --n;
669 }
670 }
671
672 void pclasses(classes, n, suffix)
673 char **classes;
674 int n;
675 char *suffix;
676 {
677 int first=1;
678
679 while ( n>0 )
680 {
681 if ( !first ) putchar(' ');
682 first=0;
683 if ( suffix == NULL ) printf("%s", *classes);
684 else {
685 printf("%s", DIR());
686 if ( strcmp(suffix, "o")==0 ) printf("%s%s", *classes, OBJ_FILE_SUFFIX);
687 else printf("%s.%s", *classes, suffix);
688 }
689 classes++;
690 --n;
691 }
692 }
693
694 static void
695 #ifdef __STDC__
696 ProcessArgs( int argc, char **argv, Opt *options )
697 #else
698 ProcessArgs( argc, argv, options )
699 int argc;
700 char **argv;
701 Opt *options;
702 #endif
703 {
704 Opt *p;
705 require(argv!=NULL, "ProcessArgs: command line NULL");
706
707 while ( argc-- > 0 )
708 {
709 p = options;
710 while ( p->option != NULL )
711 {
712 if ( strcmp(p->option, "*") == 0 ||
713 strcmp(p->option, *argv) == 0 )
714 {
715 if ( p->arg )
716 {
717 (*p->process)( *argv, *(argv+1) );
718 argv++;
719 argc--;
720 }
721 else
722 (*p->process)( *argv );
723 break;
724 }
725 p++;
726 }
727 argv++;
728 }
729 }
730
731 void fatal(char *err_)
732 {
733 fprintf(stderr, "genmk: %s\n", err_);
734 exit(1);
735 }
736
737 void warn(char *err_)
738 {
739 fprintf(stderr, "genmk: %s\n", err_);
740 }
741
742 char *DIR()
743 {
744 static char buf[200+1];
745
746 if ( strcmp(outdir,TopDirectory)==0 ) return "";
747 sprintf(buf, "%s", outdir);
748 return buf;
749 }
+0
-20
contrib/pccts/support/DECmms/makefile.VMS less more
0 $! File: MAKE.COM - Makefile for genmms OpenVMS
1 $!
2 $! History:
3 $! ---------
4 $! 28-Jan-1998 J.F. Pieronne V1.0.
5 $!
6 $ set noon !Don't stop on errors.
7 $!
8 $ if P1 .eqs. "LINK" then goto relink
9 $!
10 $!
11 $ delete/nolog *.obj;* !Get rid of existing .OBJ files.
12 $!
13 $ options = "/INCLUDE=([--.h])"
14 $ CC 'options' genmms
15 $!
16 $relink:
17 $ LINK genmms, sys$input:/options
18 ! sys$share:vaxcrtl.exe/share
19 $ EXIT
+0
-7
contrib/pccts/support/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 SUBDIRS= DECmms genmk rexpr set sym
4
5 EXTRA_DIST= msvc.dsp
6
+0
-637
contrib/pccts/support/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/support
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
102 ctags-recursive dvi-recursive html-recursive info-recursive \
103 install-data-recursive install-dvi-recursive \
104 install-exec-recursive install-html-recursive \
105 install-info-recursive install-pdf-recursive \
106 install-ps-recursive install-recursive installcheck-recursive \
107 installdirs-recursive pdf-recursive ps-recursive \
108 tags-recursive uninstall-recursive
109 am__can_run_installinfo = \
110 case $$AM_UPDATE_INFO_DIR in \
111 n|no|NO) false;; \
112 *) (install-info --version) >/dev/null 2>&1;; \
113 esac
114 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
115 distclean-recursive maintainer-clean-recursive
116 am__recursive_targets = \
117 $(RECURSIVE_TARGETS) \
118 $(RECURSIVE_CLEAN_TARGETS) \
119 $(am__extra_recursive_targets)
120 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
121 distdir
122 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
123 # Read a list of newline-separated strings from the standard input,
124 # and print each of them once, without duplicates. Input order is
125 # *not* preserved.
126 am__uniquify_input = $(AWK) '\
127 BEGIN { nonempty = 0; } \
128 { items[$$0] = 1; nonempty = 1; } \
129 END { if (nonempty) { for (i in items) print i; }; } \
130 '
131 # Make sure the list of sources is unique. This is necessary because,
132 # e.g., the same source file might be shared among _SOURCES variables
133 # for different programs/libraries.
134 am__define_uniq_tagged_files = \
135 list='$(am__tagged_files)'; \
136 unique=`for i in $$list; do \
137 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
138 done | $(am__uniquify_input)`
139 ETAGS = etags
140 CTAGS = ctags
141 DIST_SUBDIRS = $(SUBDIRS)
142 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
143 am__relativize = \
144 dir0=`pwd`; \
145 sed_first='s,^\([^/]*\)/.*$$,\1,'; \
146 sed_rest='s,^[^/]*/*,,'; \
147 sed_last='s,^.*/\([^/]*\)$$,\1,'; \
148 sed_butlast='s,/*[^/]*$$,,'; \
149 while test -n "$$dir1"; do \
150 first=`echo "$$dir1" | sed -e "$$sed_first"`; \
151 if test "$$first" != "."; then \
152 if test "$$first" = ".."; then \
153 dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
154 dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
155 else \
156 first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
157 if test "$$first2" = "$$first"; then \
158 dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
159 else \
160 dir2="../$$dir2"; \
161 fi; \
162 dir0="$$dir0"/"$$first"; \
163 fi; \
164 fi; \
165 dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
166 done; \
167 reldir="$$dir2"
168 ACLOCAL = @ACLOCAL@
169 AET2_CFLAGS = @AET2_CFLAGS@
170 AET2_LDADD = @AET2_LDADD@
171 ALLOCA = @ALLOCA@
172 AMTAR = @AMTAR@
173 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
174 AUTOCONF = @AUTOCONF@
175 AUTOHEADER = @AUTOHEADER@
176 AUTOMAKE = @AUTOMAKE@
177 AWK = @AWK@
178 CC = @CC@
179 CCDEPMODE = @CCDEPMODE@
180 CFLAGS = @CFLAGS@
181 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
182 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
183 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
184 CPP = @CPP@
185 CPPFLAGS = @CPPFLAGS@
186 CXX = @CXX@
187 CXXDEPMODE = @CXXDEPMODE@
188 CXXFLAGS = @CXXFLAGS@
189 CYGPATH_W = @CYGPATH_W@
190 DEFS = @DEFS@
191 DEPDIR = @DEPDIR@
192 ECHO_C = @ECHO_C@
193 ECHO_N = @ECHO_N@
194 ECHO_T = @ECHO_T@
195 EGREP = @EGREP@
196 EXEEXT = @EXEEXT@
197 EXTDEBUG = @EXTDEBUG@
198 EXTDEBUG2 = @EXTDEBUG2@
199 EXTDEBUG3 = @EXTDEBUG3@
200 EXTDEBUG4 = @EXTDEBUG4@
201 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
202 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
203 FSDB_CFLAGS = @FSDB_CFLAGS@
204 FSDB_LDADD = @FSDB_LDADD@
205 GCONF_CFLAGS = @GCONF_CFLAGS@
206 GCONF_LIBS = @GCONF_LIBS@
207 GEDITTEST = @GEDITTEST@
208 GEDIT_CFLAGS = @GEDIT_CFLAGS@
209 GIO_CFLAGS = @GIO_CFLAGS@
210 GIO_LIBS = @GIO_LIBS@
211 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
212 GPERF = @GPERF@
213 GREP = @GREP@
214 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
215 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
216 GTK_CFLAGS = @GTK_CFLAGS@
217 GTK_CONFIG = @GTK_CONFIG@
218 GTK_LIBS = @GTK_LIBS@
219 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
220 GTK_MAC_LIBS = @GTK_MAC_LIBS@
221 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
222 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
223 INSTALL = @INSTALL@
224 INSTALL_DATA = @INSTALL_DATA@
225 INSTALL_PROGRAM = @INSTALL_PROGRAM@
226 INSTALL_SCRIPT = @INSTALL_SCRIPT@
227 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
228 LDFLAGS = @LDFLAGS@
229 LEX = @LEX@
230 LEXLIB = @LEXLIB@
231 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
232 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
233 LIBBZ2_DIR = @LIBBZ2_DIR@
234 LIBBZ2_LDADD = @LIBBZ2_LDADD@
235 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
236 LIBJUDY_LDADD = @LIBJUDY_LDADD@
237 LIBOBJS = @LIBOBJS@
238 LIBS = @LIBS@
239 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
240 LIBXZ_LDADD = @LIBXZ_LDADD@
241 LIBZ_CFLAGS = @LIBZ_CFLAGS@
242 LIBZ_DIR = @LIBZ_DIR@
243 LIBZ_LDADD = @LIBZ_LDADD@
244 LTLIBOBJS = @LTLIBOBJS@
245 MAINT = @MAINT@
246 MAKEINFO = @MAKEINFO@
247 MINGW_LDADD = @MINGW_LDADD@
248 MKDIR_P = @MKDIR_P@
249 OBJEXT = @OBJEXT@
250 PACKAGE = @PACKAGE@
251 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
252 PACKAGE_NAME = @PACKAGE_NAME@
253 PACKAGE_STRING = @PACKAGE_STRING@
254 PACKAGE_TARNAME = @PACKAGE_TARNAME@
255 PACKAGE_URL = @PACKAGE_URL@
256 PACKAGE_VERSION = @PACKAGE_VERSION@
257 PATH_SEPARATOR = @PATH_SEPARATOR@
258 PKG_CONFIG = @PKG_CONFIG@
259 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
260 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
261 POW_LIB = @POW_LIB@
262 RANLIB = @RANLIB@
263 RPC_CFLAGS = @RPC_CFLAGS@
264 RPC_LDADD = @RPC_LDADD@
265 SET_MAKE = @SET_MAKE@
266 SHELL = @SHELL@
267 STRIP = @STRIP@
268 STRUCT_PACK = @STRUCT_PACK@
269 TCL_DEFADD = @TCL_DEFADD@
270 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
271 TCL_LDADD = @TCL_LDADD@
272 TCL_LIB_SPEC = @TCL_LIB_SPEC@
273 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
274 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
275 TIRPC_CFLAGS = @TIRPC_CFLAGS@
276 TIRPC_LIBS = @TIRPC_LIBS@
277 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
278 TK_LDADD = @TK_LDADD@
279 TK_LIB_SPEC = @TK_LIB_SPEC@
280 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
281 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
282 VERSION = @VERSION@
283 XDGDATADIR = @XDGDATADIR@
284 abs_builddir = @abs_builddir@
285 abs_srcdir = @abs_srcdir@
286 abs_top_builddir = @abs_top_builddir@
287 abs_top_srcdir = @abs_top_srcdir@
288 ac_ct_CC = @ac_ct_CC@
289 ac_ct_CXX = @ac_ct_CXX@
290 am__include = @am__include@
291 am__leading_dot = @am__leading_dot@
292 am__quote = @am__quote@
293 am__tar = @am__tar@
294 am__untar = @am__untar@
295 bindir = @bindir@
296 build_alias = @build_alias@
297 builddir = @builddir@
298 datadir = @datadir@
299 datarootdir = @datarootdir@
300 docdir = @docdir@
301 dvidir = @dvidir@
302 exec_prefix = @exec_prefix@
303 gsettingsschemadir = @gsettingsschemadir@
304 host_alias = @host_alias@
305 htmldir = @htmldir@
306 includedir = @includedir@
307 infodir = @infodir@
308 install_sh = @install_sh@
309 libdir = @libdir@
310 libexecdir = @libexecdir@
311 localedir = @localedir@
312 localstatedir = @localstatedir@
313 mandir = @mandir@
314 mkdir_p = @mkdir_p@
315 oldincludedir = @oldincludedir@
316 pdfdir = @pdfdir@
317 prefix = @prefix@
318 program_transform_name = @program_transform_name@
319 psdir = @psdir@
320 sbindir = @sbindir@
321 sharedstatedir = @sharedstatedir@
322 srcdir = @srcdir@
323 sysconfdir = @sysconfdir@
324 target_alias = @target_alias@
325 top_build_prefix = @top_build_prefix@
326 top_builddir = @top_builddir@
327 top_srcdir = @top_srcdir@
328 SUBDIRS = DECmms genmk rexpr set sym
329 EXTRA_DIST = msvc.dsp
330 all: all-recursive
331
332 .SUFFIXES:
333 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
334 @for dep in $?; do \
335 case '$(am__configure_deps)' in \
336 *$$dep*) \
337 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
338 && { if test -f $@; then exit 0; else break; fi; }; \
339 exit 1;; \
340 esac; \
341 done; \
342 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/support/Makefile'; \
343 $(am__cd) $(top_srcdir) && \
344 $(AUTOMAKE) --foreign contrib/pccts/support/Makefile
345 .PRECIOUS: Makefile
346 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
347 @case '$?' in \
348 *config.status*) \
349 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
350 *) \
351 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
352 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
353 esac;
354
355 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
356 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
357
358 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
359 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
360 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
361 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
362 $(am__aclocal_m4_deps):
363
364 # This directory's subdirectories are mostly independent; you can cd
365 # into them and run 'make' without going through this Makefile.
366 # To change the values of 'make' variables: instead of editing Makefiles,
367 # (1) if the variable is set in 'config.status', edit 'config.status'
368 # (which will cause the Makefiles to be regenerated when you run 'make');
369 # (2) otherwise, pass the desired values on the 'make' command line.
370 $(am__recursive_targets):
371 @fail=; \
372 if $(am__make_keepgoing); then \
373 failcom='fail=yes'; \
374 else \
375 failcom='exit 1'; \
376 fi; \
377 dot_seen=no; \
378 target=`echo $@ | sed s/-recursive//`; \
379 case "$@" in \
380 distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
381 *) list='$(SUBDIRS)' ;; \
382 esac; \
383 for subdir in $$list; do \
384 echo "Making $$target in $$subdir"; \
385 if test "$$subdir" = "."; then \
386 dot_seen=yes; \
387 local_target="$$target-am"; \
388 else \
389 local_target="$$target"; \
390 fi; \
391 ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
392 || eval $$failcom; \
393 done; \
394 if test "$$dot_seen" = "no"; then \
395 $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
396 fi; test -z "$$fail"
397
398 ID: $(am__tagged_files)
399 $(am__define_uniq_tagged_files); mkid -fID $$unique
400 tags: tags-recursive
401 TAGS: tags
402
403 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
404 set x; \
405 here=`pwd`; \
406 if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
407 include_option=--etags-include; \
408 empty_fix=.; \
409 else \
410 include_option=--include; \
411 empty_fix=; \
412 fi; \
413 list='$(SUBDIRS)'; for subdir in $$list; do \
414 if test "$$subdir" = .; then :; else \
415 test ! -f $$subdir/TAGS || \
416 set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
417 fi; \
418 done; \
419 $(am__define_uniq_tagged_files); \
420 shift; \
421 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
422 test -n "$$unique" || unique=$$empty_fix; \
423 if test $$# -gt 0; then \
424 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
425 "$$@" $$unique; \
426 else \
427 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
428 $$unique; \
429 fi; \
430 fi
431 ctags: ctags-recursive
432
433 CTAGS: ctags
434 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
435 $(am__define_uniq_tagged_files); \
436 test -z "$(CTAGS_ARGS)$$unique" \
437 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
438 $$unique
439
440 GTAGS:
441 here=`$(am__cd) $(top_builddir) && pwd` \
442 && $(am__cd) $(top_srcdir) \
443 && gtags -i $(GTAGS_ARGS) "$$here"
444 cscopelist: cscopelist-recursive
445
446 cscopelist-am: $(am__tagged_files)
447 list='$(am__tagged_files)'; \
448 case "$(srcdir)" in \
449 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
450 *) sdir=$(subdir)/$(srcdir) ;; \
451 esac; \
452 for i in $$list; do \
453 if test -f "$$i"; then \
454 echo "$(subdir)/$$i"; \
455 else \
456 echo "$$sdir/$$i"; \
457 fi; \
458 done >> $(top_builddir)/cscope.files
459
460 distclean-tags:
461 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
462
463 distdir: $(DISTFILES)
464 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
465 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
466 list='$(DISTFILES)'; \
467 dist_files=`for file in $$list; do echo $$file; done | \
468 sed -e "s|^$$srcdirstrip/||;t" \
469 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
470 case $$dist_files in \
471 */*) $(MKDIR_P) `echo "$$dist_files" | \
472 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
473 sort -u` ;; \
474 esac; \
475 for file in $$dist_files; do \
476 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
477 if test -d $$d/$$file; then \
478 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
479 if test -d "$(distdir)/$$file"; then \
480 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
481 fi; \
482 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
483 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
484 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
485 fi; \
486 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
487 else \
488 test -f "$(distdir)/$$file" \
489 || cp -p $$d/$$file "$(distdir)/$$file" \
490 || exit 1; \
491 fi; \
492 done
493 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
494 if test "$$subdir" = .; then :; else \
495 $(am__make_dryrun) \
496 || test -d "$(distdir)/$$subdir" \
497 || $(MKDIR_P) "$(distdir)/$$subdir" \
498 || exit 1; \
499 dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
500 $(am__relativize); \
501 new_distdir=$$reldir; \
502 dir1=$$subdir; dir2="$(top_distdir)"; \
503 $(am__relativize); \
504 new_top_distdir=$$reldir; \
505 echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
506 echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
507 ($(am__cd) $$subdir && \
508 $(MAKE) $(AM_MAKEFLAGS) \
509 top_distdir="$$new_top_distdir" \
510 distdir="$$new_distdir" \
511 am__remove_distdir=: \
512 am__skip_length_check=: \
513 am__skip_mode_fix=: \
514 distdir) \
515 || exit 1; \
516 fi; \
517 done
518 check-am: all-am
519 check: check-recursive
520 all-am: Makefile
521 installdirs: installdirs-recursive
522 installdirs-am:
523 install: install-recursive
524 install-exec: install-exec-recursive
525 install-data: install-data-recursive
526 uninstall: uninstall-recursive
527
528 install-am: all-am
529 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
530
531 installcheck: installcheck-recursive
532 install-strip:
533 if test -z '$(STRIP)'; then \
534 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
535 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
536 install; \
537 else \
538 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
539 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
540 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
541 fi
542 mostlyclean-generic:
543
544 clean-generic:
545
546 distclean-generic:
547 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
548 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
549
550 maintainer-clean-generic:
551 @echo "This command is intended for maintainers to use"
552 @echo "it deletes files that may require special tools to rebuild."
553 clean: clean-recursive
554
555 clean-am: clean-generic mostlyclean-am
556
557 distclean: distclean-recursive
558 -rm -f Makefile
559 distclean-am: clean-am distclean-generic distclean-tags
560
561 dvi: dvi-recursive
562
563 dvi-am:
564
565 html: html-recursive
566
567 html-am:
568
569 info: info-recursive
570
571 info-am:
572
573 install-data-am:
574
575 install-dvi: install-dvi-recursive
576
577 install-dvi-am:
578
579 install-exec-am:
580
581 install-html: install-html-recursive
582
583 install-html-am:
584
585 install-info: install-info-recursive
586
587 install-info-am:
588
589 install-man:
590
591 install-pdf: install-pdf-recursive
592
593 install-pdf-am:
594
595 install-ps: install-ps-recursive
596
597 install-ps-am:
598
599 installcheck-am:
600
601 maintainer-clean: maintainer-clean-recursive
602 -rm -f Makefile
603 maintainer-clean-am: distclean-am maintainer-clean-generic
604
605 mostlyclean: mostlyclean-recursive
606
607 mostlyclean-am: mostlyclean-generic
608
609 pdf: pdf-recursive
610
611 pdf-am:
612
613 ps: ps-recursive
614
615 ps-am:
616
617 uninstall-am:
618
619 .MAKE: $(am__recursive_targets) install-am install-strip
620
621 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
622 check-am clean clean-generic cscopelist-am ctags ctags-am \
623 distclean distclean-generic distclean-tags distdir dvi dvi-am \
624 html html-am info info-am install install-am install-data \
625 install-data-am install-dvi install-dvi-am install-exec \
626 install-exec-am install-html install-html-am install-info \
627 install-info-am install-man install-pdf install-pdf-am \
628 install-ps install-ps-am install-strip installcheck \
629 installcheck-am installdirs installdirs-am maintainer-clean \
630 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
631 pdf-am ps ps-am tags tags-am uninstall uninstall-am
632
633
634 # Tell versions [3.59,3.63) of GNU make to not export all variables.
635 # Otherwise a system limit (for SysV at least) may be exceeded.
636 .NOEXPORT:
+0
-13
contrib/pccts/support/genmk/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 noinst_PROGRAMS= genmk
4 genmk_SOURCES= genmk.c
5
6 # Define PC if you use a PC OS (changes directory symbol and object file extension)
7 # see pccts/h/pcctscfg.h
8 #CFLAGS=-I../../h -DPC
9 AM_CFLAGS= -I$(srcdir)/../../h
10
11 EXTRA_DIST= genmk_old.c watgenmk.mak
12
+0
-584
contrib/pccts/support/genmk/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 noinst_PROGRAMS = genmk$(EXEEXT)
79 subdir = contrib/pccts/support/genmk
80 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
81 $(top_srcdir)/depcomp
82 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
83 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
84 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
85 $(ACLOCAL_M4)
86 mkinstalldirs = $(install_sh) -d
87 CONFIG_HEADER = $(top_builddir)/config.h
88 CONFIG_CLEAN_FILES =
89 CONFIG_CLEAN_VPATH_FILES =
90 PROGRAMS = $(noinst_PROGRAMS)
91 am_genmk_OBJECTS = genmk.$(OBJEXT)
92 genmk_OBJECTS = $(am_genmk_OBJECTS)
93 genmk_LDADD = $(LDADD)
94 AM_V_P = $(am__v_P_@AM_V@)
95 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
96 am__v_P_0 = false
97 am__v_P_1 = :
98 AM_V_GEN = $(am__v_GEN_@AM_V@)
99 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
100 am__v_GEN_0 = @echo " GEN " $@;
101 am__v_GEN_1 =
102 AM_V_at = $(am__v_at_@AM_V@)
103 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
104 am__v_at_0 = @
105 am__v_at_1 =
106 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
107 depcomp = $(SHELL) $(top_srcdir)/depcomp
108 am__depfiles_maybe = depfiles
109 am__mv = mv -f
110 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
111 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
112 AM_V_CC = $(am__v_CC_@AM_V@)
113 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
114 am__v_CC_0 = @echo " CC " $@;
115 am__v_CC_1 =
116 CCLD = $(CC)
117 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
118 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
119 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
120 am__v_CCLD_0 = @echo " CCLD " $@;
121 am__v_CCLD_1 =
122 SOURCES = $(genmk_SOURCES)
123 DIST_SOURCES = $(genmk_SOURCES)
124 am__can_run_installinfo = \
125 case $$AM_UPDATE_INFO_DIR in \
126 n|no|NO) false;; \
127 *) (install-info --version) >/dev/null 2>&1;; \
128 esac
129 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
130 # Read a list of newline-separated strings from the standard input,
131 # and print each of them once, without duplicates. Input order is
132 # *not* preserved.
133 am__uniquify_input = $(AWK) '\
134 BEGIN { nonempty = 0; } \
135 { items[$$0] = 1; nonempty = 1; } \
136 END { if (nonempty) { for (i in items) print i; }; } \
137 '
138 # Make sure the list of sources is unique. This is necessary because,
139 # e.g., the same source file might be shared among _SOURCES variables
140 # for different programs/libraries.
141 am__define_uniq_tagged_files = \
142 list='$(am__tagged_files)'; \
143 unique=`for i in $$list; do \
144 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
145 done | $(am__uniquify_input)`
146 ETAGS = etags
147 CTAGS = ctags
148 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
149 ACLOCAL = @ACLOCAL@
150 AET2_CFLAGS = @AET2_CFLAGS@
151 AET2_LDADD = @AET2_LDADD@
152 ALLOCA = @ALLOCA@
153 AMTAR = @AMTAR@
154 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
155 AUTOCONF = @AUTOCONF@
156 AUTOHEADER = @AUTOHEADER@
157 AUTOMAKE = @AUTOMAKE@
158 AWK = @AWK@
159 CC = @CC@
160 CCDEPMODE = @CCDEPMODE@
161 CFLAGS = @CFLAGS@
162 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
163 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
164 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
165 CPP = @CPP@
166 CPPFLAGS = @CPPFLAGS@
167 CXX = @CXX@
168 CXXDEPMODE = @CXXDEPMODE@
169 CXXFLAGS = @CXXFLAGS@
170 CYGPATH_W = @CYGPATH_W@
171 DEFS = @DEFS@
172 DEPDIR = @DEPDIR@
173 ECHO_C = @ECHO_C@
174 ECHO_N = @ECHO_N@
175 ECHO_T = @ECHO_T@
176 EGREP = @EGREP@
177 EXEEXT = @EXEEXT@
178 EXTDEBUG = @EXTDEBUG@
179 EXTDEBUG2 = @EXTDEBUG2@
180 EXTDEBUG3 = @EXTDEBUG3@
181 EXTDEBUG4 = @EXTDEBUG4@
182 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
183 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
184 FSDB_CFLAGS = @FSDB_CFLAGS@
185 FSDB_LDADD = @FSDB_LDADD@
186 GCONF_CFLAGS = @GCONF_CFLAGS@
187 GCONF_LIBS = @GCONF_LIBS@
188 GEDITTEST = @GEDITTEST@
189 GEDIT_CFLAGS = @GEDIT_CFLAGS@
190 GIO_CFLAGS = @GIO_CFLAGS@
191 GIO_LIBS = @GIO_LIBS@
192 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
193 GPERF = @GPERF@
194 GREP = @GREP@
195 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
196 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
197 GTK_CFLAGS = @GTK_CFLAGS@
198 GTK_CONFIG = @GTK_CONFIG@
199 GTK_LIBS = @GTK_LIBS@
200 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
201 GTK_MAC_LIBS = @GTK_MAC_LIBS@
202 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
203 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
204 INSTALL = @INSTALL@
205 INSTALL_DATA = @INSTALL_DATA@
206 INSTALL_PROGRAM = @INSTALL_PROGRAM@
207 INSTALL_SCRIPT = @INSTALL_SCRIPT@
208 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
209 LDFLAGS = @LDFLAGS@
210 LEX = @LEX@
211 LEXLIB = @LEXLIB@
212 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
213 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
214 LIBBZ2_DIR = @LIBBZ2_DIR@
215 LIBBZ2_LDADD = @LIBBZ2_LDADD@
216 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
217 LIBJUDY_LDADD = @LIBJUDY_LDADD@
218 LIBOBJS = @LIBOBJS@
219 LIBS = @LIBS@
220 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
221 LIBXZ_LDADD = @LIBXZ_LDADD@
222 LIBZ_CFLAGS = @LIBZ_CFLAGS@
223 LIBZ_DIR = @LIBZ_DIR@
224 LIBZ_LDADD = @LIBZ_LDADD@
225 LTLIBOBJS = @LTLIBOBJS@
226 MAINT = @MAINT@
227 MAKEINFO = @MAKEINFO@
228 MINGW_LDADD = @MINGW_LDADD@
229 MKDIR_P = @MKDIR_P@
230 OBJEXT = @OBJEXT@
231 PACKAGE = @PACKAGE@
232 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
233 PACKAGE_NAME = @PACKAGE_NAME@
234 PACKAGE_STRING = @PACKAGE_STRING@
235 PACKAGE_TARNAME = @PACKAGE_TARNAME@
236 PACKAGE_URL = @PACKAGE_URL@
237 PACKAGE_VERSION = @PACKAGE_VERSION@
238 PATH_SEPARATOR = @PATH_SEPARATOR@
239 PKG_CONFIG = @PKG_CONFIG@
240 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
241 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
242 POW_LIB = @POW_LIB@
243 RANLIB = @RANLIB@
244 RPC_CFLAGS = @RPC_CFLAGS@
245 RPC_LDADD = @RPC_LDADD@
246 SET_MAKE = @SET_MAKE@
247 SHELL = @SHELL@
248 STRIP = @STRIP@
249 STRUCT_PACK = @STRUCT_PACK@
250 TCL_DEFADD = @TCL_DEFADD@
251 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
252 TCL_LDADD = @TCL_LDADD@
253 TCL_LIB_SPEC = @TCL_LIB_SPEC@
254 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
255 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
256 TIRPC_CFLAGS = @TIRPC_CFLAGS@
257 TIRPC_LIBS = @TIRPC_LIBS@
258 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
259 TK_LDADD = @TK_LDADD@
260 TK_LIB_SPEC = @TK_LIB_SPEC@
261 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
262 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
263 VERSION = @VERSION@
264 XDGDATADIR = @XDGDATADIR@
265 abs_builddir = @abs_builddir@
266 abs_srcdir = @abs_srcdir@
267 abs_top_builddir = @abs_top_builddir@
268 abs_top_srcdir = @abs_top_srcdir@
269 ac_ct_CC = @ac_ct_CC@
270 ac_ct_CXX = @ac_ct_CXX@
271 am__include = @am__include@
272 am__leading_dot = @am__leading_dot@
273 am__quote = @am__quote@
274 am__tar = @am__tar@
275 am__untar = @am__untar@
276 bindir = @bindir@
277 build_alias = @build_alias@
278 builddir = @builddir@
279 datadir = @datadir@
280 datarootdir = @datarootdir@
281 docdir = @docdir@
282 dvidir = @dvidir@
283 exec_prefix = @exec_prefix@
284 gsettingsschemadir = @gsettingsschemadir@
285 host_alias = @host_alias@
286 htmldir = @htmldir@
287 includedir = @includedir@
288 infodir = @infodir@
289 install_sh = @install_sh@
290 libdir = @libdir@
291 libexecdir = @libexecdir@
292 localedir = @localedir@
293 localstatedir = @localstatedir@
294 mandir = @mandir@
295 mkdir_p = @mkdir_p@
296 oldincludedir = @oldincludedir@
297 pdfdir = @pdfdir@
298 prefix = @prefix@
299 program_transform_name = @program_transform_name@
300 psdir = @psdir@
301 sbindir = @sbindir@
302 sharedstatedir = @sharedstatedir@
303 srcdir = @srcdir@
304 sysconfdir = @sysconfdir@
305 target_alias = @target_alias@
306 top_build_prefix = @top_build_prefix@
307 top_builddir = @top_builddir@
308 top_srcdir = @top_srcdir@
309 genmk_SOURCES = genmk.c
310
311 # Define PC if you use a PC OS (changes directory symbol and object file extension)
312 # see pccts/h/pcctscfg.h
313 #CFLAGS=-I../../h -DPC
314 AM_CFLAGS = -I$(srcdir)/../../h
315 EXTRA_DIST = genmk_old.c watgenmk.mak
316 all: all-am
317
318 .SUFFIXES:
319 .SUFFIXES: .c .o .obj
320 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
321 @for dep in $?; do \
322 case '$(am__configure_deps)' in \
323 *$$dep*) \
324 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
325 && { if test -f $@; then exit 0; else break; fi; }; \
326 exit 1;; \
327 esac; \
328 done; \
329 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/support/genmk/Makefile'; \
330 $(am__cd) $(top_srcdir) && \
331 $(AUTOMAKE) --foreign contrib/pccts/support/genmk/Makefile
332 .PRECIOUS: Makefile
333 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
334 @case '$?' in \
335 *config.status*) \
336 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
337 *) \
338 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
339 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
340 esac;
341
342 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
343 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
344
345 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
346 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
347 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
348 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
349 $(am__aclocal_m4_deps):
350
351 clean-noinstPROGRAMS:
352 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
353
354 genmk$(EXEEXT): $(genmk_OBJECTS) $(genmk_DEPENDENCIES) $(EXTRA_genmk_DEPENDENCIES)
355 @rm -f genmk$(EXEEXT)
356 $(AM_V_CCLD)$(LINK) $(genmk_OBJECTS) $(genmk_LDADD) $(LIBS)
357
358 mostlyclean-compile:
359 -rm -f *.$(OBJEXT)
360
361 distclean-compile:
362 -rm -f *.tab.c
363
364 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genmk.Po@am__quote@
365
366 .c.o:
367 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
368 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
369 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
370 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
371 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
372
373 .c.obj:
374 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
375 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
376 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
377 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
378 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
379
380 ID: $(am__tagged_files)
381 $(am__define_uniq_tagged_files); mkid -fID $$unique
382 tags: tags-am
383 TAGS: tags
384
385 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
386 set x; \
387 here=`pwd`; \
388 $(am__define_uniq_tagged_files); \
389 shift; \
390 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
391 test -n "$$unique" || unique=$$empty_fix; \
392 if test $$# -gt 0; then \
393 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
394 "$$@" $$unique; \
395 else \
396 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
397 $$unique; \
398 fi; \
399 fi
400 ctags: ctags-am
401
402 CTAGS: ctags
403 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
404 $(am__define_uniq_tagged_files); \
405 test -z "$(CTAGS_ARGS)$$unique" \
406 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
407 $$unique
408
409 GTAGS:
410 here=`$(am__cd) $(top_builddir) && pwd` \
411 && $(am__cd) $(top_srcdir) \
412 && gtags -i $(GTAGS_ARGS) "$$here"
413 cscopelist: cscopelist-am
414
415 cscopelist-am: $(am__tagged_files)
416 list='$(am__tagged_files)'; \
417 case "$(srcdir)" in \
418 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
419 *) sdir=$(subdir)/$(srcdir) ;; \
420 esac; \
421 for i in $$list; do \
422 if test -f "$$i"; then \
423 echo "$(subdir)/$$i"; \
424 else \
425 echo "$$sdir/$$i"; \
426 fi; \
427 done >> $(top_builddir)/cscope.files
428
429 distclean-tags:
430 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
431
432 distdir: $(DISTFILES)
433 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
434 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
435 list='$(DISTFILES)'; \
436 dist_files=`for file in $$list; do echo $$file; done | \
437 sed -e "s|^$$srcdirstrip/||;t" \
438 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
439 case $$dist_files in \
440 */*) $(MKDIR_P) `echo "$$dist_files" | \
441 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
442 sort -u` ;; \
443 esac; \
444 for file in $$dist_files; do \
445 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
446 if test -d $$d/$$file; then \
447 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
448 if test -d "$(distdir)/$$file"; then \
449 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
450 fi; \
451 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
452 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
453 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
454 fi; \
455 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
456 else \
457 test -f "$(distdir)/$$file" \
458 || cp -p $$d/$$file "$(distdir)/$$file" \
459 || exit 1; \
460 fi; \
461 done
462 check-am: all-am
463 check: check-am
464 all-am: Makefile $(PROGRAMS)
465 installdirs:
466 install: install-am
467 install-exec: install-exec-am
468 install-data: install-data-am
469 uninstall: uninstall-am
470
471 install-am: all-am
472 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
473
474 installcheck: installcheck-am
475 install-strip:
476 if test -z '$(STRIP)'; then \
477 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
478 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
479 install; \
480 else \
481 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
482 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
483 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
484 fi
485 mostlyclean-generic:
486
487 clean-generic:
488
489 distclean-generic:
490 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
491 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
492
493 maintainer-clean-generic:
494 @echo "This command is intended for maintainers to use"
495 @echo "it deletes files that may require special tools to rebuild."
496 clean: clean-am
497
498 clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am
499
500 distclean: distclean-am
501 -rm -rf ./$(DEPDIR)
502 -rm -f Makefile
503 distclean-am: clean-am distclean-compile distclean-generic \
504 distclean-tags
505
506 dvi: dvi-am
507
508 dvi-am:
509
510 html: html-am
511
512 html-am:
513
514 info: info-am
515
516 info-am:
517
518 install-data-am:
519
520 install-dvi: install-dvi-am
521
522 install-dvi-am:
523
524 install-exec-am:
525
526 install-html: install-html-am
527
528 install-html-am:
529
530 install-info: install-info-am
531
532 install-info-am:
533
534 install-man:
535
536 install-pdf: install-pdf-am
537
538 install-pdf-am:
539
540 install-ps: install-ps-am
541
542 install-ps-am:
543
544 installcheck-am:
545
546 maintainer-clean: maintainer-clean-am
547 -rm -rf ./$(DEPDIR)
548 -rm -f Makefile
549 maintainer-clean-am: distclean-am maintainer-clean-generic
550
551 mostlyclean: mostlyclean-am
552
553 mostlyclean-am: mostlyclean-compile mostlyclean-generic
554
555 pdf: pdf-am
556
557 pdf-am:
558
559 ps: ps-am
560
561 ps-am:
562
563 uninstall-am:
564
565 .MAKE: install-am install-strip
566
567 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
568 clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \
569 distclean-compile distclean-generic distclean-tags distdir dvi \
570 dvi-am html html-am info info-am install install-am \
571 install-data install-data-am install-dvi install-dvi-am \
572 install-exec install-exec-am install-html install-html-am \
573 install-info install-info-am install-man install-pdf \
574 install-pdf-am install-ps install-ps-am install-strip \
575 installcheck installcheck-am installdirs maintainer-clean \
576 maintainer-clean-generic mostlyclean mostlyclean-compile \
577 mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
578 uninstall-am
579
580
581 # Tell versions [3.59,3.63) of GNU make to not export all variables.
582 # Otherwise a system limit (for SysV at least) may be exceeded.
583 .NOEXPORT:
+0
-1068
contrib/pccts/support/genmk/genmk.c less more
0 /*
1 * genmk -- a program to make makefiles for PCCTS
2 *
3 * ANTLR 1.33MR23
4 * Terence John Parr 1989 - 2000
5 * Purdue University
6 * U of MN
7 */
8
9 #include <stdio.h>
10 #include <string.h>
11 #include "pcctscfg.h" /* be sensitive to what ANTLR/DLG call the files */
12
13 #ifdef __STDC__
14 void pclasses(char **classes, int n, char *suffix);
15 #endif
16
17
18 #ifdef VAXC
19 #define DIE return 0;
20 #define DONE return 1;
21 #else
22 #define DIE return 1;
23 #define DONE return 0;
24 #endif
25
26 #ifndef require
27 #define require(expr, err) {if ( !(expr) ) fatal(err);}
28 #endif
29
30 #define MAX_FILES 50
31 #define MAX_CFILES 1600
32 #define MAX_SFILES 50
33 #define MAX_SORS 50
34 #define MAX_CLASSES 50
35
36 char *RENAME_OBJ_FLAG="-o",
37 *RENAME_EXE_FLAG="-o";
38
39 char *dlg = "parser.dlg";
40 char *err = "err.c";
41 char *hdr = "stdpccts.h";
42 char *tok = "tokens.h";
43 char *mode = "mode.h";
44 char *scan = "scan";
45
46 char ATOKENBUFFER_O[100];
47 char APARSER_O[100];
48 char ASTBASE_O[100];
49 char PCCTSAST_O[100];
50 char LIST_O[100];
51 char DLEXERBASE_O[100];
52
53 /* Option flags */
54 static char *project="t", *files[MAX_FILES], *classes[MAX_CLASSES];
55 static char *cfiles[MAX_CFILES];
56 static char *sfiles[MAX_SORS][MAX_SFILES],*sclasses[MAX_SORS];
57 static int num_sfiles[MAX_SORS]; /*sorcerer files in group */
58 static int num_sors = 0; /*sorcerer groups */
59 static int num_files = 0; /* grammar files */
60 static int num_cfiles = 0; /* additional C/C++ files */
61 static int num_classes = 0; /* ANTLR classes */
62 static int user_lexer = 0;
63 static char *user_token_types = NULL;
64 static int gen_CPP = 0;
65 static char *outdir=".";
66 static char *dlg_class = "DLGLexer";
67 static int gen_trees = 0;
68 static int gen_hoist = 0;
69 static int nondef_comp = 0; /* 1=compiler is non default */
70 static char *compilerCCC="CC";
71 static char *compilerCC="cc";
72 static char *pccts_path="/usr/local/pccts";
73
74 #ifdef __STDC__
75 void help(void);
76 void mk(char *project, char **files, int n, int argc, char **argv);
77 void pfiles(char **files, int n, char *suffix);
78 void fatal(char *msg);
79 void warn(char *msg);
80 #else
81 void help();
82 void mk();
83 void pfiles();
84 void fatal();
85 void warn();
86 #endif
87
88 typedef struct _Opt {
89 char *option;
90 int arg;
91 #ifdef __cplusplus
92 void (*process)(...);
93 #else
94 void (*process)();
95 #endif
96 char *descr;
97 } Opt;
98
99 #ifdef __STDC__
100 static void ProcessArgs(int, char **, Opt *);
101 #else
102 static void ProcessArgs();
103 #endif
104
105 static void
106 #ifdef __STDC__
107 pProj(char *s, char *t )
108 #else
109 pProj( s, t )
110 char *s;
111 char *t;
112 #endif
113 {
114 project = t;
115 }
116
117 static void
118 #ifdef __STDC__
119 pUL( char *s )
120 #else
121 pUL( s )
122 char *s;
123 #endif
124 {
125 user_lexer = 1;
126 }
127
128 static void
129 #ifdef __STDC__
130 pCPP( char *s )
131 #else
132 pCPP( s )
133 char *s;
134 #endif
135 {
136 gen_CPP = 1;
137 }
138
139 static void
140 #ifdef __STDC__
141 pUT( char *s, char *t )
142 #else
143 pUT( s, t )
144 char *s;
145 char *t;
146 #endif
147 {
148 user_token_types = t;
149 }
150
151 static void
152 #ifdef __STDC__
153 pTrees( char *s )
154 #else
155 pTrees( s )
156 char *s;
157 #endif
158 {
159 gen_trees = 1;
160 }
161
162 static void
163 #ifdef __STDC__
164 pHoist( char *s )
165 #else
166 pHoist( s )
167 char *s;
168 #endif
169 {
170 gen_hoist = 1;
171 }
172
173 static void
174 #ifdef __STDC__
175 pSor( char *s )
176 #else
177 pSor( s )
178 char *s;
179 #endif
180 {
181 require(num_sors<MAX_SORS, "exceeded max # of sorcerer groups");
182 num_sors++;
183 pTrees(NULL); /* silently turn on tree generation */
184 }
185
186 static void
187 #ifdef __STDC__
188 pSFiles( char *s, char *t )
189 #else
190 pSFiles( s, t )
191 char *s;
192 char *t;
193 #endif
194 {
195 if (num_sors==0)
196 {
197 pSor(NULL);
198 warn("sorcerer input file before any '-sor' option");
199 }
200
201 require(num_sfiles[num_sors-1]<MAX_SFILES,
202 "exceeded max # of sorcerer input files");
203 sfiles[num_sors-1][num_sfiles[num_sors-1]++] = t;
204 }
205
206 static void
207 #ifdef __STDC__
208 pCFiles( char *s, char *t )
209 #else
210 pCFiles( s, t )
211 char *s;
212 char *t;
213 #endif
214 {
215 require(num_cfiles<MAX_CFILES, "exceeded max # of C/C++ input files");
216 cfiles[num_cfiles++] = t;
217 }
218
219 int
220 #ifdef __STDC__
221 isKnownSuffix( char *s )
222 #else
223 isKnownSuffix( s )
224 char *s;
225 #endif
226 {
227 if(s==NULL) return 0;
228 if (strcasecmp(s,".c")==0) return 1;
229 if (strcasecmp(s,".cc")==0) return 1;
230 if (strcasecmp(s,".cpp")==0) return 1;
231 if (strcasecmp(s,".cxx")==0) return 1;
232 if (strcasecmp(s,CPP_FILE_SUFFIX)==0) return 1;
233 if (strcasecmp(s,".sor")==0) return 2;
234 return 0;
235 }
236
237 static void
238 #ifdef __STDC__
239 pFile( char *s )
240 #else
241 pFile( s )
242 char *s;
243 #endif
244 {
245 if ( *s=='-' )
246 {
247 fprintf(stderr, "invalid option: '%s'; ignored...",s);
248 return;
249 }
250 switch(isKnownSuffix(strrchr(s,'.')))
251 {
252 case 1: /* c/c++ */
253 pCFiles("-cfiles",s);
254 return;
255 case 2: /* sorcerer */
256 pSFiles("",s);
257 return;
258 default: /* grammar (ANTLR) */
259 break;
260 }
261 require(num_files<MAX_FILES, "exceeded max # of input files");
262 files[num_files++] = s;
263 }
264
265 static void
266 #ifdef __STDC__
267 pClass( char *s, char *t )
268 #else
269 pClass( s, t )
270 char *s;
271 char *t;
272 #endif
273 {
274 if (num_sors==0)
275 {
276 require(num_classes<MAX_CLASSES, "exceeded max # of grammar classes");
277 classes[num_classes++] = t;
278 } else
279 {
280 sclasses[num_sors-1] = t; /* one class per sorcerer group (last valid) */
281 }
282 }
283
284 static void
285 #ifdef __STDC__
286 pDLGClass( char *s, char *t )
287 #else
288 pDLGClass( s, t )
289 char *s;
290 char *t;
291 #endif
292 {
293 if ( !gen_CPP ) {
294 fprintf(stderr, "-dlg-class makes no sense without C++ mode; ignored...");
295 }
296 else dlg_class = t;
297 }
298
299 static void
300 #ifdef __STDC__
301 pOdir( char *s, char *t )
302 #else
303 pOdir( s, t )
304 char *s;
305 char *t;
306 #endif
307 {
308 outdir = t;
309 }
310
311 static void
312 #ifdef __STDC__
313 pHdr( char *s, char *t )
314 #else
315 pHdr( s, t )
316 char *s;
317 char *t;
318 #endif
319 {
320 hdr = t;
321 }
322
323 static void
324 #ifdef __STDC__
325 pCompiler( char *s, char *t )
326 #else
327 pCompiler( s, t )
328 char *s;
329 char *t;
330 #endif
331 {
332 compilerCCC = t;
333 compilerCC = t;
334 nondef_comp = 1;
335 }
336
337 static void
338 #ifdef __STDC__
339 ppccts_path( char *s, char *t )
340 #else
341 ppccts_path( s, t )
342 char *s;
343 char *t;
344 #endif
345 {
346 pccts_path = t;
347 }
348
349 Opt options[] = {
350 { "-CC", 0, pCPP, "Generate C++ output"},
351 { "-class", 1, pClass, "Name of a grammar class defined in grammar (if C++)"},
352 { "-dlg-class", 1,pDLGClass,"Name of DLG lexer class (default=DLGLexer) (if C++)"},
353 { "-header", 1,pHdr, "Name of ANTLR standard header info (default=no file)"},
354 { "-o", 1, pOdir, "Directory where output files should go (default=\".\")"},
355 { "-project", 1, pProj, "Name of executable to create (default=t)"},
356 { "-token-types", 1, pUT, "Token types are in this file (don't use tokens.h)"},
357 { "-trees", 0, pTrees, "Generate ASTs"},
358 { "-user-lexer", 0, pUL, "Do not create a DLG-based scanner"},
359 { "-mrhoist",0,pHoist, "Maintenance release style hoisting"},
360 { "-cfiles",1,pCFiles, "Additional files in C or C++ to compile"},
361 { "-sor",0,pSor, "Start of sorcerer group"},
362 { "-pccts_path",1,ppccts_path,
363 "Path for $PCCTS directory (default is /usr/local/pccts)"},
364 { "-compiler",1,pCompiler,
365 "Default compiler (default is CC/cc)"},
366 { "*", 0,pFile, "" }, /* anything else is a file */
367 { NULL, 0, NULL, NULL }
368 };
369
370 #ifdef __STDC__
371 extern char *DIR(void);
372 #else
373 extern char *DIR();
374 #endif
375
376 #ifdef __STDC__
377 int main(int argc, char **argv)
378 #else
379 int main(argc, argv)
380 int argc;
381 char **argv;
382 #endif
383 {
384 int i;
385
386 if ( argc == 1 ) { help(); DIE; }
387 for(i=0;i<MAX_SORS;i++) num_sfiles[i]=0;
388
389 ProcessArgs(argc-1, &(argv[1]), options);
390
391 strcpy(ATOKENBUFFER_O, ATOKENBUFFER_C);
392 ATOKENBUFFER_O[strlen(ATOKENBUFFER_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
393 strcat(ATOKENBUFFER_O, OBJ_FILE_SUFFIX);
394 strcpy(APARSER_O, APARSER_C);
395 APARSER_O[strlen(APARSER_O)-strlen(CPP_FILE_SUFFIX)] = '\0';
396 strcat(APARSER_O, OBJ_FILE_SUFFIX);
397
398 strcpy(ASTBASE_O, ASTBASE_C);
399 ASTBASE_O[strlen(ASTBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
400 strcat(ASTBASE_O, OBJ_FILE_SUFFIX);
401
402 strcpy(PCCTSAST_O, PCCTSAST_C);
403 PCCTSAST_O[strlen(PCCTSAST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
404 strcat(PCCTSAST_O, OBJ_FILE_SUFFIX);
405
406 strcpy(LIST_O, LIST_C);
407 LIST_O[strlen(LIST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
408 strcat(LIST_O, OBJ_FILE_SUFFIX);
409
410 strcpy(DLEXERBASE_O, DLEXERBASE_C);
411 DLEXERBASE_O[strlen(DLEXERBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
412 strcat(DLEXERBASE_O, OBJ_FILE_SUFFIX);
413
414 if ( num_files == 0 ) fatal("no grammar files specified; exiting...");
415 if ( !gen_CPP && num_classes>0 ) {
416 warn("can't define classes w/o C++ mode; turning on C++ mode...\n");
417 gen_CPP=1;
418 }
419 if (!gen_CPP && num_sors) {
420 warn("can't define sorcerer group in C mode (yet); turning on C++ mode...\n");
421 gen_CPP=1;
422 }
423 if ( gen_CPP && num_classes==0 ) {
424 fatal("must define classes >0 grammar classes in C++ mode\n");
425 }
426
427 mk(project, files, num_files, argc, argv);
428 DONE;
429 }
430
431 #ifdef __STDC__
432 void help(void)
433 #else
434 void help()
435 #endif
436 {
437 Opt *p = options;
438 static char buf[1000+1];
439
440 fprintf(stderr, "genmk [options] f1.g ... fn.g\n");
441 while ( p->option!=NULL && *(p->option) != '*' )
442 {
443 buf[0]='\0';
444 if ( p->arg ) sprintf(buf, "%s ___", p->option);
445 else strcpy(buf, p->option);
446 fprintf(stderr, "\t%-16s %s\n", buf, p->descr);
447 p++;
448 }
449 }
450
451 #ifdef __STDC__
452 void mk(char *project, char **files, int n, int argc, char **argv)
453 #else
454 void mk(project, files, n, argc, argv)
455 char *project;
456 char **files;
457 int n;
458 int argc;
459 char **argv;
460 #endif
461 {
462 int i,j;
463
464 printf("#\n");
465 printf("# PCCTS makefile for: ");
466 pfiles(files, n, NULL);
467 printf("\n");
468 printf("#\n");
469 printf("# Created from:");
470 for (i=0; i<argc; i++) printf(" %s", argv[i]);
471 printf("\n");
472 printf("#\n");
473 printf("# PCCTS release 1.33MR23\n");
474 printf("# Project: %s\n", project);
475 if ( gen_CPP ) printf("# C++ output\n");
476 else printf("# C output\n");
477 if ( user_lexer ) printf("# User-defined scanner\n");
478 else printf("# DLG scanner\n");
479 if ( user_token_types!=NULL ) printf("# User-defined token types in '%s'\n", user_token_types);
480 else printf("# ANTLR-defined token types\n");
481 printf("#\n");
482 /***********
483 printf(".SUFFIXES:\n.SUFFIXES:\t.o .cpp .c .h .g .i .dlg .sor\n");
484 ***********/
485 if ( user_token_types!=NULL ) {
486 printf("# Make sure #tokdefs directive in ANTLR grammar lists this file:\n");
487 printf("TOKENS = %s", user_token_types);
488 }
489 else printf("TOKENS = %stokens.h", DIR());
490 printf("\n");
491 printf("#\n");
492 printf("# The following filenames must be consistent with ANTLR/DLG flags\n");
493 printf("DLG_FILE = %s%s\n", DIR(), dlg);
494 printf("ERR = %serr\n", DIR());
495 if ( strcmp(hdr,"stdpccts.h")!=0 ) printf("HDR_FILE = %s%s\n", DIR(), hdr);
496 else printf("HDR_FILE =\n");
497 if ( !gen_CPP ) printf("MOD_FILE = %s%s\n", DIR(), mode);
498 if ( !gen_CPP ) printf("SCAN = %s\n", scan);
499 else printf("SCAN = %s%s\n", DIR(), dlg_class);
500
501 printf("PCCTS = %s\n",pccts_path);
502 printf("ANTLR_H = $(PCCTS)%sh\n", DirectorySymbol);
503 if (num_sors>0) {
504 printf("SOR_H = $(PCCTS)%ssorcerer%sh\n", DirectorySymbol, DirectorySymbol);
505 printf("SOR_LIB = $(PCCTS)%ssorcerer%slib\n",
506 DirectorySymbol, DirectorySymbol);
507 }
508 printf("BIN = $(PCCTS)%sbin\n", DirectorySymbol);
509 printf("ANTLR = $(BIN)%santlr\n", DirectorySymbol);
510 printf("DLG = $(BIN)%sdlg\n", DirectorySymbol);
511 if (num_sors>0) printf("SOR = $(BIN)%ssor\n", DirectorySymbol);
512 printf("CFLAGS = -I. -I$(ANTLR_H)");
513 if (num_sors>0) printf(" -I$(SOR_H)");
514 if ( strcmp(outdir, ".")!=0 ) printf(" -I%s", outdir);
515 printf(" $(COTHER)");
516 printf("\n");
517 printf("AFLAGS =");
518 if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);
519 if ( user_lexer ) printf(" -gx");
520 if ( gen_CPP ) printf(" -CC");
521 if ( strcmp(hdr,"stdpccts.h")!=0 ) printf(" -gh %s", hdr);
522 if ( gen_trees ) printf(" -gt");
523 if ( gen_hoist ) {
524 printf(" -mrhoist on") ;
525 } else {
526 printf(" -mrhoist off");
527 };
528 printf(" $(AOTHER)");
529 printf("\n");
530 printf("DFLAGS = -C2 -i");
531 if ( gen_CPP ) printf(" -CC");
532 if ( strcmp(dlg_class,"DLGLexer")!=0 ) printf(" -cl %s", dlg_class);
533 if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);
534 printf(" $(DOTHER)");
535 printf("\n");
536 if (num_sors>0)
537 {
538 printf("SFLAGS = -CPP");
539 if ( strcmp(outdir,".")!=0 ) printf(" -out-dir %s", outdir);
540 printf(" $(SOTHER)\n");
541 }
542 printf("GRM = ");
543 pfiles(files, n, NULL);
544 printf("\n");
545 printf("SRC = ");
546 if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);
547 else pfiles(files, n, "c");
548 if ( gen_CPP ) {
549 printf(" \\\n\t");
550 pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);
551 printf(" \\\n\t");
552 printf("$(ANTLR_H)%s%s", DirectorySymbol, APARSER_C);
553 if ( !user_lexer ) printf(" $(ANTLR_H)%s%s", DirectorySymbol, DLEXERBASE_C);
554 if ( gen_trees ) {
555 printf(" \\\n\t");
556 printf("$(ANTLR_H)%s%s", DirectorySymbol, ASTBASE_C);
557 printf(" $(ANTLR_H)%s%s", DirectorySymbol, PCCTSAST_C);
558 /* printf(" $(ANTLR_H)%s%s", DirectorySymbol, LIST_C); */
559 printf(" \\\n\t");
560 }
561 printf(" $(ANTLR_H)%s%s", DirectorySymbol, ATOKENBUFFER_C);
562 }
563 if ( !user_lexer ) {
564 if ( gen_CPP ) printf(" $(SCAN)%s", CPP_FILE_SUFFIX);
565 else printf(" %s$(SCAN).c", DIR());
566 }
567 if ( !gen_CPP ) printf(" $(ERR).c");
568 for (i=0;i<num_sors;i++)
569 {
570 printf(" \\\n\t");
571 pclasses(&sclasses[i],1,CPP_FILE_SUFFIX_NO_DOT);
572 printf(" ");
573 pfiles(&sfiles[i][0],num_sfiles[i],CPP_FILE_SUFFIX_NO_DOT);
574 }
575 if(num_sors>0)
576 printf(" \\\n\t$(SOR_LIB)%sSTreeParser.cpp", DirectorySymbol);
577 if (num_cfiles>0)
578 {
579 printf(" \\\n\t");
580 pfiles(cfiles,num_cfiles,NULL);
581 }
582 printf("\n\n");
583 printf("OBJ = ");
584 pfiles(files, n, "o");
585 if ( gen_CPP ) {
586 printf(" \\\n\t");
587 pclasses(classes, num_classes, "o");
588 printf(" \\\n\t");
589 printf("%s%s", DIR(), APARSER_O);
590 if ( !user_lexer ) {
591 printf(" %s%s", DIR(), DLEXERBASE_O);
592 }
593 if ( gen_trees ) {
594 printf(" \\\n\t");
595 printf("%s%s", DIR(), ASTBASE_O);
596 printf(" %s%s", DIR(), PCCTSAST_O);
597 /* printf(" %s%s", DIR(), LIST_O); */
598 printf(" \\\n\t");
599 }
600 printf(" %s%s", DIR(), ATOKENBUFFER_O);
601 }
602 if ( !user_lexer ) {
603 if ( gen_CPP ) printf(" $(SCAN)%s", OBJ_FILE_SUFFIX);
604 else printf(" %s$(SCAN)%s", DIR(), OBJ_FILE_SUFFIX);
605 }
606 if ( !gen_CPP ) printf(" $(ERR)%s", OBJ_FILE_SUFFIX);
607 for (i=0;i<num_sors;i++)
608 {
609 printf(" \\\n\t");
610 pclasses(&sclasses[i],1,"o");
611 printf(" ");
612 pfiles(&sfiles[i][0],num_sfiles[i],"o");
613 }
614 if(num_sors>0) printf(" \\\n\tSTreeParser.o");
615 if (num_cfiles>0)
616 {
617 printf(" \\\n\t");
618 pfiles(cfiles,num_cfiles,"o");
619 }
620 printf("\n\n");
621
622 printf("ANTLR_SPAWN = ");
623 if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);
624 else pfiles(files, n, "c");
625 if ( gen_CPP ) {
626 printf(" ");
627 pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);
628 printf(" \\\n\t\t");
629 pclasses(classes, num_classes, "h");
630 if ( strcmp(hdr,"stdpccts.h")!=0 ) {
631 printf(" \\\n\t\t");
632 printf("$(HDR_FILE) stdpccts.h");
633 }
634 }
635 if ( user_lexer ) {
636 if ( !user_token_types ) printf(" $(TOKENS)");
637 }
638 else {
639 printf(" $(DLG_FILE)");
640 if ( !user_token_types ) printf(" $(TOKENS)");
641 }
642 if ( !gen_CPP ) printf(" $(ERR).c");
643 printf("\n");
644
645 if ( !user_lexer ) {
646 if ( gen_CPP ) printf("DLG_SPAWN = $(SCAN)%s", CPP_FILE_SUFFIX);
647 else printf("DLG_SPAWN = %s$(SCAN).c", DIR());
648 if ( gen_CPP ) printf(" $(SCAN).h");
649 if ( !gen_CPP ) printf(" $(MOD_FILE)");
650 printf("\n");
651 }
652
653 if ( gen_CPP ) {
654 if ( !nondef_comp )
655 printf("ifdef CXX\nCCC = $(CXX)\nendif\n\nifndef CCC\n");
656 printf("CCC = %s\n",compilerCCC);
657 if ( !nondef_comp ) printf("endif\n\n");
658 }
659 else
660 {
661 if ( !nondef_comp ) printf("ifndef CC\n");
662 printf("CC = %s\n",compilerCC);
663 if ( !nondef_comp ) printf("endif\n\n");
664 }
665
666 /* set up dependencies */
667 printf("\n%s : $(SRC) $(OBJ)\n", project);
668 printf("\t%s %s %s $(CFLAGS) $(OBJ)\n",
669 gen_CPP?"$(CCC)":"$(CC)",
670 RENAME_EXE_FLAG,
671 project);
672 printf("\n");
673
674 /* implicit rules */
675
676 /* if(gen_CPP)
677 printf("%%.o : %%.cpp\n\t$(CCC) -c $(CFLAGS) $<\n\n");
678
679 printf("%%.o : %%.c\n\t%s -c $(CFLAGS) $<\n\n",
680 gen_CPP?"$(CCC)":"$(CC)");
681 */
682 /* how to compile parser files */
683
684 for (i=0; i<num_files; i++)
685 {
686 pfiles(&files[i], 1, "o");
687 if ( user_lexer ) {
688 printf(" : $(TOKENS)");
689 }
690 else {
691 if ( gen_CPP ) printf(" : $(TOKENS) $(SCAN).h");
692 else printf(" : $(MOD_FILE) $(TOKENS)");
693 }
694 printf(" ");
695 if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);
696 else pfiles(&files[i], 1, "c");
697 if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");
698 printf("\n");
699 printf("\t%s -c $(CFLAGS) %s ",
700 gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);
701 pfiles(&files[i], 1, "o");
702 printf(" ");
703 if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);
704 else pfiles(&files[i], 1, "c");
705 printf("\n\n");
706 }
707
708 for (i=0; i<num_cfiles; i++)
709 {
710 pfiles(&cfiles[i], 1, "o");
711 printf(" : ");
712 pfiles(&cfiles[i], 1, NULL);
713 if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");
714 /*** printf(" "); ***/
715 /*** pfiles(&cfiles[i], 1, "h"); ***/
716 printf("\n");
717 printf("\t%s -c $(CFLAGS) %s ",
718 gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);
719 pfiles(&cfiles[i], 1, "o");
720 printf(" ");
721 pfiles(&cfiles[i], 1, NULL);
722 printf("\n\n");
723
724 /*
725 * pfiles(&cfiles[i], 1, "h");
726 * printf(" :\ntouch ");
727 * pfiles(&cfiles[i], 1, "h");
728 * printf("\n\n");
729 */
730 }
731
732 /* how to compile err.c */
733 if ( !gen_CPP ) {
734 printf("$(ERR)%s : $(ERR).c", OBJ_FILE_SUFFIX);
735 if ( !user_lexer ) printf(" $(TOKENS)");
736 printf("\n");
737 printf("\t%s -c $(CFLAGS) %s $(ERR)%s $(ERR).c",
738 gen_CPP?"$(CCC)":"$(CC)",
739 RENAME_OBJ_FLAG,
740 OBJ_FILE_SUFFIX);
741 printf("\n\n");
742 }
743
744 /* how to compile Class.c */
745 for (i=0; i<num_classes; i++)
746 {
747 pclasses(&classes[i], 1, "o");
748 if ( user_lexer ) {
749 printf(" : $(TOKENS)");
750 }
751 else {
752 printf(" : $(TOKENS) $(SCAN).h");
753 }
754 printf(" ");
755 pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);
756 printf(" ");
757 pclasses(&classes[i], 1, "h");
758 if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");
759 printf("\n");
760 printf("\t%s -c $(CFLAGS) %s ",
761 gen_CPP?"$(CCC)":"$(CC)",
762 RENAME_OBJ_FLAG);
763 pclasses(&classes[i], 1, "o");
764 printf(" ");
765 pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);
766 printf("\n\n");
767 }
768
769 /* how to compile scan.c */
770 if ( !user_lexer ) {
771 if ( gen_CPP ) printf("$(SCAN)%s : $(SCAN)%s", OBJ_FILE_SUFFIX, CPP_FILE_SUFFIX);
772 else printf("%s$(SCAN)%s : %s$(SCAN).c", DIR(), OBJ_FILE_SUFFIX, DIR());
773 if ( !user_lexer ) printf(" $(TOKENS)");
774 printf("\n");
775 if ( gen_CPP ) printf("\t$(CCC) -c $(CFLAGS) %s $(SCAN)%s $(SCAN)%s",
776 RENAME_OBJ_FLAG,
777 OBJ_FILE_SUFFIX,
778 CPP_FILE_SUFFIX);
779 else printf("\t$(CC) -c $(CFLAGS) %s %s$(SCAN)%s %s$(SCAN).c",
780 RENAME_OBJ_FLAG,
781 DIR(),
782 OBJ_FILE_SUFFIX,
783 DIR());
784 printf("\n\n");
785 }
786 /* how to compile sorcerer classes */
787 for (i=0;i<num_sors;i++)
788 {
789 pclasses(&sclasses[i], 1, "o");
790 printf(" : ");
791 pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);
792 printf(" ");
793 pclasses(&sclasses[i], 1, "h");
794 if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");
795 printf("\n");
796 printf("\t%s -c $(CFLAGS) %s ",
797 gen_CPP?"$(CCC)":"$(CC)",
798 RENAME_OBJ_FLAG);
799 pclasses(&sclasses[i], 1, "o");
800 printf(" ");
801 pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);
802 printf("\n\n");
803 /* how to compile i-th sorcerer's files*/
804 for (j=0; j<num_sfiles[i]; j++)
805 {
806 pfiles(&sfiles[i][j], 1, "o");
807 printf(" : ");
808 if ( gen_CPP ) pfiles(&sfiles[i][j], 1, CPP_FILE_SUFFIX_NO_DOT);
809 else pfiles(&sfiles[i][j], 1, "c");
810 if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");
811 printf("\n");
812 printf("\t%s -c $(CFLAGS) %s ",
813 gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);
814 pfiles(&sfiles[i][j], 1, "o");
815 printf(" ");
816 if ( gen_CPP ) pfiles(&sfiles[i][j], 1, CPP_FILE_SUFFIX_NO_DOT);
817 else pfiles(&sfiles[i][j], 1, "c");
818 printf("\n\n");
819 }
820 if ( gen_CPP ) pfiles(&sfiles[i][0], num_sfiles[i], CPP_FILE_SUFFIX_NO_DOT);
821 else pfiles(&sfiles[i][0], num_sfiles[i], "c");
822 if ( gen_CPP )
823 {
824 printf(" ");
825 pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);
826 printf(" ");
827 pclasses(&sclasses[i], 1, "h");
828 if ( strcmp(hdr,"stdpccts.h")!=0 )
829 {
830 printf(" ");
831 printf("$(HDR_FILE) stdpccts.h");
832 }
833 }
834 printf(" : ");
835 pfiles(&sfiles[i][0],num_sfiles[i],NULL);
836 printf("\n\t$(SOR) $(SFLAGS) ");
837 pfiles(&sfiles[i][0],num_sfiles[i],NULL);
838 printf("\n\n");
839 }
840 if(num_sors>0)
841 {
842 printf("STreeParser%s : $(SOR_LIB)%sSTreeParser.cpp\n",
843 OBJ_FILE_SUFFIX,DirectorySymbol);
844 printf("\t%s -c $(CFLAGS) %s ",
845 gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);
846 printf("STreeParser%s ",OBJ_FILE_SUFFIX);
847 printf("$(SOR_LIB)%sSTreeParser.cpp\n\n",DirectorySymbol);
848 }
849
850 printf("$(ANTLR_SPAWN) : $(GRM)\n");
851 printf("\t$(ANTLR) $(AFLAGS) $(GRM)\n");
852
853 if ( !user_lexer )
854 {
855 printf("\n");
856 printf("$(DLG_SPAWN) : $(DLG_FILE)\n");
857 if ( gen_CPP ) printf("\t$(DLG) $(DFLAGS) $(DLG_FILE)\n");
858 else printf("\t$(DLG) $(DFLAGS) $(DLG_FILE) $(SCAN).c\n");
859 }
860
861 /* do the makes for ANTLR/DLG support */
862 if ( gen_CPP ) {
863 printf("\n");
864 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);
865 printf("\t%s -c $(CFLAGS) %s ",
866 gen_CPP?"$(CCC)":"$(CC)",
867 RENAME_OBJ_FLAG);
868 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);
869 printf("\n");
870 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);
871 printf("\t%s -c $(CFLAGS) %s ",
872 gen_CPP?"$(CCC)":"$(CC)",
873 RENAME_OBJ_FLAG);
874 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);
875 if ( !user_lexer ) {
876 printf("\n");
877 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);
878 printf("\t%s -c $(CFLAGS) %s ",
879 gen_CPP?"$(CCC)":"$(CC)",
880 RENAME_OBJ_FLAG);
881 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);
882 }
883 if ( gen_trees ) {
884 printf("\n");
885 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);
886 printf("\t%s -c $(CFLAGS) %s ",
887 gen_CPP?"$(CCC)":"$(CC)",
888 RENAME_OBJ_FLAG);
889 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);
890 printf("\n");
891 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);
892 printf("\t%s -c $(CFLAGS) %s ",
893 gen_CPP?"$(CCC)":"$(CC)",
894 RENAME_OBJ_FLAG);
895 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);
896 printf("\n");
897 /*
898 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);
899 printf("\t%s -c $(CFLAGS) %s ",
900 gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);
901 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);
902 */
903 }
904 }
905
906 /* clean and scrub targets */
907
908 printf("\nclean:\n");
909 printf("\trm -f *%s core %s", OBJ_FILE_SUFFIX, project);
910 if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX);
911 printf("\n");
912
913 printf("\nscrub: clean\n");
914 /* printf("\trm -f *%s core %s", OBJ_FILE_SUFFIX, project); */
915 /* if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX); */
916 printf("\trm -f $(ANTLR_SPAWN)");
917 if ( !user_lexer ) printf(" $(DLG_SPAWN)");
918 for (i=0;i<num_sors;i++)
919 {
920 printf(" ");
921 if ( gen_CPP ) pfiles(&sfiles[i][0], num_sfiles[i], CPP_FILE_SUFFIX_NO_DOT);
922 else pfiles(&sfiles[i][0], num_sfiles[i], "c");
923 if ( gen_CPP )
924 {
925 printf(" ");
926 pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);
927 printf(" ");
928 pclasses(&sclasses[i], 1, "h");
929 }
930 }
931 printf("\n\n");
932 }
933
934 #ifdef __STDC__
935 void pfiles(char **files, int n, char *suffix)
936 #else
937 void pfiles(files, n, suffix)
938 char **files;
939 int n;
940 char *suffix;
941 #endif
942 {
943 int first=1;
944
945 while ( n>0 )
946 {
947 char *p = &(*files)[strlen(*files)-1];
948 if ( !first ) putchar(' ');
949 first=0;
950 while ( p > *files && *p != '.' ) --p;
951 if ( p == *files )
952 {
953 fprintf(stderr,
954 "genmk: filenames must be file.suffix format: %s\n",
955 *files);
956 exit(-1);
957 }
958 if ( suffix == NULL ) printf("%s", *files);
959 else
960 {
961 *p = '\0';
962 printf("%s", DIR());
963 if ( strcmp(suffix, "o")==0 ) printf("%s%s", *files, OBJ_FILE_SUFFIX);
964 else printf("%s.%s", *files, suffix);
965 *p = '.';
966 }
967 files++;
968 --n;
969 }
970 }
971
972 #ifdef __STDC__
973 void pclasses(char **classes, int n, char *suffix)
974 #else
975 pclasses(classes, n, suffix)
976 char **classes;
977 int n;
978 char *suffix;
979 #endif
980 {
981 int first=1;
982
983 while ( n>0 )
984 {
985 if ( !first ) putchar(' ');
986 first=0;
987 if ( suffix == NULL ) printf("%s", *classes);
988 else {
989 printf("%s", DIR());
990 if ( strcmp(suffix, "o")==0 ) printf("%s%s", *classes, OBJ_FILE_SUFFIX);
991 else printf("%s.%s", *classes, suffix);
992 }
993 classes++;
994 --n;
995 }
996 }
997
998 static void
999 #ifdef __STDC__
1000 ProcessArgs( int argc, char **argv, Opt *options )
1001 #else
1002 ProcessArgs( argc, argv, options )
1003 int argc;
1004 char **argv;
1005 Opt *options;
1006 #endif
1007 {
1008 Opt *p;
1009 require(argv!=NULL, "ProcessArgs: command line NULL");
1010
1011 while ( argc-- > 0 )
1012 {
1013 p = options;
1014 while ( p->option != NULL )
1015 {
1016 if ( strcmp(p->option, "*") == 0 ||
1017 strcmp(p->option, *argv) == 0 )
1018 {
1019 if ( p->arg )
1020 {
1021 (*p->process)( *argv, *(argv+1) );
1022 argv++;
1023 argc--;
1024 }
1025 else
1026 (*p->process)( *argv );
1027 break;
1028 }
1029 p++;
1030 }
1031 argv++;
1032 }
1033 }
1034
1035 #ifdef __STDC__
1036 void fatal( char *err_)
1037 #else
1038 void fatal( err_)
1039 char *err_;
1040 #endif
1041 {
1042 fprintf(stderr, "genmk: %s\n", err_);
1043 exit(1);
1044 }
1045
1046 #ifdef __STDC__
1047 void warn( char *err_)
1048 #else
1049 void warn( err_)
1050 char *err_;
1051 #endif
1052 {
1053 fprintf(stderr, "genmk: %s\n", err_);
1054 }
1055
1056 #ifdef __STDC__
1057 char *DIR(void)
1058 #else
1059 char *DIR()
1060 #endif
1061 {
1062 static char buf[200+1];
1063
1064 if ( strcmp(outdir,TopDirectory)==0 ) return "";
1065 sprintf(buf, "%s%s", outdir, DirectorySymbol);
1066 return buf;
1067 }
+0
-762
contrib/pccts/support/genmk/genmk_old.c less more
0 /*
1 * genmk -- a program to make makefiles for PCCTS
2 *
3 * ANTLR 1.33MR10
4 * Terence John Parr 1989 - 1998
5 * Purdue University
6 * U of MN
7 */
8
9 #include <stdio.h>
10 #include "pcctscfg.h" /* be sensitive to what ANTLR/DLG call the files */
11
12 #ifdef VAXC
13 #define DIE return 0;
14 #define DONE return 1;
15 #else
16 #define DIE return 1;
17 #define DONE return 0;
18 #endif
19
20 #ifndef require
21 #define require(expr, err) {if ( !(expr) ) fatal(err);}
22 #endif
23
24 #define MAX_FILES 50
25 #define MAX_CLASSES 50
26
27 char *RENAME_OBJ_FLAG="-o",
28 *RENAME_EXE_FLAG="-o";
29
30 char *dlg = "parser.dlg";
31 char *err = "err.c";
32 char *hdr = "stdpccts.h";
33 char *tok = "tokens.h";
34 char *mode = "mode.h";
35 char *scan = "scan";
36
37 char ATOKENBUFFER_O[100];
38 char APARSER_O[100];
39 char ASTBASE_O[100];
40 char PCCTSAST_O[100];
41 char LIST_O[100];
42 char DLEXERBASE_O[100];
43
44 /* Option flags */
45 static char *project="t", *files[MAX_FILES], *classes[MAX_CLASSES];
46 static int num_files = 0;
47 static int num_classes = 0;
48 static int user_lexer = 0;
49 static char *user_token_types = NULL;
50 static int gen_CPP = 0;
51 static char *outdir=".";
52 static char *dlg_class = "DLGLexer";
53 static int gen_trees = 0;
54 static int gen_hoist = 0;
55 static char cfiles[1600]="";
56 static char *compilerCCC="CC";
57 static char *compilerCC="cc";
58 static char *pccts_path="/usr/local/pccts";
59
60 void help();
61 void mk();
62 void pfiles();
63 void pclasses();
64 void fatal();
65 void warn();
66
67 typedef struct _Opt {
68 char *option;
69 int arg;
70 #ifdef __cplusplus
71 void (*process)(...);
72 #else
73 void (*process)();
74 #endif
75 char *descr;
76 } Opt;
77
78 #ifdef __STDC__
79 static void ProcessArgs(int, char **, Opt *);
80 #else
81 static void ProcessArgs();
82 #endif
83
84 static void
85 pProj( s, t )
86 char *s;
87 char *t;
88 {
89 project = t;
90 }
91
92 static void
93 pUL( s )
94 char *s;
95 {
96 user_lexer = 1;
97 }
98
99 static void
100 pCPP( s )
101 char *s;
102 {
103 gen_CPP = 1;
104 }
105
106 static void
107 pUT( s, t )
108 char *s;
109 char *t;
110 {
111 user_token_types = t;
112 }
113
114 static void
115 pTrees( s )
116 char *s;
117 {
118 gen_trees = 1;
119 }
120
121 static void
122 pHoist( s )
123 char *s;
124 {
125 gen_hoist = 1;
126 }
127
128 static void
129 #ifdef __STDC__
130 pFile( char *s )
131 #else
132 pFile( s )
133 char *s;
134 #endif
135 {
136 if ( *s=='-' )
137 {
138 fprintf(stderr, "invalid option: '%s'; ignored...",s);
139 return;
140 }
141
142 require(num_files<MAX_FILES, "exceeded max # of input files");
143 files[num_files++] = s;
144 }
145
146 static void
147 #ifdef __STDC__
148 pClass( char *s, char *t )
149 #else
150 pClass( s, t )
151 char *s;
152 char *t;
153 #endif
154 {
155 require(num_classes<MAX_CLASSES, "exceeded max # of grammar classes");
156 classes[num_classes++] = t;
157 }
158
159 static void
160 #ifdef __STDC__
161 pDLGClass( char *s, char *t )
162 #else
163 pDLGClass( s, t )
164 char *s;
165 char *t;
166 #endif
167 {
168 if ( !gen_CPP ) {
169 fprintf(stderr, "-dlg-class makes no sense without C++ mode; ignored...");
170 }
171 else dlg_class = t;
172 }
173
174 static void
175 #ifdef __STDC__
176 pOdir( char *s, char *t )
177 #else
178 pOdir( s, t )
179 char *s;
180 char *t;
181 #endif
182 {
183 outdir = t;
184 }
185
186 static void
187 #ifdef __STDC__
188 pHdr( char *s, char *t )
189 #else
190 pHdr( s, t )
191 char *s;
192 char *t;
193 #endif
194 {
195 hdr = t;
196 }
197
198 static void
199 #ifdef __STDC__
200 pCFiles( char *s, char *t )
201 #else
202 pCFiles( s, t )
203 char *s;
204 char *t;
205 #endif
206 {
207 strcat(strcat(cfiles," "), t);
208 }
209
210 static void
211 #ifdef __STDC__
212 pCompiler( char *s, char *t )
213 #else
214 pCompiler( s, t )
215 char *s;
216 char *t;
217 #endif
218 {
219 compilerCCC = t;
220 compilerCC = t;
221 }
222
223 static void
224 #ifdef __STDC__
225 ppccts_path( char *s, char *t )
226 #else
227 ppccts_path( s, t )
228 char *s;
229 char *t;
230 #endif
231 {
232 pccts_path = t;
233 }
234
235 Opt options[] = {
236 { "-CC", 0, pCPP, "Generate C++ output"},
237 { "-class", 1, pClass, "Name of a grammar class defined in grammar (if C++)"},
238 { "-dlg-class", 1,pDLGClass,"Name of DLG lexer class (default=DLGLexer) (if C++)"},
239 { "-header", 1,pHdr, "Name of ANTLR standard header info (default=no file)"},
240 { "-o", 1, pOdir, "Directory where output files should go (default=\".\")"},
241 { "-project", 1, pProj, "Name of executable to create (default=t)"},
242 { "-token-types", 1, pUT, "Token types are in this file (don't use tokens.h)"},
243 { "-trees", 0, pTrees, "Generate ASTs"},
244 { "-user-lexer", 0, pUL, "Do not create a DLG-based scanner"},
245 { "-mrhoist",0,pHoist, "Maintenance release style hoisting"},
246 { "-cfiles",1,pCFiles, "Additional files in C or C++ to compile"},
247 { "-pccts_path",1,ppccts_path,
248 "Path for $PCCTS directory (default is /usr/local/pccts)"},
249 { "-compiler",1,pCompiler,
250 "Default compiler (default is CC/cc)"},
251 { "*", 0,pFile, "" }, /* anything else is a file */
252 { NULL, 0, NULL, NULL }
253 };
254
255 extern char *DIR();
256
257 int main(argc, argv)
258 int argc;
259 char **argv;
260 {
261 if ( argc == 1 ) { help(); DIE; }
262 ProcessArgs(argc-1, &(argv[1]), options);
263
264 strcpy(ATOKENBUFFER_O, ATOKENBUFFER_C);
265 ATOKENBUFFER_O[strlen(ATOKENBUFFER_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
266 strcat(ATOKENBUFFER_O, OBJ_FILE_SUFFIX);
267 strcpy(APARSER_O, APARSER_C);
268 APARSER_O[strlen(APARSER_O)-strlen(CPP_FILE_SUFFIX)] = '\0';
269 strcat(APARSER_O, OBJ_FILE_SUFFIX);
270
271 strcpy(ASTBASE_O, ASTBASE_C);
272 ASTBASE_O[strlen(ASTBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
273 strcat(ASTBASE_O, OBJ_FILE_SUFFIX);
274
275 strcpy(PCCTSAST_O, PCCTSAST_C);
276 PCCTSAST_O[strlen(PCCTSAST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
277 strcat(PCCTSAST_O, OBJ_FILE_SUFFIX);
278
279 strcpy(LIST_O, LIST_C);
280 LIST_O[strlen(LIST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
281 strcat(LIST_O, OBJ_FILE_SUFFIX);
282
283 strcpy(DLEXERBASE_O, DLEXERBASE_C);
284 DLEXERBASE_O[strlen(DLEXERBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';
285 strcat(DLEXERBASE_O, OBJ_FILE_SUFFIX);
286
287 if ( num_files == 0 ) fatal("no grammar files specified; exiting...");
288 if ( !gen_CPP && num_classes>0 ) {
289 warn("can't define classes w/o C++ mode; turning on C++ mode...\n");
290 gen_CPP=1;
291 }
292 if ( gen_CPP && num_classes==0 ) {
293 fatal("must define classes >0 grammar classes in C++ mode\n");
294 }
295
296 mk(project, files, num_files, argc, argv);
297 DONE;
298 }
299
300 void help()
301 {
302 Opt *p = options;
303 static char buf[1000+1];
304
305 fprintf(stderr, "genmk [options] f1.g ... fn.g\n");
306 while ( p->option!=NULL && *(p->option) != '*' )
307 {
308 buf[0]='\0';
309 if ( p->arg ) sprintf(buf, "%s ___", p->option);
310 else strcpy(buf, p->option);
311 fprintf(stderr, "\t%-16s %s\n", buf, p->descr);
312 p++;
313 }
314 }
315
316 void mk(project, files, n, argc, argv)
317 char *project;
318 char **files;
319 int n;
320 int argc;
321 char **argv;
322 {
323 int i;
324
325 printf("#\n");
326 printf("# PCCTS makefile for: ");
327 pfiles(files, n, NULL);
328 printf("\n");
329 printf("#\n");
330 printf("# Created from:");
331 for (i=0; i<argc; i++) printf(" %s", argv[i]);
332 printf("\n");
333 printf("#\n");
334 printf("# PCCTS release 1.33MR21\n");
335 printf("# Project: %s\n", project);
336 if ( gen_CPP ) printf("# C++ output\n");
337 else printf("# C output\n");
338 if ( user_lexer ) printf("# User-defined scanner\n");
339 else printf("# DLG scanner\n");
340 if ( user_token_types!=NULL ) printf("# User-defined token types in '%s'\n", user_token_types);
341 else printf("# ANTLR-defined token types\n");
342 printf("#\n");
343 printf(".SUFFIXES:\n.SUFFIXES: .o .cpp .c .h .g .i .dlg\n");
344 if ( user_token_types!=NULL ) {
345 printf("# Make sure #tokdefs directive in ANTLR grammar lists this file:\n");
346 printf("TOKENS = %s", user_token_types);
347 }
348 else printf("TOKENS = %stokens.h", DIR());
349 printf("\n");
350 printf("#\n");
351 printf("# The following filenames must be consistent with ANTLR/DLG flags\n");
352 printf("DLG_FILE = %s%s\n", DIR(), dlg);
353 printf("ERR = %serr\n", DIR());
354 if ( strcmp(hdr,"stdpccts.h")!=0 ) printf("HDR_FILE = %s%s\n", DIR(), hdr);
355 else printf("HDR_FILE =\n");
356 if ( !gen_CPP ) printf("MOD_FILE = %s%s\n", DIR(), mode);
357 if ( !gen_CPP ) printf("SCAN = %s\n", scan);
358 else printf("SCAN = %s%s\n", DIR(), dlg_class);
359
360 printf("PCCTS = %s\n",pccts_path);
361 printf("ANTLR_H = $(PCCTS)%sh\n", DirectorySymbol);
362 printf("BIN = $(PCCTS)%sbin\n", DirectorySymbol);
363 printf("ANTLR = $(BIN)%santlr\n", DirectorySymbol);
364 printf("DLG = $(BIN)%sdlg\n", DirectorySymbol);
365 printf("CFLAGS = -I. -I$(ANTLR_H)");
366 if ( strcmp(outdir, ".")!=0 ) printf(" -I%s", outdir);
367 printf(" $(COTHER)");
368 printf("\n");
369 printf("AFLAGS =");
370 if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);
371 if ( user_lexer ) printf(" -gx");
372 if ( gen_CPP ) printf(" -CC");
373 if ( strcmp(hdr,"stdpccts.h")!=0 ) printf(" -gh %s", hdr);
374 if ( gen_trees ) printf(" -gt");
375 if ( gen_hoist ) {
376 printf(" -mrhoist on") ;
377 } else {
378 printf(" -mrhoist off");
379 };
380 printf(" $(AOTHER)");
381 printf("\n");
382 printf("DFLAGS = -C2 -i");
383 if ( gen_CPP ) printf(" -CC");
384 if ( strcmp(dlg_class,"DLGLexer")!=0 ) printf(" -cl %s", dlg_class);
385 if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);
386 printf(" $(DOTHER)");
387 printf("\n");
388 printf("GRM = ");
389 pfiles(files, n, NULL);
390 printf("\n");
391 printf("MYFILES = %s\n",cfiles);
392 printf("SRC = ");
393 if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);
394 else pfiles(files, n, "c");
395 if ( gen_CPP ) {
396 printf(" \\\n ");
397 printf(" ");
398 pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);
399 printf(" \\\n ");
400 printf("$(ANTLR_H)%s%s", DirectorySymbol, APARSER_C);
401 if ( !user_lexer ) printf(" $(ANTLR_H)%s%s", DirectorySymbol, DLEXERBASE_C);
402 if ( gen_trees ) {
403 printf(" \\\n ");
404 printf("$(ANTLR_H)%s%s", DirectorySymbol, ASTBASE_C);
405 printf(" $(ANTLR_H)%s%s", DirectorySymbol, PCCTSAST_C);
406 /* printf(" $(ANTLR_H)%s%s", DirectorySymbol, LIST_C); */
407 printf(" \\\n ");
408 }
409 printf(" $(ANTLR_H)%s%s", DirectorySymbol, ATOKENBUFFER_C);
410 }
411 if ( !user_lexer ) {
412 if ( gen_CPP ) printf(" $(SCAN)%s", CPP_FILE_SUFFIX);
413 else printf(" %s$(SCAN).c", DIR());
414 }
415 if ( !gen_CPP ) printf(" $(ERR).c");
416 printf("\\\n $(MYFILES)\n");
417 printf("OBJ = ");
418 pfiles(files, n, "o");
419 if ( gen_CPP ) {
420 printf(" \\\n ");
421 printf(" ");
422 pclasses(classes, num_classes, "o");
423 printf(" \\\n ");
424 printf(" %s%s", DIR(), APARSER_O);
425 if ( !user_lexer ) {
426 printf(" %s%s", DIR(), DLEXERBASE_O);
427 }
428 if ( gen_trees ) {
429 printf(" \\\n ");
430 printf("%s%s", DIR(), ASTBASE_O);
431 printf(" %s%s", DIR(), PCCTSAST_O);
432 /* printf(" %s%s", DIR(), LIST_O); */
433 printf(" \\\n ");
434 }
435 printf(" %s%s", DIR(), ATOKENBUFFER_O);
436 }
437 if ( !user_lexer ) {
438 if ( gen_CPP ) printf(" $(SCAN)%s", OBJ_FILE_SUFFIX);
439 else printf(" %s$(SCAN)%s", DIR(), OBJ_FILE_SUFFIX);
440 }
441 if ( !gen_CPP ) printf(" $(ERR)%s", OBJ_FILE_SUFFIX);
442 printf("\\\n $(MYFILES:.cpp=.o)\n");
443
444 printf("ANTLR_SPAWN = ");
445 if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);
446 else pfiles(files, n, "c");
447 if ( gen_CPP ) {
448 printf(" ");
449 pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);
450 printf(" \\\n ");
451 pclasses(classes, num_classes, "h");
452 if ( strcmp(hdr,"stdpccts.h")!=0 ) {
453 printf(" \\\n ");
454 printf("$(HDR_FILE) stdpccts.h");
455 }
456 }
457 if ( user_lexer ) {
458 if ( !user_token_types ) printf(" $(TOKENS)");
459 }
460 else {
461 printf(" $(DLG_FILE)");
462 if ( !user_token_types ) printf(" $(TOKENS)");
463 }
464 if ( !gen_CPP ) printf(" $(ERR).c");
465 printf("\n");
466
467 if ( !user_lexer ) {
468 if ( gen_CPP ) printf("DLG_SPAWN = $(SCAN)%s", CPP_FILE_SUFFIX);
469 else printf("DLG_SPAWN = %s$(SCAN).c", DIR());
470 if ( gen_CPP ) printf(" $(SCAN).h");
471 if ( !gen_CPP ) printf(" $(MOD_FILE)");
472 printf("\n");
473 }
474
475 if ( gen_CPP ) {
476 printf("CCC = %s\n",compilerCCC);
477 }
478 else printf("CC = %s\n",compilerCC);
479
480 /* set up dependencies */
481 printf("\n%s : $(OBJ) $(SRC)\n", project);
482 printf(" %s %s %s $(CFLAGS) $(OBJ)\n",
483 gen_CPP?"$(CCC)":"$(CC)",
484 RENAME_EXE_FLAG,
485 project);
486 printf("\n");
487
488 /* implicit rules */
489
490 if(gen_CPP)
491 printf("%%.o : %%.cpp\n\t$(CCC) -c $(CFLAGS) $<\n\n");
492
493 printf("%%.o : %%.c\n\t%s -c $(CFLAGS) $<\n\n",
494 gen_CPP?"$(CCC)":"$(CC)");
495
496 /* how to compile parser files */
497
498 for (i=0; i<num_files; i++)
499 {
500 pfiles(&files[i], 1, "o");
501 if ( user_lexer ) {
502 printf(" : $(TOKENS)");
503 }
504 else {
505 if ( gen_CPP ) printf(" : $(TOKENS) $(SCAN).h");
506 else printf(" : $(MOD_FILE) $(TOKENS)");
507 }
508 printf(" ");
509 if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);
510 else pfiles(&files[i], 1, "c");
511 if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");
512 printf("\n");
513 printf(" %s -c $(CFLAGS) %s ",
514 gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);
515 pfiles(&files[i], 1, "o");
516 printf(" ");
517 if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);
518 else pfiles(&files[i], 1, "c");
519 printf("\n\n");
520 }
521
522 /* how to compile err.c */
523 if ( !gen_CPP ) {
524 printf("$(ERR)%s : $(ERR).c", OBJ_FILE_SUFFIX);
525 if ( !user_lexer ) printf(" $(TOKENS)");
526 printf("\n");
527 printf(" %s -c $(CFLAGS) %s $(ERR)%s $(ERR).c",
528 gen_CPP?"$(CCC)":"$(CC)",
529 RENAME_OBJ_FLAG,
530 OBJ_FILE_SUFFIX);
531 printf("\n\n");
532 }
533
534 /* how to compile Class.c */
535 for (i=0; i<num_classes; i++)
536 {
537 pclasses(&classes[i], 1, "o");
538 if ( user_lexer ) {
539 printf(" : $(TOKENS)");
540 }
541 else {
542 printf(" : $(TOKENS) $(SCAN).h");
543 }
544 printf(" ");
545 pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);
546 printf(" ");
547 pclasses(&classes[i], 1, "h");
548 if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");
549 printf("\n");
550 printf(" %s -c $(CFLAGS) %s ",
551 gen_CPP?"$(CCC)":"$(CC)",
552 RENAME_OBJ_FLAG);
553 pclasses(&classes[i], 1, "o");
554 printf(" ");
555 pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);
556 printf("\n\n");
557 }
558
559 /* how to compile scan.c */
560 if ( !user_lexer ) {
561 if ( gen_CPP ) printf("$(SCAN)%s : $(SCAN)%s", OBJ_FILE_SUFFIX, CPP_FILE_SUFFIX);
562 else printf("%s$(SCAN)%s : %s$(SCAN).c", DIR(), OBJ_FILE_SUFFIX, DIR());
563 if ( !user_lexer ) printf(" $(TOKENS)");
564 printf("\n");
565 if ( gen_CPP ) printf(" $(CCC) -c $(CFLAGS) %s $(SCAN)%s $(SCAN)%s",
566 RENAME_OBJ_FLAG,
567 OBJ_FILE_SUFFIX,
568 CPP_FILE_SUFFIX);
569 else printf(" $(CC) -c $(CFLAGS) %s %s$(SCAN)%s %s$(SCAN).c",
570 RENAME_OBJ_FLAG,
571 DIR(),
572 OBJ_FILE_SUFFIX,
573 DIR());
574 printf("\n\n");
575 }
576
577 printf("$(ANTLR_SPAWN) : $(GRM)\n");
578 printf(" $(ANTLR) $(AFLAGS) $(GRM)\n");
579
580 if ( !user_lexer )
581 {
582 printf("\n");
583 printf("$(DLG_SPAWN) : $(DLG_FILE)\n");
584 if ( gen_CPP ) printf(" $(DLG) $(DFLAGS) $(DLG_FILE)\n");
585 else printf(" $(DLG) $(DFLAGS) $(DLG_FILE) $(SCAN).c\n");
586 }
587
588 /* do the makes for ANTLR/DLG support */
589 if ( gen_CPP ) {
590 printf("\n");
591 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);
592 printf(" %s -c $(CFLAGS) %s ",
593 gen_CPP?"$(CCC)":"$(CC)",
594 RENAME_OBJ_FLAG);
595 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);
596 printf("\n");
597 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);
598 printf(" %s -c $(CFLAGS) %s ",
599 gen_CPP?"$(CCC)":"$(CC)",
600 RENAME_OBJ_FLAG);
601 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);
602 if ( !user_lexer ) {
603 printf("\n");
604 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);
605 printf(" %s -c $(CFLAGS) %s ",
606 gen_CPP?"$(CCC)":"$(CC)",
607 RENAME_OBJ_FLAG);
608 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);
609 }
610 if ( gen_trees ) {
611 printf("\n");
612 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);
613 printf(" %s -c $(CFLAGS) %s ",
614 gen_CPP?"$(CCC)":"$(CC)",
615 RENAME_OBJ_FLAG);
616 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);
617 printf("\n");
618 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);
619 printf(" %s -c $(CFLAGS) %s ",
620 gen_CPP?"$(CCC)":"$(CC)",
621 RENAME_OBJ_FLAG);
622 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);
623 printf("\n");
624 /*
625 printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);
626 printf(" %s -c $(CFLAGS) %s ",
627 gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);
628 printf("%s%s $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);
629 */
630 }
631 }
632
633 /* clean and scrub targets */
634
635 printf("\nclean:\n");
636 printf(" rm -f *%s core %s", OBJ_FILE_SUFFIX, project);
637 if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX);
638 printf("\n");
639
640 printf("\nscrub:\n");
641 printf(" rm -f *%s core %s", OBJ_FILE_SUFFIX, project);
642 if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX);
643 printf(" $(ANTLR_SPAWN)");
644 if ( !user_lexer ) printf(" $(DLG_SPAWN)");
645 printf("\n");
646 }
647
648 void pfiles(files, n, suffix)
649 char **files;
650 int n;
651 char *suffix;
652 {
653 int first=1;
654
655 while ( n>0 )
656 {
657 char *p = &(*files)[strlen(*files)-1];
658 if ( !first ) putchar(' ');
659 first=0;
660 while ( p > *files && *p != '.' ) --p;
661 if ( p == *files )
662 {
663 fprintf(stderr,
664 "genmk: filenames must be file.suffix format: %s\n",
665 *files);
666 exit(-1);
667 }
668 if ( suffix == NULL ) printf("%s", *files);
669 else
670 {
671 *p = '\0';
672 printf("%s", DIR());
673 if ( strcmp(suffix, "o")==0 ) printf("%s%s", *files, OBJ_FILE_SUFFIX);
674 else printf("%s.%s", *files, suffix);
675 *p = '.';
676 }
677 files++;
678 --n;
679 }
680 }
681
682 void pclasses(classes, n, suffix)
683 char **classes;
684 int n;
685 char *suffix;
686 {
687 int first=1;
688
689 while ( n>0 )
690 {
691 if ( !first ) putchar(' ');
692 first=0;
693 if ( suffix == NULL ) printf("%s", *classes);
694 else {
695 printf("%s", DIR());
696 if ( strcmp(suffix, "o")==0 ) printf("%s%s", *classes, OBJ_FILE_SUFFIX);
697 else printf("%s.%s", *classes, suffix);
698 }
699 classes++;
700 --n;
701 }
702 }
703
704 static void
705 #ifdef __STDC__
706 ProcessArgs( int argc, char **argv, Opt *options )
707 #else
708 ProcessArgs( argc, argv, options )
709 int argc;
710 char **argv;
711 Opt *options;
712 #endif
713 {
714 Opt *p;
715 require(argv!=NULL, "ProcessArgs: command line NULL");
716
717 while ( argc-- > 0 )
718 {
719 p = options;
720 while ( p->option != NULL )
721 {
722 if ( strcmp(p->option, "*") == 0 ||
723 strcmp(p->option, *argv) == 0 )
724 {
725 if ( p->arg )
726 {
727 (*p->process)( *argv, *(argv+1) );
728 argv++;
729 argc--;
730 }
731 else
732 (*p->process)( *argv );
733 break;
734 }
735 p++;
736 }
737 argv++;
738 }
739 }
740
741 void fatal( err_)
742 char *err_;
743 {
744 fprintf(stderr, "genmk: %s\n", err_);
745 exit(1);
746 }
747
748 void warn( err_)
749 char *err_;
750 {
751 fprintf(stderr, "genmk: %s\n", err_);
752 }
753
754 char *DIR()
755 {
756 static char buf[200+1];
757
758 if ( strcmp(outdir,TopDirectory)==0 ) return "";
759 sprintf(buf, "%s%s", outdir, DirectorySymbol);
760 return buf;
761 }
+0
-54
contrib/pccts/support/genmk/watgenmk.mak less more
0 SET=..\..\support\set
1 PCCTS_H=..\..\h
2
3 #
4 # Watcom
5 #
6 CC=wcl386
7 ANTLR=..\..\bin\antlr
8 DLG=..\..\bin\dlg
9 CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DPC
10 OUT_OBJ = -o
11 OBJ_EXT = obj
12 LINK = wcl386
13
14 .c.obj :
15 $(CC) -c $[* $(CFLAGS)
16
17 genmk.exe: genmk.obj
18 $(LINK) -fe=genmk.exe *.obj -k14336
19 copy *.exe ..\..\bin
20
21 #clean up all the intermediate files
22 clean:
23 del *.obj
24
25 #remove everything in clean plus the PCCTS files generated
26 scrub:
27 del *.$(OBJ_EXT)
28 EOF_watgenmk.mak
29 cat << \EOF_makefile | sed 's/^>//' > makefile
30 SRC=genmk.c
31 OBJ=genmk.o
32 # Define PC if you use a PC OS (changes directory symbol and object file extension)
33 # see pccts/h/pcctscfg.h
34 #CFLAGS=-I../../h -DPC
35 CFLAGS=-I../../h
36 CC=cc
37 BAG=../../bin/bag
38
39 genmk: $(OBJ) $(SRC) ../../h/pcctscfg.h
40 $(CC) -o genmk $(OBJ)
41
42 clean:
43 rm -rf core *.o
44
45 scrub:
46 rm -rf genmk core *.o
47
48 shar:
49 shar genmk.c makefile > genmk.shar
50
51 archive:
52 $(BAG) genmk.c watgenmk.mak makefile > genmk.bag
53 EOF_makefile
+0
-251
contrib/pccts/support/msvc.dsp less more
0 # Microsoft Developer Studio Project File - Name="support" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 5.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Static Library" 0x0104
5
6 CFG=support - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "support.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "support.mak" CFG="support - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "support - Win32 Release" (based on "Win32 (x86) Static Library")
20 !MESSAGE "support - Win32 Debug" (based on "Win32 (x86) Static Library")
21 !MESSAGE
22
23 # Begin Project
24 # PROP Scc_ProjName ""$/pccts/support", YGABAAAA"
25 # PROP Scc_LocalPath "."
26 CPP=cl.exe
27
28 !IF "$(CFG)" == "support - Win32 Release"
29
30 # PROP BASE Use_MFC 0
31 # PROP BASE Use_Debug_Libraries 0
32 # PROP BASE Output_Dir "Release"
33 # PROP BASE Intermediate_Dir "Release"
34 # PROP BASE Target_Dir ""
35 # PROP Use_MFC 0
36 # PROP Use_Debug_Libraries 0
37 # PROP Output_Dir "Release"
38 # PROP Intermediate_Dir "Release"
39 # PROP Target_Dir ""
40 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
41 # ADD CPP /nologo /W3 /GX /O2 /I "..\h" /I "..\support\set" /I "..\support" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "USER_ZZSYN" /D "PC" /D "__STDC__" /YX /FD /c
42 BSC32=bscmake.exe
43 # ADD BASE BSC32 /nologo
44 # ADD BSC32 /nologo
45 LIB32=link.exe -lib
46 # ADD BASE LIB32 /nologo
47 # ADD LIB32 /nologo
48
49 !ELSEIF "$(CFG)" == "support - Win32 Debug"
50
51 # PROP BASE Use_MFC 0
52 # PROP BASE Use_Debug_Libraries 1
53 # PROP BASE Output_Dir "Debug"
54 # PROP BASE Intermediate_Dir "Debug"
55 # PROP BASE Target_Dir ""
56 # PROP Use_MFC 0
57 # PROP Use_Debug_Libraries 1
58 # PROP Output_Dir "Debug"
59 # PROP Intermediate_Dir "Debug"
60 # PROP Target_Dir ""
61 # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
62 # ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\h" /I "..\support\set" /I "..\support" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "USER_ZZSYN" /D "PC" /D "__STDC__" /YX /FD /c
63 BSC32=bscmake.exe
64 # ADD BASE BSC32 /nologo
65 # ADD BSC32 /nologo
66 LIB32=link.exe -lib
67 # ADD BASE LIB32 /nologo
68 # ADD LIB32 /nologo
69
70 !ENDIF
71
72 # Begin Target
73
74 # Name "support - Win32 Release"
75 # Name "support - Win32 Debug"
76 # Begin Group "Headers"
77
78 # PROP Default_Filter ".h"
79 # Begin Source File
80
81 SOURCE=.\errout.h
82 # End Source File
83 # Begin Source File
84
85 SOURCE=.\set\set.h
86 # End Source File
87 # End Group
88 # Begin Group "Source"
89
90 # PROP Default_Filter "c,cpp"
91 # Begin Source File
92
93 SOURCE=.\errout.c
94 # End Source File
95 # Begin Source File
96
97 SOURCE=.\set\set.c
98 # End Source File
99 # End Group
100 # Begin Group "PCCTS' clients files"
101
102 # PROP Default_Filter ""
103 # Begin Source File
104
105 SOURCE=..\h\antlr.h
106 # PROP Exclude_From_Build 1
107 # End Source File
108 # Begin Source File
109
110 SOURCE=..\h\AParser.cpp
111 # PROP Exclude_From_Build 1
112 # End Source File
113 # Begin Source File
114
115 SOURCE=..\h\AParser.h
116 # PROP Exclude_From_Build 1
117 # End Source File
118 # Begin Source File
119
120 SOURCE=..\h\ast.c
121 # PROP Exclude_From_Build 1
122 # End Source File
123 # Begin Source File
124
125 SOURCE=..\h\ast.h
126 # PROP Exclude_From_Build 1
127 # End Source File
128 # Begin Source File
129
130 SOURCE=..\h\ASTBase.cpp
131 # PROP Exclude_From_Build 1
132 # End Source File
133 # Begin Source File
134
135 SOURCE=..\h\ASTBase.h
136 # PROP Exclude_From_Build 1
137 # End Source File
138 # Begin Source File
139
140 SOURCE=..\h\AToken.h
141 # PROP Exclude_From_Build 1
142 # End Source File
143 # Begin Source File
144
145 SOURCE=..\h\ATokenBuffer.cpp
146 # PROP Exclude_From_Build 1
147 # End Source File
148 # Begin Source File
149
150 SOURCE=..\h\ATokenBuffer.h
151 # PROP Exclude_From_Build 1
152 # End Source File
153 # Begin Source File
154
155 SOURCE=..\h\ATokenStream.h
156 # PROP Exclude_From_Build 1
157 # End Source File
158 # Begin Source File
159
160 SOURCE=..\h\ATokPtr.cpp
161 # PROP Exclude_From_Build 1
162 # End Source File
163 # Begin Source File
164
165 SOURCE=..\h\ATokPtr.h
166 # PROP Exclude_From_Build 1
167 # End Source File
168 # Begin Source File
169
170 SOURCE=..\h\charbuf.h
171 # PROP Exclude_From_Build 1
172 # End Source File
173 # Begin Source File
174
175 SOURCE=..\h\charptr.c
176 # PROP Exclude_From_Build 1
177 # End Source File
178 # Begin Source File
179
180 SOURCE=..\h\charptr.h
181 # PROP Exclude_From_Build 1
182 # End Source File
183 # Begin Source File
184
185 SOURCE=..\h\pcctscfg.h
186 # PROP Exclude_From_Build 1
187 # End Source File
188 # Begin Source File
189
190 SOURCE=..\h\DLexer.cpp
191 # PROP Exclude_From_Build 1
192 # End Source File
193 # Begin Source File
194
195 SOURCE=..\h\DLexerBase.cpp
196 # PROP Exclude_From_Build 1
197 # End Source File
198 # Begin Source File
199
200 SOURCE=..\h\DLexerBase.h
201 # PROP Exclude_From_Build 1
202 # End Source File
203 # Begin Source File
204
205 SOURCE=..\h\dlgauto.h
206 # PROP Exclude_From_Build 1
207 # End Source File
208 # Begin Source File
209
210 SOURCE=..\h\dlgdef.h
211 # PROP Exclude_From_Build 1
212 # End Source File
213 # Begin Source File
214
215 SOURCE=..\h\err.h
216 # PROP Exclude_From_Build 1
217 # End Source File
218 # Begin Source File
219
220 SOURCE=..\h\int.h
221 # PROP Exclude_From_Build 1
222 # End Source File
223 # Begin Source File
224
225 SOURCE=..\h\PBlackBox.h
226 # PROP Exclude_From_Build 1
227 # End Source File
228 # Begin Source File
229
230 SOURCE=..\h\PCCTSAST.cpp
231 # PROP Exclude_From_Build 1
232 # End Source File
233 # Begin Source File
234
235 SOURCE=..\h\PCCTSAST.h
236 # PROP Exclude_From_Build 1
237 # End Source File
238 # Begin Source File
239
240 SOURCE=..\h\SList.cpp
241 # PROP Exclude_From_Build 1
242 # End Source File
243 # Begin Source File
244
245 SOURCE=..\h\SList.h
246 # PROP Exclude_From_Build 1
247 # End Source File
248 # End Group
249 # End Target
250 # End Project
+0
-7
contrib/pccts/support/rexpr/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 noinst_PROGRAMS= rexpr
4 rexpr_SOURCES= rexpr.c rexpr.h test.c
5
6
+0
-579
contrib/pccts/support/rexpr/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 noinst_PROGRAMS = rexpr$(EXEEXT)
79 subdir = contrib/pccts/support/rexpr
80 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
81 $(top_srcdir)/depcomp
82 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
83 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
84 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
85 $(ACLOCAL_M4)
86 mkinstalldirs = $(install_sh) -d
87 CONFIG_HEADER = $(top_builddir)/config.h
88 CONFIG_CLEAN_FILES =
89 CONFIG_CLEAN_VPATH_FILES =
90 PROGRAMS = $(noinst_PROGRAMS)
91 am_rexpr_OBJECTS = rexpr.$(OBJEXT) test.$(OBJEXT)
92 rexpr_OBJECTS = $(am_rexpr_OBJECTS)
93 rexpr_LDADD = $(LDADD)
94 AM_V_P = $(am__v_P_@AM_V@)
95 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
96 am__v_P_0 = false
97 am__v_P_1 = :
98 AM_V_GEN = $(am__v_GEN_@AM_V@)
99 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
100 am__v_GEN_0 = @echo " GEN " $@;
101 am__v_GEN_1 =
102 AM_V_at = $(am__v_at_@AM_V@)
103 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
104 am__v_at_0 = @
105 am__v_at_1 =
106 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
107 depcomp = $(SHELL) $(top_srcdir)/depcomp
108 am__depfiles_maybe = depfiles
109 am__mv = mv -f
110 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
111 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
112 AM_V_CC = $(am__v_CC_@AM_V@)
113 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
114 am__v_CC_0 = @echo " CC " $@;
115 am__v_CC_1 =
116 CCLD = $(CC)
117 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
118 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
119 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
120 am__v_CCLD_0 = @echo " CCLD " $@;
121 am__v_CCLD_1 =
122 SOURCES = $(rexpr_SOURCES)
123 DIST_SOURCES = $(rexpr_SOURCES)
124 am__can_run_installinfo = \
125 case $$AM_UPDATE_INFO_DIR in \
126 n|no|NO) false;; \
127 *) (install-info --version) >/dev/null 2>&1;; \
128 esac
129 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
130 # Read a list of newline-separated strings from the standard input,
131 # and print each of them once, without duplicates. Input order is
132 # *not* preserved.
133 am__uniquify_input = $(AWK) '\
134 BEGIN { nonempty = 0; } \
135 { items[$$0] = 1; nonempty = 1; } \
136 END { if (nonempty) { for (i in items) print i; }; } \
137 '
138 # Make sure the list of sources is unique. This is necessary because,
139 # e.g., the same source file might be shared among _SOURCES variables
140 # for different programs/libraries.
141 am__define_uniq_tagged_files = \
142 list='$(am__tagged_files)'; \
143 unique=`for i in $$list; do \
144 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
145 done | $(am__uniquify_input)`
146 ETAGS = etags
147 CTAGS = ctags
148 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
149 ACLOCAL = @ACLOCAL@
150 AET2_CFLAGS = @AET2_CFLAGS@
151 AET2_LDADD = @AET2_LDADD@
152 ALLOCA = @ALLOCA@
153 AMTAR = @AMTAR@
154 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
155 AUTOCONF = @AUTOCONF@
156 AUTOHEADER = @AUTOHEADER@
157 AUTOMAKE = @AUTOMAKE@
158 AWK = @AWK@
159 CC = @CC@
160 CCDEPMODE = @CCDEPMODE@
161 CFLAGS = @CFLAGS@
162 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
163 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
164 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
165 CPP = @CPP@
166 CPPFLAGS = @CPPFLAGS@
167 CXX = @CXX@
168 CXXDEPMODE = @CXXDEPMODE@
169 CXXFLAGS = @CXXFLAGS@
170 CYGPATH_W = @CYGPATH_W@
171 DEFS = @DEFS@
172 DEPDIR = @DEPDIR@
173 ECHO_C = @ECHO_C@
174 ECHO_N = @ECHO_N@
175 ECHO_T = @ECHO_T@
176 EGREP = @EGREP@
177 EXEEXT = @EXEEXT@
178 EXTDEBUG = @EXTDEBUG@
179 EXTDEBUG2 = @EXTDEBUG2@
180 EXTDEBUG3 = @EXTDEBUG3@
181 EXTDEBUG4 = @EXTDEBUG4@
182 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
183 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
184 FSDB_CFLAGS = @FSDB_CFLAGS@
185 FSDB_LDADD = @FSDB_LDADD@
186 GCONF_CFLAGS = @GCONF_CFLAGS@
187 GCONF_LIBS = @GCONF_LIBS@
188 GEDITTEST = @GEDITTEST@
189 GEDIT_CFLAGS = @GEDIT_CFLAGS@
190 GIO_CFLAGS = @GIO_CFLAGS@
191 GIO_LIBS = @GIO_LIBS@
192 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
193 GPERF = @GPERF@
194 GREP = @GREP@
195 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
196 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
197 GTK_CFLAGS = @GTK_CFLAGS@
198 GTK_CONFIG = @GTK_CONFIG@
199 GTK_LIBS = @GTK_LIBS@
200 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
201 GTK_MAC_LIBS = @GTK_MAC_LIBS@
202 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
203 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
204 INSTALL = @INSTALL@
205 INSTALL_DATA = @INSTALL_DATA@
206 INSTALL_PROGRAM = @INSTALL_PROGRAM@
207 INSTALL_SCRIPT = @INSTALL_SCRIPT@
208 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
209 LDFLAGS = @LDFLAGS@
210 LEX = @LEX@
211 LEXLIB = @LEXLIB@
212 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
213 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
214 LIBBZ2_DIR = @LIBBZ2_DIR@
215 LIBBZ2_LDADD = @LIBBZ2_LDADD@
216 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
217 LIBJUDY_LDADD = @LIBJUDY_LDADD@
218 LIBOBJS = @LIBOBJS@
219 LIBS = @LIBS@
220 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
221 LIBXZ_LDADD = @LIBXZ_LDADD@
222 LIBZ_CFLAGS = @LIBZ_CFLAGS@
223 LIBZ_DIR = @LIBZ_DIR@
224 LIBZ_LDADD = @LIBZ_LDADD@
225 LTLIBOBJS = @LTLIBOBJS@
226 MAINT = @MAINT@
227 MAKEINFO = @MAKEINFO@
228 MINGW_LDADD = @MINGW_LDADD@
229 MKDIR_P = @MKDIR_P@
230 OBJEXT = @OBJEXT@
231 PACKAGE = @PACKAGE@
232 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
233 PACKAGE_NAME = @PACKAGE_NAME@
234 PACKAGE_STRING = @PACKAGE_STRING@
235 PACKAGE_TARNAME = @PACKAGE_TARNAME@
236 PACKAGE_URL = @PACKAGE_URL@
237 PACKAGE_VERSION = @PACKAGE_VERSION@
238 PATH_SEPARATOR = @PATH_SEPARATOR@
239 PKG_CONFIG = @PKG_CONFIG@
240 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
241 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
242 POW_LIB = @POW_LIB@
243 RANLIB = @RANLIB@
244 RPC_CFLAGS = @RPC_CFLAGS@
245 RPC_LDADD = @RPC_LDADD@
246 SET_MAKE = @SET_MAKE@
247 SHELL = @SHELL@
248 STRIP = @STRIP@
249 STRUCT_PACK = @STRUCT_PACK@
250 TCL_DEFADD = @TCL_DEFADD@
251 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
252 TCL_LDADD = @TCL_LDADD@
253 TCL_LIB_SPEC = @TCL_LIB_SPEC@
254 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
255 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
256 TIRPC_CFLAGS = @TIRPC_CFLAGS@
257 TIRPC_LIBS = @TIRPC_LIBS@
258 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
259 TK_LDADD = @TK_LDADD@
260 TK_LIB_SPEC = @TK_LIB_SPEC@
261 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
262 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
263 VERSION = @VERSION@
264 XDGDATADIR = @XDGDATADIR@
265 abs_builddir = @abs_builddir@
266 abs_srcdir = @abs_srcdir@
267 abs_top_builddir = @abs_top_builddir@
268 abs_top_srcdir = @abs_top_srcdir@
269 ac_ct_CC = @ac_ct_CC@
270 ac_ct_CXX = @ac_ct_CXX@
271 am__include = @am__include@
272 am__leading_dot = @am__leading_dot@
273 am__quote = @am__quote@
274 am__tar = @am__tar@
275 am__untar = @am__untar@
276 bindir = @bindir@
277 build_alias = @build_alias@
278 builddir = @builddir@
279 datadir = @datadir@
280 datarootdir = @datarootdir@
281 docdir = @docdir@
282 dvidir = @dvidir@
283 exec_prefix = @exec_prefix@
284 gsettingsschemadir = @gsettingsschemadir@
285 host_alias = @host_alias@
286 htmldir = @htmldir@
287 includedir = @includedir@
288 infodir = @infodir@
289 install_sh = @install_sh@
290 libdir = @libdir@
291 libexecdir = @libexecdir@
292 localedir = @localedir@
293 localstatedir = @localstatedir@
294 mandir = @mandir@
295 mkdir_p = @mkdir_p@
296 oldincludedir = @oldincludedir@
297 pdfdir = @pdfdir@
298 prefix = @prefix@
299 program_transform_name = @program_transform_name@
300 psdir = @psdir@
301 sbindir = @sbindir@
302 sharedstatedir = @sharedstatedir@
303 srcdir = @srcdir@
304 sysconfdir = @sysconfdir@
305 target_alias = @target_alias@
306 top_build_prefix = @top_build_prefix@
307 top_builddir = @top_builddir@
308 top_srcdir = @top_srcdir@
309 rexpr_SOURCES = rexpr.c rexpr.h test.c
310 all: all-am
311
312 .SUFFIXES:
313 .SUFFIXES: .c .o .obj
314 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
315 @for dep in $?; do \
316 case '$(am__configure_deps)' in \
317 *$$dep*) \
318 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
319 && { if test -f $@; then exit 0; else break; fi; }; \
320 exit 1;; \
321 esac; \
322 done; \
323 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/support/rexpr/Makefile'; \
324 $(am__cd) $(top_srcdir) && \
325 $(AUTOMAKE) --foreign contrib/pccts/support/rexpr/Makefile
326 .PRECIOUS: Makefile
327 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
328 @case '$?' in \
329 *config.status*) \
330 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
331 *) \
332 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
333 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
334 esac;
335
336 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
337 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
338
339 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
340 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
341 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
342 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
343 $(am__aclocal_m4_deps):
344
345 clean-noinstPROGRAMS:
346 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
347
348 rexpr$(EXEEXT): $(rexpr_OBJECTS) $(rexpr_DEPENDENCIES) $(EXTRA_rexpr_DEPENDENCIES)
349 @rm -f rexpr$(EXEEXT)
350 $(AM_V_CCLD)$(LINK) $(rexpr_OBJECTS) $(rexpr_LDADD) $(LIBS)
351
352 mostlyclean-compile:
353 -rm -f *.$(OBJEXT)
354
355 distclean-compile:
356 -rm -f *.tab.c
357
358 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rexpr.Po@am__quote@
359 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test.Po@am__quote@
360
361 .c.o:
362 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
363 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
364 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
365 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
366 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
367
368 .c.obj:
369 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
370 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
371 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
372 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
373 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
374
375 ID: $(am__tagged_files)
376 $(am__define_uniq_tagged_files); mkid -fID $$unique
377 tags: tags-am
378 TAGS: tags
379
380 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
381 set x; \
382 here=`pwd`; \
383 $(am__define_uniq_tagged_files); \
384 shift; \
385 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
386 test -n "$$unique" || unique=$$empty_fix; \
387 if test $$# -gt 0; then \
388 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
389 "$$@" $$unique; \
390 else \
391 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
392 $$unique; \
393 fi; \
394 fi
395 ctags: ctags-am
396
397 CTAGS: ctags
398 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
399 $(am__define_uniq_tagged_files); \
400 test -z "$(CTAGS_ARGS)$$unique" \
401 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
402 $$unique
403
404 GTAGS:
405 here=`$(am__cd) $(top_builddir) && pwd` \
406 && $(am__cd) $(top_srcdir) \
407 && gtags -i $(GTAGS_ARGS) "$$here"
408 cscopelist: cscopelist-am
409
410 cscopelist-am: $(am__tagged_files)
411 list='$(am__tagged_files)'; \
412 case "$(srcdir)" in \
413 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
414 *) sdir=$(subdir)/$(srcdir) ;; \
415 esac; \
416 for i in $$list; do \
417 if test -f "$$i"; then \
418 echo "$(subdir)/$$i"; \
419 else \
420 echo "$$sdir/$$i"; \
421 fi; \
422 done >> $(top_builddir)/cscope.files
423
424 distclean-tags:
425 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
426
427 distdir: $(DISTFILES)
428 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
429 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
430 list='$(DISTFILES)'; \
431 dist_files=`for file in $$list; do echo $$file; done | \
432 sed -e "s|^$$srcdirstrip/||;t" \
433 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
434 case $$dist_files in \
435 */*) $(MKDIR_P) `echo "$$dist_files" | \
436 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
437 sort -u` ;; \
438 esac; \
439 for file in $$dist_files; do \
440 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
441 if test -d $$d/$$file; then \
442 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
443 if test -d "$(distdir)/$$file"; then \
444 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
445 fi; \
446 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
447 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
448 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
449 fi; \
450 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
451 else \
452 test -f "$(distdir)/$$file" \
453 || cp -p $$d/$$file "$(distdir)/$$file" \
454 || exit 1; \
455 fi; \
456 done
457 check-am: all-am
458 check: check-am
459 all-am: Makefile $(PROGRAMS)
460 installdirs:
461 install: install-am
462 install-exec: install-exec-am
463 install-data: install-data-am
464 uninstall: uninstall-am
465
466 install-am: all-am
467 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
468
469 installcheck: installcheck-am
470 install-strip:
471 if test -z '$(STRIP)'; then \
472 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
473 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
474 install; \
475 else \
476 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
477 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
478 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
479 fi
480 mostlyclean-generic:
481
482 clean-generic:
483
484 distclean-generic:
485 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
486 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
487
488 maintainer-clean-generic:
489 @echo "This command is intended for maintainers to use"
490 @echo "it deletes files that may require special tools to rebuild."
491 clean: clean-am
492
493 clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am
494
495 distclean: distclean-am
496 -rm -rf ./$(DEPDIR)
497 -rm -f Makefile
498 distclean-am: clean-am distclean-compile distclean-generic \
499 distclean-tags
500
501 dvi: dvi-am
502
503 dvi-am:
504
505 html: html-am
506
507 html-am:
508
509 info: info-am
510
511 info-am:
512
513 install-data-am:
514
515 install-dvi: install-dvi-am
516
517 install-dvi-am:
518
519 install-exec-am:
520
521 install-html: install-html-am
522
523 install-html-am:
524
525 install-info: install-info-am
526
527 install-info-am:
528
529 install-man:
530
531 install-pdf: install-pdf-am
532
533 install-pdf-am:
534
535 install-ps: install-ps-am
536
537 install-ps-am:
538
539 installcheck-am:
540
541 maintainer-clean: maintainer-clean-am
542 -rm -rf ./$(DEPDIR)
543 -rm -f Makefile
544 maintainer-clean-am: distclean-am maintainer-clean-generic
545
546 mostlyclean: mostlyclean-am
547
548 mostlyclean-am: mostlyclean-compile mostlyclean-generic
549
550 pdf: pdf-am
551
552 pdf-am:
553
554 ps: ps-am
555
556 ps-am:
557
558 uninstall-am:
559
560 .MAKE: install-am install-strip
561
562 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
563 clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \
564 distclean-compile distclean-generic distclean-tags distdir dvi \
565 dvi-am html html-am info info-am install install-am \
566 install-data install-data-am install-dvi install-dvi-am \
567 install-exec install-exec-am install-html install-html-am \
568 install-info install-info-am install-man install-pdf \
569 install-pdf-am install-ps install-ps-am install-strip \
570 installcheck installcheck-am installdirs maintainer-clean \
571 maintainer-clean-generic mostlyclean mostlyclean-compile \
572 mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
573 uninstall-am
574
575
576 # Tell versions [3.59,3.63) of GNU make to not export all variables.
577 # Otherwise a system limit (for SysV at least) may be exceeded.
578 .NOEXPORT:
+0
-586
contrib/pccts/support/rexpr/rexpr.c less more
0 /*
1 * This file contains code for
2 *
3 * int rexpr(char *expr, char *s);
4 *
5 * which answers
6 *
7 * 1 if 's' is in the language described by the regular expression 'expr'
8 * 0 if it is not
9 * -1 if the regular expression is invalid
10 *
11 * Language membership is determined by constructing a non-deterministic
12 * finite automata (NFA) from the regular expression. A depth-
13 * first-search is performed on the NFA (graph) to check for a match of 's'.
14 * Each non-epsilon arc consumes one character from 's'. Backtracking is
15 * performed to check all possible paths through the NFA.
16 *
17 * Regular expressions follow the meta-language:
18 *
19 * <regExpr> ::= <andExpr> ( '|' <andExpr> )*
20 *
21 * <andExpr> ::= <expr> ( <expr> )*
22 *
23 * <expr> ::= {'~'} '[' <atomList> ']' <repeatSymbol>
24 * | '(' <regExpr> ')' <repeatSymbol>
25 * | '{' <regExpr> '}' <repeatSymbol>
26 * | <atom> <repeatSymbol>
27 *
28 * <repeatSymbol> ::= { '*' | '+' }
29 *
30 * <atomList> ::= <atom> ( <atom> )*
31 * | { <atomList> } <atom> '-' <atom> { <atomList> }
32 *
33 * <atom> ::= Token[Atom]
34 *
35 * Notes:
36 * ~ means complement the set in [..]. i.e. all characters not listed
37 * * means match 0 or more times (can be on expression or atom)
38 * + means match 1 or more times (can be on expression or atom)
39 * {} optional
40 * () grouping
41 * [] set of atoms
42 * x-y all characters from x to y (found only in [..])
43 * \xx the character with value xx
44 *
45 * Examples:
46 * [a-z]+
47 * match 1 or more lower-case letters (e.g. variable)
48 *
49 * 0x[0-9A-Fa-f]+
50 * match a hex number with 0x on front (e.g. 0xA1FF)
51 *
52 * [0-9]+.[0-9]+{e[0-9]+}
53 * match a floating point number (e.g. 3.14e21)
54 *
55 * Code example:
56 * if ( rexpr("[a-zA-Z][a-zA-Z0-9]+", str) ) then str is keyword
57 *
58 * Terence Parr
59 * Purdue University
60 * April 1991
61 */
62
63 #include <stdio.h>
64 #include <ctype.h>
65 #ifdef __STDC__
66 #include <stdlib.h>
67 #else
68 #include <malloc.h>
69 #endif
70 #include "rexpr.h"
71
72 #ifdef __USE_PROTOS
73 static int regExpr( GraphPtr g );
74 static int andExpr( GraphPtr g );
75 static int expr( GraphPtr g );
76 static int repeatSymbol( GraphPtr g );
77 static int atomList( char *p, int complement );
78 static void next( void );
79 static ArcPtr newGraphArc( void );
80 static NodePtr newNode( void );
81 static int ArcBetweenGraphNode( NodePtr i, NodePtr j, int label );
82 static Graph BuildNFA_atom( int label );
83 static Graph BuildNFA_AB( Graph A, Graph B );
84 static Graph BuildNFA_AorB( Graph A, Graph B );
85 static Graph BuildNFA_set( char *s );
86 static Graph BuildNFA_Astar( Graph A );
87 static Graph BuildNFA_Aplus( Graph A );
88 static Graph BuildNFA_Aoptional( Graph A );
89 #else
90 static int regExpr();
91 static int andExpr();
92 static int expr();
93 static int repeatSymbol();
94 static int atomList();
95 static void next();
96 static ArcPtr newGraphArc();
97 static NodePtr newNode();
98 static int ArcBetweenGraphNode();
99 static Graph BuildNFA_atom();
100 static Graph BuildNFA_AB();
101 static Graph BuildNFA_AorB();
102 static Graph BuildNFA_set();
103 static Graph BuildNFA_Astar();
104 static Graph BuildNFA_Aplus();
105 static Graph BuildNFA_Aoptional();
106 #endif
107
108 static char *_c;
109 static int token, tokchar;
110 static NodePtr accept;
111 static NodePtr freelist = NULL;
112
113 /*
114 * return 1 if s in language described by expr
115 * 0 if s is not
116 * -1 if expr is an invalid regular expression
117 */
118 #ifdef __USE_PROTOS
119 int rexpr(char *expr,char *s)
120 #else
121 int rexpr(expr, s)
122 char *expr, *s;
123 #endif
124 {
125 NodePtr p,q;
126 Graph nfa;
127 int result;
128
129 fprintf(stderr, "rexpr(%s,%s);\n", expr,s);
130 freelist = NULL;
131 _c = expr;
132 next();
133 if ( regExpr(&nfa) == -1 ) return -1;
134 accept = nfa.right;
135 result = match(nfa.left, s);
136 /* free all your memory */
137 p = q = freelist;
138 while ( p!=NULL ) { q = p->track; free(p); p = q; }
139 return result;
140 }
141
142 /*
143 * do a depth-first-search on the NFA looking for a path from start to
144 * accept state labelled with the characters of 's'.
145 */
146
147 #ifdef __USE_PROTOS
148 int match(NodePtr automaton,char *s)
149 #else
150 int match(automaton, s)
151 NodePtr automaton;
152 char *s;
153 #endif
154 {
155 ArcPtr p;
156
157 if ( automaton == accept && *s == '\0' ) return 1; /* match */
158
159 for (p=automaton->arcs; p!=NULL; p=p->next) /* try all arcs */
160 {
161 if ( p->label == Epsilon )
162 {
163 if ( match(p->target, s) ) return 1;
164 }
165 else if ( p->label == *s )
166 if ( match(p->target, s+1) ) return 1;
167 }
168 return 0;
169 }
170
171 /*
172 * <regExpr> ::= <andExpr> ( '|' {<andExpr>} )*
173 *
174 * Return -1 if syntax error
175 * Return 0 if none found
176 * Return 1 if a regExrp was found
177 */
178
179 #ifdef __USE_PROTOS
180 static int regExpr(GraphPtr g)
181 #else
182 static int regExpr(g)
183 GraphPtr g;
184 #endif
185 {
186 Graph g1, g2;
187
188 if ( andExpr(&g1) == -1 )
189 {
190 return -1;
191 }
192
193 while ( token == '|' )
194 {
195 int a;
196 next();
197 a = andExpr(&g2);
198 if ( a == -1 ) return -1; /* syntax error below */
199 else if ( !a ) return 1; /* empty alternative */
200 g1 = BuildNFA_AorB(g1, g2);
201 }
202
203 if ( token!='\0' ) return -1;
204
205 *g = g1;
206 return 1;
207 }
208
209 /*
210 * <andExpr> ::= <expr> ( <expr> )*
211 */
212
213 #ifdef __USE_PROTOS
214 static int andExpr(GraphPtr g)
215 #else
216 static int andExpr(g)
217 GraphPtr g;
218 #endif
219 {
220 Graph g1, g2;
221
222 if ( expr(&g1) == -1 )
223 {
224 return -1;
225 }
226
227 while ( token==Atom || token=='{' || token=='(' || token=='~' || token=='[' )
228 {
229 if (expr(&g2) == -1) return -1;
230 g1 = BuildNFA_AB(g1, g2);
231 }
232
233 *g = g1;
234 return 1;
235 }
236
237 /*
238 * <expr> ::= {'~'} '[' <atomList> ']' <repeatSymbol>
239 * | '(' <regExpr> ')' <repeatSymbol>
240 * | '{' <regExpr> '}' <repeatSymbol>
241 * | <atom> <repeatSymbol>
242 */
243
244 #ifdef __USE_PROTOS
245 static int expr(GraphPtr g)
246 #else
247 static int expr(g)
248 GraphPtr g;
249 #endif
250 {
251 int complement = 0;
252 char s[257]; /* alloc space for string of char in [] */
253
254 if ( token == '~' || token == '[' )
255 {
256 if ( token == '~' ) {complement = 1; next();}
257 if ( token != '[' ) return -1;
258 next();
259 if ( atomList( s, complement ) == -1 ) return -1;
260 *g = BuildNFA_set( s );
261 if ( token != ']' ) return -1;
262 next();
263 repeatSymbol( g );
264 return 1;
265 }
266 if ( token == '(' )
267 {
268 next();
269 if ( regExpr( g ) == -1 ) return -1;
270 if ( token != ')' ) return -1;
271 next();
272 repeatSymbol( g );
273 return 1;
274 }
275 if ( token == '{' )
276 {
277 next();
278 if ( regExpr( g ) == -1 ) return -1;
279 if ( token != '}' ) return -1;
280 next();
281 /* S p e c i a l C a s e O p t i o n a l { } */
282 if ( token != '*' && token != '+' )
283 {
284 *g = BuildNFA_Aoptional( *g );
285 }
286 repeatSymbol( g );
287 return 1;
288 }
289 if ( token == Atom )
290 {
291 *g = BuildNFA_atom( tokchar );
292 next();
293 repeatSymbol( g );
294 return 1;
295 }
296
297 return -1;
298 }
299
300 /*
301 * <repeatSymbol> ::= { '*' | '+' }
302 */
303 #ifdef __USE_PROTOS
304 static int repeatSymbol(GraphPtr g)
305 #else
306 static int repeatSymbol(g)
307 GraphPtr g;
308 #endif
309 {
310 switch ( token )
311 {
312 case '*' : *g = BuildNFA_Astar( *g ); next(); break;
313 case '+' : *g = BuildNFA_Aplus( *g ); next(); break;
314 }
315 return 1;
316 }
317
318 /*
319 * <atomList> ::= <atom> { <atom> }*
320 * { <atomList> } <atom> '-' <atom> { <atomList> }
321 *
322 * a-b is same as ab
323 * q-a is same as q
324 */
325
326 #ifdef __USE_PROTOS
327 static int atomList(char *p, int complement)
328 #else
329 static int atomList(p, complement)
330 char *p;
331 int complement;
332 #endif
333 {
334 static unsigned char set[256]; /* no duplicates */
335 int first, last, i;
336 char *s = p;
337
338 if ( token != Atom ) return -1;
339
340 for (i=0; i<256; i++) set[i] = 0;
341 while ( token == Atom )
342 {
343 if ( !set[tokchar] ) *s++ = tokchar;
344 set[tokchar] = 1; /* Add atom to set */
345 next();
346 if ( token == '-' ) /* have we found '-' */
347 {
348 first = *(s-1); /* Get last char */
349 next();
350 if ( token != Atom ) return -1;
351 else
352 {
353 last = tokchar;
354 }
355 for (i = first+1; i <= last; i++)
356 {
357 if ( !set[tokchar] ) *s++ = i;
358 set[i] = 1; /* Add atom to set */
359 }
360 next();
361 }
362 }
363 *s = '\0';
364 if ( complement )
365 {
366 for (i=0; i<256; i++) set[i] = !set[i];
367 for (i=1,s=p; i<256; i++) if ( set[i] ) *s++ = i;
368 *s = '\0';
369 }
370 return 1;
371 }
372
373 /* a somewhat stupid lexical analyzer */
374
375 #ifdef __USE_PROTOS
376 static void next(void)
377 #else
378 static void next()
379 #endif
380 {
381 while ( *_c==' ' || *_c=='\t' || *_c=='\n' ) _c++;
382 if ( *_c=='\\' )
383 {
384 _c++;
385 if ( isdigit(*_c) )
386 {
387 int n=0;
388 while ( isdigit(*_c) )
389 {
390 n = n*10 + (*_c++ - '0');
391 }
392 if ( n>255 ) n=255;
393 tokchar = n;
394 }
395 else
396 {
397 switch (*_c)
398 {
399 case 'n' : tokchar = '\n'; break;
400 case 't' : tokchar = '\t'; break;
401 case 'r' : tokchar = '\r'; break;
402 default : tokchar = *_c;
403 }
404 _c++;
405 }
406 token = Atom;
407 }
408 else if ( isgraph(*_c) && *_c!='[' && *_c!='(' && *_c!='{' &&
409 *_c!='-' && *_c!='}' && *_c!=')' && *_c!=']' &&
410 *_c!='+' && *_c!='*' && *_c!='~' && *_c!='|' )
411 {
412 token = Atom;
413 tokchar = *_c++;
414 }
415 else
416 {
417 token = tokchar = *_c++;
418 }
419 }
420
421 /* N F A B u i l d i n g R o u t i n e s */
422
423 #ifdef __USE_PROTOS
424 static ArcPtr newGraphArc(void)
425 #else
426 static ArcPtr newGraphArc()
427 #endif
428 {
429 ArcPtr p;
430 p = (ArcPtr) calloc(1, sizeof(Arc));
431 if ( p==NULL ) {fprintf(stderr,"rexpr: out of memory\n"); exit(-1);}
432 if ( freelist != NULL ) p->track = (ArcPtr) freelist;
433 freelist = (NodePtr) p;
434 return p;
435 }
436
437 #ifdef __USE_PROTOS
438 static NodePtr newNode(void)
439 #else
440 static NodePtr newNode()
441 #endif
442 {
443 NodePtr p;
444 p = (NodePtr) calloc(1, sizeof(Node));
445 if ( p==NULL ) {fprintf(stderr,"rexpr: out of memory\n"); exit(-1);}
446 if ( freelist != NULL ) p->track = freelist;
447 freelist = p;
448 return p;
449 }
450
451 #ifdef __USE_PROTOS
452 static void ArcBetweenGraphNodes(NodePtr i,NodePtr j,int label)
453 #else
454 static void ArcBetweenGraphNodes(i, j, label)
455 NodePtr i, j;
456 int label;
457 #endif
458 {
459 ArcPtr a;
460
461 a = newGraphArc();
462 if ( i->arcs == NULL ) i->arctail = i->arcs = a;
463 else {(i->arctail)->next = a; i->arctail = a;}
464 a->label = label;
465 a->target = j;
466 }
467
468 #ifdef __USE_PROTOS
469 static Graph BuildNFA_atom(int label)
470 #else
471 static Graph BuildNFA_atom(label)
472 int label;
473 #endif
474 {
475 Graph g;
476
477 g.left = newNode();
478 g.right = newNode();
479 ArcBetweenGraphNodes(g.left, g.right, label);
480 return( g );
481 }
482
483 #ifdef __USE_PROTOS
484 static Graph BuildNFA_AB(Graph A,Graph B)
485 #else
486 static Graph BuildNFA_AB(A, B)
487 Graph A, B;
488 #endif
489 {
490 Graph g;
491
492 ArcBetweenGraphNodes(A.right, B.left, Epsilon);
493 g.left = A.left;
494 g.right = B.right;
495 return( g );
496 }
497
498 #ifdef __USE_PROTOS
499 static Graph BuildNFA_AorB(Graph A,Graph B)
500 #else
501 static Graph BuildNFA_AorB(A, B)
502 Graph A, B;
503 #endif
504 {
505 Graph g;
506
507 g.left = newNode();
508 ArcBetweenGraphNodes(g.left, A.left, Epsilon);
509 ArcBetweenGraphNodes(g.left, B.left, Epsilon);
510 g.right = newNode();
511 ArcBetweenGraphNodes(A.right, g.right, Epsilon);
512 ArcBetweenGraphNodes(B.right, g.right, Epsilon);
513 return( g );
514 }
515
516 #ifdef __USE_PROTOS
517 static Graph BuildNFA_set(char *s)
518 #else
519 static Graph BuildNFA_set( s )
520 char *s;
521 #endif
522 {
523 Graph g;
524
525 if ( s == NULL ) return g;
526
527 g.left = newNode();
528 g.right = newNode();
529 while ( *s != '\0' )
530 {
531 ArcBetweenGraphNodes(g.left, g.right, *s++);
532 }
533 return g;
534 }
535
536 #ifdef __USE_PROTOS
537 static Graph BuildNFA_Astar(Graph A)
538 #else
539 static Graph BuildNFA_Astar( A )
540 Graph A;
541 #endif
542 {
543 Graph g;
544
545 g.left = newNode();
546 g.right = newNode();
547
548 ArcBetweenGraphNodes(g.left, A.left, Epsilon);
549 ArcBetweenGraphNodes(g.left, g.right, Epsilon);
550 ArcBetweenGraphNodes(A.right, g.right, Epsilon);
551 ArcBetweenGraphNodes(A.right, A.left, Epsilon);
552
553 return( g );
554 }
555
556 #ifdef __USE_PROTOS
557 static Graph BuildNFA_Aplus(Graph A)
558 #else
559 static Graph BuildNFA_Aplus( A )
560 Graph A;
561 #endif
562 {
563 ArcBetweenGraphNodes(A.right, A.left, Epsilon);
564
565 return( A );
566 }
567
568 #ifdef __USE_PROTOS
569 static Graph BuildNFA_Aoptional(Graph A)
570 #else
571 static Graph BuildNFA_Aoptional( A )
572 Graph A;
573 #endif
574 {
575 Graph g;
576
577 g.left = newNode();
578 g.right = newNode();
579
580 ArcBetweenGraphNodes(g.left, A.left, Epsilon);
581 ArcBetweenGraphNodes(g.left, g.right, Epsilon);
582 ArcBetweenGraphNodes(A.right, g.right, Epsilon);
583
584 return( g );
585 }
+0
-30
contrib/pccts/support/rexpr/rexpr.h less more
0 #define Atom 256 /* token Atom (an impossible char value) */
1 #define Epsilon 257 /* epsilon arc (an impossible char value) */
2
3 /* track field must be same for all node types */
4 typedef struct _a {
5 struct _a *track; /* track mem allocation */
6 int label;
7 struct _a *next;
8 struct _n *target;
9 } Arc, *ArcPtr;
10
11 typedef struct _n {
12 struct _n *track;
13 ArcPtr arcs, arctail;
14 } Node, *NodePtr;
15
16 typedef struct {
17 NodePtr left,
18 right;
19 } Graph, *GraphPtr;
20
21 #ifdef __USE_PROTOS
22 int rexpr( char *expr, char *s );
23 int match( NodePtr automaton, char *s );
24 #else
25 int rexpr();
26 int match();
27 #endif
28
29
+0
-21
contrib/pccts/support/rexpr/test.c less more
0 #include <stdio.h>
1 #include "rexpr.h"
2
3 /*
4 * test for rexpr().
5 * To make this test:
6 * cc -o rexpr test.c rexpr.c
7 * Then from command line type:
8 * rexpr r string
9 * where r is the regular expression that decribes a language
10 * and string is the string to verify.
11 */
12 int main(argc,argv)
13 int argc;
14 char *argv[];
15 {
16 if ( argc!=3 ) fprintf(stderr,"rexpr: expr s\n");
17 else printf("%d\n", rexpr(argv[1], argv[2]));
18
19 return(0);
20 }
+0
-5
contrib/pccts/support/set/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 EXTRA_DIST= set.c set.h
4
+0
-456
contrib/pccts/support/set/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/support/set
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 am__can_run_installinfo = \
102 case $$AM_UPDATE_INFO_DIR in \
103 n|no|NO) false;; \
104 *) (install-info --version) >/dev/null 2>&1;; \
105 esac
106 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
107 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
108 ACLOCAL = @ACLOCAL@
109 AET2_CFLAGS = @AET2_CFLAGS@
110 AET2_LDADD = @AET2_LDADD@
111 ALLOCA = @ALLOCA@
112 AMTAR = @AMTAR@
113 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
114 AUTOCONF = @AUTOCONF@
115 AUTOHEADER = @AUTOHEADER@
116 AUTOMAKE = @AUTOMAKE@
117 AWK = @AWK@
118 CC = @CC@
119 CCDEPMODE = @CCDEPMODE@
120 CFLAGS = @CFLAGS@
121 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
122 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
123 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
124 CPP = @CPP@
125 CPPFLAGS = @CPPFLAGS@
126 CXX = @CXX@
127 CXXDEPMODE = @CXXDEPMODE@
128 CXXFLAGS = @CXXFLAGS@
129 CYGPATH_W = @CYGPATH_W@
130 DEFS = @DEFS@
131 DEPDIR = @DEPDIR@
132 ECHO_C = @ECHO_C@
133 ECHO_N = @ECHO_N@
134 ECHO_T = @ECHO_T@
135 EGREP = @EGREP@
136 EXEEXT = @EXEEXT@
137 EXTDEBUG = @EXTDEBUG@
138 EXTDEBUG2 = @EXTDEBUG2@
139 EXTDEBUG3 = @EXTDEBUG3@
140 EXTDEBUG4 = @EXTDEBUG4@
141 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
142 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
143 FSDB_CFLAGS = @FSDB_CFLAGS@
144 FSDB_LDADD = @FSDB_LDADD@
145 GCONF_CFLAGS = @GCONF_CFLAGS@
146 GCONF_LIBS = @GCONF_LIBS@
147 GEDITTEST = @GEDITTEST@
148 GEDIT_CFLAGS = @GEDIT_CFLAGS@
149 GIO_CFLAGS = @GIO_CFLAGS@
150 GIO_LIBS = @GIO_LIBS@
151 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
152 GPERF = @GPERF@
153 GREP = @GREP@
154 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
155 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
156 GTK_CFLAGS = @GTK_CFLAGS@
157 GTK_CONFIG = @GTK_CONFIG@
158 GTK_LIBS = @GTK_LIBS@
159 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
160 GTK_MAC_LIBS = @GTK_MAC_LIBS@
161 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
162 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
163 INSTALL = @INSTALL@
164 INSTALL_DATA = @INSTALL_DATA@
165 INSTALL_PROGRAM = @INSTALL_PROGRAM@
166 INSTALL_SCRIPT = @INSTALL_SCRIPT@
167 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
168 LDFLAGS = @LDFLAGS@
169 LEX = @LEX@
170 LEXLIB = @LEXLIB@
171 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
172 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
173 LIBBZ2_DIR = @LIBBZ2_DIR@
174 LIBBZ2_LDADD = @LIBBZ2_LDADD@
175 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
176 LIBJUDY_LDADD = @LIBJUDY_LDADD@
177 LIBOBJS = @LIBOBJS@
178 LIBS = @LIBS@
179 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
180 LIBXZ_LDADD = @LIBXZ_LDADD@
181 LIBZ_CFLAGS = @LIBZ_CFLAGS@
182 LIBZ_DIR = @LIBZ_DIR@
183 LIBZ_LDADD = @LIBZ_LDADD@
184 LTLIBOBJS = @LTLIBOBJS@
185 MAINT = @MAINT@
186 MAKEINFO = @MAKEINFO@
187 MINGW_LDADD = @MINGW_LDADD@
188 MKDIR_P = @MKDIR_P@
189 OBJEXT = @OBJEXT@
190 PACKAGE = @PACKAGE@
191 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
192 PACKAGE_NAME = @PACKAGE_NAME@
193 PACKAGE_STRING = @PACKAGE_STRING@
194 PACKAGE_TARNAME = @PACKAGE_TARNAME@
195 PACKAGE_URL = @PACKAGE_URL@
196 PACKAGE_VERSION = @PACKAGE_VERSION@
197 PATH_SEPARATOR = @PATH_SEPARATOR@
198 PKG_CONFIG = @PKG_CONFIG@
199 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
200 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
201 POW_LIB = @POW_LIB@
202 RANLIB = @RANLIB@
203 RPC_CFLAGS = @RPC_CFLAGS@
204 RPC_LDADD = @RPC_LDADD@
205 SET_MAKE = @SET_MAKE@
206 SHELL = @SHELL@
207 STRIP = @STRIP@
208 STRUCT_PACK = @STRUCT_PACK@
209 TCL_DEFADD = @TCL_DEFADD@
210 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
211 TCL_LDADD = @TCL_LDADD@
212 TCL_LIB_SPEC = @TCL_LIB_SPEC@
213 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
214 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
215 TIRPC_CFLAGS = @TIRPC_CFLAGS@
216 TIRPC_LIBS = @TIRPC_LIBS@
217 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
218 TK_LDADD = @TK_LDADD@
219 TK_LIB_SPEC = @TK_LIB_SPEC@
220 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
221 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
222 VERSION = @VERSION@
223 XDGDATADIR = @XDGDATADIR@
224 abs_builddir = @abs_builddir@
225 abs_srcdir = @abs_srcdir@
226 abs_top_builddir = @abs_top_builddir@
227 abs_top_srcdir = @abs_top_srcdir@
228 ac_ct_CC = @ac_ct_CC@
229 ac_ct_CXX = @ac_ct_CXX@
230 am__include = @am__include@
231 am__leading_dot = @am__leading_dot@
232 am__quote = @am__quote@
233 am__tar = @am__tar@
234 am__untar = @am__untar@
235 bindir = @bindir@
236 build_alias = @build_alias@
237 builddir = @builddir@
238 datadir = @datadir@
239 datarootdir = @datarootdir@
240 docdir = @docdir@
241 dvidir = @dvidir@
242 exec_prefix = @exec_prefix@
243 gsettingsschemadir = @gsettingsschemadir@
244 host_alias = @host_alias@
245 htmldir = @htmldir@
246 includedir = @includedir@
247 infodir = @infodir@
248 install_sh = @install_sh@
249 libdir = @libdir@
250 libexecdir = @libexecdir@
251 localedir = @localedir@
252 localstatedir = @localstatedir@
253 mandir = @mandir@
254 mkdir_p = @mkdir_p@
255 oldincludedir = @oldincludedir@
256 pdfdir = @pdfdir@
257 prefix = @prefix@
258 program_transform_name = @program_transform_name@
259 psdir = @psdir@
260 sbindir = @sbindir@
261 sharedstatedir = @sharedstatedir@
262 srcdir = @srcdir@
263 sysconfdir = @sysconfdir@
264 target_alias = @target_alias@
265 top_build_prefix = @top_build_prefix@
266 top_builddir = @top_builddir@
267 top_srcdir = @top_srcdir@
268 EXTRA_DIST = set.c set.h
269 all: all-am
270
271 .SUFFIXES:
272 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
273 @for dep in $?; do \
274 case '$(am__configure_deps)' in \
275 *$$dep*) \
276 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
277 && { if test -f $@; then exit 0; else break; fi; }; \
278 exit 1;; \
279 esac; \
280 done; \
281 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/support/set/Makefile'; \
282 $(am__cd) $(top_srcdir) && \
283 $(AUTOMAKE) --foreign contrib/pccts/support/set/Makefile
284 .PRECIOUS: Makefile
285 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
286 @case '$?' in \
287 *config.status*) \
288 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
289 *) \
290 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
291 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
292 esac;
293
294 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
295 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
296
297 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
298 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
299 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
300 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
301 $(am__aclocal_m4_deps):
302 tags TAGS:
303
304 ctags CTAGS:
305
306 cscope cscopelist:
307
308
309 distdir: $(DISTFILES)
310 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
311 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
312 list='$(DISTFILES)'; \
313 dist_files=`for file in $$list; do echo $$file; done | \
314 sed -e "s|^$$srcdirstrip/||;t" \
315 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
316 case $$dist_files in \
317 */*) $(MKDIR_P) `echo "$$dist_files" | \
318 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
319 sort -u` ;; \
320 esac; \
321 for file in $$dist_files; do \
322 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
323 if test -d $$d/$$file; then \
324 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
325 if test -d "$(distdir)/$$file"; then \
326 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
327 fi; \
328 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
329 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
330 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
331 fi; \
332 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
333 else \
334 test -f "$(distdir)/$$file" \
335 || cp -p $$d/$$file "$(distdir)/$$file" \
336 || exit 1; \
337 fi; \
338 done
339 check-am: all-am
340 check: check-am
341 all-am: Makefile
342 installdirs:
343 install: install-am
344 install-exec: install-exec-am
345 install-data: install-data-am
346 uninstall: uninstall-am
347
348 install-am: all-am
349 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
350
351 installcheck: installcheck-am
352 install-strip:
353 if test -z '$(STRIP)'; then \
354 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
355 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
356 install; \
357 else \
358 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
359 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
360 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
361 fi
362 mostlyclean-generic:
363
364 clean-generic:
365
366 distclean-generic:
367 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
368 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
369
370 maintainer-clean-generic:
371 @echo "This command is intended for maintainers to use"
372 @echo "it deletes files that may require special tools to rebuild."
373 clean: clean-am
374
375 clean-am: clean-generic mostlyclean-am
376
377 distclean: distclean-am
378 -rm -f Makefile
379 distclean-am: clean-am distclean-generic
380
381 dvi: dvi-am
382
383 dvi-am:
384
385 html: html-am
386
387 html-am:
388
389 info: info-am
390
391 info-am:
392
393 install-data-am:
394
395 install-dvi: install-dvi-am
396
397 install-dvi-am:
398
399 install-exec-am:
400
401 install-html: install-html-am
402
403 install-html-am:
404
405 install-info: install-info-am
406
407 install-info-am:
408
409 install-man:
410
411 install-pdf: install-pdf-am
412
413 install-pdf-am:
414
415 install-ps: install-ps-am
416
417 install-ps-am:
418
419 installcheck-am:
420
421 maintainer-clean: maintainer-clean-am
422 -rm -f Makefile
423 maintainer-clean-am: distclean-am maintainer-clean-generic
424
425 mostlyclean: mostlyclean-am
426
427 mostlyclean-am: mostlyclean-generic
428
429 pdf: pdf-am
430
431 pdf-am:
432
433 ps: ps-am
434
435 ps-am:
436
437 uninstall-am:
438
439 .MAKE: install-am install-strip
440
441 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
442 ctags-am distclean distclean-generic distdir dvi dvi-am html \
443 html-am info info-am install install-am install-data \
444 install-data-am install-dvi install-dvi-am install-exec \
445 install-exec-am install-html install-html-am install-info \
446 install-info-am install-man install-pdf install-pdf-am \
447 install-ps install-ps-am install-strip installcheck \
448 installcheck-am installdirs maintainer-clean \
449 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
450 pdf-am ps ps-am tags-am uninstall uninstall-am
451
452
453 # Tell versions [3.59,3.63) of GNU make to not export all variables.
454 # Otherwise a system limit (for SysV at least) may be exceeded.
455 .NOEXPORT:
+0
-816
contrib/pccts/support/set/set.c less more
0 /* set.c
1
2 The following is a general-purpose set library originally developed
3 by Hank Dietz and enhanced by Terence Parr to allow dynamic sets.
4
5 Sets are now structs containing the #words in the set and
6 a pointer to the actual set words.
7
8 Generally, sets need not be explicitly allocated. They are
9 created/extended/shrunk when appropriate (e.g. in set_of()).
10 HOWEVER, sets need to be destroyed (free()ed) when they go out of scope
11 or are otherwise no longer needed. A routine is provided to
12 free a set.
13
14 Sets can be explicitly created with set_new(s, max_elem).
15
16 Sets can be declared to have minimum size to reduce realloc traffic.
17 Default minimum size = 1.
18
19 Sets can be explicitly initialized to have no elements (set.n == 0)
20 by using the 'empty' initializer:
21
22 Examples:
23 set a = empty; -- set_deg(a) == 0
24
25 return( empty );
26
27 Example set creation and destruction:
28
29 set
30 set_of2(e,g)
31 unsigned e,g;
32 {
33 set a,b,c;
34
35 b = set_of(e); -- Creates space for b and sticks in e
36 set_new(c, g); -- set_new(); set_orel() ==> set_of()
37 set_orel(g, &c);
38 a = set_or(b, c);
39 .
40 .
41 .
42 set_free(b);
43 set_free(c);
44 return( a );
45 }
46
47 1987 by Hank Dietz
48
49 Modified by:
50 Terence Parr
51 Purdue University
52 October 1989
53
54 Made it smell less bad to C++ 7/31/93 -- TJP
55 */
56
57 #include <stdio.h>
58 #include "pcctscfg.h"
59 #ifdef __STDC__
60 #include <stdlib.h>
61 #else
62 #include <malloc.h>
63 #endif
64 #include <string.h>
65
66 #include "set.h"
67
68 #define MIN(i,j) ( (i) > (j) ? (j) : (i))
69 #define MAX(i,j) ( (i) < (j) ? (j) : (i))
70
71 /* elems can be a maximum of 32 bits */
72 static unsigned bitmask[] = {
73 0x00000001, 0x00000002, 0x00000004, 0x00000008,
74 0x00000010, 0x00000020, 0x00000040, 0x00000080,
75 0x00000100, 0x00000200, 0x00000400, 0x00000800,
76 0x00001000, 0x00002000, 0x00004000, 0x00008000,
77 #if !defined(PC) || defined(PC32)
78 0x00010000, 0x00020000, 0x00040000, 0x00080000,
79 0x00100000, 0x00200000, 0x00400000, 0x00800000,
80 0x01000000, 0x02000000, 0x04000000, 0x08000000,
81 0x10000000, 0x20000000, 0x40000000, 0x80000000
82 #endif
83 };
84
85 set empty = set_init;
86 static unsigned min=1;
87
88 #define StrSize 200
89
90 #ifdef MEMCHK
91 #define CHK(a) \
92 if ( a.setword != NULL ) \
93 if ( !valid(a.setword) ) \
94 {fprintf(stderr, "%s(%d): invalid set\n",__FILE__,__LINE__); exit(-1);}
95 #else
96 #define CHK(a)
97 #endif
98
99 /*
100 * Set the minimum size (in words) of a set to reduce realloc calls
101 */
102 void
103 #ifdef __USE_PROTOS
104 set_size( unsigned n )
105 #else
106 set_size( n )
107 unsigned n;
108 #endif
109 {
110 min = n;
111 }
112
113 unsigned int
114 #ifdef __USE_PROTOS
115 set_deg( set a )
116 #else
117 set_deg( a )
118 set a;
119 #endif
120 {
121 /* Fast compute degree of a set... the number
122 of elements present in the set. Assumes
123 that all word bits are used in the set
124 and that SETSIZE(a) is a multiple of WORDSIZE.
125 */
126 register unsigned *p = &(a.setword[0]);
127 register unsigned *endp = NULL; /* MR27 Avoid false memory check report */
128 register unsigned degree = 0;
129
130 CHK(a);
131 if ( a.n == 0 ) return(0);
132 endp = &(a.setword[a.n]);
133 while ( p < endp )
134 {
135 register unsigned t = *p;
136 register unsigned *b = &(bitmask[0]);
137 do {
138 if (t & *b) ++degree;
139 } while (++b < &(bitmask[WORDSIZE]));
140 p++;
141 }
142
143 return(degree);
144 }
145
146 set
147 #ifdef __USE_PROTOS
148 set_or( set b, set c )
149 #else
150 set_or( b, c )
151 set b;
152 set c;
153 #endif
154 {
155 /* Fast set union operation */
156 /* resultant set size is max(b, c); */
157 set *big;
158 set t;
159 unsigned int m,n;
160 register unsigned *r, *p, *q, *endp;
161
162 CHK(b); CHK(c);
163 t = empty;
164 if (b.n > c.n) {big= &b; m=b.n; n=c.n;} else {big= &c; m=c.n; n=b.n;}
165 set_ext(&t, m);
166 r = t.setword;
167
168 /* Or b,c until max of smaller set */
169 q = c.setword;
170 p = b.setword;
171 endp = &(b.setword[n]);
172 while ( p < endp ) *r++ = *p++ | *q++;
173
174 /* Copy rest of bigger set into result */
175 p = &(big->setword[n]);
176 endp = &(big->setword[m]);
177 while ( p < endp ) *r++ = *p++;
178
179 return(t);
180 }
181
182 set
183 #ifdef __USE_PROTOS
184 set_and( set b, set c )
185 #else
186 set_and( b, c )
187 set b;
188 set c;
189 #endif
190 {
191 /* Fast set intersection operation */
192 /* resultant set size is min(b, c); */
193 set t;
194 unsigned int n;
195 register unsigned *r, *p, *q, *endp;
196
197 CHK(b); CHK(c);
198 t = empty;
199 n = (b.n > c.n) ? c.n : b.n;
200 if ( n == 0 ) return t; /* TJP 4-27-92 fixed for empty set */
201 set_ext(&t, n);
202 r = t.setword;
203
204 /* & b,c until max of smaller set */
205 q = c.setword;
206 p = b.setword;
207 endp = &(b.setword[n]);
208 while ( p < endp ) *r++ = *p++ & *q++;
209
210 return(t);
211 }
212
213 set
214 #ifdef __USE_PROTOS
215 set_dif( set b, set c )
216 #else
217 set_dif( b, c )
218 set b;
219 set c;
220 #endif
221 {
222 /* Fast set difference operation b - c */
223 /* resultant set size is size(b) */
224 set t;
225 unsigned int n;
226 register unsigned *r, *p, *q, *endp;
227
228 CHK(b); CHK(c);
229 t = empty;
230 n = (b.n <= c.n) ? b.n : c.n ;
231 if ( b.n == 0 ) return t; /* TJP 4-27-92 fixed for empty set */
232 /* WEC 12-1-92 fixed for c.n = 0 */
233 set_ext(&t, b.n);
234 r = t.setword;
235
236 /* Dif b,c until smaller set size */
237 q = c.setword;
238 p = b.setword;
239 endp = &(b.setword[n]);
240 while ( p < endp ) *r++ = *p++ & (~ *q++);
241
242 /* Copy rest of b into result if size(b) > c */
243 if ( b.n > n )
244 {
245 p = &(b.setword[n]);
246 endp = &(b.setword[b.n]);
247 while ( p < endp ) *r++ = *p++;
248 }
249
250 return(t);
251 }
252
253 set
254 #ifdef __USE_PROTOS
255 set_of( unsigned b )
256 #else
257 set_of( b )
258 unsigned b;
259 #endif
260 {
261 /* Fast singleton set constructor operation */
262 static set a;
263
264 if ( b == nil ) return( empty );
265 set_new(a, b);
266 a.setword[DIVWORD(b)] = bitmask[MODWORD(b)];
267
268 return(a);
269 }
270
271 /*
272 * Extend (or shrink) the set passed in to have n words.
273 *
274 * if n is smaller than the minimum, boost n to have the minimum.
275 * if the new set size is the same as the old one, do nothing.
276 *
277 * TJP 4-27-92 Fixed so won't try to alloc 0 bytes
278 */
279 void
280 #ifdef __USE_PROTOS
281 set_ext( set *a, unsigned int n )
282 #else
283 set_ext( a, n )
284 set *a;
285 unsigned int n;
286 #endif
287 {
288 register unsigned *p;
289 register unsigned *endp;
290 unsigned int size;
291
292 CHK((*a));
293 if ( a->n == 0 )
294 {
295 if ( n == 0 ) return;
296 if (a->setword != NULL) {
297 free (a->setword); /* MR20 */
298 }
299 a->setword = (unsigned *) calloc(n, BytesPerWord);
300 if ( a->setword == NULL )
301 {
302 fprintf(stderr, "set_ext(%d words): cannot allocate set\n", n);
303 exit(-1);
304 }
305 a->n = n;
306 return;
307 }
308 if ( n < min ) n = min;
309 if ( a->n == n || n == 0 ) return;
310 size = a->n;
311 a->n = n;
312 a->setword = (unsigned *) realloc( (char *)a->setword, (n*BytesPerWord) );
313 if ( a->setword == NULL )
314 {
315 fprintf(stderr, "set_ext(%d words): cannot allocate set\n", n);
316 exit(-1);
317 }
318
319 p = &(a->setword[size]); /* clear from old size to new size */
320 endp = &(a->setword[a->n]);
321 do {
322 *p++ = 0;
323 } while ( p < endp );
324 }
325
326 set
327 #ifdef __USE_PROTOS
328 set_not( set a )
329 #else
330 set_not( a )
331 set a;
332 #endif
333 {
334 /* Fast not of set a (assumes all bits used) */
335 /* size of resultant set is size(a) */
336 /* ~empty = empty cause we don't know how bit to make set */
337 set t;
338 register unsigned *r;
339 register unsigned *p = a.setword;
340 register unsigned *endp = &(a.setword[a.n]);
341
342 CHK(a);
343 t = empty;
344 if ( a.n == 0 ) return( empty );
345 set_ext(&t, a.n);
346 r = t.setword;
347
348 do {
349 *r++ = (~ *p++);
350 } while ( p < endp );
351
352 return(t);
353 }
354
355 int
356 #ifdef __USE_PROTOS
357 set_equ( set a, set b )
358 #else
359 set_equ( a, b )
360 set a;
361 set b;
362 #endif
363 {
364 /* 8-Nov-97 Make it work with sets of different sizes */
365 /* Easy to understand, too. Probably faster. */
366 /* Check for a equal to b */
367
368 unsigned int count; /* MR11 */
369 unsigned int i; /* MR11 */
370
371 CHK(a); CHK(b);
372
373 count=MIN(a.n,b.n);
374 if (count == 0) return 1;
375 for (i=0; i < count; i++) {
376 if (a.setword[i] != b.setword[i]) return 0;
377 };
378 if (a.n < b.n) {
379 for (i=count; i < b.n; i++) {
380 if (b.setword[i] != 0) return 0;
381 }
382 return 1;
383 } else if (a.n > b.n) {
384 for (i=count; i < a.n; i++) {
385 if (a.setword[i] != 0) return 0;
386 }
387 return 1;
388 } else {
389 return 1;
390 };
391 }
392
393 int
394 #ifdef __USE_PROTOS
395 set_sub( set a, set b )
396 #else
397 set_sub( a, b )
398 set a;
399 set b;
400 #endif
401 {
402
403 /* 8-Nov-97 Make it work with sets of different sizes */
404 /* Easy to understand, too. Probably faster. */
405 /* Check for a is a PROPER subset of b */
406
407 unsigned int count;
408 unsigned int i;
409
410 CHK(a); CHK(b);
411
412 if (a.n == 0) return 1;
413 count=MIN(a.n,b.n);
414 for (i=0; i < count; i++) {
415 if (a.setword[i] & ~b.setword[i]) return 0;
416 };
417 if (a.n <= b.n) {
418 return 1;
419 } else {
420 for (i=count; i<a.n ; i++) {
421 if (a.setword[i]) return 0;
422 };
423 };
424 return 1;
425 }
426
427 unsigned
428 #ifdef __USE_PROTOS
429 set_int( set b )
430 #else
431 set_int( b )
432 set b;
433 #endif
434 {
435 /* Fast pick any element of the set b */
436 register unsigned *p = b.setword;
437 register unsigned *endp = &(b.setword[b.n]);
438
439 CHK(b);
440 if ( b.n == 0 ) return( nil );
441
442 do {
443 if (*p) {
444 /* Found a non-empty word of the set */
445 register unsigned i = ((p - b.setword) << LogWordSize);
446 register unsigned t = *p;
447 p = &(bitmask[0]);
448 while (!(*p & t)) {
449 ++i; ++p;
450 }
451 return(i);
452 }
453 } while (++p < endp);
454
455 /* Empty -- only element it contains is nil */
456 return(nil);
457 }
458
459 int
460 #ifdef __USE_PROTOS
461 set_el( unsigned b, set a )
462 #else
463 set_el( b, a )
464 unsigned b;
465 set a;
466 #endif
467 {
468 CHK(a);
469 /* nil is an element of every set */
470 if (b == nil) return(1);
471 if ( a.n == 0 || NumWords(b) > a.n ) return(0);
472
473 /* Otherwise, we have to check */
474 return( a.setword[DIVWORD(b)] & bitmask[MODWORD(b)] );
475 }
476
477 int
478 #ifdef __USE_PROTOS
479 set_nil( set a )
480 #else
481 set_nil( a )
482 set a;
483 #endif
484 {
485 /* Fast check for nil set */
486 register unsigned *p = a.setword;
487 register unsigned *endp;
488
489 CHK(a);
490 if ( a.n == 0 ) return(1);
491 endp = &(a.setword[a.n]);
492
493 /* The set is not empty if any word used to store
494 the set is non-zero. This means one must be a
495 bit careful about doing things like negation.
496 */
497 do {
498 if (*p) return(0);
499 } while (++p < endp);
500
501 return(1);
502 }
503
504 char *
505 #ifdef __USE_PROTOS
506 set_str( set a )
507 #else
508 set_str( a )
509 set a;
510 #endif
511 {
512 /* Fast convert set a into ASCII char string...
513 assumes that all word bits are used in the set
514 and that SETSIZE is a multiple of WORDSIZE.
515 Trailing 0 bits are removed from the string.
516 if no bits are on or set is empty, "" is returned.
517 */
518 register unsigned *p = a.setword;
519 register unsigned *endp = &(a.setword[a.n]);
520 static char str_tmp[StrSize+1];
521 register char *q = &(str_tmp[0]);
522
523 CHK(a);
524 if ( a.n==0 ) {*q=0; return( &(str_tmp[0]) );}
525 do {
526 register unsigned t = *p;
527 register unsigned *b = &(bitmask[0]);
528 do {
529 *(q++) = (char) ((t & *b) ? '1' : '0');
530 } while (++b < &(bitmask[WORDSIZE]));
531 } while (++p < endp);
532
533 /* Trim trailing 0s & NULL terminate the string */
534 while ((q > &(str_tmp[0])) && (*(q-1) != '1')) --q;
535 *q = 0;
536
537 return(&(str_tmp[0]));
538 }
539
540 set
541 #ifdef __USE_PROTOS
542 set_val( register char *s )
543 #else
544 set_val( s )
545 register char *s;
546 #endif
547 {
548 /* Fast convert set ASCII char string into a set.
549 If the string ends early, the remaining set bits
550 are all made zero.
551 The resulting set size is just big enough to hold all elements.
552 */
553 static set a;
554 register unsigned *p, *endp;
555
556 set_new(a, strlen(s));
557 p = a.setword;
558 endp = &(a.setword[a.n]);
559 do {
560 register unsigned *b = &(bitmask[0]);
561 /* Start with a word with no bits on */
562 *p = 0;
563 do {
564 if (*s) {
565 if (*s == '1') {
566 /* Turn-on this bit */
567 *p |= *b;
568 }
569 ++s;
570 }
571 } while (++b < &(bitmask[WORDSIZE]));
572 } while (++p < endp);
573
574 return(a);
575 }
576
577 /*
578 * Or element e into set a. a can be empty.
579 */
580 void
581 #ifdef __USE_PROTOS
582 set_orel( unsigned e, set *a )
583 #else
584 set_orel( e, a )
585 unsigned e;
586 set *a;
587 #endif
588 {
589 CHK((*a));
590 if ( e == nil ) return;
591 if ( NumWords(e) > a->n ) set_ext(a, NumWords(e));
592 a->setword[DIVWORD(e)] |= bitmask[MODWORD(e)];
593 }
594
595 /*
596 * Or set b into set a. a can be empty. does nothing if b empty.
597 */
598 void
599 #ifdef __USE_PROTOS
600 set_orin( set *a, set b )
601 #else
602 set_orin( a, b )
603 set *a;
604 set b;
605 #endif
606 {
607 /* Fast set union operation */
608 /* size(a) is max(a, b); */
609 unsigned int m;
610 register unsigned *p,
611 *q = b.setword,
612 *endq; /* MR20 */
613
614 CHK((*a)); CHK(b);
615 if ( b.n == 0 ) return;
616 endq = &(b.setword[b.n]); /* MR20 */
617 m = (a->n > b.n) ? a->n : b.n;
618 set_ext(a, m);
619 p = a->setword;
620 do {
621 *p++ |= *q++;
622 } while ( q < endq );
623 }
624
625 /*
626 * And set b into set a. a can be empty. does nothing if b empty.
627 */
628 void
629 #ifdef __USE_PROTOS
630 set_andin( set *a, set b )
631 #else
632 set_andin( a, b )
633 set *a;
634 set b;
635 #endif
636 {
637 /* Fast set intersection operation */
638 /* size(a) is max(a, b); */
639 unsigned int m;
640 register unsigned *p,
641 *q = b.setword,
642 *endq = &(b.setword[b.n]);
643
644 CHK((*a)); CHK(b);
645 if ( b.n == 0 ) return;
646 m = (a->n > b.n) ? a->n : b.n;
647 set_ext(a, m);
648 p = a->setword;
649 do {
650 *p++ &= *q++;
651 } while ( q < endq );
652 }
653
654 void
655 #ifdef __USE_PROTOS
656 set_rm( unsigned e, set a )
657 #else
658 set_rm( e, a )
659 unsigned e;
660 set a;
661 #endif
662 {
663 /* Does not effect size of set */
664 CHK(a);
665 if ( (e == nil) || (NumWords(e) > a.n) ) return;
666 a.setword[DIVWORD(e)] ^= (a.setword[DIVWORD(e)]&bitmask[MODWORD(e)]);
667 }
668
669 void
670 #ifdef __USE_PROTOS
671 set_clr( set a )
672 #else
673 set_clr( a )
674 set a;
675 #endif
676 {
677 /* Does not effect size of set */
678 register unsigned *p = a.setword;
679 register unsigned *endp;
680
681 CHK(a);
682 if ( a.n == 0 ) return;
683 endp = &(a.setword[a.n]);
684 do {
685 *p++ = 0;
686 } while ( p < endp );
687 }
688
689 set
690 #ifdef __USE_PROTOS
691 set_dup( set a )
692 #else
693 set_dup( a )
694 set a;
695 #endif
696 {
697 set b;
698 register unsigned *p,
699 *q = a.setword,
700 *endq; /* MR20 */
701
702 CHK(a);
703 b = empty;
704 if ( a.n == 0 ) return( empty );
705 endq = &(a.setword[a.n]); /* MR20 */
706 set_ext(&b, a.n);
707 p = b.setword;
708 do {
709 *p++ = *q++;
710 } while ( q < endq );
711
712 return(b);
713 }
714
715 /*
716 * Return a nil terminated list of unsigned ints that represents all
717 * "on" bits in the bit set.
718 *
719 * e.g. {011011} --> {1, 2, 4, 5, nil}
720 *
721 * _set_pdq and set_pdq are useful when an operation is required on each element
722 * of a set. Normally, the sequence is:
723 *
724 * while ( set_deg(a) > 0 ) {
725 * e = set_int(a);
726 * set_rm(e, a);
727 * ...process e...
728 * }
729 * Now,
730 *
731 * t = e = set_pdq(a);
732 * while ( *e != nil ) {
733 * ...process *e...
734 * e++;
735 * }
736 * free( t );
737 *
738 * We have saved many set calls and have not destroyed set a.
739 */
740 void
741 #ifdef __USE_PROTOS
742 _set_pdq( set a, register unsigned *q )
743 #else
744 _set_pdq( a, q )
745 set a;
746 register unsigned *q;
747 #endif
748 {
749 register unsigned *p = a.setword,
750 *endp = &(a.setword[a.n]);
751 register unsigned e=0;
752
753 CHK(a);
754 /* are there any space (possibility of elements)? */
755 if ( a.n == 0 ) return;
756 do {
757 register unsigned t = *p;
758 register unsigned *b = &(bitmask[0]);
759 do {
760 if ( t & *b ) *q++ = e;
761 ++e;
762 } while (++b < &(bitmask[WORDSIZE]));
763 } while (++p < endp);
764 *q = nil;
765 }
766
767 /*
768 * Same as _set_pdq except allocate memory. set_pdq is the natural function
769 * to use.
770 */
771 unsigned *
772 #ifdef __USE_PROTOS
773 set_pdq( set a )
774 #else
775 set_pdq( a )
776 set a;
777 #endif
778 {
779 unsigned *q;
780 int max_deg;
781
782 CHK(a);
783 max_deg = WORDSIZE*a.n;
784 /* assume a.n!=0 & no elements is rare, but still ok */
785 if ( a.n == 0 ) return(NULL);
786 q = (unsigned *) malloc((max_deg+1)*BytesPerWord);
787 if ( q == NULL ) return( NULL );
788 _set_pdq(a, q);
789 return( q );
790 }
791
792 /* a function that produces a hash number for the set
793 */
794 unsigned int
795 #ifdef __USE_PROTOS
796 set_hash( set a, register unsigned int mod )
797 #else
798 set_hash( a, mod )
799 set a;
800 register unsigned int mod;
801 #endif
802 {
803 /* Fast hash of set a (assumes all bits used) */
804 register unsigned *p = &(a.setword[0]);
805 register unsigned *endp = &(a.setword[a.n]);
806 register unsigned i = 0;
807
808 CHK(a);
809 while (p<endp){
810 i += (*p);
811 ++p;
812 }
813
814 return(i % mod);
815 }
+0
-121
contrib/pccts/support/set/set.h less more
0 #ifndef __GATE_SET_H
1 #define __GATE_SET_H
2
3 /* set.h
4
5 The following is a general-purpose set library originally developed
6 by Hank Dietz and enhanced by Terence Parr to allow dynamic sets.
7
8 Sets are now structs containing the #words in the set and
9 a pointer to the actual set words.
10
11 1987 by Hank Dietz
12
13 Modified by:
14 Terence Parr
15 Purdue University
16 October 1989
17
18 Added ANSI prototyping Dec. 1992 -- TJP
19 */
20
21 #include "pcctscfg.h"
22
23 #ifdef NOT_USED /* SEE config.h */
24 /* Define usable bits per unsigned int word */
25 #ifdef PC
26 #define WORDSIZE 16
27 #define LogWordSize 4
28 #else
29 #define WORDSIZE 32
30 #define LogWordSize 5
31 #endif
32 #define BytesPerWord sizeof(unsigned)
33 #endif
34
35 #define SETSIZE(a) ((a).n<<LogWordSize) /* Maximum items per set */
36 #define MODWORD(x) ((x) & (WORDSIZE-1)) /* x % WORDSIZE */
37 #define DIVWORD(x) ((x) >> LogWordSize) /* x / WORDSIZE */
38 #define nil (~((unsigned) 0)) /* An impossible set member all bits on (big!) */
39
40 typedef struct _set {
41 unsigned int n; /* Number of words in set */
42 unsigned *setword;
43 } set;
44
45 #define set_init {0, NULL}
46 #define set_null(a) ((a).setword==NULL)
47
48 #define NumBytes(x) (((x)>>3)+1) /* Num bytes to hold x */
49 #define NumWords(x) ((((unsigned)(x))>>LogWordSize)+1) /* Num words to hold x */
50
51
52 /* M a c r o s */
53
54 /* make arg1 a set big enough to hold max elem # of arg2 */
55 #define set_new(a,_max) \
56 if (((a).setword=(unsigned *)calloc(NumWords(_max),BytesPerWord))==NULL) \
57 fprintf(stderr, "set_new: Cannot allocate set with max of %d\n", (int)(_max)); \
58 (a).n = NumWords(_max);
59
60 #define set_free(a) \
61 {if ( (a).setword != NULL ) free((char *)((a).setword)); \
62 (a) = empty;}
63
64 #ifdef __USE_PROTOS
65 extern void set_size( unsigned );
66 extern unsigned int set_deg( set );
67 extern set set_or( set, set );
68 extern set set_and( set, set );
69 extern set set_dif( set, set );
70 extern set set_of( unsigned );
71 extern void set_ext( set *, unsigned int );
72 extern set set_not( set );
73 extern int set_equ( set, set );
74 extern int set_sub( set, set );
75 extern unsigned set_int( set );
76 extern int set_el( unsigned, set );
77 extern int set_nil( set );
78 extern char * set_str( set );
79 extern set set_val( register char * );
80 extern void set_orel( unsigned, set * );
81 extern void set_orin( set *, set );
82 extern void set_andin( set *, set );
83 extern void set_rm( unsigned, set );
84 extern void set_clr( set );
85 extern set set_dup( set );
86 extern void set_PDQ( set, register unsigned * );
87 extern unsigned *set_pdq( set );
88 extern void _set_pdq( set a, register unsigned *q );
89 extern unsigned int set_hash( set, register unsigned int );
90 #else
91 extern void set_size();
92 extern unsigned int set_deg();
93 extern set set_or();
94 extern set set_and();
95 extern set set_dif();
96 extern set set_of();
97 extern void set_ext();
98 extern set set_not();
99 extern int set_equ();
100 extern int set_sub();
101 extern unsigned set_int();
102 extern int set_el();
103 extern int set_nil();
104 extern char * set_str();
105 extern set set_val();
106 extern void set_orel();
107 extern void set_orin();
108 extern void set_andin();
109 extern void set_rm();
110 extern void set_clr();
111 extern set set_dup();
112 extern void set_PDQ();
113 extern unsigned *set_pdq();
114 extern void _set_pdq();
115 extern unsigned int set_hash();
116 #endif
117
118 extern set empty;
119
120 #endif
+0
-5
contrib/pccts/support/sym/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 EXTRA_DIST= sym.c template.h
4
+0
-456
contrib/pccts/support/sym/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/support/sym
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 am__can_run_installinfo = \
102 case $$AM_UPDATE_INFO_DIR in \
103 n|no|NO) false;; \
104 *) (install-info --version) >/dev/null 2>&1;; \
105 esac
106 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
107 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
108 ACLOCAL = @ACLOCAL@
109 AET2_CFLAGS = @AET2_CFLAGS@
110 AET2_LDADD = @AET2_LDADD@
111 ALLOCA = @ALLOCA@
112 AMTAR = @AMTAR@
113 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
114 AUTOCONF = @AUTOCONF@
115 AUTOHEADER = @AUTOHEADER@
116 AUTOMAKE = @AUTOMAKE@
117 AWK = @AWK@
118 CC = @CC@
119 CCDEPMODE = @CCDEPMODE@
120 CFLAGS = @CFLAGS@
121 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
122 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
123 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
124 CPP = @CPP@
125 CPPFLAGS = @CPPFLAGS@
126 CXX = @CXX@
127 CXXDEPMODE = @CXXDEPMODE@
128 CXXFLAGS = @CXXFLAGS@
129 CYGPATH_W = @CYGPATH_W@
130 DEFS = @DEFS@
131 DEPDIR = @DEPDIR@
132 ECHO_C = @ECHO_C@
133 ECHO_N = @ECHO_N@
134 ECHO_T = @ECHO_T@
135 EGREP = @EGREP@
136 EXEEXT = @EXEEXT@
137 EXTDEBUG = @EXTDEBUG@
138 EXTDEBUG2 = @EXTDEBUG2@
139 EXTDEBUG3 = @EXTDEBUG3@
140 EXTDEBUG4 = @EXTDEBUG4@
141 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
142 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
143 FSDB_CFLAGS = @FSDB_CFLAGS@
144 FSDB_LDADD = @FSDB_LDADD@
145 GCONF_CFLAGS = @GCONF_CFLAGS@
146 GCONF_LIBS = @GCONF_LIBS@
147 GEDITTEST = @GEDITTEST@
148 GEDIT_CFLAGS = @GEDIT_CFLAGS@
149 GIO_CFLAGS = @GIO_CFLAGS@
150 GIO_LIBS = @GIO_LIBS@
151 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
152 GPERF = @GPERF@
153 GREP = @GREP@
154 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
155 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
156 GTK_CFLAGS = @GTK_CFLAGS@
157 GTK_CONFIG = @GTK_CONFIG@
158 GTK_LIBS = @GTK_LIBS@
159 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
160 GTK_MAC_LIBS = @GTK_MAC_LIBS@
161 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
162 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
163 INSTALL = @INSTALL@
164 INSTALL_DATA = @INSTALL_DATA@
165 INSTALL_PROGRAM = @INSTALL_PROGRAM@
166 INSTALL_SCRIPT = @INSTALL_SCRIPT@
167 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
168 LDFLAGS = @LDFLAGS@
169 LEX = @LEX@
170 LEXLIB = @LEXLIB@
171 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
172 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
173 LIBBZ2_DIR = @LIBBZ2_DIR@
174 LIBBZ2_LDADD = @LIBBZ2_LDADD@
175 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
176 LIBJUDY_LDADD = @LIBJUDY_LDADD@
177 LIBOBJS = @LIBOBJS@
178 LIBS = @LIBS@
179 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
180 LIBXZ_LDADD = @LIBXZ_LDADD@
181 LIBZ_CFLAGS = @LIBZ_CFLAGS@
182 LIBZ_DIR = @LIBZ_DIR@
183 LIBZ_LDADD = @LIBZ_LDADD@
184 LTLIBOBJS = @LTLIBOBJS@
185 MAINT = @MAINT@
186 MAKEINFO = @MAKEINFO@
187 MINGW_LDADD = @MINGW_LDADD@
188 MKDIR_P = @MKDIR_P@
189 OBJEXT = @OBJEXT@
190 PACKAGE = @PACKAGE@
191 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
192 PACKAGE_NAME = @PACKAGE_NAME@
193 PACKAGE_STRING = @PACKAGE_STRING@
194 PACKAGE_TARNAME = @PACKAGE_TARNAME@
195 PACKAGE_URL = @PACKAGE_URL@
196 PACKAGE_VERSION = @PACKAGE_VERSION@
197 PATH_SEPARATOR = @PATH_SEPARATOR@
198 PKG_CONFIG = @PKG_CONFIG@
199 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
200 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
201 POW_LIB = @POW_LIB@
202 RANLIB = @RANLIB@
203 RPC_CFLAGS = @RPC_CFLAGS@
204 RPC_LDADD = @RPC_LDADD@
205 SET_MAKE = @SET_MAKE@
206 SHELL = @SHELL@
207 STRIP = @STRIP@
208 STRUCT_PACK = @STRUCT_PACK@
209 TCL_DEFADD = @TCL_DEFADD@
210 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
211 TCL_LDADD = @TCL_LDADD@
212 TCL_LIB_SPEC = @TCL_LIB_SPEC@
213 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
214 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
215 TIRPC_CFLAGS = @TIRPC_CFLAGS@
216 TIRPC_LIBS = @TIRPC_LIBS@
217 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
218 TK_LDADD = @TK_LDADD@
219 TK_LIB_SPEC = @TK_LIB_SPEC@
220 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
221 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
222 VERSION = @VERSION@
223 XDGDATADIR = @XDGDATADIR@
224 abs_builddir = @abs_builddir@
225 abs_srcdir = @abs_srcdir@
226 abs_top_builddir = @abs_top_builddir@
227 abs_top_srcdir = @abs_top_srcdir@
228 ac_ct_CC = @ac_ct_CC@
229 ac_ct_CXX = @ac_ct_CXX@
230 am__include = @am__include@
231 am__leading_dot = @am__leading_dot@
232 am__quote = @am__quote@
233 am__tar = @am__tar@
234 am__untar = @am__untar@
235 bindir = @bindir@
236 build_alias = @build_alias@
237 builddir = @builddir@
238 datadir = @datadir@
239 datarootdir = @datarootdir@
240 docdir = @docdir@
241 dvidir = @dvidir@
242 exec_prefix = @exec_prefix@
243 gsettingsschemadir = @gsettingsschemadir@
244 host_alias = @host_alias@
245 htmldir = @htmldir@
246 includedir = @includedir@
247 infodir = @infodir@
248 install_sh = @install_sh@
249 libdir = @libdir@
250 libexecdir = @libexecdir@
251 localedir = @localedir@
252 localstatedir = @localstatedir@
253 mandir = @mandir@
254 mkdir_p = @mkdir_p@
255 oldincludedir = @oldincludedir@
256 pdfdir = @pdfdir@
257 prefix = @prefix@
258 program_transform_name = @program_transform_name@
259 psdir = @psdir@
260 sbindir = @sbindir@
261 sharedstatedir = @sharedstatedir@
262 srcdir = @srcdir@
263 sysconfdir = @sysconfdir@
264 target_alias = @target_alias@
265 top_build_prefix = @top_build_prefix@
266 top_builddir = @top_builddir@
267 top_srcdir = @top_srcdir@
268 EXTRA_DIST = sym.c template.h
269 all: all-am
270
271 .SUFFIXES:
272 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
273 @for dep in $?; do \
274 case '$(am__configure_deps)' in \
275 *$$dep*) \
276 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
277 && { if test -f $@; then exit 0; else break; fi; }; \
278 exit 1;; \
279 esac; \
280 done; \
281 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/support/sym/Makefile'; \
282 $(am__cd) $(top_srcdir) && \
283 $(AUTOMAKE) --foreign contrib/pccts/support/sym/Makefile
284 .PRECIOUS: Makefile
285 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
286 @case '$?' in \
287 *config.status*) \
288 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
289 *) \
290 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
291 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
292 esac;
293
294 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
295 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
296
297 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
298 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
299 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
300 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
301 $(am__aclocal_m4_deps):
302 tags TAGS:
303
304 ctags CTAGS:
305
306 cscope cscopelist:
307
308
309 distdir: $(DISTFILES)
310 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
311 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
312 list='$(DISTFILES)'; \
313 dist_files=`for file in $$list; do echo $$file; done | \
314 sed -e "s|^$$srcdirstrip/||;t" \
315 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
316 case $$dist_files in \
317 */*) $(MKDIR_P) `echo "$$dist_files" | \
318 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
319 sort -u` ;; \
320 esac; \
321 for file in $$dist_files; do \
322 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
323 if test -d $$d/$$file; then \
324 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
325 if test -d "$(distdir)/$$file"; then \
326 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
327 fi; \
328 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
329 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
330 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
331 fi; \
332 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
333 else \
334 test -f "$(distdir)/$$file" \
335 || cp -p $$d/$$file "$(distdir)/$$file" \
336 || exit 1; \
337 fi; \
338 done
339 check-am: all-am
340 check: check-am
341 all-am: Makefile
342 installdirs:
343 install: install-am
344 install-exec: install-exec-am
345 install-data: install-data-am
346 uninstall: uninstall-am
347
348 install-am: all-am
349 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
350
351 installcheck: installcheck-am
352 install-strip:
353 if test -z '$(STRIP)'; then \
354 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
355 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
356 install; \
357 else \
358 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
359 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
360 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
361 fi
362 mostlyclean-generic:
363
364 clean-generic:
365
366 distclean-generic:
367 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
368 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
369
370 maintainer-clean-generic:
371 @echo "This command is intended for maintainers to use"
372 @echo "it deletes files that may require special tools to rebuild."
373 clean: clean-am
374
375 clean-am: clean-generic mostlyclean-am
376
377 distclean: distclean-am
378 -rm -f Makefile
379 distclean-am: clean-am distclean-generic
380
381 dvi: dvi-am
382
383 dvi-am:
384
385 html: html-am
386
387 html-am:
388
389 info: info-am
390
391 info-am:
392
393 install-data-am:
394
395 install-dvi: install-dvi-am
396
397 install-dvi-am:
398
399 install-exec-am:
400
401 install-html: install-html-am
402
403 install-html-am:
404
405 install-info: install-info-am
406
407 install-info-am:
408
409 install-man:
410
411 install-pdf: install-pdf-am
412
413 install-pdf-am:
414
415 install-ps: install-ps-am
416
417 install-ps-am:
418
419 installcheck-am:
420
421 maintainer-clean: maintainer-clean-am
422 -rm -f Makefile
423 maintainer-clean-am: distclean-am maintainer-clean-generic
424
425 mostlyclean: mostlyclean-am
426
427 mostlyclean-am: mostlyclean-generic
428
429 pdf: pdf-am
430
431 pdf-am:
432
433 ps: ps-am
434
435 ps-am:
436
437 uninstall-am:
438
439 .MAKE: install-am install-strip
440
441 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
442 ctags-am distclean distclean-generic distdir dvi dvi-am html \
443 html-am info info-am install install-am install-data \
444 install-data-am install-dvi install-dvi-am install-exec \
445 install-exec-am install-html install-html-am install-info \
446 install-info-am install-man install-pdf install-pdf-am \
447 install-ps install-ps-am install-strip installcheck \
448 installcheck-am installdirs maintainer-clean \
449 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
450 pdf-am ps ps-am tags-am uninstall uninstall-am
451
452
453 # Tell versions [3.59,3.63) of GNU make to not export all variables.
454 # Otherwise a system limit (for SysV at least) may be exceeded.
455 .NOEXPORT:
+0
-402
contrib/pccts/support/sym/sym.c less more
0 /*
1 * Simple symbol table manager using coalesced chaining to resolve collisions
2 *
3 * Doubly-linked lists are used for fast removal of entries.
4 *
5 * 'sym.h' must have a definition for typedef "Sym". Sym must include at
6 * minimum the following fields:
7 *
8 * ...
9 * char *symbol;
10 * struct ... *next, *prev, **head, *scope;
11 * unsigned int hash;
12 * ...
13 *
14 * 'template.h' can be used as a template to create a 'sym.h'.
15 *
16 * 'head' is &(table[hash(itself)]).
17 * The hash table is not resizable at run-time.
18 * The scope field is used to link all symbols of a current scope together.
19 * Scope() sets the current scope (linked list) to add symbols to.
20 * Any number of scopes can be handled. The user passes the address of
21 * a pointer to a symbol table
22 * entry (INITIALIZED TO NULL first time).
23 *
24 * Available Functions:
25 *
26 * zzs_init(s1,s2) -- Create hash table with size s1, string table size s2.
27 * zzs_done() -- Free hash and string table created with zzs_init().
28 * zzs_add(key,rec)-- Add 'rec' with key 'key' to the symbol table.
29 * zzs_newadd(key) -- create entry; add using 'key' to the symbol table.
30 * zzs_get(key) -- Return pointer to last record entered under 'key'
31 * Else return NULL
32 * zzs_del(p) -- Unlink the entry associated with p. This does
33 * NOT free 'p' and DOES NOT remove it from a scope
34 * list. If it was a part of your intermediate code
35 * tree or another structure. It will still be there.
36 * It is only removed from further consideration
37 * by the symbol table.
38 * zzs_keydel(s) -- Unlink the entry associated with key s.
39 * Calls zzs_del(p) to unlink.
40 * zzs_scope(sc) -- Specifies that everything added to the symbol
41 * table with zzs_add() is added to the list (scope)
42 * 'sc'. 'sc' is of 'Sym **sc' type and must be
43 * initialized to NULL before trying to add anything
44 * to it (passing it to zzs_scope()). Scopes can be
45 * switched at any time and merely links a set of
46 * symbol table entries. If a NULL pointer is
47 * passed, the current scope is returned.
48 * zzs_rmscope(sc) -- Remove (zzs_del()) all elements of scope 'sc'
49 * from the symbol table. The entries are NOT
50 * free()'d. A pointer to the first
51 * element in the "scope" is returned. The user
52 * can then manipulate the list as he/she chooses
53 * (such as freeing them all). NOTE that this
54 * function sets your scope pointer to NULL,
55 * but returns a pointer to the list for you to use.
56 * zzs_stat() -- Print out the symbol table and some relevant stats.
57 * zzs_new(key) -- Create a new record with calloc() of type Sym.
58 * Add 'key' to the string table and make the new
59 * records 'symbol' pointer point to it.
60 * zzs_strdup(s) -- Add s to the string table and return a pointer
61 * to it. Very fast allocation routine
62 * and does not require strlen() nor calloc().
63 *
64 * Example:
65 *
66 * #include <stdio.h>
67 * #include "sym.h"
68 *
69 * main()
70 * {
71 * Sym *scope1=NULL, *scope2=NULL, *a, *p;
72 *
73 * zzs_init(101, 100);
74 *
75 * a = zzs_new("Apple"); zzs_add(a->symbol, a); -- No scope
76 * zzs_scope( &scope1 ); -- enter scope 1
77 * a = zzs_new("Plum"); zzs_add(a->symbol, a);
78 * zzs_scope( &scope2 ); -- enter scope 2
79 * a = zzs_new("Truck"); zzs_add(a->symbol, a);
80 *
81 * p = zzs_get("Plum");
82 * if ( p == NULL ) fprintf(stderr, "Hmmm...Can't find 'Plum'\n");
83 *
84 * p = zzs_rmscope(&scope1)
85 * for (; p!=NULL; p=p->scope) {printf("Scope1: %s\n", p->symbol);}
86 * p = zzs_rmscope(&scope2)
87 * for (; p!=NULL; p=p->scope) {printf("Scope2: %s\n", p->symbol);}
88 * }
89 *
90 * Terence Parr
91 * Purdue University
92 * February 1990
93 *
94 * CHANGES
95 *
96 * Terence Parr
97 * May 1991
98 * Renamed functions to be consistent with ANTLR
99 * Made HASH macro
100 * Added zzs_keydel()
101 * Added zzs_newadd()
102 * Fixed up zzs_stat()
103 *
104 * July 1991
105 * Made symbol table entry save its hash code for fast comparison
106 * during searching etc...
107 */
108
109 #include <stdio.h>
110 #if defined(__STDC__) || defined(__USE_PROTOS)
111 #include <string.h>
112 #include <stdlib.h>
113 #else
114 #include <malloc.h>
115 #endif
116 #include "sym.h"
117
118 #define StrSame 0
119
120 static Sym **CurScope = NULL;
121 static unsigned size = 0;
122 static Sym **table=NULL;
123 static char *strings;
124 static char *strp;
125 static int strsize = 0;
126
127 #ifdef __USE_PROTOS
128 void zzs_init(int sz,int strs)
129 #else
130 void zzs_init(sz, strs)
131 int sz, strs;
132 #endif
133 {
134 if ( sz <= 0 || strs <= 0 ) return;
135 table = (Sym **) calloc(sz, sizeof(Sym *));
136 if ( table == NULL )
137 {
138 fprintf(stderr, "Cannot allocate table of size %d\n", sz);
139 exit(1);
140 }
141 strings = (char *) calloc(strs, sizeof(char));
142 if ( strings == NULL )
143 {
144 fprintf(stderr, "Cannot allocate string table of size %d\n", strs);
145 exit(1);
146 }
147 size = sz;
148 strsize = strs;
149 strp = strings;
150 }
151
152 #ifdef __USE_PROTOS
153 void zzs_done(void)
154 #else
155 void zzs_done()
156 #endif
157 {
158 if ( table != NULL ) free( table );
159 if ( strings != NULL ) free( strings );
160 }
161
162 #ifdef __USE_PROTOS
163 void zzs_add(char *key,Sym rec)
164 #else
165 void zzs_add(key, rec)
166 char *key;
167 register Sym *rec;
168 #endif
169 {
170 register unsigned int h=0;
171 register char *p=key;
172
173 HASH(p, h);
174 rec->hash = h; /* save hash code for fast comp later */
175 h %= size;
176
177 if ( CurScope != NULL ) {rec->scope = *CurScope; *CurScope = rec;}
178 rec->next = table[h]; /* Add to doubly-linked list */
179 rec->prev = NULL;
180 if ( rec->next != NULL ) (rec->next)->prev = rec;
181 table[h] = rec;
182 rec->head = &(table[h]);
183 }
184
185 #ifdef __USE_PROTOS
186 Sym * zzs_get(char *key)
187 #else
188 Sym * zzs_get(key)
189 char *key;
190 #endif
191 {
192 register unsigned int h=0;
193 register char *p=key;
194 register Sym *q;
195
196 HASH(p, h);
197
198 for (q = table[h%size]; q != NULL; q = q->next)
199 {
200 if ( q->hash == h ) /* do we even have a chance of matching? */
201 if ( strcmp(key, q->symbol) == StrSame ) return( q );
202 }
203 return( NULL );
204 }
205
206 /*
207 * Unlink p from the symbol table. Hopefully, it's actually in the
208 * symbol table.
209 *
210 * If p is not part of a bucket chain of the symbol table, bad things
211 * will happen.
212 *
213 * Will do nothing if all list pointers are NULL
214 */
215 #ifdef __USE_PROTOS
216 void zzs_del(Sym *p)
217 #else
218 void zzs_del(p)
219 register Sym *p;
220 #endif
221 {
222 if ( p == NULL ) {fprintf(stderr, "zzs_del(NULL)\n"); exit(1);}
223 if ( p->prev == NULL ) /* Head of list */
224 {
225 register Sym **t = p->head;
226
227 if ( t == NULL ) return; /* not part of symbol table */
228 (*t) = p->next;
229 if ( (*t) != NULL ) (*t)->prev = NULL;
230 }
231 else
232 {
233 (p->prev)->next = p->next;
234 if ( p->next != NULL ) (p->next)->prev = p->prev;
235 }
236 p->next = p->prev = NULL; /* not part of symbol table anymore */
237 p->head = NULL;
238 }
239
240 #ifdef __USE_PROTOS
241 void zzs_keydel(char *key)
242 #else
243 void zzs_keydel(key)
244 char *key;
245 #endif
246 {
247 Sym *p = zzs_get(key);
248
249 if ( p != NULL ) zzs_del( p );
250 }
251
252 /* S c o p e S t u f f */
253
254 /* Set current scope to 'scope'; return current scope if 'scope' == NULL */
255
256 #ifdef __USE_PROTOS
257 Sym ** zzs_scope(Sym **scope)
258 #else
259 Sym ** zzs_scope(scope)
260 Sym **scope;
261 #endif
262 {
263 if ( scope == NULL ) return( CurScope );
264 CurScope = scope;
265 return( scope );
266 }
267
268 /* Remove a scope described by 'scope'. Return pointer to 1st element in scope */
269
270 #ifdef __USE_PROTOS
271 Sym * zzs_rmscope(Sym **scope)
272 #else
273 Sym * zzs_rmscope(scope)
274 register Sym **scope;
275 #endif
276 {
277 register Sym *p;
278 Sym *start;
279
280 if ( scope == NULL ) return(NULL);
281 start = p = *scope;
282 for (; p != NULL; p=p->scope) { zzs_del( p ); }
283 *scope = NULL;
284 return( start );
285 }
286
287 #ifdef __USE_PROTOS
288 void zzs_stat(void)
289 #else
290 void zzs_stat()
291 #endif
292 {
293 static unsigned short count[20];
294 unsigned int i,n=0,low=0, hi=0;
295 register Sym **p;
296 float avg=0.0;
297
298 for (i=0; i<20; i++) count[i] = 0;
299 for (p=table; p<&(table[size]); p++)
300 {
301 register Sym *q = *p;
302 unsigned int len;
303
304 if ( q != NULL && low==0 ) low = p-table;
305 len = 0;
306 if ( q != NULL ) printf("[%d]", p-table);
307 while ( q != NULL )
308 {
309 len++;
310 n++;
311 printf(" %s", q->symbol);
312 q = q->next;
313 if ( q == NULL ) printf("\n");
314 }
315 if ( len>=20 ) printf("zzs_stat: count table too small\n");
316 else count[len]++;
317 if ( *p != NULL ) hi = p-table;
318 }
319
320 printf("Storing %d recs used %d hash positions out of %d\n",
321 n, size-count[0], size);
322 printf("%f %% utilization\n",
323 ((float)(size-count[0]))/((float)size));
324 for (i=0; i<20; i++)
325 {
326 if ( count[i] != 0 )
327 {
328 avg += (((float)(i*count[i]))/((float)n)) * i;
329 printf("Buckets of len %d == %d (%f %% of recs)\n",
330 i, count[i], 100.0*((float)(i*count[i]))/((float)n));
331 }
332 }
333 printf("Avg bucket length %f\n", avg);
334 printf("Range of hash function: %d..%d\n", low, hi);
335 }
336
337 /*
338 * Given a string, this function allocates and returns a pointer to a
339 * symbol table record whose "symbol" pointer is reset to a position
340 * in the string table.
341 */
342
343 #ifdef __USE_PROTOS
344 Sym * zzs_new(char *text)
345 #else
346 Sym * zzs_new(text)
347 char *text;
348 #endif
349 {
350 Sym *p;
351
352 if ( (p = (Sym *) calloc(1,sizeof(Sym))) == 0 )
353 {
354 fprintf(stderr,"Out of memory\n");
355 exit(1);
356 }
357 p->symbol = zzs_strdup(text);
358
359 return p;
360 }
361
362 /* create a new symbol table entry and add it to the symbol table */
363
364 #ifdef __USE_PROTOS
365 Sym * zzs_newadd(char *text)
366 #else
367 Sym * zzs_newadd(text)
368 char *text;
369 #endif
370 {
371 Sym *p = zzs_new(text);
372 if ( p != NULL ) zzs_add(text, p);
373 return p;
374 }
375
376 /* Add a string to the string table and return a pointer to it.
377 * Bump the pointer into the string table to next avail position.
378 */
379
380 #ifdef __USE_PROTOS
381 char * zzs_strdup(char *s)
382 #else
383 char * zzs_strdup(s)
384 register char *s;
385 #endif
386 {
387 register char *start=strp;
388
389 while ( *s != '\0' )
390 {
391 if ( strp >= &(strings[strsize-2]) )
392 {
393 fprintf(stderr, "sym: string table overflow (%d chars)\n", strsize);
394 exit(-1);
395 }
396 *strp++ = *s++;
397 }
398 *strp++ = '\0';
399
400 return( start );
401 }
+0
-41
contrib/pccts/support/sym/template.h less more
0 /* T e m p l a t e F o r S y m b o l T a b l e M a n a g e r */
1
2 /* define some hash function */
3 #ifndef HASH
4 #define HASH(p, h) while ( *p != '\0' ) h = (h<<1) + *p++;
5 #endif
6
7 /* minimum symbol table record */
8 typedef struct _sym {
9 char *symbol;
10 struct _sym *next, *prev, **head, *scope;
11 unsigned int hash;
12 } Sym, *SymPtr;
13
14 #ifdef __USE_PROTOS
15 void zzs_init(int, int);
16 void zzs_done(void);
17 void zzs_add(char *, Sym *);
18 Sym *zzs_get(char *);
19 void zzs_del(Sym *);
20 void zzs_keydel(char *);
21 Sym **zzs_scope(Sym **);
22 Sym *zzs_rmscope(Sym **);
23 void zzs_stat(void);
24 Sym *zzs_new(char *);
25 Sym *zzs_newadd(char *);
26 char *zzs_strdup(char *);
27 #else
28 void zzs_init();
29 void zzs_done();
30 void zzs_add();
31 Sym *zzs_get();
32 void zzs_del();
33 void zzs_keydel();
34 Sym **zzs_scope();
35 Sym *zzs_rmscope();
36 void zzs_stat();
37 Sym *zzs_new();
38 Sym *zzs_newadd();
39 char *zzs_strdup();
40 #endif
+0
-71
contrib/pccts/testcpp/1/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -class Expr -project t test.g
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = DLGLexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -CC
25 DFLAGS = -C2 -i -CC
26 GRM = test.g
27 SRC = test.cpp \
28 Expr.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
30 OBJ = test.o \
31 Expr.o \
32 AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o
33 ANTLR_SPAWN = test.cpp Expr.cpp \
34 Expr.h $(DLG_FILE) $(TOKENS)
35 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
36 #CCC=g++
37 CCC=CC
38
39 t : $(OBJ) $(SRC)
40 $(CCC) -o t $(CFLAGS) $(OBJ)
41
42 test.o : $(TOKENS) $(SCAN).h test.cpp
43 $(CCC) -c $(CFLAGS) -o test.o test.cpp
44
45 Expr.o : $(TOKENS) $(SCAN).h Expr.cpp Expr.h
46 $(CCC) -c $(CFLAGS) -o Expr.o Expr.cpp
47
48 $(SCAN).o : $(SCAN).cpp $(TOKENS)
49 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
50
51 $(ANTLR_SPAWN) : $(GRM)
52 $(ANTLR) $(AFLAGS) $(GRM)
53
54 $(DLG_SPAWN) : $(DLG_FILE)
55 $(DLG) $(DFLAGS) $(DLG_FILE)
56
57 AParser.o : $(ANTLR_H)/AParser.cpp
58 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
59
60 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
61 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
62
63 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
64 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
65
66 clean:
67 rm -f *.o core t
68
69 scrub:
70 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-97
contrib/pccts/testcpp/1/test.g less more
0 /* This is test.g which tests a simple DLG-based scanner.
1 * No garbage collection for tokens since our token can't
2 * handle ref counting.
3 */
4
5 /* ANTLR will assign token type numbers (by creating an enum which you
6 * get in tokens.h)
7 */
8
9 <<
10 /* user must define ANTLRToken */
11
12 typedef char ANTLRChar;
13
14 class ANTLRToken : public ANTLRAbstractToken {
15 protected:
16 ANTLRTokenType _type; // what's the token type of the token object
17 int _line; // track line info for errors
18
19 /* For our simple purposes, a token and a string is enough for
20 * our attribute
21 */
22 ANTLRChar _text[30];
23
24 public:
25 ANTLRToken(ANTLRTokenType t, ANTLRChar *s)
26 { setType(t); _line = 0; setText(s); }
27
28 /* Your derived class MUST have a blank constructor. */
29 ANTLRToken()
30 { setType((ANTLRTokenType)0); _line = 0; setText(""); }
31
32 // how to access the token type and line number stuff
33 ANTLRTokenType getType() const { return _type; }
34 void setType(ANTLRTokenType t) { _type = t; }
35 virtual int getLine() const { return _line; }
36 void setLine(int line) { _line = line; }
37
38 //
39 // warning - casting away const in ANTLRToken::getText() const
40 //
41
42 ANTLRChar *getText() const { return (ANTLRChar *) _text; }
43 void setText(const ANTLRChar *s) { strncpy(_text, s, 30); }
44
45 /* WARNING WARNING WARNING: you must return a stream of distinct tokens */
46 /* This function will disappear when I can use templates */
47
48 virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
49 ANTLRChar *txt,
50 int line)
51 {
52 ANTLRAbstractToken *t = new ANTLRToken(tt,txt);
53 t->setLine(line);
54 return t;
55 }
56 };
57
58 /* "DLGLexer" must match what you use on DLG command line (-cl);
59 * "DLGLexer" is the default.
60 */
61 #include "DLGLexer.h" /* include definition of DLGLexer.
62 * This cannot be generated automatically because
63 * ANTLR has no idea what you will call this file
64 * with the DLG command-line options.
65 */
66
67 int main()
68 {
69 DLGFileInput in(stdin); /* create input stream for DLG to get chars from */
70 DLGLexer scan(&in); /* create scanner reading from stdin */
71 ANTLRTokenBuffer pipe(&scan);/* make buffered pipe between lexer&parser */
72 ANTLRTokenPtr aToken=new ANTLRToken; // create a token to fill in for DLG
73 scan.setToken(mytoken(aToken));
74 Expr parser(&pipe); /* create parser of type Expr hooked to scanner */
75 parser.init(); /* init the parser; prime lookahead etc... */
76
77 parser.e(); /* start parsing at rule 'e' of that parser */
78 return 0;
79 }
80 >>
81
82 #token "[\ \t\n]+" <<skip();>>
83 #token Eof "@"
84
85 #tokclass My { IDENTIFIER NUMBER }
86
87 class Expr { /* Define a grammar class */
88
89 e : My My Eof
90 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
91 ;
92
93 }
94
95 #token IDENTIFIER "[a-z]+"
96 #token NUMBER "[0-9]+"
+0
-71
contrib/pccts/testcpp/10/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -class Expr -project t test.g
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = DLGLexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -CC
25 DFLAGS = -C2 -i -CC
26 GRM = test.g
27 SRC = test.cpp \
28 Expr.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
30 OBJ = test.o \
31 Expr.o \
32 AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o
33 ANTLR_SPAWN = test.cpp Expr.cpp \
34 Expr.h $(DLG_FILE) $(TOKENS)
35 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
36 #CCC=g++
37 CCC=CC
38
39 t : $(OBJ) $(SRC)
40 $(CCC) -o t $(CFLAGS) $(OBJ)
41
42 test.o : $(TOKENS) $(SCAN).h test.cpp
43 $(CCC) -c $(CFLAGS) -o test.o test.cpp
44
45 Expr.o : $(TOKENS) $(SCAN).h Expr.cpp Expr.h
46 $(CCC) -c $(CFLAGS) -o Expr.o Expr.cpp
47
48 $(SCAN).o : $(SCAN).cpp $(TOKENS)
49 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
50
51 $(ANTLR_SPAWN) : $(GRM)
52 $(ANTLR) $(AFLAGS) $(GRM)
53
54 $(DLG_SPAWN) : $(DLG_FILE)
55 $(DLG) $(DFLAGS) $(DLG_FILE)
56
57 AParser.o : $(ANTLR_H)/AParser.cpp
58 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
59
60 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
61 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
62
63 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
64 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
65
66 clean:
67 rm -f *.o core t
68
69 scrub:
70 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-84
contrib/pccts/testcpp/10/test.g less more
0 /* This tests a simple DLG-based scanner plus (...)? predicates */
1
2 <<
3 typedef ANTLRCommonToken ANTLRToken;
4 #include "DLGLexer.h"
5 #include "PBlackBox.h"
6
7 int main()
8 {
9 ParserBlackBox<DLGLexer, Expr, ANTLRToken> p(stdin);
10 p.parser()->begin();
11 return 0;
12 }
13
14 void doit(Expr *p)
15 {
16 printf("LT(1) is %s\n", ((ANTLRToken *)p->LT(1))->getText());
17 printf("LT(2) is %s\n", ((ANTLRToken *)p->LT(2))->getText());
18 printf("LT(3) is %s\n", ((ANTLRToken *)p->LT(3))->getText());
19 printf("LT(4) is %s\n", ((ANTLRToken *)p->LT(4))->getText());
20 printf("LT(5) is %s\n", ((ANTLRToken *)p->LT(5))->getText());
21 printf("LT(6) is %s\n", ((ANTLRToken *)p->LT(6))->getText());
22 printf("LT(7) is %s\n", ((ANTLRToken *)p->LT(7))->getText());
23 printf("LT(8) is %s\n", ((ANTLRToken *)p->LT(8))->getText());
24 printf("LT(9) is %s\n", ((ANTLRToken *)p->LT(9))->getText());
25 printf("LT(10) is %s\n", ((ANTLRToken *)p->LT(10))->getText());
26 printf("LT(11) is %s\n", ((ANTLRToken *)p->LT(11))->getText());
27 }
28 >>
29
30 #token "[\ \t\n]+" <<skip();>>
31 #token Eof "@"
32
33 class Expr { /* Define a grammar class */
34
35 begin
36 : <</*doit(this);*/>>
37 e
38 ;
39
40 e : ( list "=" )? list "=" list Eof
41 <<printf("list = list\n");>>
42 | list Eof
43 <<printf("list\n");>>
44 ;
45
46 list: "\(" (IDENTIFIER|NUMBER)* "\)"
47 ;
48
49 predict
50 : ( "\(" (IDENTIFIER|NUMBER)* "\)" "=")?
51 | "\(" "\)" "="
52 ;
53
54 /*
55 Here's another example...
56 #token INT "int"
57 #token SEMI ";"
58 #token STAR "\*"
59 #token ASSIGN "="
60
61 begin: "extern" "char" declarator ";"
62 ;
63
64 e : (decl)?
65 | expr
66 ;
67
68 expr: IDENTIFIER "=" NUMBER
69 ;
70
71 decl: "int" declarator ";"
72 ;
73
74 declarator
75 : ( "\*" )? "\*" declarator
76 | IDENTIFIER
77 ;
78 */
79
80 }
81
82 #token IDENTIFIER "[a-z]+"
83 #token NUMBER "[0-9]+"
+0
-1
contrib/pccts/testcpp/11/input.h less more
0 0x3 : 0x4
+0
-71
contrib/pccts/testcpp/11/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -project t -class Include test.g -dlg-class Lexer
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = Lexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -CC
25 DFLAGS = -C2 -i -CC -cl Lexer
26 GRM = test.g
27 SRC = test.cpp \
28 Include.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
30 OBJ = test.o \
31 Include.o \
32 AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o
33 ANTLR_SPAWN = test.cpp Include.cpp \
34 Include.h $(DLG_FILE) $(TOKENS)
35 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
36 #CCC=g++
37 CCC=CC
38
39 t : $(OBJ) $(SRC)
40 $(CCC) -o t $(CFLAGS) $(OBJ)
41
42 test.o : $(TOKENS) $(SCAN).h test.cpp
43 $(CCC) -c $(CFLAGS) -o test.o test.cpp
44
45 Include.o : $(TOKENS) $(SCAN).h Include.cpp Include.h
46 $(CCC) -c $(CFLAGS) -o Include.o Include.cpp
47
48 $(SCAN).o : $(SCAN).cpp $(TOKENS)
49 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
50
51 $(ANTLR_SPAWN) : $(GRM)
52 $(ANTLR) $(AFLAGS) $(GRM)
53
54 $(DLG_SPAWN) : $(DLG_FILE)
55 $(DLG) $(DFLAGS) $(DLG_FILE)
56
57 AParser.o : $(ANTLR_H)/AParser.cpp
58 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
59
60 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
61 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
62
63 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
64 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
65
66 clean:
67 rm -f *.o core t
68
69 scrub:
70 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-78
contrib/pccts/testcpp/11/test.g less more
0 /* This is test.g which tests multiple scanners/parsers; DLG-based scanner;
1 * also, we test multiple lexical classes.
2 */
3 <<
4 #include "Lexer.h"
5 typedef ANTLRCommonToken ANTLRToken;
6 #include "PBlackBox.h"
7
8 int main()
9 {
10 ParserBlackBox<Lexer, Include, ANTLRToken> p(stdin);
11 p.parser()->input();
12 return 0;
13 }
14 >>
15
16 #token "[\ \t\n]+" <<skip();>>
17
18 #lexclass START
19
20 class Include {
21
22 <<
23 /* this is automatically defined to be a member function of Include::
24 * since it is within the "class {...}" boundaries.
25 */
26 private:
27 char *stripquotes(ANTLRChar *s)
28 {
29 s[strlen(s)-1] = '\0';
30 return &s[1];
31 }
32 >>
33
34 input
35 : ( cmd | include )* "@"
36 ;
37
38 cmd : "print"
39 ( NUMBER <<printf("%s\n", $1->getText());>>
40 | STRING <<printf("%s\n", $1->getText());>>
41 )
42 ;
43
44 include
45 : "#data" STRING
46 <<{
47 FILE *f;
48 f = fopen(stripquotes($2->getText()), "r");
49 if ( f==NULL ) {fprintf(stderr, "can't open %s\n", $2->getText()+1);}
50 else {
51 ANTLRTokenPtr aToken = new ANTLRToken;
52 DLGFileInput in(f);
53 Lexer scan(&in);
54 scan.setToken(mytoken(aToken));
55 scan.mode(Lexer::DATA);
56 ANTLRTokenBuffer pipe(&scan);
57 Include parser(&pipe);
58 parser.init();
59 parser.data();
60 }
61 }>>
62 ;
63
64 #lexclass DATA
65
66 #token "[\ \t\n]+" <<skip();>>
67
68 data: "0x[0-9]+" ":" "0x[0-9]+"
69 <<printf("data %s\n", $1->getText());>>
70 ;
71
72 }
73
74 #lexclass START
75
76 #token STRING "\" [a-zA-Z0-9_.,\ \t]+ \""
77 #token NUMBER "[0-9]+"
+0
-71
contrib/pccts/testcpp/12/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -class Expr -project t test.g
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = DLGLexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -CC
25 DFLAGS = -C2 -i -CC
26 GRM = test.g
27 SRC = test.cpp \
28 Expr.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
30 OBJ = test.o \
31 Expr.o \
32 AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o
33 ANTLR_SPAWN = test.cpp Expr.cpp \
34 Expr.h $(DLG_FILE) $(TOKENS)
35 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
36 #CCC=g++
37 CCC=CC
38
39 t : $(OBJ) $(SRC)
40 $(CCC) -o t $(CFLAGS) $(OBJ)
41
42 test.o : $(TOKENS) $(SCAN).h test.cpp
43 $(CCC) -c $(CFLAGS) -o test.o test.cpp
44
45 Expr.o : $(TOKENS) $(SCAN).h Expr.cpp Expr.h
46 $(CCC) -c $(CFLAGS) -o Expr.o Expr.cpp
47
48 $(SCAN).o : $(SCAN).cpp $(TOKENS)
49 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
50
51 $(ANTLR_SPAWN) : $(GRM)
52 $(ANTLR) $(AFLAGS) $(GRM)
53
54 $(DLG_SPAWN) : $(DLG_FILE)
55 $(DLG) $(DFLAGS) $(DLG_FILE)
56
57 AParser.o : $(ANTLR_H)/AParser.cpp
58 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
59
60 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
61 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
62
63 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
64 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
65
66 clean:
67 rm -f *.o core t
68
69 scrub:
70 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-39
contrib/pccts/testcpp/12/test.g less more
0 /* This is test.g which tests a simple DLG-based scanner using string input */
1
2 <<
3 typedef ANTLRCommonToken ANTLRToken;
4
5 #include "DLGLexer.h"
6 #include "PBlackBox.h"
7
8 int main(int argc, char **argv)
9 {
10 if ( argc==1 ) {fprintf(stderr, "how about an argument?\n"); exit(1);}
11 DLGStringInput in(argv[1]); /* create an input stream for DLG */
12 DLGLexer scan(&in); /* create scanner reading from stdin */
13 ANTLRTokenBuffer pipe(&scan); /* make pipe between lexer & parser */
14 ANTLRTokenPtr aToken = new ANTLRToken;
15 scan.setToken(mytoken(aToken));
16 Expr parser(&pipe); /* create parser of type Expr hooked to scanner */
17 parser.init(); /* init the parser; prime lookahead etc... */
18 parser.e(); /* start parsing at rule 'e' of that parser */
19
20 return 0;
21 }
22 >>
23
24 #token "[\ \t\n]+" <<skip();>>
25 #token Eof "@"
26
27 #tokclass My { IDENTIFIER NUMBER }
28
29 class Expr { /* Define a grammar class */
30
31 e : My My Eof
32 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
33 ;
34
35 }
36
37 #token IDENTIFIER "[a-z]+"
38 #token NUMBER "[0-9]+"
+0
-71
contrib/pccts/testcpp/13/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -class PEHTest -project t test.g
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = DLGLexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -CC $(AOTHER)
25 DFLAGS = -C2 -i -CC
26 GRM = test.g
27 SRC = test.cpp \
28 PEHTest.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
30 OBJ = test.o \
31 PEHTest.o \
32 AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o
33 ANTLR_SPAWN = test.cpp PEHTest.cpp \
34 PEHTest.h $(DLG_FILE) $(TOKENS)
35 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
36 #CCC=g++
37 CCC=CC
38
39 t : $(OBJ) $(SRC)
40 $(CCC) -o t $(CFLAGS) $(OBJ)
41
42 test.o : $(TOKENS) $(SCAN).h test.cpp
43 $(CCC) -c $(CFLAGS) -o test.o test.cpp
44
45 PEHTest.o : $(TOKENS) $(SCAN).h PEHTest.cpp PEHTest.h
46 $(CCC) -c $(CFLAGS) -o PEHTest.o PEHTest.cpp
47
48 $(SCAN).o : $(SCAN).cpp $(TOKENS)
49 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
50
51 $(ANTLR_SPAWN) : $(GRM)
52 $(ANTLR) $(AFLAGS) $(GRM)
53
54 $(DLG_SPAWN) : $(DLG_FILE)
55 $(DLG) $(DFLAGS) $(DLG_FILE)
56
57 AParser.o : $(ANTLR_H)/AParser.cpp
58 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
59
60 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
61 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
62
63 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
64 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
65
66 clean:
67 rm -f *.o core t
68
69 scrub:
70 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-79
contrib/pccts/testcpp/13/test.g less more
0 /* C++ interface test of Parser Exception Handling
1 *
2 * Given input:
3 *
4 * if a+ then a=b+b;
5 *
6 * the program should respond with
7 *
8 * invalid conditional in 'if' statement
9 * found assignment to a
10 */
11 <<
12 #include <stream.h>
13 #include "DLGLexer.h"
14 #include "PBlackBox.h"
15 typedef ANTLRCommonToken ANTLRToken;
16
17 int main()
18 {
19 ParserBlackBox<DLGLexer, PEHTest, ANTLRToken> p(stdin);
20 int retsignal;
21 p.parser()->rule(&retsignal);
22 return 0;
23 }
24 >>
25
26 /*
27 Uncommenting this will make ANTLR think you put these handlers at the
28 end of each rule:
29
30 exception
31 catch MismatchedToken : <<printf("dflt:MismatchedToken\n");>>
32 default : <<printf("dflt:dflt\n");>>
33 */
34
35 #token "[\ \t]+" <<skip();>>
36 #token "\n" <<skip(); newline();>>
37 #token THEN "then"
38 #tokclass DIE { "@" "if" ID "else" }
39
40 class PEHTest {
41
42 rule: ( stat )+
43 ;
44
45 stat: "if" t:expr THEN stat { "else" stat }
46 | id:ID "=" expr ";"
47 <<printf("found assignment to %s\n", $id->getText());>>
48 ;
49 exception[t]
50 default :
51 <<
52 printf("invalid conditional in 'if' statement\n");
53 consumeUntilToken(THEN);
54 suppressSignal;
55 >>
56 exception
57 catch MismatchedToken :
58 catch NoViableAlt :
59 catch NoSemViableAlt :
60 <<
61 printf("stat:caught predefined signal\n");
62 consumeUntil(DIE_set);
63 suppressSignal;
64 >>
65
66 expr: expr1 ("\+" expr1)*
67 ;
68
69 expr1
70 : expr2 ("\*" expr2)*
71 ;
72
73 expr2: ID
74 ;
75
76 }
77
78 #token ID "[a-z]+"
+0
-76
contrib/pccts/testcpp/2/MyLexer.cpp less more
0 /* MyTokenBuffer.c */
1 /* Sample replacement for DLGLexer */
2 /* Shows how to override DLG with your own lexer */
3
4 #include <stdio.h>
5 #include <ctype.h>
6 #include <stdlib.h>
7 #include <iostream.h>
8
9 #include "config.h" /* include token defs */
10 #include "tokens.h" /* include token defs */
11 #include APARSER_H /* include all the ANTLR yuck */
12 #include "MyLexer.h" /* define your lexer */
13 typedef ANTLRCommonToken ANTLRToken;/* use a predefined Token class */
14
15 void panic(char *s) {
16 cerr << s << '\n';
17 exit(5);
18 }
19
20 MyLexer::MyLexer()
21 {
22 c = getchar();
23 }
24
25 /* Recognizes Tokens IDENTIFIER and NUMBER */
26 ANTLRAbstractToken *MyLexer::
27 getToken()
28 {
29 /* we will return a pointer to this next guy */
30 ANTLRToken *resultToken = new ANTLRToken;
31
32 ANTLRChar TokenBuffer[100];
33 /* This routine will just crash if tokens become
34 more than 99 chars; your code must of course
35 gracefully recover/adapt */
36 int index=0;
37
38 while ( c==' ' || c=='\n' ) c=getchar();
39
40 if (c==EOF) {resultToken->setType(Eof); return resultToken;}
41
42 if (isdigit(c)) {
43 /* Looks like we have ourselves a number token */
44 while (isdigit(c)) {
45 TokenBuffer[index++]=c;
46 c = getchar();
47 }
48 TokenBuffer[index]='\0';
49
50 resultToken->setType(NUMBER);
51 resultToken->setText(TokenBuffer);
52
53 return resultToken;
54 }
55
56 if (isalpha(c)) {
57 /* We have ourselves an IDENTIFIER token */
58 while (isalpha(c)) {
59 TokenBuffer[index++]=c;
60 c = getchar();
61 }
62 TokenBuffer[index]='\0';
63
64 resultToken->setType(IDENTIFIER);
65 resultToken->setText(TokenBuffer);
66
67 return resultToken;
68 }
69
70 else
71 panic("lexer error");
72
73 return NULL;
74 }
75
+0
-11
contrib/pccts/testcpp/2/MyLexer.h less more
0 /* MyTokenBuffer.h */
1
2 #include ATOKENBUFFER_H
3
4 class MyLexer : public ANTLRTokenStream {
5 private:
6 int c;
7 public:
8 MyLexer();
9 virtual ANTLRAbstractToken *getToken();
10 };
+0
-64
contrib/pccts/testcpp/2/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -project t -class Expr test.g -user-lexer
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # User-defined scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = DLGLexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -gx -CC
25 DFLAGS = -C2 -i -CC
26 GRM = test.g
27 SRC = test.cpp \
28 Expr.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/ATokenBuffer.cpp MyLexer.cpp
30 OBJ = test.o \
31 Expr.o \
32 AParser.o ATokenBuffer.o MyLexer.o
33 ANTLR_SPAWN = test.cpp Expr.cpp \
34 Expr.h $(TOKENS)
35 #CCC=g++
36 CCC=CC
37
38 t : $(OBJ) $(SRC)
39 $(CCC) -o t $(CFLAGS) $(OBJ)
40
41 test.o : $(TOKENS) test.cpp
42 $(CCC) -c $(CFLAGS) -o test.o test.cpp
43
44 MyLexer.o : $(TOKENS) MyLexer.cpp
45 $(CCC) -c $(CFLAGS) -o MyLexer.o MyLexer.cpp
46
47 Expr.o : $(TOKENS) Expr.cpp Expr.h
48 $(CCC) -c $(CFLAGS) -o Expr.o Expr.cpp
49
50 $(ANTLR_SPAWN) : $(GRM)
51 $(ANTLR) $(AFLAGS) $(GRM)
52
53 AParser.o : $(ANTLR_H)/AParser.cpp
54 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
55
56 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
57 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
58
59 clean:
60 rm -f *.o core t
61
62 scrub:
63 rm -f *.o core t $(ANTLR_SPAWN)
+0
-45
contrib/pccts/testcpp/2/test.g less more
0 /* Ariel Tamches (tamches@cs.wisc.edu):
1 * This tests linking in a simple non-DLG scanner
2 */
3
4 /* We assume that #tokdefs is not employed for this example; i.e.,
5 * ANTLR assigns token numbers.
6 *
7 * ANTLR option -gx must be used to turn off generation of DLG crud (when you
8 * want to define your own token stream).
9 */
10
11 /* user must define ANTLRToken outside of #header */
12 <<
13 typedef ANTLRCommonToken ANTLRToken; /* use a predefined Token class */
14 >>
15
16 /* At this point, ANTLRToken and ANTLRTokenStream are defined, user must now
17 * derive a class from ANTLRTokenStream (which embodies the user's scanner)
18 */
19 <<#include "MyLexer.h">>
20
21 <<
22 int main()
23 {
24 /* create one of my scanners */
25 MyLexer scan;
26 ANTLRTokenBuffer pipe(&scan);
27 /* create a parser of type Expr hooked to my scanner */
28 Expr parser(&pipe);
29 parser.init();
30 parser.setEofToken(Eof);
31
32 parser.e(); /* start parsing at rule 'e' of that parser */
33 return 0;
34 }
35 >>
36
37 class Expr { /* Define a grammar class */
38
39 e : IDENTIFIER NUMBER
40 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
41 Eof
42 ;
43
44 }
+0
-76
contrib/pccts/testcpp/3/MyLexer.cpp less more
0 /* MyTokenBuffer.c */
1 /* Sample replacement for DLGLexer */
2 /* Shows how to override DLG with your own lexer */
3
4 #include <stdio.h>
5 #include <ctype.h>
6 #include <stdlib.h>
7 #include <iostream.h>
8
9 #include "config.h" /* include token defs */
10 #include "mytokens.h" /* include token defs */
11 #include APARSER_H /* include all the ANTLR yuck */
12 #include "MyLexer.h" /* define your lexer */
13 typedef ANTLRCommonToken ANTLRToken;/* use a predefined Token class */
14
15 void panic(char *s) {
16 cerr << s << '\n';
17 exit(5);
18 }
19
20 MyLexer::MyLexer()
21 {
22 c = getchar();
23 }
24
25 /* Recognizes Tokens IDENTIFIER and NUMBER */
26 ANTLRAbstractToken *MyLexer::
27 getToken()
28 {
29 /* we will return a pointer to this next guy */
30 ANTLRToken *resultToken = new ANTLRToken;
31
32 ANTLRChar TokenBuffer[100];
33 /* This routine will just crash if tokens become
34 more than 99 chars; your code must of course
35 gracefully recover/adapt */
36 int index=0;
37
38 while ( c==' ' || c=='\n' ) c=getchar();
39
40 if (c==EOF) {resultToken->setType(Eof); return resultToken;}
41
42 if (isdigit(c)) {
43 /* Looks like we have ourselves a number token */
44 while (isdigit(c)) {
45 TokenBuffer[index++]=c;
46 c = getchar();
47 }
48 TokenBuffer[index]='\0';
49
50 resultToken->setType(NUMBER);
51 resultToken->setText(TokenBuffer); /* not exactly swift, unfortunately... */
52
53 return resultToken;
54 }
55
56 if (isalpha(c)) {
57 /* We have ourselves an IDENTIFIER token */
58 while (isalpha(c)) {
59 TokenBuffer[index++]=c;
60 c = getchar();
61 }
62 TokenBuffer[index]='\0';
63
64 resultToken->setType(IDENTIFIER);
65 resultToken->setText(TokenBuffer); /* not exactly swift, unfortunately... */
66
67 return resultToken;
68 }
69
70 else
71 panic("lexer error");
72
73 return NULL;
74 }
75
+0
-11
contrib/pccts/testcpp/3/MyLexer.h less more
0 /* MyTokenBuffer.h */
1
2 #include ATOKENBUFFER_H
3
4 class MyLexer : public ANTLRTokenStream {
5 private:
6 int c;
7 public:
8 MyLexer();
9 virtual ANTLRAbstractToken *getToken();
10 };
+0
-65
contrib/pccts/testcpp/3/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -project t -class Expr test.g -user-lexer -token-types mytokens.h
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # User-defined scanner
9 # User-defined token types in 'mytokens.h'
10 #
11 # Make sure #tokdefs directive in ANTLR grammar lists this file:
12 TOKENS = mytokens.h
13 #
14 # The following filenames must be consistent with ANTLR/DLG flags
15 DLG_FILE = parser.dlg
16 ERR = err
17 HDR_FILE =
18 SCAN = DLGLexer
19 PCCTS = ../..
20 ANTLR_H = $(PCCTS)/h
21 BIN = $(PCCTS)/bin
22 ANTLR = $(BIN)/antlr
23 DLG = $(BIN)/dlg
24 CFLAGS = -I. -I$(ANTLR_H)
25 AFLAGS = -gx -CC
26 DFLAGS = -C2 -i -CC
27 GRM = test.g
28 SRC = test.cpp \
29 Expr.cpp \
30 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/ATokenBuffer.cpp MyLexer.cpp
31 OBJ = test.o \
32 Expr.o \
33 AParser.o ATokenBuffer.o MyLexer.o
34 ANTLR_SPAWN = test.cpp Expr.cpp \
35 Expr.h
36 #CCC=g++
37 CCC=CC
38
39 t : $(OBJ) $(SRC)
40 $(CCC) -o t $(CFLAGS) $(OBJ)
41
42 test.o : $(TOKENS) test.cpp
43 $(CCC) -c $(CFLAGS) -o test.o test.cpp
44
45 MyLexer.o : $(TOKENS) MyLexer.cpp
46 $(CCC) -c $(CFLAGS) -o MyLexer.o MyLexer.cpp
47
48 Expr.o : $(TOKENS) Expr.cpp Expr.h
49 $(CCC) -c $(CFLAGS) -o Expr.o Expr.cpp
50
51 $(ANTLR_SPAWN) : $(GRM)
52 $(ANTLR) $(AFLAGS) $(GRM)
53
54 AParser.o : $(ANTLR_H)/AParser.cpp
55 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
56
57 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
58 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
59
60 clean:
61 rm -f *.o core t
62
63 scrub:
64 rm -f *.o core t $(ANTLR_SPAWN)
+0
-5
contrib/pccts/testcpp/3/mytokens.h less more
0 enum ANTLRTokenType {
1 IDENTIFIER=1,
2 NUMBER=2,
3 Eof=3
4 };
+0
-54
contrib/pccts/testcpp/3/test.g less more
0 /* Ariel Tamches (tamches@cs.wisc.edu):
1 * This tests linking in a simple non-DLG scanner with user-defined token
2 * types.
3 */
4
5 /* All TokenType's must have some end-of-file token; You must define
6 * it with setEofToken() to your end of input token.
7 *
8 * We assume that #tokdefs is employed for this example; i.e., ANTLR does
9 * NOT assign token numbers.
10 *
11 * ANTLR option -gx must be used to turn off generation of DLG crud (when you
12 * want to define your own token stream).
13 */
14
15 #tokdefs "mytokens.h"
16
17 /* user should define ANTLRToken outside of #header since AToken.h would
18 * not have been included yet. You can force inclusion of AToken.h if
19 * you must use #header, however.
20 */
21 <<
22 typedef ANTLRCommonToken ANTLRToken; /* use a predefined Token class */
23 >>
24
25 /* At this point, ANTLRToken and ANTLRTokenStream are defined, user must now
26 * derive a class from ANTLRTokenStream (which embodies the user's scanner)
27 */
28 <<#include "MyLexer.h">>
29
30 <<
31 int main()
32 {
33 /* create one of my scanners */
34 MyLexer scan;
35 ANTLRTokenBuffer pipe(&scan);
36 /* create a parser of type Expr hooked to my scanner */
37 Expr parser(&pipe);
38 parser.init();
39 parser.setEofToken(Eof);
40
41 parser.e(); /* start parsing at rule 'e' of that parser */
42 return 0;
43 }
44 >>
45
46 class Expr {
47
48 e : IDENTIFIER NUMBER
49 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
50 Eof
51 ;
52
53 }
+0
-72
contrib/pccts/testcpp/4/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -project t -class Expr test.g -token-types mytokens.h
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # User-defined token types in 'mytokens.h'
10 #
11 # Make sure #tokdefs directive in ANTLR grammar lists this file:
12 TOKENS = mytokens.h
13 #
14 # The following filenames must be consistent with ANTLR/DLG flags
15 DLG_FILE = parser.dlg
16 ERR = err
17 HDR_FILE =
18 SCAN = DLGLexer
19 PCCTS = ../..
20 ANTLR_H = $(PCCTS)/h
21 BIN = $(PCCTS)/bin
22 ANTLR = $(BIN)/antlr
23 DLG = $(BIN)/dlg
24 CFLAGS = -I. -I$(ANTLR_H)
25 AFLAGS = -CC
26 DFLAGS = -C2 -i -CC
27 GRM = test.g
28 SRC = test.cpp \
29 Expr.cpp \
30 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
31 OBJ = test.o \
32 Expr.o \
33 AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o
34 ANTLR_SPAWN = test.cpp Expr.cpp \
35 Expr.h $(DLG_FILE)
36 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
37 #CCC=g++
38 CCC=CC
39
40 t : $(OBJ) $(SRC)
41 $(CCC) -o t $(CFLAGS) $(OBJ)
42
43 test.o : $(TOKENS) $(SCAN).h test.cpp
44 $(CCC) -c $(CFLAGS) -o test.o test.cpp
45
46 Expr.o : $(TOKENS) $(SCAN).h Expr.cpp Expr.h
47 $(CCC) -c $(CFLAGS) -o Expr.o Expr.cpp
48
49 $(SCAN).o : $(SCAN).cpp $(TOKENS)
50 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
51
52 $(ANTLR_SPAWN) : $(GRM)
53 $(ANTLR) $(AFLAGS) $(GRM)
54
55 $(DLG_SPAWN) : $(DLG_FILE)
56 $(DLG) $(DFLAGS) $(DLG_FILE)
57
58 AParser.o : $(ANTLR_H)/AParser.cpp
59 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
60
61 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
62 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
63
64 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
65 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
66
67 clean:
68 rm -f *.o core t
69
70 scrub:
71 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-4
contrib/pccts/testcpp/4/mytokens.h less more
0 enum ANTLRTokenType {
1 IDENTIFIER=2,
2 NUMBER=3
3 };
+0
-45
contrib/pccts/testcpp/4/test.g less more
0 /* This is test.g which tests a simple DLG-based scanner
1 * with user-defined tokens
2 */
3
4 /* Here, we use #tokdefs to define token types, but still let DLG do the
5 * lexing. ANTLR will not create a tokens.h file.
6 */
7 #tokdefs "mytokens.h"
8
9 <<
10 #include "DLGLexer.h" /* include definition of DLGLexer.
11 * This cannot be generated automatically because
12 * ANTLR has no idea what you will call this file
13 * with the DLG command-line options.
14 */
15
16 typedef ANTLRCommonToken ANTLRToken;
17
18 int main()
19 {
20 ANTLRTokenPtr aToken = new ANTLRToken;
21 DLGFileInput in(stdin);
22 DLGLexer scan(&in);
23 ANTLRTokenBuffer pipe(&scan);
24 scan.setToken(mytoken(aToken));
25 Expr parser(&pipe);
26 parser.init();
27
28 parser.e();
29 return 0;
30 }
31 >>
32
33 #token "[\ \t\n]+" <<skip();>>
34
35 class Expr { /* Define a grammar class */
36
37 e : IDENTIFIER NUMBER "@"
38 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
39 ;
40
41 }
42
43 #token IDENTIFIER "[a-z]+"
44 #token NUMBER "[0-9]+"
+0
-2
contrib/pccts/testcpp/5/input.h less more
0 print 34
1 print "hello world"
+0
-71
contrib/pccts/testcpp/5/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -project t -class Include test.g -dlg-class Lexer
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = Lexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -CC
25 DFLAGS = -C2 -i -CC -cl Lexer
26 GRM = test.g
27 SRC = test.cpp \
28 Include.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
30 OBJ = test.o \
31 Include.o \
32 AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o
33 ANTLR_SPAWN = test.cpp Include.cpp \
34 Include.h $(DLG_FILE) $(TOKENS)
35 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
36 #CCC=g++
37 CCC=CC
38
39 t : $(OBJ) $(SRC)
40 $(CCC) -o t $(CFLAGS) $(OBJ)
41
42 test.o : $(TOKENS) $(SCAN).h test.cpp
43 $(CCC) -c $(CFLAGS) -o test.o test.cpp
44
45 Include.o : $(TOKENS) $(SCAN).h Include.cpp Include.h
46 $(CCC) -c $(CFLAGS) -o Include.o Include.cpp
47
48 $(SCAN).o : $(SCAN).cpp $(TOKENS)
49 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
50
51 $(ANTLR_SPAWN) : $(GRM)
52 $(ANTLR) $(AFLAGS) $(GRM)
53
54 $(DLG_SPAWN) : $(DLG_FILE)
55 $(DLG) $(DFLAGS) $(DLG_FILE)
56
57 AParser.o : $(ANTLR_H)/AParser.cpp
58 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
59
60 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
61 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
62
63 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
64 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
65
66 clean:
67 rm -f *.o core t
68
69 scrub:
70 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-70
contrib/pccts/testcpp/5/test.g less more
0 /* This is test.g which tests multiple scanners/parsers; DLG-based scanner */
1 <<
2 #include "Lexer.h"
3 typedef ANTLRCommonToken ANTLRToken;
4
5 int main()
6 {
7 ANTLRTokenPtr aToken = new ANTLRToken;
8 DLGFileInput in(stdin);
9 Lexer scan(&in);
10 scan.setToken(mytoken(aToken));
11 ANTLRTokenBuffer pipe(&scan);
12 Include parser(&pipe);
13 parser.init();
14
15 parser.input();
16 return 0;
17 }
18 >>
19
20 #token "[\ \t\n]+" <<skip();>>
21 #token Eof "@"
22
23 class Include {
24
25 <<
26 /* this is automatically defined to be a member function of Include::
27 * since it is within the "class {...}" boundaries.
28 */
29 private:
30 char *stripquotes(ANTLRChar *s)
31 {
32 s[strlen(s)-1] = '\0';
33 return &s[1];
34 }
35 >>
36
37 input
38 : ( cmd | include )* Eof
39 ;
40
41 cmd : "print"
42 ( NUMBER <<printf("%s\n", $1->getText());>>
43 | STRING <<printf("%s\n", $1->getText());>>
44 )
45 ;
46
47 include
48 : "#include" STRING
49 <<{
50 FILE *f;
51 f = fopen(stripquotes($2->getText()), "r");
52 if ( f==NULL ) {fprintf(stderr, "can't open %s\n", $2->getText()+1);}
53 else {
54 ANTLRTokenPtr aToken = new ANTLRToken;
55 DLGFileInput in(f);
56 Lexer scan(&in);
57 scan.setToken(mytoken(aToken));
58 ANTLRTokenBuffer pipe(&scan);
59 Include parser(&pipe);
60 parser.init();
61 parser.input();
62 }
63 }>>
64 ;
65
66 }
67
68 #token STRING "\" [a-zA-Z0-9_.,\ \t]+ \""
69 #token NUMBER "[0-9]+"
+0
-1
contrib/pccts/testcpp/6/file1 less more
0 abc 34
+0
-1
contrib/pccts/testcpp/6/file2 less more
0 def 56
+0
-54
contrib/pccts/testcpp/6/main.cpp less more
0 /* we must define ANTLRTokenType, but it will be different for parsers A and B;
1 * so, we just define it as an 'int', which is bad, but we can do nothing
2 * else.
3 */
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include "A/tokens.h"
7 #include "A.h"
8 #include "B.h"
9 #include "ALexer.h"
10 #include "BLexer.h"
11
12 #include "PBlackBox.h"
13
14 typedef ANTLRCommonToken ANTLRToken;
15
16 int main(int argc, char *argv[])
17 {
18 ANTLRToken aToken; /* create a token to fill in for DLG */
19 DLGFileInput in(stdin);
20
21 if ( argc!=3 ) {
22 fprintf(stderr, "usage: t file1 file2\n");
23 //
24 // 7-Apr-97 MR1
25 //
26 //// MR1 exit(EXIT_SUCCESS);
27 exit(PCCTS_EXIT_SUCCESS); //// MR1
28 }
29
30 ParserBlackBox<ALexer, A, ANTLRToken> p1(argv[1]);
31 p1.parser()->e();
32
33 ParserBlackBox<BLexer, B, ANTLRToken> p2(argv[2]);
34 p2.parser()->e();
35
36 /*
37 ALexer scan1(&in,2000);
38 ANTLRTokenBuffer pipe1(&scan1);
39 scan1.setToken(&aToken);
40 A parser1(&pipe1);
41 parser1.init();
42 parser1.e();
43
44 BLexer scan2(&in,2000);
45 ANTLRTokenBuffer pipe2(&scan2);
46 scan2.setToken(&aToken);
47 B parser2(&pipe2);
48 parser2.init();
49 parser2.e();
50 */
51
52 return 0;
53 }
+0
-83
contrib/pccts/testcpp/6/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # PCCTS release 1.21
4 # Project: t
5 # C++ output
6 # D scanner
7 # A-defined token types
8 #
9 TOKENS = A/tokens.h
10 #
11 # The following filenames must be consistent with A/D flags
12 D_FILE = A/parser.dlg
13 ERR = A/err
14 HDR_FILE =
15 SCAN = A/ALexer
16 PCCTS = ../..
17 A_H = $(PCCTS)/h
18 BIN = $(PCCTS)/bin
19 A = $(BIN)/antlr
20 D = $(BIN)/dlg
21 CFLAGS = -I. -I$(A_H) -IA -IB -g
22 #
23 # Delay lookahead so that an extra fetch is not done by
24 # 'A' parser which is needed by 'B' parser.
25 #
26 AFLAGS = -o A -CC
27 DFLAGS = -C2 -i -CC -cl ALexer -o A
28 GRM = test.g
29 SRC = A/test.cpp \
30 A/A.cpp \
31 $(A_H)/AParser.cpp $(A_H)/DLexerBase.cpp $(SCAN).cpp main.cpp \
32 $(A_H)/ATokenBuffer.cpp
33 OBJ = A/test.o A/A.o A/AParser.o A/DLexerBase.o $(SCAN).o main.o \
34 A/ATokenBuffer.o
35
36 OBJ2 = B/test2.o B/B.o B/BLexer.o
37 A_SPAWN = A/test.cpp A/A.cpp \
38 A/A.h \
39 $(HDR_FILE) $(D_FILE) $(TOKENS)
40 D_SPAWN = $(SCAN).cpp $(SCAN).h
41 #CCC=g++
42 CCC=CC
43
44 t: $(OBJ) $(OBJ2) $(SRC)
45 make -f makefile2
46 $(CCC) -o t $(CFLAGS) $(OBJ) $(OBJ2)
47
48 A/test.o : $(TOKENS) $(SCAN).h A/test.cpp $(HDR_FILE)
49 $(CCC) -c $(CFLAGS) -o A/test.o A/test.cpp
50
51 A/A.o : $(TOKENS) $(SCAN).h A/A.cpp A/A.h $(HDR_FILE)
52 $(CCC) -c $(CFLAGS) -o A/A.o A/A.cpp
53
54 $(SCAN).o : $(SCAN).cpp $(TOKENS)
55 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
56
57 $(A_SPAWN) : $(GRM)
58 $(A) $(AFLAGS) $(GRM)
59
60 $(D_SPAWN) : $(D_FILE)
61 $(D) $(DFLAGS) $(D_FILE)
62
63 A/ATokenBuffer.o : $(A_H)/ATokenBuffer.cpp
64 $(CCC) -c $(CFLAGS) -o A/ATokenBuffer.o $(A_H)/ATokenBuffer.cpp
65
66 A/AParser.o : $(A_H)/AParser.cpp
67 $(CCC) -c $(CFLAGS) -o A/AParser.o $(A_H)/AParser.cpp
68
69 A/DLexerBase.o : $(A_H)/DLexerBase.cpp
70 $(CCC) -c $(CFLAGS) -o A/DLexerBase.o $(A_H)/DLexerBase.cpp
71
72 main.o : main.cpp B/B.h
73 $(CCC) -c $(CFLAGS) -o main.o main.cpp
74
75 B/B.h :
76 make -f makefile2
77
78 clean:
79 rm -f *.o core t A/*.o
80
81 scrub:
82 rm -f *.o core t A/*.o $(A_SPAWN) $(D_SPAWN)
+0
-58
contrib/pccts/testcpp/6/makefile2 less more
0 #
1 # PCCTS makefile for: test2.g
2 #
3 # PCCTS release 1.21
4 # Project: t
5 # C++ output
6 # D scanner
7 # A-defined token types
8 #
9 TOKENS = B/tokens.h
10 #
11 # The following filenames must be consistent with A/D flags
12 D_FILE = B/parser.dlg
13 ERR = B/err
14 HDR_FILE =
15 SCAN = B/BLexer
16 PCCTS = ../..
17 A_H = $(PCCTS)/h
18 BIN = $(PCCTS)/bin
19 A = $(BIN)/antlr
20 D = $(BIN)/dlg
21 CFLAGS = -I. -I$(A_H) -IB -g
22 AFLAGS = -o B -CC
23 DFLAGS = -C2 -i -CC -cl BLexer -o B
24 GRM = test2.g
25 SRC = B/test2.cpp \
26 B/B.cpp \
27 $(SCAN).cpp
28 OBJ = B/test2.o B/B.o $(SCAN).o
29 A_SPAWN = B/test2.cpp B/B.cpp \
30 B/B.h \
31 $(HDR_FILE) $(D_FILE) $(TOKENS)
32 D_SPAWN = $(SCAN).cpp $(SCAN).h
33 #CCC=g++
34 CCC=$(CC)
35
36 t: $(OBJ) $(SRC)
37
38 B/test2.o : $(TOKENS) $(SCAN).h B/test2.cpp $(HDR_FILE)
39 $(CCC) -c $(CFLAGS) -o B/test2.o B/test2.cpp
40
41 B/B.o : $(TOKENS) $(SCAN).h B/B.cpp B/B.h $(HDR_FILE)
42 $(CCC) -c $(CFLAGS) -o B/B.o B/B.cpp
43
44 $(SCAN).o : $(SCAN).cpp $(TOKENS)
45 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
46
47 $(A_SPAWN) : $(GRM)
48 $(A) $(AFLAGS) $(GRM)
49
50 $(D_SPAWN) : $(D_FILE)
51 $(D) $(DFLAGS) $(D_FILE)
52
53 clean:
54 rm -f *.o core t B/*.o
55
56 scrub:
57 rm -f *.o core t B/*.o $(A_SPAWN) $(D_SPAWN)
+0
-20
contrib/pccts/testcpp/6/test.g less more
0 /* This is test.g which tests linking multiple scanners/parsers together;
1 * DLG-based scanner
2 */
3
4 <<
5 typedef ANTLRCommonToken ANTLRToken;
6 >>
7
8 #token "[\ \t\n]+" <<skip();>>
9
10 class A {
11
12 e : IDENTIFIER NUMBER
13 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
14 ;
15
16 }
17
18 #token IDENTIFIER "[a-z]+"
19 #token NUMBER "[0-9]+"
+0
-22
contrib/pccts/testcpp/6/test2.g less more
0 /* This is test2.g which is a copy of test.g and tests linking
1 * multiple scanners/parsers together; DLG-based scanner
2 */
3
4 <<
5 typedef ANTLRCommonToken ANTLRToken;
6 >>
7
8 #token "[\ \t\n]+" <<skip();>>
9 #token Eof "@"
10
11 class B {
12
13 e : IDENTIFIER NUMBER
14 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
15 Eof
16 ;
17
18 }
19
20 #token IDENTIFIER "[a-z]+"
21 #token NUMBER "[0-9]+"
+0
-71
contrib/pccts/testcpp/7/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -project t -class Expr test.g
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = DLGLexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -CC
25 DFLAGS = -C2 -i -CC
26 GRM = test.g
27 SRC = test.cpp \
28 Expr.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
30 OBJ = test.o \
31 Expr.o \
32 AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o
33 ANTLR_SPAWN = test.cpp Expr.cpp \
34 Expr.h $(DLG_FILE) $(TOKENS)
35 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
36 #CCC=g++
37 CCC=CC
38
39 t : $(OBJ) $(SRC)
40 $(CCC) -o t $(CFLAGS) $(OBJ)
41
42 test.o : $(TOKENS) $(SCAN).h test.cpp
43 $(CCC) -c $(CFLAGS) -o test.o test.cpp
44
45 Expr.o : $(TOKENS) $(SCAN).h Expr.cpp Expr.h
46 $(CCC) -c $(CFLAGS) -o Expr.o Expr.cpp
47
48 $(SCAN).o : $(SCAN).cpp $(TOKENS)
49 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
50
51 $(ANTLR_SPAWN) : $(GRM)
52 $(ANTLR) $(AFLAGS) $(GRM)
53
54 $(DLG_SPAWN) : $(DLG_FILE)
55 $(DLG) $(DFLAGS) $(DLG_FILE)
56
57 AParser.o : $(ANTLR_H)/AParser.cpp
58 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
59
60 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
61 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
62
63 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
64 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
65
66 clean:
67 rm -f *.o core t
68
69 scrub:
70 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-55
contrib/pccts/testcpp/7/test.g less more
0 <<
1 #include ATOKPTR_H // define smart pointers
2
3 class ANTLRToken : public ANTLRCommonToken {
4 public:
5 int muck;
6 public:
7 ANTLRToken(ANTLRTokenType t, ANTLRChar *s) : ANTLRCommonToken(t,s)
8 { muck = atoi(s); }
9 ANTLRToken() {;}
10 ANTLRChar *getText() const { return ""; }
11 void setText(const ANTLRChar *s) { ; }
12 virtual ANTLRAbstractToken *makeToken(ANTLRTokenType t, char *s, int line)
13 {
14 ANTLRToken *tk = new ANTLRToken(t,s);
15 tk->muck = atoi(s);
16 return tk;
17 }
18 };
19
20 #include "DLGLexer.h"
21 #include "PBlackBox.h"
22
23 int main()
24 {
25 ParserBlackBox<DLGLexer, Expr, ANTLRToken> p(stdin);
26
27 p.parser()->calc();
28 return 0;
29 }
30 >>
31
32 #token "[\ \t\n]+" <<skip();>>
33
34 class Expr {
35
36 calc: <<int r;>>
37 e>[r]
38 <<printf("result is %d\n", r);>>
39 ;
40
41 e > [int r]
42 : <<int b;>>
43 e2>[$r] ( "\+" e2>[b] <<$r+=b;>> )*
44 ;
45
46 e2 > [int r]
47 : NUMBER <<$r=mytoken($1)->muck;>>
48 ( "\*" NUMBER <<$r*=mytoken($2)->muck;>> )*
49 ;
50
51 }
52
53 #token NUMBER "[0-9]+"
54
+0
-14
contrib/pccts/testcpp/8/main.cpp less more
0 /* Simple main() to call a parser in another file */
1
2 #include "tokens.h" // define TokenType
3 #include "Expr.h" // define parser
4 #include "DLGLexer.h" // define scanner
5 #include "PBlackBox.h" // Define ParserBlackBox
6
7 int main()
8 {
9 ParserBlackBox<DLGLexer, Expr, ANTLRToken> p(stdin);
10
11 p.parser()->e(); /* start parsing at rule 'e' of that parser */
12 return 0;
13 }
+0
-74
contrib/pccts/testcpp/8/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -project t -class Expr test.g
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = DLGLexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -CC
25 DFLAGS = -C2 -i -CC
26 GRM = test.g
27 SRC = test.cpp \
28 Expr.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp main.cpp
30 OBJ = test.o \
31 Expr.o \
32 AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o main.o
33 ANTLR_SPAWN = test.cpp Expr.cpp \
34 Expr.h $(DLG_FILE) $(TOKENS)
35 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
36 #CCC=g++
37 CCC=CC
38
39 t : $(OBJ) $(SRC)
40 $(CCC) -o t $(CFLAGS) $(OBJ)
41
42 test.o : $(TOKENS) $(SCAN).h test.cpp
43 $(CCC) -c $(CFLAGS) -o test.o test.cpp
44
45 main.o : $(TOKENS) $(SCAN).h main.cpp
46 $(CCC) -c $(CFLAGS) -o main.o main.cpp
47
48 Expr.o : $(TOKENS) $(SCAN).h Expr.cpp Expr.h
49 $(CCC) -c $(CFLAGS) -o Expr.o Expr.cpp
50
51 $(SCAN).o : $(SCAN).cpp $(TOKENS)
52 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
53
54 $(ANTLR_SPAWN) : $(GRM)
55 $(ANTLR) $(AFLAGS) $(GRM)
56
57 $(DLG_SPAWN) : $(DLG_FILE)
58 $(DLG) $(DFLAGS) $(DLG_FILE)
59
60 AParser.o : $(ANTLR_H)/AParser.cpp
61 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
62
63 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
64 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
65
66 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
67 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
68
69 clean:
70 rm -f *.o core t
71
72 scrub:
73 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-22
contrib/pccts/testcpp/8/test.g less more
0 /* This is test.g which tests a simple DLG-based scanner, but with
1 * a main() in another file.
2 */
3
4 #header <<
5 #include "AToken.h" // what's ANTLRCommonToken look like?
6 typedef ANTLRCommonToken ANTLRToken; // by placing in header, Expr.h gets it
7 >>
8
9 #token "[\ \t\n]+" <<skip();>>
10 #token Eof "@"
11
12 class Expr { /* Define a grammar class */
13
14 e : IDENTIFIER NUMBER Eof
15 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
16 ;
17
18 }
19
20 #token IDENTIFIER "[a-z]+"
21 #token NUMBER "[0-9]+"
+0
-82
contrib/pccts/testcpp/9/makefile less more
0 #
1 # PCCTS makefile for: test.g
2 #
3 # Created from: ../../bin/genmk -CC -project t -class Expr test.g -trees
4 #
5 # PCCTS release 1.32
6 # Project: t
7 # C++ output
8 # DLG scanner
9 # ANTLR-defined token types
10 #
11 TOKENS = tokens.h
12 #
13 # The following filenames must be consistent with ANTLR/DLG flags
14 DLG_FILE = parser.dlg
15 ERR = err
16 HDR_FILE =
17 SCAN = DLGLexer
18 PCCTS = ../..
19 ANTLR_H = $(PCCTS)/h
20 BIN = $(PCCTS)/bin
21 ANTLR = $(BIN)/antlr
22 DLG = $(BIN)/dlg
23 CFLAGS = -I. -I$(ANTLR_H)
24 AFLAGS = -CC -gt
25 DFLAGS = -C2 -i -CC
26 GRM = test.g
27 SRC = test.cpp \
28 Expr.cpp \
29 $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp \
30 $(ANTLR_H)/ASTBase.cpp $(ANTLR_H)/PCCTSAST.cpp \
31 $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
32 OBJ = test.o \
33 Expr.o \
34 AParser.o DLexerBase.o \
35 ASTBase.o PCCTSAST.o \
36 ATokenBuffer.o $(SCAN).o
37 ANTLR_SPAWN = test.cpp Expr.cpp \
38 Expr.h $(DLG_FILE) $(TOKENS)
39 DLG_SPAWN = $(SCAN).cpp $(SCAN).h
40 #CCC=g++
41 CCC=CC
42
43 t : $(OBJ) $(SRC)
44 $(CCC) -o t $(CFLAGS) $(OBJ)
45
46 test.o : $(TOKENS) $(SCAN).h test.cpp
47 $(CCC) -c $(CFLAGS) -o test.o test.cpp
48
49 Expr.o : $(TOKENS) $(SCAN).h Expr.cpp Expr.h
50 $(CCC) -c $(CFLAGS) -o Expr.o Expr.cpp
51
52 $(SCAN).o : $(SCAN).cpp $(TOKENS)
53 $(CCC) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp
54
55 $(ANTLR_SPAWN) : $(GRM)
56 $(ANTLR) $(AFLAGS) $(GRM)
57
58 $(DLG_SPAWN) : $(DLG_FILE)
59 $(DLG) $(DFLAGS) $(DLG_FILE)
60
61 AParser.o : $(ANTLR_H)/AParser.cpp
62 $(CCC) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp
63
64 ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
65 $(CCC) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp
66
67 DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
68 $(CCC) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp
69
70 ASTBase.o : $(ANTLR_H)/ASTBase.cpp
71 $(CCC) -c $(CFLAGS) -o ASTBase.o $(ANTLR_H)/ASTBase.cpp
72
73 PCCTSAST.o : $(ANTLR_H)/PCCTSAST.cpp
74 $(CCC) -c $(CFLAGS) -o PCCTSAST.o $(ANTLR_H)/PCCTSAST.cpp
75
76
77 clean:
78 rm -f *.o core t
79
80 scrub:
81 rm -f *.o core t $(ANTLR_SPAWN) $(DLG_SPAWN)
+0
-54
contrib/pccts/testcpp/9/test.g less more
0 /* This is test.g which tests simple AST refs and construction */
1
2 /* Revised 2002-2-15: preorder_action prototype no longer
3 matched prototype of base class. (Eero Ivask,
4 Tallinn Technical University, Estonia).
5 */
6
7 <<
8 typedef ANTLRCommonToken ANTLRToken;
9 #include "DLGLexer.h"
10 #include "PBlackBox.h"
11
12 class AST : public ASTBase {
13 public:
14 ANTLRTokenPtr token;
15 AST(ANTLRTokenPtr t) { token = t; }
16 void preorder_action(void * clientData) {
17 char *s = token->getText();
18 printf(" %s", s);
19 }
20 };
21
22 int main()
23 {
24 ParserBlackBox<DLGLexer, Expr, ANTLRToken> p(stdin);
25 ASTBase *root = NULL;
26 p.parser()->e(&root);
27 root->preorder();
28 printf("\n");
29 root->destroy();
30 return 0;
31 }
32 >>
33
34 #token "[\ \t\n]+" <<skip();>>
35 #token Eof "@"
36
37 class Expr { /* Define a grammar class */
38
39 e : mult_expr ( ("\+"^|"\-"^) mult_expr )*
40 ;
41
42 mult_expr
43 : atom ( ("\*"^|"\/"^) atom )*
44 ;
45
46 atom: IDENTIFIER
47 | NUMBER
48 ;
49
50 }
51
52 #token IDENTIFIER "[a-z]+"
53 #token NUMBER "[0-9]+"
+0
-18
contrib/pccts/testcpp/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 EXTRA_DIST= \
4 1/makefile 1/test.g \
5 2/MyLexer.cpp 2/MyLexer.h 2/makefile 2/test.g \
6 3/MyLexer.cpp 3/MyLexer.h 3/makefile 3/mytokens.h 3/test.g \
7 4/makefile 4/mytokens.h 4/test.g \
8 5/input.h 5/makefile 5/test.g \
9 6/file1 6/file2 6/main.cpp 6/makefile 6/makefile2 6/test.g 6/test2.g \
10 7/makefile 7/test.g \
11 8/main.cpp 8/makefile 8/test.g \
12 9/makefile 9/test.g \
13 10/makefile 10/test.g \
14 11/input.h 11/makefile 11/test.g \
15 12/makefile 12/test.g \
16 13/makefile 13/test.g
17
+0
-470
contrib/pccts/testcpp/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17 am__make_running_with_option = \
18 case $${target_option-} in \
19 ?) ;; \
20 *) echo "am__make_running_with_option: internal error: invalid" \
21 "target option '$${target_option-}' specified" >&2; \
22 exit 1;; \
23 esac; \
24 has_opt=no; \
25 sane_makeflags=$$MAKEFLAGS; \
26 if $(am__is_gnu_make); then \
27 sane_makeflags=$$MFLAGS; \
28 else \
29 case $$MAKEFLAGS in \
30 *\\[\ \ ]*) \
31 bs=\\; \
32 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
33 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
34 esac; \
35 fi; \
36 skip_next=no; \
37 strip_trailopt () \
38 { \
39 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
40 }; \
41 for flg in $$sane_makeflags; do \
42 test $$skip_next = yes && { skip_next=no; continue; }; \
43 case $$flg in \
44 *=*|--*) continue;; \
45 -*I) strip_trailopt 'I'; skip_next=yes;; \
46 -*I?*) strip_trailopt 'I';; \
47 -*O) strip_trailopt 'O'; skip_next=yes;; \
48 -*O?*) strip_trailopt 'O';; \
49 -*l) strip_trailopt 'l'; skip_next=yes;; \
50 -*l?*) strip_trailopt 'l';; \
51 -[dEDm]) skip_next=yes;; \
52 -[JT]) skip_next=yes;; \
53 esac; \
54 case $$flg in \
55 *$$target_option*) has_opt=yes; break;; \
56 esac; \
57 done; \
58 test $$has_opt = yes
59 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
60 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
61 pkgdatadir = $(datadir)/@PACKAGE@
62 pkgincludedir = $(includedir)/@PACKAGE@
63 pkglibdir = $(libdir)/@PACKAGE@
64 pkglibexecdir = $(libexecdir)/@PACKAGE@
65 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
66 install_sh_DATA = $(install_sh) -c -m 644
67 install_sh_PROGRAM = $(install_sh) -c
68 install_sh_SCRIPT = $(install_sh) -c
69 INSTALL_HEADER = $(INSTALL_DATA)
70 transform = $(program_transform_name)
71 NORMAL_INSTALL = :
72 PRE_INSTALL = :
73 POST_INSTALL = :
74 NORMAL_UNINSTALL = :
75 PRE_UNINSTALL = :
76 POST_UNINSTALL = :
77 subdir = contrib/pccts/testcpp
78 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
79 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
80 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
81 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
82 $(ACLOCAL_M4)
83 mkinstalldirs = $(install_sh) -d
84 CONFIG_HEADER = $(top_builddir)/config.h
85 CONFIG_CLEAN_FILES =
86 CONFIG_CLEAN_VPATH_FILES =
87 AM_V_P = $(am__v_P_@AM_V@)
88 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
89 am__v_P_0 = false
90 am__v_P_1 = :
91 AM_V_GEN = $(am__v_GEN_@AM_V@)
92 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
93 am__v_GEN_0 = @echo " GEN " $@;
94 am__v_GEN_1 =
95 AM_V_at = $(am__v_at_@AM_V@)
96 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
97 am__v_at_0 = @
98 am__v_at_1 =
99 SOURCES =
100 DIST_SOURCES =
101 am__can_run_installinfo = \
102 case $$AM_UPDATE_INFO_DIR in \
103 n|no|NO) false;; \
104 *) (install-info --version) >/dev/null 2>&1;; \
105 esac
106 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
107 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
108 ACLOCAL = @ACLOCAL@
109 AET2_CFLAGS = @AET2_CFLAGS@
110 AET2_LDADD = @AET2_LDADD@
111 ALLOCA = @ALLOCA@
112 AMTAR = @AMTAR@
113 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
114 AUTOCONF = @AUTOCONF@
115 AUTOHEADER = @AUTOHEADER@
116 AUTOMAKE = @AUTOMAKE@
117 AWK = @AWK@
118 CC = @CC@
119 CCDEPMODE = @CCDEPMODE@
120 CFLAGS = @CFLAGS@
121 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
122 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
123 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
124 CPP = @CPP@
125 CPPFLAGS = @CPPFLAGS@
126 CXX = @CXX@
127 CXXDEPMODE = @CXXDEPMODE@
128 CXXFLAGS = @CXXFLAGS@
129 CYGPATH_W = @CYGPATH_W@
130 DEFS = @DEFS@
131 DEPDIR = @DEPDIR@
132 ECHO_C = @ECHO_C@
133 ECHO_N = @ECHO_N@
134 ECHO_T = @ECHO_T@
135 EGREP = @EGREP@
136 EXEEXT = @EXEEXT@
137 EXTDEBUG = @EXTDEBUG@
138 EXTDEBUG2 = @EXTDEBUG2@
139 EXTDEBUG3 = @EXTDEBUG3@
140 EXTDEBUG4 = @EXTDEBUG4@
141 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
142 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
143 FSDB_CFLAGS = @FSDB_CFLAGS@
144 FSDB_LDADD = @FSDB_LDADD@
145 GCONF_CFLAGS = @GCONF_CFLAGS@
146 GCONF_LIBS = @GCONF_LIBS@
147 GEDITTEST = @GEDITTEST@
148 GEDIT_CFLAGS = @GEDIT_CFLAGS@
149 GIO_CFLAGS = @GIO_CFLAGS@
150 GIO_LIBS = @GIO_LIBS@
151 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
152 GPERF = @GPERF@
153 GREP = @GREP@
154 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
155 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
156 GTK_CFLAGS = @GTK_CFLAGS@
157 GTK_CONFIG = @GTK_CONFIG@
158 GTK_LIBS = @GTK_LIBS@
159 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
160 GTK_MAC_LIBS = @GTK_MAC_LIBS@
161 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
162 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
163 INSTALL = @INSTALL@
164 INSTALL_DATA = @INSTALL_DATA@
165 INSTALL_PROGRAM = @INSTALL_PROGRAM@
166 INSTALL_SCRIPT = @INSTALL_SCRIPT@
167 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
168 LDFLAGS = @LDFLAGS@
169 LEX = @LEX@
170 LEXLIB = @LEXLIB@
171 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
172 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
173 LIBBZ2_DIR = @LIBBZ2_DIR@
174 LIBBZ2_LDADD = @LIBBZ2_LDADD@
175 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
176 LIBJUDY_LDADD = @LIBJUDY_LDADD@
177 LIBOBJS = @LIBOBJS@
178 LIBS = @LIBS@
179 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
180 LIBXZ_LDADD = @LIBXZ_LDADD@
181 LIBZ_CFLAGS = @LIBZ_CFLAGS@
182 LIBZ_DIR = @LIBZ_DIR@
183 LIBZ_LDADD = @LIBZ_LDADD@
184 LTLIBOBJS = @LTLIBOBJS@
185 MAINT = @MAINT@
186 MAKEINFO = @MAKEINFO@
187 MINGW_LDADD = @MINGW_LDADD@
188 MKDIR_P = @MKDIR_P@
189 OBJEXT = @OBJEXT@
190 PACKAGE = @PACKAGE@
191 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
192 PACKAGE_NAME = @PACKAGE_NAME@
193 PACKAGE_STRING = @PACKAGE_STRING@
194 PACKAGE_TARNAME = @PACKAGE_TARNAME@
195 PACKAGE_URL = @PACKAGE_URL@
196 PACKAGE_VERSION = @PACKAGE_VERSION@
197 PATH_SEPARATOR = @PATH_SEPARATOR@
198 PKG_CONFIG = @PKG_CONFIG@
199 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
200 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
201 POW_LIB = @POW_LIB@
202 RANLIB = @RANLIB@
203 RPC_CFLAGS = @RPC_CFLAGS@
204 RPC_LDADD = @RPC_LDADD@
205 SET_MAKE = @SET_MAKE@
206 SHELL = @SHELL@
207 STRIP = @STRIP@
208 STRUCT_PACK = @STRUCT_PACK@
209 TCL_DEFADD = @TCL_DEFADD@
210 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
211 TCL_LDADD = @TCL_LDADD@
212 TCL_LIB_SPEC = @TCL_LIB_SPEC@
213 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
214 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
215 TIRPC_CFLAGS = @TIRPC_CFLAGS@
216 TIRPC_LIBS = @TIRPC_LIBS@
217 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
218 TK_LDADD = @TK_LDADD@
219 TK_LIB_SPEC = @TK_LIB_SPEC@
220 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
221 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
222 VERSION = @VERSION@
223 XDGDATADIR = @XDGDATADIR@
224 abs_builddir = @abs_builddir@
225 abs_srcdir = @abs_srcdir@
226 abs_top_builddir = @abs_top_builddir@
227 abs_top_srcdir = @abs_top_srcdir@
228 ac_ct_CC = @ac_ct_CC@
229 ac_ct_CXX = @ac_ct_CXX@
230 am__include = @am__include@
231 am__leading_dot = @am__leading_dot@
232 am__quote = @am__quote@
233 am__tar = @am__tar@
234 am__untar = @am__untar@
235 bindir = @bindir@
236 build_alias = @build_alias@
237 builddir = @builddir@
238 datadir = @datadir@
239 datarootdir = @datarootdir@
240 docdir = @docdir@
241 dvidir = @dvidir@
242 exec_prefix = @exec_prefix@
243 gsettingsschemadir = @gsettingsschemadir@
244 host_alias = @host_alias@
245 htmldir = @htmldir@
246 includedir = @includedir@
247 infodir = @infodir@
248 install_sh = @install_sh@
249 libdir = @libdir@
250 libexecdir = @libexecdir@
251 localedir = @localedir@
252 localstatedir = @localstatedir@
253 mandir = @mandir@
254 mkdir_p = @mkdir_p@
255 oldincludedir = @oldincludedir@
256 pdfdir = @pdfdir@
257 prefix = @prefix@
258 program_transform_name = @program_transform_name@
259 psdir = @psdir@
260 sbindir = @sbindir@
261 sharedstatedir = @sharedstatedir@
262 srcdir = @srcdir@
263 sysconfdir = @sysconfdir@
264 target_alias = @target_alias@
265 top_build_prefix = @top_build_prefix@
266 top_builddir = @top_builddir@
267 top_srcdir = @top_srcdir@
268 EXTRA_DIST = \
269 1/makefile 1/test.g \
270 2/MyLexer.cpp 2/MyLexer.h 2/makefile 2/test.g \
271 3/MyLexer.cpp 3/MyLexer.h 3/makefile 3/mytokens.h 3/test.g \
272 4/makefile 4/mytokens.h 4/test.g \
273 5/input.h 5/makefile 5/test.g \
274 6/file1 6/file2 6/main.cpp 6/makefile 6/makefile2 6/test.g 6/test2.g \
275 7/makefile 7/test.g \
276 8/main.cpp 8/makefile 8/test.g \
277 9/makefile 9/test.g \
278 10/makefile 10/test.g \
279 11/input.h 11/makefile 11/test.g \
280 12/makefile 12/test.g \
281 13/makefile 13/test.g
282
283 all: all-am
284
285 .SUFFIXES:
286 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
287 @for dep in $?; do \
288 case '$(am__configure_deps)' in \
289 *$$dep*) \
290 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
291 && { if test -f $@; then exit 0; else break; fi; }; \
292 exit 1;; \
293 esac; \
294 done; \
295 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/pccts/testcpp/Makefile'; \
296 $(am__cd) $(top_srcdir) && \
297 $(AUTOMAKE) --foreign contrib/pccts/testcpp/Makefile
298 .PRECIOUS: Makefile
299 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
300 @case '$?' in \
301 *config.status*) \
302 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
303 *) \
304 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
305 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
306 esac;
307
308 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
309 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
310
311 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
312 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
313 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
314 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
315 $(am__aclocal_m4_deps):
316 tags TAGS:
317
318 ctags CTAGS:
319
320 cscope cscopelist:
321
322
323 distdir: $(DISTFILES)
324 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
325 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
326 list='$(DISTFILES)'; \
327 dist_files=`for file in $$list; do echo $$file; done | \
328 sed -e "s|^$$srcdirstrip/||;t" \
329 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
330 case $$dist_files in \
331 */*) $(MKDIR_P) `echo "$$dist_files" | \
332 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
333 sort -u` ;; \
334 esac; \
335 for file in $$dist_files; do \
336 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
337 if test -d $$d/$$file; then \
338 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
339 if test -d "$(distdir)/$$file"; then \
340 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
341 fi; \
342 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
343 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
344 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
345 fi; \
346 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
347 else \
348 test -f "$(distdir)/$$file" \
349 || cp -p $$d/$$file "$(distdir)/$$file" \
350 || exit 1; \
351 fi; \
352 done
353 check-am: all-am
354 check: check-am
355 all-am: Makefile
356 installdirs:
357 install: install-am
358 install-exec: install-exec-am
359 install-data: install-data-am
360 uninstall: uninstall-am
361
362 install-am: all-am
363 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
364
365 installcheck: installcheck-am
366 install-strip:
367 if test -z '$(STRIP)'; then \
368 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
369 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
370 install; \
371 else \
372 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
373 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
374 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
375 fi
376 mostlyclean-generic:
377
378 clean-generic:
379
380 distclean-generic:
381 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
382 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
383
384 maintainer-clean-generic:
385 @echo "This command is intended for maintainers to use"
386 @echo "it deletes files that may require special tools to rebuild."
387 clean: clean-am
388
389 clean-am: clean-generic mostlyclean-am
390
391 distclean: distclean-am
392 -rm -f Makefile
393 distclean-am: clean-am distclean-generic
394
395 dvi: dvi-am
396
397 dvi-am:
398
399 html: html-am
400
401 html-am:
402
403 info: info-am
404
405 info-am:
406
407 install-data-am:
408
409 install-dvi: install-dvi-am
410
411 install-dvi-am:
412
413 install-exec-am:
414
415 install-html: install-html-am
416
417 install-html-am:
418
419 install-info: install-info-am
420
421 install-info-am:
422
423 install-man:
424
425 install-pdf: install-pdf-am
426
427 install-pdf-am:
428
429 install-ps: install-ps-am
430
431 install-ps-am:
432
433 installcheck-am:
434
435 maintainer-clean: maintainer-clean-am
436 -rm -f Makefile
437 maintainer-clean-am: distclean-am maintainer-clean-generic
438
439 mostlyclean: mostlyclean-am
440
441 mostlyclean-am: mostlyclean-generic
442
443 pdf: pdf-am
444
445 pdf-am:
446
447 ps: ps-am
448
449 ps-am:
450
451 uninstall-am:
452
453 .MAKE: install-am install-strip
454
455 .PHONY: all all-am check check-am clean clean-generic cscopelist-am \
456 ctags-am distclean distclean-generic distdir dvi dvi-am html \
457 html-am info info-am install install-am install-data \
458 install-data-am install-dvi install-dvi-am install-exec \
459 install-exec-am install-html install-html-am install-info \
460 install-info-am install-man install-pdf install-pdf-am \
461 install-ps install-ps-am install-strip installcheck \
462 installcheck-am installdirs maintainer-clean \
463 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
464 pdf-am ps ps-am tags-am uninstall uninstall-am
465
466
467 # Tell versions [3.59,3.63) of GNU make to not export all variables.
468 # Otherwise a system limit (for SysV at least) may be exceeded.
469 .NOEXPORT:
3131 AM_CFLAGS= -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/src/helpers \
3232 $(GTK_CFLAGS) $(LIBZ_CFLAGS) $(LIBBZ2_CFLAGS) $(LIBLZMA_CFLAGS) \
3333 $(LIBFST_CFLAGS) $(AET2_CFLAGS) $(LIBJUDY_CFLAGS) \
34 $(GTK_MAC_CFLAGS) $(GCONF_CFLAGS)
34 $(GTK_MAC_CFLAGS) $(GCONF_CFLAGS) -DYY_NO_INPUT
3535
3636 definehash.c: vpp_keyword.gperf
3737 $(GPERF) -C -I -N is_builtin_define $(srcdir)/vpp_keyword.gperf >definehash.c
399399 AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/src/helpers \
400400 $(GTK_CFLAGS) $(LIBZ_CFLAGS) $(LIBBZ2_CFLAGS) $(LIBLZMA_CFLAGS) \
401401 $(LIBFST_CFLAGS) $(AET2_CFLAGS) $(LIBJUDY_CFLAGS) \
402 $(GTK_MAC_CFLAGS) $(GCONF_CFLAGS)
402 $(GTK_MAC_CFLAGS) $(GCONF_CFLAGS) -DYY_NO_INPUT
403403
404404 BUILT_SOURCES = definehash.c
405405 EXTRA_DIST = vpp_keyword.gperf
19431943 log_text(text, NULL, "Design unit ");
19441944 log_text_bold(text, NULL, design_unit);
19451945 {
1946 char buf[128];
1946 char buf[8192];
19471947
19481948 s_line = s_line_find > 0 ? s_line_find : s_line;
19491949 e_line = e_line_find > 0 ? e_line_find : e_line;
972972 * as published by the Free Software Foundation; either version 2
973973 * of the License, or (at your option) any later version.
974974 */
975 #line 11 "vlex.l"
975 #line 13 "vlex.l"
976976
977977 /*
978978 * vlex.l
10871087 #endif
10881088 #endif
10891089
1090 static void yyunput (int c,char *buf_ptr );
1091
10921090 #ifndef yytext_ptr
10931091 static void yy_flex_strncpy (char *,yyconst char *,int );
10941092 #endif
12101208 register char *yy_cp, *yy_bp;
12111209 register int yy_act;
12121210
1213 #line 67 "vlex.l"
1214
1215 #line 1217 "vlex.c"
1211 #line 69 "vlex.l"
1212
1213 #line 1215 "vlex.c"
12161214
12171215 if ( !(yy_init) )
12181216 {
12971295
12981296 case 1:
12991297 YY_RULE_SETUP
1300 #line 68 "vlex.l"
1298 #line 70 "vlex.l"
13011299 { BEGIN CMNT; return V_CMT; }
13021300 YY_BREAK
13031301 case 2:
1304 YY_RULE_SETUP
1305 #line 69 "vlex.l"
1306 { return V_CMT; }
1307 YY_BREAK
1308 case 3:
1309 YY_RULE_SETUP
1310 #line 70 "vlex.l"
1311 { BEGIN INITIAL; return V_CMT; }
1312 YY_BREAK
1313 case 4:
13141302 YY_RULE_SETUP
13151303 #line 71 "vlex.l"
13161304 { return V_CMT; }
13171305 YY_BREAK
1306 case 3:
1307 YY_RULE_SETUP
1308 #line 72 "vlex.l"
1309 { BEGIN INITIAL; return V_CMT; }
1310 YY_BREAK
1311 case 4:
1312 YY_RULE_SETUP
1313 #line 73 "vlex.l"
1314 { return V_CMT; }
1315 YY_BREAK
13181316 case 5:
13191317 YY_RULE_SETUP
1320 #line 72 "vlex.l"
1318 #line 74 "vlex.l"
13211319 { return V_CMT; }
13221320 YY_BREAK
13231321 case 6:
13241322 /* rule 6 can match eol */
13251323 YY_RULE_SETUP
1326 #line 73 "vlex.l"
1324 #line 75 "vlex.l"
13271325 { my_yylineno++; return V_CMT; }
13281326 YY_BREAK
13291327 case 7:
13301328 YY_RULE_SETUP
1331 #line 75 "vlex.l"
1329 #line 77 "vlex.l"
13321330 { return V_KW; }
13331331 YY_BREAK
13341332 case 8:
13351333 YY_RULE_SETUP
1336 #line 76 "vlex.l"
1334 #line 78 "vlex.l"
13371335 { return V_KW; }
13381336 YY_BREAK
13391337 case 9:
13401338 YY_RULE_SETUP
1341 #line 77 "vlex.l"
1339 #line 79 "vlex.l"
13421340 { return V_KW; }
13431341 YY_BREAK
13441342 case 10:
13451343 YY_RULE_SETUP
1346 #line 78 "vlex.l"
1344 #line 80 "vlex.l"
13471345 { return V_KW; }
13481346 YY_BREAK
13491347 case 11:
13501348 YY_RULE_SETUP
1351 #line 79 "vlex.l"
1349 #line 81 "vlex.l"
13521350 { return V_KW; }
13531351 YY_BREAK
13541352 case 12:
13551353 YY_RULE_SETUP
1356 #line 80 "vlex.l"
1354 #line 82 "vlex.l"
13571355 { return V_KW; }
13581356 YY_BREAK
13591357 case 13:
13601358 YY_RULE_SETUP
1361 #line 81 "vlex.l"
1359 #line 83 "vlex.l"
13621360 { return V_KW; }
13631361 YY_BREAK
13641362 case 14:
13651363 YY_RULE_SETUP
1366 #line 82 "vlex.l"
1364 #line 84 "vlex.l"
13671365 { return V_KW; }
13681366 YY_BREAK
13691367 case 15:
13701368 YY_RULE_SETUP
1371 #line 83 "vlex.l"
1369 #line 85 "vlex.l"
13721370 { return V_KW; }
13731371 YY_BREAK
13741372 case 16:
13751373 YY_RULE_SETUP
1376 #line 84 "vlex.l"
1374 #line 86 "vlex.l"
13771375 { return V_KW; }
13781376 YY_BREAK
13791377 case 17:
13801378 YY_RULE_SETUP
1381 #line 85 "vlex.l"
1379 #line 87 "vlex.l"
13821380 { return V_KW; }
13831381 YY_BREAK
13841382 case 18:
13851383 YY_RULE_SETUP
1386 #line 86 "vlex.l"
1384 #line 88 "vlex.l"
13871385 { return V_KW; }
13881386 YY_BREAK
13891387 case 19:
13901388 YY_RULE_SETUP
1391 #line 87 "vlex.l"
1389 #line 89 "vlex.l"
13921390 { return V_KW; }
13931391 YY_BREAK
13941392 case 20:
13951393 YY_RULE_SETUP
1396 #line 88 "vlex.l"
1394 #line 90 "vlex.l"
13971395 { return V_KW; }
13981396 YY_BREAK
13991397 case 21:
14001398 YY_RULE_SETUP
1401 #line 89 "vlex.l"
1399 #line 91 "vlex.l"
14021400 { return V_KW; }
14031401 YY_BREAK
14041402 case 22:
14051403 YY_RULE_SETUP
1406 #line 90 "vlex.l"
1404 #line 92 "vlex.l"
14071405 { return V_KW; }
14081406 YY_BREAK
14091407 case 23:
14101408 YY_RULE_SETUP
1411 #line 91 "vlex.l"
1409 #line 93 "vlex.l"
14121410 { return V_KW; }
14131411 YY_BREAK
14141412 case 24:
14151413 YY_RULE_SETUP
1416 #line 92 "vlex.l"
1414 #line 94 "vlex.l"
14171415 { return V_KW; }
14181416 YY_BREAK
14191417 case 25:
14201418 YY_RULE_SETUP
1421 #line 93 "vlex.l"
1419 #line 95 "vlex.l"
14221420 { return V_KW; }
14231421 YY_BREAK
14241422 case 26:
14251423 YY_RULE_SETUP
1426 #line 94 "vlex.l"
1424 #line 96 "vlex.l"
14271425 { return V_KW; }
14281426 YY_BREAK
14291427 case 27:
14301428 YY_RULE_SETUP
1431 #line 95 "vlex.l"
1429 #line 97 "vlex.l"
14321430 { return V_KW; }
14331431 YY_BREAK
14341432 case 28:
14351433 YY_RULE_SETUP
1436 #line 96 "vlex.l"
1434 #line 98 "vlex.l"
14371435 { return V_KW; }
14381436 YY_BREAK
14391437 case 29:
14401438 YY_RULE_SETUP
1441 #line 97 "vlex.l"
1439 #line 99 "vlex.l"
14421440 { return V_KW; }
14431441 YY_BREAK
14441442 case 30:
14451443 YY_RULE_SETUP
1446 #line 98 "vlex.l"
1444 #line 100 "vlex.l"
14471445 { return V_KW; }
14481446 YY_BREAK
14491447 case 31:
14501448 YY_RULE_SETUP
1451 #line 99 "vlex.l"
1449 #line 101 "vlex.l"
14521450 { return V_KW; }
14531451 YY_BREAK
14541452 case 32:
14551453 YY_RULE_SETUP
1456 #line 100 "vlex.l"
1454 #line 102 "vlex.l"
14571455 { return V_KW; }
14581456 YY_BREAK
14591457 case 33:
14601458 YY_RULE_SETUP
1461 #line 101 "vlex.l"
1459 #line 103 "vlex.l"
14621460 { return V_KW; }
14631461 YY_BREAK
14641462 case 34:
14651463 YY_RULE_SETUP
1466 #line 102 "vlex.l"
1464 #line 104 "vlex.l"
14671465 { return V_KW; }
14681466 YY_BREAK
14691467 case 35:
14701468 YY_RULE_SETUP
1471 #line 103 "vlex.l"
1469 #line 105 "vlex.l"
14721470 { return V_KW; }
14731471 YY_BREAK
14741472 case 36:
14751473 YY_RULE_SETUP
1476 #line 104 "vlex.l"
1474 #line 106 "vlex.l"
14771475 { return V_KW; }
14781476 YY_BREAK
14791477 case 37:
14801478 YY_RULE_SETUP
1481 #line 105 "vlex.l"
1479 #line 107 "vlex.l"
14821480 { return V_KW; }
14831481 YY_BREAK
14841482 case 38:
14851483 YY_RULE_SETUP
1486 #line 106 "vlex.l"
1484 #line 108 "vlex.l"
14871485 { return V_KW; }
14881486 YY_BREAK
14891487 case 39:
14901488 YY_RULE_SETUP
1491 #line 107 "vlex.l"
1489 #line 109 "vlex.l"
14921490 { return V_KW; }
14931491 YY_BREAK
14941492 case 40:
14951493 YY_RULE_SETUP
1496 #line 108 "vlex.l"
1494 #line 110 "vlex.l"
14971495 { return V_KW; }
14981496 YY_BREAK
14991497 case 41:
15001498 YY_RULE_SETUP
1501 #line 109 "vlex.l"
1499 #line 111 "vlex.l"
15021500 { return V_KW; }
15031501 YY_BREAK
15041502 case 42:
15051503 YY_RULE_SETUP
1506 #line 110 "vlex.l"
1504 #line 112 "vlex.l"
15071505 { return V_KW; }
15081506 YY_BREAK
15091507 case 43:
15101508 YY_RULE_SETUP
1511 #line 111 "vlex.l"
1509 #line 113 "vlex.l"
15121510 { return V_KW; }
15131511 YY_BREAK
15141512 case 44:
15151513 YY_RULE_SETUP
1516 #line 112 "vlex.l"
1514 #line 114 "vlex.l"
15171515 { return V_KW; }
15181516 YY_BREAK
15191517 case 45:
15201518 YY_RULE_SETUP
1521 #line 113 "vlex.l"
1519 #line 115 "vlex.l"
15221520 { return V_KW; }
15231521 YY_BREAK
15241522 case 46:
15251523 YY_RULE_SETUP
1526 #line 114 "vlex.l"
1524 #line 116 "vlex.l"
15271525 { return V_KW; }
15281526 YY_BREAK
15291527 case 47:
15301528 YY_RULE_SETUP
1531 #line 115 "vlex.l"
1529 #line 117 "vlex.l"
15321530 { return V_KW; }
15331531 YY_BREAK
15341532 case 48:
15351533 YY_RULE_SETUP
1536 #line 116 "vlex.l"
1534 #line 118 "vlex.l"
15371535 { return V_KW; }
15381536 YY_BREAK
15391537 case 49:
15401538 YY_RULE_SETUP
1541 #line 117 "vlex.l"
1539 #line 119 "vlex.l"
15421540 { return V_KW; }
15431541 YY_BREAK
15441542 case 50:
15451543 YY_RULE_SETUP
1546 #line 118 "vlex.l"
1544 #line 120 "vlex.l"
15471545 { return V_KW; }
15481546 YY_BREAK
15491547 case 51:
15501548 YY_RULE_SETUP
1551 #line 119 "vlex.l"
1549 #line 121 "vlex.l"
15521550 { return V_KW; }
15531551 YY_BREAK
15541552 case 52:
15551553 YY_RULE_SETUP
1556 #line 120 "vlex.l"
1554 #line 122 "vlex.l"
15571555 { return V_KW; }
15581556 YY_BREAK
15591557 case 53:
15601558 YY_RULE_SETUP
1561 #line 121 "vlex.l"
1559 #line 123 "vlex.l"
15621560 { return V_KW; }
15631561 YY_BREAK
15641562 case 54:
15651563 YY_RULE_SETUP
1566 #line 122 "vlex.l"
1564 #line 124 "vlex.l"
15671565 { return V_KW; }
15681566 YY_BREAK
15691567 case 55:
15701568 YY_RULE_SETUP
1571 #line 123 "vlex.l"
1569 #line 125 "vlex.l"
15721570 { return V_KW; }
15731571 YY_BREAK
15741572 case 56:
15751573 YY_RULE_SETUP
1576 #line 124 "vlex.l"
1574 #line 126 "vlex.l"
15771575 { return V_KW; }
15781576 YY_BREAK
15791577 case 57:
15801578 YY_RULE_SETUP
1581 #line 125 "vlex.l"
1579 #line 127 "vlex.l"
15821580 { return V_KW; }
15831581 YY_BREAK
15841582 case 58:
15851583 YY_RULE_SETUP
1586 #line 126 "vlex.l"
1584 #line 128 "vlex.l"
15871585 { return V_KW; }
15881586 YY_BREAK
15891587 case 59:
15901588 YY_RULE_SETUP
1591 #line 127 "vlex.l"
1589 #line 129 "vlex.l"
15921590 { return V_KW; }
15931591 YY_BREAK
15941592 case 60:
15951593 YY_RULE_SETUP
1596 #line 128 "vlex.l"
1594 #line 130 "vlex.l"
15971595 { return V_KW; }
15981596 YY_BREAK
15991597 case 61:
16001598 YY_RULE_SETUP
1601 #line 129 "vlex.l"
1599 #line 131 "vlex.l"
16021600 { return V_KW; }
16031601 YY_BREAK
16041602 case 62:
16051603 YY_RULE_SETUP
1606 #line 130 "vlex.l"
1604 #line 132 "vlex.l"
16071605 { return V_KW; }
16081606 YY_BREAK
16091607 case 63:
16101608 YY_RULE_SETUP
1611 #line 131 "vlex.l"
1609 #line 133 "vlex.l"
16121610 { return V_KW; }
16131611 YY_BREAK
16141612 case 64:
16151613 YY_RULE_SETUP
1616 #line 132 "vlex.l"
1614 #line 134 "vlex.l"
16171615 { return V_KW; }
16181616 YY_BREAK
16191617 case 65:
16201618 YY_RULE_SETUP
1621 #line 133 "vlex.l"
1619 #line 135 "vlex.l"
16221620 { return V_KW; }
16231621 YY_BREAK
16241622 case 66:
16251623 YY_RULE_SETUP
1626 #line 134 "vlex.l"
1624 #line 136 "vlex.l"
16271625 { return V_KW; }
16281626 YY_BREAK
16291627 case 67:
16301628 YY_RULE_SETUP
1631 #line 135 "vlex.l"
1629 #line 137 "vlex.l"
16321630 { return V_KW; }
16331631 YY_BREAK
16341632 case 68:
16351633 YY_RULE_SETUP
1636 #line 136 "vlex.l"
1634 #line 138 "vlex.l"
16371635 { return V_KW; }
16381636 YY_BREAK
16391637 case 69:
16401638 YY_RULE_SETUP
1641 #line 137 "vlex.l"
1639 #line 139 "vlex.l"
16421640 { return V_KW; }
16431641 YY_BREAK
16441642 case 70:
16451643 YY_RULE_SETUP
1646 #line 138 "vlex.l"
1644 #line 140 "vlex.l"
16471645 { return V_KW; }
16481646 YY_BREAK
16491647 case 71:
16501648 YY_RULE_SETUP
1651 #line 139 "vlex.l"
1649 #line 141 "vlex.l"
16521650 { return V_KW; }
16531651 YY_BREAK
16541652 case 72:
16551653 YY_RULE_SETUP
1656 #line 140 "vlex.l"
1654 #line 142 "vlex.l"
16571655 { return V_KW; }
16581656 YY_BREAK
16591657 case 73:
16601658 YY_RULE_SETUP
1661 #line 141 "vlex.l"
1659 #line 143 "vlex.l"
16621660 { return V_KW; }
16631661 YY_BREAK
16641662 case 74:
16651663 YY_RULE_SETUP
1666 #line 142 "vlex.l"
1664 #line 144 "vlex.l"
16671665 { return V_KW; }
16681666 YY_BREAK
16691667 case 75:
16701668 YY_RULE_SETUP
1671 #line 143 "vlex.l"
1669 #line 145 "vlex.l"
16721670 { return V_KW; }
16731671 YY_BREAK
16741672 case 76:
16751673 YY_RULE_SETUP
1676 #line 144 "vlex.l"
1674 #line 146 "vlex.l"
16771675 { return V_KW; }
16781676 YY_BREAK
16791677 case 77:
16801678 YY_RULE_SETUP
1681 #line 145 "vlex.l"
1679 #line 147 "vlex.l"
16821680 { return V_KW; }
16831681 YY_BREAK
16841682 case 78:
16851683 YY_RULE_SETUP
1686 #line 146 "vlex.l"
1684 #line 148 "vlex.l"
16871685 { return V_KW; }
16881686 YY_BREAK
16891687 case 79:
16901688 YY_RULE_SETUP
1691 #line 147 "vlex.l"
1689 #line 149 "vlex.l"
16921690 { return V_KW; }
16931691 YY_BREAK
16941692 case 80:
16951693 YY_RULE_SETUP
1696 #line 148 "vlex.l"
1694 #line 150 "vlex.l"
16971695 { return V_KW; }
16981696 YY_BREAK
16991697 case 81:
17001698 YY_RULE_SETUP
1701 #line 149 "vlex.l"
1699 #line 151 "vlex.l"
17021700 { return V_KW; }
17031701 YY_BREAK
17041702 case 82:
17051703 YY_RULE_SETUP
1706 #line 150 "vlex.l"
1704 #line 152 "vlex.l"
17071705 { return V_KW; }
17081706 YY_BREAK
17091707 case 83:
17101708 YY_RULE_SETUP
1711 #line 151 "vlex.l"
1709 #line 153 "vlex.l"
17121710 { return V_KW; }
17131711 YY_BREAK
17141712 case 84:
17151713 YY_RULE_SETUP
1716 #line 152 "vlex.l"
1714 #line 154 "vlex.l"
17171715 { return V_KW; }
17181716 YY_BREAK
17191717 case 85:
17201718 YY_RULE_SETUP
1721 #line 153 "vlex.l"
1719 #line 155 "vlex.l"
17221720 { return V_KW; }
17231721 YY_BREAK
17241722 case 86:
17251723 YY_RULE_SETUP
1726 #line 154 "vlex.l"
1724 #line 156 "vlex.l"
17271725 { return V_KW; }
17281726 YY_BREAK
17291727 case 87:
17301728 YY_RULE_SETUP
1731 #line 155 "vlex.l"
1729 #line 157 "vlex.l"
17321730 { return V_KW; }
17331731 YY_BREAK
17341732 case 88:
17351733 YY_RULE_SETUP
1736 #line 156 "vlex.l"
1734 #line 158 "vlex.l"
17371735 { return V_KW; }
17381736 YY_BREAK
17391737 case 89:
17401738 YY_RULE_SETUP
1741 #line 157 "vlex.l"
1739 #line 159 "vlex.l"
17421740 { return V_KW; }
17431741 YY_BREAK
17441742 case 90:
17451743 YY_RULE_SETUP
1746 #line 158 "vlex.l"
1744 #line 160 "vlex.l"
17471745 { return V_KW; }
17481746 YY_BREAK
17491747 case 91:
17501748 YY_RULE_SETUP
1751 #line 159 "vlex.l"
1749 #line 161 "vlex.l"
17521750 { return V_KW; }
17531751 YY_BREAK
17541752 case 92:
17551753 YY_RULE_SETUP
1756 #line 160 "vlex.l"
1754 #line 162 "vlex.l"
17571755 { return V_KW; }
17581756 YY_BREAK
17591757 case 93:
17601758 YY_RULE_SETUP
1761 #line 161 "vlex.l"
1759 #line 163 "vlex.l"
17621760 { return V_KW; }
17631761 YY_BREAK
17641762 case 94:
17651763 YY_RULE_SETUP
1766 #line 162 "vlex.l"
1764 #line 164 "vlex.l"
17671765 { return V_KW; }
17681766 YY_BREAK
17691767 case 95:
17701768 YY_RULE_SETUP
1771 #line 164 "vlex.l"
1769 #line 166 "vlex.l"
17721770 { return V_KW; }
17731771 YY_BREAK
17741772 case 96:
17751773 YY_RULE_SETUP
1776 #line 165 "vlex.l"
1774 #line 167 "vlex.l"
17771775 { return V_KW; }
17781776 YY_BREAK
17791777 case 97:
17801778 YY_RULE_SETUP
1781 #line 166 "vlex.l"
1779 #line 168 "vlex.l"
17821780 { return V_KW; }
17831781 YY_BREAK
17841782 case 98:
17851783 YY_RULE_SETUP
1786 #line 167 "vlex.l"
1784 #line 169 "vlex.l"
17871785 { return V_KW; }
17881786 YY_BREAK
17891787 case 99:
17901788 YY_RULE_SETUP
1791 #line 168 "vlex.l"
1789 #line 170 "vlex.l"
17921790 { return V_KW; }
17931791 YY_BREAK
17941792 case 100:
17951793 YY_RULE_SETUP
1796 #line 169 "vlex.l"
1794 #line 171 "vlex.l"
17971795 { return V_KW; }
17981796 YY_BREAK
17991797 case 101:
18001798 YY_RULE_SETUP
1801 #line 170 "vlex.l"
1799 #line 172 "vlex.l"
18021800 { return V_KW; }
18031801 YY_BREAK
18041802 case 102:
18051803 YY_RULE_SETUP
1806 #line 171 "vlex.l"
1804 #line 173 "vlex.l"
18071805 { return V_KW; }
18081806 YY_BREAK
18091807 case 103:
1810 YY_RULE_SETUP
1811 #line 173 "vlex.l"
1812 { return V_KW_2005; }
1813 YY_BREAK
1814 case 104:
1815 YY_RULE_SETUP
1816 #line 174 "vlex.l"
1817 { return V_KW_2005; }
1818 YY_BREAK
1819 case 105:
18201808 YY_RULE_SETUP
18211809 #line 175 "vlex.l"
18221810 { return V_KW_2005; }
18231811 YY_BREAK
1824 case 106:
1812 case 104:
18251813 YY_RULE_SETUP
18261814 #line 176 "vlex.l"
18271815 { return V_KW_2005; }
18281816 YY_BREAK
1829 case 107:
1817 case 105:
18301818 YY_RULE_SETUP
18311819 #line 177 "vlex.l"
18321820 { return V_KW_2005; }
18331821 YY_BREAK
1834 case 108:
1822 case 106:
18351823 YY_RULE_SETUP
18361824 #line 178 "vlex.l"
18371825 { return V_KW_2005; }
18381826 YY_BREAK
1839 case 109:
1827 case 107:
18401828 YY_RULE_SETUP
18411829 #line 179 "vlex.l"
18421830 { return V_KW_2005; }
18431831 YY_BREAK
1844 case 110:
1832 case 108:
18451833 YY_RULE_SETUP
18461834 #line 180 "vlex.l"
18471835 { return V_KW_2005; }
18481836 YY_BREAK
1849 case 111:
1837 case 109:
18501838 YY_RULE_SETUP
18511839 #line 181 "vlex.l"
18521840 { return V_KW_2005; }
18531841 YY_BREAK
1854 case 112:
1842 case 110:
18551843 YY_RULE_SETUP
18561844 #line 182 "vlex.l"
18571845 { return V_KW_2005; }
18581846 YY_BREAK
1859 case 113:
1847 case 111:
18601848 YY_RULE_SETUP
18611849 #line 183 "vlex.l"
18621850 { return V_KW_2005; }
18631851 YY_BREAK
1864 case 114:
1852 case 112:
18651853 YY_RULE_SETUP
18661854 #line 184 "vlex.l"
18671855 { return V_KW_2005; }
18681856 YY_BREAK
1869 case 115:
1857 case 113:
18701858 YY_RULE_SETUP
18711859 #line 185 "vlex.l"
18721860 { return V_KW_2005; }
18731861 YY_BREAK
1874 case 116:
1862 case 114:
18751863 YY_RULE_SETUP
18761864 #line 186 "vlex.l"
18771865 { return V_KW_2005; }
18781866 YY_BREAK
1879 case 117:
1867 case 115:
18801868 YY_RULE_SETUP
18811869 #line 187 "vlex.l"
18821870 { return V_KW_2005; }
18831871 YY_BREAK
1884 case 118:
1872 case 116:
18851873 YY_RULE_SETUP
18861874 #line 188 "vlex.l"
18871875 { return V_KW_2005; }
18881876 YY_BREAK
1889 case 119:
1877 case 117:
18901878 YY_RULE_SETUP
18911879 #line 189 "vlex.l"
18921880 { return V_KW_2005; }
18931881 YY_BREAK
1894 case 120:
1882 case 118:
18951883 YY_RULE_SETUP
18961884 #line 190 "vlex.l"
18971885 { return V_KW_2005; }
18981886 YY_BREAK
1899 case 121:
1887 case 119:
19001888 YY_RULE_SETUP
19011889 #line 191 "vlex.l"
19021890 { return V_KW_2005; }
19031891 YY_BREAK
1904 case 122:
1892 case 120:
19051893 YY_RULE_SETUP
19061894 #line 192 "vlex.l"
19071895 { return V_KW_2005; }
19081896 YY_BREAK
1909 case 123:
1897 case 121:
19101898 YY_RULE_SETUP
19111899 #line 193 "vlex.l"
19121900 { return V_KW_2005; }
19131901 YY_BREAK
1914 case 124:
1902 case 122:
19151903 YY_RULE_SETUP
19161904 #line 194 "vlex.l"
19171905 { return V_KW_2005; }
19181906 YY_BREAK
1919 case 125:
1907 case 123:
19201908 YY_RULE_SETUP
19211909 #line 195 "vlex.l"
19221910 { return V_KW_2005; }
19231911 YY_BREAK
1924 case 126:
1912 case 124:
1913 YY_RULE_SETUP
1914 #line 196 "vlex.l"
1915 { return V_KW_2005; }
1916 YY_BREAK
1917 case 125:
19251918 YY_RULE_SETUP
19261919 #line 197 "vlex.l"
19271920 { return V_KW_2005; }
19281921 YY_BREAK
1929 case 127:
1930 YY_RULE_SETUP
1931 #line 198 "vlex.l"
1932 { return V_KW_2005; }
1933 YY_BREAK
1934 case 128:
1922 case 126:
19351923 YY_RULE_SETUP
19361924 #line 199 "vlex.l"
19371925 { return V_KW_2005; }
19381926 YY_BREAK
1939 case 129:
1927 case 127:
19401928 YY_RULE_SETUP
19411929 #line 200 "vlex.l"
19421930 { return V_KW_2005; }
19431931 YY_BREAK
1944 case 130:
1932 case 128:
19451933 YY_RULE_SETUP
19461934 #line 201 "vlex.l"
19471935 { return V_KW_2005; }
19481936 YY_BREAK
1949 case 131:
1937 case 129:
19501938 YY_RULE_SETUP
19511939 #line 202 "vlex.l"
19521940 { return V_KW_2005; }
19531941 YY_BREAK
1954 case 132:
1942 case 130:
19551943 YY_RULE_SETUP
19561944 #line 203 "vlex.l"
19571945 { return V_KW_2005; }
19581946 YY_BREAK
1947 case 131:
1948 YY_RULE_SETUP
1949 #line 204 "vlex.l"
1950 { return V_KW_2005; }
1951 YY_BREAK
1952 case 132:
1953 YY_RULE_SETUP
1954 #line 205 "vlex.l"
1955 { return V_KW_2005; }
1956 YY_BREAK
19591957 case 133:
1960 YY_RULE_SETUP
1961 #line 205 "vlex.l"
1962 { return V_MODULE; }
1963 YY_BREAK
1964 case 134:
1965 YY_RULE_SETUP
1966 #line 206 "vlex.l"
1967 { return V_MODULE; }
1968 YY_BREAK
1969 case 135:
19701958 YY_RULE_SETUP
19711959 #line 207 "vlex.l"
19721960 { return V_MODULE; }
19731961 YY_BREAK
1962 case 134:
1963 YY_RULE_SETUP
1964 #line 208 "vlex.l"
1965 { return V_MODULE; }
1966 YY_BREAK
1967 case 135:
1968 YY_RULE_SETUP
1969 #line 209 "vlex.l"
1970 { return V_MODULE; }
1971 YY_BREAK
19741972 case 136:
19751973 YY_RULE_SETUP
1976 #line 209 "vlex.l"
1974 #line 211 "vlex.l"
19771975 { return V_ENDMODULE; }
19781976 YY_BREAK
19791977 case 137:
19801978 YY_RULE_SETUP
1981 #line 210 "vlex.l"
1979 #line 212 "vlex.l"
19821980 { return V_ENDMODULE; }
19831981 YY_BREAK
19841982 case 138:
19851983 YY_RULE_SETUP
1986 #line 212 "vlex.l"
1984 #line 214 "vlex.l"
19871985 { return V_PREPROC_WS; }
19881986 YY_BREAK
19891987 case 139:
19901988 /* rule 139 can match eol */
19911989 YY_RULE_SETUP
1992 #line 213 "vlex.l"
1990 #line 215 "vlex.l"
19931991 { my_yylineno++; BEGIN INITIAL; return V_WS; }
19941992 YY_BREAK
19951993 case 140:
19961994 YY_RULE_SETUP
1997 #line 215 "vlex.l"
1995 #line 217 "vlex.l"
19981996 {
19991997 if(is_builtin_define (yytext+1, yyleng-1))
20001998 {
20072005 YY_BREAK
20082006 case 141:
20092007 YY_RULE_SETUP
2010 #line 226 "vlex.l"
2011 { return V_ID; }
2012 YY_BREAK
2013 case 142:
2014 YY_RULE_SETUP
2015 #line 227 "vlex.l"
2016 { return V_FUNC; }
2017 YY_BREAK
2018 case 143:
2019 YY_RULE_SETUP
20202008 #line 228 "vlex.l"
20212009 { return V_ID; }
20222010 YY_BREAK
2011 case 142:
2012 YY_RULE_SETUP
2013 #line 229 "vlex.l"
2014 { return V_FUNC; }
2015 YY_BREAK
2016 case 143:
2017 YY_RULE_SETUP
2018 #line 230 "vlex.l"
2019 { return V_ID; }
2020 YY_BREAK
20232021 case 144:
20242022 YY_RULE_SETUP
2025 #line 229 "vlex.l"
2023 #line 231 "vlex.l"
20262024 { return V_ID; }
20272025 YY_BREAK
20282026 case 145:
20292027 YY_RULE_SETUP
2030 #line 230 "vlex.l"
2028 #line 232 "vlex.l"
20312029 { return V_PORT; }
20322030 YY_BREAK
20332031 case 146:
2034 YY_RULE_SETUP
2035 #line 231 "vlex.l"
2036 { return V_NUMBER; }
2037 YY_BREAK
2038 case 147:
2039 YY_RULE_SETUP
2040 #line 232 "vlex.l"
2041 { return V_NUMBER; }
2042 YY_BREAK
2043 case 148:
20442032 YY_RULE_SETUP
20452033 #line 233 "vlex.l"
20462034 { return V_NUMBER; }
20472035 YY_BREAK
2048 case 149:
2036 case 147:
20492037 YY_RULE_SETUP
20502038 #line 234 "vlex.l"
20512039 { return V_NUMBER; }
20522040 YY_BREAK
2053 case 150:
2041 case 148:
20542042 YY_RULE_SETUP
20552043 #line 235 "vlex.l"
20562044 { return V_NUMBER; }
20572045 YY_BREAK
2046 case 149:
2047 YY_RULE_SETUP
2048 #line 236 "vlex.l"
2049 { return V_NUMBER; }
2050 YY_BREAK
2051 case 150:
2052 YY_RULE_SETUP
2053 #line 237 "vlex.l"
2054 { return V_NUMBER; }
2055 YY_BREAK
20582056 case 151:
20592057 YY_RULE_SETUP
2060 #line 236 "vlex.l"
2058 #line 238 "vlex.l"
20612059 { return V_IGNORE; }
20622060 YY_BREAK
20632061 case 152:
20642062 YY_RULE_SETUP
2065 #line 237 "vlex.l"
2063 #line 239 "vlex.l"
20662064 { return V_WS; }
20672065 YY_BREAK
20682066 case 153:
20692067 /* rule 153 can match eol */
20702068 YY_RULE_SETUP
2071 #line 238 "vlex.l"
2069 #line 240 "vlex.l"
20722070 { my_yylineno++; return V_WS; }
20732071 YY_BREAK
20742072 case 154:
20752073 YY_RULE_SETUP
2076 #line 239 "vlex.l"
2074 #line 241 "vlex.l"
20772075 { return V_CMT; }
20782076 YY_BREAK
20792077 case 155:
20802078 YY_RULE_SETUP
2081 #line 240 "vlex.l"
2079 #line 242 "vlex.l"
20822080 { return V_STRING; }
20832081 YY_BREAK
20842082 case 156:
20852083 YY_RULE_SETUP
2086 #line 241 "vlex.l"
2084 #line 243 "vlex.l"
20872085 { return V_IGNORE; }
20882086 YY_BREAK
20892087 case 157:
20902088 YY_RULE_SETUP
2091 #line 243 "vlex.l"
2089 #line 245 "vlex.l"
20922090 ECHO;
20932091 YY_BREAK
2094 #line 2096 "vlex.c"
2092 #line 2094 "vlex.c"
20952093 case YY_STATE_EOF(INITIAL):
20962094 case YY_STATE_EOF(CMNT):
20972095 case YY_STATE_EOF(PREPROC):
24202418 yy_is_jam = (yy_current_state == 618);
24212419
24222420 return yy_is_jam ? 0 : yy_current_state;
2423 }
2424
2425 static void yyunput (int c, register char * yy_bp )
2426 {
2427 register char *yy_cp;
2428
2429 yy_cp = (yy_c_buf_p);
2430
2431 /* undo effects of setting up yytext */
2432 *yy_cp = (yy_hold_char);
2433
2434 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
2435 { /* need to shift things up to make room */
2436 /* +2 for EOB chars. */
2437 register yy_size_t number_to_move = (yy_n_chars) + 2;
2438 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
2439 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
2440 register char *source =
2441 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
2442
2443 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2444 *--dest = *--source;
2445
2446 yy_cp += (int) (dest - source);
2447 yy_bp += (int) (dest - source);
2448 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
2449 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
2450
2451 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
2452 YY_FATAL_ERROR( "flex scanner push-back overflow" );
2453 }
2454
2455 *--yy_cp = (char) c;
2456
2457 (yytext_ptr) = yy_bp;
2458 (yy_hold_char) = *yy_cp;
2459 (yy_c_buf_p) = yy_cp;
24602421 }
24612422
24622423 #ifndef YY_NO_INPUT
28572818 YY_BUFFER_STATE b;
28582819 char *buf;
28592820 yy_size_t n;
2860 int i;
2821 yy_size_t i;
28612822
28622823 /* Get memory for full buffer, including space for trailing EOB's. */
28632824 n = _yybytes_len + 2;
30873048
30883049 #define YYTABLES_NAME "yytables"
30893050
3090 #line 243 "vlex.l"
3091
3092
3093
3051 #line 245 "vlex.l"
3052
3053
3054
55 * as published by the Free Software Foundation; either version 2
66 * of the License, or (at your option) any later version.
77 */
8
8
9 %option nounput
10
911 %{
1012
1113 /*
+0
-39
contrib/vermin/Makefile.am less more
0 ## -*- makefile -*-
1 ##
2
3 bin_PROGRAMS= vermin
4
5 PCCTS = ../pccts
6 ANTLR_H = $(srcdir)/../pccts/h
7 ANTLR = $(PCCTS)/antlr/antlr
8 DLG = $(PCCTS)/dlg/dlg
9 AFLAGS = -ga -k 2 -gl
10 DFLAGS = -ga -C2 -i
11
12 AM_CFLAGS = -I. -I$(ANTLR_H) -I$(top_srcdir)
13 AM_LIBS= -lm
14
15 vermin_SOURCES= \
16 args.c attrib.h definehash.c err.c inter.c inter.h jrb.c jrb.h \
17 keyword_tokens.h keywordhash.c mode.h preproc.c scan.c \
18 symbol.c symbol.h tokens.h verilog.c vpp_common.h shred.h shred.c
19
20 verilog.c parser.dlg tokens.h err.c : $(srcdir)/verilog.g
21 $(ANTLR) $(AFLAGS) $(srcdir)/verilog.g
22
23 scan.c mode.h : parser.dlg
24 $(DLG) $(DFLAGS) parser.dlg scan.c
25
26 definehash.c: vpp_keyword.gperf
27 $(GPERF) -C -I -N is_builtin_define $(srcdir)/vpp_keyword.gperf >definehash.c
28
29 keywordhash.c: verilog_keyword.gperf
30 printf "$(GPERF) -o -i 1 -C -k 1-3,\044 -L C -H keyword_hash -N check_identifier -tT $(srcdir)/verilog_keyword.gperf >keywordhash.c" | sh
31
32 BUILT_SOURCES= definehash.c keywordhash.c tokens.h verilog.c tokens.h err.c parser.dlg scan.c mode.h
33
34 shred.$(OBJEXT) : tokens.h
35
36 EXTRA_DIST= \
37 parser.dlg verilog.g verilog_keyword.gperf vpp_keyword.gperf
38
+0
-669
contrib/vermin/Makefile.in less more
0 # Makefile.in generated by automake 1.13.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 bin_PROGRAMS = vermin$(EXEEXT)
79 subdir = contrib/vermin
80 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
81 $(top_srcdir)/depcomp
82 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
83 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
84 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
85 $(ACLOCAL_M4)
86 mkinstalldirs = $(install_sh) -d
87 CONFIG_HEADER = $(top_builddir)/config.h
88 CONFIG_CLEAN_FILES =
89 CONFIG_CLEAN_VPATH_FILES =
90 am__installdirs = "$(DESTDIR)$(bindir)"
91 PROGRAMS = $(bin_PROGRAMS)
92 am_vermin_OBJECTS = args.$(OBJEXT) definehash.$(OBJEXT) err.$(OBJEXT) \
93 inter.$(OBJEXT) jrb.$(OBJEXT) keywordhash.$(OBJEXT) \
94 preproc.$(OBJEXT) scan.$(OBJEXT) symbol.$(OBJEXT) \
95 verilog.$(OBJEXT) shred.$(OBJEXT)
96 vermin_OBJECTS = $(am_vermin_OBJECTS)
97 vermin_LDADD = $(LDADD)
98 AM_V_P = $(am__v_P_@AM_V@)
99 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
100 am__v_P_0 = false
101 am__v_P_1 = :
102 AM_V_GEN = $(am__v_GEN_@AM_V@)
103 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
104 am__v_GEN_0 = @echo " GEN " $@;
105 am__v_GEN_1 =
106 AM_V_at = $(am__v_at_@AM_V@)
107 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
108 am__v_at_0 = @
109 am__v_at_1 =
110 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
111 depcomp = $(SHELL) $(top_srcdir)/depcomp
112 am__depfiles_maybe = depfiles
113 am__mv = mv -f
114 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
115 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
116 AM_V_CC = $(am__v_CC_@AM_V@)
117 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
118 am__v_CC_0 = @echo " CC " $@;
119 am__v_CC_1 =
120 CCLD = $(CC)
121 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
122 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
123 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
124 am__v_CCLD_0 = @echo " CCLD " $@;
125 am__v_CCLD_1 =
126 SOURCES = $(vermin_SOURCES)
127 DIST_SOURCES = $(vermin_SOURCES)
128 am__can_run_installinfo = \
129 case $$AM_UPDATE_INFO_DIR in \
130 n|no|NO) false;; \
131 *) (install-info --version) >/dev/null 2>&1;; \
132 esac
133 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
134 # Read a list of newline-separated strings from the standard input,
135 # and print each of them once, without duplicates. Input order is
136 # *not* preserved.
137 am__uniquify_input = $(AWK) '\
138 BEGIN { nonempty = 0; } \
139 { items[$$0] = 1; nonempty = 1; } \
140 END { if (nonempty) { for (i in items) print i; }; } \
141 '
142 # Make sure the list of sources is unique. This is necessary because,
143 # e.g., the same source file might be shared among _SOURCES variables
144 # for different programs/libraries.
145 am__define_uniq_tagged_files = \
146 list='$(am__tagged_files)'; \
147 unique=`for i in $$list; do \
148 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
149 done | $(am__uniquify_input)`
150 ETAGS = etags
151 CTAGS = ctags
152 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
153 ACLOCAL = @ACLOCAL@
154 AET2_CFLAGS = @AET2_CFLAGS@
155 AET2_LDADD = @AET2_LDADD@
156 ALLOCA = @ALLOCA@
157 AMTAR = @AMTAR@
158 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
159 AUTOCONF = @AUTOCONF@
160 AUTOHEADER = @AUTOHEADER@
161 AUTOMAKE = @AUTOMAKE@
162 AWK = @AWK@
163 CC = @CC@
164 CCDEPMODE = @CCDEPMODE@
165 CFLAGS = @CFLAGS@
166 COCOA_GTK_CFLAGS = @COCOA_GTK_CFLAGS@
167 COCOA_GTK_LDADD = @COCOA_GTK_LDADD@
168 COCOA_GTK_LDFLAGS = @COCOA_GTK_LDFLAGS@
169 CPP = @CPP@
170 CPPFLAGS = @CPPFLAGS@
171 CXX = @CXX@
172 CXXDEPMODE = @CXXDEPMODE@
173 CXXFLAGS = @CXXFLAGS@
174 CYGPATH_W = @CYGPATH_W@
175 DEFS = @DEFS@
176 DEPDIR = @DEPDIR@
177 ECHO_C = @ECHO_C@
178 ECHO_N = @ECHO_N@
179 ECHO_T = @ECHO_T@
180 EGREP = @EGREP@
181 EXEEXT = @EXEEXT@
182 EXTDEBUG = @EXTDEBUG@
183 EXTDEBUG2 = @EXTDEBUG2@
184 EXTDEBUG3 = @EXTDEBUG3@
185 EXTDEBUG4 = @EXTDEBUG4@
186 EXTLOAD_CFLAGS = @EXTLOAD_CFLAGS@
187 FASTTREE_CFLAGS = @FASTTREE_CFLAGS@
188 FSDB_CFLAGS = @FSDB_CFLAGS@
189 FSDB_LDADD = @FSDB_LDADD@
190 GCONF_CFLAGS = @GCONF_CFLAGS@
191 GCONF_LIBS = @GCONF_LIBS@
192 GEDITTEST = @GEDITTEST@
193 GEDIT_CFLAGS = @GEDIT_CFLAGS@
194 GIO_CFLAGS = @GIO_CFLAGS@
195 GIO_LIBS = @GIO_LIBS@
196 GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
197 GPERF = @GPERF@
198 GREP = @GREP@
199 GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
200 GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
201 GTK_CFLAGS = @GTK_CFLAGS@
202 GTK_CONFIG = @GTK_CONFIG@
203 GTK_LIBS = @GTK_LIBS@
204 GTK_MAC_CFLAGS = @GTK_MAC_CFLAGS@
205 GTK_MAC_LIBS = @GTK_MAC_LIBS@
206 GTK_UNIX_PRINT_CFLAGS = @GTK_UNIX_PRINT_CFLAGS@
207 GTK_UNIX_PRINT_LIBS = @GTK_UNIX_PRINT_LIBS@
208 INSTALL = @INSTALL@
209 INSTALL_DATA = @INSTALL_DATA@
210 INSTALL_PROGRAM = @INSTALL_PROGRAM@
211 INSTALL_SCRIPT = @INSTALL_SCRIPT@
212 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
213 LDFLAGS = @LDFLAGS@
214 LEX = @LEX@
215 LEXLIB = @LEXLIB@
216 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
217 LIBBZ2_CFLAGS = @LIBBZ2_CFLAGS@
218 LIBBZ2_DIR = @LIBBZ2_DIR@
219 LIBBZ2_LDADD = @LIBBZ2_LDADD@
220 LIBJUDY_CFLAGS = @LIBJUDY_CFLAGS@
221 LIBJUDY_LDADD = @LIBJUDY_LDADD@
222 LIBOBJS = @LIBOBJS@
223 LIBS = @LIBS@
224 LIBXZ_CFLAGS = @LIBXZ_CFLAGS@
225 LIBXZ_LDADD = @LIBXZ_LDADD@
226 LIBZ_CFLAGS = @LIBZ_CFLAGS@
227 LIBZ_DIR = @LIBZ_DIR@
228 LIBZ_LDADD = @LIBZ_LDADD@
229 LTLIBOBJS = @LTLIBOBJS@
230 MAINT = @MAINT@
231 MAKEINFO = @MAKEINFO@
232 MINGW_LDADD = @MINGW_LDADD@
233 MKDIR_P = @MKDIR_P@
234 OBJEXT = @OBJEXT@
235 PACKAGE = @PACKAGE@
236 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
237 PACKAGE_NAME = @PACKAGE_NAME@
238 PACKAGE_STRING = @PACKAGE_STRING@
239 PACKAGE_TARNAME = @PACKAGE_TARNAME@
240 PACKAGE_URL = @PACKAGE_URL@
241 PACKAGE_VERSION = @PACKAGE_VERSION@
242 PATH_SEPARATOR = @PATH_SEPARATOR@
243 PKG_CONFIG = @PKG_CONFIG@
244 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
245 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
246 POW_LIB = @POW_LIB@
247 RANLIB = @RANLIB@
248 RPC_CFLAGS = @RPC_CFLAGS@
249 RPC_LDADD = @RPC_LDADD@
250 SET_MAKE = @SET_MAKE@
251 SHELL = @SHELL@
252 STRIP = @STRIP@
253 STRUCT_PACK = @STRUCT_PACK@
254 TCL_DEFADD = @TCL_DEFADD@
255 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
256 TCL_LDADD = @TCL_LDADD@
257 TCL_LIB_SPEC = @TCL_LIB_SPEC@
258 TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@
259 TCL_MINOR_VERSION = @TCL_MINOR_VERSION@
260 TIRPC_CFLAGS = @TIRPC_CFLAGS@
261 TIRPC_LIBS = @TIRPC_LIBS@
262 TK_INCLUDE_SPEC = @TK_INCLUDE_SPEC@
263 TK_LDADD = @TK_LDADD@
264 TK_LIB_SPEC = @TK_LIB_SPEC@
265 UPDATE_DESKTOP_DATABASE = @UPDATE_DESKTOP_DATABASE@
266 UPDATE_MIME_DATABASE = @UPDATE_MIME_DATABASE@
267 VERSION = @VERSION@
268 XDGDATADIR = @XDGDATADIR@
269 abs_builddir = @abs_builddir@
270 abs_srcdir = @abs_srcdir@
271 abs_top_builddir = @abs_top_builddir@
272 abs_top_srcdir = @abs_top_srcdir@
273 ac_ct_CC = @ac_ct_CC@
274 ac_ct_CXX = @ac_ct_CXX@
275 am__include = @am__include@
276 am__leading_dot = @am__leading_dot@
277 am__quote = @am__quote@
278 am__tar = @am__tar@
279 am__untar = @am__untar@
280 bindir = @bindir@
281 build_alias = @build_alias@
282 builddir = @builddir@
283 datadir = @datadir@
284 datarootdir = @datarootdir@
285 docdir = @docdir@
286 dvidir = @dvidir@
287 exec_prefix = @exec_prefix@
288 gsettingsschemadir = @gsettingsschemadir@
289 host_alias = @host_alias@
290 htmldir = @htmldir@
291 includedir = @includedir@
292 infodir = @infodir@
293 install_sh = @install_sh@
294 libdir = @libdir@
295 libexecdir = @libexecdir@
296 localedir = @localedir@
297 localstatedir = @localstatedir@
298 mandir = @mandir@
299 mkdir_p = @mkdir_p@
300 oldincludedir = @oldincludedir@
301 pdfdir = @pdfdir@
302 prefix = @prefix@
303 program_transform_name = @program_transform_name@
304 psdir = @psdir@
305 sbindir = @sbindir@
306 sharedstatedir = @sharedstatedir@
307 srcdir = @srcdir@
308 sysconfdir = @sysconfdir@
309 target_alias = @target_alias@
310 top_build_prefix = @top_build_prefix@
311 top_builddir = @top_builddir@
312 top_srcdir = @top_srcdir@
313 PCCTS = ../pccts
314 ANTLR_H = $(srcdir)/../pccts/h
315 ANTLR = $(PCCTS)/antlr/antlr
316 DLG = $(PCCTS)/dlg/dlg
317 AFLAGS = -ga -k 2 -gl
318 DFLAGS = -ga -C2 -i
319 AM_CFLAGS = -I. -I$(ANTLR_H) -I$(top_srcdir)
320 AM_LIBS = -lm
321 vermin_SOURCES = \
322 args.c attrib.h definehash.c err.c inter.c inter.h jrb.c jrb.h \
323 keyword_tokens.h keywordhash.c mode.h preproc.c scan.c \
324 symbol.c symbol.h tokens.h verilog.c vpp_common.h shred.h shred.c
325
326 BUILT_SOURCES = definehash.c keywordhash.c tokens.h verilog.c tokens.h err.c parser.dlg scan.c mode.h
327 EXTRA_DIST = \
328 parser.dlg verilog.g verilog_keyword.gperf vpp_keyword.gperf
329
330 all: $(BUILT_SOURCES)
331 $(MAKE) $(AM_MAKEFLAGS) all-am
332
333 .SUFFIXES:
334 .SUFFIXES: .c .o .obj
335 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
336 @for dep in $?; do \
337 case '$(am__configure_deps)' in \
338 *$$dep*) \
339 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
340 && { if test -f $@; then exit 0; else break; fi; }; \
341 exit 1;; \
342 esac; \
343 done; \
344 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/vermin/Makefile'; \
345 $(am__cd) $(top_srcdir) && \
346 $(AUTOMAKE) --foreign contrib/vermin/Makefile
347 .PRECIOUS: Makefile
348 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
349 @case '$?' in \
350 *config.status*) \
351 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
352 *) \
353 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
354 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
355 esac;
356
357 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
358 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
359
360 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
361 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
362 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
363 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
364 $(am__aclocal_m4_deps):
365 install-binPROGRAMS: $(bin_PROGRAMS)
366 @$(NORMAL_INSTALL)
367 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
368 if test -n "$$list"; then \
369 echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
370 $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
371 fi; \
372 for p in $$list; do echo "$$p $$p"; done | \
373 sed 's/$(EXEEXT)$$//' | \
374 while read p p1; do if test -f $$p \
375 ; then echo "$$p"; echo "$$p"; else :; fi; \
376 done | \
377 sed -e 'p;s,.*/,,;n;h' \
378 -e 's|.*|.|' \
379 -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
380 sed 'N;N;N;s,\n, ,g' | \
381 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
382 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
383 if ($$2 == $$4) files[d] = files[d] " " $$1; \
384 else { print "f", $$3 "/" $$4, $$1; } } \
385 END { for (d in files) print "f", d, files[d] }' | \
386 while read type dir files; do \
387 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
388 test -z "$$files" || { \
389 echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
390 $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
391 } \
392 ; done
393
394 uninstall-binPROGRAMS:
395 @$(NORMAL_UNINSTALL)
396 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
397 files=`for p in $$list; do echo "$$p"; done | \
398 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
399 -e 's/$$/$(EXEEXT)/' \
400 `; \
401 test -n "$$list" || exit 0; \
402 echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
403 cd "$(DESTDIR)$(bindir)" && rm -f $$files
404
405 clean-binPROGRAMS:
406 -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
407
408 vermin$(EXEEXT): $(vermin_OBJECTS) $(vermin_DEPENDENCIES) $(EXTRA_vermin_DEPENDENCIES)
409 @rm -f vermin$(EXEEXT)
410 $(AM_V_CCLD)$(LINK) $(vermin_OBJECTS) $(vermin_LDADD) $(LIBS)
411
412 mostlyclean-compile:
413 -rm -f *.$(OBJEXT)
414
415 distclean-compile:
416 -rm -f *.tab.c
417
418 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/args.Po@am__quote@
419 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/definehash.Po@am__quote@
420 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Po@am__quote@
421 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inter.Po@am__quote@
422 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jrb.Po@am__quote@
423 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keywordhash.Po@am__quote@
424 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/preproc.Po@am__quote@
425 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan.Po@am__quote@
426 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shred.Po@am__quote@
427 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symbol.Po@am__quote@
428 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verilog.Po@am__quote@
429
430 .c.o:
431 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
432 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
433 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
434 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
435 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
436
437 .c.obj:
438 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
439 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
440 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
441 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
442 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
443
444 ID: $(am__tagged_files)
445 $(am__define_uniq_tagged_files); mkid -fID $$unique
446 tags: tags-am
447 TAGS: tags
448
449 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
450 set x; \
451 here=`pwd`; \
452 $(am__define_uniq_tagged_files); \
453 shift; \
454 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
455 test -n "$$unique" || unique=$$empty_fix; \
456 if test $$# -gt 0; then \
457 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
458 "$$@" $$unique; \
459 else \
460 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
461 $$unique; \
462 fi; \
463 fi
464 ctags: ctags-am
465
466 CTAGS: ctags
467 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
468 $(am__define_uniq_tagged_files); \
469 test -z "$(CTAGS_ARGS)$$unique" \
470 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
471 $$unique
472
473 GTAGS:
474 here=`$(am__cd) $(top_builddir) && pwd` \
475 && $(am__cd) $(top_srcdir) \
476 && gtags -i $(GTAGS_ARGS) "$$here"
477 cscopelist: cscopelist-am
478
479 cscopelist-am: $(am__tagged_files)
480 list='$(am__tagged_files)'; \
481 case "$(srcdir)" in \
482 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
483 *) sdir=$(subdir)/$(srcdir) ;; \
484 esac; \
485 for i in $$list; do \
486 if test -f "$$i"; then \
487 echo "$(subdir)/$$i"; \
488 else \
489 echo "$$sdir/$$i"; \
490 fi; \
491 done >> $(top_builddir)/cscope.files
492
493 distclean-tags:
494 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
495
496 distdir: $(DISTFILES)
497 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
498 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
499 list='$(DISTFILES)'; \
500 dist_files=`for file in $$list; do echo $$file; done | \
501 sed -e "s|^$$srcdirstrip/||;t" \
502 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
503 case $$dist_files in \
504 */*) $(MKDIR_P) `echo "$$dist_files" | \
505 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
506 sort -u` ;; \
507 esac; \
508 for file in $$dist_files; do \
509 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
510 if test -d $$d/$$file; then \
511 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
512 if test -d "$(distdir)/$$file"; then \
513 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
514 fi; \
515 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
516 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
517 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
518 fi; \
519 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
520 else \
521 test -f "$(distdir)/$$file" \
522 || cp -p $$d/$$file "$(distdir)/$$file" \
523 || exit 1; \
524 fi; \
525 done
526 check-am: all-am
527 check: $(BUILT_SOURCES)
528 $(MAKE) $(AM_MAKEFLAGS) check-am
529 all-am: Makefile $(PROGRAMS)
530 installdirs:
531 for dir in "$(DESTDIR)$(bindir)"; do \
532 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
533 done
534 install: $(BUILT_SOURCES)
535 $(MAKE) $(AM_MAKEFLAGS) install-am
536 install-exec: install-exec-am
537 install-data: install-data-am
538 uninstall: uninstall-am
539
540 install-am: all-am
541 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
542
543 installcheck: installcheck-am
544 install-strip:
545 if test -z '$(STRIP)'; then \
546 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
547 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
548 install; \
549 else \
550 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
551 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
552 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
553 fi
554 mostlyclean-generic:
555
556 clean-generic:
557
558 distclean-generic:
559 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
560 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
561
562 maintainer-clean-generic:
563 @echo "This command is intended for maintainers to use"
564 @echo "it deletes files that may require special tools to rebuild."
565 -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
566 clean: clean-am
567
568 clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
569
570 distclean: distclean-am
571 -rm -rf ./$(DEPDIR)
572 -rm -f Makefile
573 distclean-am: clean-am distclean-compile distclean-generic \
574 distclean-tags
575
576 dvi: dvi-am
577
578 dvi-am:
579
580 html: html-am
581
582 html-am:
583
584 info: info-am
585
586 info-am:
587
588 install-data-am:
589
590 install-dvi: install-dvi-am
591
592 install-dvi-am:
593
594 install-exec-am: install-binPROGRAMS
595
596 install-html: install-html-am
597
598 install-html-am:
599
600 install-info: install-info-am
601
602 install-info-am:
603
604 install-man:
605
606 install-pdf: install-pdf-am
607
608 install-pdf-am:
609
610 install-ps: install-ps-am
611
612 install-ps-am:
613
614 installcheck-am:
615
616 maintainer-clean: maintainer-clean-am
617 -rm -rf ./$(DEPDIR)
618 -rm -f Makefile
619 maintainer-clean-am: distclean-am maintainer-clean-generic
620
621 mostlyclean: mostlyclean-am
622
623 mostlyclean-am: mostlyclean-compile mostlyclean-generic
624
625 pdf: pdf-am
626
627 pdf-am:
628
629 ps: ps-am
630
631 ps-am:
632
633 uninstall-am: uninstall-binPROGRAMS
634
635 .MAKE: all check install install-am install-strip
636
637 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
638 clean-binPROGRAMS clean-generic cscopelist-am ctags ctags-am \
639 distclean distclean-compile distclean-generic distclean-tags \
640 distdir dvi dvi-am html html-am info info-am install \
641 install-am install-binPROGRAMS install-data install-data-am \
642 install-dvi install-dvi-am install-exec install-exec-am \
643 install-html install-html-am install-info install-info-am \
644 install-man install-pdf install-pdf-am install-ps \
645 install-ps-am install-strip installcheck installcheck-am \
646 installdirs maintainer-clean maintainer-clean-generic \
647 mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
648 ps ps-am tags tags-am uninstall uninstall-am \
649 uninstall-binPROGRAMS
650
651
652 verilog.c parser.dlg tokens.h err.c : $(srcdir)/verilog.g
653 $(ANTLR) $(AFLAGS) $(srcdir)/verilog.g
654
655 scan.c mode.h : parser.dlg
656 $(DLG) $(DFLAGS) parser.dlg scan.c
657
658 definehash.c: vpp_keyword.gperf
659 $(GPERF) -C -I -N is_builtin_define $(srcdir)/vpp_keyword.gperf >definehash.c
660
661 keywordhash.c: verilog_keyword.gperf
662 printf "$(GPERF) -o -i 1 -C -k 1-3,\044 -L C -H keyword_hash -N check_identifier -tT $(srcdir)/verilog_keyword.gperf >keywordhash.c" | sh
663
664 shred.$(OBJEXT) : tokens.h
665
666 # Tell versions [3.59,3.63) of GNU make to not export all variables.
667 # Otherwise a system limit (for SysV at least) may be exceeded.
668 .NOEXPORT:
+0
-186
contrib/vermin/args.c less more
0 #include <stdio.h>
1 #include <stdlib.h>
2 #include <string.h>
3 #include "vpp_common.h"
4
5 struct arglines_t
6 {
7 struct arglines_t *next;
8 char *s;
9 int count;
10 };
11
12 static struct arglines_t *read_file(char *name)
13 {
14 FILE *f = fopen(name, "rb");
15 struct arglines_t *head = NULL, *curr = NULL;
16 char buf[8193];
17
18 if(!f)
19 {
20 warn("** Problem reading args file '%s'.\n", name);
21 perror("Why");
22 return(NULL);
23 }
24
25 while(!feof(f))
26 {
27 int len;
28 int i;
29 char *srt;
30
31 if(!fgets(buf, 8192, f)) buf[0] = 0;
32 len = strlen(buf);
33 if(!len) break;
34 buf[len-1] = 0;
35
36 for(i=len-2;i>=0;i--)
37 {
38 if(isspace((int)(unsigned char)buf[i]))
39 {
40 buf[i] = 0;
41 continue;
42 }
43 break;
44 }
45
46 srt = NULL;
47 for(i=0;i<len;i++)
48 {
49 if(buf[i] && !isspace((int)(unsigned char)buf[i]))
50 {
51 srt = buf+i;
52 break;
53 }
54 }
55
56 if(!srt) continue;
57 len = strlen(srt);
58 if(!len) continue;
59
60 if((srt[0]=='+')||((srt[0]=='-')&&(srt[1]=='D'))) /* do not parse spaces out of front/back of plusargs and defines */
61 {
62 if(!head)
63 {
64 head = curr = calloc(1, sizeof(struct arglines_t));
65 head->s = strdup(srt);
66 head->count = 1;
67 }
68 else
69 {
70 struct arglines_t *l = calloc(1, sizeof(struct arglines_t));
71 l->s = strdup(srt);
72 curr->next = l;
73 curr = l;
74 head->count++;
75 }
76 }
77 else
78 {
79 char *srt_new;
80 int first = 1;
81
82 while((srt_new = strtok(first ? srt : NULL, " \t")))
83 {
84 first = 0;
85
86 if(!head)
87 {
88 head = curr = calloc(1, sizeof(struct arglines_t));
89 head->s = strdup(srt_new);
90 head->count = 1;
91 }
92 else
93 {
94 struct arglines_t *l = calloc(1, sizeof(struct arglines_t));
95 l->s = strdup(srt_new);
96 curr->next = l;
97 curr = l;
98 head->count++;
99 }
100 }
101 }
102 }
103
104 fclose(f);
105 return(head);
106 }
107
108 void args_expand(int argc, char **argv, int *new_argc, char ***new_argv)
109 {
110 int i;
111 int has_dashf = 0;
112 int total_args;
113 struct arglines_t **shadow_list;
114
115 for(i=1;i<argc;i++)
116 {
117 if(!strcmp(argv[i], "-f"))
118 {
119 if(i==(argc-1))
120 {
121 warn("** Skipping -f missing filename as a final argument.\n");
122 argc--;
123 break;
124 }
125
126 has_dashf = 1;
127 }
128 }
129
130 if(!has_dashf)
131 {
132 *new_argc = argc;
133 *new_argv = argv;
134 }
135
136 shadow_list = calloc(argc, sizeof(struct arglines_t *));
137 total_args = 1; /* argv[0] */
138 for(i=1;i<argc;i++)
139 {
140 if(!strcmp(argv[i], "-f"))
141 {
142 struct arglines_t *al = read_file(argv[i+1]);
143
144 if(al)
145 {
146 shadow_list[i] = al;
147 total_args += al->count;
148 }
149 i++;
150 }
151 else
152 {
153 total_args++;
154 }
155 }
156
157 *new_argc = total_args;
158 *new_argv = calloc(total_args, sizeof(char *));
159
160 total_args = 0;
161 for(i=0;i<argc;i++)
162 {
163 if(!strcmp(argv[i], "-f"))
164 {
165 struct arglines_t *al = shadow_list[i];
166 struct arglines_t *al_nxt;
167 while(al)
168 {
169 al_nxt = al->next;
170 (*new_argv)[total_args++] = al->s;
171 free(al);
172 al = al_nxt;
173 }
174 i++;
175 }
176 else
177 {
178 (*new_argv)[total_args] = strdup(argv[i]);
179 total_args++;
180 }
181 }
182
183 free(shadow_list); /* scan-build */
184 }
185
+0
-38
contrib/vermin/attrib.h less more
0 #ifndef ATTRIB_H
1 #define ATTRIB_H
2
3 #define ZZA_STACKSIZE 100000
4 #define ZZAST_STACKSIZE 100000
5
6 extern int zzline, zzrewind;
7 extern int zzerrors;
8 extern int zzcomment_start, zzcomment_depth, zzcomment_entry;
9 extern char *zzfilename;
10 extern char *lineroot, *linepos;
11 extern char *prevlineroot;
12 extern int linemaxlen;
13
14 typedef union
15 {
16 int ival;
17 double rval;
18 char *text;
19 struct i_oper *oper;
20 struct i_primary *prim;
21 struct i_number *num;
22 struct i_symbol *symbol;
23 struct i_explist *explist;
24 } Attrib;
25
26 #define USER_ZZSYN
27
28 extern int do_not_translate, do_not_translate_mask;
29 #define STMODE do{if(do_not_translate)zzskip();}while(0)
30 #define STMODE_XLATEOFF_SYNOPSYS 1
31 #define STMODE_XLATEOFF_SYNTHESIS 2
32 #define STMODE_XLATEOFF_VERILINT 4
33 #define STMODE_XLATEOFF_VERTEX 8
34 #define STMODE_XLATEOFF_IFDEF 16
35
36 #endif
37
+0
-376
contrib/vermin/inter.c less more
0 #include "inter.h"
1 #include "symbol.h"
2
3 /*
4 * malloc() and fill in various i_structs..
5 */
6 struct i_oper *i_oper_make(int token, int prec)
7 {
8 struct i_oper *pnt;
9
10 pnt=(struct i_oper *)malloc(sizeof(struct i_oper));
11 pnt->prec=prec;
12 pnt->token=token;
13
14 return(pnt);
15 }
16
17 struct i_number *i_number_make(int ival)
18 {
19 struct i_number *pnt;
20
21 pnt=(struct i_number *)calloc(1,sizeof(struct i_number));
22 pnt->numtype=NV_IVAL;
23 pnt->num.ival=ival;
24 return(pnt);
25 }
26
27 struct i_number *i_number_fmake(double rval)
28 {
29 struct i_number *pnt;
30
31 pnt=(struct i_number *)calloc(1,sizeof(struct i_number));
32 pnt->numtype=NV_RVAL;
33 pnt->num.rval=rval;
34 return(pnt);
35 }
36
37
38 struct i_number *i_number_basemake(int typ, char *text)
39 {
40 struct i_number *pnt;
41 char *s;
42
43 pnt=(struct i_number *)calloc(1,sizeof(struct i_number));
44 pnt->numtype=typ;
45
46 if(typ != NV_STRING)
47 {
48 int specified_width = text[0]!='\'';
49
50 pnt->num.base.specified_width_flag=specified_width; /* when set, says that .len was specified in the verilog, else val is synthesized (32) */
51 pnt->num.base.len= specified_width ? atoi_with_underscores(text) : 32;
52
53 s=text;
54 while(*(s++)!='\'');
55 s++;
56 pnt->num.base.val=strdup(s);
57
58 if(!specified_width)
59 {
60 warn("** Warning: constant %s width unspecified in file '%s' line %d, defaulting to 32 bits\n", text, zzfilename, zzline);
61 }
62
63 free(text);
64 }
65 else
66 {
67 char *p = text;
68 char *p2 = text;
69 int octval;
70
71 while(*p)
72 {
73 if(*p!='\\')
74 {
75 *p2=*p;
76 }
77 else
78 {
79 p++;
80 switch(*p)
81 {
82 case 't': *p2 = '\t'; break;
83 case 'n': *p2 = '\n'; break;
84 case '\\': *p2 = '\\'; break;
85
86 case '0':
87 case '1':
88 case '2':
89 case '3':
90 case '4':
91 case '5':
92 case '6':
93 case '7':
94 octval = *p - '0';
95 if((*(p+1)>='0')&&(*(p+1)<='7'))
96 {
97 p++;
98 octval = 8*octval + (*p - '0');
99 if((*(p+1)>='0')&&(*(p+1)<='7'))
100 {
101 p++;
102 octval = 8*octval + (*p - '0');
103 }
104 }
105
106 *p2 = octval;
107 break;
108
109 default: *(p2++) = '\\';
110 *p2 = *p;
111 break;
112 }
113
114 }
115
116 p++;
117 p2++;
118 }
119 *p2=0;
120
121 pnt->num.base.len=8*(p2-text);
122 pnt->num.base.val=text;
123 /* warn("** Info: bits %d, string constant '%s'\n", pnt->num.base.len, pnt->num.base.val); */
124 }
125
126 return(pnt);
127 }
128
129
130 struct i_primary *i_primary_make(int typ, void *vpnt)
131 {
132 struct i_primary *pnt;
133
134 pnt=(struct i_primary *)calloc(1,sizeof(struct i_primary));
135 pnt->primtype=typ;
136 pnt->primval.generic=vpnt;
137
138 return(pnt);
139 }
140
141 struct i_primary *i_primary_mintypmax_make(struct i_primary *m1, struct i_primary *m2, struct i_primary *m3)
142 {
143 struct i_primary *pnt;
144
145 pnt=(struct i_primary *)calloc(1,sizeof(struct i_primary));
146 pnt->primtype=PRIM_MINTYPMAX;
147 pnt->primval.mintypmax.m1 = m1;
148 pnt->primval.mintypmax.m2 = m2;
149 pnt->primval.mintypmax.m3 = m3;
150
151 return(pnt);
152 }
153
154 struct i_primary *i_bin_expr_make(struct i_primary *p1, struct i_oper *o1, struct i_primary *p2)
155 {
156 struct i_primary *prdest;
157
158 prdest=(struct i_primary *)calloc(1,sizeof(struct i_primary));
159 prdest->primtype=PRIM_EXP;
160 prdest->primval.binexp.prim1 = p1;
161 prdest->primval.binexp.prim2 = p2;
162 prdest->primval.binexp.oper = o1;
163 return(prdest);
164 }
165
166 struct i_primary *i_primary_symbit_make(struct i_symbol *sym, struct i_primary *pri)
167 {
168 struct i_primary *pnt;
169 pnt=(struct i_primary *)calloc(1,sizeof(struct i_primary));
170 pnt->primtype=PRIM_SYMBIT;
171 pnt->primval.symbit.sym=sym;
172 pnt->primval.symbit.bitnum=pri;
173 return(pnt);
174 }
175
176 struct i_primary *i_primary_symrange_make(struct i_symbol *sym, struct i_primary *msb, struct i_primary *lsb)
177 {
178 struct i_primary *pnt;
179 pnt=(struct i_primary *)calloc(1,sizeof(struct i_primary));
180 pnt->primtype=PRIM_SYMRANGE;
181 pnt->primval.symrange.sym=sym;
182 pnt->primval.symrange.msb=msb;
183 pnt->primval.symrange.lsb=lsb;
184 return(pnt);
185 }
186
187 struct i_explist *i_explist_make(struct i_explist *explist)
188 {
189 return(explist); /* for now..later this will traverse through and
190 print the individual structs out to the
191 intermediate file
192 */
193 }
194
195
196 struct i_primary *i_primary_concat_make(struct i_primary *count,
197 struct i_explist *exp)
198 {
199 struct i_primary *pnt;
200 pnt=(struct i_primary *)calloc(1,sizeof(struct i_primary));
201 pnt->primtype=PRIM_CONCAT;
202 pnt->primval.concat.count=count;
203 pnt->primval.concat.exp=exp;
204 return(pnt);
205 }
206
207 struct i_primary *i_primary_funcall_make(struct i_symbol *name,
208 struct i_explist *args)
209 {
210 struct i_primary *pnt;
211 pnt=(struct i_primary *)calloc(1,sizeof(struct i_primary));
212 pnt->primtype=PRIM_FUNC;
213 pnt->primval.funcall.name=name;
214 pnt->primval.funcall.args=args;
215 return(pnt);
216 }
217
218
219
220
221 /*
222 * print various i_structs out..
223 */
224 void print_operator(struct i_oper *o)
225 {
226 int op;
227
228 op=o->token;
229
230 switch(op)
231 {
232 case V_QUEST: printf("?\n"); break;
233 case V_COLON: printf(":\n"); break;
234 case V_PLUS: printf("+\n"); break;
235 case V_MINUS: printf("-\n"); break;
236 case V_BANG: printf("!\n"); break;
237 case V_TILDE: printf("~\n"); break;
238 case V_AND: printf("&\n"); break;
239 case V_NAND: printf("~&\n"); break;
240 case V_OR: printf("|\n"); break;
241 case V_NOR: printf("~|\n"); break;
242 case V_XOR: printf("^\n"); break;
243 case V_XNOR: printf("~^\n"); break;
244 case V_STAR: printf("*\n"); break;
245 case V_SLASH: printf("/\n"); break;
246 case V_MOD: printf("%%\n"); break;
247 case V_SHL: printf("<<\n"); break;
248 case V_SHR: printf(">>\n"); break;
249 case V_SSHL: printf("<<<\n"); break;
250 case V_SSHR: printf(">>>\n"); break;
251 case V_POW: printf("**\n"); break;
252 case V_LT: printf("<\n"); break;
253 case V_LEQ: printf("<=\n"); break;
254 case V_GT: printf(">\n"); break;
255 case V_GEQ: printf(">=\n"); break;
256 case V_EQ2: printf("==\n"); break;
257 case V_NEQ: printf("!=\n"); break;
258 case V_EQ3: printf("===\n"); break;
259 case V_NEQ2: printf("!==\n"); break;
260 case V_AND2: printf("&&\n"); break;
261 case V_OR2: printf("||\n"); break;
262 case V_EOF: printf("EOF\n"); break;
263 default: printf("Unknown: %d\n",op); break;
264 }
265 }
266
267
268 void print_primary(struct i_primary *pri)
269 {
270 if(pri)
271 {
272 if(pri->primtype==PRIM_FUNC)
273 {
274 printf("PRIM: FUNCALL (%s)\n",pri->primval.funcall.name->name);
275 printf("ARGS vvvvvvvvvvvv\n");
276 print_explist(pri->primval.funcall.args);
277 printf("ARGS ^^^^^^^^^^^^\n");
278 }
279 else
280 if(pri->primtype==PRIM_CONCAT)
281 {
282 print_concat(pri->primval.concat.count,
283 pri->primval.concat.exp);
284 }
285 else
286 if(pri->primtype==PRIM_SYMBIT)
287 {
288 printf("PRIM: SYMBIT (%s)\n",pri->primval.symbit.sym->name);
289 printf("vvvvvvvvvvvv\n");
290 print_primary(pri->primval.symbit.bitnum);
291 printf("^^^^^^^^^^^^\n");
292 }
293 else
294 if(pri->primtype==PRIM_SYMRANGE)
295 {
296 printf("PRIM: RANGE (%s)\n",pri->primval.symrange.sym->name);
297 printf("msb vvvvvvvvvvvv\n");
298 print_primary(pri->primval.symrange.msb);
299 printf("msb ^^^^^^^^^^^^\n");
300 printf("lsb vvvvvvvvvvvv\n");
301 print_primary(pri->primval.symrange.lsb);
302 printf("lsb ^^^^^^^^^^^^\n");
303 }
304 else
305 if(pri->primtype==PRIM_SYMBOL)
306 {
307 printf("PRIM: SYMBOL (%s)\n",pri->primval.symbol->name);
308 }
309 else
310 if(pri->primtype==PRIM_EXP)
311 {
312 printf("PRIM: EXPRESSION\n");
313 }
314 else
315 if(pri->primtype==PRIM_MINTYPMAX)
316 {
317 printf("PRIM: MINTYPMAX\n");
318 }
319 else
320 if(pri->primtype==PRIM_NUMBER)
321 {
322 if(pri->primval.number)
323 {
324 if(pri->primval.number->numtype==NV_IVAL)
325 {
326 printf("PRIM: %d\n",pri->primval.number->num.ival);
327 }
328 else if(pri->primval.number->numtype==NV_RVAL)
329 {
330 printf("PRIM: %.16g\n",pri->primval.number->num.rval);
331 }
332 else
333 {
334 printf("PRIM: %d %s\n",pri->primval.number->num.base.len,
335 pri->primval.number->num.base.val);
336 }
337 }
338 else
339 {
340 printf("NON-NUMBER PRIMARY\n");
341 };
342 }
343 else
344 {
345 printf("YET UNSUPPORTED PRIMARY\n");
346 }
347 }
348 else
349 {
350 printf("NULL PRIMARY\n");
351 }
352 }
353
354
355 void print_explist(struct i_explist *e)
356 {
357 printf("EXPLIST VVV ---------------------------------------------\n");
358 while(e)
359 {
360 print_primary(e->item);
361 e=e->next;
362 }
363 printf("EXPLIST ^^^ ---------------------------------------------\n");
364 }
365
366 void print_concat(struct i_primary *c, struct i_explist *e)
367 {
368 printf("CONCAT VVV ---------------------------------------------\n");
369 printf("-- COUNT VVV -------------------------------------------\n");
370 print_primary(c);
371 printf("-- COUNT ^^^ -------------------------------------------\n");
372 print_explist(e);
373 printf("CONCAT ^^^ ---------------------------------------------\n");
374 }
375
+0
-175
contrib/vermin/inter.h less more
0 #ifndef INTER_H
1 #define INTER_H
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <ctype.h>
7 #if !defined __MINGW32__ && !defined _MSC_VER
8 #include <sys/errno.h>
9 #endif
10 #include "attrib.h"
11 #include "antlr.h"
12 #include "keyword_tokens.h"
13
14 struct i_explist
15 {
16 struct i_explist *next;
17 struct i_primary *item;
18 };
19
20
21 enum SymTypeBits { SYMT_INPUT_B, SYMT_OUTPUT_B, SYMT_INOUT_B, SYMT_ARRAY_B, SYMT_PARAM_B,
22 SYMT_WIRE_B, SYMT_REG_B, SYMT_TIME_B, SYMT_IVAL_B, SYMT_RVAL_B, SYMT_EVENT_B };
23
24 #define SYMT_INPUT (1UL<<SYMT_INPUT_B)
25 #define SYMT_OUTPUT (1UL<<SYMT_OUTPUT_B)
26 #define SYMT_INOUT (1UL<<SYMT_INOUT_B)
27 #define SYMT_ARRAY (1UL<<SYMT_ARRAY_B)
28 #define SYMT_PARAM (1UL<<SYMT_PARAM_B)
29 #define SYMT_WIRE (1UL<<SYMT_WIRE_B)
30 #define SYMT_REG (1UL<<SYMT_REG_B)
31 #define SYMT_TIME (1UL<<SYMT_TIME_B)
32 #define SYMT_IVAL (1UL<<SYMT_IVAL_B)
33 #define SYMT_RVAL (1UL<<SYMT_RVAL_B)
34 #define SYMT_EVENT (1UL<<SYMT_EVENT_B)
35
36 struct i_symbol
37 {
38 char *name; /* actual name */
39
40 char *fileref; /* filename of first reference */
41 int firstref; /* linenumber of first reference */
42
43 unsigned int type;
44
45 int lowindex, highindex; /* for arrays */
46 union
47 {
48 struct
49 {
50 unsigned int num_bits; /* set this == 0 for unindexed netnames */
51 int msb, lsb;
52 } vecinfo;
53 struct i_primary *value; /* for parameter substitution */
54 } u;
55 };
56
57
58 struct i_oper
59 {
60 int prec;
61 int token;
62 };
63
64 enum NumValues { NV_IVAL, NV_RVAL, NV_DBASE, NV_BBASE, NV_OBASE, NV_HBASE, NV_STRING };
65
66 struct i_number
67 {
68 int numtype;
69
70 union
71 {
72 int ival;
73 double rval;
74 struct { int len; char *val; unsigned specified_width_flag:1; } base;
75 } num;
76 };
77
78
79 struct i_function_call
80 {
81 int i_bogus;
82 };
83
84 struct i_mintypmax_exp
85 {
86 int i_bogus;
87 };
88
89
90 enum PrimValues { PRIM_NUMBER, PRIM_SYMBOL, PRIM_SYMBIT, PRIM_SYMRANGE,
91 PRIM_CONCAT, PRIM_FUNC, PRIM_MINTYPMAX, PRIM_EXP,
92 PRIM_NAMEDPARAM
93 };
94
95 struct i_primary
96 {
97 int primtype;
98
99 union
100 {
101 struct i_number *number;
102 struct i_symbol *symbol;
103 struct i_function_call *func;
104 struct i_mintypmax_exp *min;
105 void *generic;
106
107 struct {
108 struct i_primary *prim1; /* null for unary */
109 struct i_oper *oper;
110 struct i_primary *prim2;
111 } binexp;
112
113 struct
114 { /* (a:b:c) operator */
115 struct i_primary *m1;
116 struct i_primary *m2;
117 struct i_primary *m3;
118 } mintypmax;
119
120 struct
121 {
122 struct i_symbol *sym; /* reference to symbol table name */
123 struct i_primary *bitnum; /* which bit */
124 } symbit;
125
126 struct
127 {
128 struct i_symbol *sym; /* reference to symbol table name */
129 struct i_primary *msb; /* leftmost bit */
130 struct i_primary *lsb; /* rightmost bit */
131 } symrange;
132
133 struct
134 {
135 struct i_primary *count; /* repeat count (NULL='1') */
136 struct i_explist *exp; /* list of primaries */
137 } concat;
138
139 struct
140 { /* function call */
141 struct i_symbol *name;
142 struct i_explist *args;
143 } funcall;
144
145 struct /* named parameter */
146 {
147 struct i_symbol *sym;
148 struct i_primary *exp;
149 } named_param;
150
151 } primval;
152 };
153
154
155 struct i_oper *i_oper_make(int token, int prec);
156 struct i_number *i_number_make(int ival);
157 struct i_number *i_number_fmake(double rval);
158 struct i_number *i_number_basemake(int typ, char *text);
159 struct i_primary *i_primary_make(int typ, void *vpnt);
160 struct i_primary *i_primary_mintypmax_make(struct i_primary *m1, struct i_primary *m2, struct i_primary *m3);
161 struct i_primary *i_bin_expr_make(struct i_primary *p1, struct i_oper *o1, struct i_primary *p2);
162 struct i_primary *i_primary_symbit_make(struct i_symbol *sym, struct i_primary *pri);
163 struct i_primary *i_primary_symrange_make(struct i_symbol *sym, struct i_primary *msb, struct i_primary *lsb);
164 struct i_explist *i_explist_make(struct i_explist *explist);
165 struct i_primary *i_primary_concat_make(struct i_primary *count, struct i_explist *exp);
166 struct i_primary *i_primary_funcall_make(struct i_symbol *name, struct i_explist *args);
167
168
169 void print_primary(struct i_primary *pri);
170 void print_explist(struct i_explist *e);
171 void print_concat(struct i_primary *c, struct i_explist *e);
172
173 #endif
174
+0
-608
contrib/vermin/jrb.c less more
0 /*
1 * Libraries for fields, doubly-linked lists and red-black trees.
2 * Copyright (C) 2001 James S. Plank
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 */
9
10 /* Revision 1.2. Jim Plank */
11
12 /* Original code by Jim Plank (plank@cs.utk.edu) */
13 /* modified for THINK C 6.0 for Macintosh by Chris Bartley */
14
15 #include <string.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <ctype.h>
19 #include "jrb.h"
20
21 static void mk_new_int(JRB l, JRB r, JRB p, int il);
22 static JRB lprev(JRB n);
23 static JRB rprev(JRB n);
24 static void recolor(JRB n);
25 static void single_rotate(JRB y, int l);
26
27 #define isred(n) (n->red)
28 #define isblack(n) (!isred(n))
29 #define isleft(n) (n->left)
30 #define isright(n) (!isleft(n))
31 #define isint(n) (n->internal)
32 #define isext(n) (!isint(n))
33 #define ishead(n) (n->roothead & 2)
34 #define isroot(n) (n->roothead & 1)
35 #define getlext(n) ((struct jrb_node *)(n->key.v))
36 #define setlext(node, val) node->key.v = (void *) (val)
37 #define getrext(n) ((struct jrb_node *)(n->val.v))
38 #define setrext(node, value) node->val.v = (void *) (value)
39 #define setred(n) n->red = 1
40 #define setblack(n) n->red = 0
41 #define setleft(n) n->left = 1
42 #define setright(n) n->left = 0
43 #define sethead(n) (n->roothead |= 2)
44 #define setroot(n) (n->roothead |= 1)
45 #define setint(n) n->internal = 1
46 #define setext(n) n->internal = 0
47 #define setnormal(n) n->roothead = 0
48 #define sibling(n) ((isleft(n)) ? n->parent->blink : n->parent->flink)
49
50 static void insert(JRB item, JRB list) /* Inserts to the end of a list */
51 {
52 JRB last_node;
53
54 last_node = list->blink;
55
56 list->blink = item;
57 last_node->flink = item;
58 item->blink = last_node;
59 item->flink = list;
60 }
61
62 static void delete_item(JRB item) /* Deletes an arbitrary iterm */
63 {
64 item->flink->blink = item->blink;
65 item->blink->flink = item->flink;
66 }
67
68 #define mk_new_ext(new, kkkey, vvval) {\
69 new = (JRB) malloc(sizeof(struct jrb_node));\
70 new->val = vvval;\
71 new->key = kkkey;\
72 setext(new);\
73 setblack(new);\
74 setnormal(new);\
75 }
76
77 static void mk_new_int(JRB l, JRB r, JRB p, int il)
78 {
79 JRB newnode;
80
81 newnode = (JRB) malloc(sizeof(struct jrb_node));
82 setint(newnode);
83 setred(newnode);
84 setnormal(newnode);
85 newnode->flink = l;
86 newnode->blink = r;
87 newnode->parent = p;
88 setlext(newnode, l);
89 setrext(newnode, r);
90 l->parent = newnode;
91 r->parent = newnode;
92 setleft(l);
93 setright(r);
94 if (ishead(p)) {
95 p->parent = newnode;
96 setroot(newnode);
97 } else if (il) {
98 setleft(newnode);
99 p->flink = newnode;
100 } else {
101 setright(newnode);
102 p->blink = newnode;
103 }
104 recolor(newnode);
105 }
106
107
108 JRB lprev(JRB n)
109 {
110 if (ishead(n)) return n;
111 while (!isroot(n)) {
112 if (isright(n)) return n->parent;
113 n = n->parent;
114 }
115 return n->parent;
116 }
117
118 JRB rprev(JRB n)
119 {
120 if (ishead(n)) return n;
121 while (!isroot(n)) {
122 if (isleft(n)) return n->parent;
123 n = n->parent;
124 }
125 return n->parent;
126 }
127
128 JRB make_jrb()
129 {
130 JRB head;
131
132 head = (JRB) calloc (1, sizeof(struct jrb_node)); /* scan-build because of sethead() below */
133 head->flink = head;
134 head->blink = head;
135 head->parent = head;
136 head->key.s = "";
137 sethead(head);
138 return head;
139 }
140
141 JRB jrb_find_gte_str(JRB n, char *key, int *fnd)
142 {
143 int cmp;
144
145 *fnd = 0;
146 if (!ishead(n)) {
147 fprintf(stderr, "jrb_find_gte_str called on non-head 0x%p\n", (void *)n);
148 exit(1);
149 }
150 if (n->parent == n) return n;
151 cmp = strcmp(key, n->blink->key.s);
152 if (cmp == 0) {
153 *fnd = 1;
154 return n->blink;
155 }
156 if (cmp > 0) return n;
157 else n = n->parent;
158 while (1) {
159 if (isext(n)) return n;
160 cmp = strcmp(key, getlext(n)->key.s);
161 if (cmp == 0) {
162 *fnd = 1;
163 return getlext(n);
164 }
165 if (cmp < 0) n = n->flink ; else n = n->blink;
166 }
167 }
168
169 JRB jrb_find_str(JRB n, char *key)
170 {
171 int fnd;
172 JRB j;
173 j = jrb_find_gte_str(n, key, &fnd);
174 if (fnd) return j; else return NULL;
175 }
176
177 JRB jrb_find_gte_int(JRB n, int ikey, int *fnd)
178 {
179 *fnd = 0;
180 if (!ishead(n)) {
181 fprintf(stderr, "jrb_find_gte_int called on non-head 0x%p\n", (void *)n);
182 exit(1);
183 }
184 if (n->parent == n) return n;
185 if (ikey == n->blink->key.i) {
186 *fnd = 1;
187 return n->blink;
188 }
189 if (ikey > n->blink->key.i) return n;
190 else n = n->parent;
191 while (1) {
192 if (isext(n)) return n;
193 if (ikey == getlext(n)->key.i) {
194 *fnd = 1;
195 return getlext(n);
196 }
197 n = (ikey < getlext(n)->key.i) ? n->flink : n->blink;
198 }
199 }
200
201 JRB jrb_find_int(JRB n, int ikey)
202 {
203 int fnd;
204 JRB j;
205
206 j = jrb_find_gte_int(n, ikey, &fnd);
207 if (fnd) return j; else return NULL;
208 }
209
210 JRB jrb_find_gte_vptr(JRB n, void *vkey, int *fnd)
211 {
212 *fnd = 0;
213 if (!ishead(n)) {
214 fprintf(stderr, "jrb_find_gte_int called on non-head 0x%p\n", (void *)n);
215 exit(1);
216 }
217 if (n->parent == n) return n;
218 if ((char *)vkey == (char *)n->blink->key.v) {
219 *fnd = 1;
220 return n->blink;
221 }
222 if ((char *)vkey > (char *)n->blink->key.v) return n;
223 else n = n->parent;
224 while (1) {
225 if (isext(n)) return n;
226 if ((char *)vkey == (char *)getlext(n)->key.v) {
227 *fnd = 1;
228 return getlext(n);
229 }
230 n = ((char *)vkey < (char *)getlext(n)->key.v) ? n->flink : n->blink;
231 }
232 }
233
234 JRB jrb_find_vptr(JRB n, void *vkey)
235 {
236 int fnd;
237 JRB j;
238
239 j = jrb_find_gte_vptr(n, vkey, &fnd);
240 if (fnd) return j; else return NULL;
241 }
242
243 JRB jrb_find_gte_gen(JRB n, Jval key,int (*fxn)(Jval, Jval), int *fnd)
244 {
245 int cmp;
246
247 *fnd = 0;
248 if (!ishead(n)) {
249 fprintf(stderr, "jrb_find_gte_str called on non-head 0x%p\n", (void *)n);
250 exit(1);
251 }
252 if (n->parent == n) return n;
253 cmp = (*fxn)(key, n->blink->key);
254 if (cmp == 0) {
255 *fnd = 1;
256 return n->blink;
257 }
258 if (cmp > 0) return n;
259 else n = n->parent;
260 while (1) {
261 if (isext(n)) return n;
262 cmp = (*fxn)(key, getlext(n)->key);
263 if (cmp == 0) {
264 *fnd = 1;
265 return getlext(n);
266 }
267 if (cmp < 0) n = n->flink ; else n = n->blink;
268 }
269 }
270
271 JRB jrb_find_gen(JRB n, Jval key, int (*fxn)(Jval, Jval))
272 {
273 int fnd;
274 JRB j;
275
276 j = jrb_find_gte_gen(n, key, fxn, &fnd);
277 if (fnd) return j; else return NULL;
278 }
279
280 static JRB jrb_insert_b(JRB n, Jval key, Jval val)
281 {
282 JRB newleft, newright, newnode, p;
283
284 if (ishead(n)) {
285 if (n->parent == n) { /* Tree is empty */
286 mk_new_ext(newnode, key, val);
287 insert(newnode, n);
288 n->parent = newnode;
289 newnode->parent = n;
290 setroot(newnode);
291 return newnode;
292 } else {
293 mk_new_ext(newright, key, val);
294 insert(newright, n);
295 newleft = newright->blink;
296 setnormal(newleft);
297 mk_new_int(newleft, newright, newleft->parent, isleft(newleft));
298 p = rprev(newright);
299 if (!ishead(p)) setlext(p, newright);
300 return newright;
301 }
302 } else {
303 mk_new_ext(newleft, key, val);
304 insert(newleft, n);
305 setnormal(n);
306 mk_new_int(newleft, n, n->parent, isleft(n));
307 p = lprev(newleft);
308 if (!ishead(p)) setrext(p, newleft);
309 return newleft;
310 }
311 }
312
313 static void recolor(JRB n)
314 {
315 JRB p, gp, s;
316 int done = 0;
317
318 while(!done) {
319 if (isroot(n)) {
320 setblack(n);
321 return;
322 }
323
324 p = n->parent;
325
326 if (isblack(p)) return;
327
328 if (isroot(p)) {
329 setblack(p);
330 return;
331 }
332
333 gp = p->parent;
334 s = sibling(p);
335 if (isred(s)) {
336 setblack(p);
337 setred(gp);
338 setblack(s);
339 n = gp;
340 } else {
341 done = 1;
342 }
343 }
344 /* p's sibling is black, p is red, gp is black */
345
346 if ((isleft(n) == 0) == (isleft(p) == 0)) {
347 single_rotate(gp, isleft(n));
348 setblack(p);
349 setred(gp);
350 } else {
351 single_rotate(p, isleft(n));
352 single_rotate(gp, isleft(n));
353 setblack(n);
354 setred(gp);
355 }
356 }
357
358 static void single_rotate(JRB y, int l)
359 {
360 int rl = 0, ir;
361 JRB x, yp;
362
363 ir = isroot(y);
364 yp = y->parent;
365 if (!ir) {
366 rl = isleft(y);
367 }
368
369 if (l) {
370 x = y->flink;
371 y->flink = x->blink;
372 setleft(y->flink);
373 y->flink->parent = y;
374 x->blink = y;
375 setright(y);
376 } else {
377 x = y->blink;
378 y->blink = x->flink;
379 setright(y->blink);
380 y->blink->parent = y;
381 x->flink = y;
382 setleft(y);
383 }
384
385 x->parent = yp;
386 y->parent = x;
387 if (ir) {
388 yp->parent = x;
389 setnormal(y);
390 setroot(x);
391 } else {
392 if (rl) {
393 yp->flink = x;
394 setleft(x);
395 } else {
396 yp->blink = x;
397 setright(x);
398 }
399 }
400 }
401
402 void jrb_delete_node(JRB n)
403 {
404 JRB s, p, gp;
405 char ir;
406
407 if (isint(n)) {
408 fprintf(stderr, "Cannot delete an internal node: 0x%p\n", (void *)n);
409 exit(1);
410 }
411 if (ishead(n)) {
412 fprintf(stderr, "Cannot delete the head of an jrb_tree: 0x%p\n", (void *)n);
413 exit(1);
414 }
415 delete_item(n); /* Delete it from the list */
416 p = n->parent; /* The only node */
417 if (isroot(n)) {
418 p->parent = p;
419 free(n);
420 return;
421 }
422 s = sibling(n); /* The only node after deletion */
423 if (isroot(p)) {
424 s->parent = p->parent;
425 s->parent->parent = s;
426 setroot(s);
427 free(p);
428 free(n);
429 return;
430 }
431 gp = p->parent; /* Set parent to sibling */
432 s->parent = gp;
433 if (isleft(p)) {
434 gp->flink = s;
435 setleft(s);
436 } else {
437 gp->blink = s;
438 setright(s);
439 }
440 ir = isred(p);
441 free(p);
442 free(n);
443
444 if (isext(s)) { /* Update proper rext and lext values */
445 p = lprev(s);
446 if (!ishead(p)) setrext(p, s);
447 p = rprev(s);
448 if (!ishead(p)) setlext(p, s);
449 } else if (isblack(s)) {
450 fprintf(stderr, "DELETION PROB -- sib is black, internal\n");
451 exit(1);
452 } else {
453 p = lprev(s);
454 if (!ishead(p)) setrext(p, s->flink);
455 p = rprev(s);
456 if (!ishead(p)) setlext(p, s->blink);
457 setblack(s);
458 return;
459 }
460
461 if (ir) return;
462
463 /* Recolor */
464
465 n = s;
466 p = n->parent;
467 s = sibling(n);
468 while(isblack(p) && isblack(s) && isint(s) &&
469 isblack(s->flink) && isblack(s->blink)) {
470 setred(s);
471 n = p;
472 if (isroot(n)) return;
473 p = n->parent;
474 s = sibling(n);
475 }
476
477 if (isblack(p) && isred(s)) { /* Rotation 2.3b */
478 single_rotate(p, isright(n));
479 setred(p);
480 setblack(s);
481 s = sibling(n);
482 }
483
484 { JRB x, z; char il;
485
486 if (isext(s)) {
487 fprintf(stderr, "DELETION ERROR: sibling not internal\n");
488 exit(1);
489 }
490
491 il = isleft(n);
492 x = il ? s->flink : s->blink ;
493 z = sibling(x);
494
495 if (isred(z)) { /* Rotation 2.3f */
496 single_rotate(p, !il);
497 setblack(z);
498 if (isred(p)) setred(s); else setblack(s);
499 setblack(p);
500 } else if (isblack(x)) { /* Recoloring only (2.3c) */
501 if (isred(s) || isblack(p)) {
502 fprintf(stderr, "DELETION ERROR: 2.3c not quite right\n");
503 exit(1);
504 }
505 setblack(p);
506 setred(s);
507 return;
508 } else if (isred(p)) { /* 2.3d */
509 single_rotate(s, il);
510 single_rotate(p, !il);
511 setblack(x);
512 setred(s);
513 return;
514 } else { /* 2.3e */
515 single_rotate(s, il);
516 single_rotate(p, !il);
517 setblack(x);
518 return;
519 }
520 }
521 }
522
523 int jrb_nblack(JRB n)
524 {
525 int nb;
526 if (ishead(n) || isint(n)) {
527 fprintf(stderr, "ERROR: jrb_nblack called on a non-external node 0x%p\n",
528 (void *)n);
529 exit(1);
530 }
531 nb = 0;
532 while(!ishead(n)) {
533 if (isblack(n)) nb++;
534 n = n->parent;
535 }
536 return nb;
537 }
538
539 int jrb_plength(JRB n)
540 {
541 int pl;
542 if (ishead(n) || isint(n)) {
543 fprintf(stderr, "ERROR: jrb_plength called on a non-external node 0x%p\n",
544 (void *)n);
545 exit(1);
546 }
547 pl = 0;
548 while(!ishead(n)) {
549 pl++;
550 n = n->parent;
551 }
552 return pl;
553 }
554
555 void jrb_free_tree(JRB n)
556 {
557 if (!ishead(n)) {
558 fprintf(stderr, "ERROR: Rb_free_tree called on a non-head node\n");
559 exit(1);
560 }
561
562 while(jrb_first(n) != jrb_nil(n)) {
563 jrb_delete_node(jrb_first(n));
564 }
565 free(n);
566 }
567
568 Jval jrb_val(JRB n)
569 {
570 return n->val;
571 }
572
573 JRB jrb_insert_str(JRB tree, char *key, Jval val)
574 {
575 Jval k;
576 int fnd;
577
578 k.s = key;
579 return jrb_insert_b(jrb_find_gte_str(tree, key, &fnd), k, val);
580 }
581
582 JRB jrb_insert_int(JRB tree, int ikey, Jval val)
583 {
584 Jval k;
585 int fnd;
586
587 k.i = ikey;
588 return jrb_insert_b(jrb_find_gte_int(tree, ikey, &fnd), k, val);
589 }
590
591 JRB jrb_insert_vptr(JRB tree, void *vkey, Jval val)
592 {
593 Jval k;
594 int fnd;
595
596 k.v = vkey;
597 return jrb_insert_b(jrb_find_gte_vptr(tree, vkey, &fnd), k, val);
598 }
599
600 JRB jrb_insert_gen(JRB tree, Jval key, Jval val,
601 int (*func)(Jval, Jval))
602 {
603 int fnd;
604
605 return jrb_insert_b(jrb_find_gte_gen(tree, key, func, &fnd), key, val);
606 }
607
+0
-108
contrib/vermin/jrb.h less more
0 #ifndef _JRB_H_
1 #define _JRB_H_
2
3 /* The Jval -- a type that can hold any 8-byte type */
4
5 typedef union {
6 int i;
7 long l;
8 float f;
9 double d;
10 void *v;
11 char *s;
12 char c;
13 unsigned char uc;
14 short sh;
15 unsigned short ush;
16 unsigned int ui;
17 int iarray[2];
18 float farray[2];
19 char carray[8];
20 unsigned char ucarray[8];
21 } Jval;
22
23
24 /* Main jrb_node. You only ever use the fields
25 flink
26 blink
27 k.key or k.ikey
28 v.val
29 */
30 typedef struct jrb_node {
31 unsigned char red;
32 unsigned char internal;
33 unsigned char left;
34 unsigned char roothead; /* (bit 1 is root, bit 2 is head) */
35 struct jrb_node *flink;
36 struct jrb_node *blink;
37 struct jrb_node *parent;
38 Jval key;
39 Jval val;
40 } *JRB;
41
42
43 extern JRB make_jrb(); /* Creates a new rb-tree */
44
45
46 /* Creates a node with key key and val val and inserts it into the tree.
47 jrb_insert uses strcmp() as comparison funcion. jrb_inserti uses <>=,
48 jrb_insertg uses func() */
49
50 extern JRB jrb_insert_str(JRB tree, char *key, Jval val);
51 extern JRB jrb_insert_int(JRB tree, int ikey, Jval val);
52 extern JRB jrb_insert_vptr(JRB tree, void *vkey, Jval val);
53 extern JRB jrb_insert_gen(JRB tree, Jval key, Jval val, int (*func)(Jval,Jval));
54
55 /* returns an external node in t whose value is equal k. Returns NULL if
56 there is no such node in the tree */
57
58 extern JRB jrb_find_str(JRB root, char *key);
59 extern JRB jrb_find_int(JRB root, int ikey);
60 extern JRB jrb_find_vptr(JRB root, void *vkey);
61 extern JRB jrb_find_gen(JRB root, Jval, int (*func)(Jval, Jval));
62
63
64 /* returns an external node in t whose value is equal
65 k or whose value is the smallest value greater than k. Sets found to
66 1 if the key was found, and 0 otherwise. */
67
68 extern JRB jrb_find_gte_str(JRB root, char *key, int *found);
69 extern JRB jrb_find_gte_int(JRB root, int ikey, int *found);
70 extern JRB jrb_find_gte_vptr(JRB root, void *vkey, int *found);
71 extern JRB jrb_find_gte_gen(JRB root, Jval key,
72 int (*func)(Jval, Jval), int *found);
73
74
75 /* Creates a node with key key and val val and inserts it into the
76 tree before/after node nd. Does not check to ensure that you are
77 keeping the correct order */
78
79 extern void jrb_delete_node(JRB node); /* Deletes and frees a node (but
80 not the key or val) */
81 extern void jrb_free_tree(JRB root); /* Deletes and frees an entire tree */
82
83 extern Jval jrb_val(JRB node); /* Returns node->v.val -- this is to shut
84 lint up */
85
86 extern int jrb_nblack(JRB n); /* returns # of black nodes in path from
87 n to the root */
88 int jrb_plength(JRB n); /* returns the # of nodes in path from
89 n to the root */
90
91 #define jrb_first(n) (n->flink)
92 #define jrb_last(n) (n->blink)
93 #define jrb_next(n) (n->flink)
94 #define jrb_prev(n) (n->blink)
95 #define jrb_empty(t) (t->flink == t)
96 #ifndef jrb_nil
97 #define jrb_nil(t) (t)
98 #endif
99
100 #define jrb_traverse(ptr, lst) \
101 for(ptr = jrb_first(lst); ptr != jrb_nil(lst); ptr = jrb_next(ptr))
102
103 #define jrb_rtraverse(ptr, lst) \
104 for(ptr = jrb_last(lst); ptr != jrb_nil(lst); ptr = jrb_prev(ptr))
105
106 #endif
107
+0
-190
contrib/vermin/keyword_tokens.h less more
0 #ifndef _VERTEX_KEYWORD_TOKENS_H
1 #define _VERTEX_KEYWORD_TOKENS_H
2
3 enum VertexKeywordTokens {
4 /* zzEOF_TOKEN=1, */
5 V_EOF=1,
6 V_DECIMAL_NUMBER,
7 V_FLOAT1,
8 V_FLOAT2,
9 V_DBASE,
10 V_BBASE,
11 V_OBASE,
12 V_HBASE,
13 V_STRING,
14 V_EQ,
15 V_DOT,
16 V_PLUS,
17 V_MINUS,
18 V_BANG,
19 V_TILDE,
20 V_AND,
21 V_NAND,
22 V_OR,
23 V_NOR,
24 V_XOR,
25 V_XNOR,
26 V_STAR,
27 V_SLASH,
28 V_MOD,
29 V_EQ2,
30 V_NEQ,
31 V_EQ3,
32 V_NEQ2,
33 V_AND2,
34 V_AND3,
35 V_OR2,
36 V_LT,
37 V_LEQ,
38 V_GT,
39 V_GEQ,
40 V_XNOR2,
41 V_SHL,
42 V_SHR,
43 V_QUEST,
44 V_COLON,
45 V_LP,
46 V_RP,
47 V_LBRACK,
48 V_RBRACK,
49 V_LBRACE,
50 V_RBRACE,
51 V_COMMA,
52 V_AT,
53 V_SEMI,
54 V_POUND,
55 V_RARROW,
56 V_SPD1,
57 V_SPD2,
58 V_IDENTIFIER,
59 V_IDENTIFIER2,
60 V_IDENDOT,
61 V_LEVEL_SYMBOL_EXTRA,
62 V_HYPHEN,
63 V_EDGE_SYMBOL,
64 V_FUNCTION_NAME,
65 V_OUTPUT_SYMBOL,
66 V_ALWAYS,
67 V_ANDLIT,
68 V_ASSIGN,
69 V_BEGIN,
70 V_BUF,
71 V_BUFIF0,
72 V_BUFIF1,
73 V_CASE,
74 V_CASEX,
75 V_CASEZ,
76 V_CMOS,
77 V_DEASSIGN,
78 V_DEFAULT,
79 V_DEFPARAM,
80 V_DISABLE,
81 V_EDGE,
82 V_ELSE,
83 V_END,
84 V_ENDCASE,
85 V_ENDFUNCTION,
86 V_ENDMODULE,
87 V_ENDPRIMITIVE,
88 V_ENDSPECIFY,
89 V_ENDTABLE,
90 V_ENDTASK,
91 V_EVENT,
92 V_FOR,
93 V_FORCE,
94 V_FOREVER,
95 V_FORK,
96 V_FUNCTION,
97 V_HIGHZ0,
98 V_HIGHZ1,
99 V_IF,
100 V_INITIAL,
101 V_INOUT,
102 V_INPUT,
103 V_INTEGER,
104 V_JOIN,
105 V_LARGE,
106 V_MACROMODULE,
107 V_MEDIUM,
108 V_MODULE,
109 V_NANDLIT,
110 V_NEGEDGE,
111 V_NMOS,
112 V_NORLIT,
113 V_NOTIF0,
114 V_NOTIF1,
115 V_NOTLIT,
116 V_ORLIT,
117 V_OUTPUT,
118 V_PARAMETER,
119 V_PMOS,
120 V_POSEDGE,
121 V_PRIMITIVE,
122 V_PULL0,
123 V_PULL1,
124 V_PULLDOWN,
125 V_PULLUP,
126 V_RCMOS,
127 V_REAL,
128 V_REG,
129 V_RELEASE,
130 V_REPEAT,
131 V_RNMOS,
132 V_RPMOS,
133 V_RTRAN,
134 V_RTRANIF0,
135 V_RTRANIF1,
136 V_SCALARED,
137 V_SMALL,
138 V_SPECIFY,
139 V_SPECPARAM,
140 V_STRONG0,
141 V_STRONG1,
142 V_SUPPLY0,
143 V_SUPPLY1,
144 V_TABLE,
145 V_TASK,
146 V_TIME,
147 V_TRAN,
148 V_TRANIF0,
149 V_TRANIF1,
150 V_TRI,
151 V_TRI0,
152 V_TRI1,
153 V_TRIAND,
154 V_TRIOR,
155 V_TRIREG,
156 V_VECTORED,
157 V_WAIT,
158 V_WAND,
159 V_WEAK0,
160 V_WEAK1,
161 V_WHILE,
162 V_WIRE,
163 V_WOR,
164 V_XNORLIT,
165 V_XORLIT,
166 /* Verilog 2001 additions */
167 V_AUTOMATIC,
168 V_CELL,
169 V_CONFIG,
170 V_DESIGN,
171 V_ENDCONFIG,
172 V_ENDGENERATE,
173 V_GENERATE,
174 V_GENVAR,
175 V_INSTANCE,
176 V_LIBLIST,
177 V_LOCALPARAM,
178 V_NOSHOWCANCELLED,
179 V_PULSESTYLE_ONEVENT,
180 V_PULSESTYLE_ONDETECT,
181 V_SHOWCANCELLED,
182 V_SIGNED,
183 V_USE,
184 V_SSHL,
185 V_SSHR,
186 V_POW
187 };
188 #endif
189
+0
-1054
contrib/vermin/preproc.c less more
0 #include <stdio.h>
1 #include <stdlib.h>
2 #include <stdarg.h>
3 #include <string.h>
4 #include <dirent.h>
5 #include <unistd.h>
6 #include <inttypes.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include "vpp_common.h"
10 #include "attrib.h"
11 #include "jrb.h"
12
13 struct vpp_filename *vlog_filenames=NULL; /* list of verilog files to process */
14 struct vpp_filename *incchain=NULL; /* list of include directories */
15
16 extern char *zzfilename;
17 extern int zzline;
18 extern int zzerrors;
19 extern int zzrewind;
20 static FILE *fh = NULL;
21 FILE *mgetchar_fout = NULL;
22
23 JRB define_tree = NULL;
24 struct ifdef_stack_t *ifdef_stack_top = NULL;
25 struct include_stack_t *include_stack_top = NULL;
26 int include_stack_depth = 0;
27 struct macro_stack_t *mac_nest_head = NULL;
28
29 /*
30 * strcmp for char** qsort/bsearches
31 */
32 static int compar_cstarstar(const void *v1, const void *v2)
33 {
34 const char **s1 = (const char **)v1, **s2 = (const char **)v2;
35 return(strcasecmp(*s1, *s2));
36 }
37
38
39 int compar_cstarstar_bsearch(const void *v1, const void *v2)
40 {
41 const char *s1 = (const char *)v1;
42 const char **s2 = (const char **)v2;
43 return(strcasecmp(s1, *s2));
44 }
45
46
47 /*
48 * iterate on given directory (for -yi command opt)
49 */
50 int dirscan(char *path, struct vpp_filename *fn)
51 {
52 DIR *dp = opendir(path);
53 struct dirent *dirp;
54 int pathlen = strlen(path);
55 int nument = 0;
56 struct stringchain_t *sc=NULL, *sct;
57 int i;
58
59 if(dp)
60 {
61 while((dirp=readdir(dp)))
62 {
63 char *fullpath = malloc(pathlen + 1 + strlen(dirp->d_name) + 1);
64 struct stat buf;
65
66 sprintf(fullpath, "%s/%s", path, dirp->d_name);
67 if(!stat(fullpath, &buf))
68 {
69 if(S_ISREG(buf.st_mode))
70 {
71 sct = (struct stringchain_t *)calloc(1, sizeof(struct stringchain_t));
72 sct->name = strdup(dirp->d_name);
73 sct->next = sc;
74 sc = sct;
75 nument++;
76 }
77 }
78 free(fullpath);
79 }
80
81 if(nument)
82 {
83 fn->numchildren = nument;
84 fn->children = malloc(nument*sizeof(char *));
85
86 for(i=0;i<nument;i++)
87 {
88 fn->children[i] = sc->name;
89 sct = sc->next;
90 free(sc);
91 sc = sct;
92 }
93
94 qsort(fn->children, nument, sizeof(char **), compar_cstarstar);
95 }
96 }
97
98 return(dp!=NULL);
99 }
100
101
102 /*
103 * generic maintenance functions...
104 */
105 void vpp_update_yyfilename(const char *str)
106 {
107 if(!zzfilename)
108 {
109 zzfilename=malloc(strlen(str)+1);
110 strcpy(zzfilename, str);
111 }
112 else
113 {
114 free(zzfilename);
115 zzfilename=malloc(strlen(str)+1);
116 strcpy(zzfilename, str);
117 }
118 }
119
120
121 void vpp_update_yylineno(const char *str)
122 {
123 zzline = atoi(str) - 1; /* because \n follows this vpp directive! */
124 zzrewind=0;
125 }
126
127
128 unsigned int atoi_with_underscores(char *s)
129 {
130 const uint64_t max32 = 4294967295ULL;
131
132 uint64_t val;
133 unsigned int chval;
134
135 val = 0ULL;
136 while((*s) && (*s!='\''))
137 {
138 if(*s!='_')
139 {
140 chval = ((*s) -'0');
141 val *= 10ULL;
142 val += ((uint64_t)chval);
143 if(val>max32)
144 {
145 warn("** Warning: Large constant truncated to MAXINT in file '%s' line %d\n", zzfilename, zzline);
146 return((unsigned int)max32);
147 }
148 }
149
150 s++;
151 }
152
153 return((unsigned int)val);
154 }
155
156
157 /*
158 * Print a message on stderr and increment the zzerrors counter.
159 */
160 void mesg(const char *format, ...)
161 {
162 va_list ap;
163 va_start(ap, format);
164 vfprintf(stderr, format, ap);
165 zzerrors += 1;
166 va_end(ap);
167 }
168
169
170 /*
171 * Print a message on stderr but do NOT increment zzerrors
172 */
173 void warn(const char *format, ...)
174 {
175 va_list ap;
176 va_start(ap, format);
177 vfprintf(stderr, format, ap);
178 va_end(ap);
179 }
180
181
182 /*
183 * printf to memory..
184 */
185 struct preproc_buff_t *preproc_buff_head=NULL, *preproc_buff_current=NULL;
186
187 int mprintf(const char *fmt, ... )
188 {
189 int rc;
190 va_list args;
191 struct preproc_buff_t *bt = (struct preproc_buff_t *)calloc(1, sizeof(struct preproc_buff_t));
192 char buff[65537];
193
194 va_start(args, fmt);
195 rc=vsprintf(buff, fmt, args);
196 /* vfprintf(stderr, fmt, args); */
197 bt->len = strlen(buff);
198 bt->str = malloc(bt->len+1);
199 strcpy(bt->str, buff);
200
201 if(!preproc_buff_current)
202 {
203 preproc_buff_head = preproc_buff_current = bt;
204 }
205 else
206 {
207 preproc_buff_current->next = bt;
208 preproc_buff_current = bt;
209 }
210
211 va_end(args);
212 return(rc);
213 }
214
215
216 /*
217 * get maxsiz chars from memory and copy into buf
218 * (return actual number of characters copied)
219 */
220 int mgetstr(char *buf, int maxsiz)
221 {
222 struct preproc_buff_t *bt = preproc_buff_head;
223 int cpylen;
224
225 if(!bt) return(0);
226
227 cpylen = bt->len-bt->pos;
228 if(cpylen <= maxsiz)
229 {
230 memcpy(buf, bt->str + bt->pos, cpylen);
231 free(bt->str);
232
233 if(bt != preproc_buff_current)
234 {
235 preproc_buff_head = bt->next;
236 }
237 else
238 {
239 preproc_buff_head = preproc_buff_current = NULL;
240 }
241 free(bt);
242 }
243 else
244 {
245 memcpy(buf, bt->str + bt->pos, maxsiz);
246 bt->pos += (cpylen=maxsiz);
247 }
248
249 return(cpylen);
250 }
251
252
253 /*
254 * routines which get a single char and pushback define stuff
255 * into the memory buffer as needed
256 */
257 int mgetchar2(void)
258 {
259 unsigned char cbuf[2];
260
261 if(preproc_buff_head)
262 {
263 mgetstr((char *)cbuf, 1);
264 return(cbuf[0]);
265 }
266
267 if(fh)
268 {
269 int rc = fgetc(fh);
270 if(rc==EOF) /* need to do include file handling here */
271 {
272 fclose(fh);
273 fh=NULL;
274 }
275 else
276 {
277 return(rc);
278 }
279 }
280
281 if(pop_include())
282 {
283 return(mgetchar2());
284 }
285 else
286 while(vlog_filenames)
287 {
288 struct vpp_filename *vt=vlog_filenames;
289 struct stat buf;
290 int stat_rc = stat(vt->name, &buf);
291 int isdir = (!stat_rc)&&(S_ISDIR(buf.st_mode));
292
293 warn("Processing file '%s' ...\n", vt->name);
294
295 fh=fopen(vt->name, "rb");
296 if(!fh)
297 {
298 mesg("** Error: could not open file '%s'\n", vt->name);
299 }
300 else
301 {
302 if(!isdir)
303 {
304 mprintf("// vpp_file %s \n", vt->name);
305 mprintf("// vpp_line %d\n", 1);
306 }
307 else
308 {
309 /* skip as it's a directory */
310 fclose(fh); fh = NULL;
311 }
312 }
313
314 free(vt->name);
315 vlog_filenames = vlog_filenames->next;
316 free(vt);
317
318 if(fh) return(mgetchar2());
319 }
320
321 return(EOF);
322 }
323
324 int mgetchar(void)
325 {
326 int rc = mgetchar2();
327 int len;
328 char buf[1025];
329 struct preproc_buff_t *bt;
330 struct macro_stack_t *mac;
331 static char inside_skip = 0;
332 static int prevrc = 0;
333
334 if((mac_nest_head) /* &&(!(--mac_nest_head->remaining)) */)
335 {
336 free(mac_nest_head->macname);
337 free(mac_nest_head->deftext);
338 mac=mac_nest_head;
339 mac_nest_head=mac_nest_head->next;
340 free(mac);
341 }
342
343 switch(inside_skip) /* gate out macro expansion inside comments/strings */
344 {
345 case 0: if(rc=='/') inside_skip = 1;
346 else if(rc=='\"') { prevrc = 0; inside_skip = 5; }
347 break;
348
349 case 1: if(rc=='*') inside_skip = 2;
350 else if(rc=='/') inside_skip = 3;
351 else inside_skip = 0;
352 break;
353
354 case 2: if(rc=='*') inside_skip = 4;
355 else if(rc==EOF) inside_skip = 0;
356 break;
357
358 case 3: if((rc=='\n')||(rc==EOF)) inside_skip = 0;
359 break;
360
361 case 4: if((rc=='/')||(rc==EOF)) inside_skip = 0;
362 else if(rc!='*') inside_skip = 2;
363 break;
364
365 case 5:
366 default:
367 if( ((rc=='\"')&&(prevrc!='\\'))
368 ||(rc=='\n')||(rc=='\r')||(rc==EOF) ) inside_skip = 0;
369 else
370 if(rc=='\"')
371 {
372 bt = (struct preproc_buff_t *)calloc(1, sizeof(struct preproc_buff_t));
373 bt->len = 2;
374 bt->str = strdup("42"); /* octal for quote */
375 bt->next = preproc_buff_head;
376 preproc_buff_head = bt;
377 rc = '0'; /* give octal char this pass */
378 }
379
380 prevrc = (prevrc!='\\') ? rc : 0; /* to handle \\" at end of string properly */
381 break;
382 }
383
384
385 if((rc!='`')||(inside_skip))
386 {
387 return(rc);
388 }
389 else
390 {
391 len=0;
392
393 while((rc=mgetchar2())!=EOF)
394 {
395 if (
396 ((rc>='a')&&(rc<='z')) ||
397 ((rc>='A')&&(rc<='Z')) ||
398 ((rc>='0')&&(rc<='9')) ||
399 (rc=='_') ||
400 (rc=='$')
401 )
402 {
403 buf[len++] = rc;
404 continue;
405 }
406 else
407 {
408 break;
409 }
410 }
411 buf[len]=0;
412
413 if(rc!=EOF)
414 {
415 bt = (struct preproc_buff_t *)calloc(1, sizeof(struct preproc_buff_t));
416 bt->len = 1;
417 bt->str = calloc(2, sizeof(char));
418 *bt->str = rc;
419 bt->next = preproc_buff_head;
420 preproc_buff_head = bt;
421 }
422
423 if(len==0)
424 {
425 return('`');
426 }
427
428 if(!is_builtin_define(buf, len))
429 {
430 JRB node;
431
432 if((node=jrb_find_str(define_tree, buf)))
433 {
434 if(node->val.s)
435 {
436 bt = (struct preproc_buff_t *)calloc(1, sizeof(struct preproc_buff_t));
437 bt->len = strlen(node->val.s);
438 bt->str = strdup(node->val.s);
439 bt->next = preproc_buff_head;
440 preproc_buff_head = bt;
441
442 mac = (struct macro_stack_t *)calloc(1, sizeof(struct macro_stack_t));
443 mac->remaining = bt->len;
444 mac->macname = strdup(buf);
445 mac->deftext = strdup(bt->str);
446 mac->next = mac_nest_head;
447 mac_nest_head = mac;
448
449 mac=mac->next;
450 while(mac)
451 {
452 if(!strcmp(mac->macname, mac_nest_head->macname))
453 {
454 int depth=1;
455 mac = mac_nest_head->next;
456 mesg("** Error: recursive macro expansion encountered in file '%s' line %d, reverse trace follows\n", zzfilename, zzline);
457 do {
458 warn("%7d : `%s = '%s'\n", depth++, mac->macname, mac->deftext);
459 mac=mac->next;
460 } while(mac);
461
462 zzerrors+=zzLexErrCount;
463 warn("\n** %d error%s detected, exiting.\n\n",zzerrors,(zzerrors>1)?"s were":" was");
464 exit(255);
465 }
466 mac=mac->next;
467 }
468 }
469 return(mgetchar());
470 }
471 }
472
473 bt = (struct preproc_buff_t *)calloc(1, sizeof(struct preproc_buff_t));
474
475 bt->len = len;
476 bt->str = strdup(buf);
477 bt->next = preproc_buff_head;
478 preproc_buff_head = bt;
479 return('`');
480 }
481 }
482
483 int mgetchar_outhandle(void)
484 {
485 int rc = mgetchar();
486
487 if((mgetchar_fout)&&(rc!=EOF))
488 {
489 fputc(rc, mgetchar_fout);
490 }
491
492 return(rc);
493 }
494
495
496 int vpp_main(FILE *f, const char *name)
497 {
498 mprintf("// vpp_file %s\n", name);
499 mprintf("// vpp_line %d\n", 1);
500 fh = f;
501 return(0);
502 }
503
504 /*
505 * define handling/expansion
506 */
507 static void add_define_to_tree(JRB tree, char *s, char *sval)
508 {
509 Jval val;
510 JRB node;
511 char *pnt = s;
512 char ch;
513
514 /* see if s is legal */
515 while((ch=*(pnt++)))
516 {
517 if (
518 ((ch>='a')&&(ch<='z')) ||
519 ((ch>='A')&&(ch<='Z')) ||
520 ((ch>='0')&&(ch<='9')) ||
521 (ch=='_') ||
522 (ch=='$')
523 ) continue;
524
525 warn("** Warning: skipping invalid define using name '%s' with value '%s' in file '%s' line %d\n", s, sval, zzfilename, zzline);
526 return;
527 }
528
529 if(!(node=jrb_find_str(tree, s)))
530 {
531 val.s = sval;
532 jrb_insert_str(tree, strdup(s), val);
533 }
534 else
535 {
536 #if 0
537 if(zzfilename)
538 {
539 warn("** Warning: redefining '%s' to '%s' (prev '%s') in file '%s' line %d\n", s, sval ? sval : "", node->val.s ? node->val.s : "", zzfilename, zzline);
540 }
541 else
542 {
543 warn("** Warning: redefining '%s' to '%s' (prev '%s')\n", s, sval ? sval : "", node->val.s ? node->val.s : "");
544 }
545 #endif
546 if(node->val.s) free(node->val.s);
547 node->val.s = sval;
548 }
549 }
550
551
552 void store_define(char *def_text)
553 {
554 char *pnt = def_text+7;
555 char *s1, *s2;
556 int s1len, i;
557
558 s1=pnt;
559 s1len = strlen(s1);
560 for(i=1;i<s1len;i++)
561 {
562 if((s1[i]=='/') && (s1[i-1]=='/'))
563 {
564 /* trailing comment is at s1+i-1 */
565 mprintf("\n// vpp_line %d\n%s\n", zzline, s1+i-1);
566 s1[i-1] = 0;
567 break;
568 }
569 }
570
571 s1=strtok(pnt, " \t\b");
572 if((!s1)||(!*s1))
573 {
574 warn("** Warning: malformed `define directive in file '%s' line %d, ignoring.\n", zzfilename, zzline);
575 return;
576 }
577
578 s2=strtok(NULL, "");
579 if((!s2)||(!*s2))
580 {
581 s2=NULL;
582 }
583 else
584 {
585 char *s2head = s2;
586
587 while(*s2head)
588 {
589 if((*s2head==' ')||(*s2head=='\t')||(*s2head=='\b')) { s2head++; continue; }
590 break;
591 }
592
593 if(!*s2head)
594 {
595 s2=NULL;
596 }
597 else
598 {
599 int s2len = strlen(s2head);
600
601 for(i=s2len-1;i>=0;i--)
602 {
603 if((s2head[i]!=' ')&&(s2head[i]!='\t')&&(s2head[i]!='\b')) { s2head[i+1]=0; break; }
604 }
605 s2len = i+1;
606 if(s2len)
607 {
608 s2 = strdup(s2head);
609 }
610 else
611 {
612 s2 = NULL;
613 }
614 }
615 }
616
617 if(s2)
618 {
619 int nquotes=0, len=0;
620 pnt=s2;
621 while(*pnt)
622 {
623 if(*pnt=='\"') nquotes++;
624 pnt++;
625 len++;
626 }
627
628 if(nquotes&1)
629 {
630 pnt = malloc(len+2);
631 strcpy(pnt, s2);
632 strcat(pnt+len, "\"");
633 free(s2);
634 s2 = pnt;
635
636 warn("** Warning: malformed `define directive in file '%s' line %d missing endquote, added.\n", zzfilename, zzline);
637 }
638
639 len = strlen(s2);
640 pnt = s2+len;
641 while(pnt != s2)
642 {
643 pnt--;
644 if(isspace((int)(unsigned char)*pnt)) { *pnt = 0; } else { break; }
645 }
646 }
647
648 add_define_to_tree(define_tree, s1, s2);
649 }
650
651
652 void remove_define(char *def_text)
653 {
654 char *pnt = def_text+6;
655 char *s1;
656 JRB node;
657
658 s1=strtok(pnt, " \t\b");
659 if(!s1)
660 {
661 warn("** Warning: malformed `undef directive in file '%s' line %d, ignoring.\n", zzfilename, zzline);
662 return;
663 }
664
665 if(!(node=jrb_find_str(define_tree, s1)))
666 {
667 warn("** Warning: Attempted `undef of undefined '%s' in file '%s' line %d, ignoring.\n", s1, zzfilename, zzline);
668 }
669 else
670 {
671 free(node->key.s);
672 if(node->val.s) free(node->val.s);
673 jrb_delete_node(node);
674 }
675 }
676
677
678 /*
679 * ifdef/ifndef/else/endif handling
680 */
681 void handle_ifdef(char *def_text)
682 {
683 char *pnt = def_text+6;
684 char *s1;
685 /* JRB node; */
686 struct ifdef_stack_t *is;
687
688 /* warn("** IFDEF in file '%s' line %d\n", zzfilename, zzline); */
689
690 s1=strtok(pnt, " \t\b");
691 if(!s1)
692 {
693 warn("** Warning: malformed `ifdef directive in file '%s' line %d, ignoring.\n", zzfilename, zzline);
694 return;
695 }
696
697 is = calloc(1, sizeof(struct ifdef_stack_t));
698 is->polarity = 1;
699 is->zzfilename = strdup(zzfilename);
700 is->zzline = zzline;
701 is->deftext = strdup(s1);
702 is->blocked = ifdef_stack_top ? ifdef_stack_top->blocked : 0;
703 is->next = ifdef_stack_top;
704 is->do_not_translate = do_not_translate;
705 ifdef_stack_top = is;
706
707 {
708 if(!(/* node= */jrb_find_str(define_tree, s1)))
709 {
710 /* skip action */
711 do_not_translate |= STMODE_XLATEOFF_IFDEF;
712 is->blocked = 1;
713 is->else_branch = 1; /* translate in `else */
714 }
715 else
716 {
717 /* do */
718 is->else_branch = 0; /* do not translate in `else */
719 }
720 }
721
722 /* warn(" do_not_translate = %d\n", do_not_translate); */
723 }
724
725
726 void handle_ifndef(char *def_text)
727 {
728 char *pnt = def_text+7;
729 char *s1;
730 /* JRB node; */
731 struct ifdef_stack_t *is;
732
733 /* warn("** IFNDEF in file '%s' line %d\n", zzfilename, zzline); */
734
735 s1=strtok(pnt, " \t\b");
736 if(!s1)
737 {
738 warn("** Warning: malformed `ifndef directive in file '%s' line %d, ignoring.\n", zzfilename, zzline);
739 return;
740 }
741
742 is = calloc(1, sizeof(struct ifdef_stack_t));
743 is->polarity = 0;
744 is->zzfilename = strdup(zzfilename);
745 is->zzline = zzline;
746 is->deftext = strdup(s1);
747 is->next = ifdef_stack_top;
748 is->do_not_translate = do_not_translate;
749 is->blocked = ifdef_stack_top ? ifdef_stack_top->blocked : 0;
750 ifdef_stack_top = is;
751
752 {
753 if((/* node= */jrb_find_str(define_tree, s1)))
754 {
755 /* skip action */
756 do_not_translate |= STMODE_XLATEOFF_IFDEF;
757 is->blocked = 1;
758 is->else_branch = 1; /* translate in `else */
759 }
760 else
761 {
762 /* do */
763 is->else_branch = 0; /* do not translate in `else */
764 }
765 }
766
767 /* warn(" do_not_translate = %d\n", do_not_translate); */
768 }
769
770
771 void handle_else(void)
772 {
773 /* warn("** ELSE in file '%s' line %d\n", zzfilename, zzline); */
774
775 if(!ifdef_stack_top)
776 {
777 mesg("** Error: `else without `ifdef in file '%s' line %d\n", zzfilename, zzline);
778 }
779 else
780 {
781 if(ifdef_stack_top->else_branch)
782 {
783 do_not_translate = ifdef_stack_top->do_not_translate; /* take from parent */
784 }
785 else
786 {
787 do_not_translate |= STMODE_XLATEOFF_IFDEF;
788 ifdef_stack_top->blocked = 1;
789 }
790 }
791
792 /* warn(" do_not_translate = %d\n", do_not_translate); */
793 }
794
795 void handle_elsif(char *def_text)
796 {
797 /* warn("** ELSIF in file '%s' line %d\n", zzfilename, zzline); */
798
799 if(!ifdef_stack_top)
800 {
801 mesg("** Error: `elsif without `ifdef in file '%s' line %d\n", zzfilename, zzline);
802 }
803 else
804 {
805 handle_else();
806
807 if(ifdef_stack_top->else_branch)
808 {
809 char *pnt = def_text+6;
810 char *s1;
811 /* JRB node; */
812 struct ifdef_stack_t *is;
813
814 s1=strtok(pnt, " \t\b");
815 if(!s1)
816 {
817 warn("** Warning: malformed `elsif directive in file '%s' line %d, ignoring.\n", zzfilename, zzline);
818 return;
819 }
820
821 is = ifdef_stack_top;
822 is->polarity = 1;
823 free(is->zzfilename);
824 is->zzfilename = strdup(zzfilename);
825 is->zzline = zzline;
826 free(is->deftext);
827 is->deftext = strdup(s1);
828
829 /* is->blocked = ifdef_stack_top ? ifdef_stack_top->blocked : 0; */
830 /* is->next = ifdef_stack_top; */
831 /* is->do_not_translate = do_not_translate; */
832 /* ifdef_stack_top = is; */
833
834 {
835 if(!(/* node= */jrb_find_str(define_tree, s1)))
836 {
837 /* skip action */
838 do_not_translate |= STMODE_XLATEOFF_IFDEF;
839 is->blocked = 1;
840 is->else_branch = 1; /* translate in `else */
841 }
842 else
843 {
844 /* do */
845 is->else_branch = 0; /* do not translate in `else */
846 }
847 }
848 }
849 else
850 {
851 do_not_translate |= STMODE_XLATEOFF_IFDEF;
852 ifdef_stack_top->blocked = 1;
853 }
854 }
855
856 /* warn(" do_not_translate = %d\n", do_not_translate); */
857 }
858
859
860 void handle_endif(void)
861 {
862 struct ifdef_stack_t *is = ifdef_stack_top;
863 /* warn("** ENDIF in file '%s' line %d\n", zzfilename, zzline); */
864
865 if(!is)
866 {
867 mesg("** Error: `endif without `ifdef in file '%s' line %d\n", zzfilename, zzline);
868 }
869 else
870 {
871 do_not_translate = is->do_not_translate;
872
873 free(is->zzfilename);
874 free(is->deftext);
875 ifdef_stack_top = is->next;
876 free(is);
877 }
878
879 /* warn(" do_not_translate = %d\n", do_not_translate); */
880 }
881
882
883 /*
884 * include file handling
885 */
886 static FILE *incdir_fopen(char *nam, char **backpath)
887 {
888 FILE *fp=NULL;
889 struct vpp_filename *l;
890 int len;
891 static int traversed_incchain_for_caseinsens = 0;
892
893 if((nam[0]!='/')&&(incchain))
894 {
895 len = strlen(nam);
896 l=incchain;
897 while(l)
898 {
899 char *path = (char *)malloc(strlen(l->name) + 1 + len + 1);
900 sprintf(path, "%s/%s", l->name, nam);
901 fp=fopen(path, "r");
902 if(fp)
903 {
904 warn("Processing include file '%s' ...\n", path);
905 *backpath=path;
906 break;
907 }
908
909 free(path);
910 l=l->next;
911 }
912 }
913
914 if(!fp)
915 {
916 fp=fopen(nam, "r");
917 if(fp)
918 {
919 warn("Processing include file '%s' ...\n", nam);
920 *backpath=strdup(nam);
921 }
922 else
923 if((nam[0]!='/')&&(incchain))
924 {
925 if(!traversed_incchain_for_caseinsens)
926 {
927 traversed_incchain_for_caseinsens = 1;
928 l=incchain;
929 while(l)
930 {
931 dirscan(l->name, l);
932 l=l->next;
933 }
934 }
935
936 l=incchain;
937 while(l)
938 {
939 char **realname = bsearch(nam, l->children, l->numchildren, sizeof(char **), compar_cstarstar_bsearch);
940 if(realname)
941 {
942 char *buff = (char *)malloc(strlen(l->name)+1+strlen(*realname)+1);
943 sprintf(buff, "%s/%s", l->name, *realname);
944 fp=fopen(buff, "r");
945 if(fp)
946 {
947 warn("Processing include file '%s' ...\n", buff);
948 *backpath=buff;
949 }
950 else
951 {
952 free(buff);
953 }
954 break;
955 }
956 l=l->next;
957 }
958
959 }
960
961 }
962
963 return(fp);
964 }
965
966
967 void handle_include(char *def_text)
968 {
969 char *pnt = def_text+9, *pnt2;
970
971 while(*(pnt++)!='\"');
972 pnt2=pnt;
973 while(*(pnt2++)!='\"');
974 *(pnt2-1)=0;
975
976 if(!*pnt)
977 {
978 warn("** Warning: `include without filename in file '%s' line %d\n", zzfilename, zzline);
979 return;
980 }
981 else
982 {
983 FILE *fh2;
984 char *backpath;
985
986 fh2=incdir_fopen(pnt, &backpath);
987 if(!fh2)
988 {
989 mesg("** Error: could not open include file '%s'\n", pnt);
990 }
991 else
992 {
993 struct include_stack_t *ics = calloc(1, sizeof(struct include_stack_t));
994
995 ics->zzfilename=strdup(zzfilename);
996 ics->zzline = zzline;
997 ics->fh = fh;
998 ics->preproc_buff_head = preproc_buff_head;
999 ics->preproc_buff_current = preproc_buff_current;
1000 ics->next = include_stack_top;
1001 include_stack_top = ics;
1002
1003 preproc_buff_head = NULL;
1004 preproc_buff_current = NULL;
1005 fh = fh2;
1006
1007 if((++include_stack_depth) == 64)
1008 {
1009 int depth = 1;
1010 mesg("** Error: maximum include stack depth of 64 reached, reverse trace follows\n");
1011 do {
1012 warn("%7d : file '%s' line %d\n", depth++, ics->zzfilename, ics->zzline);
1013 ics=ics->next;
1014 } while ((depth==2)||(strcmp(ics->zzfilename, include_stack_top->zzfilename))||(ics->zzline!=include_stack_top->zzline));
1015
1016 zzerrors+=zzLexErrCount;
1017 warn("\n** %d error%s detected, exiting.\n\n",zzerrors,(zzerrors>1)?"s were":" was");
1018 exit(255);
1019 }
1020
1021 mprintf("// vpp_file %s \n", backpath); free(backpath);
1022 mprintf("// vpp_line %d\n", 1);
1023 }
1024 }
1025 }
1026
1027
1028 int pop_include(void)
1029 {
1030 struct include_stack_t *ics = include_stack_top;
1031
1032 if(ics)
1033 {
1034 include_stack_depth--;
1035 warn("... returning to file '%s' line %d\n", ics->zzfilename, ics->zzline);
1036 fh=ics->fh;
1037 preproc_buff_head = ics->preproc_buff_head;
1038 preproc_buff_current = ics->preproc_buff_current;
1039
1040 mprintf("// vpp_file %s \n", ics->zzfilename);
1041 mprintf("// vpp_line %d\n", ics->zzline);
1042
1043 free(ics->zzfilename);
1044 include_stack_top = ics->next;
1045 free(ics);
1046 return(1);
1047 }
1048 else
1049 {
1050 return(0);
1051 }
1052 }
1053
+0
-164
contrib/vermin/shred.c less more
0 #undef DEBUG_SHRED
1
2 #include "shred.h"
3 #include "attrib.h"
4 #include "antlr.h"
5 #include "tokens.h"
6 #include "symbol.h"
7
8 #ifndef DEBUG_SHRED
9 void DEBUG(char *dummy, ...) { (void)dummy; }
10 #endif
11
12 void **shred_root=NULL, **shred_pnt=NULL;
13 void **exp_root=NULL, **exp_pnt=NULL;
14 void ***exp_now_root=NULL, ***exp_now_pnt=NULL;
15
16
17 void shred_alloc(void)
18 {
19 shred_root=shred_pnt=(void **)calloc(SHRED_ROOT_SIZE,sizeof(void *)); /* with 12+ preclevels this is more than enough */
20 exp_root=exp_pnt=(void **)calloc(EXP_ROOT_SIZE,sizeof(void *)); /* dictates longest expr */
21 exp_now_root=exp_now_pnt=(void ***)calloc(EXP_NOW_SIZE,sizeof(void **)); /* levels of parentheses */
22 }
23
24 void shred_free(void)
25 {
26 free(exp_root);
27 free(shred_root);
28 }
29
30 void push_exp_now(void)
31 {
32 exp_now_pnt++;
33 if(exp_now_pnt==(exp_now_root+EXP_NOW_SIZE))
34 {
35 mesg("\n** Error: overflow of %d element parenthesis stack\n", EXP_NOW_SIZE);
36 zzerrors+=zzLexErrCount;
37 warn("** %d error%s detected, exiting.\n\n",zzerrors,(zzerrors>1)?"s were":" was");
38 exit(255);
39 }
40 *exp_now_pnt=(void **)exp_pnt;
41 }
42
43 void pop_exp_now(void)
44 {
45 exp_pnt=(void **)(*exp_now_pnt);
46 exp_now_pnt--;
47 }
48
49 void push_primary(struct i_primary *pri)
50 {
51 exp_pnt++;
52 if(exp_pnt==(exp_root+EXP_ROOT_SIZE))
53 {
54 mesg("\n** Error: overflow of %d element expression stack\n", EXP_ROOT_SIZE);
55 zzerrors+=zzLexErrCount;
56 warn("** %d error%s detected, exiting.\n\n",zzerrors,(zzerrors>1)?"s were":" was");
57 exit(255);
58 }
59 *exp_pnt=(void *)pri;
60 }
61
62 void push_oper(struct i_oper *oper)
63 {
64 exp_pnt++;
65 *exp_pnt=(void *)oper;
66 }
67
68 struct i_primary *pop_primary(void)
69 {
70 struct i_primary *pri;
71
72 pri=(struct i_primary *)(*exp_pnt);
73 exp_pnt--;
74 return(pri);
75 }
76
77 struct i_oper *pop_oper(void)
78 {
79 struct i_oper *oper;
80
81 oper=(struct i_oper *)(*exp_pnt);
82 exp_pnt--;
83 return(oper);
84 }
85
86 struct i_primary *shred_expression(void)
87 {
88 void **input_stream;
89 void **shredlocal;
90 struct i_primary *p1, *p2;
91 struct i_oper *o1, *o2;
92 int prec1, prec2;
93 struct i_primary *prdest;
94
95 DEBUG("Parsing Expression\n");
96 input_stream=exp_pnt;
97 shredlocal=shred_pnt;
98
99 p1=*(++shredlocal)=*(++input_stream); /* 1st primary */
100
101 shred_main:
102 o1=*(++shredlocal)=*(++input_stream); /* 1st op */
103 p2=*(++shredlocal)=*(++input_stream); /* 2nd op */
104
105 shredder:
106 DEBUG("----------\n");
107
108 #ifdef DEBUG_SHRED
109 print_primary(p1);
110 print_operator(o1);
111 #endif
112
113 if(o1->token==V_EOF)
114 {
115 DEBUG("End of expression encountered\n\n");
116 return(p1);
117 }
118
119 o2=*(input_stream+1);
120
121 #ifdef DEBUG_SHRED
122 print_primary(p2);
123 print_operator(o2);
124 #endif
125
126 prec1=o1->prec; prec2=o2->prec;
127 DEBUG("O1 prec: %d\n",prec1);
128 DEBUG("O2 prec: %d\n",prec2);
129
130 if(prec2>prec1)
131 {
132 DEBUG("Shift\n");
133
134 *(++shredlocal)=o2;
135 input_stream++;
136 p1=p2;
137 o1=o2;
138 p2=*(++shredlocal)=*(++input_stream); /* 2nd op */
139 goto shredder;
140 }
141 else
142 {
143 DEBUG("Reduce\n");
144
145 prdest=i_bin_expr_make(p1,o1,p2);
146
147 shredlocal-=2;
148
149 p1=*(shredlocal)=prdest;
150 if(shredlocal==shred_pnt+1)
151 {
152 goto shred_main;
153 }
154 else
155 {
156 p2=p1;
157 p1=*(shredlocal-2);
158 o1=*(shredlocal-1);
159 goto shredder;
160 }
161 }
162 }
163
+0
-35
contrib/vermin/shred.h less more
0 #ifndef SHRED_H
1 #define SHRED_H
2
3 #include "inter.h"
4
5 #ifdef DEBUG_SHRED
6 #define DEBUG printf
7 #endif
8
9 #ifndef DEBUG_SHRED
10 #define DEBUG blackhole_shred
11 void DEBUG(char *, ...);
12 #endif
13
14 #define SHRED_ROOT_SIZE 16384
15 #define EXP_ROOT_SIZE 65536
16 #define EXP_NOW_SIZE 4096
17
18 extern void **shred_root, **shred_pnt;
19 extern void **exp_root, **exp_pnt;
20 extern void ***exp_now_root, ***exp_now_pnt;
21
22 struct i_primary *shred_expression(void);
23
24 void shred_alloc(void);
25 void shred_free(void);
26 void push_primary(struct i_primary *pri);
27 void push_oper(struct i_oper *oper);
28 struct i_primary *pop_primary(void);
29 struct i_oper *pop_oper(void);
30 void push_exp_now(void);
31 void pop_exp_now(void);
32
33 #endif
34
+0
-69
contrib/vermin/symbol.c less more
0 #include "inter.h"
1 #include "symbol.h"
2 #include "jrb.h"
3
4 struct i_symbol_scope *sym_base=NULL; /* points to current scope, you look backward (up) from here */
5
6
7 /*
8 * Simply look for a symbol's presence in the table...
9 */
10 struct i_symbol *sym_find(char *s)
11 {
12 JRB node;
13 struct i_symbol_scope *ss = sym_base;
14
15 if(!ss) /* this is only to avoid crashes */
16 {
17 ss = (struct i_symbol_scope *)calloc(1, sizeof(struct i_symbol_scope));
18 ss->symtable = make_jrb();
19 sym_base = ss;
20 }
21
22 while(ss)
23 {
24 node = jrb_find_str(ss->symtable, s);
25 if(node)
26 {
27 return((struct i_symbol *)(node->val.v));
28 }
29 ss=ss->parent;
30 }
31
32 return(NULL); /* not found */
33 }
34
35
36 /*
37 * Malloc a symbol and copy the name data into it.
38 */
39 struct i_symbol *sym_make(char *s)
40 {
41 struct i_symbol *sym;
42
43 sym=(struct i_symbol *)calloc(1,sizeof(struct i_symbol));
44 sym->firstref=zzline;
45 strcpy(sym->name=(char *)malloc(strlen(s)+1),s);
46
47 return(sym);
48 }
49
50 /*
51 * Add a symbol presence in the table...
52 */
53 struct i_symbol *sym_add(char *s)
54 {
55 struct i_symbol *sym;
56 Jval j;
57
58 sym = sym_find(s);
59 if(!sym)
60 {
61 sym = sym_make(s);
62 j.v = (void *)sym;
63 jrb_insert_str(sym_base->symtable, sym->name, j);
64 }
65
66 return(sym);
67 }
68
+0
-27
contrib/vermin/symbol.h less more
0 #ifndef SYMBOL_H
1 #define SYMBOL_H
2
3 #include "vpp_common.h"
4 #include "jrb.h"
5
6 struct i_symbol_scope
7 {
8 struct i_symbol_scope *parent;
9 JRB symtable;
10 };
11
12
13 struct i_symbol *sym_find(char *s);
14 struct i_symbol *sym_make(char *s);
15 struct i_symbol *sym_add(char *s);
16
17 extern struct i_symbol_scope *sym_base;
18
19 /*
20 * for defines, etc
21 */
22 extern JRB define_tree;
23 extern struct ifdef_stack_t *ifdef_stack_top;
24
25 #endif
26
+0
-2145
contrib/vermin/verilog.g less more
0 #header <<
1
2 #include "attrib.h"
3 #include "vpp_common.h"
4
5 #if defined __MINGW32__ || defined _MSC_VER
6 #define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
7 #endif
8
9 int zzcr_attr(Attrib *attr, int token, char *text);
10 void vpp_update_yyfilename(const char *str);
11 void vpp_update_yylineno(const char *str);
12
13 >>
14
15 #tokdefs "keyword_tokens.h"
16
17 <<
18 #include "../../config.h"
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <sys/param.h>
22
23 #include "wave_locale.h"
24
25 #include "inter.h"
26 #include "tokens.h"
27 #include "shred.h"
28 #include "symbol.h"
29 #include "jrb.h"
30 #include "vpp_common.h"
31
32 #ifndef PATH_MAX
33 #define PATH_MAX (4096)
34 #endif
35
36 int verilog_keyword_code(const char *s, unsigned int len); /* returns token value from gperf */
37 void args_expand(int argc, char **argv, int *new_argc, char ***new_argv);
38
39 int zzerrors=0;
40 int zzcomment_start=0, zzcomment_depth=0, zzcomment_entry=0;
41 char *zzfilename=NULL;
42
43 JRB modname_tree=NULL;
44 int module_is_duplicate=0;
45
46 char *mod_current_name = NULL;
47 char *mod_current_filename = NULL;
48 int mod_start_line = 0;
49
50 char *udp_current_name = NULL;
51 char *udp_current_filename = NULL;
52 int udp_start_line = 0;
53
54 char *comp_type_name = NULL;
55
56 int emit_stems = 0, emit_vars = 0;
57
58 static void add_string_to_tree(JRB tree, char *s, int exists)
59 {
60 Jval val;
61 JRB node;
62
63 if(!(node=jrb_find_str(tree, s)))
64 {
65 val.i = (exists!=0);
66 jrb_insert_str(tree, s, val);
67 }
68 else
69 {
70 node->val.i |= (exists!=0);
71 }
72 }
73
74 char *prevlineroot=NULL;
75 char *prevprevlineroot=NULL;
76 char *lineroot=NULL, *linepos=NULL;
77 int linemaxlen=0;
78 int zzrewind=0;
79
80 /*
81 * add token to the analyzed verilog buffer..
82 */
83 void addtoken(int is_newline)
84 {
85 if(!is_newline)
86 {
87 zzrewind = strlen(zztext);
88
89 if((linepos-lineroot)+zzrewind >= linemaxlen)
90 {
91 char *t=realloc(lineroot, linemaxlen = 2*(linemaxlen+zzrewind)+1);
92 prevlineroot=realloc(prevlineroot, linemaxlen);
93 prevprevlineroot=realloc(prevprevlineroot, linemaxlen);
94 linepos = (linepos-lineroot) + t;
95 lineroot = t;
96 }
97
98 strcpy(linepos,zztext);
99 linepos+=zzrewind;
100 }
101 else
102 {
103 char *t=prevprevlineroot; /* scroll the buffer ptrs to avoid copying */
104 prevprevlineroot = prevlineroot;
105 prevlineroot = lineroot;
106 linepos = lineroot = t;
107 *linepos=0;
108 zzline++;
109 }
110 }
111
112 void report_error_context(int tok, char *badtok)
113 {
114 char *ch, v;
115 int col=0;
116
117 ch=lineroot;
118
119 do
120 {
121 v=*(ch++);
122 switch(v)
123 {
124 case '\t': col=(col+8)&(~0x07); break;
125 case '\n': col=2; break;
126 default: col++; break;
127 }
128 } while(v);
129
130 col-=zzrewind; if(col<2) col=2;
131
132 if(tok!=zzEOF_TOKEN)
133 {
134 warn(" Local context near token '%s' in '%s' on line %d.%d:\n",badtok,zzfilename, zzline,col-1);
135 }
136 else
137 {
138 warn(" Local context preceding EOF in '%s' on line %d.%d:\n",zzfilename, zzline,col-1);
139 }
140 if(zzline>2)
141 {
142 warn("%6d: %s\n", zzline-2, prevprevlineroot);
143 }
144 if(zzline>1)
145 {
146 warn("%6d: %s\n", zzline-1, prevlineroot);
147 }
148
149 if(col>2)
150 {
151 warn("%6d: %s\n\t%*s^\n", zzline, lineroot, col-2, "");
152 }
153 else
154 {
155 warn("%6d: %s\n\t^\n", zzline, lineroot);
156 }
157 }
158
159
160 int do_not_translate = 0, do_not_translate_mask = 0;
161
162 void warn_about_translation_off(void)
163 {
164 if(do_not_translate)
165 {
166 warn("** Warning: source code translation off for { %s%s%s%s%s} at EOF in '%s'.\n",
167 (do_not_translate&STMODE_XLATEOFF_IFDEF) ? "ifdef " : "",
168 (do_not_translate&STMODE_XLATEOFF_SYNOPSYS) ? "synopsys " : "",
169 (do_not_translate&STMODE_XLATEOFF_SYNTHESIS) ? "synthesis " : "",
170 (do_not_translate&STMODE_XLATEOFF_VERILINT) ? "verilint " : "",
171 (do_not_translate&STMODE_XLATEOFF_VERTEX) ? "vertex " : "",
172 zzfilename);
173
174 do_not_translate = 0;
175 }
176
177 if(ifdef_stack_top)
178 {
179 struct ifdef_stack_t *is;
180
181 while(ifdef_stack_top)
182 {
183 is=ifdef_stack_top;
184
185 warn("** Warning: pending `if%sdef %s at EOF, start is file '%s' line %d.\n",
186 is->polarity ? "" : "n",
187 is->deftext,
188 is->zzfilename, is->zzline);
189
190 free(is->zzfilename);
191 free(is->deftext);
192 ifdef_stack_top = is->next;
193 free(is);
194 }
195
196 include_stack_depth = 0;
197 }
198
199 if(zzcomment_depth)
200 {
201 mesg("** Error: Unterminated comment starts at line %d in '%s'.\n", zzcomment_start, zzfilename);
202 zzcomment_depth = 0;
203 }
204 }
205
206
207 void parsecomment(void)
208 {
209 char *tok=strdup(zztext);
210 char *tok_sav=tok;
211 strcpy(tok, zztext);
212
213 tok = strtok(tok,"/ \t");
214 if (tok != 0) {
215 if (!strcmp("vpp_file", tok))
216 {
217 tok = strtok(NULL, " \t");
218 if(tok) vpp_update_yyfilename(tok);
219 }
220 else
221 if (!strcmp("vpp_line", tok))
222 {
223 tok = strtok(NULL, "");
224 if(tok) vpp_update_yylineno(tok);
225 }
226 else
227 if(!(do_not_translate&STMODE_XLATEOFF_IFDEF)) /* make sure preprocessed block is active */
228 {
229 if ((!strcmp("synopsys", tok))&&(do_not_translate_mask & STMODE_XLATEOFF_SYNOPSYS))
230 {
231 tok = strtok(NULL, " \t");
232 if(tok)
233 {
234 if(!strcmp("translate_on", tok))
235 {
236 do_not_translate &= ~(STMODE_XLATEOFF_SYNOPSYS);
237 }
238 else
239 if(!strcmp("translate_off", tok))
240 {
241 do_not_translate |= (do_not_translate_mask & STMODE_XLATEOFF_SYNOPSYS);
242 }
243 else
244 {
245 warn("** Warning: unsupported synopsys pragma '%s' on line %d in file '%s', skipping.\n",
246 tok, zzline, zzfilename);
247 }
248 }
249 }
250 else
251 if ((!strcmp("synthesis", tok))&&(do_not_translate_mask & STMODE_XLATEOFF_SYNTHESIS))
252 {
253 tok = strtok(NULL, " \t");
254 if(tok)
255 {
256 if(!strcmp("translate_on", tok))
257 {
258 do_not_translate &= ~(STMODE_XLATEOFF_SYNTHESIS);
259 }
260 else
261 if(!strcmp("translate_off", tok))
262 {
263 do_not_translate |= (do_not_translate_mask & STMODE_XLATEOFF_SYNTHESIS);
264 }
265 else
266 {
267 warn("** Warning: unsupported synthesis pragma '%s' on line %d in file '%s', skipping.\n",
268 tok, zzline, zzfilename);
269 }
270 }
271 }
272 else
273 if ((!strcmp("verilint", tok))&&(do_not_translate_mask & STMODE_XLATEOFF_VERILINT))
274 {
275 tok = strtok(NULL, " \t");
276 if(tok)
277 {
278 if(!strcmp("translate", tok))
279 {
280 tok = strtok(NULL, " \t");
281 if(tok)
282 {
283 if(!strcmp("on", tok))
284 {
285 do_not_translate &= ~(STMODE_XLATEOFF_VERILINT);
286 }
287 else
288 if(!strcmp("off", tok))
289 {
290 do_not_translate |= (do_not_translate_mask & STMODE_XLATEOFF_VERILINT);
291 }
292 else
293 {
294 warn("** Warning: unsupported translate option '%s' on line %d in file '%s', skipping.\n",
295 tok, zzline, zzfilename);
296 }
297 }
298 }
299 }
300 }
301 else
302 if ((!strcmp("vertex", tok))&&(do_not_translate_mask & STMODE_XLATEOFF_VERTEX))
303 {
304 tok = strtok(NULL, " \t");
305 if(tok)
306 {
307 if(!strcmp("translate", tok))
308 {
309 tok = strtok(NULL, " \t");
310 if(tok)
311 {
312 if(!strcmp("on", tok))
313 {
314 do_not_translate &= ~(STMODE_XLATEOFF_VERTEX);
315 }
316 else
317 if(!strcmp("off", tok))
318 {
319 do_not_translate |= (do_not_translate_mask & STMODE_XLATEOFF_VERTEX);
320 }
321 else
322 {
323 warn("** Warning: unsupported translate option '%s' on line %d in file '%s', skipping.\n",
324 tok, zzline, zzfilename);
325 }
326 }
327 }
328 }
329 }
330 }
331 }
332
333 free(tok_sav);
334 }
335
336
337 void
338 zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
339 {
340 if(tok!=zzEOF_TOKEN)
341 {
342 mesg("** Syntax error at \"%s\"", bad_text);
343 }
344 else
345 {
346 mesg("** Syntax error at EOF");
347 }
348 if ( !etok && !eset ) {warn("\n"); return;}
349 if ( k==1 ) warn(" missing");
350 else
351 {
352 warn("; \"%s\" not", bad_text);
353 if ( zzset_deg(eset)>1 ) warn(" in");
354 }
355 if ( zzset_deg(eset)>0 ) zzedecode(eset);
356 else warn(" %s", zztokens[etok]);
357 if ( strlen(egroup) > 0 ) warn(" in %s", egroup);
358 warn("\n");
359 report_error_context(tok, bad_text);
360 }
361
362
363 int zzcr_attr(Attrib *attr, int token, char *text)
364 {
365 int len;
366
367 switch(token)
368 {
369 case V_FUNCTION_NAME:
370 case V_IDENTIFIER:
371 case V_IDENTIFIER2:
372 case V_IDENDOT:
373 attr->symbol=sym_add(text);
374 break;
375
376 case V_DBASE:
377 case V_BBASE:
378 case V_OBASE:
379 case V_HBASE:
380 attr->text=strdup(text);
381 break;
382
383 case V_STRING:
384 len = strlen(text);
385 text[len-1]=0;
386 strcpy(attr->text = malloc(len-2+1), text+1);
387 break;
388
389 case V_DECIMAL_NUMBER:
390 attr->ival=atoi_with_underscores(text);
391 break;
392 case V_FLOAT1:
393 case V_FLOAT2:
394 sscanf(text, "%lf", &attr->rval);
395 break;
396
397 default:
398 attr->ival=0;
399 }
400 return(0);
401 }
402
403
404 int main(int argc, char **argv)
405 {
406 int v_argc;
407 char **v_argv;
408 int i;
409 struct vpp_filename *head=NULL, *curr=NULL, *t, *e;
410 struct vpp_filename *lib_head=NULL, *lib_curr=NULL;
411 struct vpp_filename *libext_head=NULL, *libext_curr=NULL;
412 JRB node;
413 int maxarg; /* scan build : was int maxarg = v_argc - 1; */
414
415 WAVE_LOCALE_FIX
416
417 args_expand(argc, argv, &v_argc, &v_argv);
418 maxarg = v_argc - 1;
419
420 modname_tree=make_jrb();
421 define_tree=make_jrb();
422
423 lineroot=linepos=(char *)calloc(1, linemaxlen=16);
424 prevlineroot=(char *)calloc(1, linemaxlen);
425 prevprevlineroot=(char *)calloc(1, linemaxlen);
426
427 if(v_argc==1)
428 {
429 warn(VERNAME"\n"
430 "No files to process (use -h for help), exiting.\n\n");
431 exit(0);
432 }
433
434 warn(VERNAME"\n\n");
435
436 for(i=1;i<v_argc;i++)
437 {
438 int arglen = strlen(v_argv[i]);
439
440 if((!strcmp(v_argv[i], "-y"))||(!strcmp(v_argv[i], "-yi")))
441 {
442 if(i==maxarg)
443 {
444 warn("** Missing filename after %s option!\n", v_argv[i]);
445 }
446 else
447 {
448 t=calloc(1, sizeof(struct vpp_filename));
449 t->name = strdup(v_argv[++i]);
450
451 if(v_argv[i-1][2]) /* isn't nullchar so it's 'i' */
452 {
453 dirscan(t->name, t); /* it's a case-insensitive directory, so scan it in */
454 }
455
456 if(!lib_head)
457 {
458 lib_head=lib_curr=t;
459 }
460 else
461 {
462 lib_curr->next = t;
463 lib_curr = t;
464 }
465 }
466 }
467 else
468 if(!strcmp(v_argv[i], "-emitmono"))
469 {
470 if(i==maxarg)
471 {
472 warn("** Missing filename after -emitmono option!\n");
473 }
474 else
475 {
476 i++;
477
478 if(mgetchar_fout)
479 {
480 warn("** Ignoring extra -emitmono specification for '%s'.\n", v_argv[i]);
481 }
482 else
483 {
484 mgetchar_fout = fopen(v_argv[i], "wb");
485 if(!mgetchar_fout)
486 {
487 mesg("** Could not open -emitmono file '%s', exiting.\n", v_argv[i]);
488 perror("Why");
489 exit(255);
490 }
491 }
492 }
493 }
494 else
495 if(!strcmp(v_argv[i], "-pragma"))
496 {
497 if(i==maxarg)
498 {
499 warn("** Missing typename after -pragma option!\n");
500 }
501 else
502 {
503 i++;
504 if(!strcmp(v_argv[i], "synopsys"))
505 {
506 do_not_translate_mask |= STMODE_XLATEOFF_SYNOPSYS;
507 }
508 else
509 if(!strcmp(v_argv[i], "synthesis"))
510 {
511 do_not_translate_mask |= STMODE_XLATEOFF_SYNTHESIS;
512 }
513 else
514 if(!strcmp(v_argv[i], "verilint"))
515 {
516 do_not_translate_mask |= STMODE_XLATEOFF_VERILINT;
517 }
518 else
519 if(!strcmp(v_argv[i], "vertex"))
520 {
521 do_not_translate_mask |= STMODE_XLATEOFF_VERTEX;
522 }
523 else
524 {
525 warn("** Unknown -pragma type '%s', ignoring.\n", v_argv[i]);
526 }
527 }
528 }
529 else
530 if((!strcmp(v_argv[i], "-h"))||(!strcmp(v_argv[i], "-help")))
531 {
532 warn( "Usage:\n"
533 "------\n"
534 "%s [input filename(s)] [options]\n\n"
535 "-h[elp] prints this screen\n"
536 "-emitmono fname emit monolithic (parser view of) file to fname\n"
537 "-emitstems emit source code stems to stdout\n"
538 "-emitvars emit source code variables to stdout\n"
539 "-Dx=y equivalent to `define X Y in source\n"
540 "+define+x=y equivalent to `define X Y in source\n"
541 "+incdir+dirname add dirname to include search path\n"
542 "+libext+ext add ext to filename when searching for files\n"
543 "-pragma name add name (synopsys, synthesis, verilint, vertex) to accepted pragmas\n"
544 "-y dirname add directory to source input path\n"
545 "-yi dirname add directory to source input path (case insensitive search)\n"
546 "-f filename insert args from filename (does not work recursively)\n"
547 "\n", v_argv[0]
548 );
549 exit(0);
550 }
551 else
552 if(!strcmp(v_argv[i], "-f"))
553 {
554 warn("** Cannot nest -f option inside an args file, exiting.\n");
555 exit(255);
556 }
557 else
558 if(!strcmp(v_argv[i], "-emitstems"))
559 {
560 emit_stems = 1;
561 }
562 else
563 if(!strcmp(v_argv[i], "-emitvars"))
564 {
565 emit_vars = 1;
566 }
567 else
568 if((arglen>=8)&&(!strncmp(v_argv[i],"+incdir+",8)))
569 {
570 if(arglen==8)
571 {
572 warn("** Missing path for +incdir+ in command line argument %d, ignoring.\n", i);
573 }
574 else
575 {
576 char *lname=(char *)malloc(arglen-8+1);
577 char *tok;
578
579 strcpy(lname, v_argv[i]+8);
580 tok=strtok(lname,"+");
581
582 while(tok)
583 {
584 int toklen=strlen(tok);
585 if(!toklen)
586 {
587 /* strtok seems to never hit this */
588 warn("** Missing path for +incdir+ (consecutive ++) in command line argument %d, ignoring.\n", i);
589 }
590 else
591 {
592 if(!incchain)
593 {
594 struct vpp_filename *l;
595 l=(struct vpp_filename *)calloc(1,sizeof(struct vpp_filename));
596 strcpy(l->name=malloc(toklen+1), tok);
597
598 incchain=l;
599 }
600 else
601 {
602 struct vpp_filename *l=incchain;
603 struct vpp_filename *l2;
604
605 while(l->next) l=l->next;
606
607 l2=(struct vpp_filename *)calloc(1,sizeof(struct vpp_filename));
608 strcpy(l2->name=malloc(toklen+1), tok);
609 l->next=l2;
610 }
611 }
612
613 tok=strtok(NULL, "+");
614 }
615
616 free(lname);
617 }
618 }
619 else
620 if((arglen>=8)&&(!strncmp(v_argv[i],"+define+",8)))
621 {
622 if(arglen==8)
623 {
624 warn("** Missing value for +define+ in command line argument %d, ignoring.\n", i);
625 }
626 else
627 {
628 char *lname=(char *)malloc(arglen-8+1);
629 char *tok;
630
631 strcpy(lname, v_argv[i]+8);
632 tok=strtok(lname,"+");
633
634 while(tok)
635 {
636 int toklen=strlen(tok);
637 if(!toklen)
638 {
639 /* strtok seems to never hit this */
640 warn("** Missing value for +define+ (consecutive ++) in command line argument %d, ignoring.\n", i);
641 }
642 else
643 {
644 char *dname=(char *)malloc(toklen+8+1);
645 char *pnt;
646 sprintf(dname, "`define %s", tok);
647 pnt = dname+8;
648 while(*pnt)
649 {
650 if(*pnt=='=')
651 {
652 *pnt=' ';
653 break;
654 }
655 pnt++;
656 }
657 store_define(dname);
658 free(dname);
659 }
660
661 tok=strtok(NULL, "+");
662 }
663
664 free(lname);
665 }
666 }
667 else
668 if((arglen>=8)&&(!strncmp(v_argv[i],"+libext+",8)))
669 {
670 if(arglen==8)
671 {
672 warn("** Missing extension for +libext+ in command line argument %d, ignoring.\n", i);
673 }
674 else
675 {
676 char *lname=(char *)malloc(arglen-8+1);
677 char *tok;
678 strcpy(lname, v_argv[i]+8);
679
680 tok=strtok(lname,"+");
681 while(tok)
682 {
683 int toklen=strlen(tok);
684 if(!toklen)
685 {
686 /* strtok seems to never hit this */
687 warn("** Missing path for +libext+ (consecutive ++) in command line argument %d, ignoring.\n", i);
688 }
689 else
690 {
691 if(!libext_curr)
692 {
693 struct vpp_filename *l;
694 l=(struct vpp_filename *)calloc(1,sizeof(struct vpp_filename));
695 strcpy(l->name=malloc(toklen+1), tok);
696 libext_head=libext_curr=l;
697 }
698 else
699 {
700 struct vpp_filename *l;
701
702 l=(struct vpp_filename *)calloc(1,sizeof(struct vpp_filename));
703 strcpy(l->name=malloc(toklen+1), tok);
704 libext_curr->next=l;
705 libext_curr=l;
706 }
707 }
708
709 tok=strtok(NULL, "+");
710 }
711 free(lname);
712 }
713 }
714 else
715 if((arglen>=2)&&(v_argv[i][0] == '+'))
716 {
717 warn("** Skipping plusarg '%s' in command line argument %d.\n", v_argv[i], i);
718 }
719 else
720 if((arglen>=2)&&(!strncmp(v_argv[i],"-D",2)))
721 {
722 if(arglen==2)
723 {
724 warn("** Missing define for -D in command line argument %d, ignoring.\n", i);
725 }
726 else
727 {
728 char *dname=(char *)malloc(arglen-2+8+1);
729 char *pnt;
730 sprintf(dname, "`define %s", v_argv[i]+2);
731 pnt = dname+8;
732 while(*pnt)
733 {
734 if(*pnt=='=')
735 {
736 *pnt=' ';
737 break;
738 }
739 pnt++;
740 }
741 store_define(dname);
742 free(dname);
743 }
744 }
745 else /* filename only.. */
746 {
747 t=calloc(1, sizeof(struct vpp_filename));
748 t->name = strdup(v_argv[i]);
749
750 if(!head)
751 {
752 head=curr=t;
753 vlog_filenames = head;
754 }
755 else
756 {
757 curr->next = t;
758 curr = t;
759 }
760 }
761 }
762
763 shred_alloc();
764
765 prevprevlineroot[0]=prevlineroot[0]=lineroot[0]=0; linepos=lineroot; do_not_translate = 0;
766 ANTLRf(v_source_text(), mgetchar_fout ? mgetchar_outhandle : mgetchar);
767 warn_about_translation_off();
768 zzerrors+=zzLexErrCount;
769 if(zzerrors)
770 {
771 warn("\n** %d error%s detected, exiting.\n\n",zzerrors,(zzerrors>1)?"s were":" was");
772 exit(255);
773 }
774
775 do {
776 i=0;
777 jrb_traverse(node, modname_tree)
778 {
779 if(node->val.i==0)
780 {
781 FILE *hand;
782 int len = strlen(node->key.s);
783 int resolve = 0;
784 char *buff;
785 t=lib_head;
786
787 while(t)
788 {
789 e=libext_head;
790 do
791 {
792 char *ext=e?e->name:"";
793 buff = (char *)malloc(strlen(t->name)+1+len+strlen(ext)+1);
794 sprintf(buff, "%s/%s%s", t->name, node->key.s, ext);
795 hand = fopen(buff, "r");
796 if(hand)
797 {
798 warn("Processing file '%s' ...\n", buff);
799 vpp_main(hand, buff);
800 prevprevlineroot[0]=prevlineroot[0]=lineroot[0]=0; linepos=lineroot; do_not_translate = 0;
801 ANTLRf(v_source_text(), mgetchar_fout ? mgetchar_outhandle : mgetchar); /* preproc.c will do fclose() */
802 warn_about_translation_off();
803 free(buff);
804 zzerrors+=zzLexErrCount;
805 if(zzerrors)
806 {
807 warn("\n** %d error%s detected, exiting.\n\n",zzerrors,(zzerrors>1)?"s were":" was");
808 exit(255);
809 }
810 i=1;
811 resolve=1;
812 goto is_resolved;
813 }
814 free(buff);
815 } while((e)&&(e=e->next));
816
817 t=t->next;
818 }
819
820 t=lib_head;
821
822 while(t)
823 {
824 if(t->numchildren)
825 {
826 e=libext_head;
827 do
828 {
829 char **realname;
830 char *ext=e?e->name:"";
831 buff = (char *)malloc(len+strlen(ext)+1);
832 sprintf(buff, "%s%s", node->key.s, ext);
833 realname = bsearch(buff, t->children, t->numchildren, sizeof(char **), compar_cstarstar_bsearch);
834 free(buff);
835 if(realname)
836 {
837 buff = (char *)malloc(strlen(t->name)+1+strlen(*realname)+1);
838 sprintf(buff, "%s/%s", t->name, *realname);
839
840 hand = fopen(buff, "r");
841 if(hand)
842 {
843 warn("Processing file '%s' ...\n", buff);
844 vpp_main(hand, buff);
845 prevprevlineroot[0]=prevlineroot[0]=lineroot[0]=0; linepos=lineroot; do_not_translate = 0;
846 ANTLRf(v_source_text(), mgetchar_fout ? mgetchar_outhandle : mgetchar); /* preproc.c will do fclose() */
847 warn_about_translation_off();
848 free(buff);
849 zzerrors+=zzLexErrCount;
850 if(zzerrors)
851 {
852 warn("\n** %d error%s detected, exiting.\n\n",zzerrors,(zzerrors>1)?"s were":" was");
853 exit(255);
854 }
855 i=1;
856 resolve=1;
857 goto is_resolved;
858 }
859 free(buff);
860 }
861 } while((e)&&(e=e->next));
862 }
863
864 t=t->next;
865 }
866
867 is_resolved: if(!resolve)
868 {
869 warn("** Error: could not find module '%s'\n", node->key.s);
870 }
871
872 node->val.i=1;
873 }
874 }
875 } while(i==1);
876
877 zzerrors+=zzLexErrCount;
878 if(zzerrors)
879 {
880 warn("\n** %d error%s detected, exiting.\n\n",zzerrors,(zzerrors>1)?"s were":" was");
881 exit(255);
882 }
883
884 shred_free();
885 return(0);
886 }
887
888
889
890 >>
891
892 //
893 // error classes
894 //
895 #errclass "expression"
896 { V_DECIMAL_NUMBER V_FLOAT1 V_FLOAT2 V_DBASE V_BBASE V_OBASE V_HBASE V_STRING V_PLUS V_MINUS V_BANG
897 V_TILDE V_AND V_NAND V_OR V_NOR V_XOR V_XNOR V_XNOR2 V_LP V_LBRACE V_FUNCTION_NAME V_IDENTIFIER
898 V_IDENTIFIER2 V_IDENDOT }
899
900
901 //
902 // regular tokens
903 //
904 #token "@" << /* will set NLA=V_EOF; in generation*/ >>
905
906 #token "[\ \t\b\r]+"
907 << addtoken(0); zzskip(); >>
908 #token "\n"
909 << addtoken(1); zzskip(); >>
910
911
912 #token V_DECIMAL_NUMBER "[0-9_]+" << addtoken(0); STMODE; >>
913 #token V_FLOAT1 "[0-9_]+\.[0-9_]+" << addtoken(0); STMODE; >>
914 #token V_FLOAT2 "[0-9_]+(\.[0-9_]+)?[Ee][0-9_]+" << addtoken(0); STMODE; >>
915 #token V_DBASE "[0-9_]*\'[dD][0-9_]+" << addtoken(0); STMODE; >>
916 #token V_BBASE "[0-9_]*\'[bB][xXzZ01_\?]+" << addtoken(0); STMODE; >>
917 #token V_OBASE "[0-9_]*'[oO][xXzZ0-7_\?]+" << addtoken(0); STMODE; >>
918 #token V_HBASE "[0-9_]*\'[hH][xXzZ0-9A-Fa-f_\?]+" << addtoken(0); STMODE; >>
919 #token V_STRING "\"~[\"\r\n]*\"" << addtoken(0); STMODE; >>
920
921 #token V_EQ "\=" << addtoken(0); STMODE; >>
922 #token V_DOT "\." << addtoken(0); STMODE;>>
923
924 #token V_PLUS "\+" << addtoken(0); STMODE; >>
925 #token V_MINUS "\-" << addtoken(0); STMODE; >>
926 #token V_BANG "\!" << addtoken(0); STMODE; >>
927 #token V_TILDE "\~" << addtoken(0); STMODE; >>
928 #token V_AND "\&" << addtoken(0); STMODE; >>
929 #token V_NAND "\~\&" << addtoken(0); STMODE; >>
930 #token V_OR "\|" << addtoken(0); STMODE; >>
931 #token V_NOR "\~\|" << addtoken(0); STMODE; >>
932 #token V_XOR "\^" << addtoken(0); STMODE; >>
933 #token V_XNOR "\~\^" << addtoken(0); STMODE; >>
934
935 #token V_STAR "\*" << addtoken(0); STMODE; >>
936 #token V_SLASH "\/" << addtoken(0); STMODE; >>
937 #token V_MOD "\%" << addtoken(0); STMODE; >>
938 #token V_EQ2 "\=\=" << addtoken(0); STMODE; >>
939 #token V_NEQ "\!\=" << addtoken(0); STMODE; >>
940 #token V_EQ3 "\=\=\=" << addtoken(0); STMODE; >>
941 #token V_NEQ2 "\!\=\=" << addtoken(0); STMODE; >>
942 #token V_AND2 "\&\&" << addtoken(0); STMODE; >>
943 #token V_AND3 "\&\&\&" << addtoken(0); STMODE; >>
944 #token V_OR2 "\|\|" << addtoken(0); STMODE; >>
945 #token V_LT "\<" << addtoken(0); STMODE; >>
946 #token V_LEQ "\<\=" << addtoken(0); STMODE; >>
947 #token V_GT "\>" << addtoken(0); STMODE; >>
948 #token V_GEQ "\>\=" << addtoken(0); STMODE; >>
949 #token V_XNOR2 "\^\~" << addtoken(0); STMODE; >>
950 #token V_SHL "\<\<" << addtoken(0); STMODE; >>
951 #token V_SHR "\>\>" << addtoken(0); STMODE; >>
952 #token V_SSHL "\<\<\<" << addtoken(0); STMODE; >>
953 #token V_SSHR "\>\>\>" << addtoken(0); STMODE; >>
954 #token V_POW "\*\*" << addtoken(0); STMODE; >>
955
956 #token V_QUEST "\?" << addtoken(0); STMODE; >>
957 #token V_COLON "\:" << addtoken(0); STMODE; >>
958
959 #token V_LP "\(" << addtoken(0); STMODE; >>
960 #token V_RP "\)" << addtoken(0); STMODE; >>
961
962 #token V_LBRACK "\[" << addtoken(0); STMODE; >>
963 #token V_RBRACK "\]" << addtoken(0); STMODE; >>
964
965 #token V_LBRACE "\{" << addtoken(0); STMODE; >>
966 #token V_RBRACE "\}" << addtoken(0); STMODE; >>
967 #token V_COMMA "\," << addtoken(0); STMODE; >>
968
969 #token V_AT "\@" << addtoken(0); STMODE; >>
970
971 #token V_SEMI "\;" << addtoken(0); STMODE; >>
972 #token V_POUND "\#" << addtoken(0); STMODE; >>
973 #token V_RARROW "\-\>" << addtoken(0); STMODE; >>
974
975 #token V_TABLE "table" << addtoken(0); if(!do_not_translate) { zzmode(UDP); } else { zzskip(); } >>
976
977 #token V_SPD1 "\=\>" << addtoken(0); STMODE; >>
978 #token V_SPD2 "\*\>" << addtoken(0); STMODE; >>
979
980
981 // identifiers/functions/most keywords
982 #token V_FUNCTION_NAME "\$[_a-zA-Z][_a-zA-Z\$0-9]*" << addtoken(0); STMODE; >>
983 #token V_IDENTIFIER "[_a-zA-Z][_a-zA-Z\$0-9]*" << addtoken(0); NLA = verilog_keyword_code(zztext, zzrewind); STMODE; >>
984 #token V_IDENTIFIER2 "\\~[\ \t\b\n\r]+" << addtoken(0); STMODE; >>
985 #token V_IDENDOT "[_a-zA-Z][_a-zA-Z\$0-9]*(\.[_a-zA-Z][_a-zA-Z\$0-9]*)+" << addtoken(0); STMODE; >>
986
987 // comment handling
988 #token "//~[\n]*" << addtoken(0); parsecomment(); zzskip(); >>
989 #token "/\*" << addtoken(0); zzcomment_depth=1; zzcomment_entry=1; zzcomment_start=zzline; zzmode(COMMENT); zzskip(); >>
990 #token "\*/" << addtoken(0);
991 mesg("** End of comment when not in a comment on line %d in file '%s'.\n", zzline, zzfilename);
992 zzskip(); >>
993 #lexclass COMMENT
994 #token "/\*" << addtoken(0); /* zzcomment_depth++; <=- VERILOG DOES NOT ALLOW NESTED COMMENTS */
995 zzskip(); >>
996 #token "\*/" << addtoken(0); zzcomment_depth--; zzskip(); if(!zzcomment_depth) { zzmode(START); } >>
997 #token "\n" << addtoken(1); zzskip(); >>
998 #token "~[/\*\n]+" << addtoken(0); if(zzcomment_entry) { parsecomment(); zzcomment_entry=0; } zzskip(); >>
999 #token "[/\*]" << addtoken(0); zzskip(); >>
1000
1001 // udp handling
1002 #lexclass UDP
1003 #token V_OUTPUT_SYMBOL "[01xX\?bB]" << addtoken(0); STMODE; >>
1004 #token V_LEVEL_SYMBOL_EXTRA "[\?bB]" << addtoken(0); STMODE; >>
1005 #token V_EDGE_SYMBOL "[rRfFpPnN\*]" << addtoken(0); STMODE; >>
1006 #token V_HYPHEN "\-" << addtoken(0); STMODE; >>
1007 #token "\n" << addtoken(1); zzskip(); >>
1008 #token "[\ \t\b\r]+" << addtoken(0); zzskip(); >>
1009 #token V_COLON "\:" << addtoken(0); STMODE; >>
1010 #token V_SEMI "\;" << addtoken(0); STMODE; >>
1011 #token V_ENDTABLE "endtable" << addtoken(0); if(!do_not_translate) { zzmode(START); } else { zzskip(); } >>
1012 #token V_FUNCTION_NAME "\$[_a-zA-Z][_a-zA-Z\$0-9]*" << addtoken(0); STMODE; >> /* minimize error messages */
1013 #token V_IDENTIFIER "[_a-zA-Z][_a-zA-Z\$0-9]*" << addtoken(0); STMODE; >> /* when in udp */
1014 #token V_IDENTIFIER2 "\\~[\ \t\b\n\r]+" << addtoken(0); STMODE; >>
1015 #token V_IDENDOT "[_a-zA-Z][_a-zA-Z\$0-9]*(\.[_a-zA-Z][_a-zA-Z\$0-9]*)+" << addtoken(0); STMODE; >>
1016 #token V_LP "\(" << addtoken(0); STMODE; >>
1017 #token V_RP "\)" << addtoken(0); STMODE; >>
1018
1019 // comment handling when in udp mode..
1020 #token "`~[\n]*" << addtoken(0); zzskip(); >> // handle preprocessor stuff later..
1021 #token "//~[\n]*" << addtoken(0); parsecomment(); zzskip(); >>
1022 #token "/\*" << addtoken(0); zzcomment_depth=1; zzcomment_entry=1; zzcomment_start=zzline; zzmode(COMMENT); zzskip(); >>
1023 #token "\*/" << addtoken(0);
1024 mesg("** End of comment when not in a comment on line %d in file '%s'.\n", zzline, zzfilename);
1025 zzskip(); >>
1026 #lexclass UDPCOMMENT
1027 #token "/\*" << addtoken(0); /* zzcomment_depth++; <=- VERILOG DOES NOT ALLOW NESTED COMMENTS */
1028 zzskip(); >>
1029 #token "\*/" << addtoken(0); zzcomment_depth--; zzskip(); if(!zzcomment_depth) { zzmode(UDP); } >>
1030 #token "\n" << addtoken(1); zzskip(); >>
1031 #token "~[/\*\n]+" << addtoken(0); if(zzcomment_entry) { parsecomment(); zzcomment_entry=0; } zzskip(); >>
1032 #token "[/\*]" << addtoken(0); zzskip(); >>
1033
1034
1035 // preprocessing I
1036 #lexclass START
1037 #token "`uselib~[\n]*" << addtoken(0); zzskip(); >>
1038 #token "`default_nettype[\ \t\b]+[a-z]+" << addtoken(0); zzskip(); >>
1039 #token "`define~[\n]*" << addtoken(0); if(!do_not_translate) store_define(zztext); zzskip(); >>
1040 #token "`undef[\ \t\b]+[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0); if(!do_not_translate) remove_define(zztext); zzskip(); >>
1041 #token "`unconnected_drive[\ \t\b]+pull[01]" << addtoken(0); zzskip(); >>
1042 #token "`nounconnected_drive" << addtoken(0); zzskip(); >>
1043 #token "`resetall" << addtoken(0); zzskip(); >>
1044 #token "`timescale[\ \t\b]+1{0}{0}[\ \t\b]*{[munpf]}s[\ \t\b]*/[\ \t\b]*1{0}{0}[\ \t\b]*{[munpf]}s" << addtoken(0); zzskip(); >>
1045
1046 #token "`ifdef[\ \t\b]+[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_ifdef(zztext); zzskip(); >>
1047 #token "`ifndef[\ \t\b]+[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_ifndef(zztext); zzskip(); >>
1048 #token "`else" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_else(); zzskip(); >>
1049 #token "`endif" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_endif(); zzskip(); >>
1050 #token "`elsif[\ \t\b]+[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_elsif(zztext); zzskip(); >>
1051 #token "`include[\ \t\b]+\"~[\"\n]*\"" << addtoken(0); if(!do_not_translate) handle_include(zztext); zzskip(); >>
1052
1053 #token "`[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0);
1054 if(is_builtin_define(zztext+1, zzrewind-1)) warn("** Warning: ignoring unsupported '%s' directive in file '%s' line %d\n", zztext, zzfilename, zzline);
1055 else if(!do_not_translate)
1056 warn("** Warning: macro '%s' undefined in file '%s' line %d\n", zztext, zzfilename, zzline);
1057 zzskip(); >>
1058
1059 // preprocessing II (exactly same as tokens for START lexclass above)
1060 #lexclass UDP
1061 #token "`uselib~[\n]*" << addtoken(0); zzskip(); >>
1062 #token "`default_nettype[\ \t\b]+[a-z]+" << addtoken(0); zzskip(); >>
1063 #token "`define~[\n]*" << addtoken(0); if(!do_not_translate) store_define(zztext); zzskip(); >>
1064 #token "`undef[\ \t\b]+[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0); if(!do_not_translate) remove_define(zztext); zzskip(); >>
1065 #token "`unconnected_drive[\ \t\b]+pull[01]" << addtoken(0); zzskip(); >>
1066 #token "`nounconnected_drive" << addtoken(0); zzskip(); >>
1067 #token "`resetall" << addtoken(0); zzskip(); >>
1068 #token "`timescale[\ \t\b]+1{0}{0}[\ \t\b]*{[munpf]}s[\ \t\b]*/[\ \t\b]*1{0}{0}[\ \t\b]*{[munpf]}s" << addtoken(0); zzskip(); >>
1069
1070 #token "`ifdef[\ \t\b]+[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_ifdef(zztext); zzskip(); >>
1071 #token "`ifndef[\ \t\b]+[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_ifndef(zztext); zzskip(); >>
1072 #token "`else" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_else(); zzskip(); >>
1073 #token "`endif" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_endif(); zzskip(); >>
1074 #token "`elsif[\ \t\b]+[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0); if(!(do_not_translate&~STMODE_XLATEOFF_IFDEF)) handle_elsif(zztext); zzskip(); >>
1075 #token "`include[\ \t\b]+\"~[\"\n]*\"" << addtoken(0); if(!do_not_translate) handle_include(zztext); zzskip(); >>
1076
1077 #token "`[a-zA-Z_][a-zA-Z0-9_$]*" << addtoken(0);
1078 if(is_builtin_define(zztext+1, zzrewind-1)) warn("** Warning: ignoring unsupported '%s' directive in file '%s' line %d\n", zztext, zzfilename, zzline);
1079 else if(!do_not_translate)
1080 warn("** Warning: macro '%s' undefined in file '%s' line %d\n", zztext, zzfilename, zzline);
1081 zzskip(); >>
1082
1083
1084 //
1085 // section 1
1086 //
1087
1088 v_source_text: (v_description)* V_EOF
1089 ;
1090
1091 v_description: v_module
1092 | v_udp
1093 | v_config // v2k1
1094 ;
1095
1096 // v2k1
1097 v_config: V_CONFIG (~V_ENDCONFIG)* V_ENDCONFIG
1098 ;
1099
1100 // v2k1
1101 v_module_parameters:
1102 V_POUND V_LP V_PARAMETER (v_range | ) v_param_assignment (V_COMMA (V_PARAMETER |) (v_range | ) v_param_assignment)* V_RP
1103 |
1104 ;
1105
1106 v_module: ( V_MODULE | V_MACROMODULE )
1107 << {
1108 struct i_symbol_scope *sb = (struct i_symbol_scope *)calloc(1, sizeof(struct i_symbol_scope));
1109 sb->symtable = make_jrb();
1110 sb->parent = sym_base;
1111 sym_base = sb;
1112
1113 module_is_duplicate=0;
1114 if(mod_current_filename)
1115 {
1116 free(mod_current_filename);
1117 }
1118 mod_current_filename = strdup(zzfilename);
1119
1120 if(mod_current_name)
1121 {
1122 free(mod_current_name);
1123 mod_current_name = NULL;
1124 }
1125
1126 mod_start_line = zzline;
1127 }
1128 >>
1129 v_identifier_nodot
1130 << {
1131 JRB node = jrb_find_str(modname_tree, $2.symbol->name);
1132 /* if((!node)||((node)&&(!node->val.i))) : redundant condition */
1133 if((!node)||(!node->val.i))
1134 {
1135 add_string_to_tree(modname_tree, $2.symbol->name, TRUE);
1136 mod_current_name = strdup($2.symbol->name);
1137
1138 }
1139 else
1140 {
1141 warn("** Warning: skipping duplicate module '%s' at in file '%s' line %d\n", $2.symbol->name, zzfilename, zzline);
1142 module_is_duplicate = 1;
1143 }
1144 }
1145 >>
1146
1147 v_module_parameters // v2k1
1148
1149 v_module_body
1150
1151 V_ENDMODULE
1152 << {
1153 if(sym_base)
1154 {
1155 if(module_is_duplicate)
1156 {
1157 JRB symtree = sym_base->symtable;
1158 struct i_symbol_scope *sb = sym_base->parent;
1159 JRB node;
1160
1161 jrb_traverse(node, symtree)
1162 {
1163 free(((struct i_symbol *)node->val.v)->name);
1164 free(node->val.v); /* free up strings for any stray symbols (should be only modname) */
1165 }
1166 jrb_free_tree(symtree);
1167 free(sym_base);
1168 sym_base = sb;
1169 }
1170 else
1171 {
1172 JRB symtree = sym_base->symtable;
1173 JRB node;
1174
1175 sym_base = sym_base->parent;
1176
1177 if(emit_stems)
1178 {
1179 char real_path[PATH_MAX];
1180
1181 printf("++ module %s file %s lines %d - %d\n",
1182 mod_current_name, realpath(mod_current_filename, real_path), mod_start_line, zzline);
1183 }
1184
1185 if(emit_vars)
1186 {
1187 jrb_traverse(node, symtree)
1188 {
1189 printf("++ var %s module %s\n",
1190 ((struct i_symbol *)node->val.v)->name,
1191 mod_current_name);
1192 }
1193 }
1194
1195 if(mod_current_filename)
1196 {
1197 free(mod_current_filename);
1198 mod_current_filename = NULL;
1199 }
1200
1201 if(mod_current_name)
1202 {
1203 free(mod_current_name);
1204 mod_current_name = NULL;
1205 }
1206 }
1207 }
1208 }
1209 >>
1210 ;
1211
1212 v_module_body: (v_list_of_ports|v_v2k_list_of_ports) V_SEMI
1213 (v_module_item)*
1214 ;
1215
1216 v_v2k_list_of_ports: V_LP v_v2k_iio_declaration (V_COMMA v_v2k_iio_declaration)* V_RP // v2k1
1217 ;
1218
1219 v_v2k_iio_declaration: v_v2k_input_declaration | v_v2k_output_declaration | v_v2k_inout_declaration // v2k1
1220 ;
1221
1222 v_v2k_input_declaration: V_INPUT v_optnettype v_optsigned (v_range | ) v_name_of_variable (v_range | ) // v2k1
1223 ;
1224 v_v2k_output_declaration: V_OUTPUT v_optnettype v_optsigned (v_range | ) v_name_of_variable (v_range | ) // v2k1
1225 ;
1226 v_v2k_inout_declaration: V_INOUT v_optnettype v_optsigned (v_range | ) v_name_of_variable (v_range | ) // v2k1
1227 ;
1228
1229
1230 v_list_of_ports: V_LP v_port ( V_COMMA v_port)* V_RP
1231 |
1232 ;
1233
1234 v_port: v_port_expression
1235 | V_DOT v_identifier_nodot V_LP v_port_expression V_RP
1236 ;
1237
1238 v_port_expression: v_port_reference
1239 | V_LBRACE v_port_reference (V_COMMA v_port_reference)* V_RBRACE
1240 |
1241 ;
1242
1243 v_port_reference: v_identifier_nodot
1244 ( (V_LBRACK v_expression (V_COLON v_expression | )
1245 V_RBRACK) | )
1246 ;
1247
1248 v_module_item: v_parameter_declaration
1249 | v_localparam_declaration // v2k1
1250 | v_input_declaration
1251 | v_output_declaration
1252 | v_inout_declaration
1253 | v_reg_declaration
1254 | v_time_declaration
1255 | v_integer_declaration
1256 | v_genvar_declaration
1257 | v_real_declaration
1258 | v_event_declaration
1259 | v_gate_declaration
1260 | v_udp
1261 | v_module_instantiation
1262 | v_parameter_override
1263 | v_continuous_assign
1264 | v_initial_statement
1265 | v_always_statement
1266 | v_task
1267 | v_function
1268 | v_specify_block
1269 | v_generate_block
1270 ;
1271
1272 v_udp: V_PRIMITIVE
1273 << {
1274 struct i_symbol_scope *sb = (struct i_symbol_scope *)calloc(1, sizeof(struct i_symbol_scope));
1275 sb->symtable = make_jrb();
1276 sb->parent = sym_base;
1277 sym_base = sb;
1278
1279 module_is_duplicate = 0;
1280
1281 if(udp_current_filename)
1282 {
1283 free(udp_current_filename);
1284 }
1285 udp_current_filename = strdup(zzfilename);
1286
1287 if(udp_current_name)
1288 {
1289 free(udp_current_name);
1290 udp_current_name = NULL;
1291 }
1292
1293 udp_start_line = zzline;
1294 }
1295 >>
1296 v_name_of_udp
1297 <<
1298 {
1299 JRB node = jrb_find_str(modname_tree, $2.symbol->name);
1300 /* if((!node)||((node)&&(!node->val.i))) : redundant condition */
1301 if((!node)||(!node->val.i))
1302 {
1303 add_string_to_tree(modname_tree, $2.symbol->name, TRUE);
1304 udp_current_name = strdup($2.symbol->name);
1305 }
1306 else
1307 {
1308 warn("** Warning: skipping duplicate UDP '%s' at in file '%s' line %d\n", $2.symbol->name, zzfilename, zzline);
1309 module_is_duplicate = 1;
1310 }
1311 }
1312 >>
1313
1314 V_LP v_name_of_variable
1315 ( V_COMMA v_name_of_variable )* V_RP V_SEMI
1316 (v_udp_declaration)+
1317 v_udp_initial_statement
1318 v_table_definition
1319 V_ENDPRIMITIVE
1320 <<
1321 {
1322 if(sym_base)
1323 {
1324 if(module_is_duplicate)
1325 {
1326 JRB symtree = sym_base->symtable;
1327 struct i_symbol_scope *sb = sym_base->parent;
1328 JRB node;
1329
1330 jrb_traverse(node, symtree)
1331 {
1332 free(((struct i_symbol *)node->val.v)->name);
1333 free(node->val.v); /* free up strings for any stray symbols (should be only modname) */
1334 }
1335 jrb_free_tree(symtree);
1336 free(sym_base);
1337 sym_base = sb;
1338 }
1339 else
1340 {
1341 sym_base = sym_base->parent;
1342
1343 if(emit_stems)
1344 {
1345 char real_path[PATH_MAX];
1346
1347 printf("++ udp %s file %s lines %d - %d\n",
1348 udp_current_name, realpath(udp_current_filename, real_path), udp_start_line, zzline);
1349 }
1350
1351 if(udp_current_filename)
1352 {
1353 free(udp_current_filename);
1354 udp_current_filename = NULL;
1355 }
1356
1357 if(udp_current_name)
1358 {
1359 free(udp_current_name);
1360 udp_current_name = NULL;
1361 }
1362 }
1363 }
1364 }
1365 >>
1366 ;
1367
1368 v_udp_declaration: v_output_declaration
1369 | v_reg_declaration
1370 | v_input_declaration
1371 ;
1372
1373 v_udp_initial_statement: V_INITIAL v_output_terminal_name V_EQ v_init_val V_SEMI
1374 |
1375 ;
1376
1377 // v_init_val can ONLY be "1\'[bB]0", "1\'[bB]1", "1\'[bB][xX]", "1", "0" so this needs to be checked!
1378 v_init_val: V_DECIMAL_NUMBER
1379 | V_BBASE << $$.num = i_number_basemake(NV_BBASE, $1.text); >>
1380 ;
1381
1382 v_output_terminal_name: v_name_of_variable
1383 ;
1384
1385 v_table_definition: V_TABLE v_table_entries V_ENDTABLE
1386 ;
1387
1388 v_table_entries: (v_com_seq_entry)+
1389 ;
1390
1391 v_com_seq_entry: v_input_list V_COLON ( v_state V_COLON v_next_state
1392 | V_OUTPUT_SYMBOL) V_SEMI
1393 ;
1394
1395 v_level_symbol: V_OUTPUT_SYMBOL
1396 | V_LEVEL_SYMBOL_EXTRA
1397 ;
1398
1399 v_edge: V_LP v_fake_edge V_RP
1400 | V_EDGE_SYMBOL
1401 ;
1402
1403 // XXX: V_IDENTIFIER is to handle cases like X0, etc that can greedy lex as an identifier!
1404 v_fake_edge: v_level_symbol v_level_symbol
1405 | V_IDENTIFIER
1406 ;
1407
1408 v_level_symbol2: v_level_symbol
1409 | v_edge
1410 ;
1411
1412 v_input_list: (v_level_symbol2)*
1413 ;
1414
1415
1416 v_state: v_level_symbol
1417 ;
1418
1419 v_next_state: V_OUTPUT_SYMBOL
1420 | V_HYPHEN
1421 ;
1422
1423 v_task: V_TASK
1424 << {
1425 struct i_symbol_scope *sb = (struct i_symbol_scope *)calloc(1, sizeof(struct i_symbol_scope));
1426 sb->symtable = make_jrb();
1427 sb->parent = sym_base;
1428 sym_base = sb;
1429 }
1430 >>
1431 v_identifier_nodot V_SEMI
1432 ( v_tf_declaration )*
1433 v_statement_or_null V_ENDTASK
1434 << if(sym_base) sym_base = sym_base->parent; >>
1435 ;
1436
1437 v_function: V_FUNCTION
1438 << {
1439 struct i_symbol_scope *sb = (struct i_symbol_scope *)calloc(1, sizeof(struct i_symbol_scope));
1440 sb->symtable = make_jrb();
1441 sb->parent = sym_base;
1442 sym_base = sb;
1443 }
1444 >>
1445 ( v_range_or_type | ) v_identifier_nodot V_SEMI
1446 ( v_tf_declaration )+
1447 v_statement V_ENDFUNCTION
1448 << if(sym_base) sym_base = sym_base->parent; >>
1449 ;
1450
1451 v_range_or_type: v_range
1452 | V_INTEGER
1453 | V_REAL
1454 ;
1455
1456 v_tf_declaration: v_parameter_declaration
1457 | v_localparam_declaration // v2k1
1458 | v_input_declaration
1459 | v_output_declaration
1460 | v_inout_declaration
1461 | v_reg_declaration
1462 | v_time_declaration
1463 | v_integer_declaration
1464 | v_real_declaration
1465 ;
1466
1467 //
1468 // section 2
1469 //
1470
1471 v_parameter_declaration: V_PARAMETER v_optsigned (v_range | ) v_list_of_param_assignments V_SEMI
1472 ;
1473
1474 // v2k1
1475 v_localparam_declaration: V_LOCALPARAM v_optsigned (v_range | ) v_list_of_param_assignments V_SEMI
1476 ;
1477
1478 v_param_assignment: v_identifier V_EQ v_constant_expression
1479 ;
1480
1481 v_list_of_param_assignments: v_param_assignment
1482 (V_COMMA v_param_assignment)*
1483 ;
1484
1485 v_input_declaration: V_INPUT v_optnettype v_optsigned ( v_list_of_variables V_SEMI
1486 | v_range v_list_of_variables V_SEMI )
1487 ;
1488
1489 v_output_declaration: V_OUTPUT v_optnettype v_optsigned ( v_list_of_variables V_SEMI
1490 | v_range v_list_of_variables V_SEMI )
1491 ;
1492
1493 v_inout_declaration: V_INOUT v_optnettype v_optsigned (v_list_of_variables V_SEMI
1494 | v_range v_list_of_variables V_SEMI )
1495 ;
1496
1497 v_net_chg: v_charge_strength
1498 |
1499 ;
1500
1501 v_nettype: V_WIRE
1502 | V_TRI
1503 | V_TRI1
1504 | V_SUPPLY0
1505 | V_WAND
1506 | V_TRIAND
1507 | V_TRI0
1508 | V_SUPPLY1
1509 | V_WOR
1510 | V_TRIOR
1511 | V_TRIREG
1512 ;
1513
1514 // v2k1
1515 v_optnettype: v_nettype
1516 | V_REG
1517 |
1518 ;
1519
1520 v_expandrange: v_range
1521 | V_SCALARED v_range
1522 | V_VECTORED v_range
1523 ;
1524
1525 v_reg_declaration: V_REG v_optsigned v_reg_range v_list_of_register_variables V_SEMI
1526 ;
1527
1528 v_reg_range: v_range
1529 |
1530 ;
1531
1532 v_time_declaration: V_TIME v_optsigned (v_range | ) v_list_of_register_variables V_SEMI
1533 ;
1534
1535 v_integer_declaration: V_INTEGER v_optsigned (v_range | ) v_list_of_register_variables V_SEMI
1536 ;
1537
1538 v_genvar_declaration: V_GENVAR v_optsigned (v_range | ) v_list_of_register_variables V_SEMI
1539 ;
1540
1541 v_real_declaration: V_REAL v_optsigned (v_range | ) v_list_of_register_variables V_SEMI
1542 ;
1543
1544 v_event_declaration: V_EVENT v_name_of_event (V_COMMA v_name_of_event)* V_SEMI
1545 ;
1546
1547 v_continuous_assign: V_ASSIGN v_cont_drv v_cont_dly v_list_of_assignments V_SEMI
1548 | v_nettype
1549 v_optsigned // v2k1
1550 v_net_chg
1551 v_cont_exr v_cont_dly
1552 (v_list_of_variables | v_list_of_assignments) V_SEMI
1553 ;
1554
1555 v_cont_drv: v_drive_strength
1556 |
1557 ;
1558
1559 v_cont_exr: v_expandrange
1560 |
1561 ;
1562
1563 v_cont_dly: v_delay
1564 |
1565 ;
1566
1567
1568 v_parameter_override: V_DEFPARAM v_list_of_param_assignments V_SEMI
1569 ;
1570
1571 v_list_of_variables: v_name_of_variable v_optrange_list
1572 (V_COMMA v_name_of_variable v_optrange_list)*
1573 ;
1574
1575 v_optrange_list: (v_range | )
1576 ;
1577
1578 v_name_of_variable: v_identifier
1579 ;
1580
1581 v_list_of_register_variables: v_register_variable
1582 (V_COMMA v_register_variable)*
1583 ;
1584
1585 v_register_variable: v_name_of_register
1586 | v_name_of_register V_EQ v_expression // v2k1
1587 | v_name_of_memory V_LBRACK v_expression V_COLON
1588 v_expression V_RBRACK
1589 ;
1590
1591 v_name_of_register: v_identifier
1592 ;
1593
1594 v_name_of_memory: v_identifier
1595 ;
1596
1597 v_name_of_event: v_identifier
1598 ;
1599
1600 v_charge_strength: V_LP (V_SMALL
1601 | V_MEDIUM
1602 | V_LARGE
1603 | v_strength0 V_COMMA v_strength1
1604 | v_strength1 V_COMMA v_strength0) V_RP
1605 ;
1606
1607 v_drive_strength: V_LP (v_strength0 V_COMMA v_strength1
1608 | v_strength1 V_COMMA v_strength0) V_RP
1609 ;
1610
1611 v_strength0: V_SUPPLY0
1612 | V_STRONG0
1613 | V_PULL0
1614 | V_WEAK0
1615 | V_HIGHZ0
1616 ;
1617
1618 v_strength1: V_SUPPLY1
1619 | V_STRONG1
1620 | V_PULL1
1621 | V_WEAK1
1622 | V_HIGHZ1
1623 ;
1624
1625 // v2k1
1626 v_optsigned: V_SIGNED
1627 |
1628 ;
1629
1630 v_range: V_LBRACK v_expression
1631 V_COLON v_expression V_RBRACK
1632 ;
1633
1634 v_list_of_assignments: v_assignment (V_COMMA v_assignment)*
1635 ;
1636
1637
1638 //
1639 // section 3
1640 //
1641
1642 v_gate_declaration: v_gatetype v_gate_drv v_gate_dly v_gate_instance
1643 (V_COMMA v_gate_instance)* V_SEMI
1644 ;
1645 v_gatetype:
1646 V_ANDLIT | V_NANDLIT | V_ORLIT | V_NORLIT | V_XORLIT | V_XNORLIT
1647 | V_BUF | V_BUFIF0 | V_BUFIF1 | V_NOTLIT | V_NOTIF0 | V_NOTIF1 | V_PULLDOWN | V_PULLUP
1648 | V_NMOS | V_RNMOS | V_PMOS | V_RPMOS | V_CMOS | V_RCMOS | V_TRAN | V_RTRAN
1649 | V_TRANIF0 | V_RTRANIF0 | V_TRANIF1 | V_RTRANIF1
1650 ;
1651
1652 v_gate_drv: v_drive_strength
1653 |
1654 ;
1655
1656 v_gate_dly: v_delay
1657 |
1658 ;
1659
1660 v_gate_range: v_range
1661 |
1662 ;
1663
1664
1665 v_gate_instance: v_name_of_gate_instance V_LP v_terminal
1666 (V_COMMA v_terminal)* V_RP
1667 ;
1668
1669 v_name_of_gate_instance: v_identifier_nodot v_gate_range
1670 |
1671 ;
1672
1673 v_terminal: v_expression
1674 |
1675 ;
1676
1677 v_udp_instantiation: v_name_of_udp v_gate_drv v_gate_dly v_udp_instance
1678 (V_COMMA v_udp_instance)* V_SEMI
1679 ;
1680
1681 v_name_of_udp: v_identifier_nodot
1682 << $$.symbol = $1.symbol; >>
1683 ;
1684
1685 v_udp_instance: v_name_of_udp_instance V_LP v_terminal
1686 (V_COMMA v_terminal)* V_RP
1687 ;
1688
1689 v_name_of_udp_instance: v_identifier_nodot v_gate_range
1690 |
1691 ;
1692
1693
1694 //
1695 // section 4
1696 //
1697 v_module_instantiation: v_name_of_module
1698 <<
1699 if(!module_is_duplicate)
1700 {
1701 add_string_to_tree(modname_tree, $1.symbol->name, FALSE);
1702 if(comp_type_name)
1703 {
1704 free(comp_type_name);
1705 }
1706 comp_type_name = strdup($1.symbol->name);
1707 } /* to keep transitive closure from looking for nonexistant modules if duplicate modules differ! */
1708 >>
1709 v_parameter_value_assignment
1710 v_module_instance
1711 (V_COMMA v_module_instance)* V_SEMI
1712 <<
1713 if(comp_type_name)
1714 {
1715 free(comp_type_name);
1716 comp_type_name = NULL;
1717 }
1718 >>
1719 ;
1720
1721 v_name_of_module: v_identifier_nodot << $$.symbol = $1.symbol; >>
1722 ;
1723
1724 v_parameter_value_assignment:
1725 V_POUND V_LP v_mexplist V_RP
1726 | V_POUND v_number
1727 |
1728 ;
1729
1730 v_module_instance: v_name_of_instance_opt V_LP v_list_of_module_connections V_RP
1731 ;
1732
1733 // XXX: anon module names...
1734 v_name_of_instance_opt: v_name_of_instance
1735 |
1736 ;
1737
1738 v_name_of_instance: v_identifier_nodot v_mod_range
1739 <<
1740 if(!module_is_duplicate)
1741 {
1742 if(emit_stems)
1743 {
1744 printf("++ comp %s type %s parent %s\n", $1.symbol->name, comp_type_name, mod_current_name);
1745 }
1746 }
1747 >>
1748 ;
1749
1750 v_mod_range: v_range
1751 |
1752 ;
1753
1754 v_list_of_module_connections: v_module_port_connection (V_COMMA v_module_port_connection)*
1755 | v_named_port_connection (V_COMMA v_named_port_connection)*
1756 ;
1757
1758 v_module_port_connection: v_expression
1759 |
1760 ;
1761
1762 v_named_port_connection: V_DOT v_identifier_nodot V_LP (v_expression | ) V_RP
1763 ;
1764
1765
1766 //
1767 // section 5
1768 //
1769
1770 v_initial_statement: V_INITIAL v_statement
1771 ;
1772
1773 v_always_statement: V_ALWAYS v_statement
1774 ;
1775
1776 v_statement_or_null: v_statement
1777 | V_SEMI
1778 ;
1779
1780 v_statement: v_block_or_non_assignment V_SEMI
1781 | V_IF V_LP v_expression V_RP v_statement_or_null
1782 ( V_ELSE v_statement_or_null | )
1783 | V_CASE V_LP v_expression V_RP (v_case_item)+ V_ENDCASE
1784 | V_CASEX V_LP v_expression V_RP (v_case_item)+ V_ENDCASE
1785 | V_CASEZ V_LP v_expression V_RP (v_case_item)+ V_ENDCASE
1786 | V_FOREVER v_statement
1787 | V_REPEAT V_LP v_expression V_RP v_statement
1788 | V_WHILE V_LP v_expression V_RP v_statement
1789 | V_FOR V_LP v_assignment V_SEMI v_expression V_SEMI
1790 v_assignment V_RP v_statement
1791 | v_delay_or_event_control_stmt v_statement_or_null
1792 | V_WAIT V_LP v_expression V_RP v_statement_or_null
1793 | V_RARROW v_name_of_event V_SEMI
1794 | v_seq_block
1795 | v_par_block
1796 | v_task_enable
1797 | V_DISABLE (v_name_of_task_or_block) V_SEMI
1798 | V_ASSIGN v_assignment V_SEMI
1799 | V_DEASSIGN v_lvalue V_SEMI
1800 | V_FORCE v_assignment V_SEMI
1801 | V_RELEASE v_lvalue V_SEMI
1802 ;
1803
1804 v_assignment: v_lvalue V_EQ v_expression
1805 ;
1806
1807 v_block_or_non_assignment: v_lvalue ( v_blocking_assignment
1808 | v_non_blocking_assignment)
1809 ;
1810
1811 v_blocking_assignment: V_EQ ( v_expression
1812 | v_delay_or_event_control v_expression )
1813 ;
1814
1815 v_non_blocking_assignment: V_LEQ ( v_expression
1816 | v_delay_or_event_control v_expression )
1817 ;
1818
1819 v_delay_or_event_control: v_delay_control
1820 | v_event_control
1821 | V_REPEAT V_LP v_expression V_RP v_event_control
1822 ;
1823
1824 v_delay_or_event_control_stmt: v_delay_control
1825 | v_event_control
1826 ;
1827
1828 v_case_item: v_explist
1829 V_COLON v_statement_or_null
1830 | V_DEFAULT (V_COLON v_statement_or_null
1831 | v_statement_or_null)
1832 ;
1833
1834 v_seq_block: V_BEGIN
1835 << {
1836 struct i_symbol_scope *sb = (struct i_symbol_scope *)calloc(1, sizeof(struct i_symbol_scope));
1837 sb->symtable = make_jrb();
1838 sb->parent = sym_base;
1839 sym_base = sb;
1840 }
1841 >>
1842 ( (v_statement)* |
1843 V_COLON v_name_of_block (v_block_declaration)*
1844 (v_statement)* )
1845 V_END
1846 << if(sym_base) sym_base = sym_base->parent; >>
1847 ;
1848
1849 v_par_block: V_FORK
1850 << {
1851 struct i_symbol_scope *sb = (struct i_symbol_scope *)calloc(1, sizeof(struct i_symbol_scope));
1852 sb->symtable = make_jrb();
1853 sb->parent = sym_base;
1854 sym_base = sb;
1855 }
1856 >>
1857 ( (v_statement)* |
1858 V_COLON v_name_of_block (v_block_declaration)*
1859 (v_statement)* ) V_JOIN
1860 << if(sym_base) sym_base = sym_base->parent; >>
1861 ;
1862
1863 v_name_of_block: v_identifier_nodot
1864 ;
1865
1866 v_block_declaration: v_parameter_declaration
1867 | v_localparam_declaration // v2k1
1868 | v_reg_declaration
1869 | v_integer_declaration
1870 | v_real_declaration
1871 | v_time_declaration
1872 | v_event_declaration
1873 ;
1874
1875 v_task_enable: v_name_of_task V_SEMI
1876 | v_name_of_task V_LP v_explist V_RP V_SEMI
1877 ;
1878
1879 v_name_of_task: v_identifier
1880 ;
1881
1882 // for disable ()
1883 v_name_of_task_or_block: v_identifier_nodot
1884 ;
1885
1886 v_generate_block: V_GENERATE (~V_ENDGENERATE)* V_ENDGENERATE
1887 ;
1888
1889
1890 //
1891 // section 6 (specify blocks not supported, just skip over them with negative token matching)
1892 //
1893 v_specify_block: V_SPECIFY (~V_ENDSPECIFY)* V_ENDSPECIFY
1894 ;
1895
1896 v_constant_expression: v_expression
1897 << $$.prim = $1.prim; >>
1898 ;
1899
1900 //
1901 // section 7
1902 //
1903 v_lvalue: v_identifier
1904 (
1905 V_LBRACK v_expression
1906 ( V_COLON v_expression
1907 << $$.prim = i_primary_symrange_make($1.1.symbol,$2.2.prim,$3.2.prim); >>
1908 | << $$.prim = i_primary_symbit_make($1.1.symbol,$2.2.prim); >>
1909 ) V_RBRACK
1910 v_opt_array_handling // v2k1 FIXME for symmake
1911 | << $$.prim = i_primary_make(PRIM_SYMBOL,$1.1.symbol); >>
1912 )
1913 | v_concatenation << $$.prim = $1.prim; >>
1914 ;
1915
1916 v_expression: << push_exp_now(); >> v_expression2 <<
1917 if(!zzerrors)
1918 {
1919 push_oper(i_oper_make(V_EOF,0));
1920 push_primary(NULL);
1921 pop_exp_now();
1922 $$.prim = shred_expression();
1923 }
1924 else
1925 {
1926 $$.prim = NULL;
1927 }
1928 >>
1929 ;
1930
1931 v_expression2: ( v_primary << push_primary($1.prim); >>
1932 | v_unary_operator v_primary
1933 << push_primary(NULL); push_oper($1.oper); push_primary($2.prim); >>
1934 | V_STRING << push_primary(i_primary_make(PRIM_NUMBER, i_number_basemake(NV_STRING, $1.text))); >> )
1935 ( v_binary_operator << push_oper($1.oper); >> v_expression2
1936 | V_QUEST v_expression V_COLON v_expression
1937 << push_oper(i_oper_make(V_QUEST,1));
1938 push_primary(i_bin_expr_make($2.prim,i_oper_make(V_COLON, 1),$4.prim)); >>
1939 | )
1940 ;
1941
1942 v_mintypmax_expression: v_expression
1943 (V_COLON v_expression V_COLON v_expression
1944 << $$.prim = i_primary_mintypmax_make($1.1.prim, $2.2.prim, $2.4.prim); >>
1945 | << $$.prim = $1.1.prim; >> )
1946 ;
1947
1948 v_unary_operator: V_PLUS << $$.oper = i_oper_make(V_PLUS, 12); >>
1949 | V_MINUS << $$.oper = i_oper_make(V_MINUS,12); >>
1950 | V_BANG << $$.oper = i_oper_make(V_BANG, 12); >>
1951 | V_TILDE << $$.oper = i_oper_make(V_TILDE,12); >>
1952 | V_AND << $$.oper = i_oper_make(V_AND, 12); >>
1953 | V_NAND << $$.oper = i_oper_make(V_NAND, 12); >>
1954 | V_OR << $$.oper = i_oper_make(V_OR, 12); >>
1955 | V_NOR << $$.oper = i_oper_make(V_NOR, 12); >>
1956 | V_XOR << $$.oper = i_oper_make(V_XOR, 12); >>
1957 | V_XNOR << $$.oper = i_oper_make(V_XNOR, 12); >>
1958 | V_XNOR2 << $$.oper = i_oper_make(V_XNOR, 12); >>
1959 ;
1960
1961 v_binary_operator: V_POW << $$.oper = i_oper_make(V_POW, 11); >>
1962 | V_STAR << $$.oper = i_oper_make(V_STAR, 10); >>
1963 | V_SLASH << $$.oper = i_oper_make(V_SLASH,10); >>
1964 | V_MOD << $$.oper = i_oper_make(V_MOD, 10); >>
1965 | V_PLUS << $$.oper = i_oper_make(V_PLUS, 9); >>
1966 | V_MINUS << $$.oper = i_oper_make(V_MINUS, 9); >>
1967 | V_SHL << $$.oper = i_oper_make(V_SHL, 8); >>
1968 | V_SHR << $$.oper = i_oper_make(V_SHR, 8); >>
1969 | V_SSHL << $$.oper = i_oper_make(V_SSHL, 8); >>
1970 | V_SSHR << $$.oper = i_oper_make(V_SSHR, 8); >>
1971 | V_LT << $$.oper = i_oper_make(V_LT, 7); >>
1972 | V_LEQ << $$.oper = i_oper_make(V_LEQ, 7); >>
1973 | V_GT << $$.oper = i_oper_make(V_GT, 7); >>
1974 | V_GEQ << $$.oper = i_oper_make(V_GEQ, 7); >>
1975 | V_EQ2 << $$.oper = i_oper_make(V_EQ2, 6); >>
1976 | V_NEQ << $$.oper = i_oper_make(V_NEQ, 6); >>
1977 | V_EQ3 << $$.oper = i_oper_make(V_EQ3, 6); >>
1978 | V_NEQ2 << $$.oper = i_oper_make(V_NEQ2, 6); >>
1979 | V_AND << $$.oper = i_oper_make(V_AND, 5); >>
1980 | V_NAND << $$.oper = i_oper_make(V_NAND, 5); >>
1981 | V_XOR << $$.oper = i_oper_make(V_XOR, 5); >>
1982 | V_XNOR << $$.oper = i_oper_make(V_XNOR, 5); >>
1983 | V_XNOR2 << $$.oper = i_oper_make(V_XNOR, 5); >>
1984 | V_OR << $$.oper = i_oper_make(V_OR, 4); >>
1985 | V_NOR << $$.oper = i_oper_make(V_NOR, 4); >>
1986 | V_AND2 << $$.oper = i_oper_make(V_AND2, 3); >>
1987 | V_OR2 << $$.oper = i_oper_make(V_OR2, 2); >>
1988 ;
1989
1990 // v2k1
1991 v_opt_array_handling: ( V_LBRACK v_expression (V_COLON v_expression |) V_RBRACK | );
1992
1993 v_primary: v_number << $$.prim = i_primary_make(PRIM_NUMBER,$1.num); >>
1994 | v_identifier
1995 ( V_LBRACK v_expression
1996 ( V_RBRACK
1997 << $$.prim= i_primary_symbit_make($1.1.symbol,$2.2.prim); >>
1998 v_opt_array_handling // v2k1 FIXME for symmake
1999 | V_COLON v_expression V_RBRACK
2000 << $$.prim= i_primary_symrange_make($1.1.symbol,$2.2.prim,$3.2.prim); >> )
2001 | << $$.prim= i_primary_make(PRIM_SYMBOL,$1.1.symbol); >> )
2002 | v_multiple_concatenation << $$.prim = $1.prim; >>
2003 | v_function_call << $$.prim = $1.prim; >>
2004 | V_LP v_mintypmax_expression V_RP << $$.prim = $2.prim; >>
2005 ;
2006
2007
2008 v_number: V_DECIMAL_NUMBER << $$.num = i_number_make($1.1.ival); >>
2009 | V_HBASE << $$.num = i_number_basemake(NV_HBASE, $1.text); >>
2010 | V_DBASE << $$.num = i_number_basemake(NV_DBASE, $1.text); >>
2011 | V_BBASE << $$.num = i_number_basemake(NV_BBASE, $1.text); >>
2012 | V_OBASE << $$.num = i_number_basemake(NV_OBASE, $1.text); >>
2013 | V_FLOAT1 << $$.num = i_number_fmake($1.rval); >>
2014 | V_FLOAT2 << $$.num = i_number_fmake($1.rval); >>
2015 ;
2016
2017 v_concatenation:
2018 V_LBRACE v_explist V_RBRACE
2019 << $$.prim = i_primary_concat_make(NULL,$2.explist); >>
2020 ;
2021
2022 v_multiple_concatenation:
2023 << struct i_explist *lroot=NULL, *lcurrent=NULL; >>
2024 V_LBRACE v_expression
2025 << lroot=lcurrent=(struct i_explist *)calloc(1,sizeof(struct i_explist));
2026 lcurrent->item=$2.prim;
2027 >>
2028 (
2029 (V_COMMA v_expression
2030 << lcurrent->next=(struct i_explist *)calloc(1,sizeof(struct i_explist));
2031 lcurrent=lcurrent->next;
2032 lcurrent->item=$2.prim;
2033 >>
2034 )*
2035 << $$.prim = i_primary_concat_make(NULL,i_explist_make(lroot)); >>
2036 |
2037 V_LBRACE v_explist V_RBRACE
2038 << $$.prim = i_primary_concat_make(lroot->item,$2.explist);
2039 free(lroot);
2040 >>
2041 )
2042 V_RBRACE
2043 ;
2044
2045 v_function_call: v_name_of_function V_LP v_explist V_RP
2046 << $$.prim=i_primary_funcall_make($1.symbol,$3.explist); >>
2047 ;
2048
2049 v_name_of_function: v_identifier_nodot << $$.symbol = $1.symbol; >>
2050 ;
2051
2052 v_explist: << struct i_explist *lroot=NULL, *lcurrent=NULL; >>
2053 v_fn_expression
2054 << lroot=lcurrent=(struct i_explist *)calloc(1,sizeof(struct i_explist));
2055 lcurrent->item=$1.prim;
2056 >>
2057 (V_COMMA v_fn_expression
2058 << lcurrent->next=(struct i_explist *)calloc(1,sizeof(struct i_explist));
2059 lcurrent=lcurrent->next;
2060 lcurrent->item=$2.prim;
2061 >>
2062 )*
2063 << $$.explist=i_explist_make(lroot); >>
2064 ;
2065
2066 v_fn_expression:
2067 v_expression << $$.prim = $1.prim; >>
2068 | << $$.prim = NULL; >>
2069 ;
2070
2071 // these are the special versions for named parameters ... which are present in verilog 2001
2072 v_mexplist: << struct i_explist *lroot=NULL, *lcurrent=NULL; >>
2073 v_mfn_expression
2074 << lroot=lcurrent=(struct i_explist *)calloc(1,sizeof(struct i_explist));
2075 lcurrent->item=$1.prim;
2076 >>
2077 (V_COMMA v_mfn_expression
2078 << lcurrent->next=(struct i_explist *)calloc(1,sizeof(struct i_explist));
2079 lcurrent=lcurrent->next;
2080 lcurrent->item=$2.prim;
2081 >>
2082 )*
2083 << $$.explist=i_explist_make(lroot); >>
2084 ;
2085
2086 v_mfn_expression:
2087 V_DOT v_identifier_nodot V_LP v_expression V_RP
2088 <<
2089 struct i_primary *ip = i_primary_make(PRIM_NAMEDPARAM,NULL);
2090 ip->primval.named_param.sym = $2.symbol;
2091 ip->primval.named_param.exp = $4.prim;
2092
2093 $$.prim = ip;
2094 >>
2095 | v_expression << $$.prim = $1.prim; >>
2096 | << $$.prim = NULL; >>
2097 ;
2098
2099 //
2100 // section 8
2101 //
2102
2103 v_identifier: v_identifier_nodot << $$.symbol = $1.symbol; >>
2104 | V_IDENDOT << $$.symbol = $1.symbol; >>
2105 ;
2106
2107 v_identifier_nodot:
2108 V_IDENTIFIER << $$.symbol = $1.symbol; >>
2109 | V_IDENTIFIER2 << $$.symbol = $1.symbol; >>
2110 | V_FUNCTION_NAME << $$.symbol = $1.symbol; >>
2111 ;
2112
2113 v_delay: V_POUND ( v_number
2114 | v_identifier
2115 | V_LP v_mintypmax_expression
2116 (V_COMMA v_mintypmax_expression)* V_RP ) // complain if > 3 mintypmax expressions!
2117 ;
2118
2119 v_delay_control: V_POUND ( v_number
2120 | v_identifier
2121 | V_LP v_mintypmax_expression V_RP )
2122 ;
2123
2124 v_event_control: V_AT ( v_identifier
2125 | V_LP v_event_expression V_RP
2126 | V_STAR // v2k1
2127 )
2128 ;
2129
2130 v_event_expression:
2131 v_event_expression2 ( v_orcomma v_event_expression2 )*
2132 ;
2133
2134 v_orcomma: V_ORLIT
2135 | V_COMMA // v2k1
2136 ;
2137
2138 v_event_expression2: (v_expression
2139 | V_POSEDGE v_expression
2140 | V_NEGEDGE v_expression
2141 | V_STAR // v2k1
2142 )
2143 ;
2144
+0
-135
contrib/vermin/verilog_keyword.gperf less more
0 %{
1
2 #include <string.h>
3 #include "keyword_tokens.h"
4
5 struct verilog_keyword { const char *name; int token; };
6
7 %}
8 struct verilog_keyword
9 %%
10 always, V_ALWAYS
11 and, V_ANDLIT
12 assign, V_ASSIGN
13 begin, V_BEGIN
14 buf, V_BUF
15 bufif0, V_BUFIF0
16 bufif1, V_BUFIF1
17 case, V_CASE
18 casex, V_CASEX
19 casez, V_CASEZ
20 cmos, V_CMOS
21 deassign, V_DEASSIGN
22 default, V_DEFAULT
23 defparam, V_DEFPARAM
24 disable, V_DISABLE
25 edge, V_EDGE
26 else, V_ELSE
27 end, V_END
28 endcase, V_ENDCASE
29 endfunction, V_ENDFUNCTION
30 endmodule, V_ENDMODULE
31 endprimitive, V_ENDPRIMITIVE
32 endspecify, V_ENDSPECIFY
33 endtable, V_ENDTABLE
34 endtask, V_ENDTASK
35 event, V_EVENT
36 for, V_FOR
37 force, V_FORCE
38 forever, V_FOREVER
39 fork, V_FORK
40 function, V_FUNCTION
41 highz0, V_HIGHZ0
42 highz1, V_HIGHZ1
43 if, V_IF
44 initial, V_INITIAL
45 inout, V_INOUT
46 input, V_INPUT
47 integer, V_INTEGER
48 join, V_JOIN
49 large, V_LARGE
50 macromodule, V_MACROMODULE
51 medium, V_MEDIUM
52 module, V_MODULE
53 nand, V_NANDLIT
54 negedge, V_NEGEDGE
55 nmos, V_NMOS
56 nor, V_NORLIT
57 not, V_NOTLIT
58 notif0, V_NOTIF0
59 notif1, V_NOTIF1
60 or, V_ORLIT
61 output, V_OUTPUT
62 parameter, V_PARAMETER
63 pmos, V_PMOS
64 posedge, V_POSEDGE
65 primitive, V_PRIMITIVE
66 pull0, V_PULL0
67 pull1, V_PULL1
68 pulldown, V_PULLDOWN
69 pullup, V_PULLUP
70 rcmos, V_RCMOS
71 real, V_REAL
72 realtime, V_REAL
73 reg, V_REG
74 release, V_RELEASE
75 repeat, V_REPEAT
76 rnmos, V_RNMOS
77 rpmos, V_RPMOS
78 rtran, V_RTRAN
79 rtranif0, V_RTRANIF0
80 rtranif1, V_RTRANIF1
81 scalared, V_SCALARED
82 small, V_SMALL
83 specify, V_SPECIFY
84 specparam, V_SPECPARAM
85 strong0, V_STRONG0
86 strong1, V_STRONG1
87 supply0, V_SUPPLY0
88 supply1, V_SUPPLY1
89 table, V_TABLE
90 task, V_TASK
91 time, V_TIME
92 tran, V_TRAN
93 tranif0, V_TRANIF0
94 tranif1, V_TRANIF1
95 tri, V_TRI
96 tri0, V_TRI0
97 tri1, V_TRI1
98 triand, V_TRIAND
99 trior, V_TRIOR
100 trireg, V_TRIREG
101 vectored, V_VECTORED
102 wait, V_WAIT
103 wand, V_WAND
104 weak0, V_WEAK0
105 weak1, V_WEAK1
106 while, V_WHILE
107 wire, V_WIRE
108 wor, V_WOR
109 xnor, V_XNORLIT
110 xor, V_XORLIT
111 automatic, V_AUTOMATIC
112 cell, V_CELL
113 config, V_CONFIG
114 design, V_DESIGN
115 endconfig, V_ENDCONFIG
116 endgenerate, V_ENDGENERATE
117 generate, V_GENERATE
118 genvar, V_GENVAR
119 instance, V_INSTANCE
120 liblist, V_LIBLIST
121 localparam, V_LOCALPARAM
122 noshowcancelled, V_NOSHOWCANCELLED
123 pulsestyle_onevent, V_PULSESTYLE_ONEVENT
124 pulsestyle_ondetect, V_PULSESTYLE_ONDETECT
125 showcancelled, V_SHOWCANCELLED
126 signed, V_SIGNED
127 use, V_USE
128 %%
129
130 int verilog_keyword_code(const char *s, unsigned int len)
131 {
132 const struct verilog_keyword *rc = check_identifier(s, len);
133 return(rc ? rc->token : V_IDENTIFIER);
134 }
+0
-128
contrib/vermin/vpp_common.h less more
0 #ifndef VPP_COMMON_H
1 #define VPP_COMMON_H
2
3 /*
4 * first, the include files...
5 */
6 #include <stdio.h>
7 #include <string.h>
8 #include <ctype.h>
9 #include <stdlib.h>
10 #include <stdarg.h>
11
12
13 /*
14 * then, some globally accessible defines...
15 */
16 #define VERNAME "Vermin: Verilog Parser v0.3.1 (w)1999-2008 BSI"
17
18
19 /*
20 * structs
21 */
22 struct vpp_filename
23 {
24 struct vpp_filename *next;
25 char *name;
26
27 int numchildren;
28 char **children;
29 };
30
31 struct stringchain_t
32 {
33 struct stringchain_t *next;
34 char *name;
35 };
36
37 struct include_stack_t
38 {
39 struct include_stack_t *next;
40 char *zzfilename;
41 int zzline;
42 FILE *fh;
43 struct preproc_buff_t *preproc_buff_head, *preproc_buff_current;
44 };
45
46
47 struct preproc_buff_t
48 {
49 struct preproc_buff_t *next;
50
51 char *str;
52 int len, pos;
53 };
54
55
56 struct ifdef_stack_t
57 {
58 struct ifdef_stack_t *next;
59
60 char *zzfilename;
61 int zzline;
62 char *deftext;
63
64 int do_not_translate;
65
66 unsigned polarity : 1; /* 1 = ifdef, 0 = ifndef (for error reporting in verilog.g) */
67 unsigned else_branch : 1; /* 0 = don't translate else, 1 = translate else */
68 unsigned blocked : 1; /* blocks propagate to child ifdefs */
69 };
70
71
72 struct macro_stack_t
73 {
74 struct macro_stack_t *next;
75
76 int remaining;
77 char *macname;
78 char *deftext;
79 };
80
81
82 #define TRUE 1
83 #define FALSE 0
84
85 extern struct vpp_filename *vlog_filenames; /* list of verilog files to process */
86 extern struct vpp_filename *incchain; /* list of include directories */
87 extern int include_stack_depth;
88
89 extern int zzLexErrCount; /* inside dlg */
90
91 extern FILE *mgetchar_fout; /* for mgetchar_outhandle */
92
93 /*
94 * prototypes...
95 */
96 void do_comment_count(int force_print, int count);
97 int mprintf(const char *fmt, ... );
98 int mgetstr(char *buf, int maxsiz);
99 int mgetchar(void);
100 int mgetchar_outhandle(void);
101 void mesg(const char *format, ...);
102 void warn(const char *format, ...);
103 int vpp_main(FILE *f, const char *name);
104 void warn_about_translation_off(void);
105
106 void store_define(char *def_text);
107 void remove_define(char *def_text);
108 void handle_ifdef(char *def_text);
109 void handle_ifndef(char *def_text);
110 void handle_else(void);
111 void handle_elsif(char *def_text);
112 void handle_endif(void);
113 void handle_include(char *def_text);
114 int pop_include(void);
115
116 int is_builtin_define(const char *str, unsigned int len); /* from gperf */
117 unsigned int atoi_with_underscores(char *s); /* gives saturation warnings for >= (1<<32) */
118
119 int compar_cstarstar_bsearch(const void *v1, const void *v2);
120 int dirscan(char *path, struct vpp_filename *fn); /* do dir read on given directory */
121
122 void addtoken(int is_newline);
123 int verilog_keyword_code(const char *s, unsigned int len);
124 void parsecomment(void);
125
126 #endif
127
+0
-24
contrib/vermin/vpp_keyword.gperf less more
0 celldefine
1 default_nettype
2 define
3 delay_mode_distributed
4 delay_mode_path
5 delay_mode_unit
6 disable_portfaults
7 else
8 enable_portfaults
9 endcelldefine
10 endif
11 endprotect
12 ifdef
13 ifndef
14 include
15 nosuppress_faults
16 nounconnected_drive
17 protect
18 resetall
19 suppress_faults
20 timescale
21 unconnected_drive
22 undef
23 uselib
Binary diff not shown
33 dist_man_MANS= evcd2vcd.1 fst2vcd.1 ghwdump.1 gtkwave.1 gtkwaverc.5 lxt2miner.1 \
44 lxt2vcd.1 rtlbrowse.1 shmidcat.1 \
55 twinwave.1 vcd2fst.1 vcd2lxt.1 vcd2lxt2.1 \
6 vcd2vzt.1 vermin.1 vzt2vcd.1 vztminer.1 fstminer.1 \
6 vcd2vzt.1 vzt2vcd.1 vztminer.1 fstminer.1 \
77 xml2stems.1
88
301301 dist_man_MANS = evcd2vcd.1 fst2vcd.1 ghwdump.1 gtkwave.1 gtkwaverc.5 lxt2miner.1 \
302302 lxt2vcd.1 rtlbrowse.1 shmidcat.1 \
303303 twinwave.1 vcd2fst.1 vcd2lxt.1 vcd2lxt2.1 \
304 vcd2vzt.1 vermin.1 vzt2vcd.1 vztminer.1 fstminer.1 \
304 vcd2vzt.1 vzt2vcd.1 vztminer.1 fstminer.1 \
305305 xml2stems.1
306306
307307 all: all-am
0 .TH "GTKWAVE" "1" "3.3.74" "Anthony Bybell" "Simulation Wave Viewer"
0 .TH "GTKWAVE" "1" "3.3.98" "Anthony Bybell" "Simulation Wave Viewer"
11 .SH "NAME"
22 .LP
33 gtkwave \- Visualization tool for VCD, LXT, LXT2, VZT, FST, and GHW files
6363 .TP
6464 \fB\-t\fR,\fB\-\-stems\fR <\fIfilename\fP>
6565 Specify stems file for source code annotation. This will automatically launch the \fIrtlbrowse\fP(1) helper process.
66 See \fIvermin\fP(1) for information on stems file generation.
66 See \fIxml2stems\fP(1) for information on stems file generation.
6767 .TP
6868 \fB\-c\fR,\fB\-\-cpu\fR <\fInumcpus\fP>
6969 Specify number of CPUs available for parallelizable ops (e.g., block prefetching on VZT reads).
192192 Anthony Bybell <bybell@rocketmail.com>
193193 .SH "SEE ALSO"
194194 .LP
195 \fIgtkwaverc\fP(5) \fIlxt2vcd\fP(1) \fIvcd2lxt\fP(1) \fIvcd2lxt2\fP(1) \fIvzt2vcd\fP(1) \fIvcd2vzt\fP(1) \fIvermin\fP(1) \fIrtlbrowse\fP(1) \fItwinwave\fP(1) \fIshmidcat\fP(1)
195 \fIgtkwaverc\fP(5) \fIlxt2vcd\fP(1) \fIvcd2lxt\fP(1) \fIvcd2lxt2\fP(1) \fIvzt2vcd\fP(1) \fIvcd2vzt\fP(1) \fIxml2stems\fP(1) \fIrtlbrowse\fP(1) \fItwinwave\fP(1) \fIshmidcat\fP(1)
1919 To run this program the standard way type:
2020 .TP
2121 rtlbrowse stemsfile
22 The RTL is then brought up in a GTK tree viewer. Stems must have been previously generated with \fIvermin\fP(1) or some other tool capable of generating compatible stemsfiles.
22 The RTL is then brought up in a GTK tree viewer. Stems must have been previously generated with \fIxml2stems\fP(1) or some other tool capable of generating compatible stemsfiles.
2323 Note that \fIgtkwave\fP(1) will bring up this program as a client application for source code annotation. It does that
2424 by bringing up the viewer with the shared memory ID of a segment of memory in the viewer rather than using a stems filename.
2525 .SH "AUTHORS"
2727 Anthony Bybell <bybell@rocketmail.com>
2828 .SH "SEE ALSO"
2929 .LP
30 \fIvermin\fP(1) \fIgtkwave\fP(1)
30 \fIxml2stems\fP(1) \fIgtkwave\fP(1)
+0
-63
man/vermin.1 less more
0 .TH "VERMIN" "1" "0.1.1" "Anthony Bybell" "Verilog Compilation"
1 .SH "NAME"
2 .LP
3 vermin \- Parses and processes Verilog HDL files
4 .SH "SYNTAX"
5 .LP
6 vermin [\fIVERILOGFILE\fP]... [\fIoption\fP]...
7 .SH "DESCRIPTION"
8 .LP
9 Parses Verilog HDL files for use by other tools. The Verilog grammar used is 1364-1995.
10 .SH "OPTIONS"
11 .LP
12 .TP
13 \fB\-h[elp]\fR
14 Prints out help screen.
15 .TP
16 \fB\-emitmono \fIfname\fP\fR
17 Emit monolithic (parser view of) file to \fIfname\fP.
18 .TP
19 \fB\-emitstems\fR
20 Emit source code stems to stdout.
21 .TP
22 \fB\-emitvars\fR
23 Emit source code variables to stdout.
24 .TP
25 \fB\-D\fIx\fP=\fIy\fP
26 Equivalent to `define \fIX Y\fP in source.
27 .TP
28 \fB\+define+\fIx\fP=\fIy\fP\fR
29 Equivalent to `define \fIX Y\fP in source.
30 .TP
31 \fB\+incdir+\fIdirname\fP\fR
32 Add \fIdirname\fP to include search path.
33 .TP
34 \fB\+libext+\fIext\fP\fR
35 Add \fIext\fP to filename when searching for files.
36 .TP
37 \fB\-pragma \fIname\fP\fR
38 Add \fIname\fP (synopsys, verilint, vertex) to accepted pragmas. Note that "vertex" is for legacy reasons; the
39 executable name has since changed to avoid name clashes with an existing 3D modeling program.
40 .TP
41 \fB\-y \fIdirname\fP\fR
42 Add directory \fIdirname\fP to source input path.
43 .TP
44 \fB\-yi \fIdirname\fP\fR
45 Add directory \fIdirname\fP to source input path (case insensitive search).
46 .TP
47 \fB\-f \fIfilename\fP\fR
48 Insert args from filename. Does not work recursively.
49 .SH "EXAMPLES"
50 .LP
51 The following indicates that the library extension is .v and that the include directory is the current working
52 directory and that the library directory is also the current working directory. Stems generation is
53 enabled to generate a stems file for use with other tools. Various compile-time defines are also defined
54 on the command line.
55 .TP
56 vermin XYZ450AC6V1.v \-emitstems \-y . \+incdir+. \+libext+.v \-DUTLB_OutputData=0 \-D__PORTALS_VERILOG__
57 .SH "AUTHORS"
58 .LP
59 Anthony Bybell <bybell@rocketmail.com>
60 .SH "SEE ALSO"
61 .LP
62 \fIrtlbrowse\fP(1) \fIgtkwave\fP(1)
77 .SH "DESCRIPTION"
88 .LP
99 Converts Verilator XML AST representation to stems file for use with rtlbrowse.
10 Intended to replace vermin, and in the future, advanced tool features may possibly use additional data provided by the Verilator AST.
10 Intended to replace the obsolete vermin, and in the future, advanced tool features may possibly use additional data provided by the Verilator AST.
1111 Using "-" as an input filename reads from stdin. Omitting the output filename outputs to stdout.
1212 .SH "OPTIONS"
1313 .LP
3232 Anthony Bybell <bybell@rocketmail.com>
3333 .SH "SEE ALSO"
3434 .LP
35 \fIrtlbrowse\fP(1) \fIgtkwave\fP(1) \fIvermin\fP(1)
35 \fIrtlbrowse\fP(1) \fIgtkwave\fP(1)
5858 twinwave_LDADD= $(GTK_LIBS) $(GTK_MAC_LIBS) $(GCONF_LIBS)
5959
6060 vcd_keywords.c: vcd_keywords.gperf
61 printf "$(GPERF) -o -i 1 -C -k 1,\044 -L C -H keyword_hash -N check_identifier -tT $(srcdir)/vcd_keywords.gperf >vcd_keywords.c" | sh
61 printf "$(GPERF) -o -i 1 -C -k 1,\044 -L C -H keyword_hash -N check_identifier -tT --initializer-suffix=,0 $(srcdir)/vcd_keywords.gperf >vcd_keywords.c" | sh
6262
6363 gsettings_SCHEMAS = com.geda.gtkwave.gschema.xml
6464 @GSETTINGS_RULES@
990990 ./cocoa/libgtkwmacintegration.a: $(srcdir)/cocoa/cocoa_misc.c $(srcdir)/cocoa/cocoa_misc.h
991991
992992 vcd_keywords.c: vcd_keywords.gperf
993 printf "$(GPERF) -o -i 1 -C -k 1,\044 -L C -H keyword_hash -N check_identifier -tT $(srcdir)/vcd_keywords.gperf >vcd_keywords.c" | sh
993 printf "$(GPERF) -o -i 1 -C -k 1,\044 -L C -H keyword_hash -N check_identifier -tT --initializer-suffix=,0 $(srcdir)/vcd_keywords.gperf >vcd_keywords.c" | sh
994994 @GSETTINGS_RULES@
995995
996996 # Tell versions [3.59,3.63) of GNU make to not export all variables.
943943 pch = ch = cvt_table[(unsigned char)vec[0]];
944944 for (i = 1; i < nbits; i++)
945945 {
946 ch = cvt_table[vec[i]];
946 ch = cvt_table[(unsigned char)vec[i]];
947947 if(ch != pch) goto miscompare;
948948 }
949949
743743 switch(scale)
744744 {
745745 case 2: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 's'; break;
746 case 1: GLOBALS->time_scale = LLDescriptor(10);
746 case 1: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
747747 case 0: GLOBALS->time_dimension = 's'; break;
748748
749749 case -1: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'm'; break;
750 case -2: GLOBALS->time_scale = LLDescriptor(10);
750 case -2: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
751751 case -3: GLOBALS->time_dimension = 'm'; break;
752752
753753 case -4: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'u'; break;
754 case -5: GLOBALS->time_scale = LLDescriptor(10);
754 case -5: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
755755 case -6: GLOBALS->time_dimension = 'u'; break;
756756
757757 case -10: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'p'; break;
758 case -11: GLOBALS->time_scale = LLDescriptor(10);
758 case -11: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
759759 case -12: GLOBALS->time_dimension = 'p'; break;
760760
761761 case -13: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'f'; break;
762 case -14: GLOBALS->time_scale = LLDescriptor(10);
762 case -14: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
763763 case -15: GLOBALS->time_dimension = 'f'; break;
764764
765765 case -16: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'a'; break;
766 case -17: GLOBALS->time_scale = LLDescriptor(10);
766 case -17: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
767767 case -18: GLOBALS->time_dimension = 'a'; break;
768768
769769 case -19: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'z'; break;
770 case -20: GLOBALS->time_scale = LLDescriptor(10);
770 case -20: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
771771 case -21: GLOBALS->time_dimension = 'z'; break;
772772
773773 case -7: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'n'; break;
774 case -8: GLOBALS->time_scale = LLDescriptor(10);
774 case -8: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
775775 case -9:
776776 default: GLOBALS->time_dimension = 'n'; break;
777777 }
465465 /* currently fe->name is unused */
466466 if(fe)
467467 {
468 int ie;
468 uint32_t ie;
469469 #ifdef _WAVE_HAVE_JUDY
470470 Pvoid_t e = (Pvoid_t) NULL;
471471 for(ie=0; ie<fe->elem_count; ie++)
499499
500500 GLOBALS->xl_enum_filter[GLOBALS->num_xl_enum_filter-1] = e;
501501
502 if(GLOBALS->num_xl_enum_filter != h->u.attr.arg)
502 if((unsigned int)GLOBALS->num_xl_enum_filter != h->u.attr.arg)
503503 {
504504 fprintf(stderr, FST_RDLOAD"Internal error, nonsequential enum tables definition encountered, exiting.\n");
505505 exit(255);
753753 }
754754 else
755755 {
756 int abslen = (msb >= lsb) ? (msb - lsb + 1) : (lsb - msb + 1);
756 unsigned int abslen = (msb >= lsb) ? (msb - lsb + 1) : (lsb - msb + 1);
757757
758758 if((h->u.var.length > abslen) && !(h->u.var.length % abslen)) /* check if 2d array */
759759 {
4040 gchar *key,
4141 gpointer user_data)
4242 {
43 (void)user_data;
44
4345 char *str = NULL;
4446 char *str2 = NULL;
4547 int this_wave_rpc_id = -1;
196198
197199 void wave_gconf_init(int argc, char **argv)
198200 {
201 (void)argc;
202 (void)argv;
203
199204 if(!gs)
200205 {
201206 gs = g_settings_new (WAVE_GSETTINGS_SCHEMA_ID);
442442 struct ghw_type_array *base = arr->sa.base;
443443 char *name = NULL;
444444
445 if (dim == base->nbr_dim)
445 if ((unsigned int)dim == base->nbr_dim)
446446 {
447447 struct tree *t;
448448 sprintf (GLOBALS->asbuf, "%s]", pfx);
774774 static void
775775 create_facs (struct ghw_handler *h)
776776 {
777 int i;
777 unsigned int i;
778778 struct symchain *sc = GLOBALS->firstnode;
779779
780780 GLOBALS->numfacs = GLOBALS->nbr_sig_ref_ghw_c_1;
11181118 static void
11191119 add_tail (struct ghw_handler *h)
11201120 {
1121 int i;
1121 unsigned int i;
11221122 TimeType j;
11231123
11241124 for (j = 1; j>=0 ; j--) /* add two endcaps */
11471147 read_traces (struct ghw_handler *h)
11481148 {
11491149 int *list;
1150 int i;
1150 unsigned int i;
11511151 enum ghw_res res;
11521152
11531153 list = malloc_2((GLOBALS->numfacs + 1) * sizeof (int));
12101210 {
12111211 struct ghw_handler handle;
12121212 int i;
1213 unsigned int ui;
12131214 int rc;
12141215
12151216 if(!GLOBALS->hier_was_explicitly_set) /* set default hierarchy split char */
12421243 GLOBALS->nbr_sig_ref_ghw_c_1 = 0;
12431244
12441245 GLOBALS->nxp_ghw_c_1 =(struct Node **)calloc_2(handle.nbr_sigs, sizeof(struct Node *));
1245 for(i=0;i<handle.nbr_sigs;i++)
1246 {
1247 GLOBALS->nxp_ghw_c_1[i] = (struct Node *)calloc_2(1,sizeof(struct Node));
1246 for(ui=0;ui<handle.nbr_sigs;ui++)
1247 {
1248 GLOBALS->nxp_ghw_c_1[ui] = (struct Node *)calloc_2(1,sizeof(struct Node));
12481249 }
12491250
12501251 GLOBALS->treeroot = build_hierarchy (&handle, handle.hie);
199199 if ((v & 0x80) == 0)
200200 {
201201 if ((v & 0x40) && off < 32)
202 r |= -1 << off;
202 r |= ~0U << off;
203203 break;
204204 }
205205 }
186186 {
187187 break;
188188 }
189 /* deliberate fallthrough */
189 /* fallthrough */
190190 default:
191191 fprintf(stderr, "'%s' is an unsupported data type, exiting.\n", st);
192192 exit(255);
154154 }
155155 if (0)
156156 {
157 int ix;
157 unsigned ix;
158158 printf ("String table:\n");
159159
160160 for (ix = 1; ix < hp->nbr_str; ix++)
107107 }
108108
109109
110 static lxtint64_t vcd_prevtime;
110 static lxtint64_t vcd_prevtime = LXT2_RD_ULLDESC(~0);
111111 char vcd_blackout = 0;
112112 static int backtrack_warning = 0;
113113
119119
120120 if(vcd_prevtime != *pnt_time)
121121 {
122 if((vcd_prevtime > *pnt_time) && (!backtrack_warning) && (vcd_prevtime != -1))
122 if((vcd_prevtime > *pnt_time) && (!backtrack_warning) && (vcd_prevtime != LXT2_RD_ULLDESC(~0)))
123123 {
124124 backtrack_warning = 1;
125125 fprintf(stderr, "LXTLOAD | Time backtracking encountered: this VCD might load incorrectly in gtkwave.\n");
197197 case 0: time_dimension = 's'; break;
198198
199199 case -1: time_scale = 100; time_dimension = 'm'; break;
200 case -2: time_scale = 10;
200 case -2: time_scale = 10; /* fallthrough */
201201 case -3: time_dimension = 'm'; break;
202202
203203 case -4: time_scale = 100; time_dimension = 'u'; break;
204 case -5: time_scale = 10;
204 case -5: time_scale = 10; /* fallthrough */
205205 case -6: time_dimension = 'u'; break;
206206
207207 case -10: time_scale = 100; time_dimension = 'p'; break;
208 case -11: time_scale = 10;
208 case -11: time_scale = 10; /* fallthrough */
209209 case -12: time_dimension = 'p'; break;
210210
211211 case -13: time_scale = 100; time_dimension = 'f'; break;
212 case -14: time_scale = 10;
212 case -14: time_scale = 10; /* fallthrough */
213213 case -15: time_dimension = 'f'; break;
214214
215215 case -7: time_scale = 100; time_dimension = 'n'; break;
216 case -8: time_scale = 10;
216 case -8: time_scale = 10; /* fallthrough */
217217 case -9:
218218 default: time_dimension = 'n'; break;
219219 }
192192 case 0: time_dimension = 's'; break;
193193
194194 case -1: time_scale = 100; time_dimension = 'm'; break;
195 case -2: time_scale = 10;
195 case -2: time_scale = 10; /* fallthrough */
196196 case -3: time_dimension = 'm'; break;
197197
198198 case -4: time_scale = 100; time_dimension = 'u'; break;
199 case -5: time_scale = 10;
199 case -5: time_scale = 10; /* fallthrough */
200200 case -6: time_dimension = 'u'; break;
201201
202202 case -10: time_scale = 100; time_dimension = 'p'; break;
203 case -11: time_scale = 10;
203 case -11: time_scale = 10; /* fallthrough */
204204 case -12: time_dimension = 'p'; break;
205205
206206 case -13: time_scale = 100; time_dimension = 'f'; break;
207 case -14: time_scale = 10;
207 case -14: time_scale = 10; /* fallthrough */
208208 case -15: time_dimension = 'f'; break;
209209
210210 case -7: time_scale = 100; time_dimension = 'n'; break;
211 case -8: time_scale = 10;
211 case -8: time_scale = 10; /* fallthrough */
212212 case -9:
213213 default: time_dimension = 'n'; break;
214214 }
16521652
16531653 lt->bumptime = 1;
16541654
1655 msk = (~0 << lt->timepos);
1655 msk = (~0U << lt->timepos);
16561656 msk_n = ~msk;
16571657
16581658 for(i=0;i<s->len;i++)
17241724
17251725 lt->bumptime = 1;
17261726
1727 msk = (~0 << lt->timepos);
1727 msk = (~0U << lt->timepos);
17281728 msk_n = ~msk;
17291729
17301730 for(i=0;i<s->len;i++)
17941794 value = vfix;
17951795 }
17961796
1797 msk = (~0 << lt->timepos);
1797 msk = (~0U << lt->timepos);
17981798 msk_n = ~msk;
17991799
18001800 if(!lt->multi_state)
18551855
18561856 if(lt)
18571857 {
1858 msk = (~0 << lt->timepos);
1858 msk = (~0U << lt->timepos);
18591859 msk_n = ~msk;
18601860
18611861 for(j=0;j<lt->numfacs;j++)
52315231 " will open a file requester that will ask for the name"
52325232 " of a Verilog stemsfile. This will then launch an RTL browser and allow source code annotation based on"
52335233 " the primary marker position."
5234 " Stems files are generated by Vermin. Please see its manpage"
5234 " Stems files are generated by xml2stems. Please see its manpage"
52355235 " for syntax and more information on stems file generation."
52365236 );
52375237 return;
293293
294294 EXTERN int NpLoadLibrary(HMODULE *tclHandle, char *dllName, int dllNameSize,
295295 char *me) {
296 char *envdll, libname[MAX_PATH];
296 char *envdll, libname[MAX_PATH + 128];
297297 HMODULE handle = (HMODULE) NULL;
298298 char path[MAX_PATH], *p ;
299299
13941394 NULL);
13951395 gtk_tree_view_append_column (GTK_TREE_VIEW (sig_view), column);
13961396 }
1397
1397 /* fallthrough */
13981398 case AE2_FILE:
13991399 case VCD_FILE:
14001400 case VCD_RECODER_FILE:
16491649 NULL);
16501650 gtk_tree_view_append_column (GTK_TREE_VIEW (sig_view), column);
16511651 }
1652 /* fallthrough */
16521653
16531654 case AE2_FILE:
16541655 case VCD_FILE:
00 /* C code produced by gperf version 3.0.4 */
1 /* Command-line: /usr/bin/gperf -o -i 1 -C -k '1,$' -L C -H keyword_hash -N check_identifier -tT ./vcd_keywords.gperf */
1 /* Command-line: /usr/bin/gperf -o -i 1 -C -k '1,$' -L C -H keyword_hash -N check_identifier -tT --initializer-suffix=,0 ./vcd_keywords.gperf */
22
33 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
44 && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
106106 {
107107 static const struct vcd_keyword wordlist[] =
108108 {
109 {""}, {""}, {""}, {""}, {""},
109 {"",0}, {"",0}, {"",0}, {"",0}, {"",0},
110110 #line 23 "./vcd_keywords.gperf"
111111 {"reg", V_REG},
112112 #line 26 "./vcd_keywords.gperf"
113113 {"time", V_TIME},
114 {""},
114 {"",0},
115115 #line 30 "./vcd_keywords.gperf"
116116 {"trireg", V_TRIREG},
117117 #line 37 "./vcd_keywords.gperf"
132132 {"parameter", V_PARAMETER},
133133 #line 39 "./vcd_keywords.gperf"
134134 {"inout", V_INOUT},
135 {""},
135 {"",0},
136136 #line 19 "./vcd_keywords.gperf"
137137 {"integer", V_INTEGER},
138138 #line 44 "./vcd_keywords.gperf"
139139 {"shortint", V_SHORTINT},
140140 #line 21 "./vcd_keywords.gperf"
141141 {"real_parameter", V_REAL_PARAMETER},
142 {""}, {""}, {""},
142 {"",0}, {"",0}, {"",0},
143143 #line 38 "./vcd_keywords.gperf"
144144 {"out", V_OUT},
145145 #line 34 "./vcd_keywords.gperf"
146146 {"wire", V_WIRE},
147 {""}, {""}, {""},
147 {"",0}, {"",0}, {"",0},
148148 #line 35 "./vcd_keywords.gperf"
149149 {"wor", V_WOR},
150150 #line 46 "./vcd_keywords.gperf"
153153 {"logic", V_LOGIC},
154154 #line 28 "./vcd_keywords.gperf"
155155 {"triand", V_TRIAND},
156 {""},
156 {"",0},
157157 #line 41 "./vcd_keywords.gperf"
158158 {"bit", V_BIT},
159159 #line 20 "./vcd_keywords.gperf"
160160 {"real", V_REAL},
161 {""}, {""}, {""},
161 {"",0}, {"",0}, {"",0},
162162 #line 27 "./vcd_keywords.gperf"
163163 {"tri", V_TRI},
164164 #line 47 "./vcd_keywords.gperf"
165165 {"enum", V_ENUM},
166 {""}, {""}, {""}, {""},
166 {"",0}, {"",0}, {"",0}, {"",0},
167167 #line 48 "./vcd_keywords.gperf"
168168 {"shortreal", V_SHORTREAL},
169169 #line 17 "./vcd_keywords.gperf"
170170 {"event", V_EVENT},
171 {""}, {""}, {""},
171 {"",0}, {"",0}, {"",0},
172172 #line 33 "./vcd_keywords.gperf"
173173 {"wand", V_WAND},
174 {""}, {""}, {""}, {""},
174 {"",0}, {"",0}, {"",0}, {"",0},
175175 #line 32 "./vcd_keywords.gperf"
176176 {"tri1", V_TRI1},
177 {""}, {""}, {""}, {""},
177 {"",0}, {"",0}, {"",0}, {"",0},
178178 #line 31 "./vcd_keywords.gperf"
179179 {"tri0", V_TRI0},
180 {""}, {""},
180 {"",0}, {"",0},
181181 #line 25 "./vcd_keywords.gperf"
182182 {"supply1", V_SUPPLY1},
183 {""},
183 {"",0},
184184 #line 49 "./vcd_keywords.gperf"
185185 {"$end", V_END},
186 {""}, {""},
186 {"",0}, {"",0},
187187 #line 24 "./vcd_keywords.gperf"
188188 {"supply0", V_SUPPLY0}
189189 };
00 /*
1 * Copyright (c) Tony Bybell 2010-2018.
1 * Copyright (c) Tony Bybell 2010-2019.
22 *
33 * This program is free software; you can redistribute it and/or
44 * modify it under the terms of the GNU General Public License
99 #ifndef WAVE_VERSION_H
1010 #define WAVE_VERSION_H
1111
12 #define WAVE_VERSION_INFO "GTKWave Analyzer v" PACKAGE_VERSION " (w)1999-2018 BSI"
12 #define WAVE_VERSION_INFO "GTKWave Analyzer v" PACKAGE_VERSION " (w)1999-2019 BSI"
1313
1414 #endif
400400 if(compressable && GLOBALS->vlist_handle)
401401 {
402402 size_t rc;
403 uintptr_t write_cnt;
403 intptr_t write_cnt;
404404
405405 fseeko(GLOBALS->vlist_handle, GLOBALS->vlist_bytes_written, SEEK_SET);
406406
540540 if(GLOBALS->vlist_handle)
541541 {
542542 size_t rc;
543 uintptr_t write_cnt;
543 intptr_t write_cnt;
544544
545545 vl = *v;
546546 fseeko(GLOBALS->vlist_handle, GLOBALS->vlist_bytes_written, SEEK_SET);
20652065 ptr = buf;
20662066 if (IsClosed(t)) {
20672067 pch = strstr (ptr,"[-]");
2068 if(pch) {strncpy (pch,"[+]", 3); }
2068 if(pch) {memcpy (pch,"[+]", 3); }
20692069 } else {
20702070 pch = strstr (ptr,"[+]");
2071 if(pch) {strncpy (pch,"[-]", 3); }
2071 if(pch) {memcpy (pch,"[-]", 3); }
20722072 }
20732073 }
20742074 }