2018-01-28 01:29:14 +00:00
|
|
|
//! 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 11:08:06 +00:00
|
|
|
#![forbid(
|
|
|
|
missing_debug_implementations,
|
|
|
|
unconditional_recursion,
|
|
|
|
future_incompatible
|
|
|
|
)]
|
2018-07-29 10:51:55 +00:00
|
|
|
#![deny(bad_style, missing_docs)]
|
|
|
|
#![allow(missing_docs)]
|
2018-01-28 01:29:14 +00:00
|
|
|
//#![warn(unreachable_pub)] // rust-lang/rust#47816
|
|
|
|
|
2018-07-31 12:40:40 +00:00
|
|
|
extern crate itertools;
|
2018-07-30 11:08:06 +00:00
|
|
|
extern crate unicode_xid;
|
2018-08-01 11:55:37 +00:00
|
|
|
extern crate drop_bomb;
|
2018-08-01 19:07:09 +00:00
|
|
|
extern crate parking_lot;
|
2018-08-13 11:24:22 +00:00
|
|
|
extern crate smol_str;
|
|
|
|
extern crate text_unit;
|
2017-12-29 20:33:04 +00:00
|
|
|
|
2018-07-31 12:40:40 +00:00
|
|
|
pub mod algo;
|
|
|
|
pub mod ast;
|
2017-12-28 21:56:36 +00:00
|
|
|
mod lexer;
|
2018-07-31 20:38:19 +00:00
|
|
|
#[macro_use]
|
|
|
|
mod parser_api;
|
|
|
|
mod grammar;
|
|
|
|
mod parser_impl;
|
|
|
|
|
2018-07-29 12:16:07 +00:00
|
|
|
mod syntax_kinds;
|
2018-08-08 16:44:16 +00:00
|
|
|
mod yellow;
|
2018-07-30 12:25:52 +00:00
|
|
|
/// Utilities for simple uses of the parser.
|
|
|
|
pub mod utils;
|
2018-07-29 12:16:07 +00:00
|
|
|
|
|
|
|
pub use {
|
2018-08-09 14:43:39 +00:00
|
|
|
ast::{AstNode, File},
|
2018-07-30 11:08:06 +00:00
|
|
|
lexer::{tokenize, Token},
|
2018-07-29 12:16:07 +00:00
|
|
|
syntax_kinds::SyntaxKind,
|
2018-07-30 11:08:06 +00:00
|
|
|
text_unit::{TextRange, TextUnit},
|
2018-08-09 18:27:44 +00:00
|
|
|
yellow::{SyntaxNode, SyntaxNodeRef, SyntaxRoot, TreeRoot, SyntaxError},
|
2018-07-29 12:16:07 +00:00
|
|
|
};
|
|
|
|
|
2018-08-01 07:51:42 +00:00
|
|
|
|
2018-08-01 07:40:07 +00:00
|
|
|
pub fn parse(text: &str) -> SyntaxNode {
|
2018-07-29 12:16:07 +00:00
|
|
|
let tokens = tokenize(&text);
|
2018-07-31 20:38:19 +00:00
|
|
|
parser_impl::parse::<yellow::GreenBuilder>(text, &tokens)
|
2018-07-29 12:16:07 +00:00
|
|
|
}
|