package co.m4solutions.grammars.generator;

import co.m4solutions.grammars.model.Token;
import co.m4solutions.grammars.model.TokenGroup;
import co.m4solutions.grammars.model.TokenOperator;

public class RandomTokenGroupChooser {

	public static Token choose(TokenGroup group, GeneratorLimitAdvisor advisor) {
		if (group.getOperator().equals(TokenOperator.OR)){//The only one by now
		    
		    
		    
			int choosenTokenIndex = 0 + (int)(Math.random() * ((group.getTokens().size()-1) + 1));
			Token choosen = group.getTokens().get(choosenTokenIndex);
			
//			if(choosen instanceof NonTerminalToken){
//			     choosenTokenIndex = 0 + (int)(Math.random() * ((group.getTokens().size()-1) + 1));
//	             choosen = group.getTokens().get(choosenTokenIndex);
//			}
//			
//	        if(choosen instanceof NonTerminalToken){
//                 choosenTokenIndex = 0 + (int)(Math.random() * ((group.getTokens().size()-1) + 1));
//                 choosen = group.getTokens().get(choosenTokenIndex);
//            }
			return choosen;
		}
		return group;
	}

}

@@ -382,472 +382,185 @@
 w%0A%09%09
-    %0A%09%09    %0A%09%09    %0A%09%09%09int choosenTokenIndex = 0 + (int)(Math.random() * ((group.getTokens().size()-1) + 1));%0A%09%09%09Token choosen = group.getTokens().get(choosenTokenIndex);%0A%09%09%09%0A//%09%09%09if(choosen instanceof NonTerminalToken)%7B%0A//%09%09%09     choosenTokenIndex = 0 + (int)(Math.random() * ((group.getTokens().size()-1) + 1));%0A//%09             choosen = group.getTokens().get(choosenTokenIndex);%0A//%09%09%09%7D%0A//%09%09%09%0A//%09        if(choosen instanceof NonTerminalToken)%7B%0A//                
+%0A%09%09%09//Here is where the %22magic%22 happens, for the next version this choice should be driven %0A%09%09%09//not by random numbers, but by hints of gramatically correctnes secuences.%0A%09%09%09int
  cho
@@ -643,26 +643,16 @@
 ));%0A
-//                
+%09%09%09Token
  cho
@@ -704,24 +704,8 @@
 x);%0A
-//            %7D%0A
 %09%09%09r

Update RandomTokenGroupChooser.java