This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/adt: support interpolation of bytes and bool
Also fixes bytes interpolation, which was still WIP. For bool: use JSON representation For bytes: assume bytes are UTF-8 and replace illegal characters according to the recommendations of the Unicode consortium and W3C requirement for character encodings. (So not the Go standard for replacement.) Details clarified in spec. Fixes #475. Change-Id: I94c068f8a73a3948194b179a33e556c37692c05f Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6951 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org> Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
- Loading branch information
Showing
8 changed files
with
134 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
-- in.cue -- | ||
bool1: "1+1=2: \(true)" | ||
bool1: "1+1=2: \(true)" | ||
bool2: "1+1=1: \(false)" | ||
|
||
// one replacement character | ||
b1: 'a\xED\x95a' | ||
bytes1s: "\(b1)" | ||
bytes1b: '\(b1)' | ||
|
||
// two replacement characters | ||
b2: 'a\x80\x95a' | ||
bytes2s: "\(b2)" | ||
bytes2b: '\(b2)' | ||
|
||
// preserve precision | ||
n1: "\(1) \(2.00)" | ||
|
||
// but normalize representation | ||
n2: "\(1e2)" | ||
-- out/eval -- | ||
(struct){ | ||
bool1: (string){ "1+1=2: true" } | ||
bool2: (string){ "1+1=1: false" } | ||
b1: (bytes){ 'a\xed\x95a' } | ||
bytes1s: (string){ "a�a" } | ||
bytes1b: (bytes){ 'a\xed\x95a' } | ||
b2: (bytes){ 'a\x80\x95a' } | ||
bytes2s: (string){ "a��a" } | ||
bytes2b: (bytes){ 'a\x80\x95a' } | ||
n1: (string){ "1 2.00" } | ||
n2: (string){ "1E+2" } | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
bool1: "1+1=2: \(true)" | ||
bool1: "1+1=2: \(true)" | ||
bool2: "1+1=1: \(false)" | ||
b1: 'a\xed\x95a' | ||
bytes1s: "\(〈0;b1〉)" | ||
bytes1b: '\(〈0;b1〉)' | ||
b2: 'a\x80\x95a' | ||
bytes2s: "\(〈0;b2〉)" | ||
bytes2b: '\(〈0;b2〉)' | ||
n1: "\(1) \(2.00)" | ||
n2: "\(1E+2)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters