TUTORIAL
Below you can find a list of Speagram tutorial files that cover more and more advanced topics. These examples are live files, meaning that you can edit, change and run them when viewing. Normally on first reading you will not try to experiment too much and just read through the file and sometimes press "Run" to see Speagram output. If you decide to experiment with live files and edit them, beware that you might encounter some browser-specific bugs and take a look at formatting rules used in live files. You might as well decide to first download Speagram and run the examples in your console.
- English
Syntax Parser
The first thing we recommend you to look at is the English syntax parser written in Speagram which shows you how to use Speagram as a parser for introduced classes. The parser recognizes whether an input string belongs to one of the classes. The program can recognize sentences like: This boy wants this girl. People have cats. Tom needs some money. You will see that in Speagram specifying a grammar and writing a parser for this grammar is one and the same piece of code. - Parser
of Symbolic Expressions with Symbolic Differentiation
Afterwards we recommend you to take a look at the example where we parse symbolic arithmetic expressions and write routines to simplify and to differentiate them. This example shows you how Speagram can be used to parse structurally complex classes and how to define specialized functions to operate on such complex data. In this example you will learn how Speagram can be used both for advanced parsing and for the transformation of the parsed data. - Shorthand
Notation — Extensible Parser In Action
Suppose that you already have a grammar which recognizes a certain set of objects and a parser which can take a text file and analyze it to perceive those objects in the file. Suppose further that for some reason — while still operating on the same class of objects — you would like to introduce some alternative shorthand notation. In other words, you want to extend the parser to be ready to perceive new ways of denoting the objects of the class described by the original grammar. Speagram allows you to do that once the grammar has been set without the need to come back to the specification of the grammar. - Functional
Programming on top of Speagram
When you already know the presented examples you might want to have a look at Sasha, which is a functional language defined on top of Speagram. In fact, it is quite a demonstration of the power of Speagram's parser that it was possible to encode the syntax of a functional language on top of the usual natural-language syntax of Speagram. We show how this can be done and present an example function in Sasha that computes the conjunctive normal form of a logic formula. - Symbolic
Data Analysis in Speagram
The main use of Speagram is to provide you with a flexible and powerful parser and method to transform data given in different notations. Still, when the transformations get complex and the amount of data increases it is useful to have tools to analyse and order it. Speagram's well thought out internal representation allows you to apply transformations to symbolic data (i.e. apply them when some part of the data is unknown). Symbolic transformations allow Speagram to search for data satisfying given criteria more efficiently than just a brute-force method. This paves the way for using logic and formal analysis and reasoning methods in Speagram. You can see in this tutorial that Speagram can even generate quite an extensive class of functions automatically given only their definition.