mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +00:00
Parser: initial
This commit is contained in:
parent
39024fdc14
commit
8c478a794c
4 changed files with 13 additions and 12 deletions
|
@ -3,8 +3,10 @@ extern crate unicode_xid;
|
|||
mod text;
|
||||
mod tree;
|
||||
mod lexer;
|
||||
mod parser;
|
||||
|
||||
pub mod syntax_kinds;
|
||||
pub use text::{TextUnit, TextRange};
|
||||
pub use tree::{SyntaxKind, Token, FileBuilder, File, Node};
|
||||
pub use lexer::{next_token, tokenize};
|
||||
pub use parser::parse;
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
use {Token, File};
|
||||
use {Token, File, FileBuilder};
|
||||
|
||||
pub fn parse(tokens: &[Token]) -> File {
|
||||
unimplemented!()
|
||||
use syntax_kinds::*;
|
||||
|
||||
|
||||
pub fn parse(text: String, tokens: &[Token]) -> File {
|
||||
let mut builder = FileBuilder::new(text);
|
||||
builder.start_internal(FILE);
|
||||
builder.finish_internal();
|
||||
builder.finish()
|
||||
}
|
|
@ -7,7 +7,7 @@ use std::path::{PathBuf, Path};
|
|||
use std::fs::read_dir;
|
||||
use std::fmt::Write;
|
||||
|
||||
use libsyntax2::{tokenize, Token, Node, File, FileBuilder};
|
||||
use libsyntax2::{tokenize, parse, Token, Node, File, FileBuilder};
|
||||
|
||||
#[test]
|
||||
fn parser_tests() {
|
||||
|
@ -67,10 +67,3 @@ fn dump_tree(file: &File) -> String {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse(text: String, tokens: &[Token]) -> File {
|
||||
let mut builder = FileBuilder::new(text);
|
||||
builder.start_internal(libsyntax2::syntax_kinds::FILE);
|
||||
builder.finish_internal();
|
||||
builder.finish()
|
||||
}
|
Loading…
Reference in a new issue