diff --git a/smalidea/src/main/antlr3/smalideaParser.g b/smalidea/src/main/antlr3/smalideaParser.g index d22288d1..b2690cfe 100644 --- a/smalidea/src/main/antlr3/smalideaParser.g +++ b/smalidea/src/main/antlr3/smalideaParser.g @@ -1342,7 +1342,15 @@ packed_switch_element insn_sparse_switch_directive : SPARSE_SWITCH_DIRECTIVE sparse_switch_element* - END_SPARSE_SWITCH_DIRECTIVE; + end_sparse_switch_directive; + +end_sparse_switch_directive + : END_SPARSE_SWITCH_DIRECTIVE; + catch [RecognitionException re] { + Marker errorMarker = mark(); + recover(input, re); + reportError(errorMarker, re, false); + } sparse_switch_element @init { Marker marker = mark(); } diff --git a/smalidea/testData/InvalidInstruction.smalidea b/smalidea/testData/InvalidInstruction.smalidea index 44c52f02..0960b886 100644 --- a/smalidea/testData/InvalidInstruction.smalidea +++ b/smalidea/testData/InvalidInstruction.smalidea @@ -20,4 +20,12 @@ invoke-virtual {v1, v2} .blah Lblah;->blah()V :blah :blah2 .blah +.end method + +.method blah5()V + .sparse-switch + 1 -> :blah + 3 -> :blah2 + 5 -> :blah3 + .blah .end method \ No newline at end of file diff --git a/smalidea/testData/InvalidInstruction.txt b/smalidea/testData/InvalidInstruction.txt index dd4696ec..76502573 100644 --- a/smalidea/testData/InvalidInstruction.txt +++ b/smalidea/testData/InvalidInstruction.txt @@ -178,4 +178,59 @@ smali.FILE PsiErrorElement:mismatched input '.blah' expecting END_PACKED_SWITCH_DIRECTIVE PsiElement(BAD_CHARACTER)('.blah') PsiWhiteSpace('\n') + PsiElement(END_METHOD_DIRECTIVE)('.end method') + PsiWhiteSpace('\n\n') + SmaliMethod(METHOD) + SmaliThrowsList(THROWS_LIST) + + PsiElement(METHOD_DIRECTIVE)('.method') + PsiWhiteSpace(' ') + SmaliModifierList(MODIFIER_LIST) + + PsiElement(MEMBER_NAME) + PsiElement(SIMPLE_NAME)('blah5') + SmaliMethodPrototype(METHOD_PROTOTYPE) + PsiElement(OPEN_PAREN)('(') + SmaliMethodParamList(METHOD_PARAM_LIST) + + PsiElement(CLOSE_PAREN)(')') + PsiElement(VOID_TYPE) + PsiElement(VOID_TYPE)('V') + PsiWhiteSpace('\n ') + PsiElement(INSTRUCTION) + PsiElement(SPARSE_SWITCH_DIRECTIVE)('.sparse-switch') + PsiWhiteSpace('\n ') + PsiElement(SPARSE_SWITCH_ELEMENT) + PsiElement(LITERAL) + PsiElement(POSITIVE_INTEGER_LITERAL)('1') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(LABEL_REFERENCE) + PsiElement(COLON)(':') + PsiElement(SIMPLE_NAME)('blah') + PsiWhiteSpace('\n ') + PsiElement(SPARSE_SWITCH_ELEMENT) + PsiElement(LITERAL) + PsiElement(POSITIVE_INTEGER_LITERAL)('3') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(LABEL_REFERENCE) + PsiElement(COLON)(':') + PsiElement(SIMPLE_NAME)('blah2') + PsiWhiteSpace('\n ') + PsiElement(SPARSE_SWITCH_ELEMENT) + PsiElement(LITERAL) + PsiElement(POSITIVE_INTEGER_LITERAL)('5') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(LABEL_REFERENCE) + PsiElement(COLON)(':') + PsiElement(SIMPLE_NAME)('blah3') + PsiWhiteSpace('\n ') + PsiErrorElement:mismatched input '.blah' expecting END_SPARSE_SWITCH_DIRECTIVE + PsiElement(BAD_CHARACTER)('.blah') + PsiWhiteSpace('\n') PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file