#include "KeywordsLexer.h"
#include <iostream>

int main() {
    KeywordsLexer lex(std::cin);
    try {
        while (true) {
            KeywordsLexer::Token tok = lex.nextToken();
            switch (tok.type) {
                case KeywordsLexer::MODULE:
                    std::cout << "MODULE: ";
                    break;
                case KeywordsLexer::END:
                    std::cout << "END: ";
                    break;
                case KeywordsLexer::IF:
                    std::cout << "IF: ";
                    break;
                case KeywordsLexer::IDENT:
                    std::cout << "IDENT: ";
                    break;
                case KeywordsLexer::UNKNOWN:
                    std::cout << "UNKNOWN: ";
                    break;
                case KeywordsLexer::nonmatching: case KeywordsLexer::ignore:
                    break; //These can never occur, just to satisfy the compiler...
            }
            std::cout << "\"" << tok.content << "\"" << std::endl;
        }
    }
    catch (KeywordsLexer::NoMatch& err) {
        std::cout << "'" << lex.peek() << "'" << " did not match" << std::endl;
    }
    catch (KeywordsLexer::NoMoreTokens& err) {
        std::cout << "DONE" << std::endl;
    }
}
