From: Matt Wette <matt.wette@gmail.com>
To: guile-user@gnu.org
Subject: Re: Multi-language scripts
Date: Sat, 22 Aug 2020 08:22:12 -0700 [thread overview]
Message-ID: <170820fc-d7b2-1a2a-93ab-3777eaa5fc74@gmail.com> (raw)
In-Reply-To: <135D6304-61E4-4826-81BE-4C93257A1F6F@gmail.com>
On 8/22/20 7:53 AM, Stephen Scheck wrote:
> Matt Wette wrote:
>
>> maybe this?
>>
>> (use-modules (system base language))
>> (current-language (lookup-language 'ecmascript))
> It doesn’t work:
>
> scheme@(guile-user)> (use-modules (system base language))
> scheme@(guile-user)> (lookup-language ‘ecmascript)
> $1 = #<<language> name: ecmascript title: ECMAScript reader: #<procedure 7f939b1bb558 at language/ecmascript/spec.scm:33:16 (port env)> printer: #<procedure write (_ #:optional _)> parser: #f compilers: ((tree-il . #<procedure compile-tree-il (exp env opts)>)) decompilers: () evaluator: #f joiner: #f for-humans?: #t make-default-environment: #<procedure make-fresh-user-module ()>>
> scheme@(guile-user)> (current-language $1)
> $2 = scheme
> scheme@(guile-user)> display("We should be in JavaScript now, but we aren’t!\n”);
> $3 = #<procedure display (_ #:optional _)>
> ERROR: Wrong type to apply: "We should be in JavaScript now, but we aren’t!\n”
>
> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
>
>
> Also, even if it did, it would be problematic switching back - you’d need to do something along these lines in Scheme first:
>
> (define (string_to_symbol sym) (string->symbol sym))
> (define (lookup_language lang) (lookup-language lang))
> (define (set_current_language lang) (set-current-language! lang)) ;; assuming set-current-language! actually existed…
>
> This wouldn’t work, obviously, in the general case for other languages. I don’t really want to use JavaScript, I was just using it as an example.
>
> I really just want some way to enable the REPL reader when you pass a script to Guile with the -s switch from the command line so you can embed `,language` meta-commands in the script file.
>
>
I think the issue is that while the repl processes one input (line) at a
time guile
handles files by compiling a file at a time. I think you'd have to
write code
to process files an input (line) at a time. Maybe this could be a
procedure that
takes the name of the file, generates a repl and feeds the repl from the
file
one line at a time.
(I have played with the compiler code a bit in writing guile-hosted
parser/interpreters
for javascript, matlab, tcl and others. Try web search for guile nyacc.)
Matt
next prev parent reply other threads:[~2020-08-22 15:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-22 14:53 Multi-language scripts Stephen Scheck
2020-08-22 15:22 ` Matt Wette [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-08-21 19:17 Stephen Scheck
2020-08-22 2:47 ` Matt Wette
2020-08-21 18:22 Stephen Scheck
2020-08-21 18:36 ` Matt Wette
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=170820fc-d7b2-1a2a-93ab-3777eaa5fc74@gmail.com \
--to=matt.wette@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).