diff --git a/conformance/README.md b/conformance/README.md index 2383f6a..c0da477 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -660,7 +660,7 @@ test ::= "(" "document" name-string? fragment* continuation ")" name-string ::= string -fragment ::= "(" "text" string* ")" +fragment ::= "(" "text" text_input* ")" | "(" "binary" bytes* ")" | "(" "ivm" int int ")" | "(" "toplevel" ast* ")" @@ -680,8 +680,11 @@ extension ::= "(" "then" name-string? fragment* continuation ")" each-branch ::= name-string? fragment -bytes ::= int // In the range 0..255 - | string // Containing hexadecimal digit pairs with optional whitespace +text_input ::= int // In the range 0..255 + | string + +bytes ::= int // In the range 0..255 + | string // Containing hexadecimal digit pairs with optional whitespace ``` TODO: Explain `ast` diff --git a/conformance/core/empty_document.ion b/conformance/core/empty_document.ion index f901ea7..98fa6ed 100644 --- a/conformance/core/empty_document.ion +++ b/conformance/core/empty_document.ion @@ -56,9 +56,9 @@ // With empty fragments -(ion_1_0 (bytes) (produces)) -(ion_1_1 (bytes) (produces)) -(ion_1_x (bytes) (produces)) +(ion_1_0 (binary) (produces)) +(ion_1_1 (binary) (produces)) +(ion_1_x (binary) (produces)) (document (text) (produces)) (ion_1_0 (text) (produces)) diff --git a/conformance/data_model/integer.ion b/conformance/data_model/integer.ion index a718090..afb350b 100644 --- a/conformance/data_model/integer.ion +++ b/conformance/data_model/integer.ion @@ -5,44 +5,44 @@ (then "in Ion 1.0 binary" (ivm 1 0) (each "with length in type code" - (bytes "20") - (bytes "21 00") - (bytes "22 00 00") - (bytes "24 00 00 00 00") - (bytes "28 00 00 00 00 00 00 00 00") - (bytes "2D 00 00 00 00 00 00 00 00 00 00 00 00 00") + (binary "20") + (binary "21 00") + (binary "22 00 00") + (binary "24 00 00 00 00") + (binary "28 00 00 00 00 00 00 00 00") + (binary "2D 00 00 00 00 00 00 00 00 00 00 00 00 00") "with length as varuint" - (bytes "2E 80") - (bytes "2E 81 00") - (bytes "2E 82 00 00") - (bytes "2E 84 00 00 00 00") - (bytes "2E 88 00 00 00 00 00 00 00 00") - (bytes "2E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00") + (binary "2E 80") + (binary "2E 81 00") + (binary "2E 82 00 00") + (binary "2E 84 00 00 00 00") + (binary "2E 88 00 00 00 00 00 00 00 00") + (binary "2E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00") (denotes 0))) (then "in Ion 1.1 binary" (ivm 1 1) (each "with length in opcode" - (bytes "60") - (bytes "61 00") - (bytes "62 00 00") - (bytes "63 00 00 00") - (bytes "64 00 00 00 00") - (bytes "65 00 00 00 00 00") - (bytes "66 00 00 00 00 00 00") - (bytes "67 00 00 00 00 00 00 00") - (bytes "68 00 00 00 00 00 00 00 00") + (binary "60") + (binary "61 00") + (binary "62 00 00") + (binary "63 00 00 00") + (binary "64 00 00 00 00") + (binary "65 00 00 00 00 00") + (binary "66 00 00 00 00 00 00") + (binary "67 00 00 00 00 00 00 00") + (binary "68 00 00 00 00 00 00 00 00") "with length in flexuint" - (bytes "F6 01") - (bytes "F6 03 00") - (bytes "F6 05 00 00") - (bytes "F6 07 00 00 00") - (bytes "F6 09 00 00 00 00") - (bytes "F6 0B 00 00 00 00 00") - (bytes "F6 0D 00 00 00 00 00 00") - (bytes "F6 0F 00 00 00 00 00 00 00") - (bytes "F6 11 00 00 00 00 00 00 00 00") - (bytes "F6 13 00 00 00 00 00 00 00 00 00") - (bytes "F6 15 00 00 00 00 00 00 00 00 00 00") + (binary "F6 01") + (binary "F6 03 00") + (binary "F6 05 00 00") + (binary "F6 07 00 00 00") + (binary "F6 09 00 00 00 00") + (binary "F6 0B 00 00 00 00 00") + (binary "F6 0D 00 00 00 00 00 00") + (binary "F6 0F 00 00 00 00 00 00 00") + (binary "F6 11 00 00 00 00 00 00 00 00") + (binary "F6 13 00 00 00 00 00 00 00 00 00") + (binary "F6 15 00 00 00 00 00 00 00 00 00 00") (denotes 0))) (each "in Ion 1.0 text" (ivm 1 0) @@ -68,40 +68,40 @@ (then "in Ion 1.0 binary" (ivm 1 0) (each "with length in type code" - (bytes "21 01") - (bytes "22 00 01") - (bytes "24 00 00 00 01") - (bytes "28 00 00 00 00 00 00 00 01") - (bytes "2D 00 00 00 00 00 00 00 00 00 00 00 00 01") + (binary "21 01") + (binary "22 00 01") + (binary "24 00 00 00 01") + (binary "28 00 00 00 00 00 00 00 01") + (binary "2D 00 00 00 00 00 00 00 00 00 00 00 00 01") "with length as varuint" - (bytes "2E 81 01") - (bytes "2E 82 00 01") - (bytes "2E 84 00 00 00 01") - (bytes "2E 88 00 00 00 00 00 00 00 01") - (bytes "2E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01") + (binary "2E 81 01") + (binary "2E 82 00 01") + (binary "2E 84 00 00 00 01") + (binary "2E 88 00 00 00 00 00 00 00 01") + (binary "2E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01") (denotes 1))) (then "in Ion 1.1 binary" (ivm 1 1) (each "with length in opcode" - (bytes "61 01") - (bytes "62 01 00") - (bytes "63 01 00 00") - (bytes "64 01 00 00 00") - (bytes "65 01 00 00 00 00") - (bytes "66 01 00 00 00 00 00") - (bytes "67 01 00 00 00 00 00 00") - (bytes "68 01 00 00 00 00 00 00 00") + (binary "61 01") + (binary "62 01 00") + (binary "63 01 00 00") + (binary "64 01 00 00 00") + (binary "65 01 00 00 00 00") + (binary "66 01 00 00 00 00 00") + (binary "67 01 00 00 00 00 00 00") + (binary "68 01 00 00 00 00 00 00 00") "with length in flexuint" - (bytes "F6 03 01") - (bytes "F6 05 01 00") - (bytes "F6 07 01 00 00") - (bytes "F6 09 01 00 00 00") - (bytes "F6 0B 01 00 00 00 00") - (bytes "F6 0D 01 00 00 00 00 00") - (bytes "F6 0F 01 00 00 00 00 00 00") - (bytes "F6 11 01 00 00 00 00 00 00 00") - (bytes "F6 13 01 00 00 00 00 00 00 00 00") - (bytes "F6 15 01 00 00 00 00 00 00 00 00 00") + (binary "F6 03 01") + (binary "F6 05 01 00") + (binary "F6 07 01 00 00") + (binary "F6 09 01 00 00 00") + (binary "F6 0B 01 00 00 00 00") + (binary "F6 0D 01 00 00 00 00 00") + (binary "F6 0F 01 00 00 00 00 00 00") + (binary "F6 11 01 00 00 00 00 00 00 00") + (binary "F6 13 01 00 00 00 00 00 00 00 00") + (binary "F6 15 01 00 00 00 00 00 00 00 00 00") (denotes 1))) (each "in Ion 1.0 text" (ivm 1 0) @@ -124,40 +124,40 @@ (then "in Ion 1.0 binary" (ivm 1 0) (each "with length in type code" - (bytes "31 01") - (bytes "32 00 01") - (bytes "34 00 00 00 01") - (bytes "38 00 00 00 00 00 00 00 01") - (bytes "3D 00 00 00 00 00 00 00 00 00 00 00 00 01") + (binary "31 01") + (binary "32 00 01") + (binary "34 00 00 00 01") + (binary "38 00 00 00 00 00 00 00 01") + (binary "3D 00 00 00 00 00 00 00 00 00 00 00 00 01") "with length as varuint" - (bytes "3E 81 01") - (bytes "3E 82 00 01") - (bytes "3E 84 00 00 00 01") - (bytes "3E 88 00 00 00 00 00 00 00 01") - (bytes "3E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01") + (binary "3E 81 01") + (binary "3E 82 00 01") + (binary "3E 84 00 00 00 01") + (binary "3E 88 00 00 00 00 00 00 00 01") + (binary "3E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01") (denotes -1))) (then "in Ion 1.1 binary" (ivm 1 1) (each "with length in opcode" - (bytes "61 FF") - (bytes "62 FF FF") - (bytes "63 FF FF FF") - (bytes "64 FF FF FF FF") - (bytes "65 FF FF FF FF FF") - (bytes "66 FF FF FF FF FF FF") - (bytes "67 FF FF FF FF FF FF FF") - (bytes "68 FF FF FF FF FF FF FF FF") + (binary "61 FF") + (binary "62 FF FF") + (binary "63 FF FF FF") + (binary "64 FF FF FF FF") + (binary "65 FF FF FF FF FF") + (binary "66 FF FF FF FF FF FF") + (binary "67 FF FF FF FF FF FF FF") + (binary "68 FF FF FF FF FF FF FF FF") "with length in flexuint" - (bytes "F6 03 FF") - (bytes "F6 05 FF FF") - (bytes "F6 07 FF FF FF") - (bytes "F6 09 FF FF FF FF") - (bytes "F6 0B FF FF FF FF FF") - (bytes "F6 0D FF FF FF FF FF FF") - (bytes "F6 0F FF FF FF FF FF FF FF") - (bytes "F6 11 FF FF FF FF FF FF FF FF") - (bytes "F6 13 FF FF FF FF FF FF FF FF FF") - (bytes "F6 15 FF FF FF FF FF FF FF FF FF FF") + (binary "F6 03 FF") + (binary "F6 05 FF FF") + (binary "F6 07 FF FF FF") + (binary "F6 09 FF FF FF FF") + (binary "F6 0B FF FF FF FF FF") + (binary "F6 0D FF FF FF FF FF FF") + (binary "F6 0F FF FF FF FF FF FF FF") + (binary "F6 11 FF FF FF FF FF FF FF FF") + (binary "F6 13 FF FF FF FF FF FF FF FF FF") + (binary "F6 15 FF FF FF FF FF FF FF FF FF FF") (denotes -1))) (each "in Ion 1.0 text" (ivm 1 0) @@ -180,36 +180,36 @@ (then "in Ion 1.0 binary" (ivm 1 0) (each "with length in type code" - (bytes "22 1C 4D") - (bytes "24 00 00 1C 4D") - (bytes "28 00 00 00 00 00 00 1C 4D") - (bytes "2D 00 00 00 00 00 00 00 00 00 00 00 1C 4D") + (binary "22 1C 4D") + (binary "24 00 00 1C 4D") + (binary "28 00 00 00 00 00 00 1C 4D") + (binary "2D 00 00 00 00 00 00 00 00 00 00 00 1C 4D") "with length as varuint" - (bytes "2E 82 1C 4D") - (bytes "2E 84 00 00 1C 4D") - (bytes "2E 88 00 00 00 00 00 00 1C 4D") - (bytes "2E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1C 4D") + (binary "2E 82 1C 4D") + (binary "2E 84 00 00 1C 4D") + (binary "2E 88 00 00 00 00 00 00 1C 4D") + (binary "2E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1C 4D") (denotes 7245))) (then "in Ion 1.1 binary" (ivm 1 1) (each "with length in opcode" - (bytes "62 4D 1C") - (bytes "63 4D 1C 00") - (bytes "64 4D 1C 00 00") - (bytes "65 4D 1C 00 00 00") - (bytes "66 4D 1C 00 00 00 00") - (bytes "67 4D 1C 00 00 00 00 00") - (bytes "68 4D 1C 00 00 00 00 00 00") + (binary "62 4D 1C") + (binary "63 4D 1C 00") + (binary "64 4D 1C 00 00") + (binary "65 4D 1C 00 00 00") + (binary "66 4D 1C 00 00 00 00") + (binary "67 4D 1C 00 00 00 00 00") + (binary "68 4D 1C 00 00 00 00 00 00") "with length in flexuint" - (bytes "F6 05 4D 1C") - (bytes "F6 07 4D 1C 00") - (bytes "F6 09 4D 1C 00 00") - (bytes "F6 0B 4D 1C 00 00 00") - (bytes "F6 0D 4D 1C 00 00 00 00") - (bytes "F6 0F 4D 1C 00 00 00 00 00") - (bytes "F6 11 4D 1C 00 00 00 00 00 00") - (bytes "F6 13 4D 1C 00 00 00 00 00 00 00") - (bytes "F6 15 4D 1C 00 00 00 00 00 00 00 00") + (binary "F6 05 4D 1C") + (binary "F6 07 4D 1C 00") + (binary "F6 09 4D 1C 00 00") + (binary "F6 0B 4D 1C 00 00 00") + (binary "F6 0D 4D 1C 00 00 00 00") + (binary "F6 0F 4D 1C 00 00 00 00 00") + (binary "F6 11 4D 1C 00 00 00 00 00 00") + (binary "F6 13 4D 1C 00 00 00 00 00 00 00") + (binary "F6 15 4D 1C 00 00 00 00 00 00 00 00") (denotes 7245))) (each "in Ion 1.0 text" (ivm 1 0) @@ -243,36 +243,36 @@ (then "in Ion 1.0 binary" (ivm 1 0) (each "with length in type code" - (bytes "32 1C 4D") - (bytes "34 00 00 1C 4D") - (bytes "38 00 00 00 00 00 00 1C 4D") - (bytes "3D 00 00 00 00 00 00 00 00 00 00 00 1C 4D") + (binary "32 1C 4D") + (binary "34 00 00 1C 4D") + (binary "38 00 00 00 00 00 00 1C 4D") + (binary "3D 00 00 00 00 00 00 00 00 00 00 00 1C 4D") "with length as varuint" - (bytes "3E 82 1C 4D") - (bytes "3E 84 00 00 1C 4D") - (bytes "3E 88 00 00 00 00 00 00 1C 4D") - (bytes "3E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1C 4D") + (binary "3E 82 1C 4D") + (binary "3E 84 00 00 1C 4D") + (binary "3E 88 00 00 00 00 00 00 1C 4D") + (binary "3E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1C 4D") (denotes -7245))) (then "in Ion 1.1 binary" (ivm 1 1) (each "with length in opcode" - (bytes "62 B3 E3") - (bytes "63 B3 E3 FF") - (bytes "64 B3 E3 FF FF") - (bytes "65 B3 E3 FF FF FF") - (bytes "66 B3 E3 FF FF FF FF") - (bytes "67 B3 E3 FF FF FF FF FF") - (bytes "68 B3 E3 FF FF FF FF FF FF") + (binary "62 B3 E3") + (binary "63 B3 E3 FF") + (binary "64 B3 E3 FF FF") + (binary "65 B3 E3 FF FF FF") + (binary "66 B3 E3 FF FF FF FF") + (binary "67 B3 E3 FF FF FF FF FF") + (binary "68 B3 E3 FF FF FF FF FF FF") "with length in flexuint" - (bytes "F6 05 B3 E3") - (bytes "F6 07 B3 E3 FF") - (bytes "F6 09 B3 E3 FF FF") - (bytes "F6 0B B3 E3 FF FF FF") - (bytes "F6 0D B3 E3 FF FF FF FF") - (bytes "F6 0F B3 E3 FF FF FF FF FF") - (bytes "F6 11 B3 E3 FF FF FF FF FF FF") - (bytes "F6 13 B3 E3 FF FF FF FF FF FF FF") - (bytes "F6 15 B3 E3 FF FF FF FF FF FF FF FF") + (binary "F6 05 B3 E3") + (binary "F6 07 B3 E3 FF") + (binary "F6 09 B3 E3 FF FF") + (binary "F6 0B B3 E3 FF FF FF") + (binary "F6 0D B3 E3 FF FF FF FF") + (binary "F6 0F B3 E3 FF FF FF FF FF") + (binary "F6 11 B3 E3 FF FF FF FF FF FF") + (binary "F6 13 B3 E3 FF FF FF FF FF FF FF") + (binary "F6 15 B3 E3 FF FF FF FF FF FF FF FF") (denotes -7245))) (each "in Ion 1.0 text" (ivm 1 0) @@ -306,18 +306,18 @@ (then "in Ion 1.0 binary" (ivm 1 0) (each "with length in type code" - (bytes "29 12 34 56 78 9A BC DE F0 12") - (bytes "2D 00 00 00 00 12 34 56 78 9A BC DE F0 12") + (binary "29 12 34 56 78 9A BC DE F0 12") + (binary "2D 00 00 00 00 12 34 56 78 9A BC DE F0 12") "with length as varuint" - (bytes "2E 89 12 34 56 78 9A BC DE F0 12") - (bytes "2E 90 00 00 00 00 00 00 00 12 34 56 78 9A BC DE F0 12") + (binary "2E 89 12 34 56 78 9A BC DE F0 12") + (binary "2E 90 00 00 00 00 00 00 00 12 34 56 78 9A BC DE F0 12") (denotes 335812727670730321938))) (then "in Ion 1.1 binary" (ivm 1 1) (each "with length in flexuint" - (bytes "F6 13 12 F0 DE BC 9A 78 56 34 12") - (bytes "F6 15 12 F0 DE BC 9A 78 56 34 12 00") - (bytes "F6 17 12 F0 DE BC 9A 78 56 34 12 00 00") + (binary "F6 13 12 F0 DE BC 9A 78 56 34 12") + (binary "F6 15 12 F0 DE BC 9A 78 56 34 12 00") + (binary "F6 17 12 F0 DE BC 9A 78 56 34 12 00 00") (denotes 335812727670730321938))) (each "in Ion 1.0 text" (ivm 1 0) @@ -340,18 +340,18 @@ (then "in Ion 1.0 binary" (ivm 1 0) (each "with length in type code" - (bytes "39 12 34 56 78 9A BC DE F0 12") - (bytes "3D 00 00 00 00 12 34 56 78 9A BC DE F0 12") + (binary "39 12 34 56 78 9A BC DE F0 12") + (binary "3D 00 00 00 00 12 34 56 78 9A BC DE F0 12") "with length as varuint" - (bytes "3E 89 12 34 56 78 9A BC DE F0 12") - (bytes "3E 90 00 00 00 00 00 00 00 12 34 56 78 9A BC DE F0 12") + (binary "3E 89 12 34 56 78 9A BC DE F0 12") + (binary "3E 90 00 00 00 00 00 00 00 12 34 56 78 9A BC DE F0 12") (denotes -335812727670730321938))) (then "in Ion 1.1 binary" (ivm 1 1) (each "with length in flexuint" - (bytes "F6 13 EE 0F 21 43 65 87 A9 CB ED") - (bytes "F6 15 EE 0F 21 43 65 87 A9 CB ED FF") - (bytes "F6 17 EE 0F 21 43 65 87 A9 CB ED FF FF") + (binary "F6 13 EE 0F 21 43 65 87 A9 CB ED") + (binary "F6 15 EE 0F 21 43 65 87 A9 CB ED FF") + (binary "F6 17 EE 0F 21 43 65 87 A9 CB ED FF FF") (denotes -335812727670730321938))) (each "in Ion 1.0 text" (ivm 1 0) @@ -382,18 +382,18 @@ (signals "invalid leading zero"))) (ion_1_0 "integer zero encoded with type code 3 is invalid" - (each (bytes "30") - (bytes "31 00") - (bytes "32 00 00") - (bytes "34 00 00 00 00") - (bytes "38 00 00 00 00 00 00 00 00") - (bytes "3D 00 00 00 00 00 00 00 00 00 00 00 00 00 00") - (bytes "3E 80") - (bytes "3E 81 00") - (bytes "3E 82 00 00") - (bytes "3E 84 00 00 00 00") - (bytes "3E 88 00 00 00 00 00 00 00 00") - (bytes "3E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00") + (each (binary "30") + (binary "31 00") + (binary "32 00 00") + (binary "34 00 00 00 00") + (binary "38 00 00 00 00 00 00 00 00") + (binary "3D 00 00 00 00 00 00 00 00 00 00 00 00 00 00") + (binary "3E 80") + (binary "3E 81 00") + (binary "3E 82 00 00") + (binary "3E 84 00 00 00 00") + (binary "3E 88 00 00 00 00 00 00 00 00") + (binary "3E 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00") (signals "int zero may not be negative"))) (ion_1_x "an integer with an unexpected non-numeric character should raise an error" diff --git a/conformance/grammar.isl b/conformance/grammar.isl index 477afe3..4843f49 100644 --- a/conformance/grammar.isl +++ b/conformance/grammar.isl @@ -19,6 +19,14 @@ type::{ ] } +type::{ + name: text_input, + one_of: [ + string, + { type: int, valid_values: range::[0x00, 0xFF]}, + ] +} + type::{ name: codepoint, type: int, @@ -166,12 +174,12 @@ type::{ type::{ name: text_clause, - ordered_elements: [ { valid_values: [text, "text"] }, { type: string, occurs: range::[0, max] }, ] + ordered_elements: [ { valid_values: [text, "text"] }, { type: text_input, occurs: range::[0, max] }, ] } type::{ name: binary_clause, - ordered_elements: [ { valid_values: [binary, "binary", "bytes", bytes] }, { type: bytes, occurs: range::[0, max] }, ] + ordered_elements: [ { valid_values: [binary, "binary"] }, { type: bytes, occurs: range::[0, max] }, ] } // Expectations diff --git a/conformance/ivm.ion b/conformance/ivm.ion index ee5ff80..042310c 100644 --- a/conformance/ivm.ion +++ b/conformance/ivm.ion @@ -3,12 +3,12 @@ (document "IVMs don't appear in output data" (each (text "$ion_1_0") - (bytes "E0 01 00 EA") + (binary "E0 01 00 EA") (ivm 1 0) (toplevel '#$ion_1_0') (then (toplevel 1) (each (text "$ion_1_0") - (bytes "E0 01 00 EA") + (binary "E0 01 00 EA") (ivm 1 0) (toplevel '#$ion_1_0') (then (toplevel 2) @@ -17,7 +17,7 @@ (document "Invalid IVM version" (each (text "$ion_12_34") - (bytes "E0 0C 22 EA") + (binary "E0 0C 22 EA") (ivm 12 34) (toplevel '#$ion_12_34') (signals "Unsupported Ion version: 12.34")))