Loading ...
Sorry, an error occurred while loading the content.
 

(tree) grammar inheritance and reuse of parent rules

Expand Messages
  • Gerald Khin
    Hi, I have a parent tree walker grammar G1 with a clause like this: foo ... ; In my derived Grammar G2 I need to override only a single rule, for example the
    Message 1 of 2 , May 10, 2001
      Hi,

      I have a parent tree walker grammar G1 with a clause like this:

      foo
      : #( A ...)
      | #( B ...)
      | #( C ...)
      ...
      | #( Z ...)
      ;

      In my derived Grammar G2 I need to override only a single rule, for example the rule #( C ... ).
      The hitch is that I have to repeat also all other rules, which ends in a copy of the code like this:

      foo
      : #( A ...)
      | #( B ...)
      | #( C2 ...)
      ...
      | #( Z ...)
      ;

      My question: Is there any way to prevent the copying of the code (without touching the parent grammar!!!)?

      Regards
      Gerald
    • Ric Klaren
      Hi, ... Think this is inherant to the way antlr implements the inheritance. For now you ll probably stuck copying. If you have suggestions or so feel free to
      Message 2 of 2 , May 15, 2001
        Hi,

        On Thu, May 10, 2001 at 04:57:33PM +0200, Gerald Khin wrote:
        > My question: Is there any way to prevent the copying of the code (without
        > touching the parent grammar!!!)?

        Think this is inherant to the way antlr implements the inheritance. For now
        you'll probably stuck copying. If you have suggestions or so feel free to
        give them =)

        Ric
        --
        -----+++++*****************************************************+++++++++-------
        ---- Ric Klaren ----- klaren@... ----- +31 53 4893722 ----
        -----+++++*****************************************************+++++++++-------
        Why don't we just invite them to dinner and massacre them all when they're
        drunk? You heard the man. There's seven hundred thousand of them.
        Ah? ... So it'd have to be something simple with pasta, then.
        --- From: Interesting Times by Terry Pratchet
        -----+++++*****************************************************+++++++++-------
      Your message has been successfully submitted and would be delivered to recipients shortly.