[Newbie Alert] How can I interface an interpreter to C code?

"Ravi Mohan" <magicindian@gmail.com>
23 Dec 2005 20:53:15 -0500

          From comp.compilers

Related articles
[Newbie Alert] How can I interface an interpreter to C code? magicindian@gmail.com (Ravi Mohan) (2005-12-23)
Re: [Newbie Alert] How can I interface an interpreter to C code? anton@mips.complang.tuwien.ac.at (2005-12-24)
Re: How can I interface an interpreter to C code? englere.geo@yahoo.com (Eric) (2005-12-24)
| List of all articles for this month |

From: "Ravi Mohan" <magicindian@gmail.com>
Newsgroups: comp.compilers
Date: 23 Dec 2005 20:53:15 -0500
Organization: http://groups.google.com
Keywords: C, interpreter, question
Posted-Date: 23 Dec 2005 20:53:15 EST

I just finished working through Essentials Of Programming Languages
(first edition) and now know enough to write recursive descent
interpreters for simple languages. The book also explains how to create
bytecode virtual machines. So far so good.

I now wish to learn how to interface c code to the languages I create.
In other words, I would like to call existing C libraries from the
languages I create.

I am utterly at a loss how to do this. Can someone please point me at
any book or website that explains how to interface existing C code to
an interpreter/bytecode based vm?

From what I understand from a survey of various languages with ffi,
the first step would seem to be to write a vm/interpreter *in C* and
then have some kind of "mylanguage.h" header file that exposes various
data structures of the VM/AST. This is the key step that seems to
enable the creation of an FFI mechanism (the details of which are a
mystery to me :-( )

  I am sorry if that is totally wrong. (please correct me). Am i
totally on the wrong track? Should i now learn how linkers work?

I am totally confused as to what to study and where to look to
understand how to write a language with an ffi. Any pointers will be
very much appreciated.

Thanks in advance,

[If you want to make a fully general mechanism, you're on the right
track and it's a lot of work. On the other hand, if you merely have a
few existing libraries that you want to call, just write some operators
for the VM that call them. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.