sibil/src/lexer.rs

41 lines
639 B
Rust
Raw Normal View History

//! # Lexer
2016-12-20 17:38:44 -08:00
use characters;
2016-12-20 17:52:29 -08:00
pub enum Kind {
LeftParen,
RightParen,
Identifier,
}
2016-12-20 17:52:29 -08:00
pub struct Token {
kind: Kind,
value: String,
}
2016-12-20 17:52:29 -08:00
pub struct Lexer {
input: String,
index: usize,
2016-12-20 17:38:44 -08:00
}
impl Lexer {
2016-12-20 17:52:29 -08:00
pub fn new(input: String) -> Lexer {
Lexer { input: input, index: 0 }
}
2016-12-20 17:38:44 -08:00
}
impl Iterator for Lexer {
type Item = Token;
fn next(&mut self) -> Option<Token> {
None
}
}
pub fn hello(person: &str) {
println!("Hello, {}!", person);
for (idx, c) in person.char_indices() {
println!(" {}, {} -> {}", c, idx, characters::identifier_initials().contains(&c));
}
}