lib/Tools/update_cartouches
author haftmann
Sat, 14 Nov 2015 08:45:52 +0100
changeset 61670 301e0b4ecd45
parent 61579 634cd44bb1d3
child 62445 91902961184c
permissions -rwxr-xr-x
coalesce permanent_interpretation.ML with interpretation.ML
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58610
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
     2
#
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
     3
# Author: Makarius
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
     4
#
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
     5
# DESCRIPTION: update theory syntax to use cartouches
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
     6
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
     7
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
     8
## diagnostics
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
     9
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    10
PRG="$(basename "$0")"
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    11
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    12
function usage()
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    13
{
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    14
  echo
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    15
  echo "Usage: isabelle $PRG [FILES|DIRS...]"
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    16
  echo
61492
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    17
  echo "  Options are:"
61579
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61492
diff changeset
    18
  echo "    -c           replace comment marker \"--\" by symbol \"\\<comment>\""
61492
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    19
  echo "    -t           replace @{text} antiquotations within text tokens"
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    20
  echo
58610
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    21
  echo "  Recursively find .thy files and update theory syntax to use cartouches"
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    22
  echo "  instead of old-style {* verbatim *} or \`alt_string\` tokens."
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    23
  echo
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    24
  echo "  Old versions of files are preserved by appending \"~~\"."
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    25
  echo
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    26
  exit 1
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    27
}
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    28
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    29
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    30
## process command line
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    31
61492
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    32
# options
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    33
61579
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61492
diff changeset
    34
COMMENT="false"
61492
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    35
TEXT="false"
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    36
61579
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61492
diff changeset
    37
while getopts "ct" OPT
61492
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    38
do
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    39
  case "$OPT" in
61579
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61492
diff changeset
    40
    c)
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61492
diff changeset
    41
      COMMENT="true"
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61492
diff changeset
    42
      ;;
61492
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    43
    t)
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    44
      TEXT="true"
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    45
      ;;
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    46
    \?)
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    47
      usage
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    48
      ;;
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    49
  esac
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    50
done
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    51
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    52
shift $(($OPTIND - 1))
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    53
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    54
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    55
# args
3480725c71d2 added isabelle update_cartouches option -t;
wenzelm
parents: 58610
diff changeset
    56
58610
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    57
[ "$#" -eq 0 -o "$1" = "-?" ] && usage
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    58
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    59
SPECS="$@"; shift "$#"
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    60
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    61
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    62
## main
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    63
fffdbce036db added update_cartouches tool;
wenzelm
parents:
diff changeset
    64
find $SPECS -name \*.thy -print0 | \
61579
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61492
diff changeset
    65
  xargs -0 "$ISABELLE_TOOL" java isabelle.Update_Cartouches "$COMMENT" "$TEXT"