Search in sources :

Example 1 with IndexingParser

use of com.yahoo.vespa.indexinglanguage.parser.IndexingParser in project vespa by vespa-engine.

the class ScriptParser method parse.

private static <T extends Expression> T parse(ScriptParserContext config, ParserMethod<T> method) throws ParseException {
    CharStream input = config.getInputStream();
    IndexingParser parser = new IndexingParser(input);
    parser.setAnnotatorConfig(config.getAnnotatorConfig());
    parser.setDefaultFieldName(config.getDefaultFieldName());
    parser.setLinguistics(config.getLinguistcs());
    try {
        return method.call(parser);
    } catch (ParseException e) {
        if (!(input instanceof FastCharStream)) {
            throw e;
        }
        throw new ParseException(((FastCharStream) input).formatException(e.getMessage()));
    } finally {
        if (parser.token != null && parser.token.next != null) {
            input.backup(parser.token.next.image.length());
        }
    }
}
Also used : IndexingParser(com.yahoo.vespa.indexinglanguage.parser.IndexingParser) FastCharStream(com.yahoo.javacc.FastCharStream) ParseException(com.yahoo.vespa.indexinglanguage.parser.ParseException) CharStream(com.yahoo.vespa.indexinglanguage.parser.CharStream) FastCharStream(com.yahoo.javacc.FastCharStream)

Aggregations

FastCharStream (com.yahoo.javacc.FastCharStream)1 CharStream (com.yahoo.vespa.indexinglanguage.parser.CharStream)1 IndexingParser (com.yahoo.vespa.indexinglanguage.parser.IndexingParser)1 ParseException (com.yahoo.vespa.indexinglanguage.parser.ParseException)1