This commit is contained in:
Aleksey Kladov 2018-02-09 22:55:50 +03:00
parent 0ae26c344a
commit ac932df22a
6 changed files with 11 additions and 14 deletions

View File

@ -25,7 +25,7 @@ mod parser;
pub mod syntax_kinds; pub mod syntax_kinds;
pub use text::{TextRange, TextUnit}; pub use text::{TextRange, TextUnit};
pub use tree::{File, Node, SyntaxKind, Token}; pub use tree::{File, Node, SyntaxKind, Token};
pub(crate) use tree::{FileBuilder, Sink, ErrorMsg}; pub(crate) use tree::{ErrorMsg, FileBuilder, Sink};
pub use lexer::{next_token, tokenize}; pub use lexer::{next_token, tokenize};
pub use parser::parse; pub use parser::parse;

View File

@ -1,4 +1,4 @@
use {File, FileBuilder, ErrorMsg, Sink, SyntaxKind, TextUnit, Token}; use {ErrorMsg, File, FileBuilder, Sink, SyntaxKind, TextUnit, Token};
use syntax_kinds::TOMBSTONE; use syntax_kinds::TOMBSTONE;
use super::is_insignificant; use super::is_insignificant;
@ -141,8 +141,8 @@ pub(super) fn to_file(text: String, tokens: &[Token], events: Vec<Event>) -> Fil
builder.leaf(kind, len); builder.leaf(kind, len);
} }
&Event::Error { ref message } => builder.error(ErrorMsg { &Event::Error { ref message } => builder.error(ErrorMsg {
message: message.clone() message: message.clone(),
}) }),
} }
} }
builder.finish() builder.finish()

View File

@ -45,7 +45,7 @@ fn path_segment(p: &mut Parser, first: bool) {
IDENT | SELF_KW | SUPER_KW => p.bump(), IDENT | SELF_KW | SUPER_KW => p.bump(),
_ => { _ => {
p.error("expected identifier"); p.error("expected identifier");
}, }
}; };
segment.complete(p, PATH_SEGMENT); segment.complete(p, PATH_SEGMENT);
} }

View File

@ -27,9 +27,9 @@ impl Marker {
if idx == p.events.len() - 1 { if idx == p.events.len() - 1 {
match p.events.pop() { match p.events.pop() {
Some(Event::Start { Some(Event::Start {
kind: TOMBSTONE, kind: TOMBSTONE,
forward_parent: None, forward_parent: None,
}) => (), }) => (),
_ => unreachable!(), _ => unreachable!(),
} }
} }
@ -188,9 +188,6 @@ impl<'p, 't: 'p> Drop for ErrorBuilder<'p, 't> {
impl<'t, 'p> ErrorBuilder<'p, 't> { impl<'t, 'p> ErrorBuilder<'p, 't> {
fn new(parser: &'p mut Parser<'t>, message: String) -> Self { fn new(parser: &'p mut Parser<'t>, message: String) -> Self {
ErrorBuilder { ErrorBuilder { message, parser }
message,
parser,
}
} }
} }

View File

@ -157,5 +157,5 @@ fn grow(left: &mut TextRange, right: TextRange) {
#[derive(Default)] #[derive(Default)]
pub(crate) struct ErrorMsg { pub(crate) struct ErrorMsg {
pub(crate) message: String pub(crate) message: String,
} }

View File

@ -4,7 +4,7 @@ use std::fmt;
use std::cmp; use std::cmp;
mod file_builder; mod file_builder;
pub(crate) use self::file_builder::{FileBuilder, Sink, ErrorMsg}; pub(crate) use self::file_builder::{ErrorMsg, FileBuilder, Sink};
pub use syntax_kinds::SyntaxKind; pub use syntax_kinds::SyntaxKind;