Plan 9 from Bell Labs’s /usr/web/sources/contrib/pdt/sky/include/lex.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


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);

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.