Class ExpressionPrinter
java.lang.Object
org.cyclops.integrateddynamics.core.evaluate.expression.tree.ExpressionPrinter
Pretty-prints expression trees, such as
item => item.size() > 3.
Operators are named, and written as methods, as described in OperatorNames.
Choices are printed as c ? a : b, operator values as (+) or (reduce).-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringprint(Expression expression) static Stringprint(Expression expression, IntFunction<String> labels) static Stringprint(Expression expression, IntFunction<String> labels, IntFunction<IValueType<?>> refTypes) static StringprintExact(Expression expression, ValueDeseralizationContext values, IntFunction<String> labels, Function<String, it.unimi.dsi.fastutil.ints.IntList> labelIds, IntFunction<IValueType<?>> refTypes) Print the given expression in the text form thatExpressionParserreads back into the same expression.static StringprintLiteral(IValue value, ValueDeseralizationContext values) static StringprintNode(Expression expression, int[] path, IntFunction<String> labels, ExpressionTypeChecker.Result types) static StringprintOperatorValue(IOperator operator) static Stringstatic StringprintValue(IValue value) static Stringstatic List<ExpressionPrinter.Token> tokenize(Expression expression, IntFunction<String> labels, ExpressionTypeChecker.Result types) Pretty-print the given expression as a list of tokens.static List<ExpressionPrinter.Token> tokenizeExact(Expression expression, ValueDeseralizationContext values, IntFunction<String> labels, Function<String, it.unimi.dsi.fastutil.ints.IntList> labelIds, ExpressionTypeChecker.Result types) The text ofprintExact(Expression, ValueDeseralizationContext, IntFunction, Function, IntFunction)as tokens, which tell what node each part of the text belongs to.
-
Field Details
-
EMPTY
- See Also:
-
-
Method Details
-
print
public static String print(Expression expression, IntFunction<String> labels, IntFunction<IValueType<?>> refTypes) - Parameters:
expression- An expression.labels- Resolves the label of a variable id, may return null.refTypes- Resolves the type of a variable id, may return null when unknown.- Returns:
- The pretty-printed expression.
-
print
- Parameters:
expression- An expression.labels- Resolves the label of a variable id, may return null.- Returns:
- The pretty-printed expression, without known reference types.
-
print
- Parameters:
expression- An expression.- Returns:
- The pretty-printed expression without labels.
-
printExact
public static String printExact(Expression expression, ValueDeseralizationContext values, IntFunction<String> labels, Function<String, it.unimi.dsi.fastutil.ints.IntList> labelIds, IntFunction<IValueType<?>> refTypes) Print the given expression in the text form thatExpressionParserreads back into the same expression. In contrast toprint(Expression, IntFunction, IntFunction), values are not shortened, parameters are written with their types, and references only use a label if that label leads back to them.- Parameters:
expression- An expression.values- For serializing values that are written with their type, such as items.labels- Resolves the label of a variable id, may return null.labelIds- Resolves the ids of the variables with a label.refTypes- Resolves the type of a variable id, may return null when unknown.- Returns:
- The text.
-
tokenizeExact
public static List<ExpressionPrinter.Token> tokenizeExact(Expression expression, ValueDeseralizationContext values, IntFunction<String> labels, Function<String, it.unimi.dsi.fastutil.ints.IntList> labelIds, ExpressionTypeChecker.Result types) The text ofprintExact(Expression, ValueDeseralizationContext, IntFunction, Function, IntFunction)as tokens, which tell what node each part of the text belongs to.- Parameters:
expression- An expression.values- For serializing values that are written with their type, such as items.labels- Resolves the label of a variable id, may return null.labelIds- Resolves the ids of the variables with a label.types- The type checking result of the expression.- Returns:
- The tokens.
-
printLiteral
- Parameters:
value- A value.values- For serializing values that are written with their type.- Returns:
- The value in the text form, which
ExpressionParserreads back into the same value.
-
quote
-
printNode
public static String printNode(Expression expression, int[] path, IntFunction<String> labels, ExpressionTypeChecker.Result types) - Parameters:
expression- The expression that contains the node.path- The path of a node.labels- Resolves the label of a variable id, may return null.types- The type checking result of the expression.- Returns:
- The pretty-printed node, without the parameter list.
-
tokenize
public static List<ExpressionPrinter.Token> tokenize(Expression expression, IntFunction<String> labels, ExpressionTypeChecker.Result types) Pretty-print the given expression as a list of tokens.- Parameters:
expression- An expression.labels- Resolves the label of a variable id, may return null.types- The type checking result of the expression.- Returns:
- The tokens.
-
printValue
-
printOperatorValue
-
printRef
-