home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 336.lha / Ash / TechNotes.doc < prev    next >
Text File  |  1989-12-27  |  5KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.                                    Technical Notes
  17.  
  18.                                          ASH
  19.  
  20.                            A ksh-like Shell for the Amiga
  21.  
  22.                                      Version 1.0
  23.  
  24.  
  25.                                   (Copyright) 1989 
  26.  
  27.                                      Steve Koren
  28.  
  29.                                   November 7, 1989
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.           Implementation Notes
  74.  
  75.             Ash is the result of over 3  month's  of  evening  and  weekend
  76.             work on an Amiga 2000 with a Xetec hard disk  controller,  85mb
  77.             Seagate drive, and 3mb of ram.  The parser,  lexical  analyzer,
  78.             and program architecture were completed very quickly;  most  of
  79.             the time was spent  trying  to  figure  out  how  to  do  Amiga
  80.             specific things (like directories) and working around  compiler
  81.             bugs.
  82.  
  83.             Ash has a parser  that  was  generated  using  Amiga  yacc  and
  84.             modified by hand to deal with  some  special  features  of  Ash
  85.             (such as  command  substitution).   The  lexical  analyzer  was
  86.             written by hand, since I needed some capabilities  not  present
  87.             in Lex.
  88.  
  89.             Internally, Ash uses hash tables to keep  track  of  variables,
  90.             aliases, functions, and keywords.  A stack of  hash  tables  is
  91.             maintained, and each time a function  is  called,  a  new  hash
  92.             table  is  pushed  onto  the  stack.   Then,  when  a  name  is
  93.             referenced, it is looked up in the hash  table  stack  starting
  94.             with the most recent hash table.  When a  function  exits,  the
  95.             most recent  hash  table  is  popped  off  the  stack  and  its
  96.             contents are freed.  Hash  table  entries  have  an  associated
  97.             type (variable, function, etc),  and  a  value,  which  can  be
  98.             either a text  string  (such  as  an  alias  definition)  or  a
  99.             pointer to a parse tree (for a function).
  100.  
  101.             Ash was  written  to  be  reentrant,  so  that  in  the  future
  102.             interprocess pipes may be used between  internal  and  external
  103.             commands.  Thus, all evaluation is done using only  information
  104.             passed around in an "EVAL_PACKET" structure so that no  globals
  105.             are referenced.  Each  execution  of  the  command  interpreter
  106.             generates its own hash table stack, its own  pointer  to  input
  107.             and output files, etc.  The few parts  of  Ash  which  are  not
  108.             reentrant  are  written   using   a   semaphore-based   locking
  109.             mechanism.  This locking mechanism is intelligent; it does  not
  110.             lock out all other tasks  from  the  system  (as  Forbit()  and
  111.             Permit() do), but simply allows only a single task  to  execute
  112.             a given section of program code at one time.
  113.  
  114.             All output is done through a single low  level  routine  which,
  115.             given an EVAL_PACKET and some text, will route it to  either  a
  116.             file or a string (in the  case  of  command  substition).   The
  117.             length of the space allocated for this string is  kept  in  the
  118.             EVAL_PACKET, and if the new text  would  cause  the  string  to
  119.             overflow its allocated space, more space is allocated  and  the
  120.             original  is  copied  into  the  new  space.    Thus,   command
  121.             substition and variables can  deal  with  text  of  any  length
  122.             limited only by free memory.
  123.  
  124.             There are no hard-coded branches to routines which execute  Ash
  125.             builtin commands.  A single structure  contains  all  necessary
  126.             information for  builtin  commands,  including  their  name,  a
  127.  
  128.  
  129.           ASH Amiga Shell               Page 2             Technical Notes
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.             pointer to their execution routine, and  a  few  other  things.
  140.             This  architecture  makes  it  trivial  to  add   new   builtin
  141.             commands.  Keywords are dealt with in the same way.
  142.  
  143.             A series of test  scripts  is  run  whenever  Ash  is  changed.
  144.             These scripts test  all  the  Ash  commands  and  syntax.   The
  145.             output of these tests are compared against known  good  results
  146.             to verify that  no  previously  working  commands  were  broken
  147.             inadvertantly.  The entire series  of  20  test  scripts  takes
  148.             about 10 minutes to run on a stock 7.x mHz Amiga 2000.
  149.  
  150.             Since the entire Ash project was implemented on an  Amiga,  and
  151.             Ash was designed for Amigas, it currently runs only there.   It
  152.             was, however, designed with machine independence in mind.   The
  153.             machine specific code is enclosed in #ifdef  AMIGA  statements,
  154.             and  could  conceivably  be  replaced  with  code  specific  to
  155.             another machine.
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.           ASH Amiga Shell               Page 3             Technical Notes
  196.  
  197.  
  198.  
  199.