[Oberon] Understanding ORS.Mod.txt
John R. Strohm
strohm at airmail.net
Sun Jun 12 23:29:14 CEST 2016
The string length slen includes the terminating NUL (0X).
-----Original Message-----
From: Srinivas Nayak
Sent: Sunday, June 12, 2016 1:35 PM
To: ETH Oberon and related systems
Subject: Re: [Oberon] Understanding ORS.Mod.txt
In
PROCEDURE String;
VAR i: INTEGER;
BEGIN i := 0; Texts.Read(R, ch);
WHILE ~R.eot & (ch # 22X) DO
IF ch >= " " THEN
IF i < stringBufSize-1 THEN str[i] := ch; INC(i) ELSE Mark("string
too long") END ;
END ;
Texts.Read(R, ch)
END ;
str[i] := 0X; INC(i); Texts.Read(R, ch); slen := i
END String;
we see
str[i] := 0X; INC(i); Texts.Read(R, ch); slen := i
Why slen is one more than the actual string length?
Am I missing something silly?
With thanks and best regards,
Yours sincerely,
Srinivas Nayak
Home: http://www.mathmeth.com/sn/
Blog: http://srinivas-nayak.blogspot.in/
On 06/12/2016 07:11 PM, Srinivas Nayak wrote:
> We see
>
> PROCEDURE Ten(e: LONGINT): REAL;
>
> VAR x, t: REAL;
>
> BEGIN x := 1.0; t := 10.0;
>
> WHILE e > 0 DO
>
> IF ODD(e) THEN x := t * x END ;
>
> t := t * t; e := e DIV 2
>
> END ;
>
> RETURN x
>
> END Ten;
>
> Should it be, RETURN x * t ?
>
>
> With thanks and best regards,
>
> Yours sincerely,
> Srinivas Nayak
>
> Home: http://www.mathmeth.com/sn/
> Blog: http://srinivas-nayak.blogspot.in/
>
> On 06/12/2016 07:01 PM, Srinivas Nayak wrote:
>> Dear Friends,
>>
>> Finally I could gather my courage to read NW's compiler implementation.
>> Hope to get your help when I get doubts.
>>
>> In ORS.Mod.txt we see
>>
>> PROCEDURE Mark*(msg: ARRAY OF CHAR);
>>
>> VAR p: LONGINT;
>>
>> BEGIN p := Pos();
>>
>> IF (p > errpos) & (errcnt < 25) THEN
>>
>> Texts.WriteLn(W); Texts.WriteString(W, " pos ");
>> Texts.WriteInt(W, p, 1); Texts.Write(W, " ");
>>
>> Texts.WriteString(W, msg); Texts.Append(Oberon.Log, W.buf)
>>
>> END ;
>>
>> INC(errcnt); errpos := p + 4
>>
>> END Mark;
>>
>> Why we did, errpos := p + 4 ?
>> How do I understand/interpret this?
>> I was thinking, it should be errpos := p + 1 ...
>> Kindly correct me.
>>
>>
>> With thanks and best regards,
>>
>> Yours sincerely,
>> Srinivas Nayak
>>
>> Home: http://www.mathmeth.com/sn/
>> Blog: http://srinivas-nayak.blogspot.in/
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
More information about the Oberon
mailing list