Search in sources :

Example 1 with TokenMgrError

use of com.yahoo.searchlib.rankingexpression.parser.TokenMgrError in project vespa by vespa-engine.

the class FeatureList method parse.

/**
 * Parses the content of a reader object as a list of feature nodes.
 *
 * @param reader A reader object that contains an feature list.
 * @return A list of those features named in the string.
 * @throws ParseException if the string could not be parsed.
 */
private static List<ReferenceNode> parse(Reader reader) throws ParseException {
    List<ReferenceNode> lst;
    try {
        lst = new RankingExpressionParser(reader).featureList();
    } catch (TokenMgrError e) {
        ParseException t = new ParseException();
        throw (ParseException) t.initCause(e);
    }
    List<ReferenceNode> ret = new ArrayList<ReferenceNode>(lst.size());
    for (Object obj : lst) {
        if (!(obj instanceof ReferenceNode)) {
            throw new IllegalStateException("Feature list contains a " + obj.getClass().getName() + ".");
        }
        ret.add((ReferenceNode) obj);
    }
    return ret;
}
Also used : ReferenceNode(com.yahoo.searchlib.rankingexpression.rule.ReferenceNode) ArrayList(java.util.ArrayList) RankingExpressionParser(com.yahoo.searchlib.rankingexpression.parser.RankingExpressionParser) TokenMgrError(com.yahoo.searchlib.rankingexpression.parser.TokenMgrError) ParseException(com.yahoo.searchlib.rankingexpression.parser.ParseException)

Aggregations

ParseException (com.yahoo.searchlib.rankingexpression.parser.ParseException)1 RankingExpressionParser (com.yahoo.searchlib.rankingexpression.parser.RankingExpressionParser)1 TokenMgrError (com.yahoo.searchlib.rankingexpression.parser.TokenMgrError)1 ReferenceNode (com.yahoo.searchlib.rankingexpression.rule.ReferenceNode)1 ArrayList (java.util.ArrayList)1