rust/src/lib.rs

51 lines
1.3 KiB
Rust
Raw Normal View History

//! 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>
2018-07-30 06:08:06 -05:00
#![forbid(
missing_debug_implementations,
unconditional_recursion,
future_incompatible
)]
2018-07-29 05:51:55 -05:00
#![deny(bad_style, missing_docs)]
#![allow(missing_docs)]
//#![warn(unreachable_pub)] // rust-lang/rust#47816
2018-07-28 05:07:10 -05:00
extern crate text_unit;
2018-07-30 06:08:06 -05:00
extern crate unicode_xid;
2018-07-30 15:45:10 -05:00
extern crate itertools;
2017-12-29 14:33:04 -06:00
2017-12-28 15:56:36 -06:00
mod lexer;
2017-12-31 14:34:29 -06:00
mod parser;
2018-07-29 07:16:07 -05:00
mod syntax_kinds;
2018-07-30 06:08:06 -05:00
mod yellow;
2018-07-30 07:25:52 -05:00
/// Utilities for simple uses of the parser.
pub mod utils;
2018-07-30 13:58:49 -05:00
pub mod ast;
2018-07-30 15:45:10 -05:00
pub mod algo;
2018-07-29 07:16:07 -05:00
pub use {
2018-07-30 06:08:06 -05:00
lexer::{tokenize, Token},
2018-07-29 07:16:07 -05:00
syntax_kinds::SyntaxKind,
2018-07-30 06:08:06 -05:00
text_unit::{TextRange, TextUnit},
2018-07-30 13:58:49 -05:00
yellow::{SyntaxNode, SyntaxNodeRef, TreeRoot, SyntaxRoot},
ast::File,
2018-07-29 07:16:07 -05:00
};
2018-07-30 06:08:06 -05:00
pub(crate) use yellow::SyntaxError;
2018-07-29 07:16:07 -05:00
pub fn parse(text: String) -> SyntaxNode {
let tokens = tokenize(&text);
parser::parse::<yellow::GreenBuilder>(text, &tokens)
}
2017-12-28 15:56:36 -06:00