Improve error recovery when missing an .end packed-switch

This commit is contained in:
Ben Gruver 2015-03-06 19:27:46 -08:00
parent da28228d69
commit 3abee993db
3 changed files with 54 additions and 1 deletions

View File

@ -1320,7 +1320,15 @@ insn_packed_switch_directive
: PACKED_SWITCH_DIRECTIVE
fixed_32bit_literal
packed_switch_element*
END_PACKED_SWITCH_DIRECTIVE;
end_packed_switch_directive;
end_packed_switch_directive
: END_PACKED_SWITCH_DIRECTIVE;
catch [RecognitionException re] {
Marker errorMarker = mark();
recover(input, re);
reportError(errorMarker, re, false);
}
packed_switch_element
@init { Marker marker = mark(); }

View File

@ -13,4 +13,11 @@ invoke-virtual {v1, v2} .blah Lblah;->blah()V
1
2
.blah
.end method
.method blah4()V
.packed-switch 1
:blah
:blah2
.blah
.end method

View File

@ -140,4 +140,42 @@ smali.FILE
PsiErrorElement:mismatched input '.blah' expecting END_ARRAY_DATA_DIRECTIVE
PsiElement(BAD_CHARACTER)('.blah')
PsiWhiteSpace('\n')
PsiElement(END_METHOD_DIRECTIVE)('.end method')
PsiWhiteSpace('\n\n')
SmaliMethod(METHOD)
SmaliThrowsList(THROWS_LIST)
<empty list>
PsiElement(METHOD_DIRECTIVE)('.method')
PsiWhiteSpace(' ')
SmaliModifierList(MODIFIER_LIST)
<empty list>
PsiElement(MEMBER_NAME)
PsiElement(SIMPLE_NAME)('blah4')
SmaliMethodPrototype(METHOD_PROTOTYPE)
PsiElement(OPEN_PAREN)('(')
SmaliMethodParamList(METHOD_PARAM_LIST)
<empty list>
PsiElement(CLOSE_PAREN)(')')
PsiElement(VOID_TYPE)
PsiElement(VOID_TYPE)('V')
PsiWhiteSpace('\n ')
PsiElement(INSTRUCTION)
PsiElement(PACKED_SWITCH_DIRECTIVE)('.packed-switch')
PsiWhiteSpace(' ')
PsiElement(LITERAL)
PsiElement(POSITIVE_INTEGER_LITERAL)('1')
PsiWhiteSpace('\n ')
PsiElement(PACKED_SWITCH_ELEMENT)
PsiElement(LABEL_REFERENCE)
PsiElement(COLON)(':')
PsiElement(SIMPLE_NAME)('blah')
PsiWhiteSpace('\n ')
PsiElement(PACKED_SWITCH_ELEMENT)
PsiElement(LABEL_REFERENCE)
PsiElement(COLON)(':')
PsiElement(SIMPLE_NAME)('blah2')
PsiWhiteSpace('\n ')
PsiErrorElement:mismatched input '.blah' expecting END_PACKED_SWITCH_DIRECTIVE
PsiElement(BAD_CHARACTER)('.blah')
PsiWhiteSpace('\n')
PsiElement(END_METHOD_DIRECTIVE)('.end method')