Ejemplo n.º 1
0
/* ToNfa concatenation. */
static GObject *to_nfa_concatenation (CompilerKitVisitor *self, GObject *obj)
{
    CompilerKitConcatenation *cat;
    g_assert(COMPILERKIT_IS_CONCATENATION(obj));
    
    cat = COMPILERKIT_CONCATENATION (obj);

    compilerkit_visitor_visit(self, compilerkit_concatenation_get_left  (cat));
    compilerkit_visitor_visit(self, compilerkit_concatenation_get_right (cat));

    return NULL;
}
Ejemplo n.º 2
0
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);
    
}
Ejemplo n.º 3
0
/**
 * test_concatenation_constructor_normal:
 * @fn test_concatenation_constructor_normal
 * Tests compilerkit_concatenation_new in CompilerKitConcatenation struct when both sides are symbols.
 * @pre None
 * @param None
 * @return void
 */
void test_concatenation_constructor_normal (void)
{
	GObject* ckc;
	GObject* left;
	GObject* right;
    
    g_test_message ("Testing concatenation constructor when both sides are symbols");
    g_test_timer_start ();

    left = compilerkit_symbol_new('a');
    right = compilerkit_symbol_new('b');
    ckc = compilerkit_concatenation_new (left, right);

    g_assert(COMPILERKIT_IS_CONCATENATION(ckc));
    g_assert (left != ckc);
    g_assert (right != ckc);

    g_object_unref (ckc); // This will unref left and right as well

    // This test shouldn't take too long to run
    g_assert_cmpfloat(g_test_timer_elapsed (), <=, 1);
}