Sat Mar 22 09:12:25 EDT 2008
an intermediate representation is necessary which preserves the macros
in some form so they can be re-instantiated, but also preserves the
forth words in some form. is it possible to somehow grab the source
code (after lexing) of each word? that way original macro source can
be preserved, and forth source can be translated to abstract rep (only
basic idea: can't use source code to save current language
state. maybe save the environment functions together with the forth
structs that are generated? i.e. if address is filled, return that,
otherwise return word struct.
maybe the macro from yesterday needs to be factored a bit?
OK. incremental updates are implemented as a simple nesting of
so, how to represent the target state? i prefer to have this in a
readable form, preferrably one with macro source intact, and forth
words resolved to numbers.
first: separated out some things: there's a 2-level nesting with 'old'
not being collected. need some factoring to reset parameters.
or.. i could make the macros ephemeral, so they have to be included
explicitly in each source file?
or.. the whole thing runs at stx-transform time and expands into a
module that defines a number of forth macros and a binary code chunk?
maybe it's best to collect per level. then later, code that's not
necessary can be ignored.
can collection be done statically?
the thing is: macros need to be saved in some syntactic form, not as
an object. from this, it's not necessary to evaluate macros, except
for things that generate code. instantiated live target code is
represented by macros.
so, ground rules:
* evaluation of code gives a list of nodes in a code graph
* saving of state = saving of macros as syntax.
problem = how to save macros?
each word evaluated needs to be evaluated in the lexical context.