More parse rules
This commit is contained in:
parent
98678a9979
commit
482e6d23f9
@ -19,86 +19,86 @@ static double extract_double(context *ctx, char *fpc) {
|
|||||||
return strtod(ctx->tmp->str, NULL);
|
return strtod(ctx->tmp->str, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 45 "control_parser.rl"
|
#line 62 "control_parser.rl"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#line 27 "control_parser.c"
|
#line 27 "control_parser.c"
|
||||||
static const char _control_parser_actions[] = {
|
static const char _control_parser_actions[] = {
|
||||||
0, 1, 1, 1, 2, 1, 3, 1,
|
0, 1, 0, 1, 1, 1, 2, 1,
|
||||||
4, 1, 5, 1, 6, 1, 7, 2,
|
3, 1, 4, 1, 5, 1, 6, 1,
|
||||||
1, 2, 2, 1, 3, 2, 1, 4,
|
7, 1, 8, 2, 1, 2, 2, 1,
|
||||||
2, 1, 5, 2, 1, 6, 2, 1,
|
3, 2, 1, 4, 2, 1, 5, 2,
|
||||||
7, 2, 8, 0, 3, 1, 8, 0
|
1, 6, 2, 1, 7, 2, 1, 8
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _control_parser_key_offsets[] = {
|
static const char _control_parser_key_offsets[] = {
|
||||||
0, 0, 1, 2, 6, 10, 14, 18,
|
0, 0, 1, 2, 6, 10, 14, 18,
|
||||||
22, 26, 30, 34, 38, 42, 46, 50,
|
22, 26, 30, 34, 35, 39, 43, 47,
|
||||||
54, 58, 62
|
51, 55, 59, 63
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _control_parser_trans_keys[] = {
|
static const char _control_parser_trans_keys[] = {
|
||||||
73, 32, 32, 46, 48, 57, 32, 46,
|
73, 32, 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, 46, 59,
|
|
||||||
48, 57, 46, 59, 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, 59, 32, 46, 48, 57, 32,
|
||||||
48, 57, 32, 46, 48, 57, 0
|
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[] = {
|
static const char _control_parser_single_lengths[] = {
|
||||||
0, 1, 1, 2, 2, 2, 2, 2,
|
0, 1, 1, 2, 2, 2, 2, 2,
|
||||||
2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 1, 2, 2, 2, 2,
|
||||||
2, 2, 0
|
2, 2, 2, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _control_parser_range_lengths[] = {
|
static const char _control_parser_range_lengths[] = {
|
||||||
0, 0, 0, 1, 1, 1, 1, 1,
|
0, 0, 0, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 0, 1, 1, 1, 1,
|
||||||
1, 1, 0
|
1, 1, 1, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _control_parser_index_offsets[] = {
|
static const char _control_parser_index_offsets[] = {
|
||||||
0, 0, 2, 4, 8, 12, 16, 20,
|
0, 0, 2, 4, 8, 12, 16, 20,
|
||||||
24, 28, 32, 36, 40, 44, 48, 52,
|
24, 28, 32, 36, 38, 42, 46, 50,
|
||||||
56, 60, 64
|
54, 58, 62, 66
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _control_parser_trans_targs[] = {
|
static const char _control_parser_trans_targs[] = {
|
||||||
2, 0, 3, 0, 4, 17, 17, 0,
|
2, 0, 3, 0, 4, 18, 18, 0,
|
||||||
5, 16, 16, 0, 6, 5, 5, 0,
|
5, 17, 17, 0, 6, 5, 5, 0,
|
||||||
7, 15, 15, 0, 8, 14, 14, 0,
|
7, 16, 16, 0, 8, 15, 15, 0,
|
||||||
9, 13, 13, 0, 10, 12, 12, 0,
|
9, 14, 14, 0, 10, 13, 13, 0,
|
||||||
11, 18, 11, 0, 11, 18, 11, 0,
|
11, 12, 12, 0, 19, 0, 11, 12,
|
||||||
10, 12, 12, 0, 9, 13, 13, 0,
|
12, 0, 10, 13, 13, 0, 9, 14,
|
||||||
8, 14, 14, 0, 7, 15, 15, 0,
|
14, 0, 8, 15, 15, 0, 7, 16,
|
||||||
5, 16, 16, 0, 4, 17, 17, 0,
|
16, 0, 5, 17, 17, 0, 4, 18,
|
||||||
0, 0
|
18, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _control_parser_trans_actions[] = {
|
static const char _control_parser_trans_actions[] = {
|
||||||
0, 0, 0, 0, 15, 1, 1, 0,
|
0, 0, 0, 0, 19, 3, 3, 0,
|
||||||
18, 1, 1, 0, 0, 0, 0, 0,
|
22, 3, 3, 0, 0, 0, 0, 0,
|
||||||
21, 1, 1, 0, 24, 1, 1, 0,
|
25, 3, 3, 0, 28, 3, 3, 0,
|
||||||
27, 1, 1, 0, 30, 1, 1, 0,
|
31, 3, 3, 0, 34, 3, 3, 0,
|
||||||
1, 36, 1, 0, 0, 33, 0, 0,
|
37, 3, 3, 0, 1, 0, 17, 0,
|
||||||
13, 0, 0, 0, 11, 0, 0, 0,
|
0, 0, 15, 0, 0, 0, 13, 0,
|
||||||
9, 0, 0, 0, 7, 0, 0, 0,
|
0, 0, 11, 0, 0, 0, 9, 0,
|
||||||
5, 0, 0, 0, 3, 0, 0, 0,
|
0, 0, 7, 0, 0, 0, 5, 0,
|
||||||
0, 0
|
0, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int control_parser_start = 1;
|
static const int control_parser_start = 1;
|
||||||
static const int control_parser_first_final = 18;
|
static const int control_parser_first_final = 19;
|
||||||
static const int control_parser_error = 0;
|
static const int control_parser_error = 0;
|
||||||
|
|
||||||
static const int control_parser_en_main = 1;
|
static const int control_parser_en_main = 1;
|
||||||
|
|
||||||
#line 48 "control_parser.rl"
|
#line 65 "control_parser.rl"
|
||||||
|
|
||||||
static int control_parser_has_error(context *ctx) {
|
static int control_parser_has_error(context *ctx) {
|
||||||
return ctx->cs == control_parser_error;
|
return ctx->cs == control_parser_error;
|
||||||
@ -115,7 +115,7 @@ void control_parser_new(trial *t) {
|
|||||||
{
|
{
|
||||||
( ctx->cs) = control_parser_start;
|
( ctx->cs) = control_parser_start;
|
||||||
}
|
}
|
||||||
#line 60 "control_parser.rl"
|
#line 77 "control_parser.rl"
|
||||||
ctx->buffer = g_string_sized_new(0);
|
ctx->buffer = g_string_sized_new(0);
|
||||||
ctx->tmp = g_string_sized_new(0);
|
ctx->tmp = g_string_sized_new(0);
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ void control_parser_reset(trial *t) {
|
|||||||
{
|
{
|
||||||
( ctx->cs) = control_parser_start;
|
( ctx->cs) = control_parser_start;
|
||||||
}
|
}
|
||||||
#line 67 "control_parser.rl"
|
#line 84 "control_parser.rl"
|
||||||
g_string_truncate(ctx->tmp, 0);
|
g_string_truncate(ctx->tmp, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,31 +230,31 @@ _match:
|
|||||||
{ ctx->mark = p - ctx->buffer->str; }
|
{ ctx->mark = p - ctx->buffer->str; }
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
#line 34 "control_parser.rl"
|
#line 35 "control_parser.rl"
|
||||||
{ t->map.dx = extract_double(ctx, p); }
|
{ t->map.dx = extract_double(ctx, p); }
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
#line 35 "control_parser.rl"
|
#line 36 "control_parser.rl"
|
||||||
{ t->map.dy = extract_double(ctx, p); }
|
{ t->map.dy = extract_double(ctx, p); }
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
#line 36 "control_parser.rl"
|
#line 37 "control_parser.rl"
|
||||||
{ t->map.min_sensor = extract_double(ctx, p); }
|
{ t->map.min_sensor = extract_double(ctx, p); }
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
#line 37 "control_parser.rl"
|
#line 38 "control_parser.rl"
|
||||||
{ t->map.max_sensor = extract_double(ctx, p); }
|
{ t->map.max_sensor = extract_double(ctx, p); }
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
#line 38 "control_parser.rl"
|
#line 39 "control_parser.rl"
|
||||||
{ t->map.max_speed = extract_double(ctx, p); }
|
{ t->map.max_speed = extract_double(ctx, p); }
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
#line 39 "control_parser.rl"
|
#line 40 "control_parser.rl"
|
||||||
{ t->map.max_turn = extract_double(ctx, p); }
|
{ t->map.max_turn = extract_double(ctx, p); }
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
#line 40 "control_parser.rl"
|
#line 41 "control_parser.rl"
|
||||||
{ t->map.max_hard_turn = extract_double(ctx, p); }
|
{ t->map.max_hard_turn = extract_double(ctx, p); }
|
||||||
break;
|
break;
|
||||||
#line 261 "control_parser.c"
|
#line 261 "control_parser.c"
|
||||||
@ -269,7 +269,7 @@ _again:
|
|||||||
_test_eof: {}
|
_test_eof: {}
|
||||||
_out: {}
|
_out: {}
|
||||||
}
|
}
|
||||||
#line 87 "control_parser.rl"
|
#line 104 "control_parser.rl"
|
||||||
|
|
||||||
g_string_erase(ctx->buffer, 0, ctx->read);
|
g_string_erase(ctx->buffer, 0, ctx->read);
|
||||||
ctx->mark -= ctx->read;
|
ctx->mark -= ctx->read;
|
||||||
|
@ -25,9 +25,10 @@ static double extract_double(context *ctx, char *fpc) {
|
|||||||
|
|
||||||
action done { fbreak; }
|
action done { fbreak; }
|
||||||
action mark { ctx->mark = fpc - ctx->buffer->str; }
|
action mark { ctx->mark = fpc - ctx->buffer->str; }
|
||||||
action parsedouble { ctx->d = extract_double(ctx, fpc); }
|
action telemetrystart { }
|
||||||
|
action vehicle { }
|
||||||
|
|
||||||
sp = " ";
|
SP = " ";
|
||||||
|
|
||||||
double = (digit | '.')*;
|
double = (digit | '.')*;
|
||||||
|
|
||||||
@ -39,9 +40,23 @@ static double extract_double(context *ctx, char *fpc) {
|
|||||||
max_turn = double >mark % { t->map.max_turn = extract_double(ctx, fpc); };
|
max_turn = double >mark % { t->map.max_turn = extract_double(ctx, fpc); };
|
||||||
max_hard_turn = double >mark % { t->map.max_hard_turn = extract_double(ctx, fpc); };
|
max_hard_turn = double >mark % { t->map.max_hard_turn = extract_double(ctx, fpc); };
|
||||||
|
|
||||||
init = "I" sp dx sp dy sp double sp min_sensor sp max_sensor sp max_speed sp max_turn sp max_hard_turn ";";
|
init = "I" SP dx SP dy SP double SP min_sensor SP max_sensor SP max_speed SP max_turn SP max_hard_turn SP ";";
|
||||||
|
|
||||||
|
x = double;
|
||||||
|
y = double;
|
||||||
|
r = double;
|
||||||
|
dir = double;
|
||||||
|
speed = double;
|
||||||
|
ctl = [ab\-] [Ll\-rR];
|
||||||
|
timestamp = double;
|
||||||
|
|
||||||
|
boulder = "b" SP x SP y SP r SP;
|
||||||
|
crater = "b" SP x SP y SP r SP;
|
||||||
|
homebase = "b" SP x SP y SP r SP;
|
||||||
|
martian = "m" SP x SP y SP dir SP speed SP;
|
||||||
|
object = boulder | crater | homebase | martian;
|
||||||
|
objects = object*;
|
||||||
|
telemetry = ( ("T" SP timestamp SP ctl SP x SP y SP dir SP speed SP) %vehicle objects) >telemetrystart ";";
|
||||||
|
|
||||||
main := init @ done;
|
main := init @ done;
|
||||||
}%%
|
}%%
|
||||||
|
Loading…
Reference in New Issue
Block a user