diff --git a/md_parser.cpp b/md_parser.cpp index 3325da5..d3655f0 100644 --- a/md_parser.cpp +++ b/md_parser.cpp @@ -4,76 +4,94 @@ #include -#line 38 "md_parser.rl" +#line 40 "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 + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 2, + 1, 3, 2, 2, 3, 2, 3, 2, + 2, 5, 0 }; static const char _Parser_key_offsets[] = { - 0, 0, 1, 2, 3, 4, 10, 11, - 18, 22, 29, 31, 33, 34 + 0, 0, 1, 2, 3, 4, 8, 10, + 14, 19, 24, 31, 36, 41, 48, 53, + 55, 57, 62, 64, 65, 70, 75 }; 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 + 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, 1, 1, 1, 4, 1, 5, - 2, 5, 2, 2, 1, 5 + 0, 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, 1, 0, 1, - 1, 1, 0, 0, 0, 1 + 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, 4, 6, 8, 14, 16, - 23, 27, 34, 37, 40, 42 + 0, 0, 2, 4, 6, 8, 13, 16, + 21, 26, 31, 38, 43, 48, 55, 60, + 63, 66, 71, 74, 76, 81, 86 }; 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 + 6, 7, 8, 9, 5, 11, 12, 10, + 14, 15, 16, 17, 13, 19, 18, 12, + 18, 10, 21, 20, 22, 20, 13, 23, + 20, 15, 24, 25, 20, 13, 27, 26, + 12, 26, 10, 29, 28, 22, 28, 13, + 30, 28, 15, 16, 17, 28, 13, 31, + 26, 12, 26, 10, 11, 32, 10, 11, + 1, 10, 31, 26, 33, 26, 10, 11, + 34, 10, 35, 1, 31, 26, 32, 26, + 10, 27, 26, 33, 26, 10, 6, 7, + 8, 9, 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 + 2, 0, 3, 4, 5, 6, 7, 8, + 14, 20, 6, 7, 15, 6, 7, 8, + 14, 17, 9, 10, 9, 10, 15, 10, + 11, 21, 12, 13, 12, 13, 13, 13, + 16, 18, 19, 22 }; 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 + 0, 0, 0, 0, 9, 24, 11, 24, + 24, 24, 0, 7, 0, 1, 0, 1, + 1, 1, 3, 15, 1, 7, 1, 0, + 1, 1, 5, 21, 1, 7, 0, 18, + 0, 0, 0, 13 }; static const int Parser_start = 1; -static const int Parser_first_final = 13; +static const int Parser_first_final = 22; static const int Parser_error = 0; static const int Parser_en_main = 1; -#line 41 "md_parser.rl" +#line 43 "md_parser.rl" bool Parser::parse(const std::string& input) { @@ -86,14 +104,14 @@ bool Parser::parse(const std::string& input) { std::string tk; -#line 81 "md_parser.cpp" +#line 99 "md_parser.cpp" { cs = Parser_start; } -#line 53 "md_parser.rl" +#line 55 "md_parser.rl" -#line 84 "md_parser.cpp" +#line 102 "md_parser.cpp" { int _klen; unsigned int _trans; @@ -191,10 +209,14 @@ _match: { fmt::println("----- START"); } break; case 5: -#line 20 "md_parser.rl" - { fmt::println("END"); } +#line 21 "md_parser.rl" + { fmt::println(">> START SLIDE"); } break; -#line 178 "md_parser.cpp" + case 6: +#line 22 "md_parser.rl" + { fmt::println("<< END SLIDE"); } + break; +#line 199 "md_parser.cpp" } } @@ -207,7 +229,7 @@ _again: _out: {} } -#line 54 "md_parser.rl" +#line 56 "md_parser.rl" bool good = pe - p == 0; diff --git a/md_parser.rl b/md_parser.rl index 774aa4d..325d1d7 100644 --- a/md_parser.rl +++ b/md_parser.rl @@ -17,24 +17,26 @@ std::cout << "CONTENT:" << std::quoted(tk) << '\n'; } action start { fmt::println("----- START"); } - action end { fmt::println("END"); } action plain { fmt::println("PLAIN"); } + action start_slide { fmt::println(">> START SLIDE"); } + action end_slide { fmt::println("<< END SLIDE"); } - eol = "\n"; - start = "===" eol $start; - end = "---" eol $end; - pound = "#" $title; - asterisk = "*" $enum; + eol = '\n'; + start = '===' %start; + end = '---' %end_slide; + pound = '#' %title; + asterisk = '*' %enum; + dash = '-' %enum; content = (any+ -- (eol|end)) >mark %content; - title = pound space* content eol; - enum = asterisk space* content eol; - line = space* content eol; + title = pound space+ content eol; + enum = (asterisk | dash) space+ content eol; + line = content :>> eol; blank = space* eol; - slide = (title | enum | line | blank)+ end; + slide = (title | enum | line | blank)+ >start_slide end eol; - main := start (slide)+; + main := start eol (slide)+; }%% %% write data; diff --git a/sample/01-a-good-first-program.md b/sample/01-a-good-first-program.md index c26754c..699a575 100644 --- a/sample/01-a-good-first-program.md +++ b/sample/01-a-good-first-program.md @@ -14,8 +14,8 @@ Besos would be proud. --- # Common Student Questions -* This again. -* That too. +- This again. +- That too. --- # The Blue Plus