The kernel of a concatenative programming language can be easily implemented using a rewriting system. As a proof-of-concept the presented implementation fully relies on Scheme's rewriting system at macro expand time! All one needs is define-syntax and -- in order to provide access to Scheme's built-in procedures -- a single defmacro. (Apologies, if the formatting makes the code below hard to read. If you like to get the Scheme code, just drop me an email.) Rewriting rules concerning the data stack (ds) are written as follows: (rule swap : (@d ... snd fst) ==> (@d ... fst snd)) ^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ word datastack before datastack after Note that the topmost element of the data stack is the rightmost element in the notation above. Rewriting rules concerning the data _and_ the program stack (ps) are written as (rule call : (@d ... (@q ...)) (@p ...) ==> (@d ...) (@q ... @p ...)) ^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^ ...
gedanken, ideen, anregungen und links rund um themen zur informatik, bildung, studium