Using a parser generator such as BISON while correctly handling bad input

I need a parser for a language that is not so complicated. The only catch is that I never want the parser to make an error when it receives invalid input. Rather, I want it to just continue, making as many input options as possible, similar to how HTML parsers do in a web browser.

Naturally, I thought of using a parser generator, but I don't have that much experience with them, and all the examples I've seen in Bison and Antlr have fragile parsers that give up as soon as they encounter an error syntax. Is this doable with them, or should I review it manually? Probably, I think it would not be so difficult, given the language.

+3
source share
2 answers

I'm not sure that you can do this with the parser generator in the general case. At least not in a fully automatic way. Consider the following distorted expression:

a - b + c ) * d

? , , - , -, ? , , .

, , , .

* d

.

+1

- . C, Python COBOL ( ). - , , , .

Bison, YACC , , GNU , , , UNunk clunkers.

YACC . , :

item = "bread" {
    quantity = 7
    price = 1.50
    taxrate = 10
}

- "", . , , . ( ), , .

( ).

, reset , , .

, , , , : -).

+1

Source: https://habr.com/ru/post/1707730/


All Articles