[Oz] Preprocessor

Leif Kornstaedt kornstae at ps.uni-sb.de
Thu Feb 25 13:34:03 CET 1999


> > Is there a preprocessor for Oz. 
> > 
> > I need conditional compilation.
> 
> You can use the following
> 
> In Oz		In C
> ======================
> \if		#if

Note that if you are using Mozart, the abbreviation `\if' is
no longer supported; you have to write `\ifdef' instead.

Also for Mozart, you can use the following Emacs Lisp code to
have every feeded region being piped through m4 before being
sent to the Oz compiler.  (Not thoroughly tested though.)

Leif Kornstaedt.


(defadvice oz-send-string (before oz-preprocess-and-send-string activate)
  "Run STRING through M4 before feeding it."
  (let ((buffer (generate-new-buffer "*Oz Preprocessor*")))
    (save-excursion
      (set-buffer buffer)
      (insert (ad-get-arg 0))
      (shell-command-on-region (point-min) (point-max) "m4" nil t)
      (ad-set-arg 0 (buffer-string))
      (kill-buffer buffer))))

(defun oz-feed-buffer ()
  "Feed the current buffer to the Oz Compiler."
  (interactive "")
  (oz-send-string (oz-get-region (point-min) (point-max)))
  (oz-zmacs-stuff))

;;(ad-remove-advice 'oz-send-string 'before 'oz-preprocess-and-send-string)
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.





More information about the mozart-users mailing list