src/HOL/TPTP/TPTP_Parser/make_tptp_parser
author sultana
Tue, 03 Apr 2012 17:33:22 +0100
changeset 47316 15428dd82b54
parent 46846 9e99afaade17
child 53498 05313b45a5ae
permissions -rwxr-xr-x
removed use of CharVector in generated parser, to make SMLNJ happy

#!/bin/bash
#
# make_tptp_parser - Runs ML-Yacc to generate TPTP parser and makes it
#                    Isabelle-friendly.
#
# This code is based on that used in src/Tools/Metis to adapt Metis for
# use in Isabelle.

INTERMEDIATE_FILES="tptp.yacc.sig tptp.lex.sml tptp.yacc.sml"

echo "Cleaning"
rm -f tptp_lexyacc.ML
echo "Generating lexer and parser"
ml-lex tptp.lex && ml-yacc tptp.yacc
echo "Generating tptp_lexyacc.ML"
(
  cat <<EOF

(******************************************************************)
(* GENERATED FILE -- DO NOT EDIT -- GENERATED FILE -- DO NOT EDIT *)
(* GENERATED FILE -- DO NOT EDIT -- GENERATED FILE -- DO NOT EDIT *)
(* GENERATED FILE -- DO NOT EDIT -- GENERATED FILE -- DO NOT EDIT *)
(******************************************************************)

(*
  This file is produced from the parser generated by ML-Yacc from the
  source files tptp.lex and tptp.yacc.
*)
EOF

for FILE in $INTERMEDIATE_FILES
do
  perl -p -e 's/\bref\b/Unsynchronized.ref/g;' \
          -e 's/Unsafe\.(.*)/\1/g;' \
          -e 's/\b(Char\.ord\()CharVector\.sub\b/\1String\.sub/g;' $FILE
done
) > tptp_lexyacc.ML

rm -f $INTERMEDIATE_FILES tptp.yacc.desc