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