Commits

Nzen committed b69e7b6

Finally, some real trie tests

The majority of the work involved making tests against flat_trie's
internal state given various input sets. For the moment that only involved
a sequence of non overlapping identifiers and a set that all shared the
same first letter. While the second can stand in for a lot, it doesn't
address some other possible combinations.

I also tightened up a number of the other tests, especially the loader
quines. While it was tedious, they now check rather than naively print.
Lexer needs some real tests, preferably backed by using Fake trie as a
mock.

Finally, in the output, you can see I've broken the output a bit. It seems
to have printed the last two cells in rest/skip_l twice. Not at all sure
why. I'll check next time. Otherwise, I am tentatively hopeful that this
project is coming to a close. After my earlier declaration, it wouldn't do
to speak without looking ahead again.

Comments (0)

Files changed (8)

 		}
 	}
 
+	// check first_chars for of_new
 	private T_Flag check_initial( char of_new )
 	{
 		int index = sigma.stored_in( of_new );
 	}
 
 	// for lexer: diff flag signifies *, seen signifies @, unseen signifies ?
-	// shit. this has been sending too many key flags:
-	// Reads? a* list? of? keys? files? Flags? those?
-	// for_file_names@ read_line? cut? n* left? by* read_int@
-	// else* if* next@ r* windows@ ending?
 	@Override
 	public T_Flag check_flag( char a_flag )
 	{
 			return recur_for_flag( skip_list.get( looking ), clients );
 	}
 
-	public boolean t_matches_state( T_Flag client_thinks )
-	{ // for tests
-		return state == client_thinks;
-	}
-
 	// skip_list is only for indices past 0, else unallocated
 	private boolean more_to_try( int skip_ind )
 	{
 		return sigma.includes( thingy );
 	}
 
+	// print internals according to spec
 	public void reveal_thyself()
 	{
 		System.out.println( "\nTransition List:" );
 		emit_database( ); // saved ids
 	}
 
+	// just the alphabet, not sorted, but indicies matching
 	private void emit_alphabet( String letras )
 	{
 		int end_i = letras.length();
 		}
 	}
 
+	// run printing of rest_stacked and skip_list
 	private void emit_database( )
 	{
 		int new_low = 0;
 		int upper = rest_stacked.lastIndexOf( "?" ) + 1;
 		String storage = rest_stacked.substring( 0, upper );
 		upper = storage.length() - 1;
-		int times = upper/10; //	== make this a ratio of upper, say / 10?
-		int offset = upper / times;
-		for ( int this_time = times; this_time >= 0; this_time-- )
+		int offset = 15;
+		int times = upper / offset;
+		for ( int this_time = times; this_time > 0; this_time-- )
 			new_low = print_sans_sigma( new_low, offset, storage );
-		capture_last_few( storage, upper, times );
+		capture_last_few( storage, upper, offset );
 	}
 
+	// print most of them
 	private int print_sans_sigma( int new_low, int offset, String storage )
 	{
 		int mid_lim = offset + new_low;
 		return mid_lim;
 	}
 
+	// for skip_list, print empty spot or a skipping index 
 	private void sys_print_skip( int ind )
 	{
 		boolean used = skip_list.get( ind ) > 0;
 		System.out.printf( "%4s|", either );
 	}
 
+	// print a line smaller than the offset
 	private void capture_last_few( String storage, int upper, int times )
 	{
 		int offset = upper / times;
 		print_sans_sigma( ended_at, upper - ended_at, storage );
 	}
 
+	// where alphabet is longer than rest_stacked, take care
 	public void show_tiny()
 	{
 		show_small_alphabet();
 		show_few_ids();
 	}
 
-	// why do I am I fighting this so hard?
+	// why am I fighting this so hard? to get the indicies to match
 	private void show_small_alphabet()
 	{
 		String arbitrary_order = sigma.get_letters();
 		System.out.printf( "%n%n" );
 	}
 
+	// just print without cutting into pieces
 	private void show_few_ids()
 	{
 		String id_chars = rest_stacked.substring( 0 ,
 		for ( int nn = 0; nn < len; nn++ )
 			System.out.printf( "%3d|", skip_list.get( nn ) );
 	}
+
+	public boolean t_matches_state( T_Flag client_thinks )
+	{ // for tests
+		return state == client_thinks;
+	}
+
+	// > did char save in expected spot? 
+	public boolean t_initial_index( char a2z, int expected )
+	{
+		int was = sigma.stored_in( a2z );
+		//System.out.println( " is " + Integer.toString( !valid_symbol(was)
+		//				? was : first_chars[ was ] ) + ": thought " + Integer.toString( expected ) );
+		return ( valid_symbol(was) ? first_chars[ was ] : was ) == expected;
+	}
+
+	// > boolean to char/index pair
+	public boolean t_char_in_rest_at( char thinking, int spot )
+	{
+		//System.out.print( " " + rest_stacked.charAt( spot ) + ":" + Integer.toString( spot ) + '\t' );
+		return rest_stacked.charAt( spot ) == thinking;
+	}
+
+	public boolean t_ind_in_skip_list( int spot, int expected )
+	{
+		return skip_list.get( spot ) == expected;
+	}
+
+	public void t_empty_self()
+	{
+		int used = rest_stacked.lastIndexOf( "" + end.charAt( k_spot + 1 ) );
+		// assumes I put at least one var in.
+		for ( int ind = first_chars.length - 1; ind >=0; ind-- )
+			first_chars[ ind ] = -1;
+		for ( ; used >= 0; used-- )
+		{
+			skip_list.set( used, 0 );
+			rest_stacked.setCharAt( used, ' ' );
+		}
+		next_open = 0;
+		focus = 0;
+	}
 }
 
 
 
 public class LexTester
 {
+	static final boolean good = true;
+	static final boolean not = false;
 	// current idea is constrained lang & input.
 	//later try dependency problem with fake trie 
 
 			if ( ! grammer_nazi.t_matches_current_state( st_should_pass[nn] ) )
 			{
 				System.out.println( "lex: didnt move to between state" );
-				cc = false;
+				cc = not;
 			}
 			nn++;
-			System.out.print( flag_ ); // debug
 		}
 		return cc;
 	}
 
-	public void t_l_many_vars( Lexer grammer_nazi, char more )
+	public void t_l_many_vars( Lexer grammer_nazi, char more ) // just dumps in without testing
 	{
 		IterableString key_n_var = new IterableString( "axe l boo ace" + '\n' ); // woo fancy
 		int linel = 5;
 	public boolean t_lex_endl_rej_bad( Lexer grammer_nazi, char nil )
 	{
 		char uu = grammer_nazi.lex_char( 'd' );
-		//if ( grammer_nazi.lex_char( 'd' ) != nil )
 		if ( uu != nil )
 		{
 			System.out.println( "lex: accepted non sigma-" + uu );
-			return false;
+			return not;
 		}
 		else if ( grammer_nazi.lex_char( '\n' ) != nil )
 		{
 			System.out.println( "lex: accepted preceeding endl" );
-			return false;
+			return not;
 		}
 		else if ( grammer_nazi.lex_char( '8' ) != nil )
 		{
 			System.out.println( "lex: accepted number" );
-			return false;
+			return not;
 		}
 		else
-			return true;
+			return good;
 	}
 }
 	{ // for testing
 		return state == from_out;
 	}
+
+	public void emit_concise_data()
+	{
+		transition_list.show_tiny();
+	}
 }
 
 	public static void main( String[] args )
 	{
+		// real
 		//String keys = args[0].substring( 0, args[0].length() - 1 );
 		//run( keys, get_file_names( args[1] ) );
-		run( "SHortIn.txt", new String[] {"arg.java"} );
-		//run_tests();
+		//	tests
+		run_tests();
+		run( "ShortKeys.txt", new String[] {"arg.java"} );
+		//run( "MediumKeys.txt", new String[] {"Storage.java"} );
 	}
 
 	// first line in list_file is number of files
 		save_key_words( reserved_file, java_lexer );
 		for ( String file_f : file_list )
 			flag_program( file_f, java_lexer );
-		java_lexer.lex_char( '$' );
-		java_lexer.lex_char( '\n' );
 		java_lexer.emit_saved_data();
 	}
 
 			else
 				System.out.print( became );
 		}
+		// eof isn't sent for last key, so add this:
+		java_lexer.lex_char( '\n' );
 		System.out.println( );
 		generic.close();
 	}
 	static void run_tests()
 	{
 		TestSuite for_classes = new TestSuite();
-		//for_classes.test_iterable_string();
-		//for_classes.test_word_loader( "arg.java" );
-		//for_classes.test_loader( "monkey.txt" );
-		//for_classes.test_alphabet();
-		//for_classes.test_trie();
-		//for_classes.test_lexer();
-		for_classes.test_for_false_key();
+		for_classes.test_iterable_string();
+		for_classes.test_word_loader( "arg.java" );
+		for_classes.test_loader( "arg.java" );
+		for_classes.test_alphabet();
+		for_classes.test_trie();
+		for_classes.test_lexer();
+		System.out.println( );
 	}
 }
 	public abstract void reveal_thyself();
 
 	public abstract boolean t_matches_state( T_Flag should_be );
+
+	public abstract void show_tiny();
 }
 
 public class TestSuite
 {
+	static final int key = 0;
+	static final int var = 1;
+	static final boolean hoped = true;
+	static final boolean let_down = !hoped;
+
 	public void test_alphabet()
 	{
 		System.out.println( " - Alphabet" );
 			System.out.println( "includes: missed negative" );
 		else if ( english.stored_in( 'e' ) != 0 )
 			System.out.println( "stored_in false index" );
-		//else if ( english.stored_in( 'Q' ) != null )
-			// I expect client to check includes() first
-			// all commented because {int != null} makes compiler unhappy 
-			//System.out.println( "stored_in didn't null when got garbage" );
+		else if ( english.stored_in( 'Q' ) >= 0 )
+		{
+			System.out.println( "stored_in gave index when got garbage" );
+		}
 		else
-			System.out.println( "seems fine" );
+			System.out.println( " seems fine" );
 	}
 
-	// human checked quine.
 	public void test_loader( String bit_stream )
 	{
+		System.out.println( " - Loader (char-wise)" );
+		String whole_file = "\r\npublic class arg\r\n" +
+				"{\r\n\tpublic static void main( String[] args )\r\n" +
+				"\t{\r\n\t\tfor ( String nn : args )\r\n" +
+				"\t\t\tSystem.out.println( nn );\r\n" +
+				"\t}\r\n}\r\n";
+		boolean worked = hoped;
 		Loader this_file = new Loader();
 		this_file.open( bit_stream );
 		char temp = 'f';
+		int ind = 0;
 		while ( this_file.has_more() )
 		{
 			temp = this_file.read_next();
-			System.out.print( temp );
+			if ( temp != whole_file.charAt( ind ) )
+			{
+				System.out.printf( "expected %c @%d got %c%n", whole_file.charAt( ind ), ind, temp );
+				worked = let_down;
+			}
+			ind++;
+			//System.out.print( temp );
 		}
 		this_file.close();
+		if ( worked )
+			System.out.println( " didn't stumble" );
 	}
 
 	public void test_lexer( )
 		char nil = '_';
 		char more = '^';
 		final String letras = "axecbol";
-		boolean no_complaints = true;
+		boolean no_complaints = hoped;
 		Lexer grammer_nazi = new Lexer( letras, nil, more ); // alphabet
 		words.prep_lex_keys( grammer_nazi );
 		no_complaints = words.t_lex_endl_rej_bad( grammer_nazi, nil );
 		String first_v = "ace ";
 		no_complaints = words.t_l_first_var( grammer_nazi, first_v ) && no_complaints;
 
-		words.t_l_many_vars( grammer_nazi, more ); // just dumps in data
-		
+		//words.t_l_many_vars( grammer_nazi, more ); // just dumps in data, & prints. no no.
+
+		no_complaints = let_down;
+		System.out.println( "needs more tests" );
 		if ( no_complaints )
-			System.out.println( "\nno tests tripped" );
-		grammer_nazi.emit_saved_data( );
+			System.out.println( " no tests tripped" );
+		//grammer_nazi.emit_concise_data(  );
 	}
 
 	public void test_trie( )
 	{
 		TrieTester ram = new TrieTester();
 		String alpha = "etaolin";
-		String flags = "*?";
-		Storage delta = new FlatTrie( alpha, flags );
+		final char[] flags = { '*', '?' };
+		Storage delta = new FlatTrie( alpha, new String( flags ) );
 		String[] keys = { "ate" };
 		String[] vars = { "tat" };
-		boolean worked = true;
+		boolean worked = hoped;
 		System.out.println( " - Trie" );
 		
-		worked = ram.t_t_save_keys( delta, keys, flags.charAt( 0 ) );
-		worked = ram.t_t_save_first_var( delta, vars[ 0 ], flags.charAt( 1 ) ) && worked;
-		worked = ram.t_t_repeat_first_var( delta, vars[ 0 ], flags.charAt( 1 ) ) && worked;
-		worked = ram.t_t_repeat_key( delta, keys[ 0 ], flags.charAt( 1 ) ) && worked;
-		
+		worked = ram.save_keys( delta, keys, flags[ key ] );
+		worked = ram.save_first_var( delta, vars[ 0 ], flags[ var ] ) && worked;
+		worked = ram.repeat_first_var( delta, vars[ 0 ], flags[ var ] ) && worked;
+		worked = ram.repeat_key( delta, keys[ 0 ], flags[ var ] ) && worked;
+		worked = ram.match_trie_storage( alpha, flags ) && worked; // tests against different id set 
+
+		worked = let_down;
+		System.out.println( "needs more tests" );
 		if ( worked )
-			System.out.println( "\n didn't trip tests" );
-		ram.t_t_dump_for_reveal( delta );
-		delta.reveal_thyself(); //not until it's bigger than the alphabet
+			System.out.println( " didn't trip tests" );
+		//ram.show_trie( delta, few_ids( keys.length, vars.length, alpha.length() ) );
+	}
+
+	private boolean few_ids( int num_keys, int num_vars, int num_letters )
+	{
+		return ( num_keys + num_vars ) < num_letters ;
 	}
-	// for_file_names@ read_line? cut? n* left? by* read_int@
-	// else* if* skip_list@ r* windows@ ending?
-	// this is pretty terrible, even though I thought I fixed it earlier in check flag
-	public void test_for_false_key()
+
+	public void test_trie_visually() // human checked quine
 	{
+		TrieTester eval = new TrieTester();
 		IterableString f_key = new IterableString( "ni cut n nil cy ni nyf " );
-		// bam. n produces the behavior when it has been seen. wth?
 		T_Flag says;
-		String flags = "*?";
+		char[] flags = { '*', '?' };
 		String beta = "cutnlefbyred_i";
-		FlatTrie compo = new FlatTrie( beta, flags );
+		FlatTrie compo = new FlatTrie( beta, new String(flags ) );
 		for ( Character nu : f_key )
 		{
 			if ( nu == ' ' )
 			{
-				says = compo.check_flag( flags.charAt( 1 ) );
-				System.out.print( was_flag( says ) + " " );
+				says = compo.check_flag( flags[ 1 ] );
+				System.out.print( eval.was_flag( says ) + " " );
 			}
 			else
 			{
 		compo.show_tiny();
 	}
 
-	private char was_flag( T_Flag received )
-	{
-		if ( received == T_Flag.f_seen )
-			return '@';
-		if ( received == T_Flag.f_unseen )
-			return '?';
-		if ( received == T_Flag.f_key )
-			return '*';
-		else
-			return 'X'; // assert unreachable
-	}
-
 	public void test_iterable_string( )
 	{
 		String control = "into the grinder";
 		System.out.println( " - Iterating string" );
 		int where = 0;
 		char should_be = ' ';
-		boolean worked = true;
+		boolean worked = hoped;
 		IterableString loop = new IterableString( control );
 		for ( Character pointer : loop )
 		{
 			if ( pointer != should_be )
 			{
 				System.out.printf( "didn't match char %c : %c", pointer, should_be );
-				worked = ! worked;
+				worked = let_down;
 			}
 		}
 		if ( worked )
-			System.out.println( "seems fine" );
+			System.out.println( " seems fine" );
 	}
 
 	public void test_word_loader( String file_n )
 	{
+		boolean worked = hoped;
+		String[] args_program = { "", "public class arg", "{",
+					"\tpublic static void main( String[] args )",
+					 "\t{", "\t\tfor ( String nn : args )",
+					"\t\t\tSystem.out.println( nn );", "\t}", "}" };
+		System.out.println( " - WordLoader" );
 		WordLoader scanner = new WordLoader();
+		String what_im_looking_at;
+		int which = 0;
 		scanner.open( file_n );
 		while( scanner.moreLines() )
-			System.out.println( scanner.read_line() );
+		{
+			//System.out.println( scanner.read_line() );
+			what_im_looking_at = scanner.read_line();
+			if ( ! what_im_looking_at.equals( args_program[ which ] ) )
+				{
+					System.out.println( what_im_looking_at +
+							" <is @" + Integer.toString( which ) + " want> "
+							+ args_program[ which ] );
+					worked = let_down;
+				}
+			which++;
+		}
 		scanner.close();
+		if ( worked )
+			System.out.println( " seems fine" );
 	}
 }
 
 
 public class TrieTester
 {
+	static final boolean initial_assumption = true;
+	static final boolean didnt = false;
 
-	public boolean t_t_state_matches( Storage delta, T_Flag should_be )
+	public boolean state_matches( Storage delta, T_Flag should_be )
 	{
 		return delta.t_matches_state( should_be );
 	}
 
-	public boolean t_t_save_keys( Storage delta, String[] reserved, char k_f )
+	public boolean save_keys( Storage delta, String[] reserved, char k_f )
 	{
-		final boolean fail = false;
-		boolean worked = !fail;
+		boolean worked = initial_assumption;
 		T_Flag shoul_b_diff;
 		for ( String nn : reserved )
 		{
 			for ( Character ch : keys )
 			{
 				delta.determine_char( ch );
-				if ( ! t_t_state_matches( delta, T_Flag.saving ) )
+				if ( ! state_matches( delta, T_Flag.saving ) )
 				{
-					System.out.println( "Tr: saving key not in save mode" );
-					worked = fail;
+					System.out.println( "sk`: saving key not in save mode" );
+					worked = didnt;
 				}
 			}
 			shoul_b_diff = delta.check_flag( k_f );
 			if ( shoul_b_diff != T_Flag.f_key )
 			{
-				System.out.println( "Tr: saving key didn't give diff flag" );
-				worked = fail;
+				System.out.println( "sk`: saving key didn't give diff flag" );
+				worked = didnt;
 			}
-			else if ( ! t_t_state_matches( delta, T_Flag.initial ) )
+			else if ( ! state_matches( delta, T_Flag.initial ) )
 			{
-				System.out.println( "Tr: ending key didn't change to init state" );
-				worked = fail;
+				System.out.println( "sk`: ending key didn't change to init state" );
+				worked = didnt;
 			}
 		}
 		return worked; // returning at first problem hid later problems
 	}
 
-	public boolean t_t_save_first_var( Storage delta, String var, char n_f )
+	public boolean save_first_var( Storage delta, String var, char n_f )
 	{
-		final boolean fail = false;
 		T_Flag said;
 		IterableString iable = new IterableString( var );
 		for ( Character ind : iable )
 			said = delta.determine_char( ind );
 			if ( said != T_Flag.f_unseen )
 			{
-				System.out.println( "Tr: all new var didn't give all T_F unseen" );
-				return fail;
+				System.out.println( "sfv: all new var didn't give all T_F unseen" );
+				return didnt;
 			}
 		}
 		said = delta.check_flag( n_f );
 		if ( said != T_Flag.f_unseen )
 		{
-			System.out.println( "Tr: saving new char's flag didn't give unseen" );
-			return fail;
+			System.out.println( "sfv: saving new char's flag didn't give unseen" );
+			return didnt;
 		}
-		else
-			System.out.println( "? " );
-		return !fail;
+		return initial_assumption;
 	}
 	
 	// consider confirming the state Trie is in when closing.
-	public boolean t_t_repeat_first_var( Storage delta, String var, char n_f )
+	public boolean repeat_first_var( Storage delta, String var, char n_f )
 	{
-		final boolean fail = false;
 		T_Flag report;
 		IterableString iable = new IterableString( var );
 		for ( Character ind : iable )
 			report = delta.determine_char( ind );
 			if ( report != T_Flag.f_seen )
 			{
-				System.out.println( "Tr: seen char not giving seen" );
-				return fail;
+				System.out.println( "rfv: seen char not giving seen" );
+				return didnt;
 			}
 		}
 		report = delta.check_flag( n_f );
 		if ( report != T_Flag.f_seen )
 		{
-			System.out.println( "Tr: saving new char's flag didn't give unseen" );
-			return fail;
+			System.out.println( "rfv: saving new char's flag didn't give unseen" );
+			return didnt;
 		}
-		else
-			System.out.println( "@ " );
-		return !fail;
+		return initial_assumption;
 	}
 
-	public boolean t_t_repeat_key( Storage delta, String key, char n_f )
+	public boolean repeat_key( Storage delta, String key, char n_f )
 	{
-		final boolean fail = false;
-		boolean worked = true;
+		boolean worked = initial_assumption;
 		T_Flag report;
 		IterableString repeat = new IterableString( key );
 		for ( Character ind : repeat )
 			report = delta.determine_char( ind );
 			if ( report != T_Flag.f_seen )
 			{
-				System.out.println( "Tr: key not giving seen: " + ind ); // tripping this. why?
-				worked = fail;
+				System.out.println( "rk: key not giving seen: " + ind ); // tripping this. why?
+				worked = didnt;
 			}
-			worked = t_t_check_state( delta, T_Flag.checking,
-					"matching key not in check mode" ) && worked;
+			worked = check_state( delta, T_Flag.checking,
+					"rk: matching key not in check mode" ) && worked;
 		}
 		report = delta.check_flag( n_f );
 		if ( report != T_Flag.f_key )
 		{
-			System.out.println( "Tr: ending key didn't produce diff flag" ); // also trips this
-			worked = fail;
+			System.out.println( "rk: ending key didn't produce diff flag" ); // also trips this
+			worked = didnt;
+		}
+		return worked;
+	}
+
+	public boolean check_state( Storage delta, T_Flag expected, String error )
+	{
+		if ( ! state_matches( delta, expected ) )
+		{
+			System.out.println( error );
+			return didnt;
+		}
+		return initial_assumption;
+	}
+
+	// testing trie internals
+	public boolean match_trie_storage( String alpha, char[] flag )
+	{
+		boolean worked = initial_assumption;
+		int number_of_ids = 5;
+		FlatTrie gamma = new FlatTrie( alpha, new String( flag ) );
+			// make some permutations in a controlled manner
+		worked = case_no_overlap( gamma, alpha, number_of_ids ) && worked;
+		gamma.t_empty_self();
+		worked = case_first_only_overlap( gamma, alpha, number_of_ids ) && worked;
+		//show_trie( gamma, true ); // true = small id list
+		return worked;
+	}
+
+	private boolean case_no_overlap( FlatTrie gamma, String alpha, int number_of_ids )
+	{
+		String[] all_ids = make_non_overlapping_ids( alpha, number_of_ids );
+		fill_trie( gamma, all_ids );
+		return match_w_no_overlap( gamma, all_ids );
+	}
+
+	private boolean case_first_only_overlap( FlatTrie gamma, String alpha, int number_of_ids )
+	{
+		String[] all_ids = make_shared_first_ids( alpha, number_of_ids );
+		fill_trie( gamma, all_ids );
+		boolean sole_assumption = only_first_char_seen( gamma, alpha );
+		return match_w_first_only_overlap( gamma, all_ids ) && sole_assumption;
+	}
+
+	private void fill_trie( FlatTrie gamma, String[] all_ids )
+	{
+		for( String one_id : all_ids )
+		{
+			for ( int ind = 0; ind < one_id.length() - 1; ind++ )
+				gamma.determine_char( one_id.charAt( ind ) );
+			gamma.check_flag( one_id.charAt( one_id.length() - 1 ) );
+		}
+	}
+
+	private String[] make_non_overlapping_ids( String chars, int number_of_ids )
+	{
+		//alpha = "etaolin";
+		//int lim = chars.length();
+		String[] crate = new String[ number_of_ids ];
+		int id_ind = 0;
+		char key = '*';
+		char var = '?';
+		int start = 0;
+		int offset = 3;
+		int keys_to_use = 2;
+		for ( int n_o_keys = keys_to_use; n_o_keys > 0; n_o_keys-- )
+		{
+			String a_key = chars.substring( start, start + offset ) + key;
+			crate[ id_ind++ ] = a_key;
+			start++;
+		}
+		for ( int n_o_vars = number_of_ids - keys_to_use; n_o_vars > 0; n_o_vars-- )
+		{
+			String a_var = chars.substring( start, start + offset ) + var;
+			crate[ id_ind++ ] = a_var;
+			start++;
+		}
+		return crate;
+	}
+
+	// very artificial situation. but good to build the format against.
+	private boolean match_w_no_overlap( FlatTrie gamma, String[] everything )
+	{
+		boolean worked = initial_assumption;
+		int should_be = 0;
+		char focus;
+		for( String id : everything )
+		{
+			int word_ind = 0;
+			focus =  id.charAt( word_ind );
+			if ( ! first_ch_matches( gamma, focus, should_be ) )
+			{
+				System.out.printf( "mw!o: first ch %c index %d didnt match%n", focus, should_be );
+				worked = didnt;
+			}
+			word_ind++;
+			//should_be++;
+			for( ; word_ind < id.length(); word_ind++ )
+			{
+				focus =  id.charAt( word_ind );
+				if ( ! later_ch_matches( gamma, id.charAt( word_ind ), should_be ) )
+				{
+					System.out.printf( "mw!o: later char %c didn't match index %d%n", focus, should_be );
+					worked = didnt;
+				}
+				should_be++;
+			}
+		}
+		final int unset = -1;
+		for ( should_be--; should_be >= 0; should_be-- )
+		{
+			if ( skip_ind_matches( gamma, should_be, unset ) )
+			{
+				System.out.printf( "mw!o: skip at %d shouldnt have been set", should_be );
+				worked = didnt;
+			}
 		}
-		else
-			System.out.println( "* " ); // debug & lex sim
 		return worked;
 	}
 
-	public boolean t_t_check_state( Storage delta, T_Flag expected, String error )
+	private String[] make_shared_first_ids( String chars, int number_of_ids )
 	{
-		if ( ! t_t_state_matches( delta, expected ) )
+		String[] crate = new String[ number_of_ids ];
+		int id_ind = 0;
+		final String key = "*";
+		final String var = "?";
+		int start = 0;
+		int offset = 2;
+		int keys_to_use = 2;
+		final String first = "" + chars.charAt( start );
+		for ( int n_o_keys = keys_to_use; n_o_keys > 0; n_o_keys-- )
 		{
-			System.out.println( "Tr: " + error );
-			return false;
+			String a_key = first + chars.substring( start, start + offset ) + key;
+			crate[ id_ind++ ] = a_key;
+			start++;
 		}
-		return true;
+		for ( int n_o_vars = number_of_ids - keys_to_use; n_o_vars > 0; n_o_vars-- )
+		{
+			String a_var = first + chars.substring( start, start + offset ) + var;
+			crate[ id_ind++ ] = a_var;
+			start++;
+		}
+		return crate;
+	}
+
+	private boolean only_first_char_seen( FlatTrie gamma, String alpha )
+	{
+		boolean worked = initial_assumption;
+		final int first = 0;
+		final int unseen = -1;
+		char only_one = alpha.charAt( first );
+		IterableString rest = new IterableString( alpha.substring( first + 1 ) );
+		if ( ! gamma.t_initial_index( only_one, first ) )
+		{
+			System.out.printf( "ofcs: didnt match %d solitary used initial char%c%n", first, only_one );
+			worked = didnt;
+		}
+		for ( Character each : rest )
+		{
+			if ( ! gamma.t_initial_index( each, unseen ) )
+			{
+				System.out.printf( "ofcs: other first char %c has been set%n", each );
+				worked = didnt;
+			}
+		}
+		return worked;
+	}
+
+	private boolean match_w_first_only_overlap( FlatTrie gamma, String[] everything ) // FINISH
+	{
+		boolean worked = initial_assumption;
+		int should_be = 0;
+		final int skip_first = 1;
+		int skip_position = should_be;
+		// test first separately
+		String first_id = everything[0];
+		char shared = first_id.charAt( should_be );
+		if ( ! first_ch_matches( gamma, shared, should_be ) )
+		{
+			System.out.printf( "mw1o: didnt match solitary first char %c%n", shared );
+			worked = didnt;
+		}
+		should_be = mw1o_test_rest_of_id( gamma, skip_first, should_be, first_id );
+		if ( should_be < 0 )
+		{
+			should_be *= -1;
+			worked = didnt;
+		}
+		// rest of the ids
+		for ( int times = skip_first; times < everything.length; times++ )
+		{
+			int word_ind = skip_first;
+			if ( ! skip_ind_matches( gamma, skip_position, should_be ) )
+			{
+				System.out.printf( "mw1o: skip at %d didn't match expected, %d%n", skip_position, should_be );
+				worked = didnt;
+			}
+			skip_position = should_be;
+			should_be = mw1o_test_rest_of_id( gamma, skip_first, should_be, everything[times] );
+			if ( should_be < 0 )
+			{
+				should_be *= -1;
+				worked = didnt;
+			}
+		}
+		return worked;
+	}
+
+	private int mw1o_test_rest_of_id( FlatTrie gamma, int skip_first, int should_be, String this_id )
+	{
+		boolean worked = initial_assumption;
+		char other;
+		for ( int rest_ch = skip_first; rest_ch < this_id.length(); rest_ch++ )
+		{
+			other = this_id.charAt( rest_ch );
+			if ( ! later_ch_matches( gamma, other, should_be ) )
+			{
+				System.out.printf( "mw1o: later -%c- didnt match at %d%n", other, should_be );
+				worked = didnt;
+			}
+			should_be++;
+		}
+		return (worked) ? should_be : should_be * -1;
+	}
+	// expects a a char,index pair to match on first_chars value, or -1 if not used
+	private boolean first_ch_matches( FlatTrie gamma, char symb, int ind )
+	{
+		return gamma.t_initial_index( symb, ind );
 	}
 
-	// if trie isn't big enough the printing overflows.
-	// shouldn't be a problem when it gets real input
-	public void t_t_dump_for_reveal( Storage delta )
+	private boolean later_ch_matches( FlatTrie gamma, char symb, int ind )
 	{
-		IterableString nn = new IterableString( "llleto tali sopa nit" );
-		for ( Character uu : nn )
-			delta.determine_char( uu );
-		delta.check_flag( '?' );
+		return gamma.t_char_in_rest_at( symb, ind );
+	}
+
+	private boolean skip_ind_matches( FlatTrie gamma, int at, int val )
+	{
+		return gamma.t_ind_in_skip_list( at, val );
+	}
+
+	public char was_flag( T_Flag received )
+	{
+		if ( received == T_Flag.f_seen )
+			return '@';
+		if ( received == T_Flag.f_unseen )
+			return '?';
+		if ( received == T_Flag.f_key )
+			return '*';
+		else
+			return 'X'; // assert unreachable
+	}
+
+	public void show_trie( Storage delta, boolean small_test_space )
+	{
+		if ( small_test_space )
+			delta.show_tiny();
+		else
+			delta.reveal_thyself();
 	}
 }
+ - Iterating string
+ seems fine
+ - WordLoader
+ seems fine
+ - Loader (char-wise)
+ didn't stumble
+ - Alphabet
+ seems fine
+ - Trie
+needs more tests
+ - Lexer
+needs more tests
+
 public* class* arg?
 public* static* void? main? String? args?
 for* String@ nn? args@
 
 Transition List:
 	   $    A    B    C    D    E    F    G    H    I 
-switch	  82|  -1|  -1|  -1|  -1|  -1|  -1|  -1|  -1|  -1|
+switch	  -1|  -1|  -1|  -1|  -1|  -1|  -1|  -1|  -1|  -1|
 
 	   J    K    L    M    N    O    P    Q    R    S 
 switch	  -1|  -1|  -1|  -1|  -1|  -1|  -1|  -1|  -1|  58|
 	   m    n    o    p    q    r    s    t    u    v 
 switch	  54|  23|  74|  26|  -1|  -1|  17|  43|  -1|  50|
 
-	   0|   1|   2|   3|   4|   5|   6|   7|   8|   9|  10|
-rest	   h|   a|   r|   *|   l|   a|   s|   s|   *|   o|   r|
-skip	   4|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|
-
-	  10|  11|  12|  13|  14|  15|  16|  17|  18|  19|  20|
-rest	   r|   *|   f|   *|   n|   t|   *|   t|   a|   t|   i|
-skip	   _|   _|  14|   _|   _|   _|   _|   _|   _|   _|   _|
-
-	  20|  21|  22|  23|  24|  25|  26|  27|  28|  29|  30|
-rest	   i|   c|   *|   e|   w|   *|   r|   i|   v|   a|   t|
-skip	   _|   _|   _|  39|   _|   _|  33|   _|  77|   _|   _|
-
-	  30|  31|  32|  33|  34|  35|  36|  37|  38|  39|  40|
-rest	   t|   e|   *|   u|   b|   l|   i|   c|   *|   u|   l|
-skip	   _|   _|   _|   _|   _|   _|   _|   _|   _|  66|   _|
-
-	  40|  41|  42|  43|  44|  45|  46|  47|  48|  49|  50|
-rest	   l|   l|   *|   r|   u|   e|   *|   r|   g|   ?|   o|
-skip	   _|   _|   _|   _|   _|   _|   _|   _|   _|  64|   _|
-
-	  50|  51|  52|  53|  54|  55|  56|  57|  58|  59|  60|
-rest	   o|   i|   d|   ?|   a|   i|   n|   ?|   t|   r|   i|
-skip	   _|   _|   _|   _|   _|   _|   _|   _|  68|   _|   _|
-
-	  60|  61|  62|  63|  64|  65|  66|  67|  68|  69|  70|
-rest	   i|   n|   g|   ?|   s|   ?|   n|   ?|   y|   s|   t|
-skip	   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|
-
-	  70|  71|  72|  73|  74|  75|  76|  77|  78|  79|  80|
-rest	   t|   e|   m|   ?|   u|   t|   ?|   n|   t|   l|   n|
-skip	   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|
-
-	  80|  81|  82|  83|  84|  85|  86|  87|  88|  89|  90|
-rest	   n|   ?|   ?|Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 83
-	at java.lang.String.charAt(Unknown Source)
-	at FlatTrie.print_sans_sigma(FlatTrie.java:258)
-	at FlatTrie.emit_database(FlatTrie.java:246)
-	at FlatTrie.reveal_thyself(FlatTrie.java:205)
-	at Lexer.emit_saved_data(Lexer.java:161)
-	at Project2.run(Project2.java:48)
-	at Project2.main(Project2.java:18)
+	   0|   1|   2|   3|   4|   5|   6|   7|   8|   9|  10|  11|  12|  13|  14|  15|
+rest	   h|   a|   r|   *|   l|   a|   s|   s|   *|   o|   r|   *|   f|   *|   n|   t|
+skip	   4|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|  14|   _|   _|   _|
+
+	  15|  16|  17|  18|  19|  20|  21|  22|  23|  24|  25|  26|  27|  28|  29|  30|
+rest	   t|   *|   t|   a|   t|   i|   c|   *|   e|   w|   *|   r|   i|   v|   a|   t|
+skip	   _|   _|   _|   _|   _|   _|   _|   _|  39|   _|   _|  33|   _|  77|   _|   _|
+
+	  30|  31|  32|  33|  34|  35|  36|  37|  38|  39|  40|  41|  42|  43|  44|  45|
+rest	   t|   e|   *|   u|   b|   l|   i|   c|   *|   u|   l|   l|   *|   r|   u|   e|
+skip	   _|   _|   _|   _|   _|   _|   _|   _|   _|  66|   _|   _|   _|   _|   _|   _|
+
+	  45|  46|  47|  48|  49|  50|  51|  52|  53|  54|  55|  56|  57|  58|  59|  60|
+rest	   e|   *|   r|   g|   ?|   o|   i|   d|   ?|   a|   i|   n|   ?|   t|   r|   i|
+skip	   _|   _|   _|   _|  64|   _|   _|   _|   _|   _|   _|   _|   _|  68|   _|   _|
+
+	  60|  61|  62|  63|  64|  65|  66|  67|  68|  69|  70|  71|  72|  73|  74|  75|
+rest	   i|   n|   g|   ?|   s|   ?|   n|   ?|   y|   s|   t|   e|   m|   ?|   u|   t|
+skip	   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|   _|
+
+	  75|  76|  77|  78|  79|  80|
+rest	   t|   ?|   n|   t|   l|   n|
+skip	   _|   _|   _|   _|   _|   _|
+
+	  80|  81|
+rest	   n|   ?|
+skip	   _|   _|
+