diff --git a/smalidea/src/main/antlr3/smalideaParser.g b/smalidea/src/main/antlr3/smalideaParser.g index 97b66d43..38690da9 100644 --- a/smalidea/src/main/antlr3/smalideaParser.g +++ b/smalidea/src/main/antlr3/smalideaParser.g @@ -723,13 +723,21 @@ annotation_element Marker nameMarker = null; } : { nameMarker = mark(); } simple_name { nameMarker.done(SmaliElementTypes.ANNOTATION_ELEMENT_NAME); } - EQUAL literal + equal literal { marker.done(SmaliElementTypes.ANNOTATION_ELEMENT); }; catch [RecognitionException re] { recover(input, re); reportError(marker, re, false); } +equal + : EQUAL; + catch [RecognitionException re] { + Marker errorMarker = mark(); + recover(input, re); + reportError(errorMarker, re, false); + } + annotation @init { Marker marker = mark(); diff --git a/smalidea/testData/InvalidAnnotation.smalidea b/smalidea/testData/InvalidAnnotation.smalidea index f508be54..4c174e9b 100644 --- a/smalidea/testData/InvalidAnnotation.smalidea +++ b/smalidea/testData/InvalidAnnotation.smalidea @@ -4,3 +4,6 @@ .annotation runtime .blah .end annotation +.annotation runtime Lblah; + blah .blah .blah +.end annotation \ No newline at end of file diff --git a/smalidea/testData/InvalidAnnotation.txt b/smalidea/testData/InvalidAnnotation.txt index aa918b2d..b1764de2 100644 --- a/smalidea/testData/InvalidAnnotation.txt +++ b/smalidea/testData/InvalidAnnotation.txt @@ -27,4 +27,24 @@ smali.FILE PsiWhiteSpace('\n') PsiElement(ANNOTATION_PARAMETER_LIST) + PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') + PsiWhiteSpace('\n\n') + SmaliAnnotation(ANNOTATION) + PsiElement(ANNOTATION_DIRECTIVE)('.annotation') + PsiWhiteSpace(' ') + PsiElement(ANNOTATION_VISIBILITY)('runtime') + PsiWhiteSpace(' ') + PsiElement(CLASS_TYPE) + PsiElement(CLASS_DESCRIPTOR)('Lblah;') + PsiWhiteSpace('\n ') + PsiElement(ANNOTATION_PARAMETER_LIST) + PsiElement(ANNOTATION_ELEMENT) + PsiElement(ANNOTATION_ELEMENT_NAME) + PsiElement(SIMPLE_NAME)('blah') + PsiWhiteSpace(' ') + PsiErrorElement:mismatched input '.blah' expecting EQUAL + PsiElement(BAD_CHARACTER)('.blah') + PsiWhiteSpace(' ') + PsiElement(BAD_CHARACTER)('.blah') + PsiWhiteSpace('\n') PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') \ No newline at end of file