Skip to main content

Crate ridx_syntax

Crate ridx_syntax 

Source
Expand description

Zero-dependency, lossless Rust lexer and CST foundation (ridx-syntax).

Guarantees for lex:

  • Lossless round-trip: concatenating &src[t.start as usize..t.end as usize] across all returned tokens reproduces src byte-for-byte on arbitrary UTF-8 input.
  • Panic-free and infallible: malformed or truncated overlay code (unclosed strings, raw strings, block comments, char literals, invalid escapes, stray bytes) produces tokens marked with HAS_ERROR rather than failing.
  • Context-free atomic punctuation: multi-character operators are represented as single-character punctuation tokens with JOINT_NEXT set when adjacent with no intervening trivia.

Re-exports§

pub use parser::parse;
pub use parser::parse_for_offset;
pub use syntax_kind::SyntaxKind;
pub use token::token_at;
pub use token::Token;
pub use token::TokenKind;
pub use token::HAS_ERROR;
pub use token::JOINT_NEXT;
pub use tree::NodeId;
pub use tree::SyntaxTree;

Modules§

name_res
Compiler-free local name resolution (name_res) over crate::SyntaxTree and ItemDb.
parser
An error-tolerant recursive-descent parser over the significant tokens. It never fails: what it cannot parse goes into Error nodes, and every token ends up in the tree.
sema_fn
Syntax-only function-body semantics over SyntaxTree: parameter descriptors, scope-aware parameter use analysis (with shadowing and macro TokenTree separation), own return / ? extraction, and tail expression lookup.
syntax_kind
The kinds of syntax tree nodes. Tokens are not nodes: a node covers a range of lexer tokens.
token
Token representation, kinds, flags, and binary-search offset lookup.
tree
A lossless syntax tree stored flat: nodes in preorder, each covering a range of lexer tokens. Trivia between significant tokens belongs to the innermost node covering both neighbours, and the root covers every token, so the source is recovered from the tokens alone.
ty_infer
Compiler-free local type inference engine (ty_infer) — Phase 3 (Checkboxes 3.1 + 3.2 + 3.3):

Functions§

lex
Tokenizes src into a contiguous, lossless sequence of Tokens.