home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1988 / 06 / may.exm < prev    next >
Text File  |  1979-12-31  |  896b  |  38 lines

  1.  
  2.  
  3.  
  4. Example 1: Source Code Recreation
  5.  
  6.      Source Recreation
  7.  
  8. Object code      Result
  9. abc++            a+b+c
  10. bcdfe+*/=        let b=c/d*f+e
  11. gabc+(*cd,,$     let g=sum(a*(b+c),c,d)
  12.  
  13.  
  14. Example 2: Transformation Table
  15.  
  16.  
  17. typedef struct decomp-row  {
  18.    char    ident
  19.    short    lex_type;
  20.    char    *prefix_1;
  21.    char    *prefix_2;
  22.    char    *suffix;
  23. } decomp_row;
  24. static decomp_row table[] ={
  25.    {`!', UNARY_OP,   "-",   NIL,  NIL},
  26.    {`+', BINARY_OP,  NIL,   "+",  NIL},
  27.    {`-', BINARY_OP,  NIL,   "-",  NIL},
  28.    {`/', BINARY_OP,  NIL,   "/",  NIL},
  29.    {`*', BINARY_OP,  NIL,   "*",  NIL},
  30.    {`^'  BINARY_OP,  NIL,   "^",  NIL],
  31.    {`(', UNARY-OP,   "(",   NIL,  ")"},
  32.    {`$', UNARY_OP,   "sum(",NIL,  ")"},
  33.    {`=', BINARY_OP,  "let ","=",  ";"},
  34.    {`,', BINARY_OP,  NIL,   ",",  NIL}
  35. };
  36.  
  37.  
  38.