Hello,<br><br>I'm working on a forth compiler which uses an intermediate functional<br>compositional language (CAT) modeled after the Joy language to<br>implement the forth macros in. Until now I've used an explicit interpreter
<br>to implement the CAT language, for ease of debugging. The feature<br>used the most is 'print stack'. A possible output might look like:<br><br><2> 1 (1 +)<br><br>This indicates 2 elements on the stack. The number 1 and the quoted
<br>program (1 +). The language elements themselves are represented as<br>scheme functions (stack -> stack). I.e. the function '(1 +)' might be<br>(lambda (a . stack) (cons (+ 1 a) stack)), and the function '1' might be
<br>(lambda stack (cons 1 stack))<br><br>Currently, I'm using a simple caching mechanism to speed up execution<br>a bit, so compilation is done only once, but i still have full access to the<br>source code for debugging purpose.
<br><br>Each code atom has a the following information associated:<br>1. a source expression. 2. a function representing semantics <br>(source -> scheme fn) since there are different flavors of the language, <br>and 3. a cached scheme fn.
<br><br>Now, I don't use this for much else than debugging, so i was wondering<br>how I could simplify my implementation by using only macros,<br>taking out the explicit interpreter.<br><br>This seems to be fairly straightforward. The problem however is that my
<br>original source code information is lost.<br><br>So my question is, how can i annotate the functions I get in the end, to<br>associate them to their original source code, so my 'print stack' operation<br>still works?
<br><br>Cheers<br>Tom<br><br>