PeppaPEG
pl0c
Our great sponsors
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
PeppaPEG
- Show HN: Peppa PEG – Peg Parser in ANSI C (v1.15.0)
- Peppa PEG v1.10.0 released (Ultra-lightweight PEG Parser in ANSI C)
-
Peppa Peg – An Ultra Lightweight Peg Parser in ANSI C
- Having a PEG parser in ANSI C can benefit whoever is developing a parser, as adding C bindings for other programming languages are not too difficult.
And after SIX months' development, my project is now kinda feature complete. It's named Peppa PEG and you can find it here: .
I have learned quite a lot during the journey of creating it, such as gdb, valgrind, cmake, etc. And I wouldn't make it to the end without learning from some awesome projects, such as pest.rs, cJSON, etc.
To give you a glance how the library is used, here are some examples:
- Write an INI Parser using Peppa PEG: [ini.h](https://github.com/soasme/PeppaPEG/blob/main/examples/ini.h).
- Show HN: Peppa Peg – Ultra Lightweight Peg Parser in ANSI C
pl0c
-
The Super Tiny Compiler
> Some compilers tokenize while parsing, but for a different reason: it's faster and uses less memory to generate the AST
And some don't even generate an AST. :) Just read in and emit or interpret.
-
single pass compilers (basic questions)
Single-pass compiler tutorial
-
Compiler tutorials.
Let's Write a Compiler
-
Let's write a compiler, part 3: A parser
I don’t think there will be an AST. https://briancallahan.net/blog/20210814.html: “We will be writing a single-pass compiler for a simple language and immediately output our final output code as soon as our compiler has enough information to do so”
That “as soon as” implies code will be generated before the entire program has been parsed.
Also, for me single-pass implies “no AST”, as you would need at least one pass to construct one, and iterating over an AST counts as another pass for me.
What are some alternatives?
cmark - 💧 Elixir NIF for cmark (C), a parser library following the CommonMark spec, a compatible implementation of Markdown.
cproc - C11 compiler (mirror)
packcc - A parser generator for C
pegasus - A parser generator for C and Crystal.
honey-potion - Writing eBPF programs with Elixir!
Understanding-Unix-Linux-Programming - Source code of Understanding Unix/Linux Programming. The book provides example code in C, I would like to replicate it in Rust.
rawhide - find files using pretty C expressions
swifties - a custom language construction kit
mini-c - Dr Strangehack, or: how to write a self-hosting C compiler in 10 hours
FLOX - An adaptation of the interpreter from the book 'Crafting Interpreters' by Robert Nystrom written in F#
porth
ravi-compiler - Parser and compiler for Ravi and Lua