aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/shedlang/compiler/treetext/Trees.java
blob: fb7be9e5f921ebc16a99cd8bb0d3fad56b0bc83c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.shedlang.compiler.treetext;

import java.util.Arrays;
import java.util.List;

public class Trees {
    private Trees() {}

    public static Tree treeBool(boolean value) {
        return new TreeIdentifier(value ? "true" : "false");
    }

    public static Tree treeIdentifier(String name) {
        return new TreeIdentifier(name);
    }

    public static Tree treeInt(int value) {
        return new TreeInt(value);
    }

    public static Tree treeList(List<Tree> children) {
        return new TreeList(children);
    }

    public static Tree treeList(Tree... children) {
        return new TreeList(Arrays.asList(children));
    }

    public static Tree treeListIndented(List<Tree> children) {
        return new TreeListIndented(children);
    }

    public static Tree treeListIndented(Tree... children) {
        return new TreeListIndented(Arrays.asList(children));
    }

    public static Tree treeNamed(String name, Tree value) {
        return new TreeNamed(name, value);
    }

    public static Tree treeString(String value) {
        return new TreeString(value);
    }
}