## bool.pkg
# Compiled by:
#
src/lib/std/src/standard-core.sublib### A sage
### who had filled his glass
### at the fountain of truth
### Said, in
### a statement
### that later became canonical
### To his
### disciples,
### patterns of eager youth:
### "I have
### seen truth itself --
### and it's conical."
###
### -- Piet Hein
###
### [ NB: Piet's illustration
### shows the sage brandishing
### an overflowing cone-shaped glass. ]
stipulate
package bt = base_types; # base_types is from
src/lib/core/init/built-in.pkg package it = inline_t; # inline_t is from
src/lib/core/init/built-in.pkg package nst = number_string; # number_string is from
src/lib/std/src/number-string.pkg package pb = proto_basis; # proto_basis is from
src/lib/std/src/proto-basis.pkgherein
package bool
: (weak) Bool # Bool is from
src/lib/std/src/bool.api {
Bool == bt::Bool;
# inline_t is from
src/lib/core/init/built-in.pkg not = it::inlnot;
# NOTE: this should probably accept
# a wider range of arguments, but the
# spec hasn't been written yet. XXX BUGGO FIXME
#
fun scan (getc: nst::Reader( Char, X )) cs
=
case (getc (pb::skip_ws getc cs))
#
THE ('T', cs')
=>
case (pb::get_nchars getc (cs', 3))
#
THE (['R', 'U', 'E'], cs'')
=>
THE (TRUE, cs'');
_ => NULL;
esac;
THE ('F', cs')
=>
case (pb::get_nchars getc (cs', 4))
#
THE (['A', 'L', 'S', 'E'], cs'')
=>
THE (FALSE, cs'');
_ => NULL;
esac;
_ => NULL;
esac;
fun to_string TRUE => "TRUE";
to_string FALSE => "FALSE";
end;
from_string
=
pb::scan_string scan;
};
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.