Merge branch 'emacs' of http://git.hacks-galore.org/jao/factor
commit
5130573d56
|
@ -72,11 +72,21 @@
|
|||
|
||||
;;; Font lock:
|
||||
|
||||
(defun fuel-font-lock--syntactic-face (state)
|
||||
(cond ((nth 3 state) 'factor-font-lock-string)
|
||||
((char-equal (char-after (nth 8 state)) ?\ )
|
||||
(save-excursion
|
||||
(goto-char (nth 8 state))
|
||||
(beginning-of-line)
|
||||
(cond ((looking-at "USING: ") 'factor-font-lock-vocabulary-name)
|
||||
((looking-at "\\(TUPLE\\|SYMBOLS\\|VARS\\): ")
|
||||
'factor-font-lock-symbol)
|
||||
(t 'default))))
|
||||
(t 'factor-font-lock-comment)))
|
||||
|
||||
(defconst fuel-font-lock--font-lock-keywords
|
||||
`((,fuel-syntax--stack-effect-regex . 'factor-font-lock-stack-effect)
|
||||
(,fuel-syntax--parsing-words-regex . 'factor-font-lock-parsing-word)
|
||||
(,fuel-syntax--brace-words-regex 1 'factor-font-lock-parsing-word)
|
||||
("\\(P\\|SBUF\\)\"" 1 'factor-font-lock-parsing-word)
|
||||
(,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)
|
||||
|
@ -89,24 +99,26 @@
|
|||
(,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 2 'factor-font-lock-type-name)
|
||||
(,fuel-syntax--tuple-decl-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--bad-string-regex . 'factor-font-lock-invalid-syntax)))
|
||||
(,fuel-syntax--bad-string-regex . 'factor-font-lock-invalid-syntax)
|
||||
("\\(P\\|SBUF\\)\"" 1 'factor-font-lock-parsing-word)
|
||||
(,fuel-syntax--parsing-words-regex . 'factor-font-lock-parsing-word)))
|
||||
|
||||
(defun fuel-font-lock--font-lock-setup (&optional keywords no-syntax)
|
||||
(set (make-local-variable 'comment-start) "! ")
|
||||
(set (make-local-variable 'parse-sexp-lookup-properties) t)
|
||||
(set (make-local-variable 'font-lock-comment-face) 'factor-font-lock-comment)
|
||||
(set (make-local-variable 'font-lock-string-face) 'factor-font-lock-string)
|
||||
(set (make-local-variable 'font-lock-defaults)
|
||||
`(,(or keywords 'fuel-font-lock--font-lock-keywords)
|
||||
nil nil nil nil
|
||||
,@(if no-syntax nil
|
||||
(list (cons 'font-lock-syntactic-keywords
|
||||
fuel-syntax--syntactic-keywords))))))
|
||||
fuel-syntax--syntactic-keywords)
|
||||
(cons 'font-lock-syntactic-face-function
|
||||
'fuel-font-lock--syntactic-face))))))
|
||||
|
||||
|
||||
;;; Fontify strings as Factor code:
|
||||
|
|
|
@ -68,7 +68,8 @@ buffer."
|
|||
(setq fuel-listener--buffer (current-buffer)))))
|
||||
|
||||
(defun fuel-listener--start-process ()
|
||||
(let ((factor (expand-file-name fuel-listener-factor-binary))
|
||||
(let ((factor (locate-file (expand-file-name fuel-listener-factor-binary)
|
||||
'("") exec-suffixes))
|
||||
(image (expand-file-name fuel-listener-factor-image))
|
||||
(comint-redirect-perform-sanity-check nil))
|
||||
(unless (file-executable-p factor)
|
||||
|
@ -132,8 +133,7 @@ buffer."
|
|||
|
||||
(defun fuel-listener--setup-completion ()
|
||||
(setq fuel-syntax--current-vocab-function 'fuel-listener--current-vocab)
|
||||
(setq fuel-syntax--usings-function 'fuel-listener--usings)
|
||||
(set-syntax-table fuel-syntax--syntax-table))
|
||||
(setq fuel-syntax--usings-function 'fuel-listener--usings))
|
||||
|
||||
|
||||
;;; Stack mode support
|
||||
|
@ -160,7 +160,6 @@ buffer."
|
|||
(set (make-local-variable 'comint-prompt-regexp) fuel-con--prompt-regex)
|
||||
(set (make-local-variable 'comint-use-prompt-regexp) t)
|
||||
(set (make-local-variable 'comint-prompt-read-only) t)
|
||||
(set-syntax-table fuel-syntax--syntax-table)
|
||||
(fuel-listener--setup-completion)
|
||||
(fuel-listener--setup-stack-mode))
|
||||
|
||||
|
|
|
@ -87,14 +87,22 @@
|
|||
(defconst fuel-syntax--integer-regex
|
||||
"\\_<-?[0-9]+\\_>")
|
||||
|
||||
(defconst fuel-syntax--ratio-regex
|
||||
"\\_<-?\\([0-9]+\\+\\)?[0-9]+/-?[0-9]+\\_>")
|
||||
(defconst fuel-syntax--raw-float-regex
|
||||
"[0-9]*\\.[0-9]*\\([eE][+-]?[0-9]+\\)?")
|
||||
|
||||
(defconst fuel-syntax--float-regex
|
||||
"\\_<-?[0-9]+\\.[0-9]*\\([eE][+-]?[0-9]+\\)?\\_>")
|
||||
(format "\\_<-?%s\\_>" fuel-syntax--raw-float-regex))
|
||||
|
||||
(defconst fuel-syntax--number-regex
|
||||
(format "\\([0-9]+\\|%s\\)" fuel-syntax--raw-float-regex))
|
||||
|
||||
(defconst fuel-syntax--ratio-regex
|
||||
(format "\\_<[+-]?%s/-?%s\\_>"
|
||||
fuel-syntax--number-regex
|
||||
fuel-syntax--number-regex))
|
||||
|
||||
(defconst fuel-syntax--bad-string-regex
|
||||
"\"\\([^\"]\\|\\\\\"\\)*\n")
|
||||
"\\_<\"[^>]\\([^\"\n]\\|\\\\\"\\)*\n")
|
||||
|
||||
(defconst fuel-syntax--word-definition-regex
|
||||
(fuel-syntax--second-word-regex
|
||||
|
@ -114,8 +122,8 @@
|
|||
(defconst fuel-syntax--type-definition-regex
|
||||
(fuel-syntax--second-word-regex '("MIXIN:" "TUPLE:" "SINGLETON:" "UNION:")))
|
||||
|
||||
(defconst fuel-syntax--parent-type-regex
|
||||
"^\\(TUPLE\\|PREDICTE\\): +[^ ]+ +< +\\([^ ]+\\)")
|
||||
(defconst fuel-syntax--tuple-decl-regex
|
||||
"^TUPLE: +\\([^ \n]+\\) +< +\\([^ \n]+\\)\\_>")
|
||||
|
||||
(defconst fuel-syntax--constructor-regex "<[^ >]+>")
|
||||
|
||||
|
@ -125,7 +133,8 @@
|
|||
(defconst fuel-syntax--symbol-definition-regex
|
||||
(fuel-syntax--second-word-regex '("SYMBOL:" "VAR:")))
|
||||
|
||||
(defconst fuel-syntax--stack-effect-regex " ( .* )")
|
||||
(defconst fuel-syntax--stack-effect-regex
|
||||
"\\( ( .* )\\)\\|\\( (( .* ))\\)")
|
||||
|
||||
(defconst fuel-syntax--using-lines-regex "^USING: +\\([^;]+\\);")
|
||||
|
||||
|
@ -220,13 +229,20 @@
|
|||
table))
|
||||
|
||||
(defconst fuel-syntax--syntactic-keywords
|
||||
`(;; Comments:
|
||||
`(;; CHARs:
|
||||
("CHAR: \\(.\\)\\( \\|$\\)" (1 "w"))
|
||||
;; Comments:
|
||||
("\\_<\\(#?!\\) .*\\(\n\\|$\\)" (1 "<") (2 ">"))
|
||||
("\\_<\\(#?!\\)\\(\n\\|$\\)" (1 "<") (2 ">"))
|
||||
;; CHARs:
|
||||
("CHAR: \\(.\\)\\( \\|$\\)" (1 "w"))
|
||||
;; Strings
|
||||
("\\(\"\\)\\([^\n\r\f\\\"]\\|\\\\\"?\\)*\\(\"\\)" (1 "\"") (3 "\""))
|
||||
("\\_<\\(\"\\)\\([^\n\r\f\\\"]\\|\\\\\"\\)*\\(\"\\)\\_>" (1 "\"") (3 "\""))
|
||||
("\\_<<\\(\"\\)\\_>" (1 "\""))
|
||||
("\\_<\\(\"\\)>\\_>" (1 "\""))
|
||||
;; Multiline constructs
|
||||
("\\_<USING:\\( \\)" (1 "<b"))
|
||||
("\\_<TUPLE: +\\w+? +< +\\w+? *\\( \\)" (1 "<b"))
|
||||
("\\_<\\(TUPLE\\|SYMBOLS\\|VARS\\): +\\w+? *\\( \\)\\([^<]\\|\\_>\\)" (2 "<b"))
|
||||
("\\(\n\\| \\);\\_>" (1 ">b"))
|
||||
;; Let and lambda:
|
||||
("\\_<\\(!(\\) .* \\()\\)" (1 "<") (2 ">"))
|
||||
("\\(\\[\\)\\(let\\|wlet\\|let\\*\\)\\( \\|$\\)" (1 "(]"))
|
||||
|
|
Loading…
Reference in New Issue