Simplify your code with Tree Notation. This jtree package includes a Tree Notation parser, compiler-compiler, and virtual machine for Tree Languages, as well as sample languages, implemented in TypeScript.


3512253.0.04 months ago4 years agoMinified + gzip package size for jtree in KB


title JTree: Tree Notation SDK for TypeScript & Javascript permalink index

html <img src="https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod"/ height="20" width="153">

section Links


  • Tree Notation Homepageđź”—treenotation.org
  • Tree Notation Sandboxđź”—jtree.treenotation.org/sandbox
  • Tree Language Designerđź”—jtree.treenotation.org/designer
  • Tree Notation FAQđź”—faq.treenotation.org
  • TreeBaseđź”—treebase.treenotation.org
  • TypeScript Libraryđź”—github.com/treenotation/jtree
  • Tree Notation Subredditđź”—reddit.com/r/treenotation
  • Ohayođź”—github.com/treenotation/ohayo A Data Science App Powered By Tree Notation
  • UnitTestsđź”—jtree.treenotation.org/sandbox/test.html
  • PerfTestsđź”—jtree.treenotation.org/sandbox/perfTests.html

question Who is this package built for?

paragraph Jtree is for people who want to design Tree Languages, make Tree editing tools, use TreeBase, or use the Tree Component Web Framework.

paragraph You can think of jtree as similar to the Java Development Kit, except for Tree Notation instead of Java.

question How do I build a new language?

paragraph You can try the checklistđź”—jtree.treenotation.org/languageChecklist.html.

section Grammar Files

paragraph Jtree contains a Tree Language called "Grammar". You can write new Grammar files to define new languages. By creating a grammar file you get a parser, a type checker, syntax highlighting, autocomplete, a compiler, and virtual machine for executing your new language. Jtree also includes a simple web Tree Language Designerđź”—jtree.treenotation.org/designer.

paragraph To make your language do really interesting things, you'll want to write some code to extend your language nodes in another language that you know. Jtree lets you create new languages using just Tree Notation, Tree Notation + TypeScript, or Tree Notation + Javascript. Tree Notation and Tree Languages can be built with any language, however, not just TypeScript and Javascript. We are looking for volunteers to build libraries/sdks in other host languages.

section Using Jtree

paragraph Jtree currently includes around 10 compiled projects (aka "products") and more than a dozen Tree Languages.

subsection jtree base library for npm projects:

code const {jtree} = require("jtree") const tree = new jtree.TreeNode("hello world") console.log(tree.toString())

subsection jtree base library for the browser:


subsection jtree command line tool

code npm install -g jtree jtree help

subsection TreeBase

code npm install -g jtree jtree base

subsection jtree "sandbox" web app for exploring base Tree Notation

code npm install -g jtree jtree kitchen open http://localhost:3333/

subsection jtree "Designer" web app for building new Tree Languages

code npm install -g jtree jtree kitchen open http://localhost:3333/designer

subsection TreeComponentFramework for building web apps

paragraph (directions coming soon)

subsection Sample Languages

paragraph More than 12 example Tree Languages for helping with various tasks

paragraph See the "langs/" folder.

subsection Build Tools

paragraph If you look at the source, you will also see a set of build tools (such as Builder and TypeScriptRewriter). These are currently undocumented and not recommended for external use.

subsection Building all tools and running tests

code jtree build produceAll npm test

section Monorepo

paragraph Jtree is a monorepo. With on average over 1 major version released each month for the past 2.5 years, it would take a lot of overhead to constantly be updating 10+ different repositories and modules every month. Once we're more confident in the theory and best practices, it might make sense to break this repo into independent modules.

paragraph That being said, we despise unnecessary dependencies as much as anyone. If anyone wants to create some automated submodules built from the projects in this monorepo, to allow for consuming of a smaller subset of the code and dependencies in this module, feel free to do so.

section Development Status

paragraph All breaking changes are mentioned in the releaseNotesđź”—./releaseNotes.html. We follow semantic versioning, so breaking changes should not happen if you stay on the same major version.

section Tree Notation Libraries in Other Languages

paragraph If you build a Tree Notation library/SDK in another language, let us know and we'll add a link.

paragraph If you are working on a Tree Notation library in a new host language, feel free to post an issue or ask for help in the reeNotation subredditđź”—reddit.com/r/treenotation.

subsection How to bump versions

code jtree build updateVersion NEW_NUMBER

section Alternatives Considered

paragraph This is the first Tree Notation library in existence, so there were no alternative implementations. Note and Space were predecessors to Tree Notation.

paragraph If a better alternative low level notation to Tree Notation is possible, it has yet to be discovered.

paragraph All that said, the important part of this repo is not the code but the design patterns. Tree Notation is very simple, and you can implement the patterns contained here in your own code without using this library. In fact, that is often the best way to use Tree Notation!

section ❤️ Public Domain ❤️

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.