jflex-de / jflex

The fast scanner generator for Java™ with full Unicode support
http://jflex.de
Other
581 stars 114 forks source link

Is there a way to suppress comment/absolute path in the generated code? #971

Closed hurricup closed 1 year ago

hurricup commented 1 year ago

This is really annoying when you generate on different machines/oses and your resulting class is under VCS. Path is already changing.

I'm talking about

 * This class is a scanner generated by 
 * <a href="http://www.jflex.de/">JFlex</a> 1.7.0-1
....
lsf37 commented 1 year ago

IIRC, it should already be using a relative path which should be stable. The current version is 1.8.2 -- does it happen with that as well?

hurricup commented 1 year ago

Unfortunately I can't check, because we are using patched version of jflex. Could you please point me to the piece of code responsible for that? I tried to look yesterday, but couldn't find it :(

Does it use same slashes on windows/non-windows?

lsf37 commented 1 year ago

The code is this here https://github.com/jflex-de/jflex/blob/eb81a2960238c29b5ea91f38895359982e31b668/jflex/src/main/java/jflex/generator/Emitter.java#L407-L414

which is called in emitHeader: https://github.com/jflex-de/jflex/blob/eb81a2960238c29b5ea91f38895359982e31b668/jflex/src/main/java/jflex/generator/Emitter.java#L416-L421

In 1.7.0, emitHeader isn't in its own function yet, but if you search for generated by in Emitter.java you should find it. If you're using a patched version anyway, you could just delete that line that emits the source file name.

hurricup commented 1 year ago

Thank you!!!

lsf37 commented 1 year ago

I'll leave this open as possible enhancement, because we probably still get different versions of the path in current versions depending on the platform the lexer was generated on.

lsf37 commented 1 year ago

Closing this, because in 1.8.2 JFlex does already normalise the path to slashes, i.e. the output should not depend on the host OS.