Check-in [76226466c7]

Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed a bug in the conversion to Prolog of numeric atoms (0 vs. '0').
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:76226466c741f8012f101600584a1566d6cb9305
User & Date: andy 2015-04-15 19:51:47
Context
2015-04-15
20:17
Added a new "PVar" subtype of Term, for Prolog variables that need to be preserved as such (i.e., distinguished from specification variables). check-in: 8949a9e372 user: andy tags: trunk
19:51
Fixed a bug in the conversion to Prolog of numeric atoms (0 vs. '0'). check-in: 76226466c7 user: andy tags: trunk
19:43
Fixed a couple bugs in the handling of non-string atoms (coerce to string). check-in: 808229ea10 user: andy tags: trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to src/terms.js.

303
304
305
306
307
308
309
310






311

312
313
314
315
316
317
318
            l = l.rhs();
        }
    }

    function stringify(t) {
        if(t.isVariable())
            return " ' " + t.name + "' ";
        else if(t.isAtom())






            return " '" + t + "' ";

        else if(t.isList())
            return "[ " + stringify_list(t) + " ]";
        else if(t.isCompound())
            return " '" + t.head + 
                   "'(" + t.body.map(stringify).join(" , ") + ") ";
    }








|
>
>
>
>
>
>
|
>







303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
            l = l.rhs();
        }
    }

    function stringify(t) {
        if(t.isVariable())
            return " ' " + t.name + "' ";
        else if(t.isAtom()) {
            // Prolog distinguishes between '0' and 0 (atom vs. number),
            // so we have to make sure that numeric-ish atoms get sent 
            // unquoted.
            if(!isNaN(parseInt(t.head,10)))
                return " " + parseInt(t.head,10).toString() + " ";
            else
                return " '" + t + "' ";
        }
        else if(t.isList())
            return "[ " + stringify_list(t) + " ]";
        else if(t.isCompound())
            return " '" + t.head + 
                   "'(" + t.body.map(stringify).join(" , ") + ") ";
    }