Poki Nanpa: A Toki Pona programming language

Development blog for Jack Mullin's graduation project.

ilo nimi pi toki nanpa; A parser for Toki Nanpa

| 0 comments

There is a standardised way to turn a specification of a language into a parser that can take program code and turn it into something that can be executed by a program. The two main steps are tokenisation into a list of tokens, followed by parsing into an “abstract syntax tree”; a data structure representing the shape of a program.

After beginning by trying to invent a parser that used string operations to try to build an abstract syntax tree from scratch, I instead switched to following a more standard method, outlined in this helpful guide. This involves a parser that “eats” tokens one by one according to what is expected based on what kind of language feature the parser thinks it is currently parsing. If it encounters an unexpected token, it throws a syntax error.

I am implementing this parser in JavaScript as part of the web interface I started working on, but the idea of a specification is that someone else would be able to come along and implement Toki Nanpa in any other environment.

Leave a Reply

Required fields are marked *.