[Oberon] Native 24.08.2002: Compiler Bug

Willem Myburgh myburgh at cs.sun.ac.za
Mon Sep 30 22:29:48 CEST 2002


Hi there,

According to Oberon EBNF:
 SimpleExpr = ["+"|"-"] term {AddOperator term}.
 term = factor {MulOperator factor}.
 MulOperator = "*" | "/" | "DIV" | "MOD" | "&".

It is clear from the EBNF that the term is first evaluated before the
monadic minus sign is applied (for the expression " -i DIV j "):
 1. term <- (i DIV j);
 2. SimpleExpr <- (- (i DIV j))

Regards,
--Willem

On Mon, 30 Sep 2002, Douglas G. Danforth wrote:

> >From the Oberon Language report (as specified by BlackBox) I find
>
> "
> Note:
> (-5) DIV 3 = -2
> but
> -5 DIV 3 = -(5 DIV 3) = -1
> "
>
> The language wants
> x = (x DIV y) * y + (x MOD y)
>
> -Doug
>
> Stefan Salewski wrote:
> >
> > Hello,
> >
> > I think there is something wrong with the DIV statement.
> >
> > ==========
> >
> > MODULE StSTest;
> >
> > IMPORT Out;
> >
> > PROCEDURE Do*;
> > VAR
> >   i,j,k:LONGINT;
> > BEGIN
> >   Out.String("Output is:");
> >   Out.Ln;
> >   i:=10;
> >   j:=3;
> >   k:=-(-i DIV j);
> >   Out.Int(k,8); Out.Ln;
> >   i:=-i;
> >   k:=-(i DIV j);
> >   Out.Int(k,8); Out.Ln;
> > END Do;
> >
> > BEGIN
> > END StSTest.
> >
> > StSTest.Do ~
> >
> > Output is:
> >        3
> >        4
> > ==========
> >
> > Best regards
> >
> >   Stefan Salewski
> > --
> > Oberon at inf.ethz.ch mailing list for ETH Oberon and related systems
> > http://www.lists.inf.ethz.ch/mailman/listinfo/oberon
> --
> Oberon at inf.ethz.ch mailing list for ETH Oberon and related systems
> http://www.lists.inf.ethz.ch/mailman/listinfo/oberon
>

-- 
Willem Myburgh
Department of Computer Science
University of Stellenbosch, Private Bag X1, Matieland 7602 South Africa
 Email: myburgh at cs.sun.ac.za        "http://www.cs.sun.ac.za/~myburgh/"
   Tel: +27 (0)21 808 4389 (W)
   Fax: +27 (0)21 808 4416
Mobile: +27 (0)83 415 0416
-----------------------------------------------------------------------




More information about the Oberon mailing list