-
Notifications
You must be signed in to change notification settings - Fork 2
/
mystery.el
93 lines (93 loc) · 5.2 KB
/
mystery.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(defgroup mystery-group nil "Customizations for mystery-mode.")
(defconst mystery-font-lock-keywords
'(("\\(?:\\<OF\\>\\)\\s-*\\(\\<INTEGER\\>\\)\\s-*\\(?:\=\\|BEGIN\\|\)\:\\|\;\\|\)\\)"
;;Highlight 'INTEGER'
(1 'font-lock-type-face))
("\\(?:\=\\)\\s-*\\(\\<INTEGER\\>\\)\\s-*\\(?:\\<BEGIN\\|\;\\)"
;;Highlight 'INTEGER'
(1 'font-lock-type-face))
("\\(?:\:\\)\\s-*\\(\\<INTEGER\\>\\)\\s-*\\(?:\=\\|BEGIN\\|\)\:\\|\;\\|\)\\)"
;;Highlight 'INTEGER'
(1 'font-lock-type-face))
("\\(?:\:\\)\\s-*\\(\\<INTEGER\\>\\)\\s-*\\(?:\\<BEGIN\\|\;\\)"
;;Highlight 'INTEGER'
(1 'font-lock-type-face))
("\\(?:\)\:\\)\\s-*\\(\\<INTEGER\\>\\)\\s-*\\(?:\=\\)"
;;Highlight 'INTEGER'
(1 'font-lock-type-face))
("\\(?:\:\\)\\s-*\\(\\<INTEGER\\>\\)\\s-*\\(?:\;\\|\)\\)"
;;Highlight 'INTEGER'
(1 'font-lock-type-face))
("\\(?:\:\\)\\s-*\\(\\<INTEGER\\>\\)\\s-*\\(?:\)\:\\|\;\\|\)\\)"
;;Highlight 'INTEGER'
(1 'font-lock-type-face))
("\\(?:\\<THEN\\|BEGIN\\|\]\\|END\\|DO\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\=\\|\;\\|ELSE\\|\\`\\|INTEGER\\|\)\\)\\s-*\\(\\<BEGIN\\>\\)\\s-*\\(?:\\<DO\\|RETURN\\|THEN\\|ELSE\\|[-]?[0-9]+\\|WHILE\\|PRINT\\|VAR\\|PROCEDURE\\|IF\\|BEGIN\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\=\\|\;\\|\\`\\|TYPE\\|\(\\)"
;;Highlight 'BEGIN'
(1 'font-lock-keyword-face))
("\\(?:\\<DO\\|THEN\\|BEGIN\\|\;\\|ELSE\\>\\)\\s-*\\(\\<PRINT\\>\\)\\s-*\\(?:[-]?[0-9]+\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\(\\)"
;;Highlight 'PRINT'
(1 'font-lock-keyword-face))
("\\(?:\\<DO\\|BEGIN\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|THEN\\|\]\\|\;\\|ELSE\\|[-]?[0-9]+\\|END\\|\)\\)\\s-*\\(\\<END\\>\\)\\s-*\\(?:\\<BEGIN\\|\;\\)"
;;Highlight 'END'
(1 'font-lock-keyword-face))
("\\(?:\\<DO\\|BEGIN\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|THEN\\|\]\\|\;\\|ELSE\\|[-]?[0-9]+\\|END\\|\)\\)\\s-*\\(\\<END\\>\\)\\s-*\\(?:\\<END\\|\;\\|ELSE\\>\\)"
;;Highlight 'END'
(1 'font-lock-keyword-face))
("\\(?:\\<DO\\|BEGIN\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|THEN\\|\]\\|\;\\|ELSE\\|[-]?[0-9]+\\|END\\|\)\\)\\s-*\\(\\<END\\>\\)\\s-*\\(?:\\'\\|END\\|\;\\|ELSE\\>\\)"
;;Highlight 'END'
(1 'font-lock-keyword-face))
("\\(?:\\<THEN\\|BEGIN\\|\\`\\|DO\\|\=\\|\;\\|ELSE\\>\\)\\s-*\\(\\<VAR\\>\\)\\s-*\\(?:[a-zA-Z][a-zA-Z0-9.\-]*\\)"
;;Highlight 'VAR'
(1 'font-lock-keyword-face))
("\\(?:\\<THEN\\|BEGIN\\|\\`\\|DO\\|\=\\|\;\\|ELSE\\>\\)\\s-*\\(\\<TYPE\\>\\)\\s-*\\(?:[a-zA-Z][a-zA-Z0-9.\-]*\\)"
;;Highlight 'TYPE'
(1 'font-lock-keyword-face))
("\\(?:\\<DO\\|THEN\\|BEGIN\\|\;\\|ELSE\\>\\)\\s-*\\(\\<RETURN\\>\\)\\s-*\\(?:[-]?[0-9]+\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\(\\)"
;;Highlight 'RETURN'
(1 'font-lock-keyword-face))
("\\(?:\\<THEN\\|BEGIN\\|\\`\\|DO\\|\=\\|\;\\|ELSE\\>\\)\\s-*\\(\\<PROCEDURE\\>\\)\\s-*\\(?:[a-zA-Z][a-zA-Z0-9.\-]*\\)"
;;Highlight 'PROCEDURE'
(1 'font-lock-keyword-face))
("\\(?:\\<OF\\|\=\\|\:\\|\)\:\\)\\s-*\\(\\<PROCEDURE\\>\\)\\s-*\\(?:\(\\)"
;;Highlight 'PROCEDURE'
(1 'font-lock-keyword-face))
("\\(?:\\<OF\\|\=\\|\:\\|\)\:\\)\\s-*\\(\\<ARRAY\\>\\)\\s-*\\(?:\[\\)"
;;Highlight 'ARRAY'
(1 'font-lock-keyword-face))
("\\(?:\]\\)\\s-*\\(\\<OF\\>\\)\\s-*\\(?:\\<INTEGER\\|ARRAY\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\[\\|PROCEDURE\\>\\)"
;;Highlight 'OF'
(1 'font-lock-keyword-face))
("\\(?:\\<DO\\|THEN\\|BEGIN\\|\;\\|ELSE\\>\\)\\s-*\\(\\<WHILE\\>\\)\\s-*\\(?:[-]?[0-9]+\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\(\\)"
;;Highlight 'WHILE'
(1 'font-lock-keyword-face))
("\\(?:[-]?[0-9]+\\|\]\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\)\\)\\s-*\\(\\<DO\\>\\)\\s-*\\(?:\\<DO\\|RETURN\\|THEN\\|ELSE\\|[-]?[0-9]+\\|WHILE\\|PRINT\\|VAR\\|PROCEDURE\\|IF\\|BEGIN\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\=\\|\;\\|\\`\\|TYPE\\|\(\\)"
;;Highlight 'DO'
(1 'font-lock-keyword-face))
("\\(?:\\<DO\\|BEGIN\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|THEN\\|\]\\|\;\\|ELSE\\|[-]?[0-9]+\\|END\\|\)\\)\\s-*\\(\\<END\\>\\)\\s-*\\(?:\\<BEGIN\\|\;\\)"
;;Highlight 'END'
(1 'font-lock-keyword-face))
("\\(?:\\<DO\\|BEGIN\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|THEN\\|\]\\|\;\\|ELSE\\|[-]?[0-9]+\\|END\\|\)\\)\\s-*\\(\\<END\\>\\)\\s-*\\(?:\\<END\\|\;\\|ELSE\\>\\)"
;;Highlight 'END'
(1 'font-lock-keyword-face))
("\\(?:\\<DO\\|BEGIN\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|THEN\\|\]\\|\;\\|ELSE\\|[-]?[0-9]+\\|END\\|\)\\)\\s-*\\(\\<END\\>\\)\\s-*\\(?:\\'\\|END\\|\;\\|ELSE\\>\\)"
;;Highlight 'END'
(1 'font-lock-keyword-face))
("\\(?:[-]?[0-9]+\\|\]\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\)\\)\\s-*\\(\\<AND\\>\\)\\s-*\\(?:[-]?[0-9]+\\|[a-zA-Z][a-zA-Z0-9.\-]*\\|\(\\)"
;;Highlight 'AND'
(1 'font-lock-keyword-face))
("\\(?:[-]?[0-9]+\\)\\s-*\\(\\<TO\\>\\)\\s-*\\(?:[-]?[0-9]+\\)"
;;Highlight 'TO'
(1 'font-lock-keyword-face))))
(defun mystery-mode ()
(interactive)
(kill-all-local-variables)
(setq major-mode 'mystery-mode
mode-name "mystery"
fill-column 74
indent-tabs-mode t
tab-width 4)
(set (make-local-variable 'require-final-newline) t)
(set (make-local-variable 'next-line-add-newlines) nil)
(set (make-local-variable 'font-lock-defaults)
'(mystery-font-lock-keywords nil nil nil backward-paragraph (font-lock-lines-before . 2) (font-lock-lines-after . 2)))
(set (make-local-variable 'font-lock-lines-before) 2))