blob: a14528f9dfd8ec5ece31647126d8580f520c1edb (
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
|
#ifndef LEX_H
#define LEX_H
#include <stdio.h>
enum TOKEN_TYPE {
TOKEN_COMMA = 1,
TOKEN_DOT, /* starts an assembler directive */
TOKEN_LABEL, /* label declaration */
TOKEN_IDENT, /* identifier (not label decl) or instruction */
TOKEN_KEYWORD, /* keyword used to tell the assembler special information */
TOKEN_STRING, /* string literal */
TOKEN_NUMERIC, /* numeric literal, incl literal chars */
TOKEN_REGISTER, /* $0, $H, $1 */
TOKEN_EOL /* end of line */
};
struct token {
enum TOKEN_TYPE type;
/* line and column of the source file this token occurs at. 1-based. */
size_t line;
size_t column;
size_t span;
char *s_val;
int i_val;
};
struct token* lex(const char *filename_local, FILE *fin, size_t *len);
#endif /* LEX_H */
|