home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.compilers
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!world!iecc!compilers-sender
- From: davis@pacific.mps.ohio-state.edu (John E. Davis)
- Subject: Re: Extension Languages
- Reply-To: davis@pacific.mps.ohio-state.edu (John E. Davis)
- Organization: Dept. of Physics, The Ohio State University
- Date: Mon, 14 Dec 1992 17:11:06 GMT
- Approved: compilers@iecc.cambridge.ma.us
- Message-ID: <92-12-062@comp.compilers>
- References: <92-12-056@comp.compilers>
- Keywords: design
- Sender: compilers-sender@iecc.cambridge.ma.us
- Lines: 53
-
- marks@iris.mincom.oz.au (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
- post-fix?
-
-
- 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
- internet: davis@amy.tch.harvard.edu
- bitnet: davis@ohstpy office: 617-735-6746
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-