Re: [ooc-compiler] Strange Scan error
Brought to you by:
mva
|
From: Stewart G. <sgr...@ii...> - 2010-08-03 01:11:11
|
Hi Frank,
Try:
r := sc.real; (* REAL value scanned from input *)
instead of
r := TextRider.real; (* constant for REAL token type *)
Cheers,
Stewart
Frank Hrebabetzky wrote:
> Another strange error. The program
>
> ------------------------------------------------------------
> MODULE TestScan;
>
> IMPORT Files, TextRider, Out;
>
> VAR
> file: Files.File;
> res: Files.Result;
> sc: TextRider.Scanner;
> r: LONGREAL;
>
> PROCEDURE ScanReal (sc:TextRider.Scanner; VAR r:LONGREAL): BOOLEAN;
> BEGIN
> sc.Scan;
> IF sc.type=TextRider.real THEN
> r:= TextRider.real;
> RETURN TRUE
> END;
> RETURN FALSE
> END ScanReal;
>
> BEGIN
> file:= Files.Old ("par.txt", {Files.read}, res);
> sc:= TextRider.ConnectScanner (file);
> WHILE ScanReal (sc, r) DO Out.LongReal (r, 6, 3) END;
> Out.Ln;
> END TestScan.
> -------------------------------------------------------------------
>
> executed with the following par.txt content:
>
> 10.0 11.0 12.0
>
> prints out:
>
> 3.00 3.00 3.00 3.00
> ##
> ## Runtime error in module TextRider at pos 31799
> ## Assertion failed, code 127
>
> On order to see where these strange 3.00 come from I looked into the
> generated TestScan.c and found the function:
>
> ------------------------------------------------------------
> static OOC_CHAR8 TestScan__ScanReal(TextRider__Scanner sc, OOC_REAL64 *r) {
> register OOC_INT32 i0;
>
> i0 = (OOC_INT32)sc;
>
> OOC_TBCALL(((OOC_INT32)OOC_TBPROC_ADR(((OOC_INT32)OOC_TYPE_TAG((_check_pointer(i0,
> 219)))),
> TextRider__ScannerDesc_Scan)),TextRider__ScannerDesc_Scan)((TextRider__Scanner)i0);
> i0 = *(OOC_INT16*)((_check_pointer(i0, 233))+16);
> i0 = i0==3;
> if (!i0) goto l3;
> *r = 3.0000000000000000;
> return 1u;
> l3:
> return 0u;
> ;
> }
> ------------------------------------------------------------
>
> There is indeed a hard-coded (if this term can be used for a
> computer-generated program, but anyway) 3.00... in it. Where does that
> come from?
>
|