Replies: 6 comments
-
This is interesting, but not something we explored further in the past. I think that error recovery is hard and very specific to your use-case, so I don't see any general way that the PEGTL (or any parser library) can really help with that. What you have done so far looks like a reasonable approach for languages where, for example, statements always end in a semicolon. I wouldn't use the Control class, though, but instead apply an action to the skipping part. You also might avoid some redundancy, so how about something like:
given that the terminator |
Beta Was this translation helpful? Give feedback.
-
Sounds good. I didn't expect the PEGTL to have a generic response to error recovery; I just wanted to know if you guys had thought about methodology. Thanks for the suggestion, I'll give it a whirl. :) |
Beta Was this translation helpful? Give feedback.
-
We'd be very interested in seeing what you come up with, for future reference, and who knows, perhaps something generic can be found, if not concrete code then at least an idea that can be documented... |
Beta Was this translation helpful? Give feedback.
-
Hi, I'd appreciate any feedback. :) |
Beta Was this translation helpful? Give feedback.
-
@skyrich62 I just committed a small experiment on my own, based on some of your ideas. I am too tired to write more now, but I'll try to give more feedback in the next days. |
Beta Was this translation helpful? Give feedback.
-
@d-frey "Get some rest, if you haven't got your health, you haven't got anything." -- Count Rugen, The Princess Bride |
Beta Was this translation helpful? Give feedback.
-
Consider a grammar such as:
(Where both term and binary_adding_operator are appropriately defined.)
Suppose that the input is malformed, e.g.:
Note missing operand. I would want an appropriate error message, (easy enough to put out in
control<term>::failure
, but I also want to consume the input up to the semicolon, throw it away and continue parsing. Would that need to be embedded in the grammar something like this?(That's not quite what I had in mind, but I wonder if I'm even on the right track here.)
For more context, here's the project I'm working on: https://github.com/skyrich62/AFE
Beta Was this translation helpful? Give feedback.
All reactions