lm_switch needs to set p from tokend when there is no user action.
[external/ragel.git] / rlgen-cd / fsmcodegen.cpp
1 /*
2  *  Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
3  *            2004 Erich Ocean <eric.ocean@ampede.com>
4  *            2005 Alan West <alan@alanz.com>
5  */
6
7 /*  This file is part of Ragel.
8  *
9  *  Ragel is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  * 
14  *  Ragel is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  * 
19  *  You should have received a copy of the GNU General Public License
20  *  along with Ragel; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
22  */
23
24 #include "rlgen-cd.h"
25 #include "fsmcodegen.h"
26 #include "redfsm.h"
27 #include "gendata.h"
28 #include <sstream>
29 #include <string>
30 #include <assert.h>
31
32
33 using std::ostream;
34 using std::ostringstream;
35 using std::string;
36 using std::cerr;
37 using std::endl;
38
39 void lineDirective( ostream &out, char *fileName, int line )
40 {
41         if ( noLineDirectives )
42                 out << "/* ";
43
44         /* Write the preprocessor line info for to the input file. */
45         out << "#line " << line  << " \"";
46         for ( char *pc = fileName; *pc != 0; pc++ ) {
47                 if ( *pc == '\\' )
48                         out << "\\\\";
49                 else
50                         out << *pc;
51         }
52         out << '"';
53
54         if ( noLineDirectives )
55                 out << " */";
56
57         out << '\n';
58 }
59
60 void genLineDirective( ostream &out )
61 {
62         std::streambuf *sbuf = out.rdbuf();
63         output_filter *filter = static_cast<output_filter*>(sbuf);
64         lineDirective( out, filter->fileName, filter->line + 1 );
65 }
66
67
68 /* Init code gen with in parameters. */
69 FsmCodeGen::FsmCodeGen( ostream &out )
70 :
71         CodeGenData(out)
72 {
73 }
74
75 unsigned int FsmCodeGen::arrayTypeSize( unsigned long maxVal )
76 {
77         long long maxValLL = (long long) maxVal;
78         HostType *arrayType = keyOps->typeSubsumes( maxValLL );
79         assert( arrayType != 0 );
80         return arrayType->size;
81 }
82
83 string FsmCodeGen::ARRAY_TYPE( unsigned long maxVal )
84 {
85         long long maxValLL = (long long) maxVal;
86         HostType *arrayType = keyOps->typeSubsumes( maxValLL );
87         assert( arrayType != 0 );
88
89         string ret = arrayType->data1;
90         if ( arrayType->data2 != 0 ) {
91                 ret += " ";
92                 ret += arrayType->data2;
93         }
94         return ret;
95 }
96
97
98 /* Write out the fsm name. */
99 string FsmCodeGen::FSM_NAME()
100 {
101         return fsmName;
102 }
103
104 /* Emit the offset of the start state as a decimal integer. */
105 string FsmCodeGen::START_STATE_ID()
106 {
107         ostringstream ret;
108         ret << redFsm->startState->id;
109         return ret.str();
110 };
111
112 /* Write out the array of actions. */
113 std::ostream &FsmCodeGen::ACTIONS_ARRAY()
114 {
115         out << "\t0, ";
116         int totalActions = 1;
117         for ( ActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) {
118                 /* Write out the length, which will never be the last character. */
119                 out << act->key.length() << ", ";
120                 /* Put in a line break every 8 */
121                 if ( totalActions++ % 8 == 7 )
122                         out << "\n\t";
123
124                 for ( ActionTable::Iter item = act->key; item.lte(); item++ ) {
125                         out << item->value->actionId;
126                         if ( ! (act.last() && item.last()) )
127                                 out << ", ";
128
129                         /* Put in a line break every 8 */
130                         if ( totalActions++ % 8 == 7 )
131                                 out << "\n\t";
132                 }
133         }
134         out << "\n";
135         return out;
136 }
137
138
139 string FsmCodeGen::ACCESS()
140 {
141         ostringstream ret;
142         if ( accessExpr != 0 )
143                 INLINE_LIST( ret, accessExpr, 0, false, false );
144         return ret.str();
145 }
146
147
148 string FsmCodeGen::P()
149
150         ostringstream ret;
151         if ( pExpr == 0 )
152                 ret << "p";
153         else {
154                 ret << "(";
155                 INLINE_LIST( ret, pExpr, 0, false, false );
156                 ret << ")";
157         }
158         return ret.str();
159 }
160
161 string FsmCodeGen::PE()
162 {
163         ostringstream ret;
164         if ( peExpr == 0 )
165                 ret << "pe";
166         else {
167                 ret << "(";
168                 INLINE_LIST( ret, peExpr, 0, false, false );
169                 ret << ")";
170         }
171         return ret.str();
172 }
173
174 string FsmCodeGen::EOFV()
175 {
176         ostringstream ret;
177         if ( eofExpr == 0 )
178                 ret << "eof";
179         else {
180                 ret << "(";
181                 INLINE_LIST( ret, eofExpr, 0, false, false );
182                 ret << ")";
183         }
184         return ret.str();
185 }
186
187 string FsmCodeGen::CS()
188 {
189         ostringstream ret;
190         if ( csExpr == 0 )
191                 ret << ACCESS() << "cs";
192         else {
193                 /* Emit the user supplied method of retrieving the key. */
194                 ret << "(";
195                 INLINE_LIST( ret, csExpr, 0, false, false );
196                 ret << ")";
197         }
198         return ret.str();
199 }
200
201 string FsmCodeGen::TOP()
202 {
203         ostringstream ret;
204         if ( topExpr == 0 )
205                 ret << ACCESS() + "top";
206         else {
207                 ret << "(";
208                 INLINE_LIST( ret, topExpr, 0, false, false );
209                 ret << ")";
210         }
211         return ret.str();
212 }
213
214 string FsmCodeGen::STACK()
215 {
216         ostringstream ret;
217         if ( stackExpr == 0 )
218                 ret << ACCESS() + "stack";
219         else {
220                 ret << "(";
221                 INLINE_LIST( ret, stackExpr, 0, false, false );
222                 ret << ")";
223         }
224         return ret.str();
225 }
226
227 string FsmCodeGen::ACT()
228 {
229         ostringstream ret;
230         if ( actExpr == 0 )
231                 ret << ACCESS() + "act";
232         else {
233                 ret << "(";
234                 INLINE_LIST( ret, actExpr, 0, false, false );
235                 ret << ")";
236         }
237         return ret.str();
238 }
239
240 string FsmCodeGen::TOKSTART()
241 {
242         ostringstream ret;
243         if ( tokstartExpr == 0 )
244                 ret << ACCESS() + "ts";
245         else {
246                 ret << "(";
247                 INLINE_LIST( ret, tokstartExpr, 0, false, false );
248                 ret << ")";
249         }
250         return ret.str();
251 }
252
253 string FsmCodeGen::TOKEND()
254 {
255         ostringstream ret;
256         if ( tokendExpr == 0 )
257                 ret << ACCESS() + "te";
258         else {
259                 ret << "(";
260                 INLINE_LIST( ret, tokendExpr, 0, false, false );
261                 ret << ")";
262         }
263         return ret.str();
264 }
265
266 string FsmCodeGen::GET_WIDE_KEY()
267 {
268         if ( redFsm->anyConditions() ) 
269                 return "_widec";
270         else
271                 return GET_KEY();
272 }
273
274 string FsmCodeGen::GET_WIDE_KEY( RedStateAp *state )
275 {
276         if ( state->stateCondList.length() > 0 )
277                 return "_widec";
278         else
279                 return GET_KEY();
280 }
281
282 string FsmCodeGen::GET_KEY()
283 {
284         ostringstream ret;
285         if ( getKeyExpr != 0 ) { 
286                 /* Emit the user supplied method of retrieving the key. */
287                 ret << "(";
288                 INLINE_LIST( ret, getKeyExpr, 0, false, false );
289                 ret << ")";
290         }
291         else {
292                 /* Expression for retrieving the key, use simple dereference. */
293                 ret << "(*" << P() << ")";
294         }
295         return ret.str();
296 }
297
298 /* Write out level number of tabs. Makes the nested binary search nice
299  * looking. */
300 string FsmCodeGen::TABS( int level )
301 {
302         string result;
303         while ( level-- > 0 )
304                 result += "\t";
305         return result;
306 }
307
308 /* Write out a key from the fsm code gen. Depends on wether or not the key is
309  * signed. */
310 string FsmCodeGen::KEY( Key key )
311 {
312         ostringstream ret;
313         if ( keyOps->isSigned || !hostLang->explicitUnsigned )
314                 ret << key.getVal();
315         else
316                 ret << (unsigned long) key.getVal() << 'u';
317         return ret.str();
318 }
319
320 void FsmCodeGen::EXEC( ostream &ret, InlineItem *item, int targState, int inFinish )
321 {
322         /* The parser gives fexec two children. The double brackets are for D
323          * code. If the inline list is a single word it will get interpreted as a
324          * C-style cast by the D compiler. */
325         ret << "{" << P() << " = ((";
326         INLINE_LIST( ret, item->children, targState, inFinish, false );
327         ret << "))-1;}";
328 }
329
330 void FsmCodeGen::LM_SWITCH( ostream &ret, InlineItem *item, 
331                 int targState, int inFinish, bool csForced )
332 {
333         ret << 
334                 "       switch( " << ACT() << " ) {\n";
335
336         bool haveDefault = false;
337         for ( InlineList::Iter lma = *item->children; lma.lte(); lma++ ) {
338                 /* Write the case label, the action and the case break. */
339                 if ( lma->lmId < 0 ) {
340                         ret << "        default:\n";
341                         haveDefault = true;
342                 }
343                 else
344                         ret << "        case " << lma->lmId << ":\n";
345
346                 /* Write the block and close it off. */
347                 ret << "        {";
348                 INLINE_LIST( ret, lma->children, targState, inFinish, csForced );
349                 ret << "}\n";
350
351                 ret << "        break;\n";
352         }
353
354         if ( hostLang->lang == HostLang::D && !haveDefault )
355                 ret << "        default: break;";
356
357         ret << 
358                 "       }\n"
359                 "\t";
360 }
361
362 void FsmCodeGen::SET_ACT( ostream &ret, InlineItem *item )
363 {
364         ret << ACT() << " = " << item->lmId << ";";
365 }
366
367 void FsmCodeGen::SET_TOKEND( ostream &ret, InlineItem *item )
368 {
369         /* The tokend action sets tokend. */
370         ret << TOKEND() << " = " << P();
371         if ( item->offset != 0 ) 
372                 out << "+" << item->offset;
373         out << ";";
374 }
375
376 void FsmCodeGen::GET_TOKEND( ostream &ret, InlineItem *item )
377 {
378         ret << TOKEND();
379 }
380
381 void FsmCodeGen::INIT_TOKSTART( ostream &ret, InlineItem *item )
382 {
383         ret << TOKSTART() << " = " << NULL_ITEM() << ";";
384 }
385
386 void FsmCodeGen::INIT_ACT( ostream &ret, InlineItem *item )
387 {
388         ret << ACT() << " = 0;";
389 }
390
391 void FsmCodeGen::SET_TOKSTART( ostream &ret, InlineItem *item )
392 {
393         ret << TOKSTART() << " = " << P() << ";";
394 }
395
396 void FsmCodeGen::SUB_ACTION( ostream &ret, InlineItem *item, 
397                 int targState, bool inFinish, bool csForced )
398 {
399         if ( item->children->length() > 0 ) {
400                 /* Write the block and close it off. */
401                 ret << "{";
402                 INLINE_LIST( ret, item->children, targState, inFinish, csForced );
403                 ret << "}";
404         }
405 }
406
407
408 /* Write out an inline tree structure. Walks the list and possibly calls out
409  * to virtual functions than handle language specific items in the tree. */
410 void FsmCodeGen::INLINE_LIST( ostream &ret, InlineList *inlineList, 
411                 int targState, bool inFinish, bool csForced )
412 {
413         for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) {
414                 switch ( item->type ) {
415                 case InlineItem::Text:
416                         ret << item->data;
417                         break;
418                 case InlineItem::Goto:
419                         GOTO( ret, item->targState->id, inFinish );
420                         break;
421                 case InlineItem::Call:
422                         CALL( ret, item->targState->id, targState, inFinish );
423                         break;
424                 case InlineItem::Next:
425                         NEXT( ret, item->targState->id, inFinish );
426                         break;
427                 case InlineItem::Ret:
428                         RET( ret, inFinish );
429                         break;
430                 case InlineItem::PChar:
431                         ret << P();
432                         break;
433                 case InlineItem::Char:
434                         ret << GET_KEY();
435                         break;
436                 case InlineItem::Hold:
437                         ret << P() << "--;";
438                         break;
439                 case InlineItem::Exec:
440                         EXEC( ret, item, targState, inFinish );
441                         break;
442                 case InlineItem::Curs:
443                         CURS( ret, inFinish );
444                         break;
445                 case InlineItem::Targs:
446                         TARGS( ret, inFinish, targState );
447                         break;
448                 case InlineItem::Entry:
449                         ret << item->targState->id;
450                         break;
451                 case InlineItem::GotoExpr:
452                         GOTO_EXPR( ret, item, inFinish );
453                         break;
454                 case InlineItem::CallExpr:
455                         CALL_EXPR( ret, item, targState, inFinish );
456                         break;
457                 case InlineItem::NextExpr:
458                         NEXT_EXPR( ret, item, inFinish );
459                         break;
460                 case InlineItem::LmSwitch:
461                         LM_SWITCH( ret, item, targState, inFinish, csForced );
462                         break;
463                 case InlineItem::LmSetActId:
464                         SET_ACT( ret, item );
465                         break;
466                 case InlineItem::LmSetTokEnd:
467                         SET_TOKEND( ret, item );
468                         break;
469                 case InlineItem::LmGetTokEnd:
470                         GET_TOKEND( ret, item );
471                         break;
472                 case InlineItem::LmInitTokStart:
473                         INIT_TOKSTART( ret, item );
474                         break;
475                 case InlineItem::LmInitAct:
476                         INIT_ACT( ret, item );
477                         break;
478                 case InlineItem::LmSetTokStart:
479                         SET_TOKSTART( ret, item );
480                         break;
481                 case InlineItem::SubAction:
482                         SUB_ACTION( ret, item, targState, inFinish, csForced );
483                         break;
484                 case InlineItem::Break:
485                         BREAK( ret, targState, csForced );
486                         break;
487                 }
488         }
489 }
490 /* Write out paths in line directives. Escapes any special characters. */
491 string FsmCodeGen::LDIR_PATH( char *path )
492 {
493         ostringstream ret;
494         for ( char *pc = path; *pc != 0; pc++ ) {
495                 if ( *pc == '\\' )
496                         ret << "\\\\";
497                 else
498                         ret << *pc;
499         }
500         return ret.str();
501 }
502
503 void FsmCodeGen::ACTION( ostream &ret, Action *action, int targState, 
504                 bool inFinish, bool csForced )
505 {
506         /* Write the preprocessor line info for going into the source file. */
507         lineDirective( ret, sourceFileName, action->loc.line );
508
509         /* Write the block and close it off. */
510         ret << "\t{";
511         INLINE_LIST( ret, action->inlineList, targState, inFinish, csForced );
512         ret << "}\n";
513 }
514
515 void FsmCodeGen::CONDITION( ostream &ret, Action *condition )
516 {
517         ret << "\n";
518         lineDirective( ret, sourceFileName, condition->loc.line );
519         INLINE_LIST( ret, condition->inlineList, 0, false, false );
520 }
521
522 string FsmCodeGen::ERROR_STATE()
523 {
524         ostringstream ret;
525         if ( redFsm->errState != 0 )
526                 ret << redFsm->errState->id;
527         else
528                 ret << "-1";
529         return ret.str();
530 }
531
532 string FsmCodeGen::FIRST_FINAL_STATE()
533 {
534         ostringstream ret;
535         if ( redFsm->firstFinState != 0 )
536                 ret << redFsm->firstFinState->id;
537         else
538                 ret << redFsm->nextStateId;
539         return ret.str();
540 }
541
542 void FsmCodeGen::writeInit()
543 {
544         out << "        {\n";
545
546         if ( writeCS )
547                 out << "\t" << CS() << " = " << START() << ";\n";
548         
549         /* If there are any calls, then the stack top needs initialization. */
550         if ( redFsm->anyActionCalls() || redFsm->anyActionRets() )
551                 out << "\t" << TOP() << " = 0;\n";
552
553         if ( hasLongestMatch ) {
554                 out << 
555                         "       " << TOKSTART() << " = " << NULL_ITEM() << ";\n"
556                         "       " << TOKEND() << " = " << NULL_ITEM() << ";\n"
557                         "       " << ACT() << " = 0;\n";
558         }
559         out << "        }\n";
560 }
561
562 string FsmCodeGen::DATA_PREFIX()
563 {
564         if ( dataPrefix )
565                 return FSM_NAME() + "_";
566         return "";
567 }
568
569 /* Emit the alphabet data type. */
570 string FsmCodeGen::ALPH_TYPE()
571 {
572         string ret = keyOps->alphType->data1;
573         if ( keyOps->alphType->data2 != 0 ) {
574                 ret += " ";
575                 ret += + keyOps->alphType->data2;
576         }
577         return ret;
578 }
579
580 /* Emit the alphabet data type. */
581 string FsmCodeGen::WIDE_ALPH_TYPE()
582 {
583         string ret;
584         if ( redFsm->maxKey <= keyOps->maxKey )
585                 ret = ALPH_TYPE();
586         else {
587                 long long maxKeyVal = redFsm->maxKey.getLongLong();
588                 HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal );
589                 assert( wideType != 0 );
590
591                 ret = wideType->data1;
592                 if ( wideType->data2 != 0 ) {
593                         ret += " ";
594                         ret += wideType->data2;
595                 }
596         }
597         return ret;
598 }
599
600 void FsmCodeGen::STATE_IDS()
601 {
602         if ( redFsm->startState != 0 )
603                 STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << ";\n";
604
605         if ( writeFirstFinal )
606                 STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << ";\n";
607
608         if ( writeErr )
609                 STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << ";\n";
610
611         out << "\n";
612
613         if ( entryPointNames.length() > 0 ) {
614                 for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) {
615                         STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << 
616                                         " = " << entryPointIds[en.pos()] << ";\n";
617                 }
618                 out << "\n";
619         }
620 }
621
622
623 /*
624  * Language specific, but style independent code generators functions.
625  */
626
627 string CCodeGen::PTR_CONST()
628 {
629         return "const ";
630 }
631
632 std::ostream &CCodeGen::OPEN_ARRAY( string type, string name )
633 {
634         out << "static const " << type << " " << name << "[] = {\n";
635         return out;
636 }
637
638 std::ostream &CCodeGen::CLOSE_ARRAY()
639 {
640         return out << "};\n";
641 }
642
643 std::ostream &CCodeGen::STATIC_VAR( string type, string name )
644 {
645         out << "static const " << type << " " << name;
646         return out;
647 }
648
649 string CCodeGen::UINT( )
650 {
651         return "unsigned int";
652 }
653
654 string CCodeGen::ARR_OFF( string ptr, string offset )
655 {
656         return ptr + " + " + offset;
657 }
658
659 string CCodeGen::CAST( string type )
660 {
661         return "(" + type + ")";
662 }
663
664 string CCodeGen::NULL_ITEM()
665 {
666         return "0";
667 }
668
669 string CCodeGen::POINTER()
670 {
671         return " *";
672 }
673
674 std::ostream &CCodeGen::SWITCH_DEFAULT()
675 {
676         return out;
677 }
678
679 string CCodeGen::CTRL_FLOW()
680 {
681         return "";
682 }
683
684 void CCodeGen::writeExports()
685 {
686         if ( exportList.length() > 0 ) {
687                 for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) {
688                         out << "#define " << DATA_PREFIX() << "ex_" << ex->name << " " << 
689                                         KEY(ex->key) << "\n";
690                 }
691                 out << "\n";
692         }
693 }
694
695 /*
696  * D Specific
697  */
698
699 string DCodeGen::NULL_ITEM()
700 {
701         return "null";
702 }
703
704 string DCodeGen::POINTER()
705 {
706         // multiple items seperated by commas can also be pointer types.
707         return "* ";
708 }
709
710 string DCodeGen::PTR_CONST()
711 {
712         return "";
713 }
714
715 std::ostream &DCodeGen::OPEN_ARRAY( string type, string name )
716 {
717         out << "static const " << type << "[] " << name << " = [\n";
718         return out;
719 }
720
721 std::ostream &DCodeGen::CLOSE_ARRAY()
722 {
723         return out << "];\n";
724 }
725
726 std::ostream &DCodeGen::STATIC_VAR( string type, string name )
727 {
728         out << "static const " << type << " " << name;
729         return out;
730 }
731
732 string DCodeGen::ARR_OFF( string ptr, string offset )
733 {
734         return "&" + ptr + "[" + offset + "]";
735 }
736
737 string DCodeGen::CAST( string type )
738 {
739         return "cast(" + type + ")";
740 }
741
742 string DCodeGen::UINT( )
743 {
744         return "uint";
745 }
746
747 std::ostream &DCodeGen::SWITCH_DEFAULT()
748 {
749         out << "                default: break;\n";
750         return out;
751 }
752
753 string DCodeGen::CTRL_FLOW()
754 {
755         return "if (true) ";
756 }
757
758 void DCodeGen::writeExports()
759 {
760         if ( exportList.length() > 0 ) {
761                 for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) {
762                         out << "static const " << ALPH_TYPE() << " " << DATA_PREFIX() << 
763                                         "ex_" << ex->name << " = " << KEY(ex->key) << ";\n";
764                 }
765                 out << "\n";
766         }
767 }
768
769 /*
770  * End D-specific code.
771  */
772
773 void FsmCodeGen::finishRagelDef()
774 {
775         if ( codeStyle == GenGoto || codeStyle == GenFGoto || 
776                         codeStyle == GenIpGoto || codeStyle == GenSplit )
777         {
778                 /* For directly executable machines there is no required state
779                  * ordering. Choose a depth-first ordering to increase the
780                  * potential for fall-throughs. */
781                 redFsm->depthFirstOrdering();
782         }
783         else {
784                 /* The frontend will do this for us, but it may be a good idea to
785                  * force it if the intermediate file is edited. */
786                 redFsm->sortByStateId();
787         }
788
789         /* Choose default transitions and the single transition. */
790         redFsm->chooseDefaultSpan();
791                 
792         /* Maybe do flat expand, otherwise choose single. */
793         if ( codeStyle == GenFlat || codeStyle == GenFFlat )
794                 redFsm->makeFlat();
795         else
796                 redFsm->chooseSingle();
797
798         /* If any errors have occured in the input file then don't write anything. */
799         if ( gblErrorCount > 0 )
800                 return;
801         
802         if ( codeStyle == GenSplit )
803                 redFsm->partitionFsm( numSplitPartitions );
804
805         if ( codeStyle == GenIpGoto || codeStyle == GenSplit )
806                 redFsm->setInTrans();
807
808         /* Anlayze Machine will find the final action reference counts, among
809          * other things. We will use these in reporting the usage
810          * of fsm directives in action code. */
811         analyzeMachine();
812
813         /* Determine if we should use indicies. */
814         calcIndexSize();
815 }
816
817 ostream &FsmCodeGen::source_warning( const InputLoc &loc )
818 {
819         cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: ";
820         return cerr;
821 }
822
823 ostream &FsmCodeGen::source_error( const InputLoc &loc )
824 {
825         gblErrorCount += 1;
826         assert( sourceFileName != 0 );
827         cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": ";
828         return cerr;
829 }
830