Search in sources :

Example 6 with IUnifier

use of mb.nabl2.terms.unification.IUnifier in project nabl by metaborg.

the class TermMultiset method add.

public void add(ITerm term, int n, IUnifier unifier) {
    final ITerm rep = unifier.findRecursive(term);
    for (ITermVar var : rep.getVars().elementSet()) {
        varTerms.put(var, rep);
    }
    terms.add(rep, n);
}
Also used : ITermVar(mb.nabl2.terms.ITermVar) ITerm(mb.nabl2.terms.ITerm)

Example 7 with IUnifier

use of mb.nabl2.terms.unification.IUnifier in project nabl by metaborg.

the class VarMultiset method add.

public boolean add(ITermVar var, int n, IUnifier unifier) {
    final Multiset<ITermVar> reps = unifier.findRecursive(var).getVars();
    boolean change = false;
    for (ITermVar rep : reps) {
        vars.add(rep, n);
        change |= n > 0;
    }
    return change;
}
Also used : ITermVar(mb.nabl2.terms.ITermVar)

Example 8 with IUnifier

use of mb.nabl2.terms.unification.IUnifier in project nabl by metaborg.

the class VarMultiset method count.

public int count(ITermVar var, IUnifier unifier) {
    final Multiset<ITermVar> reps = unifier.findRecursive(var).getVars();
    int n = 0;
    for (ITermVar rep : reps.elementSet()) {
        n += vars.count(rep);
    }
    return n;
}
Also used : ITermVar(mb.nabl2.terms.ITermVar)

Example 9 with IUnifier

use of mb.nabl2.terms.unification.IUnifier in project nabl by metaborg.

the class TermMultiset method remove.

public int remove(ITerm term, int n, IUnifier unifier) {
    final ITerm rep = unifier.findRecursive(term);
    final int prev_n = terms.remove(rep, n);
    if (prev_n <= n) {
        varTerms.values().remove(rep);
    }
    return Math.min(prev_n, n);
}
Also used : ITerm(mb.nabl2.terms.ITerm)

Example 10 with IUnifier

use of mb.nabl2.terms.unification.IUnifier in project nabl by metaborg.

the class VarMultiset method remove.

public boolean remove(ITermVar var, int n, IUnifier unifier) {
    final Multiset<ITermVar> reps = unifier.findRecursive(var).getVars();
    boolean change = false;
    for (ITermVar rep : reps) {
        int prev_n = vars.remove(rep, n);
        change |= prev_n > 0 && n > 0;
    }
    return change;
}
Also used : ITermVar(mb.nabl2.terms.ITermVar)

Aggregations

ITermVar (mb.nabl2.terms.ITermVar)8 ITerm (mb.nabl2.terms.ITerm)4 HashMultimap (com.google.common.collect.HashMultimap)1 HashMultiset (com.google.common.collect.HashMultiset)1 Multimap (com.google.common.collect.Multimap)1 Multiset (com.google.common.collect.Multiset)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 TermOrigin (mb.nabl2.stratego.TermOrigin)1 IUnifier (mb.nabl2.terms.unification.IUnifier)1 FileObject (org.apache.commons.vfs2.FileObject)1 ISourceRegion (org.metaborg.core.source.ISourceRegion)1