lex() function in lexer module
This commit is contained in:
parent
3dd170ec69
commit
bf03cb8ef9
2 changed files with 7 additions and 1 deletions
|
@ -49,6 +49,10 @@ enum NewlineState { N, Ne, New, Newl, Newli, Newlin, Newline }
|
|||
#[derive(Clone, PartialEq, Debug)]
|
||||
enum SpaceState { S, Sp, Spa, Spac, Space }
|
||||
|
||||
pub fn lex(input: &str) -> Lexer {
|
||||
Lexer::new(&input)
|
||||
}
|
||||
|
||||
pub struct Lexer {
|
||||
input: String,
|
||||
begin: usize,
|
||||
|
|
|
@ -2,8 +2,10 @@ mod lexer;
|
|||
mod parser;
|
||||
mod types;
|
||||
|
||||
use lexer::lex;
|
||||
|
||||
fn main() {
|
||||
let lexer = lexer::Lexer::new("((abc def + ghi #f))");
|
||||
let lexer = lex("((abc def + ghi #f))");
|
||||
for t in lexer {
|
||||
println!("token = {:?}", t);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue