(* SPDX-License-Identifier: SMLNJ *) (* SPDX-FileCopyrightText: 1989 Andrew W. Appel, David R. Tarditi *) (* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi * * $Log$ * Revision 1.1 2006/06/23 03:21:27 michaeln * Changed the names of the files in mlyacclib because I want these files * to move into sigobj, and I don't want name-clashes, particularly with * names like stream.sml. (If you use a parser generated by mlyacc, then * you need to have the files in mlyacclib available too.) * * Revision 1.1 2006/06/22 07:40:27 michaeln * Add a MoscowML compilable implementation of MLyacc, using the MLton sources * as the base. * * Revision 1.2 1997/08/26 19:18:55 jhr * Replaced used of "abstraction" with ":>". * # Revision 1.1.1.1 1997/01/14 01:38:04 george # Version 109.24 # * Revision 1.1.1.1 1996/01/31 16:01:43 george * Version 109 * *) (* Stream: a structure implementing a lazy stream. The signature STREAM is found in base.sig *) structure Stream :> STREAM = struct datatype 'a str = EVAL of 'a * 'a str ref | UNEVAL of (unit->'a) type 'a stream = 'a str ref fun get(ref(EVAL t)) = t | get(s as ref(UNEVAL f)) = let val t = (f(), ref(UNEVAL f)) in s := EVAL t; t end fun streamify f = ref(UNEVAL f) fun cons(a,s) = ref(EVAL(a,s)) end;