abstract syntax tree - How to traverse an AST created with clang in Rascal -


i try use rascal compute metrics out of ast created clang out of objective c code. since structure of clang ast differs 1 used in rascal, think needs refactoring or workarounds work it.

one way write parser translate ast. other way use regular expressions recursion. there lot of elements in clang ast , take time write parser or function.

is there less time consuming way traverse clang ast in rascal?

in clang ast introduction small sample of ast

i believe best write code against clang ast api print ast in rascal readable form. use strategy other front-ends well.

i.e. use information in http://clang.llvm.org/docs/ravfrontendaction.html make recursive ast visitor prints things like:

ifstatement(intconstant(1),[])

after can read in ast using valueio: readtextvaluefile(#node, file), or use shellexec library , readtextvaluestring function.

this give representation of ast typed node. if want typed representation, data declarations need generated, in:

data statement = ifstatement(expression cond, list[statement] body);

by way, if has written json or xml exporter clang asts already, king because there libraries rascal directly read in these formats.


Comments

Popular posts from this blog

google app engine - 403 Forbidden POST - Flask WTForms -

Android layout hidden on keyboard show -

Parse xml element into list in Python -