1 //**************************************
3 //* Class used for storing location *
5 //**************************************
7 void error(char *); // outputs an error message then exits.
11 int LineStart, // Line number where the entity starts
12 LineEnd, // Line number where the entity ends.
13 ColumnStart, // Column number of the beginning of the entity.
14 ColumnEnd; // Column number of the end of the entity.
16 int OK( void ); // Checks some properties of the object.
20 // Several Constructors for initialisation of Location Object.
21 // The entity for the two first constructors is set to end at the same
22 // point than its beginnning.
24 // First constructor sets the Location to the beginning of the Text.
27 // Second constructor sets the Location to line Line and column Column.
28 // If Column is ommited, it is assumed that you are talking about the
31 Location( int Line , int Column = 1 );
33 // Last constructor for the ones who knows about the beginning and the
34 // end of the entity referenced.
35 Location( int First_Line, int First_Column,
36 int Last_Line, int Last_Column);
38 Location( const Location& );
40 // Set the point in the text where the entity ends.
41 void SetEnd( int Line, int Column );
43 // Move the beginning of the Location to the place indicated.
44 void Move( int Line , int Column );
46 // Advance the start position to n columns.
47 void Tab( int distance );
49 // Return the start position to next line.
52 void Select( int length );
56 void CrSelect( void );
58 // Overloading of the operator + for computing new Location
59 // The Location Object resulting begins at the first Location
60 // ( The most little position in the text) and ends at the
61 // last location (The furthest position).
62 friend Location operator + ( const Location& , const Location& );
64 // friend operation that allows to write the Location of the entity on
66 friend ostream& operator << ( ostream& cout, Location there );
70 //** Several structure used inside the lex and yacc structure
73 //** LocInt : concatenation of a integer and a location Object.
80 //** LocBool : concatenation of a boolean and a location Object.
87 //** LocInt : concatenation of a integer and a location Object.
94 //** LocStr : concatenation of a String and a location Object.
101 //** LocChar : concatenation of a character and a location Object.
108 //*******************************************
109 //* Class ErrorEntry *
110 //* This Class describes an error emited *
111 //* during the analysis of the text. *
112 //*******************************************
114 enum ErrorKind {Warning, // This entry is a warning.
115 Error, // This entry is a real error.
116 Fatal, // This entry is a spurious error.
117 Internal, // This error is because of the compiler.
118 Operating_system, // This error is because of the operating system.
119 Unknown}; // We don't know why an error has been generated.
123 Location place; // Where it has happened.
124 int number; // The number of error encountered.
125 ErrorKind kind; // The type of error (see upper).
126 char *comment; // A precision about the error.
129 // Two constructors to initialize an ErrorEntry object.
131 // First constructor, give the location of the error and its identification
132 ErrorEntry( Location, int, ErrorKind );
134 // Second constructor, just add a commend to the error.
135 ErrorEntry( Location, int, ErrorKind, char * );
137 // the friend operator << that allows to output the content of an
138 // ErrorEntry object into an output stream.
139 friend ostream operator << ( ostream& cout, ErrorEntry TheError);
142 //*******************************************
143 //* Class ErrorStorage *
144 //* This class describes the object that *
145 //* holds all of the errors and warning *
146 //* produced by the analysis phase. *
147 //*******************************************