I often find myself giving identical productions different
identifiers to make my grammar clearer and to get around the limitation
of named access only giving the last match to an identifier, like
the following:

my $grammar = <<'EOGRAMMAR';

instance : cell inst '(' signal(s /,/) ')' ';'

{ bless { cell  => $item{cell},
          inst => $item{inst},
          signals => $item[4]
        }, $item[0]; }


cell : /\w+/

{ $item [1] }

inst : /\w+/

{ $item [1] }

signal: '.' dest '(' src ')'

{
  bless { dest => $item{dest},
          src => $item{src}
        }, $item[0];
}

src : /[^)(]+/

{ $item [1] }

dest : /[^)(]+/

{ $item [1] }

EOGRAMMAR

I was wondering if there was a way to specify multiple identifiers
with the same production with a syntax like:

cell item : /\w+/

or

cell, item : /\w+/

or

cell:
item: /w+/

Thanks,
Colin Kuskie

Reply via email to