Ignore leading/trailing/repeated slashes and ampersands. Closes #32.

This commit is contained in:
Tony Garnock-Jones 2023-10-29 14:51:03 +01:00
parent 49242bb4dc
commit ee0f9a79fd
1 changed files with 14 additions and 10 deletions

View File

@ -4,7 +4,7 @@ title: "Preserves Schema"
---
Tony Garnock-Jones <tonyg@leastfixedpoint.com>
February 2023. Version 0.3.1.
February 2023. Version 0.3.2.
[abnf]: https://tools.ietf.org/html/rfc7405
@ -189,12 +189,14 @@ with algebraic data types would produce a labelled-sum-of-products type.
### Alternation definitions.
OrPattern = AltPattern "/" AltPattern *("/" AltPattern)
OrPattern = [orsep] AltPattern 1*(orsep AltPattern) [orsep]
orsep = 1*"/"
The right-hand-side of a definition may supply two or more
*alternatives*. When parsing, the alternatives are tried in order; the
result of the first successful alternative is the result of the entire
parse.
The right-hand-side of a definition may supply two or more *alternatives*.
Alternatives are separated by any number of slashes `/`, and leading or
trailing slashes are ignored. When parsing, the alternatives are tried in
order; the result of the first successful alternative is the result of the
entire parse.
**Host-language types.** The type corresponding to an `OrPattern` is an
algebraic sum type, a union type, a variant type, or a concrete subclass
@ -223,13 +225,15 @@ there is any).
### Intersection definitions.
AndPattern = NamedPattern "&" NamedPattern *("&" NamedPattern)
AndPattern = [andsep] NamedPattern 1*(andsep NamedPattern) [andsep]
andsep = 1*"&"
The right-hand-side of a definition may supply two or more patterns, the
*intersection* of whose denotations is the denotation of the overall
definition. When parsing, every pattern is tried: if all succeed, the
resulting information is combined into a single type; otherwise, the
overall parse fails.
definition. The patterns are separated by any number of ampersands `&`,
and leading or trailing ampersands are ignored. When parsing, every
pattern is tried: if all succeed, the resulting information is combined
into a single type; otherwise, the overall parse fails.
When serializing, the terms resulting from serializing at each pattern
are *merged* together.