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