[comp.lang.c] looking for interpreter / macro language facility

ajb@miles.WPI.EDU (Arthur J. Butler) (05/22/91)

hi.  i am looking for advice and/or suggestions on an interpreter or
macro language facility which i plan on adding to my application.  are
there common languages which are used to add macro facilities to
applications?  are there any PD/commercial lisp implementations
available which would suffice?

	within this macro language, i need to at least to
	a) be able to call functions within my program.
	b) be able to use control and loop constructs.
	c) define and use simple variables.

my program will be written in C/C++ to be run in a UNIX workstation
environment.  in the worst case i can develop my own language using
lex / yacc but why reinvent the wheel.

thanks.

arthur (ajb@ee.wpi.edu)

new@ee.udel.edu (Darren New) (05/23/91)

In article <1991May22.153052.30224@wpi.WPI.EDU> ajb@miles.WPI.EDU (Arthur J. Butler) writes:
>hi.  i am looking for advice and/or suggestions on an interpreter or
>macro language facility which i plan on adding to my application.  

REXX would be a good choice.  Check comp.lang.rexx to find out if
there is a REXX interpreter for the environments you are interested
in.  I think it's available on IBM mainframes, UNIX, most micros, etc.
It's an algol/basic/pascal-class language with lots more flexibility,
and any command that isn't understood by the interpreter gets
passed to whatever program started the macro.  Thus, you could 
write a REXX command called "downparagraph" which said

downparagraph:
   getline X
   while X ~= "" do
     downline
     getline X
     end

(It's been a while, so the syntax may be wrong.)  Anyway,
the getline and downline statements are not REXX statements,
so they get bounced back to the calling editor to handle.

Anyway, it's a good idea to check it out, especially since
it handles multiple concurrent appplications at once:

getfiles:
   getline X
   address command "ftp " || X
   getline X
   while X ~= "" do
      address "FTP-REXX-PORT" "get " || X
      getline X
      end
   address "FTP-REXX-PORT" "bye"

which would get the name of the machine from the current
line in the editor, start up FTP, and then get the files
named on the succeeding lines.   It's also a very easy language
to learn and works with lots of other products, which is
a plus compared to learning a new macro language for every
application.

	      -- Darren

-- 
--- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
----- Network Protocols, Graphics, Programming Languages, FDTs -----
+=+ Nails work better than screws, when both are driven with hammers +=+

hp@vmars.tuwien.ac.at (Peter Holzer) (05/23/91)

ajb@miles.WPI.EDU (Arthur J. Butler) writes:

>hi.  i am looking for advice and/or suggestions on an interpreter or
>macro language facility which i plan on adding to my application.  are
>there common languages which are used to add macro facilities to
>applications?  are there any PD/commercial lisp implementations
>available which would suffice?

>	within this macro language, i need to at least to
>	a) be able to call functions within my program.
>	b) be able to use control and loop constructs.
>	c) define and use simple variables.

You might want to have a look at tcl by Karl Lehenbauer. It was posted
to alt.sources last December. It does everything you want, is rather
small (10-20k extra code for the interpreter, if I remember correctly)
and looks like a mixture of sh and lisp. 

I have played around a little with it when it was posted, but I have
not really used it, so I can't say how usable it is for real work, but
the docu says it has already been used for an X-based editor.
If it is not archived somewhere near you, you can get it by anonymous
FTP from ftp.vmars.tuwien.ac.at.

--
|    _  | Peter J. Holzer                       | Think of it   |
| |_|_) | Technical University Vienna           | as evolution  |
| | |   | Dept. for Real-Time Systems           | in action!    |
| __/   | hp@vmars.tuwien.ac.at                 |     Tony Rand |

harrison@csl.dl.nec.com (Mark Harrison) (05/23/91)

In article <1991May22.153052.30224@wpi.WPI.EDU>
ajb@miles.WPI.EDU (Arthur J. Butler) writes:

>hi.  i am looking for advice and/or suggestions on an interpreter or
>macro language facility which i plan on adding to my application.  are
>there common languages which are used to add macro facilities to
>applications?

You might want to check out tcl, the Tool Command Language, by Prof.
John Ousterhout at UC Berkeley.  I have used it on several projects
now and am immensely pleased with the results.

It is distributed as part of the Tk release.  Here is the release
announcement for Tk 1.0:
------------------------------------------
This is to announce the first official release of the Tk toolkit
for X11.  Tk is philosophically similar to Xt, but it is based
around the Tcl language.  The use of Tcl simplifies the toolkit
and also provides a great deal of additional power:  many
applications can be written as Tcl scripts without writing any C
code at all, and Tcl provides a means for different applications
to communicate with each other.  A paper describing Tk appeared
in the Winter '91 USENIX Conference Proceedings, and is also
distributed as part of the release.

The release contains source code and documentation for the
following things:
    (1) The Tk toolkit.
    (2) The Tcl command language.
    (3) A Motif-like widget set.
    (4) A simple windowing shell called "wish".
    (5) A few demo scripts for wish.
All of the Tk and Tcl stuff is public and free.  As far as I'm
concerned, you can do anything you want with it.  If you build
applications based on Tk I'd be interested to hear what they are
and how Tk helped or hindered your application(s).  If you decide
Tk is a piece of junk, I'd be interested to hear your reasons.

Overall, I'd rate this release as about beta-level in quality:  I
hope that the code is pretty stable, but I expect to get a lot of
feedback about missing or undesirable features.  There's a complete
set of manual entries but no tutorial-style introduction yet.  I hope
that you won't have too much trouble getting started with Tk if you've
had previous experience programming X11.

Some of you may have discovered various pre-release versions of
Tcl over the last few months.  The new release supercedes the
pre-release versions and contains a number of bug fixes plus a few
additional features such as the "wm" command for dealing with window
managers.

The release is available for public FTP from sprite.berkeley.edu
(Internet address 128.32.150.27).  To retrieve the release, use
anonymous FTP to sprite (user "anonymous", password "guest") and
retrieve the file "tk.tar.Z" with the following set of commands:
                type image (try "type binary" if this command is rejected)
                get tk.tar.Z
What you'll get is a compressed tar file;  to get back the original
directory hierarchy, type the commands
                uncompress tk.tar.Z
                tar xf tk.tar
This will create a tk subdirectory with all the source files and
documentation.  There will be a README file in the subdirectory that
tells how to compile Tk and gives some hints about how to get started
with Tk.

If you can't get access to the release via the Internet, send me e-mail
and I'll try to find some other way to get the release to you (e.g.
1/2" tape or Exabyte-style 8mm videocassette).

I've also set up a mailing list for people interested in exchanging
e-mail about Tcl and Tk.  If you're interested in joining the list,
let me know.
------------------------------------------------
To subscribe to the mailing list, send a request to
tcl-admin@sprite.berkeley.edu.

-- 
Mark Harrison           | Note: harrison@ssd.dl.nec.com and
harrison@csl.dl.nec.com | necssd!harrison are not operating at
(214)518-5050           | present.  Please forward mail through the
                        | above address.  Sorry for the inconvenience.

kend@data.UUCP (Ken Dickey) (05/24/91)

ajb@miles.WPI.EDU (Arthur J. Butler) writes:

>hi.  i am looking for advice and/or suggestions on an interpreter or
>macro language facility which i plan on adding to my application.  are
>there common languages which are used to add macro facilities to
>applications?  are there any PD/commercial lisp implementations
>available which would suffice?

You can get a number of Scheme interpreters written in C.  They range
from small ("scm") to huge (MIT Scheme).  What machines are you runing
on?

==========

You might look at "scm" initially, which is fairly minimal in size and
requires the least knowledge to hack. It has been widely ported (Mac,
PC, Suns, etc.).

	ftp altdorf.ai.mit.edu (anonymous)
	cd archive/scm


For Sun3/4 (and Vaxen?), "ELK" is pretty nice:

	Elk 1.2 is available on uunet.uu.net and I believe 
	on gatekeeper.dec.com.  You can also try to connect 
	to the `archie' server on say quiche.cs.mcgill.ca
	and search for "elk".


If you are going for 68K machines (Sun3, Next, Mac), you might take a
look at the "Gambit" compiler.  It has an interpreter and is linkable
with C binaries.:
	
	You can get a copy of Gambit (release 1.5) via 
	anonymous ftp from the machine acorn.cs.brandeis.edu 
	(address 129.64.3.8).  It is in the /dist directory 
	and is compressed (about 400K). 


-Ken Dickey			kend@data.uucp

martelli@cadlab.sublink.ORG (Alex Martelli) (05/24/91)

ajb@miles.WPI.EDU (Arthur J. Butler) writes:
:hi.  i am looking for advice and/or suggestions on an interpreter or
:macro language facility which i plan on adding to my application.  are

Try looking into tcl, the Tools Command Language by John Ousterhout
(ouster@allspice.berkeley.edu); it is designed exactly for what you
are thinking of.  A paper on it was presented at the Winter 1990 
Usenix conference; it is also widely available for anon ftp (sorry,
I'm not on the Internet so I don't recall where it can be had, but
the usual 'archie' service can tell you that).  At present there are
two slightly diverging branches of the tcl family: Tcl 4.something,
enhanced by 'hackercorp' (Peter da Silva, and others) with many
modular extensions such as associative arrays and regular expressions;
and Tcl 5.something, without those enhancements but integrated with
Tk into a rich X Window System-ready environment.  From the needs
you express, I believe you'd be most interested in Tcl 4.

Other possibilities are Rexx, a nice language chosen for a similar
purpose in IBM's SAA and also dominating this field for Amiga boxes,
but I don't think you can get it for free; and others I have just
heard mentioned, such as Python.  The 'others' cathegory includes
lots of Lisps and Schemes, but I guess you could get more details
on those in comp.lang.{lisp.scheme}.
-- 
Alex Martelli - CAD.LAB s.p.a., v. Stalingrado 53, Bologna, Italia
Email: (work:) martelli@cadlab.sublink.org, (home:) alex@am.sublink.org
Phone: (work:) ++39 (51) 371099, (home:) ++39 (51) 250434; 
Fax: ++39 (51) 366964 (work only), Fidonet: 332/407.314 (home only).

guido@cwi.nl (Guido van Rossum) (05/28/91)

ajb@miles.WPI.EDU (Arthur J. Butler) writes:

>hi.  i am looking for advice and/or suggestions on an interpreter or
>macro language facility which i plan on adding to my application. [...]

>	within this macro language, i need to at least to
>	a) be able to call functions within my program.
>	b) be able to use control and loop constructs.
>	c) define and use simple variables.

>my program will be written in C/C++ to be run in a UNIX workstation
>environment. [...]

This was one of the purposes why I developed Python.  Python is an
interpreted programming language with high-level data types (strings,
lists, associative arrays; everything unlimited in size and garbage
collected) and provides all the features you request.  It is also
object-oriented.  Its syntax is intended to be as clear as possible,
to allow a quick start for casual users.

Python is normally used as a stand-alone interpreter, but hooks are
provided to add Python as an extension language to existing
C applications.  I have no experience with hooking it up to C++
applications yet.  I do know that Python is written quite portably.

Python is freely available.  It is still under development; I hope to
distribute a new version this summer.  If you try to do unusual things
with it, I am eager to hear about your experiences, and willing to
help hacking the code (or to point out where to start hacking).

See the attached availability sheet.

--Guido van Rossum, CWI, Amsterdam <guido@cwi.nl>
"The life of a Repo Man is always intense"


Availability of Python and STDWIN
=================================

Python and STDWIN were posted to alt.sources around february 1991.
They should be available from sites that archive this newsgroup, such
as wuarchive.wustl.edu.  I also post patches to this group.
(I will post the entire source to comp.sources.misc when I think the
products are a little bit more finished.)

Python and STDWIN are available from a number of ftp sites.
The * in file names is the version number, e.g., 0.9.5 (the last digit
is the patch level).

Current version numbers are 0.9.1 for Python and 0.9.5 for STDWIN.


Site		hp4nl.nluug.nl (IP address 192.16.202.2)
For whom	users in the Netherlands and the rest of Europe
Note		the same archive is also accessible via mcsun.eu.net
Directory	pub/windows
	File	stdwin*.tar.Z
Directory	pub/programming/languages
	Files	python*.tar.Z
		pythondoc[12].ps.Z
Directory	pub/comp/mac/compiler
	File	Python.hqx


Site		wuarchive.wustl.edu (IP address 128.252.135.4)
For whom	users in North America
Directory	usenet/alt.sources
Note		Raw alt.sources archive, see README there.  Grep -i the
		Index file for "stdwin" or "python".

		
Site		gatekeeper.dec.com (IP address 16.1.0.2)
For whom	users in North America
Directory	pub/misc
	File	stdwin*.tar.Z
Directory	pub/misc/python
	Files	python*.tar.Z
		pythondoc[12].ps.Z
		Python.hqx.Z