fix(parser): fix blatant bug with lexer handling

This commit is contained in:
Jef Roosens 2024-03-15 22:24:19 +01:00
parent 06a9d1e37f
commit 33824534bc
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 52 additions and 34 deletions

33
test/parser/compound.c Normal file
View file

@ -0,0 +1,33 @@
#include "test.h"
#include "mrk/lexer.h"
#include "mrk/parser_internal.h"
#define LEXER_INIT() \
mrk_lexer *lxr; \
TEST_CHECK(mrk_lexer_init(&lxr) == mrk_err_ok)
#define PARSER_INIT() \
mrk_parser *parser; \
TEST_CHECK(mrk_parser_init(&parser) == mrk_err_ok)
#define PARSER_OPEN(buf) \
mrk_lexer *lxr; \
TEST_CHECK(mrk_lexer_init(&lxr) == mrk_err_ok); \
mrk_parser *parser; \
TEST_CHECK(mrk_parser_init(&parser) == mrk_err_ok); \
mrk_lexer_open(lxr, buf, 0); \
mrk_parser_open(parser, lxr)
void test_parse_simple_header_paragraph() {
const char *buf = "# this is a header\n\nthis is a paragraph with a [link](https://example.com)";
PARSER_OPEN(buf);
mrk_ast_node *root;
TEST_CHECK(mrk_parser_parse(&root, parser) == mrk_err_ok);
}
TEST_LIST = {
{ "parser simple header and paragraph", test_parse_simple_header_paragraph },
{ NULL, NULL }
};