The following grammar is accepted by yacc(BSD) without any problems. It should work with bison(Linux) as well.
By general convention, the tokens are usually capitalized and rules are in lower case.
%token A A1 A2 A3 A4 A5 A6 A7 D
%%
a
: A b {
$$ = node($1, $2);
}
;
b
: A1 c {
$$ = node($1, $2);
}
| A2 c {
$$ = node($1, $2);
}
| A3 c {
$$ = node($1, $2);
}
;
c
: A4 d {
$$ = node($1, $2);
}
| A5 d {
$$ = node($1, $2);
}
| A6 d {
$$ = node($1, $2);
}
;
d
: D {
$$ = node($1);
}
;
%%
#include <stdio.h>
void yyerror(const char *s)
{
fflush(stdout);
fprintf(stderr, "*** %s\n", s);
}