make-rulenames
author wenzelm
Mon Oct 15 20:31:18 2001 +0200 (2001-10-15)
changeset 11773 983d2db52062
parent 0 a5a9c433f639
permissions -rwxr-xr-x
map_nth_elem;
clasohm@0
     1
#!/bin/sh
clasohm@0
     2
#   Title: 	make-rulenames
clasohm@0
     3
#   Author: 	Larry Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
#   Copyright   1990  University of Cambridge
clasohm@0
     5
#
clasohm@0
     6
#shell script for adding signature and val declarations to a rules file
clasohm@0
     7
#  usage:  make-rulenames <directory>
clasohm@0
     8
#
clasohm@0
     9
#Input is the file ruleshell.ML, which defines a theory.
clasohm@0
    10
#Output is .rules.ML
clasohm@0
    11
#
clasohm@0
    12
#
clasohm@0
    13
#Rule lines begin with a line containing the word "extend_theory"
clasohm@0
    14
#       and end   with a line containing the word "get_axiom"
clasohm@0
    15
#
clasohm@0
    16
#Each rule name xyz must appear on a line that begins
clasohm@0
    17
#           <spaces> ("xyz"
clasohm@0
    18
# ENSURE THAT THE FIRST RULE LINE DOES NOT CONTAIN A "[" CHARACTER!
clasohm@0
    19
#The file RULESIG gets lines like	val Eq_comp: thm
clasohm@0
    20
#    These are inserted after the line containing the string INSERT-RULESIG
clasohm@0
    21
#
clasohm@0
    22
#The file RULENAMES gets lines like	val Eq_comp = ax"Eq_comp";
clasohm@0
    23
#    These are inserted after the line containing the string INSERT-RULENAMES
clasohm@0
    24
#The input file should define the function "ax" above this point.
clasohm@0
    25
#
clasohm@0
    26
set -eu		#terminate if error or unset variable
clasohm@0
    27
if [ ! '(' -d $1 -a -f $1/ruleshell.ML ')' ]; \
clasohm@0
    28
           then echo $1 is not a suitable directory; exit 1; \
clasohm@0
    29
           fi
clasohm@0
    30
sed -n -e '/extend_theory/,/get_axiom/ s/^ *("\([^"]*\)".*$/  val \1: thm/p' $1/ruleshell.ML > RULESIG
clasohm@0
    31
sed -n -e '/extend_theory/,/get_axiom/ s/^ *("\([^"]*\)".*$/val \1 = ax"\1";/p' $1/ruleshell.ML > RULENAMES
clasohm@0
    32
sed -e '/INSERT-RULESIG/ r RULESIG
clasohm@0
    33
/INSERT-RULENAMES/ r RULENAMES' $1/ruleshell.ML > $1/.rules.ML
clasohm@0
    34
#WARNING: there must be no spaces after the filename in the "r" command!!
clasohm@0
    35
rm RULESIG RULENAMES
clasohm@0
    36