# Parsers with Error Recovery

**URL:** <https://discourse.elm-lang.org/t/parsers-with-error-recovery/6262>\
**Category:** Learn\
**Created:** [September 8, 2020, 3:12pm UTC](https://discourse.elm-lang.org/t/parsers-with-error-recovery/6262 "2020-09-08T15:12:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![evancz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/evancz/32/16_2.png) [@evancz](https://discourse.elm-lang.org/u/evancz)\
**Post date:** [September 8, 2020, 3:49pm UTC](https://discourse.elm-lang.org/t/parsers-with-error-recovery/6262/2 "2020-09-08T15:49:34Z")

</div>

The easiest way is probably to define a simple notion of “chunks” that any file can be broken into.

So with Elm code, maybe that means a chunk begins whenever you have a “fresh line” where a newline is directly followed by a letter. That indicates that we are seeing a `type`, `type alias`, type annotation, declaration, `import`, or `port`. Then you parse the chunks individually.

That approach could get confused by weirdly indented expressions I guess, but it seems like it’s a reasonable start at least! I also wouldn’t be to tied to trying to do it all in a single pass over the file at first. Just start by figuring out if it can get the error messages you’d like to see!

---

_[View the full topic](https://discourse.elm-lang.org/t/parsers-with-error-recovery/6262)._
