Matt Wette
2018-08-31 14:42:02 UTC
Just goofing off a bit:
scheme@(guile-user)> ,use (nyacc lang nx-lib)
scheme@(guile-user)> (install-inline-language-evaluator)
scheme@(guile-user)> #<nx-matlab: a=[1, 2, 3]; >#
scheme@(guile-user)> (define b (vector-ref a 2))
scheme@(guile-user)> #<nx-javascript: var c = b + 2; >#
scheme@(guile-user)> c
$1 = 5
scheme@(guile-user)> (define d 1)
scheme@(guile-user)> (set! d #<nx-matlab: d + 1; >#)
scheme@(guile-user)> (set! d #<nx-javascript: d + 1; >#)
scheme@(guile-user)> d
$2 = 3
This is using read-hash-extend with a handler that looks
up the language then compiles the code to tree-il, then
decompiles to scheme and returns the scheme form.
Matt
scheme@(guile-user)> ,use (nyacc lang nx-lib)
scheme@(guile-user)> (install-inline-language-evaluator)
scheme@(guile-user)> #<nx-matlab: a=[1, 2, 3]; >#
scheme@(guile-user)> (define b (vector-ref a 2))
scheme@(guile-user)> #<nx-javascript: var c = b + 2; >#
scheme@(guile-user)> c
$1 = 5
scheme@(guile-user)> (define d 1)
scheme@(guile-user)> (set! d #<nx-matlab: d + 1; >#)
scheme@(guile-user)> (set! d #<nx-javascript: d + 1; >#)
scheme@(guile-user)> d
$2 = 3
This is using read-hash-extend with a handler that looks
up the language then compiles the code to tree-il, then
decompiles to scheme and returns the scheme form.
Matt