diff options
author | Aleksey Kladov <[email protected]> | 2017-12-31 20:34:29 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2017-12-31 20:34:29 +0000 |
commit | 8c478a794c667357b0c9a82ffc5c3eb5ca1b1b0d (patch) | |
tree | 403a3feaefea71a1e2a220a79c46e31a33abfe34 | |
parent | 39024fdc14703e3936f88d9ec938aad55085d05a (diff) |
Parser: initial
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/parser/mod.rs | 12 | ||||
-rw-r--r-- | tests/data/parser/0000_empty.txt | 2 | ||||
-rw-r--r-- | tests/parser.rs | 9 |
4 files changed, 13 insertions, 12 deletions
diff --git a/src/lib.rs b/src/lib.rs index 0685e3f2c..13872a3d9 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
@@ -3,8 +3,10 @@ extern crate unicode_xid; | |||
3 | mod text; | 3 | mod text; |
4 | mod tree; | 4 | mod tree; |
5 | mod lexer; | 5 | mod lexer; |
6 | mod parser; | ||
6 | 7 | ||
7 | pub mod syntax_kinds; | 8 | pub mod syntax_kinds; |
8 | pub use text::{TextUnit, TextRange}; | 9 | pub use text::{TextUnit, TextRange}; |
9 | pub use tree::{SyntaxKind, Token, FileBuilder, File, Node}; | 10 | pub use tree::{SyntaxKind, Token, FileBuilder, File, Node}; |
10 | pub use lexer::{next_token, tokenize}; | 11 | pub use lexer::{next_token, tokenize}; |
12 | pub use parser::parse; | ||
diff --git a/src/parser/mod.rs b/src/parser/mod.rs index da902e2b7..7336c5136 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs | |||
@@ -1,5 +1,11 @@ | |||
1 | use {Token, File}; | 1 | use {Token, File, FileBuilder}; |
2 | 2 | ||
3 | pub fn parse(tokens: &[Token]) -> File { | 3 | use syntax_kinds::*; |
4 | unimplemented!() | 4 | |
5 | |||
6 | pub fn parse(text: String, tokens: &[Token]) -> File { | ||
7 | let mut builder = FileBuilder::new(text); | ||
8 | builder.start_internal(FILE); | ||
9 | builder.finish_internal(); | ||
10 | builder.finish() | ||
5 | } \ No newline at end of file | 11 | } \ No newline at end of file |
diff --git a/tests/data/parser/0000_empty.txt b/tests/data/parser/0000_empty.txt index 843ea118d..54be3e7bc 100644 --- a/tests/data/parser/0000_empty.txt +++ b/tests/data/parser/0000_empty.txt | |||
@@ -1 +1 @@ | |||
FILE@[0; 0) \ No newline at end of file | FILE@[0; 0) | ||
diff --git a/tests/parser.rs b/tests/parser.rs index f61b6830b..e71b48852 100644 --- a/tests/parser.rs +++ b/tests/parser.rs | |||
@@ -7,7 +7,7 @@ use std::path::{PathBuf, Path}; | |||
7 | use std::fs::read_dir; | 7 | use std::fs::read_dir; |
8 | use std::fmt::Write; | 8 | use std::fmt::Write; |
9 | 9 | ||
10 | use libsyntax2::{tokenize, Token, Node, File, FileBuilder}; | 10 | use libsyntax2::{tokenize, parse, Token, Node, File, FileBuilder}; |
11 | 11 | ||
12 | #[test] | 12 | #[test] |
13 | fn parser_tests() { | 13 | fn parser_tests() { |
@@ -67,10 +67,3 @@ fn dump_tree(file: &File) -> String { | |||
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | } |
70 | |||
71 | fn parse(text: String, tokens: &[Token]) -> File { | ||
72 | let mut builder = FileBuilder::new(text); | ||
73 | builder.start_internal(libsyntax2::syntax_kinds::FILE); | ||
74 | builder.finish_internal(); | ||
75 | builder.finish() | ||
76 | } \ No newline at end of file | ||