   (easy-menu-add pir-mode-menu-map pir-mode-map))
 
 
-
 (provide 'pir-mode)
-(provide 'pir-mode)
 
 ;;; pir-mode.el ends here

(defvar pir-register-regexp "[INPS]\\([12][0-9]\\|3[01]\\|[0-9]\\)")
(defvar pir-dollar-register-regexp "\\$[INPS][0-9]+")

(defvar pir-directives)
(setq pir-directives
      '("method" "non_prototyped" "prototyped" "@LOAD" "@MAIN"))

(defvar pir-dotted-directives)
(setq pir-dotted-directives
  '(".sub" ".pcc_sub" ".end" ".emit" ".eom" ".const" ".namespace"
    ".endnamespace" ".result" ".arg" ".return" ".include"
    ".pcc_begin" ".pcc_end" ".pcc_begin_return" ".pcc_end_return"
    ".pcc_begin_yield" ".pcc_end_yield"))

(defvar pir-variable-declarations)
(setq pir-variable-declarations
      '(".local" ".sym" ".param"))

(defvar pir-begin-keywords)
(setq pir-begin-keywords
  '(".sub" ".emit" ".pcc_begin_yield" ".pcc_begin_return"
    ".pcc_begin" ".namespace"))

(defvar pir-end-keywords)
(setq pir-end-keywords
  '(".end" ".eom" ".pcc_end_yield" ".pcc_end_return"
    ".pcc_end" ".endnamespace"))

(defvar pir-block-match-alist)
(setq   pir-block-match-alist
  '((".sub" ".end" 1)
    (".emit" ".eom" 1)
    (".pcc_begin_yield" ".pcc_end_yield" 0)
    (".pcc_begin_return" ".pcc_end_return" 0)
    (".pcc_begin" ".pcc_end" 0)
    (".namespace" ".endnamespace" 0)))
;  "Alist with IMCC's matching block keywords.
;Has IMCC's begin keywords as keys and a list of the matching end keywords as
;associated values.")

(defvar pir-block-offset-alist)
(setq pir-block-offset-alist
      (mapcan (lambda (blockspec)
		(let ((offset (caddr blockspec)))
		  `((,(car blockspec) . ,offset)
		    (,(cadr blockspec) . ,offset))))
	      pir-block-match-alist))

(defvar pir-open-directives)
(setq pir-open-directives
  (mapcar #'car pir-block-match-alist))

(defvar pir-close-directives)
(setq pir-close-directives
  (mapcar #'cadr pir-block-match-alist))

(defvar pir-block-begin-regexp)
(setq pir-block-begin-regexp
      (regexp-opt pir-begin-keywords 'paren))
(defvar pir-block-end-regexp)
(setq pir-block-end-regexp
  (regexp-opt pir-end-keywords 'paren))
(defvar pir-block-begin-or-end-regexp)
(setq pir-block-begin-or-end-regexp
   (concat "\\(?:"pir-block-begin-regexp "\\|"
	          pir-block-end-regexp "\\)"))

(defvar pir-function-header-regexp)
(setq pir-function-header-regexp
  "\\.\\(.sub\\)\\s-+\\(\\sw+\\)")
;  "Regexp to match a PIR function header.")


(defvar pir-font-lock-keywords)
(setq pir-font-lock-keywords
      `((,(concat "^\\s *\\(.sub\\)\\s +\\(\\sw+\\)"
		  "\\(\\s +" (regexp-opt pir-directives 'paren) "\\)?")
	 (1 font-lock-keyword-face)
	 (2 font-lock-function-name-face t t)
	 (4 font-lock-keyword-face t t))
	(,(concat "\\s-*" (regexp-opt pir-variable-declarations 'paren)
		  "\\(?:\\s +" (regexp-opt pir-type-keywords 'paren)
		  "\\(?:\\s +\\(\\sw+\\)\\)?\\)?")
	 (1 font-lock-keyword-face)
	 (2 font-lock-type-face nil t)
	 (3 font-lock-variable-name-face nil t))
	(,(concat "^\\s *\\(.const\\)\\s +"
		  (regexp-opt pir-type-keywords 'paren)
		  "\\(\\s +\\(\\sw+\\)\\)?")
	 (1 font-lock-keyword-face)
	 (2 font-lock-type-face nil t)
	 (4 font-lock-constant-face nil t))
	(,pir-block-begin-or-end-regexp . font-lock-keyword-face)
	  
	(,pir-dollar-register-regexp . font-lock-variable-name-face)
	(,pir-register-regexp . font-lock-variable-name-face)
	(,(regexp-opt pir-dotted-directives 'paren) . font-lock-keyword-face)
	(,(regexp-opt pir-ops 'words) . font-lock-keyword-face)
	("\\s-*\\(\\sw+\\)\\s=*"
	 (1 font-lock-variable-name-face))
	))

(defcustom pir-auto-indent-flag nil
  "*Non-nil means indent line after a semicolon or space in PIR mode."
  :type 'boolean
  :group 'pir)

(defcustom pir-blink-matching-block t
  "*Control the blinkin of matching PIR block keywords.
Non-nil means show matching begin of block when inserting a space,
newline or semicolon after an end keyword."
  :type 'boolean
  :group 'pir)

(defcustom pir-basic-indent 8
  "*Extra indentation applied to statements in PIR block structures."
  :type 'integer
  :group 'pir)

(defvar pir-imenu-generic-expression
  (list
   (list nil pir-function-header-regexp 2))
  "Imenu expression for PIR mode.  See `imenu-generic-expression'.")
  
(defun pir-comment ()
  "Convert an empty comment to a `larger' kind, or start a new one.
These are the known comment classes:


Keybindings
===========
\\{pir-mode-map}

Variables you can use to customize PIR mode
===========================================
