This module provides a FieldGrammarParser, one way to parse
.cabal -like files.
Fields can be specified multiple times in the .cabal files. The order of
such entries is important, but the mutual ordering of different fields is
not.Also conditional sections are considered after non-conditional data.
The example of this silent-commutation quirk is the fact that
buildable: True
if os(linux)
buildable: False
and
if os(linux)
buildable: False
buildable: True
behave the same! This is the limitation of GeneralPackageDescription
structure.
So we transform the list of fields [Field ann] into
a map of grouped ordinary fields and a list of lists of sections:
Fields ann = MapFieldName [NamelessField ann] and [[Section ann]].
We need list of list of sections, because we need to distinguish situations
where there are fields in between. For example
We can parse Fields like we parse aeson objects, yet we use
slightly higher-level API, so we can process unspecified fields,
to report unknown fields and save custom x-fields.