110 likes | 190 Views
Grammar Refactoring. December 13 th , 2013 Erik Fredericks. Overview. Nodal Recursion Grammar refactoring. Nodal Recursion. Recall issue with standard BNF recursion in EpochX d ecl_list : decl | decl_list decl. …. Nodal Recursion.
E N D
Grammar Refactoring December 13th, 2013 Erik Fredericks
Overview • Nodal Recursion • Grammar refactoring
Nodal Recursion • Recall issue with standard BNF recursion in EpochX • decl_list : decl • | decl_listdecl …
Nodal Recursion • Each node in EpochX has a set amount of allowable children • Nodes with multiple arities handled with “SEQ2,” “SEQ3,” “SEQ4” … • No “SEQN” SEQ3
Nodal Recursion • Extended EpochX framework to accept any number of child nodes at time of node creation • On a node-by-node basis • COMPOSITION root node can accept an n-amount of child nodes • INT2CHAR can only accept a single child node
Refactored Grammar • New flexibility allows standard recursion as defined in BNF grammar • E.g. <xform1>, <xform2>, <xform3>,… • With this in mind, we re-examined the grammar
Refactored Grammar • New top-level approach • Instead of defining pre- and post-conditions in the grammar… • WRAPPER : input_xform, input_xform, target, output_xform • Pre- and post-conditions are now fully defined outside of the grammar • Previously used outside as part of fitness evaluation • Lessens burden on developer using this approach
Refactored Grammar composition : statements ; statements : statements, statement | statement ; statement : transform | operation | module_invocation ; …
Condition Scanning • Previously, available variables (pre-conditions) defined outside of grammar and dynamically inserted into a single <var> production • Prior to evolution • var : numbers-in | bubbleSort … ;
Condition Scanning • Variables now given extra information in production rules • Removes ability for invalid transforms to form var : int | float_array | void_array | target_method; int : size; float_array : numbers-in; void_array : numbers-out; target_method : bubbleSort; • Other data types point to root of transforms
New Intermediate Example • Convert 2D to 1D array for passing into sorting method • Two possible methods • FLATTEN array • Use FOREACH loop and COPY • Current status • Rewarding invocation of target module with 2D array as input parameter • Always converges to solution [baseline test] • COMPOSITION(MODULE(bubble_sort,numbers_2D_array))