xo-reader: + DDefineSsm + utest

This commit is contained in:
Roland Conybeare 2026-01-19 00:39:16 -05:00
commit e252a9f4e7
22 changed files with 220 additions and 29 deletions

View file

@ -62,13 +62,38 @@ namespace xo {
SchematikaParser parser(config, &expr_alloc, false /*debug_flag*/);
parser.begin_translation_unit();
parser.begin_batch_session();
// after begin_translation_unit, parser has toplevel exprseq
// but is still "at toplevel" in the sense of ready for input
REQUIRE(parser.has_incomplete_expr() == false);
}
TEST_CASE("SchematikaParser-batch-def", "[reader2][SchematikaParser]")
{
ArenaConfig config;
config.name_ = "test-arena";
config.size_ = 16 * 1024;
DArena expr_arena = DArena::map(config);
obj<AAllocator> expr_alloc = with_facet<AAllocator>::mkobj(&expr_arena);
SchematikaParser parser(config, &expr_alloc, false /*debug_flag*/);
parser.begin_batch_session();
auto & result = parser.on_token(Token::def_token());
// define-expressions not properly implemented
// after begin_interactive_session, parser has toplevel exprseq
// but is still "at toplevel" in the sense of ready for input
REQUIRE(parser.has_incomplete_expr() == true);
REQUIRE(result.is_error());
REQUIRE(result.error_description());
}
TEST_CASE("SchematikaParser-interactive-if", "[reader2][SchematikaParser]")
{
ArenaConfig config;
@ -82,11 +107,16 @@ namespace xo {
parser.begin_interactive_session();
parser.on_token(Token::if_token());
auto & result = parser.on_token(Token::if_token());
// after begin_interactive_session, parser has toplevel exprseq
// but is still "at toplevel" in the sense of ready for input
REQUIRE(parser.has_incomplete_expr() == false);
REQUIRE(result.is_error());
// illegal input on token
REQUIRE(result.error_description());
}
} /*namespace ut*/