@@ -49,8 +49,10 @@ func rakuRules() Rules {
4949 const (
5050 colonPairOpeningBrackets = `(?:<<|<|«|\(|\[|\{)`
5151 colonPairClosingBrackets = `(?:>>|>|»|\)|\]|\})`
52- colonPairPattern = `(?<colon>:)(?<key>\w[\w'-]*)(?<opening_delimiters>` + colonPairOpeningBrackets + `)`
53- namePattern = `((?:(?!` + colonPairPattern + `)[\w':-])+)`
52+ colonPairPattern = `(?<!:)(?<colon>:)(?<key>\w[\w'-]*)(?<opening_delimiters>` + colonPairOpeningBrackets + `)`
53+ colonPairLookahead = `(?=(:['\w-]+` +
54+ colonPairOpeningBrackets + `.+?` + colonPairClosingBrackets + `)?`
55+ namePattern = `((?:(?!` + colonPairPattern + `)(?:::|[\w':-]))+)`
5456 variablePattern = `[$@%&]+[.^:?=!~]?` + namePattern
5557 globalVariablePattern = `[$@%&]+\*` + namePattern
5658 )
@@ -601,18 +603,10 @@ func rakuRules() Rules {
601603 Include ("colon-pair" ),
602604 // Token
603605 {
604- // Token with adverbs
605- `(?<=(?:^|\s)(?:regex|token|rule)(\s+))(['\w:-]+)(?=:['\w-]+` +
606- colonPairOpeningBrackets + `.+?` + colonPairClosingBrackets + `\s*[({])` ,
606+ `(?<=(?:^|\s)(?:regex|token|rule)(\s+))` + namePattern + colonPairLookahead + `\s*[({])` ,
607607 NameFunction ,
608608 Push ("token" , "name-adverb" ),
609609 },
610- {
611- // Token without adverbs
612- `(?<=(?:^|\s)(?:regex|token|rule)(?:\s+))(['\w:-]+)` ,
613- NameFunction ,
614- Push ("token" ),
615- },
616610 // Substitution
617611 {`(?<=^|\b|\s)(?<!\.)(ss|S|s|TR|tr)\b(\s*)` , ByGroups (Keyword , Text ), Push ("substitution" )},
618612 {keywordsPattern , Keyword , nil },
@@ -626,18 +620,10 @@ func rakuRules() Rules {
626620 },
627621 // Routine
628622 {
629- // Routine with adverbs
630- `(?<=(?:^|\s)(?:sub|method|multi sub|multi)\s+)!?['\w:-]+(?=:['\w-]+` +
631- colonPairOpeningBrackets + `.+?` + colonPairClosingBrackets + `\s*[({])` ,
623+ `(?<=(?:^|\s)(?:sub|method|multi sub|multi)\s+)!?` + namePattern + colonPairLookahead + `\s*[({])` ,
632624 NameFunction ,
633625 Push ("name-adverb" ),
634626 },
635- {
636- // Routine without adverbs
637- `(?<=(?:^|\s)(?:sub|submethod|method|multi)\s+)!?['\w:-]+` ,
638- NameFunction ,
639- nil ,
640- },
641627 // Constant
642628 {`(?<=\bconstant\s+)` + namePattern , NameConstant , Push ("name-adverb" )},
643629 // Namespace
@@ -655,22 +641,16 @@ func rakuRules() Rules {
655641 },
656642 // Function
657643 {
658- `\b(?:\w['\w:-]*)(?=:['\w-]+` +
659- colonPairOpeningBrackets + `.+?` + colonPairClosingBrackets + `\()` ,
644+ `\b` + namePattern + colonPairLookahead + `\()` ,
660645 NameFunction ,
661646 Push ("name-adverb" ),
662647 },
663- {`\b(?:\w['\w:-]*)(?=\()` , NameFunction , nil },
664648 // Method
665- // Method with adverb
666649 {
667- `(?<!\.\.[?^*+]?)(?<=(?:\.[?^*+&]?)|self!)['\w:-]+(?=:['\w-]+` +
668- colonPairOpeningBrackets + `.+?` + colonPairClosingBrackets + `$)` ,
650+ `(?<!\.\.[?^*+]?)(?<=(?:\.[?^*+&]?)|self!)` + namePattern + colonPairLookahead + `\b)` ,
669651 NameFunction ,
670652 Push ("name-adverb" ),
671653 },
672- // Method without adverb
673- {`(?<!\.\.[?^*+]?)(?<=(?:\.[?^*+&]?)|self!)['\w:-]+` , NameFunction , nil },
674654 // Indirect invocant
675655 {namePattern + `(?=\s+\W?['\w:-]+:\W)` , NameFunction , Push ("name-adverb" )},
676656 {`(?<=\W)(?:∅|i|e|𝑒|tau|τ|pi|π|Inf|∞)(?=\W)` , NameConstant , nil },
0 commit comments