diff --git a/src/common.rs b/src/common.rs index 2d83332..807e31a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -62,6 +62,10 @@ pub enum Symbol { DoubleQuote, /// ' SingleQuote, + /// ? + QuestionMark, + /// \ + BackSlash, } impl Display for Symbol { @@ -94,6 +98,8 @@ impl Display for Symbol { Self::Percent => write!(f, "%"), Self::DoubleQuote => write!(f, "\""), Self::SingleQuote => write!(f, "'"), + Self::QuestionMark => write!(f, "?"), + Self::BackSlash => write!(f, "\\"), } } } @@ -130,6 +136,8 @@ impl TryFrom for Symbol { '%' => Ok(Self::Percent), '"' => Ok(Self::DoubleQuote), '\'' => Ok(Self::SingleQuote), + '?' => Ok(Self::QuestionMark), + '\\' => Ok(Self::BackSlash), _ => Err("invalid symbol"), } } diff --git a/src/lexer.rs b/src/lexer.rs index b1271c5..7daf2f1 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -43,12 +43,15 @@ impl<'a> Iterator for Lexer<'a> { '(' => symbol!(self, OpenParen), ')' => symbol!(self, CloseParen), '+' => symbol!(self, Plus), + '=' => symbol!(self, Equal), + '?' => symbol!(self, QuestionMark), + '\\' => symbol!(self, BackSlash), '~' => symbol!(self, Tilde), '\'' => symbol!(self, SingleQuote), '"' => symbol!(self, DoubleQuote), ' ' => whitespace!(self, Space), '\t' => whitespace!(self, Tab), - '\n' => { + '\n' | '\x0C' => { self.buf.next(); self.pos.newline(); TokenKind::Whitespace(Whitespace::Newline) @@ -62,6 +65,7 @@ impl<'a> Iterator for Lexer<'a> { '*' => symbol!(self, Mul), '}' => symbol!(self, CloseCurlyBrace), '&' => symbol!(self, BitAnd), + '|' => symbol!(self, BitOr), '/' => self.lex_forward_slash(), '%' => { self.buf.next();