;; isa-syntax.el Syntax expressions for Isabelle ;; Copyright (C) 1994-1998 LFCS Edinburgh. ;; ;; Author: David Aspinall ;; Maintainer: Isabelle maintainer ;; ;; $Id$ ;; (require 'proof-syntax) ;;; Proof mode customization: how should it work? ;;; Presently we have a bunch of variables in proof.el which are ;;; set from a bunch of similarly named variables in -syntax.el. ;;; ;;; Seems a bit daft: why not just have the customization in ;;; one place, and settings hardwired in -syntax.el. ;;; ;;; That way we can see which settings are part of instantiation of ;;; proof.el, and which are part of cusomization for . ;; ------ customize groups ;(defgroup isa-scripting nil ; "Customization of Isabelle script management" ; :group 'external ; :group 'languages) ;(defgroup isa-syntax nil ; "Customization of Isabelle's syntax recognition" ; :group 'isa-scripting) ;; ----- syntax for font-lock and other features ;; FIXME: this command-keyword orientation isn't good ;; enough for Isabelle, since we can have arbitrary ;; ML code around. One solution is to define a ;; restricted language consisting of the interactive ;; commands. We'd still need regexps below, though. ;; Alternatively: customize this for Marcus Wenzel's ;; proof language. (defgroup isa-syntax nil "Customization of Isabelle syntax for proof mode" :group 'isa-settings) (defcustom isa-keywords-decl '("val" "fun" "datatype" "signature" "structure") "Isabelle keywords for declarations. Includes ML keywords to fontify ML files." :group 'isa-syntax :type '(repeat string)) (defcustom isa-keywords-defn '("bind_thm") "Isabelle keywords for definitions" :group 'isa-syntax :type '(repeat string)) ;; isa-keywords-goal is used to manage undo actions (defcustom isa-keywords-goal '("Goal" "Goalw" "goal" "goalw" "goalw_cterm") "Isabelle commands to begin an interactive proof" :group 'isa-syntax :type '(repeat string)) (defcustom isa-keywords-save '("qed") ;; Related commands, but having different types, so PG ;; won't bother support them: ;; "result" "uresult" "bind_thm" "store_thm" "Isabelle commands to extract the proved theorem" :group 'isa-syntax :type '(repeat string)) (defcustom isa-keywords-commands '("by" "byev" "ba" "br" "be" "bd" "brs" "bes" "bds" "chop" "choplev" "back" "undo" "fa" "fr" "fe" "fd" "frs" "fes" "fds" "bw" "bws" "ren" ;; batch proofs "prove_goal" "qed_goal" "prove_goalw" "qed_goalw" "prove_goalw_cterm") "Isabelle command keywords" :group 'isa-syntax :type '(repeat string)) ;; See isa-command-table in Isamode/isa-menus.el to get this list. ;; BUT: tactics are not commands, so appear inside some expression. (defconst isa-tactics '("resolve_tac" "assume_tac")) ;; NB: this means that any adjustments above by customize will ;; only have effect in next session. (defconst isa-keywords (append isa-keywords-goal isa-keywords-save isa-keywords-decl isa-keywords-defn isa-keywords-commands isa-tactics) "All keywords in a Isabelle script") (defconst isa-tacticals '("REPEAT" "THEN" "ORELSE" "TRY")) ;; ----- regular expressions (defconst isa-id proof-id) (defconst isa-ids (proof-ids isa-id "[ \t]*") "Matches a sequence of identifiers separated by whitespace.") (defun isa-binder-regexp (binder dot) (concat binder "\\s-*\\(" isa-ids "\\)\\s-*" dot)) (defvar isa-font-lock-terms (list ;; lambda binders (list (isa-binder-regexp "\%" "\\.") 1 'proof-declaration-name-face)) "*Font-lock table for Isabelle terms.") (defconst isa-save-command-regexp (concat "^" (proof-ids-to-regexp isa-keywords-save))) ;; CHECKED (defconst isa-save-with-hole-regexp (concat "\\(" (proof-ids-to-regexp isa-keywords-save) "\\)\\s-+\"\\(" isa-id "\\)\"\\s-*;")) (defcustom isa-goal-command-regexp (proof-ids-to-regexp isa-keywords-goal) "Regular expression used to match a goal." :type 'regexp :group 'isabelle-config) (defconst isa-string-regexp (concat "\\s-*\"\\(" isa-id "\\)\"\\s-*") "Regexp matching ML strings, with contents bracketed.") (defconst isa-goal-with-hole-regexp (concat "\\(" ;; Don't bother with "val xxx = prove_goal blah". (proof-ids-to-regexp '("qed_goal")) "\\)" isa-string-regexp) "Regexp matching goal commands in Isabelle which name a theorem") (defvar isa-font-lock-keywords-1 (append isa-font-lock-terms (list (cons (proof-ids-to-regexp isa-keywords) 'font-lock-keyword-face) (cons (proof-ids-to-regexp isa-tacticals) 'proof-tacticals-name-face) (list isa-goal-with-hole-regexp 2 'font-lock-function-name-face) (list isa-save-with-hole-regexp 2 'font-lock-function-name-face)))) (provide 'isa-syntax)