Skip to content

Commit

Permalink
[YAMLParser] Unfold multi-line scalar values (#70898)
Browse files Browse the repository at this point in the history
Long scalar values can be split into multiple lines to improve
readability. The rules are described in Section 6.5. "Line Folding",
https://yaml.org/spec/1.2.2/#65-line-folding. In addition, for flow
scalar styles, the Spec states that "All leading and trailing white
space characters on each line are excluded from the content",
https://yaml.org/spec/1.2.2/#73-flow-scalar-styles.

The patch implements these unfolding rules for double-quoted,
single-quoted, and plain scalars.
  • Loading branch information
igorkudrin committed Nov 10, 2023
1 parent 483d740 commit 652cead
Show file tree
Hide file tree
Showing 23 changed files with 376 additions and 200 deletions.
9 changes: 7 additions & 2 deletions llvm/include/llvm/Support/YAMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,14 @@ class ScalarNode final : public Node {
private:
StringRef Value;

StringRef unescapeDoubleQuoted(StringRef UnquotedValue,
StringRef::size_type Start,
StringRef getDoubleQuotedValue(StringRef UnquotedValue,
SmallVectorImpl<char> &Storage) const;

static StringRef getSingleQuotedValue(StringRef RawValue,
SmallVectorImpl<char> &Storage);

static StringRef getPlainValue(StringRef RawValue,
SmallVectorImpl<char> &Storage);
};

/// A block scalar node is an opaque datum that can be presented as a
Expand Down

0 comments on commit 652cead

Please sign in to comment.