I'm trying to parse a sequence of statements, with the following rule: statements must be separated by at least one newline, and the sequence may be padded with at least zero newlines. For example,
\n
stmt\n
stmt\n
\n
stmt
So far I've come up with this Yacc grammar,
stmt_list:
%empty
| stmt_list stmt seps
;
seps:
sep
| seps sep
;
but it doesn't match my example since my grammar expects a newline at the end. Is there are standard way of parsing this? Thanks.