src/Scanner.cpp
changeset 176 2b9141b01023
parent 174 e718b56aba78
child 194 b029d63565a2
     1.1 --- a/src/Scanner.cpp	Sat Sep 01 17:10:56 2012 -0700
     1.2 +++ b/src/Scanner.cpp	Sat Sep 01 17:11:06 2012 -0700
     1.3 @@ -278,6 +278,27 @@
     1.4  }
     1.5  
     1.6  TokenKind
     1.7 +Scanner::hexLiteral()
     1.8 +{
     1.9 +    literal_.clear();
    1.10 +
    1.11 +    char c;
    1.12 +    for (;;) {
    1.13 +        c = getChar();
    1.14 +        if (!IsHexDigit(c))
    1.15 +            break;
    1.16 +        if (!literal_.append(c))
    1.17 +            return TOK_ERROR;
    1.18 +    }
    1.19 +
    1.20 +    putChar(c);
    1.21 +
    1.22 +    if (!literal_.append('\0'))
    1.23 +        return TOK_ERROR;
    1.24 +    return TOK_HEX_LITERAL;
    1.25 +}
    1.26 +
    1.27 +TokenKind
    1.28  Scanner::numberLiteral(char first)
    1.29  {
    1.30      literal_.clear();
    1.31 @@ -293,6 +314,14 @@
    1.32              return TOK_ERROR;
    1.33      }
    1.34  
    1.35 +    // Detect a hexadecimal string.
    1.36 +    if (literal_.length() == 1 &&
    1.37 +        literal_[0] == '0' &&
    1.38 +        (c == 'x' || c == 'X'))
    1.39 +    {
    1.40 +        return hexLiteral();
    1.41 +    }
    1.42 +
    1.43      if (c != '.') {
    1.44          putChar(c);
    1.45          if (!literal_.append('\0'))