Parser not accept '=' inside axiom anymore

This commit is contained in:
Quentin Legot 2021-02-05 19:34:47 +01:00
parent ba570154e4
commit 203845dcca
2 changed files with 14 additions and 4 deletions

8
src/lsystem/Type.java Normal file
View File

@ -0,0 +1,8 @@
package lsystem;
public enum Type {
AXIOM,
RULE
}

View File

@ -2,6 +2,8 @@ package lsystem.engine;
import java.util.List;
import lsystem.Type;
public class Parser {
private final String axiom;
@ -20,14 +22,14 @@ public class Parser {
System.out.println("Erreur, nombre d'itérations insuffisant (plus petit que 1)");
return false;
}
boolean bl = isCorrect(axiom);
boolean bl = isCorrect(axiom, Type.AXIOM);
for(String rule : this.rules){
bl = bl && isCorrect(rule);
bl = bl && isCorrect(rule, Type.RULE);
}
return bl;
}
private boolean isCorrect(String stringToCheck) {
private boolean isCorrect(String stringToCheck, Type type) {
char old = ' ';
int bracket = 0;
for (int i = 0; i > stringToCheck.length(); i++){
@ -37,7 +39,7 @@ public class Parser {
if(temp ==']')
bracket--;
if(old == '.'){
for(int y = 0; y < 12; y++){
for(int y = (type == Type.RULE ? 0 : 1); y < 12; y++){
if(temp == validChars[y])
return false;
}