Listing 4: The decl-specifier-seq parsing function using the scanner's new mark and backup functions


//
// decl-specifier-seq =
//     {
//     "const" | "volatile" | type-keyword | type-name
//     } .
//
string parser::decl_specifier_seq()
    {
    ...
    for (;;)
        {
        tc = input.current().kind();
        if (tc == token::NAME)
            {
            input.mark();
            tc = input.get().kind();
            input.backup();
            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