1
1
use std:: cmp:: PartialEq ;
2
2
use std:: fmt:: Debug ;
3
+ use std:: sync:: { Arc , Mutex } ;
3
4
4
5
use super :: tokenizer:: * ;
5
6
@@ -113,11 +114,21 @@ pub trait SQLParser<TokenType, ExprType>
113
114
fn parse_infix ( & mut self , chars : & mut CharSeq , left : & SQLExpr < ExprType > , precedence : usize ) -> Result < Option < Box < SQLExpr < ExprType > > > , ParserError < TokenType > > ;
114
115
}
115
116
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
+ }
121
132
122
133
//
123
134
//pub fn parse_expr<'a, TokenType, ExprType>(parser: Arc<Mutex<SQLParser<TokenType, ExprType>>>)
@@ -130,12 +141,6 @@ pub trait SQLParser<TokenType, ExprType>
130
141
//}
131
142
132
143
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
- //
139
144
//impl<'a, TokenType, ExprType> PrattParser<'a, TokenType, ExprType>
140
145
// where TokenType: Debug + PartialEq, ExprType: Debug {
141
146
//
0 commit comments