Still, we can inspect the general pattern that is generated as a result of the compilation, and therefore write for example test cases that subsume many possible concrete cases!
On a general note, one reason why Prolog is so popular for writing compilers is that the language has a built-in mechanism for writing parsers, and in fact describing all kinds of sequences (for example, of tokens, of instructions etc.) in a very convenient way.
For example, the above three clauses can be written equivalently as a so-called definite clause grammar (DCG):
This makes it very easy to see the key aspects of the code. At the same time, the description is so general that it can be used in all directions, to generate, parse and test instructions.
Look how simple I can compile down to asm code in 35 lines of pure prolog code.
https://github.com/segmond/PrologThingz/blob/master/clause_a...