diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs index 39b01a1cb..87a9d11ea 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
@@ -1,3 +1,20 @@ | |||
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(missing_debug_implementations, unconditional_recursion, future_incompatible)] | ||
15 | #![deny(bad_style, unsafe_code, missing_docs)] | ||
16 | //#![warn(unreachable_pub)] // rust-lang/rust#47816 | ||
17 | |||
1 | extern crate unicode_xid; | 18 | extern crate unicode_xid; |
2 | 19 | ||
3 | mod text; | 20 | mod text; |
@@ -6,17 +23,20 @@ mod lexer; | |||
6 | mod parser; | 23 | mod parser; |
7 | 24 | ||
8 | #[cfg_attr(rustfmt, rustfmt_skip)] | 25 | #[cfg_attr(rustfmt, rustfmt_skip)] |
26 | #[allow(missing_docs)] | ||
9 | pub mod syntax_kinds; | 27 | pub mod syntax_kinds; |
10 | pub use text::{TextRange, TextUnit}; | 28 | pub use text::{TextRange, TextUnit}; |
11 | pub use tree::{File, FileBuilder, Node, Sink, SyntaxKind, Token}; | 29 | pub use tree::{File, FileBuilder, Node, Sink, SyntaxKind, Token}; |
12 | pub use lexer::{next_token, tokenize}; | 30 | pub use lexer::{next_token, tokenize}; |
13 | pub use parser::parse; | 31 | pub use parser::parse; |
14 | 32 | ||
33 | /// Utilities for simple uses of the parser. | ||
15 | pub mod utils { | 34 | pub mod utils { |
16 | use std::fmt::Write; | 35 | use std::fmt::Write; |
17 | 36 | ||
18 | use {File, Node}; | 37 | use {File, Node}; |
19 | 38 | ||
39 | /// Parse a file and create a string representation of the resulting parse tree. | ||
20 | pub fn dump_tree(file: &File) -> String { | 40 | pub fn dump_tree(file: &File) -> String { |
21 | let mut result = String::new(); | 41 | let mut result = String::new(); |
22 | go(file.root(), &mut result, 0); | 42 | go(file.root(), &mut result, 0); |