[BACK]Return to yyfix.sh CVS log [TXT][DIR] Up to [local] / src / usr.bin / yacc

Annotation of src/usr.bin/yacc/yyfix.sh, Revision 1.2

1.1       millert     1: #!/bin/sh -
                      2: #
1.2     ! millert     3: #      $OpenBSD: yyfix.sh,v 1.1 1999/04/18 20:41:46 millert Exp $
1.1       millert     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.
1.2     ! millert    15: # 3. Neither the name of the University nor the names of its contributors
1.1       millert    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: #
                     33: OLDYACC="yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef"
                     34: NEWYACC="yylhs yylen yydefred yydgoto yysindex yyrindex yygindex \
                     35:         yytable yycheck"
                     36:
                     37: if [ $# -eq 0 ]; then
                     38:        echo "usage: $0 file [tables]" >&2
                     39:        exit 1
                     40: fi
                     41:
                     42: file=$1
                     43: >$file
                     44: shift
                     45:
                     46: if [ $# -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
                     58: fi
                     59:
                     60: for i
                     61: do
                     62: ed - 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
                     70: w
                     71: q
                     72: END
                     73: done