Files
cworker/clib/jlexer_test.c
Олег Бородин 0cf61f4ad8 at work
2023-09-04 10:07:17 +02:00

43 lines
695 B
C

/*
* Copyright 2023 Oleg Borodin <borodin@unix7.org>
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <massert.h>
#include <rcache.h>
#include <jlexer.h>
int main(void) {
int fd = open("test.json", O_RDONLY);
MASSERT(fd > 0);
rcache_t cache;
rcache_init(&cache, fd);
jlexer_t lexer;
jlexer_init(&lexer, &cache);
char token[1024];
int type = 0;
while ((type = jlexer_gettoken(&lexer, token)) != JLEXTOK_END) {
printf("%02x: %s\n", type, token);
}
printf("%02x: %s\n", type, token);
rcache_destroy(&cache);
return 0;
}