typedef struct State State;
typedef struct Tok Tok;
typedef struct Lexer Lexer;
enum
{
Ltoksize = 512,
Leof = -1,
Loverflow = -10,
};
/* wrapper to simulate recursive function type */
struct State
{
State (*fun)(Lexer*, void*);
void *aux;
};
struct Tok
{
int typ;
Rune str[Ltoksize+1];
};
struct Lexer
{
Biobuf *bp;
Rune b[Ltoksize+1], *cur;
int start, pos;
Channel *c;
State state;
};
int linit(Lexer *l, int fd, State state);
void lterm(Lexer *l);
long lnext(Lexer *l);
void lbackup(Lexer *l);
long lpeek(Lexer *l);
void lignore(Lexer *l);
int laccept(Lexer *l, Rune *s);
long lacceptrun(Lexer *l, Rune *s);
long lacceptuntil(Lexer *l, Rune *s);
void lemit(Lexer *l, int typ);
Tok lnexttok(Lexer *l);
long llen(Lexer *l);
Rune *lestr(Lexer *l);
|