Listing 2: The decl-specifier-seq parsing functions using the scanner's get and unget to look ahead one token


//
// decl-specifier-seq =
//     {
//     "const" |
//     "volatile" |
//     type-keyword |
//     type-name
//     } .
//
string parser::decl_specifier_seq()
    {
    ...
    token::category tc;
    for (;;)
        {
        tc = input.current().kind();
        if (tc == token::NAME)
            {
            tc = input.get().kind();
            input.unget();
            if (tc == token::SCOPE)
                break;
            tc = input.current().kind();
            }
        if (tc == token::CONST)
            ...
        else if (tc == token::VOLATILE)
            ...
        else if (tc == token::TYPE_KEYWORD
        || tc == token::NAME)
            ...
        else
            break;
        input.get();
        }
    ...
    }
//End of File