@@ -3,39 +3,26 @@ use crate::pc::boxed::boxed;
33use crate :: pc:: { And , AndWithoutUndo , Chain , Errors , Map , Parser , RcStringView , ToOption , Token } ;
44use crate :: specific:: core:: expression:: ws_expr_pos_p;
55use crate :: specific:: pc_specific:: { keyword, opt_whitespace, whitespace} ;
6- use crate :: specific:: { ExpressionPos , ExpressionTrait , Keyword } ;
7-
8- /// Finds the rightmost expression of a given type,
9- /// so that it can be determined if it ended in parenthesis or not.
10- #[ deprecated]
11- pub trait ExtractExpression {
12- fn to_expression ( & self ) -> & ExpressionPos ;
13- }
14-
15- impl ExtractExpression for ExpressionPos {
16- fn to_expression ( & self ) -> & ExpressionPos {
17- self
18- }
19- }
6+ use crate :: specific:: { ExpressionPos , Keyword } ;
207
218/// Parses an optional second expression that follows the first expression
229/// and a keyword.
2310///
2411/// If the keyword is present, the second expression is mandatory.
2512///
2613/// Example: `FOR I = 1 TO 100 [STEP 5]`
27- pub fn opt_second_expression_after_keyword < P > (
28- first_expression_parser : P ,
14+ pub fn opt_second_expression_after_keyword < P , F > (
15+ first_parser : P ,
2916 keyword : Keyword ,
17+ is_first_wrapped_in_parenthesis : F ,
3018) -> impl Parser < RcStringView , Output = ( P :: Output , Option < ExpressionPos > ) >
3119where
3220 P : Parser < RcStringView > ,
33- P :: Output : ExtractExpression ,
21+ F : Fn ( & P :: Output ) -> bool ,
3422{
35- first_expression_parser . chain (
23+ first_parser . chain (
3624 move |first| {
37- let first_expr = first. to_expression ( ) ;
38- let is_paren = first_expr. is_parenthesis ( ) ;
25+ let is_paren = is_first_wrapped_in_parenthesis ( & first) ;
3926 parse_second ( keyword, is_paren)
4027 } ,
4128 |first, opt_second| ( first, opt_second) ,
0 commit comments