mirror of
https://github.com/comby-tools/comby.git
synced 2024-09-11 13:25:36 +03:00
Consecutive newline holes should match consecutive lines
This commit is contained in:
parent
c5a86ab5df
commit
45d5505c4e
@ -496,12 +496,10 @@ module Make (Syntax : Syntax.S) = struct
|
||||
|
||||
| Hole Line (identifier, _dimension) ->
|
||||
let allowed =
|
||||
let until_char = '\n' in
|
||||
let allowed = any_char |>> String.of_char in
|
||||
let allowed = (not_followed_by (char until_char) "" >> allowed) in
|
||||
allowed
|
||||
let allowed = many1 (is_not (char '\n')) in
|
||||
allowed >>= fun x -> return [(String.of_char_list x)^"\n"]
|
||||
in
|
||||
let hole_semantics = many1 (not_followed_by rest "" >> allowed) in
|
||||
let hole_semantics = allowed << char '\n' in
|
||||
record_matches identifier hole_semantics
|
||||
|
||||
| Hole Blank (identifier, _dimension) ->
|
||||
|
@ -42,10 +42,10 @@ derp
|
||||
let rewrite_template = {|{:[x]}|} in
|
||||
run source match_template rewrite_template;
|
||||
[%expect_exact {|
|
||||
{foo.}
|
||||
{foo.bar.quux}
|
||||
{derp}
|
||||
|}]
|
||||
{foo.
|
||||
}{foo.bar.quux
|
||||
}{derp
|
||||
}|}]
|
||||
|
||||
let%expect_test "leading_indentation" =
|
||||
let run = run_all in
|
||||
@ -79,3 +79,36 @@ let%expect_test "alphanum_partial_match" =
|
||||
let rewrite_template = {|{:[x]}|} in
|
||||
run source match_template rewrite_template;
|
||||
[%expect_exact {| foo. {a} derp|}]
|
||||
|
||||
let%expect_test "newline_matcher_should_not_be_sat_on_space" =
|
||||
let run = run_all in
|
||||
let source =
|
||||
{|a b c d
|
||||
e f g h|} in
|
||||
let match_template = {|:[line\n] |} in
|
||||
let rewrite_template = {|{:[line]}|} in
|
||||
run source match_template rewrite_template;
|
||||
[%expect_exact {|{a b c d
|
||||
}e f g h|}];
|
||||
|
||||
let run = run_all in
|
||||
let source =
|
||||
{|a b c d
|
||||
e f g h|} in
|
||||
let match_template = {|:[line\n]:[next]|} in
|
||||
let rewrite_template = {|{:[line]}|} in
|
||||
run source match_template rewrite_template;
|
||||
[%expect_exact {|{a b c d
|
||||
}|}];
|
||||
|
||||
let run = run_all in
|
||||
let source =
|
||||
{|a b c d
|
||||
e f g h
|
||||
|} in
|
||||
let match_template = {|:[line1\n]:[next\n]|} in
|
||||
let rewrite_template = {|{:[line1]|:[next]}|} in
|
||||
run source match_template rewrite_template;
|
||||
[%expect_exact {|{a b c d
|
||||
|e f g h
|
||||
}|}]
|
||||
|
Loading…
Reference in New Issue
Block a user