Lex quotes -- need to write a test for this but captain says its time to put devices away...

This commit is contained in:
Eryn Wells 2016-12-28 08:40:31 -07:00
parent 89e639fbac
commit b1ef5fdf3e
3 changed files with 9 additions and 0 deletions

View file

@ -9,6 +9,7 @@ pub trait Lexable {
fn is_right_paren(&self) -> bool;
fn is_hash(&self) -> bool;
fn is_dot(&self) -> bool;
fn is_quote(&self) -> bool;
fn is_string_quote(&self) -> bool;
fn is_string_escape_leader(&self) -> bool;
fn is_string_escaped(&self) -> bool;
@ -42,6 +43,10 @@ impl Lexable for char {
*self == '.'
}
fn is_quote(&self) -> bool {
*self == '''
}
fn is_string_quote(&self) -> bool {
*self == '"'
}

View file

@ -133,6 +133,9 @@ impl Lexer {
self.state = State::Hash;
self.advance();
}
else if c.is_quote() {
return self.token_result(Token::Quote);
}
else if c.is_string_quote() {
self.state = State::String;
self.advance();

View file

@ -13,6 +13,7 @@ pub enum Token {
LeftParen(String),
LeftVectorParen,
Number(Number),
Quote,
RightParen(String),
String(String),
}