Integer anomaly

This forum is to report technical problems with Rel.
Post Reply
steved
Posts:49
Joined:Sun Sep 01, 2013 10:53 pm
Integer anomaly

Post by steved » Mon May 25, 2015 3:21 am

Hi,

Code: Select all

//Try this in DBrowser.
VAR K INT;
VAR H CHAR;
DO K:=0 TO 8;
BEGIN;
H:=H || K;
WRITELN H;
EXECUTE "WRITELN " || H || ";";
END;
END DO;

//Now this.
VAR K INT;
VAR H CHAR;
DO K:=0 TO 9;
BEGIN;
IF K<>8 THEN
H:=H || K;
END IF;
WRITELN H;
EXECUTE "WRITELN " || H || ";";
END;
END DO;
thanks,
steve

Dave
Site Admin
Posts:368
Joined:Sun Nov 27, 2005 7:19 pm

Re: Integer anomaly

Post by Dave » Mon May 25, 2015 10:19 pm

Could you explain what you expect to see, and what you're seeing instead?

steved
Posts:49
Joined:Sun Sep 01, 2013 10:53 pm

Re: Integer anomaly

Post by steved » Tue May 26, 2015 3:14 am

Code: Select all

//Type the digits 01234567 and execute.
//You should see:
//1234567
//Now type 012345678
//You should see:
//ERROR: Encountered "8" at line 1, column 9.
//Type 081234567
//You should see:
//ERROR: Encountered "81234567" at line 1, column 2.
//Now try: EXECUTE "WRITELN " || '01234567' || ";";
//You should see:1234567
//Now try: EXECUTE "WRITELN " || '012345678' || ";";
//You should see:
//ERROR: RS0286: Encountered " <INTEGER_LITERAL> "8 "" at line 1, column 17.
//Try: EXECUTE "WRITELN " || '081234567' || ";";
//You should see:
//ERROR: RS0286: Encountered " <INTEGER_LITERAL> "81234567 "" at line 1, column 10.

//It's only with the beginning 0 that the error occurs.

//Type 012345679
//You should see:
//ERROR: Encountered "9" at line 1, column 9.
//Type in 091234567
//You should see:
//ERROR: Encountered "91234567" at line 1, column 2.

//It's only with the beginning 0 that the error occurs.

//Type in "012345678"
//Type in "081234567"
//Type in "012345679".
//Type in "091234567"
//Try 0.012345678
//Try 0.012345679
//All of the above should execute without error.
Any guess when we'll see the update?
thanks,
steve

Dave
Site Admin
Posts:368
Joined:Sun Nov 27, 2005 7:19 pm

Re: Integer anomaly

Post by Dave » Tue May 26, 2015 11:47 am

It's a quirk of the Rel parser that it treats an integer preceded with a zero (0) as being an octal number. So, if you type, say, 01232534 into DBrowser it works fine, but if you type 01232539 it fails because '9' isn't an octal digit.

It's on my TODO list to sort this out at some point, but it's not urgent. The workaround is to not precede an integer with a 0.

The new update is under steady development, but it's taking time because the old native-Java DBrowser is being replaced with a native Windows, Linux, and Mac OS X UI. You can keep an eye on its progress (or download the work in progress) at https://github.com/DaveVoorhis

Post Reply