@@ -2,7 +2,6 @@ package r
2
2
3
3
import (
4
4
"regexp"
5
- "sort"
6
5
"strings"
7
6
"unicode/utf8"
8
7
@@ -70,7 +69,7 @@ func rakuRules() Rules {
70
69
`dynamic-scope` , `built` , `temp` ,
71
70
}
72
71
73
- keywordsPattern := Words (`(?<!['\w:-])` , `(?!['\w:-])` , sortWords ( keywords ) ... )
72
+ keywordsPattern := Words (`(?<!['\w:-])` , `(?!['\w:-])` , keywords ... )
74
73
75
74
wordOperators := []string {
76
75
`X` , `Z` , `R` , `after` , `and` , `andthen` , `before` , `cmp` , `div` , `eq` , `eqv` , `extra` , `ge` ,
@@ -80,7 +79,7 @@ func rakuRules() Rules {
80
79
`(cont)` , `(<)` , `(<=)` , `(>)` , `(>=)` , `minmax` , `notandthen` , `S` ,
81
80
}
82
81
83
- wordOperatorsPattern := Words (`(?<=^|\b|\s)` , `(?=$|\b|\s)` , sortWords ( wordOperators ) ... )
82
+ wordOperatorsPattern := Words (`(?<=^|\b|\s)` , `(?=$|\b|\s)` , wordOperators ... )
84
83
85
84
operators := []string {
86
85
`++` , `--` , `-` , `**` , `!` , `+` , `~` , `?` , `+^` , `~^` , `?^` , `^` , `*` , `/` , `%` , `%%` , `+&` ,
@@ -93,7 +92,7 @@ func rakuRules() Rules {
93
92
`⊃` , `⊅` , `⊇` , `⊉` , `:` , `!!!` , `???` , `¯` , `×` , `÷` , `−` , `⁺` , `⁻` ,
94
93
}
95
94
96
- operatorsPattern := Words (`` , `` , sortWords ( operators ) ... )
95
+ operatorsPattern := Words (`` , `` , operators ... )
97
96
98
97
builtinTypes := []string {
99
98
`False` , `True` , `Order` , `More` , `Less` , `Same` , `Any` , `Array` , `Associative` , `AST` ,
@@ -142,7 +141,7 @@ func rakuRules() Rules {
142
141
`strict` , `trace` , `variables` ,
143
142
}
144
143
145
- builtinTypesPattern := Words (`(?<!['\w:-])` , `(?::[_UD])?(?!['\w:-])` , sortWords ( builtinTypes ) ... )
144
+ builtinTypesPattern := Words (`(?<!['\w:-])` , `(?::[_UD])?(?!['\w:-])` , builtinTypes ... )
146
145
147
146
builtinRoutines := []string {
148
147
`ACCEPTS` , `abs` , `abs2rel` , `absolute` , `accept` , `accepts_type` , `accessed` , `acos` ,
@@ -266,7 +265,7 @@ func rakuRules() Rules {
266
265
`yyyy-mm-dd` , `z` , `zip` , `zip-latest` , `HOW` , `s` , `DEPRECATED` , `trait_mod` ,
267
266
}
268
267
269
- builtinRoutinesPattern := Words (`(?<!['\w:-])` , `(?!['\w-])` , sortWords ( builtinRoutines ) ... )
268
+ builtinRoutinesPattern := Words (`(?<!['\w:-])` , `(?!['\w-])` , builtinRoutines ... )
270
269
271
270
// A map of opening and closing brackets
272
271
brackets := map [rune ]rune {
@@ -1197,15 +1196,6 @@ func joinRuneMap(m map[rune]rune) string {
1197
1196
return string (runes )
1198
1197
}
1199
1198
1200
- // Sorts words in descending order
1201
- func sortWords (words []string ) []string {
1202
- sort .Slice (words , func (i , j int ) bool {
1203
- return len ([]rune (words [i ])) > len ([]rune (words [j ]))
1204
- })
1205
-
1206
- return words
1207
- }
1208
-
1209
1199
// Finds the index of substring in the string starting at position n
1210
1200
func indexAt (str []rune , substr []rune , pos int ) int {
1211
1201
text := string (str [pos :])
0 commit comments