コード例 #1
1
ファイル: TokenStream.java プロジェクト: rwaldron/es6draft
 /**
  * <strong>[B.1.1] Numeric Literals</strong>
  *
  * <pre>
  * LegacyOctalIntegerLiteral ::
  *     0 OctalDigit
  *     LegacyOctalIntegerLiteral OctalDigit
  * </pre>
  */
 private double readLegacyOctalIntegerLiteral() {
   TokenStreamInput input = this.input;
   StringBuffer buffer = this.buffer();
   int c;
   while (isOctalDigit(c = input.get())) {
     buffer.add(c);
   }
   if (c == '8' || c == '9') {
     // invalid octal integer literal -> treat as decimal literal, no strict-mode error
     // FIXME: spec bug? undefined behaviour - SM reports a strict-mode error in this case
     return readDecimalLiteral(c, false);
   }
   parser.reportStrictModeSyntaxError(Messages.Key.StrictModeOctalIntegerLiteral);
   if (isDecimalDigitOrIdentifierStart(c)) {
     throw error(Messages.Key.InvalidOctalIntegerLiteral);
   }
   input.unget(c);
   if (buffer.length == 0) {
     throw error(Messages.Key.InvalidOctalIntegerLiteral);
   }
   return parseOctal(buffer.cbuf, buffer.length);
 }
コード例 #2
0
ファイル: TokenStream.java プロジェクト: rwaldron/es6draft
 /**
  * <strong>[B.1.2] String Literals</strong>
  *
  * <pre>
  * OctalEscapeSequence ::
  *     OctalDigit [lookahead &#x2209; DecimalDigit]
  *     ZeroToThree OctalDigit [lookahead &#x2209; DecimalDigit]
  *     FourToSeven OctalDigit
  *     ZeroToThree OctalDigit OctalDigit
  * ZeroToThree :: one of
  *     0 1 2 3
  * FourToSeven :: one of
  *     4 5 6 7
  * </pre>
  */
 private int readOctalEscape(int c) {
   parser.reportStrictModeSyntaxError(Messages.Key.StrictModeOctalEscapeSequence);
   int d = (c - '0');
   c = input.get();
   if (c < '0' || c > '7') {
     // FIXME: spec bug? behaviour for non-octal decimal digits?
     input.unget(c);
   } else {
     d = d * 8 + (c - '0');
     if (d <= 037) {
       c = input.get();
       if (c < '0' || c > '7') {
         // FIXME: spec bug? behaviour for non-octal decimal digits?
         input.unget(c);
       } else {
         d = d * 8 + (c - '0');
       }
     }
   }
   return d;
 }