Exemple #1
0
 @Override
 public void visitRuleList(boolean or, ArrayList<Rule> list) {
   if (or) {
     if (level > 10) {
       if (level > 1000) {
         // better than stack overflow
         throw new AssertionError();
       }
       list.get(0).accept(this);
       return;
     }
     int idx = random.nextInt(list.size());
     level++;
     list.get(idx).accept(this);
     level--;
     return;
   }
   StringBuilder buff = new StringBuilder();
   level++;
   for (Rule r : list) {
     r.accept(this);
     buff.append(sql);
   }
   level--;
   sql = buff.toString();
 }
Exemple #2
0
 @Override
 public void visitRuleOptional(Rule rule) {
   if (level > 10 ? random.nextInt(level) == 1 : random.nextInt(4) == 1) {
     level++;
     rule.accept(this);
     level--;
     return;
   }
   sql = "";
 }
Exemple #3
0
 @Override
 public void visitRuleElement(boolean keyword, String name, Rule link) {
   if (keyword) {
     if (name.startsWith(";")) {
       sql = "";
     } else {
       sql = name.length() > 1 ? " " + name + " " : name;
     }
   } else if (link != null) {
     level++;
     link.accept(this);
     level--;
   } else {
     throw new AssertionError(name);
   }
 }
Exemple #4
0
 @Override
 public void visitRuleRepeat(boolean comma, Rule rule) {
   rule.accept(this);
 }