/[emacs]/emacs/lisp/progmodes/mixal-mode.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/mixal-mode.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by lektu, Tue Aug 30 11:09:32 2005 UTC revision 1.7 by monnier, Tue Oct 11 21:22:14 2005 UTC
# Line 17  Line 17 
17  ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,  ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18  ;; MA 02110-1301 USA  ;; MA 02110-1301 USA
19    
20  ;; Author: Pieter E.J. Pareit <pieter.pareit@skynet.be>  ;; Author: Pieter E.J. Pareit <pieter.pareit@gmail.com>
21  ;; Maintainer: Pieter E.J. Pareit <pieter.pareit@skynet.be>  ;; Maintainer: Pieter E.J. Pareit <pieter.pareit@gmail.com>
22  ;; Created: 09 Nov 2002  ;; Created: 09 Nov 2002
23  ;; Version: 0.1  ;; Version: 0.1
24  ;; Keywords: Knuth mix mixal asm mixvm "The Art Of Computer Programming"  ;; Keywords: Knuth mix mixal asm mixvm "The Art Of Computer Programming"
# Line 27  Line 27 
27  ;; Major mode for the mix asm language.  ;; Major mode for the mix asm language.
28  ;; The mix asm language is described in "The Art Of Computer Programming".  ;; The mix asm language is described in "The Art Of Computer Programming".
29  ;;  ;;
30  ;; For optimal use, also use GNU MDK. Compiling needs mixasm, running  ;; For optimal use, also use GNU MDK.  Compiling needs mixasm, running
31  ;; and debugging needs mixvm and mixvm.el from GNU MDK. You can get  ;; and debugging needs mixvm and mixvm.el from GNU MDK.  You can get
32  ;; GNU MDK from `https://savannah.gnu.org/projects/mdk/' and  ;; GNU MDK from `https://savannah.gnu.org/projects/mdk/' and
33  ;; `ftp://ftp.gnu.org/pub/gnu/mdk'.  ;; `ftp://ftp.gnu.org/pub/gnu/mdk'.
34  ;;  ;;
35  ;; To use this mode, place the following in your .emacs file:  ;; To use this mode, place the following in your .emacs file:
36  ;; `(load-file "/PATH-TO-FILE/mixal-mode.el")'.  ;; `(load-file "/PATH-TO-FILE/mixal-mode.el")'.
37  ;; When you load a file with the extension .mixal the mode will be started  ;; When you load a file with the extension .mixal the mode will be started
38  ;; automatic. If you want to start the mode manual, use `M-x mixal-mode'.  ;; automatic.  If you want to start the mode manual, use `M-x mixal-mode'.
39  ;; Font locking will work, the behavior of tabs is the same as emacs  ;; Font locking will work, the behavior of tabs is the same as Emacs's
40  ;; default behavior. You can compile a source file with `C-c c' you can  ;; default behavior.  You can compile a source file with `C-c c' you can
41  ;; run a compiled file with `C-c r' or run it in debug mode with `C-c d'.  ;; run a compiled file with `C-c r' or run it in debug mode with `C-c d'.
42  ;; You can get more information about a particular operation code by using  ;; You can get more information about a particular operation code by using
43  ;; mixal-describe-operation-code or `C-h o'.  ;; mixal-describe-operation-code or `C-h o'.
# Line 45  Line 45 
45  ;; Have fun.  ;; Have fun.
46    
47  ;;; History:  ;;; History:
48    ;; Version 0.3:
49    ;; 08/10/05: sync mdk and emacs cvs
50    ;;           from emacs: compile-command and require-final-newline
51    ;;           from mdk:   see version 0.2
52    ;;           correct my email address
53    ;; Version 0.2:
54    ;; 06/04/05: mixasm no longer needs -g option
55    ;;           fontlocking of comments works in all? cases now
56    ;;           added some more mixal-operation-codes
57  ;; Version 0.1:  ;; Version 0.1:
58  ;; Version 0.1.1:  ;; Version 0.1.1:
59  ;; 22/11/02: bugfix in fontlocking, needed to add a '-' to the regex.  ;; 22/11/02: bugfix in fontlocking, needed to add a '-' to the regex.
# Line 54  Line 63 
63  ;; 09/11/02: started mixal-mode.  ;; 09/11/02: started mixal-mode.
64    
65  ;;; Code:  ;;; Code:
   
66  (defvar compile-command)  (defvar compile-command)
67    
68  ;;; Key map  ;;; Key map
# Line 66  Line 74 
74      (define-key map "\C-ho" 'mixal-describe-operation-code)      (define-key map "\C-ho" 'mixal-describe-operation-code)
75      map)      map)
76    "Keymap for `mixal-mode'.")    "Keymap for `mixal-mode'.")
77  ; (makunbound 'mixal-mode-map)  ;; (makunbound 'mixal-mode-map)
78    
79  ;;; Syntax table  ;;; Syntax table
80  (defvar mixal-mode-syntax-table  (defvar mixal-mode-syntax-table
81    (let ((st (make-syntax-table)))    (let ((st (make-syntax-table)))
82      (modify-syntax-entry ?* "<" st)      ;; (modify-syntax-entry ?* "<" st)    we need to do a bit more to make
83      (modify-syntax-entry ?\n ">" st)      ;; (modify-syntax-entry ?\n ">" st)    fontlocking for comments work
84      st)      st)
85    "Syntax table for `dot-mode'.")    "Syntax table for `dot-mode'.")
86    
# Line 97  value.") Line 105  value.")
105      "LD4" "LD5" "LD6" "LDX" "LDAN" "LD1N" "LD2N" "LD3N" "LD4N" "LD5N" "LD6N"      "LD4" "LD5" "LD6" "LDX" "LDAN" "LD1N" "LD2N" "LD3N" "LD4N" "LD5N" "LD6N"
106      "LDXN" "STA" "ST1" "ST2" "ST3" "ST4" "ST5" "ST6" "STX" "STJ" "STZ" "JBUS"      "LDXN" "STA" "ST1" "ST2" "ST3" "ST4" "ST5" "ST6" "STX" "STJ" "STZ" "JBUS"
107      "IOC" "IN" "OUT" "JRAD" "JMP" "JSJ" "JOV" "JNOV"      "IOC" "IN" "OUT" "JRAD" "JMP" "JSJ" "JOV" "JNOV"
108        "JL" "JE" "JG" "JGE" "JNE" "JLE"
109      "JAN" "J1N" "J2N" "J3N" "J4N" "J5N" "J6N" "JXN"      "JAN" "J1N" "J2N" "J3N" "J4N" "J5N" "J6N" "JXN"
110      "JAZ" "J1Z" "J2Z" "J3Z" "J4Z" "J5Z" "J6Z" "JXZ"      "JAZ" "J1Z" "J2Z" "J3Z" "J4Z" "J5Z" "J6Z" "JXZ"
111      "JAP" "J1P" "J2P" "J3P" "J4P" "J5P" "J6P" "JXP"      "JAP" "J1P" "J2P" "J3P" "J4P" "J5P" "J6P" "JXP"
# Line 109  value.") Line 118  value.")
118      "INCX" "DECX" "ENTX" "ENNX" "CMPA" "FCMP" "CMP1" "CMP2" "CMP3" "CMP4"      "INCX" "DECX" "ENTX" "ENNX" "CMPA" "FCMP" "CMP1" "CMP2" "CMP3" "CMP4"
119      "CMP5" "CMP6" "CMPX")      "CMP5" "CMP6" "CMPX")
120    "List of possible operation codes as strings.")    "List of possible operation codes as strings.")
121  ; (makunbound 'mixal-operation-codes)  ;; (makunbound 'mixal-operation-codes)
122    
123  (defvar mixal-assembly-pseudoinstructions  (defvar mixal-assembly-pseudoinstructions
124    '("ORIG" "EQU" "CON" "ALF" "END")    '("ORIG" "EQU" "CON" "ALF" "END")
125    "List of possible assembly pseudoinstructions")    "List of possible assembly pseudoinstructions.")
126    
127  ;;; Font-locking:  ;;; Font-locking:
128  (defvar mixal-font-lock-keywords  (defvar mixal-font-lock-keywords
# Line 124  value.") Line 133  value.")
133      (,(regexp-opt      (,(regexp-opt
134         mixal-assembly-pseudoinstructions 'words)         mixal-assembly-pseudoinstructions 'words)
135       . mixal-font-lock-assembly-pseudoinstruction-face)       . mixal-font-lock-assembly-pseudoinstruction-face)
136      ("^[A-Z0-9a-z]*[ \t]+[A-Z0-9a-z]+[ \t]+[\\-A-Z0-9a-z,():]*[\t]+\\(.*\\)$"      ("^[A-Z0-9a-z]*[ \t]+[A-ZO-9a-z]+[ \t]+\\(=.*=\\).*$"
137       (1 font-lock-comment-face)))       (1 font-lock-constant-face))
138        ("^[A-Z0-9a-z]*[ \t]+[A-Z0-9a-z]+[ \t]+[A-Z0-9a-z,():+-\\*=\" ]*\t+\\(.*\\)$"
139         (1 font-lock-comment-face))
140        ("^\\*.*$" . font-lock-comment-face))
141    "Keyword highlighting specification for `mixal-mode'.")    "Keyword highlighting specification for `mixal-mode'.")
142  ; (makunbound 'mixal-font-lock-keywords)  ;; (makunbound 'mixal-font-lock-keywords)
143    
144  ;;;; Compilation  ;;;; Compilation
145  ;; Output from mixasm is compatible with default behavior of emacs,  ;; Output from mixasm is compatible with default behavior of emacs,
# Line 139  value.") Line 151  value.")
151  ;;;; Describe  ;;;; Describe
152  (defvar mixal-operation-codes-alist '()  (defvar mixal-operation-codes-alist '()
153    "Alist that contains all the possible operation codes for mix.    "Alist that contains all the possible operation codes for mix.
154  Each elt has the form (OP-CODE GROUP FULL-NAME C-BYTE F-BYTE DESCRIPTION EXECUTION-TIME)  Each elt has the form
155  Where OP-CODE is the text of the opcode as an symbol, FULL-NAME is the human readable name    (OP-CODE GROUP FULL-NAME C-BYTE F-BYTE DESCRIPTION EXECUTION-TIME)
156  as a string, C-BYTE is the operation code telling what operation is to be performed, F-BYTE holds  Where OP-CODE is the text of the opcode as an symbol,
157  an modification of the operation code which can be a symbol or a number, DESCRIPTION contains  FULL-NAME is the human readable name as a string,
158  an string with a description about the operation code and EXECUTION-TIME holds info  C-BYTE is the operation code telling what operation is to be performed,
159  about the time it takes, number or string.")  F-BYTE holds a modification of the operation code which can be a symbol
160  ; (makunbound 'mixal-operation-codes-alist)    or a number,
161    DESCRIPTION contains an string with a description about the operation code and
162  (defun mixal-add-operation-code (op-code group full-name C-byte F-byte description execution-time)  EXECUTION-TIME holds info about the time it takes, number or string.")
163    "Add an operation code to the list that contains information about possible op code's."  ;; (makunbound 'mixal-operation-codes-alist)
164    (setq mixal-operation-codes-alist (cons (list op-code group full-name C-byte F-byte  
165                                                  description execution-time)  (defun mixal-add-operation-code (op-code group full-name C-byte F-byte
166                                            mixal-operation-codes-alist )))                                           description execution-time)
167      "Add an operation code to `mixal-operation-codes-alist'."
168      (setq mixal-operation-codes-alist
169            (cons (list op-code group full-name C-byte F-byte
170                        description execution-time)
171                  mixal-operation-codes-alist)))
172    
173  ;; now add each operation code  ;; now add each operation code
174    
# Line 1250  The converted character representation i Line 1267  The converted character representation i
1267  (defun mixal-describe-operation-code (&optional op-code)  (defun mixal-describe-operation-code (&optional op-code)
1268    "Display the full documentation of OP-CODE."    "Display the full documentation of OP-CODE."
1269    (interactive)    (interactive)
1270    ;; we like to provide completition and history, so do it ourself (interactive "?bla")?    ;; We like to provide completion and history, so do it ourself
1271      ;; (interactive "?bla")?
1272    (unless op-code    (unless op-code
1273      (let* ((completion-ignore-case t)      (let* ((completion-ignore-case t)
1274             ;; we already have a list, but it is not in the right format             ;; we already have a list, but it is not in the right format
# Line 1282  The converted character representation i Line 1300  The converted character representation i
1300    
1301  ;;;; Running  ;;;; Running
1302  (defun mixal-run ()  (defun mixal-run ()
1303    "Run's mixal file in current buffer, assumes that file has been compiled"    "Run mixal file in current buffer, assumes that file has been compiled."
1304    (interactive)    (interactive)
1305    (mixvm (concat "mixvm -r -t -d "    (mixvm (concat "mixvm -r -t -d "
1306                   (file-name-sans-extension (buffer-file-name)))))                   (file-name-sans-extension (buffer-file-name)))))
1307    
1308  (defun mixal-debug ()  (defun mixal-debug ()
1309    "Starts mixvm for debugging, assumes that file has been compiled with debugging support"    "Start mixvm for debugging.
1310    Assumes that file has been compiled with debugging support."
1311    (interactive)    (interactive)
1312    (mixvm (concat "mixvm "    (mixvm (concat "mixvm "
1313                   (file-name-sans-extension (buffer-file-name)))))                   (file-name-sans-extension (buffer-file-name)))))
# Line 1300  The converted character representation i Line 1319  The converted character representation i
1319    (set (make-local-variable 'comment-start) "*")    (set (make-local-variable 'comment-start) "*")
1320    (set (make-local-variable 'comment-start-skip) "*")    (set (make-local-variable 'comment-start-skip) "*")
1321    (set (make-local-variable 'font-lock-defaults) '(mixal-font-lock-keywords))    (set (make-local-variable 'font-lock-defaults) '(mixal-font-lock-keywords))
1322  ; might add an indent function in the future    ;; might add an indent function in the future
1323  ;  (set (make-local-variable 'indent-line-function) 'mixal-indent-line)    ;;  (set (make-local-variable 'indent-line-function) 'mixal-indent-line)
1324    (set (make-local-variable 'compile-command) (concat "mixasm -g "    (set (make-local-variable 'compile-command) (concat "mixasm "
1325                                                        buffer-file-name))                                                        buffer-file-name))
1326    ;; mixasm will do strange when there is no final newline,    ;; mixasm will do strange when there is no final newline,
1327    ;; so let Emacs ensure that it is always there    ;; so let Emacs ensure that it is always there
# Line 1314  The converted character representation i Line 1333  The converted character representation i
1333    
1334  (provide 'mixal-mode)  (provide 'mixal-mode)
1335    
1336  ;;; arch-tag: be7c128a-bf61-4951-a90e-9398267ce3f3  ;; arch-tag: be7c128a-bf61-4951-a90e-9398267ce3f3
1337  ;;; mixal-mode.el ends here  ;;; mixal-mode.el ends here

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26