RE: flex perl mess

2001-11-07 Thread Garrett Goebel

Piers Cawley writes:
: If currying magic works in subroutine parameter strings then you can
: just do 
: 
: sub assert_with_func (^sub is constant, $^expected is constant,
:   $^got, $message)
: {
: ^sub($expected, $got) or die $message || $default_message;
: }
: 
: Here's hoping it will work.

That's my intention.

Larry



RE: flex perl mess

2001-11-07 Thread Garrett Goebel

Piers Cawley writes:
: Damian Conway [EMAIL PROTECTED] writes:
:  Of course, that's not to say that the particular Cundef that's returned on
:  failure-to-numerify mightn't have a property set that indicates the problem 
:  was not-a-numeric in nature.
: 
: Having more than one 'undef' value sounds like a recipe for internals
: madness. Or is the undef that gets slung around actually going to be a
: reference to the 'real' undef? 

NaN is merely the floating-point representation of undef when your
variable is stored in a bare num.  And if you declare a variable as
int, there may well be no representation for undef at all!  Similarly,
it may be impossible to taint an int or a num, unless we can figure
out a way to stuff such information into 0 bits.  But I'd like an
array of int or num to be compact.

Larry



Re: flex perl mess

2001-10-24 Thread Graham Barr

On Wed, Oct 24, 2001 at 09:06:14AM -0400, Aaron Sherman wrote:
 On Tue, Oct 23, 2001 at 02:53:19PM +0200, Nadim Khemir wrote:
 
   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
  
  The answer is NO, regexes and a lexer are totally different. I would
  recommend Tad to study a bit more what parsing is before thinking  it's jut
  about writing regexes. Having a lexer allows perl do some kind of text
  processing (raw lexing and parsing) at a much faster. If it is of some
  interest I could benchmark a simple example.
 
 So, aren't you saying, yes, but it would be slow? I can't think of
 anything a lexer is capable of that I can't (and probably haven't) done
 in Perl with relative ease.
 
 Now, if you want a PARSER, that's a different matter, but a simple
 lexical scanner is trivial to write in Perl with logic and regular
 expressions.
 
 In terms of speed, this is particularly ideal because you can identify
 what parts of your Perl code slow the lexer down, and re-code those
 using C/XS. The best of all 2,384 worlds... that's Perl!

I have always found that the perl output from byacc (with a few tweaks)
generates a sufficient parser. The addition of a switch statement
will hopefully make it more efficient.

For a lexer I try to use a single regex with /g, but that does require the
text being parsed to be all in a single scalar. Although that could be
worked around if needed.

For an example, take a look at Convert::ASN1

Graham.