in reply to Parse::RecDescent and AUTOSTUB

You should be able to do
key_or_not_null: "primary"(?) "KEY"
Or you can write it with a regexp:
key_or_not_null: /(?:primary)?/ "KEY"
Or even:
key_or_not_null: "PRIMARY KEY" | "KEY"

Abigail

Replies are listed 'Best First'.
Re: Re: Parse::RecDescent and AUTOSTUB
by hagus (Monk) on Jan 29, 2004 at 23:21 UTC
    Me hearties, it be a fine piece o' code. But ye canna write:
    my $grammar = q { startrule: test test: "primary"(?) "key" };
    Cause ye gets an error! Arr!
    ERROR (line 4): Untranslatable item encountered: "?" (Hint: Did you misspell "?" or forget to comment it ou +t?)
    RD_TRACE told me:
    Parse::RecDescent: Treating "startrule:" as a rule declaration Parse::RecDescent: Treating "test" as a subrule match Parse::RecDescent: Treating "test:" as a rule declaration Parse::RecDescent: Treating ""primary"" as an interpolated literal terminal Parse::RecDescent: Treating "( ? )" as an implicit subrule Parse::RecDescent: Treating "_alternation_1_of_production_1_of_rul +e_test :" as a rule declaration ERROR (line 4): Untranslatable item encountered: "?" (Hint: Did you misspell "?" or forget to comment it ou +t?) Parse::RecDescent: Treating "_alternation_1_of_production_1_of_rul +e_test" as a subrule match Parse::RecDescent: Treating ""key"" as an interpolated literal ter +minal
    Arr.

    --
    Ash OS durbatulk, ash OS gimbatul,
    Ash OS thrakatulk, agh burzum-ishi krimpatul!
    Uzg-Microsoft-ishi amal fauthut burguuli.
      Sure, but you can write:
      test: ("primary")(?) "key"

      Abigail

        I see that now, Stevie-O was posting just as I finished posting mine ...
        --
        Ash OS durbatulk, ash OS gimbatul,
        Ash OS thrakatulk, agh burzum-ishi krimpatul!
        Uzg-Microsoft-ishi amal fauthut burguuli.