xref: /original-bsd/usr.bin/yacc/yyfix.sh (revision 6fdbdce2)
1#!/bin/sh -
2#
3# Copyright (c) 1990 The Regents of the University of California.
4# All rights reserved.
5#
6# %sccs.include.redist.sh%
7#
8#	@(#)yyfix.sh	5.2 (Berkeley) 05/12/90
9#
10OLDYACC="yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef"
11NEWYACC="yylhs yylen yydefred yydgoto yysindex yyrindex yygindex \
12	 yytable yycheck"
13
14file=$1
15>$file
16shift
17
18if [ $# -eq 0 ] ; then
19	if grep yylhs y.tab.c > /dev/null ; then
20		if grep yyname y.tab.c > /dev/null ; then
21			NEWYACC="$NEWYACC yyname"
22		fi
23		if grep yyrule y.tab.c > /dev/null ; then
24			NEWYACC="$NEWYACC yyrule"
25		fi
26		set $NEWYACC
27	else
28		set $OLDYACC
29	fi
30fi
31
32for i
33do
34ed - y.tab.c << END
35/^\(.*\)$i[ 	]*\[]/s//extern \1 $i[];\\
36\1 $i []/
37.ka
38/}/kb
39'br $file
40'a,.w $file
41'a,.d
42w
43q
44END
45done
46