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.
The text was updated successfully, but these errors were encountered:
Commented by lsf37 on 2004-03-08 08:20 UTC
Logged In: YES
You are right, this is a problem. An additional problem is
that I can't just change the %cup behaviour now without
breaking existing programs.
This is what I plan to do: The 1.4pre versions of JFlex
have a command line switch --jlex which is there to go
fully compatible with JLex. In this mode, %cup will do
exactly what it does now in JLex. In the 'normal' mode
(without anything) it will stay as it is. Additionally,
I'll introduce something like %noneofclose (not sure yet
about the exact syntax, maybe %eofclose false or