diff --git a/smali/src/main/java/org/jf/smali/main.java b/smali/src/main/java/org/jf/smali/main.java index 6422525c..dd895a10 100644 --- a/smali/src/main/java/org/jf/smali/main.java +++ b/smali/src/main/java/org/jf/smali/main.java @@ -103,6 +103,7 @@ public class main { boolean fixGoto = true; boolean verboseErrors = false; boolean oldLexer = false; + boolean printTokens = false; String outputDexFile = "out.dex"; String dumpFileName = null; @@ -149,6 +150,9 @@ public class main { case 'L': oldLexer = true; break; + case 'T': + printTokens = true; + break; default: assert false; } @@ -181,7 +185,7 @@ public class main { boolean errors = false; for (File file: filesToProcess) { - if (!assembleSmaliFile(file, dexFile, verboseErrors, oldLexer)) { + if (!assembleSmaliFile(file, dexFile, verboseErrors, oldLexer, printTokens)) { errors = true; } } @@ -257,7 +261,8 @@ public class main { } } - private static boolean assembleSmaliFile(File smaliFile, DexFile dexFile, boolean verboseErrors, boolean oldLexer) + private static boolean assembleSmaliFile(File smaliFile, DexFile dexFile, boolean verboseErrors, boolean oldLexer, + boolean printTokens) throws Exception { CommonTokenStream tokens; @@ -280,6 +285,19 @@ public class main { tokens = new CommonTokenStream((TokenSource)lexer); } + if (printTokens) { + tokens.getTokens(); + + for (int i=0; i