I have defined some rules with PetitParserDart:
def("start", ref("rule").separatedBy(char('\n'), includeSeparators: false);
def("rule", char('(').seq(word().plus()).seq(char(')')));
So the following text will be matched:
(aaa)
(bbbbbb)
But if there are some lines can't match:
(aaaa)
bbbbb
(cccccccc
How to define the grammars to let it fail and throw exceptions on line (ccccccccc
, but not on line bbbbb
?
I mean it only throw exceptions when a rule is not fully matched. If nothing matchs, it won't throw exception.