PGE Java parser and floating hex notation

ChrisDolan on 2009-01-12T05:41:22

Last week I reported that I had a working parser for Java source code implemented as a Perl 6 grammar. Well, a dozen or so bugs later, it actually works now. Out of 7,000+ .java files in the OpenJDK, I fail to parse 3 of them (plus a handful that that are too large to fit in a gig of RAM -- I need to work on decreasing memory consumption). One of the three is a surely a bug, and the other two are unusual syntax that I've never seen before in java.lang.Double and java.lang.Float:

    public static final double MAX_VALUE = 0x1.fffffffffffffP+1023;
    public static final double MIN_NORMAL = 0x1.0p-1022;
    public static final double MIN_VALUE = 0x0.0000000000001P-1022;
    ...
    public static final float MAX_VALUE = 0x1.fffffeP+127f;
    public static final float MIN_NORMAL = 0x1.0p-126f;
    public static final float MIN_VALUE = 0x0.000002P-126f;


Hex notation for rational numbers -- what an interesting idea. I've never encountered that before. It appears that this notation first appeared in the 3rd edition of the Java language specification.

This seems to me like a notation worth adding to Perl 6, given its inherent precision advantages over decimal notation.