[Haskell-beginners] Parsing

Mike Houghton mike_k_houghton at yahoo.co.uk
Sun Mar 6 09:26:17 UTC 2016


Hi, I’m using Parsec to parse structured text and have some problems with mandatory and optional text entries and the order in which they occur.
For example 

module{

    name   = some string
    source = …

    dest              = …..
    bundle          = …
    bundle_dest = … 
    zip_name     = ….

}

In the above text the name and source are mandatory and all others are optional. I’m not quite sure how to handle the optional parts once I’ve parsed name and source.
Should I enforce the rule that if dest does appear then it must be first in the list? 
In this situation how should  I make use of the various Parsec functions such as choice, option, optionMaybe, lookAhead etc.

Thanks

Mike



More information about the Beginners mailing list