A simple generic code generation tool
This example uses JavaScript as the control language:
readysteady.js.dna:
.#include <stdio.h> . .int main() { var i; for (i=3; i>0; i--) { . printf("@{i}!\n"); } . printf("Go!\n"); . return 0; .}
To generate the code do the following:
$ ribosome.js readysteady.js.dna
The script produces the following output (which happens to be a C program):
#include <stdio.h> int main() { printf("3!\n"); printf("2!\n"); printf("1!\n"); printf("Go!\n"); return 0; }
Any non-trivial code generating code is hard to read, understand and maintain. While most code generating tools do the technical part of the job all right, they fail on the manageability aspect. Ribosome tries to address it using following measures:
Note however, that Ribosome trades speed for readability/maintainability and thus it isn't well suited for performance-critical tasks such as, for example, generating HTML on the fly.
Ribosome is licensed under MIT/X11 license.