1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>

#include "lexer.h"

int
main()
{
    setLexerIn(stdin, "<stdin>");

    const char *comment;
    for (enum TokenKind kind; (kind = getToken()) != EOI;) {
        if (*(comment = getPendingComment())) {
            printf("comment:\n%s", comment);
        }
        
        printf("%s:%zu.%zu-%zu.%zu: %s %s\n", token.loc.filename,
               token.loc.begin.line, token.loc.begin.col, token.loc.end.line,
               token.loc.end.col, strTokenKind(token.kind), token.val.cstr);
    }
    printf("%s:%zu.%zu-%zu.%zu: %s %s\n", token.loc.filename,
           token.loc.begin.line, token.loc.begin.col, token.loc.end.line,
           token.loc.end.col, strTokenKind(token.kind), token.val.cstr);
}