Java 类org.antlr.runtime.RecognitionException 实例源码

项目:sstable-adaptor    文件:CQLFragmentParser.java   
/**
 * Just call a parser method in {@link CqlParser} - does not do any error handling.
 */
public static <R> R parseAnyUnhandled(CQLParserFunction<R> parserFunction, String input) throws RecognitionException
{
    // Lexer and parser
    ErrorCollector errorCollector = new ErrorCollector(input);
    CharStream stream = new ANTLRStringStream(input);
    CqlLexer lexer = new CqlLexer(stream);
    lexer.addErrorListener(errorCollector);

    TokenStream tokenStream = new CommonTokenStream(lexer);
    CqlParser parser = new CqlParser(tokenStream);
    parser.addErrorListener(errorCollector);

    // Parse the query string to a statement instance
    R r = parserFunction.parse(parser);

    // The errorCollector has queue up any errors that the lexer and parser may have encountered
    // along the way, if necessary, we turn the last error into exceptions here.
    errorCollector.throwFirstSyntaxError();

    return r;
}
项目:sstable-adaptor    文件:ErrorCollector.java   
/**
 * {@inheritDoc}
 */
@Override
public void syntaxError(BaseRecognizer recognizer, String[] tokenNames, RecognitionException e)
{
    String hdr = recognizer.getErrorHeader(e);
    String msg = recognizer.getErrorMessage(e, tokenNames);

    StringBuilder builder = new StringBuilder().append(hdr)
            .append(' ')
            .append(msg);

    if (recognizer instanceof Parser)
        appendQuerySnippet((Parser) recognizer, builder);

    errorMsgs.add(builder.toString());
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__183() throws RecognitionException {
    try {
        int _type = T__183;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:50:8: ( '(' )
        // Cql__.g:50:10: '('
        {
        match('('); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__184() throws RecognitionException {
    try {
        int _type = T__184;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:51:8: ( ')' )
        // Cql__.g:51:10: ')'
        {
        match(')'); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__185() throws RecognitionException {
    try {
        int _type = T__185;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:52:8: ( '+' )
        // Cql__.g:52:10: '+'
        {
        match('+'); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__187() throws RecognitionException {
    try {
        int _type = T__187;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:54:8: ( ',' )
        // Cql__.g:54:10: ','
        {
        match(','); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__188() throws RecognitionException {
    try {
        int _type = T__188;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:55:8: ( '-' )
        // Cql__.g:55:10: '-'
        {
        match('-'); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__190() throws RecognitionException {
    try {
        int _type = T__190;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:57:8: ( '.' )
        // Cql__.g:57:10: '.'
        {
        match('.'); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__191() throws RecognitionException {
    try {
        int _type = T__191;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:58:8: ( ':' )
        // Cql__.g:58:10: ':'
        {
        match(':'); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__196() throws RecognitionException {
    try {
        int _type = T__196;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:63:8: ( '>' )
        // Cql__.g:63:10: '>'
        {
        match('>'); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__197() throws RecognitionException {
    try {
        int _type = T__197;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:64:8: ( '>=' )
        // Cql__.g:64:10: '>='
        {
        match(">="); 

        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__198() throws RecognitionException {
    try {
        int _type = T__198;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:65:8: ( '[' )
        // Cql__.g:65:10: '['
        {
        match('['); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__200() throws RecognitionException {
    try {
        int _type = T__200;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:67:8: ( ']' )
        // Cql__.g:67:10: ']'
        {
        match(']'); 
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:CqlLexer.java   
public final void mT__201() throws RecognitionException {
    try {
        int _type = T__201;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // Cql__.g:68:8: ( 'expr(' )
        // Cql__.g:68:10: 'expr('
        {
        match("expr("); 

        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
        // do for sure before leaving
    }
}
项目:sstable-adaptor    文件:Cql_Parser.java   
public final String keyspaceName() throws RecognitionException {
    String id = null;


    CFName name = new CFName();
    try {
        // Parser.g:1205:5: ( ksName[name] )
        // Parser.g:1205:7: ksName[name]
        {
            pushFollow(FOLLOW_ksName_in_keyspaceName8043);
            ksName(name);
            state._fsp--;

            id = name.getKeyspace();
        }

    }
    catch (RecognitionException re) {
        reportError(re);
        recover(input,re);
    }
    finally {
        // do for sure before leaving
    }
    return id;
}
项目:sstable-adaptor    文件:Cql_Parser.java   
public final Cql_Parser.mbean_return mbean() throws RecognitionException {
    Cql_Parser.mbean_return retval = new Cql_Parser.mbean_return();
    retval.start = input.LT(1);

    try {
        // Parser.g:1605:5: ( STRING_LITERAL )
        // Parser.g:1605:7: STRING_LITERAL
        {
            match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_mbean11972);
        }

        retval.stop = input.LT(-1);

    }
    catch (RecognitionException re) {
        reportError(re);
        recover(input,re);
    }
    finally {
        // do for sure before leaving
    }
    return retval;
}
项目:QDrill    文件:TreeTest.java   
private LogicalExpression parseExpression(String expr) throws RecognitionException, IOException{

    ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
    CommonTokenStream tokens = new CommonTokenStream(lexer);

//    tokens.fill();
//    for(Token t : (List<Token>) tokens.getTokens()){
//      System.out.println(t + "" + t.getType());
//    }
//    tokens.rewind();

    ExprParser parser = new ExprParser(tokens);
    parse_return ret = parser.parse();

    return ret.e;

  }
项目:r8    文件:SmaliBuildTest.java   
@Test
public void buildWithLibrary() throws IOException, RecognitionException {
  // Build simple "Hello, world!" application.
  SmaliBuilder builder = new SmaliBuilder(DEFAULT_CLASS_NAME);
  builder.addMainMethod(
      2,
      "    sget-object         v0, Ljava/lang/System;->out:Ljava/io/PrintStream;",
      "    const-string        v1, \"Hello, world!\"",
      "    invoke-virtual      { v0, v1 }, Ljava/io/PrintStream;->println(Ljava/lang/String;)V",
      "    return-void"
  );

  InternalOptions options = new InternalOptions();
  AndroidApp app = AndroidApp.builder()
      .addDexProgramData(builder.compile())
      .addLibraryFiles(Paths.get(ToolHelper.getDefaultAndroidJar()))
      .build();

  // Java standard library added - java.lang.String is present.
  DexApplication originalApplication = buildApplication(app, options);
  checkJavaLangString(originalApplication, true);

  DexApplication processedApplication = processApplication(originalApplication, options);
  checkJavaLangString(processedApplication, true);
}
项目:DocIT    文件:PrettyPrinting.java   
@Test
public void testPp() throws IOException, RecognitionException {
    Company c = parse(sampleCompany);
    c.cut();
    PpCompany p = new PpCompany();
    p.ppCompany(c,output);
    c = parse(output);
    double total = c.total();       
    assertEquals(399747 / 2.0d, total, 0);
}
项目:alfresco-remote-api    文件:WhereCompiler.java   
/**
 * Returns a message based on the information in the RecognitionException
 * @param exception RecognitionException
 * @return String explaining the error
 */
public static String resolveMessage(RecognitionException exception)
{
    if (exception != null)
    {
        return "Error at char position "+exception.charPositionInLine;
    }

    return ""; //No message
}
项目:DocIT    文件:Main.java   
public static void main(String[] args) throws IOException, RecognitionException {
    String path = args[0];
    String pkg = args[1];
    String stem = args[2];
    FileInputStream stream = new FileInputStream(path + File.separatorChar + stem + ".yapg");
    ANTLRInputStream antlr = new ANTLRInputStream(stream);
    GrammarLexer lexer = new GrammarLexer(antlr);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    GrammarParser parser = new GrammarParser(tokens);
    Grammar g = parser.parseGrammar();
    if (parser.error) throw new RecognitionException();
    Generator.generate(path, pkg, stem, g);
}
项目:atlas    文件:SmaliMod.java   
public static boolean assembleSmaliFile(InputStream is,DexBuilder dexBuilder, boolean verboseErrors,
                                        boolean printTokens, File smaliFile) throws IOException, RecognitionException {

    // copy our filestream into a tmp file, so we don't overwrite
    File tmp = File.createTempFile("BRUT",".bak");
    tmp.deleteOnExit();

    OutputStream os = new FileOutputStream(tmp);
    IOUtils.copy(is, os);
    os.close();

    return assembleSmaliFile(tmp,dexBuilder, verboseErrors, printTokens);
}
项目:DocIT    文件:IOIParser.java   
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
    try {
        org.ioicompanies.lang.ui.contentassist.antlr.internal.InternalIOIParser typedParser = (org.ioicompanies.lang.ui.contentassist.antlr.internal.InternalIOIParser) parser;
        typedParser.entryRuleModel();
        return typedParser.getFollowElements();
    } catch(RecognitionException ex) {
        throw new RuntimeException(ex);
    }       
}
项目:JavaGraph    文件:ParseTreeAdaptor.java   
@Override
public T errorNode(TokenStream input, Token start, Token stop,
        RecognitionException e) {
    T result = this.prototype.newNode();
    result.setErrorNode(start, stop, e);
    return result;
}
项目:alfresco-remote-api    文件:WhereCompiler.java   
public static CommonTree compileWhereClause(String expression) throws RecognitionException {
    //lexer splits input into tokens
    ANTLRStringStream input = new ANTLRStringStream(expression);
    TokenStream tokens = new CommonTokenStream(new WhereClauseLexer(input));

    //parser generates abstract syntax tree
    WhereClauseParser parser = new WhereClauseParser(tokens);
    WhereClauseParser.whereclause_return ret = parser.whereclause();

    //acquire parse result
    CommonTree ast = (CommonTree) ret.getTree();
    if (logger.isDebugEnabled()) print(ast, 0);
    return ast;
}
项目:dremio-oss    文件:BaseTestOperator.java   
public static LogicalExpression toExpr(String expr) throws RecognitionException{
  ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
  CommonTokenStream tokens = new CommonTokenStream(lexer);
  ExprParser parser = new ExprParser(tokens);
  parse_return ret = parser.parse();
  return ret.e;
}
项目:atlas    文件:SmaliDiffUtils.java   
public static Set<String> buildCode(File dexFile, DexDiffInfo info) throws IOException,
        RecognitionException {
    Set<String>classes = new HashSet<>();
    Set<DexBackedClassDef> classDefs = new HashSet<DexBackedClassDef>();
    classDefs.addAll(info.getModifiedClasses());
    classDefs.addAll(info.getAddedClasses());
    DexFileFactory.writeDexFile(dexFile.getAbsolutePath(), new DexFile() {
        @Nonnull
        @Override
        public Set<? extends ClassDef> getClasses() {
            return new AbstractSet<DexBackedClassDef>() {
                @Override
                public Iterator<DexBackedClassDef> iterator() {
                    return classDefs.iterator();
                }

                @Override
                public int size() {
                    return classDefs.size();
                }
            };
        }
    });

    for (ClassDef classDef:classDefs){
        classes.add(classDef.getType());
    }
    return classes;
}
项目:sstable-adaptor    文件:Cql_Parser.java   
public final String basic_unreserved_keyword() throws RecognitionException {
    String str = null;


    Token k=null;

    try {
        // Parser.g:1628:5: (k= ( K_KEYS | K_AS | K_CLUSTERING | K_COMPACT | K_STORAGE | K_TYPE | K_VALUES | K_MAP | K_LIST | K_FILTERING | K_PERMISSION | K_PERMISSIONS | K_KEYSPACES | K_ALL | K_USER | K_USERS | K_ROLE | K_ROLES | K_SUPERUSER | K_NOSUPERUSER | K_LOGIN | K_NOLOGIN | K_OPTIONS | K_PASSWORD | K_EXISTS | K_CUSTOM | K_TRIGGER | K_CONTAINS | K_STATIC | K_FROZEN | K_TUPLE | K_FUNCTION | K_FUNCTIONS | K_AGGREGATE | K_SFUNC | K_STYPE | K_FINALFUNC | K_INITCOND | K_RETURNS | K_LANGUAGE | K_CALLED | K_INPUT | K_LIKE | K_PER | K_PARTITION | K_GROUP ) )
        // Parser.g:1628:7: k= ( K_KEYS | K_AS | K_CLUSTERING | K_COMPACT | K_STORAGE | K_TYPE | K_VALUES | K_MAP | K_LIST | K_FILTERING | K_PERMISSION | K_PERMISSIONS | K_KEYSPACES | K_ALL | K_USER | K_USERS | K_ROLE | K_ROLES | K_SUPERUSER | K_NOSUPERUSER | K_LOGIN | K_NOLOGIN | K_OPTIONS | K_PASSWORD | K_EXISTS | K_CUSTOM | K_TRIGGER | K_CONTAINS | K_STATIC | K_FROZEN | K_TUPLE | K_FUNCTION | K_FUNCTIONS | K_AGGREGATE | K_SFUNC | K_STYPE | K_FINALFUNC | K_INITCOND | K_RETURNS | K_LANGUAGE | K_CALLED | K_INPUT | K_LIKE | K_PER | K_PARTITION | K_GROUP )
        {
            k=input.LT(1);
            if ( (input.LA(1) >= K_AGGREGATE && input.LA(1) <= K_ALL)||input.LA(1)==K_AS||input.LA(1)==K_CALLED||input.LA(1)==K_CLUSTERING||(input.LA(1) >= K_COMPACT && input.LA(1) <= K_CONTAINS)||input.LA(1)==K_CUSTOM||(input.LA(1) >= K_EXISTS && input.LA(1) <= K_FINALFUNC)||input.LA(1)==K_FROZEN||(input.LA(1) >= K_FUNCTION && input.LA(1) <= K_FUNCTIONS)||input.LA(1)==K_GROUP||(input.LA(1) >= K_INITCOND && input.LA(1) <= K_INPUT)||input.LA(1)==K_KEYS||(input.LA(1) >= K_KEYSPACES && input.LA(1) <= K_LIKE)||(input.LA(1) >= K_LIST && input.LA(1) <= K_MAP)||input.LA(1)==K_NOLOGIN||input.LA(1)==K_NOSUPERUSER||input.LA(1)==K_OPTIONS||(input.LA(1) >= K_PARTITION && input.LA(1) <= K_PERMISSIONS)||input.LA(1)==K_RETURNS||(input.LA(1) >= K_ROLE && input.LA(1) <= K_ROLES)||input.LA(1)==K_SFUNC||(input.LA(1) >= K_STATIC && input.LA(1) <= K_SUPERUSER)||input.LA(1)==K_TRIGGER||(input.LA(1) >= K_TUPLE && input.LA(1) <= K_TYPE)||(input.LA(1) >= K_USER && input.LA(1) <= K_USERS)||input.LA(1)==K_VALUES ) {
                input.consume();
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }
            str = (k!=null?k.getText():null);
        }

    }
    catch (RecognitionException re) {
        reportError(re);
        recover(input,re);
    }
    finally {
        // do for sure before leaving
    }
    return str;
}
项目:DocIT    文件:Basics.java   
@Test
public void testCut() throws IOException, RecognitionException {
    Company c = parse(sampleCompany);
    c.cut();
    double total = c.total();       
    assertEquals(399747 / 2.0d, total, 0);
}
项目:atlas    文件:FastBuild.java   
public File dopatch() throws IOException, RecognitionException, CertificateException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableEntryException, PatchException {

        File dexFile = new File(out, "diff.dex");
        if (dexFile.exists() && !dexFile.delete()) {
            throw new RuntimeException("diff.dex can't be removed.");
        }
        File outFile = new File(out, "diff" + SUFFIX);
        if (outFile.exists() && !outFile.delete()) {
            throw new RuntimeException("diff" + SUFFIX + " can't be removed.");
        }
        currentTimeStamp = System.currentTimeMillis();
        File smaliDir = new File(out, "smali");
        if (smaliDir.exists()) {
            FileUtils.cleanDirectory(smaliDir);

        }
        smaliDir.mkdirs();
        classes = SmaliDiffUtils.buildCode(smaliDir, dexFile, dexDiffInfo);
        if (null == classes || classes.size() <= 0) {
            return null;
        }
        if (null != diffFile && null != diffJsonFile) {
            dexDiffInfo.writeToFile(name, diffFile, diffJsonFile);
        }
        DexDiffInfo.release();
        build(outFile, dexFile);
        File file = release(out, dexFile, outFile);
        release();

        return file;

    }
项目:QDrill    文件:ExpressionInterpreterTest.java   
private LogicalExpression parseExpr(String expr) throws RecognitionException {
  final ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
  final CommonTokenStream tokens = new CommonTokenStream(lexer);
  final ExprParser parser = new ExprParser(tokens);
  final ExprParser.parse_return ret = parser.parse();
  return ret.e;
}
项目:atlas    文件:SmaliUtils.java   
/**
 * 将smali文件夹转换为dex文件
 * @param smaliFolder
 * @param outDexFile
 * @return
 */
public static boolean assembleSmaliFile(File smaliFolder,File outDexFile) throws IOException, RecognitionException {
    Collection<File> smaliFiles =  FileUtils.listFiles(smaliFolder, new String[]{"smali"}, true);
    if(null!= smaliFiles && smaliFiles.size() > 0){
        DexBuilder dexBuilder = DexBuilder.makeDexBuilder();
        for(File smaliFile:smaliFiles){
            SmaliMod.assembleSmaliFile(smaliFile, dexBuilder, true, true);
        }
        dexBuilder.writeTo(new FileDataStore(outDexFile));
        return true;
    }else{
        return false;
    }
}
项目:r8    文件:SmaliTestBase.java   
protected DexApplication buildApplication(SmaliBuilder builder, InternalOptions options) {
  try {
    return buildApplication(AndroidApp.fromDexProgramData(builder.compile()), options);
  } catch (IOException | RecognitionException e) {
    throw new RuntimeException(e);
  }
}
项目:gemoc-studio    文件:GExpressionsParser.java   
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
    try {
        org.eclipse.gemoc.gexpressions.xtext.ui.contentassist.antlr.internal.InternalGExpressionsParser typedParser = (org.eclipse.gemoc.gexpressions.xtext.ui.contentassist.antlr.internal.InternalGExpressionsParser) parser;
        typedParser.entryRuleGProgram();
        return typedParser.getFollowElements();
    } catch(RecognitionException ex) {
        throw new RuntimeException(ex);
    }       
}
项目:n4js    文件:AbstractInternalHighlightingAntlrParser.java   
@Override
public void reportError(RecognitionException e) {
    if (state.errorRecovery) {
        return;
    }
    state.syntaxErrors++; // don't count spurious
    state.errorRecovery = true;
}
项目:alfresco-data-model    文件:FTSTest.java   
public void testLexer() throws IOException, RecognitionException
{
    ClassLoader cl = FTSTest.class.getClassLoader();
    InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/search/impl/parsers/fts_test.gunit");

    CharStream input = new ANTLRInputStream(modelStream);

    gUnitExecutor executer = new gUnitExecutor(parse(input), "FTS");

    String result = executer.execTest();
    System.out.print(executer.execTest()); // unit test result

    assertEquals("Failures: " + result, 0, executer.failures.size());
    assertEquals("Invalids " + result, 0, executer.invalids.size());
}
项目:Xtext_Xtend_HTML_Generator    文件:MyDslParser.java   
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
    try {
        InternalMyDslParser typedParser = (InternalMyDslParser) parser;
        typedParser.entryRuleMensamodel();
        return typedParser.getFollowElements();
    } catch(RecognitionException ex) {
        throw new RuntimeException(ex);
    }
}
项目:n4js    文件:InternalHighlightingParser.java   
@Override
public boolean allowASI(final RecognitionException re) {
    if (re instanceof NoViableAltException) {
        final NoViableAltException nvae = (NoViableAltException) re;
        if (asiRecoveredEx != null && re.index == asiRecoveredEx.index
                && nvae.decisionNumber == asiRecoveredEx.decisionNumber) {
            return false;
        }
        asiRecoveredEx = nvae;
    }
    return true;
}
项目:atlas    文件:APatchTool.java   
/**
 *
 *
 * @param newBundleFile
 * @param baseBundleFile
 * @param patchTmpDir
 * @return
 */
private List<File> processBundleFiles(File newBundleFile, File baseBundleFile, File patchTmpDir, File diffFile,
                                      File diffJsonFile) throws PatchException, IOException, RecognitionException {
    String bundleName = FilenameUtils.getBaseName(newBundleFile.getName());

    if (!isModifyBundle(newBundleFile.getName()) || !((ApatchInput)input).onlyIncludeModifyBundle) {
        return null;
    }
    if (null != logger) {
        logger.info("[DiffApatch]" + bundleName);
    }
    final File newBundleUnzipFolder = new File(newBundleFile.getParentFile(), bundleName);
    final File baseBundleUnzipFolder = new File(baseBundleFile.getParentFile(), bundleName);

    if (null != baseBundleFile && baseBundleFile.isFile() && baseBundleFile.exists()) {
        // unzip apk
        ZipUtils.unzip(newBundleFile, newBundleUnzipFolder.getAbsolutePath());
        ZipUtils.unzip(baseBundleFile, baseBundleUnzipFolder.getAbsolutePath());
        // String patchBundleName = getBundleName(newBundleFile.getName());
        String patchBundleName = FilenameUtils.getBaseName(newBundleFile.getName().replace("lib", ""));
        if (null != patchBundleName) {
            patchBundleName = patchBundleName.replace(".", "_");
            List<File> bundlePatchs = createBundleAPatch(newBundleUnzipFolder, baseBundleUnzipFolder, patchTmpDir,
                    patchBundleName, diffFile, diffJsonFile);
            return bundlePatchs;
        } else {
            throw new PatchException("Cannot found bundle:" + newBundleFile.getName() + " in modifyBundleInfos.");
        }

    }
    return null;
}
项目:JavaGraph    文件:CtrlTree.java   
/** Parses a given term, using an existing name space. */
static public CtrlTree parse(Namespace namespace, String term) throws FormatException {
    try {
        CtrlParser parser = createParser(namespace, term);
        CtrlTree result = parser.program()
            .getTree();
        namespace.getErrors()
            .throwException();
        return result;
    } catch (RecognitionException e) {
        throw new FormatException(e);
    }
}