Skip to main content

Crate drawlang_syntax

Crate drawlang_syntax 

Source
Expand description

Lexer, parser, lossless-enough syntax tree, and formatter for drawlang.

Design requirements (see docs/DESIGN.md):

  • Error recovery: report all errors in a file, never stop at the first.
  • Every token and node carries a span; diagnostics point at exact source.
  • Statements carry their comments so drawlang fmt round-trips them.

Re-exports§

pub use diag::Diagnostic;
pub use diag::Severity;
pub use span::SourceFile;
pub use span::Span;

Modules§

ast
AST. Every node carries its span; statements carry their leading and trailing comments so the formatter can reproduce them.
diag
Diagnostics: structured errors/warnings with spans, rendered Rust-style (colored, with source excerpts and carets) or as JSON for agents.
fmt
Canonical formatter. One statement per line, two-space indent, comments preserved, at most one consecutive blank line. Idempotent: fmt(fmt(x)) == fmt(x).
lexer
Lexer. Newlines are significant (they terminate statements and properties), comments are kept as tokens so the formatter can preserve them, and 2x4 lexes as a single grid-dimension token.
parser
Recursive-descent parser with error recovery: a malformed statement is reported and skipped, and parsing continues, so one pass reports every error in the file.
span
Byte-offset spans and source-file line/column mapping.

Structs§

Parsed

Functions§

parse_source
Lex + parse. Always returns an AST (possibly partial) plus every diagnostic found, sorted by source position.