Avi-D-coder / implicit-hie

Auto generate a stack or cabal multi component hie.yaml file
BSD 3-Clause "New" or "Revised" License
201 stars 17 forks source link

Improve list parser #12

Closed maksbotan closed 4 years ago

maksbotan commented 4 years ago

Current parser for lists, like packages: in cabal.project.local, fails to process some input, for example:

packages: foo/foo.cabal , bar/bar.cabal , baz/baz.cabal

This commit simplifies the parser by using sepBy directly and by handling indented fields more uniformly.

Avi-D-coder commented 4 years ago

See the test failure.

It also needs to parse newline delineated lists and mixed newline comma lists. Cabal will except:

packages:
         ./
         ghcide
maksbotan commented 4 years ago

Yeah, I'm already on it.

maksbotan commented 4 years ago

While reading Cabal sources I missed that it first parses fields into a tree and then parses its parts, that's why parseOptCommaList does not have to deal with indices.

This commit should work. I've also added a testcase.

Avi-D-coder commented 4 years ago

Thanks, I'll publish new version in the next few days

maksbotan commented 4 years ago

Thanks! The tool is very useful, by the way :)