-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.h
51 lines (38 loc) · 1.3 KB
/
functions.h
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
47
48
49
50
51
extern int lex();
int error(char *string);
int error(char *string){
printf("Error: %s\n\n", string);
printf(">> FAILURE: The input is not valid, according to the P-- Grammar <<\n\n");
exit(EXIT_FAILURE);
return(0);
}
// Used for exporting the files with the name of the input plus extension:
void getFilenameWithoutExtension(char nameoffile[64], char * filenameWithoutExtension);
FILE *endcodeOutputFile;
// Global file pointer and Token variable:
static FILE *input;
static int token;
static int peekToken;
static char currentLexeme[30];
static int lexeme_parsing_counter = 0;
static int lexeme_counter = 0;
// Struct for Linked List for Lexemes (used in Lex and Syntax Analyzer):
typedef struct lexeme_list {
char word[30];
struct lexeme_list *next;
int isItUsed;
} lexeme;
static lexeme *lexeme_head;
int areWeInMainBlock;
typedef struct temporary_variables_list {
char variable[30];
struct temporary_variables_list *next;
} temp_list;
static temp_list *temp_variables_head;
// Global parsing output character arrays:
static char output[BIG_CHARACTER_ARRAY_LENGTH];
static char encodedOutput[BIG_CHARACTER_ARRAY_LENGTH];
// Global state of Lexicographical Analysis (checks if it's been already done once):
static int analysis_done = 0;
// Global variables for Intercode:
static int nextquadlabel = 110;