git stults online reflex / master rx.c
master

Tree @master (Download .tar.gz)

rx.c @masterraw · history · blame

#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "rx-parse.h"
#include "rx-lex.h"


int main(int argc, char *argv[])
{
    int ret;
    FILE *in;
    YY_BUFFER_STATE yybf;
    void *scanner;

    if (argc < 2)
    {
	fprintf(stdout, "usage: %s file.rx\n", argv[0]);
	return 1;
    }
    
    if (NULL == (in = fopen(argv[1], "r")))
    {
	fprintf(stderr, "bad file %s", argv[1]);
	return 1;
    }

    yylex_init(&scanner);
    yybf = yy_create_buffer(in, YY_BUF_SIZE, scanner);
    yy_switch_to_buffer(yybf, scanner);
    ret = yyparse(scanner);
    yy_delete_buffer(yybf, scanner);
    yylex_destroy(scanner);
    fclose(in);
    return ret;
}