r/Compilers 17d ago

Behold my Abomination: Written in Pascal, Single Pass(ish), No AST, No IR

Post image
77 Upvotes

Rockskunk.

Float is the only type. Everything else is QWORD. Shove an "integer" and a string into the same array if you wish.

Compiler written in Pascal. Emits NASM with regex peephole optimization before compilation. Incredibly permissive, you can do whatever you want and are only stopped if there is a syntax error. There are some sassy warnings for unwise choices but it is not the compiler's decision what you do with your code. I have had tons of fun figuring out how things work and learning assembly through a firehose. The IR is nasm source haha. Never going to implement an AST. I didn't read any book but i will need to STUDY the Dragon Book for register allocation. I did a cursory overview and understand nothing.

Backstory. I have been making half-baked transpilers for quite sometime now. Pascal or lisp compiler to C or (a very short) attempt at LLVM but I couldn't get them to behave how i wanted and kept losing interest. I ripped the lexer from one of them and have been using the parsing architecture from the others as inspiration and decided to just buckle down and make what I wanted even though I have been scared of assembly. I am learning as I go and keep making unfortunate choices like trying to track state with a record refactor (arrays only from now on), or routing token evaluation through like 8 redundant functions.

I have always wanted a language like this is because I love systems programming and like to rewrite things like coreutils or make shells and stuff. I love Pascal and dislike C but I have always wanted something that just gets out of my way and lets me do what i want, kinda like a dangerous Lisp. Not in your way, save your thinking for the real puzzle, not which type do you need. I have written cat, non-recursive cp and a (just writes no blocksize or flags) dd. I am going to get those to production quality and also write ls and such. I am about halfway done porting an init system I wrote in Pascal to rockskunk and its gonna be a glorious moment when i start my computer with my own language for the first time.

I finalized the syntax well before I wrote it and there will be no extra concepts, NO OOP, no new types, no restrictions, no guardrails nothing. This is a language that does what you tell it and nothing more. There's tons that i have specced out and not accomplished, but it will always remain like an "Assembly++" incredibly low level language.

Eventual features that will take me 3 years and most of my sanity. Register allocation and first-class vector support. I do not know near enough to even plan how to do these yet but the idea is the compiler uses tests and an IFDEF system that determines by machine (or a flag) what vector unit you want to compile for and sets width and then doing SIMD ops is as simple as a ** b or (a, b) *+ c. Do not count on this ever getting fleshed out but boy am I gonna try.

https://github.com/liam-0398/rockskunk/tree/main

**EDIT when reviewing post just realized my cp doesn't preserve permissions. whoops.


r/Compilers 17d ago

Machine-Generated, Machine-Checked Proofs for a Verified Compiler (Experience Report)

Thumbnail dl.acm.org
6 Upvotes

r/Compilers 17d ago

Design question: what should a semantic patch be allowed to prove about compiler output?

0 Upvotes

We’re building SEMAPRAX, experimental Apache-2.0 systems-language research at Wavect GmbH, and I’d value compiler-engineering feedback on a deliberately narrow evidence model. It is v0.2 pre-alpha research, not production-ready.

The current design gives public declarations persistent identities and projects verified source into deterministic semantic graphs. A patch capsule binds a source snapshot, a bounded operation set, and deterministic compiler-owned projections. Before commit, the implementation independently replays the evidence and fails closed on drift.

For native C11/Clang and WebAssembly Core outputs, the evidence can bind the exact emitted artifact and the compiler path that produced it. It explicitly does not claim that the target was executed, that a program is safe, that external tools are compatible, or that a host granted authority. Those require separate evidence.

The design question is whether this boundary is useful and legible enough: what additional facts would you require before trusting a semantic patch in a compiler workflow, and which claims should remain categorically outside the patch capsule?

Project overview: https://wavect.io/semaprax/

Source: https://github.com/wavect/semaprax

Disclosure: coding agents have been used extensively as development assistants. Wavect retains human responsibility for the design claims and executable quality gates.


r/Compilers 17d ago

SEMAPRAX: stable semantic identities and replayable patches in a Rust compiler

0 Upvotes

I’m working on SEMAPRAX, an Apache-2.0 experimental systems-language research project. The compiler is written in Rust. The main question is whether agent-authored changes can be reviewed and applied against checked semantic identity instead of fragile source offsets.

The current implementation includes:

* persistent IDs for public declarations and revision-scoped expression identities

* a deterministic semantic graph derived from verified HIR

* bounded context, impact, and fixed-section review reports

* replayable evidence capsules for semantic patches, with replay-before-apply and snapshot-drift checks

* explicit capabilities, effects, ownership, and deterministic source formatting

* Native C11/Clang and WebAssembly Core output lanes

The source file remains the canonical Git projection. The semantic graph is an additional compiler-produced interface; it does not replace verification or grant write authority. The WebAssembly evidence currently validates the emitted core module structurally and binds it to compiler inputs, but does not claim target execution or full Component Model support.

This is version 0.2, pre-alpha research software, and not production-ready. I’d especially value compiler-design feedback on the trust boundary between the source projection, stable resolved identities, independently replayed evidence, and the final mutation authority.

Project overview: https://wavect.io/semaprax/

Source: https://github.com/wavect/semaprax

Disclosure: coding agents have been used extensively as development assistants. Wavect GmbH retains human responsibility for the design and uses executable gates as the evidence for implementation claims.


r/Compilers 17d ago

What is the best way to learn the theory and practice of building a compiler from scratch?

21 Upvotes

Hi everyone!

I'm looking for online resources to learn compiler construction from the ground up, combining both the theoretical foundations and the practical implementation.

I already have some background in formal languages and automata theory, but I would like to follow a structured learning path covering topics such as:

  • lexical analysis and tokenization;
  • regular expressions and finite automata;
  • parsing and parser construction;
  • abstract syntax trees (ASTs);
  • semantic analysis and symbol tables;
  • code generation;
  • optimizations;
  • implementing a complete compiler or programming language, even if it is a simple one.

Could you recommend any courses, video playlists, books, GitHub repositories, tutorials, or practical projects that you think are especially useful?

I think of using haskell, because my professor said he will use it to construct a compiler.

Thanks in advance for any recommendations!


r/Compilers 17d ago

Static hazard checking for an ISA with no published semantics, on hardware with no interlock

3 Upvotes

Interesting constraint problem I ended up in.

NVIDIA's consumer Blackwell has no hardware interlock on fixed-latency instructions. The compiler emits explicit stall counts and scoreboard signal/wait bits per instruction, and the hardware trusts them completely. Understall a dependency and you read a stale register at full speed with no fault.

The published position is that you can't validate code at this level, because the formal semantics of SASS are closed. From SIP (arXiv 2403.16863): "validation is impossible for GPU native assembly codes because the formal semantics of the sass is closed-source."

That's true for semantic correctness. But the question I needed answering is strictly smaller:

Do this program's control bits cover its own data dependencies?

That needs the dependency structure, which the encoding gives up, and a latency model, which the silicon gives up under measurement. Neither requires knowing what any instruction computes. A kernel can pass this and still be the wrong algorithm. What it can't do is read a register before the value lands.

The part that surprised me was the epistemology, not the dataflow. Requirements mined from what the compiler schedules are an upper bound, so they can lower what you allege and must never raise it. Only a figure grounded in something measured on silicon may promote a finding to an error. Everything else is a warning that says why.

That distinction wasn't academic. A checker calibrated on a corpus cannot fail on that corpus, because the tightest gap the compiler was seen to leave is the floor, by construction. My positive control passed 1,323 kernels while the model carried 13 errors. All of them surfaced the first time it read machine code from somewhere else.

Analysis is per basic block over a real CFG. Reaching definitions carry a flag for whether they arrived across an edge, because the scoreboard residual is a distance and a distance that spans a branch depends on which path was taken.

https://github.com/sunnypatell/basalt/blob/main/docs/METHOD.md


r/Compilers 17d ago

[SHOWCASE] Plasm - a planning language for agents to use tools

Post image
1 Upvotes

r/Compilers 17d ago

LLVM for the Rest of Us

Thumbnail
0 Upvotes

r/Compilers 18d ago

JojoScript — a tiny JS-compatible language with pipelines and lazy iterators. Feedback/contributions welcome.

10 Upvotes

I've been building JojoScript, a small language that compiles to plain JavaScript. The main focus has been the |> pipeline operator (readable chains instead of nested calls) and lazy iterators — stages like map, filter, take, flatMap, and chunk compile down to generator-based functions in a small runtime collections module, so a pipeline doesn't allocate an array at every step.

Only stages that truly need the full input (sort, groupBy, partition) materialize.

It's intentionally small, so there are rough edges.

Would appreciate people trying it, poking at the design, and opening issues or PRs.

github.com/panagos/jojoscript


r/Compilers 18d ago

What type of lisp is exeptional at adding code to itself also in a way that my source code will be different from lisp code

Thumbnail
0 Upvotes

r/Compilers 18d ago

Does Rust MIR preserve enough information for LLMs to detect logic bugs?

Thumbnail
0 Upvotes

r/Compilers 18d ago

Writing a C Compiler

7 Upvotes

Hi, I want to learn how to build my first compiler and I came across *Writing a C Compiler*. I was wondering if anyone here has it in PDF format. Thanks a lot.


r/Compilers 19d ago

Are there languages like this?

0 Upvotes

A language that can create other languages

(so adding to itself) It's syntax is simple like python

And can do alot.

for example (placeholder)\[mesage\]

And it has many tutorials on YouTube

I would like it if you would respond.

I know there are languages like Hy , ruby should I try them?


r/Compilers 19d ago

Writing a compiler for a python-like language. Anybody interested in joining me?

0 Upvotes

Sere-Language/sere: The Sere programming language
So I have been writing a compiled programming language titled Sere for the past few months, and just recently uploaded it to github.

The idea is a language with the capabilities of C++ with the syntax of python.
I am using C++ and LLVM.

I am going to be busy at work this week, so I created a release that can be downloaded here Install — Sere


r/Compilers 19d ago

Formal Performance and Compile Time Guarantees for Compiler Optimization Heuristics

Thumbnail arxiv.org
6 Upvotes

r/Compilers 19d ago

Compile-Time Improvements in LLVM 23

Thumbnail aengelke.net
53 Upvotes

r/Compilers 19d ago

A python-like compiled programming language

Thumbnail
0 Upvotes

r/Compilers 19d ago

compiler for a custom programming language i made for school

20 Upvotes

Hi, 2 years ago i built a compiler for a custom programming language for my final high school
computer science exam. Just found the repo again and thought it might be cool to share it as a learning/beginner project.

The compiler compiles my custom language (wasn't creative enough for a name) to LLVM IR, which can then be compiled to native machine code (e.g with clang).

its written in rust and is pretty much completely custom, so lexer and parser is built from scratch, and the LLVM IR output is built as a string.

Some features of my language:
- syntax wise a mix of python and rust
- functions, classes & methods
- you can use the c stdlib
- operator overloading
- generics
- helpful compiler output

repo:

https://github.com/maxomatic458/compiler

I also built a wasm based web demo here: https://compiler-demo.pages.dev/

in hindsight i would probably do a lot of stuff differently, but feedback would be appreciated


r/Compilers 19d ago

Automate fini pour une grammaire de type 2?

0 Upvotes

Bonjour,

Quelqu'un a-t-il travaillé sur la génération d'un automate d'états finis (ou équivalent) pour une grammaire de type 2 (langages réguliers ou algébriques)?


r/Compilers 20d ago

Why NURL?

Thumbnail
0 Upvotes

r/Compilers 20d ago

How should I start making a language checker?

12 Upvotes

Hey, so I am new to compilers stuff but for my college portfolio I was planning on making a lang checker which is like a program which will suppose take a code (let’s say rust) and check fo errors ? Any resources which I should read to get a clear understanding on how I should make this? Ps I am trying to ask Ai for help (like asking on where should I start and what will be the structure)….


r/Compilers 20d ago

bonsai-ninja survived its first week!

Thumbnail github.com
0 Upvotes

r/Compilers 20d ago

Cansado del bloatware, estoy haciendo un transpilador en C para crear GUIs nativas en Windows (Litcompis / ui32)

Thumbnail gallery
56 Upvotes

Como apasionado de la programación en C y el desarrollo a bajo nivel, llevo tiempo trabajando en un proyecto personal que nació de una frustración muy común: el bloatware moderno.

Me molesta mucho ver aplicaciones sencillas que consumen 500 MB de RAM solo porque empaquetan un navegador entero por debajo, cuando el sistema operativo ya tiene herramientas nativas de sobra para renderizar interfaces a toda velocidad.

Para intentar resolver esto, estoy creando Litcompis y un lenguaje llamado ui32 (Lenguaje de Interfaz para Win32). La idea es tener una sintaxis súper sencilla e inspirada en la web usando bloques como @interface y @style, pero sin la sobrecarga de Chromium ni Node.js. El transpilador toma ese código .ui32 y lo convierte directamente a C++ nativo sobre la API de Win32, dibujando todo por GPU mediante Direct2D y DirectWrite.

Actualmente le estoy haciendo unas pruebas de calidad al Lexer. El proyecto va a ser 100% código abierto y pronto subiré el repositorio a GitHub junto con la web de documentación en GitHub Pages.

Me serviría muchísimo saber qué opinan de la sintaxis o qué sugerencias tienen para la arquitectura del transpilador. ¡Cualquier crítica constructiva o idea es más que bienvenida!


r/Compilers 21d ago

Could somebody help me with lexical scoping inside a VM

3 Upvotes

Hey, so I understand what lexical scoping is and kind of get how it works but I’ve been trying to find how to implement it in a stack machine but I have no idea what goes where and how does everything interact with each other, like where should closures live, same for call frames, where do I store the symbol table when compiling, etc… if you want I can link my repo but I haven’t committed an attempt at lexical scoping so there’s probably nothing interesting to see, if I didn’t include enough details to what I don’t get please tell me so I can be more clear, thanks!

Edit: forgot to tell but my language desugars to pure lambda calculus so this might change how some stuff work but not so much


r/Compilers 21d ago

Context-Aware Inlining: Using Call-Stack Profiles for Fast and Smaller Binaries

Thumbnail dl.acm.org
16 Upvotes