@@ -3,7 +3,7 @@ use rusty_pc::and::TupleCombiner;
33use rusty_pc:: * ;
44
55use crate :: error:: ParserError ;
6- use crate :: expr:: expression_pos_p;
6+ use crate :: expr:: { expression_pos_p, ws_expr_pos_p } ;
77use crate :: input:: StringView ;
88use crate :: pc_specific:: { OrExpected , WithPos , lead_opt_ws, lead_ws} ;
99use crate :: tokens:: { TokenType , any_token} ;
@@ -31,28 +31,29 @@ fn second_parser() -> impl Parser<
3131 Error = ParserError ,
3232> {
3333 operator ( )
34- . then_with_in_context ( third_parser ( ) , is_keyword_op, TupleCombiner )
34+ . then_with_in_context ( expr_after_binary_operator ( ) , is_keyword_op, TupleCombiner )
3535 . to_option ( )
3636}
3737
3838fn is_keyword_op ( op : & Positioned < Operator > ) -> bool {
3939 op. element == Operator :: And || op. element == Operator :: Or || op. element == Operator :: Modulo
4040}
4141
42- fn third_parser ( ) -> impl Parser < StringView , bool , Output = ExpressionPos , Error = ParserError > {
42+ fn expr_after_binary_operator ( )
43+ -> impl Parser < StringView , bool , Output = ExpressionPos , Error = ParserError > {
44+ // boxed breaks apart the recursive type evaluation
4345 IifParser :: new (
44- super :: guard:: parser ( ) . to_fatal ( ) ,
45- super :: guard:: parser ( ) . to_option ( ) . map_to_unit ( ) ,
46+ // the previous operator is a keyword op, must have whitespace or parenthesis
47+ ws_expr_pos_p ( )
48+ . boxed ( )
49+ . or_expected ( "expression after operator" ) ,
50+ // the previous operator is a symbol, whitespace is optional
51+ lead_opt_ws (
52+ expression_pos_p ( )
53+ . boxed ( )
54+ . or_expected ( "expression after operator" ) ,
55+ ) ,
4656 )
47- . and_keep_right ( right_side_expr ( ) . no_context ( ) )
48- }
49-
50- /// Parses the right side expression, after having parsed the binary operator
51- fn right_side_expr ( ) -> impl Parser < StringView , Output = ExpressionPos , Error = ParserError > {
52- // boxed breaks apart the recursive type evaluation
53- expression_pos_p ( )
54- . or_expected ( "expression after operator" )
55- . boxed ( )
5657}
5758
5859fn non_bin_expr ( ) -> impl Parser < StringView , Output = ExpressionPos , Error = ParserError > {
0 commit comments