This is how I'd do it:
program : statements
| statements last opt_semi
;
statements: /* empty */
| statements statement opt_semi
;
opt_semi : /* empty */
| ';'
;
where program
corresponds to E
; statement
to S
and last
to L
.