5 #include <apc/parser.tab.h>
9 extern void lexer_pushtok(int, YYSTYPE
);
10 extern int lexer_lexmapfile(int, int);
11 extern int ipower(int, int);
12 extern int ttov(uint8_t*, int);
13 extern uint8_t* ttos(const uint8_t*, int);
15 int lexer_setdirection(uint8_t*, int);
16 int lexer_lexstring(uint8_t*, int);
17 int lexer_setstr(uint8_t*, int);
20 #define PUSHTOK(TOK,LFUNC,UTYPE) \
22 printf("Lexer_lexstring:: PUSHTOK(" $(TOK) $(LFUNC) $(UTYPE) ")\n"); \
24 yylval.UTYPE = LFUNC(ts, p-ts); \
25 lexer_pushtok(tok_t, yylval); \
30 #line 31 "lexer_fsm.c"
31 static const char _lexstring_actions
[] = {
32 0, 1, 0, 1, 1, 1, 2, 1,
33 3, 1, 4, 1, 5, 1, 13, 1,
34 14, 1, 15, 2, 0, 14, 2, 2,
35 6, 2, 2, 7, 2, 2, 8, 2,
36 2, 9, 2, 2, 10, 2, 2, 11,
40 static const short _lexstring_key_offsets
[] = {
41 0, 0, 12, 17, 22, 24, 28, 34,
42 40, 48, 54, 63, 69, 75, 76, 82,
43 83, 89, 95, 103, 111, 123, 135, 147,
44 159, 171, 183, 195, 207, 219, 231, 243,
48 static const char _lexstring_trans_keys
[] = {
49 48, 69, 78, 83, 87, 126, 49, 57,
50 65, 90, 97, 122, 0, 95, 120, 48,
51 57, 0, 95, 120, 48, 57, 48, 57,
52 0, 95, 48, 57, 0, 95, 65, 90,
53 97, 122, 0, 95, 65, 90, 97, 122,
54 0, 69, 87, 95, 65, 90, 97, 122,
55 0, 95, 65, 90, 97, 122, 0, 69,
56 83, 87, 95, 65, 90, 97, 122, 0,
57 95, 65, 90, 97, 122, 0, 95, 65,
58 90, 97, 122, 95, 35, 95, 65, 90,
59 97, 122, 95, 0, 95, 65, 90, 97,
60 122, 48, 57, 65, 90, 97, 122, 0,
61 95, 48, 57, 65, 90, 97, 122, 0,
62 95, 48, 57, 65, 90, 97, 122, 48,
63 69, 78, 83, 87, 126, 49, 57, 65,
64 90, 97, 122, 48, 69, 78, 83, 87,
65 126, 49, 57, 65, 90, 97, 122, 48,
66 69, 78, 83, 87, 126, 49, 57, 65,
67 90, 97, 122, 48, 69, 78, 83, 87,
68 126, 49, 57, 65, 90, 97, 122, 48,
69 69, 78, 83, 87, 126, 49, 57, 65,
70 90, 97, 122, 48, 69, 78, 83, 87,
71 126, 49, 57, 65, 90, 97, 122, 48,
72 69, 78, 83, 87, 126, 49, 57, 65,
73 90, 97, 122, 48, 69, 78, 83, 87,
74 126, 49, 57, 65, 90, 97, 122, 48,
75 69, 78, 83, 87, 126, 49, 57, 65,
76 90, 97, 122, 48, 69, 78, 83, 87,
77 126, 49, 57, 65, 90, 97, 122, 48,
78 69, 78, 83, 87, 126, 49, 57, 65,
79 90, 97, 122, 48, 69, 78, 83, 87,
80 126, 49, 57, 65, 90, 97, 122, 48,
81 69, 78, 83, 87, 126, 49, 57, 65,
82 90, 97, 122, 48, 69, 78, 83, 87,
83 126, 49, 57, 65, 90, 97, 122, 48,
84 69, 78, 83, 87, 126, 49, 57, 65,
88 static const char _lexstring_single_lengths
[] = {
89 0, 6, 3, 3, 0, 2, 2, 2,
90 4, 2, 5, 2, 2, 1, 2, 1,
91 2, 0, 2, 2, 6, 6, 6, 6,
92 6, 6, 6, 6, 6, 6, 6, 6,
96 static const char _lexstring_range_lengths
[] = {
97 0, 3, 1, 1, 1, 1, 2, 2,
98 2, 2, 2, 2, 2, 0, 2, 0,
99 2, 3, 3, 3, 3, 3, 3, 3,
100 3, 3, 3, 3, 3, 3, 3, 3,
104 static const short _lexstring_index_offsets
[] = {
105 0, 0, 10, 15, 20, 22, 26, 31,
106 36, 43, 48, 56, 61, 66, 68, 73,
107 75, 80, 84, 90, 96, 106, 116, 126,
108 136, 146, 156, 166, 176, 186, 196, 206,
112 static const char _lexstring_indicies
[] = {
113 0, 4, 5, 6, 7, 8, 2, 3,
114 3, 1, 9, 9, 11, 10, 1, 9,
115 9, 12, 10, 1, 13, 1, 14, 14,
116 15, 1, 16, 16, 17, 17, 1, 16,
117 18, 17, 17, 1, 16, 19, 19, 20,
118 17, 17, 1, 16, 21, 17, 17, 1,
119 16, 22, 23, 24, 25, 17, 17, 1,
120 16, 26, 17, 17, 1, 16, 27, 17,
121 17, 1, 28, 1, 29, 30, 17, 17,
122 1, 31, 1, 16, 32, 17, 17, 1,
123 33, 34, 34, 1, 35, 35, 36, 34,
124 34, 1, 37, 37, 34, 34, 34, 1,
125 0, 4, 5, 6, 7, 8, 2, 3,
126 3, 1, 0, 4, 5, 6, 7, 8,
127 2, 3, 3, 1, 0, 4, 5, 6,
128 7, 8, 2, 3, 3, 1, 0, 4,
129 5, 6, 7, 8, 2, 3, 3, 1,
130 0, 4, 5, 6, 7, 8, 2, 3,
131 3, 1, 0, 4, 5, 6, 7, 8,
132 2, 3, 3, 1, 0, 4, 5, 6,
133 7, 8, 2, 3, 3, 1, 0, 4,
134 5, 6, 7, 8, 2, 3, 3, 1,
135 0, 4, 5, 6, 7, 8, 2, 3,
136 3, 1, 0, 4, 5, 6, 7, 8,
137 2, 3, 3, 1, 0, 4, 5, 6,
138 7, 8, 2, 3, 3, 1, 0, 4,
139 5, 6, 7, 8, 2, 3, 3, 1,
140 0, 4, 5, 6, 7, 8, 2, 3,
141 3, 1, 0, 4, 5, 6, 7, 8,
142 2, 3, 3, 1, 0, 4, 5, 6,
146 static const char _lexstring_trans_targs
[] = {
147 2, 0, 3, 6, 7, 8, 10, 12,
148 13, 20, 3, 17, 4, 5, 21, 5,
149 22, 6, 23, 9, 32, 24, 11, 14,
150 16, 31, 25, 26, 27, 15, 29, 28,
151 30, 18, 19, 33, 18, 34
154 static const char _lexstring_trans_actions
[] = {
155 9, 0, 9, 9, 9, 9, 9, 9,
156 0, 0, 0, 13, 13, 9, 0, 0,
157 0, 0, 0, 0, 0, 0, 0, 0,
158 0, 0, 0, 0, 0, 11, 0, 0,
162 static const char _lexstring_to_state_actions
[] = {
163 0, 0, 0, 0, 0, 0, 0, 0,
164 0, 0, 0, 0, 0, 0, 0, 17,
165 0, 0, 0, 0, 3, 15, 5, 37,
166 31, 40, 28, 7, 0, 11, 25, 22,
170 static const int lexstring_start
= 1;
171 static const int lexstring_first_final
= 20;
172 static const int lexstring_error
= 0;
174 static const int lexstring_en_tok_lexer
= 1;
177 #line 114 "lexer_fsm.rl"
182 (uint8_t* str
, int size
)
184 uint8_t *ts
, *pe
, *eof
;
185 int cs
, ntok
, tok_t
, direction
;
187 ntok
= direction
= 0;
191 printf("|---Begin lexstring on p = %s, pe = %s.\n",p
, pe
);
194 #line 195 "lexer_fsm.c"
196 cs
= lexstring_start
;
199 #line 130 "lexer_fsm.rl"
201 #line 202 "lexer_fsm.c"
214 _keys
= _lexstring_trans_keys
+ _lexstring_key_offsets
[cs
];
215 _trans
= _lexstring_index_offsets
[cs
];
217 _klen
= _lexstring_single_lengths
[cs
];
219 const char *_lower
= _keys
;
221 const char *_upper
= _keys
+ _klen
- 1;
223 if ( _upper
< _lower
)
226 _mid
= _lower
+ ((_upper
-_lower
) >> 1);
229 else if ( (*p
) > *_mid
)
232 _trans
+= (unsigned int)(_mid
- _keys
);
240 _klen
= _lexstring_range_lengths
[cs
];
242 const char *_lower
= _keys
;
244 const char *_upper
= _keys
+ (_klen
<<1) - 2;
246 if ( _upper
< _lower
)
249 _mid
= _lower
+ (((_upper
-_lower
) >> 1) & ~1);
250 if ( (*p
) < _mid
[0] )
252 else if ( (*p
) > _mid
[1] )
255 _trans
+= (unsigned int)((_mid
- _keys
)>>1);
263 _trans
= _lexstring_indicies
[_trans
];
264 cs
= _lexstring_trans_targs
[_trans
];
266 if ( _lexstring_trans_actions
[_trans
] == 0 )
269 _acts
= _lexstring_actions
+ _lexstring_trans_actions
[_trans
];
270 _nacts
= (unsigned int) *_acts
++;
271 while ( _nacts
-- > 0 )
276 #line 41 "lexer_fsm.rl"
277 { printf("Lexer_lexstring:: action:set_ts. ts = %s\n", p
); ts
= p
; }
280 #line 42 "lexer_fsm.rl"
281 { printf("Lexer_lexstring:: action:push_SS. p = %s\n",p
);
282 yylval
.str
= (uint8_t*) "SS";
283 lexer_pushtok(SS
, yylval
);
288 #line 79 "lexer_fsm.rl"
289 { printf("Lexer_lexstring:: action:push_height p = %s\n", p
);
290 PUSHTOK(HEIGHT
, ttov
, val
);
293 #line 294 "lexer_fsm.c"
298 _acts
= _lexstring_actions
+ _lexstring_to_state_actions
[cs
];
299 _nacts
= (unsigned int) *_acts
++;
300 while ( _nacts
-- > 0 ) {
301 switch ( *_acts
++ ) {
303 #line 31 "lexer_fsm.rl"
304 { PUSHTOK(REF
, ttov
, ref
); }
307 #line 32 "lexer_fsm.rl"
308 { PUSHTOK(NUM
, ttov
, val
); }
311 #line 33 "lexer_fsm.rl"
312 { printf("Lexer_lexstring:: action:push_name: from %s to %s\n", ts
, p
);
313 PUSHTOK(NAME
, ttos
, str
);
317 #line 36 "lexer_fsm.rl"
318 { printf("Lexer_lexstring:: action:push_map: pushing '~'\n");
319 yylval
.str
= (uint8_t*) '~';
320 lexer_pushtok(MOPEN
, yylval
);
325 #line 42 "lexer_fsm.rl"
326 { printf("Lexer_lexstring:: action:push_SS. p = %s\n",p
);
327 yylval
.str
= (uint8_t*) "SS";
328 lexer_pushtok(SS
, yylval
);
333 #line 47 "lexer_fsm.rl"
334 { printf("Lexer_lexstring:: action:push_S. p = %s\n", p
);
336 lexer_pushtok(D
, yylval
);
340 #line 51 "lexer_fsm.rl"
341 { printf("Lexer_lexstring:: action:push_SW. p = %s\n", p
);
343 lexer_pushtok(D
, yylval
);
347 #line 55 "lexer_fsm.rl"
348 { printf("Lexer_lexstring:: action:push_W. p = %s\n", p
);
350 lexer_pushtok(D
, yylval
);
354 #line 59 "lexer_fsm.rl"
355 { printf("Lexer_lexstring:: action:push_NW. p = %s\n", p
);
357 lexer_pushtok(D
, yylval
);
361 #line 63 "lexer_fsm.rl"
362 { printf("Lexer_lexstring:: action:push_N. p = %s\n", p
);
364 lexer_pushtok(D
, yylval
);
368 #line 71 "lexer_fsm.rl"
369 { printf("Lexer_lexstring:: action:push_N. p = %s\n", p
);
371 lexer_pushtok(D
, yylval
);
375 #line 75 "lexer_fsm.rl"
376 { printf("Lexer_lexstring:: action:push_N. p = %s\n", p
);
378 lexer_pushtok(D
, yylval
);
382 #line 82 "lexer_fsm.rl"
383 { printf("Lexer_lexstring:: action:push_height p = %s\n", p
);
384 PUSHTOK(WIDTH
, ttov
, val
);
388 #line 85 "lexer_fsm.rl"
389 {yylval
.str
= (uint8_t*) '#'; lexer_pushtok(LINK
),yylval
); }
391 #line 392 "lexer_fsm.c"
403 #line 131 "lexer_fsm.rl"
405 printf("Ending lexstring of file %s, pushed %d tokens.\n",str
, ntok
);
412 #line 413 "lexer_fsm.c"
413 static const char _setdirection_actions
[] = {
414 0, 1, 0, 1, 1, 1, 2, 1,
415 3, 1, 4, 1, 5, 1, 6, 1,
419 static const char _setdirection_key_offsets
[] = {
420 0, 0, 6, 8, 12, 14, 16, 20,
421 22, 24, 26, 26, 26, 26, 26, 26,
425 static const char _setdirection_trans_keys
[] = {
426 0, 69, 78, 83, 87, 95, 0, 95,
427 0, 69, 87, 95, 0, 95, 0, 95,
428 0, 69, 87, 95, 0, 95, 0, 95,
432 static const char _setdirection_single_lengths
[] = {
433 0, 6, 2, 4, 2, 2, 4, 2,
434 2, 2, 0, 0, 0, 0, 0, 0,
438 static const char _setdirection_range_lengths
[] = {
439 0, 0, 0, 0, 0, 0, 0, 0,
440 0, 0, 0, 0, 0, 0, 0, 0,
444 static const char _setdirection_index_offsets
[] = {
445 0, 0, 7, 10, 15, 18, 21, 26,
446 29, 32, 35, 36, 37, 38, 39, 40,
450 static const char _setdirection_indicies
[] = {
451 0, 2, 3, 4, 5, 0, 1, 6,
452 6, 1, 7, 8, 9, 7, 1, 10,
453 10, 1, 11, 11, 1, 0, 12, 13,
454 0, 1, 14, 14, 1, 15, 15, 1,
455 16, 16, 1, 1, 1, 1, 1, 1,
459 static const char _setdirection_trans_targs
[] = {
460 10, 0, 2, 3, 6, 9, 11, 12,
461 4, 5, 13, 14, 7, 8, 15, 16,
465 static const char _setdirection_trans_actions
[] = {
466 0, 0, 0, 0, 0, 0, 0, 0,
467 0, 0, 0, 0, 0, 0, 0, 0,
471 static const char _setdirection_to_state_actions
[] = {
472 0, 0, 0, 0, 0, 0, 0, 0,
473 0, 0, 7, 5, 1, 9, 11, 13,
477 static const int setdirection_start
= 1;
478 static const int setdirection_first_final
= 10;
479 static const int setdirection_error
= 0;
481 static const int setdirection_en_main
= 1;
484 #line 166 "lexer_fsm.rl"
489 (uint8_t* str
, int size
)
490 { uint8_t *p
, *pe
, *eof
;
497 printf("|--- Begin lexer_setdirection str = %s, p = %s, pe = %s ---|\n", str
,p
, pe
);
500 #line 501 "lexer_fsm.c"
502 cs
= setdirection_start
;
505 #line 181 "lexer_fsm.rl"
507 #line 508 "lexer_fsm.c"
518 _keys
= _setdirection_trans_keys
+ _setdirection_key_offsets
[cs
];
519 _trans
= _setdirection_index_offsets
[cs
];
521 _klen
= _setdirection_single_lengths
[cs
];
523 const char *_lower
= _keys
;
525 const char *_upper
= _keys
+ _klen
- 1;
527 if ( _upper
< _lower
)
530 _mid
= _lower
+ ((_upper
-_lower
) >> 1);
533 else if ( (*p
) > *_mid
)
536 _trans
+= (unsigned int)(_mid
- _keys
);
544 _klen
= _setdirection_range_lengths
[cs
];
546 const char *_lower
= _keys
;
548 const char *_upper
= _keys
+ (_klen
<<1) - 2;
550 if ( _upper
< _lower
)
553 _mid
= _lower
+ (((_upper
-_lower
) >> 1) & ~1);
554 if ( (*p
) < _mid
[0] )
556 else if ( (*p
) > _mid
[1] )
559 _trans
+= (unsigned int)((_mid
- _keys
)>>1);
567 _trans
= _setdirection_indicies
[_trans
];
568 cs
= _setdirection_trans_targs
[_trans
];
570 _acts
= _setdirection_actions
+ _setdirection_to_state_actions
[cs
];
571 _nacts
= (unsigned int) *_acts
++;
572 while ( _nacts
-- > 0 ) {
573 switch ( *_acts
++ ) {
575 #line 141 "lexer_fsm.rl"
576 {printf("Lexer_setdirection:: direction is north, returning 4\n"); return 4;; }
579 #line 142 "lexer_fsm.rl"
580 { printf("Lexer_setdirection:: direction is west, returning 2\n");return 2;}
583 #line 143 "lexer_fsm.rl"
584 { printf("Lexer_setdirection:: direction is east, returning 6\n");return 6;}
587 #line 144 "lexer_fsm.rl"
588 { printf("Lexer_setdirection:: direction is south, returning 0\n");return 0;}
591 #line 145 "lexer_fsm.rl"
592 { printf("Lexer_setdirection:: direction is northeast, returning 5\n");return 5 ;}
595 #line 146 "lexer_fsm.rl"
596 { printf("Lexer_setdirection:: direction is northwest, returning 3\n");return 3;}
599 #line 147 "lexer_fsm.rl"
600 { printf("Lexer_setdirection:: direction is southeast, returning 7\n");return 7;}
603 #line 148 "lexer_fsm.rl"
604 { printf("Lexer_setdirection:: direction is southwest, returning 1\n");return 1;}
606 #line 607 "lexer_fsm.c"
617 #line 182 "lexer_fsm.rl"
619 printf("|--- Error in: lexer_setdirection ---|\n");
626 /**************************/
627 /****Abandon All Hope******/
628 /**************************/
637 #line 638 "lexer_fsm.c"
638 static const char _setstr_actions
[] = {
639 0, 1, 0, 1, 1, 1, 2, 1,
640 3, 1, 4, 1, 5, 1, 6, 1,
644 static const unsigned char _setstr_key_offsets
[] = {
645 0, 0, 6, 7, 13, 20, 25, 33,
646 34, 35, 36, 42, 50, 55, 60, 66,
647 75, 79, 85, 86, 92, 99, 106, 111,
648 115, 116, 117, 118, 124, 132, 137, 142,
649 148, 157, 161, 167, 168, 174, 181, 184,
650 185, 191, 195, 201, 202, 203, 209, 216,
651 222, 231, 235, 241, 241, 241, 241, 241,
655 static const char _setstr_trans_keys
[] = {
656 48, 83, 65, 90, 97, 122, 120, 48,
657 57, 65, 90, 97, 122, 0, 48, 57,
658 65, 90, 97, 122, 95, 65, 90, 97,
659 122, 35, 48, 83, 126, 65, 90, 97,
660 122, 95, 48, 120, 48, 57, 65, 90,
661 97, 122, 0, 95, 48, 57, 65, 90,
662 97, 122, 83, 65, 90, 97, 122, 0,
663 65, 90, 97, 122, 0, 83, 65, 90,
664 97, 122, 0, 69, 78, 83, 87, 65,
665 90, 97, 122, 65, 90, 97, 122, 69,
666 87, 65, 90, 97, 122, 120, 48, 57,
667 65, 90, 97, 122, 95, 48, 57, 65,
668 90, 97, 122, 35, 83, 126, 65, 90,
669 97, 122, 95, 65, 90, 97, 122, 35,
670 48, 83, 126, 95, 48, 120, 48, 57,
671 65, 90, 97, 122, 0, 95, 48, 57,
672 65, 90, 97, 122, 83, 65, 90, 97,
673 122, 0, 65, 90, 97, 122, 0, 83,
674 65, 90, 97, 122, 0, 69, 78, 83,
675 87, 65, 90, 97, 122, 65, 90, 97,
676 122, 69, 87, 65, 90, 97, 122, 120,
677 48, 57, 65, 90, 97, 122, 95, 48,
678 57, 65, 90, 97, 122, 35, 83, 126,
679 83, 83, 95, 65, 90, 97, 122, 65,
680 90, 97, 122, 69, 87, 65, 90, 97,
681 122, 48, 120, 48, 57, 65, 90, 97,
682 122, 0, 48, 57, 65, 90, 97, 122,
683 83, 95, 65, 90, 97, 122, 69, 78,
684 83, 87, 95, 65, 90, 97, 122, 65,
685 90, 97, 122, 69, 87, 65, 90, 97,
686 122, 69, 78, 83, 87, 95, 65, 90,
690 static const char _setstr_single_lengths
[] = {
691 0, 2, 1, 0, 1, 1, 4, 1,
692 1, 1, 0, 2, 1, 1, 2, 5,
693 0, 2, 1, 0, 1, 3, 1, 4,
694 1, 1, 1, 0, 2, 1, 1, 2,
695 5, 0, 2, 1, 0, 1, 3, 1,
696 2, 0, 2, 1, 1, 0, 1, 2,
697 5, 0, 2, 0, 0, 0, 0, 0,
701 static const char _setstr_range_lengths
[] = {
702 0, 2, 0, 3, 3, 2, 2, 0,
703 0, 0, 3, 3, 2, 2, 2, 2,
704 2, 2, 0, 3, 3, 2, 2, 0,
705 0, 0, 0, 3, 3, 2, 2, 2,
706 2, 2, 2, 0, 3, 3, 0, 0,
707 2, 2, 2, 0, 0, 3, 3, 2,
708 2, 2, 2, 0, 0, 0, 0, 0,
712 static const short _setstr_index_offsets
[] = {
713 0, 0, 5, 7, 11, 16, 20, 27,
714 29, 31, 33, 37, 43, 47, 51, 56,
715 64, 67, 72, 74, 78, 83, 89, 93,
716 98, 100, 102, 104, 108, 114, 118, 122,
717 127, 135, 138, 143, 145, 149, 154, 158,
718 160, 165, 168, 173, 175, 177, 181, 186,
719 191, 199, 202, 207, 208, 209, 210, 211,
723 static const char _setstr_indicies
[] = {
724 0, 3, 2, 2, 1, 4, 1, 5,
725 5, 5, 1, 6, 5, 5, 5, 1,
726 7, 2, 2, 1, 8, 9, 11, 12,
727 10, 10, 1, 13, 1, 14, 1, 15,
728 1, 16, 16, 16, 1, 17, 18, 16,
729 16, 16, 1, 20, 19, 19, 1, 17,
730 19, 19, 1, 17, 21, 19, 19, 1,
731 17, 22, 23, 23, 22, 19, 19, 1,
732 19, 19, 1, 22, 22, 19, 19, 1,
733 24, 1, 25, 25, 25, 1, 26, 25,
734 25, 25, 1, 8, 11, 12, 10, 10,
735 1, 27, 10, 10, 1, 28, 29, 30,
736 31, 1, 32, 1, 33, 1, 34, 1,
737 35, 35, 35, 1, 36, 37, 35, 35,
738 35, 1, 39, 38, 38, 1, 36, 38,
739 38, 1, 36, 40, 38, 38, 1, 36,
740 41, 42, 42, 41, 38, 38, 1, 38,
741 38, 1, 41, 41, 38, 38, 1, 43,
742 1, 44, 44, 44, 1, 45, 44, 44,
743 44, 1, 28, 30, 31, 1, 46, 1,
744 47, 27, 10, 10, 1, 10, 10, 1,
745 48, 48, 10, 10, 1, 49, 1, 50,
746 1, 51, 51, 51, 1, 52, 51, 51,
747 51, 1, 53, 7, 2, 2, 1, 54,
748 55, 55, 54, 7, 2, 2, 1, 2,
749 2, 1, 54, 54, 2, 2, 1, 1,
750 1, 1, 1, 1, 48, 56, 56, 48,
751 27, 10, 10, 1, 57, 1, 1, 0
754 static const char _setstr_trans_targs
[] = {
755 2, 0, 5, 47, 3, 4, 51, 6,
756 7, 18, 22, 40, 57, 8, 9, 10,
757 11, 52, 12, 13, 14, 15, 16, 17,
758 19, 20, 21, 23, 24, 35, 39, 55,
759 25, 26, 27, 28, 53, 29, 30, 31,
760 32, 33, 34, 36, 37, 38, 54, 56,
761 41, 44, 45, 46, 58, 48, 49, 50,
765 static const char _setstr_trans_actions
[] = {
766 17, 0, 17, 17, 17, 17, 0, 0,
767 0, 17, 17, 17, 0, 0, 17, 17,
768 17, 0, 0, 17, 17, 17, 17, 17,
769 17, 17, 0, 0, 0, 17, 0, 0,
770 0, 17, 17, 17, 0, 0, 17, 17,
771 17, 17, 17, 17, 17, 0, 0, 17,
772 17, 17, 17, 17, 0, 17, 17, 17,
776 static const char _setstr_to_state_actions
[] = {
777 0, 0, 0, 0, 13, 0, 0, 0,
778 0, 0, 0, 0, 0, 0, 0, 0,
779 0, 0, 0, 0, 0, 0, 0, 0,
780 0, 0, 0, 0, 0, 0, 0, 0,
781 0, 0, 0, 0, 0, 0, 0, 0,
782 0, 0, 0, 0, 0, 0, 0, 0,
783 0, 0, 0, 0, 1, 3, 9, 11,
787 static const int setstr_start
= 1;
788 static const int setstr_first_final
= 51;
789 static const int setstr_error
= 0;
791 static const int setstr_en_main
= 1;
794 #line 260 "lexer_fsm.rl"
799 (uint8_t* str
, int size
)
800 { uint8_t *p
, *pe
, *eof
;
801 int cs
, type
, newstrt
;
808 printf("|--- Begin lexer_setstr with str = %s, p = %s, pe = %s ---|\n", str
,p
, pe
);
811 #line 812 "lexer_fsm.c"
816 #line 276 "lexer_fsm.rl"
818 #line 819 "lexer_fsm.c"
829 _keys
= _setstr_trans_keys
+ _setstr_key_offsets
[cs
];
830 _trans
= _setstr_index_offsets
[cs
];
832 _klen
= _setstr_single_lengths
[cs
];
834 const char *_lower
= _keys
;
836 const char *_upper
= _keys
+ _klen
- 1;
838 if ( _upper
< _lower
)
841 _mid
= _lower
+ ((_upper
-_lower
) >> 1);
844 else if ( (*p
) > *_mid
)
847 _trans
+= (unsigned int)(_mid
- _keys
);
855 _klen
= _setstr_range_lengths
[cs
];
857 const char *_lower
= _keys
;
859 const char *_upper
= _keys
+ (_klen
<<1) - 2;
861 if ( _upper
< _lower
)
864 _mid
= _lower
+ (((_upper
-_lower
) >> 1) & ~1);
865 if ( (*p
) < _mid
[0] )
867 else if ( (*p
) > _mid
[1] )
870 _trans
+= (unsigned int)((_mid
- _keys
)>>1);
878 _trans
= _setstr_indicies
[_trans
];
879 cs
= _setstr_trans_targs
[_trans
];
881 if ( _setstr_trans_actions
[_trans
] == 0 )
884 _acts
= _setstr_actions
+ _setstr_trans_actions
[_trans
];
885 _nacts
= (unsigned int) *_acts
++;
886 while ( _nacts
-- > 0 )
891 #line 212 "lexer_fsm.rl"
892 {printf("p = %s \n",p
);}
894 #line 895 "lexer_fsm.c"
899 _acts
= _setstr_actions
+ _setstr_to_state_actions
[cs
];
900 _nacts
= (unsigned int) *_acts
++;
901 while ( _nacts
-- > 0 ) {
902 switch ( *_acts
++ ) {
904 #line 204 "lexer_fsm.rl"
905 {printf("Lexer_setstr:: Returning setvlink filetype for %s\n", str
); type
= 5; newstrt
= lexer_lexsetvlink(str
); {p
++; goto _out
; }}
908 #line 205 "lexer_fsm.rl"
909 {printf("Lexer_setstr:: Returning elevlink filetype for %s\n", str
); type
= 6; newstrt
= lexer_lexelevlink(str
); {p
++; goto _out
; }}
912 #line 206 "lexer_fsm.rl"
913 {printf("Lexer_setstr:: Returning setmodel filetype\n"); newstrt
= lexer_lexsetmodel(str
); type
= 1; {p
++; goto _out
; }}
916 #line 207 "lexer_fsm.rl"
917 {printf("Lexer_setstr:: Returning setmap filetype\n"); newstrt
= lexer_lexsetmap(str
); type
= 2; {p
++; goto _out
; }}
920 #line 208 "lexer_fsm.rl"
921 {printf("Lexer_setstr:: Returning elemodel filetype for %s\n", str
); newstrt
= lexer_lexelemodel(str
); type
= 3; {p
++; goto _out
; }}
924 #line 209 "lexer_fsm.rl"
925 {printf("Lexer_setstr:: Returning elemap filetype for %s\n", str
); newstrt
= lexer_lexelemap(str
); type
= 4; {p
++; goto _out
; }}
928 #line 210 "lexer_fsm.rl"
929 { printf("Lexer_setstr:: Returning setolink filetype\n"); type
= 8; newstrt
= lexer_lexsetolink(str
); {p
++; goto _out
; }}
932 #line 211 "lexer_fsm.rl"
933 { printf("Lexer_setstr:: Returning eleolink filetype\n"); type
= 7; newstrt
= lexer_lexeleolink(str
); {p
++; goto _out
; }}
935 #line 936 "lexer_fsm.c"
946 #line 277 "lexer_fsm.rl"
948 printf("|--- End lexer_setstr. Incrementing str by %d, type is %d ---|\n", newstrt
, type
);
957 /* machine file_matcher; */
959 /* action call_ml { ts = p; fgoto set_hw ;} */
960 /* action call_tl { return 0;} */
961 /* action set_height {height = ttov(p, p-ts+1); ts = p;} */
962 /* action set_width { width = ttov(p, p-ts+1);} */
963 /* action call_lmf {lexer_lexmapfile(height, width); } */
964 /* action lex_error {printf("input error: character %c in filename %s is invalid\n = %s\n", fc, str, p);} */
966 /* #This machine determines the type of file we are lexing */
967 /* #and calls the appropriate machine to handle it. */
969 /* #TODO add mapping name */
970 /* width = digit+ %set_width; */
971 /* height = digit+ %set_height; */
973 /* set_hw := height . '_' . width [\0] %to(call_lmf); */
975 /* tok_segment = alnum; */
976 /* map_end = 'm' . '_' %to(call_ml); */
977 /* tok_end = alnum+ . [\0] %to(call_tl); */
979 /* file_matcher := (tok_segment+ . '_' )+ ( map_end | tok_end ); */
985 /* lexer_matchfile */
986 /* (char* str, int size) */
989 /* int cs, ntok, height, width; */
993 /* height = width = 0; */
995 /* printf("Checking if filename is a map file:: filename = %s, p = %c, pe = %c\n", str, *p, *pe); */
998 /* %%write exec noend; */
1000 /* printf("Ending lexer_ismapfile on %s\n", str); */
1006 /* machine vartype; */
1008 /* action isele {return 0;} */
1009 /* action ismodel {return 1;} */
1011 /* set_name = alpha+; */
1012 /* ele_name = alpha+; */
1013 /* model_name = alpha+; */
1015 /* ele = set_name '_' model_name '_' ele_name %isele; */
1016 /* model = set_name '_' model_name [\0] %ismodel; */
1019 /* ismodel := (ele | model); */
1027 /* (uint8_t* str, int size) */
1028 /* { uint8_t *p, *pe, *eof; */
1032 /* pe = p + size + 1; */