From 0710a40e50d12cd731b0372d79d0ccdfbaee10d4 Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 1 Feb 2023 00:16:08 -0600 Subject: add kalmia_parse_file() --- yy/main.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'yy/main.c') diff --git a/yy/main.c b/yy/main.c index 5bc5508..52058d3 100644 --- a/yy/main.c +++ b/yy/main.c @@ -50,23 +50,10 @@ int main(int argc, char **argv) fprintf(stderr, "You must specify a file to parse!\n"); return -1; } - FILE *in = fopen(argv[1], "r"); - if (in == NULL) { - fprintf(stderr, "Could not open file \"%s\"\n", argv[1]); - return -1; - } - - struct kai_tag_t *document; - yyscan_t scanner; - kalmialex_init(&scanner); - kalmiaset_in(in, scanner); - int result = kalmiaparse(scanner, &document); - kalmialex_destroy(scanner); - fclose(in); - - if (result != 0) { - return result; + struct kai_tag_t *document = kai_parse_file(argv[1]); + if (document == NULL) { + return -1; } print_tag("", document); -- cgit v1.2.1