Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit cb07391

Browse files
author
Juanjo Alvarez
committed
Change printAST to debugging method
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
1 parent c9001df commit cb07391

1 file changed

Lines changed: 46 additions & 46 deletions

File tree

native/src/main/java/tech/sourced/babelfish/EclipseCPPParser.java

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -77,61 +77,61 @@ IASTTranslationUnit parseC(String code) {
7777
return parser.parse();
7878
}
7979

80-
void printAST(String code)
80+
void debugPrintAST(String code)
8181
throws Exception {
8282
// TODO: use C or CPP depending on the specified language
8383
TranslationUnit tuWrapper = parseCPP(code);
8484
IASTTranslationUnit translationUnit = tuWrapper.rootNode;
85-
// System.out.println("XXX comments:");
86-
// for (IASTComment comment : translationUnit.getComments()) {
87-
// System.out.print("toStr: ");
88-
// System.out.println(comment.toString());
89-
// System.out.println("location: ");
90-
// System.out.println(getNodeLocationStr(comment));
91-
// System.out.print("parent: ");
92-
// System.out.println(comment.getParent().toString());
93-
// System.out.print("propertyInParent: ");
94-
// System.out.println(comment.getPropertyInParent().toString());
95-
// System.out.print("isBlockComment: ");
96-
// System.out.println(comment.isBlockComment());
97-
// System.out.println("");
98-
// }
99-
100-
System.err.println("XXX Includes:");
85+
System.out.println("===Comments:");
86+
for (IASTComment comment : translationUnit.getComments()) {
87+
System.out.print("toStr: ");
88+
System.out.println(comment.toString());
89+
System.out.println("location: ");
90+
System.out.println(getNodeLocationStr(comment));
91+
System.out.print("parent: ");
92+
System.out.println(comment.getParent().toString());
93+
System.out.print("propertyInParent: ");
94+
System.out.println(comment.getPropertyInParent().toString());
95+
System.out.print("isBlockComment: ");
96+
System.out.println(comment.isBlockComment());
97+
System.out.println("");
98+
}
99+
100+
System.err.println("===Includes:");
101101
IASTPreprocessorIncludeStatement[] includes = translationUnit.getIncludeDirectives();
102102
for (IASTPreprocessorIncludeStatement include : includes) {
103103
System.err.println("include - " + include.getName());
104104
}
105105

106-
// System.out.println("XXX preprocStatements: ");
107-
// IASTPreprocessorStatement[] preprocessorStatements = translationUnit.getAllPreprocessorStatements();
108-
// for (IASTPreprocessorStatement ps : preprocessorStatements){
109-
// System.out.println(ps.toString());
110-
// }
111-
112-
// System.out.println("XXX macroDefinitions: ");
113-
// IASTPreprocessorMacroDefinition[] macroDefinitions = translationUnit.getMacroDefinitions();
114-
// for (IASTPreprocessorMacroDefinition macroDefinition : macroDefinitions){
115-
// System.out.println(macroDefinition);
116-
// if(macroDefinition instanceof IASTPreprocessorFunctionStyleMacroDefinition){
117-
// IASTPreprocessorFunctionStyleMacroDefinition styleDef = (IASTPreprocessorFunctionStyleMacroDefinition) macroDefinition;
118-
//
119-
// IASTFunctionStyleMacroParameter[] macroParameters = styleDef.getParameters();
120-
// for(IASTFunctionStyleMacroParameter mp : macroParameters){
121-
// System.out.println("macro parameter: "+mp.getParameter());
122-
// }
123-
// }
124-
// System.out.println(macroDefinition.getName() );
125-
// System.out.println(macroDefinition.getExpansion());
126-
// }
127-
128-
// System.out.println("XXX macroExpansions: ");
129-
// IASTPreprocessorMacroExpansion[] macroExpansions = translationUnit.getMacroExpansions();
130-
// for(IASTPreprocessorMacroExpansion macroExpansion : macroExpansions){
131-
// System.out.println(macroExpansion.getRawSignature());
132-
// System.out.println(macroExpansion.getMacroReference());
133-
// System.out.println(macroExpansion.getMacroDefinition());
134-
// }
106+
System.out.println("===PreprocStatements: ");
107+
IASTPreprocessorStatement[] preprocessorStatements = translationUnit.getAllPreprocessorStatements();
108+
for (IASTPreprocessorStatement ps : preprocessorStatements){
109+
System.out.println(ps.toString());
110+
}
111+
112+
System.out.println("===MacroDefinitions: ");
113+
IASTPreprocessorMacroDefinition[] macroDefinitions = translationUnit.getMacroDefinitions();
114+
for (IASTPreprocessorMacroDefinition macroDefinition : macroDefinitions){
115+
System.out.println(macroDefinition);
116+
if(macroDefinition instanceof IASTPreprocessorFunctionStyleMacroDefinition){
117+
IASTPreprocessorFunctionStyleMacroDefinition styleDef = (IASTPreprocessorFunctionStyleMacroDefinition) macroDefinition;
118+
119+
IASTFunctionStyleMacroParameter[] macroParameters = styleDef.getParameters();
120+
for(IASTFunctionStyleMacroParameter mp : macroParameters){
121+
System.out.println("macro parameter: "+mp.getParameter());
122+
}
123+
}
124+
System.out.println(macroDefinition.getName() );
125+
System.out.println(macroDefinition.getExpansion());
126+
}
127+
128+
System.out.println("===MacroExpansions: ");
129+
IASTPreprocessorMacroExpansion[] macroExpansions = translationUnit.getMacroExpansions();
130+
for(IASTPreprocessorMacroExpansion macroExpansion : macroExpansions){
131+
System.out.println(macroExpansion.getRawSignature());
132+
System.out.println(macroExpansion.getMacroReference());
133+
System.out.println(macroExpansion.getMacroDefinition());
134+
}
135135
System.out.println("\nAST Tree:");
136136
printTree(translationUnit, 1);
137137

0 commit comments

Comments
 (0)