Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/kdl_parser/parser/type_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mod combinators {

use crate::kdl_parser::schema::{ArraySeparator, BoolEncoding, DataType, TypeEncoding};
use miette::SourceSpan;
use winnow::ascii::{alpha1, alphanumeric1, space0, space1};
use winnow::ascii::{alpha1, alphanumeric1, multispace0, space0, space1};
use winnow::combinator::{
alt, cut_err, delimited, not, opt, peek, preceded, separated, separated_pair,
};
Expand Down Expand Up @@ -307,7 +307,7 @@ mod combinators {

pub fn parse_datatype(input: &mut Input) -> PResult {
(
space0,
multispace0,
alt((
parse_map,
parse_array,
Expand All @@ -324,7 +324,7 @@ mod combinators {
parse_custom_type,
)),
)
.map(|(_space, v)| v)
.map(|(_space1, v)| v)
.parse_next(input)
}

Expand Down Expand Up @@ -634,6 +634,22 @@ mod combinators {
assert!(val.is_err());
}

#[test]
fn can_parse_bool_with_whitespace() {
let s = "bool::int ";
let mut input = Input {
input: LocatingSlice::new(s),
state: State {},
};
let val = parse_datatype(&mut input);
assert!(matches!(
val,
Ok(DataType::Bool {
encoding: BoolEncoding::Int
})
));
}

#[test]
fn can_parse_string_encoded_i32() {
let s = "i32::str";
Expand Down
Loading