[comp.sources.misc] v06i053: y.tab.c filter

allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (03/07/89)

Posting-number: Volume 6, Issue 53
Submitted-by: megatest!djones@decwrl.dec.com (Dave Jones)
Archive-name: yaccfix.awk

[You must be kidding.  Not only was it not "shar"ed, but it does just about
the opposite of what I want.  ++bsa]

I submit the following in the category of Shortest Arguably
Nontrivial Program. It's a two-liner, written in AWK.

--- snip --- snip --- snip --- snip --- snip --- snip --- snip
#! /bin/sh
# This file was wrapped with "dummyshar".  "sh" this file to extract.
# Contents:  yaccfix.awk
echo extracting 'yaccfix.awk'
if test -f 'yaccfix.awk' -a -z "$1"; then echo Not overwriting 'yaccfix.awk'; else
sed 's/^X//' << \EOF > 'yaccfix.awk'
X# The line-number info produced by yacc causes dbx to skip
X# around foolishly, showing random lines from the .y file
X# when the execution is actually in yyparse().
X#
X# Run this over your y.tab.c to fix it.
X#
X
X/^yyparse\(/ { print "# line "  NR+1  " \"y.tab.c\"" }
X             { print }
X
X
EOF
chars=`wc -c < 'yaccfix.awk'`
if test $chars !=      300; then echo 'yaccfix.awk' is $chars characters, should be      300 characters!; fi
fi
exit 0