Remove Token::String, as it's never emitted

Indeed, given that there is Token::SingleQuotedString and
Token::Identifier, there's no other "string" that would make sense...
This commit is contained in:
Nickolay Ponomarev 2019-01-13 01:33:41 +03:00
parent 82b1467324
commit d0a65ffd05
2 changed files with 1 additions and 7 deletions

View file

@ -158,7 +158,6 @@ impl Parser {
}
}
Token::Number(_)
| Token::String(_)
| Token::SingleQuotedString(_)
| Token::DoubleQuotedString(_) => {
self.prev_token();
@ -755,7 +754,6 @@ impl Parser {
Err(e) => parser_err!(format!("Could not parse '{}' as i64: {}", n, e)),
},
Token::Identifier(id) => Ok(Value::String(id.to_string())),
Token::String(ref s) => Ok(Value::String(s.to_string())),
Token::SingleQuotedString(ref s) => {
Ok(Value::SingleQuotedString(s.to_string()))
}
@ -792,7 +790,6 @@ impl Parser {
/// Parse a literal string
pub fn parse_literal_string(&mut self) -> Result<String, ParserError> {
match self.next_token() {
Some(Token::String(ref s)) => Ok(s.clone()),
Some(Token::SingleQuotedString(ref s)) => Ok(s.clone()),
Some(Token::DoubleQuotedString(ref s)) => Ok(s.clone()),
other => parser_err!(format!("Expected literal string, found {:?}", other)),

View file

@ -32,8 +32,7 @@ pub enum Token {
Keyword(String),
/// Numeric literal
Number(String),
/// String literal
String(String),
/// A character that could not be tokenized
Char(char),
/// Single quoted string: i.e: 'string'
SingleQuotedString(String),
@ -97,7 +96,6 @@ impl ToString for Token {
Token::Identifier(ref id) => id.to_string(),
Token::Keyword(ref k) => k.to_string(),
Token::Number(ref n) => n.to_string(),
Token::String(ref s) => s.to_string(),
Token::Char(ref c) => c.to_string(),
Token::SingleQuotedString(ref s) => format!("'{}'", s),
Token::DoubleQuotedString(ref s) => format!("\"{}\"", s),
@ -194,7 +192,6 @@ impl<'a> Tokenizer<'a> {
Token::Identifier(s) => self.col += s.len() as u64,
Token::Keyword(s) => self.col += s.len() as u64,
Token::Number(s) => self.col += s.len() as u64,
Token::String(s) => self.col += s.len() as u64,
Token::SingleQuotedString(s) => self.col += s.len() as u64,
Token::DoubleQuotedString(s) => self.col += s.len() as u64,
_ => self.col += 1,