mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 10:54:29 +02:00
Add support for a new -T debugging option that prints out all the tokens
git-svn-id: https://smali.googlecode.com/svn/trunk@759 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
73d1b5d3cb
commit
5922b466bf
@ -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<tokens.size(); i++) {
|
||||
Token token = tokens.get(i);
|
||||
if (token.getChannel() == smaliLexer.HIDDEN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println(smaliParser.tokenNames[token.getType()] + ": " + token.getText());
|
||||
}
|
||||
}
|
||||
|
||||
smaliParser parser = new smaliParser(tokens);
|
||||
parser.setVerboseErrors(verboseErrors);
|
||||
|
||||
@ -382,6 +400,9 @@ public class main {
|
||||
.withDescription("Use the old lexer")
|
||||
.create("L");
|
||||
|
||||
Option printTokensOption = OptionBuilder.withLongOpt("print-tokens")
|
||||
.withDescription("Print the name and text of each token")
|
||||
.create("T");
|
||||
|
||||
basicOptions.addOption(versionOption);
|
||||
basicOptions.addOption(helpOption);
|
||||
@ -393,6 +414,7 @@ public class main {
|
||||
debugOptions.addOption(noFixGotoOption);
|
||||
debugOptions.addOption(verboseErrorsOption);
|
||||
debugOptions.addOption(oldLexerOption);
|
||||
debugOptions.addOption(printTokensOption);
|
||||
|
||||
for (Object option: basicOptions.getOptions()) {
|
||||
options.addOption((Option)option);
|
||||
|
Loading…
x
Reference in New Issue
Block a user