Improve error handling for literal parsing

This commit is contained in:
Ben Gruver 2015-02-21 14:02:12 -08:00
parent 251d6073b9
commit 4640cc9c5b
3 changed files with 46 additions and 0 deletions

View File

@ -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 {

View File

@ -6,4 +6,8 @@
.annotation runtime Lblah;
blah .blah .blah
.end annotation
.annotation runtime Lblah;
blah = .blah .blah
.end annotation

View File

@ -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')