added first parser implementation
This commit is contained in:
parent
0d8d0a68f2
commit
2216561506
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.idea/
|
.idea/
|
||||||
|
out/
|
@ -1,5 +1,7 @@
|
|||||||
package lsystem;
|
package lsystem;
|
||||||
|
|
||||||
|
import lsystem.engine.parser.Parser;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
@ -8,13 +10,22 @@ public class Main {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
System.out.println("Axiom: ");
|
Parser parser = null;
|
||||||
String axiom = scanner.next();
|
while(parser == null || parser.isCorrect()) {
|
||||||
System.out.println("Règles (laissez vide quand vous avez fini): ");
|
if(parser != null)
|
||||||
List<String> rules = new ArrayList<>();
|
System.out.println("Vos règles ou votre axiome ne sont pas correctement écrites, veuillez recommencer");
|
||||||
while(rules.isEmpty() || !rules.get(rules.size() - 1).equals("")) {
|
System.out.println("Axiome: ");
|
||||||
rules.add(scanner.next());
|
String axiom = scanner.next();
|
||||||
|
System.out.println("Règles: (\"finish\" quand vous avez fini): ");
|
||||||
|
List<String> rules = new ArrayList<>();
|
||||||
|
while(rules.isEmpty() || !rules.get(rules.size() - 1).equals("finish")) {
|
||||||
|
rules.add(scanner.next());
|
||||||
|
}
|
||||||
|
rules.remove(rules.size() - 1);
|
||||||
|
parser = new Parser(axiom, rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scanner.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
20
src/lsystem/engine/parser/Parser.java
Normal file
20
src/lsystem/engine/parser/Parser.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package lsystem.engine.parser;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Parser {
|
||||||
|
|
||||||
|
private final String axiom;
|
||||||
|
private final List<String> rules;
|
||||||
|
|
||||||
|
public Parser(String axiom, List<String> rules) {
|
||||||
|
this.axiom = axiom;
|
||||||
|
this.rules = rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCorrect(){
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user