1 Grammar Refactoring December 13 th, 2013 Erik Fredericks.
-
Upload
donald-parker -
Category
Documents
-
view
214 -
download
0
Transcript of 1 Grammar Refactoring December 13 th, 2013 Erik Fredericks.
1
Grammar RefactoringDecember 13th, 2013Erik Fredericks
2
Overview
• Nodal Recursion• Grammar refactoring
3
Nodal Recursion
• Recall issue with standard BNF recursion in EpochX
• decl_list : decl • | decl_list decl
…
4
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
5
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
6
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
7
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
8
Refactored Grammar
composition : statements ;
statements : statements, statement | statement ;
statement : transform | operation | module_invocation ;…
9
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 … ;
10
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
11
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))