Download presentation
Presentation is loading. Please wait.
Published byElwin Norton Modified over 9 years ago
2
Overview of technical progress Grammar-based implementation
3
Reviewed methods of parsing grammars in C++ Open source frameworks Stream parsing Etc.
4
Preferred Flex and Bison Flex for interpreting the incoming grammar Bison for generating tokens Both are open-source and have available Windows ports Both are standalone executables that can be built into Visual Studio’s custom build rules
5
Began primitive implementation within OpenBEAGLE Continually had issues with run-time errors in customizing examples ▪ Simple conversion of Even Parity example from Boolean to String
6
Looked back to EpochX for inspiration in designing a set of primitives for a grammar Rolled back to version 1.33.3 Custom grammar rules implemented completely differently ▪ Most of all, it “works” ▪ Nodal evaluation easily triggered
7
To continue to make progress, I moved ahead with the EpochX implementation Customized C BNF grammar Composition strategies High-level role assignments to sub-trees
8
Sample output CODE_INJECTION( CHAR 0 () bubbleSort LPARAN RPARAN) ▪ Inject the following code: ▪ char bubbleSort(); BUFFER( FUNCTION_POINTER( CHAR(bubbleSort), numbers, int*)) ▪ Create a function pointer under the ‘Buffer’ role: ▪ char (*sort)(int*) = bubbleSort; ▪ Buffer = sort(numbers);
9
public static final String GRAMMAR_FRAGMENT = " ::= \n" + " ::= | | \n“ + " ::= BUFFER ( )\n + " ::= WRAPPER(,, ) " + "| FUNCTION_POINTER(,, )" + "| CODE_INJECTION( )\n" + " ::= INT( ) | DOUBLE( ) " + "| FLOAT( ) | CHAR( )\n" + " ::= INT0() | DOUBLE0() | FLOAT0() | CHAR0()\n" + " ::= \n" + " ::= LPARAN RPARAN\n" + " ::= ";
10
public static final String GRAMMAR_FRAGMENT = " ::= \n" + " ::= | | \n“ + " ::= BUFFER ( )\n + " ::= WRAPPER(,, ) " + "| FUNCTION_POINTER(,, )" + "| CODE_INJECTION( )\n" + " ::= INT( ) | DOUBLE( ) " + "| FLOAT( ) | CHAR( )\n" + " ::= INT0() | DOUBLE0() | FLOAT0() | CHAR0()\n" + " ::= \n" + " ::= LPARAN RPARAN\n" + " ::= "; High level roles
11
public static final String GRAMMAR_FRAGMENT = " ::= \n" + " ::= | | \n“ + " ::= BUFFER ( )\n + " ::= WRAPPER(,, ) " + "| FUNCTION_POINTER(,, )" + "| CODE_INJECTION( )\n" + " ::= INT( ) | DOUBLE( ) " + "| FLOAT( ) | CHAR( )\n" + " ::= INT0() | DOUBLE0() | FLOAT0() | CHAR0()\n" + " ::= \n" + " ::= LPARAN RPARAN\n" + " ::= "; Strategy definitions
12
public static final String GRAMMAR_FRAGMENT = " ::= \n" + " ::= | | \n“ + " ::= BUFFER ( )\n + " ::= WRAPPER(,, ) " + "| FUNCTION_POINTER(,, )" + "| CODE_INJECTION( )\n" + " ::= INT( ) | DOUBLE( ) " + "| FLOAT( ) | CHAR( )\n" + " ::= INT0() | DOUBLE0() | FLOAT0() | CHAR0()\n" + " ::= \n" + " ::= LPARAN RPARAN\n" + " ::= "; C types (with and without subtree)
13
public static final String GRAMMAR_FRAGMENT = " ::= \n" + " ::= | | \n“ + " ::= BUFFER ( )\n + " ::= WRAPPER(,, ) " + "| FUNCTION_POINTER(,, )" + "| CODE_INJECTION( )\n" + " ::= INT( ) | DOUBLE( ) " + "| FLOAT( ) | CHAR( )\n" + " ::= INT0() | DOUBLE0() | FLOAT0() | CHAR0()\n" + " ::= \n" + " ::= LPARAN RPARAN\n" + " ::= "; Start of C BNF grammar
14
public static final String GRAMMAR_FRAGMENT = " ::= \n" + " ::= | | \n“ + " ::= BUFFER ( )\n + " ::= WRAPPER(,, ) " + "| FUNCTION_POINTER(,, )" + "| CODE_INJECTION( )\n" + " ::= INT( ) | DOUBLE( ) " + "| FLOAT( ) | CHAR( )\n" + " ::= INT0() | DOUBLE0() | FLOAT0() | CHAR0()\n" + " ::= \n" + " ::= LPARAN RPARAN\n" + " ::= "; Terminal nodes (target method, parameters, etc.)
15
Implementation Java classes provided for each non-terminal node that requires evaluation ▪ Strategies ▪ Types ▪ Etc. Tree shape determined by grammar constraints Fitness to be determined by SW-engineering metrics ▪ (e.g. Lines of code, complexity, number of transformations, etc.)
16
Continue grammar implementation C BNF, identify ‘canned transformations’ ▪ Int.toString() could be represented by a known set of C statements Define fitness function Impact of code Fan-in / fan-out Others…
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.