On Tuesday, May 29, 2001, at 11:18  AM, Simon Wistow wrote:

> I started looking into this when I first started doing the SWF stuff ...
> a kind of YACC for file formats. Describe it in a BNF-a-like language
> and then run a program over it et voila - you have a library for reading
> and creating that file format (he says, glossing over lots of
> complications and gotchas). Write that program for each different
> language and lots of different languages/systems have access to lots of
> different fiel formats and every time a format changes the spec gets
> updated and everyone runs their grammar->library programs again and
> everybody's got full functionality again.

As Leon points out, Parse::RecDescent is One Way To Do It. However, it's
mostly used to parse some input according to some grammar and to 
construct
the desired result directly. If you need a different result from the same
grammar, you have to specify the grammar and actions again.

It might be an idea to have grammars packed up in modules (i.e., 
reusable)
and make the actions callbacks (some sort of autoaction might do that),
much like HTML and XML parsers do it. I imagine lots of little Parse::*
modules (Parse::Regex, Parse::PDF, Parse::RPN etc.).

Is that a) a good idea, b) a bad idea, c) common practice anyway and I 
just
haven't found it?

Marcel

--
$ perl -we time
Useless use of time in void context at -e line 1.

Reply via email to