This project hasn't been updated in a long time, so it no longer appears on the homepage, categories, or search results — the data is preserved and this page still works normally.
RepositoryJavaUSUnited States
zhong-j-yu

zhong-j-yu/rekex

PEG parser generator for Java 17 - grammar as algebraic datatypes

69stars
8forks
2issues
0views

Rekex

PEG parser generator for Java 17

grammar as algebraic datatypes

A context-free grammar has the form of

A  = A1 | A2
A1 = B C
...

which looks exactly like definitions of algebraic datatypes. This is by no coincidence - both formalisms reflect an underlying model with which we build complex concepts from constituents.

Given this correspondence, we could express a context-free grammar entirely as datatypes in a programming language. For example, in Java 17,

sealed interface A permits A1, A2{}

record A1(B b, C c) implements A{}

Such datatypes can be transliterated into a grammar, which is fed to a particular parser generator to build a parser. During the parsing process, constructors of datatypes are invoked, eventually outputting a parse tree in the very same datatypes.

PegParser<A> parser = PegParser.of(A.class);

A a = parser.matchFull(input);

Rekex is a PEG parser generator that implements this novel idea for Java 17. It is the simplest, most intuitive way for writing parsers.

Read More:


Create by Zhong Yu

Similar Projects

Discover other similar projects and AI models.

RepositoryRust
kevinmehall/rust-peg

Parsing Expression Grammar (PEG) parser generator for Rust

1.6k
May 4, 2026
RepositoryJava
antlr/antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.

19.0k
Feb 16, 2026
RepositoryRust
rust-bakery/nom

Rust parser combinator framework

10.5k
Aug 26, 2025
RepositoryPython
lark-parser/lark

Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.

6.0k
Aug 27, 2026
RepositoryJavaScript
pegjs/pegjs

PEG.js: Parser generator for JavaScript

4.9k
Nov 8, 2021
RepositoryRust
zesterer/chumsky

[Chumsky has moved to Codeberg!] Write expressive, high-performance parsers with ease.

4.5k
Mar 27, 2026
RepositoryGo
alecthomas/participle

A parser library for Go

3.9k
Oct 23, 2026
RepositoryRust
lalrpop/lalrpop

LR(1) parser generator for Rust

3.5k
Oct 19, 2026
RepositoryC++
taocpp/PEGTL

Parsing Expression Grammar Template Library

2.2k
Oct 4, 2026