diff --git a/smalidea/src/main/antlr3/smalideaParser.g b/smalidea/src/main/antlr3/smalideaParser.g index e0576569..f0309f2d 100644 --- a/smalidea/src/main/antlr3/smalideaParser.g +++ b/smalidea/src/main/antlr3/smalideaParser.g @@ -650,7 +650,7 @@ array_literal enum_literal @init { Marker marker = mark(); } - : ENUM_DIRECTIVE reference_type_descriptor ARROW simple_name COLON reference_type_descriptor + : ENUM_DIRECTIVE reference_type_descriptor arrow simple_name COLON reference_type_descriptor { marker.done(SmaliElementTypes.LITERAL); }; catch [RecognitionException re] { recover(input, re); @@ -661,7 +661,7 @@ enum_literal type_field_method_literal @init { Marker marker = mark(); } : ( reference_type_descriptor - ( ARROW + ( arrow ( member_name COLON nonvoid_type_descriptor | member_name method_prototype_reference ) @@ -804,10 +804,18 @@ end_annotation_directive reportError(errorMarker, re, false); } +arrow + : ARROW; + catch [RecognitionException re] { + Marker errorMarker = mark(); + recover(input, re); + reportError(errorMarker, re, false); + } + // TODO: check missing initial token fully_qualified_method @init { Marker marker = mark(); } - : reference_type_descriptor ARROW member_name method_prototype_reference + : reference_type_descriptor arrow member_name method_prototype_reference { marker.done(SmaliElementTypes.METHOD_REFERENCE); }; catch [RecognitionException re] { recover(input, re); @@ -817,7 +825,7 @@ fully_qualified_method // TODO: check missing initial token fully_qualified_field @init { Marker marker = mark(); } - : reference_type_descriptor ARROW member_name COLON nonvoid_type_descriptor + : reference_type_descriptor arrow member_name COLON nonvoid_type_descriptor { marker.done(SmaliElementTypes.FIELD_REFERENCE); }; catch [RecognitionException re] { recover(input, re); @@ -1243,7 +1251,7 @@ insn_sparse_switch_directive sparse_switch_element @init { Marker marker = mark(); } - : fixed_32bit_literal ARROW label_ref + : fixed_32bit_literal arrow label_ref { marker.done(SmaliElementTypes.SPARSE_SWITCH_ELEMENT); }; catch [RecognitionException re] { recover(input, re); diff --git a/smalidea/testData/InvalidMethodReference.smalidea b/smalidea/testData/InvalidMethodReference.smalidea index d4789e00..cd47ddab 100644 --- a/smalidea/testData/InvalidMethodReference.smalidea +++ b/smalidea/testData/InvalidMethodReference.smalidea @@ -1,4 +1,9 @@ .method blah()V .registers 1 invoke-virtual {v0}, .blah-> +.end method + +.method blah2()V +.registers 1 +invoke-virtual {v0}, Lblah;.blah .end method \ No newline at end of file diff --git a/smalidea/testData/InvalidMethodReference.txt b/smalidea/testData/InvalidMethodReference.txt index 38932f65..821abef7 100644 --- a/smalidea/testData/InvalidMethodReference.txt +++ b/smalidea/testData/InvalidMethodReference.txt @@ -43,4 +43,46 @@ smali.FILE PsiWhiteSpace('\n') PsiElement(MEMBER_NAME) + 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)('blah2') + SmaliMethodPrototype(METHOD_PROTOTYPE) + PsiElement(OPEN_PAREN)('(') + SmaliMethodParamList(METHOD_PARAM_LIST) + + PsiElement(CLOSE_PAREN)(')') + PsiElement(VOID_TYPE) + PsiElement(VOID_TYPE)('V') + PsiWhiteSpace('\n') + PsiElement(REGISTERS_STATEMENT) + PsiElement(REGISTERS_DIRECTIVE)('.registers') + PsiWhiteSpace(' ') + PsiElement(LITERAL) + PsiElement(POSITIVE_INTEGER_LITERAL)('1') + PsiWhiteSpace('\n') + PsiElement(INSTRUCTION) + PsiElement(INSTRUCTION_FORMAT35c_METHOD)('invoke-virtual') + PsiWhiteSpace(' ') + PsiElement(OPEN_BRACE)('{') + PsiElement(REGISTER_REFERENCE) + PsiElement(REGISTER)('v0') + PsiElement(CLOSE_BRACE)('}') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(METHOD_REFERENCE) + PsiElement(CLASS_TYPE) + PsiElement(CLASS_DESCRIPTOR)('Lblah;') + PsiErrorElement:mismatched input '.blah' expecting ARROW + PsiElement(BAD_CHARACTER)('.blah') + PsiWhiteSpace('\n') + PsiElement(MEMBER_NAME) + PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file