mirror of
https://github.com/revanced/smali.git
synced 2025-06-13 12:37:37 +02:00
Improve the error recovery for the local debug directive
This commit is contained in:
@ -755,6 +755,15 @@ literal
|
|||||||
reportError(errorMarker, re, false);
|
reportError(errorMarker, re, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string_or_null_literal
|
||||||
|
: string_literal
|
||||||
|
| null_literal;
|
||||||
|
catch [RecognitionException re] {
|
||||||
|
Marker errorMarker = mark();
|
||||||
|
recover(input, re);
|
||||||
|
reportError(errorMarker, re, false);
|
||||||
|
}
|
||||||
|
|
||||||
integral_literal
|
integral_literal
|
||||||
: long_literal
|
: long_literal
|
||||||
| integer_literal
|
| integer_literal
|
||||||
@ -770,7 +779,7 @@ integral_literal
|
|||||||
fixed_32bit_literal
|
fixed_32bit_literal
|
||||||
: long_literal
|
: long_literal
|
||||||
| integer_literal
|
| integer_literal
|
||||||
| short_literal
|
| short_literal
|
||||||
| byte_literal
|
| byte_literal
|
||||||
| float_literal
|
| float_literal
|
||||||
| char_literal
|
| char_literal
|
||||||
@ -1003,7 +1012,7 @@ line_directive
|
|||||||
|
|
||||||
local_directive
|
local_directive
|
||||||
@init { Marker marker = mark(); }
|
@init { Marker marker = mark(); }
|
||||||
: LOCAL_DIRECTIVE register (comma (null_literal | string_literal) colon (void_type | nonvoid_type_descriptor)
|
: LOCAL_DIRECTIVE register (comma string_or_null_literal colon type_descriptor
|
||||||
(comma string_literal)? )?
|
(comma string_literal)? )?
|
||||||
{ marker.done(SmaliElementTypes.LOCAL_DEBUG_STATEMENT); };
|
{ marker.done(SmaliElementTypes.LOCAL_DEBUG_STATEMENT); };
|
||||||
catch [RecognitionException re] {
|
catch [RecognitionException re] {
|
||||||
|
@ -53,6 +53,7 @@ public class ParserTest extends LightCodeInsightParsingTestCase {
|
|||||||
public void testInvalidField3() throws Exception { doTest(true); }
|
public void testInvalidField3() throws Exception { doTest(true); }
|
||||||
public void testInvalidField4() throws Exception { doTest(true); }
|
public void testInvalidField4() throws Exception { doTest(true); }
|
||||||
public void testInvalidInstruction() throws Exception { doTest(true); }
|
public void testInvalidInstruction() throws Exception { doTest(true); }
|
||||||
|
public void testInvalidLocal() throws Exception { doTest(true);}
|
||||||
public void testParamListInvalidParameter() throws Exception { doTest(true); }
|
public void testParamListInvalidParameter() throws Exception { doTest(true); }
|
||||||
public void testSuperClassInvalidSyntax() throws Exception { doTest(true); }
|
public void testSuperClassInvalidSyntax() throws Exception { doTest(true); }
|
||||||
public void testSuperClassInvalidSyntax2() throws Exception { doTest(true); }
|
public void testSuperClassInvalidSyntax2() throws Exception { doTest(true); }
|
||||||
|
7
smalidea/testData/InvalidLocal.smalidea
Normal file
7
smalidea/testData/InvalidLocal.smalidea
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.method public blah()V
|
||||||
|
.local v0,
|
||||||
|
.end method
|
||||||
|
|
||||||
|
.method public blah()V
|
||||||
|
.local v0,"":
|
||||||
|
.end method
|
66
smalidea/testData/InvalidLocal.txt
Normal file
66
smalidea/testData/InvalidLocal.txt
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
smali.FILE
|
||||||
|
SmaliClass(CLASS)
|
||||||
|
SmaliExtendsList(EXTENDS_LIST)
|
||||||
|
<empty list>
|
||||||
|
SmaliImplementsList(IMPLEMENTS_LIST)
|
||||||
|
<empty list>
|
||||||
|
SmaliMethod(METHOD)
|
||||||
|
SmaliThrowsList(THROWS_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(METHOD_DIRECTIVE)('.method')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
SmaliModifierList(MODIFIER_LIST)
|
||||||
|
PsiElement(ACCESS_SPEC)('public')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(MEMBER_NAME)
|
||||||
|
PsiElement(SIMPLE_NAME)('blah')
|
||||||
|
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(LOCAL_DEBUG_STATEMENT)
|
||||||
|
PsiElement(LOCAL_DIRECTIVE)('.local')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(REGISTER_REFERENCE)
|
||||||
|
PsiElement(REGISTER)('v0')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiErrorElement:no viable alternative at input '.end method'
|
||||||
|
<empty list>
|
||||||
|
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)
|
||||||
|
PsiElement(ACCESS_SPEC)('public')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(MEMBER_NAME)
|
||||||
|
PsiElement(SIMPLE_NAME)('blah')
|
||||||
|
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(LOCAL_DEBUG_STATEMENT)
|
||||||
|
PsiElement(LOCAL_DIRECTIVE)('.local')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(REGISTER_REFERENCE)
|
||||||
|
PsiElement(REGISTER)('v0')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiElement(LITERAL)
|
||||||
|
PsiElement(STRING_LITERAL)('""')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiErrorElement:no viable alternative at input '.end method'
|
||||||
|
<empty list>
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
PsiElement(END_METHOD_DIRECTIVE)('.end method')
|
Reference in New Issue
Block a user