I wrote down the following statement in an ANTLR grammar:
loopStatement
: 'loop' (statement|exit)* 'end' 'loop' ';'
;
If I understand correctly, (statement|exit)* means that I can have a statement or an exit statement. That is
i.e statement_1 exit_1, or statement_1, or statement_1 statement_2, exit_1, right?
My parser works, besides when there's no the statement.
For example:
this works:
loop
x:=x+1; <<< statement_1
exit when x=9; <<<<exit_1
end loop;
this works as well (no exit):
loop
x:=x+1; <<< statement_1
<<<<exit_1 (no exit)
end loop;
but this DOES NOT work (no statement):
loop
<<< statement_1
exit when x=9; <<<<exit_1
end loop;
Is there anything wrong with my grammar?



