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
34
35
36
37
38
39
40
41
42
43
44
use std::collections::HashSet;
use environment::LexingEnvironment;
use tokens::{ LexerOptions, TokenIter };
use self::matchers::Matchers;
mod delimiters;
mod matchers;
pub mod options;
pub mod iter;
pub struct Lexer {
options: LexerOptions,
matchers: Matchers,
}
impl Lexer {
pub fn new(options: LexerOptions, operators: &HashSet<&'static str>) -> Lexer {
Lexer {
options: options,
matchers: Matchers::new(
&options,
operators
),
}
}
pub fn default(env: &LexingEnvironment) -> Lexer {
Lexer::new(
LexerOptions::default(),
&env.operators
)
}
pub fn tokens<'r, 'code>(&'r self, code: &'code str) -> TokenIter<'r, 'code>
{
TokenIter::new(self, code)
}
}