;; suppl-mode.el --- a simple major mode for editing suppl files.

;; Version: 20160518.0000
;; Author: Getty Ritter
;; Url: http://github.com/aisamanra/suppl-mode

(defvar suppl-keyword-list nil "list of suppl keywords")
(setq suppl-keyword-list
      '("primitive"
        "prim"
        "type"
        "data"
        "event"
        "action"
        "conflict"
        "procedure"
        "proc"
        "function"
        "func"
        "yields"
        "mode"
        "table"
        "index"
        "key"
        "lifetime"
        "handle"
        "define"
        "end"
        "axiom"
        "lemma"
        "queue"
        "insert"
        "into"
        "from"
        "query"
        "foreach"
        "skip"))

(defvar suppl-builtin-list nil "list of suppl builtin identifiers")
(setq suppl-builtin-list
      '("number"
        "num"
        "string"
        "str"
        "list"
        "set"
        "map"
        "in"
        "out"
        "inout"))

(defvar suppl-font-lock nil
  "suppl font lock table")
(setq suppl-font-lock
      `(( "\\(%.*\\)$"
          . font-lock-comment-face )
        ( ,(regexp-opt suppl-keyword-list)
          . font-lock-builtin-face )
        ( ,(regexp-opt suppl-builtin-list)
          . font-lock-builtin-face )
        ( "\\([a-z_][A-Za-z0-9_]*\\) *("
          1 font-lock-function-name-face )
        ( "\\([A-Z][A-Za-z0-9_]*\\)"
          . font-lock-variable-name-face )
        ( "\\([a-z_][A-Za-z0-9_]+\\)"
          . font-lock-constant-face )))

(defvar suppl-syntax-table nil
  "Syntax table for `suppl-mode'.")
(setq suppl-syntax-table (make-syntax-table))

(define-derived-mode suppl-mode prog-mode
  "suppl-mode is a major mode for editing .eb files"
  :syntax-table ndbl-syntax-table

  (setq font-lock-defaults '(suppl-font-lock))
  (setq mode-name "SUPPL mode")
  (setq comment-start "%")
  (setq comment-end ""))

;;;###autoload
(add-to-list 'auto-mode-alist '("\\.suppl\\'" . suppl-mode))

(provide 'suppl-mode)

;;; suppl-mode.el ends here
