Home      Discussion      Topics      Dictionary      Almanac
Signup       Login
TreeDL

TreeDL

Discussion
Ask a question about 'TreeDL'
Start a new discussion about 'TreeDL'
Answer questions from other users
Full Discussion Forum
 
Encyclopedia
Tree Description Language (TreeDL) is a computer language for description of strictly-typed tree data structures
Tree (data structure)
In computer science, a tree is a widely-used data structure that emulates a hierarchical tree structure with a set of linked nodes.Mathematically, it is an ordered directed tree, more specifically an arborescence: an acyclic connected graph where each node has zero or more children nodes and at...

 and operations on them. The main use of TreeDL is in the development of language-oriented tools (compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

s, translators, etc) for the description of a structure of abstract syntax tree
Abstract syntax tree
In computer science, an abstract syntax tree , or just syntax tree, is a tree representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code. The syntax is 'abstract' in the sense that it...

s.

Tree description can be used as
  • a documentation of interface between parser and other subsystems;
  • a source for generation of data types representing a tree in target programming languages;
  • a source for generation of various support code: visitor
    Visitor pattern
    In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure on which it operates. A practical result of this separation is the ability to add new operations to existing object structures without modifying those...

    s, walkers, factories
    Factory object
    In object-oriented computer programming, a factory is an object for creating other objects. It is an abstraction of a constructor, and can be used to implement various allocation schemes. For example, using this definition, singletons implemented by the singleton pattern are formal factories.A...

    , etc.


TreeDL can be used with any parser generator that allows custom actions during parsing (for example, ANTLR
ANTLR
In computer-based language recognition, ANTLR , or ANother Tool for Language Recognition, is a parser generator that uses LL parsing. ANTLR is the successor to the Purdue Compiler Construction Tool Set , first developed in 1989, and is under active development...

, JavaCC
JavaCC
JavaCC is an open source parser generator and lexical analyzer generator for the Java programming language. JavaCC is similar to yacc in that it generates a parser from a formal grammar written in EBNF notation, except the output is Java source code...

).

Language overview


Tree description lists the node types allowed in a tree. Node types support single inheritance. Node types have children and attributes. Children must be of defined node type. Attributes may be of primitive type (numeric, string, boolean), enum type or node type. Attributes are used to store literals during tree construction and additional information gathered during tree analysis (for example, links between reference and definition, to represent higher-order abstract syntax
Higher-order abstract syntax
In computer science, higher-order abstract syntax is a technique for the representation of abstract syntax trees for languages with variable binders.-Relation to first-order abstract syntax:...

).

Operations over a tree are defined as multimethods. Advantages of this approach are described in the article Treecc: An Aspect-Oriented Approach to Writing Compilers

Tree descriptions support inheritance to allow modularity and reuse of base language tree descriptions for language extensions.

See also

  • ANTLR
    ANTLR
    In computer-based language recognition, ANTLR , or ANother Tool for Language Recognition, is a parser generator that uses LL parsing. ANTLR is the successor to the Purdue Compiler Construction Tool Set , first developed in 1989, and is under active development...

     - parser generator that offers a different approach to tree processing: tree grammars.
  • SableCC
    SableCC
    SableCC is an open source compiler generator in Java. Stable version is licensed under the GNU Lesser General Public License...

     - parser generator that generates strictly-typed abstract syntax tree
    Abstract syntax tree
    In computer science, an abstract syntax tree , or just syntax tree, is a tree representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code. The syntax is 'abstract' in the sense that it...

    s.

External links