xref: /aosp_15_r20/external/antlr/runtime/Cpp/include/antlr3exception.inl (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger RobotANTLR_BEGIN_NAMESPACE()
2*16467b97STreehugger Robot
3*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
4*16467b97STreehugger RobotANTLR_ExceptionBase<ImplTraits, StreamType>::ANTLR_ExceptionBase(const StringType& message)
5*16467b97STreehugger Robot	:m_message(message)
6*16467b97STreehugger Robot	,m_input(NULL)
7*16467b97STreehugger Robot{
8*16467b97STreehugger Robot	m_index = 0;
9*16467b97STreehugger Robot	m_token	= NULL;
10*16467b97STreehugger Robot	m_expecting = 0;
11*16467b97STreehugger Robot	m_expectingSet = NULL;
12*16467b97STreehugger Robot	m_node = NULL;
13*16467b97STreehugger Robot	m_c = 0;
14*16467b97STreehugger Robot	m_line = 0;
15*16467b97STreehugger Robot	m_charPositionInLine = 0;
16*16467b97STreehugger Robot	m_decisionNum = 0;
17*16467b97STreehugger Robot	m_state = 0;
18*16467b97STreehugger Robot	m_nextException = NULL;
19*16467b97STreehugger Robot}
20*16467b97STreehugger Robot
21*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
22*16467b97STreehugger RobotANTLR_INLINE typename ANTLR_ExceptionBase<ImplTraits, StreamType>::StringType& ANTLR_ExceptionBase<ImplTraits, StreamType>::get_message()
23*16467b97STreehugger Robot{
24*16467b97STreehugger Robot	return m_message;
25*16467b97STreehugger Robot}
26*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
27*16467b97STreehugger RobotANTLR_INLINE typename ANTLR_ExceptionBase<ImplTraits, StreamType>::StringType& ANTLR_ExceptionBase<ImplTraits, StreamType>::get_streamName()
28*16467b97STreehugger Robot{
29*16467b97STreehugger Robot	return m_streamName;
30*16467b97STreehugger Robot}
31*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
32*16467b97STreehugger RobotANTLR_INLINE ANTLR_MARKER ANTLR_ExceptionBase<ImplTraits, StreamType>::get_index() const
33*16467b97STreehugger Robot{
34*16467b97STreehugger Robot	return m_index;
35*16467b97STreehugger Robot}
36*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
37*16467b97STreehugger RobotANTLR_INLINE const typename ANTLR_ExceptionBase<ImplTraits, StreamType>::TokenType* ANTLR_ExceptionBase<ImplTraits, StreamType>::get_token() const
38*16467b97STreehugger Robot{
39*16467b97STreehugger Robot	return m_token;
40*16467b97STreehugger Robot}
41*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
42*16467b97STreehugger RobotANTLR_INLINE typename ANTLR_ExceptionBase<ImplTraits, StreamType>::ExceptionBaseType* ANTLR_ExceptionBase<ImplTraits, StreamType>::get_nextException() const
43*16467b97STreehugger Robot{
44*16467b97STreehugger Robot	return m_nextException;
45*16467b97STreehugger Robot}
46*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
47*16467b97STreehugger RobotANTLR_INLINE ANTLR_UINT32 ANTLR_ExceptionBase<ImplTraits, StreamType>::get_expecting() const
48*16467b97STreehugger Robot{
49*16467b97STreehugger Robot	return m_expecting;
50*16467b97STreehugger Robot}
51*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
52*16467b97STreehugger RobotANTLR_INLINE typename ANTLR_ExceptionBase<ImplTraits, StreamType>::BitsetListType* ANTLR_ExceptionBase<ImplTraits, StreamType>::get_expectingSet() const
53*16467b97STreehugger Robot{
54*16467b97STreehugger Robot	return m_expectingSet;
55*16467b97STreehugger Robot}
56*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
57*16467b97STreehugger RobotANTLR_INLINE typename ANTLR_ExceptionBase<ImplTraits, StreamType>::TokenType* ANTLR_ExceptionBase<ImplTraits, StreamType>::get_node() const
58*16467b97STreehugger Robot{
59*16467b97STreehugger Robot	return m_node;
60*16467b97STreehugger Robot}
61*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
62*16467b97STreehugger RobotANTLR_INLINE ANTLR_UCHAR ANTLR_ExceptionBase<ImplTraits, StreamType>::get_c() const
63*16467b97STreehugger Robot{
64*16467b97STreehugger Robot	return m_c;
65*16467b97STreehugger Robot}
66*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
67*16467b97STreehugger RobotANTLR_INLINE ANTLR_UINT32 ANTLR_ExceptionBase<ImplTraits, StreamType>::get_line() const
68*16467b97STreehugger Robot{
69*16467b97STreehugger Robot	return m_line;
70*16467b97STreehugger Robot}
71*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
72*16467b97STreehugger RobotANTLR_INLINE ANTLR_INT32 ANTLR_ExceptionBase<ImplTraits, StreamType>::get_charPositionInLine() const
73*16467b97STreehugger Robot{
74*16467b97STreehugger Robot	return m_charPositionInLine;
75*16467b97STreehugger Robot}
76*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
77*16467b97STreehugger RobotANTLR_INLINE ANTLR_UINT32 ANTLR_ExceptionBase<ImplTraits, StreamType>::get_decisionNum() const
78*16467b97STreehugger Robot{
79*16467b97STreehugger Robot	return m_decisionNum;
80*16467b97STreehugger Robot}
81*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
82*16467b97STreehugger RobotANTLR_INLINE ANTLR_UINT32 ANTLR_ExceptionBase<ImplTraits, StreamType>::get_state() const
83*16467b97STreehugger Robot{
84*16467b97STreehugger Robot	return m_state;
85*16467b97STreehugger Robot}
86*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
87*16467b97STreehugger RobotANTLR_INLINE typename ANTLR_ExceptionBase<ImplTraits, StreamType>::StringType& ANTLR_ExceptionBase<ImplTraits, StreamType>::get_ruleName()
88*16467b97STreehugger Robot{
89*16467b97STreehugger Robot	return m_ruleName;
90*16467b97STreehugger Robot}
91*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
92*16467b97STreehugger RobotANTLR_INLINE typename ANTLR_ExceptionBase<ImplTraits, StreamType>::IntStreamType* ANTLR_ExceptionBase<ImplTraits, StreamType>::get_input() const
93*16467b97STreehugger Robot{
94*16467b97STreehugger Robot	return m_input;
95*16467b97STreehugger Robot}
96*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
97*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_message( const StringType& message )
98*16467b97STreehugger Robot{
99*16467b97STreehugger Robot	m_message = message;
100*16467b97STreehugger Robot}
101*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
102*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_streamName( const StringType& streamName )
103*16467b97STreehugger Robot{
104*16467b97STreehugger Robot	m_streamName = streamName;
105*16467b97STreehugger Robot}
106*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
107*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_index( ANTLR_MARKER index )
108*16467b97STreehugger Robot{
109*16467b97STreehugger Robot	m_index = index;
110*16467b97STreehugger Robot}
111*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
112*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_token( const TokenType* token )
113*16467b97STreehugger Robot{
114*16467b97STreehugger Robot	m_token = token;
115*16467b97STreehugger Robot}
116*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
117*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_nextException( ExceptionBaseType* nextException )
118*16467b97STreehugger Robot{
119*16467b97STreehugger Robot	m_nextException = nextException;
120*16467b97STreehugger Robot}
121*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
122*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_expecting( ANTLR_UINT32 expecting )
123*16467b97STreehugger Robot{
124*16467b97STreehugger Robot	m_expecting = expecting;
125*16467b97STreehugger Robot}
126*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
127*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_expectingSet( BitsetListType* expectingSet )
128*16467b97STreehugger Robot{
129*16467b97STreehugger Robot	m_expectingSet = expectingSet;
130*16467b97STreehugger Robot}
131*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
132*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_node( TokenType* node )
133*16467b97STreehugger Robot{
134*16467b97STreehugger Robot	m_node = node;
135*16467b97STreehugger Robot}
136*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
137*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_c( ANTLR_UCHAR c )
138*16467b97STreehugger Robot{
139*16467b97STreehugger Robot	m_c = c;
140*16467b97STreehugger Robot}
141*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
142*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_line( ANTLR_UINT32 line )
143*16467b97STreehugger Robot{
144*16467b97STreehugger Robot	m_line = line;
145*16467b97STreehugger Robot}
146*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
147*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_charPositionInLine( ANTLR_INT32 charPositionInLine )
148*16467b97STreehugger Robot{
149*16467b97STreehugger Robot	m_charPositionInLine = charPositionInLine;
150*16467b97STreehugger Robot}
151*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
152*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_decisionNum( ANTLR_UINT32 decisionNum )
153*16467b97STreehugger Robot{
154*16467b97STreehugger Robot	m_decisionNum = decisionNum;
155*16467b97STreehugger Robot}
156*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
157*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_state( ANTLR_UINT32 state )
158*16467b97STreehugger Robot{
159*16467b97STreehugger Robot	m_state = state;
160*16467b97STreehugger Robot}
161*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
162*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_ruleName( const StringType& ruleName )
163*16467b97STreehugger Robot{
164*16467b97STreehugger Robot	m_ruleName = ruleName;
165*16467b97STreehugger Robot}
166*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
167*16467b97STreehugger RobotANTLR_INLINE void ANTLR_ExceptionBase<ImplTraits, StreamType>::set_input( IntStreamType* input )
168*16467b97STreehugger Robot{
169*16467b97STreehugger Robot	m_input = input;
170*16467b97STreehugger Robot}
171*16467b97STreehugger Robot
172*16467b97STreehugger Robot
173*16467b97STreehugger Robottemplate<class ImplTraits, ExceptionType Ex, class StreamType>
174*16467b97STreehugger Robot	template<typename BaseRecognizerType>
175*16467b97STreehugger RobotANTLR_Exception<ImplTraits, Ex, StreamType>::ANTLR_Exception(BaseRecognizerType* recognizer, const StringType& message)
176*16467b97STreehugger Robot	:BaseType( message )
177*16467b97STreehugger Robot{
178*16467b97STreehugger Robot	recognizer->get_super()->fillExceptionData( this );
179*16467b97STreehugger Robot	BaseType::m_input	= recognizer->get_super()->get_istream();
180*16467b97STreehugger Robot	BaseType::m_nextException	= recognizer->get_state()->get_exception();	/* So we don't leak the memory */
181*16467b97STreehugger Robot	recognizer->get_state()->set_exception(this);
182*16467b97STreehugger Robot	recognizer->get_state()->set_error( true );	    /* Exception is outstanding	*/
183*16467b97STreehugger Robot}
184*16467b97STreehugger Robot
185*16467b97STreehugger Robottemplate<class ImplTraits, ExceptionType Ex, class StreamType>
186*16467b97STreehugger RobotANTLR_UINT32 ANTLR_Exception<ImplTraits, Ex, StreamType>::getType() const
187*16467b97STreehugger Robot{
188*16467b97STreehugger Robot	return static_cast<ANTLR_UINT32>(Ex);
189*16467b97STreehugger Robot}
190*16467b97STreehugger Robot
191*16467b97STreehugger Robottemplate<class ImplTraits, ExceptionType Ex, class StreamType>
192*16467b97STreehugger Robotvoid ANTLR_Exception<ImplTraits, Ex, StreamType>::print() const
193*16467b97STreehugger Robot{
194*16467b97STreehugger Robot   /* Ensure valid pointer
195*16467b97STreehugger Robot     */
196*16467b97STreehugger Robot	/* Number if no message, else the message
197*16467b97STreehugger Robot	*/
198*16467b97STreehugger Robot	if  ( BaseType::m_message.empty() )
199*16467b97STreehugger Robot	{
200*16467b97STreehugger Robot		fprintf(stderr, "ANTLR3_EXCEPTION number %d (%08X).\n", Ex, Ex);
201*16467b97STreehugger Robot	}
202*16467b97STreehugger Robot	else
203*16467b97STreehugger Robot	{
204*16467b97STreehugger Robot		fprintf(stderr, "ANTLR3_EXCEPTION: %s\n", BaseType::m_message.c_str() );
205*16467b97STreehugger Robot	}
206*16467b97STreehugger Robot}
207*16467b97STreehugger Robot
208*16467b97STreehugger Robottemplate<class ImplTraits, ExceptionType Ex, class StreamType>
209*16467b97STreehugger Robottypename ANTLR_Exception<ImplTraits, Ex, StreamType>::StringType
210*16467b97STreehugger Robot	ANTLR_Exception<ImplTraits, Ex, StreamType>::getName() const
211*16467b97STreehugger Robot{
212*16467b97STreehugger Robot	const char* exArray[] = {
213*16467b97STreehugger Robot						"org.antlr.runtime.RecognitionException"
214*16467b97STreehugger Robot						, "org.antlr.runtime.MismatchedTokenException"
215*16467b97STreehugger Robot						, "org.antlr.runtime.NoViableAltException"
216*16467b97STreehugger Robot						, "org.antlr.runtime.MismatchedSetException"
217*16467b97STreehugger Robot						, "org.antlr.runtime.EarlyExitException"
218*16467b97STreehugger Robot						, "org.antlr.runtime.FailedPredicateException"
219*16467b97STreehugger Robot						, "org.antlr.runtime.MismatchedTreeNodeException"
220*16467b97STreehugger Robot						, "org.antlr.runtime.tree.RewriteEarlyExitException"
221*16467b97STreehugger Robot						, "org.antlr.runtime.UnwantedTokenException"
222*16467b97STreehugger Robot						, "org.antlr.runtime.MissingTokenException"
223*16467b97STreehugger Robot					  };
224*16467b97STreehugger Robot	return StringType(exArray[Ex]);
225*16467b97STreehugger Robot}
226*16467b97STreehugger Robot
227*16467b97STreehugger Robottemplate<class ImplTraits, ExceptionType Ex, class StreamType>
228*16467b97STreehugger Robotvoid ANTLR_Exception<ImplTraits, Ex, StreamType>::displayRecognitionError( ANTLR_UINT8** tokenNames,
229*16467b97STreehugger Robot																			StringStreamType& str_stream ) const
230*16467b97STreehugger Robot{
231*16467b97STreehugger Robot	switch( Ex )
232*16467b97STreehugger Robot	{
233*16467b97STreehugger Robot	case RECOGNITION_EXCEPTION:
234*16467b97STreehugger Robot		// Indicates that the recognizer received a token
235*16467b97STreehugger Robot		// in the input that was not predicted. This is the basic exception type
236*16467b97STreehugger Robot		// from which all others are derived. So we assume it was a syntax error.
237*16467b97STreehugger Robot		// You may get this if there are not more tokens and more are needed
238*16467b97STreehugger Robot		// to complete a parse for instance.
239*16467b97STreehugger Robot		//
240*16467b97STreehugger Robot		str_stream << " : syntax error...\n";
241*16467b97STreehugger Robot		break;
242*16467b97STreehugger Robot	case UNWANTED_TOKEN_EXCEPTION:
243*16467b97STreehugger Robot		// Indicates that the recognizer was fed a token which seesm to be
244*16467b97STreehugger Robot		// spurious input. We can detect this when the token that follows
245*16467b97STreehugger Robot		// this unwanted token would normally be part of the syntactically
246*16467b97STreehugger Robot		// correct stream. Then we can see that the token we are looking at
247*16467b97STreehugger Robot		// is just something that should not be there and throw this exception.
248*16467b97STreehugger Robot		//
249*16467b97STreehugger Robot		if	(tokenNames == NULL)
250*16467b97STreehugger Robot		{
251*16467b97STreehugger Robot			str_stream << " : Extraneous input...";
252*16467b97STreehugger Robot		}
253*16467b97STreehugger Robot		else
254*16467b97STreehugger Robot		{
255*16467b97STreehugger Robot			if	( BaseType::m_expecting == ImplTraits::CommonTokenType::TOKEN_EOF)
256*16467b97STreehugger Robot			{
257*16467b97STreehugger Robot				str_stream << " : Extraneous input - expected <EOF>\n";
258*16467b97STreehugger Robot			}
259*16467b97STreehugger Robot			else
260*16467b97STreehugger Robot			{
261*16467b97STreehugger Robot				str_stream << " : Extraneous input - expected "
262*16467b97STreehugger Robot						   << tokenNames[ BaseType::m_expecting] << " ...\n";
263*16467b97STreehugger Robot			}
264*16467b97STreehugger Robot		}
265*16467b97STreehugger Robot		break;
266*16467b97STreehugger Robot	case MISSING_TOKEN_EXCEPTION:
267*16467b97STreehugger Robot		// Indicates that the recognizer detected that the token we just
268*16467b97STreehugger Robot		// hit would be valid syntactically if preceeded by a particular
269*16467b97STreehugger Robot		// token. Perhaps a missing ';' at line end or a missing ',' in an
270*16467b97STreehugger Robot		// expression list, and such like.
271*16467b97STreehugger Robot		//
272*16467b97STreehugger Robot		if	(tokenNames == NULL)
273*16467b97STreehugger Robot		{
274*16467b97STreehugger Robot			str_stream << " : Missing token ("
275*16467b97STreehugger Robot					   << BaseType::m_expecting << ")...\n";
276*16467b97STreehugger Robot		}
277*16467b97STreehugger Robot		else
278*16467b97STreehugger Robot		{
279*16467b97STreehugger Robot			if	( BaseType::m_expecting == ImplTraits::CommonTokenType::TOKEN_EOF )
280*16467b97STreehugger Robot			{
281*16467b97STreehugger Robot				str_stream <<" : Missing <EOF>\n";
282*16467b97STreehugger Robot			}
283*16467b97STreehugger Robot			else
284*16467b97STreehugger Robot			{
285*16467b97STreehugger Robot				str_stream << " : Missing " << tokenNames[BaseType::m_expecting] <<" \n";
286*16467b97STreehugger Robot			}
287*16467b97STreehugger Robot		}
288*16467b97STreehugger Robot		break;
289*16467b97STreehugger Robot	case NO_VIABLE_ALT_EXCEPTION:
290*16467b97STreehugger Robot		// We could not pick any alt decision from the input given
291*16467b97STreehugger Robot		// so god knows what happened - however when you examine your grammar,
292*16467b97STreehugger Robot		// you should. It means that at the point where the current token occurred
293*16467b97STreehugger Robot		// that the DFA indicates nowhere to go from here.
294*16467b97STreehugger Robot		//
295*16467b97STreehugger Robot		str_stream << " : cannot match to any predicted input...\n";
296*16467b97STreehugger Robot		break;
297*16467b97STreehugger Robot	case MISMATCHED_SET_EXCEPTION:
298*16467b97STreehugger Robot		{
299*16467b97STreehugger Robot			ANTLR_UINT32	  count;
300*16467b97STreehugger Robot			ANTLR_UINT32	  bit;
301*16467b97STreehugger Robot			ANTLR_UINT32	  size;
302*16467b97STreehugger Robot			ANTLR_UINT32	  numbits;
303*16467b97STreehugger Robot			BitsetType*	  errBits;
304*16467b97STreehugger Robot
305*16467b97STreehugger Robot			// This means we were able to deal with one of a set of
306*16467b97STreehugger Robot			// possible tokens at this point, but we did not see any
307*16467b97STreehugger Robot			// member of that set.
308*16467b97STreehugger Robot			//
309*16467b97STreehugger Robot			str_stream << " : unexpected input...\n  expected one of : ";
310*16467b97STreehugger Robot
311*16467b97STreehugger Robot			// What tokens could we have accepted at this point in the
312*16467b97STreehugger Robot			// parse?
313*16467b97STreehugger Robot			//
314*16467b97STreehugger Robot			count   = 0;
315*16467b97STreehugger Robot			errBits = BaseType::m_expectingSet->bitsetLoad();
316*16467b97STreehugger Robot			numbits = errBits->numBits();
317*16467b97STreehugger Robot			size    = errBits->size();
318*16467b97STreehugger Robot
319*16467b97STreehugger Robot			if  (size > 0)
320*16467b97STreehugger Robot			{
321*16467b97STreehugger Robot				// However many tokens we could have dealt with here, it is usually
322*16467b97STreehugger Robot				// not useful to print ALL of the set here. I arbitrarily chose 8
323*16467b97STreehugger Robot				// here, but you should do whatever makes sense for you of course.
324*16467b97STreehugger Robot				// No token number 0, so look for bit 1 and on.
325*16467b97STreehugger Robot				//
326*16467b97STreehugger Robot				for	(bit = 1; bit < numbits && count < 8 && count < size; bit++)
327*16467b97STreehugger Robot				{
328*16467b97STreehugger Robot					// TODO: This doesn;t look right - should be asking if the bit is set!!
329*16467b97STreehugger Robot					//
330*16467b97STreehugger Robot					if  (tokenNames[bit])
331*16467b97STreehugger Robot					{
332*16467b97STreehugger Robot						str_stream <<  ( count > 0 ? ", " : "" )
333*16467b97STreehugger Robot								   <<  tokenNames[bit];
334*16467b97STreehugger Robot						count++;
335*16467b97STreehugger Robot					}
336*16467b97STreehugger Robot				}
337*16467b97STreehugger Robot				str_stream << "\n";
338*16467b97STreehugger Robot			}
339*16467b97STreehugger Robot			else
340*16467b97STreehugger Robot			{
341*16467b97STreehugger Robot				str_stream << "Actually dude, we didn't seem to be expecting anything here, or at least\n";
342*16467b97STreehugger Robot				str_stream << "I could not work out what I was expecting, like so many of us these days!\n";
343*16467b97STreehugger Robot			}
344*16467b97STreehugger Robot		}
345*16467b97STreehugger Robot		break;
346*16467b97STreehugger Robot	case EARLY_EXIT_EXCEPTION:
347*16467b97STreehugger Robot		str_stream << " : missing elements...\n";
348*16467b97STreehugger Robot		break;
349*16467b97STreehugger Robot	default:
350*16467b97STreehugger Robot		str_stream << " : syntax not recognized...\n";
351*16467b97STreehugger Robot		break;
352*16467b97STreehugger Robot	}
353*16467b97STreehugger Robot}
354*16467b97STreehugger Robot
355*16467b97STreehugger Robottemplate<class ImplTraits, class StreamType>
356*16467b97STreehugger RobotANTLR_ExceptionBase<ImplTraits,StreamType>::~ANTLR_ExceptionBase()
357*16467b97STreehugger Robot{
358*16467b97STreehugger Robot	ANTLR_ExceptionBase<ImplTraits,StreamType>* next;
359*16467b97STreehugger Robot	ANTLR_ExceptionBase<ImplTraits,StreamType>* ex = m_nextException;
360*16467b97STreehugger Robot
361*16467b97STreehugger Robot    /* Ensure valid pointer
362*16467b97STreehugger Robot     */
363*16467b97STreehugger Robot    while   (ex != NULL)
364*16467b97STreehugger Robot    {
365*16467b97STreehugger Robot		/* Pick up anythign following now, before we free the
366*16467b97STreehugger Robot		 * current memory block.
367*16467b97STreehugger Robot		 */
368*16467b97STreehugger Robot		next	= ex->m_nextException;
369*16467b97STreehugger Robot		ex->m_nextException = NULL;
370*16467b97STreehugger Robot
371*16467b97STreehugger Robot		/* Free the actual structure itself
372*16467b97STreehugger Robot		 */
373*16467b97STreehugger Robot		delete ex;
374*16467b97STreehugger Robot
375*16467b97STreehugger Robot		ex = next;
376*16467b97STreehugger Robot    }
377*16467b97STreehugger Robot}
378*16467b97STreehugger Robot
379*16467b97STreehugger RobotANTLR_END_NAMESPACE()
380