where S, A, B, C are non-terminals,
int and id are terminals,
C.i is an inherited attribute,
A.s and int.val are synthesized attributes.
Write a YACC program for this translation scheme.
Answer 1
S : A C
| A B M C
;
A : TOK_INT {$$ = $1; }
;
B : TOK_ID
;
M : /* empty */ {$$ = $-2; }
;
C : TOK_INT {$$ = $-1 + $1; }
;