Handle sequences in parser

This commit is contained in:
2024-10-25 14:10:07 +01:00
parent 584e92c29c
commit f434af5c96
2 changed files with 47 additions and 9 deletions

View File

@@ -64,6 +64,26 @@ static void b_is_parsed_as_unquantified_literal(void)
regex_free_children(&r);
}
static void abc_is_parsed_as_sequence_of_unquantified_literals(void)
{
regex_t r = { 0 };
const int result = PARSE_REGEX_STRING("abc", &r);
ASSERT_NE(-1, result);
ASSERT_EQ(3, r.sequence.len);
ASSERT_EQ(QUANTIFIER_NONE, r.sequence.contents[0].quantifier);
ASSERT_EQ(TERM_TYPE_LITERAL, r.sequence.contents[0].type);
ASSERT_EQ('a', r.sequence.contents[0].literal);
ASSERT_EQ(QUANTIFIER_NONE, r.sequence.contents[1].quantifier);
ASSERT_EQ(TERM_TYPE_LITERAL, r.sequence.contents[1].type);
ASSERT_EQ('b', r.sequence.contents[1].literal);
ASSERT_EQ(QUANTIFIER_NONE, r.sequence.contents[2].quantifier);
ASSERT_EQ(TERM_TYPE_LITERAL, r.sequence.contents[2].type);
ASSERT_EQ('c', r.sequence.contents[2].literal);
regex_free_children(&r);
}
int main(void)
{
TESTING_BEGIN();
@@ -72,5 +92,6 @@ int main(void)
a_pipe_b_pipe_c_result_alternative_has_alternative();
a_is_parsed_as_unquantified_literal();
b_is_parsed_as_unquantified_literal();
abc_is_parsed_as_sequence_of_unquantified_literals();
return TESTING_END();
}