forked from argotorg/fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
33 lines (27 loc) · 717 Bytes
/
Copy pathlib.rs
File metadata and controls
33 lines (27 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
extern crate regex;
pub mod ast;
pub mod builders;
pub mod errors;
pub mod parsers;
pub mod span;
pub mod string_utils;
pub mod tokenizer;
mod ast_traits;
use errors::ParseError;
use tokenizer::{
tokenize,
Token,
TokenType,
TokenizeError,
};
pub type Cursor<'a> = &'a [Token<'a>];
pub type ParseResult<'a, O> = Result<(Cursor<'a>, O), ParseError<'a>>;
/// Tokenize the given source code in `source` and filter out tokens not
/// relevant to parsing.
pub fn get_parse_tokens(source: &str) -> Result<Vec<Token>, TokenizeError> {
let tokens = tokenize(source)?;
Ok(tokens
.into_iter()
.filter(|t| t.typ != TokenType::NL && t.typ != TokenType::COMMENT)
.collect())
}