This file is indexed.

/usr/bin/pretzel-it is in pretzel 2.0n-2-0.3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
#!/bin/sh
# $Id: pretzel-it,v 2.2 1998/12/03 10:58:39 felix Exp $
#----------------------------------------------------------------------

#
# pretzel-it  ---  transform input files into a pretzel prettyprinter
#
# (history at end)


# SYNOPSIS
#
#	pretzel-it [-iqvdnh] language ppname
#
#
# pretzel-it tries to produce a prettyprinter from the input files
# `language.ft' and `language.fg'. The prettyprinter is encapsulated in
# a minimal main program called `ppname'. It's usgage then is:
#
#     ppname <code >tex-code
#
# pretzel-it will leave the C code of the prettyprinter in the current
# directory. If the -i option is given, all intermediate files, such
# as the flex and Bison files, as well as the object code of the C
# files are left there too.
#
# Filenames of the C code are: language.lex.c, language.tab.c and
# ptokdefs.h for the token header.
#
# pretzel-it expects to find the `pretzel' program in your PATH. Also
# it looks for the pretzel library and include files in the directories
# specified by the environment variables PRETZEL_LIBDIR and PRETZEL_INCLUDE.
#
#
# OPTIONS
#
#       -i     don't remove intermediate products (flex/Bison source
#              and prettyprinter object code)
#       -q     run quietly
#       -v     verbose, print commands before invoking (for debugging)
#	-d     turn prettyprinter debugging features on by default,
#              produce an .output file for detailed diagnosis of parser
#              (for debugging the prettyprinting grammar)
#       -h     print help message
#
#       -n     noweb option: instead of producing a standalone
#              prettyprinter `ppname' it will produce a noweb
#              prettyprinting filter `ppname' that can be used as
#              additional filter with noweb's -filter option
#              (and LaTeX as typesetter). Without the -i option
#              it will remove _all_ intermediates and leave only the
#              filter in the current directory.
#
#
# CAVEATS:
#
#    pretzel-it is very simple and will only produce default
#    prettyprinters. Use the specialized Makefile if you want to do
#    special things like using several prettyprinters within one
#    program.
#
#    The noweb option is new and very experimental.
#
#
# IMPLEMENTATION NOTES
#
#    After checking the arguments, the commands that are used to
#    invoke flex, Bison and the compiler are pieced together and then
#    executed.
#
#    The noweb option builds a normal prettyprinter but links it with
#    a different main function and removes all intermediates.
#

cmd=`basename $0`
usage()
{
	echo "usage: $cmd [-inqvdh] language ppname"	>&2
	echo "use -h option for full usage"		>&2
	exit 1
}

full_usage()
{
	echo "usage: $cmd [-inqvdh] language ppname"		>&2
	echo "options: "					>&2
	echo " -i  don't remove intermediate products"		>&2
	echo " -q  run quietly"					>&2
	echo " -v  verbose, print commands before invoking"	>&2
	echo " -d  turn prettyprinter debugging features on"	>&2
	echo " -h  print this help message"			>&2
	echo " -n  (experimental) noweb option"			>&2
	exit 0
}

envnote()
{
	echo "you need to set the environment variables" >&2
	echo "PRETZEL_LIBDIR and PRETZEL_INCLUDE to the" >&2
	echo "pretzel library and include directories." >&2
	exit 1
}


# normalize and check arguments:

cleanup_intermediates=true
run_noisy=true
verbose_mode=''
build_debug_pp=''
noweb_mode=''

while getopts 'iqvdnh' option
  do   case "$option" in
         i)  cleanup_intermediates=''
             ;;
         q)  run_noisy=''
             ;;
         v)  verbose_mode=true
             ;;
	 d)  build_debug_pp=true
	     ;;
         n)  noweb_mode=true
             ;;
         h)  full_usage
             ;;
         # add more options here
         *)  usage
             ;;
       esac
  done

# number of remaining arguments has to be 2:
shift `expr $OPTIND - 1`
test $# -eq 2 || usage

# check if environment variables have been set

test  $PRETZEL_LIBDIR || export PRETZEL_LIBDIR=/usr/lib/pretzel # envnote
test  $PRETZEL_INCLUDE || export PRETZEL_INCLUDE=/usr/include/pretzel # envnote

# -----------------------------------------------------------------
# Build commands that are invoked by the script:

pretzel_command="pretzel -q $1"

bison_command="bison -d $1.y -o $1.tab.c"

# -v flag produces the .output file for detailed diagnosis

debug_bison_command="bison -v -d $1.y -o $1.tab.c"

after_bison="mv $1.tab.h ptokdefs.h"

flex_command="flex -t $1.l > $1.lex.c"

# don't need link commands on command line

compile_flex="g++ -c -I$PRETZEL_INCLUDE -g $1.lex.c"

compile_bison="g++ -c -I$PRETZEL_INCLUDE -g $1.tab.c"


# note that the order of the arguments is important for portability

link_command="g++ $1.lex.o $1.tab.o $PRETZEL_LIBDIR/plainpp.o \
  -I$PRETZEL_INCLUDE -L$PRETZEL_LIBDIR -lpretzel -g -o $2"

# this is used if you're building a prettyprinter for debugging
debug_link_command="g++ $1.lex.o $1.tab.o $PRETZEL_LIBDIR/plaindpp.o \
  -I$PRETZEL_INCLUDE -L$PRETZEL_LIBDIR -lpretzel -g -o $2"

#

cleanup_command="rm -f $1.l $1.y $1.lex.o $1.tab.o"


# special noweb command (invoked instead of the normal link commands):

noweb_link_command="g++ $1.lex.o $1.tab.o $PRETZEL_LIBDIR/nowebpretzelpp.o \
  -I$PRETZEL_INCLUDE -L$PRETZEL_LIBDIR -lpretzel -g -o $2"

# currently the same as noweb_link_command:
noweb_debug_link_command="g++ $1.lex.o $1.tab.o $PRETZEL_LIBDIR/nowebpretzelpp.o \
  -I$PRETZEL_INCLUDE -L$PRETZEL_LIBDIR -lpretzel -g -o $2"

noweb_cleanup_command="rm -f $1.l $1.y $1.lex.o $1.tab.o $1.lex.c	\
	$1.tab.c ptokdefs.h"


# ------------------------------------------------------------------
# now go to work: let's run the different programs on the files one
# at a time and be sure to bail out when one of them returns with an
# error.

# now go to work: run pretzel on the input files.

if [ "$run_noisy" ]
   then echo "starting to pretzel..."
fi

if [ "$verbose_mode" ]
   then echo $pretzel_command
fi
eval $pretzel_command || exit 1

# now run flex and Bison on them and try to compile...

if [ "$run_noisy" ]
   then echo "preprocessing..."
fi
if [ "$verbose_mode" ]
   then echo $bison_command
fi
if [ "$build_debug_pp" ]
   then eval $debug_bison_command || exit 1
else
   eval $bison_command  || exit 1
fi
eval $after_bison

if [ "$verbose_mode" ]
   then echo $flex_command
fi
eval $flex_command || exit 1

if [ "$run_noisy" ]
   then echo "processing .ft file..."
fi
if [ "$verbose_mode" ]
   then echo $compile_flex
fi
eval $compile_flex || exit 1

if [ "$run_noisy" ]
   then echo "processing .fg file..."
fi
if [ "$verbose_mode" ]
   then echo $compile_bison
fi
eval $compile_bison || exit 1


if [ "$build_debug_pp" ]
then
  if [ "$noweb_mode" ]
  then

    # case 1: debug and noweb

    if [ "$run_noisy" ]
       then echo "building noweb filter $2 (turning debug features on)..."
    fi
    if [ "$verbose_mode" ]
       then echo $noweb_debug_link_command
    fi
    eval $noweb_debug_link_command || exit 1

  else

    # case 2: debug and not noweb

    if [ "$run_noisy" ]
       then echo "building prettyprinter $2 (turning debug features on)..."
    fi
    if [ "$verbose_mode" ]
       then echo $debug_link_command
    fi
    eval $debug_link_command || exit 1
  fi
else
  if [ "$noweb_mode" ]
  then

    # case 3: normal noweb

    if [ "$run_noisy" ]
       then echo "building noweb filter $2..."
    fi
    if [ "$verbose_mode" ]
       then echo $noweb_link_command
    fi
    eval $noweb_link_command || exit 1
  else

    # case 4: normal

    if [ "$run_noisy" ]
       then echo "building prettyprinter $2..."
    fi
    if [ "$verbose_mode" ]
       then echo $link_command
    fi
    eval $link_command || exit 1
  fi
fi

#
if [ "$cleanup_intermediates" ]
then
  if [ "$noweb_mode" ]
  then
    if [ "$run_noisy" ]
       then echo "cleaning up and leaving only noweb filter..."
    fi
    if [ "$verbose_mode" ]
       then echo $noweb_cleanup_command
    fi
    eval $noweb_cleanup_command
  else               # cleanup but not in noweb mode
    if [ "$run_noisy" ]
       then echo "cleaning up..."
    fi
    if [ "$verbose_mode" ]
       then echo $cleanup_command
    fi
    eval $cleanup_command
  fi
fi


if [ "$run_noisy" ]
   then echo "done."
fi


#======================================================================
#
# $Log: pretzel-it,v $
# Revision 2.2  1998/12/03 10:58:39  felix
# can use standard search paths for PRETZEL_XXX if variables are
# not set (thanks to I think Dave Wilson).
#
# Revision 2.1  1998/04/25 08:03:09  gaertner
# produces .output file from bison when -d option is given for
# detailed grammar diagnosis in the presence of conflicts.
#
# Revision 2.0  1996/12/16 17:35:52  gaertner
# release 2.0
#
# Revision 1.10  1996/11/14 18:13:23  gaertner
# noweb option should work now. Changes the text lines that are
# printed out to the screen because they show too many internals.
#
# Revision 1.9  1996/11/14  18:03:13  gaertner
# Added noweb option. Added -h option.
#
# Revision 1.8  1996/09/17  13:46:37  gaertner
# Changed CC to g++ in compiler lines. Also added the `cleanup' option.
#
# Revision 1.7  1996/03/22  10:10:11  gaertner
# added -d option for grammar debugging.
#
# Revision 1.6  1996/03/21  11:08:29  gaertner
# Corrected argument checking and enhanced documentation.
#
# Revision 1.5  1996/02/06  19:24:59  gaertner
# Added new options -i -q -v. Bails out when an error is encountered.
# Invoked commands are configured in one place to ease maintenance.
#
# Revision 1.4  1996/02/06  17:28:07  gaertner
# Version before re-writing the tool.
#
# Revision 1.3  1995/08/30  17:51:57  gaertner
# tex->lex in rm-line.
#
# Revision 1.2  1995/08/30  17:48:41  gaertner
# Moved link objects to the front of the compiler line. Some
# compilers need this.
#
# Revision 1.1  1995/08/30  17:45:49  gaertner
# Initial revision
#
#