add parse()
This commit is contained in:
parent
6422e8d145
commit
19c61a91fe
@ -1,4 +1,6 @@
|
|||||||
#ifndef PARSER_H
|
#ifndef PARSER_H
|
||||||
#define PARSER_H
|
#define PARSER_H
|
||||||
|
|
||||||
|
void parse(const char * filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#define yyerror(msg) handle_error(msg, &yyloc)
|
#define yyerror(msg) handle_error(msg, &yyloc)
|
||||||
|
|
||||||
|
extern FILE * yyin;
|
||||||
int yylex(YYSTYPE *, YYLTYPE *);
|
int yylex(YYSTYPE *, YYLTYPE *);
|
||||||
static void handle_error(const char * str, const YYLTYPE * yylloc);
|
static void handle_error(const char * str, const YYLTYPE * yylloc);
|
||||||
|
|
||||||
@ -111,3 +112,18 @@ int yywrap(void)
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void parse(const char * filename)
|
||||||
|
{
|
||||||
|
yyin = fopen(filename, "r");
|
||||||
|
if (yyin == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error opening \"%s\"\n", filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (yyparse() != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Parsing error\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user