Get the latest tech news

How Janet's PEG module works


An in depth explanation of pegs and how they work.

Although the code is written in Janet, It can be translated directly to most programming languages as we make no special use of any data structures besides arrays and hashtables. This grammar will match "apple pie", "banana split", and "coconut cluster", but not "orange soda", "watermelon taffy", or "lemon snap". Janet's peg implementation does something very similar to this, although the syntax tree is first compiled to a bytecode form and validate for better speed.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of PEG

PEG

Photo of PEG module

PEG module

Photo of Janet

Janet

Related news:

News photo

Runtime-Extensible SQL Parsers Using Peg

News photo

Use context-free grammars instead of parser combinators and PEG