Dear Mark,

just in case you haven't noticed this already: you can call create and call a Mozart compiler within a Mozart application without resorting to the command line tools. In fact, it is more efficient to do so if you want to call the compiler repeatedly.

Here is a small scale example where a virtual string of Oz code is compiled and executed by a user-created compiler.

declare
MyOzCode = "local X=3 in X+X end"
{Browse {Compiler.virtualStringToValue MyOzCode}}


The definition of VirtualStringToValue can serve as an example how to create an use a compiler. The following is just a copy from the Oz sources. Note that this example always creates and uses a new compiler. If you want to use it repeatedly, you better create a compiler only once :)


proc {EvalExpression VS Env ?Kill ?Result} E I S in
   E = {New Engine init()}
   I = {New Interface init(E)}
   {E enqueue(mergeEnv(Env))}
   {E enqueue(setSwitch(expression true))}
   {E enqueue(setSwitch(threadedqueries false))}
   {E enqueue(feedVirtualString(VS return(result: ?Result)))}
   thread T in
      T = {Thread.this}
      proc {Kill}
         {E clearQueue()}
         {E interrupt()}
         try
            {Thread.terminate T}
            S = killed
         catch _ then skip   % already dead
         end
      end
      {I sync()}
      if {I hasErrors($)} then Ms in
         {I getMessages(?Ms)}
         S = error(compiler(evalExpression VS Ms))
      else
         S = success
      end
   end
   case S of error(M) then
      {Exception.raiseError M}
   [] success then skip
   [] killed then skip
   end
end

fun {VirtualStringToValue VS}
   {EvalExpression VS env() _}
end


The compiler API reference doc is here:
http://www.mozart-oz.org/documentation/compiler/node4.html

Best
Torsten

On Jun 3, 2008, at 7:06 PM, mark richardson wrote:

Hi everyone,

I'm trying to write a *very* small IDE for Mozart.
At the moment I'm using a conversion of the demo notepad application
with just a button to feed the file to Mozart. I'm using a pre-defined
file name for testing purposes but it's proving harder than I thought it
would.

My questions are:

What is the best way to pass the file out of Mozart - built in function (I've seen the feedBuffer procedure which I thought was in the Narrator
module but can't get that working) or issuing a shell command to
manually call the Oz tools?

If I used shell commands, what is the procedure for running an Oz source file (the way Emacs does)? I assume there must be a compile/link/ execute
procedure to follow but I thought ozc only accepted source code in a
to-be-a-functor form.

I don't start my course in Lisp until October so the Emacs lisp files
don't help much either.

Any help would be gratefully received.
Mark Richardson
(Frustrated novice)
______________________________________________________________________ ___________ mozart-users mailing list mozart- [EMAIL PROTECTED]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

--
Torsten Anders
Interdisciplinary Centre for Computer Music Research
University of Plymouth
Office: +44-1752-586227
Private: +44-1752-558917
http://strasheela.sourceforge.net
http://www.torsten-anders.de





_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to