Class TermLanguage


  • public class TermLanguage
    extends Object
    TermLanguage is a simple language for building Terms. It is a superset of JSON. A Term can be a, Atom which is a literal which can be a Number, String, or Symbol or the constants true, false, or null. This results in an AtomicTerm. A term can also be a "functor" applied to a list of arguments that are themselves Terms. This results in a NodeTerm. Nested list Terms are syntaticaly supported by enclosing a list of Terms between "[" and "]". This list is translated to a NodeTerm with a functor of ".list.". The characters "{" and"}" create NodeTerms that are similar to lists but imply no ordering hence we translate to a NodeTerm with a functor of ".bag.". If curlies are used with a functor then we create a special NodeTerm whose distunguised single element is the bag of elements. This list is translated to a NodeTerm with a functor of ".list.". The ":" character is used as a shorthand for denoting attributes where a:b is translated to the NodeTerm ".attr.(a(b)).Finally, ";" is used to build sequences. A run of Terms separated by ";" results in a special NodeTerm with functor ".sequence." Much of our inspiration came from the E-Language's
    Author:
    djl 2009.08.31
    See Also:
    TermL and, Mathematica examples: "a" -> AtomicTerm("a", String) 2 -> AtomicTerm("2",Integer) a -> AtomicTerm("a",Symbol) f(x) -> NodeTerm("f", AtomicTerm("a", Symbol)) the rest of the example translations will use literal Term Language. [1,2,3] -> .list.(1,2,3) {1,3,3} -> .bag.(1,2,3) foo(a:"b" z:[1,2,[3]]) -> foo(.attr.(a(b), .attr.(.list.(1,2,.list.(3))) obj{a:1, b:2} -> obj(.bag.(.attr.(a(1)), .attr.(b(2)) if( f(a), a, else: do(a);do(b);compute(c)) -> if(f(a), a, .attr.(else(.sequence.(do(a),do(b),compute(c))))
    • Constructor Detail

      • TermLanguage

        public TermLanguage()
    • Method Detail

      • tokenTable

        public static TokenTable tokenTable()
        Return an initialized TokenTable for the Term Language.
        Returns:
        a TokenTable for the Term Language