fixed problem with hex numbers, and use new PushBack feature
authorceriel <none@none>
Tue, 11 Apr 1989 11:40:49 +0000 (11:40 +0000)
committerceriel <none@none>
Tue, 11 Apr 1989 11:40:49 +0000 (11:40 +0000)
lang/m2/m2mm/.distr
lang/m2/m2mm/LLlex.c
lang/m2/m2mm/Makefile
lang/m2/m2mm/char.tab

index 5131adb..32002a9 100644 (file)
@@ -25,6 +25,5 @@ misc.c
 options.c
 program.g
 statement.g
-tab.c
 tokenname.c
 tokenname.h
index 7a03c7c..032c26e 100644 (file)
@@ -23,8 +23,6 @@ struct token  dot,
 int            idfsize = IDFSIZE;
 int            ForeignFlag;
 
-static int     eofseen;
-
 STATIC
 SkipComment()
 {
@@ -111,10 +109,6 @@ getch()
                }
                break;
        }
-       if (ch == EOI) {
-               eofseen = 1;
-               return '\n';
-       }
        return ch;
 }
 
@@ -135,7 +129,7 @@ CheckForLineDirective()
                 * Do not skip newlines
                 */
                ch = getch();
-               if (class(ch) == STNL) {
+               if (class(ch) == STNL || class(ch) == STEOI) {
                        LineNumber++;
                        error(s_error);
                        return;
@@ -145,12 +139,13 @@ CheckForLineDirective()
                i = i*10 + (ch - '0');
                ch = getch();
        }
-       while (ch != '"' && class(ch) != STNL) ch = getch();
+       while (ch != '"' && class(ch) != STNL && class(ch) != STEOI)
+               ch = getch();
        if (ch == '"') {
                c = buf;
                do {
                        *c++ = ch = getch();
-                       if (class(ch) == STNL) {
+                       if (class(ch) == STNL || class(ch) == STEOI) {
                                LineNumber++;
                                error(s_error);
                                return;
@@ -159,15 +154,15 @@ CheckForLineDirective()
                *--c = '\0';
                do {
                        ch = getch();
-               } while (class(ch) != STNL);
+               } while (class(ch) != STNL && class(ch) != STEOI);
                /*
                 * Remember the file name
                 */
-               if (!eofseen && strcmp(FileName,buf)) {
+               if (class(ch) == STNL && strcmp(FileName,buf)) {
                        FileName = Salloc(buf,(unsigned) strlen(buf) + 1);
                }
        }
-       if (eofseen) {
+       if (class(ch) == STEOI) {
                error(s_error);
                return;
        }
@@ -191,20 +186,8 @@ LLlex()
                return tk->tk_symb;
        }
 
-again1:
-       if (eofseen) {
-               eofseen = 0;
-               ch = EOI;
-       }
-       else {
 again:
-               LoadChar(ch);
-               if ((ch & 0200) && ch != EOI) {
-                       error("non-ascii '\\%03o' read", ch & 0377);
-                       goto again;
-               }
-       }
-
+       ch = getch();
        tk->tk_lineno = LineNumber;
 
        switch (class(ch))      {
@@ -212,7 +195,7 @@ again:
        case STNL:
                LineNumber++;
                CheckForLineDirective();
-               goto again1;
+               goto again;
 
        case STSKIP:
                goto again;
@@ -231,8 +214,7 @@ again:
                                SkipComment();
                                goto again;
                        }
-                       else if (nch == EOI) eofseen = 1;
-                       else PushBack();
+                       PushBack();
                }
                if (ch == '&') return tk->tk_symb = AND;
                if (ch == '~') return tk->tk_symb = NOT;
@@ -272,8 +254,7 @@ again:
                default :
                        crash("(LLlex, STCOMP)");
                }
-               if (nch == EOI) eofseen = 1;
-               else PushBack();
+               PushBack();
                return tk->tk_symb = ch;
 
        case STIDF:
@@ -286,8 +267,7 @@ again:
                        LoadChar(ch);
                } while(in_idf(ch));
 
-               if (ch == EOI) eofseen = 1;
-               else PushBack();
+               PushBack();
                *tag++ = '\0';
 
                tk->TOK_IDF = id = findidf(idfbuf);
@@ -329,9 +309,7 @@ again:
                                else if (ch == '.') state = OptReal;
                                else {
                                        state = End;
-                                       if (ch == 'H') ;
-                                       else if (ch == EOI) eofseen = 1;
-                                       else PushBack();
+                                       if (ch != 'H') PushBack();
                                }
                                break;
 
@@ -354,8 +332,7 @@ again:
                                state = End;
                                if (ch != 'H') {
                                        lexerror("H expected after hex number");
-                                       if (ch == EOI) eofseen = 1;
-                                       else PushBack();
+                                       PushBack();
                                }
                                break;
 
@@ -369,8 +346,7 @@ again:
                                        state = Hex;
                                        break;
                                }
-                               if (ch == EOI) eofseen = 1;
-                               else PushBack();
+                               PushBack();
                                /* Fall through */
                                
                        case End:
@@ -427,8 +403,7 @@ again:
                }
 
 noscale:
-               if (ch == EOI) eofseen = 1;
-               else PushBack();
+               PushBack();
 
                return tk->tk_symb = REAL;
 
index 2e61d21..296208c 100644 (file)
@@ -50,7 +50,7 @@ pr:
        @pr Makefile $(GF) $(HFILES) $(CSRC)
 
 clean:
-       rm -f $(OBJ) $(GENFILES) LLfiles Cfiles tab LL.output m2mm
+       rm -f $(OBJ) $(GENFILES) LLfiles Cfiles LL.output m2mm
 
 lint:  Cfiles
        lint $(INCLUDES) $(LINTFLAGS) $(SRC) \
@@ -73,11 +73,8 @@ tokenfile.g: tokenname.c make.tokfile
 symbol2str.c:  tokenname.c make.tokcase
        make.tokcase <tokenname.c >symbol2str.c
 
-char.c: char.tab tab
-       tab -fchar.tab >char.c
-
-tab: 
-       $(CC) tab.c -o tab
+char.c: char.tab
+       $(EMHOME)/bin/tabgen -fchar.tab >char.c
 
 depend:        Cfiles
        sed '/^#AUTOAUTO/,$$d' Makefile > Makefile.new
index e4f5740..f1bbede 100644 (file)
@@ -5,11 +5,10 @@
 %
 %      CHARACTER CLASSES
 %
-%C
-STGARB:\000-\200
-STSKIP: \r\t
-STNL:\012\013\014
-STSIMP:#&()*+,-/;=[]^{|}~
+%iSTGARB
+STSKIP: \t\013\014\015
+STNL:\012
+STSIMP:-#&()*+,/;=[]^{|}~
 STCOMP:.:<>
 STIDF:a-zA-Z
 STSTR:"'
@@ -40,7 +39,7 @@ STEOI:\200
 %      ISHEX
 %
 %C
-1:a-fA-F
+1:A-F0-9
 %Tchar ishex[] = {
 %p
 %T};