-
Notifications
You must be signed in to change notification settings - Fork 0
/
DashGlobals.h
105 lines (78 loc) · 2.38 KB
/
DashGlobals.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* File: Globals.h
* Author: zain basharat
*
* Created on April 6, 2013, 7:34 PM
*/
#ifndef GLOBALS_H
#define GLOBALS_H
#ifdef __cplusplus
extern "C" {
#endif
//header files of c library to be used in making this compiler.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <stdlib.h>
//it define the number type in the program
int MODE_STATUS;
//errorflag to stop from generating code
int CERROR;
//it holds token types which this language supports.
typedef enum{
ERROR,REPEAT,UNTIL,WHILE,ENDWHILE,FOR,ENDFOR,INPUT,
OUTPUT,DECLARATION,START,END,SWITCH,CASES,ENDCASE,
OTHERWISE,IF,THEN,ENDIF,ELSE,ENDELSE,INTEGER_DATATYPE,
CHARACTER_DATATYPE,STRING_DATATYPE,INC,DEC,PLUS,MINUS,DIV,
MULTI,MOD,ASSIGN,EQ,LEQ,NEQ,GT,GEQ,LT,LCBRACK,RCBRACK,
COMMA,SEMI,NOT,IDENTIFIER,CHARACTER,STRING,VALUE,ENDFIL,BREAK,
HASH,MODE,PINTEGER,NINTEGER,HEX,NHEX,EMPTY}TokenType;
typedef enum{
AExp,RExp,DecStat,DAAStat,AssignStat,InputStat,OutputStat,IfStat,EndIfStat,IfElseStat,SwitchStat,ForStat,
WhileStat,RepeatStat,factor,EndCaseStat,CaseStat,SwitchElse,EndforStat}StatKind;
//Token datatype which holds all the information about the token.
typedef struct{
int ID;
char lexeme[41];
TokenType type;
int value;
int line;
int column;
}Token;
//Source file pointer
FILE *f;
//typedef struct Symbol_Table;
struct Symbol_Table{
int ID;
char lexeme[41];
TokenType type;
int line;
int column;
struct Symbol_Table* next;
};
struct Literal_Table{
int ID;
char lexeme[41];
TokenType type;
int value;
struct Literal_Table* next;
};
struct Symbol_Table* Sym_Cur;
struct Literal_Table* Lit_Cur;
typedef struct IDLIST{
char IDname[41];
struct IDLIST* next;
}IDS;
typedef struct tnode{
struct tnode *child[4];
struct tnode *sibling;
StatKind kind;
IDS* ID;
TokenType Datatype;
TokenType op;
char VAL[3][41];
}node;
#ifdef __cplusplus
}
#endif
#endif /* GLOBALS_H */