unit test for ModifierValue
This commit is contained in:
parent
b107f708ce
commit
f61beaefa0
2 changed files with 15 additions and 2 deletions
|
@ -3,10 +3,10 @@ package dev.peerat.parser.java.tree;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
import dev.peerat.parser.Bag;
|
||||
import dev.peerat.parser.Token;
|
||||
import dev.peerat.parser.TokenType;
|
||||
import dev.peerat.parser.java.JavaElement;
|
||||
import dev.peerat.parser.java.value.BiValue;
|
||||
import dev.peerat.parser.java.value.ModifierValue;
|
||||
import dev.peerat.parser.java.value.StaticValue;
|
||||
import dev.peerat.parser.java.value.TriValue;
|
||||
import dev.peerat.parser.java.value.Value.ValueContainer;
|
||||
|
@ -59,6 +59,14 @@ public class ValueTree extends SyntaxTree<JavaElement> {
|
|||
return null;
|
||||
};
|
||||
|
||||
BiFunction<JavaElement, Bag, JavaElement> modifierValueBuilder = (parent, bag) -> {
|
||||
System.out.println("modifierValueBuilder "+bag);
|
||||
ModifierValue result = new ModifierValue(bag.get("modifier"), bag.get());
|
||||
bag.set(result);
|
||||
if(parent instanceof ValueContainer) ((ValueContainer)parent).addValue(result);
|
||||
return null;
|
||||
};
|
||||
|
||||
StateTree<JavaElement> redirectRight = new RedirectStateTree<>(value, (global, local) -> {
|
||||
System.out.println("redirectRight g="+global+" ,l="+local);
|
||||
global.set("right", local.get());
|
||||
|
@ -110,7 +118,7 @@ public class ValueTree extends SyntaxTree<JavaElement> {
|
|||
value_operation_bit_or.then(redirectRight).end(operationBuilder);
|
||||
value_operation_bit_or.equals("|","action","||").then(redirectRight).end(operationBuilder);
|
||||
|
||||
value.equals("!").redirect(value).end();
|
||||
value.equals("!","modifier").redirect(value).end(modifierValueBuilder);
|
||||
|
||||
StateTree<JavaElement> left_value = value.redirect(unary_value);
|
||||
left_value.end((parent, bag) -> {
|
||||
|
|
|
@ -38,4 +38,9 @@ public class ModifierValue extends Value{
|
|||
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "[ModifierValue] "+modifier+value;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue