added first parser implementation
This commit is contained in:
parent
0d8d0a68f2
commit
2216561506
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.idea/
|
||||
out/
|
@ -1,5 +1,7 @@
|
||||
package lsystem;
|
||||
|
||||
import lsystem.engine.parser.Parser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
@ -8,13 +10,22 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
System.out.println("Axiom: ");
|
||||
String axiom = scanner.next();
|
||||
System.out.println("Règles (laissez vide quand vous avez fini): ");
|
||||
List<String> rules = new ArrayList<>();
|
||||
while(rules.isEmpty() || !rules.get(rules.size() - 1).equals("")) {
|
||||
rules.add(scanner.next());
|
||||
Parser parser = null;
|
||||
while(parser == null || parser.isCorrect()) {
|
||||
if(parser != null)
|
||||
System.out.println("Vos règles ou votre axiome ne sont pas correctement écrites, veuillez recommencer");
|
||||
System.out.println("Axiome: ");
|
||||
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