in reply to To model or not to model

When I read your question, one thought hit me, which was

DOM or SAX?

Basically, it appeared as if you asking whether to construct a parse tree and subsequently evaluate it, or whether you should shift/reduce tokens on the fly.

I think the answer is

It depends.

As to the level of complexity, I would agree that frequently in all but the simplest cases, you might want to take a look into CPAN, and see if your parsing job can be made easier by one of the many modules there. However, if it is simple enough, then parsing with regexes might be the appropriate solution to your needs. Sometimes it's just easier to use a regex in a while.

Again, it's a matter of the particular problem, the nature of the data, and your requirements for processing it.

Just some thoughts,
-v.
"Perl. There is no substitute."

Replies are listed 'Best First'.
Re^2: To model or not to model
by samizdat (Vicar) on Apr 18, 2005 at 12:45 UTC
    Actually, I'm not even tokenizing it. Each line is a separate equation, and the worst line is a couple hundred characters. Perl-only regex sledgehammers work fine. ;-D

    Normally, I'd be jumping into CPAN as you suggest. I'm learning one thing here in this multipolyglot hodgepodge of systems, though. This particular project is not needed on many architectures, but many are, and keeping a module tree up to date is not a trivial thing here. For example, a co-worker has just spent literally two weeks full time and more just building gcc up to 3.4 on SPARCs running various Solarii variants. Much as I love CPAN and use it frequently, if I can do it native, I do.

    Besides, I learn more that way. ;-D