Esempio n. 1
0
/** @todo Describe what task main will accomplish. */
int main (int argc, char ** argv)
{
    CompilerKitKleeneStar* kleene_star;
    g_type_init();
    
    kleene_star = compilerkit_kleene_star_new();
    
    /** @todo Briefly show how to use the methods in CompilerKitKleeneStar to accomplish the task. */

    g_object_unref (kleene_star);
}
Esempio n. 2
0
/**
 * test_kleene_star_constructor:
 * @fn test_kleene_star_constructor
 * Tests compilerkit_kleene_star_new in CompilerKitKleeneStar struct.
 * @pre None
 * @param None
 * @return void
 */
void test_kleene_star_constructor (void)
{
	GObject* e_set;
	GObject* e_string;
	GObject* a;
	GObject* result;
	
	
    g_test_message ("Testing KleeneStar method");
    g_test_timer_start ();
	
	
	//empty set
	{
	
		e_set = compilerkit_empty_set_get_instance();
		result = compilerkit_kleene_star_new(e_set);
		g_assert(COMPILERKIT_IS_EMPTY_SET (result));
        g_object_unref (result);
	}
	
	//empty string
	{
		e_string = compilerkit_empty_string_get_instance();
		result = compilerkit_kleene_star_new(e_string);
		g_assert(COMPILERKIT_IS_EMPTY_STRING (result));
        g_object_unref (result);
	}
	
	//symbol
	{
		a = compilerkit_symbol_new('a');
		result = compilerkit_kleene_star_new(a);
		g_assert(COMPILERKIT_IS_KLEENE_STAR (result));
        g_object_unref (result);
	}
    
    
    g_assert_cmpfloat(g_test_timer_elapsed (), <=, 1);
}
Esempio n. 3
0
/**
 * compilerkit_postive_closure_new:
 * @fn compilerkit_postive_closure_new
 *
 * Constructs a positive closure (internally the equivalent CompilerKitConcatenation and CompilerKitKleeneStar).
 * 
 * For example, `compilerkit_positive_closure_new(compilerkit_concatenation_new(compilerkit_symbol_new('a'),compilerkit_symbol_new('b')))` produces the regex `(ab)+`.
 * 
 * @pre `regex` is not NULL.
 * @param GObject* `regex` The regex to match one or more times.
 * @return GObject* regex that matches the given regex one or more times.
 */
GObject *compilerkit_positive_closure_new (GObject *regex)
{
    g_assert (regex);
    return compilerkit_concatenation_new (regex, compilerkit_kleene_star_new (regex));
}