Skip to content

Commit 2f43271

Browse files
committed
fix(codemod): restore accidentally deleted generic key:value handler
The generic line-start regex (key: value -> key value) was accidentally deleted during an earlier edit, leaving the output line orphaned inside the generic heredoc handler. This caused ALL metadata fields to retain their colons, breaking many maps.
1 parent d4279c6 commit 2f43271

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

exe/codemod-imp-to-isc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ module Interscript
197197
def convert_metadata_block
198198
# Find the opening brace and consume until matching close, transforming
199199
# `key: value` -> `key value` and `description: |` / `notes:` heredocs.
200-
return unless @scanner.scan(/\s*\{/)
200+
return unless @scanner.scan(/[ \t]*\{/)
201201

202202
@out << " {"
203203
depth = 1
@@ -332,9 +332,9 @@ module Interscript
332332
@out << "\n#{indent}#{field} { "
333333
convert_indented_block_until_dedent(indent)
334334
@out << " }"
335+
elsif @scanner.scan(/(?:\A|\n)([ \t]+)([A-Za-z_][\w]*)[ \t]*:[ \t]*/)
335336
# key: value -> key value, only when the key is at the start of a
336-
# (indented) line. Use [ \t] instead of \s to avoid eating newlines
337-
# (which would merge `key:\n next:` into `key next:`).
337+
# (indented) line. Use [ \t] instead of \s to avoid eating newlines.
338338
@out << "\n#{@scanner[1]}#{@scanner[2]} "
339339
elsif @scanner.scan(/"/)
340340
@out << '"'
@@ -389,9 +389,8 @@ module Interscript
389389
# Hit the enclosing metadata `}` (possibly after blank lines).
390390
return
391391
elsif @scanner.scan(/\n[ \t]*\n/)
392-
# Blank line(s) between items — preserve one newline. Do NOT
393-
# consume the indent of the next item; the next-item regexes
394-
# require the indent prefix.
392+
# Blank line(s) — preserve one newline. Do NOT consume the
393+
# indent of the next item.
395394
@out << "\n"
396395
elsif @scanner.scan(/\n([ \t]+)-[ \t]*\|[ \t]*\n/)
397396
# `|` heredoc form
@@ -487,7 +486,7 @@ module Interscript
487486
end
488487

489488
def convert_tests_block
490-
return unless @scanner.scan(/\s*\{/)
489+
return unless @scanner.scan(/[ \t]*\{/)
491490
@out << " {"
492491
depth = 1
493492
until @scanner.eos? || depth == 0
@@ -519,7 +518,7 @@ module Interscript
519518
end
520519

521520
def convert_aliases_block
522-
return unless @scanner.scan(/\s*\{/)
521+
return unless @scanner.scan(/[ \t]*\{/)
523522
@out << " {"
524523
depth = 1
525524
until @scanner.eos? || depth == 0
@@ -588,7 +587,7 @@ module Interscript
588587
# `stage(translit) {` becomes `stage translit {`.
589588
if @scanner.scan(/\s*\(([A-Za-z_]\w*)\)\s*\{/)
590589
@out << " #{@scanner[1]} {"
591-
elsif @scanner.scan(/\s*\{/)
590+
elsif @scanner.scan(/[ \t]*\{/)
592591
@out << " main {"
593592
elsif @scanner.scan(/\s+([A-Za-z_]\w*)\s*\{/)
594593
@out << " #{@scanner[1]} {"

lib/interscript/isc/grammar/concerns/items.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module Items
5656

5757
rule(:any_constructor) do
5858
str("any") >> str("(") >> whitespace? >>
59-
(range_arg | set_arg | alias_arg).as(:any) >>
59+
(range_arg | set_arg | alias_arg | item.as(:any_item)).as(:any) >>
6060
whitespace? >> str(")")
6161
end
6262

0 commit comments

Comments
 (0)