lib/Tools/keywords
author wenzelm
Wed, 06 Jan 2010 20:00:22 +0100
changeset 34282 549969a7f582
parent 33684 29d8aaeb56e5
child 35022 c844b93dd147
permissions -rwxr-xr-x
simplified build/bootstrap of Isabelle/Scala components -- avoid make;

#!/usr/bin/env bash
#
# Author: Makarius
#
# DESCRIPTION: generate outer syntax keyword files from session logs


## diagnostics

PRG="$(basename "$0")"

function usage()
{
  echo
  echo "Usage: isabelle $PRG [OPTIONS] [LOGS ...]"
  echo
  echo "  Options are:"
  echo "    -k NAME      specific name of keywords collection (default: empty)"
  echo
  echo "  Generate outer syntax keyword files from (compressed) session LOGS."
  echo "  Targets Emacs Proof General."
  echo
  exit 1
}


## process command line

# options

KEYWORDS_NAME=""

while getopts "k:" OPT
do
  case "$OPT" in
    k)
      KEYWORDS_NAME="$OPTARG"
      ;;
    \?)
      usage
      ;;
  esac
done

shift $(($OPTIND - 1))


## main

SESSIONS=""
for LOG in "$@"
do
  NAME="$(basename "$LOG" .gz)"
  if [ -z "$SESSIONS" ]; then
    SESSIONS="$NAME"
  else
    SESSIONS="$SESSIONS + $NAME"
  fi
done

for LOG in "$@"
do
  if [ "${LOG%.gz}" = "$LOG" ]; then
    cat "$LOG"
  else
    gzip -dc "$LOG"
  fi
  echo
done | \
perl -w "$ISABELLE_HOME/lib/scripts/keywords.pl" "$KEYWORDS_NAME" "$SESSIONS"