<>

Parsers: a language for making languages

by Breck Yunits

September 10, 2017

I introduce the core idea of a new language for making languages.

*

Introduction

Creating a great programming language is a multi-step process. One step in that process is to decide on syntax and formally define a language in a parser notation such as BNF. Unfortunately, like the programming languages they describe, these parser notations are complex, brittle and error-prone.

Below I introduce the core idea of a much simpler parser notation for defining 2D Languages.

*

Parsers: A language for building languages

A microlang in Parsers consists of a set of Parser Definitions including a catchall Parser Definition.

A Parser Definition consists of a match rule and optionally another Parsers microlang.

Everything is encoded in the same sytnax (Particles), hence Parsers is written in Parsers.

Example

A Parsers file for an imagined microlang called Tally, with 2 Parsers {+, -} might look like this:

TallyParser catchAllParser errorParser parsers errorParser expressionParser extends TallyParser words int+ +Parser extends expressionParser -Parser extends expressionParser

A valid program in the Tally microlang defined by the file above:

+ 4 5 - 1 1
*

Conclusion and Future Work

The introduction above is minimal but shows the core idea: a new notation (Particles) can be used to define new languages in a language (Parsers) that itself is defined in Parsers on top of Particles.

We have developed and open-sourced Parsers a compiler-compiler implementing these ideas.

Future publications and/or open source releases will delve into the additional features found in the compiler-compiler.

โ‚

Related Posts




Built with Scroll v164.7.0