Atomics bug fix
[gem5.git] / src / mem / slicc / generator / mif_gen.cc
1
2 /*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /*
31 * $Id$
32 *
33 */
34
35 #include "mem/slicc/generator/mif_gen.hh"
36 #include "mem/slicc/symbols/State.hh"
37 #include "mem/slicc/symbols/Event.hh"
38 #include "mem/slicc/symbols/Action.hh"
39 #include "mem/slicc/symbols/Transition.hh"
40
41 // -- Helper functions
42 string formatShorthand(const string shorthand);
43 string formatCellRuling(const string shorthand);
44
45 void printStateTableMIF(const StateMachine& sm, ostream& out)
46 {
47 const string mif_prolog1 =
48 "<MIFFile 5.50> # Generated by Multifacet MIF Mungers Inc\n\
49 <Tbls\n\
50 <Tbl\n\
51 <TblID 1>\n\
52 <TblTag `Format A'>\n\
53 <TblFormat\n\
54 \n\
55 <TblAlignment Center>\n\
56 \n\
57 # <TblXColumnNum 0>\n\
58 <TblXColumnRuling `Medium'>\n\
59 \n\
60 <TblLRuling `Medium'>\n\
61 <TblRRuling `Medium'>\n\
62 <TblTRuling `Medium'>\n\
63 <TblBRuling `Medium'>\n\
64 \n\
65 <TblColumn\n\
66 <TblColumnNum 0>\n\
67 <TblColumnWidth 0.51\">\n\
68 <TblColumnH\n\
69 <PgfTag `CellHeading'>\n\
70 > # end of TblColumnH\n\
71 <TblColumnBody\n\
72 <PgfTag `CellBody'>\n\
73 > # end of TblColumnBody\n\
74 <TblColumnF\n\
75 <PgfTag `CellHeading'>\n\
76 > # end of TblColumnF\n\
77 > # end of TblColumn\n\
78 <TblColumn\n\
79 <TblColumnNum 1>\n\
80 <TblColumnWidth 0.51\">\n\
81 <TblColumnH\n\
82 <PgfTag `CellHeading'>\n\
83 > # end of TblColumnH\n\
84 <TblColumnBody\n\
85 <PgfTag `CellBody'>\n\
86 > # end of TblColumnBody\n\
87 <TblColumnF\n\
88 <PgfTag `CellHeading'>\n\
89 > # end of TblColumnF\n\
90 > # end of TblColumn\n\
91 > # end of TblFormat\n\
92 \n\
93 <TblNumColumns 2>\n\
94 <TblColumnWidth 0.51\">\n\
95 <TblColumnWidth 6.00\">\n\
96 <TblTitle\n\
97 <TblTitleContent\n\
98 <Para\n\
99 <PgfTag `TableTitle'>\n\
100 <Pgf\n\
101 <PgfAlignment Center>\n\
102 <PgfFont \n\
103 <FTag `'>\n\
104 <FFamily `Times'>\n\
105 <FVar `Regular'>\n\
106 <FWeight `Regular'>\n\
107 <FAngle `Regular'>\n\
108 <FPostScriptName `Times-Roman'>\n\
109 <FEncoding `FrameRoman'>\n\
110 <FSize 11.0 pt>\n\
111 <FUnderlining FNoUnderlining>\n\
112 <FOverline No>\n\
113 <FStrike No>\n\
114 <FChangeBar No>\n\
115 <FOutline No>\n\
116 <FShadow No>\n\
117 <FPairKern Yes>\n\
118 <FTsume No>\n\
119 <FCase FAsTyped>\n\
120 <FPosition FNormal>\n\
121 <FDX 0.0%>\n\
122 <FDY 0.0%>\n\
123 <FDW 0.0%>\n\
124 <FStretch 100.0%>\n\
125 <FLanguage USEnglish>\n\
126 <FLocked No>\n\
127 <FSeparation 0>\n\
128 <FColor `Black'>\n\
129 > # end of PgfFont\n\
130 > # end of Pgf\n\
131 <PgfNumString `TABLE 1. '>\n\
132 <ParaLine\n\
133 <Marker\n\
134 <MType 9>\n\
135 <MTypeName `Cross-Ref'>\n\
136 <MCurrPage `1'>\n\
137 > # end of Marker\n\
138 <String `";
139
140 const string mif_prolog2 =
141 "'>\n\
142 > # end of ParaLine\n\
143 > # end of Para\n\
144 > # end of TblTitleContent\n\
145 > # end of TblTitle\n\
146 \n\
147 <TblH\n\
148 <Row\n\
149 <RowMaxHeight 14.0\">\n\
150 <RowHeight 0.44444\">\n\
151 <Cell\n\
152 <CellLRuling `Medium'>\n\
153 <CellBRuling `Medium'>\n\
154 <CellRRuling `Medium'>\n\
155 <CellTRuling `Medium'>\n\
156 <CellContent\n\
157 <Para\n\
158 <PgfTag `CellHeading'>\n\
159 <Pgf\n\
160 <PgfAlignment Center>\n\
161 <PgfFont \n\
162 <FTag `'>\n\
163 <FFamily `Times'>\n\
164 <FVar `Regular'>\n\
165 <FWeight `Regular'>\n\
166 <FAngle `Regular'>\n\
167 <FPostScriptName `Times-Roman'>\n\
168 <FEncoding `FrameRoman'>\n\
169 <FSize 11.0 pt>\n\
170 <FUnderlining FNoUnderlining>\n\
171 <FOverline No>\n\
172 <FStrike No>\n\
173 <FChangeBar No>\n\
174 <FOutline No>\n\
175 <FShadow No>\n\
176 <FPairKern Yes>\n\
177 <FTsume No>\n\
178 <FCase FAsTyped>\n\
179 <FPosition FNormal>\n\
180 <FDX 0.0%>\n\
181 <FDY 0.0%>\n\
182 <FDW 0.0%>\n\
183 <FStretch 100.0%>\n\
184 <FLanguage USEnglish>\n\
185 <FLocked No>\n\
186 <FSeparation 0>\n\
187 <FColor `Black'>\n\
188 > # end of PgfFont\n\
189 >\n\
190 <ParaLine\n\
191 <String `State'>\n\
192 > # end of ParaLine\n\
193 > # end of Para\n\
194 > # end of CellContent\n\
195 > # end of Cell\n\
196 <Cell\n\
197 <CellLRuling `Medium'>\n\
198 <CellBRuling `Medium'>\n\
199 <CellRRuling `Medium'>\n\
200 <CellTRuling `Medium'>\n\
201 <CellContent\n\
202 <Para\n\
203 <PgfTag `CellHeading'>\n\
204 <PgfFont \n\
205 <FTag `'>\n\
206 <FFamily `Times'>\n\
207 <FVar `Regular'>\n\
208 <FWeight `Regular'>\n\
209 <FAngle `Regular'>\n\
210 <FPostScriptName `Times-Roman'>\n\
211 <FEncoding `FrameRoman'>\n\
212 <FSize 11.0 pt>\n\
213 <FUnderlining FNoUnderlining>\n\
214 <FOverline No>\n\
215 <FStrike No>\n\
216 <FChangeBar No>\n\
217 <FOutline No>\n\
218 <FShadow No>\n\
219 <FPairKern Yes>\n\
220 <FTsume No>\n\
221 <FCase FAsTyped>\n\
222 <FPosition FNormal>\n\
223 <FDX 0.0%>\n\
224 <FDY 0.0%>\n\
225 <FDW 0.0%>\n\
226 <FStretch 100.0%>\n\
227 <FLanguage USEnglish>\n\
228 <FLocked No>\n\
229 <FSeparation 0>\n\
230 <FColor `Black'>\n\
231 > # end of PgfFont\n\
232 <ParaLine\n\
233 <String `Description'>\n\
234 > # end of ParaLine\n\
235 > # end of Para\n\
236 > # end of CellContent\n\
237 > # end of Cell\n\
238 > # end of Row\n\
239 > # end of TblH\n\
240 \n\
241 <TblBody\n\
242 ";
243
244 const string row_before_state =
245 " <Row\n\
246 <RowMaxHeight 14.0\">\n\
247 <RowHeight 0.22222\">\n\
248 <Cell\n\
249 <CellContent\n\
250 <Para\n\
251 <PgfTag `CellBody'>\n\
252 <Pgf\n\
253 <PgfAlignment Center>\n\
254 <PgfFont \n\
255 <FTag `'>\n\
256 <FFamily `Times'>\n\
257 <FVar `Regular'>\n\
258 <FWeight `Regular'>\n\
259 <FAngle `Regular'>\n\
260 <FPostScriptName `Times-Roman'>\n\
261 <FEncoding `FrameRoman'>\n\
262 <FSize 11.0 pt>\n\
263 <FUnderlining FNoUnderlining>\n\
264 <FOverline No>\n\
265 <FStrike No>\n\
266 <FChangeBar No>\n\
267 <FOutline No>\n\
268 <FShadow No>\n\
269 <FPairKern Yes>\n\
270 <FTsume No>\n\
271 <FCase FAsTyped>\n\
272 <FPosition FNormal>\n\
273 <FDX 0.0%>\n\
274 <FDY 0.0%>\n\
275 <FDW 0.0%>\n\
276 <FStretch 100.0%>\n\
277 <FLanguage USEnglish>\n\
278 <FLocked No>\n\
279 <FSeparation 0>\n\
280 <FColor `Black'>\n\
281 > # end of PgfFont\n\
282 >\n\
283 <ParaLine\n\
284 <String `";
285
286 const string row_between_state_desc =
287 "'>\n\
288 > # end of ParaLine\n\
289 > # end of Para\n\
290 > # end of CellContent\n\
291 > # end of Cell\n\
292 <Cell\n\
293 <CellContent\n\
294 <Para\n\
295 <PgfTag `CellBody'>\n\
296 <ParaLine\n\
297 <String `";
298
299 const string row_after_desc =
300 "'>\n\
301 > # end of ParaLine\n\
302 > # end of Para\n\
303 > # end of CellContent\n\
304 > # end of Cell\n\
305 > # end of Row\n\
306 ";
307
308 const string mif_epilog =
309 " > # end of TblBody\n\
310 > # end of Tbl\n\
311 > # end of Tbls\n\
312 \n\
313 <Para\n\
314 <ParaLine\n\
315 <ATbl 1>\n\
316 > # end of ParaLine\n\
317 > # end of Para\n\
318 \n\
319 # End of MIFFile\n\
320 ";
321
322 out << mif_prolog1;
323 out << formatShorthand( sm.getShorthand() );
324 out << " states";
325 out << mif_prolog2;
326
327 for( int i = 0; i < sm.numStates(); i++ )
328 {
329 out << row_before_state;
330 out << formatShorthand( sm.getState( i ).getShorthand() );
331 out << row_between_state_desc;
332 out << sm.getState( i ).getDescription();
333 out << row_after_desc;
334 }
335
336 out << mif_epilog;
337 }
338
339
340 void printEventTableMIF(const StateMachine& sm, ostream& out)
341 {
342 const string mif_prolog1 =
343 "<MIFFile 5.50> # Generated by Multifacet MIF Mungers Inc\n\
344 <Tbls\n\
345 <Tbl\n\
346 <TblID 1>\n\
347 <TblTag `Format A'>\n\
348 <TblFormat\n\
349 \n\
350 <TblAlignment Center>\n\
351 \n\
352 # <TblXColumnNum 0>\n\
353 <TblXColumnRuling `Medium'>\n\
354 \n\
355 <TblLRuling `Medium'>\n\
356 <TblRRuling `Medium'>\n\
357 <TblTRuling `Medium'>\n\
358 <TblBRuling `Medium'>\n\
359 \n\
360 <TblColumn\n\
361 <TblColumnNum 0>\n\
362 <TblColumnWidth 0.51\">\n\
363 <TblColumnH\n\
364 <PgfTag `CellHeading'>\n\
365 > # end of TblColumnH\n\
366 <TblColumnBody\n\
367 <PgfTag `CellBody'>\n\
368 > # end of TblColumnBody\n\
369 <TblColumnF\n\
370 <PgfTag `CellHeading'>\n\
371 > # end of TblColumnF\n\
372 > # end of TblColumn\n\
373 <TblColumn\n\
374 <TblColumnNum 1>\n\
375 <TblColumnWidth 0.51\">\n\
376 <TblColumnH\n\
377 <PgfTag `CellHeading'>\n\
378 > # end of TblColumnH\n\
379 <TblColumnBody\n\
380 <PgfTag `CellBody'>\n\
381 > # end of TblColumnBody\n\
382 <TblColumnF\n\
383 <PgfTag `CellHeading'>\n\
384 > # end of TblColumnF\n\
385 > # end of TblColumn\n\
386 > # end of TblFormat\n\
387 \n\
388 <TblNumColumns 2>\n\
389 <TblColumnWidth 0.51\">\n\
390 <TblColumnWidth 6.00\">\n\
391 <TblTitle\n\
392 <TblTitleContent\n\
393 <Para\n\
394 <PgfTag `TableTitle'>\n\
395 <Pgf\n\
396 <PgfAlignment Center>\n\
397 <PgfFont \n\
398 <FTag `'>\n\
399 <FFamily `Times'>\n\
400 <FVar `Regular'>\n\
401 <FWeight `Regular'>\n\
402 <FAngle `Regular'>\n\
403 <FPostScriptName `Times-Roman'>\n\
404 <FEncoding `FrameRoman'>\n\
405 <FSize 11.0 pt>\n\
406 <FUnderlining FNoUnderlining>\n\
407 <FOverline No>\n\
408 <FStrike No>\n\
409 <FChangeBar No>\n\
410 <FOutline No>\n\
411 <FShadow No>\n\
412 <FPairKern Yes>\n\
413 <FTsume No>\n\
414 <FCase FAsTyped>\n\
415 <FPosition FNormal>\n\
416 <FDX 0.0%>\n\
417 <FDY 0.0%>\n\
418 <FDW 0.0%>\n\
419 <FStretch 100.0%>\n\
420 <FLanguage USEnglish>\n\
421 <FLocked No>\n\
422 <FSeparation 0>\n\
423 <FColor `Black'>\n\
424 > # end of PgfFont\n\
425 > # end of Pgf\n\
426 <PgfNumString `TABLE 1. '>\n\
427 <ParaLine\n\
428 <Marker\n\
429 <MType 9>\n\
430 <MTypeName `Cross-Ref'>\n\
431 <MCurrPage `1'>\n\
432 > # end of Marker\n\
433 <String `";
434 const string mif_prolog2 =
435 "'>\n\
436 > # end of ParaLine\n\
437 > # end of Para\n\
438 > # end of TblTitleContent\n\
439 > # end of TblTitle\n\
440 \n\
441 <TblH\n\
442 <Row\n\
443 <RowMaxHeight 14.0\">\n\
444 <RowHeight 0.44444\">\n\
445 <Cell\n\
446 <CellLRuling `Medium'>\n\
447 <CellBRuling `Medium'>\n\
448 <CellRRuling `Medium'>\n\
449 <CellTRuling `Medium'>\n\
450 <CellContent\n\
451 <Para\n\
452 <PgfTag `CellHeading'>\n\
453 <PgfFont \n\
454 <FTag `'>\n\
455 <FFamily `Times'>\n\
456 <FVar `Regular'>\n\
457 <FWeight `Regular'>\n\
458 <FAngle `Regular'>\n\
459 <FPostScriptName `Times-Roman'>\n\
460 <FEncoding `FrameRoman'>\n\
461 <FSize 11.0 pt>\n\
462 <FUnderlining FNoUnderlining>\n\
463 <FOverline No>\n\
464 <FStrike No>\n\
465 <FChangeBar No>\n\
466 <FOutline No>\n\
467 <FShadow No>\n\
468 <FPairKern Yes>\n\
469 <FTsume No>\n\
470 <FCase FAsTyped>\n\
471 <FPosition FNormal>\n\
472 <FDX 0.0%>\n\
473 <FDY 0.0%>\n\
474 <FDW 0.0%>\n\
475 <FStretch 100.0%>\n\
476 <FLanguage USEnglish>\n\
477 <FLocked No>\n\
478 <FSeparation 0>\n\
479 <FColor `Black'>\n\
480 > # end of PgfFont\n\
481 <Pgf\n\
482 <PgfAlignment Center>\n\
483 <PgfFont \n\
484 <FTag `'>\n\
485 <FFamily `Times'>\n\
486 <FVar `Regular'>\n\
487 <FWeight `Regular'>\n\
488 <FAngle `Regular'>\n\
489 <FPostScriptName `Times-Roman'>\n\
490 <FEncoding `FrameRoman'>\n\
491 <FSize 11.0 pt>\n\
492 <FUnderlining FNoUnderlining>\n\
493 <FOverline No>\n\
494 <FStrike No>\n\
495 <FChangeBar No>\n\
496 <FOutline No>\n\
497 <FShadow No>\n\
498 <FPairKern Yes>\n\
499 <FTsume No>\n\
500 <FCase FAsTyped>\n\
501 <FPosition FNormal>\n\
502 <FDX 0.0%>\n\
503 <FDY 0.0%>\n\
504 <FDW 0.0%>\n\
505 <FStretch 100.0%>\n\
506 <FLanguage USEnglish>\n\
507 <FLocked No>\n\
508 <FSeparation 0>\n\
509 <FColor `Black'>\n\
510 > # end of PgfFont\n\
511 >\n\
512 <ParaLine\n\
513 <String `Event'>\n\
514 > # end of ParaLine\n\
515 > # end of Para\n\
516 > # end of CellContent\n\
517 > # end of Cell\n\
518 <Cell\n\
519 <CellLRuling `Medium'>\n\
520 <CellBRuling `Medium'>\n\
521 <CellRRuling `Medium'>\n\
522 <CellTRuling `Medium'>\n\
523 <CellContent\n\
524 <Para\n\
525 <PgfTag `CellHeading'>\n\
526 <ParaLine\n\
527 <String `Description'>\n\
528 > # end of ParaLine\n\
529 > # end of Para\n\
530 > # end of CellContent\n\
531 > # end of Cell\n\
532 > # end of Row\n\
533 > # end of TblH\n\
534 \n\
535 <TblBody\n\
536 ";
537
538 const string row_before_event =
539 " <Row\n\
540 <RowMaxHeight 14.0\">\n\
541 <RowHeight 0.22222\">\n\
542 <Cell\n\
543 <CellContent\n\
544 <Para\n\
545 <PgfTag `CellBody'>\n\
546 <Pgf\n\
547 <PgfAlignment Center>\n\
548 <PgfFont \n\
549 <FTag `'>\n\
550 <FFamily `Times'>\n\
551 <FVar `Regular'>\n\
552 <FWeight `Regular'>\n\
553 <FAngle `Regular'>\n\
554 <FPostScriptName `Times-Roman'>\n\
555 <FEncoding `FrameRoman'>\n\
556 <FSize 11.0 pt>\n\
557 <FUnderlining FNoUnderlining>\n\
558 <FOverline No>\n\
559 <FStrike No>\n\
560 <FChangeBar No>\n\
561 <FOutline No>\n\
562 <FShadow No>\n\
563 <FPairKern Yes>\n\
564 <FTsume No>\n\
565 <FCase FAsTyped>\n\
566 <FPosition FNormal>\n\
567 <FDX 0.0%>\n\
568 <FDY 0.0%>\n\
569 <FDW 0.0%>\n\
570 <FStretch 100.0%>\n\
571 <FLanguage USEnglish>\n\
572 <FLocked No>\n\
573 <FSeparation 0>\n\
574 <FColor `Black'>\n\
575 > # end of PgfFont\n\
576 >\n\
577 <ParaLine\n\
578 <String `";
579
580 const string row_between_event_desc =
581 "'>\n\
582 > # end of ParaLine\n\
583 > # end of Para\n\
584 > # end of CellContent\n\
585 > # end of Cell\n\
586 <Cell\n\
587 <CellContent\n\
588 <Para\n\
589 <PgfTag `CellBody'>\n\
590 <ParaLine\n\
591 <String `";
592
593 const string row_after_desc =
594 "'>\n\
595 > # end of ParaLine\n\
596 > # end of Para\n\
597 > # end of CellContent\n\
598 > # end of Cell\n\
599 > # end of Row\n\
600 ";
601
602 const string mif_epilog =
603 " > # end of TblBody\n\
604 > # end of Tbl\n\
605 > # end of Tbls\n\
606 \n\
607 <Para\n\
608 <ParaLine\n\
609 <ATbl 1>\n\
610 > # end of ParaLine\n\
611 > # end of Para\n\
612 \n\
613 # End of MIFFile\n\
614 ";
615
616 out << mif_prolog1;
617 out << formatShorthand( sm.getShorthand() );
618 out << " events";
619 out << mif_prolog2;
620
621 for( int i = 0; i < sm.numEvents(); i++ )
622 {
623 out << row_before_event;
624 out << formatShorthand( sm.getEvent( i ).getShorthand() );
625 out << row_between_event_desc;
626 out << sm.getEvent( i ).getDescription();
627 out << row_after_desc;
628 }
629
630 out << mif_epilog;
631 }
632
633
634 void printActionTableMIF(const StateMachine& sm, ostream& out)
635 {
636 const string mif_prolog1 =
637 "<MIFFile 5.50> # Generated by Multifacet MIF Mungers Inc\n\
638 <Tbls\n\
639 <Tbl\n\
640 <TblID 1>\n\
641 <TblTag `Format A'>\n\
642 <TblFormat\n\
643 \n\
644 <TblAlignment Center>\n\
645 \n\
646 # <TblXColumnNum 0>\n\
647 <TblXColumnRuling `Medium'>\n\
648 \n\
649 <TblLRuling `Medium'>\n\
650 <TblRRuling `Medium'>\n\
651 <TblTRuling `Medium'>\n\
652 <TblBRuling `Medium'>\n\
653 \n\
654 <TblColumn\n\
655 <TblColumnNum 0>\n\
656 <TblColumnWidth 0.51\">\n\
657 <TblColumnH\n\
658 <PgfTag `CellHeading'>\n\
659 > # end of TblColumnH\n\
660 <TblColumnBody\n\
661 <PgfTag `CellBody'>\n\
662 > # end of TblColumnBody\n\
663 <TblColumnF\n\
664 <PgfTag `CellHeading'>\n\
665 > # end of TblColumnF\n\
666 > # end of TblColumn\n\
667 <TblColumn\n\
668 <TblColumnNum 1>\n\
669 <TblColumnWidth 0.51\">\n\
670 <TblColumnH\n\
671 <PgfTag `CellHeading'>\n\
672 > # end of TblColumnH\n\
673 <TblColumnBody\n\
674 <PgfTag `CellBody'>\n\
675 > # end of TblColumnBody\n\
676 <TblColumnF\n\
677 <PgfTag `CellHeading'>\n\
678 > # end of TblColumnF\n\
679 > # end of TblColumn\n\
680 > # end of TblFormat\n\
681 \n\
682 <TblNumColumns 2>\n\
683 <TblColumnWidth 0.51\">\n\
684 <TblColumnWidth 6.00\">\n\
685 <TblTitle\n\
686 <TblTitleContent\n\
687 <Para\n\
688 <PgfTag `TableTitle'>\n\
689 <Pgf\n\
690 <PgfAlignment Center>\n\
691 <PgfFont \n\
692 <FTag `'>\n\
693 <FFamily `Times'>\n\
694 <FVar `Regular'>\n\
695 <FWeight `Regular'>\n\
696 <FAngle `Regular'>\n\
697 <FPostScriptName `Times-Roman'>\n\
698 <FEncoding `FrameRoman'>\n\
699 <FSize 11.0 pt>\n\
700 <FUnderlining FNoUnderlining>\n\
701 <FOverline No>\n\
702 <FStrike No>\n\
703 <FChangeBar No>\n\
704 <FOutline No>\n\
705 <FShadow No>\n\
706 <FPairKern Yes>\n\
707 <FTsume No>\n\
708 <FCase FAsTyped>\n\
709 <FPosition FNormal>\n\
710 <FDX 0.0%>\n\
711 <FDY 0.0%>\n\
712 <FDW 0.0%>\n\
713 <FStretch 100.0%>\n\
714 <FLanguage USEnglish>\n\
715 <FLocked No>\n\
716 <FSeparation 0>\n\
717 <FColor `Black'>\n\
718 > # end of PgfFont\n\
719 > # end of Pgf\n\
720 <PgfNumString `TABLE 1. '>\n\
721 <ParaLine\n\
722 <Marker\n\
723 <MType 9>\n\
724 <MTypeName `Cross-Ref'>\n\
725 <MCurrPage `1'>\n\
726 > # end of Marker\n\
727 <String `";
728 const string mif_prolog2 =
729 "'>\n\
730 > # end of ParaLine\n\
731 > # end of Para\n\
732 > # end of TblTitleContent\n\
733 > # end of TblTitle\n\
734 \n\
735 <TblH\n\
736 <Row\n\
737 <RowMaxHeight 14.0\">\n\
738 <RowHeight 0.44444\">\n\
739 <Cell\n\
740 <CellLRuling `Medium'>\n\
741 <CellBRuling `Medium'>\n\
742 <CellRRuling `Medium'>\n\
743 <CellTRuling `Medium'>\n\
744 <CellContent\n\
745 <Para\n\
746 <PgfTag `CellHeading'>\n\
747 <Pgf\n\
748 <PgfAlignment Center>\n\
749 <PgfFont \n\
750 <FTag `'>\n\
751 <FFamily `Times'>\n\
752 <FVar `Regular'>\n\
753 <FWeight `Regular'>\n\
754 <FAngle `Regular'>\n\
755 <FPostScriptName `Times-Roman'>\n\
756 <FEncoding `FrameRoman'>\n\
757 <FSize 11.0 pt>\n\
758 <FUnderlining FNoUnderlining>\n\
759 <FOverline No>\n\
760 <FStrike No>\n\
761 <FChangeBar No>\n\
762 <FOutline No>\n\
763 <FShadow No>\n\
764 <FPairKern Yes>\n\
765 <FTsume No>\n\
766 <FCase FAsTyped>\n\
767 <FPosition FNormal>\n\
768 <FDX 0.0%>\n\
769 <FDY 0.0%>\n\
770 <FDW 0.0%>\n\
771 <FStretch 100.0%>\n\
772 <FLanguage USEnglish>\n\
773 <FLocked No>\n\
774 <FSeparation 0>\n\
775 <FColor `Black'>\n\
776 > # end of PgfFont\n\
777 >\n\
778 <ParaLine\n\
779 <String `Action'>\n\
780 > # end of ParaLine\n\
781 > # end of Para\n\
782 > # end of CellContent\n\
783 > # end of Cell\n\
784 <Cell\n\
785 <CellLRuling `Medium'>\n\
786 <CellBRuling `Medium'>\n\
787 <CellRRuling `Medium'>\n\
788 <CellTRuling `Medium'>\n\
789 <CellContent\n\
790 <Para\n\
791 <PgfTag `CellHeading'>\n\
792 <ParaLine\n\
793 <String `Description'>\n\
794 > # end of ParaLine\n\
795 > # end of Para\n\
796 > # end of CellContent\n\
797 > # end of Cell\n\
798 > # end of Row\n\
799 > # end of TblH\n\
800 \n\
801 <TblBody\n\
802 ";
803
804 const string row_before_action =
805 " <Row\n\
806 <RowMaxHeight 14.0\">\n\
807 <RowHeight 0.22222\">\n\
808 <Cell\n\
809 <CellContent\n\
810 <Para\n\
811 <PgfTag `CellBody'>\n\
812 <Pgf\n\
813 <PgfAlignment Center>\n\
814 <PgfFont \n\
815 <FTag `'>\n\
816 <FFamily `Times'>\n\
817 <FVar `Regular'>\n\
818 <FWeight `Regular'>\n\
819 <FAngle `Regular'>\n\
820 <FPostScriptName `Times-Roman'>\n\
821 <FEncoding `FrameRoman'>\n\
822 <FSize 11.0 pt>\n\
823 <FUnderlining FNoUnderlining>\n\
824 <FOverline No>\n\
825 <FStrike No>\n\
826 <FChangeBar No>\n\
827 <FOutline No>\n\
828 <FShadow No>\n\
829 <FPairKern Yes>\n\
830 <FTsume No>\n\
831 <FCase FAsTyped>\n\
832 <FPosition FNormal>\n\
833 <FDX 0.0%>\n\
834 <FDY 0.0%>\n\
835 <FDW 0.0%>\n\
836 <FStretch 100.0%>\n\
837 <FLanguage USEnglish>\n\
838 <FLocked No>\n\
839 <FSeparation 0>\n\
840 <FColor `Black'>\n\
841 > # end of PgfFont\n\
842 >\n\
843 <ParaLine\n\
844 <String `";
845
846 const string row_between_action_desc =
847 "'>\n\
848 > # end of ParaLine\n\
849 > # end of Para\n\
850 > # end of CellContent\n\
851 > # end of Cell\n\
852 <Cell\n\
853 <CellContent\n\
854 <Para\n\
855 <PgfTag `CellBody'>\n\
856 <ParaLine\n\
857 <String `";
858
859 const string row_after_desc =
860 "'>\n\
861 > # end of ParaLine\n\
862 > # end of Para\n\
863 > # end of CellContent\n\
864 > # end of Cell\n\
865 > # end of Row\n\
866 ";
867
868 const string mif_epilog =
869 " > # end of TblBody\n\
870 > # end of Tbl\n\
871 > # end of Tbls\n\
872 \n\
873 <Para\n\
874 <ParaLine\n\
875 <ATbl 1>\n\
876 > # end of ParaLine\n\
877 > # end of Para\n\
878 \n\
879 # End of MIFFile\n\
880 ";
881
882 out << mif_prolog1;
883 out << formatShorthand( sm.getShorthand() );
884 out << " actions";
885 out << mif_prolog2;
886
887 for( int i = 0; i < sm.numActions(); i++ )
888 {
889 out << row_before_action;
890 out << formatShorthand( sm.getAction( i ).getShorthand() );
891 out << row_between_action_desc;
892 out << sm.getAction( i ).getDescription();
893 out << row_after_desc;
894 }
895
896 out << mif_epilog;
897 }
898
899
900 void printTransitionTableMIF(const StateMachine& sm, ostream& out)
901 {
902 const string mif_prolog =
903 "<MIFFile 5.50> # Generated by Multifacet MIF Mungers Inc\n\
904 <Tbls\n\
905 <Tbl\n\
906 <TblID 1>\n\
907 <TblTag `Format A'>\n\
908 <TblFormat\n\
909 \n\
910 <TblAlignment Center>\n\
911 \n\
912 # <TblXColumnNum 0>\n\
913 <TblXColumnRuling `Medium'>\n\
914 \n\
915 <TblLRuling `Medium'>\n\
916 <TblRRuling `Medium'>\n\
917 <TblTRuling `Medium'>\n\
918 <TblBRuling `Medium'>\n\
919 \n\
920 ";
921
922 const string tbl_fmt_before_col_num =
923 " <TblColumn\n\
924 <TblColumnNum ";
925
926 const string tbl_fmt_after_col_num =
927 ">\n\
928 <TblColumnWidth 0.51\">\n\
929 <TblColumnH\n\
930 <PgfTag `CellHeading'>\n\
931 > # end of TblColumnH\n\
932 <TblColumnBody\n\
933 <PgfTag `CellBody'>\n\
934 > # end of TblColumnBody\n\
935 <TblColumnF\n\
936 <PgfTag `CellHeading'>\n\
937 > # end of TblColumnF\n\
938 > # end of TblColumn\n\
939 ";
940
941 const string tbl_fmt_before_num_cols =
942 " > # end of TblFormat\n\
943 \n\
944 <TblNumColumns ";
945
946 const string tbl_fmt_each_col_width_begin =
947 ">\n\
948 <TblColumnWidth ";
949
950 const string tbl_fmt_each_col_width_end = "\"";
951
952 const string tbl_before_first_header1 =
953 ">\n\
954 <TblTitle\n\
955 <TblTitleContent\n\
956 <Para\n\
957 <PgfTag `TableTitle'>\n\
958 <Pgf\n\
959 <PgfAlignment Center>\n\
960 <PgfFont \n\
961 <FTag `'>\n\
962 <FFamily `Times'>\n\
963 <FVar `Regular'>\n\
964 <FWeight `Regular'>\n\
965 <FAngle `Regular'>\n\
966 <FPostScriptName `Times-Roman'>\n\
967 <FEncoding `FrameRoman'>\n\
968 <FSize 11.0 pt>\n\
969 <FUnderlining FNoUnderlining>\n\
970 <FOverline No>\n\
971 <FStrike No>\n\
972 <FChangeBar No>\n\
973 <FOutline No>\n\
974 <FShadow No>\n\
975 <FPairKern Yes>\n\
976 <FTsume No>\n\
977 <FCase FAsTyped>\n\
978 <FPosition FNormal>\n\
979 <FDX 0.0%>\n\
980 <FDY 0.0%>\n\
981 <FDW 0.0%>\n\
982 <FStretch 100.0%>\n\
983 <FLanguage USEnglish>\n\
984 <FLocked No>\n\
985 <FSeparation 0>\n\
986 <FColor `Black'>\n\
987 > # end of PgfFont\n\
988 > # end of Pgf\n\
989 <PgfNumString `TABLE 1. '>\n\
990 <ParaLine\n\
991 <Marker\n\
992 <MType 9>\n\
993 <MTypeName `Cross-Ref'>\n\
994 <MCurrPage `1'>\n\
995 > # end of Marker\n\
996 <String `";
997
998 const string tbl_before_first_header2 =
999 "'>\n\
1000 > # end of ParaLine\n\
1001 > # end of Para\n\
1002 > # end of TblTitleContent\n\
1003 > # end of TblTitle\n\
1004 \n\
1005 <TblH\n\
1006 <Row\n\
1007 <RowMaxHeight 14.0\">\n\
1008 <RowHeight 0.44444\">";
1009
1010 const string tbl_before_each_header =
1011 " <Cell\n\
1012 <CellLRuling `Medium'>\n\
1013 <CellBRuling `Medium'>\n\
1014 <CellRRuling `Medium'>\n\
1015 <CellTRuling `Medium'>\n\
1016 <CellContent\n\
1017 <Para\n\
1018 <PgfTag `CellHeading'>\n\
1019 <Pgf\n\
1020 <PgfAlignment Center>\n\
1021 <PgfFont \n\
1022 <FTag `'>\n\
1023 <FFamily `Times'>\n\
1024 <FVar `Regular'>\n\
1025 <FWeight `Regular'>\n\
1026 <FAngle `Regular'>\n\
1027 <FPostScriptName `Times-Roman'>\n\
1028 <FEncoding `FrameRoman'>\n\
1029 <FSize 11.0 pt>\n\
1030 <FUnderlining FNoUnderlining>\n\
1031 <FOverline No>\n\
1032 <FStrike No>\n\
1033 <FChangeBar No>\n\
1034 <FOutline No>\n\
1035 <FShadow No>\n\
1036 <FPairKern Yes>\n\
1037 <FTsume No>\n\
1038 <FCase FAsTyped>\n\
1039 <FPosition FNormal>\n\
1040 <FDX 0.0%>\n\
1041 <FDY 0.0%>\n\
1042 <FDW 0.0%>\n\
1043 <FStretch 100.0%>\n\
1044 <FLanguage USEnglish>\n\
1045 <FLocked No>\n\
1046 <FSeparation 0>\n\
1047 <FColor `Black'>\n\
1048 > # end of PgfFont\n\
1049 >\n\
1050 <ParaLine\n\
1051 <String `";
1052
1053 const string tbl_before_each_rot_header =
1054 " <Cell\n\
1055 <CellLRuling `Medium'>\n\
1056 <CellBRuling `Medium'>\n\
1057 <CellRRuling `Medium'>\n\
1058 <CellTRuling `Medium'>\n\
1059 <CellAngle 270>\n\
1060 <CellContent\n\
1061 <Para\n\
1062 <PgfTag `CellHeading'>\n\
1063 <ParaLine\n\
1064 <String `";
1065
1066 const string tbl_after_each_header =
1067 "'>\n\
1068 > # end of ParaLine\n\
1069 > # end of Para\n\
1070 > # end of CellContent\n\
1071 > # end of Cell\n\
1072 ";
1073
1074 const string before_first_row =
1075 " > # end of Row\n\
1076 > # end of TblH\n\
1077 \n\
1078 <TblBody\n\
1079 ";
1080
1081 const string row_before_first_cell =
1082 " <Row\n\
1083 <RowMaxHeight 14.0\">\n\
1084 <RowHeight 0.22222\">";
1085
1086 const string row_cell_before_ruling =
1087 " <Cell\n\
1088 ";
1089
1090 const string row_cell_before_contents =
1091 " <CellContent\n\
1092 <Para\n\
1093 <PgfTag `CellBody'>\n\
1094 <Pgf\n\
1095 <PgfAlignment Center>\n\
1096 <PgfFont \n\
1097 <FTag `'>\n\
1098 <FFamily `Times'>\n\
1099 <FVar `Regular'>\n\
1100 <FWeight `Regular'>\n\
1101 <FAngle `Regular'>\n\
1102 <FPostScriptName `Times-Roman'>\n\
1103 <FEncoding `FrameRoman'>\n\
1104 <FSize 11.0 pt>\n\
1105 <FUnderlining FNoUnderlining>\n\
1106 <FOverline No>\n\
1107 <FStrike No>\n\
1108 <FChangeBar No>\n\
1109 <FOutline No>\n\
1110 <FShadow No>\n\
1111 <FPairKern Yes>\n\
1112 <FTsume No>\n\
1113 <FCase FAsTyped>\n\
1114 <FPosition FNormal>\n\
1115 <FDX 0.0%>\n\
1116 <FDY 0.0%>\n\
1117 <FDW 0.0%>\n\
1118 <FStretch 100.0%>\n\
1119 <FLanguage USEnglish>\n\
1120 <FLocked No>\n\
1121 <FSeparation 0>\n\
1122 <FColor `Black'>\n\
1123 > # end of PgfFont\n\
1124 >\n\
1125 <ParaLine\n\
1126 <String `";
1127
1128 const string row_cell_after_contents =
1129 "'>\n\
1130 > # end of ParaLine\n\
1131 > # end of Para\n\
1132 > # end of CellContent\n\
1133 > # end of Cell\n\
1134 ";
1135
1136 const string row_empty_cell =
1137 " <CellFill 5>\n\
1138 <CellColor `Cyan'>\n\
1139 <CellContent\n\
1140 <Para\n\
1141 <PgfTag `CellBody'>\n\
1142 <ParaLine\n\
1143 <String `'>\n\
1144 > # end of ParaLine\n\
1145 > # end of Para\n\
1146 > # end of CellContent\n\
1147 > # end of Cell\n\
1148 ";
1149
1150 const string row_after_last_cell =
1151 " > # end of Row\n\
1152 ";
1153
1154
1155 const string mif_epilog =
1156 " > # end of TblBody\n\
1157 > # end of Tbl\n\
1158 > # end of Tbls\n\
1159 \n\
1160 <Para\n\
1161 <ParaLine\n\
1162 <ATbl 1>\n\
1163 > # end of ParaLine\n\
1164 > # end of Para\n\
1165 \n\
1166 # End of MIFFile\n\
1167 ";
1168
1169 int i, j, num_rows, num_cols;
1170 string row_ruling;
1171 string col_ruling;
1172
1173 num_rows = sm.numStates();
1174 num_cols = sm.numEvents() + 1;
1175
1176 // -- Prolog
1177 out << mif_prolog;
1178
1179 // -- Table format (for each column)
1180 for( i = 0; i < num_cols; i++ )
1181 {
1182 out << tbl_fmt_before_col_num;
1183 out << i;
1184 out << tbl_fmt_after_col_num;
1185 }
1186
1187 // -- Spell out width of each column
1188
1189 // -- FIXME: make following constants into parameters
1190 const float total_table_width = 7.5; // -- Total page width = 7.5" (portrait mode)
1191 const float min_col_width = 0.35; // -- Min col width (for legibility)
1192 const float max_col_width = 0.75; // -- Max col width (for aesthetics)
1193 float column_width;
1194
1195 // -- Calculate column width and clamp it within a range
1196 column_width = total_table_width / num_cols;
1197 column_width = ((column_width < min_col_width)
1198 ? min_col_width
1199 : ((column_width > max_col_width)
1200 ? max_col_width
1201 : column_width));
1202
1203 out << tbl_fmt_before_num_cols;
1204 out << num_cols;
1205 for( i = 0; i < num_cols; i++ )
1206 {
1207 out << tbl_fmt_each_col_width_begin << column_width << tbl_fmt_each_col_width_end;
1208 }
1209
1210 // -- Column headers
1211 out << tbl_before_first_header1;
1212 out << formatShorthand( sm.getShorthand() );
1213 out << " transitions";
1214 out << tbl_before_first_header2;
1215
1216 out << tbl_before_each_header;
1217 out << "State";
1218 out << tbl_after_each_header;
1219
1220 for( i = 0; i < sm.numEvents(); i++ )
1221 {
1222 out << tbl_before_each_rot_header;
1223 out << formatShorthand( sm.getEvent(i).getShorthand() );
1224 out << tbl_after_each_header;
1225 }
1226 out << before_first_row;
1227
1228
1229 // -- Body of table
1230 for( i = 0; i < num_rows; i++ )
1231 {
1232 // -- Each row
1233 out << row_before_first_cell;
1234
1235 // -- Figure out ruling
1236 if (sm.getState(i).existPair("format")) {
1237 row_ruling = formatCellRuling( sm.getState(i).lookupPair("format"));
1238 } else {
1239 row_ruling = "";
1240 }
1241
1242 // -- First column = state
1243 out << row_cell_before_ruling;
1244 out << row_ruling;
1245 out << row_cell_before_contents;
1246 out << formatShorthand( sm.getState(i).getShorthand() );
1247 out << row_cell_after_contents;
1248
1249 // -- One column for each event
1250 for( j = 0; j < sm.numEvents(); j++ )
1251 {
1252 const Transition* trans_ptr = sm.getTransPtr( i, j );
1253
1254 // -- Figure out ruling
1255 if (sm.getEvent(j).existPair("format")) {
1256 col_ruling = formatCellRuling(sm.getEvent(j).lookupPair("format"));
1257 } else {
1258 col_ruling = "";
1259 }
1260
1261 out << row_cell_before_ruling;
1262 out << row_ruling;
1263 out << col_ruling;
1264
1265 if( trans_ptr != NULL )
1266 {
1267 string actions;
1268 string nextState;
1269
1270 // -- Get the actions
1271 actions = formatShorthand( trans_ptr->getActionShorthands() );
1272
1273 // -- Get the next state
1274 // FIXME: should compare index, not the string
1275 if (trans_ptr->getNextStateShorthand() !=
1276 sm.getState(i).getShorthand() )
1277 {
1278 nextState = formatShorthand( trans_ptr->getNextStateShorthand() );
1279 } else
1280 {
1281 nextState = "";
1282 }
1283
1284 // -- Print out "actions/next-state"
1285 out << row_cell_before_contents;
1286 out << actions;
1287 if ((nextState.length() != 0) && (actions.length() != 0)) {
1288 out << "/";
1289 }
1290 out << nextState;
1291 out << row_cell_after_contents;
1292 }
1293 else
1294 {
1295 out << row_empty_cell;
1296 }
1297
1298 }
1299
1300 out << row_after_last_cell;
1301 }
1302
1303 // -- Epilog
1304 out << mif_epilog;
1305
1306 }
1307 /*
1308 void printTBETableMIF(const StateMachine& sm, const Vector<Field>& fields, ostream& out)
1309 {
1310 const string mif_prolog1 =
1311 "<MIFFile 5.50> # Generated by Multifacet MIF Mungers Inc\n\
1312 <Tbls\n\
1313 <Tbl\n\
1314 <TblID 1>\n\
1315 <TblTag `Format A'>\n\
1316 <TblFormat\n\
1317 \n\
1318 <TblAlignment Center>\n\
1319 \n\
1320 # # <TblXColumnNum 0>\n\
1321 <TblXColumnRuling `Medium'>\n\
1322 \n\
1323 <TblLRuling `Medium'>\n\
1324 <TblRRuling `Medium'>\n\
1325 <TblTRuling `Medium'>\n\
1326 <TblBRuling `Medium'>\n\
1327 \n\
1328 <TblColumn\n\
1329 <TblColumnNum 0>\n\
1330 <TblColumnWidth 0.51\">\n\
1331 <TblColumnH\n\
1332 <PgfTag `CellHeading'>\n\
1333 > # end of TblColumnH\n\
1334 <TblColumnBody\n\
1335 <PgfTag `CellBody'>\n\
1336 > # end of TblColumnBody\n\
1337 <TblColumnF\n\
1338 <PgfTag `CellHeading'>\n\
1339 > # end of TblColumnF\n\
1340 > # end of TblColumn\n\
1341 <TblColumn\n\
1342 <TblColumnNum 1>\n\
1343 <TblColumnWidth 0.51\">\n\
1344 <TblColumnH\n\
1345 <PgfTag `CellHeading'>\n\
1346 > # end of TblColumnH\n\
1347 <TblColumnBody\n\
1348 <PgfTag `CellBody'>\n\
1349 > # end of TblColumnBody\n\
1350 <TblColumnF\n\
1351 <PgfTag `CellHeading'>\n\
1352 > # end of TblColumnF\n\
1353 > # end of TblColumn\n\
1354 > # end of TblFormat\n\
1355 \n\
1356 <TblNumColumns 2>\n\
1357 <TblColumnWidth 0.51\">\n\
1358 <TblColumnWidth 6.00\">\n\
1359 <TblTitle\n\
1360 <TblTitleContent\n\
1361 <Para\n\
1362 <PgfTag `TableTitle'>\n\
1363 <Pgf\n\
1364 <PgfAlignment Center>\n\
1365 <PgfFont \n\
1366 <FTag `'>\n\
1367 <FFamily `Times'>\n\
1368 <FVar `Regular'>\n\
1369 <FWeight `Regular'>\n\
1370 <FAngle `Regular'>\n\
1371 <FPostScriptName `Times-Roman'>\n\
1372 <FEncoding `FrameRoman'>\n\
1373 <FSize 11.0 pt>\n\
1374 <FUnderlining FNoUnderlining>\n\
1375 <FOverline No>\n\
1376 <FStrike No>\n\
1377 <FChangeBar No>\n\
1378 <FOutline No>\n\
1379 <FShadow No>\n\
1380 <FPairKern Yes>\n\
1381 <FTsume No>\n\
1382 <FCase FAsTyped>\n\
1383 <FPosition FNormal>\n\
1384 <FDX 0.0%>\n\
1385 <FDY 0.0%>\n\
1386 <FDW 0.0%>\n\
1387 <FStretch 100.0%>\n\
1388 <FLanguage USEnglish>\n\
1389 <FLocked No>\n\
1390 <FSeparation 0>\n\
1391 <FColor `Black'>\n\
1392 > # end of PgfFont\n\
1393 > # end of Pgf\n\
1394 <PgfNumString `TABLE 1. '>\n\
1395 <ParaLine\n\
1396 <Marker\n\
1397 <MType 9>\n\
1398 <MTypeName `Cross-Ref'>\n\
1399 <MCurrPage `1'>\n\
1400 > # end of Marker\n\
1401 <String `";
1402
1403 const string mif_prolog2 =
1404 "'>\n\
1405 > # end of ParaLine\n\
1406 > # end of Para\n\
1407 > # end of TblTitleContent\n\
1408 > # end of TblTitle\n\
1409 \n\
1410 <TblH\n\
1411 <Row\n\
1412 <RowMaxHeight 14.0\">\n\
1413 <RowHeight 0.44444\">\n\
1414 <Cell\n\
1415 <CellLRuling `Medium'>\n\
1416 <CellBRuling `Medium'>\n\
1417 <CellRRuling `Medium'>\n\
1418 <CellTRuling `Medium'>\n\
1419 <CellContent\n\
1420 <Para\n\
1421 <PgfTag `CellHeading'>\n\
1422 <Pgf\n\
1423 <PgfAlignment Center>\n\
1424 <PgfFont \n\
1425 <FTag `'>\n\
1426 <FFamily `Times'>\n\
1427 <FVar `Regular'>\n\
1428 <FWeight `Regular'>\n\
1429 <FAngle `Regular'>\n\
1430 <FPostScriptName `Times-Roman'>\n\
1431 <FEncoding `FrameRoman'>\n\
1432 <FSize 11.0 pt>\n\
1433 <FUnderlining FNoUnderlining>\n\
1434 <FOverline No>\n\
1435 <FStrike No>\n\
1436 <FChangeBar No>\n\
1437 <FOutline No>\n\
1438 <FShadow No>\n\
1439 <FPairKern Yes>\n\
1440 <FTsume No>\n\
1441 <FCase FAsTyped>\n\
1442 <FPosition FNormal>\n\
1443 <FDX 0.0%>\n\
1444 <FDY 0.0%>\n\
1445 <FDW 0.0%>\n\
1446 <FStretch 100.0%>\n\
1447 <FLanguage USEnglish>\n\
1448 <FLocked No>\n\
1449 <FSeparation 0>\n\
1450 <FColor `Black'>\n\
1451 > # end of PgfFont\n\
1452 >\n\
1453 <ParaLine\n\
1454 <String `Field'>\n\
1455 > # end of ParaLine\n\
1456 > # end of Para\n\
1457 > # end of CellContent\n\
1458 > # end of Cell\n\
1459 <Cell\n\
1460 <CellLRuling `Medium'>\n\
1461 <CellBRuling `Medium'>\n\
1462 <CellRRuling `Medium'>\n\
1463 <CellTRuling `Medium'>\n\
1464 <CellContent\n\
1465 <Para\n\
1466 <PgfTag `CellHeading'>\n\
1467 <PgfFont \n\
1468 <FTag `'>\n\
1469 <FFamily `Times'>\n\
1470 <FVar `Regular'>\n\
1471 <FWeight `Regular'>\n\
1472 <FAngle `Regular'>\n\
1473 <FPostScriptName `Times-Roman'>\n\
1474 <FEncoding `FrameRoman'>\n\
1475 <FSize 11.0 pt>\n\
1476 <FUnderlining FNoUnderlining>\n\
1477 <FOverline No>\n\
1478 <FStrike No>\n\
1479 <FChangeBar No>\n\
1480 <FOutline No>\n\
1481 <FShadow No>\n\
1482 <FPairKern Yes>\n\
1483 <FTsume No>\n\
1484 <FCase FAsTyped>\n\
1485 <FPosition FNormal>\n\
1486 <FDX 0.0%>\n\
1487 <FDY 0.0%>\n\
1488 <FDW 0.0%>\n\
1489 <FStretch 100.0%>\n\
1490 <FLanguage USEnglish>\n\
1491 <FLocked No>\n\
1492 <FSeparation 0>\n\
1493 <FColor `Black'>\n\
1494 > # end of PgfFont\n\
1495 <ParaLine\n\
1496 <String `Description'>\n\
1497 > # end of ParaLine\n\
1498 > # end of Para\n\
1499 > # end of CellContent\n\
1500 > # end of Cell\n\
1501 > # end of Row\n\
1502 > # end of TblH\n\
1503 \n\
1504 <TblBody\n\
1505 ";
1506
1507 const string row_before_state =
1508 " <Row\n\
1509 <RowMaxHeight 14.0\">\n\
1510 <RowHeight 0.22222\">\n\
1511 <Cell\n\
1512 <CellContent\n\
1513 <Para\n\
1514 <PgfTag `CellBody'>\n\
1515 <Pgf\n\
1516 <PgfAlignment Center>\n\
1517 <PgfFont \n\
1518 <FTag `'>\n\
1519 <FFamily `Times'>\n\
1520 <FVar `Regular'>\n\
1521 <FWeight `Regular'>\n\
1522 <FAngle `Regular'>\n\
1523 <FPostScriptName `Times-Roman'>\n\
1524 <FEncoding `FrameRoman'>\n\
1525 <FSize 11.0 pt>\n\
1526 <FUnderlining FNoUnderlining>\n\
1527 <FOverline No>\n\
1528 <FStrike No>\n\
1529 <FChangeBar No>\n\
1530 <FOutline No>\n\
1531 <FShadow No>\n\
1532 <FPairKern Yes>\n\
1533 <FTsume No>\n\
1534 <FCase FAsTyped>\n\
1535 <FPosition FNormal>\n\
1536 <FDX 0.0%>\n\
1537 <FDY 0.0%>\n\
1538 <FDW 0.0%>\n\
1539 <FStretch 100.0%>\n\
1540 <FLanguage USEnglish>\n\
1541 <FLocked No>\n\
1542 <FSeparation 0>\n\
1543 <FColor `Black'>\n\
1544 > # end of PgfFont\n\
1545 >\n\
1546 <ParaLine\n\
1547 <String `";
1548
1549 const string row_between_state_desc =
1550 "'>\n\
1551 > # end of ParaLine\n\
1552 > # end of Para\n\
1553 > # end of CellContent\n\
1554 > # end of Cell\n\
1555 <Cell\n\
1556 <CellContent\n\
1557 <Para\n\
1558 <PgfTag `CellBody'>\n\
1559 <ParaLine\n\
1560 <String `";
1561
1562 const string row_after_desc =
1563 "'>\n\
1564 > # end of ParaLine\n\
1565 > # end of Para\n\
1566 > # end of CellContent\n\
1567 > # end of Cell\n\
1568 > # end of Row\n\
1569 ";
1570
1571 const string mif_epilog =
1572 " > # end of TblBody\n\
1573 > # end of Tbl\n\
1574 > # end of Tbls\n\
1575 \n\
1576 <Para\n\
1577 <ParaLine\n\
1578 <ATbl 1>\n\
1579 > # end of ParaLine\n\
1580 > # end of Para\n\
1581 \n\
1582 # End of MIFFile\n\
1583 ";
1584
1585 out << mif_prolog1;
1586 out << sm.getShorthand();
1587 out << " TBE";
1588 out << mif_prolog2;
1589
1590 for( int i = 0; i < fields.size(); i++ ) {
1591 out << row_before_state;
1592 out << formatShorthand(fields[i].getShorthand());
1593 out << row_between_state_desc;
1594 out << fields[i].getDescription();
1595 out << row_after_desc;
1596 }
1597
1598 out << mif_epilog;
1599 }
1600 */
1601 // --
1602 // -- Helper function to do some shorthand formatting (kludge before we
1603 // -- get the tuple attributes into the state machine language.
1604 // -- Current convention:
1605 // -- - each `_' indicates a toggle between normal mode and superscript
1606 // -- - each escaped (using `\') character indicates a letter formatted
1607 // -- using the Symbol character set. \a = alpha, \b = beta, \c = chi etc.
1608 // -- See the FrameMaker character sets manual in the Online Manuals.
1609 // -- - a `!' indicates extra stuff at the end which can be ignored (used
1610 // -- for determining cell ruling and so on)
1611 // --
1612 string formatShorthand(const string shorthand)
1613 {
1614 string munged_shorthand = "";
1615 bool mode_is_normal = true;
1616 const string mif_superscript = "'> <Font <FPosition FSuperscript> <FLocked No> > <String `";
1617 const string mif_normal = "'> <Font <FPosition FNormal> <FLocked No> > <String `";
1618 const string mif_symbol = "'> <Font <FFamily `Symbol'> <FPostScriptName `Symbol'> <FEncoding `FrameRoman'> <FLocked No> > <String `";
1619 const string mif_times = "'> <Font <FFamily `Times'> <FPostScriptName `Times-Roman'> <FEncoding `FrameRoman'> <FLocked No> > <String `";
1620
1621
1622 // -- Walk over the string, processing superscript directives
1623 for( unsigned int i = 0; i < shorthand.length(); i++ )
1624 {
1625 if( shorthand[i] == '!' )
1626 {
1627 // -- Reached logical end of shorthand name
1628 break;
1629 }
1630 else if( shorthand[i] == '^' )
1631 {
1632 // -- Process super/subscript formatting
1633
1634 mode_is_normal = !mode_is_normal;
1635 if( mode_is_normal )
1636 {
1637 // -- Back to normal mode
1638 munged_shorthand += mif_normal;
1639 }
1640 else
1641 {
1642 // -- Going to superscript mode
1643 munged_shorthand += mif_superscript;
1644 }
1645
1646 }
1647 else if( shorthand[i] == '\\' )
1648 {
1649 // -- Process Symbol character set
1650 if( (i + 1) < shorthand.length() )
1651 {
1652 i++; // -- Proceed to next char. Yes I know that changing the loop var is ugly!
1653 munged_shorthand += mif_symbol;
1654 munged_shorthand += shorthand[i];
1655 munged_shorthand += mif_times;
1656 }
1657 else
1658 {
1659 // -- FIXME: Add line number info later
1660 cerr << "Encountered a `\\` without anything following it!" << endl;
1661 exit( -1 );
1662 }
1663
1664 }
1665 else
1666 {
1667 // -- Pass on un-munged
1668 munged_shorthand += shorthand[i];
1669 }
1670
1671 } // -- end for all characters in shorthand
1672
1673 // -- Do any other munging
1674
1675 // -- Return the formatted shorthand name
1676 return munged_shorthand;
1677 }
1678
1679
1680 // --
1681 // -- Helper function to figure out where to put rules in the table (kludge before we
1682 // -- get the tuple attributes into the shorthand machine language.
1683 // -- Current convention:
1684 // -- - a `!' in the shorthand indicates the beginning of ruling information
1685 // -- - `b' => bottom of this row is ruled
1686 // -- - `r' => right of this column is ruled
1687 // --
1688 string formatCellRuling( const string shorthand)
1689 {
1690 for( unsigned int i = 0; i < shorthand.length(); i++ )
1691 {
1692 if( shorthand[i] == '!' )
1693 {
1694 // -- OK, found beginning of ruling information
1695 for( unsigned int j = i+1; j < shorthand.length(); j++ )
1696 {
1697 if( shorthand[j] == 'b')
1698 {
1699 // -- Rule the bottom
1700 return "<CellBRuling `Medium'>\n";
1701 }
1702 else if( shorthand[j] == 'r')
1703 {
1704 // -- Rule the bottom
1705 return "<CellRRuling `Medium'>\n";
1706 }
1707
1708 }
1709
1710 // -- No ruling directives recognized, return default ruling
1711 return "";
1712 }
1713
1714 }
1715
1716 // -- No ruling information found, return default ruling
1717 return "";
1718 }