572 lines
14 KiB
C
572 lines
14 KiB
C
#line 1 "control_parser.rl"
|
|
|
|
#include "control_parser.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <sys/socket.h>
|
|
|
|
typedef control_parser_ctx context;
|
|
|
|
static void extract(context *ctx, char *fpc) {
|
|
gssize curpos = (fpc - ctx->buffer->str);
|
|
gssize len = curpos - ctx->mark;
|
|
g_string_truncate(ctx->tmp, 0);
|
|
g_string_append_len(ctx->tmp, ctx->buffer->str + ctx->mark, len);
|
|
ctx->mark = -1;
|
|
/* printf("Read chunk '%s'\n", ctx->tmp->str); */
|
|
}
|
|
|
|
static double extract_double(context *ctx, char *fpc) {
|
|
extract(ctx, fpc);
|
|
return strtod(ctx->tmp->str, NULL);
|
|
}
|
|
|
|
static timestamp extract_ts(context *ctx, char *fpc) {
|
|
extract(ctx, fpc);
|
|
return atoi(ctx->tmp->str);
|
|
}
|
|
|
|
#line 134 "control_parser.rl"
|
|
|
|
|
|
|
|
#line 35 "control_parser.c"
|
|
static const char _control_parser_actions[] = {
|
|
0, 1, 0, 1, 1, 1, 2, 1,
|
|
3, 1, 4, 1, 5, 1, 6, 1,
|
|
7, 1, 8, 1, 9, 1, 10, 1,
|
|
11, 1, 12, 1, 13, 1, 14, 1,
|
|
15, 1, 16, 1, 17, 1, 18, 1,
|
|
19, 1, 20, 1, 21, 1, 22, 1,
|
|
23, 1, 24, 1, 25, 1, 26, 1,
|
|
27, 1, 28, 1, 29, 2, 1, 5,
|
|
2, 1, 6, 2, 1, 7, 2, 1,
|
|
8, 2, 1, 9, 2, 1, 10, 2,
|
|
1, 11, 2, 1, 12, 2, 1, 13,
|
|
2, 1, 14, 2, 1, 15, 2, 1,
|
|
16, 2, 1, 25, 2, 1, 26, 2,
|
|
3, 2
|
|
};
|
|
|
|
static const short _control_parser_key_offsets[] = {
|
|
0, 0, 7, 8, 11, 12, 18, 19,
|
|
22, 23, 24, 25, 28, 31, 32, 35,
|
|
38, 41, 42, 45, 48, 53, 54, 59,
|
|
64, 69, 74, 79, 85, 86, 91, 96,
|
|
101, 106, 107, 112, 117, 122, 127, 128,
|
|
133, 138, 143, 148, 149, 154, 159, 164,
|
|
169, 174, 178, 182, 186, 190, 194, 198,
|
|
202, 206, 210, 214, 218, 222, 226, 230,
|
|
234, 238, 242, 245, 248, 249, 254, 259,
|
|
264, 269, 274, 279, 284, 289, 293, 297,
|
|
301, 305, 309, 313, 317, 321
|
|
};
|
|
|
|
static const char _control_parser_trans_keys[] = {
|
|
66, 67, 69, 73, 75, 83, 84, 32,
|
|
32, 48, 57, 59, 66, 67, 69, 75,
|
|
83, 84, 32, 32, 48, 57, 59, 69,
|
|
32, 32, 48, 57, 32, 48, 57, 59,
|
|
32, 48, 57, 32, 48, 57, 32, 48,
|
|
57, 32, 32, 48, 57, 45, 97, 98,
|
|
45, 76, 82, 108, 114, 32, 32, 45,
|
|
46, 48, 57, 32, 45, 46, 48, 57,
|
|
32, 45, 46, 48, 57, 32, 45, 46,
|
|
48, 57, 59, 98, 99, 104, 109, 66,
|
|
67, 69, 75, 83, 84, 32, 32, 45,
|
|
46, 48, 57, 32, 45, 46, 48, 57,
|
|
32, 45, 46, 48, 57, 59, 98, 99,
|
|
104, 109, 32, 32, 45, 46, 48, 57,
|
|
32, 45, 46, 48, 57, 32, 45, 46,
|
|
48, 57, 59, 98, 99, 104, 109, 32,
|
|
32, 45, 46, 48, 57, 32, 45, 46,
|
|
48, 57, 32, 45, 46, 48, 57, 59,
|
|
98, 99, 104, 109, 32, 32, 45, 46,
|
|
48, 57, 32, 45, 46, 48, 57, 32,
|
|
45, 46, 48, 57, 32, 45, 46, 48,
|
|
57, 59, 98, 99, 104, 109, 32, 46,
|
|
48, 57, 32, 46, 48, 57, 32, 46,
|
|
48, 57, 32, 46, 48, 57, 32, 46,
|
|
48, 57, 32, 46, 48, 57, 32, 46,
|
|
48, 57, 32, 46, 48, 57, 32, 46,
|
|
48, 57, 32, 46, 48, 57, 32, 46,
|
|
48, 57, 32, 46, 48, 57, 32, 46,
|
|
48, 57, 32, 46, 48, 57, 32, 46,
|
|
48, 57, 32, 46, 48, 57, 32, 46,
|
|
48, 57, 32, 48, 57, 32, 48, 57,
|
|
32, 32, 45, 46, 48, 57, 32, 45,
|
|
46, 48, 57, 32, 45, 46, 48, 57,
|
|
32, 45, 46, 48, 57, 32, 45, 46,
|
|
48, 57, 32, 45, 46, 48, 57, 32,
|
|
45, 46, 48, 57, 32, 45, 46, 48,
|
|
57, 32, 46, 48, 57, 32, 46, 48,
|
|
57, 32, 46, 48, 57, 32, 46, 48,
|
|
57, 32, 46, 48, 57, 32, 46, 48,
|
|
57, 32, 46, 48, 57, 32, 46, 48,
|
|
57, 0
|
|
};
|
|
|
|
static const char _control_parser_single_lengths[] = {
|
|
0, 7, 1, 1, 1, 6, 1, 1,
|
|
1, 1, 1, 1, 1, 1, 1, 1,
|
|
1, 1, 1, 3, 5, 1, 1, 1,
|
|
1, 1, 5, 6, 1, 1, 1, 1,
|
|
5, 1, 1, 1, 1, 5, 1, 1,
|
|
1, 1, 5, 1, 1, 1, 1, 1,
|
|
5, 2, 2, 2, 2, 2, 2, 2,
|
|
2, 2, 2, 2, 2, 2, 2, 2,
|
|
2, 2, 1, 1, 1, 1, 1, 1,
|
|
1, 1, 1, 1, 1, 2, 2, 2,
|
|
2, 2, 2, 2, 2, 0
|
|
};
|
|
|
|
static const char _control_parser_range_lengths[] = {
|
|
0, 0, 0, 1, 0, 0, 0, 1,
|
|
0, 0, 0, 1, 1, 0, 1, 1,
|
|
1, 0, 1, 0, 0, 0, 2, 2,
|
|
2, 2, 0, 0, 0, 2, 2, 2,
|
|
0, 0, 2, 2, 2, 0, 0, 2,
|
|
2, 2, 0, 0, 2, 2, 2, 2,
|
|
0, 1, 1, 1, 1, 1, 1, 1,
|
|
1, 1, 1, 1, 1, 1, 1, 1,
|
|
1, 1, 1, 1, 0, 2, 2, 2,
|
|
2, 2, 2, 2, 2, 1, 1, 1,
|
|
1, 1, 1, 1, 1, 0
|
|
};
|
|
|
|
static const short _control_parser_index_offsets[] = {
|
|
0, 0, 8, 10, 13, 15, 22, 24,
|
|
27, 29, 31, 33, 36, 39, 41, 44,
|
|
47, 50, 52, 55, 59, 65, 67, 71,
|
|
75, 79, 83, 89, 96, 98, 102, 106,
|
|
110, 116, 118, 122, 126, 130, 136, 138,
|
|
142, 146, 150, 156, 158, 162, 166, 170,
|
|
174, 180, 184, 188, 192, 196, 200, 204,
|
|
208, 212, 216, 220, 224, 228, 232, 236,
|
|
240, 244, 248, 251, 254, 256, 260, 264,
|
|
268, 272, 276, 280, 284, 288, 292, 296,
|
|
300, 304, 308, 312, 316, 320
|
|
};
|
|
|
|
static const char _control_parser_trans_targs[] = {
|
|
2, 6, 10, 68, 6, 6, 17, 0,
|
|
3, 0, 4, 67, 0, 5, 0, 2,
|
|
6, 10, 6, 6, 17, 0, 7, 0,
|
|
8, 16, 0, 9, 0, 10, 0, 11,
|
|
0, 12, 15, 0, 13, 14, 0, 85,
|
|
0, 13, 14, 0, 12, 15, 0, 8,
|
|
16, 0, 18, 0, 19, 66, 0, 20,
|
|
20, 20, 0, 21, 21, 21, 21, 21,
|
|
0, 22, 0, 23, 65, 65, 0, 24,
|
|
64, 64, 0, 25, 63, 63, 0, 26,
|
|
62, 62, 0, 27, 28, 33, 38, 43,
|
|
0, 2, 6, 10, 6, 6, 17, 0,
|
|
29, 0, 30, 61, 61, 0, 31, 60,
|
|
60, 0, 32, 59, 59, 0, 27, 28,
|
|
33, 38, 43, 0, 34, 0, 35, 58,
|
|
58, 0, 36, 57, 57, 0, 37, 56,
|
|
56, 0, 27, 28, 33, 38, 43, 0,
|
|
39, 0, 40, 55, 55, 0, 41, 54,
|
|
54, 0, 42, 53, 53, 0, 27, 28,
|
|
33, 38, 43, 0, 44, 0, 45, 52,
|
|
52, 0, 46, 51, 51, 0, 47, 50,
|
|
50, 0, 48, 49, 49, 0, 27, 28,
|
|
33, 38, 43, 0, 48, 49, 49, 0,
|
|
47, 50, 50, 0, 46, 51, 51, 0,
|
|
45, 52, 52, 0, 42, 53, 53, 0,
|
|
41, 54, 54, 0, 40, 55, 55, 0,
|
|
37, 56, 56, 0, 36, 57, 57, 0,
|
|
35, 58, 58, 0, 32, 59, 59, 0,
|
|
31, 60, 60, 0, 30, 61, 61, 0,
|
|
26, 62, 62, 0, 25, 63, 63, 0,
|
|
24, 64, 64, 0, 23, 65, 65, 0,
|
|
19, 66, 0, 4, 67, 0, 69, 0,
|
|
70, 84, 84, 0, 71, 83, 83, 0,
|
|
72, 82, 82, 0, 73, 81, 81, 0,
|
|
74, 80, 80, 0, 75, 79, 79, 0,
|
|
76, 78, 78, 0, 4, 77, 77, 0,
|
|
4, 77, 77, 0, 76, 78, 78, 0,
|
|
75, 79, 79, 0, 74, 80, 80, 0,
|
|
73, 81, 81, 0, 72, 82, 82, 0,
|
|
71, 83, 83, 0, 70, 84, 84, 0,
|
|
0, 0
|
|
};
|
|
|
|
static const char _control_parser_trans_actions[] = {
|
|
0, 0, 0, 0, 0, 0, 5, 0,
|
|
0, 0, 97, 3, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 5, 0, 0, 0,
|
|
97, 3, 0, 0, 0, 0, 0, 0,
|
|
0, 97, 3, 0, 100, 3, 0, 1,
|
|
0, 53, 0, 0, 51, 0, 0, 51,
|
|
0, 0, 0, 0, 97, 3, 0, 37,
|
|
35, 39, 0, 45, 41, 49, 43, 47,
|
|
0, 0, 0, 82, 3, 3, 0, 85,
|
|
3, 3, 0, 91, 3, 3, 0, 94,
|
|
3, 3, 0, 9, 9, 9, 9, 9,
|
|
0, 7, 7, 7, 7, 7, 103, 0,
|
|
0, 0, 82, 3, 3, 0, 85, 3,
|
|
3, 0, 88, 3, 3, 0, 55, 55,
|
|
55, 55, 55, 0, 0, 0, 82, 3,
|
|
3, 0, 85, 3, 3, 0, 88, 3,
|
|
3, 0, 57, 57, 57, 57, 57, 0,
|
|
0, 0, 82, 3, 3, 0, 85, 3,
|
|
3, 0, 88, 3, 3, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 82, 3,
|
|
3, 0, 85, 3, 3, 0, 91, 3,
|
|
3, 0, 94, 3, 3, 0, 59, 59,
|
|
59, 59, 59, 0, 33, 0, 0, 0,
|
|
31, 0, 0, 0, 27, 0, 0, 0,
|
|
25, 0, 0, 0, 29, 0, 0, 0,
|
|
27, 0, 0, 0, 25, 0, 0, 0,
|
|
29, 0, 0, 0, 27, 0, 0, 0,
|
|
25, 0, 0, 0, 29, 0, 0, 0,
|
|
27, 0, 0, 0, 25, 0, 0, 0,
|
|
33, 0, 0, 0, 31, 0, 0, 0,
|
|
27, 0, 0, 0, 25, 0, 0, 0,
|
|
51, 0, 0, 51, 0, 0, 0, 0,
|
|
61, 3, 3, 0, 64, 3, 3, 0,
|
|
0, 0, 0, 0, 67, 3, 3, 0,
|
|
70, 3, 3, 0, 73, 3, 3, 0,
|
|
76, 3, 3, 0, 79, 3, 3, 0,
|
|
23, 0, 0, 0, 21, 0, 0, 0,
|
|
19, 0, 0, 0, 17, 0, 0, 0,
|
|
15, 0, 0, 0, 0, 0, 0, 0,
|
|
13, 0, 0, 0, 11, 0, 0, 0,
|
|
0, 0
|
|
};
|
|
|
|
static const int control_parser_start = 1;
|
|
static const int control_parser_first_final = 85;
|
|
static const int control_parser_error = 0;
|
|
|
|
static const int control_parser_en_main = 1;
|
|
|
|
#line 137 "control_parser.rl"
|
|
|
|
static int control_parser_has_error(context *ctx) {
|
|
return ctx->cs == control_parser_error;
|
|
}
|
|
|
|
static int control_parser_is_finished(context *ctx) {
|
|
return ctx->cs >= control_parser_first_final;
|
|
}
|
|
|
|
void control_parser_new(trial *t) {
|
|
context *ctx = t->parse_ctx = g_slice_new(context);
|
|
|
|
#line 260 "control_parser.c"
|
|
{
|
|
( ctx->cs) = control_parser_start;
|
|
}
|
|
#line 149 "control_parser.rl"
|
|
ctx->buffer = g_string_sized_new(0);
|
|
ctx->tmp = g_string_sized_new(0);
|
|
ctx->mark = -1;
|
|
ctx->pos = 0;
|
|
}
|
|
|
|
void control_parser_reset(trial *t) {
|
|
context *ctx = t->parse_ctx;
|
|
|
|
#line 274 "control_parser.c"
|
|
{
|
|
( ctx->cs) = control_parser_start;
|
|
}
|
|
#line 158 "control_parser.rl"
|
|
g_string_truncate(ctx->tmp, 0);
|
|
ctx->mark = -1;
|
|
/* fprintf(stderr, "Parser reset\n"); */
|
|
}
|
|
|
|
void control_parser_free(trial *t) {
|
|
g_string_free(t->parse_ctx->buffer, TRUE);
|
|
g_string_free(t->parse_ctx->tmp, TRUE);
|
|
g_slice_free(context, t->parse_ctx);
|
|
}
|
|
|
|
run_t control_parse(trial *t) {
|
|
context *ctx = t->parse_ctx;
|
|
gsize wehave;
|
|
|
|
if (0 < (wehave = ctx->buffer->len - ctx->pos)) {
|
|
char *p, *pe;
|
|
|
|
p = ctx->buffer->str + ctx->pos;
|
|
pe = p + wehave;
|
|
/* fprintf(stderr, "Parsing '%s' (len=%zu)\n", p, wehave); */
|
|
|
|
|
|
#line 302 "control_parser.c"
|
|
{
|
|
int _klen;
|
|
unsigned int _trans;
|
|
const char *_acts;
|
|
unsigned int _nacts;
|
|
const char *_keys;
|
|
|
|
if ( p == pe )
|
|
goto _test_eof;
|
|
if ( ( ctx->cs) == 0 )
|
|
goto _out;
|
|
_resume:
|
|
_keys = _control_parser_trans_keys + _control_parser_key_offsets[( ctx->cs)];
|
|
_trans = _control_parser_index_offsets[( ctx->cs)];
|
|
|
|
_klen = _control_parser_single_lengths[( ctx->cs)];
|
|
if ( _klen > 0 ) {
|
|
const char *_lower = _keys;
|
|
const char *_mid;
|
|
const char *_upper = _keys + _klen - 1;
|
|
while (1) {
|
|
if ( _upper < _lower )
|
|
break;
|
|
|
|
_mid = _lower + ((_upper-_lower) >> 1);
|
|
if ( (*p) < *_mid )
|
|
_upper = _mid - 1;
|
|
else if ( (*p) > *_mid )
|
|
_lower = _mid + 1;
|
|
else {
|
|
_trans += (_mid - _keys);
|
|
goto _match;
|
|
}
|
|
}
|
|
_keys += _klen;
|
|
_trans += _klen;
|
|
}
|
|
|
|
_klen = _control_parser_range_lengths[( ctx->cs)];
|
|
if ( _klen > 0 ) {
|
|
const char *_lower = _keys;
|
|
const char *_mid;
|
|
const char *_upper = _keys + (_klen<<1) - 2;
|
|
while (1) {
|
|
if ( _upper < _lower )
|
|
break;
|
|
|
|
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
|
if ( (*p) < _mid[0] )
|
|
_upper = _mid - 2;
|
|
else if ( (*p) > _mid[1] )
|
|
_lower = _mid + 2;
|
|
else {
|
|
_trans += ((_mid - _keys)>>1);
|
|
goto _match;
|
|
}
|
|
}
|
|
_trans += _klen;
|
|
}
|
|
|
|
_match:
|
|
( ctx->cs) = _control_parser_trans_targs[_trans];
|
|
|
|
if ( _control_parser_trans_actions[_trans] == 0 )
|
|
goto _again;
|
|
|
|
_acts = _control_parser_actions + _control_parser_trans_actions[_trans];
|
|
_nacts = (unsigned int) *_acts++;
|
|
while ( _nacts-- > 0 )
|
|
{
|
|
switch ( *_acts++ )
|
|
{
|
|
case 0:
|
|
#line 34 "control_parser.rl"
|
|
{
|
|
t->alive = 0;
|
|
/* fprintf(stderr, "Run finished\n"); */
|
|
{p++; goto _out; }
|
|
}
|
|
break;
|
|
case 1:
|
|
#line 39 "control_parser.rl"
|
|
{ ctx->mark = p - ctx->buffer->str; }
|
|
break;
|
|
case 2:
|
|
#line 40 "control_parser.rl"
|
|
{ ctx->tm = telemetry_new(); }
|
|
break;
|
|
case 3:
|
|
#line 41 "control_parser.rl"
|
|
{
|
|
g_queue_push_tail(&t->telemetry, ctx->tm);
|
|
if (!t->alive) {
|
|
t->vehicle.accel = ctx->tm->vehicle.accel;
|
|
t->vehicle.turn = ctx->tm->vehicle.turn;
|
|
gettimeofday(&t->started, NULL);
|
|
/* fprintf(stderr, "New run\n"); */
|
|
} else {
|
|
/* fprintf(stderr, "time difference [ms]: %i\n", getcurts(t) - ctx->tm->ts); */
|
|
}
|
|
/* Reset simulation */
|
|
t->sim.ts = ctx->tm->ts;
|
|
t->sim.vehicle = t->vehicle;
|
|
|
|
t->last_ts = ctx->tm->ts;
|
|
ctx->tm = NULL;
|
|
t->alive = 1;
|
|
}
|
|
break;
|
|
case 4:
|
|
#line 59 "control_parser.rl"
|
|
{
|
|
ctx->tm->ts = ctx->ts;
|
|
ctx->tm->vehicle.x = ctx->x;
|
|
ctx->tm->vehicle.y = ctx->y;
|
|
ctx->tm->vehicle.dir = ctx->dir;
|
|
ctx->tm->vehicle.speed = ctx->speed;
|
|
t->vehicle.x = ctx->x;
|
|
t->vehicle.y = ctx->y;
|
|
t->vehicle.dir = ctx->dir;
|
|
t->vehicle.speed = ctx->speed;
|
|
/* printf("Vehicle at %f / %f\n", ctx->x, ctx->y); */
|
|
}
|
|
break;
|
|
case 5:
|
|
#line 76 "control_parser.rl"
|
|
{ t->map.dx = extract_double(ctx, p); }
|
|
break;
|
|
case 6:
|
|
#line 77 "control_parser.rl"
|
|
{ t->map.dy = extract_double(ctx, p); }
|
|
break;
|
|
case 7:
|
|
#line 78 "control_parser.rl"
|
|
{ t->map.min_sensor = extract_double(ctx, p); }
|
|
break;
|
|
case 8:
|
|
#line 79 "control_parser.rl"
|
|
{ t->map.max_sensor = extract_double(ctx, p); }
|
|
break;
|
|
case 9:
|
|
#line 80 "control_parser.rl"
|
|
{ t->map.max_speed = extract_double(ctx, p); }
|
|
break;
|
|
case 10:
|
|
#line 81 "control_parser.rl"
|
|
{ t->map.max_turn = extract_double(ctx, p); }
|
|
break;
|
|
case 11:
|
|
#line 82 "control_parser.rl"
|
|
{ t->map.max_hard_turn = extract_double(ctx, p); }
|
|
break;
|
|
case 12:
|
|
#line 86 "control_parser.rl"
|
|
{ ctx->x = extract_double(ctx, p); }
|
|
break;
|
|
case 13:
|
|
#line 87 "control_parser.rl"
|
|
{ ctx->y = extract_double(ctx, p); }
|
|
break;
|
|
case 14:
|
|
#line 88 "control_parser.rl"
|
|
{ ctx->r = extract_double(ctx, p); }
|
|
break;
|
|
case 15:
|
|
#line 89 "control_parser.rl"
|
|
{ ctx->dir = extract_double(ctx, p); }
|
|
break;
|
|
case 16:
|
|
#line 90 "control_parser.rl"
|
|
{ ctx->speed = extract_double(ctx, p); }
|
|
break;
|
|
case 17:
|
|
#line 92 "control_parser.rl"
|
|
{ ctx->tm->vehicle.accel = ACCEL; }
|
|
break;
|
|
case 18:
|
|
#line 93 "control_parser.rl"
|
|
{ ctx->tm->vehicle.accel = ROLL; }
|
|
break;
|
|
case 19:
|
|
#line 94 "control_parser.rl"
|
|
{ ctx->tm->vehicle.accel = BRAKE; }
|
|
break;
|
|
case 20:
|
|
#line 96 "control_parser.rl"
|
|
{ ctx->tm->vehicle.turn = TURN_HARD_LEFT; }
|
|
break;
|
|
case 21:
|
|
#line 97 "control_parser.rl"
|
|
{ ctx->tm->vehicle.turn = TURN_LEFT; }
|
|
break;
|
|
case 22:
|
|
#line 98 "control_parser.rl"
|
|
{ ctx->tm->vehicle.turn = TURN_STRAIGHT; }
|
|
break;
|
|
case 23:
|
|
#line 99 "control_parser.rl"
|
|
{ ctx->tm->vehicle.turn = TURN_RIGHT; }
|
|
break;
|
|
case 24:
|
|
#line 100 "control_parser.rl"
|
|
{ ctx->tm->vehicle.turn = TURN_HARD_RIGHT; }
|
|
break;
|
|
case 25:
|
|
#line 102 "control_parser.rl"
|
|
{ ctx->ts = extract_ts(ctx, p); }
|
|
break;
|
|
case 26:
|
|
#line 103 "control_parser.rl"
|
|
{ printf("Score %u\n", extract_ts(ctx, p)); }
|
|
break;
|
|
case 27:
|
|
#line 105 "control_parser.rl"
|
|
{
|
|
object o = { BOLDER, ctx->x, ctx->y, ctx->r, 0, 0 };
|
|
g_array_append_val(ctx->tm->objects, o);
|
|
}
|
|
break;
|
|
case 28:
|
|
#line 109 "control_parser.rl"
|
|
{
|
|
object o = { CRATER, ctx->x, ctx->y, ctx->r, 0, 0 };
|
|
g_array_append_val(ctx->tm->objects, o);
|
|
}
|
|
break;
|
|
case 29:
|
|
#line 114 "control_parser.rl"
|
|
{
|
|
object o = { MARTIAN, ctx->x, ctx->y, MARTIAN_RADIUS, ctx->dir, ctx->speed };
|
|
g_array_append_val(ctx->tm->objects, o);
|
|
}
|
|
break;
|
|
#line 536 "control_parser.c"
|
|
}
|
|
}
|
|
|
|
_again:
|
|
if ( ( ctx->cs) == 0 )
|
|
goto _out;
|
|
if ( ++p != pe )
|
|
goto _resume;
|
|
_test_eof: {}
|
|
_out: {}
|
|
}
|
|
#line 181 "control_parser.rl"
|
|
|
|
ctx->pos = p - ctx->buffer->str;
|
|
if (ctx->mark == -1) {
|
|
g_string_erase(ctx->buffer, 0, ctx->pos);
|
|
ctx->pos = 0;
|
|
} else if (ctx->mark) {
|
|
g_string_erase(ctx->buffer, 0, ctx->mark);
|
|
ctx->pos -= ctx->mark;
|
|
ctx->mark = 0;
|
|
}
|
|
} else {
|
|
fprintf(stderr, "No data to parse\n");
|
|
}
|
|
|
|
if (control_parser_has_error(ctx)) {
|
|
fprintf(stderr, "Parse error: '%s'\n", ctx->buffer->str + ctx->pos);
|
|
shutdown(t->socket, SHUT_RDWR);
|
|
close(t->socket);
|
|
exit(126);
|
|
return RUN_ERROR;
|
|
}
|
|
if (control_parser_is_finished(ctx)) return RUN_DONE;
|
|
return RUN_GO_ON;
|
|
}
|