> On 22 Oct 2019, at 08:05, Alan Eliasen <el...@mi... <mailto:el...@mi...>> wrote:
> To begin withn, I don't understand what [^] is supposed to match. It looks like a negating character class, but with nothing to negate. This makes no sense, so obviously something else was intended. What was it?
In JFlex, [] matches nothing, and [^] is the character class that negates that, i.e. it matches any single input character. It’s a generalisation of “.”
See also the section “Semantics” on character classes on https://www.jflex.de/manual.html <https://www.jflex.de/manual.html> .
The operator ! negates entire expressions. Since Pascal is matching something of the form "r | !r", this should match literally everything (either r matches or it doesn’t), and the second line in his spec should therefore never get a chance to run (but for some reason it does for the input he sent).
Cheers,
Gerwin
|