summaryrefslogtreecommitdiff
path: root/test cases/frameworks/8 flex/prog.c
blob: 840a0644ae81814d90cc067e9c7d06323c11da60 (plain)
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
#include"parser.tab.h"
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<stdio.h>
#include<stdlib.h>

extern int yyparse();

int main(int argc, char **argv) {
    int input;
    if(argc != 2) {
        printf("%s <input file>\n", argv[0]);
        return 1;
    }
    input = open(argv[1], O_RDONLY);
    dup2(input, STDIN_FILENO);
    close(input);
    return yyparse();
}

int yywrap(void) {
     return 0;
}

int yyerror(char* s) {
     printf("Parse error: %s\n", s);
     exit(1);
}