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