1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
|
#line 1 "params.rl"
/*
* Parse command line arguments.
*/
#include <stdio.h>
#include <string.h>
#define BUFLEN 1024
struct params
{
char buffer[BUFLEN+1];
int buflen;
int cs;
};
#line 61 "params.rl"
#line 25 "params.c"
static const int params_start = 23;
static const int params_first_final = 23;
static const int params_error = 0;
static const int params_en_main = 23;
#line 64 "params.rl"
void params_init( struct params *fsm )
{
fsm->buflen = 0;
#line 39 "params.c"
{
fsm->cs = params_start;
}
#line 69 "params.rl"
}
void params_execute( struct params *fsm, const char *data, int len )
{
const char *p = data;
const char *pe = data + len;
#line 53 "params.c"
{
if ( p == pe )
goto _test_eof;
switch ( fsm->cs )
{
tr11:
#line 38 "params.rl"
{ printf("help\n"); }
goto st23;
tr17:
#line 39 "params.rl"
{ printf("version\n"); }
goto st23;
tr21:
#line 30 "params.rl"
{
if ( fsm->buflen < BUFLEN )
fsm->buffer[fsm->buflen++] = 0;
}
#line 42 "params.rl"
{ printf("machine: \"%s\"\n", fsm->buffer); }
goto st23;
tr25:
#line 30 "params.rl"
{
if ( fsm->buflen < BUFLEN )
fsm->buffer[fsm->buflen++] = 0;
}
#line 41 "params.rl"
{ printf("spec: \"%s\"\n", fsm->buffer); }
goto st23;
tr29:
#line 30 "params.rl"
{
if ( fsm->buflen < BUFLEN )
fsm->buffer[fsm->buflen++] = 0;
}
#line 40 "params.rl"
{ printf("output: \"%s\"\n", fsm->buffer); }
goto st23;
st23:
if ( ++p == pe )
goto _test_eof23;
case 23:
#line 98 "params.c"
if ( (*p) == 45 )
goto st1;
goto st0;
st0:
fsm->cs = 0;
goto _out;
st1:
if ( ++p == pe )
goto _test_eof1;
case 1:
switch( (*p) ) {
case 45: goto st2;
case 63: goto st6;
case 72: goto st6;
case 77: goto st14;
case 83: goto st17;
case 104: goto st6;
case 111: goto st20;
case 118: goto st13;
}
goto st0;
st2:
if ( ++p == pe )
goto _test_eof2;
case 2:
switch( (*p) ) {
case 104: goto st3;
case 118: goto st7;
}
goto st0;
st3:
if ( ++p == pe )
goto _test_eof3;
case 3:
if ( (*p) == 101 )
goto st4;
goto st0;
st4:
if ( ++p == pe )
goto _test_eof4;
case 4:
if ( (*p) == 108 )
goto st5;
goto st0;
st5:
if ( ++p == pe )
goto _test_eof5;
case 5:
if ( (*p) == 112 )
goto st6;
goto st0;
st6:
if ( ++p == pe )
goto _test_eof6;
case 6:
if ( (*p) == 0 )
goto tr11;
goto st0;
st7:
if ( ++p == pe )
goto _test_eof7;
case 7:
if ( (*p) == 101 )
goto st8;
goto st0;
st8:
if ( ++p == pe )
goto _test_eof8;
case 8:
if ( (*p) == 114 )
goto st9;
goto st0;
st9:
if ( ++p == pe )
goto _test_eof9;
case 9:
if ( (*p) == 115 )
goto st10;
goto st0;
st10:
if ( ++p == pe )
goto _test_eof10;
case 10:
if ( (*p) == 105 )
goto st11;
goto st0;
st11:
if ( ++p == pe )
goto _test_eof11;
case 11:
if ( (*p) == 111 )
goto st12;
goto st0;
st12:
if ( ++p == pe )
goto _test_eof12;
case 12:
if ( (*p) == 110 )
goto st13;
goto st0;
st13:
if ( ++p == pe )
goto _test_eof13;
case 13:
if ( (*p) == 0 )
goto tr17;
goto st0;
st14:
if ( ++p == pe )
goto _test_eof14;
case 14:
if ( (*p) == 0 )
goto st16;
goto tr18;
tr18:
#line 36 "params.rl"
{ fsm->buflen = 0; }
#line 24 "params.rl"
{
if ( fsm->buflen < BUFLEN )
fsm->buffer[fsm->buflen++] = (*p);
}
goto st15;
tr20:
#line 24 "params.rl"
{
if ( fsm->buflen < BUFLEN )
fsm->buffer[fsm->buflen++] = (*p);
}
goto st15;
st15:
if ( ++p == pe )
goto _test_eof15;
case 15:
#line 233 "params.c"
if ( (*p) == 0 )
goto tr21;
goto tr20;
st16:
if ( ++p == pe )
goto _test_eof16;
case 16:
if ( (*p) == 0 )
goto st0;
goto tr18;
st17:
if ( ++p == pe )
goto _test_eof17;
case 17:
if ( (*p) == 0 )
goto st19;
goto tr22;
tr22:
#line 36 "params.rl"
{ fsm->buflen = 0; }
#line 24 "params.rl"
{
if ( fsm->buflen < BUFLEN )
fsm->buffer[fsm->buflen++] = (*p);
}
goto st18;
tr24:
#line 24 "params.rl"
{
if ( fsm->buflen < BUFLEN )
fsm->buffer[fsm->buflen++] = (*p);
}
goto st18;
st18:
if ( ++p == pe )
goto _test_eof18;
case 18:
#line 271 "params.c"
if ( (*p) == 0 )
goto tr25;
goto tr24;
st19:
if ( ++p == pe )
goto _test_eof19;
case 19:
if ( (*p) == 0 )
goto st0;
goto tr22;
st20:
if ( ++p == pe )
goto _test_eof20;
case 20:
if ( (*p) == 0 )
goto st22;
goto tr26;
tr26:
#line 36 "params.rl"
{ fsm->buflen = 0; }
#line 24 "params.rl"
{
if ( fsm->buflen < BUFLEN )
fsm->buffer[fsm->buflen++] = (*p);
}
goto st21;
tr28:
#line 24 "params.rl"
{
if ( fsm->buflen < BUFLEN )
fsm->buffer[fsm->buflen++] = (*p);
}
goto st21;
st21:
if ( ++p == pe )
goto _test_eof21;
case 21:
#line 309 "params.c"
if ( (*p) == 0 )
goto tr29;
goto tr28;
st22:
if ( ++p == pe )
goto _test_eof22;
case 22:
if ( (*p) == 0 )
goto st0;
goto tr26;
}
_test_eof23: fsm->cs = 23; goto _test_eof;
_test_eof1: fsm->cs = 1; goto _test_eof;
_test_eof2: fsm->cs = 2; goto _test_eof;
_test_eof3: fsm->cs = 3; goto _test_eof;
_test_eof4: fsm->cs = 4; goto _test_eof;
_test_eof5: fsm->cs = 5; goto _test_eof;
_test_eof6: fsm->cs = 6; goto _test_eof;
_test_eof7: fsm->cs = 7; goto _test_eof;
_test_eof8: fsm->cs = 8; goto _test_eof;
_test_eof9: fsm->cs = 9; goto _test_eof;
_test_eof10: fsm->cs = 10; goto _test_eof;
_test_eof11: fsm->cs = 11; goto _test_eof;
_test_eof12: fsm->cs = 12; goto _test_eof;
_test_eof13: fsm->cs = 13; goto _test_eof;
_test_eof14: fsm->cs = 14; goto _test_eof;
_test_eof15: fsm->cs = 15; goto _test_eof;
_test_eof16: fsm->cs = 16; goto _test_eof;
_test_eof17: fsm->cs = 17; goto _test_eof;
_test_eof18: fsm->cs = 18; goto _test_eof;
_test_eof19: fsm->cs = 19; goto _test_eof;
_test_eof20: fsm->cs = 20; goto _test_eof;
_test_eof21: fsm->cs = 21; goto _test_eof;
_test_eof22: fsm->cs = 22; goto _test_eof;
_test_eof: {}
_out: {}
}
#line 77 "params.rl"
}
int params_finish( struct params *fsm )
{
if ( fsm->cs == params_error )
return -1;
if ( fsm->cs >= params_first_final )
return 1;
return 0;
}
#define BUFSIZE 2048
int main( int argc, char **argv )
{
int a;
struct params params;
params_init( ¶ms );
for ( a = 1; a < argc; a++ )
params_execute( ¶ms, argv[a], strlen(argv[a])+1 );
if ( params_finish( ¶ms ) != 1 )
fprintf( stderr, "params: error processing arguments\n" );
return 0;
}
|