[Oberon] ORP.set

Chris Burrows chris at cfbsoftware.com
Tue Mar 12 23:53:34 CET 2019


> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Andreas Pirklbauer
> Sent: Wednesday, 13 March 2019 6:07 AM
> To: ETH Oberon and related systems
> Subject: [Oberon] ORP.set
> 
> 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;
> 
> 
> Has anyone else seen this and/or addressed this issue in a different
> way?
> 

This is how we handle it in the ARM Cortex-M compilers:

      WHILE (sym < OSAS.rparen) & (sym # OSAS.rbrace) DO
        IF sym = OSAS.comma THEN OSAS.Get(sym)
        ELSE OSAS.Mark("missing comma")
        END;
        element(y); OSAG.SetOp(OSAS.plus, x, y)
      END

If the programmer makes an understandable mistake e.g. 

  x := {1)

The compiler reports:

  Line  Col
     4   15 Error: no }

Regards,
Chris

Chris Burrows
CFB Software
http://www.astrobe.com




More information about the Oberon mailing list