mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-23 07:24:10 +00:00
Refactoring
This commit is contained in:
parent
037ebb0f73
commit
fa2ef528b7
2 changed files with 36 additions and 22 deletions
|
@ -36,27 +36,33 @@ impl SQLTokenizer<AcmeToken> for AcmeTokenizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_token(&mut self, chars: &mut CharSeq) -> Result<Option<SQLToken<AcmeToken>>, TokenizerError> {
|
fn next_token(&mut self, chars: &mut CharSeq) -> Result<Option<SQLToken<AcmeToken>>, TokenizerError> {
|
||||||
// let mut arc = self.ansi_tokenizer.lock().unwrap();
|
let mut ansi = self.ansi_tokenizer.lock().unwrap();
|
||||||
// match arc.peek_char() {
|
match chars.peek() {
|
||||||
// Some(&ch) => match ch {
|
Some(&ch) => match ch {
|
||||||
// '!' => {
|
'!' => {
|
||||||
// arc.next_char(); // consume the first `!`
|
chars.mark();
|
||||||
// match arc.peek_char() {
|
chars.next(); // consume the first `!`
|
||||||
// Some(&ch) => match ch {
|
match chars.peek() {
|
||||||
// '!' => {
|
Some(&ch) => match ch {
|
||||||
// arc.next_char(); // consume the second `!`
|
'!' => {
|
||||||
// Ok(Some(SQLToken::Custom(AcmeToken::Factorial)))
|
chars.next(); // consume the second `!`
|
||||||
// },
|
Ok(Some(SQLToken::Custom(AcmeToken::Factorial)))
|
||||||
// _ => Err(TokenizerError::UnexpectedChar(ch,Position::new(0,0)))
|
},
|
||||||
// },
|
_ => {
|
||||||
// None => Ok(Some(SQLToken::Not))
|
chars.reset();
|
||||||
// }
|
ansi.next_token(chars)
|
||||||
// }
|
}
|
||||||
// _ => arc.next_token()
|
},
|
||||||
// }
|
None => {
|
||||||
// _ => arc.next_token()
|
chars.reset();
|
||||||
// }
|
ansi.next_token(chars)
|
||||||
unimplemented!()
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => ansi.next_token(chars)
|
||||||
|
}
|
||||||
|
_ => ansi.next_token(chars)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +105,9 @@ fn main() {
|
||||||
let ansi_parser = Arc::new(Mutex::new(ANSISQLParser::new(acme_tokenizer.clone())));
|
let ansi_parser = Arc::new(Mutex::new(ANSISQLParser::new(acme_tokenizer.clone())));
|
||||||
let acme_parser = Arc::new(Mutex::new(AcmeParser::new(acme_tokenizer.clone())));
|
let acme_parser = Arc::new(Mutex::new(AcmeParser::new(acme_tokenizer.clone())));
|
||||||
|
|
||||||
//let parser_list: Vec<Arc<Mutex<SQLParser<>>>> = vec![acme_parser, ansi_parser];
|
// ansi_parser.lock().unwrap().next_token();
|
||||||
|
|
||||||
|
//let parser_list = vec![acme_parser, ansi_parser];
|
||||||
|
|
||||||
// Custom ACME parser
|
// Custom ACME parser
|
||||||
// let acme_parser: Arc<Mutex<SQLParser<AcmeToken, AcmeExpr>>> = Arc::new(Mutex::new(AcmeParser {
|
// let acme_parser: Arc<Mutex<SQLParser<AcmeToken, AcmeExpr>>> = Arc::new(Mutex::new(AcmeParser {
|
||||||
|
|
|
@ -113,6 +113,12 @@ pub trait SQLParser<TokenType, ExprType>
|
||||||
fn parse_infix(&mut self, chars: &mut CharSeq, left: &SQLExpr<ExprType>, precedence: usize) -> Result<Option<Box<SQLExpr<ExprType>>>, ParserError<TokenType>>;
|
fn parse_infix(&mut self, chars: &mut CharSeq, left: &SQLExpr<ExprType>, precedence: usize) -> Result<Option<Box<SQLExpr<ExprType>>>, ParserError<TokenType>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//struct PrattParser<ExprType, TokenType> {
|
||||||
|
//
|
||||||
|
// ansi_parser:
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
//
|
//
|
||||||
//pub fn parse_expr<'a, TokenType, ExprType>(parser: Arc<Mutex<SQLParser<TokenType, ExprType>>>)
|
//pub fn parse_expr<'a, TokenType, ExprType>(parser: Arc<Mutex<SQLParser<TokenType, ExprType>>>)
|
||||||
// -> Result<Box<SQLExpr<ExprType>>, ParserError<TokenType>> where TokenType: Debug + PartialEq, ExprType: Debug {
|
// -> Result<Box<SQLExpr<ExprType>>, ParserError<TokenType>> where TokenType: Debug + PartialEq, ExprType: Debug {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue