home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume17 / ease2 / part01 / src / errors.c next >
Encoding:
C/C++ Source or Header  |  1989-02-08  |  2.4 KB  |  123 lines

  1. /*    $Header: errors.c,v 2.0 88/06/15 14:41:10 root Exp $    */
  2.  
  3. /*
  4.  * $Log:    errors.c,v $
  5.  * Revision 2.0  88/06/15  14:41:10  root
  6.  * Baseline release for net posting. ADR.
  7.  * 
  8.  */
  9.  
  10. /*
  11.  *      errors.c   -- Contains error initialization and reporting routines.
  12.  *
  13.  *      author     -- James S. Schoner, Purdue University Computing Center,
  14.  *                        West Lafayette, Indiana  47907
  15.  *
  16.  *      date       -- July 9, 1985
  17.  *
  18.  *    Copyright (c) 1985 by Purdue Research Foundation
  19.  *
  20.  *    All rights reserved.
  21.  *
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include "fixstrings.h"
  26.  
  27. extern int  ErrorCount;     /* error count                   */
  28. extern char FNbuf[];     /* input file name              */
  29. extern int  Lcount;     /* line count                    */
  30. FILE *DIAGf = {stderr};  /* file for diagnostic output */
  31.  
  32.  
  33. /*
  34.  *    ErrorReport () -- Prints source file name (FNbuf), line number (Lcount),
  35.  *              and error message (sbErr) for each invokation.
  36.  *
  37.  */
  38. void
  39. ErrorReport (sbErr)
  40. char *sbErr;
  41. {
  42.     fprintf (DIAGf, "%s, line %d: %s", FNbuf, Lcount, sbErr);
  43.     ErrorCount++;
  44. }
  45.  
  46.  
  47. /*
  48.  *    FatalError () -- Translator fatal error routine which prints 
  49.  *             error message (sbErr) and an argument (sbArg).
  50.  *
  51.  */
  52. void
  53. FatalError (sbErr, sbArg)
  54. char *sbErr,
  55.      *sbArg;
  56. {
  57.     fprintf (DIAGf, "%s, line %d: Fatal Error In Translator: %s %s\n", 
  58.          FNbuf, Lcount, sbErr, sbArg);
  59.     exit (1);
  60. }
  61.  
  62.  
  63. /*
  64.  *    yyerror () -- Prints source file name (FNbuf), line number (Lcount),
  65.  *              and error message (sbErr) for each invokation.
  66.  *
  67.  */
  68. void
  69. yyerror (sbErr)
  70. char *sbErr;
  71. {
  72.     fprintf (DIAGf, "%s, line %d: %s\n", FNbuf, Lcount, sbErr);
  73.     ErrorCount++;
  74. }
  75.  
  76.  
  77. /*
  78.  *    PrintError () -- Prints source file name (FNbuf), line number
  79.  *             (cline), error message (sbErr), and argument
  80.  *             (sbArg) for each invokation.
  81.  *
  82.  */
  83. void
  84. PrintError (sbErr, sbArg)
  85. char *sbErr;
  86. char *sbArg;
  87. {
  88.     fprintf (DIAGf, "%s, line %d: %s %s.\n", FNbuf, Lcount, sbErr, sbArg);
  89.     ErrorCount++;
  90. }
  91.  
  92.  
  93. /*
  94.  *    PrintWarning () -- Prints a warning message with source file
  95.  *               name (FNbuf), line number (Lcount), warning
  96.  *               (sbWarn), and a possible identifier (sbID).
  97.  *
  98.  */
  99. void
  100. PrintWarning (sbWarn, sbID)
  101. char *sbWarn;
  102. char *sbID;
  103. {
  104.     fprintf (DIAGf, "%s, line %d: Warning: ", FNbuf, Lcount);
  105.     if (sbID != NULL)
  106.         fprintf (DIAGf, sbWarn, sbID);
  107.     else
  108.         fprintf (DIAGf, sbWarn);
  109. }
  110.  
  111.  
  112. /*
  113.  *    InitError () -- Initialize line count (Lcount) to one and error count
  114.  *                (ErrorCount) to zero.
  115.  *
  116.  */
  117. void
  118. InitError ()
  119. {
  120.     Lcount     = 1;
  121.     ErrorCount = 0;
  122. }
  123.