Scott Linder f3487c7be9 [YAMLParser] Add multi-line literal folding support
Last year I was working at Swift to add support for [Localization of Compiler Diagnostic Messages](https://forums.swift.org/t/localization-of-compiler-diagnostic-messages/36412/41). We are currently using YAML as the new diagnostic format. The LLVM::YAMLParser didn't have a support for multiline string literal folding and it's crucial to have that for the diagnostic message to help us keep up with the 80 columns rule. Therefore, I decided to add a multiline string literal folding support to the YAML parser.

Patch By: @HassanElDesouky (Hassan ElDesouky)

Differential Revision: https://reviews.llvm.org/D102590
2022-02-28 21:03:36 +00:00

104 lines
1.3 KiB
Plaintext

# RUN: yaml-bench -canonical %s | FileCheck %s
# CHECK: ? !!str "literal_strip"
# CHECK: : !!str "Hello\n\n\nworld\non\nmultiple \n\n\nlines\n\nfoo bar"
# CHECK: ? !!str "literal_clip"
# CHECK: : !!str "Hello\n\n\nworld\non\nmultiple \n\n\nlines\n\nfoo bar\n"
# CHECK: ? !!str "literal_keep"
# CHECK: : !!str "Hello\n\n\nworld\non\nmultiple \n\n\nlines\n\nfoo bar\n\n\n\n"
# CHECK: ? !!str "folded_strip"
# CHECK: : !!str "Hello\n\nworld on multiple \n\nlines\nfoo bar"
# CHECK: ? !!str "folded_clip"
# CHECK: : !!str "Hello\n\nworld on multiple \n\nlines\nfoo bar\n"
# CHECK: ? !!str "folded_keep"
# CHECK: : !!str "Hello\n\nworld on multiple \n\nlines\nfoo bar\n\n\n"
literal_strip: |-
Hello
world
on
multiple
lines
foo bar
literal_clip: |
Hello
world
on
multiple
lines
foo bar
literal_keep: |+
Hello
world
on
multiple
lines
foo bar
folded_strip: >-
Hello
world
on
multiple
lines
foo bar
folded_clip: >
Hello
world
on
multiple
lines
foo bar
folded_keep: >+
Hello
world
on
multiple
lines
foo bar