diff options
Diffstat (limited to 'crates/libsyntax2/src/lib.rs')
-rw-r--r-- | crates/libsyntax2/src/lib.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/lib.rs b/crates/libsyntax2/src/lib.rs new file mode 100644 index 000000000..ca33618a0 --- /dev/null +++ b/crates/libsyntax2/src/lib.rs | |||
@@ -0,0 +1,55 @@ | |||
1 | //! An experimental implementation of [Rust RFC#2256 libsyntax2.0][rfc#2256]. | ||
2 | //! | ||
3 | //! The intent is to be an IDE-ready parser, i.e. one that offers | ||
4 | //! | ||
5 | //! - easy and fast incremental re-parsing, | ||
6 | //! - graceful handling of errors, and | ||
7 | //! - maintains all information in the source file. | ||
8 | //! | ||
9 | //! For more information, see [the RFC][rfc#2265], or [the working draft][RFC.md]. | ||
10 | //! | ||
11 | //! [rfc#2256]: <https://github.com/rust-lang/rfcs/pull/2256> | ||
12 | //! [RFC.md]: <https://github.com/matklad/libsyntax2/blob/master/docs/RFC.md> | ||
13 | |||
14 | #![forbid( | ||
15 | missing_debug_implementations, | ||
16 | unconditional_recursion, | ||
17 | future_incompatible | ||
18 | )] | ||
19 | #![deny(bad_style, missing_docs)] | ||
20 | #![allow(missing_docs)] | ||
21 | //#![warn(unreachable_pub)] // rust-lang/rust#47816 | ||
22 | |||
23 | extern crate itertools; | ||
24 | extern crate text_unit; | ||
25 | extern crate unicode_xid; | ||
26 | extern crate drop_bomb; | ||
27 | extern crate parking_lot; | ||
28 | |||
29 | pub mod algo; | ||
30 | pub mod ast; | ||
31 | mod lexer; | ||
32 | #[macro_use] | ||
33 | mod parser_api; | ||
34 | mod grammar; | ||
35 | mod parser_impl; | ||
36 | |||
37 | mod syntax_kinds; | ||
38 | mod smol_str; | ||
39 | mod yellow; | ||
40 | /// Utilities for simple uses of the parser. | ||
41 | pub mod utils; | ||
42 | |||
43 | pub use { | ||
44 | ast::{AstNode, File}, | ||
45 | lexer::{tokenize, Token}, | ||
46 | syntax_kinds::SyntaxKind, | ||
47 | text_unit::{TextRange, TextUnit}, | ||
48 | yellow::{SyntaxNode, SyntaxNodeRef, SyntaxRoot, TreeRoot, SyntaxError}, | ||
49 | }; | ||
50 | |||
51 | |||
52 | pub fn parse(text: &str) -> SyntaxNode { | ||
53 | let tokens = tokenize(&text); | ||
54 | parser_impl::parse::<yellow::GreenBuilder>(text, &tokens) | ||
55 | } | ||