Skip to content

Commit 2535d1a

Browse files
CIAvashalecthomas
authored andcommitted
Raku: Fix operators that come after <
1 parent bb38ae2 commit 2535d1a

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

Diff for: lexers/r/raku.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ func rakuRules() Rules {
791791
},
792792
// <{code}>
793793
{
794-
`(?<!(?<!\\)\\)(<)([?!])?((?<!(?<!\\)\\){)(.*?)(}>)`,
794+
`(?<!(?<!\\)\\)(<)([?!.]*)((?<!(?<!\\)\\){)(.*?)(}>)`,
795795
ByGroups(Punctuation, Operator, Punctuation, UsingSelf("root"), Punctuation),
796796
nil,
797797
},
@@ -807,7 +807,7 @@ func rakuRules() Rules {
807807
{`#[^\n]*\n`, CommentSingle, nil},
808808
// Lookaround
809809
{
810-
`(?<!(?<!\\)\\)(<)(\s*)([?!.])(\s*)(after|before)`,
810+
`(?<!(?<!\\)\\)(<)(\s*)([?!.]+)(\s*)(after|before)`,
811811
ByGroups(Punctuation, Text, Operator, Text, OperatorWord),
812812
Push("regex"),
813813
},
@@ -818,8 +818,8 @@ func rakuRules() Rules {
818818
},
819819
// <$variable>
820820
{
821-
`(?<!(?<!\\)\\)(<)([$@]\w[\w-:]*)(>)`,
822-
ByGroups(Punctuation, NameVariable, Punctuation),
821+
`(?<!(?<!\\)\\)(<)([?!.]*)([$@]\w[\w-:]*)(>)`,
822+
ByGroups(Punctuation, Operator, NameVariable, Punctuation),
823823
nil,
824824
},
825825
// Capture markers
@@ -841,6 +841,7 @@ func rakuRules() Rules {
841841
{`(?<!(?<!\\)\\)>`, Punctuation, Pop(1)},
842842
Include("regex-class-builtin"),
843843
Include("variable"),
844+
{`(?<=<)[|!?.]+`, Operator, nil},
844845
// <regexfunc> | <regexfunc(parameter)> | <variable=regexfunc>
845846
{
846847
`(?:(\w[\w-:]*)(=\.?))?(&?\w[\w'-:]+?)(\(.+?\))?(?=>)`,
@@ -861,7 +862,6 @@ func rakuRules() Rules {
861862
{`(?<!(?<!\\)\\)\[`, Punctuation, Push("regex-character-class")},
862863
{`\+|\-`, Operator, nil},
863864
{`@[\w'-:]+`, NameVariable, nil},
864-
{`(?<=<)[|!?.]`, Operator, nil},
865865
{`.+?`, StringRegex, nil},
866866
},
867867
"regex-escape-class": {

Diff for: lexers/testdata/raku.actual

+4
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ rx/:i
233233

234234
$<myname> = [ \w+ ]
235235

236+
<!!{ $*LANG := $*LEAF := $/.clone_braid_from(self); 1 }>
237+
238+
<?before <.[\)\]\}]>>
239+
236240
$<string>=( [ $<part>=[abc] ]* % '-' )
237241
$<variable>=\w+ '=' $<value>=\w+
238242
a <( b )> c

Diff for: lexers/testdata/raku.expected

+33
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,39 @@
16991699
{"type":"LiteralStringRegex","value":" "},
17001700
{"type":"Punctuation","value":"]"},
17011701
{"type":"LiteralStringRegex","value":"\n\n "},
1702+
{"type":"Punctuation","value":"\u003c"},
1703+
{"type":"Operator","value":"!!"},
1704+
{"type":"Punctuation","value":"{"},
1705+
{"type":"Text","value":" "},
1706+
{"type":"NameVariableGlobal","value":"$*LANG"},
1707+
{"type":"Text","value":" "},
1708+
{"type":"Operator","value":":="},
1709+
{"type":"Text","value":" "},
1710+
{"type":"NameVariableGlobal","value":"$*LEAF"},
1711+
{"type":"Text","value":" "},
1712+
{"type":"Operator","value":":="},
1713+
{"type":"Text","value":" "},
1714+
{"type":"NameVariable","value":"$/"},
1715+
{"type":"Operator","value":"."},
1716+
{"type":"NameFunction","value":"clone_braid_from"},
1717+
{"type":"Punctuation","value":"("},
1718+
{"type":"NameBuiltin","value":"self"},
1719+
{"type":"Punctuation","value":");"},
1720+
{"type":"Text","value":" "},
1721+
{"type":"LiteralNumberInteger","value":"1"},
1722+
{"type":"Text","value":" "},
1723+
{"type":"Punctuation","value":"}\u003e"},
1724+
{"type":"LiteralStringRegex","value":"\n\n "},
1725+
{"type":"Punctuation","value":"\u003c"},
1726+
{"type":"Operator","value":"?"},
1727+
{"type":"OperatorWord","value":"before"},
1728+
{"type":"LiteralStringRegex","value":" "},
1729+
{"type":"Punctuation","value":"\u003c"},
1730+
{"type":"Operator","value":"."},
1731+
{"type":"Punctuation","value":"["},
1732+
{"type":"LiteralStringRegex","value":"\\)\\]\\}"},
1733+
{"type":"Punctuation","value":"]\u003e\u003e"},
1734+
{"type":"LiteralStringRegex","value":"\n\n "},
17021735
{"type":"NameVariable","value":"$\u003cstring\u003e"},
17031736
{"type":"Operator","value":"="},
17041737
{"type":"Punctuation","value":"("},

0 commit comments

Comments
 (0)