Following, sort of, some advice I received earlier I modified my bison by 
adding this:

open_bracket:
 '(' | '[';
close_bracket:
 ')' | ']’;

And then modified the original code thus:

variable:
  VARIABLE_NAME
  {
    variable_t *new = malloc(sizeof(*new));
    new->name = $1;
    new->subscripts = NULL;
    new->slicing = NULL;
    $$ = new;
}
|
 VARIABLE_NAME open_bracket exprlist close_bracket
 {
    variable_t *new = malloc(sizeof(*new));
    new->name = $1;
    new->subscripts = $3;
    new->slicing = NULL;
    $$ = new;
 }

This source code works:

130 DIM A$(26),G$(26),L$(1)

But this fails:

130 DIM A$[26],G$[26],L$[1]

In this case it falls though the first variable case, not the second, it is not 
treating the [ as an open. The open_bracket is the only place [ appears.

I assume I have screwed up the alternation?

Reply via email to