P::RD for tab-completion

[email protected] (Ted Zlatanov) Tue, 30 Mar 2010 13:44:46 -0500
Newsgroups perl.recdescent
Organization Теодор Златанов @ Cienfuegos
Message-ID <[email protected]>
I've got a working grammar that will parse, say

A a1 a2 a3
B b1 b2

into structures.  A and B don't overlap so I know that any sequence
beginning with A must have a1, a2, and a3.

Now I'm interested in finding out how much of the A rule can be matched,
for tab-completion (so I can tell if a1, a2, or a3 should be
completed).  I'm using Term::ReadLine::Gnu but that's not too
important.  Basically I want, given "A a1", to say "oh you want all the
possible values for a2 and a1 is already given."

I'm currently doing this by making a1..3 optional and then assembling
them back in order, but was wondering if there's a better way to fail
the match but tell me how far the parser got before it failed.

Thanks
Ted