home *** CD-ROM | disk | FTP | other *** search
- /*
- * lexswitch -- switch lex tables
- */
-
- /*
- * Bob Denny 28-Aug-82 Remove reference to stdio.h
- * Scott Guthery 20-Nov-83 Adapt for IBM PC & DeSmet C
- */
-
- #include <lex.h>
- #include <stdlib.h>
-
- extern struct lextab *_tabp;
-
- typedef struct stack {
- struct stack *next;
- struct lextab *table;
- } STACK;
-
- static STACK *lextop = NULL;
-
- struct lextab *lexswitch(struct lextab *lp)
- {
- register struct lextab *olp;
-
- olp = _tabp;
- _tabp = lp;
- return(olp);
- }
-
- void lexpush(struct lextab *lp)
- {
- STACK *sp;
-
- sp = (STACK *) malloc(sizeof(STACK));
- sp->next = lextop;
- sp->table = lexswitch(lp);
- lextop = sp;
- }
-
- void lexpop(void)
- {
- STACK *sp;
-
- if (lextop != NULL)
- {
- sp = lextop;
- lextop = sp->next;
- lexswitch(sp->table);
- free(sp);
- }
-
- }
-
-