syntax-lab/SOURCE_REGION_EXPERIMENTS.md
2026-04-25 16:42:57 +02:00

16 lines
1.1 KiB
Markdown

# Source Region Parser Experiment Notes
## Current Parser Experiment
- The parser works directly with `CodePointIndex` and `CodePointSpan`; rich `Span` conversion is intentionally left to rendering or reporting code.
- Structured errors are currently enough to identify the failing region and the syntactic fact that failed, without committing to message text.
- Empty documents are valid because the document grammar is a sequence of expressions.
## Source Region Observations
- `SourceText.getSpan(CodePointSpan)` is the key boundary operation: parsers can stay low-level, while diagnostics can opt into line and column information later.
- Zero-width EOF spans are important for parse errors such as an unclosed list. The existing `eofSpan` support fits this well.
- Parser clients still need a few tiny local span helpers, such as current-code-point span and EOF cursor span.
- `renderSpan` returning structured `LineView` data works well for UI rendering because the application can choose its own DOM and styling without reimplementing line slicing.
## Potential Nice-To-Haves