--- Yary Hluchan <[EMAIL PROTECTED]> wrote:
> Thanks for the thoughtful consideration.  Austin's given some high-
> level examples of the kind I was hoping for,
> 
> "AH>" = Austin Hastings
> 
> AH> grammar Rainbow;
> AH> use Colorific;  # Import C<rule color;> and C<new>, among others.
> AH> 
> AH> What I don't know is how to recognize a color, which is to say I
> don't
> AH> know how to write the <color> rule -- because I don't know what
> this is
> AH> being applied to. Is this reading pixels, interpreting the
> results of
> AH> radio telescopy, or consuming Lucky Charms breakfast cereal bits?
> I
> AH> don't know, so I'm just going to assume that Yary can write that
> for me
> AH> -- it's his class, after all.
> 
> Right, "encapsulation" & "public interface" are the keys- rexen don't
> need
> to know what makes Colorific. (And yes, I am a he, unlike Yari from
> Tron.)
> I am curious about
> 
> AH> rule color {...};  # this one's on you.
> 
> if Colorific doesn't have stringification- that's the crux: passing
> non-letter atoms to the regex engine.  The way it's presented and
> used, it's a rule that matches a color object, and seeing it in the
> same_color rule is terrific- but (via RFC93?) I want to write it
> thus:
> 

This isn't quite meaningful. What does a "non-letter atom" mean?

If you're processing a file or a string, that's the basic P6 model.

But consider \u for unicode -- that's a multi-byte object in the
stream.  So for streams of bytes, the right way is just to code C<rule
color> such that it recognizes them in whatever form -- stringified or
not.

On the other hand, let's suppose that you've got a vast array of
floating point data:

my float @seti = {...evidence of intelligence, somewhere...};

It's a fair question to ask how to retarget the rexengine to use @seti
as the input stream. (I hereby declare that if anyone ever writes a
grammar to do stock-picking, I thunk it first! :-)

I'm guessing that the right way is to replace the low-level operators,
but what are they?

>  rule color { (.) <( $1.isa(Colorific) )> }
>  $daylight = &peek_at_sky =~ /<color>/; # is something in sky
> Colorific?

Alternatively, there may be a lower-level "stream" object that could be
replaced:

grammar Rainbow
{
  let &Rex::get_one := &read_float_from_array;

  # ...
}

> This example could be written with grep- but then, T(always)MTOWTDI.

Interesting, and possibly true. If you replaced all the interface-level
rules with code that interacted with some other data structure, it
might work:

rule color {
  fail unless some_condition($_);
  $0 = $_;
}

and then:

grep <Rainbow::Rainbow>, @sky_data;


But that's just wrong. I'll wager there's a "trick" we don't know yet
that will allow for processing arbitrary streams of data, no matter
what the source. The only question is whether we have to override
something on the grammer, override something on the regex, or implement
a "fake IOstream" class to feed to the rexengine.

> 
> Bonus points for the implementation of grammar Rainbow, very cute!
> Lucky strike is also clearly written, though, I was hoping to do away
> with any mention of \d.  I want to grab numbers as atoms and never
> enter the character realm.

But what does that mean? Do you want "standard patterns" so that you
can talk about <int> patterns and just have them work, or do you want
to change your "source" from a character stream/string to something
else?

> 
> AH>What I think you're looking for is the fact that they're not
> regexes
> AH>any more. They are "rexen", but in horrifying-secret-reality, what
> has
> AH>happened is that Larry's decided to move Fortran out of core, and
> AH>replace it with yacc.
> 
> Cool, I did quite like yacc when I needed it- and it does look like
> we
> have that expressive power now!  Never used Fortran but I did spend a
> couple summers in RPG-2, good riddence to big iron...

Well, formats have gone into a module, and the complex number stuff has
been relegated to the care of a more formal class structure. I was
pulling for "COMMON" data declarations, but that went to "state". 

But at least the Parrot interpreter can use computed gotos... :-)

=Austin

Reply via email to