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

222 lines
4.1 KiB

#line 1 "md_parser.rl"
#include <fmt/core.h>
#include <iostream>
#line 38 "md_parser.rl"
#line 7 "md_parser.cpp"
static const char _Parser_actions[] = {
0, 1, 0, 1, 3, 1, 4, 2,
0, 1, 2, 0, 2, 2, 1, 0,
2, 2, 0, 2, 3, 5
};
static const char _Parser_key_offsets[] = {
0, 0, 1, 2, 3, 4, 10, 11,
18, 22, 29, 31, 33, 34
};
static const char _Parser_trans_keys[] = {
61, 61, 61, 10, 10, 32, 35, 42,
9, 13, 10, 10, 32, 35, 42, 45,
9, 13, 10, 32, 9, 13, 10, 32,
35, 42, 45, 9, 13, 10, 45, 10,
45, 10, 10, 32, 35, 42, 45, 9,
13, 0
};
static const char _Parser_single_lengths[] = {
0, 1, 1, 1, 1, 4, 1, 5,
2, 5, 2, 2, 1, 5
};
static const char _Parser_range_lengths[] = {
0, 0, 0, 0, 0, 1, 0, 1,
1, 1, 0, 0, 0, 1
};
static const char _Parser_index_offsets[] = {
0, 0, 2, 4, 6, 8, 14, 16,
23, 27, 34, 37, 40, 42
};
static const char _Parser_indicies[] = {
0, 1, 2, 1, 3, 1, 4, 1,
7, 6, 8, 9, 6, 5, 11, 10,
7, 6, 8, 9, 12, 6, 5, 13,
6, 6, 5, 7, 6, 14, 15, 12,
6, 5, 11, 16, 10, 11, 17, 10,
18, 10, 7, 6, 8, 9, 12, 6,
5, 0
};
static const char _Parser_trans_targs[] = {
2, 0, 3, 4, 5, 6, 8, 9,
8, 8, 6, 7, 10, 9, 8, 8,
11, 12, 13
};
static const char _Parser_trans_actions[] = {
0, 0, 0, 0, 5, 1, 1, 0,
13, 16, 0, 3, 1, 3, 7, 10,
0, 0, 19
};
static const int Parser_start = 1;
static const int Parser_first_final = 13;
static const int Parser_error = 0;
static const int Parser_en_main = 1;
#line 41 "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 81 "md_parser.cpp"
{
cs = Parser_start;
}
#line 53 "md_parser.rl"
#line 84 "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"
{ fmt::println("----- START"); }
break;
case 5:
#line 20 "md_parser.rl"
{ fmt::println("END"); }
break;
#line 178 "md_parser.cpp"
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
_out: {}
}
#line 54 "md_parser.rl"
bool good = pe - p == 0;
if(good) {
finalize();
} else {
error = true;
std::cout << "!!!!!!!!!!!!!!!!!!!!!! error at:";
std::cout << p;
}
return good;
}