-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStage2.c
35 lines (31 loc) · 858 Bytes
/
Stage2.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
#include <stdio.h>
#include <stdlib.h>
#include "include.h"
int main(int argc, char *argv[])
{
FILE *fp = fopen(DEFAULT_GRAMMAR_FILE, "r");
if (fp == NULL)
{
print_error("File is not opened, exit.");
exit(-1);
}
Grammar grammar = generateGrammar(fp);
printGrammar(grammar);
AutomatonStates automaton_states;
ActionTable action_table;
getActionTable(grammar, &automaton_states, &action_table);
printStates(automaton_states);
printActionTable(action_table);
FILE *fp1 = fopen(DEFAULT_INPUT_FILE, "r");
if (fp == NULL)
{
print_error("Input File can't be opened, exit........");
exit(-2);
}
int ret = ParseAndGenerate(fp1, action_table, grammar, NULL);
if (ret)
printf("Parse success!\n");
else
printf("Parse failed!\n");
return 0;
}