On Feb 28, 2010, at 12:46 PM, Beto Roth wrote:
> The problem I have is how to tell ECJ to build a tree with that
> specific
> structure. When ECJ creates a tree, it puts the terminals on the
> leaves, and
> nonterminals on the remainder nodes. But how can I specify that the
> nodes
> previous to the leaves have to have a comparator?
Norberto, ECJ's set types are good for this. I'm going to presume
from your diagram that you want to have terminals on the left of the
">" or "<" and numbers on the right. It's easy to modify if this is
not the case. Here's what you do:
ATOMIC TYPE 1: numbers
ATOMIC TYPE 2: variables
ATOMIC TYPE 3: comparisons
ATOMIC TYPE 4: logic
SET TYPE 1: booleans = {comparisons, logic}
TREE RETURN TYPE: logic
"&" RETURN TYPE: logic
"&" CHILD TYPES: booleans (that is, either comparisons or logic)
">" etc. RETURN TYPE: comparisons
">" etc. LEFT CHILD TYPE: variables
">" etc. RIGHT CHILD TYPE: numbers
"A" etc. RETURN TYPE: variables
"5" etc. RETURN TYPE: numbers
This sets things up so that "&" nodes can have *either* "<" etc. *or*
"&" nodes as their children. But the tree must have an "&" node as
its root. Furthermore, "<" etc. must have variables as their left
children and numbers as their right children.
Sean
