Skip to content

Commit c4358c0

Browse files
feat: update grammar for pywire v0.1.8
1 parent 3cdcc73 commit c4358c0

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

grammar.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ module.exports = grammar({
5959
$.self_closing_tag,
6060
$.text,
6161
$.hyphen,
62-
$.interpolation
62+
$.interpolation,
63+
$.brace_block,
64+
$.end_brace_block
6365
),
6466

6567
tag: $ => seq(
@@ -80,14 +82,17 @@ module.exports = grammar({
8082
'/>'
8183
),
8284

83-
tag_name: $ => /\w+/,
85+
tag_name: $ => /[a-zA-Z0-9_$-]+/,
8486

85-
attribute: $ => seq(
86-
$._attribute_name,
87-
optional(seq(
88-
'=',
89-
$.attribute_value
90-
))
87+
attribute: $ => choice(
88+
seq(
89+
$._attribute_name,
90+
optional(seq(
91+
'=',
92+
$.attribute_value
93+
))
94+
),
95+
$.interpolation
9196
),
9297

9398
_attribute_name: $ => choice(
@@ -109,6 +114,23 @@ module.exports = grammar({
109114

110115
_interpolation_content: $ => /[^}]+/,
111116

117+
brace_block: $ => seq(
118+
'{',
119+
'$',
120+
alias(choice('if', 'elif', 'else', 'for', 'await', 'then', 'catch', 'try', 'except', 'finally', 'html'), $.keyword_control),
121+
optional(alias($._python_code, $.python_code)),
122+
'}'
123+
),
124+
125+
end_brace_block: $ => seq(
126+
'{',
127+
'/',
128+
alias(choice('if', 'for', 'await', 'try'), $.keyword_control),
129+
'}'
130+
),
131+
132+
_python_code: $ => /[^}]+/,
133+
112134
// Separator must be on its own line (roughly)
113135
separator: $ => token(seq(
114136
/-{3,}/,

0 commit comments

Comments
 (0)