in reply to Re: Re: Re: Re: Re: Re: Re: A Macro System for Perl?
in thread A Macro System for Perl?

The only problem there is that adding rules to the parser is likely to look more like:
myour => qc( my | our | ), decl => qc( package <package_decl> | module <module_decl> | class <class_decl> | sub <sub_decl> | <@other_declarations> ),
than perl. Perl's not necessarily the best language to express rules in.

I'm also not sure we're going top-down with the parser. We'll see what works best.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Re: Re: Re: A Macro System for Perl?
by educated_foo (Vicar) on May 05, 2002 at 22:42 UTC
    For the first part, I'd be inclined to say "it's just syntax." Granted, it's _important_ syntax -- we shouldn't force new syntax on programmers unless absolutely necessary -- but _if_ this is actually something a lot of people want to use, would it be hard to make the syntax perlier? Perl5 may not be the best language to express rules, but I get the feeling that Larry's eminent integration of regex backtracking with the rest of the language may change that somewhat.

    For the second -- I personally think top-down is more intuitive, but I don't think the "reconfigure the parser" idea is necessarily tied to "the parser" being top-down. Also, the possibility of doing something like this could factor into your definition of "best".

    /s

      It's not quite just syntax, though--it's severely restricted syntax. If you want a fast parser, the rules need to be stated in a way that allows the parser rule processor to transform them into a single big glob 'o program. (Generally a state machine, but that's not strictly necessary) The more degrees of freedom you allow in rule specification, the slower and more difficult the parser is to write.

      The problem with top-down parsing is that it's slow. The more states and rules, the slower it is. Perl's grammar would take ages to process by a top-down parser.

        The problem with top-down parsing is that it's slow. The more states and rules, the slower it is. Perl's grammar would take ages to process by a top-down parser.
        Speaking as someone currently wrestling with Inline::CPP, "amen". In the interest of finding out how it was getting lost in my C++, I turned on tracing, and was presented with the spoor of something like two minutes of backtracking fury. I'm not about to try and re-implement it in Parse::YAPP, though...

        /s