improve explain bits to be usable
This commit is contained in:
1 parent
7087fa8510
commit
1928b4f866
4 files changed
+46
-14
No files matched your search
@@ -1535,22 +1535,31 @@ public class Expression
|
||||
}
|
||||
}
|
||||
|
||||
public List<Token> explain(Context context)
|
||||
public List<Token> explain(Context context, @Nullable String method, @Nullable String style)
|
||||
{
|
||||
//todo convert to explain
|
||||
Tokenizer tokenizer = new Tokenizer(context, this, expression, true, true);
|
||||
// stripping lousy but acceptable semicolons
|
||||
List<Token> input = tokenizer.parseTokens();
|
||||
if (style.equalsIgnoreCase("raw")) {
|
||||
return input;
|
||||
}
|
||||
List<Token> cleanedTokens = Tokenizer.postProcess(input);
|
||||
if (style.equalsIgnoreCase("clean")) {
|
||||
return cleanedTokens;
|
||||
}
|
||||
|
||||
List<Token> rpn = shuntingYard(context, cleanedTokens);
|
||||
validate(context, rpn);
|
||||
ExpressionNode root = RPNToParseTree(rpn, context);
|
||||
List<Token> parsedTokens = root.tokensRecursive(this);
|
||||
if (style.equalsIgnoreCase("canonical")) {
|
||||
return parsedTokens;
|
||||
}
|
||||
|
||||
Context optimizeOnlyContext = new Context.ContextForErrorReporting(context);
|
||||
// pure functional
|
||||
optimizeTree(root, optimizeOnlyContext, null, true);
|
||||
optimizeTree(root, optimizeOnlyContext, null, style.equalsIgnoreCase("functional"));
|
||||
List<Token> compileTimeOptimized = root.tokensRecursive(this);
|
||||
|
||||
return compileTimeOptimized;
|
||||
|
||||
Reference in new issue
Block a user