From e5888a1ffdae813d7575f5fb02275c6bb07e5199 Mon Sep 17 00:00:00 2001 From: Taru Karttunen Date: Wed, 30 Mar 2011 15:46:40 +0300 Subject: Import sources from 2011-03-30 iso image --- sys/src/liblex/reject.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 sys/src/liblex/reject.c (limited to 'sys/src/liblex/reject.c') diff --git a/sys/src/liblex/reject.c b/sys/src/liblex/reject.c new file mode 100755 index 000000000..24e8bee1f --- /dev/null +++ b/sys/src/liblex/reject.c @@ -0,0 +1,58 @@ +#include +#include +#include + +extern FILE* yyout; +extern FILE* yyin; +extern int yyprevious, *yyfnd; +extern char yyextra[]; +extern char yytext[]; +extern int yyleng; + +extern +struct +{ + int *yyaa, *yybb; + int *yystops; +} *yylstate [], **yylsp, **yyolsp; + +int yyback(int *p, int m); +int yyinput(void); +void yyoutput(int c); +void yyunput(int c); + +int +yyracc(int m) +{ + + yyolsp = yylsp; + if(yyextra[m]) { + while(yyback((*yylsp)->yystops, -m) != 1 && yylsp > yylstate) { + yylsp--; + yyunput(yytext[--yyleng]); + } + } + yyprevious = yytext[yyleng-1]; + yytext[yyleng] = 0; + return m; +} + +int +yyreject(void) +{ + for(; yylsp < yyolsp; yylsp++) + yytext[yyleng++] = yyinput(); + if(*yyfnd > 0) + return yyracc(*yyfnd++); + while(yylsp-- > yylstate) { + yyunput(yytext[yyleng-1]); + yytext[--yyleng] = 0; + if(*yylsp != 0 && (yyfnd = (*yylsp)->yystops) && *yyfnd > 0) + return yyracc(*yyfnd++); + } + if(yytext[0] == 0) + return 0; + yyoutput(yyprevious = yyinput()); + yyleng = 0; + return -1; +} -- cgit v1.2.3