Main ArticleExamples TOC

List of Takmela examples

The TakmelaDemo code comes with various examples with their traces, which you can find on this page.

The examples also show their output normally to stdout, so you don't need to follow the traces if you want to quickly check them out

Parser examples

Arithmetic expressions

A classic example for context-free grammars. Shows how Takmela deals with left-recursion.

1+2

A very basic and easy to follow example, as presented in the main article.

1+2+3

A slightly more complicated example showing how Takmela can resume the same continuation more than once.

1+2+3 (with ambuiguity)

A classic example showing ambiguity.

Arithmetic expressions (2)

Complicated expressions

A more fully fleshed-out grammar for arithmetic expressions, somewhat harder to trace though!

Complicated expressions with ambiguity

More complicated grammar example with deliberate ambiguity introduced

Nullable nonterminal example

An example of a known bug in the initial version of Earley's parsing algorithm (fixed in later iterations). How does Takmela deal with this special case?

Simplified version

Full version

More Left-recursion examples

Indirect left recursion

Here

Left recursion due to nullable nonterminals

Here

Datalog examples

Ancestors

The classic Datalog showcase example!

The length of a query's trace varies according to e.g the query's nature or the facts included.

Self Match

A small example to test Datalog programs where an atom contains the same variable more than once

Reverse same-generation

From the book "Foundations of Databases"

Full version found here

Shorter trace version found here

Siblings

Another classic example from Logic programming