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

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

[nongnu] elpa/raku-mode cc28223bb7 182/253: add new name categories and


From: ELPA Syncer
Subject: [nongnu] elpa/raku-mode cc28223bb7 182/253: add new name categories and other improvements
Date: Sat, 29 Jan 2022 08:28:56 -0500 (EST)

branch: elpa/raku-mode
commit cc28223bb72fad9ee9bcff8bc9910d5ac26749e2
Author: Tom Browder <tom.browder@gmail.com>
Commit: Tom Browder <tom.browder@gmail.com>

    add new name categories and other improvements
    
    + add regex, token, rule, and grammar categories for Perl 6
    + allow '::' in identifiers in certain positions
    + add appropriate regexes for the new categories
    + add new categories to the menu list
    + add new categories to the Perl 6 test file
---
 perl6-imenu.el     | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 test/test-imenu.p6 | 10 ++++++++-
 2 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/perl6-imenu.el b/perl6-imenu.el
index 122c57016b..a48a729dbb 100644
--- a/perl6-imenu.el
+++ b/perl6-imenu.el
@@ -17,8 +17,11 @@
 ;; Regex definitions:
 (defvar perl6-name-regex
   (concat
-   "[_[:alpha:]]"                              ; mandatory leading character
-   "\\(?:[-']?[[:alpha:]]\\|[_[:alnum:]]\\)*"  ; rest of the name allowing 
embedded hyphens or single quotes
+   "[_[:alpha:]]"           ; mandatory leading character
+   "\\(?:[-']?[[:alpha:]]"  ; rest of the name allowing embedded hyphens or 
single quotes or '::'
+   "\\|[_[:alnum:]]"
+   "\\|\\:\\:[_[:alnum:]]"
+   "\\)*"
    ))
 
 (defvar nqp-name-regex
@@ -68,9 +71,61 @@
    "\\)"              ; end of capture group 1
    ))
 
+(defvar perl6-regexes-regex
+  (concat
+   "^\\s-*"           ; leading ws allowed
+                      ; must have an identifier followed by at least one space:
+   "regex\\s-+"
+   "\\("              ; start capture group 1 of the regex name
+   perl6-name-regex
+   "\\|"
+   nqp-name-regex
+   "\\)"              ; end of capture group 1
+   ))
+
+(defvar perl6-tokens-regex
+  (concat
+   "^\\s-*"           ; leading ws allowed
+                      ; must have an identifier followed by at least one space:
+   "token\\s-+"
+   "\\("              ; start capture group 1 of the regex name
+   perl6-name-regex
+   "\\|"
+   nqp-name-regex
+   "\\)"              ; end of capture group 1
+   ))
+
+(defvar perl6-rules-regex
+  (concat
+   "^\\s-*"           ; leading ws allowed
+                      ; must have an identifier followed by at least one space:
+   "rule\\s-+"
+   "\\("              ; start capture group 1 of the regex name
+   perl6-name-regex
+   "\\|"
+   nqp-name-regex
+   "\\)"              ; end of capture group 1
+   ))
+
+(defvar perl6-grammars-regex
+  (concat
+   "^\\s-*"           ; leading ws allowed
+                      ; must have an identifier followed by at least one space:
+   "grammar\\s-+"
+   "\\("              ; start capture group 1 of the regex name
+   perl6-name-regex
+   "\\|"
+   nqp-name-regex
+   "\\)"              ; end of capture group 1
+   ))
+
 (defvar perl6-imenu-generic-expression
   `(
     ;; the names are in reverse desired order since they are evaluated here 
last first
+    ("Rules" ,perl6-rules-regex 1)
+    ("Tokens" ,perl6-tokens-regex 1)
+    ("Regexes" ,perl6-regexes-regex 1)
+    ("Grammars" ,perl6-grammars-regex 1)
     ("Classes" ,perl6-classes-regex 1)
     ("Variables" ,perl6-vars-regex 1)
     ("Subs/Methods" ,perl6-subs-regex 1)
diff --git a/test/test-imenu.p6 b/test/test-imenu.p6
index 3073db891f..6268250e4d 100644
--- a/test/test-imenu.p6
+++ b/test/test-imenu.p6
@@ -1,6 +1,7 @@
 # file: test-imenu.p6
 
-# Perl 6 syntax file for testing perl6-mode with imenu support, which is 
located at:
+# Perl 6 syntax file for testing perl6-mode with imenu support, which
+# is located at:
 #
 #   https://github.com/tbrowder/perl6-mode [branch: "my-branch"]
 
@@ -20,6 +21,13 @@ multi c() {}
 proto xx() {}
 multi method !z-private() {}
 
+my $F::B;
+
 class My-class1 {}
 class My-class2{
     class doit () {}
+
+    token one {}
+    regex two {}
+    rule three {}
+    grammar G::T {}



reply via email to

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