Summary
Add first-class interval literals to the Expressif grammar and syntax model.
Intervals should use an explicit I prefix and mathematical bound notation, while accepting both common bracket conventions.
Proposed syntax
Bounded intervals
I[1, 10] // inclusive lower, inclusive upper
I[1, 10) // inclusive lower, exclusive upper
I(1, 10] // exclusive lower, inclusive upper
I(1, 10) // exclusive lower, exclusive upper
Also accept the continental-European notation using reversed square brackets:
I[1, 10[ // inclusive lower, exclusive upper
I]1, 10] // exclusive lower, inclusive upper
I]1, 10[ // exclusive lower, exclusive upper
The two notations are aliases and must produce the same syntax/AST semantics.
Infinite bounds
Expressif already uses +INF and -INF. They should be valid interval bounds:
I[-INF, +INF]
I[0, +INF]
I]0, +INF]
I[-INF, 0]
I[-INF, 0[
Existing sign-oriented shorthands
Preserve the established interval forms and map them to the corresponding first-class interval semantics:
I(0+) // zero or positive
I(+) // positive
I(0-) // zero or negative
I(-) // negative
Equivalent semantics:
I(0+) == [0, +INF]
I(+) == ]0, +INF]
I(0-) == [-INF, 0]
I(-) == [-INF, 0[
Dates and temporal values
Interval bounds should use the canonical Expressif literal syntax. Dates must therefore remain explicit typed literals:
I[#"2022-12-10", #"2022-12-31"[
Do not accept bare date-looking tokens such as:
I[2022-12-10, 2022-12-31]
because 2022-12-10 is otherwise lexically indistinguishable from arithmetic subtraction. The canonical date literal is #"2022-12-10".
Syntax model
The syntax/AST representation should normalize notation differences and expose at least:
- lower bound value
- upper bound value
- lower-bound inclusivity
- upper-bound inclusivity
- infinite bounds where applicable
For example, these should have identical semantics:
Acceptance criteria
- Parse bounded intervals with inclusive/exclusive endpoints.
- Accept both parenthesis and European reversed-square-bracket notation.
- Support
+INF and -INF as interval bounds.
- Support the existing
(0+), (+), (0-), and (-) interval concepts through the new interval literal syntax.
- Require canonical Expressif literals for temporal bounds, e.g.
#"2022-12-10".
- Normalize equivalent spellings to the same syntax/AST semantics.
- Add grammar tests, syntax-node tests, and C# bindings for interval literals.
Summary
Add first-class interval literals to the Expressif grammar and syntax model.
Intervals should use an explicit
Iprefix and mathematical bound notation, while accepting both common bracket conventions.Proposed syntax
Bounded intervals
Also accept the continental-European notation using reversed square brackets:
The two notations are aliases and must produce the same syntax/AST semantics.
Infinite bounds
Expressif already uses
+INFand-INF. They should be valid interval bounds:Existing sign-oriented shorthands
Preserve the established interval forms and map them to the corresponding first-class interval semantics:
Equivalent semantics:
Dates and temporal values
Interval bounds should use the canonical Expressif literal syntax. Dates must therefore remain explicit typed literals:
Do not accept bare date-looking tokens such as:
because
2022-12-10is otherwise lexically indistinguishable from arithmetic subtraction. The canonical date literal is#"2022-12-10".Syntax model
The syntax/AST representation should normalize notation differences and expose at least:
For example, these should have identical semantics:
Acceptance criteria
+INFand-INFas interval bounds.(0+),(+),(0-), and(-)interval concepts through the new interval literal syntax.#"2022-12-10".