yyfix.sh revision 1.3
1#!/bin/sh - 2# 3# $OpenBSD: yyfix.sh,v 1.3 2009/06/12 13:33:29 sobrado Exp $ 4# Copyright (c) 1990 The Regents of the University of California. 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 2. Redistributions in binary form must reproduce the above copyright 13# notice, this list of conditions and the following disclaimer in the 14# documentation and/or other materials provided with the distribution. 15# 3. Neither the name of the University nor the names of its contributors 16# may be used to endorse or promote products derived from this software 17# without specific prior written permission. 18# 19# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29# SUCH DAMAGE. 30# 31# from: @(#)yyfix.sh 5.2 (Berkeley) 5/12/90 32# 33OLDYACC="yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef" 34NEWYACC="yylhs yylen yydefred yydgoto yysindex yyrindex yygindex \ 35 yytable yycheck" 36 37if [ $# -eq 0 ]; then 38 echo "usage: `basename $0` file [tables]" >&2 39 exit 1 40fi 41 42file=$1 43>$file 44shift 45 46if [ $# -eq 0 ] ; then 47 if grep yylhs y.tab.c > /dev/null ; then 48 if grep yyname y.tab.c > /dev/null ; then 49 NEWYACC="$NEWYACC yyname" 50 fi 51 if grep yyrule y.tab.c > /dev/null ; then 52 NEWYACC="$NEWYACC yyrule" 53 fi 54 set $NEWYACC 55 else 56 set $OLDYACC 57 fi 58fi 59 60for i 61do 62ed - y.tab.c << END 63/^\(.*\)$i[ ]*\[]/s//extern \1 $i[];\\ 64\1 $i []/ 65.ka 66/}/kb 67'br $file 68'a,.w $file 69'a,.d 70w 71q 72END 73done 74