* @param token
* @return
*/
private static Regex parseToken(String ruleName, String token, Map<String, Regex> existingRule) throws InvalidDocumentException {
String unmodifiedToken = token;
Context ctx = new Context();
ctx.setValue("index", 0);
ctx.setValue("token", token);
ctx.setValue("regexList", new ArrayList<Regex>());
ctx.setValue("existingRule", existingRule);
ctx.setValue("ruleName", ruleName);
boolean modified = true;
while(modified){
for(TokenParser parser : parsers){
if(modified = parser.parseToken(ctx)){
break;
}
}
}
int index = ctx.getValue("index");
token = ctx.getValue("token");
List<Regex> regexList = ctx.getValue("regexList");
if (Pattern.matches(TokenParser.ID + "[\\d]+", token)) {
Regex retVal = regexList.get(index - 1);
return retVal;
} else {