SubComposant limits

This commit is contained in:
jeffcheasey88 2023-07-15 12:57:29 +02:00
parent cffe1eb19d
commit afbb114086

View file

@ -110,6 +110,8 @@ public class ParserComposantGenerator {
StateTree<Element> operations = new StateTree<>();
StateTree<Element> operation = new StateTree<>();
StateTree<Element> sub_operations = new StateTree<>();
StateTree<Element> gotoValidator = new StateTree<>();
gotoValidator.then((v) -> v.validate(
(t) -> t.getType().equals(TokenType.NAME),
@ -123,7 +125,7 @@ public class ParserComposantGenerator {
parent.currentDeclared = comp;
return parent;
}).then(new RedirectStateTree<>(operations, (bag) -> {
}).then(new RedirectStateTree<>(sub_operations, (bag) -> {
return "operations";
}))
.end((composant, bag) -> {
@ -265,6 +267,63 @@ public class ParserComposantGenerator {
return composant;
});
StateTree<Element> sub_suit = sub_operations.then(new RedirectStateTree<>(operation, (bag) -> {
Integer count = bag.get("count");
if(count == null) count = 0;
bag.set("count", count+1);
return "operation"+count;
})).loop();
sub_suit.then((v) -> v.validate((t) -> t.getValue().equals(",")))
.end((composant, bag) -> {
Composant current = (Composant)composant;
if(current.currentDeclared != null) current = current.currentDeclared;
MultipleWayComposant way = current.current;
int count = bag.get("count");
LinkedComposant linked = new LinkedComposant();
for(int i = 0; i < count; i++){
Bag op = bag.get("operation"+i);
if(op.get() == null) continue;
linked.elements.add(op.get());
}
way.elements.add(linked);
return composant;
}).then(suit);
sub_suit.then((v) -> v.validate((t) -> t.getValue().equals(";")))
.end((composant, bag) -> {
Composant current = (Composant)composant;
if(current.currentDeclared != null) current = current.currentDeclared;
MultipleWayComposant way = current.current;
int count = bag.get("count");
LinkedComposant linked = new LinkedComposant();
for(int i = 0; i < count; i++){
Bag op = bag.get("operation"+i);
if(op.get() == null) continue;
linked.elements.add(op.get());
}
way.elements.add(linked);
current.include();
return composant;
});
sub_suit.end((composant, bag) -> {
Composant current = (Composant)composant;
if(current.currentDeclared != null) current = current.currentDeclared;
MultipleWayComposant way = current.current;
int count = bag.get("count");
LinkedComposant linked = new LinkedComposant();
for(int i = 0; i < count; i++){
Bag op = bag.get("operation"+i);
if(op.get() == null) continue;
linked.elements.add(op.get());
}
way.elements.add(linked);
current.include();
return composant;
});
StateTree<Element> main = new StateTree<>();
StateTree<Element> composant = main.then((v) -> v.validate(