2014-01-08 11:25:05 +00:00
( require 'generic-x )
2014-01-09 17:32:47 +00:00
( require 'lean-input )
2014-01-09 19:45:31 +00:00
( require 'compile )
( defvar lean-exe " lean "
" Path for the Lean executable " )
( defun lean-execute ( )
" Execute Lean in the current buffer "
( interactive )
( compile ( format " %s %s " lean-exe ( buffer-file-name ) ) ) )
( defun lean-set-keys ( )
( local-set-key " \C -c \C -x " 'lean-execute )
( local-set-key " \C -c \C -l " 'lean-execute ) )
2014-01-08 11:25:05 +00:00
( define-generic-mode
'lean-mode ;; name of the mode to create
' ( " -- " ) ;; comments start with
2014-01-09 16:33:52 +00:00
' ( " import " " definition " " variable " " variables " " print " " axiom " " theorem " " universe " " alias " " help " " set_option " " set_opaque " " environment " " options " " infix " " infixl " " infixr " " notation " " eval " " check " " exit " " coercion " " end " " using " " namespace " " builtin " " scope " " pop_scope " ) ;; some keywords
2014-01-08 11:25:05 +00:00
' ( ( " \\ < \\ (Bool \\ |Int \\ |Nat \\ |Real \\ |Type \\ |TypeU \\ |ℕ \\ |ℤ \\ ) \\ > " . 'font-lock-type-face )
( " \\ < \\ (calc \\ |have \\ |in \\ |let \\ ) \\ > " . font-lock-keyword-face )
( " \" [^ \" ]* \" " . 'font-lock-string-face )
( " \\ (-> \\ |/ \\ \\ \\ |== \\ | \\ \\ / \\ |[*+/:<=>¬λ→∀∃∧∨≠≤≥-] \\ ) " . 'font-lock-constant-face ) )
' ( " \\ .lean$ " ) ;; files for which to activate this mode
' ( ( lambda ( )
2014-01-09 17:32:47 +00:00
( set-input-method " Lean " )
2014-01-09 17:48:18 +00:00
( set ( make-local-variable 'lisp-indent-function )
'common-lisp-indent-function )
2014-01-09 19:45:31 +00:00
( lean-set-keys )
2014-01-09 17:48:18 +00:00
) )
2014-01-08 11:25:05 +00:00
" A mode for Lean files " ;; doc string for this mode
)
2014-01-09 17:32:47 +00:00
( provide 'lean-mode )
2014-01-08 11:25:05 +00:00
; (regexp-opt '("Int" "Bool" "Nat" "Type" "Real") t)
; (regexp-opt '("let" "in" "have" "calc" "forall" "exists") t)
; (regexp-opt '("=" "->" "≠" "∨ " "∧" "¬" "/\\" "\\/" "+" "-" "*" "/" "<" ">" "≤" "≥" "==" "∀" "∃" "→" "λ" ":") t)