[Oberon] ORP.set

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Tue Mar 12 20:37:24 CET 2019


The following program fragment hangs the FPGA Oberon-07 compiler:

   MODULE M;
     VAR x: SET;
   BEGIN x := {1

The issue is caused by an endless loop in procedure ORP.set, namely

  WHILE (sym < ORS.rparen) OR (sym > ORS.rbrace) DO

One possible way to address this is to change procedure ORP.set

From:

  PROCEDURE set(VAR x: ORG.Item);
    VAR y: ORG.Item;
  BEGIN
    IF sym >= ORS.if THEN
      IF sym # ORS.rbrace THEN ORS.Mark(" } missing") END ;
      ORG.MakeConstItem(x, ORB.setType, 0) (*empty set*)
    ELSE element(x);
      WHILE (sym < ORS.rparen) OR (sym > ORS.rbrace) DO
        IF sym = ORS.comma THEN ORS.Get(sym)
        ELSIF sym # ORS.rbrace THEN ORS.Mark("missing comma")
        END ;
        element(y); ORG.SetOp(ORS.plus, x, y)
      END
    END
  END set; 

To:

PROCEDURE set(VAR x: ORG.Item);
    VAR y: ORG.Item;
  BEGIN
    IF sym >= ORS.if THEN
      IF sym # ORS.rbrace THEN ORS.Mark(" } missing") END ;
      ORG.MakeConstItem(x, ORB.setType, 0) (*empty set*)
    ELSE element(x);
      WHILE (sym <= ORS.comma) OR (sym = ORS.semicolon) DO
        IF sym = ORS.comma THEN ORS.Get(sym) ELSE ORS.Mark("comma?") END ;
        element(y); ORG.SetOp(ORS.plus, x, y)
      END
    END
  END set; 

With this change, the compiler no longer hands and outputs the message:

  pos 43 no }

Has anyone else seen this and/or addressed this issue in a different way?




More information about the Oberon mailing list