home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / compiler / 2030 < prev    next >
Encoding:
Text File  |  1992-12-14  |  2.7 KB  |  68 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!world!iecc!compilers-sender
  3. From: davis@pacific.mps.ohio-state.edu  (John E. Davis)
  4. Subject: Re: Extension Languages
  5. Reply-To: davis@pacific.mps.ohio-state.edu  (John E. Davis)
  6. Organization: Dept. of Physics, The Ohio State University
  7. Date: Mon, 14 Dec 1992 17:11:06 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <92-12-062@comp.compilers>
  10. References: <92-12-056@comp.compilers>
  11. Keywords: design
  12. Sender: compilers-sender@iecc.cambridge.ma.us
  13. Lines: 53
  14.  
  15. marks@iris.mincom.oz.au (Mark Stavar) writes: 
  16.    IS there any specific reason why one would choose to utilise an prefix
  17.    notation language for extensions to an editor as opposed to infix or
  18.    post-fix? 
  19.  
  20.  
  21. For my JED editor, I invented a language which I call S-Lang or
  22. ``Ssslang''.  It is stack based and resembles postscript in many ways.
  23. However unlike other stack based languages, it supports local variables
  24. which tremendously simply taking care of the stack.  However, this is not
  25. just an editor language--- rather it is a language embedded into the
  26. editor.  I am currently writing a program which utilizes a frame grabber
  27. and I have embedded the languge in it as well.  So for example, suppose I
  28. have a C function called `draw' which takes 4 integers and draws a line
  29. between two points and returns nothing.  Then to embed this function in
  30. the language, simply put:
  31.  
  32. add_intrinsic("line", draw, VOID_TYPE, 4);
  33.  
  34. in your C program.  Then you can call the function from within Slang:
  35.  
  36. 1 1 10 10 line  ;; draws a line between points (1,1) and (10,10)
  37.  
  38. Then you can create a function called `box':
  39.  
  40. ( [x1 y1 x2 y2]        ;; local variables
  41.   =y2 =x2 =y1 =x1
  42.  
  43.   x1 y1 x1 y2 line
  44.   x1 y2 x2 y2 line
  45.   x2 y2 x2 y1 line
  46.   x2 y1 x1 y1 line
  47. ) box
  48.  
  49. Then `1 2 10 12 box' will draw a box with two corners at (1,2) and
  50. (10,12).  I think that you can see how such a program adds a new dimension
  51. to a program with a C function called draw.  In addition, think about how
  52. you would have to write the box function with NO local variables using
  53. stack operators `dup', `exch', `roll', etc....
  54.  
  55. The reason I chose a stack based language is easy: The parsing stage is
  56. simple.  I did not want most of the executable devoted to the language.
  57.  
  58. I will release Slang as a standalone product soon.  Of course it is not
  59. really standalone because it needs to be embedded into you application.
  60. Look at my JED sources (in ledit.c) to see how Slang is embedded.
  61. --
  62. John E. Davis
  63. internet: davis@amy.tch.harvard.edu
  64. bitnet: davis@ohstpy   office: 617-735-6746
  65. -- 
  66. Send compilers articles to compilers@iecc.cambridge.ma.us or
  67. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  68.