! enum checks
+[ "type Thing enum {}" parse-schema ] [ not-enough-entries? ] must-fail-with
+[ "type Thing enum { }" parse-schema ] [ not-enough-entries? ] must-fail-with
[
"type Alphabet enum {
A
! union checks
+[ "type Thing union {}" parse-schema ] [ not-enough-entries? ] must-fail-with
+[ "type Thing union { }" parse-schema ] [ not-enough-entries? ] must-fail-with
[ "type Thing union {int=0|int|str=0}" parse-schema ] [ duplicate-keys? ] must-fail-with
[ "type Thing union {int=0|uint|str=0}" parse-schema ] [ duplicate-values? ] must-fail-with
! struct checks
+[ "type Thing struct {}" parse-schema ] [ not-enough-entries? ] must-fail-with
+[ "type Thing struct { }" parse-schema ] [ not-enough-entries? ] must-fail-with
[ "type Thing struct { a: int b: int a: int }" parse-schema ] [ duplicate-keys? ] must-fail-with
[ "type Thing struct { a: void }" parse-schema ] [ cannot-be-void? ] must-fail-with
data = "data"~ length? => [[ <data> ]]
void = "void" => [[ void ]]
-enum-values = enum-value (ws enum-value)* => [[ first2 swap prefix ]]
+enum-values = (ws enum-value ws)*
enum-value = enum-value-name (ws "="~ ws number)?
enum-value-name = upper (upper|digit|[_])* => [[ first2 swap prefix >string ]]
enum = "enum"~ ws "{"~ ws enum-values ws "}"~ => [[ <enum> ]]
struct-field-name = alpha+ => [[ >string ]]
struct-field = struct-field-name ws ":"~ ws any-type => [[ >array ]]
-struct-fields = struct-field (ws struct-field)* => [[ first2 swap prefix ]]
-struct = "struct"~ ws "{"~ ws~ struct-fields ws "}"~ => [[ <struct> ]]
+struct-fields = (ws struct-field ws)*
+struct = "struct"~ ws "{"~ ws struct-fields ws "}"~ => [[ <struct> ]]
union-members = union-member (ws "|"~ ws union-member)* => [[ first2 swap prefix ]]
union-member = any-type (ws "="~ ws number)? => [[ >array ]]
-union = "union"~ ws "{"~ ws ("|"?)~ ws union-members ws ("|"?)~ ws "}"~ => [[ <union> ]]
+union = "union"~ ws "{"~ ws ("|"?)~ ws union-members? ws ("|"?)~ ws "}"~ => [[ <union> ]]
aggregate = optional|list|map|struct|union
user-type = "type"~ ws user-type-name ws any-type
=> [[ first2 [ 2array ] 2keep swap user-types [ ?set-at ] change ]]
-user-types = user-type (ws user-type)* => [[ first2 swap prefix ]]
-schema = ws user-types ws => [[ <schema> ]]
+schema = (ws user-type ws)* => [[ <schema> ]]
]=]