-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.h
More file actions
55 lines (44 loc) · 1.13 KB
/
header.h
File metadata and controls
55 lines (44 loc) · 1.13 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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*Virtual Machine*/
#define MAX_STACK_HEIGHT 2000
#define MAX_CODE_LENGTH 500
#define MAX_LEXI_LEVELS 3
//Instruction struct
typedef struct
{
int op;
int l;
int m;
} instruction;
/*************************************/
/*Lexer*/
//Declare token types
typedef enum token{
nulsym = 1, identsym, numbersym, plussym, minussym,
multsym, slashsym, oddsym, eqsym, neqsym, lessym, leqsym,
gtrsym, geqsym, lparentsym, rparentsym, commasym, semicolonsym,
periodsym, becomessym, beginsym, endsym, ifsym, thensym,
whilesym, dosym, callsym, constsym, varsym, procsym, writesym,
readsym , elsesym
} token_type;
typedef struct {
char value[13];
token_type type;
} token;
token tokens[1000];
/******************************************/
/*Parser*/
#define MAX_SYMBOL_TABLE_SIZE 100
typedef struct symbol
{
int kind; //const = 1, var = 2, proc = 3
char name[12]; //name up to 11 characters
int val; //number (ASCII value)
int level; //L level
int addr; //M address
} symbol;
/***************************************************/
void lexer(FILE*, FILE*, int);
void program();