summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pipac.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/pipac.c b/pipac.c
index a93e77f..dba6109 100644
--- a/pipac.c
+++ b/pipac.c
@@ -227,6 +227,14 @@ print_usage()
fputs("pipac <filename.pipa>\n", stderr);
}
+void
+print_tokens(lexer_t *lexer) {
+ token_t token;
+ for (lexer_next_token(lexer, &token); token.kind != TOKEN_EOF; lexer_next_token(lexer, &token)) {
+ printf("%s:%d:%d: [kind=%d, value='%s']\n", lexer->filepath, token.row + 1, token.col + 1, token.kind, token.value);
+ }
+}
+
int
main(int argc, char **argv)
{
@@ -242,10 +250,7 @@ main(int argc, char **argv)
printf("[INFO]: %ld bytes loaded [filename='%s']\n", lexer.srclen, lexer.filepath);
- token_t token;
- for (lexer_next_token(&lexer, &token); token.kind != TOKEN_EOF; lexer_next_token(&lexer, &token)) {
- printf("%s:%d:%d: [kind=%d, value='%s']\n", lexer.filepath, token.row + 1, token.col + 1, token.kind, token.value);
- }
+ print_tokens(&lexer);
return EXIT_SUCCESS;
}