On 11/4/05, Patrick R. Michaud <[EMAIL PROTECTED]> wrote:
> As a quick example, one can now use the <p6rule> subrule
> to parse a perl 6 rule expression, and the Match object
> that is returned contains the parse tree.  Other examples
> and demonstrations or parsing are in the examples/pge/
> directory.

pmichaud++ for getting this done. :-)

I have just committed (in Parrot and Pugs) the support for the
newstyle match tree for PGE::Hs, so this works now:

  pugs> ('1' ~~ /<p6rule>/)<p6rule>
  Match.new(
    ok => bool::true,
    from => 0,
    to => 1,
    str => "1",
    sub_pos => (),
    sub_named =>
      { "expr" =>
          Match.new(
            ok => bool::true,
            from => 0,
            to => 1,
            str => "1",
            sub_pos => (),
            sub_named => {"type" => "term:", "value" => "1"}
          )
      }
  )

I noticed that zero-length input is now rejected by <p6rules>; I tried
to fix it, but could not determine where the fix should go.  A trace is
listed below:

  compilers/pge$ echo 'rule ' | parrot demo.pir
  Missing term at offset 0
  current instr.: 'PGE::OPTable :: parse' pc 1483
(compilers/pge/PGE/Exp.pir:134)

As a workaround, I special-cased m:// and m:P5// in Pugs, which may
be useful anyway, as split(//, $string) is quite common.

Cheers again for getting the OPTable nailed!

Thanks,
/Autrijus/

Reply via email to