#!/bin/sh
#
# Based on suggestion from ORA lex/yacc book, 2nd ed.
# Defining C macros doesn't work for flex 2.5.2, it includes the header
# file too late, and things lose.
#
# If you run across more symbols exported by some variant of lex, just
# add them to the file below.

file=/tmp/yyfix$$
test -f $file && rm -f $file

prefix=$1
symlist="
yyback
yybgin
yycrank
yyerror
yyestate
yyextra
yyfnd
yyin
yyinput
yyleng
yylex
yylineno
yylook
yylsp
yylstate
yylval
yymatch
yymorfg
yyolsp
yyout
yyoutput
yyprevious
yysbuf
yysptr
yysvec
yytchar
yytext
yytop
yyunput
yyvstop
yywrap
yy_create_buffer
yy_delete_buffer
yy_flush_buffer
yy_init_buffer
yy_load_buffer_state
yy_scan_buffer
yy_scan_bytes
yy_scan_string
yy_switch_to_buffer
yyrestart
yychar
yynerrs
yyparse
"

> $file
for sym in $symlist ; do
  echo s/$sym/$prefix$sym/g >> $file || {
    echo 1>&2 Cannot append to $file.
    exit 1
  }
done

sed -f $file || {
  echo 1>&2 Error running sed.
  exit 1
}

rm -f $file

exit 0
