mirror of
https://github.com/revanced/smali.git
synced 2025-05-04 08:34:25 +02:00
Improve error recovery of colons in various places
This commit is contained in:
parent
16c154b96e
commit
ff7172c68d
@ -296,14 +296,6 @@ field
|
||||
reportError(marker, re, false);
|
||||
}
|
||||
|
||||
colon
|
||||
: COLON;
|
||||
catch [RecognitionException re] {
|
||||
Marker marker = mark();
|
||||
recover(input, re);
|
||||
reportError(marker, re, false);
|
||||
}
|
||||
|
||||
end_field_directive
|
||||
: END_FIELD_DIRECTIVE;
|
||||
|
||||
@ -476,6 +468,14 @@ comma
|
||||
reportError(errorMarker, re, false);
|
||||
}
|
||||
|
||||
colon
|
||||
: COLON;
|
||||
catch [RecognitionException re] {
|
||||
Marker errorMarker = mark();
|
||||
recover(input, re);
|
||||
reportError(errorMarker, re, false);
|
||||
}
|
||||
|
||||
param_list_inner
|
||||
: ((PARAM_LIST_START param* PARAM_LIST_END)
|
||||
| (PARAM_LIST_OR_ID_START param* PARAM_LIST_OR_ID_END)
|
||||
@ -689,7 +689,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);
|
||||
@ -701,7 +701,7 @@ type_field_method_literal
|
||||
@init { Marker marker = mark(); }
|
||||
: ( reference_type_descriptor
|
||||
( arrow
|
||||
( member_name COLON nonvoid_type_descriptor
|
||||
( member_name colon nonvoid_type_descriptor
|
||||
| member_name method_prototype_reference
|
||||
)
|
||||
| /* epsilon */
|
||||
@ -864,7 +864,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);
|
||||
@ -874,7 +874,7 @@ fully_qualified_field
|
||||
// TODO: check missing initial token
|
||||
label
|
||||
@init { Marker marker = mark(); }
|
||||
: COLON simple_name
|
||||
: colon simple_name
|
||||
{ marker.done(SmaliElementTypes.LABEL); };
|
||||
catch [RecognitionException re] {
|
||||
recover(input, re);
|
||||
@ -884,7 +884,7 @@ label
|
||||
// TODO: check missing initial token
|
||||
label_ref
|
||||
@init { Marker marker = mark(); }
|
||||
: COLON simple_name
|
||||
: colon simple_name
|
||||
{ marker.done(SmaliElementTypes.LABEL_REFERENCE); };
|
||||
catch [RecognitionException re] {
|
||||
recover(input, re);
|
||||
@ -971,7 +971,7 @@ line_directive
|
||||
|
||||
local_directive
|
||||
@init { Marker marker = mark(); }
|
||||
: LOCAL_DIRECTIVE register (comma (null_literal | string_literal) COLON (void_type | nonvoid_type_descriptor)
|
||||
: LOCAL_DIRECTIVE register (comma (null_literal | string_literal) colon (void_type | nonvoid_type_descriptor)
|
||||
(comma string_literal)? )?
|
||||
{ marker.done(SmaliElementTypes.LOCAL_DEBUG_STATEMENT); };
|
||||
catch [RecognitionException re] {
|
||||
|
@ -47,6 +47,7 @@ public class ParserTest extends LightCodeInsightParsingTestCase {
|
||||
public void testInvalidClassDirective() throws Exception { doTest(true); }
|
||||
public void testInvalidClassDirective2() throws Exception { doTest(true); }
|
||||
public void testInvalidClassDirective3() throws Exception { doTest(true); }
|
||||
public void testInvalidEnumLiteral() throws Exception { doTest(true); }
|
||||
public void testInvalidField() throws Exception { doTest(true); }
|
||||
public void testInvalidField2() throws Exception { doTest(true); }
|
||||
public void testInvalidField3() throws Exception { doTest(true); }
|
||||
|
1
smalidea/testData/InvalidEnumLiteral.smalidea
Normal file
1
smalidea/testData/InvalidEnumLiteral.smalidea
Normal file
@ -0,0 +1 @@
|
||||
.field public static blah:Ljava/lang/Object; = .enum Lblah;->blah .blah Lblah;
|
36
smalidea/testData/InvalidEnumLiteral.txt
Normal file
36
smalidea/testData/InvalidEnumLiteral.txt
Normal file
@ -0,0 +1,36 @@
|
||||
smali.FILE
|
||||
SmaliClass(CLASS)
|
||||
SmaliExtendsList(EXTENDS_LIST)
|
||||
<empty list>
|
||||
SmaliImplementsList(IMPLEMENTS_LIST)
|
||||
<empty list>
|
||||
SmaliField(FIELD)
|
||||
PsiElement(FIELD_DIRECTIVE)('.field')
|
||||
PsiWhiteSpace(' ')
|
||||
SmaliModifierList(MODIFIER_LIST)
|
||||
PsiElement(ACCESS_SPEC)('public')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(ACCESS_SPEC)('static')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(MEMBER_NAME)
|
||||
PsiElement(SIMPLE_NAME)('blah')
|
||||
PsiElement(COLON)(':')
|
||||
PsiElement(CLASS_TYPE)
|
||||
PsiElement(CLASS_DESCRIPTOR)('Ljava/lang/Object;')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(FIELD_INITIALIZER)
|
||||
PsiElement(EQUAL)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LITERAL)
|
||||
PsiElement(ENUM_DIRECTIVE)('.enum')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(CLASS_TYPE)
|
||||
PsiElement(CLASS_DESCRIPTOR)('Lblah;')
|
||||
PsiElement(ARROW)('->')
|
||||
PsiElement(SIMPLE_NAME)('blah')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:mismatched input '.blah' expecting COLON
|
||||
PsiElement(BAD_CHARACTER)('.blah')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(CLASS_TYPE)
|
||||
PsiElement(CLASS_DESCRIPTOR)('Lblah;')
|
Loading…
x
Reference in New Issue
Block a user