emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/raku-mode 730155c851 103/253: Apply prefix syntax property


From: ELPA Syncer
Subject: [nongnu] elpa/raku-mode 730155c851 103/253: Apply prefix syntax property to sigils and twigils
Date: Sat, 29 Jan 2022 08:28:46 -0500 (EST)

branch: elpa/raku-mode
commit 730155c85112a728ca9cdb481ff4749bf65b5a22
Author: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Commit: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>

    Apply prefix syntax property to sigils and twigils
---
 perl6-font-lock.el | 256 +++++++++++++++++++++++++++--------------------------
 1 file changed, 132 insertions(+), 124 deletions(-)

diff --git a/perl6-font-lock.el b/perl6-font-lock.el
index 51a22384dc..86fe5d9679 100644
--- a/perl6-font-lock.el
+++ b/perl6-font-lock.el
@@ -114,123 +114,132 @@
     (let ((body (cdr form)))
       (rx-to-string `(and symbol-start ,@body symbol-end) 'no-group)))
 
-  (defconst perl6-rx-constituents
-    `((symbol perl6-rx-symbol 0 nil)
-      (routine
-       . ,(rx (or "macro" "sub" "submethod" "method" "multi" "proto" "only"
-                  "category")))
-      (module
-       . ,(rx (or "module" "class" "role" "package" "enum" "grammar" "slang"
-                  "subset")))
-      (rule . ,(rx (or "regex" "rule" "token")))
-      (include . ,(rx (or "use" "require")))
-      (conditional . ,(rx (or "if" "else" "elsif" "unless")))
-      (scope . ,(rx (or "let" "my" "our" "state" "temp" "has" "constant")))
-      (loop . ,(rx (or "for" "loop" "repeat" "while" "until" "gather" 
"given")))
-      (flow-control
-       . ,(rx (or "take" "do" "when" "next" "last" "redo" "return" "contend"
-                  "maybe" "defer" "start" "default" "exit" "make" "continue"
-                  "break" "goto" "leave" "async" "lift")))
-      (phaser
-       . ,(rx (or "BEGIN" "CHECK" "INIT" "START" "FIRST" "ENTER" "LEAVE" "KEEP"
-                  "UNDO" "NEXT" "LAST" "PRE" "POST" "END" "CATCH" "CONTROL"
-                  "TEMP")))
-      (exception . ,(rx (or "die" "fail" "try" "warn")))
-      (pragma . ,(rx (or "oo" "fatal")))
-      (type-constraint
-       . ,(rx (or "does" "as" "but" "trusts" "of" "returns" "handles" "where"
-                  "augment" "supersede")))
-      (type-property
-       . ,(rx (or "signature" "context" "also" "shape" "prec" "irs" "ofs" "ors"
-                  "export" "deep" "binary" "unary" "reparsed" "rw" "parsed"
-                  "cached" "readonly" "defequiv" "will" "ref" "copy" "inline"
-                  "tighter" "looser" "equiv" "assoc" "required")))
-      (operator-word
-       . ,(rx (or "div" "xx" "x" "mod" "also" "leg" "cmp" "before" "after" "eq"
-                  "ne" "le" "lt" "not" "gt" "eqv" "ff" "fff" "and" "andthen"
-                  "or" "xor" "orelse" "extra" "lcm" "gcd")))
-      (operator-char . ,(rx (any "-:+/*~?|=^!%&,<>».;\\∈∉∋∌∩∪≼≽⊂⊃⊄⊅⊆⊇⊈⊉⊍⊎⊖∅")))
-      (set-operator
-       . ,(rx (opt "R")
-              "\("
-              (or (char "-^.+|&")
-                  (and (char "<>") (opt (char "=+")))
-                  "cont"
-                  "elem")
-              "\)"))
-      (rsxz-operator
-       . ,(rx
-           symbol-start
-           (any "RSXZ")
-           (or (or (and (or "div" "mod" "gcd" "lcm" "xx" "x" "does" "but" "cmp"
-                            "leg" "eq" "ne" "gt" "ge" "lt" "le" "before" 
"after"
-                            "eqv" "min" "max" "not" "so" "andthen" "and" "or"
-                            "orelse")
-                        symbol-end)
-                   (any ".,")
-                   (1+ (regex "[^:\[.,[:space:][:alnum:]]")))
-               symbol-end)))
-      (reduce-operator
-       . ,(rx (0+ (any "RSXZ\["))
-              (opt (any "RSXZ&"))
-              (1+ "\[")
-              (opt "\(")
-              (or (and (regex "[^[:digit:]@%$]")
-                       (0+ (regex "[^\[\{\('\"[:space:]]")))
-                  (and (any "@%$")
-                       (regex "[^.?^=_[:alpha:]]\[\{\('\"[:space:]]")
-                       (0+ (regex "[^\[\{\('\"[:space:]]"))))
-              (opt "\)")
-              (1+ "\]")))
-      (low-type
-       . ,(rx (or "int" "int1" "int2" "int4" "int8" "int16" "int32" "int64"
-                  "rat" "rat1" "rat2" "rat4" "rat8" "rat16" "rat32" "rat64"
-                  "buf" "buf1" "buf2" "buf4" "buf8" "buf16" "buf32" "buf64"
-                  "uint" "uint1" "uint2" "uint4" "uint8" "uint16" "uint32"
-                  "uint64" "utf8" "utf16" "utf32" "bit" "bool" "bag" "set"
-                  "mix" "num" "complex")))
-      (high-type
-       . ,(rx (or "Object" "Any" "Junction" "Whatever" "Capture" "Match"
-                  "Signature" "Proxy" "Matcher" "Package" "Module" "Class"
-                  "Grammar" "Scalar" "Array" "Hash" "KeyHash" "KeySet" "KeyBag"
-                  "Pair" "List" "Seq" "Range" "Set" "Bag" "Mapping" "Void"
-                  "Undef" "Failure" "Exception" "Code" "Block" "Routine" "Sub"
-                  "Macro" "Method" "Submethod" "Regex" "Str" "Blob" "Char"
-                  "Byte" "Parcel" "Codepoint" "Grapheme" "StrPos" "StrLen"
-                  "Version" "Num" "Complex" "Bit" "True" "False" "Order" "Same"
-                  "Less" "More" "Increasing" "Decreasing" "Ordered" "Callable"
-                  "AnyChar" "Positional" "Associative" "Ordering" 
"KeyExtractor"
-                  "Comparator" "OrderingPair" "IO" "KitchenSink" "Role" "Int"
-                  "Rat" "Buf" "UInt" "Abstraction" "Numeric" "Real" "Nil" 
"Mu")))
-      (identifier . ,(rx (regex "[_[:alpha:]]")
-                         (0+ (regex "[_[:alnum:]]"))
-                         (0+ (any "-'")
-                             (regex "[_[:alpha:]]") (0+ (regex 
"[_[:alnum:]]")))))
-      (version . ,(rx "v" (1+ digit) (0+ "." (or "*" (1+ digit))) (opt "+")))
-      (number
-       . ,(rx
-           (group-n 1
-             (opt (1+ digit) (opt "_" (1+ digit)))
-             (opt ".")
-             (1+ digit))
-           (opt (group-n 2 (any "Ee"))
-                (group-n 3 (opt "-") (1+ digit) (opt "_" (1+ digit))))
-           (opt (group-n 4 "i"))))
-      (base-number
-       . ,(rx symbol-start
-              (group-n 1 "0")
-              (or (and
-                   (group-n 2 "o")
-                   (group-n 3 (any "0-7") (0+ (any "0-7_"))))
-                  (and
-                   (group-n 2 "b")
-                   (group-n 3 (any "0-1") (0+ (any "0-1_"))))
-                  (and
-                   (group-n 2 "x")
-                   (group-n 3 (regex "[[:xdigit:]]") (0+ (regex 
"[[:xdigit:]_]"))))
-                  (and
-                   (group-n 2 "d")
-                   (group-n 3 (regex "[[:digit:]]") (0+ (regex 
"[[:digit:]_]")))))))))
+  (let ((rx-identifier (rx (regex "[_[:alpha:]]")
+                           (0+ (regex "[_[:alnum:]]"))
+                           (0+ (any "-'")
+                               (regex "[_[:alpha:]]") (0+ (regex 
"[_[:alnum:]]"))))))
+    (defconst perl6-rx-constituents
+      `((symbol perl6-rx-symbol 0 nil)
+        (identifier . ,rx-identifier)
+        (variable
+         . ,(rx-to-string
+             `(and (group (1+ (char "@$%&")))
+                   (group (opt (char ".^*?=!~:")))
+                   (group (opt (or (and "::" (0+ (regex ,rx-identifier) "::"))
+                                   (1+ (regex ,rx-identifier) "::"))))
+                   (group (or (or digit (char "/!¢"))
+                              (and (regex ,rx-identifier) symbol-end))))))
+        (routine
+         . ,(rx (or "macro" "sub" "submethod" "method" "multi" "proto" "only"
+                    "category")))
+        (module
+         . ,(rx (or "module" "class" "role" "package" "enum" "grammar" "slang"
+                    "subset")))
+        (rule . ,(rx (or "regex" "rule" "token")))
+        (include . ,(rx (or "use" "require")))
+        (conditional . ,(rx (or "if" "else" "elsif" "unless")))
+        (scope . ,(rx (or "let" "my" "our" "state" "temp" "has" "constant")))
+        (loop . ,(rx (or "for" "loop" "repeat" "while" "until" "gather" 
"given")))
+        (flow-control
+         . ,(rx (or "take" "do" "when" "next" "last" "redo" "return" "contend"
+                    "maybe" "defer" "start" "default" "exit" "make" "continue"
+                    "break" "goto" "leave" "async" "lift")))
+        (phaser
+         . ,(rx (or "BEGIN" "CHECK" "INIT" "START" "FIRST" "ENTER" "LEAVE" 
"KEEP"
+                    "UNDO" "NEXT" "LAST" "PRE" "POST" "END" "CATCH" "CONTROL"
+                    "TEMP")))
+        (exception . ,(rx (or "die" "fail" "try" "warn")))
+        (pragma . ,(rx (or "oo" "fatal")))
+        (type-constraint
+         . ,(rx (or "does" "as" "but" "trusts" "of" "returns" "handles" "where"
+                    "augment" "supersede")))
+        (type-property
+         . ,(rx (or "signature" "context" "also" "shape" "prec" "irs" "ofs" 
"ors"
+                    "export" "deep" "binary" "unary" "reparsed" "rw" "parsed"
+                    "cached" "readonly" "defequiv" "will" "ref" "copy" "inline"
+                    "tighter" "looser" "equiv" "assoc" "required")))
+        (operator-word
+         . ,(rx (or "div" "xx" "x" "mod" "also" "leg" "cmp" "before" "after" 
"eq"
+                    "ne" "le" "lt" "not" "gt" "eqv" "ff" "fff" "and" "andthen"
+                    "or" "xor" "orelse" "extra" "lcm" "gcd")))
+        (operator-char . ,(rx (any 
"-:+/*~?|=^!%&,<>».;\\∈∉∋∌∩∪≼≽⊂⊃⊄⊅⊆⊇⊈⊉⊍⊎⊖∅")))
+        (set-operator
+         . ,(rx (opt "R")
+                "\("
+                (or (char "-^.+|&")
+                    (and (char "<>") (opt (char "=+")))
+                    "cont"
+                    "elem")
+                "\)"))
+        (rsxz-operator
+         . ,(rx
+             symbol-start
+             (any "RSXZ")
+             (or (or (and (or "div" "mod" "gcd" "lcm" "xx" "x" "does" "but" 
"cmp"
+                              "leg" "eq" "ne" "gt" "ge" "lt" "le" "before" 
"after"
+                              "eqv" "min" "max" "not" "so" "andthen" "and" "or"
+                              "orelse")
+                          symbol-end)
+                     (any ".,")
+                     (1+ (regex "[^:\[.,[:space:][:alnum:]]")))
+                 symbol-end)))
+        (reduce-operator
+         . ,(rx (0+ (any "RSXZ\["))
+                (opt (any "RSXZ&"))
+                (1+ "\[")
+                (opt "\(")
+                (or (and (regex "[^[:digit:]@%$]")
+                         (0+ (regex "[^\[\{\('\"[:space:]]")))
+                    (and (any "@%$")
+                         (regex "[^.?^=_[:alpha:]]\[\{\('\"[:space:]]")
+                         (0+ (regex "[^\[\{\('\"[:space:]]"))))
+                (opt "\)")
+                (1+ "\]")))
+        (low-type
+         . ,(rx (or "int" "int1" "int2" "int4" "int8" "int16" "int32" "int64"
+                    "rat" "rat1" "rat2" "rat4" "rat8" "rat16" "rat32" "rat64"
+                    "buf" "buf1" "buf2" "buf4" "buf8" "buf16" "buf32" "buf64"
+                    "uint" "uint1" "uint2" "uint4" "uint8" "uint16" "uint32"
+                    "uint64" "utf8" "utf16" "utf32" "bit" "bool" "bag" "set"
+                    "mix" "num" "complex")))
+        (high-type
+         . ,(rx (or "Object" "Any" "Junction" "Whatever" "Capture" "Match"
+                    "Signature" "Proxy" "Matcher" "Package" "Module" "Class"
+                    "Grammar" "Scalar" "Array" "Hash" "KeyHash" "KeySet" 
"KeyBag"
+                    "Pair" "List" "Seq" "Range" "Set" "Bag" "Mapping" "Void"
+                    "Undef" "Failure" "Exception" "Code" "Block" "Routine" 
"Sub"
+                    "Macro" "Method" "Submethod" "Regex" "Str" "Blob" "Char"
+                    "Byte" "Parcel" "Codepoint" "Grapheme" "StrPos" "StrLen"
+                    "Version" "Num" "Complex" "Bit" "True" "False" "Order" 
"Same"
+                    "Less" "More" "Increasing" "Decreasing" "Ordered" 
"Callable"
+                    "AnyChar" "Positional" "Associative" "Ordering" 
"KeyExtractor"
+                    "Comparator" "OrderingPair" "IO" "KitchenSink" "Role" "Int"
+                    "Rat" "Buf" "UInt" "Abstraction" "Numeric" "Real" "Nil" 
"Mu")))
+        (version . ,(rx "v" (1+ digit) (0+ "." (or "*" (1+ digit))) (opt "+")))
+        (number
+         . ,(rx
+             (group-n 1
+               (opt (1+ digit) (opt "_" (1+ digit)))
+               (opt ".")
+               (1+ digit))
+             (opt (group-n 2 (any "Ee"))
+                  (group-n 3 (opt "-") (1+ digit) (opt "_" (1+ digit))))
+             (opt (group-n 4 "i"))))
+        (base-number
+         . ,(rx symbol-start
+                (group-n 1 "0")
+                (or (and
+                     (group-n 2 "o")
+                     (group-n 3 (any "0-7") (0+ (any "0-7_"))))
+                    (and
+                     (group-n 2 "b")
+                     (group-n 3 (any "0-1") (0+ (any "0-1_"))))
+                    (and
+                     (group-n 2 "x")
+                     (group-n 3 (regex "[[:xdigit:]]") (0+ (regex 
"[[:xdigit:]_]"))))
+                    (and
+                     (group-n 2 "d")
+                     (group-n 3 (regex "[[:digit:]]") (0+ (regex 
"[[:digit:]_]"))))))))))
 
   (defmacro perl6-rx (&rest sexps)
     "Specialized `rx' variant for perl6-mode."
@@ -415,7 +424,11 @@ Takes arguments START and END which delimit the region to 
propertize."
       ((rx (any "‘「“"))
        (0 (ignore (progn (backward-char)
                          (with-syntax-table perl6-string-delimiter-syntax-table
-                           (perl6-syntax-propertize-delimiters "|")))))))
+                           (perl6-syntax-propertize-delimiters "|"))))))
+      ((perl6-rx variable)
+       (1 ". p")
+       (2 ". p")
+       (3 (ignore (goto-char (match-beginning 3))))))
       start end)))
 
 (defun perl6-font-lock-syntactic-face (state)
@@ -498,12 +511,7 @@ LIMIT can be used to bound the search."
                  (and (0+ space)
                       (or (any ",\)\}") (symbol "where")))))
      1 'perl6-sigil)
-    (,(perl6-rx (group (1+ (char "@$%&")))
-                (group (opt (char ".^*?=!~:")))
-                (group (opt (or (and "::" (0+ (and identifier "::")))
-                                (1+ identifier "::"))))
-                (group (or (or digit (char "/!¢"))
-                           (and identifier symbol-end))))
+    (,(perl6-rx variable)
      (1 'perl6-sigil)
      (2 'perl6-twigil)
      (3 'perl6-var-package)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]