Make tl_yylex hookable (default is tl_lex)

This allows replacing the lexer when using libltl2ba.la.
This commit is contained in:
Michael Weber 2010-11-29 10:35:43 +01:00
parent f277db6c7e
commit 2e9e1a61dd
3 changed files with 4 additions and 10 deletions

11
lex.c
View file

@ -36,9 +36,10 @@
static Symbol *symtab[Nhash+1]; static Symbol *symtab[Nhash+1];
static int tl_lex(void); static int tl_lex(void);
int (*tl_yylex)() = tl_lex;
extern YYSTYPE tl_yylval; extern YYSTYPE tl_yylval;
char yytext[2048]; static char yytext[2048];
#define Token(y) tl_yylval = tl_nn(y,ZN,ZN); return y #define Token(y) tl_yylval = tl_nn(y,ZN,ZN); return y
@ -86,14 +87,6 @@ follow(int tok, int ifyes, int ifno)
return ifno; return ifno;
} }
int
tl_yylex(void)
{ int c = tl_lex();
#if 0
printf("c = %d\n", c);
#endif
return c;
}
static int static int
tl_lex(void) tl_lex(void)

View file

@ -260,6 +260,8 @@ extern int tl_verbose;
extern int tl_terse; extern int tl_terse;
extern unsigned long All_Mem; extern unsigned long All_Mem;
extern int (*tl_yylex)(); /* hook for lexer */
int ltl2ba_init(); int ltl2ba_init();
int set_uform(const char *str); int set_uform(const char *str);
void append_uform(const char *str); void append_uform(const char *str);

View file

@ -32,7 +32,6 @@
#include "ltl2ba.h" #include "ltl2ba.h"
extern int tl_yylex(void);
extern int tl_verbose, tl_simp_log; extern int tl_verbose, tl_simp_log;
int tl_yychar = 0; int tl_yychar = 0;