Mach/builder/src-c/token-displayer.c

21 lines
515 B
C
Raw Normal View History

#include <parser.h>
#include <string.h>
#include <stdio.h>
void mach_display_token_stream(MachTokenStream *stream)
{
usz_t token_index = 0;
while(token_index < stream->num_tokens)
{
MachToken token = stream->tokens[token_index];
char token_string[token.length + 1];
memcpy(token_string, &stream->source[token.offset], token.length);
token_string[token.length] = 0;
printf("#%-4d %s\n", (int) token_index, token_string);
++token_index;
}
}