In the variable statement changed the name "curstate" to "cs" (the default
[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 );
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 );
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 );
169                 ret << ")";
170         }
171         return ret.str();
172 }
173
174 string FsmCodeGen::CS()
175 {
176         ostringstream ret;
177         if ( csExpr == 0 )
178                 ret << ACCESS() << "cs";
179         else {
180                 /* Emit the user supplied method of retrieving the key. */
181                 ret << "(";
182                 INLINE_LIST( ret, csExpr, 0, false );
183                 ret << ")";
184         }
185         return ret.str();
186 }
187
188 string FsmCodeGen::TOP()
189 {
190         ostringstream ret;
191         if ( topExpr == 0 )
192                 ret << ACCESS() + "top";
193         else {
194                 ret << "(";
195                 INLINE_LIST( ret, topExpr, 0, false );
196                 ret << ")";
197         }
198         return ret.str();
199 }
200
201 string FsmCodeGen::STACK()
202 {
203         ostringstream ret;
204         if ( stackExpr == 0 )
205                 ret << ACCESS() + "stack";
206         else {
207                 ret << "(";
208                 INLINE_LIST( ret, stackExpr, 0, false );
209                 ret << ")";
210         }
211         return ret.str();
212 }
213
214 string FsmCodeGen::ACT()
215 {
216         ostringstream ret;
217         if ( actExpr == 0 )
218                 ret << ACCESS() + "act";
219         else {
220                 ret << "(";
221                 INLINE_LIST( ret, actExpr, 0, false );
222                 ret << ")";
223         }
224         return ret.str();
225 }
226
227 string FsmCodeGen::TOKSTART()
228 {
229         ostringstream ret;
230         if ( tokstartExpr == 0 )
231                 ret << ACCESS() + "tokstart";
232         else {
233                 ret << "(";
234                 INLINE_LIST( ret, tokstartExpr, 0, false );
235                 ret << ")";
236         }
237         return ret.str();
238 }
239
240 string FsmCodeGen::TOKEND()
241 {
242         ostringstream ret;
243         if ( tokendExpr == 0 )
244                 ret << ACCESS() + "tokend";
245         else {
246                 ret << "(";
247                 INLINE_LIST( ret, tokendExpr, 0, false );
248                 ret << ")";
249         }
250         return ret.str();
251 }
252
253 string FsmCodeGen::GET_WIDE_KEY()
254 {
255         if ( redFsm->anyConditions() ) 
256                 return "_widec";
257         else
258                 return GET_KEY();
259 }
260
261 string FsmCodeGen::GET_WIDE_KEY( RedStateAp *state )
262 {
263         if ( state->stateCondList.length() > 0 )
264                 return "_widec";
265         else
266                 return GET_KEY();
267 }
268
269 string FsmCodeGen::GET_KEY()
270 {
271         ostringstream ret;
272         if ( getKeyExpr != 0 ) { 
273                 /* Emit the user supplied method of retrieving the key. */
274                 ret << "(";
275                 INLINE_LIST( ret, getKeyExpr, 0, false );
276                 ret << ")";
277         }
278         else {
279                 /* Expression for retrieving the key, use simple dereference. */
280                 ret << "(*" << P() << ")";
281         }
282         return ret.str();
283 }
284
285 /* Write out level number of tabs. Makes the nested binary search nice
286  * looking. */
287 string FsmCodeGen::TABS( int level )
288 {
289         string result;
290         while ( level-- > 0 )
291                 result += "\t";
292         return result;
293 }
294
295 /* Write out a key from the fsm code gen. Depends on wether or not the key is
296  * signed. */
297 string FsmCodeGen::KEY( Key key )
298 {
299         ostringstream ret;
300         if ( keyOps->isSigned || !hostLang->explicitUnsigned )
301                 ret << key.getVal();
302         else
303                 ret << (unsigned long) key.getVal() << 'u';
304         return ret.str();
305 }
306
307 void FsmCodeGen::EXEC( ostream &ret, InlineItem *item, int targState, int inFinish )
308 {
309         /* The parser gives fexec two children. The double brackets are for D
310          * code. If the inline list is a single word it will get interpreted as a
311          * C-style cast by the D compiler. */
312         ret << "{" << P() << " = ((";
313         INLINE_LIST( ret, item->children, targState, inFinish );
314         ret << "))-1;}";
315 }
316
317 void FsmCodeGen::EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish )
318 {
319         /* Tokend version of exec. */
320
321         /* The parser gives fexec two children. The double brackets are for D
322          * code. If the inline list is a single word it will get interpreted as a
323          * C-style cast by the D compiler. */
324         ret << "{" << TOKEND() << " = ((";
325         INLINE_LIST( ret, item->children, targState, inFinish );
326         ret << "));}";
327 }
328
329
330 void FsmCodeGen::LM_SWITCH( ostream &ret, InlineItem *item, 
331                 int targState, int inFinish )
332 {
333         ret << 
334                 "       switch( " << ACT() << " ) {\n";
335
336         /* If the switch handles error then we also forced the error state. It
337          * will exist. */
338         if ( item->handlesError ) {
339                 ret << "        case 0: " << TOKEND() << " = " << TOKSTART() << "; ";
340                 GOTO( ret, redFsm->errState->id, inFinish );
341                 ret << "\n";
342         }
343
344         for ( InlineList::Iter lma = *item->children; lma.lte(); lma++ ) {
345                 /* Write the case label, the action and the case break. */
346                 ret << "        case " << lma->lmId << ":\n";
347
348                 /* Write the block and close it off. */
349                 ret << "        {";
350                 INLINE_LIST( ret, lma->children, targState, inFinish );
351                 ret << "}\n";
352
353                 ret << "        break;\n";
354         }
355         /* Default required for D code. */
356         ret << 
357                 "       default: break;\n"
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 )
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 );
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 )
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::HoldTE:
443                         ret << TOKEND() << "--;";
444                         break;
445                 case InlineItem::ExecTE:
446                         EXECTE( ret, item, targState, inFinish );
447                         break;
448                 case InlineItem::Curs:
449                         CURS( ret, inFinish );
450                         break;
451                 case InlineItem::Targs:
452                         TARGS( ret, inFinish, targState );
453                         break;
454                 case InlineItem::Entry:
455                         ret << item->targState->id;
456                         break;
457                 case InlineItem::GotoExpr:
458                         GOTO_EXPR( ret, item, inFinish );
459                         break;
460                 case InlineItem::CallExpr:
461                         CALL_EXPR( ret, item, targState, inFinish );
462                         break;
463                 case InlineItem::NextExpr:
464                         NEXT_EXPR( ret, item, inFinish );
465                         break;
466                 case InlineItem::LmSwitch:
467                         LM_SWITCH( ret, item, targState, inFinish );
468                         break;
469                 case InlineItem::LmSetActId:
470                         SET_ACT( ret, item );
471                         break;
472                 case InlineItem::LmSetTokEnd:
473                         SET_TOKEND( ret, item );
474                         break;
475                 case InlineItem::LmGetTokEnd:
476                         GET_TOKEND( ret, item );
477                         break;
478                 case InlineItem::LmInitTokStart:
479                         INIT_TOKSTART( ret, item );
480                         break;
481                 case InlineItem::LmInitAct:
482                         INIT_ACT( ret, item );
483                         break;
484                 case InlineItem::LmSetTokStart:
485                         SET_TOKSTART( ret, item );
486                         break;
487                 case InlineItem::SubAction:
488                         SUB_ACTION( ret, item, targState, inFinish );
489                         break;
490                 case InlineItem::Break:
491                         BREAK( ret, targState );
492                         break;
493                 }
494         }
495 }
496 /* Write out paths in line directives. Escapes any special characters. */
497 string FsmCodeGen::LDIR_PATH( char *path )
498 {
499         ostringstream ret;
500         for ( char *pc = path; *pc != 0; pc++ ) {
501                 if ( *pc == '\\' )
502                         ret << "\\\\";
503                 else
504                         ret << *pc;
505         }
506         return ret.str();
507 }
508
509 void FsmCodeGen::ACTION( ostream &ret, Action *action, int targState, bool inFinish )
510 {
511         /* Write the preprocessor line info for going into the source file. */
512         lineDirective( ret, sourceFileName, action->loc.line );
513
514         /* Write the block and close it off. */
515         ret << "\t{";
516         INLINE_LIST( ret, action->inlineList, targState, inFinish );
517         ret << "}\n";
518 }
519
520 void FsmCodeGen::CONDITION( ostream &ret, Action *condition )
521 {
522         ret << "\n";
523         lineDirective( ret, sourceFileName, condition->loc.line );
524         INLINE_LIST( ret, condition->inlineList, 0, false );
525 }
526
527 string FsmCodeGen::ERROR_STATE()
528 {
529         ostringstream ret;
530         if ( redFsm->errState != 0 )
531                 ret << redFsm->errState->id;
532         else
533                 ret << "-1";
534         return ret.str();
535 }
536
537 string FsmCodeGen::FIRST_FINAL_STATE()
538 {
539         ostringstream ret;
540         if ( redFsm->firstFinState != 0 )
541                 ret << redFsm->firstFinState->id;
542         else
543                 ret << redFsm->nextStateId;
544         return ret.str();
545 }
546
547 void FsmCodeGen::writeInit()
548 {
549         out << "        {\n";
550
551         if ( writeCS )
552                 out << "\t" << CS() << " = " << START() << ";\n";
553         
554         /* If there are any calls, then the stack top needs initialization. */
555         if ( redFsm->anyActionCalls() || redFsm->anyActionRets() )
556                 out << "\t" << TOP() << " = 0;\n";
557
558         if ( hasLongestMatch ) {
559                 out << 
560                         "       " << TOKSTART() << " = " << NULL_ITEM() << ";\n"
561                         "       " << TOKEND() << " = " << NULL_ITEM() << ";\n"
562                         "       " << ACT() << " = 0;\n";
563         }
564         out << "        }\n";
565 }
566
567 string FsmCodeGen::DATA_PREFIX()
568 {
569         if ( dataPrefix )
570                 return FSM_NAME() + "_";
571         return "";
572 }
573
574 /* Emit the alphabet data type. */
575 string FsmCodeGen::ALPH_TYPE()
576 {
577         string ret = keyOps->alphType->data1;
578         if ( keyOps->alphType->data2 != 0 ) {
579                 ret += " ";
580                 ret += + keyOps->alphType->data2;
581         }
582         return ret;
583 }
584
585 /* Emit the alphabet data type. */
586 string FsmCodeGen::WIDE_ALPH_TYPE()
587 {
588         string ret;
589         if ( redFsm->maxKey <= keyOps->maxKey )
590                 ret = ALPH_TYPE();
591         else {
592                 long long maxKeyVal = redFsm->maxKey.getLongLong();
593                 HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal );
594                 assert( wideType != 0 );
595
596                 ret = wideType->data1;
597                 if ( wideType->data2 != 0 ) {
598                         ret += " ";
599                         ret += wideType->data2;
600                 }
601         }
602         return ret;
603 }
604
605 void FsmCodeGen::STATE_IDS()
606 {
607         if ( redFsm->startState != 0 )
608                 STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << ";\n";
609
610         if ( writeFirstFinal )
611                 STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << ";\n";
612
613         if ( writeErr )
614                 STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << ";\n";
615
616         out << "\n";
617
618         if ( entryPointNames.length() > 0 ) {
619                 for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) {
620                         STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << 
621                                         " = " << entryPointIds[en.pos()] << ";\n";
622                 }
623                 out << "\n";
624         }
625 }
626
627
628 /*
629  * Language specific, but style independent code generators functions.
630  */
631
632 string CCodeGen::PTR_CONST()
633 {
634         return "const ";
635 }
636
637 std::ostream &CCodeGen::OPEN_ARRAY( string type, string name )
638 {
639         out << "static const " << type << " " << name << "[] = {\n";
640         return out;
641 }
642
643 std::ostream &CCodeGen::CLOSE_ARRAY()
644 {
645         return out << "};\n";
646 }
647
648 std::ostream &CCodeGen::STATIC_VAR( string type, string name )
649 {
650         out << "static const " << type << " " << name;
651         return out;
652 }
653
654 string CCodeGen::UINT( )
655 {
656         return "unsigned int";
657 }
658
659 string CCodeGen::ARR_OFF( string ptr, string offset )
660 {
661         return ptr + " + " + offset;
662 }
663
664 string CCodeGen::CAST( string type )
665 {
666         return "(" + type + ")";
667 }
668
669 string CCodeGen::NULL_ITEM()
670 {
671         return "0";
672 }
673
674 string CCodeGen::POINTER()
675 {
676         return " *";
677 }
678
679 std::ostream &CCodeGen::SWITCH_DEFAULT()
680 {
681         return out;
682 }
683
684 string CCodeGen::CTRL_FLOW()
685 {
686         return "";
687 }
688
689 void CCodeGen::writeExports()
690 {
691         if ( exportList.length() > 0 ) {
692                 for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) {
693                         out << "#define " << DATA_PREFIX() << "ex_" << ex->name << " " << 
694                                         KEY(ex->key) << "\n";
695                 }
696                 out << "\n";
697         }
698 }
699
700 /*
701  * D Specific
702  */
703
704 string DCodeGen::NULL_ITEM()
705 {
706         return "null";
707 }
708
709 string DCodeGen::POINTER()
710 {
711         // multiple items seperated by commas can also be pointer types.
712         return "* ";
713 }
714
715 string DCodeGen::PTR_CONST()
716 {
717         return "";
718 }
719
720 std::ostream &DCodeGen::OPEN_ARRAY( string type, string name )
721 {
722         out << "static const " << type << "[] " << name << " = [\n";
723         return out;
724 }
725
726 std::ostream &DCodeGen::CLOSE_ARRAY()
727 {
728         return out << "];\n";
729 }
730
731 std::ostream &DCodeGen::STATIC_VAR( string type, string name )
732 {
733         out << "static const " << type << " " << name;
734         return out;
735 }
736
737 string DCodeGen::ARR_OFF( string ptr, string offset )
738 {
739         return "&" + ptr + "[" + offset + "]";
740 }
741
742 string DCodeGen::CAST( string type )
743 {
744         return "cast(" + type + ")";
745 }
746
747 string DCodeGen::UINT( )
748 {
749         return "uint";
750 }
751
752 std::ostream &DCodeGen::SWITCH_DEFAULT()
753 {
754         out << "                default: break;\n";
755         return out;
756 }
757
758 string DCodeGen::CTRL_FLOW()
759 {
760         return "if (true) ";
761 }
762
763 void DCodeGen::writeExports()
764 {
765         if ( exportList.length() > 0 ) {
766                 for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) {
767                         out << "static const " << ALPH_TYPE() << " " << DATA_PREFIX() << 
768                                         "ex_" << ex->name << " = " << KEY(ex->key) << ";\n";
769                 }
770                 out << "\n";
771         }
772 }
773
774 /*
775  * End D-specific code.
776  */
777
778 void FsmCodeGen::finishRagelDef()
779 {
780         if ( codeStyle == GenGoto || codeStyle == GenFGoto || 
781                         codeStyle == GenIpGoto || codeStyle == GenSplit )
782         {
783                 /* For directly executable machines there is no required state
784                  * ordering. Choose a depth-first ordering to increase the
785                  * potential for fall-throughs. */
786                 redFsm->depthFirstOrdering();
787         }
788         else {
789                 /* The frontend will do this for us, but it may be a good idea to
790                  * force it if the intermediate file is edited. */
791                 redFsm->sortByStateId();
792         }
793
794         /* Choose default transitions and the single transition. */
795         redFsm->chooseDefaultSpan();
796                 
797         /* Maybe do flat expand, otherwise choose single. */
798         if ( codeStyle == GenFlat || codeStyle == GenFFlat )
799                 redFsm->makeFlat();
800         else
801                 redFsm->chooseSingle();
802
803         /* If any errors have occured in the input file then don't write anything. */
804         if ( gblErrorCount > 0 )
805                 return;
806         
807         if ( codeStyle == GenSplit )
808                 redFsm->partitionFsm( numSplitPartitions );
809
810         if ( codeStyle == GenIpGoto || codeStyle == GenSplit )
811                 redFsm->setInTrans();
812
813         /* Anlayze Machine will find the final action reference counts, among
814          * other things. We will use these in reporting the usage
815          * of fsm directives in action code. */
816         analyzeMachine();
817
818         /* Determine if we should use indicies. */
819         calcIndexSize();
820 }
821
822 ostream &FsmCodeGen::source_warning( const InputLoc &loc )
823 {
824         cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": warning: ";
825         return cerr;
826 }
827
828 ostream &FsmCodeGen::source_error( const InputLoc &loc )
829 {
830         gblErrorCount += 1;
831         assert( sourceFileName != 0 );
832         cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": ";
833         return cerr;
834 }
835