[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Pattern matches one type of paren but not another
From: |
Maury Markowitz |
Subject: |
Pattern matches one type of paren but not another |
Date: |
Sun, 28 May 2023 14:12:10 -0400 |
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?
- Pattern matches one type of paren but not another,
Maury Markowitz <=