Better working but still picks up stray numbers I didn't specify.
This commit is contained in:
parent
74310304bd
commit
3394327981
2 changed files with 120 additions and 89 deletions
|
@ -10,85 +10,125 @@
|
||||||
using namespace fmt;
|
using namespace fmt;
|
||||||
|
|
||||||
|
|
||||||
#line 40 ".\\scratchpad\\testragel.rl"
|
#line 42 ".\\scratchpad\\testragel.rl"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#line 13 ".\\scratchpad\\testragel.cpp"
|
#line 13 ".\\scratchpad\\testragel.cpp"
|
||||||
static const char _foo_actions[] = {
|
static const char _foo_actions[] = {
|
||||||
0, 1, 0, 1, 1, 1, 2, 1,
|
0, 1, 0, 1, 1, 1, 2, 1,
|
||||||
3, 1, 4, 1, 5, 1, 6, 1,
|
3, 1, 4, 2, 1, 5, 2, 1,
|
||||||
9, 1, 10, 1, 11, 2, 1, 7,
|
6, 2, 1, 7, 2, 1, 8, 2,
|
||||||
2, 1, 8, 2, 1, 9, 2, 1,
|
1, 9, 2, 1, 10
|
||||||
10, 2, 4, 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_key_offsets[] = {
|
static const char _foo_key_offsets[] = {
|
||||||
0, 0, 1, 3, 5, 6, 7, 12,
|
0, 0, 1, 5, 7, 10, 15, 19,
|
||||||
15, 17, 19, 22, 24
|
23, 27, 29, 32, 34, 37, 39, 42,
|
||||||
|
46, 48, 51, 53, 56, 61, 65, 69,
|
||||||
|
73, 75, 78, 80, 83, 85, 88, 92,
|
||||||
|
94, 97, 99, 102
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_trans_keys[] = {
|
static const char _foo_trans_keys[] = {
|
||||||
91, 48, 57, 50, 53, 59, 59, 27,
|
91, 59, 109, 48, 57, 48, 57, 109,
|
||||||
59, 109, 48, 57, 59, 48, 57, 48,
|
48, 57, 56, 59, 109, 48, 57, 59,
|
||||||
|
109, 48, 57, 50, 53, 48, 57, 59,
|
||||||
|
109, 48, 57, 48, 57, 59, 48, 57,
|
||||||
|
48, 57, 59, 48, 57, 48, 57, 109,
|
||||||
|
48, 57, 59, 109, 48, 57, 48, 57,
|
||||||
|
59, 48, 57, 48, 57, 109, 48, 57,
|
||||||
|
56, 59, 109, 48, 57, 59, 109, 48,
|
||||||
|
57, 50, 53, 48, 57, 59, 109, 48,
|
||||||
57, 48, 57, 59, 48, 57, 48, 57,
|
57, 48, 57, 59, 48, 57, 48, 57,
|
||||||
59, 48, 57, 0
|
59, 48, 57, 48, 57, 109, 48, 57,
|
||||||
|
59, 109, 48, 57, 48, 57, 59, 48,
|
||||||
|
57, 48, 57, 109, 48, 57, 27, 51,
|
||||||
|
52, 48, 57, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_single_lengths[] = {
|
static const char _foo_single_lengths[] = {
|
||||||
0, 1, 0, 2, 1, 1, 3, 1,
|
0, 1, 2, 0, 1, 3, 2, 2,
|
||||||
0, 0, 1, 0, 1
|
2, 0, 1, 0, 1, 0, 1, 2,
|
||||||
|
0, 1, 0, 1, 3, 2, 2, 2,
|
||||||
|
0, 1, 0, 1, 0, 1, 2, 0,
|
||||||
|
1, 0, 1, 3
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_range_lengths[] = {
|
static const char _foo_range_lengths[] = {
|
||||||
0, 0, 1, 0, 0, 0, 1, 1,
|
0, 0, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_index_offsets[] = {
|
static const unsigned char _foo_index_offsets[] = {
|
||||||
0, 0, 2, 4, 7, 9, 11, 16,
|
0, 0, 2, 6, 8, 11, 16, 20,
|
||||||
19, 21, 23, 26, 28
|
24, 28, 30, 33, 35, 38, 40, 43,
|
||||||
|
47, 49, 52, 54, 57, 62, 66, 70,
|
||||||
|
74, 76, 79, 81, 84, 86, 89, 93,
|
||||||
|
95, 98, 100, 103
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_trans_targs[] = {
|
static const char _foo_trans_targs[] = {
|
||||||
6, 0, 8, 6, 4, 5, 0, 9,
|
35, 0, 3, 35, 2, 0, 4, 0,
|
||||||
0, 11, 0, 1, 3, 6, 7, 0,
|
35, 4, 0, 6, 3, 35, 2, 0,
|
||||||
2, 7, 6, 8, 6, 10, 6, 9,
|
7, 35, 2, 0, 8, 15, 4, 0,
|
||||||
10, 6, 12, 6, 11, 12, 6, 6,
|
9, 35, 4, 0, 10, 0, 11, 10,
|
||||||
6, 6, 6, 6, 6, 6, 0
|
0, 12, 0, 13, 12, 0, 14, 0,
|
||||||
|
35, 14, 0, 16, 35, 4, 0, 17,
|
||||||
|
0, 18, 17, 0, 19, 0, 35, 19,
|
||||||
|
0, 21, 3, 35, 2, 0, 22, 35,
|
||||||
|
2, 0, 23, 30, 4, 0, 24, 35,
|
||||||
|
4, 0, 25, 0, 26, 25, 0, 27,
|
||||||
|
0, 28, 27, 0, 29, 0, 35, 29,
|
||||||
|
0, 31, 35, 4, 0, 32, 0, 33,
|
||||||
|
32, 0, 34, 0, 35, 34, 0, 1,
|
||||||
|
5, 20, 2, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_trans_actions[] = {
|
static const char _foo_trans_actions[] = {
|
||||||
11, 0, 1, 19, 0, 0, 0, 0,
|
9, 0, 3, 23, 0, 0, 1, 0,
|
||||||
0, 0, 0, 0, 0, 13, 33, 0,
|
26, 0, 0, 0, 3, 23, 0, 0,
|
||||||
3, 9, 21, 0, 24, 1, 17, 3,
|
3, 23, 0, 0, 1, 1, 1, 0,
|
||||||
0, 30, 1, 15, 3, 0, 27, 19,
|
0, 26, 0, 0, 1, 0, 3, 0,
|
||||||
21, 24, 17, 30, 15, 27, 0
|
0, 1, 0, 3, 0, 0, 1, 0,
|
||||||
|
17, 0, 0, 0, 26, 0, 0, 1,
|
||||||
|
0, 3, 0, 0, 1, 0, 11, 0,
|
||||||
|
0, 0, 3, 23, 0, 0, 3, 23,
|
||||||
|
0, 0, 1, 1, 1, 0, 0, 26,
|
||||||
|
0, 0, 1, 0, 3, 0, 0, 1,
|
||||||
|
0, 3, 0, 0, 1, 0, 20, 0,
|
||||||
|
0, 0, 26, 0, 0, 1, 0, 3,
|
||||||
|
0, 0, 1, 0, 14, 0, 0, 0,
|
||||||
|
1, 1, 1, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_to_state_actions[] = {
|
static const char _foo_to_state_actions[] = {
|
||||||
0, 0, 0, 0, 0, 0, 5, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 5
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_from_state_actions[] = {
|
static const char _foo_from_state_actions[] = {
|
||||||
0, 0, 0, 0, 0, 0, 7, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 7
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char _foo_eof_trans[] = {
|
static const int foo_start = 35;
|
||||||
0, 0, 32, 0, 0, 0, 0, 33,
|
static const int foo_first_final = 35;
|
||||||
34, 35, 36, 37, 38
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int foo_start = 6;
|
|
||||||
static const int foo_first_final = 6;
|
|
||||||
static const int foo_error = 0;
|
static const int foo_error = 0;
|
||||||
|
|
||||||
static const int foo_en_main = 6;
|
static const int foo_en_main = 35;
|
||||||
|
|
||||||
|
|
||||||
#line 43 ".\\scratchpad\\testragel.rl"
|
#line 45 ".\\scratchpad\\testragel.rl"
|
||||||
|
|
||||||
void parse_ansi(std::string_view &codes) {
|
void parse_ansi(std::string_view &codes) {
|
||||||
const char *start = NULL;
|
const char *start = NULL;
|
||||||
|
@ -101,7 +141,7 @@ void parse_ansi(std::string_view &codes) {
|
||||||
const char *eof = pe;
|
const char *eof = pe;
|
||||||
|
|
||||||
|
|
||||||
#line 96 ".\\scratchpad\\testragel.cpp"
|
#line 136 ".\\scratchpad\\testragel.cpp"
|
||||||
{
|
{
|
||||||
cs = foo_start;
|
cs = foo_start;
|
||||||
ts = 0;
|
ts = 0;
|
||||||
|
@ -109,9 +149,9 @@ void parse_ansi(std::string_view &codes) {
|
||||||
act = 0;
|
act = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 55 ".\\scratchpad\\testragel.rl"
|
#line 57 ".\\scratchpad\\testragel.rl"
|
||||||
|
|
||||||
#line 102 ".\\scratchpad\\testragel.cpp"
|
#line 142 ".\\scratchpad\\testragel.cpp"
|
||||||
{
|
{
|
||||||
int _klen;
|
int _klen;
|
||||||
unsigned int _trans;
|
unsigned int _trans;
|
||||||
|
@ -132,7 +172,7 @@ _resume:
|
||||||
#line 1 "NONE"
|
#line 1 "NONE"
|
||||||
{ts = p;}
|
{ts = p;}
|
||||||
break;
|
break;
|
||||||
#line 121 ".\\scratchpad\\testragel.cpp"
|
#line 161 ".\\scratchpad\\testragel.cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +225,6 @@ _resume:
|
||||||
}
|
}
|
||||||
|
|
||||||
_match:
|
_match:
|
||||||
_eof_trans:
|
|
||||||
cs = _foo_trans_targs[_trans];
|
cs = _foo_trans_targs[_trans];
|
||||||
|
|
||||||
if ( _foo_trans_actions[_trans] == 0 )
|
if ( _foo_trans_actions[_trans] == 0 )
|
||||||
|
@ -213,38 +252,34 @@ _eof_trans:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
#line 1 "NONE"
|
#line 34 ".\\scratchpad\\testragel.rl"
|
||||||
{te = p+1;}
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
#line 33 ".\\scratchpad\\testragel.rl"
|
|
||||||
{te = p+1;{ println("START"); }}
|
{te = p+1;{ println("START"); }}
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
#line 35 ".\\scratchpad\\testragel.rl"
|
||||||
|
{te = p+1;{ println("fg 256 color"); }}
|
||||||
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
#line 38 ".\\scratchpad\\testragel.rl"
|
#line 36 ".\\scratchpad\\testragel.rl"
|
||||||
{te = p+1;{ println("END"); }}
|
{te = p+1;{ println("bg 256 color"); }}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
#line 34 ".\\scratchpad\\testragel.rl"
|
#line 37 ".\\scratchpad\\testragel.rl"
|
||||||
{te = p;p--;{ println("single"); }}
|
{te = p+1;{ println("fg true color"); }}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
#line 35 ".\\scratchpad\\testragel.rl"
|
#line 38 ".\\scratchpad\\testragel.rl"
|
||||||
{te = p;p--;{ println("basic"); }}
|
{te = p+1;{ println("bg true color"); }}
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
#line 36 ".\\scratchpad\\testragel.rl"
|
#line 39 ".\\scratchpad\\testragel.rl"
|
||||||
{te = p;p--;{ println("256 color"); }}
|
{te = p+1;{ println("single"); }}
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
#line 37 ".\\scratchpad\\testragel.rl"
|
#line 40 ".\\scratchpad\\testragel.rl"
|
||||||
{te = p;p--;{ println("true color"); }}
|
{te = p+1;{ println("basic"); }}
|
||||||
break;
|
break;
|
||||||
case 11:
|
#line 258 ".\\scratchpad\\testragel.cpp"
|
||||||
#line 34 ".\\scratchpad\\testragel.rl"
|
|
||||||
{{p = ((te))-1;}{ println("single"); }}
|
|
||||||
break;
|
|
||||||
#line 222 ".\\scratchpad\\testragel.cpp"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +292,7 @@ _again:
|
||||||
#line 1 "NONE"
|
#line 1 "NONE"
|
||||||
{ts = 0;}
|
{ts = 0;}
|
||||||
break;
|
break;
|
||||||
#line 233 ".\\scratchpad\\testragel.cpp"
|
#line 269 ".\\scratchpad\\testragel.cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,30 +301,23 @@ _again:
|
||||||
if ( ++p != pe )
|
if ( ++p != pe )
|
||||||
goto _resume;
|
goto _resume;
|
||||||
_test_eof: {}
|
_test_eof: {}
|
||||||
if ( p == eof )
|
|
||||||
{
|
|
||||||
if ( _foo_eof_trans[cs] > 0 ) {
|
|
||||||
_trans = _foo_eof_trans[cs] - 1;
|
|
||||||
goto _eof_trans;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_out: {}
|
_out: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 56 ".\\scratchpad\\testragel.rl"
|
#line 58 ".\\scratchpad\\testragel.rl"
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// possibly put alphtype unsigned int?
|
// possibly put alphtype unsigned int?
|
||||||
std::vector<std::string_view> tests = {
|
std::vector<std::string_view> tests = {
|
||||||
"\x1B[;5;78;98m",
|
"\x1B[38;5;78;98m",
|
||||||
"\x1B[;2;36;46;23m",
|
"\x1B[48;5;78;98m",
|
||||||
|
"\x1B[38;2;36;46;23m",
|
||||||
|
"\x1B[48;2;36;46;23m",
|
||||||
"\x1B[36;46m",
|
"\x1B[36;46m",
|
||||||
"\x1B[36m",
|
"\x1B[36m",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
for(auto test : tests) {
|
for(auto test : tests) {
|
||||||
println("--- PARSING");
|
println("--- PARSING");
|
||||||
parse_ansi(test);
|
parse_ansi(test);
|
||||||
|
|
|
@ -22,20 +22,22 @@ using namespace fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
start = 0x1B "[";
|
start = 0x1B "[";
|
||||||
|
fg = "38;";
|
||||||
|
bg = "48;";
|
||||||
num = digit+ >tstart %number;
|
num = digit+ >tstart %number;
|
||||||
|
color256 = "5;" num ";" num;
|
||||||
color256 = ";5;" (num ";"?)**;
|
color24b = "2;" num ";" num ";" num;
|
||||||
color24b = ";2;" (num ";"?)**;
|
|
||||||
basic = num ";" num;
|
basic = num ";" num;
|
||||||
single = num;
|
single = num;
|
||||||
|
|
||||||
main := |*
|
main := |*
|
||||||
start => { println("START"); };
|
start => { println("START"); };
|
||||||
single => { println("single"); };
|
fg color256 "m" => { println("fg 256 color"); };
|
||||||
basic => { println("basic"); };
|
bg color256 "m" => { println("bg 256 color"); };
|
||||||
color256 => { println("256 color"); };
|
fg color24b "m" => { println("fg true color"); };
|
||||||
color24b => { println("true color"); };
|
bg color24b "m" => { println("bg true color"); };
|
||||||
"m" => { println("END"); };
|
single "m" => { println("single"); };
|
||||||
|
basic "m" => { println("basic"); };
|
||||||
*|;
|
*|;
|
||||||
}%%
|
}%%
|
||||||
|
|
||||||
|
@ -58,13 +60,14 @@ void parse_ansi(std::string_view &codes) {
|
||||||
int main() {
|
int main() {
|
||||||
// possibly put alphtype unsigned int?
|
// possibly put alphtype unsigned int?
|
||||||
std::vector<std::string_view> tests = {
|
std::vector<std::string_view> tests = {
|
||||||
"\x1B[;5;78;98m",
|
"\x1B[38;5;78;98m",
|
||||||
"\x1B[;2;36;46;23m",
|
"\x1B[48;5;78;98m",
|
||||||
|
"\x1B[38;2;36;46;23m",
|
||||||
|
"\x1B[48;2;36;46;23m",
|
||||||
"\x1B[36;46m",
|
"\x1B[36;46m",
|
||||||
"\x1B[36m",
|
"\x1B[36m",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
for(auto test : tests) {
|
for(auto test : tests) {
|
||||||
println("--- PARSING");
|
println("--- PARSING");
|
||||||
parse_ansi(test);
|
parse_ansi(test);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue