Re: Extension Languages (John E. Davis)
Mon, 14 Dec 1992 17:11:06 GMT

          From comp.compilers

Related articles
Extension Languages (1992-12-14)
Re: Extension Languages xjam@cork.CS.Berkeley.EDU (1992-12-14)
Re: Extension Languages (1992-12-14)
Re: Extension Languages (Dave Gillespie) (1992-12-15)
Re: Extension Languages (1992-12-16)
Re: Extension Languages (1992-12-17)
Re: Extension Languages (Peter Ludemann) (1992-12-17)
Re: Extension Languages (1992-12-18)
Re: Extension Languages (Dave Gillespie) (1992-12-19)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (John E. Davis)
Organization: Dept. of Physics, The Ohio State University
Date: Mon, 14 Dec 1992 17:11:06 GMT
References: 92-12-056
Keywords: design (Mark Stavar) writes:
      IS there any specific reason why one would choose to utilise an prefix
      notation language for extensions to an editor as opposed to infix or

For my JED editor, I invented a language which I call S-Lang or
``Ssslang''. It is stack based and resembles postscript in many ways.
However unlike other stack based languages, it supports local variables
which tremendously simply taking care of the stack. However, this is not
just an editor language--- rather it is a language embedded into the
editor. I am currently writing a program which utilizes a frame grabber
and I have embedded the languge in it as well. So for example, suppose I
have a C function called `draw' which takes 4 integers and draws a line
between two points and returns nothing. Then to embed this function in
the language, simply put:

add_intrinsic("line", draw, VOID_TYPE, 4);

in your C program. Then you can call the function from within Slang:

1 1 10 10 line ;; draws a line between points (1,1) and (10,10)

Then you can create a function called `box':

( [x1 y1 x2 y2] ;; local variables
    =y2 =x2 =y1 =x1

    x1 y1 x1 y2 line
    x1 y2 x2 y2 line
    x2 y2 x2 y1 line
    x2 y1 x1 y1 line
) box

Then `1 2 10 12 box' will draw a box with two corners at (1,2) and
(10,12). I think that you can see how such a program adds a new dimension
to a program with a C function called draw. In addition, think about how
you would have to write the box function with NO local variables using
stack operators `dup', `exch', `roll', etc....

The reason I chose a stack based language is easy: The parsing stage is
simple. I did not want most of the executable devoted to the language.

I will release Slang as a standalone product soon. Of course it is not
really standalone because it needs to be embedded into you application.
Look at my JED sources (in ledit.c) to see how Slang is embedded.
John E. Davis
bitnet: davis@ohstpy office: 617-735-6746

Post a followup to this message

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