Topological sort: Difference between revisions

Line 512:
staload UN = "prelude/SATS/unsafe.sats"
 
(* Macros for list construction. *)
#define NIL list_nil ()
#define :: list_cons
 
(*------------------------------------------------------------------*)
(* A shorthand for list reversal. This could also have been written as
better than a macro. *)
a macro, and less verbosely, but a template function usually is
 
better than a macro. *)
fn {a : t@ype}
rev {n : int}
Line 525 ⟶ 527:
that result to a "regular" list. *)
list_vt2t (list_reverse<a> lst)
 
(*------------------------------------------------------------------*)
(* Some shorthands for string operations. These are written as
macros. *)
 
macdef substr (s, i, n) =
(* string_make_substring returns a linear strnptr, but we want a
"regular" string. *)
strnptr2string (string_make_substring (text,(s), ,(i), j - i,(n)))
 
macdef copystr (s) =
(* string0 copy returns a linear strptr, but we want a "regular"
string. *)
strptr2string (string0_copy (,(s)))
 
(*------------------------------------------------------------------*)
Line 676 ⟶ 692:
val j = skip_ident (text, n, i)
val () = $effmask_exn assertloc (i < j)
val nodename = substr (text, i, j - i)
strnptr2string
(string_make_substring (text, i, j - i))
in
loop (nodename :: row, j)
Line 742 ⟶ 756:
c := $extfcall (int, "getchar")
end;
strptr2string (string0_copycopystr ($UN.cast{string} (addr@ buf)))
end
 
Line 1,127 ⟶ 1,141:
nodenames_array[i]
 
(* A shorthand. Seefor alsomapping thefrom shorthandnodenum "rev"to for liststring. reversal,*)
defined above as a template function instead of a macro. *)
macdef map (lst) =
list_vt2t (list_map<nodenum n><String1> ,(lst))
1,448

edits