1 02/13/84  lex_error_
  2 
  3 
  4 Entry points in lex_error_:
  5    (List is generated by the help command)
  6 
  7 
  8 :Entry: lex_error_: 02/13/84  lex_error_
  9 
 10 Function: generates compiler-style error messages on the error_output
 11 I/O switch for translators generated by the reduction_compiler command
 12 and for other procedures that process tokens generated by the
 13 lex_string_ subroutine.  See "Notes" below for a description of the
 14 error message format.
 15 
 16 
 17 Syntax:
 18 declare lex_error_ entry options (variable);
 19 call lex_error_ (error_number, Serror_printed, severity_no,
 20      max_severity_no, Pstmt, Ptoken, Scontrol, message, brief_message,
 21      arg1, ..., argN);
 22 
 23 
 24 Arguments:
 25 error_number
 26    is the error number (fixed bin), as it should appear in the error
 27    message.  (Input)
 28 Serror_printed
 29    is a switch (bit(1) unaligned) that is "1"b if the text of the error
 30    message has been printed in a previous error and "0"b, otherwise.
 31    (Input/Output).  If Serror_printed is "1"b, the text is omitted from
 32    the error message.  Otherwise, text is included and the switch is
 33    set to "1"b to suppress this text in any subsequent occurrence of
 34    the same error.
 35 severity_no
 36    is the severity number (fixed bin) of the error.  (Input).  It must
 37    have a value from 0 through 4.  See "Notes" below for an
 38    interpretation of the severity_no value.
 39 
 40 
 41 max_severity_no
 42    is the severity number (fixed bin) of the highest severity error
 43    message that has been printed by the lex_error_ subroutine.
 44    (Input/Output).  Before the lex_error_ is invoked by a translator,
 45    max_severity_no should be initialized to 0.  Each time it is called,
 46    the lex_error_ subroutine compares this value with the severity_no
 47    of the current message and sets max_severity_no to the higher of
 48    these two numbers.
 49 Pstmt
 50    is a pointer to the statement descriptor generated by the
 51    lex_string_ subroutine for the statement that is to be printed after
 52    the error message.  (Input).  The line number and statement number
 53    given in this statement descriptor are included in the error
 54    message.
 55 
 56 
 57 Ptoken
 58    is a pointer to the token descriptor of the token that is in error.
 59    (Input).  If Pstmt is null, then the number of the line that
 60    contains the token described by the descriptor is included in the
 61    error message.  If both Pstmt and Ptoken are null, then no line
 62    number is included in the error message.
 63 Scontrol
 64    is a control bit string (bit(*)) that determines whether the message
 65    character string or the brief_message character string is used in
 66    the error message.  (Input).  The interpretation of the bits in this
 67    string is described in "Notes" below.
 68 
 69 
 70 error_message_text
 71    is an ioa_ control string (char(*) or char(*) varying) that contains
 72    the long form of the error message text.  (Input)
 73 brief_message_text
 74    is an ioa_ control string (char(*) or char(*) varying) that contains
 75    the brief form of the error message text.  (Input)
 76 argN
 77    are optional arguments that are substituted into the ioa_ message
 78    texts, in place of the ioa_ control characters.  (Input)
 79 
 80 
 81 Notes: The error messages that are generated by the lex_error_
 82 subroutine have the form shown below.
 83 
 84    prefix error_number, SEVERITY severity_no IN STATEMENT k OF LINE l.
 85    error_message_text
 86    SOURCE:
 87    statement_in_error
 88 
 89 For example,
 90 
 91    ERROR 7, SEVERITY 2 IN STATEMENT 2 OF LINE 2.
 92    A bad track specification was given in a Volume statement.
 93    9track has been assumed.
 94    SOURCE:
 95    Volume: 70082, 8track;
 96 
 97 
 98 The severity_no associated with an error controls the prefix that is
 99 placed in the error message, as shown in the list below.
100 
101 0   COMMENT
102    Comment.  The error message is a comment, which does not indicate
103    that an error has occurred, but merely provides information for the
104    user.
105 1   WARNING
106    Warning only.  The error message warns of a statement that may or
107    may not be in error, but compilation continues without ill effect.
108 2   ERROR
109    Correctable error.  The message diagnoses an error that the
110    translator can correct, probably without ill effect.  Compilation
111    continues, but correct results cannot be guaranteed.
112 
113 
114 3   FATAL ERROR
115    An uncorrectable but recoverable error.  The translator has detected
116    an error that it cannot correct.  Translation continues in an
117    attempt to diagnose further errors, but no output is produced by the
118    translation.
119 4   TRANSLATOR ERROR
120    An unrecoverable error.  The translator cannot continue beyond this
121    error.  The translation is aborted after the error message is
122    printed.
123 
124 
125 The phrase "IN STATEMENT k OF LINE l" appears in the error message only
126 if Pstmt is a nonnull pointer.  Pstmt is assumed to point to a
127 statement descriptor generated by the lex_string_ subroutine.  The
128 values for k and l come from this descriptor.  If the error occurred in
129 the first statement of line l, then the phrase "STATEMENT k OF" is
130 omitted from the error message.
131 
132 If Pstmt is null, then "STATEMENT k OF" is omitted from the error
133 message, and l is the line number on which the token described by
134 Ptoken appears.  If Ptoken is a null pointer, "IN STATEMENT k OF LINE
135 l" is omitted altogether.
136 
137 
138 Currently, only the first two bits of the Scontrol bit string have
139 meaning, as shown in the table below.
140 
141 "00"b     The printed error contains the error_message_text the first
142           time the error occurs, and the brief_message_text for
143           subsequent occurrences of that error during a given
144           translation.
145 
146 "10"b     The printed error always contains the error_message_text.
147 
148 "11"b     The printed error always contains the error_message_text.
149 
150 "01"b     The printed error always contains the brief_message_text.
151 
152 
153 If Serror_printed is "1"b, then the lex_error_ subroutine assumes the
154 text of the error message has already been printed in a previous
155 message.  It uses the long or brief error message text, according to
156 the value of Scontrol.
157 
158 If Pstmt points to a statement descriptor, then the lex_error_
159 subroutine sets the error_in_stmt switch in the statement descriptor.
160 It also checks the value of the output_in_err_msg switch in the
161 descriptor.  If this switch is "0"b, the lex_error_ subroutine sets it
162 to "1"b and prints the character string representation of the statement
163 in the error message.  If it is already "1"b, then the lex_error_
164 subroutine assumes that the statement has already appeared in another
165 error message and omits the "SOURCE:" phrase from the error message.
166 
167 
168 If max_severity_no is less than severity_no, then the lex_error_
169 subroutine sets max_severity_no equal to severity_no.
170 
171 Refer to the lex_string_ subroutine for a description of statement and
172 token descriptors.