pxb1988 / dex2jar

Tools to work with android .dex and java .class files
Apache License 2.0
12.21k stars 2.1k forks source link

d2j-smali : no viable alternative at input ':' #16

Open sealinglip opened 9 years ago

sealinglip commented 9 years ago

If a field is named as some special word, e.g. 'constructor', as the following shows

.field private final constructor:Lcom/google/mygson/internal/ObjectConstructor;

The small parser would complain as the title shows.

I think there should be some bug in the ANTLR rule 'sField', and perhaps other rules quote rule 'sAccList' are also the same.

sField : '.field' acc=sAccList (f=sFieldF|f=sFieldP) ('=' v=sFieldValue)? (sAnnotation* '.end field')? ;

As in the above-mentioned case, the token 'constructor' will be matched as a ACC because rule 'sAccList' is greedy and it will not go into the following rule to be matched as a field name.

I'm a newbie to ANTLR. It seems Apktool use the same rule to parse a field declaration, but it's surprising it works fine. And I also tried to change rule 'sAccList' into a nongreedy rule, but I failed.

I'm sorry I'm also a newbie to Github and I even don't know how to highlight the code snippet. I hope the information above could help you!

pxb1988 commented 9 years ago

yes, seams dex2jar is buggy on the 'constructor' var.

the different between dex2jar and smali is that the token sequence is different

the constructor token is greedy eat by sAccList

ClockerZadq commented 7 years ago

The problem I'm seeing is referenced [here] (https://github.com/JesusFreke/smali/issues/251) and I get that its not relevant to this but this tool and the ApkTool seem to be in disagreement.

I'm seeing this issue come up when using the ApkTool lib when attempting to re-build an APK. I'm using this tool to convert from dex to smali .The variable names in my source that are throwing the errors are: "views", "intent", "pending"... Will renaming my variables solve this issue?