I wrote the following expression in the ANTLR grammar:
loopStatement
: 'loop' (statement|exit)* 'end' 'loop' ';'
;
If I understand correctly, it (statement|exit)*means that I can have statementor exit statement. That is, ie statement_1 exit_1, or statement_1, or statement_1 statement_2, exit_1, right?
My parser also works when there is no approval.
For instance:
it works:
loop
x:=x+1; <<< statement_1
exit when x=9; <<<<exit_1
end loop;
this works too (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 something wrong with my grammar?
source
share