Skip to main content

ridx_syntax/
lib.rs

1/*
2 * rust-intelligence — Ultra-fast, zero-memory code intelligence for Rust
3 * Copyright (c) 2026 Alexander Panasenko
4 *
5 * Contact: alex@prod.codes
6 * Author: https://prod.codes/about/
7 * Project: https://github.com/alex09x/rust-intelligence
8 * SPDX-License-Identifier: MIT OR Apache-2.0
9 */
10
11//! Zero-dependency, lossless Rust lexer and CST foundation (`ridx-syntax`).
12//!
13//! Guarantees for [`lex`]:
14//! - Lossless round-trip: concatenating `&src[t.start as usize..t.end as usize]` across
15//!   all returned tokens reproduces `src` byte-for-byte on arbitrary UTF-8 input.
16//! - Panic-free and infallible: malformed or truncated overlay code (unclosed strings,
17//!   raw strings, block comments, char literals, invalid escapes, stray bytes) produces
18//!   tokens marked with [`HAS_ERROR`] rather than failing.
19//! - Context-free atomic punctuation: multi-character operators are represented as
20//!   single-character punctuation tokens with [`JOINT_NEXT`] set when adjacent with no
21//!   intervening trivia.
22
23mod char_class;
24mod keyword;
25mod lexer;
26pub mod name_res;
27pub mod parser;
28mod scan_char;
29mod scan_lit;
30mod scan_trivia;
31pub mod sema_fn;
32mod sema_macro;
33mod sema_pat;
34mod sema_scope;
35pub mod syntax_kind;
36pub mod token;
37pub mod tree;
38mod tree_dump;
39pub mod ty_infer;
40
41pub use lexer::lex;
42pub use parser::{parse, parse_for_offset};
43pub use syntax_kind::SyntaxKind;
44pub use token::{token_at, Token, TokenKind, HAS_ERROR, JOINT_NEXT};
45pub use tree::{NodeId, SyntaxTree};