Re: A proposal for more powerful text processing to be built in to Perl: Flex and Pushdown Expressions.
On Thu, May 10, 2001 at 04:26:56PM -0700, Daniel S. Wilkerson wrote: > Flex - Put all of flex right into Perl. Flex is simply an event > engine (-compiler) for driving calls against code according to regular > expression matching events. While it is often convenient to have the > the flow of control expressed in an imperative way (do this; do this; > do this) as Perl already has, the event-driven regular expression > matching that lexers offer would allow one to easily write > mini-language interpreters or pre-processors in Perl very easily. Don't we already have that in Perl 5? if ( /\G\s+/gc ) {# whitespaces } elsif ( /\G[*/+-]/gc ) { # operator } elsif ( /\G\d+/gc ) {# term } elsif ( /\G.+/gc ) { # unrecognized token } -- Tad McClellan SGML consulting [EMAIL PROTECTED] Perl programming Fort Worth, Texas
Re: A proposal for more powerful text processing to be built in to Perl: Flex and Pushdown Expressions.
On Fri, 11 May 2001 08:29:07 -0500, Tad McClellan wrote: >On Thu, May 10, 2001 at 04:26:56PM -0700, Daniel S. Wilkerson wrote: > >> Flex - Put all of flex right into Perl. >Don't we already have that in Perl 5? Sortof. What he is proposing, is again the age old proposal of putting the notion of (simple) grammars into Perl's regex engine. Part of what he proposes, namely the events, can/could be done with embedded perl code into the regex, AKA the infamous "(?{...})" construct. The advantage over doing this in plain perl, as you showed, is that includes the possibility for backtracking, all without any help from the outside. The "(??{...})" construct might likely be used to match nested parentheses, for example. I'm not really sure, I'm not too familiar with this crash-prone feature. -- Bart.
Re: A proposal for more powerful text processing to be built in to Perl: Flex and Pushdown Expressions.
On Thu, May 10, 2001 at 04:26:56PM -0700, Daniel S. Wilkerson wrote: > Flex - Put all of flex right into Perl. Having a lexer in Perl is useful, but does it have to be built into the core? There already are several lexer modules for Perl 5 (Parse::Lex, Lex, Parse::RecDescent...) and while they may be benefited by certain small, sharp additions to Perl, they do rather well outside the core (and it means the Perl 6 developers don't have to add Yet More to their plate). > Pushdown expressions - Slightly more powerful "regular" expressions. > > This modifier would require that all parentheses-like literals: () [] > {} pair-up in order for the trailing one to match. That might be handy, its been getting easier to do this sort of thing in a regex but its still a bit less-than-obvious. Non-obvious enough to require its own module: Text::Balanced. Can't comment on the particular syntax you've chosen, but the idea sounds useful. -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One make a channel called #Perl, and infest it with joking and fun it doesnt make alot of sense.
Re: A proposal for more powerful text processing to be built in to Perl: Flex and Pushdown Expressions.
I consider that the biggest weakness of the regex implementation currently is that it can't easily return nested data structures. Of course, regex readability could always use work too. Larry