public static BuilderClassDef parse(String path, InputStream is, DexBuilder dexBuilder) throws UnsupportedEncodingException, RecognitionException { File smaliFile = new File(path); InputStreamReader reader = new InputStreamReader(is, "UTF-8"); LexerErrorInterface lexer = new smaliFlexLexer(reader); ((smaliFlexLexer) lexer).setSourceFile(smaliFile); CommonTokenStream tokens = new CommonTokenStream((TokenSource) lexer); smaliParser parser = new smaliParser(tokens); parser.setApiLevel(DEFAULT_API_LEVEL); smaliParser.smali_file_return result = parser.smali_file(); if ((parser.getNumberOfSyntaxErrors() > 0) || (lexer.getNumberOfSyntaxErrors() > 0)) { throw new RuntimeException("Unable to parse: " + smaliFile); } CommonTree t = result.getTree(); CommonTreeNodeStream treeStream = new CommonTreeNodeStream(t); treeStream.setTokenStream(tokens); smaliTreeWalker dexGen = new smaliTreeWalker(treeStream); dexGen.setVerboseErrors(false); dexGen.setDexBuilder(dexBuilder); BuilderClassDef classDef = (BuilderClassDef) dexGen.smali_file(); if (dexGen.getNumberOfSyntaxErrors() != 0) { throw new RuntimeException("Unable to walk: " + smaliFile); } return classDef; }
I_METHOD72=(CommonTree)match(input,I_METHOD,FOLLOW_I_METHOD_in_method961); match(input, Token.DOWN, null); pushFollow(FOLLOW_method_name_and_prototype_in_method969); method_name_and_prototype69=method_name_and_prototype(); state._fsp--; pushFollow(FOLLOW_access_list_in_method977); access_list68=access_list(); state._fsp--; pushFollow(FOLLOW_registers_directive_in_method1004); registers_directive70=registers_directive(); state._fsp--; pushFollow(FOLLOW_ordered_method_items_in_method1061); ordered_method_items(); state._fsp--; pushFollow(FOLLOW_catches_in_method1069); catches71=catches(); state._fsp--; pushFollow(FOLLOW_parameters_in_method1077); parameters((method_name_and_prototype69!=null?((smaliTreeWalker.method_name_and_prototype_return)method_name_and_prototype69).parameters:null)); state._fsp--; pushFollow(FOLLOW_annotations_in_method1086); annotations73=annotations(); state._fsp--;
match(input,I_ANNOTATIONS,FOLLOW_I_ANNOTATIONS_in_annotations3865); if ( input.LA(1)==Token.DOWN ) { match(input, Token.DOWN, null); pushFollow(FOLLOW_annotation_in_annotations3868); annotation234=annotation(); state._fsp--; match(input, Token.UP, null); reportError(re); recover(input,re);
match(input,I_STATEMENT_ARRAY_DATA,FOLLOW_I_STATEMENT_ARRAY_DATA_in_insn_array_data_directive3366); match(input, Token.DOWN, null); match(input,I_ARRAY_ELEMENT_SIZE,FOLLOW_I_ARRAY_ELEMENT_SIZE_in_insn_array_data_directive3369); match(input, Token.DOWN, null); pushFollow(FOLLOW_short_integral_literal_in_insn_array_data_directive3371); short_integral_literal204=short_integral_literal(); state._fsp--; match(input, Token.UP, null); pushFollow(FOLLOW_array_elements_in_insn_array_data_directive3374); array_elements205=array_elements(); state._fsp--; match(input, Token.UP, null); reportError(re); recover(input,re);
match(input,I_CLASS_DEF,FOLLOW_I_CLASS_DEF_in_smali_file52); match(input, Token.DOWN, null); pushFollow(FOLLOW_header_in_smali_file54); header1=header(); state._fsp--; pushFollow(FOLLOW_methods_in_smali_file56); methods4=methods(); state._fsp--; pushFollow(FOLLOW_fields_in_smali_file58); fields3=fields(); state._fsp--; pushFollow(FOLLOW_annotations_in_smali_file60); annotations2=annotations(); state._fsp--; match(input, Token.UP, null); ex.printStackTrace(System.err); reportError(new SemanticException(input, ex));
public final smaliTreeWalker.class_spec_return class_spec() throws RecognitionException { smaliTreeWalker.class_spec_return retval = new smaliTreeWalker.class_spec_return(); retval.start = input.LT(1); CommonTree CLASS_DESCRIPTOR9=null; int access_list10 =0; try { // smaliTreeWalker.g:190:3: ( CLASS_DESCRIPTOR access_list ) // smaliTreeWalker.g:190:5: CLASS_DESCRIPTOR access_list { CLASS_DESCRIPTOR9=(CommonTree)match(input,CLASS_DESCRIPTOR,FOLLOW_CLASS_DESCRIPTOR_in_class_spec110); pushFollow(FOLLOW_access_list_in_class_spec112); access_list10=access_list(); state._fsp--; retval.type = (CLASS_DESCRIPTOR9!=null?CLASS_DESCRIPTOR9.getText():null); retval.accessFlags = access_list10; } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return retval; } // $ANTLR end "class_spec"
match(input,I_FIELD,FOLLOW_I_FIELD_in_field383); match(input, Token.DOWN, null); SIMPLE_NAME20=(CommonTree)match(input,SIMPLE_NAME,FOLLOW_SIMPLE_NAME_in_field385); pushFollow(FOLLOW_access_list_in_field387); access_list18=access_list(); state._fsp--; match(input,I_FIELD_TYPE,FOLLOW_I_FIELD_TYPE_in_field390); match(input, Token.DOWN, null); pushFollow(FOLLOW_nonvoid_type_descriptor_in_field392); nonvoid_type_descriptor21=nonvoid_type_descriptor(); state._fsp--; match(input, Token.UP, null); pushFollow(FOLLOW_field_initial_value_in_field395); field_initial_value19=field_initial_value(); state._fsp--; pushFollow(FOLLOW_annotations_in_field397); annotations22=annotations(); state._fsp--; match(input, Token.UP, null); reportError(re); recover(input,re);
I_PARAMETER96=(CommonTree)match(input,I_PARAMETER,FOLLOW_I_PARAMETER_in_parameter1539); match(input, Token.DOWN, null); REGISTER95=(CommonTree)match(input,REGISTER,FOLLOW_REGISTER_in_parameter1541); pushFollow(FOLLOW_string_literal_in_parameter1543); string_literal97=string_literal(); state._fsp--; pushFollow(FOLLOW_annotations_in_parameter1546); annotations98=annotations(); state._fsp--; match(input, Token.UP, null); final int registerNumber = parseRegister_short((REGISTER95!=null?REGISTER95.getText():null)); int totalMethodRegisters = method_stack.peek().totalMethodRegisters; int methodParameterRegisters = method_stack.peek().methodParameterRegisters; reportError(re); recover(input,re);
match(input,I_SUBANNOTATION,FOLLOW_I_SUBANNOTATION_in_subannotation3953); match(input, Token.DOWN, null); CLASS_DESCRIPTOR240=(CommonTree)match(input,CLASS_DESCRIPTOR,FOLLOW_CLASS_DESCRIPTOR_in_subannotation3963); pushFollow(FOLLOW_annotation_element_in_subannotation3974); annotation_element239=annotation_element(); state._fsp--; match(input, Token.UP, null); reportError(re); recover(input,re);
match(input,I_FIELD,FOLLOW_I_FIELD_in_field383); match(input, Token.DOWN, null); SIMPLE_NAME20=(CommonTree)match(input,SIMPLE_NAME,FOLLOW_SIMPLE_NAME_in_field385); pushFollow(FOLLOW_access_list_in_field387); access_list18=access_list(); state._fsp--; match(input,I_FIELD_TYPE,FOLLOW_I_FIELD_TYPE_in_field390); match(input, Token.DOWN, null); pushFollow(FOLLOW_nonvoid_type_descriptor_in_field392); nonvoid_type_descriptor21=nonvoid_type_descriptor(); state._fsp--; match(input, Token.UP, null); pushFollow(FOLLOW_field_initial_value_in_field395); field_initial_value19=field_initial_value(); state._fsp--; pushFollow(FOLLOW_annotations_in_field397); annotations22=annotations(); state._fsp--; match(input, Token.UP, null); reportError(re); recover(input,re);
match(input,I_CLASS_DEF,FOLLOW_I_CLASS_DEF_in_smali_file52); match(input, Token.DOWN, null); pushFollow(FOLLOW_header_in_smali_file54); header1=header(); state._fsp--; pushFollow(FOLLOW_methods_in_smali_file56); methods4=methods(); state._fsp--; pushFollow(FOLLOW_fields_in_smali_file58); fields3=fields(); state._fsp--; pushFollow(FOLLOW_annotations_in_smali_file60); annotations2=annotations(); state._fsp--; match(input, Token.UP, null); ex.printStackTrace(System.err); reportError(new SemanticException(input, ex));
I_PARAMETER87=(CommonTree)match(input,I_PARAMETER,FOLLOW_I_PARAMETER_in_parameter1410); match(input, Token.DOWN, null); REGISTER86=(CommonTree)match(input,REGISTER,FOLLOW_REGISTER_in_parameter1412); pushFollow(FOLLOW_string_literal_in_parameter1414); string_literal88=string_literal(); state._fsp--; pushFollow(FOLLOW_annotations_in_parameter1417); annotations89=annotations(); state._fsp--; match(input, Token.UP, null); final int registerNumber = parseRegister_short((REGISTER86!=null?REGISTER86.getText():null)); int totalMethodRegisters = method_stack.peek().totalMethodRegisters; int methodParameterRegisters = method_stack.peek().methodParameterRegisters; reportError(re); recover(input,re);
match(input,I_STATEMENT_ARRAY_DATA,FOLLOW_I_STATEMENT_ARRAY_DATA_in_insn_array_data_directive2979); match(input, Token.DOWN, null); match(input,I_ARRAY_ELEMENT_SIZE,FOLLOW_I_ARRAY_ELEMENT_SIZE_in_insn_array_data_directive2982); match(input, Token.DOWN, null); pushFollow(FOLLOW_short_integral_literal_in_insn_array_data_directive2984); short_integral_literal176=short_integral_literal(); state._fsp--; match(input, Token.UP, null); pushFollow(FOLLOW_array_elements_in_insn_array_data_directive2987); array_elements177=array_elements(); state._fsp--; match(input, Token.UP, null); reportError(re); recover(input,re);
public final smaliTreeWalker.class_spec_return class_spec() throws RecognitionException { smaliTreeWalker.class_spec_return retval = new smaliTreeWalker.class_spec_return(); retval.start = input.LT(1); CommonTree CLASS_DESCRIPTOR9=null; int access_list10 =0; try { // D:\\decomplier_tools\\smali\\smali\\smali\\src\\main\\antlr3\\smaliTreeWalker.g:186:3: ( CLASS_DESCRIPTOR access_list ) // D:\\decomplier_tools\\smali\\smali\\smali\\src\\main\\antlr3\\smaliTreeWalker.g:186:5: CLASS_DESCRIPTOR access_list { CLASS_DESCRIPTOR9=(CommonTree)match(input,CLASS_DESCRIPTOR,FOLLOW_CLASS_DESCRIPTOR_in_class_spec110); pushFollow(FOLLOW_access_list_in_class_spec112); access_list10=access_list(); state._fsp--; retval.type = (CLASS_DESCRIPTOR9!=null?CLASS_DESCRIPTOR9.getText():null); retval.accessFlags = access_list10; } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return retval; } // $ANTLR end "class_spec"
match(input,I_SUBANNOTATION,FOLLOW_I_SUBANNOTATION_in_subannotation3953); match(input, Token.DOWN, null); CLASS_DESCRIPTOR240=(CommonTree)match(input,CLASS_DESCRIPTOR,FOLLOW_CLASS_DESCRIPTOR_in_subannotation3963); pushFollow(FOLLOW_annotation_element_in_subannotation3974); annotation_element239=annotation_element(); state._fsp--; match(input, Token.UP, null); reportError(re); recover(input,re);
treeStream.setTokenStream(tokens); smaliTreeWalker dexGen = new smaliTreeWalker(treeStream); dexGen.setVerboseErrors(verboseErrors); dexGen.setDexBuilder(dexBuilder); dexGen.smali_file(); return dexGen.getNumberOfSyntaxErrors() == 0;
I_METHOD72=(CommonTree)match(input,I_METHOD,FOLLOW_I_METHOD_in_method961); match(input, Token.DOWN, null); pushFollow(FOLLOW_method_name_and_prototype_in_method969); method_name_and_prototype69=method_name_and_prototype(); state._fsp--; pushFollow(FOLLOW_access_list_in_method977); access_list68=access_list(); state._fsp--; pushFollow(FOLLOW_registers_directive_in_method1004); registers_directive70=registers_directive(); state._fsp--; pushFollow(FOLLOW_ordered_method_items_in_method1061); ordered_method_items(); state._fsp--; pushFollow(FOLLOW_catches_in_method1069); catches71=catches(); state._fsp--; pushFollow(FOLLOW_parameters_in_method1077); parameters((method_name_and_prototype69!=null?((smaliTreeWalker.method_name_and_prototype_return)method_name_and_prototype69).parameters:null)); state._fsp--; pushFollow(FOLLOW_annotations_in_method1086); annotations73=annotations(); state._fsp--;
match(input,I_FIELD,FOLLOW_I_FIELD_in_field383); match(input, Token.DOWN, null); SIMPLE_NAME20=(CommonTree)match(input,SIMPLE_NAME,FOLLOW_SIMPLE_NAME_in_field385); pushFollow(FOLLOW_access_list_in_field387); access_list18=access_list(); state._fsp--; match(input,I_FIELD_TYPE,FOLLOW_I_FIELD_TYPE_in_field390); match(input, Token.DOWN, null); pushFollow(FOLLOW_nonvoid_type_descriptor_in_field392); nonvoid_type_descriptor21=nonvoid_type_descriptor(); state._fsp--; match(input, Token.UP, null); pushFollow(FOLLOW_field_initial_value_in_field395); field_initial_value19=field_initial_value(); state._fsp--; pushFollow(FOLLOW_annotations_in_field397); annotations22=annotations(); state._fsp--; match(input, Token.UP, null); reportError(re); recover(input,re);
match(input,I_CLASS_DEF,FOLLOW_I_CLASS_DEF_in_smali_file52); match(input, Token.DOWN, null); pushFollow(FOLLOW_header_in_smali_file54); header1=header(); state._fsp--; pushFollow(FOLLOW_methods_in_smali_file56); methods4=methods(); state._fsp--; pushFollow(FOLLOW_fields_in_smali_file58); fields3=fields(); state._fsp--; pushFollow(FOLLOW_annotations_in_smali_file60); annotations2=annotations(); state._fsp--; match(input, Token.UP, null); ex.printStackTrace(System.err); reportError(new SemanticException(input, ex));
I_PARAMETER96=(CommonTree)match(input,I_PARAMETER,FOLLOW_I_PARAMETER_in_parameter1539); match(input, Token.DOWN, null); REGISTER95=(CommonTree)match(input,REGISTER,FOLLOW_REGISTER_in_parameter1541); pushFollow(FOLLOW_string_literal_in_parameter1543); string_literal97=string_literal(); state._fsp--; pushFollow(FOLLOW_annotations_in_parameter1546); annotations98=annotations(); state._fsp--; match(input, Token.UP, null); final int registerNumber = parseRegister_short((REGISTER95!=null?REGISTER95.getText():null)); int totalMethodRegisters = method_stack.peek().totalMethodRegisters; int methodParameterRegisters = method_stack.peek().methodParameterRegisters; reportError(re); recover(input,re);