Ted Zlatanov
Thu, 25 Oct 2007 00:53:17 -0700
On Wed, 24 Oct 2007 05:17:11 -0400 "Terrence Brannon" <[EMAIL PROTECTED]> wrote:
TB> On 10/23/07, Ted Zlatanov <[EMAIL PROTECTED]> wrote:
>>
>> Any chance you can post a complete example with sample input that fails?
>>
TB> my $grammar = << 'EOGRAMMAR';
TB> store: name geoloc
TB> name: "trader joe's" | "whole foods"
TB> geoloc: geoloc1 and(?) geoloc2 | geoloc_
TB> geoloc1: geoloc_
TB> geoloc2: geoloc_
TB> geoloc_: city | state | country | area
TB> and: 'and'
TB> city: 'los angeles' | 'new york'
TB> state: 'california' | 'new york'
TB> country: 'united states'
TB> area: 'north' | 'south' | 'east' | 'west'
TB> EOGRAMMAR
I think actions may be the answer for your original problem, which was
to distinguish the two positions (so you created the geoloc1 and geoloc2
rules). An action like this:
{ $return = { item1 => $item[1], item2 => $item[3] }; }
would give you back a hash with the entries for your matched items named
appropriately. I don't know why you had subrule problems, sorry.
You could also consider the <leftop> command, which could set up
"A and B and C" parsing for you, unlike your current rules which only
accomodate one "and". You can use actions again to return the right
things by name.
Hope this helps.
Ted