]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: improved highlighting of alias defs
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 5 Aug 2015 00:28:07 +0000 (02:28 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 6 Aug 2015 16:21:33 +0000 (09:21 -0700)
misc/fuel/factor-mode.el

index cd497297e5b678e2db78ca48ec480539bfe3ec2a..390f36507ff2b93645da5e2662aa8485c178e433 100644 (file)
@@ -194,9 +194,12 @@ these lines in your .emacs:
 (defun syntax-begin (content)
   (one-symbol (concat (regexp-opt content) ":")))
 
-(defsubst factor-second-word-regex (prefixes)
+(defun syntax-and-1-symbol (prefixes)
   (concat (syntax-begin prefixes) ws+ symbol))
 
+(defun syntax-and-2-symbols (prefixes)
+  (concat (syntax-begin prefixes) ws+ symbol ws+ symbol))
+
 ;; Used to font-lock stack effect declarations with may be nested.
 (defun factor-match-brackets (limit)
   (let ((start (point)))
@@ -213,7 +216,7 @@ these lines in your .emacs:
 ;; Excludes parsing words that are handled by other regexps
 (defconst factor-parsing-words
   '(":" "::" ";" ":>" "&:" "<<" "<PRIVATE" ">>"
-    "ABOUT:" "AFTER:" "ALIAS:" "ALIEN:" "ARTICLE:"
+    "ABOUT:" "AFTER:" "ALIEN:" "ARTICLE:"
     "B" "BEFORE:"
     "C-GLOBAL:" "C-TYPE:" "CHAR:" "COLOR:" "COM-INTERFACE:"
     "CONSULT:" "call-next-method"
@@ -296,12 +299,9 @@ these lines in your .emacs:
              "PRIMITIVE" "SYNTAX" "TYPED" "TYPED:"))
           "\\(\\sw\\|\\s_\\|\\s(\\|\\s)\\)+"))
 
-(defconst factor-alias-definition-regex
-  "^ALIAS: +\\(\\_<.+?\\_>\\) +\\(\\_<.+?\\_>\\)")
-
 ;; [parsing-word] [vocab-word]
 (defconst factor-vocab-ref-regex
-  (factor-second-word-regex
+  (syntax-and-1-symbol
    '("IN" "USE" "EXCLUDE" "QUALIFIED" "QUALIFIED-WITH")))
 
 (defconst factor-using-lines-regex
@@ -309,7 +309,7 @@ these lines in your .emacs:
 
 ;; [parsing-word] [symbol-word]
 (defconst factor-symbol-definition-regex
-  (factor-second-word-regex
+  (syntax-and-1-symbol
    '("&" "CONSTANT" "DESTRUCTOR" "FORGET" "HELP" "LIBRARY"
      "MAIN" "STRING" "SYMBOL" "VAR")))
 
@@ -318,10 +318,10 @@ these lines in your .emacs:
   (concat (syntax-begin '("SYMBOLS")) ws+ symbols-to-semicolon))
 
 (defconst factor-int-constant-def-regex
-  (factor-second-word-regex '("ALIEN" "CHAR" "NAN")))
+  (syntax-and-1-symbol '("ALIEN" "CHAR" "NAN")))
 
 (defconst factor-type-definition-regex
-  (factor-second-word-regex
+  (syntax-and-1-symbol
    '("C-STRUCT" "C-UNION" "COM-INTERFACE" "MIXIN" "SINGLETON"
      "SPECIALIZED-ARRAY" "STRUCT" "UNION-STRUCT")))
 
@@ -416,10 +416,13 @@ these lines in your .emacs:
           "M[^:]*: [^ ]+ [^ ]+"))
 
 (defconst factor-constructor-decl-regex
-  (concat (syntax-begin '("C")) ws+ symbol ws+ symbol))
+  (syntax-and-2-symbols '("C")))
 
 (defconst factor-typedef-regex
-  (concat (syntax-begin '("TYPEDEF" "INSTANCE")) ws+ symbol ws+ symbol))
+  (syntax-and-2-symbols '("TYPEDEF" "INSTANCE")))
+
+(defconst factor-alias-regex
+  (syntax-and-2-symbols '("ALIAS")))
 
 (defconst factor-c-global-regex
   (format "\\_<C-GLOBAL: +%s +%s\\( .*\\)?$" symbol symbol))
@@ -428,10 +431,7 @@ these lines in your .emacs:
   (format "\\_<C-TYPE: +%s\\( .*\\)?$" symbol))
 
 (defconst factor-rename-regex
-  (concat (syntax-begin '("RENAME")) ws+
-          symbol ws+
-          symbol ws+
-          "\\(=>\\)" ws+ symbol))
+  (concat (syntax-and-2-symbols '("RENAME")) ws+ "\\(=>\\)" ws+ symbol))
 
 (defconst factor-from/exclude-regex
   (concat (syntax-begin '("FROM" "EXCLUDE")) ws+
@@ -481,8 +481,9 @@ these lines in your .emacs:
                           (4 'factor-font-lock-invalid-syntax nil t))
     (,factor-declaration-words-regex . 'factor-font-lock-comment)
     (,factor-word-definition-regex 2 'factor-font-lock-word)
-    (,factor-alias-definition-regex (1 'factor-font-lock-word)
-                                    (2 'factor-font-lock-word))
+    (,factor-alias-regex (1 'factor-font-lock-parsing-word)
+                         (2 'factor-font-lock-word)
+                         (3 'factor-font-lock-word))
     (,factor-int-constant-def-regex 2 'factor-font-lock-constant)
     (,factor-integer-regex . 'factor-font-lock-number)
     (,factor-float-regex . 'factor-font-lock-number)