Example of Language Translation

The first stage is transformation through patterns to produce a Lisp representation of the output syntax.


(trans '(defun foo (x y)
            (incf y)
            (setq x (+ x y)))
       'lisptoc)

("" FOO "(" ("" X ", " ("" Y)) ")"
  #\Tab #\Return
 ("{" #\Tab #\Return
  ("" ("++" Y) ";" #\Return (""
  ("" X " += " Y )) ";")
  #\Return "}"))

A simple program, cpr, can print the result.


foo(x, y)
  {
    ++y;
    x += y;
    }

Contents    Page-10    Prev    Next    Page+10    Index