Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 46 lines (41 sloc) 1.089 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#include <stdio.h>
#include <stdlib.h>
#include "cdata.h"
#include "lexglb.h"

void *cdataParseAlloc(void *(*mallocProc)(size_t));
void *cdataParseFree(void *p, void (*freeProc)(void*));

extern FILE *yyin;
typedef struct yy_buffer_state *YY_BUFFER_STATE;

extern int yylex(void);
extern YY_BUFFER_STATE yy_scan_string(const char*);
extern void yy_delete_buffer(YY_BUFFER_STATE);

int main(int argc, char** argv)
{
int n;
int yv;
char buf[4096];
FILE *cfile;
void* pParser = cdataParseAlloc(malloc);

cfile = fopen("test_parser.c", "ro");
if (cfile != NULL)
printf("File opened successfully!\n");
//printf("---------------------------\n");
while ((n = fread(buf, 1, sizeof(buf), cfile)) > 0)
{
buf[n] = '\0';
//printf("%s", buf);
printf("==========================\n");
yy_scan_string(buf);
while ((yv=yylex()) !=0)
{
cdataParse(pParser, yv, yylval);
}
}
printf("\n\n");
printf("---------------------------\n");
fclose(cfile);
printf("File closed successfully!\n");
cdataParse(pParser, 0, yylval);
cdataParseFree(pParser, free);
return EXIT_SUCCESS;
}
Something went wrong with that request. Please try again.