Reported by ulibube on 2004-03-05 16:38 UTC
The fact that %cup includes %eofclose can cause
trouble, in particular when switching from JLex to
JFlex. When using the %cup directive in JLex, no code
is generated to automatically close the input stream at
EOF. Closing an input stream typically also closes all
associated FilterStreams, etc., so it can have
far-reaching consequences. In my case, my code
mysteriously broke and had NullPointerExceptions in
unexpected places when I switched from JLex, because I
didn't realize that the %cup directive in JFlex behaves
substantially different in this respect from %cup in JLex.
I don't really understand why JFlex's %cup contains
%eofclose in the first place. I have not seen any
particular requirement from CUP to do so.
A related problem with this is that there is no
%noeofclose directive to undo the implicit effect of
%cup. So if I want to use CUP without automatic stream
closing (which I find perfectly ok) I cannot use %cup.
Reported by ulibube on 2004-03-05 16:38 UTC
The fact that %cup includes %eofclose can cause
trouble, in particular when switching from JLex to
JFlex. When using the %cup directive in JLex, no code
is generated to automatically close the input stream at
EOF. Closing an input stream typically also closes all
associated FilterStreams, etc., so it can have
far-reaching consequences. In my case, my code
mysteriously broke and had NullPointerExceptions in
unexpected places when I switched from JLex, because I
didn't realize that the %cup directive in JFlex behaves
substantially different in this respect from %cup in JLex.
I don't really understand why JFlex's %cup contains
%eofclose in the first place. I have not seen any
particular requirement from CUP to do so.
A related problem with this is that there is no
%noeofclose directive to undo the implicit effect of
%cup. So if I want to use CUP without automatic stream
closing (which I find perfectly ok) I cannot use %cup.