J-F-Liu / pom

PEG parser combinators using operator overloading without macros.
MIT License
496 stars 30 forks source link

How to get all the input token when a parse failed, so I can display them on the expect? #37

Closed g1rp closed 4 years ago

g1rp commented 4 years ago

Example I'm parsing for supported data_type with:

    static ref MUST_BE_VALID_DATA_TYPE: String = format!(
        "must have a valid data types are: {}",  SUPPORTED_DATA_TYPE.join(", ")
    );

    (tag("bool").map(|_| DataType::Bool)
        | tag("u8").map(|_| DataType::U8)
        | tag("u16").map(|_| DataType::U16)
        | tag("u32").map(|_| DataType::U32)
    .expect(&MUST_BE_VALID_DATA_TYPE)

I want to display show the symbols that are being processed instead of only the first letter.

J-F-Liu commented 4 years ago

.collect().expect(&MUST_BE_VALID_DATA_TYPE)