If Amazon used this Besos wouldn't have banned PowerPoint.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
besos-loves-slides/md_parser.cpp

257 lines
5.0 KiB

#line 1 "md_parser.rl"
#include <fmt/core.h>
#include <iostream>
#line 45 "md_parser.rl"
#line 7 "md_parser.cpp"
static const char _Parser_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3, 1, 4, 1, 5, 1, 6, 1,
7, 2, 1, 3, 2, 2, 3, 2,
3, 2, 2, 6, 0
};
static const char _Parser_key_offsets[] = {
0, 0, 1, 1, 2, 3, 4, 5,
6, 7, 11, 13, 17, 22, 27, 34,
39, 44, 51, 56, 58, 60, 65, 67,
68, 73, 78
};
static const char _Parser_trans_keys[] = {
123, 125, 10, 61, 61, 61, 10, 10,
35, 42, 45, 10, 45, 10, 35, 42,
45, 10, 32, 45, 9, 13, 10, 32,
45, 9, 13, 10, 32, 35, 42, 45,
9, 13, 10, 32, 45, 9, 13, 10,
32, 45, 9, 13, 10, 32, 35, 42,
45, 9, 13, 10, 32, 45, 9, 13,
10, 45, 10, 45, 10, 32, 45, 9,
13, 10, 45, 10, 10, 32, 45, 9,
13, 10, 32, 45, 9, 13, 10, 35,
42, 45, 0
};
static const char _Parser_single_lengths[] = {
0, 1, 0, 1, 1, 1, 1, 1,
1, 4, 2, 4, 3, 3, 5, 3,
3, 5, 3, 2, 2, 3, 2, 1,
3, 3, 4
};
static const char _Parser_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 0, 0, 1, 0, 0,
1, 1, 0
};
static const char _Parser_index_offsets[] = {
0, 0, 2, 3, 5, 7, 9, 11,
13, 15, 20, 23, 28, 33, 38, 45,
50, 55, 62, 67, 70, 73, 78, 81,
83, 88, 93
};
static const char _Parser_indicies[] = {
0, 1, 2, 3, 2, 4, 1, 5,
1, 6, 1, 7, 1, 8, 1, 10,
11, 12, 13, 9, 15, 16, 14, 18,
19, 20, 21, 17, 23, 22, 16, 22,
14, 25, 24, 26, 24, 17, 27, 24,
19, 28, 29, 24, 17, 31, 30, 16,
30, 14, 33, 32, 26, 32, 17, 34,
32, 19, 20, 21, 32, 17, 35, 30,
16, 30, 14, 15, 36, 14, 15, 1,
14, 35, 30, 37, 30, 14, 15, 38,
14, 39, 1, 35, 30, 36, 30, 14,
31, 30, 37, 30, 14, 10, 11, 12,
13, 9, 0
};
static const char _Parser_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 18, 24, 10, 11,
19, 10, 11, 12, 18, 21, 13, 14,
13, 14, 19, 14, 15, 25, 16, 17,
16, 17, 17, 17, 20, 22, 23, 26
};
static const char _Parser_trans_actions[] = {
1, 0, 0, 0, 9, 0, 0, 0,
11, 26, 13, 26, 26, 26, 0, 7,
0, 1, 0, 1, 1, 1, 3, 17,
1, 7, 1, 0, 1, 1, 5, 23,
1, 7, 0, 20, 0, 0, 0, 15
};
static const int Parser_start = 1;
static const int Parser_first_final = 26;
static const int Parser_error = 0;
static const int Parser_en_main = 1;
#line 48 "md_parser.rl"
bool Parser::parse(const std::string& input) {
int cs = 0;
const char *start = nullptr;
const char *begin = input.data();
const char *p = input.data();
const char *pe = p + input.size();
const char *eof = p + input.size(); (void)eof;
std::string tk;
#line 105 "md_parser.cpp"
{
cs = Parser_start;
}
#line 60 "md_parser.rl"
#line 108 "md_parser.cpp"
{
int _klen;
unsigned int _trans;
const char *_acts;
unsigned int _nacts;
const char *_keys;
if ( p == pe )
goto _test_eof;
if ( cs == 0 )
goto _out;
_resume:
_keys = _Parser_trans_keys + _Parser_key_offsets[cs];
_trans = _Parser_index_offsets[cs];
_klen = _Parser_single_lengths[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 += (unsigned int)(_mid - _keys);
goto _match;
}
}
_keys += _klen;
_trans += _klen;
}
_klen = _Parser_range_lengths[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 += (unsigned int)((_mid - _keys)>>1);
goto _match;
}
}
_trans += _klen;
}
_match:
_trans = _Parser_indicies[_trans];
cs = _Parser_trans_targs[_trans];
if ( _Parser_trans_actions[_trans] == 0 )
goto _again;
_acts = _Parser_actions + _Parser_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
#line 12 "md_parser.rl"
{ start = p; }
break;
case 1:
#line 13 "md_parser.rl"
{ fmt::println("TITLE"); }
break;
case 2:
#line 14 "md_parser.rl"
{ fmt::println("ENUM"); }
break;
case 3:
#line 15 "md_parser.rl"
{
tk = input.substr(start - begin, p - start);
std::cout << "CONTENT:" << std::quoted(tk) << '\n';
}
break;
case 4:
#line 19 "md_parser.rl"
{
tk = input.substr(start - begin, p - start);
std::cout << "META:" << std::quoted(tk) << '\n';
}
break;
case 5:
#line 23 "md_parser.rl"
{ fmt::println("----- START"); }
break;
case 6:
#line 25 "md_parser.rl"
{ fmt::println(">> START SLIDE"); }
break;
case 7:
#line 26 "md_parser.rl"
{ fmt::println("<< END SLIDE"); }
break;
#line 211 "md_parser.cpp"
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
_out: {}
}
#line 61 "md_parser.rl"
bool good = pe - p == 0;
if(good) {
finalize();
} else {
error = true;
std::cout << "!!!!!!!!!!!!!!!!!!!!!! error at:";
std::cout << p;
}
return good;
}