[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

loading an ecmascript file

From: Matt Wette
Subject: loading an ecmascript file
Date: Sun, 15 Jul 2018 16:53:33 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Hi All,

I was hoping to kludge together a procedure to load a file containing
a non-Scheme extension language.  I am not surprised that it doesn't
work, given the complexity of the load/compile code in (ice-9 boot-9
(check load-in-vicinity) and (system base compile) (check compile-file).
Any ideas how to make progress?

(define file-ext-map
  '(("scm" . scheme)
    ("js" . ecmascript)))

(define* (load/x file-name)
  (let* ((ext (and=> (string-rindex file-name #\.)
                    (lambda (ix) (substring file-name (1+ ix)))))
         (ext-lang (assoc-ref file-ext-map ext)))
    (simple-format #t "loading a ~S file\n" ext-lang)
    (parameterize ((current-language ext-lang))
      (load file-name))))

Notice in my test below that I get dumped into ecmascript in the
debugger.  When I exit, I'm back in Scheme mode.  Also, if I try
to load with normal load I get the same error message.

scheme@(guile-user)> (load/x ",zz.js")
loading a ecmascript file
ERROR: In procedure %resolve-variable:
Unbound variable: var

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
ecmascript@(guile-user) [1]> ,bt
           2 (primitive-load-path "nyacc/lang/javascript/,zz.js")
In ice-9/eval.scm:
   223:20  1 (proc #<directory (guile-user) 2231140>)
In unknown file:
           0 (%resolve-variable (7 . var) #<directory (guile-user) 2231140>)
ecmascript@(guile-user) [1]>

scheme@(guile-user)> (load ",zz.js")
ERROR: In procedure %resolve-variable:
Unbound variable: var


P.S.  I am not working on ecmascript but my own javascript,
with goal to generate tools and procedures for adding more
extension languages with nyacc.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]