home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / the25.zip / the25O_w32.zip / compile.the < prev    next >
Text File  |  1997-09-10  |  5KB  |  143 lines

  1. /*
  2. $Id: compile.the 2.1 1995/06/24 16:29:22 MH Rel MH $
  3. */
  4. /***********************************************************************/
  5. /* Description: REXX macro to simulate an Integrated Development       */
  6. /*              Environment (IDE) for a C program.                     */
  7. /* Syntax:      COMPILE compiler                                       */
  8. /* Notes:       This macro is a very simple attempt at development of  */
  9. /*              and IDE using THE as the engine.                       */
  10. /*              The current C program is compiled (syntax of compile   */
  11. /*              command dependant on supplied parameter); the output   */
  12. /*              of the compiler is redirected to a temporary file, the */
  13. /*              macro reads this file and parses each line to determine*/
  14. /*              the line number and error message. Each line is then   */
  15. /*              given a name associated with the error message.        */
  16. /*              The macro then goes into an infinite loop reading      */
  17. /*              keystrokes from the user via READV KEY until the exit  */
  18. /*              key is hit. The macro will position the focus line     */
  19. /*              associated with each error message vi the next and     */
  20. /*              previous error keys (defined below).                   */
  21. /*              Normal editing is possible while in this macro,        */
  22. /*              although the user will notice significant response     */
  23. /*              delays.                                                */
  24. /***********************************************************************/
  25. Trace o
  26. Parse Arg comp .
  27. If comp = '' Then
  28.   Do
  29.     'emsg No compiler supplied'
  30.     Return
  31.   End
  32. 'EXTRACT /CURLINE/FNAME/FPATH/VERSION/ALT/'       /* get various stuff */
  33. If rc \= 0 Then
  34.    Do
  35.      Say 'Error in EXTRACT:' rc
  36.      Exit 1
  37.    End
  38. If alt.1 > 0 Then
  39.    Do
  40.      'save'                            /* save any changes to the file */
  41.      If rc \= 0 Then Exit 0
  42.    End
  43. /*---------------------------------------------------------------------*/
  44. /* The default settings in the following block can be tailored to your */
  45. /* own preferences.                                                    */
  46. /*---------------------------------------------------------------------*/
  47. key_exit = 'F3'                                   /* key to exit macro */
  48. key_prev = 'F7'                       /* key to move to previous error */
  49. key_next = 'F8'                           /* key to move to next error */
  50. /*rsrvd_line = curline.1+1*/    /* line on which to display error messages */
  51. rsrvd_line = 3
  52. tmpfile = 'tmp.tmp'                          /* name of temporary file */
  53. /*---------------------------------------------------------------------*/
  54. filename = fpath.1||fname.1
  55. idx = 0
  56. err. = ''
  57. 'osredir' tmpfile comp filename
  58. Do While(Lines(tmpfile) > 0)
  59.    line = Linein(tmpfile)
  60.    Select
  61.      When comp = 'cc' Then 
  62.           Do
  63.             Parse Var line '"' fn '"' 'line ' line ':'  message
  64.             If Datatype(line) = 'NUM' Then Call setline
  65.           End
  66.      When comp = 'c89' Then
  67.           Do
  68.             Parse Var line '"' fn '"' 'line ' line '.' . ': ' message
  69.             If Datatype(line) = 'NUM' Then Call setline
  70.           End
  71.      When comp = 'icc' Then 
  72.           Do
  73.             Parse Var line fn '(' line ':' col ')' . message
  74.             If Datatype(line) = 'NUM' & Datatype(col) = 'NUM' Then Call setline
  75.           End
  76.      When comp = 'gcc' Then
  77.           Do
  78.             Parse Var line first 3 fn ':' line ': ' message
  79.             fn = first||fn
  80.             If Datatype(line) = 'NUM' Then Call setline
  81.           End
  82.    End
  83. End
  84. rc = Lineout(tmpfile)
  85.  
  86. If version.3 = 'UNIX' | version.3 = 'X11' Then 'osq rm -f' tmpfile
  87. Else 'osq del' tmpfile
  88.  
  89. num_errs = idx
  90. idx = 1
  91. If num_errs = 0 Then
  92.    Do
  93.      'msg No errors'
  94.      'nomsg reserved * off'
  95.      Return
  96.    End
  97. 'msg' num_errs 'errors encountered'
  98. Call show_err err.1
  99.  
  100. Do Forever
  101.    'readv key'
  102.    Select
  103.      When readv.1 = key_exit Then Leave
  104.      When readv.1 = key_prev Then
  105.           Do
  106.             If idx \= 1 Then idx = idx - 1
  107.             Call show_err err.idx
  108.           End
  109.      When readv.1 = key_next Then
  110.           Do
  111.             If idx \= num_errs Then idx = idx + 1
  112.             Call show_err err.idx
  113.           End
  114.      Otherwise 
  115.           Do
  116.             'hit' readv.1
  117.             If rc \= 0 Then Leave
  118.           End
  119.   End
  120. End
  121. 'nomsg reserved' rsrvd_line 'off'
  122. Return
  123.  
  124. show_err: Procedure Expose rsrvd_line
  125. Parse Arg err
  126. fn = Word(err,1)
  127. lineno = Word(err,2)
  128. message = Subword(err,3)
  129. 'nomsg reserved * off'
  130. 'x' fn
  131. 'nomsg locate .l'||lineno
  132. If rc < 2 Then 'reserved' rsrvd_line message
  133. Else 'msg Original line:' lineno 'no longer exists'
  134. Return
  135.  
  136. setline:
  137. 'x' fn
  138. ':'||line
  139. 'set point .l'||line
  140. idx = idx + 1
  141. err.idx = fn line message
  142. Return
  143.