Lex quotes -- need to write a test for this but captain says its time to put devices away...
This commit is contained in:
parent
89e639fbac
commit
b1ef5fdf3e
3 changed files with 9 additions and 0 deletions
|
@ -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 == '"'
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -13,6 +13,7 @@ pub enum Token {
|
|||
LeftParen(String),
|
||||
LeftVectorParen,
|
||||
Number(Number),
|
||||
Quote,
|
||||
RightParen(String),
|
||||
String(String),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue