Skip to content

Commit c0f0745

Browse files
committed
Fix comments in regexp multiline strings.
1 parent 33c8f23 commit c0f0745

6 files changed

Lines changed: 237 additions & 109 deletions

File tree

grammars/MagicPython.YAML-tmLanguage

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ repository:
1414
$apply:
1515
- file: 'regexp-common.inc.yaml'
1616

17+
- file: 'comment.inc.yaml'
18+
vars:
19+
suffix: ''
20+
marker: ''
21+
22+
- file: 'comment.inc.yaml'
23+
vars:
24+
suffix: '-string-single-three'
25+
marker: "|(?=''')"
26+
27+
- file: 'comment.inc.yaml'
28+
vars:
29+
suffix: '-string-double-three'
30+
marker: '|(?=""")'
31+
1732
- file: 'regexp.inc.yaml'
1833
vars:
1934
prefix: 'single-one-'
@@ -24,7 +39,7 @@ repository:
2439
vars:
2540
prefix: 'single-three-'
2641
marker: "|(?=\\'\\'\\')"
27-
nested: "- include: '#comments'"
42+
nested: "- include: '#comments-string-single-three'"
2843

2944
- file: 'regexp.inc.yaml'
3045
vars:
@@ -36,7 +51,7 @@ repository:
3651
vars:
3752
prefix: 'double-three-'
3853
marker: '|(?=""")'
39-
nested: "- include: '#comments'"
54+
nested: "- include: '#comments-string-double-three'"
4055

4156
- file: 'pystring.inc.yaml'
4257
vars:
@@ -66,17 +81,6 @@ repository:
6681
marker: '\"\"\"'
6782
guard: ""
6883

69-
comments:
70-
name: comment.line.number-sign.python
71-
begin: (\#)
72-
beginCaptures:
73-
'1': {name: punctuation.definition.comment.python}
74-
end: ($)
75-
patterns:
76-
- match: (?:\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\b)
77-
captures:
78-
'1': {name: keyword.comment.line.note.notation.python}
79-
8084
statement:
8185
patterns:
8286
- include: '#class-declaration'
@@ -173,7 +177,6 @@ repository:
173177
captures:
174178
'1': {name: keyword.string.quoted.docstring.note.python}
175179

176-
177180
statement-keyword:
178181
patterns:
179182
- name: storage.type.function.python
@@ -450,7 +453,6 @@ repository:
450453
'0': {name: punctuation.definition.string.end.python}
451454
patterns:
452455
- include: '#single-three-regexp-expression'
453-
- include: '#comments'
454456

455457
regexp-double-quoted-multi-line:
456458
name: string.regexp.quoted.triple.python
@@ -465,7 +467,6 @@ repository:
465467
'0': {name: punctuation.definition.string.end.python}
466468
patterns:
467469
- include: '#double-three-regexp-expression'
468-
- include: '#comments'
469470

470471
string:
471472
patterns:

grammars/MagicPython.cson

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,6 @@ patterns: [
2323
}
2424
]
2525
repository:
26-
comments:
27-
name: "comment.line.number-sign.python"
28-
begin: "(\\#)"
29-
beginCaptures:
30-
"1":
31-
name: "punctuation.definition.comment.python"
32-
end: "($)"
33-
patterns: [
34-
{
35-
match: "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)"
36-
captures:
37-
"1":
38-
name: "keyword.comment.line.note.notation.python"
39-
}
40-
]
4126
statement:
4227
patterns: [
4328
{
@@ -623,9 +608,6 @@ repository:
623608
{
624609
include: "#single-three-regexp-expression"
625610
}
626-
{
627-
include: "#comments"
628-
}
629611
]
630612
"regexp-double-quoted-multi-line":
631613
name: "string.regexp.quoted.triple.python"
@@ -647,9 +629,6 @@ repository:
647629
{
648630
include: "#double-three-regexp-expression"
649631
}
650-
{
651-
include: "#comments"
652-
}
653632
]
654633
string:
655634
patterns: [
@@ -1700,6 +1679,51 @@ repository:
17001679
include: "#regexp-escape-catchall"
17011680
}
17021681
]
1682+
comments:
1683+
name: "comment.line.number-sign.python"
1684+
begin: "(\\#)"
1685+
beginCaptures:
1686+
"1":
1687+
name: "punctuation.definition.comment.python"
1688+
end: "($)"
1689+
patterns: [
1690+
{
1691+
match: "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)"
1692+
captures:
1693+
"1":
1694+
name: "keyword.comment.line.note.notation.python"
1695+
}
1696+
]
1697+
"comments-string-single-three":
1698+
name: "comment.line.number-sign.python"
1699+
begin: "(\\#)"
1700+
beginCaptures:
1701+
"1":
1702+
name: "punctuation.definition.comment.python"
1703+
end: "($|(?='''))"
1704+
patterns: [
1705+
{
1706+
match: "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)"
1707+
captures:
1708+
"1":
1709+
name: "keyword.comment.line.note.notation.python"
1710+
}
1711+
]
1712+
"comments-string-double-three":
1713+
name: "comment.line.number-sign.python"
1714+
begin: "(\\#)"
1715+
beginCaptures:
1716+
"1":
1717+
name: "punctuation.definition.comment.python"
1718+
end: "($|(?=\"\"\"))"
1719+
patterns: [
1720+
{
1721+
match: "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)"
1722+
captures:
1723+
"1":
1724+
name: "keyword.comment.line.note.notation.python"
1725+
}
1726+
]
17031727
"single-one-regexp-expression":
17041728
patterns: [
17051729
{
@@ -1956,6 +1980,9 @@ repository:
19561980
{
19571981
include: "#single-three-regexp-parentheses"
19581982
}
1983+
{
1984+
include: "#comments-string-single-three"
1985+
}
19591986
]
19601987
"single-three-regexp-character-set":
19611988
patterns: [
@@ -2012,7 +2039,7 @@ repository:
20122039
include: "#single-three-regexp-expression"
20132040
}
20142041
{
2015-
include: "#comments"
2042+
include: "#comments-string-single-three"
20162043
}
20172044
]
20182045
"single-three-regexp-comments":
@@ -2041,7 +2068,7 @@ repository:
20412068
include: "#single-three-regexp-expression"
20422069
}
20432070
{
2044-
include: "#comments"
2071+
include: "#comments-string-single-three"
20452072
}
20462073
]
20472074
"single-three-regexp-lookahead-negative":
@@ -2060,7 +2087,7 @@ repository:
20602087
include: "#single-three-regexp-expression"
20612088
}
20622089
{
2063-
include: "#comments"
2090+
include: "#comments-string-single-three"
20642091
}
20652092
]
20662093
"single-three-regexp-lookbehind":
@@ -2079,7 +2106,7 @@ repository:
20792106
include: "#single-three-regexp-expression"
20802107
}
20812108
{
2082-
include: "#comments"
2109+
include: "#comments-string-single-three"
20832110
}
20842111
]
20852112
"single-three-regexp-lookbehind-negative":
@@ -2098,7 +2125,7 @@ repository:
20982125
include: "#single-three-regexp-expression"
20992126
}
21002127
{
2101-
include: "#comments"
2128+
include: "#comments-string-single-three"
21022129
}
21032130
]
21042131
"single-three-regexp-conditional":
@@ -2117,7 +2144,7 @@ repository:
21172144
include: "#single-three-regexp-expression"
21182145
}
21192146
{
2120-
include: "#comments"
2147+
include: "#comments-string-single-three"
21212148
}
21222149
]
21232150
"single-three-regexp-parentheses-non-capturing":
@@ -2134,7 +2161,7 @@ repository:
21342161
include: "#single-three-regexp-expression"
21352162
}
21362163
{
2137-
include: "#comments"
2164+
include: "#comments-string-single-three"
21382165
}
21392166
]
21402167
"single-three-regexp-parentheses":
@@ -2151,7 +2178,7 @@ repository:
21512178
include: "#single-three-regexp-expression"
21522179
}
21532180
{
2154-
include: "#comments"
2181+
include: "#comments-string-single-three"
21552182
}
21562183
]
21572184
"double-one-regexp-expression":
@@ -2410,6 +2437,9 @@ repository:
24102437
{
24112438
include: "#double-three-regexp-parentheses"
24122439
}
2440+
{
2441+
include: "#comments-string-double-three"
2442+
}
24132443
]
24142444
"double-three-regexp-character-set":
24152445
patterns: [
@@ -2466,7 +2496,7 @@ repository:
24662496
include: "#double-three-regexp-expression"
24672497
}
24682498
{
2469-
include: "#comments"
2499+
include: "#comments-string-double-three"
24702500
}
24712501
]
24722502
"double-three-regexp-comments":
@@ -2495,7 +2525,7 @@ repository:
24952525
include: "#double-three-regexp-expression"
24962526
}
24972527
{
2498-
include: "#comments"
2528+
include: "#comments-string-double-three"
24992529
}
25002530
]
25012531
"double-three-regexp-lookahead-negative":
@@ -2514,7 +2544,7 @@ repository:
25142544
include: "#double-three-regexp-expression"
25152545
}
25162546
{
2517-
include: "#comments"
2547+
include: "#comments-string-double-three"
25182548
}
25192549
]
25202550
"double-three-regexp-lookbehind":
@@ -2533,7 +2563,7 @@ repository:
25332563
include: "#double-three-regexp-expression"
25342564
}
25352565
{
2536-
include: "#comments"
2566+
include: "#comments-string-double-three"
25372567
}
25382568
]
25392569
"double-three-regexp-lookbehind-negative":
@@ -2552,7 +2582,7 @@ repository:
25522582
include: "#double-three-regexp-expression"
25532583
}
25542584
{
2555-
include: "#comments"
2585+
include: "#comments-string-double-three"
25562586
}
25572587
]
25582588
"double-three-regexp-conditional":
@@ -2571,7 +2601,7 @@ repository:
25712601
include: "#double-three-regexp-expression"
25722602
}
25732603
{
2574-
include: "#comments"
2604+
include: "#comments-string-double-three"
25752605
}
25762606
]
25772607
"double-three-regexp-parentheses-non-capturing":
@@ -2588,7 +2618,7 @@ repository:
25882618
include: "#double-three-regexp-expression"
25892619
}
25902620
{
2591-
include: "#comments"
2621+
include: "#comments-string-double-three"
25922622
}
25932623
]
25942624
"double-three-regexp-parentheses":
@@ -2605,7 +2635,7 @@ repository:
26052635
include: "#double-three-regexp-expression"
26062636
}
26072637
{
2608-
include: "#comments"
2638+
include: "#comments-string-double-three"
26092639
}
26102640
]
26112641
"string-raw-single-quoted-single-line":

0 commit comments

Comments
 (0)