11use std:: cmp:: PartialEq ;
22use std:: fmt:: Debug ;
3+ use std:: sync:: { Arc , Mutex } ;
34
45use super :: tokenizer:: * ;
56
@@ -113,11 +114,21 @@ pub trait SQLParser<TokenType, ExprType>
113114 fn parse_infix ( & mut self , chars : & mut CharSeq , left : & SQLExpr < ExprType > , precedence : usize ) -> Result < Option < Box < SQLExpr < ExprType > > > , ParserError < TokenType > > ;
114115}
115116
116- //struct PrattParser<ExprType, TokenType> {
117- //
118- // ansi_parser:
119- //
120- //}
117+ pub struct PrattParser < TokenType , ExprType > {
118+ pub chars : CharSeq ,
119+ pub parser : Arc < Mutex < SQLParser < TokenType , ExprType > > >
120+ }
121+
122+ impl < TokenType , ExprType > PrattParser < TokenType , ExprType > where TokenType : Debug + PartialEq , ExprType : Debug {
123+
124+ pub fn parse_expr ( & mut self ) -> Result < Option < Box < SQLExpr < ExprType > > > , ParserError < TokenType > > {
125+
126+ let mut p = self . parser . lock ( ) . unwrap ( ) ;
127+
128+ p. parse_prefix ( & mut self . chars )
129+ }
130+
131+ }
121132
122133//
123134//pub fn parse_expr<'a, TokenType, ExprType>(parser: Arc<Mutex<SQLParser<TokenType, ExprType>>>)
@@ -130,12 +141,6 @@ pub trait SQLParser<TokenType, ExprType>
130141//}
131142
132143
133- //pub struct PrattParser<'a, TokenType, ExprType> {
134- // chars: Peekable<Chars<'a>>,
135- // tokenizer: Rc<SQLTokenizer<TokenType>>,
136- // parser: Rc<SQLParser<TokenType, ExprType>>
137- //}
138- //
139144//impl<'a, TokenType, ExprType> PrattParser<'a, TokenType, ExprType>
140145// where TokenType: Debug + PartialEq, ExprType: Debug {
141146//
0 commit comments