summaryrefslogtreecommitdiff
path: root/sys/src/liblex/reject.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/liblex/reject.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/liblex/reject.c')
-rwxr-xr-xsys/src/liblex/reject.c58
1 files changed, 58 insertions, 0 deletions
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 <u.h>
+#include <libc.h>
+#include <stdio.h>
+
+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;
+}