mirror of
https://github.com/alecthomas/chroma.git
synced 2026-06-20 11:35:42 +02:00
Fix Raku colon pair, function adverb and POD declaration
This commit is contained in:
committed by
Alec Thomas
parent
2cff0c9b1f
commit
f4ffd6cea9
+17
-13
@@ -603,7 +603,7 @@ func rakuRules() Rules {
|
||||
{
|
||||
// Token with adverbs
|
||||
`(?<=(?:^|\s)(?:regex|token|rule)(\s+))(['\w:-]+)(?=:['\w-]+` +
|
||||
colonPairOpeningBrackets + `.+?` + colonPairClosingBrackets + `[({])`,
|
||||
colonPairOpeningBrackets + `.+?` + colonPairClosingBrackets + `\s*[({])`,
|
||||
NameFunction,
|
||||
Push("token", "name-adverb"),
|
||||
},
|
||||
@@ -628,7 +628,7 @@ func rakuRules() Rules {
|
||||
{
|
||||
// Routine with adverbs
|
||||
`(?<=(?:^|\s)(?:sub|method|multi sub|multi)\s+)!?['\w:-]+(?=:['\w-]+` +
|
||||
colonPairOpeningBrackets + `.+?` + colonPairClosingBrackets + `[({])`,
|
||||
colonPairOpeningBrackets + `.+?` + colonPairClosingBrackets + `\s*[({])`,
|
||||
NameFunction,
|
||||
Push("name-adverb"),
|
||||
},
|
||||
@@ -737,8 +737,8 @@ func rakuRules() Rules {
|
||||
{colonPairPattern, colonPair(String), bracketsFinder(rakuNameAttribute)},
|
||||
// :123abc
|
||||
{
|
||||
`(:)(\d+)(\w[\w'-]*)(\s*[,;)]?\s*$)`,
|
||||
ByGroups(Punctuation, UsingSelf("number"), String, Text),
|
||||
`(:)(\d+)(\w[\w'-]*)`,
|
||||
ByGroups(Punctuation, UsingSelf("number"), String),
|
||||
nil,
|
||||
},
|
||||
// :key
|
||||
@@ -750,8 +750,8 @@ func rakuRules() Rules {
|
||||
{colonPairPattern, colonPair(NameAttribute), bracketsFinder(rakuNameAttribute)},
|
||||
// :123abc
|
||||
{
|
||||
`(:)(\d+)(\w+)(\s*[,;)]?\s*$)`,
|
||||
ByGroups(Punctuation, UsingSelf("number"), NameAttribute, Text),
|
||||
`(:)(\d+)(\w[\w'-]*)`,
|
||||
ByGroups(Punctuation, UsingSelf("number"), NameAttribute),
|
||||
nil,
|
||||
},
|
||||
// :key
|
||||
@@ -923,7 +923,7 @@ func rakuRules() Rules {
|
||||
`keyword`: Keyword,
|
||||
`opening_delimiters`: Punctuation,
|
||||
`delimiter`: nil,
|
||||
`value`: UsingSelf("pod-begin"),
|
||||
`value`: UsingSelf("pod-declaration"),
|
||||
`closing_delimiters`: Punctuation,
|
||||
}),
|
||||
bracketsFinder(rakuPodDeclaration),
|
||||
@@ -986,13 +986,13 @@ func rakuRules() Rules {
|
||||
{
|
||||
`(?<=^ *)(?<ws> *)(?<keyword>=head\d+)(?<ws2> *)(?<config>#?)`,
|
||||
ByGroups(Comment, Keyword, GenericHeading, Keyword),
|
||||
Push("pod-single-heading"),
|
||||
Push("pod-heading"),
|
||||
},
|
||||
// =item ...
|
||||
{
|
||||
`(?<=^ *)(?<ws> *)(?<keyword>=(?:item\d*|comment|data|[A-Z]+))(?<ws2> *)(?<config>#?)`,
|
||||
ByGroups(Comment, Keyword, StringDoc, Keyword),
|
||||
Push("pod-single"),
|
||||
Push("pod-paragraph"),
|
||||
},
|
||||
{
|
||||
`(?<=^ *)(?<ws> *)(?<keyword>=finish)(?<config>[^\n]*)`,
|
||||
@@ -1003,7 +1003,7 @@ func rakuRules() Rules {
|
||||
{
|
||||
`(?<=^ *)(?<ws> *)(?<name>=\w[\w'-]*)(?<ws2> *)(?<config>#?)`,
|
||||
ByGroups(Comment, Name, StringDoc, Keyword),
|
||||
Push("pod-single"),
|
||||
Push("pod-paragraph"),
|
||||
},
|
||||
// = podconfig
|
||||
{
|
||||
@@ -1018,8 +1018,12 @@ func rakuRules() Rules {
|
||||
Include("pre-pod-formatter"),
|
||||
{`.+?`, StringDoc, nil},
|
||||
},
|
||||
"pod-declaration": {
|
||||
Include("pre-pod-formatter"),
|
||||
{`.+?`, StringDoc, nil},
|
||||
},
|
||||
"pod-paragraph": {
|
||||
{`\n\s*?\n`, StringDoc, Pop(1)},
|
||||
{`\n *\n|\n(?=^ *=)`, StringDoc, Pop(1)},
|
||||
Include("pre-pod-formatter"),
|
||||
{`.+?`, StringDoc, nil},
|
||||
},
|
||||
@@ -1028,8 +1032,8 @@ func rakuRules() Rules {
|
||||
Include("pre-pod-formatter"),
|
||||
{`.+?`, StringDoc, nil},
|
||||
},
|
||||
"pod-single-heading": {
|
||||
{`\n`, GenericHeading, Pop(1)},
|
||||
"pod-heading": {
|
||||
{`\n *\n|\n(?=^ *=)`, GenericHeading, Pop(1)},
|
||||
Include("pre-pod-formatter"),
|
||||
{`.+?`, GenericHeading, nil},
|
||||
},
|
||||
|
||||
Vendored
+7
-1
@@ -3,6 +3,10 @@
|
||||
=begin pod
|
||||
=head1 Some test data for B<Chroma>
|
||||
|
||||
=head2 Multi-line
|
||||
heading
|
||||
|
||||
=head2 One-line heading
|
||||
=begin code :lang<go>
|
||||
fmt.Println("Hello from Go")
|
||||
=end code
|
||||
@@ -396,7 +400,9 @@ class Calculations {
|
||||
|
||||
say Calculator.parse('2 + 3', actions => Calculations).made;
|
||||
|
||||
put Date.today.later(:2years).year;
|
||||
|
||||
=finish
|
||||
C<say> Date.today.year;
|
||||
# Output: 2020
|
||||
B<say> Date.today.later(:2years).year;
|
||||
B<say> Date.today.later(:2years).year;
|
||||
|
||||
Vendored
+30
-10
@@ -11,8 +11,11 @@
|
||||
{"type":"Punctuation","value":"\u003c"},
|
||||
{"type":"GenericStrong","value":"Chroma"},
|
||||
{"type":"Punctuation","value":"\u003e"},
|
||||
{"type":"GenericHeading","value":"\n"},
|
||||
{"type":"LiteralStringDoc","value":"\n"},
|
||||
{"type":"GenericHeading","value":"\n\n"},
|
||||
{"type":"Keyword","value":"=head2"},
|
||||
{"type":"GenericHeading","value":" Multi-line\nheading\n\n"},
|
||||
{"type":"Keyword","value":"=head2"},
|
||||
{"type":"GenericHeading","value":" One-line heading\n"},
|
||||
{"type":"Keyword","value":"=begin code"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":":"},
|
||||
@@ -591,10 +594,7 @@
|
||||
{"type":"Punctuation","value":"\u003c"},
|
||||
{"type":"LiteralStringOther","value":"SomeCode"},
|
||||
{"type":"Punctuation","value":"\u003e"},
|
||||
{"type":"LiteralStringDoc","value":"\n"},
|
||||
{"type":"Keyword","value":"=head1"},
|
||||
{"type":"GenericHeading","value":" heading\n"},
|
||||
{"type":"LiteralStringDoc","value":"]"},
|
||||
{"type":"LiteralStringDoc","value":"\n=head1 heading\n]"},
|
||||
{"type":"Punctuation","value":"」"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"Keyword","value":"grammar"},
|
||||
@@ -2005,7 +2005,8 @@
|
||||
{"type":"Punctuation","value":":"},
|
||||
{"type":"LiteralNumberInteger","value":"23"},
|
||||
{"type":"LiteralString","value":"year"},
|
||||
{"type":"Text","value":",\n "},
|
||||
{"type":"Operator","value":","},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"LiteralString","value":"m"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"=\u003e"},
|
||||
@@ -3208,7 +3209,9 @@
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"method"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameFunction","value":"calc-op:sym"},
|
||||
{"type":"NameFunction","value":"calc-op"},
|
||||
{"type":"Punctuation","value":":"},
|
||||
{"type":"NameAttribute","value":"sym"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameVariable","value":"$/"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
@@ -3226,7 +3229,9 @@
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"method"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameFunction","value":"calc-op:sym"},
|
||||
{"type":"NameFunction","value":"calc-op"},
|
||||
{"type":"Punctuation","value":":"},
|
||||
{"type":"NameAttribute","value":"sym"},
|
||||
{"type":"Punctuation","value":"\u003c"},
|
||||
{"type":"LiteralString","value":"sub"},
|
||||
{"type":"Punctuation","value":"\u003e"},
|
||||
@@ -3264,6 +3269,21 @@
|
||||
{"type":"Keyword","value":"made"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"NameBuiltin","value":"put"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameBuiltin","value":"Date"},
|
||||
{"type":"Operator","value":"."},
|
||||
{"type":"NameBuiltin","value":"today"},
|
||||
{"type":"Operator","value":"."},
|
||||
{"type":"NameBuiltin","value":"later"},
|
||||
{"type":"Punctuation","value":"(:"},
|
||||
{"type":"LiteralNumberInteger","value":"2"},
|
||||
{"type":"LiteralString","value":"years"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"Operator","value":"."},
|
||||
{"type":"NameBuiltin","value":"year"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"Keyword","value":"=finish"},
|
||||
{"type":"LiteralStringDoc","value":"\n"},
|
||||
{"type":"Keyword","value":"C"},
|
||||
@@ -3275,5 +3295,5 @@
|
||||
{"type":"Punctuation","value":"\u003c"},
|
||||
{"type":"GenericStrong","value":"say"},
|
||||
{"type":"Punctuation","value":"\u003e"},
|
||||
{"type":"LiteralStringDoc","value":" Date.today.later(:2years).year;"}
|
||||
{"type":"LiteralStringDoc","value":" Date.today.later(:2years).year;\n"}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user