using flex and bison combo or generating parse tree from java bytecode -


i intending generate parse trees java byte codes. typical byte code of following,

public class org.scandroid.testing.invokecallargtest extends org.scandroid.testing.sourcesink{ public org.scandroid.testing.invokecallargtest();   code:    0:   aload_0    1:   invokespecial   #8; //method org/scandroid/testing/sourcesink."<init>":()v    4:   return  public static java.lang.string invokecallargsourcespec();   code:    0:   iconst_1    1:   newarray char    3:   astore_0    4:   aload_0    5:   invokestatic    #16; //method org/scandroid/testing/sourcesink.load:([c)v    8:   new     #20; //class java/lang/string    11:  dup    12:  aload_0    13:  invokespecial   #22; //method java/lang/string."<init>":([c)v    16:  areturn  public static int invokecallargsourcespecint();   code:    0:   iconst_1    1:   newarray char    3:   astore_0    4:   aload_0    5:   invokestatic    #16; //method org/scandroid/testing/sourcesink.load:([c)v    8:   aload_0    9:   arraylength    10:  ireturn  public static void invokecallargsinkspecint(int);   code:    0:   iload_0    1:   invokestatic    #30; //method java/lang/integer.valueof:(i)ljava/lang/integer;    4:   invokestatic    #36; //method org/scandroid/testing/sourcesink.sink:(ljava/lang/object;)v    7:   return  public static void invokecallargsinkspecbiint(int, int);   code:    0:   iload_0    1:   iload_1    2:   iadd    3:   invokestatic    #30; //method java/lang/integer.valueof:(i)ljava/lang/integer;    6:   invokestatic    #36; //method org/scandroid/testing/sourcesink.sink:(ljava/lang/object;)v    9:   return  } 

my goal generate parse tree or abstract syntax tree. planning use flex , bison combo. want know correct approach? , should start scratch or there other tools available dealing creating ast byte code?

the first step of course figure out want ast be. bytecode has less use standard language, because of lack of variables, scoping, unlabeled breaks, , other features conveniently represented ast. can still have tree nodes representing class, methods, instructions, , operands, within each method, code flat.

as actual implementations, don't know of who's created asts out of bytecode manipulation due reasons above. closest, you'll come parsers bytecode assemblers. example, can find grammar assembler here. uses ply python based implementation of lex , yacc, should similar. parse tree designed assist process of assembling classfile, not particular programmatic transformations.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -