1 / 11

Grammar Refactoring

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.

Download Presentation

Grammar Refactoring

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Grammar Refactoring December 13th, 2013 Erik Fredericks

  2. Overview • Nodal Recursion • Grammar refactoring

  3. Nodal Recursion • Recall issue with standard BNF recursion in EpochX • decl_list : decl • | decl_listdecl …

  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))

More Related