Skip navigation links

Package com.singularsys.extensions.rewrite

Allow expression rewriting to be created and applied.

See: Description

Package com.singularsys.extensions.rewrite Description

Allow expression rewriting to be created and applied. Rules must implement RewriteRuleI providing methods boolean test(ASTFunNode node,Node children[]) and Node apply(ASTFunNode node,Node children[]). The set of rewriting rules can be applied using the RewriteVisitor.

For example

Jep jep = new Jep();
jep.setComponent(new DeepCopyVisitor());
jep.setComponent(new TreeUtils());
jep.setComponent(new SimplificationVisitor());
RewriteVisitor ev = new RewriteVisitor();
RewriteRuleI expand = new ExpandBrackets();
ev.add(expand);                 // Add the rule
jep.reinitializeComponents();   // reinitialize Jep
Node node = jep.parse("(a+b)*(c+d)");
Node expanded = ev.rewrite(node,false); // perform the rewriting
Jep 3.5 / Extensions 2.0
See Also:
Rewrite documentation
Skip navigation links

Copyright © 2018 Singular Systems