blob: fef8625985646819b5ede97db0e954a43c00b032 (
plain)
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
|
#include <stdint.h>
#include <stdio.h>
typedef enum {
OP, ARG, LABEL, COLON, NEWLINE, ENDOFFILE
} TokenType;
typedef struct {
TokenType type;
int line;
int col;
char *sval;
int64_t ival;
double fval;
} Token;
#define INPUT_STREAM_BUF_SIZE 1024
typedef struct {
FILE *fp;
char *buf;
int buf_pos;
int cursor;
int line;
int col;
} InputStream;
typedef struct {
Token* buf;
InputStream *s;
} TokenStream;
Token *nextToken(TokenStream *ts);
Token *peekToken(TokenStream *ts);
void printToken(Token *t);
TokenStream* makeTokenStream(FILE* fp);
|