diff --git a/smalidea/src/main/antlr3/smalideaParser.g b/smalidea/src/main/antlr3/smalideaParser.g index 38690da9..0483f3e3 100644 --- a/smalidea/src/main/antlr3/smalideaParser.g +++ b/smalidea/src/main/antlr3/smalideaParser.g @@ -690,6 +690,11 @@ literal | subannotation | type_field_method_literal | enum_literal; + catch [RecognitionException re] { + Marker errorMarker = mark(); + recover(input, re); + reportError(errorMarker, re, false); + } integral_literal : long_literal @@ -697,6 +702,11 @@ integral_literal | short_literal | char_literal | byte_literal; + catch [RecognitionException re] { + Marker errorMarker = mark(); + recover(input, re); + reportError(errorMarker, re, false); + } fixed_32bit_literal : long_literal @@ -706,6 +716,11 @@ fixed_32bit_literal | float_literal | char_literal | bool_literal; + catch [RecognitionException re] { + Marker errorMarker = mark(); + recover(input, re); + reportError(errorMarker, re, false); + } fixed_literal : integer_literal @@ -716,6 +731,11 @@ fixed_literal | double_literal | char_literal | bool_literal; + catch [RecognitionException re] { + Marker errorMarker = mark(); + recover(input, re); + reportError(errorMarker, re, false); + } annotation_element @init { diff --git a/smalidea/testData/InvalidAnnotation.smalidea b/smalidea/testData/InvalidAnnotation.smalidea index 4c174e9b..c9ea7be6 100644 --- a/smalidea/testData/InvalidAnnotation.smalidea +++ b/smalidea/testData/InvalidAnnotation.smalidea @@ -6,4 +6,8 @@ .annotation runtime Lblah; blah .blah .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 b1764de2..56290d71 100644 --- a/smalidea/testData/InvalidAnnotation.txt +++ b/smalidea/testData/InvalidAnnotation.txt @@ -47,4 +47,26 @@ smali.FILE PsiWhiteSpace(' ') PsiElement(BAD_CHARACTER)('.blah') PsiWhiteSpace('\n') + 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(' ') + PsiElement(EQUAL)('=') + PsiWhiteSpace(' ') + PsiErrorElement:no viable alternative at input '.blah' + PsiElement(BAD_CHARACTER)('.blah') + PsiWhiteSpace(' ') + PsiElement(BAD_CHARACTER)('.blah') + PsiWhiteSpace('\n') PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') \ No newline at end of file