Search in sources :

Example 1 with AtomList

use of org.apache.stanbol.rules.base.api.util.AtomList in project stanbol by apache.

the class RuleParserImpl method unionAtom.

public final RuleAtom unionAtom() throws ParseException {
    AtomList atomList1;
    AtomList atomList2;
    jj_consume_token(UNION);
    jj_consume_token(LPAR);
    atomList1 = atomList();
    jj_consume_token(COMMA);
    atomList2 = atomList();
    jj_consume_token(RPAR);
    {
        if (true)
            return new UnionAtom(atomList1, atomList2);
    }
    throw new Error("Missing return statement in function");
}
Also used : AtomList(org.apache.stanbol.rules.base.api.util.AtomList) UnionAtom(org.apache.stanbol.rules.manager.atoms.UnionAtom)

Example 2 with AtomList

use of org.apache.stanbol.rules.base.api.util.AtomList in project stanbol by apache.

the class RuleParserImpl method atomList.

public final AtomList atomList() throws ParseException {
    AtomList atomList = new AtomList();
    RuleAtom kReSAtom;
    switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
        case SAME:
        case DIFFERENT:
        case LESSTHAN:
        case GREATERTHAN:
        case IS:
        case NEW_IRI:
        case NEW_LITERAL:
        case STARTS_WITH:
        case ENDS_WITH:
        case LET:
        case HAS:
        case VALUES:
        case NOT:
        case UNION:
        case IS_BLANK:
            kReSAtom = atom();
            atomList = atomListRest();
            atomList.addToHead(kReSAtom);
            {
                if (true)
                    return atomList;
            }
            break;
        default:
            jj_la1[2] = jj_gen;
            {
                if (true)
                    return atomList;
            }
    }
    throw new Error("Missing return statement in function");
}
Also used : AtomList(org.apache.stanbol.rules.base.api.util.AtomList) RuleAtom(org.apache.stanbol.rules.base.api.RuleAtom)

Example 3 with AtomList

use of org.apache.stanbol.rules.base.api.util.AtomList in project stanbol by apache.

the class RuleParserImpl method prefix.

public final void prefix() throws ParseException {
    String nsPrefix;
    Object obj;
    Rule rule;
    nsPrefix = getVariable();
    switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
        case EQUAL:
            obj = equality();
            String prefixURI = (String) obj;
            prefixURI = prefixURI.substring(1, prefixURI.length() - 1);
            kb.addPrefix(nsPrefix, prefixURI);
            break;
        case LQUAD:
            obj = rule();
            AtomList[] atoms = (AtomList[]) obj;
            String ruleStorePrefix = kb.getPrefixURI("rmi2");
            ruleStorePrefix = ruleStorePrefix.substring(0, ruleStorePrefix.length());
            if (atoms.length == 1) {
                AtomList body = atoms[0];
                if (body.size() == 1) {
                // FIXME it previously managed SPARQL code injection.
                }
            } else {
                rule = new RuleImpl(new IRI(ruleStorePrefix + nsPrefix), nsPrefix, atoms[0], atoms[1]);
                kb.addRule(rule);
            }
            break;
        default:
            jj_la1[1] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
    }
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) AtomList(org.apache.stanbol.rules.base.api.util.AtomList) RuleImpl(org.apache.stanbol.rules.manager.RuleImpl) Rule(org.apache.stanbol.rules.base.api.Rule)

Example 4 with AtomList

use of org.apache.stanbol.rules.base.api.util.AtomList in project stanbol by apache.

the class RuleParserImpl method atomListRest.

public final AtomList atomListRest() throws ParseException {
    AtomList atomList = new AtomList();
    RuleAtom kReSAtom;
    switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
        case AND:
            jj_consume_token(AND);
            atomList = atomList();
            {
                if (true)
                    return atomList;
            }
            break;
        default:
            jj_la1[3] = jj_gen;
            {
                if (true)
                    return atomList;
            }
    }
    throw new Error("Missing return statement in function");
}
Also used : AtomList(org.apache.stanbol.rules.base.api.util.AtomList) RuleAtom(org.apache.stanbol.rules.base.api.RuleAtom)

Example 5 with AtomList

use of org.apache.stanbol.rules.base.api.util.AtomList in project stanbol by apache.

the class RuleParserImpl method ruleDefinition.

public final AtomList[] ruleDefinition() throws ParseException {
    AtomList body;
    AtomList head;
    Token t;
    body = atomList();
    jj_consume_token(LARROW);
    head = atomList();
    {
        if (true)
            return new AtomList[] { body, head };
    }
    throw new Error("Missing return statement in function");
}
Also used : AtomList(org.apache.stanbol.rules.base.api.util.AtomList)

Aggregations

AtomList (org.apache.stanbol.rules.base.api.util.AtomList)7 RuleAtom (org.apache.stanbol.rules.base.api.RuleAtom)4 UnsupportedTypeForExportException (org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException)2 ClauseEntry (com.hp.hpl.jena.reasoner.rulesys.ClauseEntry)1 ArrayList (java.util.ArrayList)1 IRI (org.apache.clerezza.commons.rdf.IRI)1 SPARQLFunction (org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)1 Rule (org.apache.stanbol.rules.base.api.Rule)1 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)1 SPARQLObject (org.apache.stanbol.rules.base.api.SPARQLObject)1 UnavailableRuleObjectException (org.apache.stanbol.rules.base.api.UnavailableRuleObjectException)1 RuleImpl (org.apache.stanbol.rules.manager.RuleImpl)1 UnionAtom (org.apache.stanbol.rules.manager.atoms.UnionAtom)1