From 2c0d465311b4e6c5de4bf4b79eb78b0a81695782 Mon Sep 17 00:00:00 2001 From: Tom London Date: Sun, 5 Nov 1978 23:30:52 -0500 Subject: [PATCH] Bell 32V development Work on file usr/src/libln/allprint.c Work on file usr/src/cmd/lex/lib/allprint.c Work on file usr/src/cmd/lex/lib/main.c Work on file usr/src/libln/main.c Work on file usr/src/cmd/lex/lib/reject.c Work on file usr/src/cmd/lex/lib/yywrap.c Work on file usr/src/libln/yywrap.c Work on file usr/src/cmd/lex/lib/yyless.c Work on file usr/src/libln/yyless.c Work on file usr/src/libln/reject.c Co-Authored-By: John Reiser Synthesized-from: 32v --- usr/src/cmd/lex/lib/allprint.c | 37 ++++++++++++++++++++++++++++++ usr/src/cmd/lex/lib/main.c | 5 +++++ usr/src/cmd/lex/lib/reject.c | 41 ++++++++++++++++++++++++++++++++++ usr/src/cmd/lex/lib/yyless.c | 18 +++++++++++++++ usr/src/cmd/lex/lib/yywrap.c | 4 ++++ usr/src/libln/allprint.c | 37 ++++++++++++++++++++++++++++++ usr/src/libln/main.c | 5 +++++ usr/src/libln/reject.c | 41 ++++++++++++++++++++++++++++++++++ usr/src/libln/yyless.c | 18 +++++++++++++++ usr/src/libln/yywrap.c | 4 ++++ 10 files changed, 210 insertions(+) create mode 100644 usr/src/cmd/lex/lib/allprint.c create mode 100644 usr/src/cmd/lex/lib/main.c create mode 100644 usr/src/cmd/lex/lib/reject.c create mode 100644 usr/src/cmd/lex/lib/yyless.c create mode 100644 usr/src/cmd/lex/lib/yywrap.c create mode 100644 usr/src/libln/allprint.c create mode 100644 usr/src/libln/main.c create mode 100644 usr/src/libln/reject.c create mode 100644 usr/src/libln/yyless.c create mode 100644 usr/src/libln/yywrap.c diff --git a/usr/src/cmd/lex/lib/allprint.c b/usr/src/cmd/lex/lib/allprint.c new file mode 100644 index 0000000000..238cade1c8 --- /dev/null +++ b/usr/src/cmd/lex/lib/allprint.c @@ -0,0 +1,37 @@ +# include +allprint(c) + char c; { + extern FILE *yyout; + switch(c){ + case '\n': + fprintf(yyout,"\\n"); + break; + case '\t': + fprintf(yyout,"\\t"); + break; + case '\b': + fprintf(yyout,"\\b"); + break; + case ' ': + fprintf(yyout,"\\\bb"); + break; + default: + if(!printable(c)) + fprintf(yyout,"\\%-3o",c); + else + putc(c,yyout); + break; + } + return; + } +sprint(s) + char *s; { + while(*s) + allprint(*s++); + return; + } +printable(c) + int c; + { + return(040 < c && c < 0177); + } diff --git a/usr/src/cmd/lex/lib/main.c b/usr/src/cmd/lex/lib/main.c new file mode 100644 index 0000000000..123b66591d --- /dev/null +++ b/usr/src/cmd/lex/lib/main.c @@ -0,0 +1,5 @@ +# include "stdio.h" +main(){ +yylex(); +exit(0); +} diff --git a/usr/src/cmd/lex/lib/reject.c b/usr/src/cmd/lex/lib/reject.c new file mode 100644 index 0000000000..7fa928201b --- /dev/null +++ b/usr/src/cmd/lex/lib/reject.c @@ -0,0 +1,41 @@ +# include +extern struct {int *yyaa, *yybb; int *yystops;} *yylstate [], **yylsp, **yyolsp; +yyreject () +{ +extern FILE *yyout, *yyin; +extern int yyprevious , *yyfnd; +extern char yyextra[]; +extern char yytext[]; +extern int yyleng; +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); +} +yyracc(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); +} diff --git a/usr/src/cmd/lex/lib/yyless.c b/usr/src/cmd/lex/lib/yyless.c new file mode 100644 index 0000000000..5914bd9630 --- /dev/null +++ b/usr/src/cmd/lex/lib/yyless.c @@ -0,0 +1,18 @@ +yyless(x) +{ +extern char yytext[]; +register char *lastch, *ptr; +extern int yyleng; +extern int yyprevious; +lastch = yytext+yyleng; +if (x>=0 && x <= yyleng) + ptr = x + yytext; +else + ptr = x; +while (lastch > ptr) + yyunput(*--lastch); +*lastch = 0; +if (ptr >yytext) + yyprevious = *--lastch; +yyleng = ptr-yytext; +} diff --git a/usr/src/cmd/lex/lib/yywrap.c b/usr/src/cmd/lex/lib/yywrap.c new file mode 100644 index 0000000000..08669938ba --- /dev/null +++ b/usr/src/cmd/lex/lib/yywrap.c @@ -0,0 +1,4 @@ +yywrap() +{ + return(1); +} diff --git a/usr/src/libln/allprint.c b/usr/src/libln/allprint.c new file mode 100644 index 0000000000..238cade1c8 --- /dev/null +++ b/usr/src/libln/allprint.c @@ -0,0 +1,37 @@ +# include +allprint(c) + char c; { + extern FILE *yyout; + switch(c){ + case '\n': + fprintf(yyout,"\\n"); + break; + case '\t': + fprintf(yyout,"\\t"); + break; + case '\b': + fprintf(yyout,"\\b"); + break; + case ' ': + fprintf(yyout,"\\\bb"); + break; + default: + if(!printable(c)) + fprintf(yyout,"\\%-3o",c); + else + putc(c,yyout); + break; + } + return; + } +sprint(s) + char *s; { + while(*s) + allprint(*s++); + return; + } +printable(c) + int c; + { + return(040 < c && c < 0177); + } diff --git a/usr/src/libln/main.c b/usr/src/libln/main.c new file mode 100644 index 0000000000..123b66591d --- /dev/null +++ b/usr/src/libln/main.c @@ -0,0 +1,5 @@ +# include "stdio.h" +main(){ +yylex(); +exit(0); +} diff --git a/usr/src/libln/reject.c b/usr/src/libln/reject.c new file mode 100644 index 0000000000..7fa928201b --- /dev/null +++ b/usr/src/libln/reject.c @@ -0,0 +1,41 @@ +# include +extern struct {int *yyaa, *yybb; int *yystops;} *yylstate [], **yylsp, **yyolsp; +yyreject () +{ +extern FILE *yyout, *yyin; +extern int yyprevious , *yyfnd; +extern char yyextra[]; +extern char yytext[]; +extern int yyleng; +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); +} +yyracc(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); +} diff --git a/usr/src/libln/yyless.c b/usr/src/libln/yyless.c new file mode 100644 index 0000000000..5914bd9630 --- /dev/null +++ b/usr/src/libln/yyless.c @@ -0,0 +1,18 @@ +yyless(x) +{ +extern char yytext[]; +register char *lastch, *ptr; +extern int yyleng; +extern int yyprevious; +lastch = yytext+yyleng; +if (x>=0 && x <= yyleng) + ptr = x + yytext; +else + ptr = x; +while (lastch > ptr) + yyunput(*--lastch); +*lastch = 0; +if (ptr >yytext) + yyprevious = *--lastch; +yyleng = ptr-yytext; +} diff --git a/usr/src/libln/yywrap.c b/usr/src/libln/yywrap.c new file mode 100644 index 0000000000..08669938ba --- /dev/null +++ b/usr/src/libln/yywrap.c @@ -0,0 +1,4 @@ +yywrap() +{ + return(1); +} -- 2.20.1