Tutorial: create a new Tree Language using Grammar

Key Concepts

Tree Notation is a notation for human & machine friendly languages that are as simple as possible. Simplicity is measured by the count of the pieces: the fewer pieces to build a language the better. We call languages that use Tree Notation Tree Languages.

A Tree Notation program is a string, a tree, and a spreadsheet all at the same time. You will often work treat your program as all 3, sometimes concurrently.

Grammar is a Tree Language for building other Tree Languages. This tutorial walks you through building a very simple language in Grammar.

Grammar has one main concepts: Parsers. Parsers take a line(s) and handle it according to the definitions you write in your Grammar program. A language is simple a combination of Parsers.

Before you start:

Step 1

Step 2

Step 3

{yourLanguageNameGoesHere}Parser root

Step 4

{yourLanguageNameGoesHere}Parser root description {thisIsALangageToHelpYouDoX}

Step 5

birthdaysParser root description A language for storing your friend's birthdays. friendParser description Store information about a friend. cruxFromId

Step 6

birthdaysParser root description A language for storing your friend's birthdays. inScope friendParser friendParser description Store information about a friend. cruxFromId

Step 7

friend friend friend

Step 8

... friendParser description Store information about a friend. cruxFromId inScope nameParser nameParser

Step 9

friend name friend name ...

Step 10

nameCell highlightScope string ...

Step 11

... nameParser catchAllCellType nameCell

Step 12

friend name Ben Franklin friend name Ada Lovelace

Step 13

birthdaysParser root description A language for storing your friend's birthdays. inScope friendParser catchAllParser errorParser errorParser baseParser errorParser

frieeeend name Ben Franklin

Step 14

That's all for now! Let us know what you need to do next. Of course, we haven't really gotten to the fun stuff yet. Languages get really interesting once you start implementing the "interesting methods", like compile, execute, render, and format.

View source