DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Untracked file

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is the JavaScript 2 Prototype.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 1998
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include <vector>

#include "systemtypes.h"
#include "js2value.h"

#include "numerics.h"
#include "lexer.h"

namespace JS = JavaScript;


// Create a new Lexer for lexing the provided source code.  The Lexer will
// intern identifiers, keywords, and regular expressions in the designated
// world.
JS::Lexer::Lexer(World &world, const String &source, const String &sourceLocation, uint32 initialLineNum):
        world(world), reader(source, sourceLocation, initialLineNum)
{
    nextToken = tokens;
    nTokensFwd = 0;
#ifdef DEBUG
    nTokensBack = 0;
#endif
    lexingUnit = false;
}


// Skip past the next token, which must have been either peeked or read and then unread.
// skip is faster than get but must not be called if the next token has not been seen yet.
void JS::Lexer::skip()
{
    ASSERT(nTokensFwd);
    if (++nextToken == tokens + tokenBufferSize)
        nextToken = tokens;
    --nTokensFwd;
    DEBUG_ONLY(++nTokensBack);
}


// Get and return the next token.  The token remains valid until the next
// call to this Lexer.  If the Reader reached the end of file, return a
// Token whose Kind is end.  The caller may alter the value of this Token
// (in particular, take control over the auto_ptr's data), but if it does so,
// the caller is not allowed to unget this Token.
//
// If preferRegExp is true, a / will be preferentially interpreted as
// starting a regular expression; otherwise, a / will be preferentially
// interpreted as division or /=.
const JS::Token &JS::Lexer::get(bool preferRegExp)
{
    const Token &t = peek(preferRegExp);
    if (++nextToken == tokens + tokenBufferSize)
        nextToken = tokens;
    --nTokensFwd;
    DEBUG_ONLY(++nTokensBack);
    return t;
}


// Peek at the next token using the given preferRegExp setting.  If that
// token's kind matches the given kind, consume that token and return it.
// Otherwise, do not consume that token and return nil.
const JS::Token *JS::Lexer::eat(bool preferRegExp, Token::Kind kind)
{
    const Token &t = peek(preferRegExp);
    if (t.kind != kind)
        return 0;
    if (++nextToken == tokens + tokenBufferSize)
        nextToken = tokens;
    --nTokensFwd;
    DEBUG_ONLY(++nTokensBack);
    return &t;
}


// Return the next token without consuming it.
//
// If preferRegExp is true, a / will be preferentially interpreted as
// starting a regular expression; otherwise, a / will be preferentially
// interpreted as division or /=. A subsequent call to peek or get will
// return the same token; that call must be presented with the same value
// for preferRegExp.
const JS::Token &JS::Lexer::peek(bool preferRegExp)
{
    // Use an already looked-up token if there is one.
    if (nTokensFwd) {
        ASSERT(savedPreferRegExp[nextToken - tokens] == preferRegExp);
    } else {
        lexToken(preferRegExp);
        nTokensFwd = 1;
#ifdef DEBUG
        savedPreferRegExp[nextToken - tokens] = preferRegExp;
        if (nTokensBack == tokenLookahead) {
            nTokensBack = tokenLookahead-1;
            if (tokenGuard)
                (nextToken >= tokens+tokenLookahead ?
                 nextToken-tokenLookahead :
                 nextToken+tokenBufferSize-tokenLookahead)->valid = false;
        }
#endif
    }
    return *nextToken;
}


#ifdef DEBUG
// Change the setting of preferRegExp for an already peeked token.
// The token must not be one for which that setting mattered.
//
// THIS IS A DANGEROUS FUNCTION!
// Use it only if you can be prove that the already peeked token does not
// start with a slash.
void JS::Lexer::redesignate(bool preferRegExp)
{
    if (nTokensFwd) {
        ASSERT(savedPreferRegExp[nextToken - tokens] != preferRegExp);
        ASSERT(!(nextToken->hasKind(Token::regExp) ||
                 nextToken->hasKind(Token::divide) ||
                 nextToken->hasKind(Token::divideEquals)));
        savedPreferRegExp[nextToken - tokens] = preferRegExp;
    }
}
#endif


// Unread the last token.  This call may be called to unread at most
// tokenBufferSize tokens at a time (where a peek also counts as temporarily
// reading and unreading one token). When a token that has been unread is
// peeked or read again, the same value must be passed in preferRegExp as for
// the first time that token was read or peeked.
void JS::Lexer::unget()
{
    ASSERT(nTokensBack--);
    nTokensFwd++;
    if (nextToken == tokens)
        nextToken = tokens + tokenBufferSize;
    --nextToken;
}


// Report a syntax error at the backUp-th last character read by the Reader.
// In other words, if backUp is 0, the error is at the next character to be
// read by the Reader; if backUp is 1, the error is at the last character
// read by the Reader, and so forth.
void JS::Lexer::syntaxError(const char *message, uint backUp)
{
    reader.unget(backUp);
    reader.error(Exception::syntaxError, widenCString(message), reader.getPos());
}


// Get the next character from the reader, skipping any Unicode format-control
// (Cf) characters.
inline char16 JS::Lexer::getChar()
{
    char16 ch = reader.get();
    if (char16Value(ch) >= firstFormatChar)
        ch = internalGetChar(ch);
    return ch;
}


// Helper for getChar()
char16 JS::Lexer::internalGetChar(char16 ch)
{
    while (isFormat(ch))
        ch = reader.get();
    return ch;
}


// Peek the next character from the reader, skipping any Unicode
// format-control (Cf) characters, which are read and discarded.
inline char16 JS::Lexer::peekChar()
{
    char16 ch = reader.peek();
    if (char16Value(ch) >= firstFormatChar)
        ch = internalPeekChar(ch);
    return ch;
}


// Helper for peekChar()
char16 JS::Lexer::internalPeekChar(char16 ch)
{
    while (isFormat(ch)) {
        reader.get();
        ch = reader.peek();
    }
    return ch;
}


// Peek the next character from the reader, skipping any Unicode
// format-control (Cf) characters, which are read and discarded.  If the
// peeked character matches ch, read that character and return true;
// otherwise return false.  ch must not be null.
bool JS::Lexer::testChar(char16 ch)
{
    ASSERT(ch);     // If ch were null, it could match the eof null.
    char16 ch2 = peekChar();
    if (ch == ch2) {
        reader.get();
        return true;
    }
    return false;
}


// A backslash has been read.  Read the rest of the escape code.
// Return the interpreted escaped character.  Throw an exception if the
// escape is not valid. If unicodeOnly is true, allow only \uxxxx escapes.
char16 JS::Lexer::lexEscape(bool unicodeOnly)
{
    char16 ch = getChar();
    int nDigits;

    if (!unicodeOnly || ch == 'u')
        switch (ch) {
          case '0':
            // Make sure that the next character isn't a digit.
            ch = peekChar();
            if (!isASCIIDecimalDigit(ch))
                return 0x00;
/*
            // Point to the next character in the error message
            getChar();
            break;
*/
			/* E3 compatibility, parse the sequence as octal */
            {
                uint32 n = 0;
                while (isASCIIDecimalDigit(ch)) {
                    ch = getChar();
                    n = (n << 3) | (ch - '0');
					ch = peekChar();
                }
                return static_cast<char16>(n);
            }


          case 'b':
            return 0x08;
          case 'f':
            return 0x0C;
          case 'n':
            return 0x0A;
          case 'r':
            return 0x0D;
          case 't':
            return 0x09;
          case 'v':
            return 0x0B;

          case 'x':
            nDigits = 2;
            goto lexHex;
          case 'u':
            nDigits = 4;
          lexHex:
            {
                uint32 n = 0;
                while (nDigits--) {
                    ch = getChar();
                    uint digit;
                    if (!isASCIIHexDigit(ch, digit)) {
						/* E3 compatibility, back off */
						// goto error;
						do {
							reader.unget();
							ch = peekChar();
						} while (ch != '\\');
                        return getChar();
					}
                    n = (n << 4) | digit;
                }
                return static_cast<char16>(n);
            }
          default:
/*
            if (!reader.getEof(ch)) {
                CharInfo chi(ch);
                if (!isAlphanumeric(chi) && !isLineBreak(chi))
                    return ch;
            }
*/
              return ch;
        }
//  error:
    syntaxError("Bad escape code");
    return 0;
}


// Read an identifier into s.  The initial value of s is ignored and cleared.
// Return true if an escape code has been encountered.
// If allowLeadingDigit is true, allow the first character of s to be a digit,
// just like any continuing identifier character.
bool JS::Lexer::lexIdentifier(String &s, bool allowLeadingDigit)
{
    reader.beginRecording(s);
    bool hasEscape = false;

    while (true) {
        char16 ch = getChar();
        char16 ch2 = ch;
        if (ch == '\\') {
            ch2 = lexEscape(true);
            hasEscape = true;
        }
        CharInfo chi2(ch2);

        if (!(allowLeadingDigit ? isIdContinuing(chi2) :
              isIdLeading(chi2))) {
            if (ch == '\\')
                syntaxError("Identifier escape expands into non-identifier character");
            else
                reader.unget();
            break;
        }
        reader.recordChar(ch2);
        allowLeadingDigit = true;
    }
    reader.endRecording();
    return hasEscape;
}


// Read a numeric literal into nextToken->chars and nextToken->value.
// Return true if the numeric literal is followed by a unit, but don't read
// the unit yet.
bool JS::Lexer::lexNumeral()
{
    int hasDecimalPoint = 0;
    bool hexadecimal = false;
    bool octal = false;
    String &s = nextToken->chars;
    uint digit;

    reader.beginRecording(s);
    char16 ch = getChar();
    if (ch == '0') {
        reader.recordChar('0');
        ch = getChar();
        if ((ch&~0x20) == 'X') {
            size_t pos = reader.getPos();
            char16 ch2 = getChar();
            if (isASCIIHexDigit(ch2, digit)) {
                hexadecimal = true;
                reader.recordChar(ch);
                do {
                    reader.recordChar(ch2);
                    ch2 = getChar();
                } while (isASCIIHexDigit(ch2, digit));
                ch = ch2;
            } else
                reader.setPos(pos);
            goto done;
        } else if (isASCIIOctalDigit(ch)) {
            // Backward compatible hack, support octal for SpiderMonkey's sake
            octal = true;
            while (isASCIIOctalDigit(ch)) {
                reader.recordChar(ch);
                ch = getChar();
            }
            goto done;
//          syntaxError("Numeric constant syntax error");
        }
    }
    while (isASCIIDecimalDigit(ch) || ch == '.' && !hasDecimalPoint++) {
        reader.recordChar(ch);
        ch = getChar();
    }
    if ((ch&~0x20) == 'E') {
        size_t pos = reader.getPos();
        char16 ch2 = getChar();
        char16 sign = 0;
        if (ch2 == '+' || ch2 == '-') {
            sign = ch2;
            ch2 = getChar();
        }
        if (isASCIIDecimalDigit(ch2)) {
            reader.recordChar(ch);
            if (sign)
                reader.recordChar(sign);
            do {
                reader.recordChar(ch2);
                ch2 = getChar();
            } while (isASCIIDecimalDigit(ch2));
            ch = ch2;
        } else
            reader.setPos(pos);
    }

  done:
    // At this point the reader is just past the character ch, which
    // is the first non-formatting character that is not part of the
    // number.
    reader.endRecording();
    const char16 *sBegin = s.data();
    const char16 *sEnd = sBegin + s.size();
    const char16 *numEnd;
    nextToken->value = hexadecimal ? 
                            stringToInteger(sBegin, sEnd, numEnd, 16)
                          : octal ? 
                                stringToInteger(sBegin, sEnd, numEnd, 8)
                              : stringToDouble(sBegin, sEnd, numEnd);
    ASSERT(numEnd == sEnd);
    reader.unget();
    ASSERT(ch == reader.peek());
    return isIdContinuing(ch) || ch == '\\';
}


// Read a string literal into s.  The initial value of s is ignored and
// cleared. The opening quote has already been read into separator.
void JS::Lexer::lexString(String &s, char16 separator)
{
    char16 ch;

    reader.beginRecording(s);
    while ((ch = reader.get()) != separator) {
        CharInfo chi(ch);
        if (!isFormat(chi)) {
            if (ch == '\\')
                ch = lexEscape(false);
            else if (reader.getEof(ch) || isLineBreak(chi))
                syntaxError("Unterminated string literal");
            reader.recordChar(ch);
        }
    }
    reader.endRecording();
}


// Read a regular expression literal.  Store the regular expression in
// nextToken->id and the flags in nextToken->chars.
// The opening slash has already been read.
void JS::Lexer::lexRegExp()
{
    String s;
    char16 prevCh = 0;

    reader.beginRecording(s);
    while (true) {
        char16 ch = getChar();
        CharInfo chi(ch);
        if (reader.getEof(ch) || isLineBreak(chi))
            syntaxError("Unterminated regular expression literal");
        if (prevCh == '\\') {
            reader.recordChar(ch);
            // Ignore slashes and backslashes immediately after a backslash
            prevCh = 0;
        } else if (ch != '/') {
            reader.recordChar(ch);
            prevCh = ch;
        } else
            break;
    }
    reader.endRecording();
    nextToken->id = &world.identifiers[s];

    lexIdentifier(nextToken->chars, true);
}


// Read a token from the Reader and store it at *nextToken.
// If the Reader reached the end of file, store a Token whose Kind is end.
void JS::Lexer::lexToken(bool preferRegExp)
{
    Token &t = *nextToken;
    t.lineBreak = false;
    t.id = 0;
    // Don't really need to waste time clearing this string here
    //clear(t.chars);
    Token::Kind kind;

    if (lexingUnit) {
        if (reader.peek() == '_')
            syntaxError("Unit suffix may not begin with an underscore", 0);
        lexIdentifier(t.chars, false);
        ASSERT(t.chars.size());
        kind = Token::unit;   // unit
        lexingUnit = false;
    } else {
      next:
        char16 ch = reader.get();
        if (reader.getEof(ch)) {
          endOfInput:
            t.pos = reader.getPos() - 1;
            kind = Token::end;
        } else {
            char16 ch2;
            CharInfo chi(ch);

            switch (cGroup(chi)) {
              case CharInfo::FormatGroup:
              case CharInfo::WhiteGroup:
                goto next;

              case CharInfo::IdGroup:
                t.pos = reader.getPos() - 1;
              readIdentifier:
                {
                    reader.unget();
                    String s;
                    bool hasEscape = lexIdentifier(s, false);
                    t.id = &world.identifiers[s];
                    kind = hasEscape ? Token::identifier : t.id->tokenKind;
                }
                break;

              case CharInfo::NonIdGroup:
              case CharInfo::IdContinueGroup:
                t.pos = reader.getPos() - 1;
                switch (ch) {
                  case '(':
                    kind = Token::openParenthesis;  // (
                    break;
                  case ')':
                    kind = Token::closeParenthesis; // )
                    break;
                  case '[':
                    kind = Token::openBracket;      // [
                    break;
                  case ']':
                    kind = Token::closeBracket;     // ]
                    break;
                  case '{':
                    kind = Token::openBrace;        // {
                    break;
                  case '}':
                    kind = Token::closeBrace;       // }
                    break;
                  case ',':
                    kind = Token::comma;            // ,
                    break;
                  case ';':
                    kind = Token::semicolon;        // ;
                    break;
                  case '.':
                    kind = Token::dot;              // .
                    ch2 = getChar();
                    if (isASCIIDecimalDigit(ch2)) {
                        reader.setPos(t.pos);
                        goto number;                // decimal point
                    } else if (ch2 == '.') {
                        kind = Token::doubleDot;    // ..
                        if (testChar('.'))
                            kind = Token::tripleDot;// ...
                    } else
                        reader.unget();
                    break;
                  case ':':
                    kind = Token::colon;            // :
                    if (testChar(':'))
                        kind = Token::doubleColon;  // ::
                    break;
                  case '#':
                    kind = Token::pound;            // #
                    break;
                  case '@':
                    kind = Token::at;               // @
                    break;
                  case '?':
                    kind = Token::question;         // ?
                    break;

                  case '~':
                    kind = Token::complement;       // ~
                    break;
                  case '!':
                    kind = Token::logicalNot;       // !
                    if (testChar('=')) {
                        kind = Token::notEqual;     // !=
                        if (testChar('='))
                            kind = Token::notIdentical; // !==
                    }
                    break;

                  case '*':
                    kind = Token::times;            // * *=
                  tryAssignment:
                    if (testChar('='))
                        kind = Token::Kind(kind + Token::timesEquals - Token::times);
                    break;

                  case '/':
                    kind = Token::divide;           // /
                    ch = getChar();
                    if (ch == '/') {                // // comment
                        do {
                            ch = reader.get();
                            if (reader.getEof(ch))
                                goto endOfInput;
                        } while (!isLineBreak(ch));
                        goto endOfLine;
                    } else if (ch == '*') {         // /*comment*/
                        ch = 0;
                        do {
                            ch2 = ch;
                            ch = getChar();
                            if (isLineBreak(ch)) {
                                reader.beginLine();
                                t.lineBreak = true;
                            } else if (reader.getEof(ch))
                                syntaxError("Unterminated /* comment");
                        } while (ch != '/' || ch2 != '*');
                        goto next;
                    } else {
                        reader.unget();
                        if (preferRegExp) {         // Regular expression
                            kind = Token::regExp;
                            lexRegExp();
                        } else
                            goto tryAssignment;     // /=
                    }
                    break;

                  case '%':
                    kind = Token::modulo;           // %
                    goto tryAssignment;             // %=

                  case '+':
                    kind = Token::plus;             // +
                    if (testChar('+'))
                        kind = Token::increment;    // ++
                    else
                        goto tryAssignment;         // +=
                    break;

                  case '-':
                    kind = Token::minus;            // -
                    ch = getChar();
                    if (ch == '-')
                        kind = Token::decrement;    // --
                    else if (ch == '>')
                        kind = Token::arrow;        // ->
                    else {
                        reader.unget();
                        goto tryAssignment;         // -=
                    }
                    break;

                  case '&':
                    kind = Token::bitwiseAnd;       // & && &= &&=
                  logical:
                    if (testChar(ch))
                        kind = Token::Kind(kind - Token::bitwiseAnd + Token::logicalAnd);
                    goto tryAssignment;
                  case '^':
                    kind = Token::bitwiseXor;       // ^ ^^ ^= ^^=
                    goto logical;
                  case '|':
                    kind = Token::bitwiseOr;        // | || |= ||=
                    goto logical;

                  case '=':
                    kind = Token::assignment;       // =
                    if (testChar('=')) {
                        kind = Token::equal;        // ==
                        if (testChar('='))
                            kind = Token::identical; // ===
                    }
                    break;

                  case '<':
                    kind = Token::lessThan;         // <
                    if (testChar('<')) {
                        kind = Token::leftShift;    // <<
                        goto tryAssignment;         // <<=
                    }
                  comparison:
                    if (testChar('='))              // <= >=
                        kind = Token::Kind(kind + Token::lessThanOrEqual - Token::lessThan);
                    break;
                  case '>':
                    kind = Token::greaterThan;      // >
                    if (testChar('>')) {
                        kind = Token::rightShift;   // >>
                        if (testChar('>'))
                            kind = Token::logicalRightShift; // >>>
                        goto tryAssignment;         // >>= >>>=
                    }
                    goto comparison;

                  case '\\':
                    goto readIdentifier;            // An identifier that starts with an escape

                  case '\'':
                  case '"':
                    kind = Token::string;           // 'string' "string"
                    lexString(t.chars, ch);
                    break;

                  case '0':
                  case '1':
                  case '2':
                  case '3':
                  case '4':
                  case '5':
                  case '6':
                  case '7':
                  case '8':
                  case '9':
                    reader.unget();                 // Number
                  number:
                    kind = Token::number;
#ifdef PARSE_UNIT
                    lexingUnit = 
#else
						lexNumeral();
#endif
                    break;

                  default:
                    syntaxError("Bad character");
                }
                break;

              case CharInfo::LineBreakGroup:
              endOfLine:
                reader.beginLine();
                t.lineBreak = true;
                goto next;
            }
        }
    }
    t.kind = kind;
#ifdef DEBUG
    t.valid = true;
#endif
}