-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlexer.h
More file actions
53 lines (42 loc) · 1.83 KB
/
Copy pathlexer.h
File metadata and controls
53 lines (42 loc) · 1.83 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
// ,-. Group 08 //
// , ( {o\ Satvik Golechha :: 2017A7PS0117P ///
// {`"=,___) (`~ Bharat Bhargava :: 2017A7PS0025P ////
// \ ,_.- ) Ayush Jain :: 2017A7PS0093P /////
// ~^~^~^`- ~^ ~^ '~^~^~^~ //////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "hash.h"
#include<stdio.h>
#ifndef __LEXER
#define __LEXER
#define max_id_len 20 // maximum allowed length of identifier
#define max_num_len 100 // maximum allowed length of any number (this has been defined by us)
#define TOKEN_SIZE 22
//#define SOURCE_CODE_FILE "../testcases-1/testcase-bt.txt"/*"./test.erplag"*/
#define SOURCE_CODE_FILE "./t2.txt" //"./t6.txt"
/*"./test.erplag"*/
#define not !
#define and &&
enum active_buffer {Steve, Mark};
#define TWIN_BUFFER_SIZE 512
typedef struct lexeme_tuple
{
// lexeme (tuple of (TOKEN, VALUE, LINE))
char *token; // ID
char *value; // a, b
unsigned int line;
} LEXEME;
typedef struct twin_buffer
{
// steve and mark are our twin buffers
char steve[TWIN_BUFFER_SIZE];
char mark[TWIN_BUFFER_SIZE];
int bp; // base pointer
int fp; // forward pointer
int active; // active buffer for the forward pointer (don't need one for base p)
int read;
} TWIN_BUFFER;
void init_buffer(FILE *f, TWIN_BUFFER *buff);
char get_stream(FILE *f, TWIN_BUFFER *buff);
LEXEME *get_token(FILE *f, TWIN_BUFFER *twin_buff, int *line_count);
void print_lexeme(LEXEME *l);
#endif