-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlexerDef.h
More file actions
62 lines (44 loc) · 1.92 KB
/
lexerDef.h
File metadata and controls
62 lines (44 loc) · 1.92 KB
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
/*
*Batch Number 6
*Abhinav Bhatia (2011A7PS371P)
*Mukul Bhutani (2011A7PS343P)
*/
#ifndef _LEXERDEF_
#define _LEXERDEF_
#include "definitions.h"
#define BUFFER_SIZE 10 * 1024
#define MAX_LINE_SIZE 10 * 1024
typedef int Buffersize;
typedef char* Buffer;
typedef struct
{
DFA* pDFA; //Pointer to DFA which is used by this lexical analyzer
//Twin buffer scheme has been used. This is the upper buffer and input reading starts from this buffer.
//When this lexer has read from this buffer, it starts reading from the lower buffer, instead of waiting for I/O.
//As the lexer starts reading from the lower buffer, command is issued to read more file input to upper buffer.
Buffer upperBuffer;
//Twin buffer scheme has been used.
//When this lexer has read from the upper buffer, it starts reading from the lower buffer, instead of waiting for I/O into upper buffer.
//As the lexer starts reading from the lower buffer, command is issued to read more file input to upper buffer.
//When this lexer has read from the lower buffer also, it starts reading from the upper buffer.
Buffer lowerBuffer;
//The buffer which holds the input which has been read so far since tokenizing last lexeme.
Buffer lexemeBuffer;
//This field is a pointer to either one of upper buffer or lower buffer depending on which buffer is currently being used by the
//lexer to read input.
Buffer currentBuffer;
//The source code file
FILE* pSourceFile;
//Indicates whether input has ended
int moreTokensPossible;
//Index corresponding to the current buffer from which input is being read.
int mainBufferIndex;
//Index corresponding to the lexeme buffer.
int lexemeBufferIndex;
//A lookup table which has TokenInfo entries. They store keywords as lexemes and also corresponding token.
//The table is hashed by keywords (lexemes).
HashTable keyWordTable;
//The line no. of the source code which is currently being read.
int lineNo;
} Lexer;
#endif