51 lines
849 B
C
51 lines
849 B
C
#ifndef LEX_H
|
|
#define LEX_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#define KEYWORD_COUNT 23
|
|
|
|
enum token_type {
|
|
TOK_COMM = 0,
|
|
TOK_ASSOCL = 1,
|
|
TOK_ASSOCR = 2,
|
|
TOK_DISTL = 3,
|
|
TOK_DISTR = 4,
|
|
TOK_FACTL = 5,
|
|
TOK_FACTR = 6,
|
|
TOK_MAPL = 7,
|
|
TOK_MAPR = 8,
|
|
TOK_UNITIL = 9,
|
|
TOK_UNITIR = 10,
|
|
TOK_UNITEL = 11,
|
|
TOK_UNITER = 12,
|
|
TOK_COMM_PLUS = 13,
|
|
TOK_ASSOCL_PLUS = 14,
|
|
TOK_ASSOCR_PLUS = 15,
|
|
TOK_MAPL_PLUS = 16,
|
|
TOK_MAPR_PLUS = 17,
|
|
TOK_INL = 18,
|
|
TOK_INR = 19,
|
|
TOK_OUT = 20,
|
|
TOK_HALT = 21,
|
|
TOK_IF = 22,
|
|
TOK_LABEL,
|
|
TOK_JUMP,
|
|
TOK_MAP_BEGIN,
|
|
TOK_MAP_END,
|
|
TOK_EOF, // end of file
|
|
};
|
|
|
|
struct token {
|
|
enum token_type type;
|
|
char* identifier;
|
|
};
|
|
|
|
struct token next(void);
|
|
struct token peek(void);
|
|
|
|
void print_token(struct token tok);
|
|
|
|
#endif
|