-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstructs.h
More file actions
37 lines (31 loc) · 695 Bytes
/
structs.h
File metadata and controls
37 lines (31 loc) · 695 Bytes
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
#ifndef __GUARD_STRUCTS__
#define __GUARD_STRUCTS__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef enum {START, ERROR, QUIT, ATRIB, ADD, SUB, MUL, PRINT, READ, IF, GOTO, LABEL} OpKind;
typedef enum {INT_CONST, STRING, EMPTY} ElemKind;
typedef struct{
ElemKind kind;
union
{
int val;
char* name;
}content;
} Elem;
typedef struct{
OpKind op;
Elem first, second, third;
int type, index;
} Instr;
Elem mkVar(char*);
Elem mkInt(int);
Elem empty();
Instr mkInstr(OpKind, Elem, Elem, Elem, int, int);
int getVal(Elem );
char* getName(Elem);
void escrever(Instr);
void removeSpaces(char*);
Instr parseInstr(char*, int);
int getType(char*, char*);
#endif