Group all in the base composant
This commit is contained in:
parent
2fb97d42fb
commit
958ab49552
1 changed files with 37 additions and 6 deletions
|
@ -10,6 +10,7 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import be.jeffcheasey88.peeratcode.parser.Bag;
|
||||
import be.jeffcheasey88.peeratcode.parser.Parser;
|
||||
|
@ -117,7 +118,8 @@ public class ParserComposantGenerator {
|
|||
comp.title = parent.title+"_"+bag.<Token>get().getValue();
|
||||
parent.declare(bag.<Token>get().getValue(), comp.current);
|
||||
|
||||
System.out.println("go on "+comp);
|
||||
System.out.println("+\t"+composant);
|
||||
|
||||
return comp;
|
||||
});
|
||||
|
||||
|
@ -261,7 +263,16 @@ public class ParserComposantGenerator {
|
|||
(bag, token) -> bag.set(token)
|
||||
));
|
||||
composant.<Element>end((element, bag) -> {
|
||||
return new Composant(bag);
|
||||
Composant child = new Composant(bag);
|
||||
SynthaxeComposant base;
|
||||
if(element instanceof SynthaxeComposant){
|
||||
base = (SynthaxeComposant)element;
|
||||
}else{
|
||||
base = ((Composant)element).parent;
|
||||
}
|
||||
child.parent = base;
|
||||
base.register(child.title, child);
|
||||
return child;
|
||||
}).then(new RedirectStateTree<>(op_childs, (bag) -> "content"))
|
||||
.then(composant);
|
||||
|
||||
|
@ -272,6 +283,11 @@ public class ParserComposantGenerator {
|
|||
};
|
||||
|
||||
parser.parse(reader, composant);
|
||||
|
||||
System.out.println();
|
||||
System.out.println(composant);
|
||||
System.out.println();
|
||||
|
||||
parser.build(new BufferedWriter(new FileWriter(new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-parseur\\java.out"))));
|
||||
|
||||
return composant;
|
||||
|
@ -297,22 +313,28 @@ public class ParserComposantGenerator {
|
|||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "SynthaxeComposant";
|
||||
String elements = "";
|
||||
for(Entry<String, Composant> entry : composants.entrySet()){
|
||||
elements+=",\n"+entry.getKey()+":"+entry.getValue();
|
||||
}
|
||||
if(elements.length() > 1) elements = elements.substring(2);
|
||||
return "SynthaxeComposant(\n"+elements+"\n)";
|
||||
}
|
||||
|
||||
public static class Composant extends Element{
|
||||
|
||||
private SynthaxeComposant parent;
|
||||
|
||||
private String title;
|
||||
|
||||
private MultipleWayComposant path;
|
||||
private Map<String, MultipleWayComposant> declared;
|
||||
private List<Element> next;
|
||||
private MultipleWayComposant next;
|
||||
|
||||
private MultipleWayComposant current;
|
||||
|
||||
public Composant(){
|
||||
this.declared = new HashMap<>();
|
||||
this.next = new ArrayList<>();
|
||||
|
||||
current = new MultipleWayComposant();
|
||||
}
|
||||
|
@ -326,6 +348,9 @@ public class ParserComposantGenerator {
|
|||
if(path == null){
|
||||
path = current;
|
||||
current = new MultipleWayComposant();
|
||||
}else{
|
||||
next = current;
|
||||
current = new MultipleWayComposant();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,7 +360,7 @@ public class ParserComposantGenerator {
|
|||
|
||||
@Override
|
||||
public String toString(){
|
||||
return title+"("+path;
|
||||
return title+"("+path+", "+declared+", "+next+")";
|
||||
}
|
||||
|
||||
public static class LinkedComposant extends Element{
|
||||
|
@ -372,6 +397,8 @@ public class ParserComposantGenerator {
|
|||
private boolean end;
|
||||
private boolean loop;
|
||||
|
||||
private Composant composant;
|
||||
|
||||
public Validator(Bag bag){
|
||||
String type = bag.get("type");
|
||||
action = bag.<Token>get().getValue();
|
||||
|
@ -419,6 +446,8 @@ public class ParserComposantGenerator {
|
|||
|
||||
private String target;
|
||||
|
||||
private Composant composant;
|
||||
|
||||
public Redirection(Bag bag){
|
||||
this.target = bag.<Token>get().getValue();
|
||||
System.out.println(this);
|
||||
|
@ -434,6 +463,8 @@ public class ParserComposantGenerator {
|
|||
|
||||
private String name;
|
||||
|
||||
private Composant composant;
|
||||
|
||||
public ComposantCall(Bag bag){
|
||||
this.name = bag.<Token>get().getValue();
|
||||
System.out.println(this);
|
||||
|
|
Loading…
Add table
Reference in a new issue