Commit 779b7566 authored by Daniel Salzman's avatar Daniel Salzman

yparser: add CR+LF support + cleanup

parent 15ced159
......@@ -26,115 +26,126 @@
// Include parser static data (Ragel internals).
static const char _yparser_actions[] = {
0, 1, 0, 1, 1, 1, 3, 1,
4, 1, 5, 1, 7, 1, 8, 1,
9, 1, 10, 1, 11, 1, 14, 2,
1, 0, 2, 1, 2, 2, 3, 4,
2, 5, 0, 2, 6, 7, 2, 11,
12, 2, 13, 11, 3, 1, 2, 0,
3, 1, 6, 7, 3, 1, 11, 12,
3, 1, 13, 11, 4, 1, 2, 6,
7, 4, 1, 2, 11, 12, 4, 1,
2, 13, 11
0, 1, 0, 1, 1, 1, 2, 1,
3, 1, 4, 1, 5, 1, 7, 1,
8, 1, 9, 1, 10, 1, 11, 1,
14, 2, 1, 0, 2, 1, 2, 2,
2, 0, 2, 3, 4, 2, 5, 0,
2, 6, 7, 2, 11, 12, 2, 13,
11, 3, 1, 2, 0, 3, 1, 6,
7, 3, 1, 11, 12, 3, 1, 13,
11, 3, 2, 6, 7, 3, 2, 11,
12, 3, 2, 13, 11, 4, 1, 2,
6, 7, 4, 1, 2, 11, 12, 4,
1, 2, 13, 11
};
static const unsigned char _yparser_key_offsets[] = {
0, 0, 10, 11, 12, 19, 28, 30,
31, 41, 51, 60, 62, 64, 75, 78,
80, 83, 84, 94, 102, 105, 107, 110,
113, 122, 132, 142
0, 0, 11, 13, 14, 21, 30, 32,
33, 43, 54, 63, 65, 68, 80, 83,
86, 90, 92, 102, 110, 113, 116, 119,
122, 131, 142, 153, 164
};
static const char _yparser_trans_keys[] = {
10, 32, 35, 45, 48, 57, 65, 90,
97, 122, 10, 32, 32, 48, 57, 65,
90, 97, 122, 32, 45, 58, 48, 57,
65, 90, 97, 122, 32, 58, 32, 32,
33, 34, 92, 36, 43, 45, 90, 94,
126, 10, 32, 33, 92, 36, 43, 45,
90, 94, 126, 32, 45, 58, 48, 57,
65, 90, 97, 122, 32, 58, 10, 32,
10, 32, 34, 35, 91, 33, 43, 45,
92, 94, 126, 34, 32, 126, 10, 32,
10, 32, 35, 10, 32, 33, 34, 92,
10, 13, 32, 35, 45, 48, 57, 65,
90, 97, 122, 10, 13, 32, 32, 48,
57, 65, 90, 97, 122, 32, 45, 58,
48, 57, 65, 90, 97, 122, 32, 58,
32, 32, 33, 34, 92, 36, 43, 45,
90, 94, 126, 10, 13, 32, 33, 92,
36, 43, 45, 90, 94, 126, 32, 45,
58, 48, 57, 65, 90, 97, 122, 32,
58, 10, 13, 32, 10, 13, 32, 34,
35, 91, 33, 43, 45, 92, 94, 126,
34, 32, 126, 10, 13, 32, 10, 13,
32, 35, 10, 13, 32, 33, 34, 92,
36, 43, 45, 90, 94, 126, 32, 33,
44, 93, 36, 90, 92, 126, 32, 44,
93, 10, 32, 34, 32, 126, 32, 44,
93, 32, 45, 58, 48, 57, 65, 90,
97, 122, 10, 32, 35, 45, 48, 57,
65, 90, 97, 122, 10, 32, 35, 45,
48, 57, 65, 90, 97, 122, 10, 32,
35, 45, 48, 57, 65, 90, 97, 122,
0
93, 10, 13, 32, 34, 32, 126, 32,
44, 93, 32, 45, 58, 48, 57, 65,
90, 97, 122, 10, 13, 32, 35, 45,
48, 57, 65, 90, 97, 122, 10, 13,
32, 35, 45, 48, 57, 65, 90, 97,
122, 10, 13, 32, 35, 45, 48, 57,
65, 90, 97, 122, 10, 13, 32, 35,
45, 48, 57, 65, 90, 97, 122, 0
};
static const char _yparser_single_lengths[] = {
0, 4, 1, 1, 1, 3, 2, 1,
4, 4, 3, 2, 2, 5, 1, 2,
3, 1, 4, 4, 3, 2, 1, 3,
3, 4, 4, 4
0, 5, 2, 1, 1, 3, 2, 1,
4, 5, 3, 2, 3, 6, 1, 3,
4, 2, 4, 4, 3, 3, 1, 3,
3, 5, 5, 5, 5
};
static const char _yparser_range_lengths[] = {
0, 3, 0, 0, 3, 3, 0, 0,
3, 3, 3, 0, 0, 3, 1, 0,
0, 0, 3, 2, 0, 0, 1, 0,
3, 3, 3, 3
3, 3, 3, 3, 3
};
static const unsigned char _yparser_index_offsets[] = {
0, 0, 8, 10, 12, 17, 24, 27,
29, 37, 45, 52, 55, 58, 67, 70,
73, 77, 79, 87, 94, 98, 101, 104,
108, 115, 123, 131
0, 0, 9, 12, 14, 19, 26, 29,
31, 39, 48, 55, 58, 62, 72, 75,
79, 84, 87, 95, 102, 106, 110, 113,
117, 124, 133, 142, 151
};
static const char _yparser_indicies[] = {
1, 2, 3, 4, 5, 5, 5, 0,
1, 3, 6, 0, 6, 7, 7, 7,
0, 8, 9, 10, 9, 9, 9, 0,
11, 12, 0, 13, 0, 13, 14, 15,
14, 14, 14, 14, 0, 16, 17, 18,
18, 18, 18, 18, 0, 19, 20, 21,
20, 20, 20, 0, 22, 23, 0, 24,
25, 0, 24, 25, 15, 26, 27, 14,
14, 14, 0, 29, 28, 0, 16, 17,
0, 24, 30, 26, 0, 24, 26, 27,
31, 32, 31, 31, 31, 31, 0, 33,
34, 35, 36, 34, 34, 0, 37, 27,
38, 0, 24, 30, 0, 40, 39, 0,
33, 35, 36, 0, 41, 42, 43, 42,
42, 42, 0, 1, 2, 3, 4, 44,
44, 44, 0, 45, 46, 47, 48, 49,
49, 49, 0, 50, 51, 52, 53, 54,
54, 54, 0, 0
1, 2, 3, 4, 5, 6, 6, 6,
0, 1, 2, 4, 7, 0, 7, 8,
8, 8, 0, 9, 10, 11, 10, 10,
10, 0, 12, 13, 0, 14, 0, 14,
15, 16, 15, 15, 15, 15, 0, 17,
18, 19, 20, 20, 20, 20, 20, 0,
21, 22, 23, 22, 22, 22, 0, 24,
25, 0, 26, 27, 28, 0, 26, 27,
28, 16, 29, 30, 15, 15, 15, 0,
32, 31, 0, 17, 18, 19, 0, 26,
27, 33, 29, 0, 26, 27, 29, 30,
34, 35, 34, 34, 34, 34, 0, 36,
37, 38, 39, 37, 37, 0, 40, 30,
41, 0, 26, 27, 33, 0, 43, 42,
0, 36, 38, 39, 0, 44, 45, 46,
45, 45, 45, 0, 1, 2, 3, 4,
5, 47, 47, 47, 0, 48, 49, 50,
51, 52, 53, 53, 53, 0, 54, 55,
56, 57, 58, 59, 59, 59, 0, 60,
61, 62, 63, 64, 65, 65, 65, 0,
0
};
static const char _yparser_trans_targs[] = {
0, 26, 1, 2, 3, 24, 4, 5,
6, 5, 7, 6, 7, 8, 9, 14,
27, 16, 9, 11, 10, 12, 11, 12,
27, 13, 17, 18, 14, 15, 16, 19,
22, 20, 19, 18, 21, 20, 21, 22,
23, 11, 24, 12, 10, 26, 1, 2,
3, 10, 26, 1, 2, 3, 10
0, 26, 27, 1, 2, 3, 24, 4,
5, 6, 5, 7, 6, 7, 8, 9,
14, 28, 25, 16, 9, 11, 10, 12,
11, 12, 28, 25, 13, 17, 18, 14,
15, 16, 19, 22, 20, 19, 18, 21,
20, 21, 22, 23, 11, 24, 12, 10,
26, 27, 1, 2, 3, 10, 26, 27,
1, 2, 3, 10, 26, 27, 1, 2,
3, 10
};
static const char _yparser_trans_actions[] = {
21, 1, 38, 0, 41, 35, 19, 35,
17, 11, 17, 0, 0, 0, 29, 5,
32, 9, 7, 13, 11, 13, 0, 0,
1, 0, 0, 0, 7, 0, 0, 29,
5, 9, 7, 9, 9, 0, 0, 7,
0, 15, 11, 15, 35, 44, 65, 26,
70, 60, 23, 52, 3, 56, 48
23, 1, 0, 43, 0, 46, 40, 21,
40, 19, 13, 19, 0, 0, 0, 34,
7, 37, 11, 11, 9, 15, 13, 15,
0, 0, 1, 0, 0, 0, 0, 9,
0, 0, 34, 7, 11, 9, 11, 11,
0, 0, 9, 0, 17, 13, 17, 40,
49, 28, 82, 28, 87, 77, 31, 5,
69, 5, 73, 65, 25, 3, 57, 3,
61, 53
};
static const char _yparser_eof_actions[] = {
0, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21,
21, 0, 26, 3
0, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23,
23, 0, 28, 5, 3
};
......
......@@ -38,7 +38,7 @@
parser->event = YP_ENULL;
parser->processed = false;
}
newline_char = '\n' >_newline_init %_newline;
newline_char = '\n' >_newline_init %_newline | '\r';
# Comment processing.
comment_char = '#';
......@@ -133,13 +133,13 @@
}
parser->indent = 0;
}
key_name = (alnum . ("-" | alnum)*) >_key_init $_key;
key_name = (alnum . ('-' | alnum)*) >_key_init $_key;
key0 = key_name %_key0_exit;
key1 = sep $_indent . key_name %_key1_exit;
id = ((sep $_id)? . "-" >_dash_init . sep) $_indent . key_name %_id_exit;
item = (((key0 . sep? . ":" . (sep . (item_data_list | item_data))?)
|(key1 . sep? . ":" . (sep . (item_data_list | item_data))?)
|(id . sep? . ":" . sep . item_data)
id = ((sep $_id)? . '-' >_dash_init . sep) $_indent . key_name %_id_exit;
item = (((key0 . sep? . ':' . (sep . (item_data_list | item_data))?)
|(key1 . sep? . ':' . (sep . (item_data_list | item_data))?)
|(id . sep? . ':' . sep . item_data)
) . rest
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment