ChAoSUnItY / ebnf

A successor bnf parsing library of bnf parsing library, for parsing Extended Backus–Naur form context-free grammars
MIT License
10 stars 3 forks source link

Incorrect parsing results #7

Closed extf33 closed 1 year ago

extf33 commented 1 year ago

I've got two issues.

1. The code below should print an error.

Code:

fn main() {
    let source = r"
        Foo ::= ['0'-'1'];
    ";

    let result = ebnf::get_grammar(source);
    println!("{:#?}", result);
}

Output:

Ok(
    Grammar {
        expressions: [
            Expression {
                lhs: "Foo",
                rhs: Optional(
                    String(
                        "0",
                    ),
                ),
            },
        ],
    },
)

2. The code below should be parsed normally.

Code:

fn main() {
    let source = r"
        Bar ::= '\'';
    ";

    let result = ebnf::get_grammar(source);
    println!("{:#?}", result);
}

Output:

Err(
    Error(
        VerboseError {
            errors: [
                (
                    "';\n    ",
                    Char(
                        ';',
                    ),
                ),
            ],
        },
    ),
)