-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
44 lines (40 loc) · 848 Bytes
/
main.c
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
/*************************************************************************
> File Name: main.c
> Author: ellochen
> Mail: [email protected]
> Created Time: Mon Apr 29 21:36:12 2013
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "parser.h"
#include "lex.h"
#include "symtbl.h"
#define LINE_MAX 256
void help()
{
printf("Welcome to freeCompute!\n");
}
void processOneLine()
{
printf("%lf\n",statement());
}
int main(int argc, char*argv[])
{
if (1 == argc){
lexerInit();
parserInit();
char *line = (char*)malloc(LINE_MAX);
help();
printf(">>>");
while(fgets(line,LINE_MAX,stdin) != NULL) {
CURSOR = line;
processOneLine();
memset(line,0,strlen(line));
printf(">>>");
}
free(line);
parserDestroy();
}
return 0;
}