Reputation: 73
I am currently using PolyML 5.5.2, and trying to create a runtime compiler function that takes a string and runs it.
The desired function should be like
fun eval string -> unit
when input
>eval "val a=1;";
val a = 1: int
I have done some research that in old version there is a function like PolyML.compilerEx but it seems there is no such thing in PolyML 5.5.2.
Many thanks to all.
Upvotes: 1
Views: 86
Reputation: 412
You will want something along the lines of
PolyML.compiler(infn,
[PolyML.Compiler.CPErrorMessageProc record_error,
PolyML.Compiler.CPOutStream obufPush]) ()
where infn
is the function that gives the compiler characters, and obufPush
is something that consumes the compiler's output. The record_error
is defined in the code I'm sampling from to be:
fun record_error {message,...} = PolyML.prettyPrint(obufPush,70) message
Upvotes: 1
Reputation: 526
You can use PolyML.compiler. The documentation is closer to the forthcoming 5.6 release but it should work fine with 5.5.2.
Upvotes: 1