home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8708 / 30 < prev    next >
Encoding:
Internet Message Format  |  1990-07-13  |  50.1 KB

  1. From: dietz@zhmti.UUCP (Dieter H. Zebbedies)
  2. Newsgroups: comp.sources.misc
  3. Subject: "Producer" translates Smalltalk to Objective-C (Part 1 of 5)
  4. Message-ID: <4217@ncoast.UUCP>
  5. Date: 20 Aug 87 01:54:37 GMT
  6. Sender: allbery@ncoast.UUCP
  7. Organization: Zebb-Hoff Machine Tool Inc's Automated Mfg. Project, Cleve., OH
  8. Lines: 1162
  9. Approved: allbery@ncoast.UUCP
  10. X-Archive: comp.sources.misc/8708/30
  11.  
  12. "Producer", A package to translate Smalltalk-80 code to your favorite
  13. object oriented language, Objective-C.
  14.  
  15. #!/bin/sh
  16. # to extract, remove the header and type "sh filename"
  17. if `test ! -s ./Makefile`
  18. then
  19. echo "writting ./Makefile"
  20. cat > ./Makefile << '\Rogue\Monster\'
  21. DOC= README producer.f
  22. .SUFFIXES: .me .i .f
  23. all: README
  24. README: readme.f    ; mv readme.f README
  25. .me.i:        ; itroff -me mac.me $<
  26. .me.f:        ; nroff -me mac.me $< >$$$$.f && mv $$$$.f $*.f
  27. \Rogue\Monster\
  28. else
  29.   echo "will not over write ./Makefile"
  30. fi
  31. if `test ! -s ./mac.me`
  32. then
  33. echo "writting ./mac.me"
  34. cat > ./mac.me << '\Rogue\Monster\'
  35. .\" Must be defined externally
  36. .\" \nN        Chapter Number
  37. .po .5i
  38. .ll 7i
  39. .nr % 1
  40. .ds NM \\nN
  41. .de H
  42. .    tm .H0 \\*(NM-\\n% "\\$1"
  43. .    sp
  44. .(l C
  45. \\s12\\fB\\$1\\fP\\s0
  46. .)l
  47. .    pp
  48. ..
  49. .de H1
  50. .    tm .H1 \\*(NM-\\n% "\\$1"
  51. .    uh "\\$1"
  52. .    pp
  53. ..
  54. .de H2
  55. .    tm .H2 \\*(NM-\\n% "\\$1"
  56. .    uh "\\$1"
  57. ..
  58. .de M
  59. .    tm .M \\*(NM-\\n% "\\$1"
  60. .    uh "\\$1"
  61. ..
  62. .de MC
  63. .    tm .MC \\*(NM-\\n% "\\$1"
  64. .    uh "\\$1"
  65. ..
  66. .de (C
  67. .    (l
  68. .    sz -2n
  69. .    ls 1
  70. .    ta .25i +.25i +.25i +.25i +.25i +.25i +.25i +.25i +.25i +.25i +.25i +.25i
  71. ..
  72. .de )C
  73. .    ta
  74. .    ls 2
  75. .    sz
  76. .    )l
  77. ..
  78. .nr fn 1
  79. .ds F \*(NM-1
  80. .de (F
  81. .    ds F \\*(NM-\\n(fn
  82. .    tm .F \\*(NM-\\n% "Figure \\*F: \\$1"
  83. .    (l M F
  84. .    hl
  85. .    sp
  86. .    ce
  87. \fIFigure \\*F:\fP \\$1
  88. ..
  89. .de )F
  90. .    hl
  91. .    )l
  92. .    nr fn +1
  93. .    ds F \\*(NM-\\n(fn
  94. ..
  95. .de (N
  96. .    (q
  97. \\fINOTE IN DRAFT: \\$1\\fP
  98. ..
  99. .de )N
  100. .    )q
  101. ..
  102. .de NT
  103. .    (q
  104. \\fINOTE IN DRAFT: \\$1\\fP
  105. .    )q
  106. .    tm .NT \\*(NM-\\n% "NOTE: \\$1"
  107. ..
  108. .de C
  109. .nr N \\$1
  110. .ds NA \\$1
  111. .he ''\\*(NA''
  112. .fo 'Brad Cox'%'\\*(td'
  113. .(l C
  114. \\s14\\fB\\$2\\fP\\s0
  115. .sp 2
  116. .)l
  117. .he ''\\*(NA''
  118. .tm .C \\nN-\\n% "\\$2"
  119. .pp
  120. ..
  121. \Rogue\Monster\
  122. else
  123.   echo "will not over write ./mac.me"
  124. fi
  125. if `test ! -s ./README`
  126. then
  127. echo "writting ./README"
  128. cat > ./README << '\Rogue\Monster\'
  129.  
  130.  
  131.  
  132.  
  133.                 Producer: Smalltalk-80 to Objective-C Translator
  134.  
  135.  
  136.                                   Brad J. Cox
  137.                       Productivity Products International
  138.                                   75 Glen Road
  139.                               Sandy Hook, CT 06482
  140.                                 (203) 426 1875.
  141.  
  142.  
  143.           Smalltalk-80 is a tool for  turning  raw  concepts  into  working
  144.      software prototypes. Objective-C is a tool for turning proven concepts
  145.      into fast, commercial-quality, production systems. Producer is a  tool
  146.      for  bridging  the gap between prototyping and production by automati-
  147.      cally translating Smalltalk-80 sources into Objective-C  sources.  The
  148.      translation is guided by a rule base in which the programmer describes
  149.      how differences between the Smalltalk-80 prototyping  environment  and
  150.      the   Objective-C  production  environment  should  be  resolved  when
  151.      translating the code.
  152.  
  153.           At SIGGRAPH-87, PPI will announce a  library  of  user  interface
  154.      components  from which programmers build applications with iconic user
  155.      interfaces.  The library and applications built using it are  portable
  156.      across  diverse  window  systems,  initially X-Windows, SunWindows and
  157.      Hewlett Packard's window system. While the Objective-C user  interface
  158.      classes  are  different from Smalltalk's, they are similar enough that
  159.      Producer can usually bridge the differences with some  hand-tuning  of
  160.      the  translated  output.   We  confidently hope that Objective-C, this
  161.      library and Producer will make automatic translation  of  Smalltalk-80
  162.      prototypes  a  routine  part  of  many companies' software development
  163.      lifecycle.
  164.  
  165.           I'm distributing Producer to enlist  your  help  in  testing  the
  166.      practicality of this notion.
  167.  
  168.  
  169.  
  170.                                    Disclaimer
  171.  
  172.  
  173.           Producer is not a mature software  product  but  an  embryo  that
  174.      could  grow  to maturity someday.  Specifically it is not supported or
  175.      warranteed in any  way.  It  was  written  by  myself,  an  individual
  176.      employed  by PPI, and has been released prior to maturity by myself as
  177.      an individual with the consent of the  company.   This  document  will
  178.      make its strengths and some of its present shortcomings clear.
  179.  
  180.           However, even in its present state,  Producer  demonstrates  that
  181.      automatic  translation  is technically feasible and its present imple-
  182.      mentation provides a capable foundation on which to build.  Since  the
  183.      market  for Smalltalk-80 translators is insufficient for PPI to pursue
  184.      presently, we've released Producer for you to make what use of it  you
  185.      can.
  186.  
  187.           I do ask that you keep me informed of your experiences  in  using
  188.      it  in  its  current  state,  and  PPI requests that you feed back any
  189.  
  190.  
  191.      Brad Cox                          1                      June 22, 1987
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.                 Producer: Smalltalk-80 to Objective-C Translator
  200.  
  201.  
  202.      improvements so that we can offer a fully supported  translation  pro-
  203.      duct in the future. PPI retains the copyright and all other applicable
  204.      rights. For example, you may not sell products that contain  any  part
  205.      of the Producer distribution without PPI's permission.
  206.  
  207.  
  208.  
  209.                                   How it works
  210.  
  211.  
  212.           The following is a brief description of how Producer works inter-
  213.      nally.   This  was written from my recollection of how I left the code
  214.      over a year ago. It may be inaccurate in places.
  215.  
  216.           Producer is basically a compiler. It's lexical analyzer  (written
  217.      in  lex) divides Smalltalk-80 text into lexemes, and its parser (writ-
  218.      ten in yacc) recognizes  valid  lexeme  sequences  and  constructs  an
  219.      abstract  representation  of  the  program  as an expression tree. The
  220.      expression tree consists of instances  of  Objective-C  classes;  e.g.
  221.      Method,  Statement, Expression, Message, and Variable. The grammar was
  222.      derived from the syntax diagrams in Goldberg and Robson; _S_m_a_l_l_t_a_l_k-_8_0:
  223.      _T_h_e _L_a_n_g_u_a_g_e _a_n_d _i_t_s _I_m_p_l_e_m_e_n_t_a_t_i_o_n; Addison Wesley; 1986.
  224.  
  225.           The grammar was extended to also recognize rules  that  may  also
  226.      appear  in the lexeme stream. Rules are enclosed in { braces } to help
  227.      fend off shift-reduce conflicts from yacc. The parser stores the rules
  228.      in separate data structures for use during code generation.
  229.  
  230.           At certain points, the parser sends the  top  of  the  expression
  231.      tree  a  gen  message  to  trigger  code  generation[1].  Recall  that
  232.      Smalltalk-80 is an extremely simple language with basically  two  com-
  233.      ponents;  data  references  (variables,  literals,  etc) and messages.
  234.      Rules may influence how each case is treated during code generation.
  235.  
  236.           Code generation proceeds in two passes. The first  pass  collects
  237.      typing  information  for  each  symbol  and  message  by examining the
  238.      expression tree from the bottom up. The bottom-most nodes  are  either
  239.      literals whose type is immediately obvious (e.g. 1, 2.3, or 'string'),
  240.      or they are symbols whose type can be known or unknown.  Symbol  types
  241.      ____________________
  242. 9        [1] I now regard this as a major architectural flaw whenever I  see
  243.      it in any application. It represents a key departure from an important
  244.      but often ignored rule of object-oriented design.  The expression tree
  245.      classes  should  be  abstract  so  that  they could be reused in other
  246.      tools. But their code generation methods pollute the abstraction  with
  247.      knowledge about a particular concrete interface; Objective-C. The code
  248.      generation methods should have been provided in a  separate  hierarchy
  249.      of  classes  that  know  how to connect the abstract classes to one of
  250.      many potential concrete interfaces. This rule is simply a  generaliza-
  251.      tion  of  the model/view/controller paradigm to apply to interfaces of
  252.      any kind, not just user interfaces.
  253.  
  254.  
  255.  
  256. 9     Brad Cox                          2                      June 22, 1987
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.                 Producer: Smalltalk-80 to Objective-C Translator
  265.  
  266.  
  267.      become known either as the  result  of  a  previous  type  inferencing
  268.      operation  or because their type was specified in a rule. Unknown sym-
  269.      bols default to id when first referenced.
  270.  
  271.           Most of the internal  nodes  are  messages.   Message  typing  is
  272.      slightly more complicated because any message can have multiple trans-
  273.      lations depending on how the message is used because  different  rules
  274.      may  specify  different  translations for different receiver and argu-
  275.      ments types. The diverse translations may  each  compute  a  different
  276.      type.  Since  we  assign types bottom up, types have been assigned for
  277.      the arguments and the receiver, so a translation for that selector  is
  278.      chosen  by searching a table of possible translations for one matching
  279.      the receiver and argument types.
  280.  
  281.           In all cases, unless  overridden  by  a  specific  rule,  default
  282.      translations  are  used.  These amount to a fairly literal translation
  283.      from Smalltalk-80 syntax to Objective-C syntax. However exceptions are
  284.      made  for  Smalltalk  literal  constants, which translate to C literal
  285.      constants. In other words, 2+2 translates  to  [2  plus:2],  which  is
  286.      _g_u_a_r_a_n_t_e_e_d  to  fail catastrophically in Objective-C. The integer 2 is
  287.      an object only in Smalltalk!
  288.  
  289.           The moral:  _N_e_v_e_r  believe  the  translator.  _A_l_w_a_y_s  monitor  it
  290.      closely. Remember the 90-10 rule. The automatic translation concept is
  291.      capable, with suitable rules, of automatically translating only 90% of
  292.      an  application  correctly;  the  other  10% (where the bugs will have
  293.      congregated) is still up to you.
  294.  
  295.  
  296.  
  297.                              Implementation Status
  298.  
  299.  
  300.           Producer currently represents about three  man-weeks  of  effort,
  301.      spent  in  two  intensive  bursts  separated by about a year. The most
  302.      recent burst was nearly a year and a half ago.  The first burst was to
  303.      demonstrate  the  feasibility and practicality of the translation con-
  304.      cept. The second burst was in the course of preparing  a  paper  that,
  305.      coauthored  with Kurt Schmucker, will appear in the OOPSLA-87 proceed-
  306.      ings. A (very) early draft is provided with this distribution.
  307.  
  308.           For being developed so quickly, the translator does an  effective
  309.      job  of  translation.  I refer you to the paper for discussions of the
  310.      strengths and limitations of the translation  concept.   This  section
  311.      discusses  the current implementation of this concept, the items on my
  312.      own must-do list for the planned, but not yet completed,  third  stage
  313.      of Producer's evolution.
  314.  
  315.      (1)  Smalltalk-80 fileout format uses '!' delimiters in a fashion that
  316.           I  was never able to formalize correctly in Producer's yacc gram-
  317.           mar. The symptom is that  the  translator  will  generate  syntax
  318.           errors  in nearly every translated file for certain of these del-
  319.           imiters. I'm told that fileout format has been  documented  in  a
  320.  
  321.  
  322.      Brad Cox                          3                      June 22, 1987
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.                 Producer: Smalltalk-80 to Objective-C Translator
  331.  
  332.  
  333.           paper  somewhere, but I've never worked the repairs back into the
  334.           code. The fix should be local to gram.y.
  335.  
  336.      (2)  The translator loads its rule base by reading files of  rules  as
  337.           if  they were concatenated with the sources to be translated. The
  338.           rule-specification syntax is abysmal, primarily  because  it  was
  339.           chosen  to  minimize  the  amount of time I spent struggling with
  340.           shift-reduce conflicts from yacc, rather than  making  the  rules
  341.           intelligible  to  users. Smalltalk's formal grammar seemed unrea-
  342.           sonably difficult for yacc to swallow, and I suspect the  problem
  343.           may  lie  in  some  mistake I've made in translating Smalltalk-80
  344.           syntax diagrams into yacc specifications.
  345.  
  346.      (3)  The program contains extensive provisions for reporting its cogi-
  347.           tations in type inferencing. The various error, warning, logging,
  348.           and debugging messages need to be tuned for greater utility.
  349.  
  350.      (4)  The code was based on an as yet unreleased libary (phylum) called
  351.           "Substrate",  which  supports  features  that  are not yet in our
  352.           standard product set, like  Blocks,  Coroutining,  and  exception
  353.           handling.   I made a fast editing pass to remove any dependencies
  354.           on these nonstandard library  features.  I  also  added  a  file,
  355.           Substrate.h,  that defines stylistic conventions that I adhere to
  356.           in all my work. See USE, IMPORT, EXPORT, etc in the sources.
  357.  
  358.           The preceeding problems are superficial and easily repaired.  The
  359.      following  ones  are  somewhat  more  substantial in that they involve
  360.      design work in addition to coding work.
  361.  
  362.      (1)  The type inferencing machinery infers types of  newly-encountered
  363.           (unknown)  messages and variables by seeing how they are combined
  364.           with variables and messages whose types are known apriori or else
  365.           determined  earlier through inferencing.  The only types that are
  366.           known apriori are literals like 1, 2.3, or  'string'.  This  gen-
  367.           erally  provides  insufficient  typing  information from which to
  368.           infer anything useful, so you should generally  provide  variable
  369.           rules  to  pin  down  types for key instance variables and method
  370.           arguments You do this with rules that state, in effect, that `the
  371.           type of the Smalltalk variable named foo is int, and the variable
  372.           is called foobar in Objective-C'.  Presently  rules  have  global
  373.           scope.  If different Smalltalk classes use the name, foo, in ways
  374.           that should be translated differently, different rule  sets  must
  375.           be  provided  manually  to  the translator. Creating and managing
  376.           these application-specific rules sets  adds  to  the  translation
  377.           effort  and tends to make rules non-reusable across translations.
  378.           The rules should be organized with a scoping  mechanism,  ideally
  379.           one based on inheritance.
  380.  
  381.      (2)  The inferencing logic is ad-hoc and quite possibly slow.  However
  382.           the  main  bottleneck seems to be loading the rule-base; transla-
  383.           tion  speed  has  never  been  a  real  problem.  Inferencing  is
  384.           presently  deductive,  and  a more inductive scheme based on both
  385.           forwards and backwards reasoning  might  produce  higher  quality
  386.  
  387.  
  388.      Brad Cox                          4                      June 22, 1987
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.                 Producer: Smalltalk-80 to Objective-C Translator
  397.  
  398.  
  399.           translations.  In other words, the translation of a given message
  400.           expression is determined exclusively by whatever information  can
  401.           be inferred about the types of the receiver and arguments to that
  402.           message (forward reasoning). Backward reasoning would  also  con-
  403.           sider how the results of the expression are used in other expres-
  404.           sions.
  405.  
  406.      (3)  Producer does not presently handle  non-trivial  uses  of  Blocks
  407.           correctly;  ie.   Block  expressions  that  cannot  be translated
  408.           directly into C conditional expressions like if, while,  or  for,
  409.           which Producer handles just fine already.  Nearly all occurrences
  410.           of Smalltalk-80 Blocks could  be  handled  without  changing  the
  411.           Objective-C  language by adding a trivially simple Block class to
  412.           the library. A named instance  variable  holds  a  pointer  to  a
  413.           static function and indexed instance variables hold _c_o_p_i_e_s _o_f any
  414.           variables that the block accesses in the  instantiation  site[2].
  415.           This  copy  could  be taken entirely automatically by copying the
  416.           instantiation site's stack frame.  However I prefer to have  more
  417.           control  over  space  than that. So I've been using a scheme that
  418.           requires the programmer (and someday  the  compiler)  to  specify
  419.           which  variables are really accessed by the block as arguments to
  420.           the message that instantiates the block; like this
  421.  
  422.                ... {
  423.                 IMPORT void aStaticFunction();
  424.                   id var1 = something, var2 = something;
  425.                 aBlock = [Block function:aStaticFunction args:2, var1, var2];
  426.                 [anyObject do:aBlock];
  427.                 ...
  428.                }
  429.                LOCAL void aStaticFunction(instantiationSiteVariables, value1, value2)
  430.                 struct { id var1, var2; } *instantiationSiteVariables;
  431.                 id value1, value2;
  432.                {
  433.                 if ([instantiationSiteVariables->var1 someMessage])
  434.                   ...
  435.                }
  436.  
  437.  
  438.           The block will call the function when anyObject sends  the  block
  439.           one  of  several  evaluation  messages  (value:arg1 or value:arg1
  440.           value:arg2 or ...). The first argument is a  _p_o_i_n_t_e_r  to  block's
  441.           copy  of  the  instantiation site's variables. The trailing argu-
  442.           ments contain the arguments that the invocation  site  passed  in
  443.           the value: message.  I've used this approach extensively by writ-
  444.           ing the static functions by hand, and am trying to get our  staff
  445.           to  extend  the  language  to provide some kind of language-level
  446.           support to make the syntax simpler.  This approach could be,  but
  447.           has not yet been, taken by Producer.
  448.      ____________________
  449. 9        [2] In Smalltalk-80, the block seems to have access to the  instan-
  450.      tiation  site's  variables,  so that the block can change variables in
  451.  
  452.  
  453. 9     Brad Cox                          5                      June 22, 1987
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.                 Producer: Smalltalk-80 to Objective-C Translator
  462.  
  463.  
  464.           The inferencing machinery's primary current virtue is that it can
  465.      be made to work for selected test cases. It leaves lots to be desired.
  466.      Call me if you decide to extend it so that I can  prevent  unnecessary
  467.      duplication of effort.
  468.  
  469.  
  470.  
  471.                              About the distribution
  472.  
  473.  
  474.           The top level of the distribution consists of
  475.  
  476.          total 88
  477.          -rw-r--r--  1 cox           181 Jun 22 14:32 Makefile
  478.          -rw-r--r--  1 cox         26592 Jun 22 14:30 README
  479.          drwxr-xr-x  2 cox           512 Jun 22 14:19 example
  480.          -rw-r--r--  1 cox           166 Jun 16 13:18 log
  481.          -rw-r--r--  1 cox           997 Jun 15 11:09 mac.me
  482.          -rw-r--r--  1 cox         26751 Jun 15 11:02 producer.me
  483.          -rw-r--r--  1 cox         21444 Jun 22 14:29 readme.me
  484.          drwxr-xr-x  2 cox           512 Jun 12 10:22 rules
  485.          drwxr-xr-x  2 cox          3072 Jun 22 14:31 src
  486.  
  487.      The Makefile governs formatting of  the  two  documents;  this  README
  488.      (from   readme.me)   and  the  draft  of  the  OOPSLA-87  paper  (from
  489.      Producer.me). The mac.me file contains text formatting macros that are
  490.      common to both papers; used like this:
  491.  
  492.          nroff -me mac.me Producer.me >Producer.f
  493.  
  494.  
  495.           The rules directory contains  a  single  file,  generic.ru,  that
  496.      represents a first pass at an application-independent rules base. This
  497.      set of rules translate Smalltalk to the conventions used in my  proto-
  498.      type version of the user interface library.
  499.  
  500.           For example, it translates Smalltalk Integer operations to C  int
  501.      operations,  and  it translates Smalltalk Point operations to C macros
  502.      that manage points as type PT; a pair of 16-bit coordinates in  a  32-
  503.      bit  C  int.   For  example,  pt(x,y) invokes a C macro that trims and
  504.      shifts two ints, x and y, to fit side by side  in  a  32-bit  integer,
  505.      ptPlus(p,q)  invokes  a  macro  that  computes  the  vector sum of two
  506.      points, p and q, etc.
  507.  
  508.          rules:
  509.          total 35
  510.      ____________________
  511. 9     the instantiation site. In Objective-C the block receives  a  copy  of
  512.      the  variables  and cannot use them to communicate with the instantia-
  513.      tion site. I believe that  this  is  the  sole  functional  difference
  514.      between the two schemes.
  515.  
  516.  
  517.  
  518. 9     Brad Cox                          6                      June 22, 1987
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.                 Producer: Smalltalk-80 to Objective-C Translator
  527.  
  528.  
  529.          -rw-r--r--  1 cox         35567 Jun 12 10:22 generic.ru
  530.  
  531.  
  532.           The src directory contains a fragment from  the  video  animation
  533.      program  that  appears  at  the  end  of  the Smalltalk-80 video tape.
  534.      BounceInBoxNode.st is the Smalltalk-80 source file, animation.ru  con-
  535.      tains  the  application-specific  rule  set,  BounceInBoxNode.m is the
  536.      translated version built by Producer as invoked by Makefile[3].
  537.  
  538.          example:
  539.          total 7
  540.          -rw-r--r--  1 cox          1730 Jun 16 10:24 BounceInBoxNode.m
  541.          -rw-r--r--  1 cox           868 Jun 16 10:18 BounceInBoxNode.st
  542.          -rw-r--r--  1 cox           394 Jun 16 10:20 Makefile
  543.          -rw-r--r--  1 cox          2178 Jun 16 10:18 animation.ru
  544.          -rw-r--r--  1 cox           185 Jun 16 10:24 log
  545.          -rw-r--r--  1 cox           239 Jun 16 10:18 st80.h
  546.  
  547.  
  548.           The log file records the results of the translation session.  The
  549.      syntax  error  is innocuous, the result of the beforementioned problem
  550.      in the grammar in handling '!' delimiters.
  551.  
  552.          Producer -c ../rules/generic.ru animation.ru BounceInBoxNode.st >BounceInBoxNode.m
  553.          error 7:BounceInBoxNode.st: tegory:'Graphics-Animation'!! : syntax error
  554.          *** Error code 1 (ignored)
  555.  
  556.  
  557.           The src directory contains the sources for Producer, with its own
  558.      Makefile.    The  Substrate.h  header  file,  which  is  automatically
  559.      included by the Producer.h header file, is technically  a  part  of  a
  560.      internal  lower level library, Substrate, on which Producer was origi-
  561.      nally developed. Substrate.h was copied and changed  superficially  so
  562.      that Producer compiles correctly without the Substrate library.
  563.  
  564.          src:
  565.          total 70
  566.          -rw-r--r--  1 cox           483 Jun 12 10:21 AbstractTranslation.m
  567.          -rw-r--r--  1 cox           282 Jun 12 10:21 ArgumentList.m
  568.          -rw-r--r--  1 cox           897 Jun 12 10:21 Block.m
  569.          -rw-r--r--  1 cox           143 Jun 12 10:21 CharConstant.m
  570.          -rw-r--r--  1 cox          2205 Jun 12 10:21 Class.m
  571.          -rw-r--r--  1 cox           630 Jun 12 10:21 Comment.m
  572.          -rw-r--r--  1 cox           176 Jun 12 10:21 Constant.m
  573.          -rw-r--r--  1 cox          2032 Jun 12 10:21 Expr.m
  574.          -rw-r--r--  1 cox          1243 Jun 12 10:21 FunctionTranslation.m
  575.          -rw-r--r--  1 cox          1484 Jun 12 10:21 Identifier.m
  576.          -rw-r--r--  1 cox          1248 Jun 12 10:21 IdentifierTranslation.m
  577.      ____________________
  578. 9        [3] The full source for the animation program is not  provided.  My
  579.      copyright paranoia argued against providing even this fragment.
  580.  
  581.  
  582.  
  583. 9     Brad Cox                          7                      June 22, 1987
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.                 Producer: Smalltalk-80 to Objective-C Translator
  592.  
  593.  
  594.          -rw-r--r--  1 cox           105 Jun 12 10:21 List.m
  595.          -rw-r--r--  1 cox          1985 Jun 15 11:55 METHODDECLS.m
  596.          -rw-r--r--  1 cox          1384 Jun 15 11:51 Makefile
  597.          -rw-r--r--  1 cox          4302 Jun 12 10:21 Method.m
  598.          -rw-r--r--  1 cox          3136 Jun 12 10:21 Msg.m
  599.          -rw-r--r--  1 cox           583 Jun 12 10:21 MsgArgPattern.m
  600.          -rw-r--r--  1 cox           828 Jun 12 10:21 MsgNamePattern.m
  601.          -rw-r--r--  1 cox          1280 Jun 12 10:21 MsgTranslation.m
  602.          -rw-r--r--  1 cox           775 Jun 12 10:21 MsgTranslator.m
  603.          -rw-r--r--  1 cox          1868 Jun 12 10:21 Node.m
  604.          -rw-r--r--  1 cox           229 Jun 12 10:21 NumberConstant.m
  605.          -rw-r--r--  1 cox          1402 Jun 15 11:27 Producer.h
  606.          -rw-r--r--  1 cox           306 Jun 12 10:21 Return.m
  607.          -rw-r--r--  1 cox           825 Jun 12 10:21 Scope.m
  608.          -rw-r--r--  1 cox          3157 Jun 12 10:21 Selector.m
  609.          -rw-r--r--  1 cox           253 Jun 12 10:21 SelectorConstant.m
  610.          -rw-r--r--  1 cox           457 Jun 12 10:21 StArray.m
  611.          -rw-r--r--  1 cox           492 Jun 12 10:21 Stmt.m
  612.          -rw-r--r--  1 cox           381 Jun 12 10:21 StringConstant.m
  613.          -rw-r--r--  1 cox          1268 Jun 12 10:21 StringTranslation.m
  614.          -rw-r--r--  1 cox          2140 Jun 15 11:38 Substrate.h
  615.          -rw-r--r--  1 cox          1405 Jun 15 11:53 Symbol.m
  616.          -rw-r--r--  1 cox           452 Jun 12 10:21 Template.m
  617.          -rw-r--r--  1 cox           901 Jun 12 10:21 Type.m
  618.          -rw-r--r--  1 cox          1800 Jun 12 10:21 design.me
  619.          -rw-r--r--  1 cox          3271 Jun 12 10:21 gen.m
  620.          -rw-r--r--  1 cox          9007 Jun 12 10:21 gram.y
  621.          -rw-r--r--  1 cox          3601 Jun 12 10:21 lex.l
  622.          -rw-r--r--  1 cox          2212 Jun 12 10:21 main.m
  623.          -rw-r--r--  1 cox           260 Jun 12 10:21 st80.h
  624.          -rw-r--r--  1 cox           259 Jun 15 11:59 y.tab.h
  625.  
  626.  
  627.           The files are exactly as I left them nearly a  year  and  a  half
  628.      ago, except for:
  629.  
  630.      (1)  The addition of this README  document.  An  early  draft  of  the
  631.           OOPSLA-87 paper, sadly prior to Kurt Schmucker's improvements, is
  632.           in Producer.me.
  633.  
  634.      (2)  One recompilation pass to remove any obvious dependencies  on  my
  635.           private  Substrate  library  and to verify that Producer compiles
  636.           and runs correctly on the standard Foundation library.  I  tested
  637.           the  changes  by verifing that the Makefile in the example direc-
  638.           tory ran to completion, but this is hardly an ironclad guarantee.
  639.  
  640.  
  641.  
  642.                                    Using Producer
  643.  
  644.  
  645.           Flags controlling the  translation  process,  source  files,  and
  646.      rules  files are provided on the command line and are processed in the
  647.  
  648.  
  649.      Brad Cox                          8                      June 22, 1987
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.                 Producer: Smalltalk-80 to Objective-C Translator
  658.  
  659.  
  660.      order they appear.  The flags are[4]
  661.  
  662.      -d:  Enable debugging functions (dbg()) scattered throughout the code.
  663.           Seldom useful.
  664.  
  665.      -m:  Enables  the  Objective-C  Foundation  library  message   tracing
  666.           feature. Seldom useful in Producer.
  667.  
  668.      -a:  Enables the Objective-C  Foundation  library  allocation  tracing
  669.           feature. Seldom useful in Producer.
  670.  
  671.      -l:  Enables printing of each lexical token as produced by lex. Useful
  672.           only for debugging lex.l.
  673.  
  674.      -g:  Enables automatic redirection of each class into a separate  file
  675.           based on the class name parsed from the input file. Automatically
  676.           puts class Foobar into file Foobar.m.
  677.  
  678.               CAREFUL! This puts at risk other files whose  name  might
  679.               coincide with a Smalltalk-80 class name!
  680.  
  681.  
  682.      -s:  Generate Smalltalk-80 sources in the output file  as  Objective-C
  683.           comments (the default).
  684.  
  685.      -c:  Don't generate Smalltalk-80 sources in the output file.
  686.  
  687.      -i:  Generate information that was thought at one time  to  be  useful
  688.           when debugging rules.
  689.  
  690.      -M:  Send storeOn: to the message rule  dictionary  just  before  ter-
  691.           minating as a debugging aid.
  692.  
  693.      -I:  Send storeOn: to the variable rule dictionary  just  before  ter-
  694.           minating as a debugging aid.
  695.  
  696.           Typically, the generic rules  in  rules/generic.ru  is  specified
  697.      first, then any application-specific rules, then a single Smalltalk-80
  698.      source file.  Unless -g is  set,  the  translated  output  appears  on
  699.      stdout.  The  various  creaks, groans and mumbles that can be elicited
  700.      about the translation process itself appear on stderr.
  701.  
  702.           For the syntax for writing new rules, refer to  the  examples  in
  703.      generic.ru  and  animation.ru,  and if necessary, the rules section of
  704.      the grammar in gram.y.
  705.  
  706.           And good luck! Let me know how you fare...
  707.  
  708.      ____________________
  709. 9        [4] I'm working from memory about what these flags mean.  Some  may
  710.      be nonfunctional:
  711.  
  712.  
  713.  
  714. 9     Brad Cox                          9                      June 22, 1987
  715.  
  716.  
  717.  
  718. \Rogue\Monster\
  719. else
  720.   echo "will not over write ./README"
  721. fi
  722. if `test ! -s ./readme.me`
  723. then
  724. echo "writting ./readme.me"
  725. cat > ./readme.me << '\Rogue\Monster\'
  726. .C "Producer: Smalltalk-80 to Objective-C Translator"
  727. .(l C
  728. Brad J. Cox
  729. Productivity Products International
  730. 75 Glen Road
  731. Sandy Hook, CT 06482
  732. (203) 426 1875.
  733. .)l
  734. .pp
  735. Smalltalk-80 is a tool for turning raw concepts into working software 
  736. prototypes. Objective-C is a tool for turning proven concepts into fast,
  737. commercial-quality, production systems. Producer is a tool for bridging
  738. the gap between prototyping and production by automatically translating 
  739. Smalltalk-80 sources into Objective-C sources. The translation is guided
  740. by a rule base in which the programmer describes how differences between 
  741. the Smalltalk-80 prototyping environment and the Objective-C production
  742. environment should be resolved when translating the code.
  743. .pp
  744. At SIGGRAPH-87, PPI will announce a library of user interface components 
  745. from which programmers build applications with iconic user interfaces.
  746. The library and applications built using it are portable across diverse window
  747. systems, initially X-Windows, SunWindows and Hewlett Packard's window
  748. system. While the Objective-C user interface classes are different from
  749. Smalltalk's, they are similar enough that Producer can usually bridge the
  750. differences with some hand-tuning of the translated output.  We confidently 
  751. hope that Objective-C, this library and Producer will make automatic 
  752. translation of Smalltalk-80 prototypes a routine part of many companies'
  753. software development lifecycle.
  754. .pp
  755. I'm distributing Producer to enlist your help in testing the practicality of
  756. this notion.
  757.  
  758. .H "Disclaimer"
  759. .pp
  760. Producer is not a mature software product but an embryo that could grow to
  761. maturity someday.  Specifically it is not supported or warranteed in any way.  
  762. It was written by myself, an individual employed by PPI, and has been released 
  763. prior to maturity by myself as an individual with the consent of the company.
  764. This document will make its strengths and some of its present shortcomings
  765. clear.
  766. .pp
  767. However, even in its present state, Producer demonstrates that automatic
  768. translation is technically feasible and its present implementation provides
  769. a capable foundation on which to build. Since the market for Smalltalk-80 
  770. translators is insufficient for PPI to pursue presently, we've released
  771. Producer for you to make what use of it you can.
  772. .pp
  773. I do ask that you keep me informed of your experiences in using it in its
  774. current state, and PPI requests that you feed back any improvements so that 
  775. we can offer a fully supported translation product in the future. PPI retains
  776. the copyright and all other applicable rights. For example, you may not 
  777. sell products that contain any part of the Producer distribution without 
  778. PPI's permission.
  779.  
  780. .H "How it works"
  781. .pp
  782. The following is a brief description of how Producer works internally.
  783. This was written from my recollection of how I left the code over a
  784. year ago. It may be inaccurate in places.
  785. .pp
  786. Producer is basically a compiler. It's lexical analyzer (written in lex)
  787. divides Smalltalk-80 text into lexemes, and its parser (written in yacc)
  788. recognizes valid lexeme sequences and constructs an abstract representation
  789. of the program as an expression tree. The expression tree consists of 
  790. instances of Objective-C classes; e.g. Method, Statement, Expression,
  791. Message, and Variable. The grammar was derived from the syntax diagrams
  792. in Goldberg and Robson; \fISmalltalk-80: The Language and its
  793. Implementation\fP; Addison Wesley; 1986.
  794. .pp
  795. The grammar was extended to also recognize rules that may also appear
  796. in the lexeme stream. Rules are enclosed in { braces } to help fend off
  797. shift-reduce conflicts from yacc. The parser stores the rules in separate
  798. data structures for use during code generation.
  799. .pp
  800. At certain points, the parser sends the top of the expression tree a 
  801. gen message to trigger code generation\**. Recall that Smalltalk-80
  802. is an extremely simple language with basically two components; data
  803. references (variables, literals, etc) and messages. Rules may influence
  804. how each case is treated during code generation.
  805. .(f
  806. \** I now regard this as a major architectural flaw whenever I see it in any
  807. application. It represents a key departure from an important but often
  808. ignored rule of object-oriented design.  The expression tree classes should
  809. be abstract so that they could be reused in other tools. But their code 
  810. generation methods pollute the abstraction with knowledge about a particular
  811. concrete interface; Objective-C. The code generation methods should have been
  812. provided in a separate hierarchy of classes that know how to connect the
  813. abstract classes to one of many potential concrete interfaces. This rule 
  814. is simply a generalization of the model/view/controller paradigm to apply 
  815. to interfaces of any kind, not just user interfaces.
  816. .)f
  817. .pp
  818. Code generation proceeds in two passes. The first pass collects typing
  819. information for each symbol and message by examining the expression
  820. tree from the bottom up. The bottom-most nodes are either literals whose
  821. type is immediately obvious (e.g. 1, 2.3, or 'string'), or they are symbols
  822. whose type can be known or unknown. Symbol types become known either as
  823. the result of a previous type inferencing operation or because their type
  824. was specified in a rule. Unknown symbols default to id when first referenced.
  825. .pp
  826. Most of the internal nodes are messages.  Message typing is slightly more
  827. complicated because any message can have multiple translations depending on
  828. how the message is used because different rules may specify different 
  829. translations for different receiver and arguments types. The diverse
  830. translations may each compute a different type. Since we assign types bottom
  831. up, types have been assigned for the arguments and the receiver, so a 
  832. translation for that selector is chosen by searching a table of possible
  833. translations for one matching the receiver and argument types. 
  834. .pp
  835. In all cases, unless overridden by a specific rule, default translations
  836. are used. These amount to a fairly literal translation from Smalltalk-80 
  837. syntax to Objective-C syntax. However exceptions are made for Smalltalk
  838. literal constants, which translate to C literal constants. In other words,
  839. 2+2 translates to [2 plus:2], which is \fIguaranteed\fP to fail 
  840. catastrophically in Objective-C. The integer 2 is an object only in 
  841. Smalltalk!
  842. .pp
  843. The moral: \fINever\fP believe the translator. \fIAlways\fP monitor it 
  844. closely. Remember the 90-10 rule. The automatic translation concept is
  845. capable, with suitable rules, of automatically translating only 90% of
  846. an application correctly; the other 10% (where the bugs will have 
  847. congregated) is still up to you.
  848.  
  849. .H "Implementation Status"
  850. .pp
  851. Producer currently represents about three man-weeks of effort, spent in two
  852. intensive bursts separated by about a year. The most recent burst was nearly
  853. a year and a half ago.  The first burst was to demonstrate the feasibility 
  854. and practicality of the translation concept. The second burst was in the
  855. course of preparing a paper that, coauthored with Kurt Schmucker, will appear
  856. in the OOPSLA-87 proceedings. A (very) early draft is provided with this
  857. distribution. 
  858. .pp
  859. For being developed so quickly, the translator does an effective job of 
  860. translation.  I refer you to the paper for discussions of the strengths 
  861. and limitations of the translation concept.  This section discusses the
  862. current implementation of this concept, the items on my own must-do list 
  863. for the planned, but not yet completed, third stage of Producer's evolution.
  864. .np
  865. Smalltalk-80 fileout format uses '!' delimiters in a fashion that I was
  866. never able to formalize correctly in Producer's yacc grammar. The symptom
  867. is that the translator will generate syntax errors in nearly every translated
  868. file for certain of these delimiters. I'm told that fileout format has been
  869. documented in a paper somewhere, but I've never worked the repairs back into
  870. the code. The fix should be local to gram.y.
  871. .np
  872. The translator loads its rule base by reading files of rules as if they
  873. were concatenated with the sources to be translated. The rule-specification
  874. syntax is abysmal, primarily  because it was chosen to minimize the amount 
  875. of time I spent struggling with shift-reduce conflicts from yacc, rather than
  876. making the rules intelligible to users. Smalltalk's formal grammar seemed
  877. unreasonably difficult for yacc to swallow, and I suspect the problem may
  878. lie in some mistake I've made in translating Smalltalk-80 syntax diagrams
  879. into yacc specifications.
  880. .np
  881. The program contains extensive provisions for reporting its cogitations in
  882. type inferencing. The various error, warning, logging, and debugging messages
  883. need to be tuned for greater utility.
  884. .np
  885. The code was based on an as yet unreleased libary (phylum) called "Substrate",
  886. which supports features that are not yet in our standard product set, like
  887. Blocks, Coroutining, and exception handling.  I made a fast editing pass
  888. to remove any dependencies on these nonstandard library features. I also 
  889. added a file, Substrate.h, that defines stylistic conventions that I adhere
  890. to in all my work. See USE, IMPORT, EXPORT, etc in the sources.
  891. .pp
  892. The preceeding problems are superficial and easily repaired. The following
  893. ones are somewhat more substantial in that they involve design work in 
  894. addition to coding work.
  895. .np
  896. The type inferencing machinery infers types of newly-encountered (unknown)
  897. messages and variables by seeing how they are combined with variables and
  898. messages whose types are known apriori or else determined earlier through
  899. inferencing.  The only types that are known apriori are literals like 1,
  900. 2.3, or 'string'. This generally provides insufficient typing information
  901. from which to infer anything useful, so you should generally provide variable
  902. rules to pin down types for key instance variables and method arguments
  903. You do this with rules that state, in effect, that `the type of the Smalltalk
  904. variable named foo is int, and the variable is called foobar in Objective-C'.
  905. Presently rules have global scope. If different Smalltalk classes use the
  906. name, foo, in ways that should be translated differently, different rule
  907. sets must be provided manually to the translator. Creating and managing 
  908. these application-specific rules sets adds to the translation effort and 
  909. tends to make rules non-reusable across translations. The rules should be
  910. organized with a scoping mechanism, ideally one based on inheritance.
  911. .np
  912. The inferencing logic is ad-hoc and quite possibly slow. However the main
  913. bottleneck seems to be loading the rule-base; translation speed has never 
  914. been a real problem. Inferencing is presently deductive, and a more inductive
  915. scheme based on both forwards and backwards reasoning might produce higher
  916. quality translations. In other words, the translation of a given message
  917. expression is determined exclusively by whatever information can be inferred
  918. about the types of the receiver and arguments to that message (forward 
  919. reasoning). Backward reasoning would also consider how the results of the
  920. expression are used in other expressions.
  921. .np
  922. Producer does not presently handle non-trivial uses of Blocks correctly; ie.
  923. Block expressions that cannot be translated directly into C conditional
  924. expressions like if, while, or for, which Producer handles just fine already.
  925. Nearly all occurrences of Smalltalk-80 Blocks could be handled without
  926. changing the Objective-C language by adding a trivially simple Block class
  927. to the library. A named instance variable holds a pointer to a static function
  928. and indexed instance variables hold \fIcopies of\fP any variables that the
  929. block accesses in the instantiation site\**. This copy could be taken
  930. entirely automatically by copying the instantiation site's stack frame.
  931. However I prefer to have more control over space than that. So I've been
  932. using a scheme that requires the programmer (and someday the compiler) to
  933. specify which variables are really accessed by the block as arguments to
  934. the message that instantiates the block; like this
  935. .(C
  936.  ... { 
  937.     IMPORT void aStaticFunction();
  938.     id var1 = something, var2 = something;
  939.     aBlock = [Block function:aStaticFunction args:2, var1, var2];
  940.     [anyObject do:aBlock];
  941.     ...
  942.  }
  943.  LOCAL void aStaticFunction(instantiationSiteVariables, value1, value2)
  944.     struct { id var1, var2; } *instantiationSiteVariables;
  945.     id value1, value2;
  946.  {
  947.     if ([instantiationSiteVariables->var1 someMessage])
  948.         ...
  949.  }
  950. .)C
  951. .ip
  952. The block will call the function when anyObject sends the block one of several
  953. evaluation messages (value:arg1 or value:arg1 value:arg2 or ...). The first
  954. argument is a \fIpointer\fP to block's copy of the instantiation site's 
  955. variables. The trailing arguments contain the arguments that the invocation 
  956. site passed in the value: message.  I've used this approach extensively by
  957. writing the static functions by hand, and am trying to get our staff to 
  958. extend the language to provide some kind of language-level support to make
  959. the syntax simpler.  This approach could be, but has not yet been, taken by
  960. Producer.
  961. .(f
  962. \** In Smalltalk-80, the block seems to have access to the instantiation
  963. site's variables, so that the block can change variables in the instantiation
  964. site. In Objective-C the block receives a copy of the variables and cannot
  965. use them to communicate with the instantiation site. I believe that this is
  966. the sole functional difference between the two schemes.
  967. .)f
  968. .pp
  969. The inferencing machinery's primary current virtue is that it can be made
  970. to work for selected test cases. It leaves lots to be desired. Call me
  971. if you decide to extend it so that I can prevent unnecessary duplication of
  972. effort.
  973.  
  974. .H "About the distribution"
  975. .pp
  976. The top level of the distribution consists of
  977. .(C
  978. total 88
  979. -rw-r--r--  1 cox           181 Jun 22 14:32 Makefile
  980. -rw-r--r--  1 cox         26592 Jun 22 14:30 README
  981. drwxr-xr-x  2 cox           512 Jun 22 14:19 example
  982. -rw-r--r--  1 cox           166 Jun 16 13:18 log
  983. -rw-r--r--  1 cox           997 Jun 15 11:09 mac.me
  984. -rw-r--r--  1 cox         26751 Jun 15 11:02 producer.me
  985. -rw-r--r--  1 cox         21444 Jun 22 14:29 readme.me
  986. drwxr-xr-x  2 cox           512 Jun 12 10:22 rules
  987. drwxr-xr-x  2 cox          3072 Jun 22 14:31 src
  988. .)C
  989. The Makefile governs formatting of the two documents; this README (from 
  990. readme.me) and the draft of the OOPSLA-87 paper (from Producer.me). The 
  991. mac.me file contains text formatting macros that are common to both papers;
  992. used like this:
  993. .(C
  994. nroff -me mac.me Producer.me >Producer.f
  995. .)C
  996. .pp
  997. The rules directory contains a single file, generic.ru, that represents a 
  998. first pass at an application-independent rules base. This set of rules 
  999. translate Smalltalk to the conventions used in my prototype version of 
  1000. the user interface library.
  1001. .pp
  1002. For example, it translates Smalltalk Integer operations to C int operations,
  1003. and it translates Smalltalk Point operations to C macros that manage points 
  1004. as type PT; a pair of 16-bit coordinates in a 32-bit C int.  For example,
  1005. pt(x,y) invokes a C macro that trims and shifts two ints, x and y, to fit
  1006. side by side in a 32-bit integer, ptPlus(p,q) invokes a macro that computes 
  1007. the vector sum of two points, p and q, etc.
  1008. .(C
  1009. rules:
  1010. total 35
  1011. -rw-r--r--  1 cox         35567 Jun 12 10:22 generic.ru
  1012. .)C
  1013. .pp
  1014. The src directory contains a fragment from the video animation program that
  1015. appears at the end of the Smalltalk-80 video tape. BounceInBoxNode.st is
  1016. the Smalltalk-80 source file, animation.ru contains the application-specific
  1017. rule set, BounceInBoxNode.m is the translated version built by Producer as
  1018. invoked by Makefile\**.
  1019. .(f
  1020. \** The full source for the animation program is not provided. My copyright
  1021. paranoia argued against providing even this fragment.
  1022. .)f
  1023. .(C
  1024. example:
  1025. total 7
  1026. -rw-r--r--  1 cox          1730 Jun 16 10:24 BounceInBoxNode.m
  1027. -rw-r--r--  1 cox           868 Jun 16 10:18 BounceInBoxNode.st
  1028. -rw-r--r--  1 cox           394 Jun 16 10:20 Makefile
  1029. -rw-r--r--  1 cox          2178 Jun 16 10:18 animation.ru
  1030. -rw-r--r--  1 cox           185 Jun 16 10:24 log
  1031. -rw-r--r--  1 cox           239 Jun 16 10:18 st80.h
  1032. .)C
  1033. .pp
  1034. The log file records the results of the translation session. The syntax
  1035. error is innocuous, the result of the beforementioned problem in the grammar
  1036. in handling '!' delimiters.
  1037. .(C
  1038. Producer -c ../rules/generic.ru animation.ru BounceInBoxNode.st >BounceInBoxNode.m
  1039. error 7:BounceInBoxNode.st: tegory:'Graphics-Animation'!! : syntax error
  1040. *** Error code 1 (ignored)
  1041. .)C
  1042. .pp
  1043. The src directory contains the sources for Producer, with its own Makefile.
  1044. The Substrate.h header file, which is automatically included by the
  1045. Producer.h header file, is technically a part of a internal lower level
  1046. library, Substrate, on which Producer was originally developed. Substrate.h
  1047. was copied and changed superficially so that Producer compiles correctly
  1048. without the Substrate library.
  1049. .(C
  1050. src:
  1051. total 70
  1052. -rw-r--r--  1 cox           483 Jun 12 10:21 AbstractTranslation.m
  1053. -rw-r--r--  1 cox           282 Jun 12 10:21 ArgumentList.m
  1054. -rw-r--r--  1 cox           897 Jun 12 10:21 Block.m
  1055. -rw-r--r--  1 cox           143 Jun 12 10:21 CharConstant.m
  1056. -rw-r--r--  1 cox          2205 Jun 12 10:21 Class.m
  1057. -rw-r--r--  1 cox           630 Jun 12 10:21 Comment.m
  1058. -rw-r--r--  1 cox           176 Jun 12 10:21 Constant.m
  1059. -rw-r--r--  1 cox          2032 Jun 12 10:21 Expr.m
  1060. -rw-r--r--  1 cox          1243 Jun 12 10:21 FunctionTranslation.m
  1061. -rw-r--r--  1 cox          1484 Jun 12 10:21 Identifier.m
  1062. -rw-r--r--  1 cox          1248 Jun 12 10:21 IdentifierTranslation.m
  1063. -rw-r--r--  1 cox           105 Jun 12 10:21 List.m
  1064. -rw-r--r--  1 cox          1985 Jun 15 11:55 METHODDECLS.m
  1065. -rw-r--r--  1 cox          1384 Jun 15 11:51 Makefile
  1066. -rw-r--r--  1 cox          4302 Jun 12 10:21 Method.m
  1067. -rw-r--r--  1 cox          3136 Jun 12 10:21 Msg.m
  1068. -rw-r--r--  1 cox           583 Jun 12 10:21 MsgArgPattern.m
  1069. -rw-r--r--  1 cox           828 Jun 12 10:21 MsgNamePattern.m
  1070. -rw-r--r--  1 cox          1280 Jun 12 10:21 MsgTranslation.m
  1071. -rw-r--r--  1 cox           775 Jun 12 10:21 MsgTranslator.m
  1072. -rw-r--r--  1 cox          1868 Jun 12 10:21 Node.m
  1073. -rw-r--r--  1 cox           229 Jun 12 10:21 NumberConstant.m
  1074. -rw-r--r--  1 cox          1402 Jun 15 11:27 Producer.h
  1075. -rw-r--r--  1 cox           306 Jun 12 10:21 Return.m
  1076. -rw-r--r--  1 cox           825 Jun 12 10:21 Scope.m
  1077. -rw-r--r--  1 cox          3157 Jun 12 10:21 Selector.m
  1078. -rw-r--r--  1 cox           253 Jun 12 10:21 SelectorConstant.m
  1079. -rw-r--r--  1 cox           457 Jun 12 10:21 StArray.m
  1080. -rw-r--r--  1 cox           492 Jun 12 10:21 Stmt.m
  1081. -rw-r--r--  1 cox           381 Jun 12 10:21 StringConstant.m
  1082. -rw-r--r--  1 cox          1268 Jun 12 10:21 StringTranslation.m
  1083. -rw-r--r--  1 cox          2140 Jun 15 11:38 Substrate.h
  1084. -rw-r--r--  1 cox          1405 Jun 15 11:53 Symbol.m
  1085. -rw-r--r--  1 cox           452 Jun 12 10:21 Template.m
  1086. -rw-r--r--  1 cox           901 Jun 12 10:21 Type.m
  1087. -rw-r--r--  1 cox          1800 Jun 12 10:21 design.me
  1088. -rw-r--r--  1 cox          3271 Jun 12 10:21 gen.m
  1089. -rw-r--r--  1 cox          9007 Jun 12 10:21 gram.y
  1090. -rw-r--r--  1 cox          3601 Jun 12 10:21 lex.l
  1091. -rw-r--r--  1 cox          2212 Jun 12 10:21 main.m
  1092. -rw-r--r--  1 cox           260 Jun 12 10:21 st80.h
  1093. -rw-r--r--  1 cox           259 Jun 15 11:59 y.tab.h
  1094. .)C
  1095. .pp
  1096. The files are exactly as I left them nearly a year and a half ago, except 
  1097. for:
  1098. .np
  1099. The addition of this README document. An early draft of the OOPSLA-87
  1100. paper, sadly prior to Kurt Schmucker's improvements, is in Producer.me.
  1101. .np
  1102. One recompilation pass to remove any obvious dependencies on my private
  1103. Substrate library and to verify that Producer compiles and runs correctly 
  1104. on the standard Foundation library. I tested the changes by verifing that 
  1105. the Makefile in the example directory ran to completion, but this is hardly
  1106. an ironclad guarantee. 
  1107.  
  1108. .H "Using Producer"
  1109. .pp
  1110. Flags controlling the translation process, source files, and rules files
  1111. are provided on the command line and are processed in the order they appear.
  1112. The flags are\**
  1113. .(f
  1114. \** I'm working from memory about what these flags mean. Some may
  1115. be nonfunctional:
  1116. .)f
  1117. .ip -d:
  1118. Enable debugging functions (dbg()) scattered throughout the code. Seldom
  1119. useful.
  1120. .ip -m:
  1121. Enables the Objective-C Foundation library message tracing feature. Seldom
  1122. useful in Producer.
  1123. .ip -a:
  1124. Enables the Objective-C Foundation library allocation tracing feature. Seldom
  1125. useful in Producer.
  1126. .ip -l:
  1127. Enables printing of each lexical token as produced by lex. Useful only for
  1128. debugging lex.l.
  1129. .ip -g:
  1130. Enables automatic redirection of each class into a separate file based
  1131. on the class name parsed from the input file. Automatically puts class
  1132. Foobar into file Foobar.m. 
  1133. .(q
  1134. CAREFUL! This puts at risk other files whose name might coincide with
  1135. a Smalltalk-80 class name!
  1136. .)q
  1137. .ip -s:
  1138. Generate Smalltalk-80 sources in the output file as Objective-C comments
  1139. (the default).
  1140. .ip -c:
  1141. Don't generate Smalltalk-80 sources in the output file.
  1142. .ip -i:
  1143. Generate information that was thought at one time to be useful when 
  1144. debugging rules.
  1145. .ip -M:
  1146. Send storeOn: to the message rule dictionary just before terminating 
  1147. as a debugging aid.
  1148. .ip -I:
  1149. Send storeOn: to the variable rule dictionary just before terminating 
  1150. as a debugging aid.
  1151. .pp
  1152. Typically, the generic rules in rules/generic.ru is specified first, then 
  1153. any application-specific rules, then a single Smalltalk-80 source file.
  1154. Unless -g is set, the translated output appears on stdout. The various
  1155. creaks, groans and mumbles that can be elicited about the translation 
  1156. process itself appear on stderr.
  1157. .pp
  1158. For the syntax for writing new rules, refer to the examples in generic.ru
  1159. and animation.ru, and if necessary, the rules section of the grammar in gram.y. 
  1160. .pp
  1161. And good luck! Let me know how you fare...
  1162. \Rogue\Monster\
  1163. else
  1164.   echo "will not over write ./readme.me"
  1165. fi
  1166. echo "Finished archive 1 of 5"
  1167. exit
  1168. ----
  1169. Dieter H. Zebbedies ('dee-ter  ayech  'zeb-ed-eez)
  1170.  Zebb-Hoff Mach. Tool's Automated Manufacturing Project Cleveland, OH
  1171.  (USnail): 9535 Clinton Rd, Cleveland, OH 44144 (+216 631 6100) (+216 741-5994)
  1172.  (UUCP): ...{decvax,sun,cbosgd}!cwruecmp!zhmti!dieter
  1173.  (CSNET/ARPA/BITNET): dieter@CWRU.EDU
  1174.