Search in sources :

Example 1 with FPair

use of suite.node.parser.FactorizeResult.FPair in project suite by stupidsing.

the class RecursiveParser method node.

private Node node(FNode fn) {
    if (fn instanceof FTree) {
        FTree ft = (FTree) fn;
        String name = ft.name;
        List<FPair> pairs = ft.pairs;
        FNode fn0 = pairs.get(0).node;
        FNode fn1 = pairs.get(1).node;
        FNode fn2 = pairs.get(2).node;
        if (name.equals("("))
            return node(fn1);
        else if (name.equals("["))
            return Tree.of(TermOp.TUPLE_, Atom.of("[]"), node(fn1));
        else if (name.equals("`"))
            return Tree.of(TermOp.TUPLE_, Atom.of("`"), node(fn1));
        else
            return Tree.of(TermOp.valueOf(name), node(fn0), node(fn2));
    } else
        return terminalParser.parseTerminal(((FTerminal) fn).chars.toString());
}
Also used : FPair(suite.node.parser.FactorizeResult.FPair) FTree(suite.node.parser.FactorizeResult.FTree) FNode(suite.node.parser.FactorizeResult.FNode)

Aggregations

FNode (suite.node.parser.FactorizeResult.FNode)1 FPair (suite.node.parser.FactorizeResult.FPair)1 FTree (suite.node.parser.FactorizeResult.FTree)1