andreina-covi/GrammaticalEvolution

Need an example

Opened this issue · 0 comments

If I have the following:

"
 E -> E + T
 T -> T * F
 F -> (E) | char .
"

grammar := GEGrammar new.
grammar
		addNonTerminal: #E
		ofType: RBMessageNode
		andSequence: #( #E #Add #T ).
grammar
		addNonTerminal: #T
		ofType: RBMessageNode
		andSequence: #( #T #Mult #F ).

grammar
		addNonTerminal: #F
		ofType: RBMessageNode
		andSequence: #( #E ).

grammar
		addTerminal: #F
		ofType: RBLiteralNode
		andValues: #( 4 8 21 ).

grammar
		addSelectorTerminal: #Add  withValues: #(#+).
grammar
		addSelectorTerminal: #Mult  withValues: #(#*).

tree := grammar generateNodeOfRule: #E

How can I make the GP produce the tree: 21 + (4 * 8) ?