Hello,
I've been experimenting with implementing a language spec for Gash, such that you can use the shell from the Guile REPL:
scheme@(guile-user)> ,language gash
Happy hacking with Guile as Shell! To switch back, type `,L scheme'.
gash@(guile-user)> find .
.
./src
./src/language
./src/language/gash-compiled
./src/language/gash-compiled/spec.scm
./src/language/gash
./src/language/gash/spec.scm
$1 = 0
gash@(guile-user)> find foo
find: 'foo': No such file or directory
$2 = 1
To achieve this as a simple evaluated language is straightforward:
(define-module (language gash spec)
#:use-module (gash parser)
#:use-module (gash eval)
#:use-module (gash environment)
#:use-module (system base language)
#:export (gash))
(define-language gash
#:title "Guile as Shell"
#:reader (lambda (port env) (read-sh port))
#:evaluator (lambda (x module) (eval-sh x) (get-status))
#:printer write)
I'm wondering if there would be any interest in including something like this in Gash?
It's
also not difficult to naively compile to tree-il, but I think the way
I've done it would not be what is wanted, since it really just compiles
the *interpreter* `eval-sh` code. Of course, `eval-sh` examines an
_expression_ of Gash tokens, producing bits of Scheme code and immediately
evaluating them; a proper compiler should replace the Gash token stream
with those same Scheme _expression_ sequences without executing them, and
pass that to the tree-il compiler. However, that's beyond the scope of
my current familiarity with the Gash implementation.
Happy hacking with Guile as Shell!
-ss