aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
blob: 953c9b8606407d1d525ec024f4cfb45ff7c27eb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! An experimental implementation of [Rust RFC#2256 libsyntax2.0][rfc#2256].
//!
//! The intent is to be an IDE-ready parser, i.e. one that offers
//!
//! - easy and fast incremental re-parsing,
//! - graceful handling of errors, and
//! - maintains all information in the source file.
//!
//! For more information, see [the RFC][rfc#2265], or [the working draft][RFC.md].
//!
//!   [rfc#2256]: <https://github.com/rust-lang/rfcs/pull/2256>
//!   [RFC.md]: <https://github.com/matklad/libsyntax2/blob/master/docs/RFC.md>

#![forbid(
    missing_debug_implementations,
    unconditional_recursion,
    future_incompatible
)]
#![deny(bad_style, missing_docs)]
#![allow(missing_docs)]
//#![warn(unreachable_pub)] // rust-lang/rust#47816

extern crate itertools;
extern crate text_unit;
extern crate unicode_xid;

pub mod algo;
pub mod ast;
mod lexer;
mod parser;
mod syntax_kinds;
/// Utilities for simple uses of the parser.
pub mod utils;
mod yellow;

pub use {
    ast::File,
    lexer::{tokenize, Token},
    syntax_kinds::SyntaxKind,
    text_unit::{TextRange, TextUnit},
    yellow::{SyntaxNode, SyntaxNodeRef, SyntaxRoot, TreeRoot},
};

pub(crate) use yellow::SyntaxError;

pub fn parse(text: String) -> SyntaxNode {
    let tokens = tokenize(&text);
    parser::parse::<yellow::GreenBuilder>(text, &tokens)
}