FUEL: better font-locking of a bunch of syntax

Like for PREDICATE:, GAME: and SINGLETONS:
db4
Björn Lindqvist 2015-10-29 00:44:08 +01:00
parent 705e2b8d4b
commit 4b4a5d24e9
1 changed files with 16 additions and 14 deletions

View File

@ -222,7 +222,7 @@ these lines in your .emacs:
"CONSULT:" "call-next-method" "CONSULT:" "call-next-method"
"EBNF:" ";EBNF" "ENUM:" "ERROR:" "EBNF:" ";EBNF" "ENUM:" "ERROR:"
"FOREIGN-ATOMIC-TYPE:" "FOREIGN-ENUM-TYPE:" "FOREIGN-RECORD-TYPE:" "FUNCTION-ALIAS:" "FOREIGN-ATOMIC-TYPE:" "FOREIGN-ENUM-TYPE:" "FOREIGN-RECORD-TYPE:" "FUNCTION-ALIAS:"
"GAME:" "GIR:" "GIR:"
"GLSL-SHADER:" "GLSL-PROGRAM:" "GLSL-SHADER:" "GLSL-PROGRAM:"
"HINTS:" "HINTS:"
"initial:" "INTERSECTION:" "IMPLEMENT-STRUCTS:" "initial:" "INTERSECTION:" "IMPLEMENT-STRUCTS:"
@ -230,7 +230,7 @@ these lines in your .emacs:
"METHOD:" "METHOD:"
"PRIVATE>" "PROTOCOL:" "PROVIDE:" "PRIVATE>" "PROTOCOL:" "PROVIDE:"
"read-only" "REQUIRE:" "REQUIRES:" "read-only" "REQUIRE:" "REQUIRES:"
"SINGLETONS:" "SLOT:" "SLOT:"
"SPECIALIZED-ARRAYS:" "STRING:" "SYNTAX:" "SPECIALIZED-ARRAYS:" "STRING:" "SYNTAX:"
"TYPED:" "TYPED::" "TYPED:" "TYPED::"
"UNIFORM-TUPLE:" "UNIFORM-TUPLE:"
@ -282,12 +282,14 @@ these lines in your .emacs:
(defconst factor-bad-string-regex (defconst factor-bad-string-regex
"\\_<\"[^>]\\([^\"\n]\\|\\\\\"\\)*\n") "\\_<\"[^>]\\([^\"\n]\\|\\\\\"\\)*\n")
(defconst factor-word-starters
'(":" "::" "GENERIC:" "GENERIC#" "DEFER:" "HOOK:"
"MACRO:" "MACRO::" "MATH:" "MEMO:" "MEMO::"
"POSTPONE:" "PRIMITIVE:" "SYNTAX:" "TYPED:" "TYPED::"))
(defconst factor-word-definition-regex (defconst factor-word-definition-regex
(concat (concat
(format "\\_<\\(\\(?:%s\\)?[:#]\\)" (format "\\_<\\(%s\\)" (regexp-opt factor-word-starters))
(regexp-opt
'(":" "GENERIC" "DEFER" "HOOK" "MACRO" "MATH" "MEMO" "MEMO:"
"POSTPONE" "PRIMITIVE" "SYNTAX" "TYPED" "TYPED:")))
ws+ symbol)) ws+ symbol))
;; [parsing-word] [vocab-word] ;; [parsing-word] [vocab-word]
@ -300,15 +302,15 @@ these lines in your .emacs:
;; [parsing-word] [symbol-word] ;; [parsing-word] [symbol-word]
(defconst factor-symbol-definition-regex (defconst factor-symbol-definition-regex
(syntax-and-1-symbol (syntax-and-1-symbol
'("&" "CONSTANT" "DESTRUCTOR" "FORGET" "HELP" "LIBRARY" '("&" "CONSTANT" "DESTRUCTOR" "FORGET" "GAME" "HELP" "LIBRARY"
"MAIN" "MAIN-WINDOW" "STRING" "SYMBOL" "VAR"))) "MAIN" "MAIN-WINDOW" "STRING" "SYMBOL" "VAR")))
;; [parsing-word] [symbol-word]* ; ;; [parsing-word] [symbol-word]* ;
(defconst factor-symbols-lines-regex (defconst factor-symbols-lines-regex
(concat (syntax-begin '("SYMBOLS")) ws+ symbols-to-semicolon)) (concat (syntax-begin '("SYMBOLS")) ws+ symbols-to-semicolon))
;; (defconst factor-int-constant-def-regex (defconst factor-types-lines-regex
;; (syntax-and-1-symbol '("ALIEN" "CHAR" "NAN"))) (concat (syntax-begin '("SINGLETONS")) ws+ symbols-to-semicolon))
(defconst factor-type-definition-regex (defconst factor-type-definition-regex
(syntax-and-1-symbol (syntax-and-1-symbol
@ -416,6 +418,9 @@ these lines in your .emacs:
symbol ws+ symbol ws+
"\\(=>\\)" ws+ symbols-to-semicolon)) "\\(=>\\)" ws+ symbols-to-semicolon))
(defconst factor-predicate-regex
(concat (syntax-begin '("PREDICATE")) ws+ symbol ws+ "\\(<\\)" ws+ symbol))
(defconst factor-group-name-to-face (defconst factor-group-name-to-face
#s(hash-table test equal data #s(hash-table test equal data
("C" 'factor-font-lock-comment ("C" 'factor-font-lock-comment
@ -460,6 +465,7 @@ these lines in your .emacs:
,(factor-syntax factor-word-definition-regex '("P" "W")) ,(factor-syntax factor-word-definition-regex '("P" "W"))
,(factor-syntax (syntax-and-2-symbols '("ALIAS")) '("P" "W" "W")) ,(factor-syntax (syntax-and-2-symbols '("ALIAS")) '("P" "W" "W"))
,(factor-syntax (syntax-and-1-symbol '("ALIEN" "CHAR" "NAN")) '("P" "CT")) ,(factor-syntax (syntax-and-1-symbol '("ALIEN" "CHAR" "NAN")) '("P" "CT"))
,(factor-syntax factor-types-lines-regex '("P" "T"))
(,factor-integer-regex . 'factor-font-lock-number) (,factor-integer-regex . 'factor-font-lock-number)
(,factor-float-regex . 'factor-font-lock-number) (,factor-float-regex . 'factor-font-lock-number)
(,factor-ratio-regex . 'factor-font-lock-ratio) (,factor-ratio-regex . 'factor-font-lock-ratio)
@ -496,11 +502,7 @@ these lines in your .emacs:
nil nil
(1 'factor-font-lock-symbol nil t) (1 'factor-font-lock-symbol nil t)
(2 'factor-font-lock-symbol nil t))) (2 'factor-font-lock-symbol nil t)))
;; Highlights predicates ,(factor-syntax factor-predicate-regex '("P" "T" "P" "T"))
(,(format "\\(PREDICATE\\):[ \n]%s[ \n]<[ \n]%s" symbol symbol)
(1 'factor-font-lock-parsing-word)
(2 'factor-font-lock-type-name)
(3 'factor-font-lock-type-name))
;; Highlights alien function definitions. Types in stack effect ;; Highlights alien function definitions. Types in stack effect
;; declarations are given a bold face. ;; declarations are given a bold face.
(,(format "\\(\\(?:GL-\\)?FUNCTION\\|CALLBACK\\):[ \n]+%s[ \n]+%s[ \n]+" symbol symbol) (,(format "\\(\\(?:GL-\\)?FUNCTION\\|CALLBACK\\):[ \n]+%s[ \n]+%s[ \n]+" symbol symbol)