1typedef enum {2 TOK_EOF, /* End of file */34 TOK_VAR, /* A variable name */5 TOK_DIG, /* A natural number */6 TOK_ERROR, /* Lexer error of some sort */78 TOK_ASSIGN, /* := */9 TOK_QUESTION, /* ? */10 TOK_SEMICOLON, /* ; */11 TOK_EXCLAMATION, /* ! */1213 TOK_LBRACKET, /* ( */14 TOK_RBRACKET, /* ) */1516 TOK_DIVIDE, /* % */17 TOK_MULTI, /* * */18 TOK_MINUS, /* - */19 TOK_PLUS, /* + */20} tok_t;2122typedef struct token token;2324struct token {25 TAILQ_ENTRY(token) toks;26 tok_t type;27 char *text;28 int line;29};3031TAILQ_HEAD(tqueue, token);3233typedef struct scanner scanner;3435struct scanner {36 sem_t *fullsem, *emptysem;37 pthread_t *thread;38 size_t pos, start, inlen;39 struct tqueue qhead;40 pthread_mutex_t *qmutex;41 char *input;42 int line, eof;43};4445void freescr(scanner *scr);46scanner *scanstr(char *str);47token *nxttok(scanner *scr);