Search in sources :

Example 6 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class SpellChecker method parse.

@Override
public ParseResult parse(RSyntaxDocument doc1, String style) {
    boolean spNow = IdeOptions.theCurrentOptions.getBool(IdeOption.SPELL_CHECK);
    if (spNow != spPrev) {
        spPrev = spNow;
        result.clearNotices();
        return parse(doc1, style);
    }
    spPrev = spNow;
    doc = doc1;
    Element root = doc.getDefaultRootElement();
    int lineCount = root.getElementCount();
    result.clearNotices();
    result.setParsedLines(0, lineCount - 1);
    if (!spNow) {
        return result;
    }
    // try {
    for (Token t : doc) {
        if (t.isComment()) {
            int startOffs = t.getOffset();
            String comment = t.getLexeme();
            Matcher matcher = pattern.matcher(comment);
            while (matcher.find()) {
                String word = matcher.group();
                String word2 = word.toLowerCase().replaceAll("[^a-z ]", "");
                if (word2.length() > 0 && !getWords().contains(word2) && !local.apply(new Unit()).contains(word.replace("`", "").replaceAll("\"", "").replaceAll(".", "").replaceAll(",", "").replaceAll(":", ""))) {
                    spellingError(word, startOffs + matcher.start());
                }
            }
        }
    }
    return result;
}
Also used : Matcher(java.util.regex.Matcher) Element(javax.swing.text.Element) Token(org.fife.ui.rsyntaxtextarea.Token) Unit(catdata.Unit)

Example 7 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class MplDriver method makeEnv.

@SuppressWarnings({ "rawtypes", "unchecked" })
public static Environment<MplObject> makeEnv(@SuppressWarnings("unused") String str, Program<MplExp<String, String>> init) {
    Environment<MplObject> ret = new Environment<>();
    for (String k : init.order) {
        MplExp se = init.exps.get(k);
        try {
            MplObject xxx = (MplObject) se.accept(new Unit(), new MplOps(ret));
            ret.put(k, xxx);
        } catch (Throwable t) {
            t.printStackTrace();
            throw new LineException(t.getLocalizedMessage(), k, "");
        }
    }
    return ret;
}
Also used : MplExp(catdata.mpl.Mpl.MplExp) LineException(catdata.LineException) Environment(catdata.Environment) Unit(catdata.Unit)

Example 8 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class Constraints method triggers.

public <X, Y, Gen, Sk> Collection<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>> triggers(Instance<Ty, En, Sym, Fk, Att, Gen, Sk, X, Y> I, AqlOptions options) {
    Collection<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>> T = new LinkedList<>();
    for (ED<Ty, En, Sym, Fk, Att> ed : eds) {
        Query<Ty, En, Sym, Fk, Att, WHICH, Unit, Void> Q = ed.Q;
        EvalInstance<Ty, En, Sym, Fk, Att, Gen, Sk, WHICH, Unit, Void, X, Y> QI = new EvalInstance<>(Q, I, options);
        outer: for (Row<WHICH, X> e : QI.algebra().en(WHICH.FRONT)) {
            for (Row<WHICH, X> a : QI.algebra().en(WHICH.BACK)) {
                if (QI.algebra().fk(new Unit(), a).equals(e)) {
                    continue outer;
                }
            }
            T.add(new Pair<>(ed, e));
        }
    }
    return T;
}
Also used : Unit(catdata.Unit) LinkedList(java.util.LinkedList) WHICH(catdata.aql.ED.WHICH) Row(catdata.aql.fdm.EvalAlgebra.Row) EvalInstance(catdata.aql.fdm.EvalInstance) Pair(catdata.Pair)

Example 9 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class XOptions method display.

// @Override
@Override
public Pair<JComponent, Function<Unit, Unit>> display() {
    JSplitPane generalsplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    JPanel x_1 = new JPanel(new GridLayout(Options.biggestSize, 1));
    JPanel x_2 = new JPanel(new GridLayout(Options.biggestSize, 1));
    generalsplit.add(x_1);
    generalsplit.add(x_2);
    JCheckBox reorder_joins_box = new JCheckBox("", reorder_joins);
    JLabel reorder_joins_label = new JLabel("Re-order FROM clauses:");
    x_1.add(reorder_joins_label);
    x_2.add(reorder_joins_box);
    JCheckBox fast_amalgams_box = new JCheckBox("", fast_amalgams);
    JLabel fast_amalgams_label = new JLabel("Use fast amalgams on saturated presentations:");
    x_1.add(fast_amalgams_label);
    x_2.add(fast_amalgams_box);
    JCheckBox validate_amalgams_box = new JCheckBox("", validate_amalgams);
    JLabel validate_amalgams_label = new JLabel("Validate amalgams (if validating categories):");
    x_1.add(validate_amalgams_label);
    x_2.add(validate_amalgams_box);
    JCheckBox x_typing_box = new JCheckBox("", x_typing);
    JLabel typing_label = new JLabel("Type check:");
    x_1.add(typing_label);
    x_2.add(x_typing_box);
    JTextField x_path_length_box = new JTextField(Integer.toString(MAX_PATH_LENGTH), 12);
    JLabel x_path_length_label = new JLabel("Max path length:");
    x_2.add(wrap(x_path_length_box));
    x_1.add(x_path_length_label);
    JPanel xArea = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JCheckBox x_cat_box = new JCheckBox("Cat", x_cat);
    JCheckBox x_graph_box = new JCheckBox("Graph", x_graph);
    JCheckBox x_textual_box = new JCheckBox("Text", x_text);
    JCheckBox x_tabular_box = new JCheckBox("Table", x_tables);
    JCheckBox x_adom_box = new JCheckBox("ADom", x_adom);
    JCheckBox x_elem_box = new JCheckBox("Elements", x_elements);
    JCheckBox x_json_box = new JCheckBox("JSON", x_json);
    xArea.add(x_textual_box);
    xArea.add(x_graph_box);
    xArea.add(x_cat_box);
    xArea.add(x_tabular_box);
    xArea.add(x_adom_box);
    xArea.add(x_elem_box);
    xArea.add(x_json_box);
    x_1.add(new JLabel("Viewers:"));
    x_2.add(xArea);
    for (int i = 0; i < Options.biggestSize - size(); i++) {
        x_1.add(new JLabel());
        x_2.add(new JLabel());
    }
    Function<Unit, Unit> fn = (Unit t) -> {
        int mpl = MAX_PATH_LENGTH;
        try {
            try {
                mpl = Integer.parseInt(x_path_length_box.getText());
            } catch (NumberFormatException nfe) {
            }
            if (mpl < 1) {
                mpl = MAX_PATH_LENGTH;
            }
        } catch (NumberFormatException nfe) {
        }
        MAX_PATH_LENGTH = mpl;
        x_adom = x_adom_box.isSelected();
        x_cat = x_cat_box.isSelected();
        x_graph = x_graph_box.isSelected();
        x_tables = x_tabular_box.isSelected();
        x_adom = x_adom_box.isSelected();
        fast_amalgams = fast_amalgams_box.isSelected();
        validate_amalgams = validate_amalgams_box.isSelected();
        reorder_joins = reorder_joins_box.isSelected();
        x_typing = x_typing_box.isSelected();
        x_elements = x_elem_box.isSelected();
        x_json = x_json_box.isSelected();
        return new Unit();
    };
    return new Pair<>(generalsplit, fn);
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) FlowLayout(java.awt.FlowLayout) JLabel(javax.swing.JLabel) JSplitPane(javax.swing.JSplitPane) JTextField(javax.swing.JTextField) Unit(catdata.Unit) Pair(catdata.Pair)

Example 10 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class XProd method subst2.

public static <C> List subst2(String yyy, List<String> eq, Map<String, Triple<C, C, List<C>>> tuple, Set<String> keys, Set xxx) {
    List ret = (List) eq.stream().flatMap(x -> {
        List l = new LinkedList<>();
        if (x.equals("!__Q")) {
            l.add(yyy);
            return l.stream();
        }
        if (tuple.containsKey(x)) {
            l.add(yyy);
            l.add(tuple.get(x).first);
            l.addAll(tuple.get(x).third);
            return l.stream();
        } else if (keys.contains(x)) {
            l.add(x);
            xxx.add(new Unit());
            return l.stream();
        } else {
            l.add(x);
            return l.stream();
        }
    }).collect(Collectors.toList());
    return ret;
}
Also used : List(java.util.List) LinkedList(java.util.LinkedList) Unit(catdata.Unit) LinkedList(java.util.LinkedList)

Aggregations

Unit (catdata.Unit)29 Pair (catdata.Pair)16 LinkedList (java.util.LinkedList)11 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)10 List (java.util.List)9 Map (java.util.Map)8 Set (java.util.Set)8 Chc (catdata.Chc)6 Util (catdata.Util)6 Fn (catdata.fqlpp.cat.FinSet.Fn)6 JPanel (javax.swing.JPanel)6 GridLayout (java.awt.GridLayout)5 LinkedHashMap (java.util.LinkedHashMap)5 Collectors (java.util.stream.Collectors)5 FUNCTION (catdata.fqlpp.FUNCTION)4 CodeTextPanel (catdata.ide.CodeTextPanel)4 Entry (java.util.Map.Entry)4 Triple (catdata.Triple)3 Optional (java.util.Optional)3