#!/bin/sh
#   Title: 	make-rulenames
#   Author: 	Larry Paulson, Cambridge University Computer Laboratory
#   Copyright   1988  University of Cambridge
#
#shell script for adding signature and val declarations to a rules file
#  usage:  make-rulenames <directory>
#
#Input is the file ruleshell.ML, which defines a theory.
#Output is .rules.ML
#
#Each rule name xyz must appear on a line that begins
#           <spaces> ("xyz"
#The file RULESIG gets lines like	val Eq_comp: Pure.thm
#    These are inserted after the line containing the string INSERT-RULESIG
#
#The file RULENAMES gets lines like	val Eq_comp = ax"Eq_comp";
#    These are inserted after the line containing the string INSERT-RULENAMES
#The input file should define the function "ax" above this point.
#
sed -n -e 's/^ *("\([^"]*\)".*$/  val \1: Pure.thm/p' $1/ruleshell.ML > RULESIG
sed -n -e 's/^ *("\([^"]*\)".*$/val \1 = ax"\1";/p' $1/ruleshell.ML > RULENAMES
sed -e '/INSERT-RULESIG/ r RULESIG
/INSERT-RULENAMES/ r RULENAMES' $1/ruleshell.ML > $1/.rules.ML
#WARNING: there must be no spaces after the filename in the "r" command!!
rm RULESIG RULENAMES

