Lexikalische Analyse III

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

Expr2.om
PROCEDURE GetSy;
BEGIN
   (* skip white space *)
   WHILE (ch = " ") OR (ch = ASCII.tab) OR
         (ch = ASCII.nl) DO
      NextCh;
   END;
   CASE ch OF
   | "+":   sy := plusSY; NextCh;
   | "-":   sy := minusSY; NextCh;
   | "*":   sy := multiplySY; NextCh;
   | "/":   sy := divideSY; NextCh;
   | "(":   sy := lparenSY; NextCh;
   | ")":   sy := rparenSY; NextCh;
   | "0".."9":
            const := ORD(ch) - ORD("0");
            NextCh;
            WHILE (ch >= "0") & (ch <= "9") DO
               const := const * 10 + ORD(ch) - ORD("0");
               NextCh;
            END;
            sy := constantSY;
   | 0X:    sy := eofSY;
   ELSE     sy := errorSY;
   END;
END GetSy;

*Die Prozedur GetSy liefert nun ein Symbol zurück aus dem Bereich plusSY .. errorSY.
 

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 1999 Andreas Borchert, in HTML konvertiert am 29.06.1999