Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cue/literal: expose some internal data
Browse files Browse the repository at this point in the history
1) whether a multi-line string was parsed
2) the whitespace common to each line of multiline strings.

Change-Id: I69cbdab6c464908fa89ebc1cefa412990df341f2
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9242
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Apr 2, 2021
1 parent 2115955 commit 276e164
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cue/literal/quote.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Form struct {
// - QuoteExact that fails with an error if a string cannot be represented
// without loss.
// - Handle auto-breaking for long lines (Swift-style, \-terminated lines).
// This is not supported yet in CUE, but may, and should be considred as
// This is not supported yet in CUE, but may, and should be considered as
// a possibility in API design.
// - Other possible convenience forms: Blob (auto-break bytes), String (bytes
// or string), Label.
Expand Down
10 changes: 10 additions & 0 deletions cue/literal/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func (q QuoteInfo) IsDouble() bool {
return q.char == '"'
}

// IsMulti reports whether a multi-line string was parsed.
func (q QuoteInfo) IsMulti() bool {
return q.multiline
}

// Whitespace returns prefix whitespace for multiline strings.
func (q QuoteInfo) Whitespace() string {
return q.whitespace
}

// ParseQuotes checks if the opening quotes in start matches the ending quotes
// in end and reports its type as q or an error if they do not matching or are
// invalid. nStart indicates the number of bytes used for the opening quote.
Expand Down

0 comments on commit 276e164

Please sign in to comment.