[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/raku-mode 4f1e2928d2 158/253: add more generalization with
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/raku-mode 4f1e2928d2 158/253: add more generalization with more defined regexes, remove commented out old code |
Date: |
Sat, 29 Jan 2022 08:28:53 -0500 (EST) |
branch: elpa/raku-mode
commit 4f1e2928d2c56732dea509a758a065acf477f72c
Author: Tom Browder <tom.browder@gmail.com>
Commit: Tom Browder <tom.browder@gmail.com>
add more generalization with more defined regexes, remove commented out old
code
---
perl6-imenu.el | 71 +++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 51 insertions(+), 20 deletions(-)
diff --git a/perl6-imenu.el b/perl6-imenu.el
index 9681820e56..68f1a9bfc3 100644
--- a/perl6-imenu.el
+++ b/perl6-imenu.el
@@ -2,45 +2,76 @@
;; Imenu functions and variables are defined here.
-;; TODO: tighten regexes to distinguish correct naming for Perl 6
-;; vs. NQP (make a minor mode?)
+;; Definition of "identifiers" (names) from
+;; https://docs.perl6.org/language/syntax#Identifiers
+;;
+;; Identifiers are a grammatical building block that occur in several
+;; places. An identifier is a primitive name, and must start with an
+;; alphabetic character (or an underscore), followed by zero or more
+;; word characters (alphabetic, underscore or number). You can also
+;; embed dashes - or single quotes ' in the middle, but not two in a
+;; row, and only if followed immediately by an alphabetic character.
+;;
+;; For NQP names, no embedded hyphens or single quotes are allowed.
;; Regex definitions:
+(defvar perl6-name-regex
+ (concat
+ "[_[:alpha:]]" ; mandatory leading character
+ "\\(?:[-']?[[:alpha:]]\\|[_[:alnum:]]\\)*" ; rest of the name allowing
embedded hyphens or single quotes
+ ))
+
+(defvar nqp-name-regex
+ (concat
+ "[_[:alpha:]]" ; mandatory leading character
+ "[_[:alnum:]]*" ; rest of the name (stricter than Perl 6 name)
+ ))
+
(defvar perl6-vars-regex
(concat
- "^\\s-*" ; leading ws allowed
- "\\(?:my\\|our\\)\\s-+" ; scope of var, followed by mandatory ws
- "\\(" ; start capture group 1 for the var name
- "\\(?:\\$\\|@\\|%\\)" ; sigil for type of var
- "\\(?:[-_[:alnum:]]+\\)" ; the var name ends with ws
- "\\)" ; end of capture group 1
+ "^\\s-*" ; leading ws allowed
+ "\\(?:my\\|our\\)\\s-+" ; scope of var, followed by mandatory ws
+ "\\(" ; start capture group 1 for the var name
+ "\\(?:\\$\\|@\\|%\\)" ; sigil for type of var
+ "\\(?:" ; start shy group for choice of one type name
+ perl6-name-regex
+ "\\|"
+ nqp-name-regex
+ "\\)" ; end shy group
+ "\\)" ; end of capture group 1
))
(defvar perl6-subs-regex
(concat
- "^\\s-*" ; leading ws allowed
- "\\(?:my\\s-+\\|our\\s-+\\)?" ; optional specific scope followed by at
least one space
- ; must have one of the five type identifiers followed by at least one
space:
-
"\\(?:multi\\s-+sub\\|multi\\s-+method\\|sub\\|method\\|multi\\|proto\\)\\s-+"
- "\\([-_[:alnum:]]+\\)" ; the capture group of the sub name
+ "^\\s-*" ; leading ws allowed
+ "\\(?:my\\s-+\\|our\\s-+\\)?" ; optional specific scope followed by at
least one space
+ ; must have one of the five type identifiers
+ ; followed by at least one space:
+
"\\(?:multi\\s-+sub\\|multi\\s-+method\\|sub\\|method\\|multi\\|proto\\)\\s-+"
+ "\\(" ; start capture group 1 for the sub name
+ perl6-name-regex
+ "\\|"
+ nqp-name-regex
+ "\\)" ; end of capture group 1
))
(defvar perl6-classes-regex
(concat
- "^\\s-*" ; leading ws allowed
- ; must have one of the four type identifiers followed by at least one
space:
- "class\\s-+"
- "\\([-_[:alnum:]]+\\)" ; the capture group of the sub
name
- ;"[\\n\\s\\-{]+" ; ended by whitespace or an opening curly
brace'
+ "^\\s-*" ; leading ws allowed
+ ; must have one of the four type identifiers followed by
at least one space:
+ "class\\s-+"
+ "\\(" ; start capture group 1 of the class 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
- ;("Variables"
"^\\s-*\\(?:my\\|our\\)\\s-+\\(\\(?:\\$\\|@\\|%\\)\\(?:[_[:alnum:]]+\\)\\)" 1)
("Classes" ,perl6-classes-regex 1)
("Variables" ,perl6-vars-regex 1)
- ;;("Subs/Methods"
"^\\s-*\\(?:my\\s-+\\|our\\s-+\\)?\\(?:multi\\s-+sub\\|multi\\s-+method\\|sub\\|method\\|multi\\)\\s-+\\(.+)\\)"
1)
("Subs/Methods" ,perl6-subs-regex 1)
)
"Define interesting points in the Perl 6 buffer for `imenu'.
- [nongnu] elpa/raku-mode acc516e76d 225/253: Uncomment code blocks in POD., (continued)
- [nongnu] elpa/raku-mode acc516e76d 225/253: Uncomment code blocks in POD., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 341c898848 029/253: Add note about electricity, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode e7a3770427 008/253: Recommend `:defer t` with use-package, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 032fa40e1b 068/253: Highlight [RSXZ] metaoperators, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode e8111ebbdf 106/253: Factor metaoperator regex into a reusable part, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode bfccfac15a 090/253: Alter priority of metaoperator highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode d9682fb331 098/253: Highlight regex/rule/token even when not followed by an identifier, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 0f053e21f2 146/253: now have a working solution for an Index imenu for subs and vars, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 14073feeb0 161/253: Don't highlight hyperops starting with << and «« as strings, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 0bd2a09663 153/253: add vars moved from perl6-imenu.el per comments from syohex, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4f1e2928d2 158/253: add more generalization with more defined regexes, remove commented out old code,
ELPA Syncer <=
- [nongnu] elpa/raku-mode aa3a58e4c5 162/253: "Map" type highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4867c6d268 181/253: add example state var, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 0d2dfb04c1 178/253: Remove pointer to original repo's bug tracker, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 5a7cc0d425 173/253: Let's see what's going on, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 2e622f86e0 202/253: Change perl6-repl command to run-perl6, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode bcdd53e9ec 201/253: Merge remote-tracking branch 'origin/master' into repl, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 0be91cc76e 204/253: Fix cask instalation on travis-ci, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode d62231e902 167/253: Merge branch 'my-branch' of https://github.com/tbrowder/perl6-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode e53f3d4f94 194/253: Update README, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode f3256bb3fd 159/253: add some more test names, ELPA Syncer, 2022/01/29