JFlex: `[^]` matches any character including newline (`[]`/`[^]` are illegal in flex)
In JFlex a negated character class with an empty list — [^] — matches any character of the input character set, INCLUDING a line terminator. That is the idiomatic way to write a block-comment rule that spans lines:
blockcomment = "/*"[^]*"*/"This is a real divergence from flex: the JFlex manual states the classes [] and [^] are illegal in flex but have meaning in JFlex ([^] = any character, including unpaired Unicode surrogates).
Related gotchas in the same family:
- . in JFlex does NOT match the line terminator, so "//".* stops at end of line (good for line comments).
- JFlex has an up-to operator ~a; ~"*/" matches everything up to and including */, so a C comment is "/*" ~"*/".
- \n is the LF character only, not "end of line"; for a true line terminator use \R (which additionally covers CR, CRLF, NEL, LS, PS).
So a block comment that must cross lines is "/*"[^]*"*/" in JFlex, whereas in flex you would need a start condition. Do not port a flex block-comment rule verbatim.