Skip to main content

Module source

Module source 

Source
Expand description

Source-level document representation with layout metadata.

Used for programmatic construction of Eure documents with preserved formatting information (comments, section ordering, etc.). Source-level document representation for programmatic construction and formatting.

This module provides types for representing Eure source structure as an AST, while actual values are referenced via [NodeId] into an [EureDocument].

The structure directly mirrors the Eure grammar from eure.par:

Eure: [ ValueBinding ] { Binding } { Section } ;
Binding: Keys BindingRhs ;
  BindingRhs: ValueBinding | SectionBinding | TextBinding ;
Section: At Keys SectionBody ;
  SectionBody: [ ValueBinding ] { Binding } | Begin Eure End ;

§Design

SourceDocument
├── EureDocument (semantic data)
└── sources: Vec<EureSource> (arena)
    └── EureSource
        ├── leading_trivia: Vec<Trivia>
        ├── value: Option<NodeId>
        ├── bindings: Vec<BindingSource>
        │   └── trivia_before: Vec<Trivia>
        ├── sections: Vec<SectionSource>
        │   └── trivia_before: Vec<Trivia>
        └── trailing_trivia: Vec<Trivia>

Trivia (comments and blank lines) is preserved for round-trip formatting.

Structs§

ArrayElementSource
Layout information for an array element.
BindingSource
A binding statement: path followed by value or block.
EureSource
A source-level Eure document/block.
SectionSource
A section statement: @ path followed by body.
SourceDocument
A document with source structure metadata.
SourceId
Index into the sources arena.
SourcePathSegment
A segment in a source path.

Enums§

BindSource
The right-hand side of a binding.
Comment
A comment in the source.
SectionBody
The body of a section.
SourceKey
A key in source representation.
StringStyle
Syntax style for string keys (for round-trip formatting).
Trivia
Trivia: comments and blank lines that appear between statements.

Type Aliases§

SourcePath
A path in source representation.