Parslet parsers are composeable. It sounds like you want to make a method that takes a date parser and returns you a shortee parser.
--- "No man is an island... except Philip" On Wed, Feb 6, 2013 at 8:49 AM, Nigel Thorne <[email protected]> wrote: > Do you want to post your parser so we can suggest changes? > > --- > "No man is an island... except Philip" > > > On Wed, Feb 6, 2013 at 8:46 AM, Jeremy Nevill <[email protected]> wrote: > >> First of all, great parser and documentation which has helped me make the >> leap from regex to proper parsing. >> >> We're using Parslet it to parse our Shortee event message format, sample >> messages being: >> >> @JeremyNevill ate 1lambchop 01/02/2013 >> @JeremyNevill walked @Rover 3miles 12/dec/2012 >> >> I have the parser working nicely, extracting the message entities defined >> in my syntax: https://github.com/JeremyNevill/shortee >> >> Now the issue I have is how to handle ambiguous dates as we have both US >> date format and UK date format clients: >> >> e.g. 01/02/2013 in the UK is 1st/Feb/2013 but 2nd/Jan/2013 in the US >> >> At present I have 2 very similar parsers, one that handles UK dates, the >> other that handles US… this is not very DRY and I'm wondering if there is a >> better way to go…maybe appending the date format required to the message >> when it gets sent into the parser. >> >> Any help will be most appreciated as I'm a bit stumped on the preferred >> method for problems like this. >> >> Regards, >> >> Jeremy Nevill >> www.nevill.net >> >> >
