langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
changeset 25445 603f0c93d5c9
parent 22163 3651128c74eb
child 25600 7f93cb0536fd
equal deleted inserted replaced
25444:27045478cf23 25445:603f0c93d5c9
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    44  */
    44  */
    45 public class JavaTokenizer {
    45 public class JavaTokenizer {
    46 
    46 
    47     private static final boolean scannerDebug = false;
    47     private static final boolean scannerDebug = false;
    48 
    48 
    49     /** Allow hex floating-point literals.
       
    50      */
       
    51     private boolean allowHexFloats;
       
    52 
       
    53     /** Allow binary literals.
    49     /** Allow binary literals.
    54      */
    50      */
    55     private boolean allowBinaryLiterals;
    51     private boolean allowBinaryLiterals;
    56 
    52 
    57     /** Allow underscores in literals.
    53     /** Allow underscores in literals.
   124         this.log = fac.log;
   120         this.log = fac.log;
   125         this.tokens = fac.tokens;
   121         this.tokens = fac.tokens;
   126         this.source = fac.source;
   122         this.source = fac.source;
   127         this.reader = reader;
   123         this.reader = reader;
   128         this.allowBinaryLiterals = source.allowBinaryLiterals();
   124         this.allowBinaryLiterals = source.allowBinaryLiterals();
   129         this.allowHexFloats = source.allowHexFloats();
       
   130         this.allowUnderscoresInLiterals = source.allowUnderscoresInLiterals();
   125         this.allowUnderscoresInLiterals = source.allowUnderscoresInLiterals();
   131     }
   126     }
   132 
   127 
   133     /** Report an error at the given position using the provided arguments.
   128     /** Report an error at the given position using the provided arguments.
   134      */
   129      */
   218                 reader.putChar(true);
   213                 reader.putChar(true);
   219             }
   214             }
   220             skipIllegalUnderscores();
   215             skipIllegalUnderscores();
   221             if ('0' <= reader.ch && reader.ch <= '9') {
   216             if ('0' <= reader.ch && reader.ch <= '9') {
   222                 scanDigits(pos, 10);
   217                 scanDigits(pos, 10);
   223                 if (!allowHexFloats) {
   218                 if (!hexFloatsWork)
   224                     lexError(pos, "unsupported.fp.lit", source.name);
       
   225                     allowHexFloats = true;
       
   226                 }
       
   227                 else if (!hexFloatsWork)
       
   228                     lexError(pos, "unsupported.cross.fp.lit");
   219                     lexError(pos, "unsupported.cross.fp.lit");
   229             } else
   220             } else
   230                 lexError(pos, "malformed.fp.lit");
   221                 lexError(pos, "malformed.fp.lit");
   231         } else {
   222         } else {
   232             lexError(pos, "malformed.fp.lit");
   223             lexError(pos, "malformed.fp.lit");