Note that there are some explanatory texts on larger screens.

plurals
  1. POHaskell Parsec and Unordered Properties
    text
    copied!<p>I am trying to use Parsec to parse something like this:</p> <pre><code>property :: CharParser SomeObject property = do name parameters value return SomeObjectInstance { fill in records here } </code></pre> <p>I am implementing the iCalendar spec and on every like there is a name:parameters:value triplet, very much like the way that XML has a name:attributes:content triplet. Infact <a href="http://tools.ietf.org/html/draft-daboo-et-al-icalendar-in-xml-06" rel="noreferrer">you could very easily convert an iCalendar into XML format</a> (thought I can't really see the advantages).</p> <p>My point is that the parameters do not have to come in any order at all and each paramater may have a different type. One parameter may be a string while the other is the numeric id of another element. They may share no similarity yet, in the end, I want to place them correctly in the right record fields for whatever 'SomeObjectInstance' that I wanted the parser to return. How do I go about doing this sort of thing (or can you point me to an example of where somebody had to parse data like this)? </p> <p>Thankyou, I know that my question is probably a little confused but that reflects my level of understanding of what I need to do.</p> <p><strong>Edit</strong>: I was trying to avoid giving the expected output (because it is large, not because it is hidden) but here is an example of an input file (from wikipedia):</p> <blockquote> <p>BEGIN:VCALENDAR<br> VERSION:2.0<br> PRODID:-//hacksw/handcal//NONSGML v1.0//EN<br> BEGIN:VEVENT<br> UID:uid1@example.com<br> DTSTAMP:19970714T170000Z<br> ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com<br> DTSTART:19970714T170000Z<br> DTEND:19970715T035959Z<br> SUMMARY:Bastille Day Party<br> END:VEVENT<br> END:VCALENDAR </p> </blockquote> <p>As you can see it contains one VEvent inside a VCalendar, I have made <a href="http://github.com/robertmassaioli/hICalendar/blob/combined/Text/ICalendar/Components.hs" rel="noreferrer">data structures that represent them here</a>.</p> <p>I am trying to write a parser that parses that type of file into my data structures and I am stuck on the bit where I need to handle properties coming in any order with any type; date, time, int, string, uid, ect. I hope that makes more sense without repeating the entire iCalendar spec.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload