FUEL: Better syntax highlighting.
							parent
							
								
									a889b9d2d0
								
							
						
					
					
						commit
						b149a01248
					
				| 
						 | 
				
			
			@ -54,6 +54,7 @@
 | 
			
		|||
 factor-font-lock font-lock factor-mode
 | 
			
		||||
 ((comment comment "comments")
 | 
			
		||||
  (constructor type  "constructors (<foo>)")
 | 
			
		||||
  (constant constant  "constants and literal values")
 | 
			
		||||
  (declaration keyword "declaration words")
 | 
			
		||||
  (parsing-word keyword  "parsing words")
 | 
			
		||||
  (setter-word function-name "setter words (>>foo)")
 | 
			
		||||
| 
						 | 
				
			
			@ -73,17 +74,21 @@
 | 
			
		|||
    (,fuel-syntax--brace-words-regex 1 'factor-font-lock-parsing-word)
 | 
			
		||||
    ("\\(P\\|SBUF\\)\"" 1 'factor-font-lock-parsing-word)
 | 
			
		||||
    (,fuel-syntax--stack-effect-regex . 'factor-font-lock-stack-effect)
 | 
			
		||||
    (,fuel-syntax--vocab-ref-regexp  2 'factor-font-lock-vocabulary-name)
 | 
			
		||||
    (,fuel-syntax--declaration-words-regex . 'factor-font-lock-declaration)
 | 
			
		||||
    (,fuel-syntax--word-definition-regex 2 'factor-font-lock-word)
 | 
			
		||||
    (,fuel-syntax--alias-definition-regex (1 'factor-font-lock-word)
 | 
			
		||||
                                          (2 'factor-font-lock-word))
 | 
			
		||||
    (,fuel-syntax--int-constant-def-regex 2 'factor-font-lock-constant)
 | 
			
		||||
    (,fuel-syntax--number-regex . 'factor-font-lock-constant)
 | 
			
		||||
    (,fuel-syntax--type-definition-regex 2 'factor-font-lock-type-name)
 | 
			
		||||
    (,fuel-syntax--method-definition-regex (1 'factor-font-lock-type-name)
 | 
			
		||||
                                           (2 'factor-font-lock-word))
 | 
			
		||||
    (,fuel-syntax--parent-type-regex 1 'factor-font-lock-type-name)
 | 
			
		||||
    (,fuel-syntax--parent-type-regex 2 'factor-font-lock-type-name)
 | 
			
		||||
    (,fuel-syntax--constructor-regex . 'factor-font-lock-constructor)
 | 
			
		||||
    (,fuel-syntax--setter-regex . 'factor-font-lock-setter-word)
 | 
			
		||||
    (,fuel-syntax--getter-regex . 'factor-font-lock-getter-word)
 | 
			
		||||
    (,fuel-syntax--symbol-definition-regex 2 'factor-font-lock-symbol)
 | 
			
		||||
    (,fuel-syntax--use-line-regex 1 'factor-font-lock-vocabulary-name))
 | 
			
		||||
    (,fuel-syntax--symbol-definition-regex 2 'factor-font-lock-symbol))
 | 
			
		||||
  "Font lock keywords definition for Factor mode.")
 | 
			
		||||
 | 
			
		||||
(defun fuel-font-lock--font-lock-setup (&optional keywords no-syntax)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,16 +44,24 @@
 | 
			
		|||
 | 
			
		||||
(defconst fuel-syntax--parsing-words
 | 
			
		||||
  '(":" "::" ";" "<<" "<PRIVATE" ">>"
 | 
			
		||||
    "B" "BIN:" "C:" "C-STRUCT:" "C-UNION:" "CHAR:"
 | 
			
		||||
    "DEFER:" "ERROR:" "EXCLUDE:" "FORGET:"
 | 
			
		||||
    "GENERIC#" "GENERIC:" "HEX:" "HOOK:"
 | 
			
		||||
    "IN:" "INSTANCE:" "INTERSECTION:"
 | 
			
		||||
    "ALIAS:"
 | 
			
		||||
    "B" "BIN:"
 | 
			
		||||
    "C:" "C-STRUCT:" "C-UNION:" "CHAR:" "CONSTANT:" "call-next-method"
 | 
			
		||||
    "DEFER:"
 | 
			
		||||
    "ERROR:" "EXCLUDE:"
 | 
			
		||||
    "f" "FORGET:" "FROM:"
 | 
			
		||||
    "GENERIC#" "GENERIC:"
 | 
			
		||||
    "HEX:" "HOOK:"
 | 
			
		||||
    "IN:" "initial:" "INSTANCE:" "INTERSECTION:"
 | 
			
		||||
    "M:" "MACRO:" "MACRO::" "MAIN:" "MATH:" "MEMO:" "MEMO:" "METHOD:" "MIXIN:"
 | 
			
		||||
    "OCT:" "POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROVIDE:"
 | 
			
		||||
    "REQUIRE:"  "REQUIRES:" "SINGLETON:" "SLOT:" "SYMBOL:" "SYMBOLS:"
 | 
			
		||||
    "OCT:"
 | 
			
		||||
    "POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROVIDE:"
 | 
			
		||||
    "QUALIFIED-WITH:" "QUALIFIED:"
 | 
			
		||||
    "read-only" "RENAME:" "REQUIRE:"  "REQUIRES:"
 | 
			
		||||
    "SINGLETON:" "SINGLETONS:" "SLOT:" "SYMBOL:" "SYMBOLS:"
 | 
			
		||||
    "TUPLE:" "t" "t?" "TYPEDEF:"
 | 
			
		||||
    "UNION:" "USE:" "USING:" "VARS:"
 | 
			
		||||
    "call-next-method" "delimiter" "f" "initial:" "read-only"))
 | 
			
		||||
    "UNION:" "USE:" "USING:"
 | 
			
		||||
    "VARS:"))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--bracers
 | 
			
		||||
  '("B" "BV" "C" "CS" "H" "T" "V" "W"))
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +73,7 @@
 | 
			
		|||
  (format "%s{" (regexp-opt fuel-syntax--bracers t)))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--declaration-words
 | 
			
		||||
  '("flushable" "foldable" "inline" "parsing" "recursive"))
 | 
			
		||||
  '("flushable" "foldable" "inline" "parsing" "recursive" "delimiter"))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--declaration-words-regex
 | 
			
		||||
  (regexp-opt fuel-syntax--declaration-words 'words))
 | 
			
		||||
| 
						 | 
				
			
			@ -76,13 +84,29 @@
 | 
			
		|||
(defconst fuel-syntax--method-definition-regex
 | 
			
		||||
  "^M: +\\([^ ]+\\) +\\([^ ]+\\)")
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--number-regex
 | 
			
		||||
  "\\(\\+\\|-\\)?\\([0-9]+\\.?[0-9]*\\|\\.[0-9]+\\)\\([eE]\\(\\+\\|-\\)?[0-9]+\\)?")
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--word-definition-regex
 | 
			
		||||
  (fuel-syntax--second-word-regex '(":" "::" "GENERIC:")))
 | 
			
		||||
  (fuel-syntax--second-word-regex
 | 
			
		||||
   '(":" "::" "GENERIC:" "DEFER:" "HOOK:" "MAIN:" "MATH:" "POSTPONE:"
 | 
			
		||||
     "SYMBOL:" "RENAME:")))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--alias-definition-regex
 | 
			
		||||
  "^ALIAS: +\\(\\_<.+?\\_>\\) +\\(\\_<.+?\\_>\\)")
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--vocab-ref-regexp
 | 
			
		||||
  (fuel-syntax--second-word-regex
 | 
			
		||||
   '("IN:" "USE:" "FROM:" "EXCLUDE:" "QUALIFIED:" "QUALIFIED-WITH:")))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--int-constant-def-regex
 | 
			
		||||
  (fuel-syntax--second-word-regex '("CHAR:" "BIN:" "HEX:" "OCT:")))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--type-definition-regex
 | 
			
		||||
  (fuel-syntax--second-word-regex '("TUPLE:" "SINGLETON:")))
 | 
			
		||||
  (fuel-syntax--second-word-regex '("MIXIN:" "TUPLE:" "SINGLETON:" "UNION:")))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--parent-type-regex "^TUPLE: +[^ ]+ +< +\\([^ ]+\\)")
 | 
			
		||||
(defconst fuel-syntax--parent-type-regex
 | 
			
		||||
  "^\\(TUPLE\\|PREDICTE\\): +[^ ]+ +< +\\([^ ]+\\)")
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--constructor-regex "<[^ >]+>")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -102,21 +126,37 @@
 | 
			
		|||
 | 
			
		||||
(defconst fuel-syntax--sub-vocab-regex "^<\\([^ \n]+\\) *$")
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--definition-starters-regex
 | 
			
		||||
  (regexp-opt
 | 
			
		||||
   '("VARS" "TUPLE" "MACRO" "MACRO:" "M" "MEMO" "MEMO:" "METHOD" ":" "")))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--definition-start-regex
 | 
			
		||||
  (format "^\\(%s:\\) " fuel-syntax--definition-starters-regex))
 | 
			
		||||
  (format "^\\(%s:\\) " (regexp-opt '("" ":"
 | 
			
		||||
                                      "FROM"
 | 
			
		||||
                                      "INTERSECTION:"
 | 
			
		||||
                                      "MACRO" "MACRO:" "M" "MEMO" "MEMO:" "METHOD"
 | 
			
		||||
                                      "PREDICATE" "PRIMITIVE"
 | 
			
		||||
                                      "SINGLETONS" "SYMBOLS"
 | 
			
		||||
                                      "TUPLE"
 | 
			
		||||
                                      "UNION"
 | 
			
		||||
                                      "VARS"))))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--definition-end-regex
 | 
			
		||||
  (format "\\(\\(^\\| +\\);\\( *%s\\)*\\($\\| +\\)\\)"
 | 
			
		||||
          fuel-syntax--declaration-words-regex))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--single-liner-regex
 | 
			
		||||
  (format "^%s" (regexp-opt '("C:" "DEFER:" "GENERIC:" "IN:"
 | 
			
		||||
                              "PRIVATE>" "<PRIVATE"
 | 
			
		||||
                              "SINGLETON:" "SYMBOL:" "USE:" "VAR:"))))
 | 
			
		||||
  (format "^%s" (regexp-opt '("ALIAS:"
 | 
			
		||||
                              "CONSTANT:" "C:"
 | 
			
		||||
                              "DEFER:"
 | 
			
		||||
                              "FORGET:"
 | 
			
		||||
                              "GENERIC:" "GENERIC#"
 | 
			
		||||
                              "HEX:" "HOOK:"
 | 
			
		||||
                              "IN:" "INSTANCE:"
 | 
			
		||||
                              "MAIN:" "MATH:" "MIXIN:"
 | 
			
		||||
                              "OCT:"
 | 
			
		||||
                              "POSTPONE:" "PRIVATE>" "<PRIVATE"
 | 
			
		||||
                              "QUALIFIED-WITH:" "QUALIFIED:"
 | 
			
		||||
                              "RENAME:"
 | 
			
		||||
                              "SINGLETON:" "SLOT:" "SYMBOL:"
 | 
			
		||||
                              "USE:"
 | 
			
		||||
                              "VAR:"))))
 | 
			
		||||
 | 
			
		||||
(defconst fuel-syntax--begin-of-def-regex
 | 
			
		||||
  (format "^USING: \\|\\(%s\\)\\|\\(%s .*\\)"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue