[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[NODEF][COMMITTED] poke-mode: few improvements in font-lock
From: |
Jose E. Marchesi |
Subject: |
[NODEF][COMMITTED] poke-mode: few improvements in font-lock |
Date: |
Sun, 08 Nov 2020 00:13:23 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
I just pushed a bunch of quick new rules to the font-lock support in
poke-mode.
Salud!
commit c012d2e1a7a0de24f023b0d5a09a091e6ff315de (HEAD -> nodef,
origin/jemarch/nodef)
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Date: Sun Nov 8 00:07:31 2020 +0100
poke-mode: few improvements in font-lock
2020-11-07 Jose E. Marchesi <jemarch@gnu.org>
* etc/poke-mode.el (poke-builtin-types): Remove "offset".
(poke-type-constructor-integral): New face.
(poke-type-constructor-offset): Likewise.
(poke-declaration-name): Likewise.
(poke-font-lock-keywords): Font-lock string literals, integral
constructors, offset constructors and the names of declared
entities.
diff --git a/ChangeLog b/ChangeLog
index 43b2d445..9e3361f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-11-07 Jose E. Marchesi <jemarch@gnu.org>
+
+ * etc/poke-mode.el (poke-builtin-types): Remove "offset".
+ (poke-type-constructor-integral): New face.
+ (poke-type-constructor-offset): Likewise.
+ (poke-declaration-name): Likewise.
+ (poke-font-lock-keywords): Font-lock string literals, integral
+ constructors, offset constructors and the names of declared
+ entities.
+
2020-11-07 Jose E. Marchesi <jemarch@gnu.org>
* etc/poke-mode.el (poke-smie-grammar): Indent chained
diff --git a/etc/poke-mode.el b/etc/poke-mode.el
index 7a77be4f..0b4c561e 100644
--- a/etc/poke-mode.el
+++ b/etc/poke-mode.el
@@ -53,6 +53,14 @@
'((t (:inherit font-lock-type-face)))
"Face used to highlight builtin types.")
+(defface poke-type-constructor-integral
+ '((t (:inherit font-lock-type-face)))
+ "Face used to highlight type constructors.")
+
+(defface poke-type-constructor-offset
+ '((t (:inherit poke-unit)))
+ "Face used to highlight offset type constructors")
+
(defface poke-function
'((t (:inherit font-lock-function-name-face)))
"Face used to highlight builtin functions.")
@@ -65,6 +73,10 @@
'((t (:inherit error)))
"Face used to highlight builtin exceptions.")
+(defface poke-declaration-name
+ '((t (:inherit font-lock-variable-name-face)))
+ "Face used to highlight declaration names.")
+
;; from libpoke/pkl-lex.l
(defconst poke-keywords
'("pinned" "struct" "union" "else" "while" "until" "for" "in" "where" "if"
@@ -76,7 +88,7 @@
;; from libpoke/pkl-lex.l
;; from perl -nE 'say qq{"$1"} if /^type (\S+)/' libpoke/*.pk
(defconst poke-builtin-types
- '("string" "void" "int" "uint" "offset"
+ '("string" "void" "int" "uint"
"Exception"
"bit" "nibble" "byte" "char"
"ushort" "short"
@@ -168,12 +180,36 @@
(: "\\" (repeat 1 3 (any "01234567"))))
"'")
0 'font-lock-string-face)
+ ;; string
+ `("\"[^\"]*\"" 0 'font-lock-string-face)
+ ;; Names of declared entities
+ `(,(rx (regexp (regexp-opt '("type" "unit" "fun" "var" "method")))
+ (+ space)
+ (group (any "A-Z" "a-z" "_") (* (any "A-Z" "a-z" "_" "0-9")))
+ (+ space)
+ "=")
+ 1 'poke-declaration-name)
;; attributes
`(,(rx "'" (group (any "A-Z" "a-z" "_") (* (any "A-Z" "a-z" "0-9" "_"))))
0 'poke-attribute)
;; keywords
`(,(rx symbol-start (regexp (regexp-opt poke-keywords)) symbol-end)
0 'font-lock-keyword-face)
+ ;; offset type constructors
+ `(,(rx "offset<"
+ (* space)
+ (+ (not ","))
+ (* space)
+ ","
+ (* space)
+ (+ (any "A-Z" "a-z" "_" "0-9"))
+ (* space)
+ ">")
+ 0 'poke-type-constructor-offset)
+ ;; integral type constructors
+ `(,(rx (regexp (regexp-opt '("int" "uint"))) "<"
+ (* space) (+ (any "0-9")) (* space) ">")
+ (0 'poke-type-constructor-integral t))
;; builtin types
`(,(rx symbol-start (regexp (regexp-opt poke-builtin-types)) symbol-end)
0 'poke-type)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [NODEF][COMMITTED] poke-mode: few improvements in font-lock,
Jose E. Marchesi <=