Skip to content

Commit ba8c050

Browse files
committed
refactor(parser): Use IifCtxParser in ParamName
1 parent a0f480b commit ba8c050

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

rusty_parser/src/core/param_name.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,17 @@ fn array_indicator() -> impl Parser<StringView, Output = Option<(Token, Token)>,
9797
}
9898

9999
fn extended_type() -> impl Parser<StringView, VarNameCtx, Output = ParamType, Error = ParserError> {
100-
ctx_parser()
101-
.map(|(_, allow_user_defined)| {
102-
if allow_user_defined {
103-
built_in_extended_type()
104-
.or(user_defined_type())
105-
.with_expected_message(
106-
"Expected: INTEGER or LONG or SINGLE or DOUBLE or STRING or identifier",
107-
)
108-
.boxed()
109-
} else {
110-
built_in_extended_type().boxed()
111-
}
112-
})
113-
.flatten()
100+
IifCtxParser::new(
101+
// allow user defined
102+
built_in_extended_type()
103+
.or(user_defined_type())
104+
.with_expected_message(
105+
"Expected: INTEGER or LONG or SINGLE or DOUBLE or STRING or identifier",
106+
),
107+
// do not allow user defined
108+
built_in_extended_type(),
109+
)
110+
.map_ctx(|ctx: &VarNameCtx| ctx.1)
114111
}
115112

116113
fn built_in_extended_type() -> impl Parser<StringView, Output = ParamType, Error = ParserError> {

0 commit comments

Comments
 (0)