Free C Interpreters (CINT, UPS, EiC)

Dibyendu Majumdar <dibyendu@mazumdar.demon.co.uk>
2 Jan 1999 21:48:55 -0500

          From comp.compilers

Related articles
Free C Interpreters (CINT, UPS, EiC) dibyendu@mazumdar.demon.co.uk (Dibyendu Majumdar) (1999-01-02)
| List of all articles for this month |
From: Dibyendu Majumdar <dibyendu@mazumdar.demon.co.uk>
Newsgroups: comp.compilers
Date: 2 Jan 1999 21:48:55 -0500
Organization: Compilers Central
Keywords: C, interpreter, summary

Hi.


I am writing this in the hope that it may be of use to others.


I have wanted to write an ISO/ANSI C interpreter for some
time. However, not being trained in this area, I found it difficult to
get started. Maybe one day I will understand the principles well
enough to write a C interpreter on my own.


In the meantime, I decided that the next best thing for me to do was
to understand an existing implementation of a C interpreter. After
looking for several months for a decent implementation of an ISO/ANSI
C interpreter for which source was freely available - I found three
that I liked. These are described below:


1. CINT - a C/C++ interpreter


This was the first one I found. The website is:


root.cern.ch/root/Cint.html


Created by Masaharu Goto, this is reasonably good C/C++
interpreter. Particularly notable is its ability to call external
routines (even in shared libraries or DLLs). The product is portable
and available for Win32/MSDOS/various UNIX flavors. The Interpreter
can be linked into any C application. It is also perhaps the only C++
interpreter available freely.


From my point of view I found the quality of code such that it was
very near impossible to understand how it works. However, it works
reasonably well - it can interpret itself !!


2. UPS C Debugger


Although this is really an X-Windows graphical debugger for C/C++, it
contains a reasonably complete ANSI-C interpreter. This implementation
is interesting for the following reasons:


                * It can interpret single C source files, or
                    multiple C source files. When interpreting multiple C
                    sources, a compile/link model is used to build
                    a byte-code executable. This can then be executed
                    by a Virtual Machine interpreter. This works for
                    single C source files as well.


                * The UPS debugger can debug (with limitaions) an
                    interpreter executable created above.


The website for this is www.concerto.demon.co.uk/UPS. Note that the
UPS C interpreter is undocumented - and does not work straight out of
the box as of now. I can supply patch files for Linux RedHat 5.1 to
anyone who is interested - please write to me at
dibyendu@mazumdar.demon.co.uk.


I found this implementation the best from my point of view. The
quality/style of code is very good and the design is excellent - the
design completely separates the following phases:


                lexer
                parser
                compiler
                linker
                executor
                debugger


If you want to understand how to write interpreters/debuggers, I
recommend this whole-heartedly.


3. EiC byte-code interpreter


I recently found this. Created by Ed Breen, this is a good C
interpreter. It can be run interactively or in scripting mode. Since
most readers of this new group are already aware of this interpreter -
I am not describing it further here.


The website I use is antarctica.penguincomputing.com/~eic.


For my purposes, I found UPS to be better mainly because of the way it
is written.


-----------------


I am currently working on improving the UPS C Interpreter. I have
made a number of bug-fixes/minor enhancements - my main objective is
to make the interpreter as 'ANSI/ISO conforming' as possible. I have
also created a list of known problems/bugs in the interpreter, and a
brief writeup.


I have submitted my changes to the team that maintains the code -
hopefully the fixes will be available in the standard release very
soon.


Until then, I can supply a patch to anyone who is interested (my patch
will only work on RedHat 5.1).


Regards
Dibyendu
dibyendu@mazumdar.demon.co.uk


Post a followup to this message

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