Dave,
> I'll be happy to cleanup the program once I know more about
> Spirit2. I'm really looking forward to your talk and suggestions.
>
> The range on the years is in the original grammar and, for a
> start, I just stuck with that. They probably limited the
> years to 1970-2050 for two digit years as in 01/01/99, which
> makes sense. But for four digit years there's no reason to
> restrict it. I'd like to try accepting "European-style"
> dates too, such as "25 December 2007" instead of "December
> 25, 2007". If I get really carried away, I'll even do "B.C."
> dates. :-) Does anyone know how ISO dates handle this?
>
> I don't have test cases yet, but that's a good idea if people
> start using this for more than fun. Right now, it's just
> interactive. It would be a good idea to add some description
> about what date formats are accepted and which are not, too.
As you all might know, Spirit2 now contains not only a parser framework (btw
named 'qi'), but also a compatible and completely dual generator framework
(named 'karma'). Borrowing the idea that a grammar usable to parse a certain
input may be used to re-generate the same input again from the internal
representation, the karma generator framework allows to use grammars very
similar to the qi parser grammars to generate output.
Just some examples:
std::vector<char> v;
v += 'a', 'b', 'c';
generate(some_outiter, *char_, v); // generates "abc"
Or
fusion::vector<char, char, std::string> p ('a', 'b', "cdefg");
generate(some_outiter, char_ << char_ << lit, p)); // generates
"abcdefg"
You get the idea. Everything is orthogonal to the parser world. Semantic
actions are available as well, the only difference is, these do not receive
the parsed values but provide the values to output.
My idea would be, if we really start thinking about reusable parser
components like the date parsers, shouldn't we start to think about the
corresponding generator components as well? This would allow for a very nice
formatting and generating components, useable to output data using different
formats. Upto a certain degree I even imagine using the very _same_ grammar
for both parts, parsing and generating.
Regards Hartmut
> Regards,
> Dave Jenkins
>
> "Joel de Guzman" <joel@...> wrote in message
> news:evub57$7dj$1@......
> > Joel de Guzman wrote:
> >> Dave Jenkins wrote:
> >>
> >>> I would welcome any
> comments/optimizations/simplifications upon the
> >>> programs. It was tempting to improve upon the Microsoft date
> >>> grammar that I started with, but I resisted. It will be easy to
> >>> modify if anyone wants to add more abbreviations,
> case-insensitive
> >>> matching, different date ranges, etc.
> >>
> >> There's definitely room for improvement. One is phoenix
> and another
> >> is Spirit2's rule contexts and attributes. Also, I'd not hard-code
> >> the dates to be limited to 1970...2050.
> >
> > Oh BTW, do you have test cases for various (preferably including
> > pathological) inputs?
> >
> > Regards,
> > --
> > Joel de Guzman
> > http://www.boost-consulting.com
> > http://spirit.sf.net
> >
> >
> >
> ----------------------------------------------------------------------
> > --- This SF.net email is sponsored by DB2 Express Download
> DB2 Express
> > C - the FREE version of DB2 express and take control of
> your XML. No
> > limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
>
>
>
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by DB2 Express Download DB2
> Express C - the FREE version of DB2 express and take control
> of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Spirit-general mailing list
> Spirit-general@...
> https://lists.sourceforge.net/lists/listinfo/spirit-general
|