/* ToNfa Kleene star. */ static GObject *to_nfa_kleene_star (CompilerKitVisitor *self, GObject *obj) { CompilerKitKleeneStar *star; g_assert(COMPILERKIT_IS_KLEENE_STAR(obj)); star = COMPILERKIT_KLEENE_STAR (obj); compilerkit_visitor_visit(self, compilerkit_kleene_star_get_node (star)); return NULL; }
/* StringBuilder Kleene star. */ static GObject *string_builder_kleene_star (CompilerKitVisitor *self, GObject *obj) { CompilerKitKleeneStar *star; GString *str = (GString *) compilerkit_visitor_get_state(self); g_assert(COMPILERKIT_IS_KLEENE_STAR(obj)); star = COMPILERKIT_KLEENE_STAR (obj); g_string_append_c (str, '('); compilerkit_visitor_visit(self, compilerkit_kleene_star_get_node (star)); g_string_append (str, ")*"); return NULL; }
void test_positive_closure(void) { GObject *regex, *positive_closure; CompilerKitConcatenation *cat; CompilerKitKleeneStar *star; regex = compilerkit_concatenation_new (compilerkit_symbol_new('a'), compilerkit_symbol_new('b')); positive_closure = compilerkit_positive_closure_new (regex); g_assert (COMPILERKIT_IS_CONCATENATION(positive_closure)); cat = COMPILERKIT_CONCATENATION(positive_closure); g_assert (compilerkit_concatenation_get_left (cat) == regex); g_assert (COMPILERKIT_IS_KLEENE_STAR (compilerkit_concatenation_get_right (cat))); star = COMPILERKIT_KLEENE_STAR (compilerkit_concatenation_get_right (cat)); g_assert (compilerkit_kleene_star_get_node (star) == regex); }