Skip to main content

Crate marginalia

Crate marginalia 

Source
Expand description

Trivia-preserving parsing and formatting for logos + lalrpop pipelines.

  • TriviaLexer wraps any Iterator<Item = Result<(usize, Tok, usize), E>> and records comments/blank lines on the side while the parser sees only semantic tokens.
  • attach places those trivia events on AST node spans as leading, trailing, or dangling comments.
  • pretty is a small Doc IR with explicit trivia slots that the renderer resolves against a CommentMap.

Trivia is generic over a kind enum K so downstream crates can carry a richer classification through every layer. The default K = BuiltinKind covers the common line/block distinction without any extra wiring.

See the calc example for an end-to-end integration.

Modules§

attach
Comment attachment.
pretty
Pretty-printing harness.

Structs§

Span
TriviaEvent
TriviaLexer
TriviaPiece
A trivia piece classified by the user’s token type.
TriviaTable

Enums§

BuiltinKind
Built-in trivia kinds for the common case where a language only needs to distinguish line from block comments.
Trivia
A piece of trivia recorded between two semantic tokens.

Traits§

Classify
Tokens that may carry trivia implement Classify so the lexer can split them off into a side table.
TriviaClass
Layout properties a trivia kind exposes to the renderer.

Functions§

span