compiler construction - Which is a good and simple intermediate code? -


Suppose an assignment is to write a compiler that works on a subset of C language (you can consider a subset Whatever language, the complex things support the basic scripting expressions in the form of objects.)

What kind of intermediate code can be used to verify the accuracy of the compiler? I was talking to a professor and he talked about the fact that he did not know what to give VM to his students to use for "compiled code", so I thought it was a good The solution can be.

  subset of C - & gt; Compiler - & gt; Code? - & gt; VM  

In which code can be either better in binary format or better in some ASCII format (some pseudo-samas).

I'm looking for some things I have already created, not an intermediate code and how to configure VM, ready to use to test some compiled programs. You can describe some abstract machine design and then it's a list of easy-to- Can provide set directions in the format. I am a gentleman in small Lisp Parser Parsers.

  (label add-to) (Init-stack-frame 2) (load R0 0) (load R2 1) (add val R1 R2)  

In addition, it is a nobrainer by writing a lip interpreter to read.

  load_labels (index, expr, env) if expr first == 'label' anniversase (xpsecond, index) interpretation (machine, XPR, NV) returns NV. Lookup (XProp). Aval (machine, exp. Tail)  

Comments