[<<][staapl][>>][..]
Mon Apr 21 21:26:18 EDT 2008
string -> language
How to create forth code from a string?
i forgot how the logic works..
pic18/lang/reader.ss:
(module reader scat/forth/module-reader
scat/pic18/purrr18-module-language)
the generic forth reader uses #%plain-module-begin from the specified
module. to declare and instantiate a module body
(module test "pic18/purrr18-module-language.ss" : abc 1 2 3)
(require 'test)
(print-all-code)
abc:
[dup]
[movlw 1]
[dup]
[movlw 2]
[dup]
[movlw 3]
now, from a string: open the reader module with a prefix:
(require (prefix-in 'forth- "pic18/lang/reader.ss"))
The answer seems to be: forth code lives in a namespace, so in order
to load a file, create a new namespace.
EDIT: got it to work by using:
(parameterize
((current-namespace ns))
(eval form)
(eval `(require
scat/macro/code
',name)))
now i can instantiate multiple namepspaces, each with their own
language. one problem though: the word structures are not accessible,
because the instances are different.
anyways, this gives a nice border to create the "badnop interface".
now, this takes noticable time with all modules compiled.
(ns-print-code (purrr18->namespace ": abc 1 2 3"))
which means something is running during instantiation of the
modules.. maybe it's the tests? maybe it's possible to keep a
namespace around with an instantiated compiler, and re-evaluate forth
code? TODO: split instantiation of compiler, and compilation, to make
way for incremental compilation.
looks like this is the next step: make this easy to use.
[Reply][About][<<][staapl][>>][..]