In a message dated Fri, 7 Jun 2002, [EMAIL PROTECTED] writes:
> The most serious objection to this was 'well, use modules for matching *ml" -
> which simply points out that the current incarnation of perl6 regex doesn'
> t handle a very large class of matching problems very well.

I don't think that's what people were saying at all.  They were saying you
should use modules, not because it's too hard to do in Perl 6 regexes, but
because *ml are well-formed, well-published languages and it doesn't make
sense to reinvent the wheel when you're nearly certain to miss cases
handled by the standard modules.

Unless I'm missing something, I'm assuming that those modules, when
rewritten in Perl 6, will be able to dump the specialized parsers and go
to using grammars as given in A5.

I guess this is as good an opportunity as any to be sure I've got what's
going on.  So, here's a first, simple, addmitedly broken hack at a simple
parser for xml-ish start tags and empty entities:

rule lt { \< }
rule gt { \> }
rule identifier {
    # I don't know the XML identifier rules, but let's pretend:
    <alpha> [ <alpha> | \d | _ ]*
}
rule val {
    [   # quoted
       $b := <['"]>
       ( [ \\. | . ]*? )
       $b
    ] | # or not
       (\H+)
}
rule parsetag :w {
   <lt> $tagname :=    <identifier>
        %attrs   := [ (<identifier>) =
                      (<val>)
                    ]*
   /?
   <gt>
}

for <$fh> {
    while m:e/<parsetag>/ {
       print "Found tag $0{tagname}\n";
       print "  $a = '$v'\n" for $0{attrs}.kv -> $a, $b;
    }
}

My questions are:

1. Does the match in my <val> rule get passed correctly?  I.e., I have
   parens in alternations, will whichever one gets matched become the
   return value of the whole rule?
2. Did I do the binding to the hash correctly?
3. Will my I/O loop work like I expect?

Trey

Reply via email to