Listing 3: A simple program for testing the scanner


//
// scantest.cpp
//
#include <iomanip>
#include <iostream>
#include <string>
#include "scanner.h"
int main()
    {
    scanner s(cin);
    token t;
    while ((t = s.get()).kind() != token::NO_MORE)
        cout << setw(16) << image(t.kind())
            << " : " << t.text() << '\n';
    return 0;
    }