coolmichael has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, it's been a while (only seven years!).
I'm working on a project to parse, validate, and transform some large data files which look like SGML tags, but most definitely are not. For example, <FOO=4> is perfectly valid and well defined, and the tags do not have to nest properly as they do in SGML and XML. I've tried the SGML:: tools on CPAN, but they don't quite work. I've also tried HTML::Parser, but it chokes on attributes which use "smart quotes" (0x201D in Unicode).
I've written a pure perl finite state machine parser (and test suite) which creates a data structure I can validate, but it is very slow. Like 45 seconds on a 900Kb file. The bottleneck is the parsing phase, so I'd like to speed that up somehow.
I've squeezed as much performance out of it as I can with Devel::NYTProf, but I think if I want to get it down to 10 seconds a file I need to rewrite the parser some how. I could go the C/XS route for it, but that would be a massive learning curve.
I haven't tried Parse::RecDescent yet or Parse::Yapp. What are your thoughts on them?
If you were writing a parser for something SGMLish (but not SGML), where would you start?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing SGML-ish Data Files
by mirod (Canon) on Aug 02, 2012 at 06:47 UTC | |
by coolmichael (Deacon) on Aug 15, 2012 at 19:27 UTC | |
by GrandFather (Saint) on Aug 16, 2012 at 03:29 UTC | |
|
Re: Parsing SGML-ish Data Files
by Anonymous Monk on Aug 01, 2012 at 22:09 UTC |