Skip to content

Commit 4efbb72

Browse files
committed
Moved or_expected into pc
1 parent 6cb19d8 commit 4efbb72

10 files changed

Lines changed: 19 additions & 28 deletions

File tree

rusty_parser/src/core/sub_call.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rusty_pc::*;
44
use crate::error::ParserError;
55
use crate::expr::{csv_expressions_first_guarded, expression_pos_p, property};
66
use crate::input::StringView;
7-
use crate::pc_specific::*;
87
use crate::tokens::equal_sign_ws;
98
use crate::*;
109

rusty_parser/src/expr/binary_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rusty_pc::*;
55
use crate::error::ParserError;
66
use crate::expr::{expression_pos_p, ws_expr_pos_p};
77
use crate::input::StringView;
8-
use crate::pc_specific::{OrExpected, WithPos, lead_opt_ws, lead_ws};
8+
use crate::pc_specific::{WithPos, lead_opt_ws, lead_ws};
99
use crate::tokens::{TokenType, any_token};
1010
use crate::{ExpressionPos, ExpressionPosTrait, ExpressionTrait, Keyword, Operator};
1111

rusty_parser/src/expr/parenthesis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rusty_pc::*;
22

33
use crate::expr::expression_pos_p;
44
use crate::input::StringView;
5-
use crate::pc_specific::{OrExpected, WithPos, in_parenthesis};
5+
use crate::pc_specific::{WithPos, in_parenthesis};
66
use crate::{Expression, ExpressionPos, ParserError};
77

88
pub(super) fn parser() -> impl Parser<StringView, Output = ExpressionPos, Error = ParserError> {

rusty_parser/src/expr/parsers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,6 @@ fn opt_keyword_expr(
149149
let msg = format!("expression after {}", keyword);
150150
conditionally_opt_whitespace()
151151
.and_keep_right(keyword_ignoring(keyword).no_context())
152-
.and_keep_right(ws_expr_pos_p().or_expected(&msg).no_context())
152+
.and_keep_right(ws_expr_pos_p().or_expected(msg).no_context())
153153
.to_option()
154154
}

rusty_parser/src/expr/property.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rusty_pc::*;
44
use crate::core::{name_as_tokens_p, token_to_type_qualifier};
55
use crate::error::ParserError;
66
use crate::input::StringView;
7-
use crate::pc_specific::OrExpected;
87
use crate::tokens::dot;
98
use crate::{BareName, Expression, ExpressionPos, ExpressionType, Name, NameAsTokens};
109

rusty_parser/src/expr/unary_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rusty_pc::*;
33

44
use crate::expr::{expression_pos_p, ws_expr_pos_p};
55
use crate::input::StringView;
6-
use crate::pc_specific::{OrExpected, WithPos, keyword};
6+
use crate::pc_specific::{WithPos, keyword};
77
use crate::tokens::minus_sign;
88
use crate::{ExpressionPos, ExpressionPosTrait, Keyword, ParserError, UnaryOperator};
99

rusty_parser/src/pc_specific/csv.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use rusty_pc::*;
22

33
use crate::error::ParserError;
44
use crate::input::StringView;
5-
use crate::pc_specific::OrExpected;
65
use crate::tokens::comma_ws;
76

87
/// Comma separated list of items.

rusty_parser/src/pc_specific/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ mod whitespace;
77
#[cfg(debug_assertions)]
88
pub mod logging;
99

10-
mod or_expected;
1110
mod with_pos;
1211

1312
pub use self::csv::*;
1413
pub use self::in_parenthesis::*;
1514
pub use self::keyword::*;
1615
pub use self::keyword_map::*;
17-
pub use self::or_expected::*;
1816
pub use self::whitespace::*;
1917
pub use self::with_pos::*;

rusty_parser/src/pc_specific/or_expected.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

rusty_pc/src/parser.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ where
320320

321321
/// If this parser returns a soft error, the soft error will be replaced
322322
/// by transforming the given message into an error.
323+
///
323324
/// The parameter will be converted with the standard `From` trait.
325+
/// It is expected that the conversion returns a soft error.
324326
fn with_expected_message<E>(self, msg: E) -> MapSoftErrParser<Self, Self::Error>
325327
where
326328
Self: Sized,
@@ -339,6 +341,19 @@ where
339341
self.with_soft_err(err)
340342
}
341343

344+
/// Converts the soft errors of this parser to fatal errors
345+
/// based on the given error message.
346+
///
347+
/// The message parameter will be converted with the standard `From` trait.
348+
/// The resulting error is converted into a fatal one.
349+
fn or_expected<E>(self, msg: E) -> MapSoftErrParser<Self, Self::Error>
350+
where
351+
Self: Sized,
352+
Self::Error: From<E>,
353+
{
354+
self.with_soft_err(Self::Error::from(msg).to_fatal())
355+
}
356+
342357
// =======================================================================
343358
// NoContext
344359
// =======================================================================

0 commit comments

Comments
 (0)