Skip to content

Commit 0b889f1

Browse files
committed
CASE filters: add support in additional places:
<content_from_segment> and <update_move_clause_destination> now support <line_filter> (CASE WHEN...THEN | ED)
1 parent d92135d commit 0b889f1

File tree

5 files changed

+226
-215
lines changed

5 files changed

+226
-215
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

grammar.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ module.exports = grammar({
183183
choice($.content_literal, $.content_from_segment)
184184
),
185185
seq($.replace_region_clause, 'WITH',
186-
choice($.content_literal, $.content_from_segment, $.case_stmt, $.ed_stmt)
186+
choice($.content_literal, $.content_from_segment, $.line_filter)
187187
)
188188
)
189189
)
@@ -200,7 +200,7 @@ module.exports = grammar({
200200
choice($.content_literal, $.content_from_segment)
201201
),
202202
seq($.replace_region_clause, 'WITH',
203-
choice($.content_literal, $.content_from_segment, $.case_stmt, $.ed_stmt)
203+
choice($.content_literal, $.content_from_segment, $.line_filter)
204204
)
205205
)
206206
)
@@ -243,7 +243,8 @@ module.exports = grammar({
243243
update_move_clause_destination: $ => field('move_destination', seq(
244244
optional(seq('TO', $.singlefile_clause)), // `TO` can ONLY be used if it points to a different file
245245
$.insert_clause,
246-
optional($.relative_indentation)
246+
optional($.relative_indentation),
247+
optional($.line_filter)
247248
)),
248249

249250
// update_move_mos_clause, update_move_region_clause
@@ -386,7 +387,8 @@ module.exports = grammar({
386387
content_from_segment: $ => seq(
387388
optional($.singlefile_clause),
388389
$.marker_or_segment,
389-
optional($.relative_indentation)
390+
optional($.relative_indentation),
391+
optional($.line_filter)
390392
),
391393

392394
content_literal: $ => seq('CONTENT', field('content', $.string)),
@@ -405,6 +407,7 @@ module.exports = grammar({
405407

406408
// Filters
407409

410+
line_filter: $ => choice($.case_stmt, $.ed_stmt),
408411
case_stmt: $ => seq(
409412
'CASE', repeat1(seq(
410413
'WHEN', $.line_base,

test/corpus/update/move.case.txt

Lines changed: 90 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,36 @@ END;
4747
(number)))))))
4848
(relative_indentation
4949
(number))
50-
(case_stmt
51-
(line_base)
52-
(case_action)
53-
(line_base
54-
(string
55-
(single_quoted_string)))
56-
(case_action
57-
(loop_control
58-
(loop_break)))
59-
(line_base
60-
(string
61-
(single_quoted_string)))
62-
(case_action
63-
(loop_control
64-
(loop_break)))
65-
(line_base
66-
(number))
67-
(case_action
68-
(string
69-
(raw_string))
70-
(string
71-
(raw_string))
72-
(loop_control
73-
(loop_break)))
74-
(case_action
75-
(string
76-
(raw_string))
77-
(string
78-
(raw_string)))))))
50+
(line_filter
51+
(case_stmt
52+
(line_base)
53+
(case_action)
54+
(line_base
55+
(string
56+
(single_quoted_string)))
57+
(case_action
58+
(loop_control
59+
(loop_break)))
60+
(line_base
61+
(string
62+
(single_quoted_string)))
63+
(case_action
64+
(loop_control
65+
(loop_break)))
66+
(line_base
67+
(number))
68+
(case_action
69+
(string
70+
(raw_string))
71+
(string
72+
(raw_string))
73+
(loop_control
74+
(loop_break)))
75+
(case_action
76+
(string
77+
(raw_string))
78+
(string
79+
(raw_string))))))))
7980
(command_separator))
8081

8182
==================
@@ -117,35 +118,36 @@ END;
117118
(number)))))))
118119
(relative_indentation
119120
(number))
120-
(case_stmt
121-
(line_base)
122-
(case_action)
123-
(line_base
124-
(string
125-
(single_quoted_string)))
126-
(case_action
127-
(loop_control
128-
(loop_break)))
129-
(line_base
130-
(string
131-
(single_quoted_string)))
132-
(case_action
133-
(loop_control
134-
(loop_break)))
135-
(line_base
136-
(number))
137-
(case_action
138-
(string
139-
(raw_string))
140-
(string
141-
(raw_string))
142-
(loop_control
143-
(loop_break)))
144-
(case_action
145-
(string
146-
(raw_string))
147-
(string
148-
(raw_string)))))))
121+
(line_filter
122+
(case_stmt
123+
(line_base)
124+
(case_action)
125+
(line_base
126+
(string
127+
(single_quoted_string)))
128+
(case_action
129+
(loop_control
130+
(loop_break)))
131+
(line_base
132+
(string
133+
(single_quoted_string)))
134+
(case_action
135+
(loop_control
136+
(loop_break)))
137+
(line_base
138+
(number))
139+
(case_action
140+
(string
141+
(raw_string))
142+
(string
143+
(raw_string))
144+
(loop_control
145+
(loop_break)))
146+
(case_action
147+
(string
148+
(raw_string))
149+
(string
150+
(raw_string))))))))
149151
(command_separator))
150152

151153
==================
@@ -186,33 +188,34 @@ END;
186188
(single_quoted_string)))))))
187189
(relative_indentation
188190
(number))
189-
(case_stmt
190-
(line_base)
191-
(case_action)
192-
(line_base
193-
(string
194-
(single_quoted_string)))
195-
(case_action
196-
(loop_control
197-
(loop_break)))
198-
(line_base
199-
(string
200-
(single_quoted_string)))
201-
(case_action
202-
(loop_control
203-
(loop_break)))
204-
(line_base
205-
(number))
206-
(case_action
207-
(string
208-
(raw_string))
209-
(string
210-
(raw_string))
211-
(loop_control
212-
(loop_break)))
213-
(case_action
214-
(string
215-
(raw_string))
216-
(string
217-
(raw_string)))))))
191+
(line_filter
192+
(case_stmt
193+
(line_base)
194+
(case_action)
195+
(line_base
196+
(string
197+
(single_quoted_string)))
198+
(case_action
199+
(loop_control
200+
(loop_break)))
201+
(line_base
202+
(string
203+
(single_quoted_string)))
204+
(case_action
205+
(loop_control
206+
(loop_break)))
207+
(line_base
208+
(number))
209+
(case_action
210+
(string
211+
(raw_string))
212+
(string
213+
(raw_string))
214+
(loop_control
215+
(loop_break)))
216+
(case_action
217+
(string
218+
(raw_string))
219+
(string
220+
(raw_string))))))))
218221
(command_separator))

0 commit comments

Comments
 (0)