aboutsummaryrefslogtreecommitdiff
path: root/src/tree
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-01-28 08:18:17 +0000
committerAleksey Kladov <[email protected]>2018-01-28 08:18:17 +0000
commit1417f26f820bd6428b528c3dc6127fabb084115a (patch)
treea943a0920b2eeb4be44eca9987aae6302bb9fac2 /src/tree
parentefadcf715862a2d96af0f57d2b53bfa325390779 (diff)
Document the design of `FileBuilder`
Diffstat (limited to 'src/tree')
-rw-r--r--src/tree/file_builder.rs16
-rw-r--r--src/tree/mod.rs2
2 files changed, 12 insertions, 6 deletions
diff --git a/src/tree/file_builder.rs b/src/tree/file_builder.rs
index 738705f02..47038496d 100644
--- a/src/tree/file_builder.rs
+++ b/src/tree/file_builder.rs
@@ -1,10 +1,16 @@
1// FIXME(CAD97): I don't understand this mod well enough to stub out docs for the public symbols yet 1//! This module provides a way to construct a `File`.
2#![allow(missing_docs)] 2//! It is intended to be completely decoupled from the
3 3//! parser, so as to allow to evolve the tree representation
4//! and the parser algorithm independently.
5//!
6//! The `Sink` trait is the bridge between the parser and the
7//! tree builder: the parser produces a stream of events like
8//! `start node`, `finish node`, and `FileBuilder` converts
9//! this stream to a real tree.
4use {SyntaxKind, TextRange, TextUnit}; 10use {SyntaxKind, TextRange, TextUnit};
5use super::{File, NodeData, NodeIdx, SyntaxErrorData}; 11use super::{File, NodeData, NodeIdx, SyntaxErrorData};
6 12
7pub trait Sink { 13pub(crate) trait Sink {
8 fn leaf(&mut self, kind: SyntaxKind, len: TextUnit); 14 fn leaf(&mut self, kind: SyntaxKind, len: TextUnit);
9 fn start_internal(&mut self, kind: SyntaxKind); 15 fn start_internal(&mut self, kind: SyntaxKind);
10 fn finish_internal(&mut self); 16 fn finish_internal(&mut self);
@@ -12,7 +18,7 @@ pub trait Sink {
12} 18}
13 19
14#[derive(Debug)] 20#[derive(Debug)]
15pub struct FileBuilder { 21pub(crate) struct FileBuilder {
16 text: String, 22 text: String,
17 nodes: Vec<NodeData>, 23 nodes: Vec<NodeData>,
18 errors: Vec<SyntaxErrorData>, 24 errors: Vec<SyntaxErrorData>,
diff --git a/src/tree/mod.rs b/src/tree/mod.rs
index aaf048c73..30a4b33a9 100644
--- a/src/tree/mod.rs
+++ b/src/tree/mod.rs
@@ -5,7 +5,7 @@ use std::fmt;
5use std::cmp; 5use std::cmp;
6 6
7mod file_builder; 7mod file_builder;
8pub use self::file_builder::{FileBuilder, Sink}; 8pub(crate) use self::file_builder::{FileBuilder, Sink};
9 9
10/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. 10/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
11#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 11#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]